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


PHP Safe::rename方法代码示例

本文整理汇总了PHP中Safe::rename方法的典型用法代码示例。如果您正苦于以下问题:PHP Safe::rename方法的具体用法?PHP Safe::rename怎么用?PHP Safe::rename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Safe的用法示例。


在下文中一共展示了Safe::rename方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1:

        $from = $context['path_to_root'] . Files::get_path($last_parent->get_reference()) . '/' . $file->item['file_name'];
        $dir = $context['path_to_root'] . Files::get_path($target->get_reference());
        $to = $dir . '/' . $file->item['file_name'];
        // check that dir exists
        if (!is_dir($dir)) {
            Safe::make_path($dir);
        }
        Safe::rename($from, $to);
        // move thumb if any
        if ($file->item['thumbnail_url']) {
            $from = Files::get_path($last_parent->get_reference()) . '/thumbs/' . $file->item['file_name'];
            // make directory thumbs
            $to = $dir . '/thumbs/' . $file->item['file_name'];
            // check that dir exist
            if (!is_dir($dir . '/thumbs')) {
                Safe::mkdir($dir . '/thumbs');
            }
            Safe::rename($from, $to);
        }
    }
}
// we return some JSON
$output = json_encode($output);
// allow for data compression
render_raw('application/json; charset=' . $context['charset']);
// actual transmission except on a HEAD request
if (!isset($_SERVER['REQUEST_METHOD']) || $_SERVER['REQUEST_METHOD'] != 'HEAD') {
    echo $output;
}
// the post-processing hook, then exit
finalize_page(TRUE);
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:move.php

