/** * Checks if a user has the rights to view this page, is not locked/banned or not logged in * * @param string $name - permission name */ function auth($name) { locked(); // stop blocked people from acessing if (!$this->loggedIn()) { // if not authorised/logged in set_error('Please login to Echelon'); sendLogin(); exit; } if (!$this->reqLevel($name)) { // if users level is less than needed access, deny entry, and cause error set_error('You do not have the correct privilages to view that page'); sendHome(); exit; } }
require 'inc.php'; if (!$mem->loggedIn()) { // if not logged in checkBL(); } // check the blacklist for the users IP ##### start script ##### if ($mem->loggedIn()) { ## if logged in users may skip this page sendHome(); // send to the index/home page } elseif ($_POST['f-name']) { ## if this is a log in request // if over the maxium amount of wrong attempts, // or if hack attempts detected, BL user IP and remove user locked(); // set sent vars $username = cleanvar($_POST['f-name']); // strip and remove spaces from vars $pw = $_POST['f-pw']; $game_input = cleanvar($_POST['f-game']); // are they empty values emptyInput($username, 'username'); emptyInput($pw, 'password'); if (!verifyFormTokenLogin('login')) { // verify token wrong(1); // plus 1 to wrong counter hack(1); // plus 1 to hack counter writeLog('Login - Bad Token');
public function run($max, $class = null) { $lck = 'logic.push.running'.(is_null($class)?'.mix':'.'.$class); $MT = ini('service.push.mthread'); if (!$MT && locked($lck)) { return array('status' => 'error', 'msg' => 'locked'); } $MT || locked($lck, true); ignore_user_abort(1); set_time_limit(0); $safe_time = 0; $max_time = ini_get('max_execution_time'); if ($max_time > 0) { $safe_time = $max_time; } $time_start = time(); $ix = 0; $rps = array(); while ($ix < $max) { $qhandler = dbc(DBCMax)->select('push_queue'); $class && $qhandler->where(array('type' => $class)); $qhandler->where(array('worked' => 'idle', 'rund' => 'false')); $qhandler->order('pr.desc'); $queue = $qhandler->limit(1)->done(); if ($queue) { $guid = (string)microtime(true); $locked_request_time = microtime(true); $signal_busying = dbc(DBCMax)->update('push_queue') ->where(array('id' => $queue['id'], 'worked' => 'idle')) ->data(array('guid' => $guid, 'worked' => 'busying')) ->done(); if ($signal_busying) { $locked_finish_time = microtime(true); $locking_time = $locked_finish_time - $locked_request_time; if ($locking_time < 1) { if (is_numeric($signal_busying) && $signal_busying === 1) { $queuemsg = 'Q:'.$queue['id'].'+'.(string)round($locking_time, 5); $runCode = 'run_'.$queue['type']; $result = $this->$runCode($queue['target'], logic('push')->datapas($queue, 'run'), $queuemsg); $signal_completed = dbc(DBCMax)->update('push_queue') ->where(array('id' => $queue['id'], 'worked' => 'busying')) ->data(array('rund' => 'true', 'worked' => 'completed')) ->done(); if ($signal_completed) { if (dbc(DBCMax)->update('push_queue')->where(array('id' => $queue['id']))->data(array('result' => $result, 'update' => time()))->done()) { $rps['Q:'.$queue['id']] = 'ok:result/'.$result; } else { $rps['Q:'.$queue['id']] = 'error:result/record'; } } else { $rps['Q:'.$queue['id']] = 'error:queue/make-completed'; } $ix ++; if ($safe_time > 0) { if (time() - $time_start > $safe_time) { $rps['Q:'.$queue['id']] = 'error:time/overdue'; break; } } } else { $rps['Q:'.$queue['id']] = 'error:queue/busying-illegal'; } } else { $rps['Q:'.$queue['id']] = 'error:queue/busying-slow'; } } else { $rps['Q:'.$queue['id']] = 'error:queue/make-busying'; } } else { break; } } $this->__clear(); $MT || locked($lck, false); $rps && $this->run_log_error_scan($rps); return array('status' => 'ok', 'pool' => $rps); }
function lock() { file_put_contents(LOCKFILE, time()); } function unlock() { file_put_contents(LOCKFILE, 0); } function locked() { return (bool) file_exists(LOCKFILE) && file_get_contents(LOCKFILE); } ignoraTransazione(); // Controlla se ci sono sessioni avviate // e termina ritornando stato 0 (OK) if (locked()) { echo "#{$task}, {$time} ha provato a partire, ma ha trovato un file di lock.\n"; exit(0); } echo "#{$task}, {$time} sta partendo, ha creato un file di lock.\n"; // Imposta flag di esecuzione (non voglio) lock(); // Ottieni cursore alle prossime email da inviare $coda = MEmail::inCoda($conf['batch_size']); $ok = true; // Per ogni comunicazione in copia foreach ($coda as $_comunicazione) { // 10 minuti per botta! set_time_limit(600); $time = date('d-m-Y H:i:s'); try {