本文整理汇总了PHP中unlock函数的典型用法代码示例。如果您正苦于以下问题:PHP unlock函数的具体用法?PHP unlock怎么用?PHP unlock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了unlock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sig_handler
function sig_handler($signo)
{
global $check_file;
switch ($signo) {
case SIGTERM:
case SIGINT:
unlock();
exit;
}
}
示例2: ses
function ses()
{
echo 'Start Notification' . PHP_EOL;
$this->load->library('lib_feedback');
if (is_running() === FALSE) {
lock();
while (TRUE) {
if (is_null($this->lib_feedback->process_notification())) {
show_error($this->lib_feedback->get_error_message());
}
}
unlock();
}
}
示例3: doAction
public function doAction($id, $new_page_id = null)
{
$this->checkPage($id);
$this->saveActivity('delete', $id, $new_page_id, !empty($new_page_id) ? true : false, 'new');
lock($id);
$this->cleanPage($id);
$this->cleanAttic($id);
$this->cleanMeta($id);
$this->cleanMedia($id);
unlock($id);
$this->saveActivity('delete', $id, $new_page_id, !empty($new_page_id) ? true : false, 'finished');
if (!empty($new_page_id)) {
$this->fixForeignPageLinks($id, $new_page_id);
}
}
示例4: campaign
function campaign($count = 99)
{
echo 'Start Campaign' . PHP_EOL;
if (is_running() === FALSE) {
lock();
while (TRUE) {
$campaign_message = $this->lib_request_scheduled->get_latest_campaign();
if (empty($campaign_message)) {
echo 'No task found!' . PHP_EOL;
break;
}
if (is_null($this->lib_request_scheduled->process_campaign($campaign_message, $count))) {
show_error($this->lib_request_scheduled->get_error_message());
}
}
unlock();
}
}
示例5: send
function send($count = 9)
{
echo 'Start send' . PHP_EOL;
$this->load->library('lib_archive');
if (is_running() === FALSE) {
lock();
while (TRUE) {
$messages = $this->lib_archive->get_unsent($count);
if (empty($messages)) {
echo 'No task found!' . PHP_EOL;
break;
}
if (is_null($this->lib_archive->send($messages))) {
show_error($this->lib_archive->get_error_message());
}
}
unlock();
}
}
示例6: handle
public function handle()
{
global $ID;
global $INPUT;
if ($INPUT->has('New')) {
$name = $INPUT->str('New');
if (!$name) {
return 'manage_files';
}
$ID = cleanID(getNS($ID) . ':' . $name);
}
$path = wikiFN($ID);
if (file_exists($path)) {
return 'show';
}
global $TEXT;
$type = strtolower($INPUT->str('type'));
switch ($type) {
case 'generated':
$TEXT = '<generated-file>' . DOKU_LF . '</generated-file>';
break;
case 'source':
$TEXT = '<source-file>' . DOKU_LF . '</source-file>';
break;
case 'project':
$ID .= ':';
return 'show';
default:
return 'edit';
}
saveWikiText($ID, $TEXT, "Created");
unlock($ID);
global $INFO;
$INFO['exists'] = true;
return "show";
}
示例7: start
/**
* Start server.
*/
public function start()
{
log_console('Starting RPC Server at ' . $this->config['ip'] . ' on port ' . $this->config['port']);
$errno = 0;
$err = "";
$this->master = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
// Non block socket type
socket_set_option($this->master, SOL_SOCKET, SO_RCVTIMEO, array("sec" => 10, "usec" => 0));
socket_set_option($this->master, SOL_SOCKET, SO_LINGER, array('l_onoff' => 1, 'l_linger' => 0));
socket_set_option($this->master, SOL_SOCKET, SO_REUSEADDR, 1);
@socket_bind($this->master, $this->config['ip'], $this->config['port']);
while (socket_last_error() === 98) {
log_console("Socket terminated but address already in use, wait 2 sec's and try again.");
sleep(2);
@socket_bind($this->master, $this->config['ip'], $this->config['port']);
}
$listen = socket_listen($this->master);
if ($listen === FALSE) {
unlock();
log_console("Can't listen on socket.");
exit;
}
$this->listen();
}
示例8: array
/*
hotspot_blocklist_edit.php
Copyright (C) 2013-2015 Ogün AÇIK
All rights reserved.
*/
require 'guiconfig.inc';
require 'captiveportal.inc';
require 'local_connection.inc';
$pgtitle = array('HOTSPOT ', 'MAC ADRESİ ENGELLE');
/* Get active captiveportal sessions */
if (file_exists("{$g['vardb_path']}/captiveportal.db")) {
$captiveportallck = lock('captiveportaldb');
$cpcontents = file("{$g['vardb_path']}/captiveportal.db", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
unlock($captiveportallck);
}
if ($connection) {
if ($_GET['act'] == 'new' && is_mac($_GET['mac'])) {
$macFound['mac'] = $_GET['mac'];
}
if ($_GET['act'] == 'edit' && is_mac($_GET['mac'])) {
$mac_addr = $_GET['mac'];
$getInfo = $pdo->prepare("\n\t\t\tSELECT mac_addr AS mac, description\n\t\t\tFROM blocklist\n\t\t\tWHERE mac_addr = :mac\n\t\t");
$getInfo->bindParam(':mac', $mac_addr);
$getInfo->execute();
$macFound = $getInfo->fetch(PDO::FETCH_ASSOC);
if (!$macFound) {
$input_errors[] = "'{$mac_addr}' MAC adresi bulunamadı.";
}
}
示例9: act_auth
/**
* Handle 'login', 'logout'
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function act_auth($act)
{
global $ID;
global $INFO;
//already logged in?
if (isset($_SERVER['REMOTE_USER']) && $act == 'login') {
return 'show';
}
//handle logout
if ($act == 'logout') {
$lockedby = checklock($ID);
//page still locked?
if ($lockedby == $_SERVER['REMOTE_USER']) {
unlock($ID);
}
//try to unlock
// do the logout stuff
auth_logoff();
// rebuild info array
$INFO = pageinfo();
act_redirect($ID, 'login');
}
return $act;
}
示例10: mysql_query
$isValidAddress = $bitcoinController->validateaddress($paymentAddress);
if ($isValidAddress) {
//Subtract TX fee, donation and site fees
$currentBalance = $currentBalance * (1 - $sitepercent / 100) * (1 - $donatepercent / 100) - $txfee;
$paid += $currentBalance;
//Send money//
mysql_query("BEGIN");
try {
//Reduce balance amount to zero
//echo "UPDATE accountBalance SET balance = '0', paid = '$paid' WHERE userId = $userId\n";
mysql_query("UPDATE accountBalance SET balance = '0', paid = '{$paid}' WHERE userId = {$userId}");
if ($bitcoinController->sendtoaddress($paymentAddress, $currentBalance)) {
mysql_query("INSERT INTO payoutHistory (userId, address, amount) VALUES ('" . $resultR->userId . "', '" . $paymentAddress . "', '" . $currentBalance . "')");
mail($resultR->email, "Simplecoin.us Automatic Payout Notification", "Hello,\n\nYour balance of " . $currentBalance . " BTC has exceeded your automatic payment threshold and has been sent to your payment address " . $paymentAddress . ".", "From: Simplecoin.us Notifications <server@simplecoin.us>");
mysql_query("COMMIT");
} else {
mysql_query("ROLLBACK");
echo "Commodity {$currentBalance} failed to send to {$paymentAddress} for userid {$userId}\n";
}
} catch (Exception $e) {
mysql_query("ROLLBACK");
echo "Commodity {$currentBalance} failed to send to {$paymentAddress} for userid {$userId}\n";
}
}
}
}
} catch (Exception $ex) {
echo $ex - getMessage();
}
unlock("money");
示例11: act_auth
/**
* Handle 'login', 'logout'
*
* @author Andreas Gohr <andi@splitbrain.org>
*
* @param string $act action command
* @return string action command
*/
function act_auth($act)
{
global $ID;
global $INFO;
/* @var Input $INPUT */
global $INPUT;
//already logged in?
if ($INPUT->server->has('REMOTE_USER') && $act == 'login') {
return 'show';
}
//handle logout
if ($act == 'logout') {
$lockedby = checklock($ID);
//page still locked?
if ($lockedby == $INPUT->server->str('REMOTE_USER')) {
unlock($ID);
//try to unlock
}
// do the logout stuff
auth_logoff();
// rebuild info array
$INFO = pageinfo();
act_redirect($ID, 'login');
}
return $act;
}
示例12: setLocks
/**
* Locks or unlocks a given batch of pages
*
* Give an associative array with two keys: lock and unlock. Both should contain a
* list of pages to lock or unlock
*
* Returns an associative array with the keys locked, lockfail, unlocked and
* unlockfail, each containing lists of pages.
*/
function setLocks($set)
{
$locked = array();
$lockfail = array();
$unlocked = array();
$unlockfail = array();
foreach ((array) $set['lock'] as $id) {
$id = $this->resolvePageId($id);
if (auth_quickaclcheck($id) < AUTH_EDIT || checklock($id)) {
$lockfail[] = $id;
} else {
lock($id);
$locked[] = $id;
}
}
foreach ((array) $set['unlock'] as $id) {
$id = $this->resolvePageId($id);
if (auth_quickaclcheck($id) < AUTH_EDIT || !unlock($id)) {
$unlockfail[] = $id;
} else {
$unlocked[] = $id;
}
}
return array('locked' => $locked, 'lockfail' => $lockfail, 'unlocked' => $unlocked, 'unlockfail' => $unlockfail);
}
示例13: _sync
/**
* Execute the sync action and print the results
*/
function _sync(&$synclist, $type)
{
if (!$this->_connect()) {
return false;
}
$no = $this->profno;
$sum = $_REQUEST['sum'];
if ($type == 'pages') {
$lock = $this->_lockfiles($synclist);
}
// do the sync
foreach ((array) $synclist as $id => $dir) {
@set_time_limit(30);
if ($dir == 0) {
$this->_listOut($this->getLang('skipped') . ' ' . $id, 'skipped');
continue;
}
if ($dir == -2) {
//delete local
if ($type == 'pages') {
saveWikiText($id, '', $sum, false);
$this->_listOut($this->getLang('localdelok') . ' ' . $id, 'del_okay');
} else {
if (unlink(mediaFN($id))) {
$this->_listOut($this->getLang('localdelok') . ' ' . $id, 'del_okay');
} else {
$this->_listOut($this->getLang('localdelfail') . ' ' . $id, 'del_fail');
}
}
continue;
}
if ($dir == -1) {
//pull
if ($type == 'pages') {
$ok = $this->client->query('wiki.getPage', $id);
} else {
$ok = $this->client->query('wiki.getAttachment', $id);
}
if (!$ok) {
$this->_listOut($this->getLang('pullfail') . ' ' . $id . ' ' . $this->client->getErrorMessage(), 'pull_fail');
continue;
}
$data = $this->client->getResponse();
if ($type == 'pages') {
saveWikiText($id, $data, $sum, false);
} else {
if ($this->apiversion < 7) {
$data = base64_decode($data);
}
io_saveFile(mediaFN($id), $data);
}
$this->_listOut($this->getLang('pullok') . ' ' . $id, 'pull_okay');
continue;
}
if ($dir == 1) {
// push
if ($type == 'pages') {
$data = rawWiki($id);
$ok = $this->client->query('wiki.putPage', $id, $data, array('sum' => $sum));
} else {
$data = io_readFile(mediaFN($id), false);
if ($this->apiversion < 6) {
$data = base64_encode($data);
} else {
$data = new IXR_Base64($data);
}
$ok = $this->client->query('wiki.putAttachment', $id, $data, array('ow' => true));
}
if (!$ok) {
$this->_listOut($this->getLang('pushfail') . ' ' . $id . ' ' . $this->client->getErrorMessage(), 'push_fail');
continue;
}
$this->_listOut($this->getLang('pushok') . ' ' . $id, 'push_okay');
continue;
}
if ($dir == 2) {
// remote delete
if ($type == 'pages') {
$ok = $this->client->query('wiki.putPage', $id, '', array('sum' => $sum));
} else {
$ok = $this->client->query('wiki.deleteAttachment', $id);
}
if (!$ok) {
$this->_listOut($this->getLang('remotedelfail') . ' ' . $id . ' ' . $this->client->getErrorMessage(), 'del_fail');
continue;
}
$this->_listOut($this->getLang('remotedelok') . ' ' . $id, 'del_okay');
continue;
}
}
// unlock
if ($type == 'pages') {
foreach ((array) $synclist as $id => $dir) {
unlock($id);
}
$this->client->query('dokuwiki.setLocks', array('lock' => array(), 'unlock' => $lock));
}
//.........这里部分代码省略.........
示例14: unlock
*/
//require controller to handle all the work
require_once "../src/controller.php";
//define a few regex
$pattern = '/^\\/test.(mp3|jpg|mp4)\\/?$/';
$pattern2 = '/^\\/show\\/s\\/test.(mp3|jpg|mp4)\\/?$/';
$pattern3 = '/^\\/show\\/u\\/test.(mp3|jpg|mp4)\\/?$/';
//get request path
$path = $_SERVER['REQUEST_URI'];
//get request method
$method = $_SERVER['REQUEST_METHOD'];
//ROUTING LOGIC
//route to proper controller function
if (preg_match($pattern, $path)) {
if ($method == "POST") {
unlock($path);
} else {
if ($method == "GET") {
purchase($path);
}
}
} else {
if (preg_match($pattern2, $path)) {
getScrambledMedia($path);
} else {
if (preg_match($pattern3, $path)) {
getUnscrambledMedia($path);
} else {
require "index.html";
}
}
示例15: handle
public function handle()
{
global $ID;
global $INPUT;
$this->file = Projects_file::file($ID);
$old_text = $INPUT->post->str($this->old_input_name(), '');
$old = $this->split($old_text);
$new_text = $INPUT->post->str($this->new_input_name(), '');
$new = $this->split($new_text);
$diff = new Diff($old, $new);
$now = $this->now();
if ($new == $now) {
return "show";
}
if ($old != $now) {
$check = new Diff($old, $now);
$merged = merge3($diff->edits, $check->edits);
if ($merged['conflict']) {
global $MERGED_DIFF;
$MERGED_DIFF = $merged['merged'];
return $this->action();
}
$diff->edits = $merged['merged'];
$new = $diff->closing();
}
lock($ID);
$text = $this->update($this->merge($new));
if ($text === FALSE) {
msg('file has been changed, cannot save!', -1);
} else {
saveWikiText($ID, $text, "");
}
unlock($ID);
return "show";
}