├── 360safe ├── 360webscan.php └── webscan_cache.php ├── README.md ├── api.php ├── config.php ├── do.php ├── includes ├── api.inc.php ├── db.class.php ├── function.php ├── member.php └── txprotect.php ├── index.html ├── install.sql └── 使用说明.txt /360safe/360webscan.php: -------------------------------------------------------------------------------- 1 | |<.*(data|src)=data:text\\/html.*>|\\b(alert\\(|confirm\\(|expression\\(|prompt\\(|benchmark\s*?\(.*\)|sleep\s*?\(.*\)|\\b(group_)?concat[\\s\\/\\*]*?\\([^\\)]+?\\)|\bcase[\s\/\*]*?when[\s\/\*]*?\([^\)]+?\)|load_file\s*?\\()|<[a-z]+?\\b[^>]*?\\bon([a-z]{4,})\s*?=|^\\+\\/v(8|9)|\\b(and|or)\\b\\s*?([\\(\\)'\"\\d]+?=[\\(\\)'\"\\d]+?|[\\(\\)'\"a-zA-Z]+?=[\\(\\)'\"a-zA-Z]+?|>|<|\s+?[\\w]+?\\s+?\\bin\\b\\s*?\(|\\blike\\b\\s+?[\"'])|\\/\\*.*\\*\\/|<\\s*script\\b|\\bEXEC\\b|UNION.+?SELECT\s*(\(.+\)\s*|@{1,2}.+?\s*|\s+?.+?|(`|'|\").*?(`|'|\")\s*)|UPDATE\s*(\(.+\)\s*|@{1,2}.+?\s*|\s+?.+?|(`|'|\").*?(`|'|\")\s*)SET|INSERT\\s+INTO.+?VALUES|(SELECT|DELETE)@{0,2}(\\(.+\\)|\\s+?.+?\\s+?|(`|'|\").*?(`|'|\"))FROM(\\(.+\\)|\\s+?.+?|(`|'|\").*?(`|'|\"))|(CREATE|ALTER|DROP|TRUNCATE)\\s+(TABLE|DATABASE)|<.*(iframe|frame|style|embed|object|frameset|meta|xml|a|img)|hacker"; 11 | //post拦截规则 12 | $postfilter = "<.*=(&#\\d+?;?)+?>|<.*data=data:text\\/html.*>|\\b(alert\\(|confirm\\(|expression\\(|prompt\\(|benchmark\s*?\(.*\)|sleep\s*?\(.*\)|\\b(group_)?concat[\\s\\/\\*]*?\\([^\\)]+?\\)|\bcase[\s\/\*]*?when[\s\/\*]*?\([^\)]+?\)|load_file\s*?\\()|<[^>]*?\\b(onerror|onmousemove|onload|onclick|onmouseover)\\b|\\b(and|or)\\b\\s*?([\\(\\)'\"\\d]+?=[\\(\\)'\"\\d]+?|[\\(\\)'\"a-zA-Z]+?=[\\(\\)'\"a-zA-Z]+?|>|<|\s+?[\\w]+?\\s+?\\bin\\b\\s*?\(|\\blike\\b\\s+?[\"'])|\\/\\*.*\\*\\/|<\\s*script\\b|\\bEXEC\\b|UNION.+?SELECT\s*(\(.+\)\s*|@{1,2}.+?\s*|\s+?.+?|(`|'|\").*?(`|'|\")\s*)|UPDATE\s*(\(.+\)\s*|@{1,2}.+?\s*|\s+?.+?|(`|'|\").*?(`|'|\")\s*)SET|INSERT\\s+INTO.+?VALUES|(SELECT|DELETE)(\\(.+\\)|\\s+?.+?\\s+?|(`|'|\").*?(`|'|\"))FROM(\\(.+\\)|\\s+?.+?|(`|'|\").*?(`|'|\"))|(CREATE|ALTER|DROP|TRUNCATE)\\s+(TABLE|DATABASE)|<.*(iframe|frame|style|embed|object|frameset|meta|xml|a|img)|hacker"; 13 | //cookie拦截规则 14 | $cookiefilter = "benchmark\s*?\(.*\)|sleep\s*?\(.*\)|load_file\s*?\\(|\\b(and|or)\\b\\s*?([\\(\\)'\"\\d]+?=[\\(\\)'\"\\d]+?|[\\(\\)'\"a-zA-Z]+?=[\\(\\)'\"a-zA-Z]+?|>|<|\s+?[\\w]+?\\s+?\\bin\\b\\s*?\(|\\blike\\b\\s+?[\"'])|\\/\\*.*\\*\\/|<\\s*script\\b|\\bEXEC\\b|UNION.+?SELECT\s*(\(.+\)\s*|@{1,2}.+?\s*|\s+?.+?|(`|'|\").*?(`|'|\")\s*)|UPDATE\s*(\(.+\)\s*|@{1,2}.+?\s*|\s+?.+?|(`|'|\").*?(`|'|\")\s*)SET|INSERT\\s+INTO.+?VALUES|(SELECT|DELETE)@{0,2}(\\(.+\\)|\\s+?.+?\\s+?|(`|'|\").*?(`|'|\"))FROM(\\(.+\\)|\\s+?.+?|(`|'|\").*?(`|'|\"))|(CREATE|ALTER|DROP|TRUNCATE)\\s+(TABLE|DATABASE)"; 15 | //获取指令 16 | $webscan_action = isset($_POST['webscan_act'])&&webscan_cheack() ? trim($_POST['webscan_act']) : ''; 17 | //referer获取 18 | $webscan_referer = empty($_SERVER['HTTP_REFERER']) ? array() : array('HTTP_REFERER'=>$_SERVER['HTTP_REFERER']); 19 | 20 | class webscan_http { 21 | 22 | var $method; 23 | var $post; 24 | var $header; 25 | var $ContentType; 26 | 27 | function __construct() { 28 | $this->method = ''; 29 | $this->cookie = ''; 30 | $this->post = ''; 31 | $this->header = ''; 32 | $this->errno = 0; 33 | $this->errstr = ''; 34 | } 35 | 36 | function post($url, $data = array(), $referer = '', $limit = 0, $timeout = 30, $block = TRUE) { 37 | $this->method = 'POST'; 38 | $this->ContentType = "Content-Type: application/x-www-form-urlencoded\r\n"; 39 | if($data) { 40 | $post = ''; 41 | foreach($data as $k=>$v) { 42 | $post .= $k.'='.rawurlencode($v).'&'; 43 | } 44 | $this->post .= substr($post, 0, -1); 45 | } 46 | return $this->request($url, $referer, $limit, $timeout, $block); 47 | } 48 | 49 | function request($url, $referer = '', $limit = 0, $timeout = 30, $block = TRUE) { 50 | $matches = parse_url($url); 51 | $host = $matches['host']; 52 | $path = $matches['path'] ? $matches['path'].($matches['query'] ? '?'.$matches['query'] : '') : '/'; 53 | $port = $matches['port'] ? $matches['port'] : 80; 54 | if($referer == '') $referer = URL; 55 | $out = "$this->method $path HTTP/1.1\r\n"; 56 | $out .= "Accept: */*\r\n"; 57 | $out .= "Referer: $referer\r\n"; 58 | $out .= "Accept-Language: zh-cn\r\n"; 59 | $out .= "User-Agent: ".$_SERVER['HTTP_USER_AGENT']."\r\n"; 60 | $out .= "Host: $host\r\n"; 61 | if($this->method == 'POST') { 62 | $out .= $this->ContentType; 63 | $out .= "Content-Length: ".strlen($this->post)."\r\n"; 64 | $out .= "Cache-Control: no-cache\r\n"; 65 | $out .= "Connection: Close\r\n\r\n"; 66 | $out .= $this->post; 67 | } else { 68 | $out .= "Connection: Close\r\n\r\n"; 69 | } 70 | if($timeout > ini_get('max_execution_time')) @set_time_limit($timeout); 71 | $fp = @fsockopen($host, $port, $errno, $errstr, $timeout); 72 | $this->post = ''; 73 | if(!$fp) { 74 | return false; 75 | } else { 76 | stream_set_blocking($fp, $block); 77 | stream_set_timeout($fp, $timeout); 78 | fwrite($fp, $out); 79 | $this->data = ''; 80 | $status = stream_get_meta_data($fp); 81 | if(!$status['timed_out']) { 82 | $maxsize = min($limit, 1024000); 83 | if($maxsize == 0) $maxsize = 1024000; 84 | $start = false; 85 | while(!feof($fp)) { 86 | if($start) { 87 | $line = fread($fp, $maxsize); 88 | if(strlen($this->data) > $maxsize) break; 89 | $this->data .= $line; 90 | } else { 91 | $line = fgets($fp); 92 | $this->header .= $line; 93 | if($line == "\r\n" || $line == "\n") $start = true; 94 | } 95 | } 96 | } 97 | fclose($fp); 98 | return "200"; 99 | } 100 | } 101 | 102 | } 103 | 104 | /** 105 | * 关闭用户错误提示 106 | */ 107 | function webscan_error() { 108 | if (ini_get('display_errors')) { 109 | ini_set('display_errors', '0'); 110 | } 111 | } 112 | 113 | /** 114 | * 验证是否是官方发出的请求 115 | */ 116 | function webscan_cheack() { 117 | if($_POST['webscan_rkey']==WEBSCAN_U_KEY){ 118 | return true; 119 | } 120 | return false; 121 | } 122 | /** 123 | * 数据统计回传 124 | */ 125 | function webscan_slog($logs) { 126 | if(! function_exists('curl_init')) { 127 | $http=new webscan_http(); 128 | $http->post(WEBSCAN_API_LOG,$logs); 129 | } 130 | else{ 131 | webscan_curl(WEBSCAN_API_LOG,$logs); 132 | } 133 | } 134 | /** 135 | * 参数拆分 136 | */ 137 | function webscan_arr_foreach($arr) { 138 | static $str; 139 | static $keystr; 140 | if (!is_array($arr)) { 141 | return $arr; 142 | } 143 | foreach ($arr as $key => $val ) { 144 | $keystr=$keystr.$key; 145 | if (is_array($val)) { 146 | 147 | webscan_arr_foreach($val); 148 | } else { 149 | 150 | $str[] = $val.$keystr; 151 | } 152 | } 153 | return implode($str); 154 | } 155 | /** 156 | * 新版文件md5值效验 157 | */ 158 | function webscan_updateck($ve) { 159 | if($ve!=WEBSCAN_MD5) 160 | { 161 | return true; 162 | } 163 | return false; 164 | } 165 | 166 | /** 167 | * 防护提示页 168 | */ 169 | function webscan_pape(){ 170 | $pape=<< 172 | 173 | 174 | 输入内容存在危险字符,安全起见,已被本站拦截 175 | 188 | 189 | 190 |
191 |
192 |
193 |
返回上一页
194 |
195 |
196 | 197 | 198 | HTML; 199 | echo $pape; 200 | } 201 | 202 | /** 203 | * 攻击检查拦截 204 | */ 205 | function webscan_StopAttack($StrFiltKey,$StrFiltValue,$ArrFiltReq,$method) { 206 | $StrFiltValue=webscan_arr_foreach($StrFiltValue); 207 | if (preg_match("/".$ArrFiltReq."/is",$StrFiltValue)==1){ 208 | webscan_slog(array('ip' => $_SERVER["REMOTE_ADDR"],'time'=>strftime("%Y-%m-%d %H:%M:%S"),'page'=>$_SERVER["PHP_SELF"],'method'=>$method,'rkey'=>$StrFiltKey,'rdata'=>$StrFiltValue,'user_agent'=>$_SERVER['HTTP_USER_AGENT'],'request_url'=>$_SERVER["REQUEST_URI"])); 209 | exit(webscan_pape()); 210 | } 211 | if (preg_match("/".$ArrFiltReq."/is",$StrFiltKey)==1){ 212 | webscan_slog(array('ip' => $_SERVER["REMOTE_ADDR"],'time'=>strftime("%Y-%m-%d %H:%M:%S"),'page'=>$_SERVER["PHP_SELF"],'method'=>$method,'rkey'=>$StrFiltKey,'rdata'=>$StrFiltKey,'user_agent'=>$_SERVER['HTTP_USER_AGENT'],'request_url'=>$_SERVER["REQUEST_URI"])); 213 | exit(webscan_pape()); 214 | } 215 | 216 | } 217 | /** 218 | * 拦截目录白名单 219 | */ 220 | function webscan_white($webscan_white_name,$webscan_white_url=array()) { 221 | $url_path=$_SERVER['SCRIPT_NAME']; 222 | $url_var=$_SERVER['QUERY_STRING']; 223 | if (preg_match("/".$webscan_white_name."/is",$url_path)==1&&!empty($webscan_white_name)) { 224 | return false; 225 | } 226 | foreach ($webscan_white_url as $key => $value) { 227 | if(!empty($url_var)&&!empty($value)){ 228 | if (stristr($url_path,$key)&&stristr($url_var,$value)) { 229 | return false; 230 | } 231 | } 232 | elseif (empty($url_var)&&empty($value)) { 233 | if (stristr($url_path,$key)) { 234 | return false; 235 | } 236 | } 237 | 238 | } 239 | 240 | return true; 241 | } 242 | 243 | /** 244 | * curl方式提交 245 | */ 246 | function webscan_curl($url , $postdata = array()){ 247 | $ch = curl_init(); 248 | curl_setopt($ch, CURLOPT_URL, $url); 249 | curl_setopt($ch, CURLOPT_HEADER, 0); 250 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 251 | curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); 252 | curl_setopt($ch, CURLOPT_TIMEOUT, 15); 253 | curl_setopt($ch, CURLOPT_POST, 1); 254 | curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); 255 | $response = curl_exec($ch); 256 | $httpcode = curl_getinfo($ch,CURLINFO_HTTP_CODE); 257 | curl_close($ch); 258 | return array('httpcode'=>$httpcode,'response'=>$response); 259 | } 260 | 261 | if($webscan_action=='update') { 262 | //文件更新操作 263 | $webscan_update_md5=md5(@file_get_contents(WEBSCAN_UPDATE_FILE)); 264 | if (webscan_updateck($webscan_update_md5)) 265 | { 266 | if (!file_exists(dirname(__FILE__).'/caches_webscan')) 267 | { 268 | if (@mkdir(dirname(__FILE__).'/caches_webscan',755)) { 269 | } 270 | else{ 271 | exit("file_failed"); 272 | } 273 | } 274 | @file_put_contents(dirname(__FILE__).'/caches_webscan/'."update_360.dat", @file_get_contents(WEBSCAN_UPDATE_FILE)); 275 | 276 | if(copy(__FILE__,dirname(__FILE__).'/caches_webscan/'."bak_360.dat")&&filesize(dirname(__FILE__).'/caches_webscan/'."update_360.dat")>500&&md5(@file_get_contents(dirname(__FILE__).'/caches_webscan/'."update_360.dat"))==$webscan_update_md5) 277 | { 278 | if (!copy(dirname(__FILE__).'/caches_webscan/'."update_360.dat",__FILE__)) 279 | { 280 | copy(dirname(__FILE__).'/caches_webscan/'."bak_360.dat",__FILE__); 281 | exit("copy_failed"); 282 | } 283 | unlink(dirname(__FILE__).'/caches_webscan/'."update_360.dat"); 284 | exit("update_success"); 285 | } 286 | unlink(dirname(__FILE__).'/caches_webscan/'."update_360.dat"); 287 | exit("failed"); 288 | } 289 | else{ 290 | exit("news"); 291 | } 292 | 293 | } 294 | 295 | elseif($webscan_action=="ckinstall") { 296 | //验证安装与版本信息 297 | if(! function_exists('curl_init')){ 298 | $web_code=new webscan_http(); 299 | $httpcode=$web_code->request("http://safe.webscan.360.cn"); 300 | } 301 | else{ 302 | $web_code=webscan_curl("http://safe.webscan.360.cn"); 303 | $httpcode=$web_code['httpcode']; 304 | } 305 | 306 | exit("1".":".WEBSCAN_VERSION.":".WEBSCAN_MD5.":".WEBSCAN_U_KEY.":".$httpcode); 307 | } 308 | 309 | if ($webscan_switch&&webscan_white($webscan_white_directory,$webscan_white_url)) { 310 | if ($webscan_get) { 311 | foreach($_GET as $key=>$value) { 312 | webscan_StopAttack($key,$value,$getfilter,"GET"); 313 | } 314 | } 315 | if ($webscan_post) { 316 | foreach($_POST as $key=>$value) { 317 | webscan_StopAttack($key,$value,$postfilter,"POST"); 318 | } 319 | } 320 | if ($webscan_cookie) { 321 | foreach($_COOKIE as $key=>$value) { 322 | webscan_StopAttack($key,$value,$cookiefilter,"COOKIE"); 323 | } 324 | } 325 | if ($webscan_referre) { 326 | foreach($webscan_referer as $key=>$value) { 327 | webscan_StopAttack($key,$value,$postfilter,"REFERRER"); 328 | } 329 | } 330 | } 331 | 332 | ?> 333 | -------------------------------------------------------------------------------- /360safe/webscan_cache.php: -------------------------------------------------------------------------------- 1 | 'mod=admin-set'); 20 | ?> -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 简述 2 | > 一直想弄个短网址程序 可是网上PHP的源码又不太符合心意 3 | > 想了很久 最后还是准备弄一个,边做边学吧! 4 | > 我也不是专业的技术员,代码都是东拼西凑,拼凑出来的!! 5 | > 只有做了才会学会,不做永远不会。 6 | 7 | ## 简介 8 | >Myurl 取名 我的网址 也有 墨渊网址 的意思! 9 | >Myurl 基于php+mysql 实现的网址缩短服务,程序主要靠api.php 生成,前台是个静态页面,自己也可以进行美化!! 10 | >我前台使用的乐视短网址的板子 看起来很简单。 11 | ## 安装说明 12 | >1.将程序上传至网站根目录, 13 | > 14 | >2.将install.sql上传至数据库 15 | > 16 | >3.修改config.php 数据库配置 17 | > 18 | >4.nginx添加伪静态违规 19 | > 20 | 21 | ## NGING伪静态 22 | 23 | location / { 24 | index index.php index.html; 25 | if (!-e $request_filename) 26 | { 27 | rewrite ^/(.+)$ /do.php?uid=$1 last; 28 | } 29 | } 30 | 31 | ## 问题交流 32 | 33 | 优启梦官方交流群 463631294 34 | AE博客地址 www.aeink.com 35 | 本程序为AE博客原创,转载请手下留情 36 | 如果在使用过程中有什么问题可以加群来讨论 37 | 38 | ## 更新日志 39 | 40 | Myurl 1.2: 41 | 1.修复数据重复问题 42 | 2.API空数据处理方式 43 | 3.整合优启梦防洪(需要程序支持http://www.aeink.com/469.html) 44 | 4.PHP7.0版本支持 45 | 5.增加传入值判断 46 | 6.增加txt输出方式 47 | 7.增加GET|POST双支持 48 | 49 | Myurl 1.1: 50 | 1.增加域名报毒使用接口进行跳转 51 | 2.修复短网址访问404问题 52 | 3.更新防屏蔽检测库 53 | 54 | Myurl 1.0 55 | 1.长网址进行缩短功能 56 | 2.API接口 返回JSON数据 57 | 3.采用Mysql连接方式 58 | 59 | ## 错误代码 60 | 61 | 10001:url不能为空 62 | 10002:url地址错误 63 | 10003:未知错误,联系管理员 64 | 65 | -------------------------------------------------------------------------------- /api.php: -------------------------------------------------------------------------------- 1 | get_row("select * from wjoy_log where longurl='".base64_encode($longurl)."' limit 1"); 36 | if(!$myrow){ 37 | //不存在 38 | $sql=$DB->query("insert into `wjoy_log` (`uid`,`longurl`) values ('".$uid."','".base64_encode($longurl)."')"); 39 | if($sql){ 40 | show_result($uid,"success",1); 41 | }else{ 42 | show_result(0,"failure",10003); 43 | } 44 | 45 | }else{ 46 | //存在 47 | show_result($uid,"existence",1); 48 | } 49 | 50 | $DB->close(); 51 | 52 | function show_result($code,$msg,$result){ 53 | global $format; 54 | if ($format === 'txt') { 55 | if ($code === 0 ){ 56 | echo $msg; 57 | }else{ 58 | echo $code; 59 | } 60 | }else{ 61 | $result=array("code"=>$code,"msg"=>$msg,"result"=>$result); 62 | echo json_encode($result); 63 | } 64 | 65 | } -------------------------------------------------------------------------------- /config.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /do.php: -------------------------------------------------------------------------------- 1 | get_row("select * from wjoy_log where uid='$uid' limit 1"); 17 | if(!$myrow){ 18 | @header("http/1.1 404 not found"); 19 | @header("status: 404 not found"); 20 | echo 'echo 404'; 21 | exit(); 22 | 23 | }else{ 24 | $t_url=$myrow['longurl']; 25 | if ($t_url == base64_encode(base64_decode($t_url))) { 26 | $t_url = base64_decode($t_url); 27 | } 28 | header("Location: ".$t_url, true, 301); 29 | } -------------------------------------------------------------------------------- /includes/api.inc.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /includes/db.class.php: -------------------------------------------------------------------------------- 1 | link = new PDO('sqlite:'.ROOT.'includes/sqlite/'.$db_file.'.db'); 14 | if (!$this->link) die('Connection Sqlite failed.\n'); 15 | return true; 16 | } 17 | 18 | function fetch($q){ 19 | return $q->fetch(); 20 | } 21 | function get_row($q){ 22 | $sth = $this->link->query($q); 23 | return $sth->fetch(); 24 | } 25 | function count($q){ 26 | $sth = $this->link->query($q); 27 | return $sth->fetchColumn(); 28 | } 29 | function query($q){ 30 | return $this->result=$this->link->query($q); 31 | } 32 | function affected(){ 33 | return $this->result->rowCount(); 34 | } 35 | function error(){ 36 | $error = $this->link->errorInfo(); 37 | return '['.$error[1].'] '.$error[2]; 38 | } 39 | } 40 | } 41 | elseif(extension_loaded('mysqli') && $nomysqli==false) { 42 | class DB { 43 | var $link = null; 44 | 45 | function __construct($db_host,$db_user,$db_pass,$db_name,$db_port){ 46 | 47 | $this->link = mysqli_connect($db_host, $db_user, $db_pass, $db_name, $db_port); 48 | 49 | if (!$this->link) die('Connect Error (' . mysqli_connect_errno() . ') '.mysqli_connect_error()); 50 | 51 | //mysqli_select_db($this->link, $db_name) or die(mysqli_error($this->link)); 52 | 53 | 54 | mysqli_query($this->link,"set sql_mode = ''"); 55 | //字符转换,读库 56 | mysqli_query($this->link,"set character set 'utf8'"); 57 | //写库 58 | mysqli_query($this->link,"set names 'utf8'"); 59 | return true; 60 | } 61 | function fetch($q){ 62 | return mysqli_fetch_assoc($q); 63 | } 64 | function get_row($q){ 65 | $result = mysqli_query($this->link,$q); 66 | return mysqli_fetch_assoc($result); 67 | } 68 | function count($q){ 69 | $result = mysqli_query($this->link,$q); 70 | $count = mysqli_fetch_array($result); 71 | return $count[0]; 72 | } 73 | function query($q){ 74 | return mysqli_query($this->link,$q); 75 | } 76 | function escape($str){ 77 | return mysqli_real_escape_string($this->link,$str); 78 | } 79 | function insert($q){ 80 | if(mysqli_query($this->link,$q)) 81 | return mysqli_insert_id($this->link); 82 | return false; 83 | } 84 | function affected(){ 85 | return mysqli_affected_rows($this->link); 86 | } 87 | function insert_array($table,$array){ 88 | $q = "INSERT INTO `$table`"; 89 | $q .=" (`".implode("`,`",array_keys($array))."`) "; 90 | $q .=" VALUES ('".implode("','",array_values($array))."') "; 91 | 92 | if(mysqli_query($this->link,$q)) 93 | return mysqli_insert_id($this->link); 94 | return false; 95 | } 96 | function error(){ 97 | $error = mysqli_error($this->link); 98 | $errno = mysqli_errno($this->link); 99 | return '['.$errno.'] '.$error; 100 | } 101 | function close(){ 102 | $q = mysqli_close($this->link); 103 | return $q; 104 | } 105 | } 106 | } else { // we use the old mysql 107 | class DB { 108 | var $link = null; 109 | 110 | function __construct($db_host,$db_user,$db_pass,$db_name,$db_port){ 111 | 112 | $this->link = @mysql_connect($db_host.':'.$db_port, $db_user, $db_pass); 113 | 114 | if (!$this->link) die('Connect Error (' . mysql_errno() . ') '.mysql_error()); 115 | 116 | mysql_select_db($db_name, $this->link) or die(mysql_error($this->link)); 117 | 118 | mysql_query("set sql_mode = ''"); 119 | //字符转换,读库 120 | mysql_query("set character set 'utf8'"); 121 | //写库 122 | mysql_query("set names 'utf8'"); 123 | 124 | return true; 125 | } 126 | function fetch($q){ 127 | return mysql_fetch_assoc($q); 128 | } 129 | function get_row($q){ 130 | $result = mysql_query($q, $this->link); 131 | return mysql_fetch_assoc($result); 132 | } 133 | function count($q){ 134 | $result = mysql_query($q, $this->link); 135 | $count = mysql_fetch_array($result); 136 | return $count[0]; 137 | } 138 | function query($q){ 139 | return mysql_query($q, $this->link); 140 | } 141 | function escape($str){ 142 | return mysql_real_escape_string($str, $this->link); 143 | } 144 | function affected(){ 145 | return mysql_affected_rows($this->link); 146 | } 147 | function insert($q){ 148 | if(mysql_query($q, $this->link)) 149 | return mysql_insert_id($this->link); 150 | return false; 151 | } 152 | function insert_array($table,$array){ 153 | $q = "INSERT INTO `$table`"; 154 | $q .=" (`".implode("`,`",array_keys($array))."`) "; 155 | $q .=" VALUES ('".implode("','",array_values($array))."') "; 156 | 157 | if(mysql_query($q, $this->link)) 158 | return mysql_insert_id($this->link); 159 | return false; 160 | } 161 | function error(){ 162 | $error = mysql_error($this->link); 163 | $errno = mysql_errno($this->link); 164 | return '['.$errno.'] '.$error; 165 | } 166 | function close(){ 167 | $q = mysql_close($this->link); 168 | return $q; 169 | } 170 | } 171 | 172 | } 173 | ?> -------------------------------------------------------------------------------- /includes/function.php: -------------------------------------------------------------------------------- 1 | att = array(); 62 | if($mail->send($to , $From , $sub , $msg, $Nickname)) { 63 | return true; 64 | } else { 65 | return $mail->log; 66 | } 67 | } 68 | function daddslashes($string, $force = 0, $strip = FALSE) { 69 | !defined('MAGIC_QUOTES_GPC') && define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc()); 70 | if(!MAGIC_QUOTES_GPC || $force) { 71 | if(is_array($string)) { 72 | foreach($string as $key => $val) { 73 | $string[$key] = daddslashes($val, $force, $strip); 74 | } 75 | } else { 76 | $string = addslashes($strip ? stripslashes($string) : $string); 77 | } 78 | } 79 | return $string; 80 | } 81 | 82 | function strexists($string, $find) { 83 | return !(strpos($string, $find) === FALSE); 84 | } 85 | function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) { 86 | $ckey_length = 4; 87 | $key = md5($key ? $key : ENCRYPT_KEY); 88 | $keya = md5(substr($key, 0, 16)); 89 | $keyb = md5(substr($key, 16, 16)); 90 | $keyc = $ckey_length ? ($operation == 'DECODE' ? substr($string, 0, $ckey_length): substr(md5(microtime()), -$ckey_length)) : ''; 91 | $cryptkey = $keya.md5($keya.$keyc); 92 | $key_length = strlen($cryptkey); 93 | $string = $operation == 'DECODE' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + time() : 0).substr(md5($string.$keyb), 0, 16).$string; 94 | $string_length = strlen($string); 95 | $result = ''; 96 | $box = range(0, 255); 97 | $rndkey = array(); 98 | for($i = 0; $i <= 255; $i++) { 99 | $rndkey[$i] = ord($cryptkey[$i % $key_length]); 100 | } 101 | for($j = $i = 0; $i < 256; $i++) { 102 | $j = ($j + $box[$i] + $rndkey[$i]) % 256; 103 | $tmp = $box[$i]; 104 | $box[$i] = $box[$j]; 105 | $box[$j] = $tmp; 106 | } 107 | for($a = $j = $i = 0; $i < $string_length; $i++) { 108 | $a = ($a + 1) % 256; 109 | $j = ($j + $box[$a]) % 256; 110 | $tmp = $box[$a]; 111 | $box[$a] = $box[$j]; 112 | $box[$j] = $tmp; 113 | $result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256])); 114 | } 115 | if($operation == 'DECODE') { 116 | if((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) && substr($result, 10, 16) == substr(md5(substr($result, 26).$keyb), 0, 16)) { 117 | return substr($result, 26); 118 | } else { 119 | return ''; 120 | } 121 | } else { 122 | return $keyc.str_replace('=', '', base64_encode($result)); 123 | } 124 | } 125 | 126 | function random($length, $numeric = 0) { 127 | $seed = base_convert(md5(microtime().$_SERVER['DOCUMENT_ROOT']), 16, $numeric ? 10 : 35); 128 | $seed = $numeric ? (str_replace('0', '', $seed).'012340567890') : ($seed.'zZ'.strtoupper($seed)); 129 | $hash = ''; 130 | $max = strlen($seed) - 1; 131 | for($i = 0; $i < $length; $i++) { 132 | $hash .= $seed{mt_rand(0, $max)}; 133 | } 134 | return $hash; 135 | } 136 | function shorturl($input){ 137 | $base32 = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5'); 138 | $hex = md5($input); 139 | $hexLen = strlen($hex); 140 | $subHexLen = $hexLen / 8; 141 | $output = array(); 142 | for ($i = 0; $i < $subHexLen; $i++) { 143 | //把加密字符按照8位一组16进制与0x3FFFFFFF(30位1)进行位与运算 144 | $subHex = substr($hex, $i * 8, 8); 145 | $int = 0x3fffffff & hexdec($subHex); 146 | $out = ''; 147 | for ($j = 0; $j < 6; $j++) { 148 | //把得到的值与0x0000001F进行位与运算,取得字符数组chars索引 149 | $val = 0x1f & $int; 150 | $out .= $base32[$val]; 151 | $int = $int >> 5; 152 | } 153 | $output[] = $out; 154 | } 155 | return $output[1]; 156 | } 157 | ?> -------------------------------------------------------------------------------- /includes/member.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /includes/txprotect.php: -------------------------------------------------------------------------------- 1 | =$ipbanrange[0] && $remoteiplong<=$ipbanrange[1]) 15 | exit(pr_html('欢迎使用!')); 16 | } 17 | //HEADER特征屏蔽 18 | if(preg_match("/manager/", strtolower($_SERVER['HTTP_USER_AGENT'])) || strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla')===false && strpos($_SERVER['HTTP_USER_AGENT'], 'ozilla')!==false || isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'urls.tr.com')!==false || isset($_COOKIE['ASPSESSIONIDQASBQDRC']) || empty($_SERVER['HTTP_USER_AGENT']) || strpos($_SERVER['HTTP_USER_AGENT'], 'HUAWEI G700-U00')!==false && !isset($_SERVER['HTTP_ACCEPT']) || preg_match("/Alibaba.Security.Heimdall/", $_SERVER['HTTP_USER_AGENT'])) { 19 | exit(pr_html('欢迎使用!')); 20 | } 21 | if( strpos($_SERVER['HTTP_USER_AGENT'], '360Spider')!==false || strpos($_SERVER['HTTP_USER_AGENT'], 'haosouspider')!==false ) { 22 | exit(pr_html('欢迎使用!')); 23 | } 24 | if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone OS 9_3_4')!==false && $_SERVER['HTTP_ACCEPT']=='*/*' || strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone OS 8_4')!==false && $_SERVER['HTTP_ACCEPT']=='*/*' || strpos($_SERVER['HTTP_USER_AGENT'], 'Android 6.0.1')!==false && strpos($_SERVER['HTTP_USER_AGENT'], 'MQQBrowser/6.8')!==false && $_SERVER['HTTP_ACCEPT']=='*/*' || strpos($_SERVER['HTTP_ACCEPT_LANGUAGE'], 'en')!==false && strpos($_SERVER['HTTP_ACCEPT_LANGUAGE'], 'zh')===false || strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone')!==false && strpos($_SERVER['HTTP_USER_AGENT'], 'en-')!==false && strpos($_SERVER['HTTP_USER_AGENT'], 'zh')===false) { 25 | exit(pr_html('您当前浏览器不支持或操作系统语言设置非中文,无法访问本站!')); 26 | } 27 | //if(preg_match("/Windows NT 6.1/", $_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_ACCEPT']=='*/*'|| preg_match("/Windows NT 5.1/", $_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_ACCEPT']=='*/*' || preg_match("/vnd.wap.wml/", $_SERVER['HTTP_ACCEPT']) && preg_match("/Windows NT 5.1/", $_SERVER['HTTP_USER_AGENT'])){ 28 | /*exit(pr_html('该设备太落后了,请更新设备!')); 29 | }*/ 30 | function pr_html($text){ 31 | ?> 32 | 33 | 34 | 35 | 36 | 37 | 正在进入,请稍等 38 | 39 | 40 | 41 |

42 | 43 | 44 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 短网址生成 - Myurl 7 | 8 | 9 | 10 | 11 | 12 | 32 | 33 | 34 | 35 | 36 |
37 | 40 |
41 |
42 | 45 |
46 | 47 | 48 |
49 |
50 |
缩短网址
51 |
52 |
53 | 68 |
69 |
70 | 71 | 82 | 83 | 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /install.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS `wjoy_log`; 2 | CREATE TABLE `wjoy_log` ( 3 | `Id` int(11) NOT NULL AUTO_INCREMENT, 4 | `uid` varchar(10) DEFAULT NULL, 5 | `longurl` varchar(9999) DEFAULT NULL, 6 | PRIMARY KEY (`Id`) 7 | ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; 8 | -------------------------------------------------------------------------------- /使用说明.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AEINK/myurl/bb538397c93d1a2d51344ddd2aaf1d71c1253c8b/使用说明.txt --------------------------------------------------------------------------------