Exemplo n.º 1
0
 /**
  * Perform an update.
  *
  * If enabled (default) this method will send a E_USER_NOTICE about the update.
  *
  * @see setNotice()
  */
 public function perform(DataBackend $backend)
 {
     $isNotice = $this->notice;
     $lock = new Lock(self::UPDATE_LOCK);
     $lock->nonblockingExecuteOnce(function () use($backend, $isNotice) {
         $backend->update();
         if ($isNotice) {
             trigger_error("bav's bank data was updated sucessfully.", E_USER_NOTICE);
         }
     });
 }
Exemplo n.º 2
0
 /**
  * gets lightbulb form
  * @return string HTML div
  */
 public static function getLockForm()
 {
     //get all lightbulbs from db and create button for each
     $lockArray = self::get_appliances_by_type('lock');
     $form = "<div><h2>Locks</h2>";
     foreach ($lockArray as $lockItem) {
         $lock = new Lock($lockItem['applianceId']);
         $onclick = "toggleLock(this); ";
         $button = $lock->getButtonDiv($onclick);
         $form .= "<div>{$button}</div>";
     }
     $form .= "</div>";
     return $form;
 }
Exemplo n.º 3
0
 /**
  * Builds a configured data backend.
  *
  * If configured this method would automatically install the backend. I.e. a first
  * call will take some amount of time.
  *
  * @return DataBackend
  * @throws DataBackendException
  */
 private function buildDataBackend()
 {
     $configuration = ConfigurationRegistry::getConfiguration();
     $backend = $this->makeDataBackend();
     // Installation
     if ($configuration->isAutomaticInstallation() && !$backend->isInstalled()) {
         $lock = new Lock(self::INSTALL_LOCK);
         $lock->executeOnce(function () use($backend) {
             $backend->install();
         });
     }
     // Update hook
     register_shutdown_function(array($this, "applyUpdatePlan"), $backend);
     return $backend;
 }
Exemplo n.º 4
0
 public function processControlMenu()
 {
     if (isset($_REQUEST['main_tab'])) {
         $option = $_REQUEST['main_tab'];
         if ($option === 'lights') {
             echo Lightbulb::getLightBulbForm();
         } elseif ($option === 'locks') {
             echo Lock::getLockForm();
         } elseif ($option === 'thermostat') {
             echo Thermostat::getThermostatForm();
         } else {
             if ($option == 'lightGroups') {
                 echo LightGroup::getLightGroupForm();
             } else {
                 echo "<h3>Undefined Tab Selected</h3>";
             }
         }
         //continue with locks
         //thermostat etc.
         $this->display = FALSE;
     } else {
         $command = escapeshellcmd("python /var/www/python/killall.py");
         shell_exec($command);
         $command = escapeshellcmd("python /var/www/python/clear.py");
         shell_exec($command);
     }
 }
Exemplo n.º 5
0
 function __call($fnName, $args)
 {
     if (in_array($fnName, self::$functionExceptions)) {
         return call_user_func_array(array($this, $fnName), $args);
     }
     //get node (since all private functions require it)
     $node = $args[0] = $this->getNode($args[0]);
     if ($this->fkColumn) {
         $this->baseWhere[$this->fkColumn] = $node[$this->fkColumn];
     }
     //get foreign key to localise lock
     $lockName = 'DbTree-' . $this->table;
     if ($this->fkColumn) {
         $lockName .= '-' . $node[$this->fkColumn];
     }
     $this->__methodExists($fnName);
     Lock::req($lockName, 2);
     $this->db->db->beginTransaction();
     try {
         $return = call_user_func_array(array($this, $fnName), $args);
         $this->db->db->commit();
     } catch (Exception $e) {
         Lock::off($lockName);
         $this->db->db->rollBack();
         throw $e;
     }
     Lock::off($lockName);
     return $return;
 }
Exemplo n.º 6
0
 function __destruct()
 {
     parent::__destruct();
     if ($this->connected) {
         socket_shutdown($this->socket);
         $this->socket = null;
         $this->connected = false;
     }
 }
