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


PHP Dir::copy方法代码示例

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


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

示例1: main

 /**
  * Backup admin
  */
 public static function main()
 {
     $backups_path = ROOT . DS . 'backups';
     // Create backup
     // -------------------------------------
     if (Request::post('create_backup')) {
         if (Security::check(Request::post('csrf'))) {
             @set_time_limit(0);
             @ini_set("memory_limit", "512M");
             $zip = Zip::factory();
             // Add storage folder
             $zip->readDir(STORAGE . DS, false);
             // Add public folder
             $zip->readDir(ROOT . DS . 'public' . DS, false);
             // Add plugins folder
             $zip->readDir(PLUGINS . DS, false, null, array(PLUGINS . DS . 'box'));
             if ($zip->archive($backups_path . DS . Date::format(time(), "Y-m-d-H-i-s") . '.zip')) {
                 Notification::set('success', __('Backup was created', 'backup'));
             } else {
                 Notification::set('error', __('Backup was not created', 'backup'));
             }
             Request::redirect(Option::get('siteurl') . '/admin/index.php?id=backup');
         } else {
             die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
         }
     }
     // Delete backup
     // -------------------------------------
     if (Request::get('id') == 'backup' && Request::get('delete_file')) {
         if (Security::check(Request::get('token'))) {
             if (File::delete($backups_path . DS . Request::get('delete_file'))) {
                 Notification::set('success', __('Backup was deleted', 'backup'));
             } else {
                 Notification::set('error', __('Backup was not deleted', 'backup'));
             }
             Request::redirect(Option::get('siteurl') . '/admin/index.php?id=backup');
         } else {
             die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
         }
     }
     // Download backup
     // -------------------------------------
     if (Request::get('download')) {
         if (Security::check(Request::get('token'))) {
             File::download($backups_path . DS . Request::get('download'));
         } else {
             die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
         }
     }
     // Restore backup
     // -------------------------------------
     if (Request::get('restore')) {
         if (Security::check(Request::get('token'))) {
             $tmp_dir = ROOT . DS . 'tmp' . DS . uniqid('backup_');
             if (Dir::create($tmp_dir)) {
                 $file_locations = Zip::factory()->extract($backups_path . DS . Request::get('restore'), $tmp_dir);
                 if (!empty($file_locations)) {
                     Dir::copy($tmp_dir, ROOT . DS);
                     Notification::set('success', __('Backup was restored', 'backup'));
                 } else {
                     Notification::set('error', __('Unzip error', 'backup'));
                 }
             } else {
                 Notification::set('error', __('Backup was not restored', 'backup'));
             }
             Request::redirect(Option::get('siteurl') . '/admin/index.php?id=backup');
         } else {
             die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
         }
     }
     // Display view
     View::factory('box/backup/views/backend/index')->assign('backups_list', File::scan($backups_path, '.zip'))->display();
 }
开发者ID:rowena-altastratus,项目名称:altastratus,代码行数:76,代码来源:backup.admin.php

示例2: copy

 public function copy($destination)
 {
     return is_dir($this->path) ? Dir::copy($this->path, $destination) : File::copy($this->path, $destination);
 }
开发者ID:ncaneldiee,项目名称:sampadeh,代码行数:4,代码来源:Filesystem.php

示例3: copy

 /**
  * Copy directory. 
  * 
  * Skip unreadable entries.
  *
  * @param string $source_dir
  * @param string $target_dir
  * @param string $link_root (default = '', if set keep links)
  */
 public static function copy($source_dir, $target_dir, $link_root = '')
 {
     if (empty($source_dir)) {
         throw new Exception("Source directory is empty");
     }
     if (empty($target_dir)) {
         throw new Exception("Target directory is empty");
     }
     $s = FSEntry::stat($source_dir);
     if (!FSEntry::isDir($target_dir, false)) {
         Dir::create($target_dir, $s['perms']['octal']);
     }
     $entries = Dir::entries($source_dir);
     foreach ($entries as $entry) {
         $s = FSEntry::stat($entry);
         if ($s['filetype']['is_link'] && $link_root) {
             if (($pos = mb_strpos($s['file']['realpath'], $link_root)) !== false && $pos == 0) {
                 // link is inside source dir
                 $link_target = str_replace($link_root . '/', '', $s['file']['realpath']);
                 symlink($link_target, $target_dir . '/' . basename($entry));
             } else {
                 symlink($s['file']['realpath'], $target_dir . '/' . basename($entry));
             }
             continue;
         }
         if (!$s['filetype']['is_readable']) {
             if (self::$SKIP_UNREADABLE) {
                 continue;
             }
             throw new Exception("Entry is unreadable", $entry);
         }
         if ($s['filetype']['is_dir']) {
             $target_subdir = $target_dir . '/' . basename($entry);
             Dir::create($target_subdir, $s['perms']['octal']);
             Dir::copy($entry, $target_subdir, $link_root);
         } else {
             if ($s['filetype']['is_file']) {
                 File::copy($entry, $target_dir . '/' . basename($entry), $s['perms']['octal']);
             }
         }
     }
 }
