//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...'); $filecheck->downloadHeaders('http://rdf.dmoz.org/rdf/structure.rdf.u8.gz'); //Download headers from a URL $filecheck->lastModified(); //Run the function that finds when the URL(document) was last modified. $filecheck->lastModifiedCompare(); //Compare the DMOZ file, with your last updated Basic::printToConsole("OK. Ready for an update!\n"); } /****** start_script.php/Structure_file * SECTION * Calls that handle the DMOZ structure file ****/ /****** Structure_file/Download * FUNCTION * Download the structure file ****/
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"); }