Ejemplo n.º 1
0
function prep_DB_content()
{
    global $databaseConnection;
    $admin_role_id = 1;
    create_tables($databaseConnection);
    create_roles($databaseConnection, $admin_role_id);
    create_admin($databaseConnection, $admin_role_id);
}
 /** Installs the forum.
  *
  * @Given /^the forum is installed$/
  */
 public function installBoard()
 {
     require_once __DIR__ . '/../../admin/install_common.inc.php';
     create_tables($this->pdo, true);
     $fp = @fopen(__DIR__ . '/../../inc/config.inc.php', 'w');
     p_configuration($fp, ['database-hostname' => $this->database_hostname, 'database-username' => $this->database_username, 'database-password' => $this->database_password, 'database-name' => $this->database_name, 'table-prefix' => $this->table_prefix]);
     fclose($fp);
 }
function prep_DB_content()
{
    global $db;
    $admin_role_id = 1;
    create_tables($db);
    create_roles($db, $admin_role_id);
    create_admin($db, $admin_role_id);
}
Ejemplo n.º 4
0
function prep_DB_content()
{
    global $conn;
    create_tables($conn);
    create_user($conn);
    create_user_devices($conn);
    create_env($conn);
    create_env_devices($conn);
}
Ejemplo n.º 5
0
function setup_db()
{
    global $install;
    $install->title("Website Installation - Setup Database");
    echo '<div class="row">';
    echo '<div class="col-sm-12">';
    create_tables();
    create_roles();
    create_admin();
    install_finalise();
    echo '</div>';
    echo '</div>';
}
Ejemplo n.º 6
0
/**
Install the Plugin
*/
function rpgsuite_install()
{
    global $db;
    // Create Settings
    $settinggroup = array('gid' => 'NULL', 'name' => 'rpgsuite', 'title' => 'RPG Suite', 'description' => 'Settings For RPG Suite', 'disporder' => "1", 'isdefault' => "0");
    $db->insert_query('settinggroups', $settinggroup);
    $gid = $db->insert_id();
    $settings = build_settings($gid);
    foreach ($settings as $setting) {
        $db->insert_query('settings', $setting);
    }
    rebuild_settings();
    // Create the custom tables (but first ensure they aren't there already)
    destroy_tables();
    create_tables();
    // We are going to have multiple groups, so we will split this off into another file
    create_templates();
}
Ejemplo n.º 7
0
     echo $lang->sprintf($lang->mybb_already_installed, $mybb->version);
     $output->print_footer();
 } else {
     $output->steps = array('intro' => $lang->welcome, 'license' => $lang->license_agreement, 'requirements_check' => $lang->req_check, 'database_info' => $lang->db_config, 'create_tables' => $lang->table_creation, 'populate_tables' => $lang->data_insertion, 'templates' => $lang->theme_install, 'configuration' => $lang->board_config, 'adminuser' => $lang->admin_user, 'final' => $lang->finish_setup);
     switch ($mybb->get_input('action')) {
         case 'license':
             license_agreement();
             break;
         case 'requirements_check':
             requirements_check();
             break;
         case 'database_info':
             database_info();
             break;
         case 'create_tables':
             create_tables();
             break;
         case 'populate_tables':
             populate_tables();
             break;
         case 'templates':
             insert_templates();
             break;
         case 'configuration':
             configure();
             break;
         case 'adminuser':
             create_admin_user();
             break;
         case 'final':
             install_done();
Ejemplo n.º 8
0
function open_base()
{
    $handle = create_tables();
    $handle->setAttribute(PDO::ATTR_EMULATE_PREPARES, FALSE);
    return $handle;
}
Ejemplo n.º 9
0
function dota2_install()
{
    include_once 'build_database.php';
    create_tables();
}
Ejemplo n.º 10
0
function compressToMonth()
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/SquidStatsMonthQueue.pid";
    $pidTime = "/etc/artica-postfix/pids/SquidStatsMonthQueue.time";
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        die("Already executed");
    }
    @file_put_contents($pidfile, getmypid());
    $timeExec = $unix->file_time_min($pidTime);
    if ($timeExec < 15) {
        die("Only Each 15mn");
    }
    @unlink($pidfile);
    @file_put_contents($pidfile, time());
    $q = new postgres_sql();
    if ($q->isRemote) {
        return;
    }
    @file_put_contents("/etc/artica-postfix/settings/Daemons/SquidStatsMonthQueue", 0);
    if (system_is_overloaded()) {
        @file_put_contents("/etc/artica-postfix/settings/Daemons/SquidStatsMonthQueue", 1);
        squid_admin_mysql(0, "Overloaded system {$GLOBALS["SYSTEM_INTERNAL_LOAD"]}, aborting task", null, __FILE__, __LINE__);
        return;
    }
    $Curday = date("Y-m-d");
    $sql = "SELECT date_trunc('day',zdate)  as zdate FROM access_log GROUP BY  date_trunc('day',zdate) ORDER BY zdate";
    $q = new postgres_sql();
    $q->CREATE_TABLES();
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo $q->mysql_error . "\n";
    }
    $SOURCES_DAY = array();
    while ($ligne = @pg_fetch_assoc($results)) {
        $day = date("Y-m-d", strtotime($ligne["zdate"]));
        if ($Curday == $day) {
            continue;
        }
        $SOURCES_DAY[$day] = true;
    }
    $sql = "SELECT date_trunc('day',zdate)  as zdate FROM access_month GROUP BY  date_trunc('day',zdate) ORDER BY zdate";
    $q = new postgres_sql();
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo $q->mysql_error . "\n";
    }
    $DEST_DAY = array();
    while ($ligne = @pg_fetch_assoc($results)) {
        $day = date("Y-m-d", strtotime($ligne["zdate"]));
        if ($Curday == $day) {
            continue;
        }
        $DEST_DAY[$day] = true;
    }
    $CountOfSourcesDay = count($SOURCES_DAY);
    $c = 0;
    $OverLoadedCount = 0;
    $OverLoadedMax = round($OverLoadedCount / 2);
    while (list($Day, $ligne) = each($SOURCES_DAY)) {
        if (isset($DEST_DAY[$Day])) {
            echo "{$Day} already done\n";
            continue;
        }
        echo "{$Day} not imported done\n";
        $c++;
        if (!compress_day($Day)) {
            @file_put_contents("/etc/artica-postfix/settings/Daemons/SquidStatsMonthQueue", 1);
            return;
        }
        if (system_is_overloaded()) {
            $OverLoadedCount++;
            if ($OverLoadedCount > $OverLoadedMax) {
                squid_admin_mysql(0, "Overloaded system {$GLOBALS["SYSTEM_INTERNAL_LOAD"]}, aborting tasks after compressing {$c} days", null, __FILE__, __LINE__);
                @file_put_contents("/etc/artica-postfix/settings/Daemons/SquidStatsMonthQueue", 1);
                return;
            }
        }
    }
    if (!is_file("/etc/artica-postfix/pids/SquidStatsYearQueue.pid")) {
        create_tables();
        compressToYear(true);
    }
}
Ejemplo n.º 11
0
function install_base()
{
    global $phpc_config_file;
    $sql_type = "mysqli";
    $my_hostname = $_POST['my_hostname'];
    $my_username = $_POST['my_username'];
    $my_passwd = $_POST['my_passwd'];
    $my_prefix = $_POST['my_prefix'];
    $my_database = $_POST['my_database'];
    $fp = fopen($phpc_config_file, 'w') or soft_error('Couldn\'t open config file.');
    fwrite($fp, create_config($my_hostname, $my_username, $my_passwd, $my_database, $my_prefix, $sql_type)) or soft_error("Could not write to file");
    fclose($fp);
    // Make the database connection.
    include $phpc_config_file;
    $dbh = connect_db(SQL_HOST, SQL_USER, SQL_PASSWD, SQL_DATABASE);
    create_tables($dbh);
    $query = "REPLACE INTO `" . SQL_PREFIX . "config`\n" . "(`name`, `value`)\n" . "VALUES ('version', '" . PHPC_DB_VERSION . "')";
    $dbh->query($query) or install_db_error($dbh, 'Error creating version row.', $query);
    echo "<p>Config file created at \"" . realpath($phpc_config_file) . "\"</p>" . "<p>Calendars database created</p>\n" . "<div><input type=\"submit\" name=\"base\" value=\"continue\">" . "</div>\n";
}
Ejemplo n.º 12
0
     //			mysql_connect($_POST['frm_db_host'], $_POST['frm_db_user'], $_POST['frm_db_password']) or die("<FONT CLASS=\"warn\">Couldn't connect to database on '$_POST[frm_db_host]', make sure it is running and user has permissions. Click back in your browser.</FONT>");
     mysql_select_db($_POST['frm_db_dbname']) or die("<FONT CLASS=\"warn\">Couldn't select database '{$_POST['frm_db_dbname']}', make sure it exists and user has permissions. Click back in your browser.</FONT>");
     //			$query = "SET GLOBAL sql_mode='STRICT_ALL_TABLES'";					// 11/6/08
     //			mysql_query($query) or die("<FONT CLASS=\"warn\">SQL error at line " . __LINE__ . " </FONT>");
 }
 //run the functions
 switch ($_POST['frm_option']) {
     case 'install':
         create_tables($_POST['frm_db_prefix']);
         create_user();
         insert_settings();
         write_conf($_POST['frm_db_host'], $_POST['frm_db_dbname'], $_POST['frm_db_user'], $_POST['frm_db_password'], $_POST['frm_db_prefix']);
         print "<LI> Tickets version {$version} installation complete!";
         break;
     case 'install-drop':
         create_tables($_POST['frm_db_prefix'], 1);
         create_user();
         insert_settings();
         write_conf($_POST['frm_db_host'], $_POST['frm_db_dbname'], $_POST['frm_db_user'], $_POST['frm_db_password'], $_POST['frm_db_prefix']);
         print "<LI> Re-Installation done!";
         break;
         //			case 'upgrade-0.65':{
         //				upgrade_065_07($_POST['frm_db_prefix']);
         //				write_conf($_POST['frm_db_host'],$_POST['frm_db_dbname'],$_POST['frm_db_user'],$_POST['frm_db_password'],$_POST['frm_db_prefix']);
         //				print "<LI> Upgrade <B>0.65->0.7</B> complete!";
         //				break;
         //				}
     //			case 'upgrade-0.65':{
     //				upgrade_065_07($_POST['frm_db_prefix']);
     //				write_conf($_POST['frm_db_host'],$_POST['frm_db_dbname'],$_POST['frm_db_user'],$_POST['frm_db_password'],$_POST['frm_db_prefix']);
     //				print "<LI> Upgrade <B>0.65->0.7</B> complete!";
Ejemplo n.º 13
0
/**
 * Install new DB.
 */
function install_newdb()
{
    global $new_db_version, $admin_url, $baseurl, $install_login, $random_password, $create_sample_contents;
    /*
     * -----------------------------------------------------------------------------------
     * NEW DB: Create a plain new db structure + sample contents
     * -----------------------------------------------------------------------------------
     */
    require_once dirname(__FILE__) . '/_functions_create.php';
    if ($old_db_version = get_db_version()) {
        echo '<p class="text-warning"><strong><evo:warning>' . T_('OOPS! It seems b2evolution is already installed!') . '</evo:warning></strong></p>';
        if ($old_db_version < $new_db_version) {
            echo '<p>' . sprintf(T_('Would you like to <a %s>upgrade your existing installation now</a>?'), 'href="?action=evoupgrade"') . '</p>';
        }
        return;
    }
    /**
     * 1 - If current installation is local, test or intranet
     *     Used to turn off gravatar and all ping plugins
     *
     * @var integer
     */
    $local_installation = param('local_installation', 'integer', $create_sample_contents == 'all' ? intval(check_local_installation()) : 0);
    echo '<h2>' . T_('Creating b2evolution tables...') . '</h2>';
    evo_flush();
    create_tables();
    // Update the progress bar status
    update_install_progress_bar();
    echo '<h2>' . T_('Creating minimum default data...') . '</h2>';
    evo_flush();
    create_default_data();
    if ($create_sample_contents) {
        global $Settings, $test_install_all_features;
        echo '<h2>' . T_('Installing sample contents...') . '</h2>';
        evo_flush();
        // We're gonna need some environment in order to create the demo contents...
        load_class('settings/model/_generalsettings.class.php', 'GeneralSettings');
        load_class('users/model/_usersettings.class.php', 'UserSettings');
        /**
         * @var GeneralSettings
         */
        $Settings = new GeneralSettings();
        /**
         * @var UserCache
         */
        $UserCache =& get_UserCache();
        // Create $current_User object.
        // (Assigning by reference does not work with "global" keyword (PHP 5.2.8))
        $GLOBALS['current_User'] =& $UserCache->get_by_ID(1);
        create_demo_contents();
    }
    // Update the progress bar status
    update_install_progress_bar();
    track_step('install-success');
    $install_result_title = T_('Installation successful!');
    $install_result_body = '<p><strong>' . sprintf(T_('Now you can <a %s>log in</a> with the following credentials:'), 'href="' . $admin_url . '"') . '</strong></p>' . '<table>' . '<tr><td>' . T_('Login') . ': &nbsp;</td><td><strong><evo:login>' . (isset($install_login) ? $install_login : '******') . '</evo:login></strong></td></tr>' . '<tr><td>' . T_('Password') . ': &nbsp;</td><td><strong><evo:password>' . $random_password . '</evo:password></strong></td></tr>' . '</table>' . '<br /><p>' . T_('Note that password carefully! It is a <em>random</em> password that is given to you when you install b2evolution. If you lose it, you will have to delete the database tables and re-install anew.') . '</p>';
    // Display installation data and instructions
    echo '<h2>' . $install_result_title . '</h2>';
    echo $install_result_body;
    // Modal window with installation data and instructions
    display_install_result_window($install_result_title, $install_result_body);
}
Ejemplo n.º 14
0
        }
        if (!isset($_SESSION['database-clear'])) {
            $_SESSION['database-clear'] = false;
        }
        try {
            $pdo = new PDO(sprintf('mysql:host=%s;dbname=%s', $_SESSION['database-hostname'], $_SESSION['database-name']), $_SESSION['database-username'], $_SESSION['database-password']);
            $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            $pdo->prefix = $_SESSION['table-prefix'];
            if (isset($_POST['submit'])) {
                $_SESSION['table-prefix'] = $_POST['table-prefix'];
                $_SESSION['database-clear'] = isset($_POST['database-clear']) && $_POST['database-clear'] == 'true';
                if (preg_match('/[^a-zA-Z1-9_]/', $_POST['table-prefix'])) {
                    p_errormsg(lng('error'), lng('invalidtableprefixerror'), '?step=table-create');
                    exit;
                }
                create_tables($pdo, $_SESSION['database-clear']);
                header('Location: ' . $_SERVER['PHP_SELF'] . '?step=administrator-create');
                exit;
            }
            $stmt = $pdo->prepare(<<<SQL
SELECT
    TABLE_NAME
FROM
    INFORMATION_SCHEMA.TABLES
WHERE
    TABLE_SCHEMA = :database
SQL
);
            $stmt->bindValue(':database', $_SESSION['database-name']);
            $stmt->execute();
            $tables = $stmt->fetchAll(PDO::FETCH_COLUMN, 0);
Ejemplo n.º 15
0
function DeltaImport($mysql_db, $date)
{
    $mysql_db->query("CREATE TABLE myrulib_update(date integer primary key, aid integer, bid integer, sid integer, zid integer)");
    $sqltest = "SELECT * FROM myrulib_update WHERE date=(SELECT MAX(date) FROM myrulib_update WHERE date<{$date})";
    $query = $mysql_db->query($sqltest);
    if ($row = $query->fetch_array()) {
        $code = $row["date"];
        $sqlite_db = new PDO("sqlite:./{$code}.upd");
        create_tables($sqlite_db, $date);
        setup_params($sqlite_db, $date, "DELTA");
        convert_authors($mysql_db, $sqlite_db, $row['aid']);
        convert_seqnames($mysql_db, $sqlite_db, $row['sid']);
        convert_books($mysql_db, $sqlite_db, $row['bid']);
        convert_sequences($mysql_db, $sqlite_db, $row['bid']);
        convert_genres($mysql_db, $sqlite_db, $row['bid']);
        convert_dates($mysql_db, $sqlite_db, $row['bid']);
        convert_zips($mysql_db, $sqlite_db, $row['zid']);
        convert_files($mysql_db, $sqlite_db, $row['zid'], $row['bid']);
        system("zip {$code}.zip {$code}.upd");
    }
    $mysql_db->query("INSERT INTO myrulib_update(date) VALUES(" . $date . ")");
    $mysql_db->query("\n\tUPDATE myrulib_update SET \n\t  aid=(SELECT MAX(aid) FROM libavtorname),\n\t  bid=(SELECT MAX(bid) FROM libbook),\n\t  sid=(SELECT MAX(sid) FROM libseq),\n\t  zid=(SELECT MAX(zid) FROM myrulib_zip)\n\tWHERE date={$date}");
}
Ejemplo n.º 16
0
function FullImport($file, $date)
{
    $sqlite_db = new PDO('sqlite:./' . $file);
    create_tables($sqlite_db);
    setup_params($sqlite_db, $date, "FULL");
    convert_auth($sqlite_db, 0);
    convert_book($sqlite_db, 0);
    convert_seqn($sqlite_db, 0);
    convert_date($sqlite_db, 0);
    convert_genr($sqlite_db, 0);
    convert_info($sqlite_db, 0);
    create_indexes($sqlite_db);
    /*
      convert_sequences($mysql_db, $sqlite_db, 0);
      convert_dates($mysql_db, $sqlite_db, 0);
      
      convert_zips($mysql_db, $sqlite_db, 0);
      convert_files($mysql_db, $sqlite_db, 0, 0);
    */
}
    public function step4()
    {
        if (session('step') !== '3') {
            $this->error('请按顺序安装', U('step3'));
        }
        session('step', '4');
        session('error', false);
        $this->assign('meta_title', "step4");
        $this->display();
        //连接数据库
        $db_config = session('db_config');
        $db_instance = Db::getInstance($db_config);
        //创建数据表
        create_tables($db_instance, $db_config['DB_PREFIX']);
        //生成加密字符串
        $add_chars .= '`~!@#$%^&*()_+-=[]{};:"|,.<>/?';
        $auth = String::randString(64, '', $add_chars);
        //生成随机数
        //创建配置文件
        $conf = write_config($db_config, $auth);
        //根据加密字符串更新admin密码的加密结果
        $new_admin_password = user_md5('admin', $auth);
        $sql = <<<SQL
        UPDATE `{$db_config["DB_PREFIX"]}admin_config` SET `value`='{$auth}' WHERE `name` = 'AUTH_KEY';
        UPDATE `{$db_config["DB_PREFIX"]}admin_user` SET `password`='{$new_admin_password}' WHERE `id` = 1;
SQL;
        $result = $db_instance->execute($sql);
        if (!$result) {
            $this->error('写入系统加密KEY或管理员新密码出错!');
        }
        if (session('error')) {
            $this->error('安装出错', 'index');
        } else {
            $this->redirect('complete');
        }
    }
Ejemplo n.º 18
0
function process_tables($db1, $db2)
{
    global $options;
    $tables1 = list_tables($db1);
    $tables2 = list_tables($db2);
    create_tables($db1, $tables1, $tables2);
    if ($options->drop_tables) {
        drop_tables($tables1, $tables2);
    }
    alter_tables($tables1, $tables2);
    alter_tables_columns($db1, $db2);
    process_indexes($tables1, $tables2, $db1, $db2);
}
Ejemplo n.º 19
0
function ParseSizeBuffer($buffer)
{
    if (!class_exists("class.logfile_daemon.inc")) {
        include_once "/usr/share/artica-postfix/ressources/class.logfile_daemon.inc";
    }
    $re = explode(":::", $buffer);
    $mac = trim(strtolower($re[0]));
    if ($mac == "-") {
        $mac == null;
    }
    $mac = str_replace("-", ":", $mac);
    if ($mac == "00:00:00:00:00:00") {
        $mac = null;
    }
    $ipaddr = trim($re[1]);
    // uid
    $uid = $re[2];
    $uid2 = $re[3];
    if ($uid == "-") {
        $uid = null;
    }
    if ($uid2 == "-") {
        $uid2 = null;
    }
    if (preg_match("#^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\$#", $uid2)) {
        $uid2 = null;
    }
    if ($uid == null) {
        if ($uid2 != null) {
            $uid = $uid2;
        }
    }
    $zdate = $re[4];
    $xtime = time();
    $SUFFIX_DATE = date("YmdH", $xtime);
    $logzdate = date("Y-m-d H:i:s", $xtime);
    $proto = $re[5];
    $uri = $re[6];
    $code_error = $re[8];
    $SIZE = $re[9];
    $SquidCode = $re[10];
    $UserAgent = urldecode($re[11]);
    $Forwarded = $re[12];
    $sitename = trim($re[13]);
    $hostname = $re[14];
    $response_time = $re[15];
    $MimeType = $re[16];
    $uid = str_replace("%20", " ", $uid);
    $uid = str_replace("%25", "-", $uid);
    if ($uid == "-") {
        $uid = null;
    }
    $Forwarded = str_replace("%25", "", $Forwarded);
    //events("MimeType: ......: $MimeType");
    if (strpos($uid, '$') > 0) {
        if (substr($uid, strlen($uid) - 1, 1) == "\$") {
            $uid = null;
        }
    }
    if (preg_match("#^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\$#", $uid)) {
        $uid = null;
    }
    if (!preg_match("#^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\$#", $ipaddr)) {
        eventsfailed("***** WRONG LINE ipaddr:{$ipaddr} column 13 " . @implode(" | ", $re) . "*****");
        return;
    }
    if ($sitename == "-") {
        $h = parse_url($uri);
        if (isset($h["host"])) {
            $sitename = $h["host"];
        }
        if ($sitename == "-") {
            eventsfailed("***** WRONG SITENAME {$sitename} column 13 " . @implode(" | ", $re) . "*****");
            eventsfailed("{$buffer}");
            eventsfailed("*");
            $GLOBALS["REFUSED_REQUESTS"] = $GLOBALS["REFUSED_REQUESTS"] + 1;
            return;
        }
        if ($sitename == null) {
            eventsfailed("***** WRONG SITENAME {$sitename} column 13 " . @implode(" | ", $re) . "*****");
            eventsfailed("{$buffer}");
            eventsfailed("*");
            $GLOBALS["REFUSED_REQUESTS"] = $GLOBALS["REFUSED_REQUESTS"] + 1;
            return;
        }
    }
    if (strpos($sitename, ":") > 0) {
        $XA = explode(":", $sitename);
        $sitename = $XA[0];
    }
    if ($sitename == "127.0.0.1") {
        $GLOBALS["REFUSED_REQUESTS"] = $GLOBALS["REFUSED_REQUESTS"] + 1;
        if ($GLOBALS["VERBOSE"]) {
            events("127.0.0.1 -> uid = null -> SKIP");
        }
        return;
    }
    if ($Forwarded == "unknown") {
        $Forwarded = null;
    }
    if ($Forwarded == "-") {
        $Forwarded = null;
    }
    if ($Forwarded == "0.0.0.0") {
        $Forwarded = null;
    }
    if ($Forwarded == "255.255.255.255") {
        $Forwarded = null;
    }
    if (strlen($Forwarded) > 4) {
        $ipaddr = $Forwarded;
        $mac = null;
    }
    $ipaddr = str_replace("%25", "-", $ipaddr);
    $mac = str_replace("%25", "-", $mac);
    if ($mac == "-") {
        $mac = null;
    }
    if ($ipaddr == "127.0.0.1" or $ipaddr == "::") {
        if ($uid == null) {
            $GLOBALS["REFUSED_REQUESTS"] = $GLOBALS["REFUSED_REQUESTS"] + 1;
            if ($GLOBALS["VERBOSE"]) {
                events("127.0.0.1 -> uid = null -> SKIP");
            }
            return;
        }
    }
    if (preg_match("#([0-9:a-z]+)\$#", $mac, $z)) {
        $mac = $z[1];
    }
    if ($GLOBALS["VERBOSE"]) {
        events("ITEM: DATE......: {$logzdate}");
        events("ITEM: MAC.......: {$mac}");
        events("ITEM: IP........: {$ipaddr}");
        events("ITEM: Size......: {$SIZE}");
        events("ITEM: SQUID CODE: {$SquidCode}");
        events("ITEM: HTTP CODE.: {$code_error}");
        events("ITEM: uid.......: {$uid}");
        events("ITEM: uri.......: {$uri}");
        events("ITEM: UserAgent.: {$UserAgent}");
        events("ITEM: Forwarded.: {$Forwarded}");
        events("ITEM: SiteName..: {$sitename}");
    }
    if ($UserAgent != null) {
        UserAuthDB($mac, $ipaddr, $uid, $hostname, $UserAgent);
    } else {
        events("No UserAgents in {$buffer}");
    }
    $GLOBALS["COUNT_HASH_TABLE"] = $GLOBALS["COUNT_HASH_TABLE"] + 1;
    $arrayURI = parse_url($uri);
    $sitename = $arrayURI["host"];
    if (strpos($sitename, ":")) {
        $xtr = explode(":", $sitename);
        $sitename = $xtr[0];
        if (preg_match("#^www\\.(.+)#", $sitename, $rz)) {
            $sitename = $rz[1];
        }
    }
    $TimeCache = date("YmdH");
    if (!isset($GLOBALS["FAMLILYSITE"][$sitename])) {
        $fam = new squid_familysite();
        $GLOBALS["FAMLILYSITE"][$sitename] = $fam->GetFamilySites($sitename);
    }
    $FamilySite = $GLOBALS["FAMLILYSITE"][$sitename];
    $TablePrimaireHour = "squidhour_" . $TimeCache;
    $TableSizeHours = "sizehour_" . $TimeCache;
    $TableCacheHours = "cachehour_" . $TimeCache;
    $tableYoutube = "youtubehours_" . $TimeCache;
    $tableSearchWords = "searchwords_" . $TimeCache;
    $tableQuotaTemp = "quotatemp_" . $TimeCache;
    $category = null;
    if ($GLOBALS["DisableLogFileDaemonCategories"] == 0) {
        if ($GLOBALS["VERBOSE"]) {
            $time_start = microtime(true);
        }
        $category = ufdbcat($sitename);
        if ($GLOBALS["VERBOSE"]) {
            $time_end = microtime(true);
            $time_calc = $time_end - $time_start;
        }
        if ($GLOBALS["VERBOSE"]) {
            events("{$sitename} = {$category} {$time_calc}ms");
        }
    }
    $logfile_daemon = new logfile_daemon();
    $cached = $logfile_daemon->CACHEDORNOT($SquidCode);
    $SearchWords = $logfile_daemon->SearchWords($uri);
    $GLOBALS["ACCEPTED_REQUESTS"] = $GLOBALS["ACCEPTED_REQUESTS"] + 1;
    $MAIN["TIMESTAMP"] = time();
    $MAIN["URI"] = $uri;
    $MAIN["sitename"] = $sitename;
    $MAIN["SIZE"] = $SIZE;
    $MAIN["CACHED"] = $cached;
    $MAIN["IPADDR"] = $ipaddr;
    $MAIN["CATEGORY"] = $category;
    $MAIN["MIMETYPE"] = $MimeType;
    $MAIN["FAMILYSITE"] = $GLOBALS["FAMLILYSITE"][$sitename];
    $MAIN["MAC"] = $mac;
    $MAIN["UID"] = $uid;
    $MAIN["USERAGENT"] = $UserAgent;
    $MAIN["SQUID_CODE"] = $SquidCode;
    $MAIN["RESPONSE_TIME"] = $response_time;
    $MAIN["PROTO"] = $proto;
    $MAIN["HTTP_CODE"] = $code_error;
    if ($hostname != null) {
        $MAIN["HOSTNAME"] = $hostname;
    }
    if (is_array($SearchWords)) {
        $MAIN["WORDS"] = $SearchWords["WORDS"];
    }
    $md5 = md5(serialize($MAIN));
    berekley_add($md5, base64_encode(serialize($MAIN)));
    return;
    if (!isset($GLOBALS["RTTCREATED"][$TimeCache])) {
        events("Creating RTTH_{$TimeCache} table...");
        if (create_tables($TimeCache)) {
            $GLOBALS["RTTCREATED"][$TimeCache] = true;
        }
    }
    $sql = "INSERT IGNORE INTO `squidlogs`.`RTTH_{$TimeCache}` (`xtime`,`sitename`,`ipaddr`,`uid`,`MAC`,`size`) VALUES('{$xtime}','{$FamilySite}','{$ipaddr}','{$uid}','{$mac}','{$SIZE}')";
    if ($GLOBALS["VERBOSE"]) {
        $time_start = microtime(true);
    }
    if (!SEND_MYSQL($sql)) {
        @file_put_contents("/var/log/squid/mysql-rtterrors/" . md5($sql), serialize(array("TABLE" => "RTTH_{$TimeCache}", "CMD" => $sql)));
    }
    if ($GLOBALS["VERBOSE"]) {
        $time_end = microtime(true);
        $time_calc = $time_end - $time_start;
    }
    if ($GLOBALS["VERBOSE"]) {
        events("RTTH_{$TimeCache} {$time_calc}ms DisableLogFileDaemonMySQL={$GLOBALS["DisableLogFileDaemonMySQL"]}");
    }
    $uri = xmysql_escape_string2($uri);
    if (!isset($GLOBALS["CODE_TO_STRING"][$code_error])) {
        $GLOBALS["CODE_TO_STRING"][$code_error] = $logfile_daemon->codeToString($code_error);
    }
    $zMD5 = md5("{$uri}{$xtime}{$mac}{$ipaddr}");
    $TYPE = $GLOBALS["CODE_TO_STRING"][$code_error];
    $cached = $GLOBALS["CACHEDX"][$SquidCode];
    $UserAgent = xmysql_escape_string2($UserAgent);
    if ($GLOBALS["VERBOSE"]) {
        $time_start = microtime(true);
    }
    $sql = "INSERT IGNORE INTO `{$TableSizeHours}` (`zDate`,`size`,`cached`) VALUES ('{$logzdate}','{$SIZE}','{$cached}')";
    if (!SEND_MYSQL($sql)) {
        @file_put_contents("/var/log/squid/mysql-rtterrors/" . md5($sql), serialize(array("TimeCache" => $TimeCache, "TABLE" => $TableSizeHours, "CMD" => $sql)));
    }
    if ($GLOBALS["VERBOSE"]) {
        $time_end = microtime(true);
        $time_calc = $time_end - $time_start;
    }
    if ($GLOBALS["VERBOSE"]) {
        events("{$TableSizeHours} = {$time_calc}ms");
    }
    $sql = "INSERT IGNORE INTO `{$tableQuotaTemp}` (`xtime`,`keyr`,`ipaddr`,`familysite`,`servername`,`uid`,`MAC`,`size`) VALUES \n\t('{$logzdate}','{$zMD5}','{$ipaddr}','{$FamilySite}','{$FamilySite}','{$uid}','{$mac}','{$SIZE}')";
    if (!SEND_MYSQL($sql)) {
        @file_put_contents("/var/log/squid/mysql-rtterrors/" . md5($sql), serialize(array("TimeCache" => $TimeCache, "TABLE" => $tableQuotaTemp, "CMD" => $sql)));
    }
    $sql = "INSERT IGNORE INTO `{$TablePrimaireHour}` (`sitename`,`uri`,`TYPE`,`REASON`,`CLIENT`,`hostname`,`zDate`,`zMD5`,`uid`,`QuerySize`,`cached`,`MAC`,`category`) VALUES ('{$sitename}','{$uri}','{$TYPE}','{$TYPE}','{$ipaddr}','{$hostname}','{$logzdate}','{$zMD5}','{$uid}','{$SIZE}','{$cached}','{$mac}','{$category}')";
    if (!SEND_MYSQL($sql)) {
        @file_put_contents("/var/log/squid/mysql-rtterrors/" . md5($sql), serialize(array("TABLE" => $TablePrimaireHour, "CMD" => $sql)));
    }
    $sql = "INSERT IGNORE INTO `{$TableCacheHours}` (`zDate`,`size`,`cached`,`familysite`) VALUES ('{$logzdate}','{$SIZE}','{$cached}','{$FamilySite}')";
    if (!SEND_MYSQL($sql)) {
        @file_put_contents("/var/log/squid/mysql-rtterrors/" . md5($sql), serialize(array("TimeCache" => $TimeCache, "TABLE" => $TableCacheHours, "CMD" => $sql)));
    }
    if (strpos(" {$uri}", "youtube") > 0) {
        $VIDEOID = $logfile_daemon->GetYoutubeID($uri);
        if ($VIDEOID != null) {
            $sql = "INSERT IGNORE INTO `{$tableYoutube}` (`zDate`,`ipaddr`,`hostname`,`uid`,`MAC` ,`account`,`youtubeid`) VALUES ('{$logzdate}','{$ipaddr}','','{$uid}','{$mac}','0','{$VIDEOID}')";
            events_youtube($sql);
            if (!SEND_MYSQL($sql)) {
                @file_put_contents("/var/log/squid/mysql-rtterrors/" . md5($sql), serialize(array("TimeCache" => $TimeCache, "TABLE" => $tableYoutube, "CMD" => $sql)));
            }
        }
    }
    if (is_array($SearchWords)) {
        $words = xmysql_escape_string2($SearchWords["WORDS"]);
        $sql = "INSERT IGNORE INTO `{$tableSearchWords}` (`zmd5`,`sitename`,`zDate`,`ipaddr`,`hostname`,`uid`,`MAC`,`account`,`familysite`,`words`) VALUES ('{$zMD5}','{$sitename}','{$logzdate}','{$ipaddr}','{$hostname}','{$uid}','{$mac}','0','{$FamilySite}','{$words}')";
        if (!SEND_MYSQL($sql)) {
            @file_put_contents("/var/log/squid/mysql-rtterrors/" . md5($sql), serialize(array("TimeCache" => $TimeCache, "TABLE" => $tableYoutube, "CMD" => $sql)));
        }
    }
    if (count($GLOBALS["CACHE_SQL"]) > 2) {
        events("CACHE_SQL = " . count($GLOBALS["CACHE_SQL"] . " seems 2 minutes"));
        empty_TableHash();
    }
    $dd = date("Hi");
    if (count($GLOBALS["CACHE_SQL"][$dd]) > 1000) {
        events("CACHE_SQL[{$dd}] = " . count($GLOBALS["CACHE_SQL"][$dd]));
        empty_TableHash();
    }
    return;
    $GLOBALS["RTTHASH"][$SUFFIX_DATE][] = array("TIME" => $xtime, "MAC" => $mac, "IPADDR" => $ipaddr, "SIZE" => $SIZE, "SQUID_CODE" => $SquidCode, "HTTP_CODE" => $code_error, "UID" => $uid, "URI" => $uri, "USERAGENT" => $UserAgent, "SITENAME" => $sitename, "HOSTNAME" => $hostname, "RESPONSE_TIME" => $response_time);
    $GLOBALS["ACCEPTED_REQUESTS"] = $GLOBALS["ACCEPTED_REQUESTS"] + 1;
    if (count($GLOBALS["RTTHASH"][$SUFFIX_DATE]) > 50) {
        if ($GLOBALS["VERBOSE"]) {
            events("-> empty_TableHash()");
        }
        empty_TableHash();
    }
    if ($GLOBALS["VERBOSE"]) {
        events("---------------------- DONE ----------------------");
    }
}
Ejemplo n.º 20
0
function install_base()
{
    global $phpc_config_file, $dbh;
    $sql_type = "mysqli";
    $my_hostname = $_POST['my_hostname'];
    $my_username = $_POST['my_username'];
    $my_passwd = $_POST['my_passwd'];
    $my_prefix = $_POST['my_prefix'];
    $my_database = $_POST['my_database'];
    $fp = fopen($phpc_config_file, 'w') or soft_error('Couldn\'t open config file.');
    fwrite($fp, create_config($my_hostname, $my_username, $my_passwd, $my_database, $my_prefix, $sql_type)) or soft_error("Could not write to file");
    fclose($fp);
    // Make the database connection.
    include $phpc_config_file;
    $dbh = connect_db(SQL_HOST, SQL_USER, SQL_PASSWD, SQL_DATABASE);
    create_tables();
    echo "<p>Config file created at \"" . realpath($phpc_config_file) . "\"</p>" . "<p>Calendars database created</p>\n" . "<div><input type=\"submit\" name=\"base\" value=\"continue\">" . "</div>\n";
}
Ejemplo n.º 21
0
function FullImport($mysql_db, $file, $date)
{
    $sqlite_db = new PDO('sqlite:./' . $file);
    create_tables($sqlite_db);
    setup_params($sqlite_db, $date, "FULL");
    $sqlite_db->query("DROP TABLE tables");
    $sqlite_db->query("DROP TABLE dir0");
    $sqlite_db->query("DROP TABLE ref0");
    $sqlite_db->query("CREATE TABLE dir0(code INTEGER PRIMARY KEY, name, info, parent INTEGER NOT NULL)");
    $sqlite_db->query("CREATE TABLE ref0(code INTEGER, book INTEGER, PRIMARY KEY(code, book))");
    $sqlite_db->query("CREATE INDEX dir0_parent ON dir0(parent)");
    $sqlite_db->query("CREATE INDEX ref0_book ON ref0(book)");
    $sqlite_db->query("CREATE TABLE tables(id INTEGER PRIMARY KEY AUTOINCREMENT,title,\n\tdir_file,dir_data,dir_type,dir_code,dir_name,dir_info,dir_prnt,\n\tref_file,ref_data,ref_type,ref_code,ref_book,fb2_code)");
    $sqlite_db->query("INSERT INTO tables(title,dir_data,dir_type,dir_code,dir_name,dir_prnt,ref_data,ref_type,ref_code,ref_book)\n\tVALUES ('Тематический рубрикатор','dir0','INTEGER','code','name','parent','ref0','id','code','book')");
    convert_books($mysql_db, $sqlite_db);
    convert_auth($mysql_db, $sqlite_db);
    convert_dates($mysql_db, $sqlite_db);
    convert_topics($mysql_db, $sqlite_db);
    create_indexes($sqlite_db);
}
Ejemplo n.º 22
0
 public function step4()
 {
     $this->assign('meta_title', "step4");
     $this->display();
     //连接数据库
     $db_config = session('db_config');
     $db_instance = Db::getInstance($db_config);
     //创建数据表
     create_tables($db_instance, $db_config['DB_PREFIX']);
     //生成加密字符串
     $add_chars .= '`~!@#$%^&*()_+-=[]{};:"|,.<>/?';
     $auth = \Org\Util\String::randString(64, '', $add_chars);
     //生成随机数
     //创建配置文件
     $conf = write_config($db_config, $auth);
     //根据加密字符串更新admin密码的加密结果
     $sql = 'UPDATE `' . $db_config["DB_PREFIX"] . 'user` SET `password`="' . user_md5('admin', $auth) . '" WHERE `id` = 1';
     $result = $db_instance->execute($sql);
     if (!$result) {
         $this->error('写入加密后密码出错!');
     }
     if (session('error')) {
         $this->error('安装出错', 'step1');
     } else {
         session('step', 4);
         $this->redirect('complete');
     }
 }
 public function step3()
 {
     /* if(session('step') != 2){
            $this->redirect('step2');
        }*/
     $this->display();
     //连接数据库
     $dbconfig = cookie('db_config');
     $db = Db::getInstance($dbconfig);
     //创建数据表
     create_tables($db, $dbconfig['DB_PREFIX']);
     //注册创始人帐号
     $auth = build_auth_key();
     $admin = session('admin_info');
     register_administrator($db, $dbconfig['DB_PREFIX'], $admin, $auth);
     //创建配置文件
     $conf = write_config($dbconfig, $auth);
     session('config_file', $conf);
     if (session('error')) {
         //show_msg();
     } else {
         session('step', 3);
         echo "<script type=\"text/javascript\">setTimeout(function(){location.href='" . U('Index/complete') . "'},5000)</script>";
         ob_flush();
         flush();
         //$this->redirect('Index/complete');
     }
 }
Ejemplo n.º 24
0
 public function step4()
 {
     session('error', false);
     //连接数据库
     $db_config = session('db_config');
     $db_instance = Db::getInstance($db_config);
     $this->display();
     //创建数据表
     if (session('tiyang') == 1) {
         create_tables($db_instance, 'zml_', '1');
     } else {
         create_tables($db_instance, 'zml_');
     }
     if (session('error')) {
         $this->error('安装出错', 'index');
     } else {
         session('step', 4);
         $this->redirect('complete');
     }
 }
Ejemplo n.º 25
0
/**
 * This is where the install really takes place.
 */
function install_process()
{
    // {{{
    build_dirs();
    create_tables();
    insert_defaults();
    write_config();
    header("Location: index.php");
}
Ejemplo n.º 26
0
function install_base()
{
    global $phpc_root_path, $db;
    $sql_type = $_POST['sql_type'];
    $my_hostname = $_POST['my_hostname'];
    $my_username = $_POST['my_username'];
    $my_passwd = $_POST['my_passwd'];
    $my_prefix = $_POST['my_prefix'];
    $my_database = $_POST['my_database'];
    $fp = fopen($phpc_root_path . 'config.php', 'w') or soft_error('Couldn\'t open config file.');
    fwrite($fp, create_config($my_hostname, $my_username, $my_passwd, $my_database, $my_prefix, $sql_type)) or soft_error("could not write to file");
    fclose($fp);
    require_once $phpc_root_path . 'config.php';
    // Make the database connection.
    $db = NewADOConnection(SQL_TYPE);
    if (!$db->Connect(SQL_HOST, SQL_USER, SQL_PASSWD, SQL_DATABASE)) {
        db_error(_("Could not connect to the database"));
    }
    create_tables();
    echo "<p>calendars base created</p>\n" . "<div><input type=\"submit\" name=\"base\" value=\"continue\">" . "</div>\n";
}
 public function step3()
 {
     if (session('step') != 3) {
         $this->redirect('step2');
     }
     $this->display();
     //连接数据库
     $dbconfig = session('db_config');
     $db = Db::getInstance($dbconfig);
     //创建数据表
     create_tables($db, $dbconfig['DB_PREFIX']);
     //注册创始人帐号
     $auth = build_auth_key();
     $admin = session('admin_info');
     register_administrator($db, $dbconfig['DB_PREFIX'], $admin, $auth);
     //创建初始编辑号
     register_editor($db, $dbconfig['DB_PREFIX'], $auth);
     //创建配置文件
     $conf = write_config($dbconfig, $auth);
     session('config_file', $conf);
     if (session('error')) {
         //show_msg();
     } else {
         session('step', 3);
         $this->redirect('Index/complete');
     }
 }
Ejemplo n.º 28
0
 public function step3()
 {
     if (session('step') != 2) {
         $this->redirect('step2');
     }
     $this->display();
     if (session('update')) {
         $db = Db::getInstance();
         //更新数据表
         update_tables($db, C('DB_PREFIX'));
     } else {
         //连接数据库
         $dbconfig = session('db_config');
         $db = Db::getInstance($dbconfig);
         //创建数据表
         create_tables($db, $dbconfig['DB_PREFIX']);
         //注册创始人帐号
         $admin = session('admin_info');
         $admin['password'] = md5($admin['password']);
         register_administrator($db, $dbconfig['DB_PREFIX'], $admin, $auth);
         //创建配置文件
         $conf = write_config($dbconfig, $auth);
         session('config_file', $conf);
     }
     if (session('error')) {
         //show_msg();
     } else {
         session('step', 3);
         Storage::put(APP_PATH . 'Common/Conf/install.lock', 'lock');
         $this->redirect('Index/complete');
     }
 }
Ejemplo n.º 29
0
function validate_form()
{
    global $input;
    // Test connection to DB
    $errors = array();
    $res = db_ping($input['db_type'], $input['db_host'], $input['db_login'], $input['db_passwd'], $input['db_name']);
    if (!$res) {
        $errors['db_error'] = 'Could not connect to database ' . $input['db_host'];
    }
    if (count($errors) > 0) {
        require template_getpath('install.php');
        die;
    }
    try {
        // used for the verification of existing tables and columns
        $tables = array(escapeshellarg($input['db_prefix'] . 'classrooms') => array(escapeshellarg('room_id'), escapeshellarg('name'), escapeshellarg('IP'), escapeshellarg('enabled')), escapeshellarg($input['db_prefix'] . 'courses') => array(escapeshellarg('course_code'), escapeshellarg('course_name'), escapeshellarg('shortname'), escapeshellarg('in_recorders'), escapeshellarg('has_albums'), escapeshellarg('date_created'), escapeshellarg('origin')), escapeshellarg($input['db_prefix'] . 'logs') => array(escapeshellarg('ID'), escapeshellarg('time'), escapeshellarg('table'), escapeshellarg('message'), escapeshellarg('author')), escapeshellarg($input['db_prefix'] . 'users') => array(escapeshellarg('user_ID'), escapeshellarg('surname'), escapeshellarg('forename'), escapeshellarg('passwd'), escapeshellarg('recorder_passwd'), escapeshellarg('permissions'), escapeshellarg('origin')), escapeshellarg($input['db_prefix'] . 'users_courses') => array(escapeshellarg('ID'), escapeshellarg('course_code'), escapeshellarg('user_ID'), escapeshellarg('origin')));
        $db = new PDO($input['db_type'] . ':host=' . $input['db_host'] . ';dbname=' . $input['db_name'], $input['db_login'], $input['db_passwd']);
        // checks if tables already exist
        $data = $db->query('SELECT table_name FROM information_schema.tables ' . 'WHERE table_schema = ' . escapeshellarg($input['db_name']) . ' ' . 'AND table_name IN (' . implode(', ', array_keys($tables)) . ')');
        $result = $data->fetchAll(PDO::FETCH_ASSOC);
        if (count($result) <= 0) {
            // tables don't exist yet, we can create them
            create_tables();
        } else {
            // saves values from user
            $_SESSION['user_inputs'] = $input;
            // prepare radio buttons for next view
            $radio_buttons = array('replace' => '<b>Replace</b> the existing tables. <b style="color:red">All contents of the existing tables will be erased.</b>', 'prefix' => 'Choose another prefix for the tables of EZcast. This will create new tables for EZcast. <br/><input type="text" name="new_prefix"/>');
            if (count($result) >= count(array_keys($tables))) {
                // all tables already exist
                $all_columns = true;
                foreach ($tables as $table => $columns) {
                    // checks if table contains all required columns
                    $data = $db->query('SELECT * FROM information_schema.columns ' . 'WHERE table_schema = ' . escapeshellarg($input['db_name']) . ' ' . 'AND table_name = ' . $table . ' ' . 'AND column_name IN (' . implode(', ', array_keys($columns)) . ')');
                    $result = $data->fetchAll(PDO::FETCH_ASSOC);
                    if (count($result) < count($columns)) {
                        $all_columns = false;
                        break;
                    }
                }
                if ($all_columns) {
                    $radio_buttons['use'] = 'Use the existing tables for EZcast. None table will be created.';
                }
            }
            require template_getpath('install_db_choice.php');
            die;
        }
    } catch (PDOException $e) {
        $errors['db_error'] = $e->getMessage();
        require template_getpath('install.php');
        die;
    }
}
Ejemplo n.º 30
0
function create_crude($name, $empty)
{
    create_controller($name, $empty);
    create_model($name);
    create_routing($name);
    create_tables();
    echo "Crud " . $name . " created with success\n";
}