当前位置: 首页>>代码示例>>PHP>>正文


PHP lock函数代码示例

本文整理汇总了PHP中lock函数的典型用法代码示例。如果您正苦于以下问题:PHP lock函数的具体用法?PHP lock怎么用?PHP lock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了lock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 <chi@chimeric.de> 
  */
 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 <andi@splitbrain.org>
 */
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


注:本文中的lock函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。