<?php /** * @version $Header$ * @package install * @subpackage functions */ /** * Global flag to indicate we are installing * @ignore */ define('BIT_INSTALL', 'TRUE'); global $failedcommands; // keep some crappy notices from spewing $_SERVER['HTTP_HOST'] = 'shell'; $_SERVER['SERVER_SOFTWARE'] = 'command_line'; /** * required setup */ require_once 'install_lib.php'; include "../kernel/setup_inc.php"; if (count($argv) < 2) { print "Please enter name of SQL file in db/ directory to process\n"; } else { // avoid errors in ADONewConnection() (wrong darabase driver etc...) $gBitDb =& ADONewConnection($gBitDbType); if ($gBitDb->Connect($gBitDbHost, $gBitDbUser, $gBitDbPassword, $gBitDbName)) { process_sql_file($argv[1], $gBitDbType, BIT_DB_PREFIX); } }
// If no admin account then we are logged if ($admin_acc == 'n') { $_SESSION["install-logged-{$multi}"] = 'y'; } $smarty->assign('dbdone', 'n'); $smarty->assign('logged', $logged); if (isset($_SESSION["install-logged-{$multi}"]) && $_SESSION["install-logged-{$multi}"] == 'y') { $smarty->assign('logged', 'y'); if (isset($_REQUEST['scratch'])) { process_sql_file('tiki-' . $dbversion_tiki . "-" . $db_tiki . '.sql', $db_tiki); $smarty->assign('dbdone', 'y'); if (isset($_REQUEST['profile'])) { process_sql_file('profiles/' . $_REQUEST['profile'], $db_tiki); //$profile = $_REQUEST['profile']; //print "Profile: $profile"; } } if (isset($_REQUEST['update'])) { process_sql_file($_REQUEST['file'], $db_tiki); $smarty->assign('dbdone', 'y'); } } $smarty->assign_by_ref('tikifeedback', $tikifeedback); // getting memory_limit from PHP $php_memory_limit = ini_get('memory_limit'); $smarty->assign('php_memory_limit', $php_memory_limit); // disallow robots to index page: $smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW'); $smarty->display("tiki.tpl"); //print "<hr>"; //setup_help();
} echo "Installing cal_access.sql... \n"; # Create empty cal_access tables (used to store data scraped) process_sql_file("install_cal_access.sql"); echo "Installing ftp_tables.sql... \n"; # Create empty ftp tables (used to store the data from ftp) process_sql_file("install_ftp_tables.sql"); echo "Installing processing_tables.sql... \n"; # Create tables used to process the data process_sql_file("install_processing_tables.sql"); echo "Installing smry_tables.sql... \n"; # Create tables used for fast web searches process_sql_file("install_smry_tables.sql"); echo "Installing populated.sql... \n"; # Create populated tables (name parse tables and state name table) process_sql_file("install_populated.sql"); echo "Populating all cal_access sessions from http://www.sos.ca.gov/elections/elections_cand.htm \n"; # Populate all cal_access sessions get_elections_list(); echo "Scraping the cal-access data for all sessions (this process can take up to 8 - 10 hours) \n"; $result = $script_db->prepare("SELECT session FROM cal_access_sessions ORDER BY session DESC"); $result->execute(); while ($row = $result->fetch(PDO::FETCH_ASSOC)) { echo "Retrieving data for session " . $row["session"] . "\n"; get_propositions($row["session"], 1); get_propositions_committees($row["session"], 1); get_candidate_names($row["session"], 1); get_candidate_data($row["session"], 1); $result2 = $script_db->prepare("UPDATE cal_access_sessions SET last_ran = NOW() WHERE session = ?"); $result2->execute(array($row["session"])); }
# link in the needed libraries for scraping and connecting to the database require "cal_access_scraper.inc"; echo "Starting update... \n"; echo "Update the most recent cal_access session \n"; system("php cal_access_data_scraper.php"); echo "Get the ftp data \n"; system("php get_ftp_data.php"); echo "Reopen database connection \n"; $script_db = new PDO("mysql:host={$hostname};dbname=ca_process;charset=utf8", $script_login, $script_pwd); $script_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $script_db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); echo "Database connection reopened \n"; echo "Process data for contributions table - stage 1 \n"; process_sql_file("process_stage_1.sql"); echo "Clean up names \n"; clean_candidate_names(); echo "Process data for contributions table - stage 2 \n"; process_sql_file("process_stage_2.sql"); echo "Process data for contributions table - stage 3 \n"; process_sql_file("process_stage_3.sql"); echo "generate search words \n"; generate_search_words(); echo "Reset last update file \n"; $script_db->query("TRUNCATE ca_search.smry_last_update"); $script_db->query("INSERT INTO ca_search.smry_last_update SELECT FiledDate FROM contributions_full WHERE FiledDate <= NOW() ORDER BY FiledDate DESC LIMIT 1"); echo "Process data for contributions table - stage 4 \n"; process_sql_file("process_stage_4.sql"); echo "Update done... \n"; # release the lock file ftruncate($lockFile, 0); flock($lockFile, LOCK_UN);