Ejemplo n.º 1
0
 private static function getArmyId(Dolumar_Underworld_Models_Mission $mission, Dolumar_Underworld_Models_Army $army, $forceUpdate = false)
 {
     $db = Neuron_DB_Database::getInstance();
     $data = $db->query("\n\t\t\tSELECT\n\t\t\t\tul_a_vid,\n\t\t\t\tul_a_id,\n\t\t\t\tul_a_version\n\t\t\tFROM\n\t\t\t\tunderworld_log_armies\n\t\t\tWHERE\n\t\t\t\tua_id = {$army->getId()}\n\t\t\tORDER BY\n\t\t\t\tul_a_version DESC\n\t\t\tLIMIT 1\n\t\t");
     if ($forceUpdate || count($data) === 0) {
         if (count($data) > 0) {
             $logArmyId = $data[0]['ul_a_id'];
             $version = $data[0]['ul_a_version'] + 1;
         } else {
             $lock = Neuron_Core_Lock::getInstance();
             if ($lock->setLock('underworld_army_id', 1)) {
                 $chk = $db->query("\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\tMAX(ul_a_id) AS id\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\tunderworld_log_armies\n\t\t\t\t\t");
                 $logArmyId = intval($chk[0]['id']) + 1;
                 $version = 1;
                 $lock->releaseLock('underworld_army_id', 1);
             }
         }
         $id = self::createArmy($mission, $army, $logArmyId, $version);
     } else {
         $id = $data[0]['ul_a_vid'];
     }
     return $id;
 }
Ejemplo n.º 2
0
<?php

session_write_close();
$action = isset($_GET['action']) ? $_GET['action'] : null;
$lockid = isset($_GET['lock']) ? $_GET['lock'] : time();
if ($action == 'lock') {
    $lock = Neuron_Core_Lock::getInstance('test');
    if ($lock->setLock('test', $lockid)) {
        usleep(2 * 1000000);
        echo 'Here I am!';
        usleep(2 * 1000000);
        $lock->releaseLock('test', $lockid);
    } else {
        echo 'Was locked :(';
    }
    echo '<br />Lock ID: ' . $lockid;
} else {
    for ($i = 0; $i < 20; $i++) {
        echo '<iframe src="' . ABSOLUTE_URL . 'test/locks/?action=lock&lock=' . $lockid . '"></iframe>';
    }
}
Ejemplo n.º 3
0
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
require_once 'bootstrap/bootstrap.php';
$lock = Neuron_Core_Lock::getInstance();
if (!defined('CRONJOB_OUTPUT')) {
    define('CRONJOB_OUTPUT', true);
}
if (CRONJOB_OUTPUT) {
    header('Content-type: text/text');
}
function runCronjobFile($file)
{
    if (!CRONJOB_OUTPUT) {
        ob_start();
        include $file;
        ob_end_clean();
    } else {
        echo 'Running ' . $file . "\n";
        echo '----------------------' . "\n";
Ejemplo n.º 4
0
 public function onWin(Dolumar_Underworld_Models_Side $side)
 {
     // Add log
     $lock = Neuron_Core_Lock::getInstance();
     $lockname = 'uw_fin';
     if ($lock->setLock($lockname, $this->getMission()->getId())) {
         // Reload mission, just to be sure
         $mission = Dolumar_Underworld_Mappers_MissionMapper::getFromId($this->getMission()->getId());
         if ($mission) {
             // Logger
             $this->getMission()->getLogger()->win($side);
             // Do whatever we need to do
             $this->winnerBenefits($side);
             // Start removing mission
             $mission->destroy();
             // Release the lock
             $lock->releaseLock($lockname, $this->getMission()->getId());
         }
     }
 }