コード例 #1
0
function processImportLogs()
{
    // This function will import all existing log files.  This is useful for rebuilding an empty Gamespy database
    global $cfg;
    // Make Sure Script doesn't timeout
    set_time_limit(0);
    // Find Log Files
    showLog("Importing Log Files");
    $regex = '([0-9]{4})([0-9]{2})([0-9]{2})_([0-9]{4})';
    $dir = opendir(chkPath($cfg->get('stats_logs')));
    chdir(chkPath($cfg->get('stats_logs')));
    while (($file = readdir($dir)) !== false) {
        if (strpos($file, $cfg->get('stats_ext'))) {
            ereg($regex, $file, $sort);
            $files[] = $sort[0] . "|" . $file;
        }
    }
    // Sort Files
    sort($files, SORT_STRING);
    // Re-post existing log data to bf2statistics
    $total = 0;
    for ($x = 0; $x < count($files); $x++) {
        $file = explode("|", $files[$x]);
        $fh = fsockopen($_SERVER['HTTP_HOST'], 80);
        fwrite($fh, "POST /ASP/bf2statistics.php HTTP/1.1\r\n");
        fwrite($fh, "HOST: localhost\r\n");
        fwrite($fh, "User-Agent: GameSpyHTTP/1.0\r\n");
        fwrite($fh, "Content-Type: application/x-www-form-urlencoded\r\n");
        $filename = @fopen($file[1], 'r');
        $data = fread($filename, filesize($file[1]));
        @fclose($filename);
        if (strpos($data, '\\EOF\\1') === false) {
            // Older SNAPSHOT.  Insert EOF to ensure bf2statiscs.php processes this...
            $data .= '\\EOF\\1';
        }
        if (strpos($file[1], "importdata") === false) {
            // Make sure we know this is an import of existing log data
            $data .= '\\import\\1';
        }
        fwrite($fh, "Content-Length: " . strlen($data) . "\r\n\r\n");
        fwrite($fh, $data . "\r\n");
        fclose($fh);
        showLog(" -> Importing {$file['1']}...done!");
        $total++;
    }
    showLog("Total files imported: {$total}");
}
コード例 #2
0
 */
 /*
  ErrorLog("Processing SMOC and General Ranks",3);
  smocCheck();
  genCheck();
 */
 /*     * ******************************
  * Process 'Archive Data File'
  * ****************************** */
 if ($cfg->get('stats_move_logs')) {
     if (file_exists(chkPath($cfg->get('stats_logs_store')) . $ip_s)) {
     } else {
         mkdir(chkPath($cfg->get('stats_logs_store')) . $ip_s, 0777);
     }
     $fn_src = chkPath($cfg->get('stats_logs')) . $stats_filename;
     $fn_dest = chkPath($cfg->get('stats_logs_store')) . $ip_s . '/' . $stats_filename;
     if (file_exists($fn_src)) {
         if (file_exists($fn_dest)) {
             $errmsg = "SNAPSHOT Data File Already Exists, Over-writing! ({$fn_src} -> {$fn_dest})";
             ErrorLog($errmsg, 2);
         }
         copy($fn_src, $fn_dest);
         // Remove the original ONLY if it copies
         if (file_exists($fn_dest)) {
             unlink($fn_src);
         }
     }
     $errmsg = "SNAPSHOT Data File Moved! ({$fn_src} -> {$fn_dest})";
     ErrorLog($errmsg, 3);
 }
 $errmsg = "SNAPSHOT Data File Processed: {$stats_filename}";