function run_cron_for_game($server_cfg, $game_cfg, $time_slots) { date_default_timezone_set('UTC'); $current_timestamp = $_SERVER['REQUEST_TIME']; // // Logger object has to be passed to all child functions, // put it in the game configuration array // $game_cfg['logger'] = new Logger($server_cfg, $game_cfg); // All metrics are enabled by default if (!array_key_exists("enabled_metrics", $game_cfg)) { $enabled_metrics = array("rightscale_data", "xhprof_blob", "apache_stats", "zmonitor_data", "function_analytics", "slow_page"); } else { $enabled_metrics = $game_cfg["enabled_metrics"]; } // // If time slots are passed as parameter it should be passed // in correct format i.e. {t1,t2},where t1 etc are timeslots, // so that it can be used in glob with BRACE. If there is no // timestamp we assume processing is happening for the current // timeslot. We need the current time slot and the previous one // as we may have crossed the 30 min boundary after the cron // job was launched. // if (empty($time_slots)) { $slot = (int) ($current_timestamp / 1800); $time_slots = sprintf("{%d,%d}", $slot, $slot - 1); } error_log(sprintf("==> Game: %s, time_slots: %s<==\n", $game_cfg["name"], $time_slots), 3, sprintf($server_cfg['log_file'], $game_cfg['name'])); // // we need to look at xhprof uploads only if any of the enabled // metrics need it. // if (in_array("xhprof_blob", $enabled_metrics) || in_array("function_analytics", $enabled_metrics)) { process_xhprof_uploads($server_cfg, $game_cfg, $time_slots); } insert_events($server_cfg, $game_cfg); foreach ($enabled_metrics as $metric) { try { $metric_function = "insert_{$metric}"; // // calls insert_apache_stats // $metric_function($server_cfg, $game_cfg, $time_slots); } catch (Exception $e) { $game_cfg['logger']->log("Cron Run", "Failed to process and \n\t\t\t\t\t\t insert data for {$metric}", Logger::CRIT); error_log("Failed to process and insert data for {$metric}\n", 3, sprintf($server_cfg['log_file'], $game_cfg['name'])); error_log("Exception says: " . $e->getMessage() . "\n", 3, sprintf($server_cfg['log_file'], $game_cfg['name'])); } } }
<!-- insertion de la fonction permettant d'ajouter des utilisateurs à la base de données !--> <?php require 'FonctionsEvent.php'; insert_events(); ?> <h2> Formulaire de création d'événements : </h2> <!-- insertion du formulaire!--> <?php include "Form-Event.html";