示例2: elseif

    // end of the form
    $context['text'] .= '</div></form>';
    // set the focus
    Page::insert_script('$("#files_extensions").focus();');
    // general help on this form
    $help = '<p>' . i18n::s('Shared files are not put in the database, but in the file system of the web server.') . '</p>' . '<p>' . i18n::s('If you cannot upload files because of permissions settings, use the configuration panel for users to disable all uploads.') . '</p>';
    $context['components']['boxes'] = Skin::build_box(i18n::s('Help'), $help, 'boxes', 'help');
    // no modifications in demo mode
} elseif (file_exists($context['path_to_root'] . 'parameters/demo.flag')) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation in demonstration mode.'));
    // save updated parameters
} else {
    // backup the old version
    Safe::unlink($context['path_to_root'] . 'parameters/files.include.php.bak');
    Safe::rename($context['path_to_root'] . 'parameters/files.include.php', $context['path_to_root'] . 'parameters/files.include.php.bak');
    // build the new configuration file
    $content = '<?php' . "\n" . '// This file has been created by the configuration script files/configure.php' . "\n" . '// on ' . gmdate("F j, Y, g:i a") . ' GMT, for ' . Surfer::get_name() . '. Please do not modify it manually.' . "\n" . 'global $context;' . "\n";
    if (isset($_REQUEST['files_extensions'])) {
        $content .= '$context[\'files_extensions\']=\'' . addcslashes($_REQUEST['files_extensions'], "\\'") . "';\n";
    }
    if (isset($_REQUEST['files_on_ftp'])) {
        $content .= '$context[\'files_on_ftp\']=\'' . addcslashes($_REQUEST['files_on_ftp'], "\\'") . "';\n";
    }
    if (isset($_REQUEST['files_path'])) {
        $content .= '$context[\'files_path\']=\'' . addcslashes($_REQUEST['files_path'], "\\'") . "';\n";
    }
    if (isset($_REQUEST['files_url'])) {
        $content .= '$context[\'files_url\']=\'' . addcslashes($_REQUEST['files_url'], "\\'") . "';\n";
    }
    $content .= '?>' . "\n";
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:configure.php

示例3: foreach

 }
 // include all scripts named 'hook.php' recursively
 foreach ($scanned as $name) {
     include_hook($context['path_to_root'] . $name);
 }
 global $scanned_directories;
 if ($scanned_directories > 1) {
     $context['text'] .= sprintf(i18n::s('%d directories have been scanned.'), $scanned_directories) . BR . "\n";
 }
 // no hook has been found
 if (!count($hooks)) {
     $context['text'] .= i18n::s('No item has been found.');
 } else {
     // backup the old version
     Safe::unlink('../parameters/hooks.include.php.bak');
     Safe::rename('../parameters/hooks.include.php', '../parameters/hooks.include.php.bak');
     // what we have to produce
     $called_items = array();
     $included_items = array();
     $included_items['tick'] = '';
     $linked_items = array();
     $served_items = array();
     // we will remember a xml file as well
     $xml = '';
     // consider each hook
     foreach ($hooks as $hook) {
         // bad script!
         if (!$hook['id'] || !$hook['type'] || $hook['type'] != 'call' && !$hook['script']) {
             $context['text'] .= '<p><strong>' . i18n::s('Bad hook:') . '</strong>' . BR . "\n";
             foreach ($hook as $name => $value) {
                 $context['text'] .= $name . ': ' . $value . BR;
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:scan.php

示例4: elseif

} elseif ($file && !preg_match('/(\\.css|template\\.php)$/i', $file)) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // ensure the file already exists
} elseif ($file && !file_exists($context['path_to_root'] . 'skins/' . $skin . '/' . $file)) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // save the content of an updated file
} elseif (isset($_REQUEST['content']) && $_REQUEST['content']) {
    // warning if modification of some reference skin
    if (isset($_REQUEST['content']) && $_REQUEST['content'] && preg_match('/^(boxesandarrows|digital|joi|skeleton)$/', $skin)) {
        Logger::error(sprintf(i18n::s('Do not attempt to modify a reference theme directly, your changes would be overwritten on next software update. %s instead to preserve your work over time.'), Skin::build_link('skins/derive.php', i18n::s('Derive a theme'), 'shortcut')));
    }
    // backup the old version, if any
    Safe::unlink($context['path_to_root'] . 'skins/' . $skin . '/' . $file . '.bak');
    Safe::rename($context['path_to_root'] . 'skins/' . $skin . '/' . $file, $context['path_to_root'] . 'skins/' . $skin . '/' . $file . '.bak');
    // actual save
    if (Safe::file_put_contents('skins/' . $skin . '/' . $file, $_REQUEST['content']) != strlen($_REQUEST['content'])) {
        Logger::error(sprintf(i18n::s('The target file %s may have been corrupted. Please check file content manually, and revert to the backup file, with the extension .bak, if necessary.'), 'skins/' . $skin . '/' . $file));
    } else {
        $context['text'] .= '<p>' . sprintf(i18n::s('The target file %s has been successfully updated.'), 'skins/' . $skin . '/' . $file) . '</p>';
        // follow-up commands
        $follow_up = i18n::s('What do you want to do now?');
        $menu = array();
        $menu = array_merge($menu, array('skins/test.php?skin=' . urlencode($skin) => i18n::s('Test this theme')));
        $menu = array_merge($menu, array('skins/edit.php?skin=' . urlencode($skin) => i18n::s('Edit this theme')));
        $menu = array_merge($menu, array('skins/' => i18n::s('Themes')));
        $menu = array_merge($menu, array('skins/configure.php' => i18n::s('Configure the page factory')));
        $follow_up .= Skin::build_list($menu, 'menu_bar');
        $context['text'] .= Skin::build_block($follow_up, 'bottom');
    }
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:edit.php

示例5: move_uploaded_file

 /**
  * move a new file
  *
  * @param string the source file
  * @param string the destination file
  * @return TRUE on success, FALSE on failure
  */
 public static function move_uploaded_file($source, $destination)
 {
     // translate the path
     $destination = Safe::realpath($destination);
     // file may have been already loaded through ajax
     if (file_exists($source)) {
         return Safe::rename($source, $destination);
     }
     // ensure call is allowed
     if (is_callable('move_uploaded_file')) {
         return @move_uploaded_file($source, $destination);
     }
     // tough luck
     return FALSE;
 }
开发者ID:rair,项目名称:yacs,代码行数:22,代码来源:safe.php

示例6: process


//.........这里部分代码省略.........
     // the <Blogger>...</Blogger> block
     $areas = preg_split('/<Blogger>(.*?)<\\/Blogger>/is', trim($template), -1, PREG_SPLIT_DELIM_CAPTURE);
     $template = '';
     $index = 0;
     foreach ($areas as $area) {
         // blogging area
         if ($index == 1) {
             $template .= '<?php ' . "\n" . '// display the menu bar, if any' . "\n" . 'if(@count($context[\'page_menu\']) > 0)' . "\n" . '	echo Skin::build_list($context[\'page_menu\'], \'page_menu\');' . "\n" . "\n" . '// display the prefix, if any' . "\n" . 'if($context[\'prefix\'])' . "\n" . '	echo $context[\'prefix\'];' . "\n" . "\n" . '// display the error message, if any' . "\n" . 'if($context[\'error\'])' . "\n" . '	  echo Skin::build_block($context[\'error\'], \'error\');' . "\n" . "\n" . '// display the page image, if any' . "\n" . 'if($context[\'page_image\'])' . "\n" . '	  echo \'<img src="\'.$context[\'page_image\'].\'" class="icon" alt="" />\';' . "\n" . "\n" . '// the main part of the page' . "\n" . 'echo $context[\'text\'];' . "\n" . "\n" . '// display the suffix, if any' . "\n" . 'if($context[\'suffix\'])' . "\n" . '	echo \'<p>\'.$context[\'suffix\'].\'</p>\';' . "\n" . '?>';
             // make a skin for each item of the blogging area
             // break lines to not interfere with regular code
             $area = str_replace("\n", "'\n\t\t\t.'", addcslashes(trim($area), "'"));
             // <$BlogDateHeaderDate$>
             $from = '/<\\$BlogDateHeaderDate\\$>/i';
             $to = '\'.Skin::build_date($item[\'create_date\']).\'';
             $area = preg_replace($from, $to, $area);
             // <$BlogItemArchiveFileName$>
             $from = '/<\\$BlogItemArchiveFileName\\$>/i';
             $to = '\'.$context[\'url_to_root\'].Articles::get_permalink($item).\'';
             $area = preg_replace($from, $to, $area);
             // <$BlogItemAuthor$>
             $from = '/<\\$BlogItemAuthor\\$>/i';
             $to = '\'.$item[\'create_name\'].\'';
             $area = preg_replace($from, $to, $area);
             // <$BlogItemAuthorNickname$>
             $from = '/<\\$BlogItemAuthorNickname\\$>/i';
             $to = '\'.$item[\'create_name\'].\'';
             $area = preg_replace($from, $to, $area);
             // <$BlogItemBody$>
             $article_prefix .= 'unset($BlogItemBody);' . "\n" . '// the introduction' . "\n" . 'if($item[\'introduction\'])' . "\n" . '	$BlogItemBody .= Codes::beautify(trim($item[\'introduction\']));' . "\n" . 'elseif(!is_object($overlay)) {' . "\n" . '	// extract up to markup, if any' . "\n" . '	$raw = preg_split(\'/(\\[|<)/\', $item[\'description\']);' . "\n" . '	$BlogItemBody .= Skin::strip(trim($raw[0]), 30);' . "\n" . '}' . "\n" . 'if($suffix)' . "\n" . '	$BlogItemBody = \' -&nbsp;\'.$suffix;' . "\n" . "\n" . '// insert overlay data, if any' . "\n" . 'if(is_object($overlay))' . "\n" . '	$BlogItemBody .= $overlay->get_text(\'list\', $item);' . "\n" . "\n";
             $from = '/<\\$BlogItemBody\\$>/i';
             $to = '\'.$BlogItemBody.\'';
             $area = preg_replace($from, $to, $area);
             // <$BlogItemCommentCount$>
             $article_prefix .= 'unset($BlogItemCommentCount);' . "\n" . '// info on related comments' . "\n" . 'include_once $context[\'path_to_root\'].\'comments/comments.php\';' . "\n" . '$BlogItemCommentCount = Comments::count_for_anchor(\'article:\'.$item[\'id\']);' . "\n" . "\n";
             $from = '/<\\$BlogItemCommentCount\\$>/i';
             $to = '\'.$BlogItemCommentCount.\'';
             $area = preg_replace($from, $to, $area);
             // <$BlogItemControl$> -- the menu bar for associates and poster
             $article_prefix .= 'unset($BlogItemControl);' . "\n" . 'if(Surfer::is_associate() || Surfer::is($item[\'create_id\']) || Surfer::is($item[\'edit_id\'])) {' . "\n" . '	$menu = array( Articles::get_url($item[\'id\'], \'edit\') => i18n::s(\'edit\'),' . "\n" . '		Articles::get_url($item[\'id\'], \'delete\') => i18n::s(\'delete\') );' . "\n" . '	$BlogItemControl = \' \'.Skin::build_list($menu, \'menu\');' . "\n" . '}' . "\n" . "\n";
             $from = '/<\\$BlogItemControl\\$>/i';
             $to = '\'.$BlogItemControl.\'';
             $area = preg_replace($from, $to, $area);
             // <$BlogItemDateTime$>
             $from = '/<\\$BlogItemDateTime\\$>/i';
             $to = '\'.Skin::build_date($item[\'create_date\']).\'';
             $area = preg_replace($from, $to, $area);
             // <$BlogItemNumber$>
             $from = '/<\\$BlogItemNumber\\$>/i';
             $to = '\'.$item[\'id\'].\'';
             $area = preg_replace($from, $to, $area);
             // <$BlogItemPermalinkURL$>
             $from = '/<\\$BlogItemPermalinkURL\\$>/i';
             $to = '\'.$context[\'url_to_root\'].Articles::get_permalink($item).\'';
             $area = preg_replace($from, $to, $area);
             // <$BlogItemTitle$> -- it has to be the last one for this item
             $from = '/<\\$BlogItemTitle\\$>/i';
             list($item_prefix, $item_suffix) = preg_split($from, $area);
             // make a skin
             $skin .= "\n" . '	function layout_article($item, $variant = \'compact\') {' . "\n" . '		global $context;' . "\n" . '		' . str_replace("\n", "\n\t\t", $article_prefix) . "\n" . '		//	array($prefix, $title, $suffix, $type, $icon)' . "\n" . '		$prefix = \'' . trim($item_prefix) . '\';' . "\n" . '		$title = trim($item[\'title\']);' . "\n" . '		$suffix = \'' . trim($item_suffix) . '\';' . "\n" . '		return array($prefix, $title, $suffix, \'article\', NULL);' . "\n" . "\t}\n";
         } else {
             // suffix block
             $template .= $area;
         }
         $index++;
     }
     // skin end
     $skin .= "}\n" . '?>' . "\n";
     // backup the old skin, if any
     Safe::unlink($context['path_to_root'] . 'skins/' . $directory . '/skin.php.bak');
     Safe::rename($context['path_to_root'] . 'skins/' . $directory . '/skin.php', $context['path_to_root'] . 'skins/' . $directory . '/skin.php.bak');
     // create a new skin file
     if (!$skin) {
         Logger::error(i18n::s('No blogging block has been found.'));
     } elseif (!Safe::make_path('skins/' . $directory)) {
         Logger::error(sprintf(i18n::s('Impossible to create path %s.'), 'skins/' . $directory));
     } elseif (!($handle = Safe::fopen($context['path_to_root'] . 'skins/' . $directory . '/skin.php', 'wb'))) {
         Logger::error(sprintf(i18n::s('Impossible to write to %s.'), $context['path_to_root'] . 'skins/' . $directory . '/skin.php'));
     } else {
         fwrite($handle, $skin);
         fclose($handle);
     }
     // backup the old template, if any
     Safe::unlink($context['path_to_root'] . 'skins/' . $directory . '/template.php.bak');
     if (!$template) {
         Logger::error(i18n::s('Empty template file'));
     } else {
         Safe::rename($context['path_to_root'] . 'skins/' . $directory . '/template.php', $context['path_to_root'] . 'skins/' . $directory . '/template.php.bak');
     }
     // create a new template file
     if (!Safe::make_path('skins/' . $directory)) {
         Logger::error(sprintf(i18n::s('Impossible to create path %s.'), 'skins/' . $directory));
     } elseif (!($handle = Safe::fopen($context['path_to_root'] . 'skins/' . $directory . '/template.php', 'wb'))) {
         Logger::error(sprintf(i18n::s('Impossible to write to %s.'), $context['path_to_root'] . 'skins/' . $directory . '/template.php'));
     } else {
         fwrite($handle, $template);
         fclose($handle);
         $context['text'] .= '<p>' . sprintf(i18n::s('Template has been imported. Check skin %s'), Skin::build_link('skins/test.php?skin=' . $directory, $directory, 'shortcut')) . "</p>\n";
     }
     return NULL;
 }
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:import.php

示例7: explode_callback

 function explode_callback($name)
 {
     global $context;
     // reject all files put in sub-folders
     if (($path = substr($name, strlen($context['uploaded_path'] . '/'))) && strpos($path, '/') !== FALSE) {
         Safe::unlink($name);
     } elseif (!Files::is_authorized($name)) {
         Safe::unlink($name);
     } else {
         // make it easy to download
         $ascii = utf8::to_ascii(basename($name));
         Safe::rename($name, $context['uploaded_path'] . '/' . $ascii);
         // remember this name
         $context['uploaded_files'][] = $ascii;
     }
 }
开发者ID:rair,项目名称:yacs,代码行数:16,代码来源:files.php

示例8: purge_run_once

 /**
  * flag all scripts in scripts/run_once
  *
  */
 public static function purge_run_once()
 {
     global $context;
     // silently purge pending run-once scripts, if any
     if ($handle = Safe::opendir($context['path_to_root'] . 'scripts/run_once')) {
         // process every file in the directory
         while (($node = Safe::readdir($handle)) !== FALSE) {
             // skip special entries
             if ($node[0] == '.') {
                 continue;
             }
             // we are only interested in php scripts
             if (!preg_match('/\\.php$/i', $node)) {
                 continue;
             }
             // full name
             $target = $context['path_to_root'] . 'scripts/run_once/' . $node;
             // skip directories and links
             if (!is_file($target)) {
                 continue;
             }
             // check we have enough permissions
             if (!is_readable($target)) {
                 continue;
             }
             // stamp the file to remember execution time
             Safe::touch($target);
             // flag script as being already processed
             Safe::unlink($target . '.done');
             Safe::rename($target, $target . '.done');
         }
         Safe::closedir($handle);
     }
 }
开发者ID:rair,项目名称:yacs,代码行数:38,代码来源:scripts.php

示例9: define

}
// version 8.4
if (!defined('YACS')) {
    define('YACS', TRUE);
}
// version 8.5 - new side menu
if (!isset($context['page_tools'])) {
    $context['page_tools'] = array();
}
if (!isset($context['script_url'])) {
    $context['script_url'] = '';
}
// version 8.6 - new page components
if (!isset($context['page_tags'])) {
    $context['page_tags'] = '';
}
if (!isset($_SESSION['surfer_interface'])) {
    $_SESSION['surfer_interface'] = 'C';
}
// force a refresh of compacted javascript libraries
if ($items = Safe::glob($context['path_to_root'] . 'temporary/cache_*.js')) {
    foreach ($items as $name) {
        Safe::unlink($name);
    }
}
// safe copy of footprints.php to the root directory
Safe::unlink($context['path_to_root'] . 'footprints.php.bak');
Safe::rename($context['path_to_root'] . 'footprints.php', $context['path_to_root'] . 'footprints.php.bak');
Safe::copy($context['path_to_root'] . 'scripts/staging/footprints.php', $context['path_to_root'] . 'footprints.php');
// remember this as a significant event --i18n::s does not exist before 6.12
Logger::remember('scripts/update_trailer.php: update trailer has been executed');
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:update_trailer.php

