コード例 #1
0
ファイル: admin_parse_log.php プロジェクト: Victory/FreeTale
function parse_form_file($log_file_name)
{
    $sqlite_db_name = preg_replace("/.log\$/", ".sqlite", $log_file_name);
    $db = new DBx(DB_DIR . $sqlite_db_name, "sqlite");
    $sql = "DROP TABLE IF EXISTS actions";
    $db->q($sql);
    $sql = "\nCREATE TABLE actions (\n  unixtime INT NOT NULL,\n  remote_addr CHAR(30),\n  user_agent TEXT,\n  id INT,\n  url TEXT NOT NULL,\n  referer TEXT,\n  input_type TEXT,\n  form_id TEXT,\n  input_name TEXT,\n  time_elapsed TEXT,\n  key_ups INT\n)";
    $db->q($sql);
    $sql = "\nCREATE INDEX IF NOT EXISTS \n  actions_id\n    ON actions(id)\n";
    $db->q($sql);
    global $form_actions;
    $contents = file_get_contents(DB_DIR . $log_file_name);
    $lines = explode("\n", $contents);
    // begin a transaction
    $db->bt();
    foreach ($lines as $line) {
        if (strlen($line) == 0) {
            continue;
        }
        $tic = parse_form_action($line);
        $db->set('actions', $tic);
        // todo add cleanup string
        /** /
            echo "<pre>";
            print_r($tic);
            echo "</pre>";
            /**/
    }
    $db->c();
}