本文整理汇总了PHP中gpFiles::Unlock方法的典型用法代码示例。如果您正苦于以下问题:PHP gpFiles::Unlock方法的具体用法?PHP gpFiles::Unlock怎么用?PHP gpFiles::Unlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gpFiles
的用法示例。
在下文中一共展示了gpFiles::Unlock方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Init
/**
* Set variables for blog display
*
*/
public static function Init()
{
global $addonPathData;
if (isset(self::$data)) {
return;
}
self::$data_dir = $addonPathData;
self::$index_file = self::$data_dir . '/index.php';
self::$root_url = 'Special_Blog';
if (is_callable(array('common', 'SpecialHref'))) {
self::$root_url = common::SpecialHref('Special_Blog');
}
self::GetBlogData();
self::AddCSS();
//regenerate if there are pending posts that need to be published
if (!is_null(SimpleBlogCommon::$data['next_regen']) && SimpleBlogCommon::$data['next_regen'] < time()) {
if (@gpFiles::WriteLock()) {
self::GenStaticContent();
SimpleBlogCommon::NextGenTime();
SimpleBlogCommon::SaveIndex();
gpFiles::Unlock('write', gp_random);
}
}
}
示例2: BufferOut
/**
* Complete the response by adding final content to the <head> of the document
* @static
* @since 2.4.1
* @param string $buffer html content
* @return string finalized response
*/
static function BufferOut($buffer)
{
global $config, $gp_head_content, $addonFolderName, $dataDir, $addon_current_id, $wbErrorBuffer;
//add error notice if there was a fatal error
if (!ini_get('display_errors') && function_exists('error_get_last')) {
//check for fatal error
$fatal_errors = array(E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR);
$last_error = error_get_last();
if (is_array($last_error) && in_array($last_error['type'], $fatal_errors)) {
$last_error['request'] = $_SERVER['REQUEST_URI'];
if ($addon_current_id) {
$last_error['addon_name'] = $config['addons'][$addonFolderName]['name'];
$last_error['addon_id'] = $addon_current_id;
}
$last_error['file'] = realpath($last_error['file']);
//may be redundant
showError($last_error['type'], $last_error['message'], $last_error['file'], $last_error['line'], false);
//send error to logger
$reload = false;
//disable execution
if (count(self::$catchable)) {
$last_error['time'] = time();
$last_error['request_method'] = $_SERVER['REQUEST_METHOD'];
if (!empty($last_error['file'])) {
$last_error['file_modified'] = filemtime($last_error['file']);
$last_error['file_size'] = filesize($last_error['file']);
}
//error text, check for existing fatal notice
if (count(self::$fatal_notices)) {
$content = end(self::$fatal_notices);
reset(self::$fatal_notices);
if ($content[0] == '{' && ($temp = json_decode($content, true))) {
$last_error = $temp;
}
} else {
$content = json_encode($last_error);
}
//$buffer .= pre(self::$catchable).'<hr/>';
//$buffer .= '<h3>Existing Fatal Notices</h3>'.pre(self::$fatal_notices).'<hr/>';
$temp = array_reverse(self::$catchable);
foreach ($temp as $error_hash => $info) {
$file = $dataDir . '/data/_site/fatal_' . $error_hash;
gpFiles::Save($file, $content);
$reload = true;
if ($info['catchable_type'] == 'exec') {
break;
}
}
}
//reload non-logged in users automatically, display message to admins
$buffer .= '<p>Oops, an error occurred while generating this page.<p>';
if (!common::LoggedIn()) {
if ($reload) {
$buffer .= 'Reloading... <script type="text/javascript">window.setTimeout(function(){window.location.href = window.location.href},1000);</script>';
} else {
$buffer .= '<p>If you are the site administrator, you can troubleshoot the problem by changing php\'s display_errors setting to 1 in the gpconfig.php file.</p>' . '<p>If the problem is being caused by an addon, you may also be able to bypass the error by enabling gpEasy\'s safe mode in the gpconfig.php file.</p>' . '<p>More information is available in the <a href="http://docs.gpeasy.com/Main/Troubleshooting">gpEasy documentation</a>.</p>' . '<p><a href="">Reload this page to continue</a>.</p>';
}
} else {
$buffer .= '<h3>Error Details</h3>' . pre($last_error) . '<p><a href="">Reload this page</a></p>';
if ($reload) {
$buffer .= '<p><a href="">Reload this page with the faulty component disabled</a></p>' . '<p><a href="?cmd=enable_component&hash=' . $error_hash . '">Reload this page with the faulty component enabled</a></p>';
}
$buffer .= '<p style="font-size:90%">Note: Error details are only displayed for logged in administrators</p>' . common::ErrorBuffer(true, false);
}
}
}
//remove lock
if (defined('gp_has_lock') && gp_has_lock) {
gpFiles::Unlock('write', gp_random);
}
//replace the <head> placeholder with header content
$placeholder = '<!-- get_head_placeholder ' . gp_random . ' -->';
$pos = strpos($buffer, $placeholder);
if ($pos === false) {
return $buffer;
}
$buffer = substr_replace($buffer, $gp_head_content, $pos, strlen($placeholder));
//add jquery if needed
$placeholder = '<!-- jquery_placeholder ' . gp_random . ' -->';
$pos = strpos($buffer, $placeholder);
if ($pos !== false) {
$replacement = '';
if (strpos($buffer, '<script') !== false) {
if ($config['jquery'] != 'local') {
$replacement = "\n<script type=\"text/javascript\" src=\"//ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js\"></script>";
} else {
$replacement = "\n<script type=\"text/javascript\" src=\"" . common::GetDir('/include/thirdparty/js/jquery.js') . "\"></script>";
}
}
$buffer = substr_replace($buffer, $replacement, $pos, strlen($placeholder));
}
//messages
$pos = strpos($buffer, '<!-- message_start ' . gp_random . ' -->');
//.........这里部分代码省略.........
示例3: Install_DataFiles_New
//.........这里部分代码省略.........
<li>Runs on PHP</li>
<li>File Upload Manager</li>
<li>Drag \'n Drop Theme Content</li>
<li>Deleted File Trash Can</li>
<li>Multiple User Administration</li>
<li>Flat File Storage</li>
<li>Fast Page Loading</li>
<li>Fast and Easy Installation</li>
<li>reCaptcha for Contact Form</li>
<li>HTML Tidy (when available)</li>
</ul>';
self::NewTitle($destination, 'About', $content, $config, $new_index);
//Side_Menu
$file = $destination . '/data/_extra/Side_Menu.php';
$content = '<h3>Join the ' . CMS_NAME . ' Community</h3>
<p>Visit ' . CMS_READABLE_DOMAIN . ' to access the many <a href="' . CMS_DOMAIN . '/Resources" title="' . CMS_NAME . ' Community Resources">available resources</a> to help you get the most out of our CMS.</p>
<ul>
<li><a href="' . CMS_DOMAIN . '/Themes" title="' . CMS_NAME . ' Themes">Download Themes</a></li>
<li><a href="' . CMS_DOMAIN . '/Plugins" title="' . CMS_NAME . ' Plugin">Download Plugins</a></li>
<li><a href="' . CMS_DOMAIN . '/Forum" title="' . CMS_NAME . ' Forum">Get Help in the Forum</a></li>
<li><a href="' . CMS_DOMAIN . '/Powered_by" title="Sites using ' . CMS_NAME . '">Show off Your Site</a></li>
<li><a href="' . CMS_DOMAIN . '/Resources" title="' . CMS_NAME . ' Community Resources">And Much More...</a></li>
</ul>
<p class="sm">(Edit this content by clicking "Edit", it's that easy!)</p>';
self::NewExtra($file, $content);
//Header
$file = $destination . '/data/_extra/Header.php';
$content = '<h1>' . $config['title'] . '</h1>
<h4>' . 'The Fast and Easy CMS' . '</h4>';
self::NewExtra($file, $content);
//Footer
$file = $destination . '/data/_extra/Footer.php';
$content = '<h3><a href="' . CMS_DOMAIN . '/Our_CMS" title="Features of Our CMS">' . CMS_NAME . ' Features</a></h3>
<p>Easy to use True WYSIWYG Editing.</p>
<p>Flat-file data storage and advanced resource management for fast websites.</p>
<p>Community driven development</p>
<p><a href="' . CMS_DOMAIN . '/Our_CMS" title="Features of Our CMS">And More...</a></p>
<p>If you like ' . CMS_NAME . ', then you might also like
<a href="http://lessphp.gpeasy.com" title="A Less to CSS compiler based on the official lesscss project">Less.php</a>,
<a href="http://whatcms.org" title="What CMS? Find out what CMS a site is using">WhatCMS.org</a> and
<a href="http://whichcms.org" title="Which CMS? Find out which CMS has the features you\'re looking for.">WhichCMS.org</a>.
</p>';
self::NewExtra($file, $content);
//Another example area
$file = $destination . '/data/_extra/Lorem.php';
$content = '<h3>Heading</h3>
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>';
self::NewExtra($file, $content);
//contact html
$file = $destination . '/data/_extra/Contact.php';
self::NewExtra($file, '<h2>Contact Us</h2><p>Use the form below to contact us, and be sure to enter a valid email address if you want to hear back from us.</p>');
//users
echo '<li>';
$user_info = array();
$user_info['password'] = common::hash($_POST['password'], 'sha512');
$user_info['passhash'] = 'sha512';
$user_info['granted'] = 'all';
$user_info['editing'] = 'all';
$user_info['email'] = $_POST['email'];
$users = array();
$username = $_POST['username'];
//log user in here to finish user_info
if ($base_install) {
includeFile('tool/sessions.php');
gp_defined('gp_session_cookie', gpsession::SessionCookie($config['gpuniq']));
gpsession::create($user_info, $username, $sessions);
}
$users[$username] = $user_info;
if (!gpFiles::SaveData($destination . '/data/_site/users.php', 'users', $users)) {
echo '<span class="failed">';
echo sprintf($langmessage['COULD_NOT_SAVE'], 'users.php');
echo '</span>';
echo '</li>';
return false;
}
echo '<span class="passed">';
echo sprintf($langmessage['_SAVED'], 'users.php');
echo '</span>';
echo '</li>';
//save config
//not using SaveConfig() because $config is not global here
echo '<li>';
$config['file_count'] = self::$file_count;
if (!gpFiles::SaveData($destination . '/data/_site/config.php', 'config', $config)) {
echo '<span class="failed">';
echo sprintf($langmessage['COULD_NOT_SAVE'], 'config.php');
echo '</span>';
echo '</li>';
return false;
}
echo '<span class="passed">';
echo sprintf($langmessage['_SAVED'], 'config.php');
echo '</span>';
echo '</li>';
if ($base_install) {
Install_Tools::InstallHtaccess($destination, $config);
}
gpFiles::Unlock('write', gp_random);
return true;
}
示例4: BufferOut
/**
* Complete the response by adding final content to the <head> of the document
* @static
* @since 2.4.1
* @param string $buffer html content
* @return string finalized response
*/
static function BufferOut($buffer)
{
global $config, $gp_head_content;
//add error notice if there was a fatal error
if (!ini_get('display_errors')) {
$last_error = self::LastFatal();
if ($last_error) {
self::RecordFatal($last_error);
$buffer .= self::FatalMessage($last_error);
}
}
//remove lock
if (defined('gp_has_lock') && gp_has_lock) {
gpFiles::Unlock('write', gp_random);
}
//make sure whe have a complete html request
$placeholder = '<!-- get_head_placeholder ' . gp_random . ' -->';
if (strpos($buffer, $placeholder) === false) {
return $buffer;
}
$replacements = array();
//performace stats
if (class_exists('admin_tools')) {
$replacements = self::PerformanceStats();
}
//head content
$replacements[$placeholder] = $gp_head_content;
//add jquery if needed
$placeholder = '<!-- jquery_placeholder ' . gp_random . ' -->';
$replacement = '';
if (strpos($gp_head_content, '<script') !== false || strpos($buffer, '<script') !== false) {
if ($config['jquery'] != 'local') {
$replacement = "\n<script type=\"text/javascript\" src=\"//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js\"></script>";
} else {
$replacement = "\n<script type=\"text/javascript\" src=\"" . common::GetDir('/include/thirdparty/js/jquery.js') . "\"></script>";
}
}
$replacements[$placeholder] = $replacement;
//messages
$pos = strpos($buffer, '<!-- message_start ' . gp_random . ' -->');
$len = strpos($buffer, '<!-- message_end -->') - $pos;
if ($pos && $len) {
$replacement = GetMessages(false);
$buffer = substr_replace($buffer, $replacement, $pos, $len + 20);
}
return str_replace(array_keys($replacements), array_values($replacements), $buffer);
}
示例5: LogOut
static function LogOut()
{
global $langmessage;
if (!isset($_COOKIE[gp_session_cookie])) {
return false;
}
$session_id = $_COOKIE[gp_session_cookie];
gpFiles::Unlock('admin', sha1(sha1($session_id)));
self::cookie(gp_session_cookie);
self::CleanSession($session_id);
msg($langmessage['LOGGED_OUT']);
}