├── .gitignore ├── LICENSE ├── README.md ├── autocomplete.php ├── config.php ├── google_avaiable_ip.txt ├── google_search.class.php ├── index.php ├── res ├── favicon.ico ├── google-alias.css ├── google-alias.js ├── logo11w.png ├── nav_logo195.png └── search.png └── view.class.php /.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | .idea/ 3 | *.*~ 4 | test*.php -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | 167 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | google-alias 2 | ============ 3 | 这是一个用 PHP 写的谷歌搜索, 主要使用 php 的 curl 和 preg 模块. 4 | Google Alias 意为谷歌的替代品. 5 | ##部署## 6 | 部署非常简单, 你甚至不用做什么, 只要把你的代码上传到 VPS 或者 web host. 7 | 大家都知道 PHP 的免费主机非常多, 部署也非常便捷. 大范围的部署也不成问题, 即使被墙也能迅速的更换主机. 8 | ##配置## 9 | config.php 里面有许多个性化的设置, 比如自定义 GET 的键名, 默认的每页结果数, 或者你可以自定义http的header, 是否开启安全搜索等等等 10 | ##功能## 11 | 1. 限制时间 12 | 2. 可定义每页结果数 13 | 3. 相关搜索 14 | 4. 设置地区和语言 15 | 5. url关键字加密 16 | 7. html内容加密, 可搜索敏感词 17 | 8. 谷歌搜索功能, 使用谷歌的可用ip, 前端会检测ip是否可用, 需要在google_avaiable_ip.txt中添加可用的ip, 用 | 分割. 18 | 6. 热键功能, 按`alt+j`可以获得搜索框的焦点, `alt+i`获得焦点并清空. 19 | 7. 返回新闻, 视频, 图片的搜索结果(未实现) 20 | 8. 兼容特殊搜索, 比如特定的文件(未实现) 21 | 9. 待续 22 | 23 | 24 | ##注意## 25 | 如果你想部署在自己的网站上, 一定要及时更新可用ip列表. 26 | 27 | 28 | ##BUGs## 29 | 1. 没有搜索结果时会报错(fixed) 30 | 2. 你找找看 31 | 32 | 33 | ##可用服务## 34 | 1. http://googlealias.com 35 | -------------------------------------------------------------------------------- /autocomplete.php: -------------------------------------------------------------------------------- 1 | FALSE, //安全搜索 14 | 'LANG' => 'zh-CN', //默认的搜索语言 15 | 'ENABLE_GZIP' => TRUE, //gzip 压缩, 启用之后可节省近3分之一的流量, 前提是有gzip的模块, 否则开启也是无效的. 16 | 'TIMEOUT' => 3, //连接超时, second 17 | 'ENCRYPT' => TRUE, //是否开启URL参数加密 18 | 'CON_ENC' => TRUE, //是否开启网页内容加密 19 | 'CON_ENC_K' => 6, //网页内容加密的秘钥 20 | 'NUM' => 10, //默认的每页结果数 21 | 'GET_LANG' => 'hl', //设置语言的get键名 22 | 'GET_Q' => 'qq', //查询内容的get键名 23 | 'GET_PAGE' => 'pp', //页数的get键名 24 | 'GET_NUM' => 'num', //每页结果数的get键名 25 | 'GET_TIME' => 'dd', //时间限制的get键名 26 | 'DOMAIN' => 'http://googlealias.tk/' //网站的域名 27 | ); 28 | $headers = array( 29 | CURLOPT_HTTPHEADER => array( //http headers, 可以根据需求来修改 30 | 'User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.111 Safari/537.36', 31 | 'referer:https://www.google.com/', 32 | 'Host:www.google.com', 33 | 34 | ), 35 | //以下内容如无必要请不要修改 36 | CURLOPT_RETURNTRANSFER => TRUE, 37 | CURLOPT_BINARYTRANSFER => TRUE, 38 | CURLOPT_HEADER => TRUE, 39 | CURLOPT_CONNECTTIMEOUT => $GLOBALS['OPTIONS']['TIMEOUT'] //set connect timeout 40 | ); 41 | if(function_exists('zlib_decode')) 42 | define("HAVE_GZIP", TRUE); 43 | else 44 | define("HAVE_GZIP", FALSE); 45 | if(HAVE_GZIP && $GLOBALS['OPTIONS']['ENABLE_GZIP']) 46 | $headers[CURLOPT_HTTPHEADER][] = 'accept-encoding:gzip'; 47 | 48 | 49 | //functions 50 | /** 51 | * get config 52 | * @param string $key 53 | * @return string 54 | */ 55 | function opt($key){ 56 | return $GLOBALS['OPTIONS'][$key]; 57 | } 58 | 59 | /** 60 | * simple decryption 61 | * @param string $str 62 | * @param int $key 63 | * @return string 64 | */ 65 | function decrypt($str, $key){ 66 | if(substr($str, 0, 3) == '%FF') 67 | $str = substr($str, 3); 68 | $s = ''; 69 | $len = strlen($str); 70 | for($i = 0; $i < $len; ++$i){ 71 | if($str[$i] != '%'){ 72 | $s .= $str[$i]; 73 | } 74 | else{ 75 | $t = dechex(hexdec(substr($str, $i + 1, 2)) + $key); 76 | if(strlen($t) == 1) 77 | $t = '0'.$t; 78 | $s .= '%'.$t; 79 | $i += 2; 80 | } 81 | } 82 | return urldecode($s); 83 | } 84 | function encrypt($str, $key){ 85 | $s = ''; 86 | for($i = 0; $i < strlen($str); $i++){ 87 | if($str[$i] == ' '){ 88 | $s .= '+'; 89 | } 90 | elseif(urlencode($str[$i]) == $str[$i]){ 91 | $s .= $str[$i]; 92 | } 93 | else{ 94 | $c = urlencode($str[$i]); 95 | $c = explode('%', $c); 96 | $f = array(); 97 | for($j = 1; $j < count($c); $j++){ 98 | $t = strtoupper(dechex(hexdec($c[$j]) - $key)); 99 | if(strlen($t) == 1) 100 | $t = '0'.$t; 101 | $f[] = $t; 102 | } 103 | $s .= '%'.implode('%', $f); 104 | } 105 | } 106 | return '%FF'.$s; 107 | } -------------------------------------------------------------------------------- /google_avaiable_ip.txt: -------------------------------------------------------------------------------- 1 | 195.13.189.24|195.13.189.30|195.13.189.39|195.13.189.35|195.13.189.45|195.13.189.59|195.13.189.40|195.13.189.50|195.13.189.49|195.13.189.29|195.13.189.55|195.13.189.20|195.13.189.34|195.13.189.54|195.13.189.25|195.122.16.59|195.122.16.55|195.122.16.40|195.122.16.45|195.13.231.178|195.13.231.172|195.13.231.157|195.13.231.163|195.13.231.183|195.13.231.148|195.13.231.158|195.122.16.39|195.122.16.55|195.122.16.49|195.122.16.54|195.122.16.34|195.122.16.30|195.122.16.44|195.122.16.40|195.122.16.25|195.122.16.59|195.122.16.35|195.122.16.45|195.122.16.50|195.122.16.29|195.122.16.24|195.122.16.20|195.13.231.177|195.13.231.182|195.13.231.158|195.13.231.152|195.13.231.157|195.13.231.163|195.13.231.162|195.13.231.173|195.13.231.148|195.13.231.187|195.13.231.178|195.13.231.167|195.13.231.168|195.13.231.153|195.13.231.183|195.13.231.172|195.13.231.172|195.13.231.183|195.13.231.157|195.13.231.173|195.13.231.187|195.13.231.168|195.13.231.182|195.13.231.158|195.13.231.167|195.13.231.162|195.13.231.163|195.13.231.178|195.13.231.152|195.13.231.148|195.13.231.177|195.13.231.153 -------------------------------------------------------------------------------- /google_search.class.php: -------------------------------------------------------------------------------- 1 | k = opt('CON_ENC_K'); 32 | $this->e = opt('CON_ENC'); 33 | $this->headers =$headers; 34 | $this->paras['q'] = $keywork; 35 | $this->paras_m[opt('GET_Q')] = $keywork; 36 | if(!isset($this->paras['num'])) 37 | $this->paras['num'] = opt('NUM'); 38 | if(opt('SAFE_SEARCH')) 39 | $this->paras['safe'] = 'strict'; 40 | $this->paras['start'] = 0; 41 | $this->paras['hl'] = opt('LANG'); 42 | } 43 | 44 | /** 45 | * prepare parameters to load html data. 46 | * @return $this 47 | */ 48 | public function load(){ 49 | $paras = $this->arr2url($this->paras); 50 | $ch = curl_init(search::url.$paras); 51 | curl_setopt_array($ch, $this->headers); 52 | $this->content = curl_exec($ch); 53 | $this->status['errno'] = curl_errno($ch); 54 | if($this->status['errno']) 55 | return FALSE; 56 | if(HAVE_GZIP && opt('ENABLE_GZIP')) 57 | $this->content = zlib_decode($this->content); 58 | $this->remove_css_and_js(); 59 | preg_match('`
]*>[^\d]*([\d,]*)[^<]*[^\d]*([\d\.]*)[^<]*
`m', $this->content, $r); 60 | if(!isset($r[1]) || !isset($r[2])){ 61 | $this->status['errno'] = 404; 62 | return FALSE; 63 | } 64 | else{ 65 | $this->status['res_num'] = $r[1]; 66 | $this->status['time'] = $r[2]; 67 | } 68 | return $this; 69 | } 70 | 71 | /** 72 | * remove the style and javascript tag from content. 73 | * @return $this 74 | */ 75 | private function remove_css_and_js(){ 76 | $this->content = str_replace("\n", '', $this->content); 77 | $this->content = preg_replace('`]*>.*?`', '', $this->content); 78 | $this->content = preg_replace('`]*>.*?`', '', $this->content); 79 | return $this; 80 | } 81 | /** 82 | * arr convert into url. 83 | * @param $arr 84 | * @return string 85 | */ 86 | public static function arr2url(array $arr){ 87 | if(!is_array($arr)) 88 | return FALSE; 89 | $s = ''; 90 | foreach($arr as $k => $v){ 91 | $s .= urlencode($k).'='.urlencode($v).'&'; 92 | } 93 | $s = substr($s, 0, count($s) - 2); 94 | return $s; 95 | } 96 | 97 | /** 98 | * url convert into url. 99 | * @param $str 100 | * @return array 101 | */ 102 | public static function url2arr($str){ 103 | if(!is_string($str)) 104 | return FALSE; 105 | parse_str($str, $f); 106 | return $f; 107 | } 108 | 109 | /** 110 | * set the results per page. 111 | * @param int $num 112 | * @return $this 113 | */ 114 | public function set_num($num){ 115 | $this->paras['num'] = $num; 116 | $this->paras_m[opt('GET_NUM')] = $num; 117 | return $this; 118 | } 119 | 120 | /** 121 | * set the page number. 122 | * @param int $p 123 | * @return $this 124 | */ 125 | public function set_page($p){ 126 | $this->paras['start'] = ($p - 1) * $this->paras['num']; 127 | $this->paras_m[opt('GET_PAGE')] = $p; 128 | return $this; 129 | } 130 | 131 | /** 132 | * set the search language use standard language code. see https://sites.google.com/site/tomihasa/google-language-codes 133 | * @param string $lang 134 | * @return $this 135 | */ 136 | public function set_lang($lang){ 137 | $this->paras_m[opt('GET_LANG')] = $lang; 138 | $this->paras['hl'] = $lang; 139 | $this->paras['lr'] = 'lang_'.$lang; 140 | return $this; 141 | } 142 | 143 | /** 144 | * set time before, e.g. h12 = before 12 hours, m30 = before 30 minutes. 145 | * @param $str 146 | * @return $this 147 | */ 148 | public function set_time($str){ 149 | if(!is_string($str)) 150 | return FALSE; 151 | $str = strtolower($str); 152 | if(!isset($this->paras['tbs'])){ 153 | $this->paras['tbs'] = ''; 154 | 155 | } 156 | else 157 | $this->paras['tbs'] .= ','; 158 | switch($str){ 159 | //just now 160 | case 's': 161 | $this->paras['tbs'] .= 'qdr:s'; 162 | $this->paras_m[opt('GET_TIME')] = $str; 163 | break; 164 | //few minutes ago 165 | case 'n': 166 | $this->paras['tbs'] .= 'qdr:n'; 167 | $this->paras_m[opt('GET_TIME')] = $str; 168 | break; 169 | //half of hour ago 170 | case 't': 171 | $this->paras['tbs'] .= 'qdr:n30'; 172 | $this->paras_m[opt('GET_TIME')] = $str; 173 | break; 174 | //half of day ago 175 | case 'j': 176 | $this->paras['tbs'] .= 'qdr:h12'; 177 | $this->paras_m[opt('GET_TIME')] = $str; 178 | break; 179 | //a hour ago 180 | case 'h': 181 | $this->paras['tbs'] .= 'qdr:h'; 182 | $this->paras_m[opt('GET_TIME')] = $str; 183 | break; 184 | //a day ago 185 | case 'd': 186 | $this->paras['tbs'] .= 'qdr:d'; 187 | $this->paras_m[opt('GET_TIME')] = $str; 188 | break; 189 | //a weekend ago 190 | case 'w': 191 | $this->paras['tbs'] .= 'qdr:w'; 192 | $this->paras_m[opt('GET_TIME')] = $str; 193 | break; 194 | //a month ago 195 | case 'm': 196 | $this->paras['tbs'] .= 'qdr:m'; 197 | $this->paras_m[opt('GET_TIME')] = $str; 198 | break; 199 | //a year ago 200 | case 'y': 201 | $this->paras['tbs'] .= 'qdr:y'; 202 | $this->paras_m[opt('GET_TIME')] = $str; 203 | break; 204 | default: 205 | return False; 206 | } 207 | return $this; 208 | } 209 | /** 210 | * parsing the html data to array. 211 | * @return $this 212 | */ 213 | function get_results(){ 214 | if($this->status['errno']) 215 | return FALSE; 216 | $c = 0; 217 | $s = array(); 218 | while(TRUE){ 219 | $s1 = stripos($this->content, '
content, '
content, $s1); 223 | $s3 = strripos($e, '
') + 5; 224 | $s[] = substr($this->content, $s1, $s3); 225 | break; 226 | } 227 | $e = substr($this->content, $s1, $s2); 228 | $s3 = strripos($e, '
') + 5; 229 | $s[] = substr($this->content, $s1, $s3); 230 | $c = $s2; 231 | } 232 | for($i = 0; $i < count($s); $i++){ 233 | $id_reg = '@]+class="g"[^>]?(?:id="([^"]*)")?[^>]*>@s'; 234 | preg_match($id_reg, $s[$i], $r); 235 | $id = isset($r[1]) ? $this->e ? encrypt($r[1], $this->k) : $r[1] : ''; 236 | $href_reg = '@]+class="r">.*?]+href="([^"]*)"[^>]*>(.*?)@s'; 237 | preg_match($href_reg, $s[$i], $r); 238 | $href = isset($r[1]) ? $this->e ? encrypt($r[1], $this->k) : $r[1] : ''; 239 | $tle = isset($r[2]) ? $this->e ? encrypt($r[2], $this->k) : $r[2] : ''; 240 | $disc_reg = '@]+class="st"[^>]*>((?:]+class="f">.*?)?.*?)@s'; 241 | preg_match($disc_reg, $s[$i], $r); 242 | $disc = isset($r[1]) ? $this->e ? encrypt($r[1], $this->k) : $r[1] : ''; 243 | $site_reg = '@]+class="_Rm[^"]*"[^>]*>(.*?)@s'; 244 | preg_match($site_reg, $s[$i], $r); 245 | $site = isset($r[1]) ? $this->e ? encrypt($r[1], $this->k) : $r[1] : ''; 246 | $this->results[] = array('id' => $id, 'url' => $href, 'title' => $tle, 'info' => $disc, 'site' => $site); 247 | } 248 | //related searches 249 | preg_match_all('@

]+>(.*?)@s', $this->content, $r, PREG_SET_ORDER); 250 | if(count($r) > 0){ 251 | $this->results['related'] = array(); 252 | foreach($r as $v){ 253 | $this->results['related'][] = $v[1]; 254 | } 255 | } 256 | else{ 257 | $this->results['related'] = FALSE; 258 | } 259 | return $this; 260 | } 261 | 262 | /** 263 | * return current page number; 264 | * @return int 265 | */ 266 | public function get_page(){ 267 | return floor($this->paras['start'] / $this->paras['num']) + 1; 268 | } 269 | 270 | /** 271 | * use by view class, this is url builder, not original url; 272 | * @param array $paras 273 | * @param string key 274 | * @param string value 275 | * @return string url 276 | */ 277 | public function get_url($paras = null, $key = null, $val = null){ 278 | $tmp = $this->paras_m; 279 | if(is_array($paras)){ 280 | foreach($paras as $k => $v){ 281 | $tmp[$k] = $v; 282 | } 283 | } 284 | elseif($key !== null && $val !== null){ 285 | $tmp[$key] = $val; 286 | } 287 | if(opt('ENCRYPT')){ 288 | $tmp[opt('GET_Q')] = encrypt($tmp[opt('GET_Q')], opt('ENCRYPT_K')); 289 | } 290 | return './?'.$this->arr2url($tmp); 291 | } 292 | public function get_key(){ 293 | return $this->paras['q']; 294 | } 295 | public function get_key_url($key){ 296 | $paras = array(); 297 | if(isset($this->paras_m[opt('GET_NUM')])) 298 | $paras[opt('GET_NUM')] = $this->paras_m[opt('GET_NUM')]; 299 | if(isset($this->paras_m[opt('GET_LANG')])) 300 | $paras[opt('GET_LANG')] = $this->paras_m[opt('GET_LANG')]; 301 | if(isset($this->paras_m[opt('GET_TIME')])) 302 | $paras[opt('GET_TIME')] = $this->paras_m[opt('GET_TIME')]; 303 | $paras[opt('GET_Q')] = $this->e ? encrypt($key, opt('ENCRYPT_K')) : $key; 304 | return './?'.$this->arr2url($paras); 305 | } 306 | public function get_commit_paras(){ 307 | $paras = array(); 308 | if(isset($this->paras_m[opt('GET_NUM')])) 309 | $paras[opt('GET_NUM')] = $this->paras_m[opt('GET_NUM')]; 310 | if(isset($this->paras_m[opt('GET_LANG')])) 311 | $paras[opt('GET_LANG')] = $this->paras_m[opt('GET_LANG')]; 312 | if(isset($this->paras_m[opt('GET_TIME')])) 313 | $paras[opt('GET_TIME')] = $this->paras_m[opt('GET_TIME')]; 314 | return $paras; 315 | } 316 | }; -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | show(); 21 | } 22 | else{ 23 | require_once 'google_search.class.php'; 24 | require_once 'view.class.php'; 25 | $q = $_GET[opt('GET_Q')]; 26 | $h = isset($_GET[opt('GET_LANG')]) ? $_GET[opt('GET_LANG')] : FALSE; 27 | $p = isset($_GET[opt('GET_PAGE')]) ? $_GET[opt('GET_PAGE')] : 0; 28 | $d = isset($_GET[opt('GET_TIME')]) ? $_GET[opt('GET_TIME')] : FALSE; 29 | $n = isset($_GET[opt('GET_NUM')]) ? (int) $_GET[opt('GET_NUM')] : FALSE; 30 | if(substr($q, 0, 3) == '%FF' && opt('ENCRYPT')) 31 | $q = decrypt($q, opt('ENCRYPT_K')); 32 | $g = new search($q); 33 | if($n) 34 | $g->set_num($n); 35 | if($p) 36 | $g->set_page($p); 37 | if($d) 38 | $g->set_time($d); 39 | if($h) 40 | $g->set_lang($h); 41 | $g->load(); 42 | $g->get_results(); 43 | $s = new view($g); 44 | $s->show(); 45 | } -------------------------------------------------------------------------------- /res/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Celend/google-alias/6e28ef099ace47d97504badc7a6eea0486b704f6/res/favicon.ico -------------------------------------------------------------------------------- /res/google-alias.css: -------------------------------------------------------------------------------- 1 | html { 2 | height: 100%; 3 | overflow: hidden; 4 | } 5 | 6 | body { 7 | margin: 0; 8 | height: 100%; 9 | font-family: arial,sans-serif; 10 | overflow: auto; 11 | } 12 | 13 | .i-search { 14 | margin: 0 auto; 15 | margin-top: 10%; 16 | } 17 | 18 | .i-logo { 19 | width: 300px; 20 | margin: 0 auto; 21 | } 22 | 23 | .i-logo-img { 24 | background: url("./logo11w.png") no-repeat; 25 | background-size: 300px 105px; 26 | position: relative; 27 | margin: 0 auto; 28 | width: 300px; 29 | height: 105px; 30 | } 31 | 32 | .alias { 33 | position: relative; 34 | color: #777; 35 | font-size: 20px; 36 | left: 256px; 37 | top: -25px; 38 | font-weight: bold; 39 | } 40 | 41 | .i-search-bar { 42 | margin: 15px; 43 | text-align: center; 44 | } 45 | 46 | .i-q { 47 | width: 100%; 48 | height: 29px; 49 | padding: 4px 6px 2px 4px; 50 | border: 1px solid #b9b9b9; 51 | font: -webkit-small-control; 52 | box-sizing: border-box; 53 | font-size: 17px; 54 | min-width: 230px; 55 | max-width: 600px; 56 | } 57 | 58 | .i-q:hover { 59 | border-color: #a3a3a3; 60 | } 61 | 62 | .i-q:focus { 63 | border-color: #5f8be8; 64 | } 65 | 66 | .i-search-bu { 67 | border: none; 68 | font-family: "Microsoft YaHei", "微软雅黑"; 69 | border-radius: 2px; 70 | background-color: #4d90fe; 71 | font-size: 1.05em; 72 | padding: .2em 1.1em 1.5em 1.1em; 73 | margin: 0 15px 0 15px; 74 | color: #FFF; 75 | height: 27px; 76 | cursor: pointer; 77 | } 78 | .s-search-bu{ 79 | background: url("./search.png") no-repeat center center; 80 | margin-left: 10px; 81 | border: none; 82 | border-radius: 2px; 83 | background-color: #4d90fe; 84 | height: 27px; 85 | width: 60px; 86 | display: inline-block; 87 | vertical-align: top; 88 | } 89 | 90 | /*result page*/ 91 | .s-logo { 92 | margin-top: 20px; 93 | margin-left: 15px; 94 | width: 110px; 95 | display: inline-block; 96 | vertical-align: middle; 97 | } 98 | 99 | .s-logo-img { 100 | width: 110px; 101 | } 102 | 103 | .s-top-bar { 104 | width: 100%; 105 | overflow: auto; 106 | background: #f1f1f1; 107 | border-bottom: 1px #e5e5e5 solid; 108 | } 109 | 110 | .s-logo-alias { 111 | position: relative; 112 | top: -12px; 113 | left: 90px; 114 | color: #777; 115 | font-size: .7em; 116 | } 117 | 118 | .s-q { 119 | width: 530px; 120 | font-size: 28px; 121 | height: 27px; 122 | padding: 0 0 0 6px ; 123 | border: 1px solid #b9b9b9; 124 | font: 17px arial,sans-serif; 125 | box-sizing: border-box; 126 | line-height: 1.25em !important; 127 | } 128 | 129 | .s-q:hover { 130 | border-color: #a3a3a3; 131 | } 132 | 133 | .s-q:focus { 134 | border-color: #5f8be8; 135 | } 136 | 137 | .s-search-bar { 138 | margin-top: 20px; 139 | margin-left: 16px; 140 | display: inline-block; 141 | } 142 | 143 | .search-res { 144 | position: relative; 145 | top: 20px; 146 | width: 540px; 147 | margin-left: 145px; 148 | } 149 | 150 | .search-res ul { 151 | padding: 0; 152 | } 153 | 154 | .search-tool-bar { 155 | position: relative; 156 | height: 40px; 157 | width: 100%; 158 | border-bottom: 1px #e5e5e5 solid; 159 | background: #fff; 160 | } 161 | 162 | em { 163 | color: #dd4b39; 164 | font-style: normal; 165 | } 166 | 167 | .s-box { 168 | display: block; 169 | margin-bottom: 20px; 170 | } 171 | 172 | .s-title { 173 | font-size: 1.2em; 174 | } 175 | 176 | .s-title:hover { 177 | text-decoration: underline; 178 | } 179 | .s-disc { 180 | line-height: 1.4; 181 | word-wrap: break-word; 182 | color: #545454; 183 | font-size: small; 184 | } 185 | 186 | .s-title-link { 187 | color: #006621; 188 | font-style: normal; 189 | font-size: 13px; 190 | display: block; 191 | margin-top: -2px; 192 | } 193 | 194 | a:link { 195 | color: #1a0dab; 196 | text-decoration: none; 197 | } 198 | 199 | a:visited { 200 | color: #609; 201 | } 202 | 203 | .f { 204 | color: #808080; 205 | } 206 | /*pages bar*/ 207 | .navcnt{ 208 | width: 100%; 209 | height: 55px; 210 | } 211 | .nav-t{ 212 | margin: 25px auto 0 auto; 213 | } 214 | .nav-a{ 215 | display: block; 216 | color: #1a0dab; 217 | font-size: .8em; 218 | } 219 | .nav-a:visited{ 220 | color: #1a0dab; 221 | } 222 | .s-prev{ 223 | width: 74px; 224 | height: 55px; 225 | } 226 | .t-prev{ 227 | float: left; 228 | } 229 | .t-prev:hover, .t-next:hover{ 230 | text-decoration: underline; 231 | } 232 | .t-next{ 233 | text-decoration: none; 234 | float: right; 235 | } 236 | .s-next{ 237 | width: 88px; 238 | height: 55px 239 | } 240 | .nav-n{ 241 | margin-left: -4px; 242 | text-align: center; 243 | display: block; 244 | width: 20px; 245 | } 246 | .nav-n:hover{ 247 | text-decoration: underline; 248 | } 249 | .csb{ 250 | background: url("./nav_logo195.png") no-repeat left; 251 | height: 40px; 252 | display: block; 253 | margin-left: -4px; 254 | text-align: center; 255 | } 256 | .c-g{ 257 | background-position: 0 0; 258 | width: 52px; 259 | margin-left: 0; 260 | float: right; 261 | } 262 | .c-o1{ 263 | background-position: -52px 0; 264 | width: 22px; 265 | } 266 | .c-o2{ 267 | background-position: -74px 0; 268 | width: 22px; 269 | } 270 | .c-gle{ 271 | background-position: -96px 0; 272 | width: 70px; 273 | display: block; 274 | } 275 | .tool-box{ 276 | position: relative; 277 | margin: 12px 0 0 145px; 278 | width: 445px; 279 | display: inline-block; 280 | } 281 | .search-info{ 282 | line-height: 2.8em; 283 | color: #808080; 284 | font-size: .95em; 285 | } 286 | .no-sel{ 287 | -moz-user-select: none; 288 | -webkit-user-select: none; 289 | -ms-user-select: none; 290 | -khtml-user-select: none; 291 | user-select: none; 292 | } 293 | .tool-btn-b{ 294 | cursor: pointer; 295 | color: #777; 296 | margin-top: 4px; 297 | display: inline-block; 298 | } 299 | .tool-btn{ 300 | padding: 8px 8px 5px 8px; 301 | } 302 | .tool-btn:hover{ 303 | border: 1px solid #c6c6c6; 304 | padding: 7px 8px 6px 7px; 305 | border-radius: 2px ; 306 | background: #f1f1f1; 307 | } 308 | .tool-btn-press{ 309 | padding: 7px 8px 6px 7px; 310 | box-shadow: inset 0 1px 2px 0 rgba(0,0,0,0.1); 311 | background: -webkit-linear-gradient(top,#eee,#e0e0e0); 312 | border: 1px solid #d7d7d7; 313 | border-radius: 2px ; 314 | } 315 | #tool-panel{ 316 | margin-top: 9px; 317 | display: none; 318 | } 319 | .left-tool-box{ 320 | 321 | } 322 | .tf{ 323 | min-height: 100%; height: auto; margin-left: 145px; width: 450px;float: left; 324 | } 325 | .tool{ 326 | font-size: .95em; 327 | color:#777; 328 | display: inline-block; 329 | height: 20px; 330 | padding: 0 0 0 25px; 331 | cursor: pointer; 332 | } 333 | .tool:hover{ 334 | color:#333; 335 | } 336 | .tool-time{ 337 | position: relative; 338 | left: -25px; 339 | margin-right: -25px; 340 | } 341 | .dwn-tri{ 342 | font-size: .7em; 343 | display: inline; 344 | margin: -2px 0 0 2px; 345 | } 346 | .tool-al{ 347 | position: absolute; 348 | background: #ffffff; 349 | min-width: 95px; 350 | margin: -8px 0 0 -30px; 351 | z-index: 6; 352 | border: 1px solid #d9d9d9; 353 | padding: 5px 0 5px 0; 354 | color:#777; 355 | } 356 | .opt{ 357 | padding: 5px 0 5px 15px; 358 | margin: 2px 0 2px 0; 359 | } 360 | .opt:hover{ 361 | background: #D9D9D9; 362 | } 363 | .t-l, .t-l:link, .t-l:visited{ 364 | color: #777; 365 | } 366 | .t-l:active{ 367 | color: #de3937; 368 | } 369 | .med { 370 | color: gray; 371 | font-style: normal; 372 | font-size: 17px; 373 | line-height: 1.3; 374 | font-weight: 400; 375 | } 376 | ._e4b { 377 | margin: 0; 378 | white-space:nowrap; 379 | padding-top: 5px; 380 | min-width: 120px; 381 | } 382 | ._e4b:hover{ 383 | text-decoration: underline; 384 | } 385 | .row{ 386 | display: inline-block; 387 | width: auto; 388 | max-width: 280px; 389 | overflow: hidden; 390 | margin-right: 20px; 391 | } 392 | #clear{ 393 | letter-spacing: 2px; 394 | color: #db4823; 395 | padding: 8px 9px 5px 8px; 396 | list-style: none; 397 | float: right; 398 | margin: -6px 10px 0 0; 399 | } 400 | #clear:hover{ 401 | border: 1px solid #c6c6c6; 402 | padding: 7px 8px 5px 8px; 403 | border-radius: 2px ; 404 | background: #f1f1f1; 405 | } 406 | .fbar{ 407 | bottom: 0;left: 0; right: 0;height: 40px;background: #F2F2F2;margin-top: 56px;border-top: 1px solid #E4E4E4; 408 | } 409 | .fa{ 410 | display: inline-block; 411 | margin-right: 50px; 412 | } 413 | .fa:link, .fa:visited{ 414 | color: #777; 415 | } 416 | .fa:hover{ 417 | color: #444; 418 | } 419 | .fb{ 420 | line-height: 40px; margin-left: 145px; 421 | } 422 | .loading{ 423 | height: 100%; 424 | } 425 | .loading .cont{ 426 | display: none; 427 | } 428 | .loading-mes{ 429 | font-size: 2em;text-align: center; color: #CCC; line-height: 16em; height: 100%; 430 | } 431 | .i-box{ 432 | margin: 0 auto 0 auto; width: 50% 433 | } 434 | ul{ 435 | margin: 0; 436 | padding: 0; 437 | } 438 | #tool-time{ 439 | display: none;left:165px; 440 | } 441 | #tool-num{ 442 | display: none;left: 272px; 443 | } 444 | #tool-lang{ 445 | display: none;left: 375px; 446 | } 447 | .button-bar{ 448 | margin: 20px auto 0 auto; width: auto; 449 | } 450 | @media screen and (max-width: 780px){ 451 | .s-logo { 452 | display: block; 453 | margin-left: auto; 454 | margin-right: auto; 455 | } 456 | 457 | .s-top-bar { 458 | text-align: center; 459 | } 460 | 461 | .s-logo { 462 | text-align: left; 463 | } 464 | 465 | .s-search-bar { 466 | width: 95%; 467 | margin: 0; 468 | } 469 | 470 | .s-q { 471 | width: 72%; 472 | max-width: 400px; 473 | } 474 | 475 | .search-res { 476 | width: 90%; 477 | margin: 0 auto; 478 | max-width: 580px; 479 | } 480 | .s-prev{ 481 | width: 40px; 482 | height: 55px; 483 | } 484 | .s-next{ 485 | width: 50px; 486 | height: 55px 487 | } 488 | .nav-t{ 489 | margin: 25px auto 0 auto; 490 | width: 90%; 491 | } 492 | .tf{ 493 | margin-left: 5%; font-size: .9em; width: auto; 494 | } 495 | #tool-time{ 496 | left: 35px; 497 | } 498 | #tool-num{ 499 | left: 135px; 500 | } 501 | #tool-lang{ 502 | left: 225px; 503 | } 504 | .fb{ 505 | margin-left: 15px; 506 | } 507 | .contactme{ 508 | display: none; 509 | } 510 | .i-q{ 511 | widows: 10; 512 | } 513 | .i-box{ 514 | width:90% 515 | } 516 | .fa{ 517 | margin: 0 5px 0 5px; 518 | } 519 | .i-search-bu{ 520 | margin: 0 6px 0 6px; 521 | padding: .3em .9em 1.5em .9em; 522 | font-size: .95em; 523 | } 524 | #tool-panel{ 525 | margin-top: 12px; 526 | } 527 | .search-info{ 528 | line-height: 3.1em; 529 | } 530 | } 531 | @media screen and (max-height: 350px){ 532 | .i-search{ 533 | margin-top: 4%; 534 | } 535 | .i-search-bar{ 536 | margin: 0 0 0 0; 537 | } 538 | .i-q{ 539 | display: inline-block; 540 | width: auto; 541 | min-width: 50%; 542 | max-width: 300px; 543 | margin: 0; 544 | } 545 | .button-bar{ 546 | display: inline-block; 547 | margin-top: 10px; 548 | } 549 | .i-search-bu{ 550 | margin: 0 3px 0 3px; 551 | } 552 | } -------------------------------------------------------------------------------- /res/google-alias.js: -------------------------------------------------------------------------------- 1 | /** 2 | * javascript 3 | * @license GNU LGPL Ver 3.0 4 | * @package google-alias 5 | * @author celend 6 | * @date 14-10-15 7 | */ 8 | this.searchtype = 0; 9 | 'use strict';(function(d){function h(a,b,e){var c="rgb"+(d.support.rgba?"a":"")+"("+parseInt(a[0]+e*(b[0]-a[0]),10)+","+parseInt(a[1]+e*(b[1]-a[1]),10)+","+parseInt(a[2]+e*(b[2]-a[2]),10);d.support.rgba&&(c+=","+(a&&b?parseFloat(a[3]+e*(b[3]-a[3])):1));return c+")"}function f(a){var b;return(b=/#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/.exec(a))?[parseInt(b[1],16),parseInt(b[2],16),parseInt(b[3],16),1]:(b=/#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/.exec(a))?[17*parseInt(b[1],16),17*parseInt(b[2],16),17*parseInt(b[3],16),1]:(b=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(a))?[parseInt(b[1]),parseInt(b[2]),parseInt(b[3]),1]:(b=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9\.]*)\s*\)/.exec(a))?[parseInt(b[1],10),parseInt(b[2],10),parseInt(b[3],10),parseFloat(b[4])]:l[a]}d.extend(!0,d,{support:{rgba:function(){var a=d("script:first"),b=a.css("color"),e=!1;if(/^rgba/.test(b))e=!0;else try{e=b!=a.css("color","rgba(0, 0, 0, 0.5)").css("color"), 10 | a.css("color",b)}catch(c){}return e}()}});var k="color backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor outlineColor".split(" ");d.each(k,function(a,b){d.Tween.propHooks[b]={get:function(a){return d(a.elem).css(b)},set:function(a){var c=a.elem.style,g=f(d(a.elem).css(b)),m=f(a.end);a.run=function(a){c[b]=h(g,m,a)}}}});d.Tween.propHooks.borderColor={set:function(a){var b=a.elem.style,e=[],c=k.slice(2,6);d.each(c,function(b,c){e[c]=f(d(a.elem).css(c))});var g=f(a.end); 11 | a.run=function(a){d.each(c,function(d,c){b[c]=h(e[c],g,a)})}}};var l={aqua:[0,255,255,1],azure:[240,255,255,1],beige:[245,245,220,1],black:[0,0,0,1],blue:[0,0,255,1],brown:[165,42,42,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgrey:[169,169,169,1],darkgreen:[0,100,0,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkviolet:[148,0,211,1],fuchsia:[255,0,255,1],gold:[255,215,0,1],green:[0,128,0,1],indigo:[75,0,130,1],khaki:[240,230,140,1],lightblue:[173,216,230,1],lightcyan:[224,255,255,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],magenta:[255,0,255,1],maroon:[128,0,0,1],navy:[0,0,128,1],olive:[128,128,0,1],orange:[255,165,0,1],pink:[255,192,203,1],purple:[128,0,128,1],violet:[128,0,128,1],red:[255,0,0,1],silver:[192,192,192,1],white:[255,255,255,1],yellow:[255,255,0,1],transparent:[255,255,255,0]}})(jQuery); 12 | !function(a){"use strict";var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,b=a.Base64,c="2.1.4";"undefined"!=typeof module&&module.exports&&(d=require("buffer").Buffer),e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=function(a){var c,d,b={};for(c=0,d=a.length;d>c;c++)b[a.charAt(c)]=c;return b}(e),g=String.fromCharCode,h=function(a){var b;return a.length<2?(b=a.charCodeAt(0),128>b?a:2048>b?g(192|b>>>6)+g(128|63&b):g(224|15&b>>>12)+g(128|63&b>>>6)+g(128|63&b)):(b=65536+1024*(a.charCodeAt(0)-55296)+(a.charCodeAt(1)-56320),g(240|7&b>>>18)+g(128|63&b>>>12)+g(128|63&b>>>6)+g(128|63&b))},i=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,j=function(a){return a.replace(i,h)},k=function(a){var b=[0,2,1][a.length%3],c=a.charCodeAt(0)<<16|(a.length>1?a.charCodeAt(1):0)<<8|(a.length>2?a.charCodeAt(2):0),d=[e.charAt(c>>>18),e.charAt(63&c>>>12),b>=2?"=":e.charAt(63&c>>>6),b>=1?"=":e.charAt(63&c)];return d.join("")},l=a.btoa?function(b){return a.btoa(b)}:function(a){return a.replace(/[\s\S]{1,3}/g,k)},m=d?function(a){return new d(a).toString("base64")}:function(a){return l(j(a))},n=function(a,b){return b?m(a).replace(/[+\/]/g,function(a){return"+"==a?"-":"_"}).replace(/=/g,""):m(a)},o=function(a){return n(a,!0)},p=new RegExp(["[À-ß][€-¿]","[à-ï][€-¿]{2}","[ð-÷][€-¿]{3}"].join("|"),"g"),q=function(a){switch(a.length){case 4:var b=(7&a.charCodeAt(0))<<18|(63&a.charCodeAt(1))<<12|(63&a.charCodeAt(2))<<6|63&a.charCodeAt(3),c=b-65536;return g((c>>>10)+55296)+g((1023&c)+56320);case 3:return g((15&a.charCodeAt(0))<<12|(63&a.charCodeAt(1))<<6|63&a.charCodeAt(2));default:return g((31&a.charCodeAt(0))<<6|63&a.charCodeAt(1))}},r=function(a){return a.replace(p,q)},s=function(a){var b=a.length,c=b%4,d=(b>0?f[a.charAt(0)]<<18:0)|(b>1?f[a.charAt(1)]<<12:0)|(b>2?f[a.charAt(2)]<<6:0)|(b>3?f[a.charAt(3)]:0),e=[g(d>>>16),g(255&d>>>8),g(255&d)];return e.length-=[0,0,2,1][c],e.join("")},t=a.atob?function(b){return a.atob(b)}:function(a){return a.replace(/[\s\S]{1,4}/g,s)},u=d?function(a){return new d(a,"base64").toString()}:function(a){return r(t(a))},v=function(a){return u(a.replace(/[-_]/g,function(a){return"-"==a?"+":"/"}).replace(/[^A-Za-z0-9\+\/]/g,""))},w=function(){var c=a.Base64;return a.Base64=b,c},a.Base64={VERSION:c,atob:t,btoa:l,fromBase64:v,toBase64:n,utob:j,encode:n,encodeURI:o,btou:r,decode:v,noConflict:w},"function"==typeof Object.defineProperty&&(x=function(a){return{value:a,enumerable:!1,writable:!0,configurable:!0}},a.Base64.extendString=function(){Object.defineProperty(String.prototype,"fromBase64",x(function(){return v(this)})),Object.defineProperty(String.prototype,"toBase64",x(function(a){return n(this,a)})),Object.defineProperty(String.prototype,"toBase64URI",x(function(){return n(this,!0)}))})}(this); 13 | $( document ).ready(function(){ 14 | $('.tool-btn').on('click', function(e){ 15 | $('.tool-al').hide(); 16 | if(!$('#tool-panel').is(':visible')){ 17 | $(this).removeClass('tool-btn').addClass('tool-btn-press'); 18 | $('#tool-panel').show(); 19 | $('#search-info').animate({ 20 | 'marginTop': '-40px' 21 | }, 150); 22 | } 23 | else{ 24 | $(this).removeClass('tool-btn-press').addClass('tool-btn'); 25 | $('#search-info').animate({ 26 | 'marginTop': 0 27 | }, 150, function(){ 28 | $('#tool-panel').hide(); 29 | }); 30 | } 31 | }); 32 | $('.tool').on('click', function(e){ 33 | var type = $(this).attr('id'); 34 | $('.tool-al').not('#tool-'+type).hide(); 35 | var ele = $('#tool-'+type); 36 | if(ele.is(':visible')) 37 | ele.hide(); 38 | else 39 | ele.show(); 40 | $('body').one('click', function(e){ 41 | ele.hide(); 42 | }); 43 | return false; 44 | }); 45 | $('#clear').on('click', function(){ 46 | $('.hd-fd').remove(); 47 | $(this).hide(0, function(){ 48 | $(this).remove(); 49 | $('.s-q').css('color', '#FFF'); 50 | $('.s-q').animate({ 51 | 'backgroundColor': '#F00' 52 | }, 50, function(){ 53 | $('.s-q').animate({ 54 | 'color' : '#000', 55 | 'backgroundColor': '#FFF' 56 | }, 1000); 57 | }) 58 | }); 59 | }) 60 | }); 61 | function encrypt(str, key){ 62 | var s = ''; 63 | var t = ''; 64 | for(var i = 0; i < str.length; ++i){ 65 | if(encodeURI(str[i]) == str[i]){ 66 | s += str[i]; 67 | } 68 | else{ 69 | var c = encodeURI(str[i]); 70 | c = c.split('%'); 71 | var f = []; 72 | for(var j = 1; j < c.length; ++j){ 73 | t = parseInt(parseInt(c[j], 16) - key).toString(16).toLocaleUpperCase(); 74 | if(t.length == 1) 75 | t = '0' + t; 76 | f.push(t); 77 | } 78 | s += '%' + f.join('%'); 79 | } 80 | } 81 | return '%FF' + s; 82 | } 83 | //extend 84 | $.fn.decrypt = function(key){ 85 | try{ 86 | this.html(decrypt(this.html(), key)); 87 | } 88 | catch(e){ 89 | console.log(e); 90 | } 91 | return this; 92 | } 93 | var table = {'40':'@', '23':'#', '24':'$', '26':'&', '2F':'/', '3B':';', '3A':':', '3F':'?', '2C':',', '3D':'='}; 94 | function decrypt(str, key){ 95 | if(str.substr(0, 3) == '%FF'){ 96 | str = str.substr(3); 97 | } 98 | var t = ''; 99 | var s = ''; 100 | for(var i = 0; i < str.length; ++i){ 101 | if(str[i] == '+'){ 102 | s += ' '; 103 | } 104 | else if(str[i] != '%'){ 105 | s += str[i]; 106 | } 107 | else{ 108 | t = parseInt(parseInt(str.substr(i + 1, 2), 16) + key).toString(16).toLocaleUpperCase(); 109 | if(t.length == 1){ 110 | s = '0' + t; 111 | } 112 | if(table[t] != undefined){ 113 | s += table[t]; 114 | } 115 | else{ 116 | s += '%' + t; 117 | } 118 | i += 2; 119 | } 120 | } 121 | return decodeURI(s); 122 | }; 123 | 124 | var avaip = ''; 125 | var ips = []; 126 | var ip_k = 0; 127 | function index(modify){ 128 | if(typeof modify == 'string' && modify.length > 6){ 129 | avaip = modify; 130 | return true; 131 | } 132 | if(modify){ 133 | if(ips.length <= 1){ 134 | $('.fa:eq(2)').html('暂无可用IP'); 135 | return false; 136 | } 137 | ips.splice(0, modify); 138 | ip_k = 0; 139 | } 140 | else{ 141 | $('.i-q').focus(); 142 | } 143 | var inUse = false; 144 | function testip(state, callback){ 145 | if(state){ 146 | avaip = ips[ip_k]; 147 | console.info('now google ip is:' + avaip); 148 | if(callback) 149 | callback(); 150 | return true; 151 | } 152 | else{ 153 | ip_k++; 154 | ping(callback) 155 | } 156 | } 157 | function ping(callback){ 158 | if(!inUse){ 159 | var img = new Image(); 160 | inUse = true; 161 | img.onload = function(){ 162 | if(inUse){ 163 | inUse = false; 164 | testip(true, callback); 165 | } 166 | } 167 | img.onerror = function(){ 168 | if(inUse){ 169 | inUse = false; 170 | testip(true, callback); 171 | } 172 | } 173 | img.src = 'http://' + ips[ip_k] + '/images/srpr/logo11w.png'; 174 | setTimeout(function(){ 175 | if(inUse){ 176 | inUse = false; 177 | testip(false, callback); 178 | } 179 | }, 500); 180 | } 181 | } 182 | if(modify){ 183 | ping(function(){ 184 | $('.i-q').stop().animate({ 185 | 'backgroundColor': '#F00' 186 | }, 50, function(){ 187 | $(this).animate({ 188 | 'backgroundColor': '#FFF' 189 | }, 1000); 190 | }); 191 | }); 192 | } 193 | else{ 194 | $.ajax({ 195 | 'type': 'get', 196 | 'url': './google_avaiable_ip.txt', 197 | 'success': function(d){ 198 | ips = d.split('|'); 199 | ips.sort(function(){ return 0.5 - Math.random() }); 200 | ping(function(){ 201 | $('.i-search-bu')[0].innerHTML = 'Google搜索'; 202 | }); 203 | }, 204 | 'error': function(){ 205 | alert('从服务器获取可用IP失败, 请联系管理员'); 206 | } 207 | }); 208 | } 209 | } 210 | function commit1(){ 211 | if($('.i-q')[0].value == '') 212 | return false; 213 | if(searchtype === 0){ 214 | if(avaip == ''){ 215 | return false; 216 | } 217 | window.open('http://' + avaip + '/search?newwindow=1&q=' + encodeURI($('.i-q')[0].value), '_blank'); 218 | return false; 219 | } 220 | else if(searchtype === 1){ 221 | $('#hdq').attr('value', encrypt($('.i-q')[0].value, Number($('meta[name=urlencrypt]').attr('content')))); 222 | $('#i-f').submit(); 223 | } 224 | return true; 225 | } 226 | function commit2(){ 227 | if($('.s-q')[0].value == '') 228 | return false; 229 | $('#hdq').attr('value', encrypt($('.s-q')[0].value, Number($('meta[name=urlencrypt]').attr('content')))); 230 | return true; 231 | } 232 | function search(s){ 233 | var k = Number($('meta[name=conencrypt]').attr('content')); 234 | $('.s-q').attr('value', decrypt($('.s-q').attr('value-t'), k)); 235 | if($('meta[name=conencrypt]').attr('content') != 'FALSE'){ 236 | $('title').decrypt(k); 237 | if($('#rel').length > 0) 238 | $('#rel').decrypt(k); 239 | var s = $('.s-title'); 240 | for(var i = 0; i < s.length; ++i){ 241 | $(s[i]).attr('href', decrypt($(s[i]).decrypt(k).attr('href'), k)); 242 | 243 | } 244 | s = $('.s-disc'); 245 | for(i = 0; i < s.length; ++i){ 246 | $(s[i]).decrypt(k); 247 | } 248 | s = $('.rel_a'); 249 | for(i = 0; i < s.length; ++i){ 250 | $(s[i]).decrypt(k); 251 | } 252 | s = $('.s-title-link'); 253 | for(i = 0; i < s.length; ++i){ 254 | $(s[i]).decrypt(k); 255 | } 256 | $('.loading-mes').fadeOut(100, function(){ 257 | $('.loading-mes').remove(); 258 | $('.cont').fadeIn(300, function(){ 259 | $('.search-res').removeClass('loading'); 260 | }); 261 | }); 262 | } 263 | $('.s-q').focus(); 264 | var s = $('.s-q')[0]; 265 | if(s.setSelectionRange){ 266 | s.setSelectionRange(s.value.length, s.value.length); 267 | } 268 | else{ 269 | var r = s.createTextRange(); 270 | r.collapse(true); 271 | r.moveStart('character', s.value.length); 272 | r.select(); 273 | } 274 | }; 275 | window.onkeydown = function(e){ 276 | if($('.s-q').is(':focus') || $('.i-q').is(':focus')) 277 | return true; 278 | if(e.altKey && (e.key == 'j' || 'j'.charCodeAt(0) - 32 == e.keyCode) && !e.shiftKey){ 279 | if($('.i-q').length > 0) 280 | $('.i-q').focus(); 281 | else{ 282 | $('.s-q').focus(); 283 | } 284 | } 285 | else if(e.altKey && (e.key == 'i' || 'i'.charCodeAt(0) - 32 == e.keyCode) && !e.shiftKey){ 286 | if($('.i-q').length > 0) 287 | $('.i-q').focus()[0].value = ''; 288 | else{ 289 | $('.s-q').focus()[0].value = ''; 290 | } 291 | } 292 | return true; 293 | } 294 | -------------------------------------------------------------------------------- /res/logo11w.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Celend/google-alias/6e28ef099ace47d97504badc7a6eea0486b704f6/res/logo11w.png -------------------------------------------------------------------------------- /res/nav_logo195.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Celend/google-alias/6e28ef099ace47d97504badc7a6eea0486b704f6/res/nav_logo195.png -------------------------------------------------------------------------------- /res/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Celend/google-alias/6e28ef099ace47d97504badc7a6eea0486b704f6/res/search.png -------------------------------------------------------------------------------- /view.class.php: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | <{title}> 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | '; 30 | private $index_body = ' 31 |

51 |
52 | 60 |
61 |
62 | 63 | '; 64 | private $res_tmp = '
  • 65 | <{tle}> 66 | <{site}> 67 | <{disc}> 68 |
  • '; 69 | private $s_start = ' 70 |
    71 | 72 | 76 | 77 | 85 |
    86 |
    '; 87 | private $reset = '
  • 重置
  • '; 88 | private $hidden_field = ''; 89 | private $s_end = '
    90 | 91 |
    92 | 97 |
    98 |
    99 | 100 | '; 101 | private $notfound = '
    102 |

    找不到和您的查询 "<{key}>" 相符的内容或信息。

    103 |

    建议:

    104 |
      105 |
    • 请检查输入字词有无错误。
    • 106 |
    • 请尝试其他的查询词
    • 107 |
    • 请改用较常见的字词。
    • 108 |
    109 |
    '; 110 | private $toobar_s = '
    111 |
    112 |
    113 | <{status}> 114 |
    115 |
    116 |
      117 |
    • 时间限制
    • 118 |
    • 每页结果数
    • 119 |
    • 语言
    • 120 | <{fill3}> 121 |
    122 |
    123 |
    124 |
    125 |
      126 | <{fill1}> 127 |
    128 |
    129 |
    130 |
      131 | <{fill2}> 132 |
    133 |
    134 |
    135 |
      136 | <{fill4}> 137 |
    138 |
    139 |
    140 |
    搜索工具
    '; 141 | private $toobar_e = ' 142 |
    143 | <{loadmes}> 144 |
    145 |
      '; 146 | private $toobar_status = '找到约 <{num}> 条结果, 用时 <{second}> 秒.'; 147 | private $page_G = '
    148 |
    149 | '; 182 | 183 | private $rel_s = '

    <{key}>的相关搜索

    '; 184 | private $rel_r_s = '
    '; 185 | private $rel_tmp = "

    \" class=\"rel_a\"><{tle}>

    \n"; 186 | 187 | private $have_hidden = FALSE; 188 | public $g = ''; 189 | function __construct(search $Google_search = null){ 190 | $tle = 'Google Alias Search'; 191 | $this->head = str_replace('<{encrypt}>', opt('ENCRYPT') ? opt('ENCRYPT_K') : 'FALSE', 192 | str_replace('<{conencrypt}>', opt('CON_ENC') ? opt('CON_ENC_K') : 'FALSE', $this->head) 193 | ); 194 | if(@get_class($Google_search) == 'search'){ 195 | $this->g = $Google_search; 196 | $this->is_start = str_replace('<{GET_Q}>', $GLOBALS['OPTIONS']['GET_Q'], $this->s_start); 197 | $this->head = str_replace('<{title}>', opt('CON_ENC') ? encrypt($this->g->get_key().' - '.$tle, opt('CON_ENC_K')) : $this->g->get_key().' - '.$tle, $this->head); 198 | $this->s_start = str_replace('<{GET_Q}>', $GLOBALS['OPTIONS']['GET_Q'], $this->s_start); 199 | $this->type = 1; 200 | if(opt('CON_ENC')){ 201 | $this->toobar_e = str_replace('<{load}>', 'loading', 202 | str_replace('<{loadmes}>', '
    search results is loading...
    ', 203 | $this->toobar_e) 204 | ); 205 | } 206 | else{ 207 | $this->toobar_e = str_replace('<{load}>', '', 208 | str_replace('<{loadmes}>', '', 209 | $this->toobar_e) 210 | ); 211 | } 212 | } 213 | else{ 214 | $this->type = 0; 215 | $this->index_body = str_replace('<{GET_Q}>', $GLOBALS['OPTIONS']['GET_Q'], $this->index_body); 216 | $this->head = str_replace('<{title}>', $tle, $this->head); 217 | } 218 | } 219 | /** 220 | * set the class 221 | */ 222 | public function set_type($str){ 223 | switch($str){ 224 | case 'index': $this->type = 0;break; 225 | case 'search': $this->type = 1;break; 226 | default: return FALSE; 227 | } 228 | return $this; 229 | } 230 | function show(){ 231 | if($this->type){ 232 | if($this->g == ''){ 233 | return FALSE; 234 | } 235 | $s = ''; 236 | $t = $this->g->get_commit_paras(); 237 | if(count($t) > 0){ 238 | $this->have_hidden = TRUE; 239 | foreach($t as $k => $v){ 240 | $s .= str_replace('<{name}>', $k, 241 | str_replace('<{value}>', $v, $this->hidden_field) 242 | ); 243 | } 244 | } 245 | //echo var_dump($this->g->results); 246 | if($this->g->status['errno']){ 247 | if($this->g->status['errno'] == 404){ 248 | echo str_replace('<{key}>', $this->g->get_key(), 249 | str_replace('<{fill1}>', $s ,$this->s_start) 250 | ); 251 | $this->show_tool_bar(); 252 | echo str_replace('<{key}>', $this->g->get_key(), $this->notfound); 253 | echo $this->s_end; 254 | } 255 | return FALSE; 256 | } 257 | echo $this->head; 258 | echo str_replace('<{key}>', opt('CON_ENC') ? encrypt($this->g->get_key(), opt('CON_ENC_K')) : $this->g->get_key(), 259 | str_replace('<{fill1}>', $s ,$this->s_start) 260 | ); 261 | $this->show_tool_bar(); 262 | foreach($this->g->results as $k => $v){ 263 | if(((int) $k) == FALSE && $k !== 0) 264 | continue; 265 | if($v['id'] != ""){ 266 | continue; 267 | } 268 | echo str_replace('<{disc}>', $v['info'], 269 | str_replace('<{site}>', $v['site'], 270 | str_replace('<{tle}>', $v['title'], 271 | str_replace('<{href}>', $v['url'], $this->res_tmp) 272 | ) 273 | ) 274 | ); 275 | } 276 | if($this->g->results['related']) 277 | $this->show_related(); 278 | $this->show_page(); 279 | echo $this->s_end; 280 | } 281 | else{ 282 | echo $this->head.$this->index_body; 283 | } 284 | } 285 | private function show_tool_bar(){ 286 | $t1 = array('s' => '刚刚', 287 | 'n' => '几分钟前', 288 | 't' => '半小时前', 289 | 'h' => '一小时前', 290 | 'j' => '12小时前', 291 | 'd' => '24小时前', 292 | 'w' => '一星期前', 293 | 'm' => '一个月前', 294 | 'y' => '一年前' 295 | ); 296 | $t2 = array('10', '20', '30', '50', '100'); 297 | $t3 = array('zh-CN' => '中文-简体', 'en' => '英语', 'zh-TW' => '中文-繁体'); 298 | $fill1 = ''; 299 | $fill2 = ''; 300 | $fill4 = ''; 301 | foreach($t1 as $k => $v){ 302 | $fill1 .= '
  • '.$v.'
  • '; 303 | } 304 | foreach($t2 as $v){ 305 | $fill2 .= '
  • '.$v.'
  • '; 306 | } 307 | foreach($t3 as $k => $v){ 308 | $fill4 .= '
  • '.$v.'
  • '; 309 | } 310 | if($this->have_hidden) 311 | $s = $this->reset; 312 | else 313 | $s = ''; 314 | if($this->g->status['errno'] == 404){ 315 | echo str_replace('<{status}>' , ' ', 316 | str_replace('<{fill1}>', $fill1, 317 | str_replace('<{fill2}>', $fill2, 318 | str_replace('<{fill3}>', $s, 319 | str_replace('<{fill4}>', $fill4,$this->toobar_s) 320 | ) 321 | ) 322 | ) 323 | ); 324 | } 325 | else{ 326 | echo str_replace('<{second}>', $this->g->status['time'], 327 | str_replace('<{num}>', $this->g->status['res_num'], 328 | str_replace('<{fill1}>', $fill1, 329 | str_replace('<{fill2}>', $fill2, 330 | str_replace('<{status}>', $this->toobar_status, 331 | str_replace('<{fill3}>', $s, 332 | str_replace('<{fill4}>', $fill4,$this->toobar_s) 333 | ) 334 | ) 335 | ) 336 | ) 337 | ) 338 | ); 339 | } 340 | echo $this->toobar_e; 341 | } 342 | private function show_page(){ 343 | if(!$this->type) 344 | return FALSE; 345 | $cp = $this->g->get_page(); 346 | if($cp == 1){ 347 | echo str_replace('<{href}>', '', 348 | str_replace('<{page_p}>', '', $this->page_G) 349 | ); 350 | } 351 | else{ 352 | echo str_replace('<{page_p}>', $this->page_p, 353 | str_replace('<{href}>', 'href="'. 354 | $this->g->get_url(array(opt('GET_PAGE') => ($cp - 1))).'"', $this->page_G) 355 | ); 356 | } 357 | if($cp <= 6){ 358 | for($i = 1; $i <= 10; $i++){ 359 | if($i == $cp){ 360 | echo str_replace('<{href}>', '', 361 | str_replace('<{num}>', $i, $this->page_o1) 362 | ); 363 | } 364 | else{ 365 | echo str_replace('<{href}>', 366 | 'href="'.$this->g->get_url(array(opt('GET_PAGE') => $i)).'"', 367 | str_replace('<{num}>', $i, $this->page_o2) 368 | ); 369 | } 370 | } 371 | } 372 | else{ 373 | for($i = $cp - 5; $i < $cp + 5; $i++){ 374 | if($i == $cp){ 375 | echo str_replace('<{href}>', '', 376 | str_replace('<{num}>', $i, $this->page_o1) 377 | ); 378 | } 379 | else{ 380 | echo str_replace('<{href}>', 381 | 'href="'.$this->g->get_url(array(opt('GET_PAGE') => $i)).'"', 382 | str_replace('<{num}>', $i, $this->page_o2) 383 | ); 384 | } 385 | } 386 | } 387 | echo str_replace('<{href}>', 'href="'.$this->g->get_url(array(opt('GET_PAGE') => $cp + 1)).'"', $this->page_g); 388 | } 389 | private function show_related(){ 390 | $i = 0; 391 | echo str_replace('<{key}>', opt('CON_ENC') ? encrypt($this->g->get_key(),opt('CON_ENC_K')) : $this->g->get_key(), $this->rel_s); 392 | foreach($this->g->results['related'] as $v){ 393 | if($i % 5 == 0){ 394 | echo $this->rel_r_s; 395 | } 396 | echo str_replace('<{href}>', $this->g->get_key_url($v), 397 | str_replace('<{tle}>', opt('CON_ENC') ? encrypt($v, opt('CON_ENC_K')) : $v, $this->rel_tmp) 398 | ); 399 | if(($i + 1) % 5 == 0){ 400 | echo '
    '; 401 | } 402 | $i++; 403 | } 404 | echo '
    '; 405 | } 406 | } 407 | --------------------------------------------------------------------------------