예제 #1
0
// Init
$starttime = microtime() + time();
// create logging facility
$sdl = new scheduler();
// create sql-object for db-connection
$db = new sql($config['server'] . ":" . $config['port'], $config['game_database'], $config['user'], $config['password']);
$game = new game();
$sdl->log('<br><br><br><b>-------------------------------------------------------------</b><br>' . '<b>Starting Daily script at ' . date('d.m.y H:i:s', time()) . '</b>');
// #######################################################################################
// #######################################################################################
// Reset New Registration Count
$sdl->start_job('Reset New Registration Count');
if (!$db->query('UPDATE config SET new_register = 0')) {
    $sdl->log('<b>Error:</b> cannot reset new registration count!');
}
$sdl->finish_job('Reset New Registration Count');
// #######################################################################################
// #######################################################################################
// Check sitting abuse and lock'em
$sdl->start_job('Sitting abuse check');
$sql = 'SELECT user_id,user_name,num_hits,num_sitting FROM user
        WHERE (num_sitting/(num_hits+1))>0.35 AND
              (num_sitting>50 OR (num_hits<10 AND num_sitting>30))';
if (($result = $db->query($sql)) === false) {
    $sdl->log('<b>Error:</b> cannot select user data!');
} else {
    if (!$db->query('UPDATE user SET num_hits=0, num_sitting=0')) {
        $sdl->log('<b>Error:</b> cannot reset sitting information!');
    }
    while ($user = $db->fetchrow($result)) {
        /* 25/08/14 - AC: According to the used query, num_sitting cannot be zero instead num_hits could be */
예제 #2
0
$sdl->finish_job('Mine Job'); // terminates the timer
*/
// ########################################################################################
// ########################################################################################
$sdl->start_job('Extra-Optimal Range Upgrade Planet Step');
$threshold = new DateTime('now');
date_sub($threshold, date_interval_create_from_date_string("45 days"));
$uts_threshold = date_format($threshold, 'U');
$sql = 'UPDATE planets SET planet_available_points = 677 WHERE planet_available_points = 320 AND planet_owner > 10 AND planet_owned_date < ' . $uts_threshold;
$db->query($sql);
$res = $db->num_rows();
if ($res > 0) {
    $sdl->log('Extra-Optimal Range Upgrade Planet this time: ' . $res);
}
$sdl->finish_job('Extra-Optimal Range Upgrade Planet Step');
// ########################################################################################
// ########################################################################################
// Building Scheduler
$sdl->start_job('Building Scheduler');
$sql = 'SELECT planet_id,installation_type
        FROM scheduler_instbuild
        WHERE build_finish <= ' . $ACTUAL_TICK;
if (($q_inst = $db->query($sql)) === false) {
    $sdl->log('<b>Error:</b> Could not query scheduler instbuild data! - SKIPPED');
} else {
    if ($db->num_rows() > 0) {
        while ($build = $db->fetchrow($q_inst)) {
            $recompute_static = in_array($build['installation_type'], array(1, 2, 3, 11)) ? 1 : 0;
            $sql = 'UPDATE planets
                SET building_' . ($build['installation_type'] + 1) . ' = building_' . ($build['installation_type'] + 1) . ' + 1,
예제 #3
0
    exit;
}
if (empty($ACTUAL_TICK)) {
    $sdl->log('Finished Scheduler in ' . round(microtime() + time() - $starttime, 4) . ' secs<br>- Fatal: empty($ACTUAL_TICK) == true');
    exit;
}
/*
Example Job:

$sdl->start_job('Mine Job');

do something ... during error / message:
  $sdl->log('...');
best also - before, so it's apart from the other messages, also: $sdl->log('- this was not true');

$sdl->finish_job('Mine Job'); // terminates the timer
*/
// ########################################################################################
// ########################################################################################
// Moves Scheduler
$sdl->start_job('Moves Scheduler');
include 'moves_main.php';
$sdl->finish_job('Moves Scheduler');
// ########################################################################################
// ########################################################################################
// Quit and close log
$db->close();
$sdl->log('<b>Finished Scheduler in <font color=#009900>' . round(microtime() + time() - $starttime, 4) . ' secs</font><br>Executed Queries: <font color=#ff0000>' . $db->i_query . '</font></b>');
?>

예제 #4
0
    exit;
}
/*
Example Job:

$sdl->start_job('Mine Job');

do something ... during error / message:
  $sdl->log('...');
best also - before, so it's apart from the other messages, also: $sdl->log('- this was not true');

$sdl->finish_job('Mine Job'); // terminates the timer
*/
$sdl->start_job('Recalculate resources');
$db->query('UPDATE planets SET recompute_static=1');
$sdl->finish_job('Recalculate resources');
$sdl->start_job('Recalculate security forces');
$sql = 'SELECT u.user_id FROM user u WHERE u.user_active=1';
$count = 0;
if (!($q_user = $db->query($sql))) {
    $sdl->log('<b>Error:</b> could not query user data');
}
while ($user = $db->fetchrow($q_user)) {
    $sql = 'SELECT planet_id, planet_owner_enum FROM planets WHERE planet_owner=' . $user['user_id'] . ' ORDER BY  planet_owned_date ASC, planet_id ASC';
    if (!($q_planet = $db->query($sql))) {
        $sdl->log('<b>Error:</b> could not query user data');
    }
    $i = 0;
    while ($planet = $db->fetchrow($q_planet)) {
        if ($planet['planet_owner_enum'] != $i) {
            $count++;
예제 #5
0
        $limit['user_points'] = 2000;
    } elseif ($limit['user_points'] <= 2000) {
        $limit['user_points'] = 2000;
    }
    // Who is ABOVE the threshold can have only five colony ship at a time!!!
    $sql = 'UPDATE user SET user_max_colo = 5 WHERE user_points > ' . $limit['user_points'];
    if (!$db->query($sql)) {
        $sdl->log('<b>Error:</b> Cannot set user_max_colo to 5! CONTINUED');
    }
    //Who is equal to or smaller than the threshold, can do as many colony ship as he want!!!
    $sql = 'UPDATE user SET user_max_colo = 0 WHERE user_points <= ' . $limit['user_points'];
    if (!$db->query($sql)) {
        $sdl->log('<b>Error:</b> Cannot set user_max_colo to 0! CONTINUED');
    }
}
$sdl->finish_job('Recalculate colony ship limits');
// #######################################################################################
// #######################################################################################
// Check of miners available on Borg planets
$sdl->start_job('Check miners on Borg planets');
$mines_upgraded = 0;
$miners = array();
$mines_level = array();
$borg = new NPC($db, $sdl);
$borg->LoadNPCUserData(BORG_USERID);
// We need many infos here, for StartBuild() function
$sql = 'SELECT planet_id, planet_type,
               building_1, building_2, building_3, building_4, building_5,
               building_6, building_7, building_8, building_9, building_10,
               building_11, building_12, building_13,
               resource_1, resource_2, resource_3, resource_4