コード例 #1
0
ファイル: start_script.php プロジェクト: floge/dmoz2mysql
require 'class_clean.php';
require 'class_parse.php';
require 'class_download.php';
/****** start_script.php/Common_calls
 * FUNCTION
 *        Common calls: connect to the database
 *        Create the objects:
 *            check_url (checks a specific URL)
 *            downloadfile (downloads files)
 *            clean_xml (cleans the XML files)
 *            parse_xml_structure
 *            parse_xml_content
 ****/
Database::connect();
//Connect to the database
$filecheck = new CheckURL();
//Create a object that can check a specific URL
$file = new DownloadExtractFile();
//Create a new object
$clean_xml = new CleanXML();
$parse_structure = new ParseXMLStructure();
//Create a new object
$parse_content = new ParseXMLContent();
/****** start_script.php/Check_for_updates
 * FUNCTION
 *        This section download the headers for the structure file.
 *        Then it checks when the file was last modified.
 *        at last it compares it with the users last update.
 ****/
if (CHECK_FOR_UPDATES) {
    Basic::printToConsole('CHECKING FOR UPDATES...');
コード例 #2
0
ファイル: class_download.php プロジェクト: floge/dmoz2mysql
 function download()
 {
     $this->count = 0;
     //
     //Download file information
     //
     Basic::printToConsole('Downloading file information:  ', false);
     $filecheck = new CheckURL();
     //Create a new object
     $filecheck->downloadHeaders($this->path);
     //Download headers from a URL
     $filecheck->lastModified();
     //Run the function that finds when the URL(document) was last modified.
     $filecheck->contentLenght();
     //Run the function that finds content lenght
     $filesize = round($filecheck->content_lenght / 1024);
     //Create a variable filesize
     Basic::printToConsole('DOWNLOADED', false);
     $this->frequency = 100;
     //Set the frequency
     Basic::printToConsole("\nThe script is downloading " . $this->path . "\nThe file is downloaded with " . $this->downloadSpeed . " KB/s\nSize of the file is: {$filesize} KB\nThe DMOZ data dumps were last updated: " . $filecheck->last_modified . "\n\nDownloading please wait");
     //Open the url of the structure rdf file
     if (!($file = fopen($this->path, "r"))) {
         basic::error('Fatal error', 'I/O error! Could not download the file');
     }
     //Open the file we write to
     if (!($openfile = fopen($this->filename . ".u8.gz", 'w'))) {
         basic::error('Fatal error', 'Cannot open the file (' . $this->filename . '.u8.gz)');
     }
     //Write the data
     while ($data = fread($file, round(DOWNLOAD_SPEED * 1024))) {
         if (!fwrite($openfile, $data)) {
             basic::error('Fatal error', 'Cannot write to file ' . $this->filename . '');
         }
         //Don't write the dot every time
         $this->PrintDot();
     }
     fclose($file);
     fclose($openfile);
     Basic::printToConsole("\n\n " . strtoupper($this->filename) . ".U8.GZ WAS SUCCESSFUL DOWNLOADED \n Download URL: " . $this->path . "\n");
 }