Exemplo n.º 7
0
 public function read()
 {
     $this->_open('r');
     $lock = new Lock($this);
     $lock->sh();
     if ($this->ttl > 0) {
         if (time() - filemtime($this->fileName) >= $this->ttl) {
             $lock->unlock();
             $this->_close();
             unlink($this->fileName);
             return false;
         }
     }
     $content = false;
     while (!feof($this->handle)) {
         $content .= fread($this->handle, 4012);
     }
     $lock->unlock();
     $this->_close();
     return $content;
 }
Exemplo n.º 8
0
 /**
  *    监测是否过期 删除对用过期信息
  */
 public function check_data()
 {
     $result = Lock::all()->toArray();
     if (!empty($result)) {
         $nowtime = time();
         foreach ($result as $key => $value) {
             if ($value['time'] <= $nowtime) {
                 $this->del_data[$value['contentid']];
             }
         }
     }
 }
Exemplo n.º 9
0
 private function loadVars()
 {
     if (!$this->lock->lock()) {
         return;
     }
     if (!shm_has_var($this->memory, self::SID_VARS)) {
         $this->varNames = [];
         shm_put_var($this->memory, self::SID_VARS, $this->varNames);
     } else {
         $this->varNames = shm_get_var($this->memory, self::SID_VARS);
     }
     $this->lock->unlock();
 }
Exemplo n.º 10
0
 public function fetchRecord()
 {
     try {
         $lock = Lock::acquire('getPendingRecord');
         if (($r = $this->getPendingRecord()) == NULL) {
             throw new fExpectedException('No pending record.');
         }
         $p = $r->getProblem();
         $r->setJudgeStatus(JudgeStatus::WAITING);
         $r->store();
         Lock::release($lock);
         echo json_encode(array('id' => $r->getId(), 'problem_id' => $p->getId(), 'code_language' => $r->getLanguageName(), 'code' => base64_encode($r->getSubmitCode()), 'memoryLimit' => $p->getMemoryLimit(), 'timeLimit' => $p->getTimeLimit(), 'caseScore' => $p->getCaseScore(), 'caseCount' => $p->getCaseCount(), 'Timestamp' => $p->getLastModified()), JSON_NUMERIC_CHECK);
     } catch (fException $e) {
         echo -1;
     }
 }
 public static function lock($log)
 {
     $lock_file = BASE_PATH . '/.lock';
     // check if lock file exists
     if (file_exists($lock_file)) {
         // get pid of locking process
         self::$_PID = file_get_contents($lock_file);
         // check if we locked it by ourselfs
         if (self::$_PID == getmypid()) {
             return TRUE;
         }
         // check if process is still running
         if (self::running()) {
             $log->log(\Psr\Log\LogLevel::INFO, "AIESEC-Customer.io-Connector is still running with pid " . self::$_PID);
             return FALSE;
         } else {
             $log->log(\Psr\Log\LogLevel::ERROR, "AIESEC-Customer.io-Connector died. Please look into this accident and then manually delete the .lock-file");
             die;
         }
     } else {
         // get our own pid
         self::$_PID = getmypid();
         // try to get the lock
         if (file_put_contents($lock_file, self::$_PID) > 0) {
             // sleep 1s
             sleep(1);
             // check that we really got the lock
             if (self::$_PID == file_get_contents($lock_file)) {
                 $log->log(\Psr\Log\LogLevel::INFO, "Process " . self::$_PID . " locked the base directory");
                 return self::$_PID;
             } else {
                 $log->log(Psr\Log\LogLevel::WARNING, "Some process overwrote the lock for process " . self::$_PID);
                 return FALSE;
             }
         } else {
             $log->log(\Psr\Log\LogLevel::ERROR, "Couldn't write lock-file. Please make the base directory writeable for the php process");
         }
     }
 }
