public function getAllGames()
 {
     $prevDb = $this->cs->setDb('games');
     $seq = $this->cs->get("_design/newFilter/_view/allGames?");
     $lobbies = [];
     date_default_timezone_set("America/New_York");
     $odd = 0;
     foreach ($seq->rows as $row) {
         $keys = $row->key;
         $creator = array_shift($keys);
         $gameName = array_shift($keys);
         $name = array_shift($keys);
         $gameType = array_shift($keys);
         $id = array_shift($keys);
         //               $key = implode($keys,"  ");
         $id = $row->id;
         $dt = $row->value[1];
         $fd = formatDateDiff($dt);
         $myTurn = "";
         $row->value[1] = "created " . formatDateDiff($dt) . " ago";
         //            $row->value[1] = "created a long long time ago";
         $odd ^= 1;
         $lobbies[] = array("odd" => $odd ? "odd" : "", "id" => $id, "gameName" => $gameName, "name" => $name, 'date' => $row->value[1], "id" => $id, "creator" => $creator, "gameType" => $gameType);
     }
     $this->cs->setDb($prevDb);
     return $lobbies;
 }
 public function fetchLobby($last_seq)
 {
     $this->cs->setDb('games');
     $user = Auth::user()['name'];
     if (!$user) {
         header("Content-Type: application/json");
         echo json_encode(['forward' => site_url('/users/login')]);
         return;
     }
     header("Content-Type: application/json");
     //            $lastSeq = $this->wargame_model->getLobbyChanges($user, $last_seq);
     $lastSeq = $this->fetchLobbyChanges($this->cs, $user, $last_seq);
     $this->cs->setDb('games');
     $seq = $this->cs->get("_design/newFilter/_view/getLobbies?startkey=[\"{$user}\",\"hot seat\"]&endkey=[\"{$user}\",\"hot seat\",\"zzzzzzzzzzzzzzzzzzzzzzzz\"]");
     $lobbies = [];
     date_default_timezone_set("America/New_York");
     $odd = 0;
     foreach ($seq->rows as $row) {
         $keys = $row->key;
         $creator = array_shift($keys);
         $gameType = array_shift($keys);
         $gameName = array_shift($keys);
         $name = array_shift($keys);
         $playerTurn = array_shift($keys);
         array_shift($keys);
         $public = array_shift($keys);
         $filename = array_shift($keys);
         $id = $row->id;
         $dt = new DateTime($row->value[1]);
         $thePlayers = $row->value[2];
         $playerTurn = $thePlayers[$playerTurn];
         $gameOver = $row->value[4];
         $currentTurn = $row->value[5];
         $maxTurn = $row->value[6];
         $myTurn = "";
         if ($gameOver === true) {
             $playerTurn = "Game Over";
             $myTurn = "gameOver";
         } else {
             $playerTurn = "{$currentTurn} of {$maxTurn}";
         }
         array_shift($thePlayers);
         $players = implode($thePlayers, " ");
         $row->value[1] = "created " . formatDateDiff($dt) . " ago";
         $odd ^= 1;
         $lobbies[] = array("public" => $public, "odd" => $odd ? "odd" : "", "gameName" => $gameName, "name" => $name, 'timestamp' => $dt->getTimestamp(), 'date' => $row->value[1], "id" => $id, "creator" => $creator, "gameType" => $gameType, "turn" => $playerTurn, "players" => $players, "myTurn" => $myTurn);
     }
     $seq = $this->cs->get("/_design/newFilter/_view/getLobbies?startkey=[\"{$user}\",\"multi\"]&endkey=[\"{$user}\",\"multi\",\"zzzzzzzzzzzzzzzzzzzzzzzz\"]");
     $multiLobbies = [];
     date_default_timezone_set("America/New_York");
     $odd = 0;
     foreach ($seq->rows as $row) {
         $keys = $row->key;
         $creator = array_shift($keys);
         $gameType = array_shift($keys);
         $gameName = array_shift($keys);
         $name = array_shift($keys);
         $playerTurn = array_shift($keys);
         array_shift($keys);
         $public = array_shift($keys);
         $filename = array_shift($keys);
         $id = $row->id;
         $dt = new DateTime($row->value[1]);
         $thePlayers = $row->value[2];
         $playerTurn = $thePlayers[$playerTurn];
         $gameOver = $row->value[4];
         $myTurn = "";
         if ($gameOver === true) {
             $playerTurn = "Game Over";
             $myTurn = "gameOver";
         } else {
             if ($playerTurn == $user) {
                 $playerTurn = "It's Your Turn";
                 $myTurn = "myTurn";
             } else {
                 $playerTurn = "It's " . $playerTurn . "'s Turn";
             }
         }
         array_shift($thePlayers);
         $players = implode($thePlayers, " ");
         $row->value[1] = "created " . formatDateDiff($dt) . " ago";
         $odd ^= 1;
         $multiLobbies[] = array("public" => $public, "odd" => $odd ? "odd" : "", "gameName" => $gameName, "name" => $name, 'timestamp' => $dt->getTimestamp(), 'date' => $row->value[1], "id" => $id, "creator" => $creator, "gameType" => $gameType, "turn" => $playerTurn, "players" => $players, "myTurn" => $myTurn);
     }
     $seq = $this->cs->get("/_design/newFilter/_view/getGamesImIn?startkey=[\"{$user}\"]&endkey=[\"{$user}\",\"zzzzzzzzzzzzzzzzzzzzzzzz\"]");
     $odd = 0;
     $otherGames = array();
     foreach ($seq->rows as $row) {
         $keys = $row->key;
         $you = array_shift($keys);
         $creator = array_shift($keys);
         $name = array_shift($keys);
         $gameName = array_shift($keys);
         $oldGame = array_shift($keys);
         $gameType = array_shift($keys);
         $playerTurn = array_shift($keys);
         $filename = array_shift($keys);
         $id = $row->id;
         $dt = new DateTime($row->value[1]);
         $thePlayers = $row->value[2];
         $playerTurn = $thePlayers[$playerTurn];
         $gameOver = $row->value[3];
         $myTurn = "";
         if ($gameOver === true) {
             $playerTurn = "Game Over";
             $myTurn = "gameOver";
         } else {
             if ($playerTurn == $user) {
                 $playerTurn = "Your";
                 $myTurn = "myTurn";
             }
         }
         array_shift($thePlayers);
         $players = implode($thePlayers, " ");
         $row->value[1] = "created " . formatDateDiff($dt) . " ago";
         $odd ^= 1;
         $otherGames[] = array("odd" => $odd ? "odd" : "", "name" => $name, "gameName" => $gameName, 'timestamp' => $dt->getTimestamp(), 'date' => $row->value[1], "id" => $id, "creator" => $creator, "gameType" => $gameType, "turn" => $playerTurn, "players" => $players, "myTurn" => $myTurn);
     }
     $seq = $this->cs->get("/_design/newFilter/_view/publicGames");
     $odd = 0;
     $publicGames = array();
     foreach ($seq->rows as $row) {
         $keys = $row->key;
         $creator = array_shift($keys);
         $name = array_shift($keys);
         $gameName = array_shift($keys);
         array_shift($keys);
         $gameType = array_shift($keys);
         $playerTurn = array_shift($keys);
         $filename = array_shift($keys);
         $id = $row->id;
         $dt = new DateTime($row->value[1]);
         $thePlayers = $row->value[2];
         $playerTurn = $thePlayers[$playerTurn];
         $myTurn = "";
         if ($playerTurn == $user) {
             $playerTurn = "Your";
             $myTurn = "myTurn";
         }
         array_shift($thePlayers);
         $players = implode($thePlayers, " ");
         $row->value[1] = "created " . formatDateDiff($dt) . " ago";
         $odd ^= 1;
         $publicGames[] = array("odd" => $odd ? "odd" : "", "name" => $name, "gameName" => $gameName, 'timestamp' => $dt->getTimestamp(), 'date' => $row->value[1], "id" => $id, "creator" => $creator, "gameType" => $gameType, "turn" => $playerTurn, "players" => $players, "myTurn" => $myTurn);
     }
     $results = $lastSeq->results;
     $last_seq = $lastSeq->last_seq;
     return compact("lobbies", "multiLobbies", "otherGames", "last_seq", "publicGames");
 }
