diff --git a/config/define.php b/config/define.php index ed6f55b..36f29a1 100755 --- a/config/define.php +++ b/config/define.php @@ -31,6 +31,7 @@ define('ADMIN_USER_CLOSE', 2); define('FREE_LOGIN_STR', '2c131fa45a19a7aa6d9d0123g'); + define('FREE_DOWNLOAD_STR', '3c151jg5a4dga16a7a6d9n02gf'); define('WEIXIN_OPEN_APPID','wx68a1060c4ec4722f'); define('WEIXIN_OPEN_APPSCRET','9f8a1dd8352e1150a40ebf3262429f69'); define('WEIXIN_OPEN_GET_ACCESS_TOKEN','https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code'); @@ -40,8 +41,8 @@ //css/js版本 define('CSS_JS_VERSION', '1.0.0000007'); - define('ALIYUN_OSS_ACCESS_KEY_ID', 'LTAI5tRBq7yr1vcdvhqNMb7P'); - define('ALIYUN_OSS_ACCESS_KEY_SECRET', 'E4No4AjlWGrHSULsR8apZkTAC8DMw6'); + define('ALIYUN_OSS_ACCESS_KEY_ID', 'LTAIjMbHCTksUg3b'); + define('ALIYUN_OSS_ACCESS_KEY_SECRET', 'jYC7VRwcEssvgqr61Hoz90iHknE6VT'); define('ALIYUN_OSS_END_POINT', 'oss-cn-hangzhou-internal.aliyuncs.com'); // oss节点 Endpoint以杭州为例,其它Region请按实际情况填写。 define('ALIYUN_OSS_BUCKET_WEIBO_DATA', 'chinese-medicine-knowledge'); define('ALIYUN_OSS_PARTS_UPLOAD_SIZE', 5*1024*1024); diff --git a/control/index.php b/control/index.php index e8fc1cd..af2c7e4 100755 --- a/control/index.php +++ b/control/index.php @@ -26,6 +26,42 @@ class index extends publicBase { exit(); } + public function down_mp_article() { + $aliobj = new mAliyunOSS(); + $ossUrl = $aliobj->getFileUrl('mp-articles', 'mp_article.zip', 180); + + // 初始化 cURL + $ch = curl_init($ossUrl); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, false); // 直接输出 + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_HEADER, false); + + // 设置 HTTP Headers,告诉浏览器这是一个下载文件 + header('Content-Description: File Transfer'); + header('Content-Type: application/octet-stream'); + header('Content-Disposition: attachment; filename="公众号文章.zip"'); + header('Content-Transfer-Encoding: binary'); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + + // 打开输出缓冲 + flush(); + + // 执行 cURL 下载并直接输出给客户端 + curl_exec($ch); + + if (curl_errno($ch)) { + http_response_code(500); + echo "下载失败: " . curl_error($ch); + } + + curl_close($ch); + + echo ''; + exit; + } + public function user_list() { $user_info = $this->get_user_info(); if (!$user_info['is_super_admin']) $this->show_message(false, '您还有此权限'); diff --git a/index.php b/index.php index d7bd7b8..08d0bad 100755 --- a/index.php +++ b/index.php @@ -89,6 +89,10 @@ if($this->control_name !== 'weibo' || $this->control_func == 'home') $this->ajax_json(false, '暂无权限'); } + if($_GET['str'] == FREE_DOWNLOAD_STR && $this->control_name == 'index' && $this->control_func == 'down_mp_article'){ + $needlogin = false; + } + if ($needlogin) { if(empty($_SESSION['openid']) && empty($_SESSION['token'])) { header("Location: /login?url=".$_SERVER['REQUEST_URI']);