public static function init()
 {
     tools::log('Initializing gamespy class');
     $handle = opendir('./games/');
     while ($file = readdir($handle)) {
         if ($file != '.' and $file != '..') {
             include_once './games/' . $file;
             $file = substr($file, 0, strlen($file) - 4);
             self::$plugins[$file] = new $file();
         }
     }
     closedir($handle);
 }
 private function disconnect()
 {
     @mysql_close(self::$socket);
     tools::log('disconnected database connection');
 }
Exemple #3
0
 public static function start_log($where)
 {
     $address = explode('/', $_SESSION['current_page']);
     if (!$_SESSION['log_started']) {
         tools::log(date('d.m.Y H:i:s') . ". Hypno start\nDoctor: " . $_SESSION['doctor'] . ". Patient: " . $_SESSION['patient']['character_name']);
         if ($_SESSION['sneaky']) {
             tools::log('*SNEAKY* ', true);
         }
         tools::log('Entered from: ' . $where);
         tools::log($_SESSION['sack']);
         tools::log($address[1] . '/' . $address[2], true);
         $_SESSION['log_started'] = 1;
     } else {
         tools::log(" -> " . $address[1] . '/' . $address[2], true);
     }
 }
        //        Отнимаем хиты
        $_SESSION['exp']['hp'] -= $hit_lost;
        if ($_SESSION['exp']['hp'] <= 0) {
            //            Сдох, определяем пенальти
            $next_page = 'protector_mocks';
            $_SESSION['exp']['penalty'] = $penalties[$scene_color][$scene_epoch];
        } else {
            $_SESSION['exp']['scene_number'] += 1;
            if ($_SESSION['exp']['scene_number'] >= $MAX_SCENES_IN_EXPERIMENT) {
                $next_page = 'protector_respects';
            } else {
                $next_page = $_SESSION['exp']['scenes'][$_SESSION['exp']['scene_number']];
            }
        }
        $_SESSION['current_page'] = 'common/experiment/' . $next_page;
        tools::log("({$scene_color} {$scene_epoch}, select={$select}, hit_lost={$hit_lost}, hit_rest=" . $_SESSION['exp']['hp'] . ")");
        $res = array('success' => true, 'hit_lost' => $hit_lost, 'hit_rest' => $_SESSION['exp']['hp']);
        die(json_encode($res));
        break;
}
if (isset($_REQUEST['s']) || isset($_REQUEST['sf'])) {
    $ses = $_SESSION;
    if (!isset($_REQUEST['sf'])) {
        $ses['athlas_data'] = '*** FILLED ***';
        $ses['players'] = '*** FILLED ***';
        $ses['trigger_pages'] = '*** FILLED ***';
    }
    print_r($ses);
}
if (isset($_REQUEST['decipher_file'])) {
    $dat_file = $MAIN_DIR . $_REQUEST['decipher_file'];
 public function parse_statistics($csocket, $ex, $schallenge, $session)
 {
     // only whitelisted servers are allowed to give us statistics
     //        $query = "SELECT * FROM stats_servers WHERE ip='" . database::esc($this->ip) . "' AND active='1' LIMIT 0,1";
     //        $sql = database::query($query);
     //        if (database::num_rows($sql) == 1) {
     //            $row = database::fetch_object($sql);
     if (in_array('gamedata', $ex)) {
         $data = explode(chr(1), $ex[array_search('gamedata', $ex) + 1]);
         $users = array();
         $server = array();
         $time = time();
         foreach ($data as $key => $value) {
             // 0 => 0   Var
             // 1 => 0,5 Wert
             // 2 => 1   Var
             // 3 => 1,5 Wert
             // if this entry is a variable
             if ($key % 2 === 1) {
                 // user value
                 if (strpos($value, '_') !== FALSE) {
                     $ex3 = explode('_', $value, 2);
                     if (isset($ex3[1]) and isset($data[$key + 1])) {
                         if (isset($users[$ex3[1]])) {
                             $users[$ex3[1]][$ex3[0]] = $data[$key + 1];
                         } else {
                             $users[$ex3[1]] = array();
                             $users[$ex3[1]][$ex3[0]] = $data[$key + 1];
                         }
                     }
                 } else {
                     // server value
                     if (isset($data[$key + 1])) {
                         $server[$value] = $data[$key + 1];
                     }
                 }
             }
         }
         // we have data - round ended :)
         // users array:
         // 0...X => array:
         // finishes => 1
         // player => Kalle
         // deaths => 10
         // playerpoints => 102
         // endfaction => Empire
         // timePlayed => 565
         // kills => 4
         // ctime => 0
         // starts => 1
         // heropoints => 0
         // livingStreak => 0
         // rating_0 => 102
         //
         // server array:
         // winningTeam => Empire
         // gameComplete => 1
         // winningCnt => 2147483622
         // losingCnt => 2147483581
         // gametype => IA
         // losingTeam => Rebels
         // GameMode => 3
         // mapname => spa7c_ass
         // only if more then 3 people are logged in!
         //
         if (count($users) > 0 and count($server) > 0) {
             foreach ($users as $user) {
                 if (isset($user['player']) and isset($user['endfaction']) and isset($user['auth'])) {
                     if (!isset($user['finishes'])) {
                         $user['finishes'] = 0;
                     }
                     if (!isset($user['deaths'])) {
                         $user['deaths'] = 0;
                     }
                     if (!isset($user['playerpoints'])) {
                         $user['playerpoints'] = 0;
                     }
                     if (!isset($user['timePlayed'])) {
                         $user['timePlayed'] = 0;
                     }
                     if (!isset($user['kills'])) {
                         $user['kills'] = 0;
                     }
                     if (!isset($user['ctime'])) {
                         $user['ctime'] = 0;
                     }
                     if (!isset($user['starts'])) {
                         $user['starts'] = 1;
                     }
                     if (!isset($user['heropoints'])) {
                         $user['heropoints'] = 0;
                     }
                     if (!isset($user['livingStreak'])) {
                         $user['livingStreak'] = 0;
                     }
                     if (!isset($user['rating'])) {
                         $user['rating'] = 0;
                     }
                     $user['timestamp'] = $time;
                     //                            $user['sid'] = $row->id;
                     tools::log(print_r($user, true));
                     $this->sql_insertround(array_merge($user, $server));
                 }
             }
             tools::log('gameserver (' . $this->ip . ':' . $this->port . ') statistic updated');
         }
     }
     //        } else {
     //            tools::log('gameserver (' . $this->ip . ':' . $this->port . ') is NOT whitelisted - sorry no statistics...');
     //        }
 }
Exemple #6
0
 public function run()
 {
     try {
         $class = $this->controller . 'Controller';
         require_once _DIR_ . '/app/controller/' . $class . '.php';
         $start = new $class();
         if (isset($start->models) && !empty($start->models)) {
             foreach ($start->models as $model) {
                 include _DIR_ . "/app/model/{$model}.php";
                 $start->{$model} = new $model();
             }
         }
         if (isset($start->libs) && !empty($start->libs)) {
             foreach ($start->libs as $lib) {
                 include _DIR_ . "/app/libs/{$lib}/{$lib}.php";
             }
         }
         $action = is_null($this->action) ? 'index' : $this->action;
         $start->{$action}($this->value);
     } catch (Exception $e) {
         tools::log($e->getMessage(), 'error');
     }
 }
 /**
  * 
  */
 public function loop()
 {
     // socket available
     if ($this->socket !== FALSE) {
         // announce connected clients
         $this->client_announcement();
         // read
         $read = array_merge(array($this->socket), $this->clients);
         $write = [];
         $except = [];
         // if you can read from sockets
         if (socket_select($read, $write, $except, 0, 0) !== FALSE) {
             // read from socket
             $this->read_sockets($read);
         } else {
             // exit if there is an fatal error
             tools::log('FATAL ERROR');
             exit;
         }
         // loop through existing clients
         $this->read_clients($read);
         // delete closed client connections
         $this->clients = array_filter($this->clients);
     }
     return TRUE;
 }
Exemple #8
0
            if ($ldiff > 0) {
				if ($_SESSION['doctor_skills']['quot'])	{
					$ldiff = floor($ldiff*$_SESSION['doctor_skills']['quot']);
					$now = $was + $ldiff;
				}
                $ldiff = '+'.$ldiff;
            }
            echo "<span class=diff>".$now." ($ldiff)";
        }
        echo "</div>";
    }
?>
    <div class=clear></div>
</div>
<? } ?>
<div id=other_results class=roundrect>
    <div class=block_caption style='width: 206px'>ПРОЧИЕ РЕЗУЛЬТАТЫ</div>
    <?
if ($_SESSION['messages'])
    echo "<ul><li>".join("<li>\n", $_SESSION['messages'])."</ul>";
echo "</div>
<br><a style='color: #FFDD00; font-size: 24px;' href='login.php'>Завершить сеанс</a>";
if (!$_SESSION['labels']['extra_awake'])
    tools::log(" -> awake");
if(strpos($_SESSION['current_page'], 'experiment')===FALSE)
    tools::log(json_encode($sack->diff($_SESSION['start_sack'], true)));
if ($_SESSION['messages'])
    tools::log(join("\n", $_SESSION['messages']));
tools::log("\n".date('d.m.Y H:i:s').'. Hypno_end');
tools::log(str_repeat('=',50));
 /**
  * 
  * @param type $ex
  * @return boolean
  */
 public function gs_quiet($ex)
 {
     tools::log('DEBUG quiet: ' . implode('|', $ex));
     return true;
 }