Exemple #3
0
switch ($appStatus->Status()) {
    case Isapprunning::NotRunning:
        $alreadyRunning = false;
        break;
    case Isapprunning::WasRunning:
        $period = $appStatus->timePeriod();
        $timeperiod = new DateInterval("PT10M");
        if ($period < $timeperiod) {
            // too close to last run about
            $text = "Application execution is too soon after previous run";
            $text = $text . "<br/>Time since last run: " . formatDateDiff($period);
            $mailed = mail($email, "WebMonitor: ERROR SCANNING " . $domain, $text);
            die($text);
        } else {
            $text = "Last run or Web Monitor application did not complete properly";
            $text = $text . "<br/>Time since last run: " . formatDateDiff($period);
            $mailed = mail($email, "WebMonitor: WARNING SCANNING " . $domain, $text);
            $alreadyRunning = true;
        }
        break;
    case Isapprunning::GaveError:
        $text = $appStatus->ErrorText();
        $mailed = mail($email, "WebMonitor: ERROR SCANNING " . $domain, $text);
        die($text);
        break;
}
if (isset($joomlaFolders)) {
    foreach ($joomlaFolders as $value) {
        if (!isset($skipFolders)) {
            $skipFolders = array($value . "/tmp/");
        } else {
Exemple #4
0
 protected function stats()
 {
     $this->output->outputLine('PHPResque Statistics', 'title');
     $this->output->outputLine();
     $this->output->outputLine('Jobs Stats', 'subtitle');
     $this->output->outputLine("   Processed Jobs : " . Resque_Stat::get('processed'));
     $this->output->outputLine("   Failed Jobs    : " . Resque_Stat::get('failed'), 'failure');
     $this->output->outputLine();
     $this->output->outputLine('Workers Stats', 'subtitle');
     $workers = Resque_Worker::all();
     $this->output->outputLine("   Active Workers : " . count($workers));
     if (!empty($workers)) {
         foreach ($workers as $worker) {
             $this->output->outputLine("\tWorker : " . $worker, 'bold');
             $this->output->outputLine("\t - Started on     : " . Resque::Redis()->get('worker:' . $worker . ':started'));
             $this->output->outputLine("\t - Uptime         : " . formatDateDiff(new \DateTime(Resque::Redis()->get('worker:' . $worker . ':started'))));
             $this->output->outputLine("\t - Processed Jobs : " . $worker->getStat('processed'));
             $worker->getStat('failed') == 0 ? $this->output->outputLine("\t - Failed Jobs    : " . $worker->getStat('failed')) : $this->output->outputLine("\t - Failed Jobs    : " . $worker->getStat('failed'), 'failure');
         }
     }
     $this->output->outputLine("\n");
 }