Exemplo n.º 12
0
 public static function release_lock($UID, $entity_type, $user)
 {
     // add record to lock table in order to specify that the kbit is no longer locked
     // NOTE: it is recomended to implement the lock in separated class
     if (Lock::is_locked($UID, $entity_type) == false) {
         debugLog::log("<i>[Lock::release_lock]:</i> cannot release lock of [" . $entity_type . "]: " . $UID . " because it is not locked");
         return false;
     }
     if (Lock::is_locked_by_user($UID, $entity_type, $user) == false) {
         debugLog::log("<i>[Lock::release_lock]:</i>cannot release lock of [" . $entity_type . "]: " . $UID . " because it is not locked by the same user");
         return false;
     }
     $dbObj = new dbAPI();
     // disable lock records
     $query = "UPDATE CONTENT_LOCK SET ENABLED = 0 WHERE LOCKED_UID = '" . $UID . "' AND ENTITY_TYPE = '" . $entity_type . "' AND LOCK_STATUS = 'LOCKED' AND ENABLED = 1 ";
     $results = $dbObj->run_query($dbObj->db_get_contentDB(), $query);
     if ($results == false) {
         debugLog::log("<i>[Lock::release_lock]:</i>cannot release lock of [" . $entity_type . "]: " . $UID . " because of database update error");
         return false;
     }
     // add release record
     $query = "INSERT INTO CONTENT_LOCK (LOCKED_UID, ENTITY_TYPE, ENABLED, LOCK_STATUS, USER_ID, CREATION_DATE) VALUES (" . $UID . ", '" . $entity_type . "', 1, 'UNLOCKED', " . $user . ",'" . date("Y-m-d H:i:s") . "')";
     return $dbObj->run_query($dbObj->db_get_contentDB(), $query) == true;
 }
Exemplo n.º 13
0
<?php

require "Lock.php";
$lock = Lock::factory("Dreadlock");
print "Locking...\n";
$lock->lock("ABCD");
$lock->lock("test1");
$lock->lock("test2");
$lock->lock("test3");
print "Locked.\n";
sleep(3);
print "Un-Locking...\n";
$lock->unlock("test");
print "Unlocked.\n";
sleep(3);
test:
print "Locking...\n";
$lock->lock("test");
print "Locked.\n";
sleep(3);
print "Un-Locking.\n";
$lock->unlock("test");
print "Unlocked.\n";
sleep(3);
Exemplo n.º 14
0
<?php

/**
 * The page edit form.
 */
