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


PHP gpFiles::Replace方法代码示例

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


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

示例1: UploadPlugin

 /**
  * Add an uploaded plugin
  *
  */
 function UploadPlugin()
 {
     global $langmessage, $dataDir;
     includeFile('admin/admin_uploaded.php');
     $archive = $this->UploadedArchive();
     if (!$archive) {
         return false;
     }
     // get plugin name and check file types
     $list = $archive->ListFiles();
     $plugin_name = '';
     $remove_path = '';
     foreach ($list as $file) {
         //don't check extensions on folder
         if ($file['size'] == 0) {
             continue;
         }
         //check extension
         if (!admin_uploaded::AllowedExtension($file['name'], false)) {
             msg($langmessage['OOPS'] . ' (File type not allowed:' . htmlspecialchars($file['name']) . ')');
             return false;
         }
         //plugin name
         if (strpos($file['name'], 'plugin.js') !== false) {
             $new_plugin_name = $this->FindPluginName($archive, $file['name']);
             if (!$new_plugin_name) {
                 continue;
             }
             //use the most relevant plugin name
             $new_path = dirname($file['name']);
             if (!$plugin_name || strlen($new_path) < strlen($remove_path)) {
                 $plugin_name = $new_plugin_name;
                 $remove_path = $new_path;
             }
         }
     }
     if (!$this->CanUpload($plugin_name)) {
         return;
     }
     //extract to temporary location
     $extract_temp = $dataDir . \gp\tool\FileSystem::TempFile('/data/_temp/' . $plugin_name);
     if (!$archive->extractTo($extract_temp)) {
         gpFiles::RmAll($extract_temp);
         msg($langmessage['OOPS'] . ' (Couldn\'t extract to temp location)');
         return false;
     }
     //move to _ckeditor folder
     $destination = $dataDir . '/data/_ckeditor/' . $plugin_name;
     $rename_from = $extract_temp . '/' . ltrim($remove_path, '/');
     if (!gpFiles::Replace($rename_from, $destination)) {
         msg($langmessage['OOPS'] . ' (Not replaced)');
         return false;
     }
     // save configuration
     if (!array_key_exists($plugin_name, $this->cke_config['plugins'])) {
         $this->cke_config['plugins'][$plugin_name] = array('installed' => time());
     }
     $this->cke_config['plugins'][$plugin_name]['updated'] = time();
     $this->SaveConfig();
     msg($langmessage['SAVED']);
 }
开发者ID:VTAMAGNO,项目名称:gpEasy-CMS,代码行数:65,代码来源:admin_ckeditor.php

示例2: ExtractArchive

 /**
  * Write Archive
  *
  */
 private function ExtractArchive($archive_path)
 {
     global $langmessage, $dataDir;
     $archive = new \gp\tool\Archive($archive_path);
     $extract_temp = $dataDir . \gp\tool\FileSystem::TempFile('/data/_temp/addon');
     if (!$archive->extractTo($extract_temp)) {
         $this->message($langmessage['download_failed'] . ' (Package not extracted)');
         return false;
     }
     //get archive root
     $archive_root = $archive->GetRoot();
     if (is_null($archive_root)) {
         $this->message($langmessage['download_failed'] . ' (Root not found)');
         return false;
     }
     //rename to source folder
     $rename_from = $extract_temp . '/' . ltrim($archive_root, '/');
     if (!gpFiles::Replace($rename_from, $this->source)) {
         $this->message($langmessage['download_failed'] . ' (Not replaced)');
         return false;
     }
     return true;
 }
开发者ID:VTAMAGNO,项目名称:gpEasy-CMS,代码行数:27,代码来源:admin_addon_installer.php


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