diff --git a/upload/archiver/index.php b/upload/archiver/index.php index 7320c6c78a9b704a99a29ae35ca4b445fd493fcd..b048b662f3049bc3f98b2f3c5439abce70e11cbd 100644 --- a/upload/archiver/index.php +++ b/upload/archiver/index.php @@ -13,7 +13,7 @@ chdir('../'); $querystring = $_SERVER['QUERY_STRING']; -if(!empty($_GET['action'])) { +if(!empty($_GET['action']) && !empty($_GET['value'])) { $querystring = $_GET['action'].'-'.$_GET['value']; } diff --git a/upload/install/include/install_function.php b/upload/install/include/install_function.php index 5c9adab6aadb7eb9c4922ab8935ede75a0a23427..d3dc45d4dd02c967cf43aa31ce4f9a6bff5c00fa 100644 --- a/upload/install/include/install_function.php +++ b/upload/install/include/install_function.php @@ -885,7 +885,15 @@ function dfopen($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE, $ $ch = curl_init(); $ip && curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: ".$host)); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); - curl_setopt($ch, CURLOPT_URL, $scheme.'://'.($ip ? $ip : $host).':'.$port.$path); + // 在请求主机名并非一个合法 IP 地址, 且 PHP 版本 >= 5.5.0 时, 使用 CURLOPT_RESOLVE 设置固定的 IP 地址与域名关系 + // 在不支持的 PHP 版本下, 继续采用原有不支持 SNI 的流程 + if(!filter_var($host, FILTER_VALIDATE_IP) && version_compare(PHP_VERSION, '5.5.0', 'ge')) { + curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, false); + curl_setopt($ch, CURLOPT_RESOLVE, array("$host:$port:$ip")); + curl_setopt($ch, CURLOPT_URL, $scheme.'://'.$host.':'.$port.$path); + } else { + curl_setopt($ch, CURLOPT_URL, $scheme.'://'.($ip ? $ip : $host).':'.$port.$path); + } curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); diff --git a/upload/source/class/table/table_forum_thread.php b/upload/source/class/table/table_forum_thread.php index 797deeee0dee4e1baff6755672e58ba76d6b4ce8..2736fec2be7160479716adb7ffcac5104789eb24 100644 --- a/upload/source/class/table/table_forum_thread.php +++ b/upload/source/class/table/table_forum_thread.php @@ -506,7 +506,7 @@ class table_forum_thread extends discuz_table } } } - if($firstpage && !empty($tlkey) && ($ttl = getglobal('setting/memory/forum_thread_forumdisplay')) !== null && ($data = $this->fetch_cache($tlkey, 'forumdisplay_')) !== false) { + if(!$tableid && $firstpage && !empty($tlkey) && ($ttl = getglobal('setting/memory/forum_thread_forumdisplay')) !== null && ($data = $this->fetch_cache($tlkey, 'forumdisplay_')) !== false) { $delusers = $this->fetch_cache('deleteuids', ''); if(!empty($delusers)) { foreach($data as $tid => $value) { @@ -521,7 +521,7 @@ class table_forum_thread extends discuz_table } } $data = DB::fetch_all("SELECT * FROM ".DB::table($this->get_table_name($tableid))." $forceindex".$this->search_condition($conditions)." $ordersql ".DB::limit($start, $limit)); - if(!defined('IN_MOBILE') && $firstpage && !empty($tlkey) && ($ttl = getglobal('setting/memory/forum_thread_forumdisplay')) !== null) { + if(!defined('IN_MOBILE') && !$tableid && $firstpage && !empty($tlkey) && ($ttl = getglobal('setting/memory/forum_thread_forumdisplay')) !== null) { $this->store_cache($tlkey, $data, $ttl, 'forumdisplay_'); } return $data; diff --git a/upload/source/function/function_filesock.php b/upload/source/function/function_filesock.php index 1a8594e56e8c68f26f404a82e36de40151a261f7..d0bd95e16dd55250c95062d929aa595285b002fd 100644 --- a/upload/source/function/function_filesock.php +++ b/upload/source/function/function_filesock.php @@ -75,7 +75,7 @@ function _dfsockopen($url, $limit = 0, $post = '', $cookie = '', $bysocket = FAL return ''; } $path = $matches['path'] ? $matches['path'].($matches['query'] ? '?'.$matches['query'] : '') : '/'; - $port = !empty($matches['port']) ? $matches['port'] : ($scheme == 'http' ? '80' : ''); + $port = !empty($matches['port']) ? $matches['port'] : (strtolower($scheme) == 'https' ? 443 : 80); $boundary = $encodetype == 'URLENCODE' ? '' : random(40); if($post) { @@ -95,7 +95,15 @@ function _dfsockopen($url, $limit = 0, $post = '', $cookie = '', $bysocket = FAL if($httpheader) { curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader); } - curl_setopt($ch, CURLOPT_URL, $scheme.'://'.($ip ? $ip : $host).($port ? ':'.$port : '').$path); + // 在请求主机名并非一个合法 IP 地址, 且 PHP 版本 >= 5.5.0 时, 使用 CURLOPT_RESOLVE 设置固定的 IP 地址与域名关系 + // 在不支持的 PHP 版本下, 继续采用原有不支持 SNI 的流程 + if(!filter_var($host, FILTER_VALIDATE_IP) && version_compare(PHP_VERSION, '5.5.0', 'ge')) { + curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, false); + curl_setopt($ch, CURLOPT_RESOLVE, array("$host:$port:$ip")); + curl_setopt($ch, CURLOPT_URL, $scheme.'://'.$host.':'.$port.$path); + } else { + curl_setopt($ch, CURLOPT_URL, $scheme.'://'.($ip ? $ip : $host).':'.$port.$path); + } curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); diff --git a/upload/source/function/function_forumlist.php b/upload/source/function/function_forumlist.php index 7da26a7d06e85b24c55918b9ee80ec2fe573aa32..2e478bdc0f8e1c3aa9fafedecf524907bf3be2c5 100644 --- a/upload/source/function/function_forumlist.php +++ b/upload/source/function/function_forumlist.php @@ -36,7 +36,7 @@ function forum(&$forum) { if($forum['icon']) { $forum['icon'] = get_forumimg($forum['icon']); - $forum['icon'] = ''; + $forum['icon'] = ''.$forum['name'].''; } $lastpost = array(0, 0, '', ''); diff --git a/upload/source/function/media/media_ixigua.php b/upload/source/function/media/media_ixigua.php new file mode 100644 index 0000000000000000000000000000000000000000..64e31a33ac5af7fa992c97a981a20652cbcee579 --- /dev/null +++ b/upload/source/function/media/media_ixigua.php @@ -0,0 +1,15 @@ +(.+?)<\/span>/i", $str, $image)) { $imgurl = trim($image[1]); } diff --git a/upload/source/function/media/media_youtube.php b/upload/source/function/media/media_youtube.php index fb74640547f00608f39263dd2dc754a4e92050db..b516a5cf4cf12441319b865ce1f20d2d8966e035 100644 --- a/upload/source/function/media/media_youtube.php +++ b/upload/source/function/media/media_youtube.php @@ -4,14 +4,14 @@ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } -$checkurl = array('www.youtube.com/watch?'); +$checkurl = array('youtube.com/watch?'); function media_youtube($url, $width, $height) { - if(preg_match("/^https?:\/\/www.youtube.com\/watch\?v=([^\/&]+)&?/i", $url, $matches)) { - $flv = 'https://www.youtube.com/v/'.$matches[1].'&hl=zh_CN&fs=1'; - $iframe = 'https://www.youtube.com/embed/'.$matches[1]; + if(preg_match("/^https?:\/\/(|m.|www.)youtube.com\/watch\?v=([^\/&]+)&?/i", $url, $matches)) { + $flv = 'https://www.youtube.com/v/'.$matches[2].'&fs=1'; + $iframe = 'https://www.youtube.com/embed/'.$matches[2]; if(!$width && !$height) { - $str = file_get_contents($url, false, $ctx); + $str = file_get_contents($url, false); if(!empty($str) && preg_match("/'VIDEO_HQ_THUMB':\s'(.+?)'/i", $str, $image)) { $url = substr($image[1], 0, strrpos($image[1], '/')+1); $filename = substr($image[1], strrpos($image[1], '/')+3); diff --git a/upload/source/include/spacecp/spacecp_credit_base.php b/upload/source/include/spacecp/spacecp_credit_base.php index 695edaef87f67e8b45e15c22f653ef1de66f6d2b..2cd092f0dac61847fb525fe408d6ff5f9683ad2b 100644 --- a/upload/source/include/spacecp/spacecp_credit_base.php +++ b/upload/source/include/spacecp/spacecp_credit_base.php @@ -150,9 +150,9 @@ if($_GET['op'] == 'base') { 'submitdate' => $_G['timestamp'], )); - include template('common/header_ajax'); - echo '
'; - include template('common/footer_ajax'); + include isset($_REQUEST['inajax']) ? template('common/header_ajax') : template('common/header'); + echo '
'; + include isset($_REQUEST['inajax']) ? template('common/footer_ajax') : template('common/footer'); dexit(); } } else { diff --git a/upload/source/include/spacecp/spacecp_index.php b/upload/source/include/spacecp/spacecp_index.php index b20b19f606d353522446e47a26072f30497ccd32..d1a5fdd19b9d0fc63f0b9176e9953dd823a99511 100644 --- a/upload/source/include/spacecp/spacecp_index.php +++ b/upload/source/include/spacecp/spacecp_index.php @@ -109,8 +109,8 @@ if ($op == 'start') { space_merge($space,'field_home'); if (submitcheck('savespaceinfosubmit')) { - $spacename = getstr($_POST['spacename'], 30); - $spacedescription = getstr($_POST['spacedescription'], 135); + $spacename = censor(getstr($_POST['spacename'], 30)); + $spacedescription = censor(getstr($_POST['spacedescription'], 135)); $setarr = array(); $setarr['spacename'] = $spacename; @@ -137,7 +137,7 @@ if (submitcheck('blocksubmit')) { space_merge($space,'field_home'); $blockdata = dunserialize($space['blockposition']); - $title = getstr($_POST['blocktitle'],50); + $title = censor(getstr($_POST['blocktitle'],50)); $blockdata['parameters'][$blockname]['title'] = $title; if (in_array($blockname, array('block1', 'block2', 'block3', 'block4', 'block5'))) { @@ -219,13 +219,14 @@ if (submitcheck('musicsubmit')) { ); $blockdata['parameters']['music']['config'] = $config; - $blockdata['parameters']['music']['title']= getstr($_POST['blocktitle'],50); + $blockdata['parameters']['music']['title']= censor(getstr($_POST['blocktitle'],50)); } elseif ($_POST['act'] == 'addmusic') { $mp3url = $_POST['mp3url']; $mp3name = $_POST['mp3name']; $cdbj = $_POST['cdbj']; $mp3list = empty($blockdata['parameters']['music']['mp3list']) ? array() : $blockdata['parameters']['music']['mp3list']; + censor(implode('', $_POST['mp3name'])); foreach ($mp3url as $key => $value) { if (!empty($value)) { if(empty($mp3name[$key])) $mp3name[$key] = substr($value,strrpos($value,'/')+1,strlen($value)); @@ -239,6 +240,7 @@ if (submitcheck('musicsubmit')) { $mp3name = $_POST['mp3name']; $cdbj = $_POST['cdbj']; $mp3list = array(); + censor(implode('', $_POST['mp3name'])); foreach ($mp3url as $key => $value) { if (!empty($value)) { if(empty($mp3name[$key])) $mp3name[$key] = substr($value,strrpos($value,'/')+1,strlen($value)); diff --git a/upload/source/include/topicadmin/topicadmin_moderate.php b/upload/source/include/topicadmin/topicadmin_moderate.php index 55bc6012b32d9855f71bc8561ff7d2ae52e24b4e..4832743faaa47c418868b07625a980d7d95b3272 100644 --- a/upload/source/include/topicadmin/topicadmin_moderate.php +++ b/upload/source/include/topicadmin/topicadmin_moderate.php @@ -707,6 +707,13 @@ if(!submitcheck('modsubmit')) { set_stamp($stampstatus, $stampaction, $threadlist, $expiration); } + // 当进行管理操作后, 更新相关板块的板块缓存 + $fidarr = array(); + foreach ($threadlist as $thread) { + $fidarr[] = $thread['fid']; + } + C::t('forum_thread')->clear_cache($fidarr, 'forumdisplay_'); + } showmessage('admin_succeed', $_G['referer']); } diff --git a/upload/source/language/lang_admincp.php b/upload/source/language/lang_admincp.php index c3cc58421073aa40eedf49749d4dfaf58d296d2b..eaccfdafb191a0a02dc65ac2e32907fa3a928fab 100644 --- a/upload/source/language/lang_admincp.php +++ b/upload/source/language/lang_admincp.php @@ -2713,7 +2713,7 @@ $lang = array 'forums_grid_show_grid' => '是否开启首页四格', 'forums_grid_show_grid_comment' => '在论坛首页展示四格内容', 'forums_grid_style_type' => '展示风格', - 'forums_grid_style_type_comment' => '图文并茂: 幻灯+新帖+新回复+热帖; 简洁文字:新帖+新回复+精华贴+精华贴;', + 'forums_grid_style_type_comment' => '图文并茂: 幻灯+新帖+新回复+热帖; 简洁文字:新帖+新回复+热帖+精华贴;', 'forums_grid_style_image' => '图文并茂', 'forums_grid_style_text' => '简洁文字', 'forums_grid_data_source' => '数据来源版块', diff --git a/upload/source/language/lang_admincp_msg.php b/upload/source/language/lang_admincp_msg.php index 620c61e4e783763b3aad9199ff059b0a7e2c4f94..d6a6e7dab559e44442b6dbc7f47d2692af320b73 100644 --- a/upload/source/language/lang_admincp_msg.php +++ b/upload/source/language/lang_admincp_msg.php @@ -104,7 +104,7 @@ $lang = array ( 'select_thread_empty' => '没有选择主题', 'threadtype_infotypes_option_invalid' => '分类扩展选项名称或者变量名为空', 'threadtype_infotypes_optionvariable_iskeyword' => '选项变量名不被允许使用', - 'threadtype_infotypes_optionvariable_invalid' => '分类选项变量名重复', + 'threadtype_infotypes_optionvariable_invalid' => '分类选项变量名重复或不为字母开头', 'threadtype_infotypes_succeed' => '分类选项更新成功 ', 'forums_threadtypes_duplicate' => '新增主题分类与现有重复', 'threadtype_import_succeed' => '导入成功', diff --git a/upload/source/module/forum/forum_ajax.php b/upload/source/module/forum/forum_ajax.php index 39d932cd3053f9f6f59898c759c98481841fc90c..af195d4b080039d550d2d5587f9d396bb945f055 100644 --- a/upload/source/module/forum/forum_ajax.php +++ b/upload/source/module/forum/forum_ajax.php @@ -682,7 +682,9 @@ EOF; C::t('common_setting')->update($funkey, $funstatus); $setting[$funkey] = $funstatus; - include libfile('function/cache'); + if(!function_exists('updatecache')) { + include libfile('function/cache'); + } updatecache('setting'); } showmessage('do_success', dreferer(), array(), array('header'=>true)); diff --git a/upload/source/module/forum/forum_index.php b/upload/source/module/forum/forum_index.php index e9fe2b5071c249e05912020ead82e565e80a275c..7e7273ef3640cf6afca573b9d605bd79209b1e09 100644 --- a/upload/source/module/forum/forum_index.php +++ b/upload/source/module/forum/forum_index.php @@ -476,8 +476,12 @@ function get_index_page_guest_cache() { }); readfile($indexcache['filename']); $updatetime = dgmdate($filemtime, 'Y-m-d H:i:s'); - $gzip = $_G['gzipcompress'] ? ', Gzip On' : ''; - echo ''; + $debuginfo = ", Updated at $updatetime"; + if(getglobal('setting/debug')) { + $gzip = $_G['gzipcompress'] ? ', Gzip On' : ''; + $debuginfo .= ', Processed in '.sprintf("%0.6f", microtime(TRUE) - $start_time).' second(s)'.$gzip; + } + echo ''; ob_end_flush(); exit(); } diff --git a/upload/source/module/forum/forum_viewthread.php b/upload/source/module/forum/forum_viewthread.php index 588b604ca485a523f7a6fe3485d92f8bfd260ac8..f6e4ce8ec9807d83616eaa03b165e72058e70d76 100644 --- a/upload/source/module/forum/forum_viewthread.php +++ b/upload/source/module/forum/forum_viewthread.php @@ -34,7 +34,7 @@ if($page === 1 && !empty($_G['setting']['antitheft']['allow']) && empty($_G['set helper_antitheft::check($_G['forum_thread']['tid'], 'tid'); } -if($_G['setting']['cachethreadlife'] && $_G['forum']['threadcaches'] && !$_G['uid'] && $page == 1 && !$_G['forum']['special'] && empty($_GET['do']) && empty($_GET['threadindex']) && !defined('IN_ARCHIVER') && !defined('IN_MOBILE')) { +if($_G['setting']['cachethreadlife'] && $_G['forum']['threadcaches'] && !$_G['uid'] && $page == 1 && !$_G['forum']['special'] && empty($_GET['do']) && empty($_GET['from']) && empty($_GET['threadindex']) && !defined('IN_ARCHIVER') && !defined('IN_MOBILE')) { viewthread_loadcache(); } @@ -1307,8 +1307,12 @@ function viewthread_loadcache() { readfile($threadcache['filename']); viewthread_updateviews($_G['forum_thread']['threadtableid']); $updatetime = dgmdate($filemtime, 'Y-m-d H:i:s'); - $gzip = $_G['gzipcompress'] ? ', Gzip On' : ''; - echo ''; + $debuginfo = ", Updated at $updatetime"; + if(getglobal('setting/debug')) { + $gzip = $_G['gzipcompress'] ? ', Gzip On' : ''; + $debuginfo .= ', Processed in '.sprintf("%0.6f", microtime(TRUE) - $start_time).' second(s)'.$gzip; + } + echo ''; ob_end_flush(); exit(); } diff --git a/upload/source/module/misc/misc_buyinvitecode.php b/upload/source/module/misc/misc_buyinvitecode.php index ab4129da719860ab826a991695edc0c932bb084e..9fbe05006bc92c3ab00fa94990e9f753f289b308 100644 --- a/upload/source/module/misc/misc_buyinvitecode.php +++ b/upload/source/module/misc/misc_buyinvitecode.php @@ -45,9 +45,9 @@ if(submitcheck('buysubmit')) { 'email' => $email, 'ip' => $_G['clientip'], )); - include template('common/header_ajax'); - echo '
'; - include template('common/footer_ajax'); + include isset($_REQUEST['inajax']) ? template('common/header_ajax') : template('common/header'); + echo '
'; + include isset($_REQUEST['inajax']) ? template('common/footer_ajax') : template('common/footer'); dexit(); } else { showmessage('action_closed', NULL); diff --git a/upload/static/js/space_diy.js b/upload/static/js/space_diy.js index 281b49b256c31dabfed359b95335ac7345f067d2..63361f4d2950e6f93163fc5038ed6505b91873dc 100644 --- a/upload/static/js/space_diy.js +++ b/upload/static/js/space_diy.js @@ -175,7 +175,7 @@ spaceDiy.extend({ if ($('spaceinfoshow')) $('spaceinfoshow').style.display = 'inline'; }, spaceInfoSave : function () { - ajaxpost('savespaceinfo','spaceinfoshow'); + ajaxpost('savespaceinfo','spaceinfoshow','','onerror'); }, init : function () { drag.init(); diff --git a/upload/uc_client/client.php b/upload/uc_client/client.php index 0f97d1a31e88febebc4e4a94dfbff75ed208fbc2..9e050bd95c9bea100a0e798b0b4ed3cc70db8959 100644 --- a/upload/uc_client/client.php +++ b/upload/uc_client/client.php @@ -234,7 +234,15 @@ function uc_fopen($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE, $ch = curl_init(); $ip && curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: ".$host)); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); - curl_setopt($ch, CURLOPT_URL, $scheme.'://'.($ip ? $ip : $host).':'.$port.$path); + // 在请求主机名并非一个合法 IP 地址, 且 PHP 版本 >= 5.5.0 时, 使用 CURLOPT_RESOLVE 设置固定的 IP 地址与域名关系 + // 在不支持的 PHP 版本下, 继续采用原有不支持 SNI 的流程 + if(!filter_var($host, FILTER_VALIDATE_IP) && version_compare(PHP_VERSION, '5.5.0', 'ge')) { + curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, false); + curl_setopt($ch, CURLOPT_RESOLVE, array("$host:$port:$ip")); + curl_setopt($ch, CURLOPT_URL, $scheme.'://'.$host.':'.$port.$path); + } else { + curl_setopt($ch, CURLOPT_URL, $scheme.'://'.($ip ? $ip : $host).':'.$port.$path); + } curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); diff --git a/upload/uc_client/model/misc.php b/upload/uc_client/model/misc.php index 55ed49bb32adf96737739a3bdc1f5ee3d3415a6c..5d60abda77d6c35c47cc2a44a1d4de686c2734f8 100644 --- a/upload/uc_client/model/misc.php +++ b/upload/uc_client/model/misc.php @@ -73,7 +73,15 @@ class miscmodel { $ch = curl_init(); $ip && curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: ".$host)); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); - curl_setopt($ch, CURLOPT_URL, $scheme.'://'.($ip ? $ip : $host).':'.$port.$path); + // 在请求主机名并非一个合法 IP 地址, 且 PHP 版本 >= 5.5.0 时, 使用 CURLOPT_RESOLVE 设置固定的 IP 地址与域名关系 + // 在不支持的 PHP 版本下, 继续采用原有不支持 SNI 的流程 + if(!filter_var($host, FILTER_VALIDATE_IP) && version_compare(PHP_VERSION, '5.5.0', 'ge')) { + curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, false); + curl_setopt($ch, CURLOPT_RESOLVE, array("$host:$port:$ip")); + curl_setopt($ch, CURLOPT_URL, $scheme.'://'.$host.':'.$port.$path); + } else { + curl_setopt($ch, CURLOPT_URL, $scheme.'://'.($ip ? $ip : $host).':'.$port.$path); + } curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); diff --git a/upload/uc_server/install/func.inc.php b/upload/uc_server/install/func.inc.php index 24204f578a1914885eafcde625a30f1817e60a6c..c0365a283fd12e2428150dfd8e53af7449352527 100644 --- a/upload/uc_server/install/func.inc.php +++ b/upload/uc_server/install/func.inc.php @@ -755,7 +755,15 @@ function dfopen($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE, $ $ch = curl_init(); $ip && curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: ".$host)); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); - curl_setopt($ch, CURLOPT_URL, $scheme.'://'.($ip ? $ip : $host).':'.$port.$path); + // 在请求主机名并非一个合法 IP 地址, 且 PHP 版本 >= 5.5.0 时, 使用 CURLOPT_RESOLVE 设置固定的 IP 地址与域名关系 + // 在不支持的 PHP 版本下, 继续采用原有不支持 SNI 的流程 + if(!filter_var($host, FILTER_VALIDATE_IP) && version_compare(PHP_VERSION, '5.5.0', 'ge')) { + curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, false); + curl_setopt($ch, CURLOPT_RESOLVE, array("$host:$port:$ip")); + curl_setopt($ch, CURLOPT_URL, $scheme.'://'.$host.':'.$port.$path); + } else { + curl_setopt($ch, CURLOPT_URL, $scheme.'://'.($ip ? $ip : $host).':'.$port.$path); + } curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); diff --git a/upload/uc_server/model/misc.php b/upload/uc_server/model/misc.php index e904401381737a611f37c738d30352647119c0f9..9ab23336b653298dff8278c44486758ab761694f 100644 --- a/upload/uc_server/model/misc.php +++ b/upload/uc_server/model/misc.php @@ -71,7 +71,15 @@ class miscmodel { $ch = curl_init(); $ip && curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: ".$host)); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); - curl_setopt($ch, CURLOPT_URL, $scheme.'://'.($ip ? $ip : $host).':'.$port.$path); + // 在请求主机名并非一个合法 IP 地址, 且 PHP 版本 >= 5.5.0 时, 使用 CURLOPT_RESOLVE 设置固定的 IP 地址与域名关系 + // 在不支持的 PHP 版本下, 继续采用原有不支持 SNI 的流程 + if(!filter_var($host, FILTER_VALIDATE_IP) && version_compare(PHP_VERSION, '5.5.0', 'ge')) { + curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, false); + curl_setopt($ch, CURLOPT_RESOLVE, array("$host:$port:$ip")); + curl_setopt($ch, CURLOPT_URL, $scheme.'://'.$host.':'.$port.$path); + } else { + curl_setopt($ch, CURLOPT_URL, $scheme.'://'.($ip ? $ip : $host).':'.$port.$path); + } curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);