$page->layout = 'admin';
if (!User::require_admin()) {
    $this->redirect('/admin');
}
$lock = new Lock('Webpage', $_GET['page']);
if ($lock->exists()) {
    $page->title = i18n_get('Editing Locked');
    echo $tpl->render('admin/locked', $lock->info());
    return;
} else {
    $lock->add();
}
require_once 'apps/admin/lib/Functions.php';
$wp = new Webpage($_GET['page']);
$f = new Form('post', 'admin/edit');
$f->verify_csrf = false;
if ($f->submit()) {
    $wp->id = $_POST['id'];
    $wp->title = $_POST['title'];
    $wp->menu_title = $_POST['menu_title'];
    $wp->window_title = $_POST['window_title'];
    $wp->access = $_POST['access'];
    $wp->layout = $_POST['layout'];
    $wp->description = $_POST['description'];
    $wp->keywords = $_POST['keywords'];
    $wp->body = $_POST['body'];
Exemplo n.º 15
0
                    <div class="col-md-12">
                        <fieldset>
                            <legend>Locks</legend>
                            <table class="table">
                                <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>Selection</th>
                                        <th>Serial</th>
                                        <th>Address</th>
                                        <th>Model</th>                                        
                                    </tr>
                                </thead>
                                <tbody id='locks'>    
                                    <?php 
$locks = Lock::searchByOwner($_SESSION['identification']);
$counter = 1;
foreach ($locks as $lock) {
    $row = "<tr>" . "<td>" . $counter++ . "</td>" . "<td><input type='radio' name='locks' onchange='showCodes(selectLock())' value='" . $lock->serial() . "'></td>" . "<td>" . $lock->serial() . "</td>" . "<td>" . $lock->address() . "</td>" . "<td>" . $lock->model() . "</td>" . "</tr>";
    echo $row;
}
?>
                                </tbody>
                            </table>
                        </fieldset>
                    </div>
                </div>
            </div>
        </div>
        <div class="section">
            <div class="container">
Exemplo n.º 16
0
<?php

require_once 'class/HelperOfBailiff.php';
require_once 'class/Lock.php';
require_once 'class/LockMaster.php';
require_once 'class/Owner.php';
$owner = new Owner();
$owner->setIsPresent(true);
$owner->setAgrees(false);
$lock = new Lock();
$lock->setIsLocked(true);
$helperOfBailiff = new HelperOfBailiff();
$helperOfBailiff->order($owner, $lock);
echo ' 100: Kas uks on lukus?' . $lock->getIsLocked();
Exemplo n.º 17
0
 /**
  * returns list of terms that are related to object
  * @param {array} $object_UID    array of type array("column_name"=>'DELIVERY_BASE_ID', "value"=>5)
  * @param {string} $link_type     The link type
  * @param {string} $tableName     Table name of the relation which depends on object type, e.g. R_LD2T, R_LK2T.
  * @param  {string} $lang          The required language, if no language is selected all languages will be returned
  * @return {array:terms}                array of terms
  */
 public static function get_related_Kbits($Delivery_UID, $user)
 {
     $NEEDED = array();
     $PROVIDED = array();
     $OTHERS = array();
     // get database name
     if (Lock::is_locked_by_user($Delivery_UID, 'DELIVERY_BASE', $user) == true) {
         $database_name = dbAPI::get_db_name('user');
     } else {
         $database_name = dbAPI::get_db_name('content');
     }
     $dbObj = new dbAPI();
     // get all needed and provide Kbits (as relation objects)
     $query = "SELECT * FROM R_LD2K where ENABLED = 1 AND (DELIVERY_BASE_ID = " . $Delivery_UID . ")";
     $results = $dbObj->db_select_query($database_name, $query);
     for ($i = 0; $i < count($results); $i++) {
         $curr_Kbit = Kbit::get_Kbit_details($results[$i]["KBIT_BASE_ID"], $user);
         if ($results[$i]["LINK_TYPE"] == 'NEEDED') {
             array_push($NEEDED, $curr_Kbit);
         } else {
             if ($results[$i]["LINK_TYPE"] == 'PROVIDED') {
                 array_push($PROVIDED, $curr_Kbit);
             } else {
                 array_push($OTHERS, $curr_Kbit);
             }
         }
     }
     $kbits = array("NEEDED" => $NEEDED, "PROVIDED" => $PROVIDED, "OTHERS" => $OTHERS);
     return $kbits;
 }
Exemplo n.º 18
0
    } else {
        foreach (array_keys($config) as $key) {
            if (isset($_GET[$key])) {
                $config[$key] = $_GET[$key];
            }
        }
    }
    return $config;
}
$config = getParams();
// if requested, clear the lock
if ($config['fix-lock']) {
    if (Lock::release('process_mail_queue')) {
        echo "The lock file was removed successfully.\n";
    }
    exit(0);
}
if (!Lock::acquire('process_mail_queue')) {
    $pid = Lock::getProcessID('process_mail_queue');
    fwrite(STDERR, "ERROR: There is already a process (pid={$pid}) of this script running.");
    fwrite(STDERR, "If this is not accurate, you may fix it by running this script with '--fix-lock' as the only parameter.\n");
    exit(1);
}
// handle only pending emails
$limit = 50;
Mail_Queue::send('pending', $limit);
// handle emails that we tried to send before, but an error happened...
$limit = 50;
Mail_Queue::send('error', $limit);
Lock::release('process_mail_queue');
Exemplo n.º 19
0
 /**
  * @covers Yeriomin\ConsoleApp\ConsoleApp::getLogFileName
  */
 public function testGetLogFileName()
 {
     $object1 = new ConsoleAppMock();
     $pathDefault = $this->invokeMethod($object1, 'getTempFileName', array('log'));
     $this->assertEquals(realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'consoleAppMock.log', $pathDefault);
     $testDir = '/tmp/console-app-test-dir';
     mkdir($testDir);
     $config2 = array('oneInstanceOnly' => false, 'logDir' => $testDir);
     $this->writeConfig($config2);
     Lock::getInstance()->unlock();
     $_SERVER['argv'] = self::$argvWithConfig;
     $object2 = new ConsoleAppMock();
     $pathWithDir = $this->invokeMethod($object2, 'getTempFileName', array('log'));
     $this->assertEquals(realpath($testDir) . DIRECTORY_SEPARATOR . 'consoleAppMock.log', $pathWithDir);
     $testFile = '/tmp/console-app-test-file.log';
     $config3 = array('oneInstanceOnly' => false, 'logFile' => $testFile);
     $this->writeConfig($config3);
     Lock::getInstance()->unlock();
     $object3 = new ConsoleAppMock();
     $pathWithFile = $this->invokeMethod($object3, 'getTempFileName', array('log'));
     $this->assertEquals($testFile, $pathWithFile);
     unlink($pathWithDir);
     rmdir($testDir);
 }
