コード例 #1
0
/****** create_tables.php/Include_stuff
 * FUNCTION
 *		Include classes and the config file.
 ****/
include 'config.php';
require 'class_command.php';
Database::connect();
//Connect to the database
/****** create_tables.php/Create_tables_in_db
 * FUNCTION
 *		Creates the tables in our database.
 ****/
//Create content_description table
$query = "CREATE TABLE content_description (\n  externalpage text NOT NULL,\n  title text NOT NULL,\n  description text NOT NULL,\n  ages varchar(100) NOT NULL default '',\n  mediadate date NOT NULL default '0000-00-00',\n  priority tinyint(2) NOT NULL default 0\n);\n";
Database::sqlWithoutAnswer($query);
//Create :)
//Create content_links table
$query = "CREATE TABLE content_links (\n  catid bigint(8) NOT NULL default '0',\n  topic text NOT NULL,\n  type varchar(20) NOT NULL default '',\n  resource text NOT NULL,\n  KEY catid (catid)\n);\n";
Database::sqlWithoutAnswer($query);
//Create :)
//Create structure table
$query = "CREATE TABLE structure (\n  catid bigint(8) NOT NULL default '0',\n  name text NOT NULL,\n  title varchar(255) NOT NULL default '',\n  description text NOT NULL default '',\n  lastupdate datetime NOT NULL default '0000-00-00 00:00:00',\n  KEY catid (catid)\n);\n";
Database::sqlWithoutAnswer($query);
//Create :)
//Create datatypes table
$query = "CREATE TABLE datatypes (\n  catid bigint(8) NOT NULL default '0',\n  type varchar(20) NOT NULL default '',\n  resource text NOT NULL,\n  KEY catid (catid)\n);\n";
Database::sqlWithoutAnswer($query);
//Create :)
Basic::printToConsole("\nTables in the database (" . DB_DATABASE . ") are successfully created!\n");
Database::close();
//Close connection
コード例 #2
0
ファイル: start_script.php プロジェクト: floge/dmoz2mysql
    $file->setPath('http://rdf.dmoz.org/rdf/content.rdf.u8.gz');
    //Set path of what file it is downloading.
    $file->download();
    //Start the download
    $file->extract();
    //Extract the file
}
/****** Content_file/Clean_xml
 * FUNCTION
 *         Clean the content file! (dirty xml - we don't like it :D)
 ****/
if (CONTENT_CLEAN) {
    $clean_xml->cleanFile(FILE_RDF_CONTENT);
}
/****** Content_file/Parse_and_insert
 * FUNCTION
 *         Parse and insert the content RDF file into a database
 ****/
if (CONTENT_PARSE_N_INSERT) {
    $parse_content->setStartTime();
    //Start time
    $parse_content->setXMLFile(FILE_RDF_CONTENT);
    //Set what XML file to parse
    $parse_content->startParse();
    //Start parsing the document
}
//Write to a lastupdate.data file
$filecheck->writeLastUpdate();
Basic::printToConsole('FINISHED - Farewell and thanks for the fish! :)');
Database::close();
//Close connection
コード例 #3
0
ファイル: class_clean.php プロジェクト: benbucksch/dmoz2mysql
 function cleanFile($__filename)
 {
     Basic::printToConsole("Cleaning {$__filename}\nThis could take some time!");
     Basic::printToConsole("\nStatus: ");
     //Create a dot object - used to print the dot
     $this->count = 0;
     $this->frequency = 15000;
     //Set the frequency
     //Open 2 file pointers - one for read and one for write
     $__fp = fopen($__filename, 'r');
     $this->_write_fp = fopen('clean_' . $__filename, 'w');
     //Continue until you have reached end of file
     while (!feof($__fp)) {
         $this->_dirty_data = fgets($__fp, 8192);
         //Get some dirty data
         $this->_correction();
         //Clean the dirty data
         $this->_dirty_data = '';
         //Reset dirty data
     }
     fclose($__fp);
     //Close the pointer
     fclose($this->_write_fp);
     //Close the pointer
     unlink($__filename);
     //Delete the old file
     //Rename the clean file to the old file
     rename('clean_' . $__filename, $__filename);
     Basic::printToConsole("\nFinished!\n");
 }
コード例 #4
0
ファイル: class_parse.php プロジェクト: benbucksch/dmoz2mysql
 function startParse()
 {
     //Starts with clean properties
     //(content_links)
     $this->topic = '';
     $this->type = '';
     $this->resource = '';
     //(content_description)
     $this->external_page = '';
     $this->title = '';
     $this->description = '';
     $this->ages = '';
     $this->mediadate = '';
     $this->priority = '';
     $this->current_tag = '';
     //
     //Here we specify what tags are legal
     //
     $this->permitted_tags = array('link', 'link1');
     $this->_startToParse();
     //Start to parse function [located in XMLGlobal]
     //Print out that it is finished!
     Basic::printToConsole("Finished processing content RDF file!\nIt took " . $this->h . ' hours, ' . $this->m . ' minutes and ' . $this->s . " seconds\nInserted rows into the database: " . $this->count_rows . "\n");
 }
コード例 #5
0
ファイル: class_download.php プロジェクト: floge/dmoz2mysql
 function extract()
 {
     Basic::printToConsole("\n\nExtracting the gunzipped file...", false);
     //Open the downloaded gunzip file
     if (!($file = gzopen($this->filename . ".u8.gz", "r"))) {
         basic::error('Fatal error', 'I/O error! Could not open the downloaded file!');
     }
     //Open the file we write to
     if (!($openfile = fopen($this->filename, 'a'))) {
         basic::error('Fatal error', 'Cannot open the file (' . $this->filename . ')');
     }
     //Write the data
     while (!gzeof($file)) {
         $buff = gzgets($file, 4096);
         fputs($openfile, $buff);
     }
     fclose($openfile);
     gzclose($file);
     Basic::printToConsole("\n\n " . strtoupper($this->filename) . ".U8.GZ WAS SUCCESSFUL EXTRACTED! \n Filename: " . $this->filename . "\n");
 }
コード例 #6
0
 function printDot()
 {
     //Don't write the dot every time
     $this->count++;
     //Used to check out if we just started, and to check if we have reached our frequency.
     //If it's reached, then the count will be set to 0.
     switch ($this->count) {
         case 1:
             Basic::printToConsole('.', false);
             break;
         case $this->frequency:
             $this->count = 0;
             break;
         default:
     }
 }