本文整理汇总了PHP中lock函数的典型用法代码示例。如果您正苦于以下问题:PHP lock函数的具体用法?PHP lock怎么用?PHP lock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了lock函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: test_PageLockedByYou
public function test_PageLockedByYou()
{
$page_id = 'test:main';
$GLOBALS['INPUT']->server->set('REMOTE_USER', 'testuser');
saveWikiText($page_id, 'some text', 'some summary');
lock($page_id);
$json = $this->doCall($page_id, null, 'testuser');
$this->assertInstanceOf('\\stdClass', $json);
$this->assertObjectHasAttribute('error', $json);
$this->assertRegExp("/^\\d{2}:\\d{2}:\\d{2} Page is locked by You. You cannot delete page during edit.\$/", $json->error);
}
开发者ID:yurii-github,项目名称:dokuwiki-plugin-yktools,代码行数:11,代码来源:CheckPage.php
示例2: deleteDid
/**
* Deleting function
* @param id Hardware identifier to be deleted
* @param checkLock Tells wether or not the locking system must be used (default true)
* @param traceDel Tells wether or not the deleted entities must be inserted in deleted_equiv for tracking purpose (default true)
*/
function deleteDid($id, $checkLock = true, $traceDel = true, $silent = false)
{
global $l;
//If lock is not user OR it is used and available
if (!$checkLock || lock($id)) {
$resId = mysql_query("SELECT deviceid,name FROM hardware WHERE id='{$id}'", $_SESSION["readServer"]) or die(mysql_error());
$valId = mysql_fetch_array($resId);
$idHard = $id;
$did = $valId["deviceid"];
if ($did) {
//Deleting a network device
if (strpos($did, "NETWORK_DEVICE-") === false) {
$resNetm = @mysql_query("SELECT macaddr FROM networks WHERE hardware_id={$idHard}", $_SESSION["writeServer"]) or die(mysql_error());
while ($valNetm = mysql_fetch_array($resNetm)) {
@mysql_query("DELETE FROM netmap WHERE mac='" . $valNetm["macaddr"] . "';", $_SESSION["writeServer"]) or die(mysql_error());
}
}
//deleting a regular computer
if ($did != "_SYSTEMGROUP_" and $did != '_DOWNLOADGROUP_') {
$tables = array("accesslog", "accountinfo", "bios", "controllers", "drives", "inputs", "memories", "modems", "monitors", "networks", "ports", "printers", "registry", "slots", "softwares", "sounds", "storages", "videos", "devices", "download_history", "download_servers", "groups_cache");
} elseif ($did == "_SYSTEMGROUP_" or $did == '_DOWNLOADGROUP_') {
//Deleting a group
$tables = array("devices");
$del_groups_server_cache = "DELETE FROM download_servers WHERE group_id='" . $idHard . "'";
mysql_query($del_groups_server_cache, $_SESSION["writeServer"]) or die(mysql_error());
mysql_query("DELETE FROM groups WHERE hardware_id={$idHard}", $_SESSION["writeServer"]) or die(mysql_error());
$resDelete = mysql_query("DELETE FROM groups_cache WHERE group_id={$idHard}", $_SESSION["writeServer"]) or die(mysql_error());
$affectedComputers = mysql_affected_rows($_SESSION["writeServer"]);
}
if (!$silent) {
echo "deleting record " . $valId["name"] . "\n";
}
foreach ($tables as $table) {
mysql_query("DELETE FROM {$table} WHERE hardware_id={$idHard};", $_SESSION["writeServer"]) or die(mysql_error());
}
mysql_query("delete from download_enable where SERVER_ID=" . $idHard, $_SESSION["writeServer"]) or die(mysql_error($_SESSION["writeServer"]));
mysql_query("DELETE FROM hardware WHERE id={$idHard};", $_SESSION["writeServer"]) or die(mysql_error());
//Deleted computers tracking
if ($traceDel && mysql_num_rows(mysql_query("SELECT IVALUE FROM config WHERE IVALUE>0 AND NAME='TRACE_DELETED'", $_SESSION["writeServer"]))) {
mysql_query("insert into deleted_equiv(DELETED,EQUIVALENT) values('{$did}',NULL)", $_SESSION["writeServer"]) or die(mysql_error());
}
}
//Using lock ? Unlock
if ($checkLock) {
unlock($id);
}
} else {
errlock();
}
}
开发者ID:yhchiu,项目名称:puppet,代码行数:56,代码来源:delete_old.php
示例3: 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();
}
}
开发者ID:RimeOfficial,项目名称:postmaster,代码行数:14,代码来源:Process_notification.php
示例4: 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);
}
}
开发者ID:yurii-github,项目名称:dokuwiki-plugin-yktools,代码行数:15,代码来源:delete.php
示例5: 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();
}
}
开发者ID:RimeOfficial,项目名称:postmaster,代码行数:18,代码来源:Scheduled.php
示例6: obtainLock
function obtainLock($WIKI_ID)
{
global $USERNAME;
if (!file_exists(wikiFN($WIKI_ID))) {
fwrite(STDERR, "{$WIKI_ID} does not yet exist\n");
}
$_SERVER['REMOTE_USER'] = $USERNAME;
if (checklock($WIKI_ID)) {
fwrite(STDERR, "Page {$WIKI_ID} is already locked by another user\n");
exit(1);
}
lock($WIKI_ID);
$_SERVER['REMOTE_USER'] = '_' . $USERNAME . '_';
if (checklock($WIKI_ID) != $USERNAME) {
fwrite(STDERR, "Unable to obtain lock for {$WIKI_ID}\n");
exit(1);
}
}
开发者ID:stretchyboy,项目名称:dokuwiki,代码行数:18,代码来源:dwpage.php
示例7: 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();
}
}
开发者ID:RimeOfficial,项目名称:postmaster,代码行数:19,代码来源:Message.php
示例8: handle_act_preprocess
/**
* Checks if 'newentry' was given as action, if so we
* do handle the event our self and no further checking takes place
*/
function handle_act_preprocess(&$event, $param)
{
//if ($event->data != 'newentry') return; // nothing to do for us
global $ACT;
global $ID;
echo "param={$param}";
return;
// we can handle it -> prevent others
$event->stopPropagation();
$event->preventDefault();
$ns = $_REQUEST['ns'];
$title = str_replace(':', '', $_REQUEST['title']);
$id = ($ns ? $ns . ':' : '') . cleanID($title);
// check if we are allowed to create this file
if (auth_quickaclcheck($id) >= AUTH_CREATE) {
$back = $ID;
$ID = $id;
$file = wikiFN($ID);
//check if locked by anyone - if not lock for my self
if (checklock($ID)) {
$ACT = 'locked';
} else {
lock($ID);
}
// prepare the new thread file with default stuff
if (!@file_exists($file)) {
global $TEXT;
global $INFO;
global $conf;
$TEXT = pageTemplate($ns . ':' . $title);
if (!$TEXT) {
$TEXT = "====== {$title} ======\n\n\n\n" . "~~DISCUSSION~~\n";
}
$ACT = 'preview';
} else {
$ACT = 'edit';
}
} else {
$ACT = 'show';
}
}
开发者ID:BackupTheBerlios,项目名称:openaqua-svn,代码行数:45,代码来源:action.php
示例9: obtainLock
/**
* Lock the given page or exit
*
* @param string $wiki_id
*/
protected function obtainLock($wiki_id)
{
if ($this->force) {
$this->deleteLock($wiki_id);
}
$_SERVER['REMOTE_USER'] = $this->username;
if (checklock($wiki_id)) {
$this->error("Page {$wiki_id} is already locked by another user");
exit(1);
}
lock($wiki_id);
if (checklock($wiki_id)) {
$this->error("Unable to obtain lock for {$wiki_id} ");
var_dump(checklock($wiki_id));
exit(1);
}
}
开发者ID:kevinlovesing,项目名称:dokuwiki,代码行数:22,代码来源:dwpage.php
示例10: _handle_newEntry
/**
* Creates a new entry page
*/
function _handle_newEntry()
{
global $ID, $INFO;
$ns = cleanID($_REQUEST['ns']);
$title = str_replace(':', '', $_REQUEST['title']);
$ID = $this->_newEntryID($ns, $title);
$INFO = pageinfo();
// check if we are allowed to create this file
if ($INFO['perm'] >= AUTH_CREATE) {
//check if locked by anyone - if not lock for my self
if ($INFO['locked']) {
return 'locked';
} else {
lock($ID);
}
// prepare the new thread file with default stuff
if (!@file_exists($INFO['filepath'])) {
global $TEXT;
$TEXT = pageTemplate(array(($ns ? $ns . ':' : '') . $title));
if (!$TEXT) {
$data = array('id' => $ID, 'ns' => $ns, 'title' => $title);
$TEXT = $this->_pageTemplate($data);
}
return 'preview';
} else {
return 'edit';
}
} else {
return 'show';
}
}
开发者ID:kosenconf,项目名称:kcweb,代码行数:34,代码来源:action.php
示例11: _lockFiles
/**
* Lock files that will be modified on either side.
*
* Lock fails are printed and removed from synclist
*
* @returns list of locked files
*/
function _lockFiles(&$synclist)
{
if (!$this->_connect()) {
return array();
}
// lock the files
$lock = array();
foreach ((array) $synclist as $id => $dir) {
if ($dir == 0) {
continue;
}
if (checklock($id)) {
$this->_listOut($this->getLang('lockfail') . ' ' . hsc($id), 'error');
unset($synclist[$id]);
} else {
lock($id);
// lock local
$lock[] = $id;
}
}
// lock remote files
$ok = $this->client->query('dokuwiki.setLocks', array('lock' => $lock, 'unlock' => array()));
if (!$ok) {
$this->_listOut('failed RPC communication');
$synclist = array();
return array();
}
$data = $this->client->getResponse();
foreach ((array) $data['lockfail'] as $id) {
$this->_listOut($this->getLang('lockfail') . ' ' . hsc($id), 'error');
unset($synclist[$id]);
}
return $lock;
}
开发者ID:omusico,项目名称:isle-web-framework,代码行数:41,代码来源:admin.php
示例12: putPage
/**
* Save a wiki page
*
* @author Michael Klier <[email protected]>
*/
function putPage($id, $text, $params)
{
global $TEXT;
global $lang;
global $conf;
$id = cleanID($id);
$TEXT = trim($text);
$sum = $params['sum'];
$minor = $params['minor'];
if (empty($id)) {
return new IXR_Error(1, 'Empty page ID');
}
if (!page_exists($id) && empty($TEXT)) {
return new IXR_ERROR(1, 'Refusing to write an empty new wiki page');
}
if (auth_quickaclcheck($id) < AUTH_EDIT) {
return new IXR_Error(1, 'You are not allowed to edit this page');
}
// Check, if page is locked
if (checklock($id)) {
return new IXR_Error(1, 'The page is currently locked');
}
// SPAM check
if (checkwordblock()) {
return new IXR_Error(1, 'Positive wordblock check');
}
// autoset summary on new pages
if (!page_exists($id) && empty($sum)) {
$sum = $lang['created'];
}
// autoset summary on deleted pages
if (page_exists($id) && empty($TEXT) && empty($sum)) {
$sum = $lang['deleted'];
}
lock($id);
saveWikiText($id, $TEXT, $sum, $minor);
unlock($id);
// run the indexer if page wasn't indexed yet
if (!@file_exists(metaFN($id, '.indexed'))) {
// try to aquire a lock
$lock = $conf['lockdir'] . '/_indexer.lock';
while (!@mkdir($lock, $conf['dmode'])) {
usleep(50);
if (time() - @filemtime($lock) > 60 * 5) {
// looks like a stale lock - remove it
@rmdir($lock);
} else {
return false;
}
}
if ($conf['dperm']) {
chmod($lock, $conf['dperm']);
}
require_once DOKU_INC . 'inc/indexer.php';
// do the work
idx_addPage($id);
// we're finished - save and free lock
io_saveFile(metaFN($id, '.indexed'), INDEXER_VERSION);
@rmdir($lock);
}
return 0;
}
开发者ID:jalemanyf,项目名称:wsnlocalizationscala,代码行数:67,代码来源:xmlrpc.php
示例13:
}
}
?>
<header id="header">
<h1>
<a href="../">PunkSky:MCSE</a>
</h1>
<nav id="nav">
<ul>
<li><a href="index">Home</a></li>
<li><a href="http://github.com/zarlo/MCSE/releases/latest">Download</a></li>
<li><a href="INFO">INFO</a></li>
<?php
if ($lock == true) {
if (isset($_session['username'])) {
if (lock() == false) {
echo '<li><a href="../login?url=' . $_SERVER['PHP_SELF'] . '" class="button special">Login</a></li>';
} else {
echo '<li><a href="../logout" class="button special">Logout</a></li>';
}
} else {
echo '<li><a href="../login?url=' . $_SERVER['PHP_SELF'] . '" class="button special">Login</a></li>';
}
} else {
echo '<li><a href="../login?url=' . $_SERVER['PHP_SELF'] . '" class="button special">Login</a></li>';
}
?>
</ul>
</nav>
</header>
开发者ID:zarlo,项目名称:punksky.xyz,代码行数:30,代码来源:header.php
示例14: unschedule_post_news
/**
* 禁用插件时执行函数,用于删除任务
* @package WordPress
* @subpackage Auto-Post-News
* @since 0.0.1
*/
function unschedule_post_news()
{
remove_filter('cron_schedules', 'cron_add_quarter');
wp_clear_scheduled_hook('post_news');
if (file_exists(dirname(__FILE__) . '/post.lock')) {
lock('delete', dirname(__FILE__) . '/post.lock');
}
}
开发者ID:023yangbo,项目名称:WordPress,代码行数:14,代码来源:auto-post-news.php
示例15: ajax_lock
/**
* Refresh a page lock and save draft
*
* Andreas Gohr <[email protected]>
*/
function ajax_lock()
{
global $conf;
global $lang;
$id = cleanID($_POST['id']);
if (empty($id)) {
return;
}
if (!checklock($id)) {
lock($id);
echo 1;
}
if ($conf['usedraft'] && $_POST['wikitext']) {
$client = $_SERVER['REMOTE_USER'];
if (!$client) {
$client = clientIP(true);
}
$draft = array('id' => $id, 'prefix' => substr($_POST['prefix'], 0, -1), 'text' => $_POST['wikitext'], 'suffix' => $_POST['suffix'], 'date' => (int) $_POST['date'], 'client' => $client);
$cname = getCacheName($draft['client'] . $id, '.draft');
if (io_saveFile($cname, serialize($draft))) {
echo $lang['draftdate'] . ' ' . dformat();
}
}
}
开发者ID:stretchyboy,项目名称:dokuwiki,代码行数:29,代码来源:ajax.php
示例16: array
<?php
/*
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ı.";
}
开发者ID:nuclewall,项目名称:nuclewall,代码行数:31,代码来源:hotspot_blocklist_edit.php
示例17: act_edit
/**
* Handle 'edit', 'preview'
*
* @author Andreas Gohr <[email protected]>
*/
function act_edit($act)
{
global $ID;
global $INFO;
//check if locked by anyone - if not lock for my self
$lockedby = checklock($ID);
if ($lockedby) {
return 'locked';
}
lock($ID);
return $act;
}
开发者ID:JeromeS,项目名称:dokuwiki,代码行数:17,代码来源:actions.php
示例18: dirname
// 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, see <http://www.gnu.org/licenses/>.
// BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc
include dirname(__FILE__) . "/../includes/requiredFunctions.php";
//Check that script is run locally
ScriptIsRunLocally();
$txfee = 0;
if ($settings->getsetting("sitetxfee") > 0) {
$txfee = $settings->getsetting("sitetxfee");
}
$sitepercent = $settings->getsetting("sitepercent");
/////////Pay users who have reached their threshold payout
$resultQ = mysql_query("SELECT b.userId, b.balance, IFNULL(b.paid, 0) as paid, IFNULL(b.sendAddress,'') as sendAddress, u.email, u.donate_percent FROM accountBalance b, webUsers u WHERE b.userId = u.id AND b.threshold >= 1 AND b.balance >= threshold");
lock("money");
try {
while ($resultR = mysql_fetch_object($resultQ)) {
$currentBalance = $resultR->balance;
$paid = $resultR->paid;
$paymentAddress = $resultR->sendAddress;
$userId = $resultR->userId;
$donatepercent = $resultR->donate_percent;
if ($paymentAddress != '') {
$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");
开发者ID:neofutur,项目名称:simplecoin,代码行数:31,代码来源:payout.php
示例19: xmlrpc_authfail
if (!xmlrpc_auth($params)) {
xmlrpc_authfail();
return $xmlrpc_g['return']['authfail'];
}
if (!function_exists("get_notices")) {
require "notices.inc";
}
if (!$params) {
$toreturn = get_notices();
} else {
$toreturn = get_notices($params);
}
$response = new XML_RPC_Response(XML_RPC_encode($toreturn));
return $response;
}
$xmlrpclockkey = lock('xmlrpc', LOCK_EX);
/*****************************/
$server = new XML_RPC_Server(array('pfsense.exec_shell' => array('function' => 'exec_shell_xmlrpc', 'signature' => $exec_shell_sig, 'docstring' => $exec_shell_doc), 'pfsense.exec_php' => array('function' => 'exec_php_xmlrpc', 'signature' => $exec_php_sig, 'docstring' => $exec_php_doc), 'pfsense.filter_configure' => array('function' => 'filter_configure_xmlrpc', 'signature' => $filter_configure_sig, 'docstring' => $filter_configure_doc), 'pfsense.interfaces_carp_configure' => array('function' => 'interfaces_carp_configure_xmlrpc', 'docstring' => $carp_configure_sig), 'pfsense.backup_config_section' => array('function' => 'backup_config_section_xmlrpc', 'signature' => $backup_config_section_sig, 'docstring' => $backup_config_section_doc), 'pfsense.restore_config_section' => array('function' => 'restore_config_section_xmlrpc', 'signature' => $restore_config_section_sig, 'docstring' => $restore_config_section_doc), 'pfsense.merge_config_section' => array('function' => 'merge_config_section_xmlrpc', 'signature' => $merge_config_section_sig, 'docstring' => $merge_config_section_doc), 'pfsense.merge_installedpackages_section_xmlrpc' => array('function' => 'merge_installedpackages_section_xmlrpc', 'signature' => $merge_config_section_sig, 'docstring' => $merge_config_section_doc), 'pfsense.host_firmware_version' => array('function' => 'pfsense_firmware_version_xmlrpc', 'signature' => $pfsense_firmware_version_sig, 'docstring' => $host_firmware_version_doc), 'pfsense.reboot' => array('function' => 'reboot_xmlrpc', 'signature' => $reboot_sig, 'docstring' => $reboot_doc), 'pfsense.get_notices' => array('function' => 'get_notices_xmlrpc', 'signature' => $get_notices_sig)));
unlock($xmlrpclockkey);
function array_overlay($a1, $a2)
{
foreach ($a1 as $k => $v) {
if (!array_key_exists($k, $a2)) {
continue;
}
if (is_array($v) && is_array($a2[$k])) {
$a1[$k] = array_overlay($v, $a2[$k]);
} else {
$a1[$k] = $a2[$k];
}
}
开发者ID:michaeleino,项目名称:pfsense,代码行数:31,代码来源:xmlrpc.php
示例20: create_dummy
function create_dummy($deptid)
{
db_connect();
# Dummy Vars
$cusnum = 0;
$salespn = "";
$comm = "";
$salespn = "";
$chrgvat = getSetting("SELAMT_VAT");
$odate = date("Y-m-d");
$ordno = "";
$delchrg = "0.00";
$cordno = "";
$terms = 0;
$traddisc = 0;
$SUBTOT = 0;
$vat = 0;
$total = 0;
lock(1);
# Insert invoice to DB
$sql = "INSERT INTO invoices(deptid, cusnum, cordno, ordno, chrgvat, terms, traddisc, salespn, odate, delchrg, subtot, vat, total, balance, comm, username, printed, done, prd, div)";
$sql .= " VALUES('{$deptid}', '{$cusnum}', '{$cordno}', '{$ordno}', '{$chrgvat}', '{$terms}', '{$traddisc}', '{$salespn}', '{$odate}', '{$delchrg}', '{$SUBTOT}', '{$vat}' , '{$total}', '{$total}', '{$comm}', '" . USER_NAME . "', 'n', 'n', '" . PRD_DB . "', '" . USER_DIV . "')";
$rslt = db_exec($sql) or errDie("Unable to insert invoice to Cubit.", SELF);
unlock(1);
return lastinvid();
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:26,代码来源:cust-credit-stockinv-b.php
注:本文中的lock函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论