示例10: elseif

 // get the file locally
 if (file_exists($local_reference)) {
     $content = Safe::file_get_contents($local_reference);
 } elseif (($content = http::proceed($remote_reference)) === FALSE) {
     $local['error_en'] = 'Unable to get ' . $file;
     $local['error_fr'] = 'Impossible d\'obtenir ' . $file;
     echo i18n::user('error') . "<br />\n";
 }
 // we have something in hand
 if ($content) {
     // create missing directories where applicable
     Safe::make_path(dirname($file));
     // create backups, if possible
     if (file_exists($context['path_to_root'] . $file)) {
         Safe::unlink($context['path_to_root'] . $file . '.bak');
         Safe::rename($context['path_to_root'] . $file, $context['path_to_root'] . $file . '.bak');
     }
     // update the target file
     if (!Safe::file_put_contents($file, $content)) {
         $local['label_en'] = 'Impossible to write to the file ' . $file . '.';
         $local['label_fr'] = 'Impossible d\'&eacute;crire le fichier ' . $file . '.';
         echo i18n::user('label') . "<br />\n";
     } else {
         $local['label_en'] = 'has been updated';
         $local['label_fr'] = 'a &eacute;t&eacute; mis &agrave; jour';
         echo $file . ' ' . i18n::user('label') . "<br />\n";
     }
 }
 // next one
 $count += 1;
 Safe::set_time_limit(30);
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:150224_lasares_to_netgrabber.php

