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


PHP Zend_Rest_Client::getUpdateLink方法代码示例

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


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

示例1: updateToNewVersion

 private function updateToNewVersion()
 {
     ini_set('max_execution_time', 0);
     $tp = SJB_System::getTemplateProcessor();
     $errors = array();
     $isZipExtLoaded = extension_loaded('zip');
     $tp->assign('zip_extension_loaded', $isZipExtLoaded);
     $updatesDir = SJB_System::getSystemSettings('SJB_UPDATES_DIR');
     $updateToVer = SJB_Request::getVar('to_version');
     if (!empty($updateToVer)) {
         // remove all path elements
         $updateToVer = basename($updateToVer);
         $startPath = $updatesDir . $updateToVer . DIRECTORY_SEPARATOR . "updater.php";
         if (file_exists($startPath)) {
             include_once $startPath;
         } else {
             echo '<p class="error">' . SJB_I18N::getInstance()->gettext(null, 'Update package files are missing') . '</p>';
         }
         $tp->display('updater_starts.tpl');
     } else {
         $formSubmitted = SJB_Request::getVar('update_to_version');
         $wayToUpdate = SJB_Request::getVar('way_to_update');
         if (!$isZipExtLoaded) {
             $errors[] = "The update process cannot be continued. There is no Zip-extension for PHP installed on your server.\nPlease install it and try again.";
         }
         if (!empty($formSubmitted) && $isZipExtLoaded) {
             // OK. we need to create Zend_Rest_Client, check user and get available updates if allowed
             $client = new Zend_Rest_Client(SJB_System::getSystemSettings('SJB_UPDATE_SERVER_URL'));
             $result = $client->getUpdateLink(SJB_Request::getVar('auth_username'), SJB_Request::getVar('auth_password'), SJB_System::getSystemSettings('version'))->get();
             if ($result->isSuccess()) {
                 if (isset($result->error)) {
                     $errors[] = (string) $result->error;
                     $tp->assign("wayToUpdate", $wayToUpdate);
                 }
                 if (isset($result->update)) {
                     $updateLink = (string) $result->update;
                     $downloadedFileName = basename($updateLink);
                     $unzipDirname = basename($updateLink, '.zip');
                     $downloadedFilePath = $updatesDir . $downloadedFileName;
                     // download update file to cache/updates folder
                     $result = copy($updateLink, $downloadedFilePath);
                     if ($result) {
                         if ($isZipExtLoaded) {
                             $zip = new ZipArchive();
                             $res = $zip->open($downloadedFilePath);
                             if ($res === true) {
                                 $zip->extractTo($updatesDir . DIRECTORY_SEPARATOR . $unzipDirname . DIRECTORY_SEPARATOR);
                                 $zip->close();
                             } else {
                                 $errors[] = 'Failed to extract upgrade package files';
                             }
                         } else {
                             $errors[] = "The update process cannot be continued. There is no Zip-extension for PHP installed on your server.\nPlease install it and try again.";
                         }
                     } else {
                         $errors[] = 'Failed to download upgrade package';
                     }
                     if ($wayToUpdate == 'autoUpdate') {
                         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('ADMIN_SITE_URL') . '/update-to-new-version/?to_version=' . urlencode($unzipDirname));
                     } elseif ($wayToUpdate == 'makeArchive') {
                         $ignorePaths = array('system/plugins/facebook_social_plugin', 'system/plugins/linkedin_social_plugin', 'system/plugins/broadbean_integration_plugin', 'system/plugins/jobg8_integration_plugin', 'system/plugins/mobile', 'system/plugins/api', 'system/plugins/facebook_app', 'templates/Facebook', 'templates/BusinessView', 'templates/ClearView', 'templates/EnhancedView', 'templates/ElegantView', 'templates/mobile');
                         $serializedFilesInfo = file_get_contents($updatesDir . $unzipDirname . DIRECTORY_SEPARATOR . 'files_info_serialized.info');
                         $filesInfo = unserialize($serializedFilesInfo);
                         $filesList = array_keys($filesInfo);
                         $updateManager = new SJB_UpdateManager($unzipDirname);
                         foreach ($filesInfo as $key => $fileInfo) {
                             $filepath = $fileInfo['filepath'];
                             foreach ($ignorePaths as $ignorePath) {
                                 if (strpos($filepath, $ignorePath) !== false) {
                                     $ignorePath = SJB_BASE_DIR . $ignorePath;
                                     if (!file_exists($ignorePath)) {
                                         unset($filesInfo[$key]);
                                         continue 2;
                                     }
                                 }
                             }
                         }
                         $errors = $updateManager->createZipArchiveWithFiles($filesList, $filesInfo);
                         if (empty($errors)) {
                             $updateManager->sendArchiveToUser();
                             exit;
                         }
                     }
                 }
             }
         }
         $tp->assign('errors', $errors);
         $tp->display('update_to_new_version.tpl');
     }
 }
开发者ID:Maxlander,项目名称:shixi,代码行数:90,代码来源:update_to_new_version.php


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