本文整理汇总了PHP中Safe::chdir方法的典型用法代码示例。如果您正苦于以下问题:PHP Safe::chdir方法的具体用法?PHP Safe::chdir怎么用?PHP Safe::chdir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Safe
的用法示例。
在下文中一共展示了Safe::chdir方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send_body
/**
* dynamically generate the page
*
* @see skins/index.php
*/
function send_body()
{
global $context;
// only associates can proceed
if (!Surfer::is_associate()) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
echo '<p>' . i18n::s('You are not allowed to perform this operation.') . "</p>\n";
// forward to the index page
$menu = array('scripts/' => i18n::s('Server software'));
echo Skin::build_list($menu, 'menu_bar');
// ask for confirmation
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'GET') {
// the splash message
echo '<p>' . i18n::s('This tool will include most of the running reference PHP scripts. Any syntax error should be spotted easily.') . '</p>';
// the submit button
echo '<form method="post" action="' . $context['script_url'] . '" id="main_form"><p>' . Skin::build_submit_button(i18n::s('Yes, I want to validate scripts'), NULL, NULL, 'confirmed') . '</p></form>';
// set the focus on the button
Page::insert_script('$("#confirmed").focus();');
// this may take some time
echo '<p>' . i18n::s('When you will click on the button the server will be immediately requested to proceed. However, because of the so many things to do on the back-end, you may have to wait for minutes before getting a response displayed. Thank you for your patience.') . '</p>';
// just do it
} else {
// the splash message
echo '<p>' . i18n::s('All reference scripts are included, to show evidence of possible syntax errors.') . "</p>\n";
// list running scripts
echo '<p>' . i18n::s('Listing files...') . BR . "\n";
// locate script files starting at root
$scripts = Scripts::list_scripts_at(NULL);
if (is_array($scripts) && count($scripts)) {
echo BR . sprintf(i18n::s('%d scripts have been found.'), count($scripts)) . "\n";
natsort($scripts);
}
echo "</p>\n";
// including scripts
echo '<p>' . i18n::s('Including reference scripts...') . BR . "\n";
// strip as much output as possible
$_SERVER['REQUEST_METHOD'] = 'HEAD';
// we will finalize this page later on
global $finalizing_fuse;
$finalizing_fuse = FALSE;
// take care of dependancies
include_once '../behaviors/behavior.php';
include_once '../services/codec.php';
include_once '../users/authenticator.php';
// analyse each script
$included_files = 0;
$links_to_be_checked_manually = array();
foreach ($scripts as $file) {
// ensure we have enough time to process this script
Safe::set_time_limit(30);
// skip run once scripts
if (strpos($file, 'run_once/')) {
continue;
}
// don't include ourself
if ($file == 'scripts/validate.php') {
continue;
}
// process only reference scripts
if (!Scripts::hash($file)) {
continue;
}
// check file content
if (!($handle = Safe::fopen($file, 'rb'))) {
echo sprintf(i18n::s('%s has no readable content.'), $file) . BR . "\n";
continue;
}
// look at the beginning of the file
if (!($header = fread($handle, 16384))) {
echo sprintf(i18n::s('%s has no readable content.'), $file) . BR . "\n";
fclose($handle);
continue;
}
fclose($handle);
// skip scripts that generate content asynchronously
if (stripos($header, 'send_body') || stripos($header, 'page::content')) {
$links_to_be_checked_manually[$file] = '(asynchronous)';
continue;
}
// skip scripts that would redefine our skin
if (stripos($header, 'extends skin_skeleton')) {
$links_to_be_checked_manually[$file] = '(skin)';
continue;
}
// log script inclusion on development host
if ($context['with_debug'] == 'Y') {
logger::remember('scripts/validate.php: inclusion of ' . $file, '', 'debug');
}
// include the script and display any error
$included_files += 1;
$validate_stamp = time();
echo sprintf(i18n::s('inclusion of %s'), $file) . "\n";
Safe::chdir($context['path_to_root'] . dirname($file));
include_once $context['path_to_root'] . $file;
$duration = time() - $validate_stamp;
//.........这里部分代码省略.........