diff --git a/TeStore/Action.php b/TeStore/Action.php index 9bd74011..dec50f5e 100644 --- a/TeStore/Action.php +++ b/TeStore/Action.php @@ -94,7 +94,7 @@ public function getPluginData() $page = str_replace(array('github.com', 'raw.githubusercontent.com'), $proxy, $page); $page = str_replace(array('blob/', 'raw/', 'master/'), '', $page); } else { - $page = rtrim($proxy, "/") . $page; + $page = Typecho_Common::url($page, $proxy); } } $html .= $this->useCurl ? $this->curlGet($page) : @file_get_contents($page,0, @@ -223,14 +223,19 @@ public function install() $this->makedir($tempDir); //创建临时目录 } $proxy = $this->settings->proxy; + $isRaw = strpos($zip, 'raw.githubusercontent.com') || strpos($zip, 'raw/master'); //替换为加速地址 - if ($proxy || strpos($zip, 'raw.githubusercontent.com') || strpos($zip, 'raw/master')) { - $cdn = $this->ZIP_CDN($plugin, $author); - $zip = $cdn ? $cdn : $zip; - $proxy = $proxy ? $proxy : 'cdn.jsdelivr.net/gh'; - $zip = str_replace(array('github.com', 'raw.githubusercontent.com'), $proxy, $zip); - $zip = substr($proxy, -3) === "/gh" ? str_replace(array('blob/', 'raw/', 'master/'), '', $zip) : str_replace(array('blob/', 'raw/'), '', $zip); - } + if ($proxy || $isRaw) { + if (substr($proxy, -3) === "/gh") { + $cdn = $this->ZIP_CDN($plugin, $author); + $zip = $cdn ? $cdn : $zip; + $proxy = $proxy ? $proxy : 'cdn.jsdelivr.net/gh'; + $zip = str_replace(array('github.com', 'raw.githubusercontent.com'), $proxy, $zip); + $zip = substr($proxy, -3) === "/gh" ? str_replace(array('blob/', 'raw/', 'master/'), '', $zip) : str_replace(array('blob/', 'raw/'), '', $zip); + } else { + $zip = Typecho_Common::url($zip, $proxy); + } + } //下载至临时目录 $zipFile = $this->useCurl ? $this->curlGet($zip) : @file_get_contents($zip, 0, diff --git a/TeStore/Plugin.php b/TeStore/Plugin.php index 11d5bdaf..5ff48ab3 100644 --- a/TeStore/Plugin.php +++ b/TeStore/Plugin.php @@ -2,7 +2,7 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; /** * 读取Github上维护的专用表格实现插件仓库各项功能 - * + * * @package TeStore * @author 羽中, zhulin3141, Ryan * @version 1.1.6 @@ -15,7 +15,7 @@ class TeStore_Plugin implements Typecho_Plugin_Interface { /** * 激活插件方法,如果激活失败,直接抛出异常 - * + * * @access public * @return void * @throws Typecho_Plugin_Exception @@ -46,7 +46,7 @@ public static function activate() /** * 禁用插件方法,如果禁用失败,直接抛出异常 - * + * * @static * @access public * @return void @@ -62,7 +62,7 @@ public static function deactivate() /** * 获取插件配置面板 - * + * * @access public * @param Typecho_Widget_Helper_Form $form 配置面板 * @return void @@ -91,7 +91,7 @@ public static function config(Typecho_Widget_Helper_Form $form) $form->addInput($cache); $proxy = new Typecho_Widget_Helper_Form_Element_Radio('proxy', - array(''=>_t('否'),'cdn.jsdelivr.net/gh'=>_t('jsDelivr镜像'),'jsd.onmicrosoft.cn/gh'=>_t('渺软镜像')),'',_t('使用代理加速'),_t('GitHub连接不畅时可选')); + array(''=>_t('否'),'cdn.jsdelivr.net/gh'=>_t('jsDelivr镜像'),'jsd.onmicrosoft.cn/gh'=>_t('渺软镜像'), 'https://ghmirror.pp.ua' => _('GitHub Proxy')),'',_t('使用代理加速'),_t('GitHub连接不畅时可选')); $form->addInput($proxy); $curl = new Typecho_Widget_Helper_Form_Element_Checkbox('curl', @@ -105,7 +105,7 @@ public static function config(Typecho_Widget_Helper_Form $form) /** * 检查cURL支持 - * + * * @param array $settings * @return string */ @@ -121,7 +121,7 @@ public static function configCheck(array $settings) /** * 个人用户的配置面板 - * + * * @access public * @param Typecho_Widget_Helper_Form $form * @return void @@ -130,7 +130,7 @@ public static function personalConfig(Typecho_Widget_Helper_Form $form){} /** * 输出导航按钮 - * + * * @access public * @return void */ @@ -144,7 +144,7 @@ public static function render() /** * 判断目录可写 - * + * * @access public * @return boolean */