示例11: send_body

/**
 * dynamically generate the page
 *
 * @see skins/index.php
 */
function send_body()
{
    global $context, $action;
    // check that the user is an admin, but only if there is at least one user record
    $query = "SELECT count(*) FROM " . SQL::table_name('users');
    if (!Surfer::is_associate() && SQL::query($query) !== FALSE) {
        Safe::header('Status: 401 Unauthorized', TRUE, 401);
        echo '<p>' . i18n::s('You are not allowed to perform this operation.') . "</p>\n";
        return;
    }
    // log the current surfer as an associate if not yet the case
    if (!Surfer::is_associate()) {
        $fields = array();
        $fields['id'] = 1;
        $fields['nick_name'] = 'admin';
        $fields['email'] = '';
        $fields['capability'] = 'A';
        Surfer::set($fields);
        echo '<p>' . i18n::s('You have associate privilege') . '</p>';
    }
    // check every table of the database
    if ($action == 'build') {
        // maybe we will have to switch the server off
        $temporary_off = FALSE;
        // ensure nobody else will access the database during the operation
        if (file_exists('../parameters/switch.on')) {
            if (Safe::rename($context['path_to_root'] . 'parameters/switch.on', $context['path_to_root'] . 'parameters/switch.off')) {
                echo BR . i18n::s('The server has been switched off.');
                $temporary_off = TRUE;
            }
            // let concurrent on-going transactions finish properly
            Safe::sleep(3);
            // first installation
        } elseif (!file_exists('../parameters/switch.off')) {
            echo '<p>' . i18n::s('Review provided information and go to the bottom of the page to move forward.') . "</a></p>\n";
        }
        // ensure utf8 character set for this database
        $query = "ALTER DATABASE `" . $context['database'] . "`  DEFAULT CHARACTER SET utf8";
        SQL::query($query);
        // create tables for users
        echo Users::setup();
        // create tables for activities
        echo Activities::setup();
        // create tables for notifications
        include_once '../users/notifications.php';
        echo Notifications::setup();
        // create tables for messages
        echo Mailer::setup();
        // create tables for visits
        include_once '../users/visits.php';
        echo Visits::setup();
        // create tables for sections
        echo Sections::setup();
        // create tables for articles
        echo Articles::setup();
        // create tables for images
        include_once '../images/images.php';
        echo Images::setup();
        // create tables for tables
        include_once '../tables/tables.php';
        echo Tables::setup();
        // create tables for files
        echo Files::setup();
        // create tables for links
        include_once '../links/links.php';
        echo Links::setup();
        // create tables for locations
        include_once '../locations/locations.php';
        echo Locations::setup();
        // create tables for comments
        include_once '../comments/comments.php';
        echo Comments::setup();
        // create tables for categories
        echo Categories::setup();
        // create tables for members
        include_once '../shared/members.php';
        echo Members::setup();
        // create tables for dates
        include_once '../dates/dates.php';
        echo Dates::setup();
        // create tables for servers
        include_once '../servers/servers.php';
        echo Servers::setup();
        // create tables for versions
        include_once '../versions/versions.php';
        echo Versions::setup();
        // create tables for enrolments
        include_once '../shared/enrolments.php';
        echo Enrolments::setup();
        // create tables for values
        include_once '../shared/values.php';
        echo Values::setup();
        // create tables for the cache
        echo Cache::setup();
        // create tables for the php documentation
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:setup.php

示例12: sprintf

         $content .= $chunk;
     }
 }
 // with Indexes
 if (isset($_SESSION['htaccess']['indexes'])) {
     if (!($chunk = Safe::file_get_contents('control/htaccess/indexes/.htaccess'))) {
         Logger::error(sprintf(i18n::s('Impossible to read %s.'), 'control/htaccess/indexes/.htaccess'));
     } else {
         $content .= $chunk;
     }
 }
 // ensure smooth operations
 if ($content && !count($context['error'])) {
     // backup the old version
     Safe::unlink($context['path_to_root'] . '.htaccess.bak');
     Safe::rename($context['path_to_root'] . '.htaccess', $context['path_to_root'] . '.htaccess.bak');
     // update the parameters file
     if (!Safe::file_put_contents($context['path_to_root'] . '.htaccess', $content)) {
         Logger::error(sprintf(i18n::s('ERROR: Impossible to write to the file %s. The configuration has not been saved.'), $context['path_to_root'] . '.htaccess'));
         // allow for a manual update
         $context['text'] .= '<p style="text-decoration: blink;">' . sprintf(i18n::s('To actually change the configuration, please copy and paste following lines by yourself in file %s.'), $context['path_to_root'] . '.htaccess') . "</p>\n";
         // job done
     } else {
         $context['text'] .= '<p>' . sprintf(i18n::s('The following configuration has been saved into the file %s.'), '.htaccess') . "</p>\n";
         // remember the change
         $label = sprintf(i18n::c('%s has been updated'), '.htaccess');
         Logger::remember('control/htaccess/index.php: ' . $label);
     }
     // display updated parameters
     $context['text'] .= Skin::build_box(i18n::s('Configuration parameters'), str_replace("\n", BR, htmlspecialchars($content)), 'folded');
     // follow-up commands
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:index.php

示例13: save_patterns

 /**
  * internal method to store patterns of this serveur in a file
  * this to spare time for parsing each extension in /codes at page loading
  * @see method render
  * 
  * @global array $context
  * @param array $patterns_map
  */
 private static function save_patterns($patterns_map)
 {
     global $context;
     // backup the old version
     Safe::unlink($context['path_to_root'] . 'codes/patterns.auto.php.bak');
     Safe::rename($context['path_to_root'] . 'codes/patterns.auto.php', $context['path_to_root'] . 'codes/auto.patterns.auto.php.bak');
     $content = '<?php' . "\n" . '// This file has been created by the script codes/codes.php' . "\n" . '// on ' . gmdate("F j, Y, g:i a") . ' GMT, Please do not modify it manually.' . "\n";
     foreach ($patterns_map as $pattern => $action) {
         $content .= '$patterns_map[\'' . $pattern . '\']="' . addcslashes(str_replace("\n", '\\n', $action), '"') . "\";\n";
     }
     if (!Safe::file_put_contents('codes/patterns.auto.php', $content)) {
         Logger::error(sprintf(i18n::s('ERROR: Impossible to write to the file %s. The configuration has not been saved.'), 'codes/patterns.auto.php'));
     }
 }
开发者ID:rair,项目名称:yacs,代码行数:22,代码来源:codes.php

示例14: send_body

/**
 * dynamically generate the page
 *
 * @see skins/index.php
 */
function send_body()
{
    global $context, $local;
    // $local is required to localize included scripts
    // include every script that has to be run once
    global $scripts, $scripts_count;
    if (@count($scripts)) {
        // the alphabetical order may be used to control script execution order
        sort($scripts);
        reset($scripts);
        // process each script one by one
        foreach ($scripts as $item) {
            // do not execute on first installation
            if (file_exists('../parameters/switch.on') || file_exists('../parameters/switch.off')) {
                // ensure we have a valid database resource
                if (!$context['connection']) {
                    break;
                }
                // remember this as an event
                Logger::remember('scripts/run_once.php: ' . sprintf(i18n::c('script %s has been executed'), $item));
                // where scripts actually are
                $actual_item = str_replace('//', '/', $context['path_to_root'] . 'scripts/run_once/' . $item);
                // include the script to execute it
                $scripts_count++;
                echo Skin::build_block($item, 'subtitle');
                include $actual_item;
                echo "\n";
            }
            // ensure enough overall execution time
            Safe::set_time_limit(30);
            // stamp the file to remember execution time
            Safe::touch($actual_item);
            // rename the script to avoid further execution
            Safe::unlink($actual_item . '.done');
            Safe::rename($actual_item, $actual_item . '.done');
        }
        // refresh javascript libraries
        Cache::purge('js');
    }
    // report on actual execution
    if ($scripts_count) {
        echo '<p>&nbsp;</p><p>' . sprintf(i18n::ns('%d script has been executed', '%d scripts have been executed', $scripts_count), $scripts_count) . "</p>\n";
    } else {
        echo '<p>' . i18n::s('No script has been executed') . "</p>\n";
    }
    // display the total execution time
    $time = round(get_micro_time() - $context['start_time'], 2);
    if ($time > 30) {
        echo '<p>' . sprintf(i18n::s('Script terminated in %.2f seconds.'), $time) . '</p>';
    }
    // if the server has been switched off, go back to the control panel
    if (file_exists('../parameters/switch.off')) {
        echo '<form method="get" action="' . $context['url_to_root'] . 'control/">' . "\n" . '<p class="assistant_bar">' . Skin::build_submit_button(i18n::s('Control Panel')) . '</p>' . "\n" . '</form>' . "\n";
        // else back to the control panel as well, but without a button
    } else {
        $menu = array('control/' => i18n::s('Control Panel'));
        echo Skin::build_list($menu, 'menu_bar');
    }
    // purge the cache, since it is likely that we have modified some data
    Cache::clear();
}
开发者ID:rair,项目名称:yacs,代码行数:66,代码来源:run_once.php

示例15: elseif

    // end of the form
    $context['text'] .= '</div></form>';
    // set the focus
    Page::insert_script('$("#flash_font_r").focus();');
    // general help on this form
    $help = '<p>' . i18n::s('Do not set any background color to achieve a transparent object.') . '</p>';
    $context['components']['boxes'] = Skin::build_box(i18n::s('Help'), $help, 'boxes', 'help');
    // no modifications in demo mode
} elseif (file_exists($context['path_to_root'] . 'parameters/demo.flag')) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation in demonstration mode.'));
    // save updated parameters
} else {
    // backup the old version
    Safe::unlink($context['path_to_root'] . 'parameters/feeds.flash.include.php.bak');
    Safe::rename($context['path_to_root'] . 'parameters/feeds.flash.include.php', $context['path_to_root'] . 'parameters/feeds.flash.include.php.bak');
    // build the new configuration file
    $content = '<?php' . "\n" . '// This file has been created by the configuration script feeds/flash/configure.php' . "\n" . '// on ' . gmdate("F j, Y, g:i a") . ' GMT, for ' . Surfer::get_name() . '. Please do not modify it manually.' . "\n";
    if (isset($_REQUEST['flash_font_r'])) {
        $content .= '$context[\'flash_font_r\']=' . addcslashes($_REQUEST['flash_font_r'], "\\'") . ";\n";
    }
    if (isset($_REQUEST['flash_font_g'])) {
        $content .= '$context[\'flash_font_g\']=' . addcslashes($_REQUEST['flash_font_g'], "\\'") . ";\n";
    }
    if (isset($_REQUEST['flash_font_b'])) {
        $content .= '$context[\'flash_font_b\']=' . addcslashes($_REQUEST['flash_font_b'], "\\'") . ";\n";
    }
    if (isset($_REQUEST['flash_background_r'])) {
        $content .= '$context[\'flash_background_r\']=' . addcslashes($_REQUEST['flash_background_r'], "\\'") . ";\n";
    }
    if (isset($_REQUEST['flash_background_g'])) {
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:configure.php


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