Exemplo n.º 20
0
} else {
    trigger_error("AIESEC-Customer.io-Connector is missing a config file", E_USER_ERROR);
    die;
}
// instantiate KLogger (we don't catch anything here, because we can not do anything about it)
$log = new \Katzgrau\KLogger\Logger(LOG, LOGLEVEL);
$log->log(\Psr\Log\LogLevel::INFO, "AIESEC-Customer.io-Connector is starting.");
// try to get lock
$pid = Lock::lock($log);
// check if we got the lock
if ($pid < 1) {
    // there is a problem or another process running. Shutdown...
    $log->log(\Psr\Log\LogLevel::INFO, "AIESEC-Customer.io-Connector didn't got the lock. This instance is shutting down...");
} else {
    // we got the lock, so check that data directory is writeable
    if (!file_exists('./data') || !is_writeable('./data')) {
        die("data directory must be writeable");
    }
    //try to run the core and sync once
    try {
        $core = new Core($log);
        if ($core) {
            $core->run();
        }
    } catch (Exception $e) {
        // catch all Exception to release the lock before dying.
        $log->log(\Psr\Log\LogLevel::ERROR, "We encountered an unhandled Exception: " . $e->getMessage(), (array) $e->getTrace());
    }
    // unlock the base directory
    Lock::unlock($log);
}
Exemplo n.º 21
0
 public static function remove_Kbit_from_delivery($Kbit_UID, $Delivery_UID, $link_type, $user)
 {
     if (Lock::is_locked_by_user($Delivery_UID, 'DELIVERY_BASE', $user) == false) {
         debugLog::log("<i>[delivery.php:remove_term_from_Delivery]</i> Delivery (" . $Delivery_UID . ") is not locked by the user (" . $user . ")");
         return null;
     }
     $locking_user = Lock::get_locking_user($UID, 'KBIT_BASE');
     if ($locking_user != null && $locking_user["UID"] != $user) {
         debugLog::log("<i>[delivery.php:add_Kbit_to_delivery]</i> Kbit(" . $Kbit_UID . ") is locked by other user(" . $locking_user["UID"] . ")");
         return null;
     }
     return D2KRelation::remove_D2K_relation($Kbit_UID, $Delivery_UID, $link_type, 'user');
 }