开发者ID:RolandKujundzic,项目名称:rkphplib,代码行数:51,代码来源:Dir.class.php

示例4: main


//.........这里部分代码省略.........
                 include PLUGINS . DS . basename(Text::lowercase(Request::get('install')), '.manifest.xml') . DS . 'install' . DS . $plugin_name . '.install.php';
             }
             Request::redirect('index.php?id=plugins');
         } else {
             die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
         }
     }
     // Delete plugin from server
     // -------------------------------------
     if (Request::get('delete_plugin_from_server')) {
         if (Security::check(Request::get('token'))) {
             // Clean Monstra TMP folder.
             Monstra::cleanTmp();
             Stylesheet::stylesVersionIncrement();
             Javascript::javascriptVersionIncrement();
             Dir::delete(PLUGINS . DS . basename(Request::get('delete_plugin_from_server'), '.manifest.xml'));
             Request::redirect('index.php?id=plugins');
         } else {
             die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
         }
     }
     // Upload & extract plugin archive
     // -------------------------------------
     if (Request::post('upload_file')) {
         if (Security::check(Request::post('csrf'))) {
             if ($_FILES['file']) {
                 if (in_array(File::ext($_FILES['file']['name']), array('zip'))) {
                     $tmp_dir = ROOT . DS . 'tmp' . DS . uniqid('plugin_');
                     $error = 'Plugin was not uploaded';
                     if (Dir::create($tmp_dir)) {
                         $file_locations = Zip::factory()->extract($_FILES['file']['tmp_name'], $tmp_dir);
                         if (!empty($file_locations)) {
                             $manifest = '';
                             foreach ($file_locations as $filepath) {
                                 if (substr($filepath, -strlen('.manifest.xml')) === '.manifest.xml') {
                                     $manifest = $filepath;
                                     break;
                                 }
                             }
                             if (!empty($manifest) && basename(dirname($manifest)) === 'install') {
                                 $manifest_file = pathinfo($manifest, PATHINFO_BASENAME);
                                 $plugin_name = str_replace('.manifest.xml', '', $manifest_file);
                                 if (Dir::create(PLUGINS . DS . $plugin_name)) {
                                     $tmp_plugin_dir = dirname(dirname($manifest));
                                     Dir::copy($tmp_plugin_dir, PLUGINS . DS . $plugin_name);
                                     Notification::set('success', __('Plugin was uploaded', 'plugins'));
                                     $error = false;
                                 }
                             }
                         }
                     } else {
                         $error = 'System error';
                     }
                 } else {
                     $error = 'Forbidden plugin file type';
                 }
             } else {
                 $error = 'Plugin was not uploaded';
             }
             if ($error) {
                 Notification::set('error', __($error, 'plugins'));
             }
             if (Request::post('dragndrop')) {
                 Request::shutdown();
             } else {
                 Request::redirect($site_url . '/admin/index.php?id=plugins#installnew');
             }
         } else {
             die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
         }
     }
     // Installed plugins
     $plugins_installed = array();
     // New plugins
     $plugins_new = array();
     // Plugins to install
     $plugins_to_intall = array();
     // Scan plugins directory for .manifest.xml
     $plugins_new = File::scan(PLUGINS, '.manifest.xml');
     // Get installed plugins from plugins table
     $plugins_installed = $plugins->select(null, 'all', null, array('location', 'priority'), 'priority', 'ASC');
     // Update $plugins_installed array. extract plugins names
     foreach ($plugins_installed as $plg) {
         $_plg[] = basename($plg['location'], 'plugin.php') . 'manifest.xml';
     }
     // Diff
     $plugins_to_install = array_diff($plugins_new, $_plg);
     // Create array of plugins to install
     $count = 0;
     foreach ($plugins_to_install as $plugin) {
         $plg_path = PLUGINS . DS . Text::lowercase(basename($plugin, '.manifest.xml')) . DS . 'install' . DS . $plugin;
         if (file_exists($plg_path)) {
             $plugins_to_intall[$count]['path'] = $plg_path;
             $plugins_to_intall[$count]['plugin'] = $plugin;
             $count++;
         }
     }
     // Draw template
     View::factory('box/plugins/views/backend/index')->assign('installed_plugins', $installed_plugins)->assign('plugins_to_intall', $plugins_to_intall)->assign('_users_plugins', $_users_plugins)->assign('fileuploader', array('uploadUrl' => $site_url . '/admin/index.php?id=plugins', 'csrf' => Security::token(), 'errorMsg' => __('Upload server error', 'filesmanager')))->display();
 }
开发者ID:rowena-altastratus,项目名称:altastratus,代码行数:101,代码来源:plugins.admin.php


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