PHP实现openSug.js参数调试

这是一款利PHP对百度搜索下拉框提示免费代码实现参数配置调试的程序源代码.

由想要对网站进行搜索下拉调试的站长朋友们进行方便、快速的效果演示,具体参考下面的PHP代码.

如何使用?

请新建一份PHP文档,并将下面PHP代码粘贴进去,然后通过浏览器访问访该文档即可进行预览openSug各种效果

  1 php
  2 $starttime = explode(' ',microtime());
  3 $title = array(
  4     'qun' => 'QQ群',
  5     'friend' => '分流节点',
  6     'api' => 'API进阶',
  7 );
  8 
  9 session_start();
 10 $n = empty($_GET["n"]) ? NULL : $_GET["n"];
 11 $f = empty($_POST["friend"]) ? NULL : $_POST["friend"];
 12 $q = empty($_POST["qun"]) ? NULL : $_POST["qun"];
 13 $l = empty($_POST["link"]) ? NULL : $_POST["link"];
 14 
 15 date_default_timezone_set("PRC");
 16 header("Refresh: 3600");
 17 header("Content-Type:text/html;charset=utf-8");
 18 header("Cache-Control: max-age=". 9E9);
 19 header("Expires: ". gmdate ("l, d F Y H:i:s",strtotime("+9 year"))." GMT");
 20 
 21 define("Q", "./qun.list");
 22 define("F", "./friend.list");
 23 define("D", "./js/opensug.js");
 24 define("WP_USE_THEMES", false);
 25 define("G", "aHR0cHM6Ly9vcGVuc3VnLmdpdGh1Yi5pby9qcy9vcGVuc3VnLmpz");
 26 define("I", substr($_SERVER["PHP_SELF"],strrpos($_SERVER["PHP_SELF"], "/")+1));
 27 define("H", dirname(((isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"]=="on") || (isset($_SERVER["HTTP_X_FORWARDED_PROTO"]) && $_SERVER["HTTP_X_FORWARDED_PROTO"] == "https")) ? "https://". $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"] : "http://". $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]));
 28 define("S", $_SERVER["SERVER_NAME"]);
 29 define("client", '_'. md5($_SERVER['REMOTE_ADDR']) .'_');
 30 //empty($_SERVER['HTTP_VIA']) or exit('Access Denied!');
 31 if(isset($_SESSION[client])){
 32     list($s1, $s2) = explode(' ', microtime());
 33     if( (float)sprintf('%.0f', (floatval($s1) + floatval($s2)) * 1000) - $_SESSION[client] < 2000){
 34         header("Refresh:5");
 35         header("HTTP/1.1 403 Forbidden");
 36         exit('

[403]刷新过于频繁, 请稍后重试!

'); 37 } 38 $_SESSION[client] = (float)sprintf('%.0f', (floatval($s1) + floatval($s2)) * 1000); 39 }else{ 40 list($s1, $s2) = explode(' ', microtime()); 41 $_SESSION[client] = (float)sprintf('%.0f', (floatval($s1) + floatval($s2)) * 1000); 42 } 43 44 if($n == 'js') _down(D);elseif($n == 'php')_down(I); 45 if(!empty($_GET['dl'])) _down('./user/'. $_GET['dl']); 46 47 // update openSug.js 48 if($n == S) exit(G); 49 if(!file_exists(D)){/* || (time()-filemtime(D)) > 604800*/ 50 !is_dir("./js/")&&mkdir("./js/", 0755, true); 51 $res = _curl(base64_decode(G)); 52 if(strlen($res) > 10){ 53 if(!file_put_contents(D, $res )) exit("Error: execution failed."); 54 }else(exit("Update failed!")); 55 header("Refresh: 3"); 56 exit("Updating openSug.js file, please wait..."); 57 } 58 59 if(!empty($f)){ 60 $url = parse_url($f) ? parse_url($f) : NULL; 61 if(!empty($url["host"])){ 62 $auth = _curl($url["scheme"] ."://". $url["host"] . (!empty($url["path"]) ? $url["path"] : NULL) ."?n=". $url["host"]); 63 if($auth == G){ 64 if(!file_put_contents(F, $url["scheme"]."://".$url["host"].$url["path"]."|" )) exit("Error: execution failed."); 65 $Msg = "Subnode sharing is complete, thank you for your support!"; 66 header("Refresh: 0"); 67 }else($Msg ="Error:The submission failed and the site you submitted is not an openSug subnode."); 68 } 69 } 70 71 if(!empty($q)){ 72 if(preg_match("/^\d*$/",$q) && strlen($q) > 4){ 73 if(!empty($l) && strlen($l) == 64 && preg_match('/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9a-zA-Z]+$/', $l) == 1) $links = $l; 74 else $qunt = 'Illegal IdKey!'; 75 if(!file_put_contents(Q, intval($q).','. (empty($links) ? NULL : $links) .'|', FILE_APPEND)) $qunt = 'Failed!'; 76 $qunt = 'Success.'; 77 }else $qunt='Illegal group number!'; 78 } 79 80 if((!empty($_POST['user']))){ 81 !is_dir("./user/")&&mkdir("./user/", 0755, true); 82 if(!file_exists(D))exit($Msg = "The openSug.js file is missing."); 83 $userJS = time() .'.js'; 84 if(!file_put_contents('./user/'. $userJS, ( get('sugResult',"") ? 'var _source;_source="'. get('sugResult',"") .'";':NULL) . file_get_contents(D) . "\r\n". $_POST['conf'] ."\r\n//{{".date('H:i:s m/d Y').'}}'.(!empty($_SERVER["HTTP_CLIENT_IP"]) ? $_SERVER["HTTP_CLIENT_IP"] : !empty($_SERVER["HTTP_X_FORWARDED_FOR"]) ? $_SERVER["HTTP_X_FORWARDED_FOR"]:!empty($_SERVER["REMOTE_ADDR"])?$_SERVER["REMOTE_ADDR"]:NULL)."{".$_SERVER['HTTP_USER_AGENT'].'}' )) exit("Error: execution failed."); 85 } 86 87 88 function get($i="",$o=""){return empty($_GET[$i]) ? $o : $_GET[$i];} 89 function _down($d){ 90 if(!file_exists($d)){header("HTTP/1.0 404 Not Found");return"";} 91 header("Content-type: application/javascript"); 92 header("Content-Disposition: attachment; filename=\"". basename($d) ."\""); 93 exit(file_get_contents($d)); 94 } 95 96 function _curl($url = ""){ 97 if(function_exists("curl_init") && strlen($url) > 6){ 98 $c = curl_init(); 99 curl_setopt($c, CURLOPT_URL, $url); 100 curl_setopt($c, CURLOPT_TIMEOUT,5); 101 curl_setopt($c, CURLOPT_RETURNTRANSFER,TRUE); 102 curl_setopt($c, CURLOPT_SSL_VERIFYPEER,false); 103 curl_setopt($c, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); 104 $res = curl_exec($c); 105 $sta = curl_getinfo($c)["http_code"]; 106 curl_close($c); 107 if($sta == '200') return $res; 108 return false; 109 }else(exit("Error:the current environment does not support cURL.")); 110 }?> 111 <?php <span style="color:#0000ff;">echo</span> <span style="color:#0000ff;">empty</span>(<span style="color:#800080;">$n</span>) ? '' : <span style="color:#800080;">$title</span>[<span style="color:#800080;">$n</span>] .'['. (<span style="color:#0000ff;">empty</span>(<span style="color:#800080;">$_GET</span>["sugResult"]) ? 'BaiduSuggestion' : <span style="color:#800080;">$_GET</span>["sugResult"]) .'.bind()] - ';?>百度搜索下拉框提示免费代码 - openSug.js.bind" /> 112 <header role="banner" style="padding:2.5% 4.5455%;background-color:#191919;margin-bottom:1em;"> 113
114

百度搜索下拉框提示免费代码_openSug.js

115

只需引用一段JS即可获得带有“搜索框提示”功能的搜索框,让您的搜索更便捷! license:MIT

116
117 header> 118 119
class="container"> 120
下载: JS PHP NPMJS  Q群 分流
121 if($n=='api'){?> 122
class="list" style="margin-bottom:0;"> 123
class="item title">
class="c-list-title">API进阶
124
class="row" style="padding:5rem">
class="DEMO1">
class="msfo">
class="DEMO3 DEMO0 DEMO4" id="inputObj" maxlength="2048" name="wd" autocapitalize="off" autocomplete="off" autocorrect="off" autofocus="autofocus" placeholder="本输入框ID为:inputObj">
125

关于出现Uncaught TypeError: Cannot read property '_GUID' of null的解决方案,请点击此处...

126
127 128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165168169170171172173174177178
class="i"> class="i" for="act">
class="i"> class="i">
class="i"> " /> class="i">
class="i"> class="i">
class="i"> class="i">
class="i"> class="i">
166          167 if(get('id',"")){?>

本页面仅供参数调试,请调整参数以配合实际生产环境!
if(!empty($userJS))echo '

您的专属openSug.js文件:$userJS .'" target="_blank">'. H .'/user/'. $userJS .' [$userJS .'" target="_blank">下载]

';?>
179 180
181 elseif($n=='qun'){?> 182
class="list"> 183
class="item title"> 184
class="c-list-title">加入QQ群讨论
185
186
class="item" style="padding:10px;word-wrap:break-word;"> 187 if(file_exists(Q)){$tmp=explode('|',file_get_contents(Q));$cou=count($tmp)-2;for($i=0;$i<=$cou;$i++){$tt=explode(',',$tmp[$i]);$last=$i==$cou?' style="color:red;font-weight:bold;text-decoration:underline" title="最新分享群讨论 '.$tt[0].'"'.$tt[0]:"";echo empty($tt[1])?'$last.' οnclick="prompt(\'请手动加群:\','.$tt[0].');">'.$tt[0].'    ':'$tt[1].'" target="_blank"'.$last.'>'.$tt[0].'    ';}}?> 188
189
190 shang.qq.com/wpa/qunwpa?idkey=$l;?>" />
191 群号码:$q;?>" /> 192 if(isset($qunt))echo ' '.$qunt;?> 193
194
195 elseif($n=='friend'){?> 196
class="list"> 197
节点:$f;?>" />
198

199

class="item title">
class="c-list-title">openSug分流节点
200
class="item" style="padding:10px;word-wrap:break-word;"> 201 if(file_exists(F)){ 202 $tmp=explode('|',file_get_contents(F)); 203 $cou=count($tmp)-2; 204 for($i=0;$i<=$cou;$i++){ 205 $url = parse_url($tmp[$i]); 206 echo '$tmp[$i] .'" target="_blank">'. $url['host'] .'    '; 207 } 208 }?>
209

210
211 else{?> 212
class="list"> 213
class="item-1st"> 214
class="item title"> 215
class="c-list-title">baiduSug = "1"
216
217
class="item"> 218
class="c-list-title"> 219
class="DEMO1">
class="msfo">
class="DEMO3 DEMO0 DEMO4" maxlength="2048" name="wd" autocapitalize="off" autocomplete="off" autocorrect="off" autofocus="autofocus" placeholder="baiduSug = '1'" baiduSug="1" />
220
221 选中词条时默认执行表单提交动作 222
223
224
class="code"> 225
<form action="https://www.baidu.com/baidu" target="_blank">
    <input type="textbaiduSug="1" name="word" size="30" />
    <input type="submit" value="百度搜索" />
</form>
226
227
228
class="item-2nd"> 229
class="item title"> 230
class="c-list-title">baiduSug = "2"
231
232
class="item"> 233
class="c-list-title"> 234
235 236 237
class="DEMO1"> 238
class="msfo"> 239
240
241 class="DEMO3 DEMO0 DEMO4" id="inputObj" maxlength="2048" name="wd" autocapitalize="off" autocomplete="off" autocorrect="off" placeholder="baiduSug = '2'" baiduSug="2" /> 242
243
244
245 246
247
248 选中词条时不执行表单提交动作 249
250
251
class="code"> 252
<form action="https://www.baidu.com/baidu" target="_blank">
    <input type="textbaiduSug="2" name="word" size="30" />
    <input type="submit" value="百度搜索" />
</form>
253
254
255
class="item-3rd"> 256
class="item title"> 257
class="c-list-title">API
258
259
class="item"> 260
class="c-list-title" style="padding:53px 10px;"> 261
BaiduSuggestion.bind();
262
263
264
class="code">提供“百度搜索框提示”API,打造您的个性化搜索框提示功能!  获得开始...
265
266
267 268 php } 269 echo '
更新日志'; 270 if(file_exists('./faq/wp-load.php')){ 271 // 加载wp-load.php占用内存超过32倍. 272 require('./faq/wp-load.php'); 273 query_posts('showposts=5&orderby=new'); 274 while(have_posts()) : the_post();?> 275 276 php 277 endwhile; 278 wp_tag_cloud('number=8&orderby=count&order=RAND&smallest=16&largest=16&unit=px'); 279 }else echo ''; 280 ?> 281
282 * 浏览器支持:IE6+, Firefox, Chrome, Safari, Opera, Edge...
283 * 在网页中引入Javascript文件,Javascript代码请尽量添加到网页中 </body> 闭合标签之前.
284 * 如使用utf-8编码,请务必在script标签中设置 charset="gbk" 属性,否则搜索提示词会出现乱码.已修正!
class="src" onClick="prompt('请把以下代码添加到网页</body>后面','<script type="text/javascript"  src="https://opensug.github.io/js/opensug.js">');"><script type="text/javascript" src="https://cdn.jsdelivr.net/g/opensug/"></script>
285
为受窘的人说一句解围的话;为沮丧的人说一句鼓励的话;为疑惑的人说一句提醒的话;为自卑的人说一句自信的话;为痛苦的人说一句安慰的话...因为,更多时候,我们需要的是雪中送炭,而不是锦上添花.
   
DNS: charles.ns.cloudflare.com、janet.ns.cloudflare.com
echo date('Y.m.d H:i:s[D|z]');?> if(function_exists('memory_get_usage')){$mem = round(memory_get_usage() / 1024, 2);echo $mem > 1000 ? round($mem / 1024, 2) .'MB': $mem .'KB';}$endtime = explode(' ',microtime());$thistime=$endtime[0]+$endtime[1]-($starttime[0]+$starttime[1]);echo " ". round($thistime,2) ."second.";?>
286 if(get('sugResult',""))echo '';?> 287 288 if($n=='api'){?> 289 290
291 292 293
View Code

 

转载于:https://www.cnblogs.com/opensug/p/10287433.html

你可能感兴趣的:(php,javascript,ViewUI)