Exemplo n.º 22
0
assertEquals("ș'aibă", FlexStringUtil::placeAccent("șaibă", 2, 'a'));
assertEquals("ș'aibă", FlexStringUtil::placeAccent("șaibă", 3, 'a'));
assertEquals("șa'ibă", FlexStringUtil::placeAccent("șaibă", 2, 'i'));
assertEquals("șa'ibă", FlexStringUtil::placeAccent("șaibă", 3, 'i'));
assertEquals("unfuckingbelievable", FlexStringUtil::insert("unbelievable", "f*****g", 2));
assertEquals("abcdef", FlexStringUtil::insert("cdef", "ab", 0));
assertEquals("abcdef", FlexStringUtil::insert("abcd", "ef", 4));
assertEquals('mamă      ', AdminStringUtil::padRight('mamă', 10));
assertEquals('mama      ', AdminStringUtil::padRight('mama', 10));
assertEquals('ăâîșț   ', AdminStringUtil::padRight('ăâîșț', 8));
assertEquals('ăâîșț', AdminStringUtil::padRight('ăâîșț', 5));
assertEquals('ăâîșț', AdminStringUtil::padRight('ăâîșț', 3));
assertEqualArrays(array('c', 'a', 'r'), AdminStringUtil::unicodeExplode('car'));
assertEqualArrays(array('ă', 'a', 'â', 'ș', 'ț'), AdminStringUtil::unicodeExplode('ăaâșț'));
assertEqualArrays(array(1, 5, 10), util_intersectArrays(array(1, 3, 5, 7, 9, 10), array(1, 2, 4, 5, 6, 8, 10)));
assertEqualArrays(array(), util_intersectArrays(array(2, 4, 6, 8), array(1, 3, 5, 7)));
assert(!Lock::release('test'));
assert(!Lock::exists('test'));
assert(Lock::acquire('test'));
assert(Lock::exists('test'));
assert(!Lock::acquire('test'));
assert(Lock::release('test'));
assert(!Lock::exists('test'));
assert(!Lock::release('test'));
assertEquals(0, util_findSnippet(array(array(1, 2, 10))));
assertEquals(1, util_findSnippet(array(array(1, 2, 10), array(5, 6, 9))));
assertEquals(2, util_findSnippet(array(array(1, 2, 10), array(5, 6, 8))));
assertEquals(4, util_findSnippet(array(array(1, 2, 10), array(6, 20), array(8, 15))));
assertEquals('$abc$ @def@', AdminStringUtil::formatLexem('$abc$ @def@'));
// This is intentional -- lexem formatting is very lenient.
assertEquals("m'amă m'are", AdminStringUtil::formatLexem("m'am~a máre  "));
Exemplo n.º 23
0
 /**
  * @see CommonGLPI::getTabNameForItem()
  *
  * @param $item               CommonGLPI object
  * @param $withtemplate        (default 0)
  **/
 function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     if ($item->isDynamic() && $item->canCreate()) {
         return Lock::getTypeName(2);
     }
     return '';
 }
Exemplo n.º 24
0
 /**
  * Sets the lock instance for this caller
  *
  * @param \BeatSwitch\Lock\Lock $lock
  * @throws \BeatSwitch\Lock\InvalidLockInstance
  */
 public function setLock(Lock $lock)
 {
     // Make sure that the subject from the given lock instance is this object.
     if ($lock->getSubject() !== $this) {
         throw new InvalidLockInstance('Invalid Lock instance given for current object.');
     }
     $this->lock = $lock;
 }
Exemplo n.º 25
0
$id = isset($this->params[0]) ? $this->params[0] : (isset($data['id']) ? $data['id'] : false);
if (isset($data['id'])) {
    $fallback_id = isset($data['fallback']) ? $data['fallback'] : false;
}
if (!$id) {
    if (User::require_acl('admin', 'admin/edit', 'blocks')) {
        echo $tpl->render('blocks/editable', (object) array('id' => $id, 'locked' => false));
    }
    return;
}
$level = isset($data['level']) && preg_match('/^h[1-6]$/', $data['level']) ? $data['level'] : 'h3';
$lock = new Lock('Block', $id);
$b = new Block($id);
if ($b->error) {
    if ($fallback_id) {
        $lock = new Lock('Block', $fallback_id);
        $b = new Block($fallback_id);
        $b->new_id = $id;
    }
    if ($b->error) {
        if (User::require_acl('admin', 'admin/edit', 'blocks')) {
            $fallback_id = $id;
            echo $tpl->render('blocks/editable', (object) array('id' => $fallback_id, 'locked' => false, 'title' => false));
        }
        return;
    }
}
// permissions
if ($b->access !== 'public') {
    if (!User::require_login()) {
        return;
Exemplo n.º 26
0
                $triggered_issues[] = $issue;
            }
        }
        if (count($issues) > 0) {
            foreach ($issues as $issue) {
                if (Reminder::isDebug()) {
                    echo "  - Processing issue '" . $issue . "'\n";
                }
                // only perform one action per issue id
                if (in_array($issue, $triggered_issues)) {
                    if (Reminder::isDebug()) {
                        echo "  - Ignoring issue '" . $issue . "' because it was found in the list of already triggered issues\n";
                    }
                    continue;
                }
                $triggered_issues[] = $issue;
                if (Reminder::isDebug()) {
                    echo "  - Triggered Action '" . $action['rma_title'] . "' for issue #" . $issue . "\n";
                }
                Reminder_Action::perform($issue, $reminder, $action);
            }
        } else {
            if (Reminder::isDebug()) {
                echo "  - No triggered issues for action '" . $action['rma_title'] . "'\n";
            }
        }
    }
}
// release the lock
Lock::release('check_reminders');
Exemplo n.º 27
0
 public static function delete($serial)
 {
     $query = "delete from Locks where serial = '" . $serial . "'";
     return Lock::exec($query);
 }
