Miscellaneous Code
  Home arrow Miscellaneous Code arrow classKurs
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MISCELLANEOUS CODE

classKurs
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2002-11-11

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    classKurs is a PHP class that lets you grab Bank Indonesia's content of kurs, then put the content on a single file. The grabber can be set as cron job. There is also the function to show the grabbed file in formated html tags, ready to go.

    By : hermawan

    <?php
    /***********************************************
    * Class Name : classKurs *
    * Scripted By : Hermawan Haryanto *
    * Website : http://hermawan.com *
    * Email : hermawan@codewalkers.com *
    * License : GPL (General Public License) *
    * Created Date : 09/08/2001 *
    * Last Update : 11/11/2002 *
    * Instruction : Read INSTALL *
    ***********************************************/

    class kurs {
    var $admin;
    var $file;
    var $graburl;
    var $chop;
    var $choptitle;
    var $jual = Array ();
    var $beli = Array ();
    var $titles = Array ();
    var $temp;
    function kurs() {
    global $conf;
    $this->admin = $conf["admin"];
    $this->file = $conf["file"];
    $this->graburl = $conf["graburl"];
    $this->chop = $conf["chop"];
    $this->choptitle = $conf["choptitle"];
    $this->textTitle = $conf["textTitle"];
    $this->textKurs = $conf["textKurs"];
    $this->textBuy = $conf["textBuy"];
    $this->textSell = $conf["textSell"];
    }
    function writeToFile() {
    $fp = fopen($this->file,"w+");
    @fwrite($fp,$this->temp);
    @fclose($fp);
    }
    function grab() {
    $fp = fopen ($this->graburl,"r");
    $fp2 = fopen ($this->graburl,"r");
    if (!$fp) {
    $this->sendAdminError();
    exit();
    }
    $this->getKurs ($fp);
    $this->getTitles ($fp2);
    $this->formatText();
    $this->writeToFile();
    }
    function formatText() {
    for ($i=0;$i<count($this->titles);$i++) {
    $this->temp .= $this->titles[$i]."|".$this->jual[$i]."|".$this->beli[$i]."|".time()."\n";
    }
    }
    function getTitles ($fp) {
    while(!feof($fp)){
    $data = fgets($fp, 4096);
    if(ereg($this->choptitle,$data,$arr)) $this->titles[] = trim($arr[1]);
    }
    }
    function getKurs($fp) {
    while(!feof($fp)){
    $data = fgets($fp, 4096);
    if(ereg($this->chop,$data,$arr)){
    if ($i%2==0) $this->jual[] = str_replace(",","",trim($arr[1]));
    else $this->beli[] = str_replace(",","",trim($arr[1]));
    $i++;
    }
    }
    }
    function sendAdminError() {
    $to = $this->admin;
    $subject = "Kurs::Error";
    $message = "Your Homepage\n";
    $message.= "Kurs Module (".$_SERVER["SERVER_NAME"].")is generating this Error.\n";
    $message.= "Please check!.\n\n";
    $message.= "[MalFunction]";
    $headers.= "From: Hermawan Haryanto <hermawan@dmonster.com>\r\n";
    $headers.= "Reply-To: Hermawan Haryanto <hermawan@haryan.to>\r\n";
    $headers.= "X-Mailer: Hermawan Haryanto";
    @mail($to,$subject,$message,$headers);
    }
    function show() {
    $fp = @file($this->file);
    $rtn .= "<table width=100% border=0 cellpadding=0 cellspacing=0><tr><td><table width=100% border=0 cellpadding=2 cellspacing=1 bgcolor=#EEEEEE><tr class=header><td align=center valign=middle>$this->textTitle</td></tr><tr><td align=center valign=middle bgcolor=#FFFFFF><table width=100% border=0 cellspacing=1 cellpadding=2><tr align=center valign=top bgcolor=#CCCCCC class=subtitle><td>$this->textKurs</td><td width=100>$this->textSell</td><td width=100>$this->textBuy</td></tr>";
    for ($i=0;$i<count($fp);$i++) {
    list ($mtu, $jual, $beli, $lastupdate) = explode("|", $fp[$i]);
    $rtn .= "<tr align=left valign=top class=body><td>$mtu</td><td>Rp.".number_format($jual,2,",",".")."</td><td>Rp.".number_format($beli,2,",",".")."</td></tr>";
    }
    $rtn .= "</table></td></tr><tr><td align=center valign=middle class=body>Update : ".date("j/n/Y H:i:s",$lastupdate)."</td></tr></table>";
    $rtn .= "</td></tr><tr><td align=center>";
    $rtn .= "<a href=\"http://www.bi.go.id/bank_indonesia2/moneter/kurs_valuta/default.asp\">Bank Indonesia</a>";
    $rtn .= "</td></tr></table>";
    return $rtn;
    }
    };
    $fixpath = dirname(__FILE__);
    require_once ($fixpath."/ckConfig.php");
    $kurs = new kurs($conf);
    ?>

    Click to Download File



    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More Miscellaneous Code Articles
    More By Codewalkers

     

    IBM® developerWorks developerWorks - FREE Tools!


    NEW! Cook up Web sites fast with CakePHP, Part 4: Use CakePHP&apos;s Session and Request Handler components

    CakePHP is a stable production-ready, rapid-development aid for building Web sites in PHP. This "Cook up Web sites fast with CakePHP" series shows you how to build an online product catalog using CakePHP.
    FREE! Go There Now!


    NEW! Did you say mainframe? e-kit

    Learn how you can extend modern application lifecycle management to IBM System z through the IBM Rational Software Delivery Platform (SDP). The Did you say mainframe? e-kit includes podcasts, webcasts, tutorials, white and red papers, demos, and articles designed to help ease the challenges of modernizing your enterprise. This complimentary kit for mainframe developers is a practical, how-to guide for making the most of an existing development environment, including the skills and infrastructure already in place at an established enterprise.
    FREE! Go There Now!


    NEW! Evaluate WebSphere Extended Deployment Compute Grid V6.1

    Visit IBM developerWorks to download a free trial version of WebSphere Extended Deployment Compute Grid, which lets you schedule, execute, and monitor batch jobs. Because online transaction processing and batch jobs execute simultaneously on the same server resources, you can avoid costly duplication of resources. Compute Grid supports job types of Java transactional batch, compute-intensive and a new type called "native execution", which enables non-Java workloads to run on distributed end points.
    FREE! Go There Now!


    NEW! Hello World: WebSphere Service Registry and Repository

    Manage, govern, and share services across your organization by using WebSphere Service Registry and Repository. Follow the hands-on exercises to learn how to navigate the Web interface to publish, find, reuse, and update services.
    FREE! Go There Now!


    NEW! Rational Testing eKits

    Discover how Rational tools and best practices for testing can make your job easier. The new Rational Testing eKits provide you with valuable resources – including demos, webcasts, tutorials, and articles – that help you address your specific testing needs across the software lifecycle. Five new eKits are available covering the topics of Requirements and Test Management, Functional Testing, Performance Testing, Code Quality and Embedded Systems, and SOA and Web Services Testing.
    FREE! Go There Now!


    NEW! Test terminal-based applications with Rational Functional Tester

    Regression testing -- in which code is thoroughly tested to ensure that changes have not produced unexpected results -- is an important part of any development process. But many testing environments neglect the terminal-based applications that still form the backbone of many industries. In this tutorial, you'll learn how the Rational Functional Tester Extension for Terminal-Based Applications works with other Rational Functional Tester to help test terminal-based applications quickly and easily.
    FREE! Go There Now!


    NEW! Trial download: IBM Rational Performance Tester V7.0.1

    Get a free trial download of the latest version of IBM Rational Performance Tester V7.0.1, a load and performance testing solution for teams concerned about the scalability of their Web-based applications. Combining multiple ease-of-use features with granular detail, Rational Performance Tester simplifies the test-creation, load-generation and data-collection processes that help teams ensure the ability of their applications to accommodate required user loads.
    FREE! Go There Now!


    NEW! Using IBM Rational Developer for System z and IBM Rational ClearCase together to manage application development

    Whether you are creating new applications or modifying existing ones, managing integration of new components with traditional z/OS elements is a critical part of building and deploying modern applications. Listen to this webcast to see how IBM can help you optimize your development process using an IDE like Rational Developer for System z that integrates with management tools, such as ClearCase to manage your application development on mainframes.
    FREE! Go There Now!


    NEW! Webcast: Application security testing and Web compliance

    Join the IBM Watchfire team for an informative discussion on techniques and best practices to proactively manage Web application security and how to effectively build application security testing into the software development lifecycle (SDLC). In this Software Delivery Platform webcast you will learn: How to better understand potential web application security vulnerabilities, best practices and how to effectively integrate application security testing into the software development lifecycle, the importance of detecting and removing software vulnerabilities during application development.
    FREE! Go There Now!


    NEW! Webcast: Eclipse: Empowering the universal platform

    The Eclipse community is constantly working to extend Eclipse's functionality. In this webcast, learn about some of the most important and feature-rich projects under development. From multi-language support to plug-in development, tune in to see what Eclipse is capable of now.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    MISCELLANEOUS CODE ARTICLES

    - A Web App Based on a Model for the CodeIgnit...
    - Completing a Model for the CodeIgniter PHP F...
    - Validating Input Data with the CodeIgniter P...
    - Deleting Database Records with the CodeIgnit...
    - Inserting Database Records with a CodeIgnite...
    - Fetching Database Rows with a Model for the ...
    - Model Data and Validation Rules for a Generi...
    - Building a Generic Model for the CodeIgniter...
    - upload image to database sql
    - Random Password Generator
    - BCroot, get the root of a number with BC fun...
    - Find pi in a high precision
    - [PHP5] FORMCHECKER : data validation
    - SPL and ITERATOR : examples
    - Xml with Rss Feeds





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek