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


PHP Safe::copy方法代码示例

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


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

示例1: preg_replace

         if (preg_match('/(\\.php|\\.css)$/i', $target) && ($content = Safe::file_get_contents($context['path_to_root'] . $origin))) {
             // change internal reference
             $content = preg_replace('/skins\\/' . preg_quote($skin, '/') . '/i', 'skins/' . $directory, $content);
             $content = preg_replace('/\'' . preg_quote($skin, '/') . '\'/i', "'" . $directory . "'", $content);
             $content = preg_replace('/' . preg_quote($skin, '/') . '\\.css/i', $directory . ".css", $content);
             // not part of the reference set anymore
             $content = preg_replace('/\\s*\\*\\s+@reference\\s*\\n/i', "\n", $content);
             // save it as the new cache file
             if (Safe::file_put_contents($target, $content)) {
                 $context['text'] .= sprintf(i18n::s('%s has been transcoded'), $target) . BR . "\n";
             } else {
                 $context['text'] .= sprintf(i18n::s('Impossible to write to %s.'), $target) . BR . "\n";
                 $errors++;
             }
             // copy the file
         } elseif (!Safe::copy($context['path_to_root'] . $origin, $context['path_to_root'] . $target)) {
             $context['text'] .= sprintf(i18n::s('Impossible to copy file %s.'), $target) . BR . "\n";
             $errors++;
             // attempt to preserve the modification date of the origin file
         } else {
             Safe::touch($context['path_to_root'] . $target, Safe::filemtime($context['path_to_root'] . $origin));
             $context['text'] .= sprintf(i18n::s('%s has been copied'), $target) . BR . "\n";
         }
         // this will be filtered by umask anyway
         Safe::chmod($context['path_to_root'] . $target, $context['file_mask']);
     }
     $context['text'] .= "</p>\n";
 }
 // some errors have occured
 if ($errors) {
     $context['text'] .= '<p>' . i18n::s('Operation has failed.') . "</p>\n";
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:derive.php

示例2: duplicate_for_anchor

 /**
  * duplicate all images for a given anchor
  *
  * This function duplicates records in the database, and changes anchors
  * to attach new records as per second parameter.
  *
  * @param string the source anchor
  * @param string the target anchor
  * @return int the number of duplicated records
  *
  * @see shared/anchors.php
  */
 public static function duplicate_for_anchor($anchor_from, $anchor_to)
 {
     global $context;
     // look for records attached to this anchor
     $count = 0;
     $query = "SELECT * FROM " . SQL::table_name('images') . " WHERE anchor LIKE '" . SQL::escape($anchor_from) . "'";
     if (($result = SQL::query($query)) && SQL::count($result)) {
         // create target folders
         $file_to = $context['path_to_root'] . Files::get_path($item['anchor'], 'images');
         if (!Safe::make_path($file_to . '/thumbs')) {
             Logger::error(sprintf(i18n::s('Impossible to create path %s.'), $file_to . '/thumbs'));
         }
         $file_to = $context['path_to_root'] . $file_to . '/';
         // the list of transcoded strings
         $transcoded = array();
         // process all matching records one at a time
         $file_from = $context['path_to_root'] . Files::get_path($anchor_from, 'images');
         while ($item = SQL::fetch($result)) {
             // sanity check
             if (!file_exists($context['path_to_root'] . $file_from . '/' . $item['image_name'])) {
                 continue;
             }
             // duplicate image file
             if (!copy($context['path_to_root'] . $file_from . '/' . $item['image_name'], $file_to . $item['image_name'])) {
                 Logger::error(sprintf(i18n::s('Impossible to copy file %s.'), $item['image_name']));
                 continue;
             }
             // this will be filtered by umask anyway
             Safe::chmod($file_to . $item['image_name'], $context['file_mask']);
             // copy the thumbnail as well
             Safe::copy($context['path_to_root'] . $file_from . '/' . $item['thumbnail_name'], $file_to . $item['thumbnail_name']);
             // this will be filtered by umask anyway
             Safe::chmod($file_to . $item['thumbnail_name'], $context['file_mask']);
             // a new id will be allocated
             $old_id = $item['id'];
             unset($item['id']);
             // target anchor
             $item['anchor'] = $anchor_to;
             // actual duplication
             if ($new_id = Images::post($item)) {
                 // more pairs of strings to transcode --no automatic solution for [images=...]
                 $transcoded[] = array('/\\[image=' . preg_quote($old_id, '/') . '/i', '[image=' . $new_id);
                 // duplicate elements related to this item
                 Anchors::duplicate_related_to('image:' . $old_id, 'image:' . $new_id);
                 // stats
                 $count++;
             }
         }
         // transcode in anchor
         if ($anchor = Anchors::get($anchor_to)) {
             $anchor->transcode($transcoded);
         }
     }
     // number of duplicated records
     return $count;
 }
开发者ID:rair,项目名称:yacs,代码行数:68,代码来源:images.php

示例3: 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

示例4: sprintf

     if (strpos($file, '.include.php')) {
         continue;
     }
     // process only reference scripts
     if (!($footprint = Scripts::hash($file))) {
         $context['text'] .= sprintf(i18n::s('%s is not a reference script'), $file) . BR . "\n";
         continue;
     }
     // store the footprint for later use --number of lines, content hash
     $footprints[$file] = array($footprint[0], $footprint[1]);
     // ensure a clean reference store
     Safe::unlink($context['path_to_reference'] . $file);
     // create adequate path
     if (!Safe::make_path($context['path_to_reference'] . dirname($file))) {
         $context['text'] .= sprintf(i18n::s('Impossible to create path %s.'), $context['path_to_reference'] . dirname($file)) . BR . "\n";
     } elseif (!Safe::copy($context['path_to_root'] . $file, $context['path_to_reference'] . $file)) {
         $context['text'] .= sprintf(i18n::s('Impossible to copy file %s.'), $file) . BR . "\n";
     } else {
         // try to preserve the modification date
         Safe::touch($context['path_to_reference'] . $file, Safe::filemtime($context['path_to_root'] . $file));
         // this will be filtered by umask anyway
         Safe::chmod($context['path_to_reference'] . $file, $context['file_mask']);
     }
     // avoid timeouts
     if (!(count($footprints) % 50)) {
         Safe::set_time_limit(30);
         SQL::ping();
     }
 }
 if (count($footprints)) {
     $context['text'] .= sprintf(i18n::s('%d reference scripts have been copied.'), count($footprints)) . "\n";
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:build.php


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