exit; } // ####################################################################################### // ####################################################################################### // 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('- Notice: Could not update tick_time! CONTINUED'); } /* 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('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
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>'); ?>
if (empty($ACTUAL_TICK)) { $sdl->log('Finished FixAll-Script 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 */ $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 (empty($ACTUAL_TICK)) { $sdl->log('Finished SixHours-Script 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 */ // ####################################################################################### // ####################################################################################### // Ok, now we try to update the user_max_colo $sdl->start_job('Recalculate colony ship limits'); // Activate colony limit only if there are at least 30 players $sql = 'SELECT count(user_id) as num_users FROM user WHERE user_active = 1 AND user_auth_level = ' . STGC_PLAYER; if (!($players = $db->queryrow($sql))) { $sdl->log('<b>Error:</b> Could not query users number! SKIP'); } elseif ($players['num_users'] > 30) { $sql = 'SELECT user_points FROM user ORDER BY user_points DESC LIMIT 30,1'; if (!($limit = $db->queryrow($sql))) { $sdl->log('<b>Error:</b> Could not query user points data! CONTINUED'); $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'];