大淘客的index.php,index.php · zenozhengs/大淘客CMS底部菜单修改版 - Gitee.com
/*
* 请勿使用windows下的记事本修改本文件。推荐使用 notepad++
* * 版本v2.6
* 1.自动选择最优服务api地址返回数据
* 2.请求时添加压缩返回
* * 版本v2.5
* 1.500页面优化
* 2.数据请求增加重试,减少请求失败
* 版本v2.4
* 新增加cdn节点检测
* 版本 v2.3
* 1.500页面展示
* 版本 v2.2
* 1.增加mbstring检测
* *版本 v2.1
* 1.增加cache检测
* 2.增加显示debug信息限制
* 版本 v2.0
* 1.documentUrl 做兼容解决部分用户二级目录报错
* 2.增加debug信息方便为用户定位错误
*
* 版本 v1.1.0
* 升级日志:
* 1、添加自动更新
* 2、修正缓存的BUG
* 3、添加自动清理cache
* 4、实现http code的转发
*
* 版本 v1.0.1
* 升级日志:
* 1、修正第一次无法打开,需要刷新才能打开的BUG
* 2、添加对二级目录的支持
* 3、添加对非index.php文件名的支持。
*
* */
$appId = '1409274'; // 站点的APPID (请勿修改和泄漏)
$appKey = 'E2D55BEFF32D237AA88714253CF3EB2B';// 站点的APP KEY(请勿修改和泄漏)
$proxyVersion = 16;
//===============================================================================
//===============================================================================
//===============================================================================
//================ 请勿修改以下程序 ====================
//===============================================================================
//===============================================================================
//===============================================================================
if (!defined("DTK_TYPE")) {
define("DTK_TYPE", true);
}
$test_env = strrpos(@$_SERVER['HTTP_USER_AGENT'], 'test') === false ? false : true;
$requestUrl = @$_SERVER["REQUEST_URI"];
$documentUrl = @$_SERVER["PHP_SELF"];
if (empty($documentUrl)) {
$documentUrl = @$_SERVER["SCRIPT_NAME"];
}
if (empty($documentUrl)) {
$documentUrl = @$_SERVER["DOCUMENT_URI"];
}
if (empty($documentUrl)) {
$documentUrl = $requestUrl;
$str_pos = strpos($requestUrl, '?');
if ($str_pos !== false) {
$documentUrl = substr($requestUrl, 0, $str_pos);
}
}
$file = @$_SERVER["DOCUMENT_ROOT"] . $documentUrl . 'req.php';
$file2 = dirname(__FILE__) . DIRECTORY_SEPARATOR . $documentUrl . 'req.php';
if (file_exists($file)) {
require_once $file;
exit;
} elseif (file_exists($file2)) {
require_once $file2;
exit;
} else {
header("Content-type: text/html; charset=utf-8");
echo 'cms 版本:' . $proxyVersion . '
';
echo 'php 版本:' . PHP_VERSION . '
';
if ($test_env) {
echo 'CMS-HOST: ' . @$_SERVER["HTTP_HOST"] . '
';
echo 'DOCUMENT-URL: ' . $documentUrl . '
';
echo 'REQUEST-URL: ' . $requestUrl . '
';
}
$run_check = true;
if (function_exists('curl_init')) {
echo 'curl 已经开启 ' . '
';
} else {
$run_check = false;
echo 'curl 未开启,请先开启curl扩展,否则无法运行,请联系您的空间或者服务器提供商' . '
';
}
if (function_exists('mb_substr')) {
echo 'mbstring 已经开启 ' . '
';
} else {
$run_check = false;
echo 'mbstring 未开启,请先开启mbstring扩展,否则无法运行' . '
';
}
if( $run_check == false){
exit;
}
$test_dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'cache';
$test_file = $test_dir . '/test.txt';
if (!is_dir($test_dir)) {
mkdir($test_dir);
}
file_put_contents($test_file, 'test');
if (file_exists($test_file)) {
echo 'cache:有效
';
} else {
echo 'cache 无效,请先设置目录读写权限,请联系您的空间或者服务器提供商' . '
';
exit;
}
echo '......正在下载文件.......
';
$httpHelper = new HttpHelperes($appId, $appKey, $proxyVersion, $documentUrl);
$s = $httpHelper->upgrade();
if ($s === false) {
echo '......文件下载失败,请刷新页面重试,如果还是失败请联系客服.......
';
echo '......如果是香港或者国外虚拟主机服务器,请联系您的主机供应商优化网络CDN.......
';
if (function_exists('gethostbyname')) {
echo 'www.dataoke.com --CDN 节点 ---' . gethostbyname("www.dataoke.com");
echo '......可以尝试修改服务器DNS 然后ping 以上网址测试是否正常.......
';
}
} else {
echo '......文件下载成功.......
';
echo '------5秒后跳转----------
';
echo '------或者点击立即跳转----------
';
echo '';
exit;
}
}
class HttpHelperes
{
protected $appId;
protected $key;
protected $documentUrl;
protected $proxyVersion;
protected $upgradeUrl = "http://www.dataoke.com/pmc/upgrade.html";
public $httpCode = 200;
public function __construct($appId, $key, $proxyVersion, $documentUrl)
{
$this->appId = $appId;
$this->key = $key;
$this->proxyVersion = $proxyVersion;
$this->documentUrl = $documentUrl;
}
/**
* @param $host
* @param bool $re_try
* @return bool|mixed
*/
public function getIp($host, $re_try = false)
{
$output = '';
global $test_env;
try {
$header=array();
$host = str_replace('http://', '', $host);
if (strlen($host) != (strpos($host, '.com') + 4)) {
$host = substr($host, 0, strpos($host, '.com') + 4);
}
if ($re_try) {
$url = 'http://39.106.70.132:80/d?dn=' . $host;
$header[] = 'Host: dighttpd.dataoke.com';
} else {
$url = 'http://crab.qingcdn.com/d?dn='.$host;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPGET, TRUE);
curl_setopt($ch, CURLOPT_URL, $url);
if(!empty($header)){
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
}
$output = curl_exec($ch);
$output = json_decode($output, true);
} catch (Exception $e) {
if ($test_env) {
var_dump($e->getMessage());
}
}
if ($test_env && isset($_GET['debug']) && $_GET['debug'] == 'getip') {
var_dump($output);
var_dump($url);
}
return !empty($output['data'][$host]['ips']) ? $output['data'][$host]['ips'] : ($re_try ? false : $this->getIp($host, true));
}
/**
* @param $url
* @param $requestUrl
* @param array $param
* @param string $method
* @param bool $isAjax
* @param string $cookie
* @param string $refer
* @param null $userAgent
* @param bool $checkNewVersion
* @return string
*/
public function getHtml($url, $requestUrl, $param = array(), $method = 'GET', $isAjax = null, $cookie = NULL, $refer = null, $userAgent = null, $checkNewVersion = true, $re_try = true)
{
if (strpos($requestUrl, 'auth') !== false) {
$url .= '/auth';
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 1);
empty($refer) && $refer = @$_SERVER['HTTP_REFERER'];
$ua = $userAgent;
empty($ua) && $ua = (!empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '-');
$curl_time = $re_try == true ? 40 : 120;
curl_setopt($ch, CURLOPT_TIMEOUT, $curl_time);
curl_setopt($ch, CURLOPT_USERAGENT, $ua);
curl_setopt($ch, CURLOPT_REFERER, $refer);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$header = array(
'APPID: ' . $this->appId,
'APPKEY: ' . $this->key,
'PROXY-VERSION: ' . $this->proxyVersion,
'CMS-HOST: ' . @$_SERVER["HTTP_HOST"],
'DOCUMENT-URL: ' . $this->documentUrl,
'REQUEST-URL: ' . $requestUrl,
'CMS-CONNECTION: ' . (!empty($_SERVER["HTTP_CONNECTION"]) ? $_SERVER["HTTP_CONNECTION"] : '-'),
'CMS-ACCEPT-ENCODING: ' . (!empty($_SERVER["HTTP_ACCEPT_ENCODING"]) ? $_SERVER["HTTP_ACCEPT_ENCODING"] : '-'),
);
$cdn_ip = $this->getIp($url);
if ($re_try && $cdn_ip !== false) {
$url = str_replace('http://', '', $url);
$check_url_show = false;
if (strpos($url, '/pmc/upgrade.html') !== false) {
$check_url_show = true;
$url = str_replace('/pmc/upgrade.html', '', $url);
}
$header[] = 'Host: ' . $url;
if ($check_url_show) {
$url = $cdn_ip[0] . '/pmc/upgrade.html';
} else {
$url = $cdn_ip[0];
}
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
if (empty($cookie)) {
$cookie = $_COOKIE;
}
if (is_array($cookie)) {
$cookie = http_build_query($cookie,'',";");
}
if (!empty($cookie)) {
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
}
curl_setopt($ch, CURLOPT_HTTPGET, TRUE);
if ($param) {
$urlInfo = parse_url($url);
$q = array();
if (isset($urlInfo['query']) && !empty($urlInfo['query'])) {
parse_str($urlInfo['query'], $q);
}
$q = array_merge($q, $param);
$cUrl = sprintf('%s://%s%s%s%s',
$urlInfo['scheme'],
$urlInfo['host'],
isset($urlInfo['port']) ? ':' . $urlInfo['port'] : '',
isset($urlInfo['path']) ? $urlInfo['path'] : '',
count($q) ? '?' . http_build_query($q) : '');
curl_setopt($ch, CURLOPT_URL, $cUrl);
} else {
curl_setopt($ch, CURLOPT_URL, $url);
}
$r = curl_exec($ch);
$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = mb_substr($r, 0, $headerSize);
$r = mb_substr($r, $headerSize);
$this->httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
unset($ch);
$headers = explode("\r\n", $header);
$expires = time() + 300;
foreach ($headers as $h) {
$h = trim($h);
if (empty($h) || preg_match('/^(HTTP|Connection|EagleId|Server|X\-Powered\-By|Date|Transfer\-Encoding|Content)/i', $h)) {
continue;
}
if (strpos($h, 'expires:') !== false) {
$temp_arr = explode(':', $h);
if (!empty($temp_arr[1]) && is_numeric(trim($temp_arr[1]))) {
$expires = intval(trim($temp_arr[1]));
}
}
if (strpos($h, 'Cookie') !== false) {
$h = explode(':', $h);
if (!empty($h[1])) {
$h = explode('=', $h[1]);
if (!empty($h[0]) && !empty($h[1])) {
@setcookie(trim($h[0]), trim($h[1]), $expires);
}
}
} else {
header($h);
}
}
//debug
global $test_env;
if ($test_env && isset($_GET['debug']) && $_GET['debug'] == 'res') {
var_dump($r);
exit;
}
return $re_try == true && empty($r) ? $this->getHtml($url, $requestUrl, $param, $method, $isAjax, $cookie, $refer, $userAgent, $checkNewVersion, false) : $r;
}
public function php_self()
{
try {
$php_self = substr(@$_SERVER['PHP_SELF'], strrpos(@$_SERVER['PHP_SELF'], '/') + 1);
} catch (Exception $e) {
$php_self = '';
}
return $php_self;
}
public function upgrade()
{
$php = $this->getHtml($this->upgradeUrl, '', array(), 'GET', false, null, null, null, false);
if ($php === false || strlen($php) < 500) {
echo ' 请求服务器读取数据失败,请确认服务器网络是否稳定,或者联系服务器供应商修改优化DNS配置' . '
';
return false;
}
$php = @json_decode($php, true);
if (empty($php['appid']) || empty($php['appkey']) || empty($php['content']) || $php['appid'] !== $this->appId) {
echo ' 请求服务器读取数据失败,请确认文件没有被修改,或者重新下载index.php文件上传' . '
';
return false;
}
$file = dirname(__FILE__) . DIRECTORY_SEPARATOR . $this->documentUrl;
if (!file_exists($file)) {
$file_name = $this->php_self();
$file = dirname(__FILE__) . DIRECTORY_SEPARATOR . $file_name;
}
$result = file_put_contents($file, $php['content'], LOCK_EX);
if ($result === false) {
$file .= 'req.php';
$result = file_put_contents($file, $php['content'], LOCK_EX);
}
if ($result == false) {
echo ' 写文件失败,请先设置目录读写权限,保证WEB服务器(nginx ,apache等)的帐号和PHP,对该目录有读写操作权限' . '
';
}
return $result;
}
}
一键复制
编辑
Web IDE
原始数据
按行查看
历史
大淘客的index.php,index.php · zenozhengs/大淘客CMS底部菜单修改版 - Gitee.com相关推荐
- 网页制作期末大作业成品 HTML5+CSS大作业——简约个性高逼格博客(5页) web网页制作期末大作业模板
HTML5+CSS大作业--简约个性高逼格博客(5页) web网页制作期末大作业模板 常见网页设计作业题材有 个人. 美食. 公司. 学校. 旅游. 电商. 宠物. 电器. 茶叶. 家居. 酒店. 舞 ...
- HTML期末大作业~简单的程序员个人博客网站模板源码(HTML+CSS)~个人主页博客web网页设计制作~HTML简单个人网页制作~Web大学生网页成品...
HTML期末大作业~ 简单的程序员个人博客网站模板源码(HTML+CSS)~学生HTML个人网页作业作品下载 ~个人主页博客网页设计制作 ~大学生个人网站作业模板 ~简单个人网页制作 临近期末, 你还 ...
- HTML期末大作业:学生HTML个人网页作业作品下载 个人主页博客网页设计制作 大学生个人网站作业模板 dreamweaver简单个人网页制作...
1.临近期末, 你还在为HTML网页设计结课作业,老师的作业要求感到头大?HTML网页作业无从下手? 网页要求的总数量太多? 2.没有合适的模板?等等一系列问题.你想要解决的问题,在这篇博文中基本都能 ...
- HTML5期末大作业:个人网站设计——自适应个人相册展示留言博客模板(6页) HTML+CSS+JavaScript...
常见网页设计作业题材有 个人. 美食. 公司. 学校. 旅游. 电商. 宠物. 电器. 茶叶. 家居. 酒店. 舞蹈. 动漫. 明星. 服装. 体育. 化妆品. 物流. 环保. 书籍. 婚纱. 军 ...
- 博客园是个大金矿,管理员不挖掘有些可惜:给博客园提一些双赢的建议
当前十天排行榜里排在首页的文章是,『建议』给博客园官方的一个意见,这说明博客园的广大用户(也包括我)非常乐意看到博客园不断进步. 博客园在国内技术论坛里,应该说是有一定的知名度,每天的流量不少,要知道 ...
- 淘宝客如何通过闲鱼引流?淘宝客的推广方法有哪些?
淘宝客如何通过闲鱼引流?淘宝客的推广方法有哪些? 淘宝网的总流量针对淘客而言一直全是较为精确的,这都是淘宝客一直勤奋开淘宝店內部总流量的缘故,例如店面淘宝客.在淘宝客网内引流方法等,而淘宝闲鱼都是归属 ...
- 淘宝客如何通过闲鱼引流?淘宝客、闲鱼营销推广方式有哪些?
淘宝客如何通过闲鱼引流?淘宝客.闲鱼营销推广方式有哪些? 淘宝网的总流量针对淘客而言一直全是较为精确的,这都是淘宝客一直勤奋开淘宝店內部总流量的缘故,例如店面淘宝客.在淘宝客网内引流方法等,而淘宝闲鱼 ...
- 【新闻资讯】淘宝客达人:网赚盈利模式之淘宝客盈利技巧分享
来源:站长网 淘宝客一词相信很多个人站长都熟悉,但不是人人都是成功的淘客.做淘宝客也许不是个人做站生涯的最好的选择,但确实网赚盈利模式上一个不错的方式. 10月14日站长网论坛周四版聊活动,邀请淘宝客 ...
- 苹果付费app共享公众号_公众号淘客和APP淘客哪个好做?公众号与淘客APP利弊分析...
更多精彩,请点击上方蓝字关注我们!近来淘客圈内很多人都在讨论APP淘客和公众号淘客,到底哪个更好做?哪个更赚钱?这两个问题一直困扰着中小淘客. 由于少数有实力的大淘客肯定做全领域的覆盖,相互配合引流, ...
最新文章
- MyBatis,动态传入表名,字段名的解决办法
- Jan 09 - Number of 1 Bits; Bit Operation;
- Github注册过程以及对管理软件的了解
- 【OS学习笔记】三十五 保护模式十:中断描述符表、中断门和陷阱门
- 里面不仅有强悍的zhajinhuaplayer
- 八点建议写出优雅的 Java 代码
- Web Client Software Factory系列(4):数据绑定和ObjectContainerDataSource控件
- Android 系统(220)---如何快速对系统重启问题进行归类
- pygame的最小系统
- 1054. 求平均值
- dotnet core 文档链接
- Linux编译和下载嵌入式实验,嵌入式实验6交叉编译及Linux简单程序设计实验
- 前端面试宝典(2)——JavaScript
- 各类原版系统下载:在MSDN下载Windows、MacOS、Linux原版系统镜像
- 软件开发过程模型——喷泉模型
- 最新版mysql8.0.13如何汉化_MySQL 8.0.13 下载安装教程图文详解
- 计算机中英文标点符号对照表,常用中文标点符号和键盘对照表.doc
- PyCharm 实用快捷键
- win7无法连接打印机拒绝访问_win7系统共享打印机拒绝访问的完美解决方法
- 平安保险php软件工程师工资,软件工程师
热门文章
- php 微信红包接龙源码_PHP生成微信红包
- 2020python考试题库_大学mooc2020用Python玩转数据期末考试公众号答案
- Qt 纯代码模仿 WPS 登录界面
- RabbitMQ Applying plugin configuration to rabbit@xxx... Plugin configuration unchanged.
- [解决方法] 连接深信服Easyconnect之后无法代理抓包
- 基于ESP8266的物联网智能鱼缸系统设计
- 山东最新高级消防设施操作员考试真题及答案
- Civil 3d中的mms文件
- 信息系统项目管理师必背核心考点(六十二)项目组合治理主要过程
- 【面试】腾讯优图-计算机视觉