function action_configurer_dist() { $securiser_action = charger_fonction('securiser_action', 'inc'); $arg = $securiser_action(); # ceinture & bretelles, a priori le test dans exec_configurer # suffit a empecher d'obtenir un hash qui passe le test ci-dessus if(!autoriser('configurer', _request('configuration'))) { include_spip('inc/minipres'); echo minipres(_T('info_acces_interdit')); exit; } $r = rawurldecode(_request('redirect')); $r = parametre_url($r, 'configuration', $arg,"&"); appliquer_modifs_config(); // Cette globale est fixee par appliquer_modifs_config(); // c'est un message a afficher dans l'exec de retour (relayeur si comme ici on est en ajax) if ($arg == 'relayeur') $r = parametre_url($r, 'retour_proxy', $GLOBALS['retour_proxy'],"&"); else if ($arg == 'langue') { include_spip('inc/rubriques'); calculer_langues_rubriques(); } if (_request('envoi_now')) cron(0, array('mail' => -1)); redirige_par_entete($r); }
function exec_configurer_iecompat() { $securiser_action = charger_fonction('securiser_action', 'inc'); $arg = $securiser_action(); $r = rawurldecode(_request('redirect')); $r = parametre_url($r, 'configuration', $arg,"&"); appliquer_modifs_config(); // Cette globale est fixee par appliquer_modifs_config(); // c'est un message a afficher dans l'exec de retour (relayeur si comme ici on est en ajax) if ($arg == 'relayeur') $r = parametre_url($r, 'retour_proxy', $GLOBALS['retour_proxy'],"&"); else if ($arg == 'langue') { include_spip('inc/rubriques'); calculer_langues_rubriques(); } if (_request('envoi_now')) cron(0, array('mail' => -1)); redirige_par_entete($r); }
function action_cron() { include_spip('inc/headers'); http_status(204); // No Content header("Connection: close"); define('_DIRECT_CRON_FORCE', true); cron(); }
// cf. public/assembler.php) echo pipeline('affichage_final' . _PIPELINE_SUFFIX, $page['texte']); if ($lang) { lang_select(); } // l'affichage de la page a pu lever des erreurs (inclusion manquante) // il faut tester a nouveau $debug = (_request('var_mode') == 'debug' or $tableau_des_temps) ? array(1) : array(); // Appel au debusqueur en cas d'erreurs ou de demande de trace // at last if ($debug) { // en cas d'erreur, retester l'affichage if ($html and ($affiche_boutons_admin or $debug)) { $var_mode_affiche = _request('var_mode_affiche'); $GLOBALS['debug_objets'][$var_mode_affiche][$var_mode_objet . 'tout'] = $var_mode_affiche == 'validation' ? $page['texte'] : ""; echo erreur_squelette(false); } } else { if (isset($GLOBALS['meta']['date_prochain_postdate']) and $GLOBALS['meta']['date_prochain_postdate'] <= time()) { include_spip('inc/rubriques'); calculer_prochain_postdate(true); } // Effectuer une tache de fond ? // si _DIRECT_CRON_FORCE est present, on force l'appel if (defined('_DIRECT_CRON_FORCE')) { cron(); } // sauver le cache chemin si necessaire save_path_cache(); } }
// Close connection to browser before running shutdown function header("Pragma: public"); header("Content-Type: text/plain; name=\"cron.txt\""); header("Content-Disposition: inline; filename=\"cron.txt\""); header("Cache-Control: no-store"); header("Connection: close"); ob_start(); // Status report requested? if (isset($_GET['status'])) { echo "Cron is " . (file_exists($exitFile) ? 'waiting to exit' : (file_exists($pidFile) ? '' : 'not ') . 'running') . ".\r\n"; exit; } else { echo "Starting cron from a web server environment.\r\n"; } // Start cron cron($cronFile, $pidFile, $exitFile, $stderrFile, $reportType, $adminEmail, isset($_GET['force']), isset($_GET['kill'])); } exit; // Class representing a single cronjob // Rules for crontab file format and scheduling conditions taken from: // http://en.wikipedia.org/wiki/Cron class CronJob { public $minutes; public $hours; public $dates; public $months; public $weekdays; public $job; public $name; public function __construct($jobText)
function living_temp() { cron(); }
/** * create one test case * * @param integer $case * @param integer $stopcase * @return boolean true after last case */ function create_case($case, $stopcase) { global $date, $login, $ngroup; $stop = 0; $branch = 0; static $branch1 = 0; $casedesc = $case." (".$stopcase."/".$branch1.")"; echo "Test case ".$casedesc."\n"; Login::$member = $login; // create period if ($stopcase == ++$stop) { // period without ballot voting $sql = "INSERT INTO period (debate, preparation, voting, ballot_assignment, ballot_preparation, counting, ballot_voting, ngroup) VALUES ( now(), now() + interval '1 week', now() + interval '2 weeks', NULL, NULL, now() + interval '4 weeks', false, ".$ngroup->id." )"; DB::query($sql); return; } else { // period with ballot voting $sql = "INSERT INTO period (debate, preparation, voting, ballot_assignment, ballot_preparation, counting, ballot_voting, ngroup, postage) VALUES ( now(), now() + interval '1 week', now() + interval '2 weeks', now() + interval '1 week', now() + interval '3 weeks', now() + interval '4 weeks', true, ".$ngroup->id.", true ) RETURNING id"; $result = DB::query($sql); $row = DB::fetch_row($result); $period = new Period($row[0]); } ${'branch'.++$branch.'_array'} = array(0, 5, 15); $ballot_count = ${'branch'.$branch.'_array'}[${'branch'.$branch}]; for ( $i=1; $i<=$ballot_count; $i++ ) { // create a ballot $ballot = new Ballot; $ballot->ngroup = $ngroup->id; $ballot->name = "Test ballot ".$casedesc; $ballot->agents = "Test agents"; $ballot->period = $period->id; $ballot->opening = "8:00"; $ballot->create(); // add participants for ( $j=1; $j<=$i-1; $j++ ) { add_participant($period, $ballot, $case, "a".$ballot_count."i".$i."j".$j); } } // add postal voters for ( $j=1; $j<=10; $j++ ) { add_participant($period, true, $case, "a".$ballot_count."i0j".$j); } if ($stopcase == ++$stop) return; // approve ballots with 10 or more participants $sql = "SELECT * FROM ballot WHERE period=".intval($period->id); $result = DB::query($sql); while ( $ballot = DB::fetch_object($result, "Ballot") ) { if ($ballot->voters < 10) continue; $ballot->approved = true; $ballot->update(["approved"]); } if ($stopcase == ++$stop) return; // add further participants without assigning them to ballots for ($i=1; $i<=100; $i++) { add_participant($period, null, $case, "t".$date."c".$case."i".$i); } // move to phase "ballot_assignment" time_warp($period, "1 week"); cron(); if ($stopcase == ++$stop) return; // move to phase "ballot_preparation" time_warp($period, "2 weeks"); cron(); // continue with next case if branches are still available for ($i=1; $i<=$branch; $i++) { if (isset(${'branch'.$i.'_array'}[++${'branch'.$i}])) { for ($j=1; $j<$i; $j++) ${'branch'.$j}=0; return true; } } // end of last case return "end"; }
/** * create one test case * * @param integer $case * @param integer $stopcase * @return mixed null after one stopcase, false after one branchcase, true after last case */ function create_case($case, $stopcase) { global $bcase, $date, $login, $proposal, $proposal2, $casetitle, $ngroup; $stop = 0; $branch = 0; $casedesc = $case." (stop: ".$stopcase.", branches:"; foreach ($bcase as $value) $casedesc .= " ".$value; $casedesc .= ")"; echo "Test case ".$casedesc."\n"; Login::$member = $login; $proposal = null; $proposal2 = null; $casetitle = ""; // create area $area = new Area; $area->ngroup = $ngroup->id; $area->name = "Test area case ".$casedesc; $area->create(); // create new proposal $proposal = new Proposal; $proposal->title = "Test ".$date." case ".$casedesc; $proposal->content = "Test content"; $proposal->reason = "Test reason"; $proposal->create("Test proponent ".$date." proposal case ".$casedesc, $area->id); $proponents = array(Login::$member); if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { $casetitle = "draft"; return; } $issue = $proposal->issue(); if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { $proposal->remove_proponent(Login::$member); cron(); $casetitle = "remove proponent from draft"; return; } if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { $proposal->remove_proponent(Login::$member); time_warp($issue, "1 week"); cron(); $casetitle = "remove proponent from draft and finally revoke proposal"; return; } if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { $proposal->remove_proponent(Login::$member); add_proponent($proposal, "px"); time_warp($issue, "1 week"); cron(); $casetitle = "remove proponent from draft, add new proponent"; return; } // add proponents for ( $i=2; $i<=REQUIRED_PROPONENTS; $i++ ) { add_proponent($proposal, "pi".$i); $proponents[] = Login::$member; } if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { $casetitle = "draft with proponents"; return; } $proposal->submit(); if ($proposal->state=="submitted") { if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { foreach ($proponents as $proponent) { $proposal->remove_proponent($proponent); } cron(); $casetitle = "remove all proponents from submitted proposal"; return; } if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { foreach ($proponents as $proponent) { $proposal->remove_proponent($proponent); } for ( $i=1; $i<=REQUIRED_PROPONENTS-1; $i++ ) { add_proponent($proposal, "pr".$i); } time_warp($issue, "1 week"); cron(); $casetitle = "remove all proponents from submitted proposal, add less than required new proponents and finally revoke proposal"; return; } if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { foreach ($proponents as $proponent) { $proposal->remove_proponent($proponent); } for ( $i=1; $i<=REQUIRED_PROPONENTS; $i++ ) { add_proponent($proposal, "pr".$i); } time_warp($issue, "1 week"); cron(); $casetitle = "remove all proponents from submitted proposal, add sufficient new proponents"; return; } $required_supporters = $proposal->quorum_required(); ${'branch'.++$branch.'_array'} = array(0, $required_supporters-1, $required_supporters); $supporter_count = ${'branch'.$branch.'_array'}[$bcase[$branch]]; for ( $i=1; $i<=$supporter_count-REQUIRED_PROPONENTS; $i++ ) { add_supporter($proposal, "a".$i); } if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { $casetitle = "alternative proposal with $supporter_count supporters"; return; } if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { time_warp($issue, CANCEL_NOT_ADMITTED_INTERVAL); cron(); $casetitle = "cancel long time not admitted proposal"; return; } // create alternative proposal $proposal2 = new Proposal; $proposal2->title = "Test ".$date." alternative proposal case ".$casedesc; $proposal2->content = "Test content"; $proposal2->reason = "Test reason"; $proposal2->issue = $proposal->issue; $proposal2->create("Test proponent ".$date." alternative proposal case ".$casedesc, $area->id); $proponents = array(Login::$member); if ($stopcase == ++$stop) { $casetitle = "alternative draft"; return; } // add proponents for ( $i=1; $i<=4; $i++ ) { add_proponent($proposal2, "qi".$i); $proponents[] = Login::$member; } if ($stopcase == ++$stop) { $casetitle = "alternative draft with proponents"; return; } $proposal2->submit(); if ($proposal2->state=="submitted" and $stopcase == ++$stop) { foreach ($proponents as $proponent) { $proposal2->remove_proponent($proponent); } cron(); $casetitle = "remove all proponents from submitted alternative proposal"; return; } $required_supporters = $proposal2->quorum_required(); ${'branch'.++$branch.'_array'} = array(0, $required_supporters-1, $required_supporters); $supporter_count2 = ${'branch'.$branch.'_array'}[$bcase[$branch]]; for ( $i=1; $i<=$supporter_count2; $i++ ) { add_supporter($proposal2, "a".$i); } if ($stopcase == ++$stop) { $casetitle = "alternative proposal with $supporter_count2 supporters"; return; } if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { time_warp($issue, CANCEL_NOT_ADMITTED_INTERVAL); cron(); $casetitle = "cancel long time not admitted alternative proposal"; return; } if ($proposal->state=="admitted" or $proposal2->state=="admitted") { // create period $sql = "INSERT INTO period (debate, preparation, voting, counting, ballot_voting, ngroup) VALUES ( now() + interval '1 week', now() + interval '2 weeks', now() + interval '3 weeks', now() + interval '4 weeks', false, ".$ngroup->id." ) RETURNING id"; $result = DB::query($sql); $row = DB::fetch_row($result); $period = $row[0]; // assign issue to period $issue->period = $period; /** @var $issue Issue */ $issue->update(["period"]); // assigned, but not yet started cron(); if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { $casetitle = "assigned issue"; return; } // move on to state "debate" time_warp($issue, "1 week"); cron(); $votingmode_required = $issue->quorum_votingmode_required(); ${'branch'.++$branch.'_array'} = array(0, $votingmode_required-1, $votingmode_required); $votingmode_demanders_count = ${'branch'.$branch.'_array'}[$bcase[$branch]]; for ( $i=1; $i<=$votingmode_demanders_count; $i++ ) { add_votingmode_demander($proposal2, "a".$i); } if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { $casetitle = "issue with $votingmode_demanders_count offline voting demanders"; return; } $proposal2->read(); ${'branch'.++$branch.'_array'} = array(false, true); if ( ${'branch'.$branch.'_array'}[$bcase[$branch]] and $proposal2->state!="cancelled" ) { // remove all proponents from alternative proposal during debate foreach ($proponents as $proponent) { $proposal2->remove_proponent($proponent); } } // move on to state "preparation" time_warp($issue, "1 week"); cron(); if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { $casetitle = "issue in voting preparation state"; return; } // move on to state "voting" time_warp($issue, "1 week"); cron(); if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { $casetitle = "issue in voting state"; return; } // random votes random_votes($issue); // move on to state "counting" and then "finished" time_warp($issue, "1 week"); cron(); if (no_branch_skip($branch, $bcase) and $stopcase == ++$stop) { $casetitle = "issue in finished state"; return; } // move on to cleared time_warp($issue, CLEAR_INTERVAL); cron(); $casetitle = "issue finished and cleared"; } else { $casetitle = "no admitted proposal"; } } else { $casetitle = "proposal not submitted"; } // continue with next case if branches are still available for ($i=1; $i<=$branch; $i++) { if (isset(${'branch'.$i.'_array'}[++$bcase[$i]])) { for ($j=1; $j<$i; $j++) $bcase[$j]=0; return true; } } // end of last case return "end"; }
function main() { switch ($_GET["get"]) { case "stations": connectDB(); echo json_encode(getStations($_GET["lat"], $_GET["lng"], $_GET["radius"])); break; case "station": connectDB(); echo json_encode(getStation($_GET["id"])); break; case "cron": global $cronjob_key; if ($_GET["key"] == $cronjob_key) { cron(); } break; case "info": connectDB(); getInfo(true); break; default: header("Location: https://github.com/xXSparkeyy/harbour-spritradar"); } }
function action_editer_site_dist($arg=null) { if (is_null($arg)){ $securiser_action = charger_fonction('securiser_action', 'inc'); $arg = $securiser_action(); } $resyndiquer = false; include_spip('inc/filtres'); // pour vider_url() if (preg_match(',options/(\d+),',$arg, $r)) { $id_syndic = $r[1]; $resyndiquer = editer_site_options($id_syndic); // Envoi depuis le formulaire d'edition d'un site existant } else if ($id_syndic = intval($arg)) { // reload si on change une des valeurs de syndication if ( (_request('url_syndic') OR _request('resume') OR _request('syndication')) AND $t = sql_fetsel('url_syndic,syndication,resume', 'spip_syndic', "id_syndic=".sql_quote($id_syndic)) AND ( (_request('url_syndic') AND _request('url_syndic') != $t['url_syndic']) OR (_request('syndication') AND _request('syndication') != $t['syndication']) OR (_request('resume') AND _request('resume') != $t['resume']) ) ) set_request('reload', 'oui'); revisions_sites($id_syndic); // Envoi normal depuis le formulaire de creation d'un site } elseif (strlen(vider_url(_request('url_site'))) AND strlen(_request('nom_site'))) { set_request('reload', 'oui'); $id_syndic = insert_syndic(_request('id_parent')); revisions_sites($id_syndic); if ($logo = _request('logo') AND $format_logo = _request('format_logo')){ include_spip('inc/distant'); @rename(copie_locale($logo), _DIR_IMG . 'siteon'.$id_syndic.'.'.$format_logo); } } // Erreur else { include_spip('inc/headers'); redirige_url_ecrire(); } // Re-syndiquer le site if (_request('reload') == 'oui') { // Effacer les messages si on supprime la syndication if (_request('syndication') == 'non') sql_delete("spip_syndic_articles", "id_syndic=".sql_quote($id_syndic)); $t = sql_getfetsel('descriptif', 'spip_syndic', "id_syndic=$id_syndic AND syndication IN ('oui', 'sus', 'off')", '','', 1); if ($t !== NULL) { // Si descriptif vide, chercher le logo si pas deja la $chercher_logo = charger_fonction('chercher_logo', 'inc'); if (!$logo = $chercher_logo($id_syndic, 'id_syndic', 'on') OR !$t) { if ($auto = vider_url(_request('url_auto'))) { $auto = analyser_site($auto); if (!strlen($t) AND strlen($auto['descriptif'])) revisions_sites($id_syndic, array('descriptif' => $auto['descriptif'])); } if (!$logo AND $auto['logo'] AND $auto['format_logo']) @rename($auto['logo'], _DIR_IMG . 'siteon'.$id_syndic.'.'.$auto['format_logo']); } $resyndiquer = true; } } if ($resyndiquer) { // ah si PHP connaisait les fermetures... // A la place, une constante utilisee exclusivement // dans la fct suivante. define('_GENIE_SYNDIC_NOW', $id_syndic); // forcer l'execution immediate de cette tache // (i.e. appeler la fct suivante avec gestion du verrou) cron(0, array('syndic' => -91)); } if (_request('redirect')) { $redirect = parametre_url(urldecode(_request('redirect')), 'id_syndic', $id_syndic, '&'); include_spip('inc/headers'); redirige_par_entete($redirect); } else return array($id_syndic,''); }
ini_set('display_errors', 1); ini_set('error_reporting', E_ALL); } if (preg_match("#--show#", implode(" ", $argv))) { $GLOBALS["SHOW"] = true; } if ($argv[1] == "--sync") { sync($argv[2]); exit; } if ($argv[1] == "--cron") { cron(); exit; } if ($argv[1] == "--stop") { cron($argv[2]); exit; } if ($argv[1] == "--alltasks") { cronAll(); exit; } die; function stop($id) { $unix = new unix(); $sql = "SELECT * FROM imapsync WHERE ID='{$id}'"; $q = new mysql(); $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup")); if (!$q->ok) { write_syslog("Mysql error {$q->mysql_error}", __FILE__);
function action_cron() { include_spip('inc/headers'); http_status(204); // No Content header("Connection: close"); cron (2); }
#!/usr/bin/php <?php namespace Thin; set_time_limit(false); require_once __DIR__ . DIRECTORY_SEPARATOR . 'init.php'; require_once APPLICATION_PATH . DS . 'Bootstrap.php'; Bootstrap::cli(); if (empty($argv[1])) { exit("L'argument cron n'a pas été livré à l’exécution."); } else { $cron = cron($argv); }
function cron($start = 0, $limit = 70, $schema_id = 0) { global $_db; $where = "WHERE `status` = 'on'"; if ($schema_id > 0) { $where .= " AND schema_id = {$schema_id}"; $start = 0; $limit = 1; } $sql = "SELECT * FROM `schemas` {$where} LIMIT {$start},{$limit}"; $schemas = $_db->get_results($sql); fetch_web($schemas); return count($schemas); } if (is_numeric($_REQUEST['start'])) { echo cron($_REQUEST['start'], $_REQUEST['limit']); } elseif (empty($_REQUEST['start'])) { $total = $_db->get_var("SELECT count(*) FROM `schemas` WHERE `status` = 'on'"); $queue = new SaeTaskQueue("cron_tail"); $array = array(); for ($i = 0; $i <= $total + 70; $i += 70) { $array[] = array('url' => "http://pickcat.sinaapp.com/cron.php", "postdata" => "start={$i}&limit=70"); } $queue->addTask($array); $ret = $queue->push(); if ($ret === false) { var_dump($queue->errno(), $queue->errmsg()); } else { echo 'true'; } }