"; $end="Last Revised"; //MySQL Connection Definitions: //change these to your connection details $DB_Server = "localhost"; //mysql database host $DB_Username = "grabber"; //mysql username $DB_Password = "gci85960759"; //mysql password $DB_DBName = "grabber"; //mysql database name $DB_TBLName = "content1"; //mysql table name /* End of Configuration Variables */ //create a unix time stamp for today's date //uses mktime() function: //mktime ( int hour, int minute, int second, int month, int day, int year ); if($hourly == 1){ //checks for new content every hour //this will ignore minutes & seconds $todaydate = mktime (date("H"),0,0,date("m"),date("d"),date("Y")); } else{ //checks for new content once a day //this will ignore hours, minutes & seconds $todaydate = mktime (0,0,0,date("m"),date("d"),date("Y")); } /* Start - MySQL Connection Defs */ Function MySQLConnect() { $connection=@mysql_connect($DB_Server, $DB_Username, $DB_Password) or die(mysql_error()); } Function MySQLQuery($DB_DBName,$query) { $success=@mysql_db_query($DB_DBName, $query) or die(mysql_error()); } //alternative connection settings for selecting //mysql_fetch_array($result) $ALT_Connect = @mysql_connect($DB_Server, $DB_Username, $DB_Password) or die(mysql_error()); $ALT_Db = @mysql_select_db($DB_DBName, $ALT_Connect) or die(mysql_error()); /* End - MySQL Connection Defs */ //go to database and get item for today's date if it exists $dep_list = "SELECT * FROM $DB_TBLName WHERE date_grabbed = 0"; // $todaydate"; $result1 = @mysql_query($dep_list, $ALT_Connect) or die("Couldn't execute query #1"); //loop through departments table to populate select menu //set var to 'none' so we can check it later //we'll check if no content for today's date is found in the database $date_grabbed = "none"; //start of db loop while ($row = mysql_fetch_array($result1)) { $date_grabbed = $row['$date_grabbed']; $grabbedContent = $row['content']; //strip slashes from content //this is important because addslashes() is used before //saving the content in the database $grabbedContent = stripslashes($grabbedContent); } //end of db loop //if there's no content for this date/time saved in the database, leech it, //then display it and save it in MySQL If($date_grabbed=="none"){ /* Start of Grabber */ // PHP Headlines Grabber // Grab source code from a file or web site if(!($myFile=@fopen($url_to_grab,"r"))) { echo "The news interface is down for maintenance."; exit; } while(!feof($myFile)) { // Read each line and add to $myLine $myLine.=fgets($myFile,255); } fclose($myFile); $start_position=strpos($myLine, $start); $end_position=strpos($myLine, $end)+strlen($end); $length=$end_position-$start_position; $myLine=substr($myLine, $start_position, $length); //clean up some of the content: this will vary depending on the content //and what you need for your web page $myLine=ereg_replace("Last Revised", "", $myLine); $myLine=ereg_replace("
  • ", "
    ", $myLine); $myLine=ereg_replace("", "", $myLine); $myLine=ereg_replace("href=\"", "target=\"_blank\" href=\"http://newsroom.cisco.com/dlls/", $myLine); $myLine=ereg_replace("img src=\"http://yachtworld.com/graphics/button_email.gif\" ", "", $myLine); $myLine=ereg_replace("img src=", "img border=\"0\" src=", $myLine); $myLine=eregi_replace(" bgColor=\"#ffffff\"", "", $myLine); $myLine=eregi_replace(" bgColor=\"#336666\"", "", $myLine); $myLine=ereg_replace("img border=\"0\" src=\'http://yachtworld.com/graphics/button_finance.gif\' ", "", $myLine); $myLine=ereg_replace("img border=\"0\" src=\'http://yachtworld.com/graphics/button_insure.gif\' ", "", $myLine); $myLine=ereg_replace("img border=\"0\" src=\'/graphics/button_finance.gif\' ", "", $myLine); $myLine=ereg_replace("img border=\"0\" src=\'/graphics/button_insure.gif\' ", "", $myLine); $myLine=ereg_replace("\"Photo", "", $myLine); $myLine=ereg_replace("\"Photo", "", $myLine); $myLine=ereg_replace("center", "", $myLine); $myLine=ereg_replace("h2", "strong", $myLine); $myLine=ereg_replace("/h2>", "/strong>

    ", $myLine); $myLine=ereg_replace("<>", "", $myLine); $myLine=ereg_replace("< border","","", $myLine); $myLine=ereg_replace("\"Foreign","", $myLine); // Display HTML echo "

    .

    .

    .

    .

    .

    "; echo $myLine; /* End of Grabber */ //add slashes to prevent problems with MySQL queries //don't forget to stripslashes() before displaying it! $myLine = addslashes($myLine); //insert the grabbed content into the database //MySQLQuery($DB_DBName,"INSERT INTO $DB_TBLName (date_grabbed, content) VALUES ('$todaydate', '$myLine')"); //MySQLQuery($DB_DBName,"INSERT INTO $DB_TBLName (date_grabbed, content) VALUES ('$todaydate', '$myLine')"); //if option is enabled to delete old content, go ahead and delete it from db if( $delete_old_content == 1 ){ // MySQLQuery($DB_DBName,"DELETE FROM $DB_TBLName WHERE date_grabbed < $todaydate"); MySQLQuery($DB_DBName,"DELETE FROM $DB_TBLName WHERE date_grabbed < $todaydate"); } } else //this is for when there IS content for this date/time saved in the database //==> then simply display it { // Just Display HTML echo $grabbedContent; } ?>