本篇文章给大家带来的内容是关于如何使用php实现openSug.js的参数调试(代码示例),有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。
这是一款利PHP对百度搜索下拉框提示免费代码实现参数配置调试的程序源代码.
由想要对网站进行搜索下拉调试的站长朋友们进行方便、快速的效果演示,具体参考下面的PHP代码.
如何使用?
请新建一份PHP文档,并将下面PHP代码粘贴进去,然后通过浏览器访问访该文档即可进行预览openSug各种效果
'QQ群', 'friend' => '分流节点', 'api' => 'API进阶', ); session_start(); $n = empty($_GET["n"]) ? NULL : $_GET["n"]; $f = empty($_POST["friend"]) ? NULL : $_POST["friend"]; $q = empty($_POST["qun"]) ? NULL : $_POST["qun"]; $l = empty($_POST["link"]) ? NULL : $_POST["link"]; date_default_timezone_set("PRC"); header("Refresh: 3600"); header("Content-Type:text/html;charset=utf-8"); header("Cache-Control: max-age=". 9E9); header("Expires: ". gmdate ("l, d F Y H:i:s",strtotime("+9 year"))." GMT"); define("Q", "./qun.list"); define("F", "./friend.list"); define("D", "./js/opensug.js"); define("WP_USE_THEMES", false); define("G", "aHR0cHM6Ly9vcGVuc3VnLmdpdGh1Yi5pby9qcy9vcGVuc3VnLmpz"); define("I", substr($_SERVER["PHP_SELF"],strrpos($_SERVER["PHP_SELF"], "/")+1)); 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"])); define("S", $_SERVER["SERVER_NAME"]); define("client", '_'. md5($_SERVER['REMOTE_ADDR']) .'_'); //empty($_SERVER['HTTP_VIA']) or exit('Access Denied!'); if(isset($_SESSION[client])){ list($s1, $s2) = explode(' ', microtime()); if( (float)sprintf('%.0f', (floatval($s1) + floatval($s2)) * 1000) - $_SESSION[client] < 2000){ header("Refresh:5"); header("HTTP/1.1 403 Forbidden"); exit('[403]刷新过于频繁, 请稍后重试!
'); } $_SESSION[client] = (float)sprintf('%.0f', (floatval($s1) + floatval($s2)) * 1000); }else{ list($s1, $s2) = explode(' ', microtime()); $_SESSION[client] = (float)sprintf('%.0f', (floatval($s1) + floatval($s2)) * 1000); } if($n == 'js') _down(D);elseif($n == 'php')_down(I); if(!empty($_GET['dl'])) _down('./user/'. $_GET['dl']); // update openSug.js if($n == S) exit(G); if(!file_exists(D)){/* || (time()-filemtime(D)) > 604800*/ !is_dir("./js/")&&mkdir("./js/", 0755, true); $res = _curl(base64_decode(G)); if(strlen($res) > 10){ if(!file_put_contents(D, $res )) exit("Error: execution failed."); }else(exit("Update failed!")); header("Refresh: 3"); exit("Updating openSug.js file, please wait..."); } if(!empty($f)){ $url = parse_url($f) ? parse_url($f) : NULL; if(!empty($url["host"])){ $auth = _curl($url["scheme"] ."://". $url["host"] . (!empty($url["path"]) ? $url["path"] : NULL) ."?n=". $url["host"]); if($auth == G){ if(!file_put_contents(F, $url["scheme"]."://".$url["host"].$url["path"]."|" )) exit("Error: execution failed."); $Msg = "Subnode sharing is complete, thank you for your support!"; header("Refresh: 0"); }else($Msg ="Error:The submission failed and the site you submitted is not an openSug subnode."); } } if(!empty($q)){ if(preg_match("/^\d*$/",$q) && strlen($q) > 4){ if(!empty($l) && strlen($l) == 64 && preg_match('/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9a-zA-Z]+$/', $l) == 1) $links = $l; else $qunt = 'Illegal IdKey!'; if(!file_put_contents(Q, intval($q).','. (empty($links) ? NULL : $links) .'|', FILE_APPEND)) $qunt = 'Failed!'; $qunt = 'Success.'; }else $qunt='Illegal group number!'; } if((!empty($_POST['user']))){ !is_dir("./user/")&&mkdir("./user/", 0755, true); if(!file_exists(D))exit($Msg = "The openSug.js file is missing."); $userJS = time() .'.js'; 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."); } function get($i="",$o=""){return empty($_GET[$i]) ? $o : $_GET[$i];} function _down($d){ if(!file_exists($d)){header("HTTP/1.0 404 Not Found");return"";} header("Content-type: application/javascript"); header("Content-Disposition: attachment; filename=\"". basename($d) ."\""); exit(file_get_contents($d)); } function _curl($url = ""){ if(function_exists("curl_init") && strlen($url) > 6){ $c = curl_init(); curl_setopt($c, CURLOPT_URL, $url); curl_setopt($c, CURLOPT_TIMEOUT,5); curl_setopt($c, CURLOPT_RETURNTRANSFER,TRUE); curl_setopt($c, CURLOPT_SSL_VERIFYPEER,false); curl_setopt($c, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); $res = curl_exec($c); $sta = curl_getinfo($c)["http_code"]; curl_close($c); if($sta == '200') return $res; return false; }else(exit("Error:the current environment does not support cURL.")); }?>百度搜索下拉框提示免费代码 - openSug.js .bind" />百度搜索下拉框提示免费代码_openSug.js
只需引用一段JS即可获得带有“搜索框提示”功能的搜索框,让您的搜索更便捷!
* 浏览器支持:IE6+, Firefox, Chrome, Safari, Opera, Edge...节点:
openSug分流节点'. $url['host'] .' '; } }?>更新日志'; if(file_exists('./faq/wp-load.php')){ // 加载wp-load.php占用内存超过32倍. require('./faq/wp-load.php'); query_posts('showposts=5&orderby=new'); while(have_posts()) : the_post();?> '; ?>baiduSug = "1"选中词条时默认执行表单提交动作 <form action="https://www.baidu.com/baidu" target="_blank">
<input type="text" baiduSug="1" name="word" size="30" />
<input type="submit" value="百度搜索" />
</form>baiduSug = "2"选中词条时不执行表单提交动作 <form action="https://www.baidu.com/baidu" target="_blank">
<input type="text" baiduSug="2" name="word" size="30" />
<input type="submit" value="百度搜索" />
</form>
* 在网页中引入Javascript文件,Javascript代码请尽量添加到网页中 </body> 闭合标签之前.
* 如使用utf-8编码,请务必在script标签中设置 charset="gbk" 属性,否则搜索提示词会出现乱码.已修正!<script type="text/javascript" src="https://cdn.jsdelivr.net/g/opensug/"></script>
The above is the detailed content of How to use php to implement parameter debugging of openSug.js (code example). For more information, please follow other related articles on the PHP Chinese website!