本文整理汇总了PHP中gpFiles::Exists方法的典型用法代码示例。如果您正苦于以下问题:PHP gpFiles::Exists方法的具体用法?PHP gpFiles::Exists怎么用?PHP gpFiles::Exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gpFiles
的用法示例。
在下文中一共展示了gpFiles::Exists方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Upgrade_234
/**
* Update the gp_index, gp_titles and menus so that special pages can be renamed
*
*/
function Upgrade_234()
{
global $gp_index, $gp_titles, $gp_menu, $config, $dataDir;
includeFile('tool/gpOutput.php');
$special_indexes = array();
$new_index = array();
$new_titles = array();
foreach ($gp_index as $title => $index) {
$info = $gp_titles[$index];
$type = common::SpecialOrAdmin($title);
if ($type === 'special') {
$special_indexes[$index] = strtolower($title);
$index = strtolower($title);
$info['type'] = 'special';
//some older versions didn't maintain this value well
}
$new_index[$title] = $index;
$new_titles[$index] = $info;
}
$gp_titles = $new_titles;
$gp_index = $new_index;
//update gp_menu
$gp_menu = $this->FixMenu($gp_menu, $special_indexes);
//save pages
if (!admin_tools::SavePagesPHP()) {
return;
}
$config['gpversion'] = '2.3.4';
admin_tools::SaveConfig();
//update alt menus
if (isset($config['menus']) && is_array($config['menus'])) {
foreach ($config['menus'] as $key => $value) {
$menu_file = $dataDir . '/data/_menus/' . $key . '.php';
if (gpFiles::Exists($menu_file)) {
$menu = gpOutput::GetMenuArray($key);
$menu = $this->FixMenu($menu, $special_indexes);
gpFiles::SaveData($menu_file, 'menu', $menu);
}
}
}
}
示例2: NewExtraArea
/**
* Return the name of the cleansed extra area name, create file if it doesn't already exist
*
*/
function NewExtraArea()
{
global $langmessage, $dataDir;
$title = gp_edit::CleanTitle($_REQUEST['extra_area']);
if (empty($title)) {
message($langmessage['OOPS']);
return false;
}
$data = gp_edit::DefaultContent($_POST['type']);
$file = $dataDir . '/data/_extra/' . $title . '.php';
if (gpFiles::Exists($file)) {
return $title;
}
if (!gpFiles::SaveData($file, 'extra_content', $data)) {
message($langmessage['OOPS']);
return false;
}
return $title;
}
示例3: ExtraContent
/**
* Get and return the extra content specified by $title
*
*/
static function ExtraContent($title, &$file_stats = array())
{
$file = '_extra/' . $title;
$extra_content = array();
if (gpFiles::Exists($file)) {
ob_start();
$extra_content = gpFiles::Get($file, 'extra_content');
$extra_content_string = ob_get_clean();
if (!count($extra_content)) {
$extra_content['content'] = $extra_content_string;
}
}
return $extra_content + array('type' => 'text', 'content' => '');
}
示例4: Save
/**
* Save raw content to a file to the server
*
* @param string $file The path of the file to be saved
* @param string $contents The contents of the file to be saved
* @return bool True on success
*/
public static function Save($file, $contents)
{
global $gp_not_writable;
if (!self::WriteLock()) {
return false;
}
$exists = gpFiles::Exists($file);
//make sure directory exists
if (!$exists) {
$dir = common::DirName($file);
if (!file_exists($dir)) {
gpFiles::CheckDir($dir);
}
}
$fp = @fopen($file, 'wb');
if ($fp === false) {
$gp_not_writable[] = $file;
return false;
}
if (!$exists) {
@chmod($file, gp_chmod_file);
} elseif (function_exists('opcache_invalidate') && substr($file, -4) === '.php') {
opcache_invalidate($file);
}
$return = fwrite($fp, $contents);
fclose($fp);
return $return !== false;
}
示例5: AltMenu_Remove
function AltMenu_Remove()
{
global $langmessage, $config, $dataDir;
$menu_id =& $_POST['id'];
if (!$this->IsAltMenu($menu_id)) {
message($langmessage['OOPS']);
return;
}
$menu_file = $dataDir . '/data/_menus/' . $menu_id . '.php';
unset($config['menus'][$menu_id]);
unset($this->avail_menus[$menu_id]);
if (!admin_tools::SaveConfig()) {
message($langmessage['OOPS']);
}
message($langmessage['SAVED']);
//delete menu file
$menu_file = $dataDir . '/data/_menus/' . $menu_id . '.php';
if (gpFiles::Exists($menu_file)) {
unlink($menu_file);
}
}
示例6: start
/**
* Determine if $session_id represents a valid session and if so start the session
*
*/
static function start($session_id, $sessions = false)
{
global $langmessage, $dataDir, $wbMessageBuffer;
static $locked_message = false;
//get the session file
if (!$sessions) {
$sessions = self::GetSessionIds();
if (!isset($sessions[$session_id])) {
msg('hmm: ' . gp_session_cookie);
self::cookie(gp_session_cookie);
//make sure the cookie is deleted
msg($langmessage['Session Expired'] . ' (timeout)');
return false;
}
}
$sess_info = $sessions[$session_id];
//check ~ip, ~user agent ...
if (gp_browser_auth && !empty($sess_info['uid'])) {
$auth_uid = self::auth_browseruid();
$auth_uid_legacy = self::auth_browseruid(true);
//legacy option added to prevent logging users out, added 2.0b2
if ($sess_info['uid'] != $auth_uid && $sess_info['uid'] != $auth_uid_legacy) {
self::cookie(gp_session_cookie);
//make sure the cookie is deleted
msg($langmessage['Session Expired'] . ' (browser auth)');
return false;
}
}
$session_file = $dataDir . '/data/_sessions/' . $sess_info['file_name'];
if ($session_file === false || !gpFiles::Exists($session_file)) {
self::cookie(gp_session_cookie);
//make sure the cookie is deleted
msg($langmessage['Session Expired'] . ' (invalid)');
return false;
}
//prevent browser caching when editing
Header('Last-Modified: ' . gmdate('D, j M Y H:i:s') . ' GMT');
Header('Expires: ' . gmdate('D, j M Y H:i:s', time()) . ' GMT');
Header('Cache-Control: no-store, no-cache, must-revalidate');
// HTTP/1.1
Header('Cache-Control: post-check=0, pre-check=0', false);
Header('Pragma: no-cache');
// HTTP/1.0
$GLOBALS['gpAdmin'] = self::SessionData($session_file, $checksum);
//lock to prevent conflicting edits
if (gp_lock_time > 0 && (!empty($GLOBALS['gpAdmin']['editing']) || !empty($GLOBALS['gpAdmin']['granted']))) {
$expires = gp_lock_time;
if (!gpFiles::Lock('admin', sha1(sha1($session_id)), $expires)) {
msg($langmessage['site_locked'] . ' ' . sprintf($langmessage['lock_expires_in'], ceil($expires / 60)));
$locked_message = true;
} else {
unset($GLOBALS['gpAdmin']['locked']);
}
}
//extend cookie?
if (isset($GLOBALS['gpAdmin']['remember'])) {
$elapsed = time() - $GLOBALS['gpAdmin']['remember'];
if ($elapsed > 604800) {
//7 days
$GLOBALS['gpAdmin']['remember'] = time();
self::cookie(gp_session_cookie, $session_id);
}
}
register_shutdown_function(array('gpsession', 'close'), $session_file, $checksum);
self::SaveSetting();
//make sure forms have admin nonce
ob_start(array('gpsession', 'AdminBuffer'));
gpOutput::$lang_values += array('cancel' => 'ca', 'update' => 'up', 'caption' => 'cp', 'Width' => 'Width', 'Height' => 'Height');
common::LoadComponents('sortable,autocomplete,gp-admin,gp-admin-css');
admin_tools::VersionsAndCheckTime();
gpOutput::$inline_vars += array('gpRem' => admin_tools::CanRemoteInstall());
//prepend messages from message buffer
if (isset($GLOBALS['gpAdmin']['message_buffer']) && count($GLOBALS['gpAdmin']['message_buffer'])) {
$wbMessageBuffer = array_merge($GLOBALS['gpAdmin']['message_buffer'], $wbMessageBuffer);
unset($GLOBALS['gpAdmin']['message_buffer']);
}
//alias
if (isset($_COOKIE['gp_alias'])) {
$GLOBALS['gpAdmin']['useralias'] = $_COOKIE['gp_alias'];
} else {
$GLOBALS['gpAdmin']['useralias'] = $GLOBALS['gpAdmin']['username'];
}
return true;
}
示例7: SetVars
/**
* SetVars
*
*/
public function SetVars()
{
global $dataDir, $config;
if (!parent::SetVars()) {
return false;
}
$this->permission_edit = admin_tools::CanEdit($this->gp_index);
$this->permission_menu = admin_tools::HasPermission('Admin_Menu');
$this->draft_file = dirname($this->file) . '/draft.php';
//admin actions
if ($this->permission_menu) {
$this->cmds['renameform'] = 'return';
$this->cmds['togglevisibility'] = '';
}
if ($this->permission_edit) {
$this->cmds['rawcontent'] = 'return';
$this->cmds['managesections'] = 'newsectioncontent';
$this->cmds['newsectioncontent'] = 'return';
$this->cmds['savesections'] = 'return';
$this->cmds['viewrevision'] = 'return';
$this->cmds['userevision'] = '';
$this->cmds['viewhistory'] = 'return';
$this->cmds['viewcurrent'] = 'return';
$this->cmds['deleterevision'] = 'viewhistory';
$this->cmds['publishdraft'] = '';
$this->cmds['discarddraft'] = '';
}
if (!gpFiles::Exists($this->draft_file)) {
return true;
}
$this->draft_exists = true;
return true;
}
示例8: stop
/**
* Stop loading gpEasy
* Check to see if gpEasy has already been installed
*
*/
static function stop()
{
global $dataDir;
if (!gpFiles::Exists($dataDir . '/data/_site/config.php')) {
if (file_exists($dataDir . '/include/install/install.php')) {
common::SetLinkPrefix();
includeFile('install/install.php');
die;
}
}
die('<p>Notice: The site configuration did not load properly.</p>' . '<p>If you are the site administrator, you can troubleshoot the problem turning debugging "on" or bypass it by enabling gpEasy safe mode.</p>' . '<p>More information is available in the <a href="http://docs.gpeasy.com/Main/Troubleshooting">gpEasy documentation</a>.</p>' . common::ErrorBuffer(true, false));
}
示例9: SetVars
/**
* SetVars
*
*/
function SetVars()
{
global $dataDir, $config;
if (!parent::SetVars()) {
return false;
}
$this->draft_file = dirname($this->file) . '/draft.php';
if (!gpFiles::Exists($this->draft_file)) {
return true;
}
$this->draft_exists = true;
return true;
}
示例10: RestoreTitles
/**
* Restore $titles and return array with menu information
* @param array $titles An array of titles to be restored. After completion, it will contain only the titles that were prepared successfully
* @return array A list of restored titles that can be used for menu insertion
*
*/
static function RestoreTitles(&$titles)
{
global $dataDir, $gp_index, $gp_titles, $config;
$new_menu = array();
$restored = array();
foreach ($titles as $trash_index) {
//get trash info about file
$title_info = admin_trash::GetInfo($trash_index);
if ($title_info === false) {
continue;
}
$new_title = admin_tools::CheckPostedNewPage($title_info['title'], $message);
if (!$new_title) {
continue;
}
//make sure the page_file exists
if (!gpFiles::Exists($title_info['page_file'])) {
continue;
}
//add to $gp_index before PageFile()
if (isset($title_info['index'])) {
$index = $title_info['index'];
$gp_index[$new_title] = $index;
} else {
$index = common::NewFileIndex();
$gp_index[$new_title] = $index;
}
// move the trash file to the /_pages directory if needed
$new_file = gpFiles::PageFile($new_title);
if (!gpFiles::Exists($new_file)) {
if (!gpFiles::Rename($title_info['page_file'], $new_file)) {
unset($gp_index[$new_title]);
continue;
}
}
//add to $gp_titles
$gp_titles[$index] = array();
$gp_titles[$index]['label'] = $title_info['label'];
$gp_titles[$index]['type'] = $title_info['type'];
$new_menu[$index] = array();
$restored[$trash_index] = $title_info;
admin_trash::RestoreFile($new_title, $new_file, $title_info);
}
$titles = $restored;
return $new_menu;
}
示例11: RestoreTitles
/**
* Restore $titles and return array with menu information
* @param array $titles An array of titles to be restored. After completion, it will contain only the titles that were prepared successfully
* @return array A list of restored titles that can be used for menu insertion
*
*/
static function RestoreTitles(&$titles)
{
global $dataDir, $gp_index, $gp_titles;
$new_menu = array();
$new_titles = array();
foreach ($titles as $title => $empty) {
$new_title = admin_tools::CheckPostedNewPage($title, $message);
if (!$new_title) {
//message($message);
continue;
}
//add to $gp_index first for PageFile()
$index = common::NewFileIndex();
$gp_index[$new_title] = $index;
//get trash info about file
$title_info = admin_trash::GetInfo($title);
if ($title_info === false) {
unset($gp_index[$new_title]);
continue;
}
//make sure the trash file exists
$trash_file = $dataDir . '/data/_trash/' . $title_info['file'];
if (!gpFiles::Exists($trash_file)) {
unset($gp_index[$new_title]);
continue;
}
//copy the trash file to the /_pages directory
$new_file = gpFiles::PageFile($new_title);
if (!copy($trash_file, $new_file)) {
unset($gp_index[$new_title]);
continue;
}
//add to $gp_titles
$gp_titles[$index] = array();
$gp_titles[$index]['label'] = $title_info['label'];
$gp_titles[$index]['type'] = $title_info['type'];
$new_menu[$index] = array();
$new_titles[$new_title] = true;
admin_trash::RestoreFile($new_title, $trash_file, $title_info);
}
$titles = $new_titles;
return $new_menu;
}