Exemplo n.º 28
0
// | 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:                           |
// |                                                                      |
// | Free Software Foundation, Inc.                                       |
// | 51 Franklin Street, Suite 330                                        |
// | Boston, MA 02110-1301, USA.                                          |
// +----------------------------------------------------------------------+
// | Authors: Bryan Alsdorf <*****@*****.**>                          |
// +----------------------------------------------------------------------+
ini_set('memory_limit', '1024M');
require_once dirname(__FILE__) . '/../init.php';
// if requested, clear the lock
if (in_array('--fix-lock', $argv)) {
    if (Lock::release('truncate_mail_queue')) {
        echo "The lock file was removed successfully.\n";
    }
    exit(0);
}
if (!Lock::acquire('truncate_mail_queue')) {
    $pid = Lock::getProcessID('truncate_mail_queue');
    fwrite(STDERR, "ERROR: There is already a process (pid={$pid}) of this script running.");
    fwrite(STDERR, "If this is not accurate, you may fix it by running this script with '--fix-lock' as the only parameter.\n");
    exit(1);
}
Mail_Queue::truncate();
Lock::release('truncate_mail_queue');
Exemplo n.º 29
0
<?php

/**
 * Lists all content blocks for editing.
 */
$page->layout = 'admin';
$this->require_acl('admin', 'blocks');
$limit = 20;
$num = isset($_GET['offset']) ? $_GET['offset'] : 1;
$offset = ($num - 1) * $limit;
$lock = new Lock();
$blocks = Block::query('id, title, access')->order('id asc')->fetch_orig($limit, $offset);
$count = Block::query()->count();
foreach ($blocks as $k => $b) {
    $blocks[$k]->locked = $lock->exists('Block', $b->id);
}
$page->title = __('Content Blocks');
echo $tpl->render('blocks/admin', array('limit' => $limit, 'total' => $count, 'blocks' => $blocks, 'count' => count($blocks), 'url' => '/blocks/admin?offset=%d'));
Exemplo n.º 30
0
if ($cuv) {
    smarty_assign('cuv', $cuv);
    $arr = StringUtil::analyzeQuery($cuv);
    $hasDiacritics = session_user_prefers('FORCE_DIACRITICS') || $arr[0];
    $hasRegexp = $arr[1];
    $isAllDigits = $arr[2];
}
if ($isAllDigits) {
    $d = Definition::get_by_id($cuv);
    if ($d) {
        util_redirect(util_getWwwRoot() . "definitie/{$d->lexicon}/{$d->id}" . ($xml ? '/xml' : ''));
    }
}
if ($text) {
    $searchType = SEARCH_FULL_TEXT;
    if (Lock::exists(LOCK_FULL_TEXT_INDEX)) {
        smarty_assign('lockExists', true);
        $definitions = array();
    } else {
        $words = preg_split('/ +/', $cuv);
        list($properWords, $stopWords) = StringUtil::separateStopWords($words, $hasDiacritics);
        smarty_assign('stopWords', $stopWords);
        $defIds = Definition::searchFullText($properWords, $hasDiacritics);
        smarty_assign('numResults', count($defIds));
        // Show at most 50 definitions;
        $defIds = array_slice($defIds, 0, 500);
        // Load definitions in the given order
        $definitions = array();
        foreach ($defIds as $id) {
            if ($res = Definition::get_by_id($id)) {
                $definitions[] = $res;