Exemplo n.º 1
0
 /**
  * Filesystem method detection
  *
  */
 function UpdateFilesystem()
 {
     global $page;
     $filesystem_method = $page->DetectFileSystem();
     self::AssertEquals($filesystem_method, 'gp_filesystem_direct');
     $this->FileSystem = \gp\tool\FileSystem::set_method('gp_filesystem_direct');
 }
Exemplo n.º 2
0
 public function __construct()
 {
     global $langmessage, $dataDir;
     $this->server_name = gpsession::ServerName();
     //get current rules
     $this->rule_file_name = self::IIS() ? 'web.config' : '.htaccess';
     $this->rule_file = $dataDir . '/' . $this->rule_file_name;
     if (file_exists($this->rule_file)) {
         $this->orig_rules = file_get_contents($this->rule_file);
     }
     $this->FileSystem = \gp\tool\FileSystem::init($this->rule_file);
     $this->WWWAvail();
     echo '<h2>' . $langmessage['permalink_settings'] . '</h2>';
     $cmd = common::GetCommand();
     switch ($cmd) {
         case 'continue':
             if (!$this->SaveHtaccess()) {
                 break;
             }
         default:
             $this->ShowForm();
             break;
     }
 }
Exemplo n.º 3
0
 /**
  * Prepare FileSystem for writing to $dataDir
  * $dataDir writability is required so that we can create & rename subfolders: $dataDir/data, $dataDir/themes
  *
  */
 public function RevertFilesystem()
 {
     global $dataDir, $langmessage;
     $this->FileSystem = \gp\tool\FileSystem::init($dataDir);
     if (is_null($this->FileSystem)) {
         message($langmessage['OOPS'] . ' (No filesystem)');
         return false;
     }
     return true;
 }
Exemplo n.º 4
0
 /**
  * Download the source code
  *
  */
 function DownloadSource()
 {
     global $langmessage, $dataDir;
     $this->msg('Downloading version ' . $this->core_package['version'] . ' from ' . CMS_READABLE_DOMAIN . '.');
     /* for testing
      * $download = 'http://gpeasy.loc/x_gpEasy.zip';
      */
     $download = addon_browse_path . '/Special_gpEasy?cmd=download';
     $contents = \gp\tool\RemoteGet::Get_Successful($download);
     if (!$contents || empty($contents)) {
         $this->msg($langmessage['download_failed'] . '(1)');
         return false;
     }
     $this->msg($langmessage['package_downloaded']);
     $md5 = md5($contents);
     if ($md5 != $this->core_package['md5']) {
         $this->msg($langmessage['download_failed_md5'] . '<br/>Downloaded Checksum (' . $md5 . ') != Expected Checksum (' . $this->core_package['md5'] . ')');
         return false;
     }
     $this->msg($langmessage['download_verified']);
     //save contents
     $temp_file = $dataDir . \gp\tool\FileSystem::TempFile('/data/_temp/update', '.zip');
     if (!\gp\tool\Files::Save($temp_file, $contents)) {
         $this->msg($langmessage['download_failed'] . ' (2)');
         return false;
     }
     $this->core_package['file'] = $temp_file;
     return true;
 }
Exemplo n.º 5
0
 /**
  * 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']);
 }
Exemplo n.º 6
0
 /**
  * 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 (!\gp\tool\Files::Replace($rename_from, $this->source)) {
         $this->message($langmessage['download_failed'] . ' (Not replaced)');
         return false;
     }
     return true;
 }