コード例 #1
0
ファイル: Manager.php プロジェクト: laiello/resmania
 /**
  * @throws RM_Exception
  * @param RM_Plugin_Row $row
  * @return bool
  */
 function autoUpgrade(RM_Plugin_Row $row)
 {
     $sourceFile = $this->_getUpgradeURL($row->name);
     if (!$sourceFile) {
         throw new RM_Exception($this->_translate->_('Admin.Plugins.AutoUpgradeMsg', 'CannotUpgrade'));
     }
     $fileName = $row->name . ".zip";
     $destinationFile = RM_Environment::getConnector()->getRootPath() . DIRECTORY_SEPARATOR . 'RM' . DIRECTORY_SEPARATOR . 'userdata' . DIRECTORY_SEPARATOR . 'temp' . DIRECTORY_SEPARATOR . $fileName;
     $system = new RM_Filesystem();
     $result = $system->fileDownload($sourceFile, $destinationFile);
     if ($result == false) {
         throw new RM_Exception($this->_translate->_('Admin.Plugins.AutoUpgradeMsg', 'DownloadFailed'));
     }
     $json = new stdClass();
     $json->success = 1;
     $json->msg = array();
     return $this->upgrade($fileName, $destinationFile, $json);
 }
コード例 #2
0
ファイル: SystemController.php プロジェクト: laiello/resmania
 /** Download the Core Zip File
  *  step 1
  *
  * @return json
  */
 public function downloadcoreJsonAction()
 {
     $tmpPath = implode(DIRECTORY_SEPARATOR, array(RM_Environment::getConnector()->getRootPath(), 'RM', 'userdata', 'temp'));
     if (is_writable($tmpPath)) {
         if (!file_exists($tmpPath . DIRECTORY_SEPARATOR . "upgrade")) {
             if (!@mkdir($tmpPath . DIRECTORY_SEPARATOR . "upgrade")) {
                 return array('data' => array('success' => false, 'msg' => 'Could not create temp upgrade folder'));
             }
         }
     } else {
         return array('data' => array('success' => false, 'msg' => 'Temp Not Writable'));
     }
     $version = RM_Environment::getInstance()->getLatestVersion();
     $config = new RM_Config();
     $licenseKey = $config->getValue('rm_config_licensekey');
     $sourceFileSize = @file_get_contents(RM_Environment::getInstance()->getDistroURL() . "d.php?d=" . base64_encode('{"d": "' . $_SERVER['SERVER_NAME'] . '", "l": "' . $licenseKey . '", "p": "core", "v":"' . $version . '", "qt": "size"}'));
     if ($sourceFileSize === "false") {
         return array('data' => array('success' => false, 'msg' => $this->_translate->_('Common', 'LicenseNotValid')));
     }
     $sourceFile = RM_Environment::getInstance()->getDistroURL() . "d.php?d=" . base64_encode('{"d": "' . $_SERVER['SERVER_NAME'] . '", "l": "' . $licenseKey . '", "p": "core", "v":"' . $version . '"}');
     $this->_setSourceSize($sourceFileSize, $this->_getParam('sessionid'));
     $destinationFile = $tmpPath . DIRECTORY_SEPARATOR . 'upgrade' . DIRECTORY_SEPARATOR . 'core.zip';
     // remove any old versions of core.zip
     unlink($destinationFile);
     if (function_exists('copy')) {
         // check this is enabled
         $copyResult = copy($sourceFile, $destinationFile);
     } else {
         // try to use fopen to copy this instead...
         $rmfs = new RM_Filesystem();
         $copyResult = $rmfs->fileDownload($sourceFile, $destinationFile);
     }
     if (!$copyResult) {
         RM_Log::toLog('Upgrade - Core Download Failed (source: ' . $sourceFile . " destination: " . $destinationFile . ")", RM_Log::ERR);
         return array('data' => array('success' => false, 'msg' => 'Download Failed'));
     }
     RM_Log::toLog('Upgrade - Core Download Completed OK', RM_Log::INFO);
     return array('data' => array('success' => true));
 }