public function clearOrderLogs(array $params)
 {
     $logDir = Config::orderlogDirectory();
     if (!is_dir($logDir) or !($handle = opendir($logDir))) {
         throw new Exception(l_t("Could not open log directory"));
     }
     $logs = array();
     $exclude = array('.', '..', 'index.html');
     while (false !== ($file = readdir($handle))) {
         if (in_array($file, $exclude)) {
             continue;
         }
         $logs[] = $file;
     }
     closedir($handle);
     $i = 0;
     foreach ($logs as $log) {
         unlink($logDir . '/' . $log);
         $i++;
     }
     return l_t('The order logs were cleared, %s files deleted.', $i);
 }
}
function adminStatusList($name, $query)
{
    global $DB;
    print '<p><strong>' . $name . ':</strong> ';
    $tabl = $DB->sql_tabl($query);
    while (list($row) = $DB->tabl_row($tabl)) {
        print $row . ', ';
    }
}
if ($User->type['Admin']) {
    // Get the order logs used to validate whether stories about orders being swapped around
    if (isset($_REQUEST['viewOrderLogGameID']) && isset($_REQUEST['viewOrderLogCountryID'])) {
        $viewOrderLogGameID = (int) $_REQUEST['viewOrderLogGameID'];
        $viewOrderLogCountryID = (int) $_REQUEST['viewOrderLogCountryID'];
        $orderlogDirectory = Config::orderlogDirectory();
        if (false === $orderlogDirectory) {
            print '<p class="notice">' . l_t('Order logging not enabled; check config.php') . '</p>';
        } else {
            require_once l_r('objects/game.php');
            $logfile = libCache::dirID($orderlogDirectory, $viewOrderLogGameID, true) . '/' . $viewOrderLogCountryID . '.txt';
            if (!file_exists($logfile)) {
                print '<p class="notice">' . l_t('No log file found for this gameID/countryID.') . '</p>';
            } else {
                print '<pre>' . file_get_contents($logfile) . '</pre>';
            }
            unset($logfile);
        }
    } else {
        $viewOrderLogGameID = '';
        $viewOrderLogCountryID = '';
Example #3
0
   along with webDiplomacy.  If not, see <http://www.gnu.org/licenses/>.
*/
/**
 * @package Admin
 */
require_once 'header.php';
ini_set('memory_limit', "128M");
// 8M is the default
ini_set('max_execution_time', '240');
if ($User->type['Moderator'] && isset($_REQUEST['viewOrderLogGame']) && isset($_REQUEST['viewOrderLogCountryID'])) {
    $gameID = (int) $_REQUEST['viewOrderLogGame'];
    $countryID = (int) $_REQUEST['viewOrderLogCountryID'];
    require_once l_r('objects/game.php');
    $Variant = libVariant::loadFromGameID($gameID);
    $Game = $Variant->Game($gameID);
    if (!($data = file_get_contents(libCache::dirID(Config::orderlogDirectory(), $gameID, true) . '/' . $countryID . '.txt'))) {
        trigger_error(l_t("Couldn't open file %s.txt", $log));
    }
    header('Content-type:text/plain');
    print $data;
    die;
}
if ($User->type['Admin'] && isset($_REQUEST['viewErrorLog'])) {
    $log = (int) $_REQUEST['viewErrorLog'];
    if (!($data = file_get_contents(Config::errorlogDirectory() . '/' . $log . '.txt'))) {
        trigger_error(l_t("Couldn't open file %s.txt", $log));
    }
    header('Content-type:text/plain');
    print $data;
    die;
}
Example #4
0
 protected function log($logData)
 {
     $orderlogDirectory = Config::orderlogDirectory();
     if (false === $orderlogDirectory) {
         return;
     }
     require_once l_r('objects/game.php');
     $directory = libCache::dirID($orderlogDirectory, $this->gameID, true);
     $file = $this->countryID . '.txt';
     if (!($orderLog = fopen($directory . '/' . $file, 'a'))) {
         trigger_error(l_t("Couldn't open order log file."));
     }
     if (!fwrite($orderLog, 'Time: ' . gmdate("M d Y H:i:s") . " (UTC+0)\n" . $logData . "\n\n")) {
         trigger_error(l_t("Couldn't write to order log file."));
     }
     fflush($orderLog) or trigger_error(l_t("Couldn't write to order log file."));
     fclose($orderLog);
 }