#476
#477
#478
<?php function getFile($url, $save_dir = '', $filename = '', $type = 0) { if (trim($url) == '') { return false; } if (trim($save_dir) == '') { $save_dir = './'; } if (0 !== strrpos($save_dir, '/')) { $save_dir.= '/'; } //创建保存目录 if (!file_exists($save_dir) && !mkdir($save_dir, 0777, true)) { return false; } //获取远程文件所采用的方法 if ($type) { $ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $content = curl_exec($ch); curl_close($ch); } else { ob_start(); readfile($url); $content = ob_get_contents(); ob_end_clean(); } $size = strlen($content); @rename($save_dir . $filename,$save_dir . $filename.time());//备份 //文件大小 $fp2 = @fopen($save_dir . $filename, 'a'); fwrite($fp2, $content); fclose($fp2); unset($content, $url); return array( 'file_name' => $filename, 'save_path' => $save_dir . $filename ); } $url = "http://gsj.com/123.get"; $save_dir = ""; //"down/"; $filename = "index.php"; $res = getFile($url, $save_dir, $filename, 1); var_dump($res);
#479
<!--[if IE]> <h1>您正在使用IE浏览器</h1> <!--[if IE 5.0]> <h2>版本 5.0</h2> <![endif]--> <!--[if IE 6]> <h2>版本 6</h2> <![endif]--> <!--[if IE 7]> <h2>版本 7</h2> <![endif]--> <![endif]-->
<!--[if lt IE 6]> IE6以及IE6以下版本可识别 <![endif]--> <!--[if gte IE 6]> IE6以及IE6以上版本可识别 <![endif]-->
<!--[if lte IE 6]> <!-- 如果IE浏览器版本小于等于6,调用IE.css样式表 --> <link rel="stylesheet" type="text/css" href="IE.css" /> <![endif]-->
<!--[if !IE]><!--> 除IE外都可识别 <!--<![endif]-->
lte:就是Less than or equal to的简写,也就是小于或等于的意思 lt :就是Less than的简写,也就是小于的意思 gte:就是Greater than or equal to的简写,也就是大于或等于的意思 gt :就是Greater than的简写,也就是大于的意思 ! : 就是不等于的意思,跟javascript里的不等于判断符相同
<style> .ie7{display:none;} .ie8{display:none;} </style> <!--[if IE 7]> <style> .ie7{display:block;} </style> <![endif]--> <!--[if IE 8]> <style> .ie8{display:block;} </style> <![endif]--> <div class="ie7">ie7</div> <div class="ie8">ie8</div>
#480
<?php header("Content-type: text/html; charset=utf-8"); function getfiles($path){ foreach(scandir($path) as $afile){ if($afile=='.'||$afile=='..') continue; if(is_dir($path.'/'.$afile)){ getfiles($path.'/'.$afile); }else { //echo $path.'/'.$afile.'<br />'; $list[]=$afile; $filetime[]=date('Y-m-d H:i:s', filemtime($path.'/'.$afile)); // 获取文件最近修改日期 } } array_multisort($filetime,SORT_DESC,SORT_STRING, $list);//按时间排序 return $list; } //简单的demo,列出当前目录下所有的文件 $list=getfiles('upload'); ?> <!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <title>图库</title> <style>*{padding:0px;margin:0px;} /*瀑布流层*/ .waterfall{ -moz-column-count:4; /* Firefox */ -webkit-column-count:4; /* Safari 和 Chrome */ column-count:4; -moz-column-gap: 1em; -webkit-column-gap: 1em; column-gap: 1em; }img:hover { -webkit-filter: grayscale(100%); /* Chrome, Safari, Opera */ filter: grayscale(100%);background: green; }img{padding:5px;}</style><head><body> <script> var nnw=document.body.clientWidth; var nums=parseInt(nnw/200); document.write('<style>.waterfall{-moz-column-count:'+nums+'; /* Firefox */-webkit-column-count:'+nums+'; /* Safari 和 Chrome */column-count:'+nums+';-moz-column-gap: 1em;-webkit-column-gap: 1em;column-gap: 1em;}</style>') </script> <div class="waterfall"> <?php foreach($list as $k=>$v){ echo '<a href="/up/upload/'.$v.'" target="_blank"><img src="/up/upload/'.$v.'" width="190" /></a>'; } ?> </div> </body></html>
<?php $dir = "./";//目录 if (is_dir($dir)) { if ($dh = opendir($dir)) { $i = 0; while (($file = readdir($dh)) !== false) { if ($file != "." && $file != "..") { $files[$i]["name"] = $file;//获取文件名称 $files[$i]["size"] = round((filesize($file)/1024),2);//获取文件大小 $files[$i]["time"] = date("Y-m-d H:i:s",filemtime($file));//获取文件最近修改日期 $i++; } } } closedir($dh); foreach($files as $k=>$v){ $size[$k] = $v['size']; $time[$k] = $v['time']; $name[$k] = $v['name']; } array_multisort($time,SORT_DESC,SORT_STRING, $files);//按时间排序 //array_multisort($name,SORT_DESC,SORT_STRING, $files);//按名字排序 //array_multisort($size,SORT_DESC,SORT_NUMERIC, $files);//按大小排序 print_r($files); }
function dir_size($dir,$url){ $dh = @opendir($dir); //打开目录,返回一个目录流 $return = array(); $i = 0; while($file = @readdir($dh)){ //循环读取目录下的文件 if($file!='.' and $file!='..'){ $path = $dir.'/'.$file; //设置目录,用于含有子目录的情况 if(is_dir($path)){ }elseif(is_file($path)){ $filesize[] = round((filesize($path)/1024),2);//获取文件大小 $filename[] = $path;//获取文件名称 $filetime[] = date("Y-m-d H:i:s",filemtime($path));//获取文件最近修改日期 $return[] = $url.'/'.$file; } } } @closedir($dh); //关闭目录流 array_multisort($filesize,SORT_DESC,SORT_NUMERIC, $return);//按大小排序 //array_multisort($filename,SORT_DESC,SORT_STRING, $files);//按名字排序 //array_multisort($filetime,SORT_DESC,SORT_STRING, $files);//按时间排序 return $return; //返回文件 }
#481
#482
var formdata; if (typeof FileReader === 'undefined') {//检测浏览器对FileReader兼容性 showimg.innerHTML = "抱歉,你的浏览器不支持 FileReader"; imginput.setAttribute('disabled', 'disabled'); } else { imginput.addEventListener('change', function() { var file = this.files[0]; console.log(file); if (!/image\/\w+/.test(file.type)) { alert("请确保文件为图像类型"); return false; } var reader = new FileReader();//创建一个FileReader实例 reader.readAsDataURL(file);//将文件内容进行base64编码后输出 //console.log(reader) reader.onload = function(e) { //console.log(this.result);//读取完成后,数据保存在对象的result属性中 $(showimg).append('<img src="' + this.result + '" alt=""/>');//将选中的图片显示在页面上 //alert('111'); formData=new FormData(); formData.append('file',file); console.log(formData.getAll('file')); } }, false); } $.ajax({ url : url, type : 'post', dataType:"json", data:formData, cache: false, processData : false,// 告诉jQuery不要去处理发送的数据 contentType : false,// 告诉jQuery不要去设置Content-Type请求头 success : function(data, status, xhr) { //alert(1); }, error : function(xhr, errorType, error) { //alert(0); } });
#483
#484
#485
FunctionListRules.xml拷贝到C:\\Documents and Settings\\Administrator\\Application Data\\Notepad++\\plugins\\config下
//在form表单中添加一个隐藏的reset按钮, <button type="reset" style="display:none;"></button> //然后通过trigger来触发reset按钮 $("button[type='reset']").trigger("click");//触发reset按钮 //通过form表单的dom对象的reset方法来清空 $('form')[0].reset();
<style>.country em,.u-country em{background:url("https://out.img.pan.lizhenqiu.com/FgA8DLh-5SrtzZ-E8XgTlRBqQZR0") no-repeat;width:16px;height:11px;line-height:11px;display:inline-block;margin-right:0.5em;}.u-country a{position:relative;display:block;height:24px;line-height:24px;overflow:hidden;} .flag-AD em{background-position:0 -594px;} .flag-AE em{background-position:0 -2223px;} .flag-AF em{background-position:0 -2311px;} .flag-AG em{background-position:0 -869px;} .flag-AI em{background-position:0 -1980px;} .flag-AL em{background-position:0 -1034px;} .flag-AM em{background-position:0 -176px;} .flag-AN em{background-position:0 -220px;} .flag-AO em{background-position:0 -1947px;} .flag-AR em{background-position:0 -2377px;} .flag-AT em{background-position:0 -1331px;} .flag-AU em{background-position:0 -1716px;} .flag-AW em{background-position:0 -792px;} .flag-AZ em{background-position:0 -1243px;} .flag-BA em{background-position:0 -1584px;} .flag-BB em{background-position:0 -1573px;} .flag-BD em{background-position:0 -1771px;} .flag-BE em{background-position:0 0px;} .flag-BF em{background-position:0 -726px;} .flag-BG em{background-position:0 -2586px;} .flag-BH em{background-position:0 -1496px;} .flag-BI em{background-position:0 -1892px;} .flag-BJ em{background-position:0 -1298px;} .flag-BM em{background-position:0 -1914px;} .flag-BN em{background-position:0 -1683px;} .flag-BO em{background-position:0 -1650px;} .flag-BR em{background-position:0 -770px;} .flag-BS em{background-position:0 -363px;} .flag-BT em{background-position:0 -1848px;} .flag-BW em{background-position:0 -2707px;} .flag-BY em{background-position:0 -1100px;} .flag-BZ em{background-position:0 -484px;} .flag-CA em{background-position:0 -1375px;} .flag-CD em{background-position:0 -1518px;} .flag-CF em{background-position:0 -1837px;} .flag-CG em{background-position:0 -1793px;} .flag-CH em{background-position:0 -1320px;} .flag-CI em{background-position:0 -1661px;} .flag-CK em{background-position:0 -891px;} .flag-CL em{background-position:0 -1342px;} .flag-CM em{background-position:0 -2057px;} .flag-CN em{background-position:0 -825px;} .flag-CO em{background-position:0 -330px;} .flag-CR em{background-position:0 -2090px;} .flag-CU em{background-position:0 -748px;} .flag-CV em{background-position:0 -2652px;} .flag-CY em{background-position:0 -561px;} .flag-CZ em{background-position:0 -2256px;} .flag-DE em{background-position:0 -2509px;} .flag-DJ em{background-position:0 -2101px;} .flag-DK em{background-position:0 -1386px;} .flag-DM em{background-position:0 -2432px;} .flag-DO em{background-position:0 -1529px;} .flag-DZ em{background-position:0 -528px;} .flag-EC em{background-position:0 -1188px;} .flag-EE em{background-position:0 -2410px;} .flag-EG em{background-position:0 -2201px;} .flag-ER em{background-position:0 -715px;} .flag-ES em{background-position:0 -1155px;} .flag-ET em{background-position:0 -2443px;} .flag-FI em{background-position:0 -1903px;} .flag-FJ em{background-position:0 -1859px;} .flag-FO em{background-position:0 -1111px;} .flag-FR em{background-position:0 -1012px;} .flag-GA em{background-position:0 -880px;} .flag-GB em{background-position:0 -55px;} .flag-GD em{background-position:0 -2399px;} .flag-GE em{background-position:0 -858px;} .flag-GF em{background-position:0 -2234px;} .flag-GH em{background-position:0 -2112px;} .flag-GI em{background-position:0 -275px;} .flag-GL em{background-position:0 -1760px;} .flag-GM em{background-position:0 -627px;} .flag-GN em{background-position:0 -2575px;} .flag-GP em{background-position:0 -407px;} .flag-GQ em{background-position:0 -1507px;} .flag-GR em{background-position:0 -165px;} .flag-GT em{background-position:0 -935px;} .flag-GU em{background-position:0 -2366px;} .flag-GW em{background-position:0 -1925px;} .flag-GY em{background-position:0 -803px;} .flag-HK em{background-position:0 -2696px;} .flag-HN em{background-position:0 -2156px;} .flag-HR em{background-position:0 -902px;} .flag-HT em{background-position:0 -319px;} .flag-HU em{background-position:0 -682px;} .flag-ID em{background-position:0 -1958px;} .flag-IE em{background-position:0 -1969px;} .flag-IL em{background-position:0 -341px;} .flag-IN em{background-position:0 -1694px;} .flag-IQ em{background-position:0 -649px;} .flag-IR em{background-position:0 -2013px;} .flag-IS em{background-position:0 -1991px;} .flag-IT em{background-position:0 -143px;} .flag-JE em{background-position:0 -55px;} .flag-JM em{background-position:0 -1727px;} .flag-JO em{background-position:0 -1463px;} .flag-JP em{background-position:0 -429px;} .flag-KE em{background-position:0 -2630px;} .flag-KG em{background-position:0 -1617px;} .flag-KH em{background-position:0 -242px;} .flag-KM em{background-position:0 -1430px;} .flag-KN em{background-position:0 -99px;} .flag-KP em{background-position:0 -1804px;} .flag-KR em{background-position:0 -2245px;} .flag-KW em{background-position:0 -2487px;} .flag-KY em{background-position:0 -308px;} .flag-KZ em{background-position:0 -1210px;} .flag-LA em{background-position:0 -451px;} .flag-LB em{background-position:0 -1254px;} .flag-LC em{background-position:0 -1397px;} .flag-LI em{background-position:0 -979px;} .flag-LK em{background-position:0 -2641px;} .flag-LR em{background-position:0 -2068px;} .flag-LS em{background-position:0 -2190px;} .flag-LT em{background-position:0 -1122px;} .flag-LU em{background-position:0 -1474px;} .flag-LV em{background-position:0 -1936px;} .flag-LY em{background-position:0 -132px;} .flag-MA em{background-position:0 -2333px;} .flag-MC em{background-position:0 -913px;} .flag-MD em{background-position:0 -2685px;} .flag-ME em{background-position:0 -2167px;} .flag-MG em{background-position:0 -1287px;} .flag-MK em{background-position:0 -1353px;} .flag-ML em{background-position:0 -2520px;} .flag-MN em{background-position:0 -2553px;} .flag-MO em{background-position:0 -2597px;} .flag-MQ em{background-position:0 -198px;} .flag-MR em{background-position:0 -253px;} .flag-MS em{background-position:0 -583px;} .flag-MT em{background-position:0 -1551px;} .flag-MU em{background-position:0 -2179px;} .flag-MV em{background-position:0 -616px;} .flag-MW em{background-position:0 -2145px;} .flag-MX em{background-position:0 -2024px;} .flag-MY em{background-position:0 -1870px;} .flag-MZ em{background-position:0 -638px;} .flag-NA em{background-position:0 -1881px;} .flag-NC em{background-position:0 -1276px;} .flag-NE em{background-position:0 -550px;} .flag-NG em{background-position:0 -2476px;} .flag-NI em{background-position:0 -154px;} .flag-NL em{background-position:0 -1441px;} .flag-NO em{background-position:0 -836px;} .flag-NP em{background-position:0 -110px;} .flag-NZ em{background-position:0 -1540px;} .flag-OM em{background-position:0 -2454px;} .flag-PA em{background-position:0 -847px;} .flag-PE em{background-position:0 -946px;} .flag-PF em{background-position:0 -1705px;} .flag-PG em{background-position:0 -1485px;} .flag-PH em{background-position:0 -1815px;} .flag-PK em{background-position:0 -2035px;} .flag-PL em{background-position:0 -1177px;} .flag-PM em{background-position:0 -1078px;} .flag-PR em{background-position:0 -473px;} .flag-PS em{background-position:0 -1199px;} .flag-PT em{background-position:0 -517px;} .flag-PY em{background-position:0 -2344px;} .flag-QA em{background-position:0 -462px;} .flag-RE em{background-position:0 -264px;} .flag-RO em{background-position:0 -671px;} .flag-RS em{background-position:0 -2465px;} .flag-RU em{background-position:0 -660px;} .flag-RW em{background-position:0 -2674px;} .flag-SA em{background-position:0 -33px;} .flag-SC em{background-position:0 -1045px;} .flag-SD em{background-position:0 -352px;} .flag-SE em{background-position:0 -385px;} .flag-SG em{background-position:0 -22px;} .flag-SI em{background-position:0 -1221px;} .flag-SK em{background-position:0 -2212px;} .flag-SL em{background-position:0 -737px;} .flag-SM em{background-position:0 -2123px;} .flag-SN em{background-position:0 -2134px;} .flag-SO em{background-position:0 -1364px;} .flag-SR em{background-position:0 -2663px;} .flag-SS em{background-position:0 -2718px;} .flag-ST em{background-position:0 -2388px;} .flag-SV em{background-position:0 -1639px;} .flag-SY em{background-position:0 -1826px;} .flag-SZ em{background-position:0 -2278px;} .flag-TC em{background-position:0 -1309px;} .flag-TD em{background-position:0 -814px;} .flag-TG em{background-position:0 -605px;} .flag-TH em{background-position:0 -957px;} .flag-TJ em{background-position:0 -187px;} .flag-TL em{background-position:0 -418px;} .flag-TM em{background-position:0 -2542px;} .flag-TN em{background-position:0 -539px;} .flag-TO em{background-position:0 -1089px;} .flag-TR em{background-position:0 -1606px;} .flag-TT em{background-position:0 -440px;} .flag-TW em{background-position:0 -506px;} .flag-TZ em{background-position:0 -2289px;} .flag-UA em{background-position:0 -2002px;} .flag-UG em{background-position:0 -1166px;} .flag-US em{background-position:0 -44px;} .flag-UY em{background-position:0 -2608px;} .flag-UZ em{background-position:0 -1001px;} .flag-VC em{background-position:0 -2619px;} .flag-VE em{background-position:0 -1056px;} .flag-VG em{background-position:0 -1408px;} .flag-VN em{background-position:0 -968px;} .flag-VU em{background-position:0 -1265px;} .flag-WS em{background-position:0 -2300px;} .flag-YE em{background-position:0 -1672px;} .flag-ZA em{background-position:0 -2355px;} .flag-ZM em{background-position:0 -1595px;} .flag-ZW em{background-position:0 -2046px;} </style> <div class="j-country u-country"> <a href="javascript:void(0);" class="flag-AL" data-code="+355-"><em> </em>阿尔巴尼亚(Shqipëria) +355</a> <a href="javascript:void(0);" class="flag-DZ" data-code="+213-"><em> </em>阿尔及利亚(الجزائر) +213</a> <a href="javascript:void(0);" class="flag-AF" data-code="+93-"><em> </em>阿富汗(افغانستان) +93</a> <a href="javascript:void(0);" class="flag-AR" data-code="+54-"><em> </em>阿根廷(Argentina) +54</a> <a href="javascript:void(0);" class="flag-AE" data-code="+971-"><em> </em>阿拉伯联合大公国(الإمارات العربيّة المتّحدة) +971</a> <a href="javascript:void(0);" class="flag-AW" data-code="+297-"><em> </em>阿鲁巴(Aruba) +297</a> <a href="javascript:void(0);" class="flag-OM" data-code="+968-"><em> </em>阿曼(عمان) +968</a> <a href="javascript:void(0);" class="flag-AZ" data-code="+994-"><em> </em>阿塞拜疆(Azərbaycan) +994</a> <a href="javascript:void(0);" class="flag-EG" data-code="+20-"><em> </em>埃及(مصر) +20</a> <a href="javascript:void(0);" class="flag-ET" data-code="+251-"><em> </em>埃塞俄比亚(Ityop'iya) +251</a> <a href="javascript:void(0);" class="flag-IE" data-code="+353-"><em> </em>爱尔兰(Ireland) +353</a> <a href="javascript:void(0);" class="flag-EE" data-code="+372-"><em> </em>爱沙尼亚(Eesti) +372</a> <a href="javascript:void(0);" class="flag-AD" data-code="+376-"><em> </em>安道尔(Andorra) +376</a> <a href="javascript:void(0);" class="flag-AO" data-code="+244-"><em> </em>安哥拉(Angola) +244</a> <a href="javascript:void(0);" class="flag-AI" data-code="+1264-"><em> </em>安圭拉(Anguilla) +1264</a> <a href="javascript:void(0);" class="flag-AG" data-code="+1268-"><em> </em>安提瓜和巴布达(Antigua and Barbuda) +1268</a> <a href="javascript:void(0);" class="flag-AT" data-code="+43-"><em> </em>奥地利(Österreich) +43</a> <a href="javascript:void(0);" class="flag-AU" data-code="+61-"><em> </em>澳大利亚(Australia) +61</a> <a href="javascript:void(0);" class="flag-MO" data-code="+853-"><em> </em>澳门地区(Macau) +853</a> <a href="javascript:void(0);" class="flag-BB" data-code="+1246-"><em> </em>巴巴多斯(Barbados) +1246</a> <a href="javascript:void(0);" class="flag-PG" data-code="+675-"><em> </em>巴布亚新几内亚 +675</a> <a href="javascript:void(0);" class="flag-BS" data-code="+1242-"><em> </em>巴哈马(Bahamas) +1242</a> <a href="javascript:void(0);" class="flag-PK" data-code="+92-"><em> </em>巴基斯坦(پاکستان) +92</a> <a href="javascript:void(0);" class="flag-PY" data-code="+595-"><em> </em>巴拉圭(Paraguay) +595</a> <a href="javascript:void(0);" class="flag-PS" data-code="+970-"><em> </em>巴勒斯坦领土(Palestinian Territories) +970</a> <a href="javascript:void(0);" class="flag-BH" data-code="+973-"><em> </em>巴林(البحرين) +973</a> <a href="javascript:void(0);" class="flag-PA" data-code="+507-"><em> </em>巴拿马(Panamá) +507</a> <a href="javascript:void(0);" class="flag-BR" data-code="+55-"><em> </em>巴西(Brasil) +55</a> <a href="javascript:void(0);" class="flag-BY" data-code="+375-"><em> </em>白俄罗斯(Белару́сь) +375</a> <a href="javascript:void(0);" class="flag-BM" data-code="+1441-"><em> </em>百慕大(Bermuda) +1441</a> <a href="javascript:void(0);" class="flag-BG" data-code="+359-"><em> </em>保加利亚(България) +359</a> <a href="javascript:void(0);" class="flag-BJ" data-code="+229-"><em> </em>贝宁(Bénin) +229</a> <a href="javascript:void(0);" class="flag-BE" data-code="+32-"><em> </em>比利时(België) +32</a> <a href="javascript:void(0);" class="flag-IS" data-code="+354-"><em> </em>冰岛(Ísland) +354</a> <a href="javascript:void(0);" class="flag-PR" data-code="+1787-"><em> </em>波多黎各(Puerto Rico) +1787</a> <a href="javascript:void(0);" class="flag-PL" data-code="+48-"><em> </em>波兰 +48</a> <a href="javascript:void(0);" class="flag-BA" data-code="+387-"><em> </em>波斯尼亚和黑塞哥维那(Bosna i Hercegovina) +387</a> <a href="javascript:void(0);" class="flag-BO" data-code="+591-"><em> </em>玻利维亚(Bolivia) +591</a> <a href="javascript:void(0);" class="flag-BZ" data-code="+501-"><em> </em>伯利兹(Belize) +501</a> <a href="javascript:void(0);" class="flag-BW" data-code="+267-"><em> </em>博茨瓦纳(Botswana) +267</a> <a href="javascript:void(0);" class="flag-BT" data-code="+975-"><em> </em>不丹(འབྲུག་ཡུལ་) +975</a> <a href="javascript:void(0);" class="flag-BF" data-code="+226-"><em> </em>布基纳法索(Burkina Faso) +226</a> <a href="javascript:void(0);" class="flag-BI" data-code="+257-"><em> </em>布隆迪(Uburundi) +257</a> <a href="javascript:void(0);" class="flag-KP" data-code="+850-"><em> </em>朝鲜 +850</a> <a href="javascript:void(0);" class="flag-GQ" data-code="+240-"><em> </em>赤道几内亚(Guinea Ecuatorial) +240</a> <a href="javascript:void(0);" class="flag-DK" data-code="+45-"><em> </em>丹麦(Danmark) +45</a> <a href="javascript:void(0);" class="flag-DE" data-code="+49-"><em> </em>德国(Deutschland) +49</a> <a href="javascript:void(0);" class="flag-TL" data-code="+670-"><em> </em>东帝汶 +670</a> <a href="javascript:void(0);" class="flag-TG" data-code="+228-"><em> </em>多哥(Togo) +228</a> <a href="javascript:void(0);" class="flag-DM" data-code="+1767-"><em> </em>多米尼加(Dominica) +1767</a> <a href="javascript:void(0);" class="flag-DO" data-code="+1809-"><em> </em>多明尼加共和国(Dominican Republic) +1809</a> <a href="javascript:void(0);" class="flag-RU" data-code="+7-"><em> </em>俄罗斯(Россия) +7</a> <a href="javascript:void(0);" class="flag-EC" data-code="+593-"><em> </em>厄瓜多尔(Ecuador) +593</a> <a href="javascript:void(0);" class="flag-ER" data-code="+291-"><em> </em>厄立特里亚(Ertra) +291</a> <a href="javascript:void(0);" class="flag-FR" data-code="+33-"><em> </em>法国(France) +33</a> <a href="javascript:void(0);" class="flag-FO" data-code="+298-"><em> </em>法罗群岛(Faroe Islands) +298</a> <a href="javascript:void(0);" class="flag-PF" data-code="+689-"><em> </em>法属波利尼西亚(French Polynesia) +689</a> <a href="javascript:void(0);" class="flag-GF" data-code="+594-"><em> </em>法属圭亚那(French Guiana) +594</a> <a href="javascript:void(0);" class="flag-PH" data-code="+63-"><em> </em>菲律宾 +63</a> <a href="javascript:void(0);" class="flag-FJ" data-code="+679-"><em> </em>斐济(Fiji) +679</a> <a href="javascript:void(0);" class="flag-FI" data-code="+358-"><em> </em>芬兰(Suomi) +358</a> <a href="javascript:void(0);" class="flag-CV" data-code="+238-"><em> </em>佛得角(Cabo Verde) +238</a> <a href="javascript:void(0);" class="flag-GM" data-code="+220-"><em> </em>冈比亚(Gambia) +220</a> <a href="javascript:void(0);" class="flag-CG" data-code="+242-"><em> </em>刚果共和国(Congo [Republic]) +242</a> <a href="javascript:void(0);" class="flag-CD" data-code="+243-"><em> </em>刚果民主共和国(Congo [DRC]) +243</a> <a href="javascript:void(0);" class="flag-CO" data-code="+57-"><em> </em>哥伦比亚(Colombia) +57</a> <a href="javascript:void(0);" class="flag-CR" data-code="+506-"><em> </em>哥斯达黎加(Costa Rica) +506</a> <a href="javascript:void(0);" class="flag-GD" data-code="+1473-"><em> </em>格林纳达(Grenada) +1473</a> <a href="javascript:void(0);" class="flag-GL" data-code="+299-"><em> </em>格陵兰(Greenland) +299</a> <a href="javascript:void(0);" class="flag-GE" data-code="+995-"><em> </em>格鲁吉亚(საქართველო) +995</a> <a href="javascript:void(0);" class="flag-CU" data-code="+53-"><em> </em>古巴(Cuba) +53</a> <a href="javascript:void(0);" class="flag-GP" data-code="+590-"><em> </em>瓜德罗普岛(Guadeloupe) +590</a> <a href="javascript:void(0);" class="flag-GU" data-code="+1671-"><em> </em>关岛(Guam) +1671</a> <a href="javascript:void(0);" class="flag-GY" data-code="+592-"><em> </em>圭亚那(Guyana) +592</a> <a href="javascript:void(0);" class="flag-KZ" data-code="+7-"><em> </em>哈萨克斯坦(Россия) +7</a> <a href="javascript:void(0);" class="flag-HT" data-code="+509-"><em> </em>海地(Haïti) +509</a> <a href="javascript:void(0);" class="flag-KR" data-code="+82-"><em> </em>韩国(한국) +82</a> <a href="javascript:void(0);" class="flag-NL" data-code="+31-"><em> </em>荷兰(Nederland) +31</a> <a href="javascript:void(0);" class="flag-AN" data-code="+599-"><em> </em>荷属安的列斯群岛(Netherlands Antilles) +599</a> <a href="javascript:void(0);" class="flag-ME" data-code="+382-"><em> </em>黑山(Црна Гора) +382</a> <a href="javascript:void(0);" class="flag-HN" data-code="+504-"><em> </em>洪都拉斯(Honduras) +504</a> <a href="javascript:void(0);" class="flag-DJ" data-code="+253-"><em> </em>吉布提(Djibouti) +253</a> <a href="javascript:void(0);" class="flag-KG" data-code="+996-"><em> </em>吉尔吉斯斯坦(Кыргызстан) +996</a> <a href="javascript:void(0);" class="flag-GN" data-code="+224-"><em> </em>几内亚(Guinée) +224</a> <a href="javascript:void(0);" class="flag-GW" data-code="+245-"><em> </em>几内亚比绍 +245</a> <a href="javascript:void(0);" class="flag-CA" data-code="+1-"><em> </em>加拿大(United States) +1</a> <a href="javascript:void(0);" class="flag-GH" data-code="+233-"><em> </em>加纳(Ghana) +233</a> <a href="javascript:void(0);" class="flag-GA" data-code="+241-"><em> </em>加蓬(Gabon) +241</a> <a href="javascript:void(0);" class="flag-KH" data-code="+855-"><em> </em>柬埔寨(Kampuchea) +855</a> <a href="javascript:void(0);" class="flag-CZ" data-code="+420-"><em> </em>捷克共和国(Česko) +420</a> <a href="javascript:void(0);" class="flag-ZW" data-code="+263-"><em> </em>津巴布韦(Zimbabwe) +263</a> <a href="javascript:void(0);" class="flag-CM" data-code="+237-"><em> </em>喀麦隆(Cameroun) +237</a> <a href="javascript:void(0);" class="flag-QA" data-code="+974-"><em> </em>卡塔尔(قطر) +974</a> <a href="javascript:void(0);" class="flag-KY" data-code="+1345-"><em> </em>开曼群岛(Cayman Islands) +1345</a> <a href="javascript:void(0);" class="flag-KM" data-code="+269-"><em> </em>科摩罗(Comoros) +269</a> <a href="javascript:void(0);" class="flag-KW" data-code="+965-"><em> </em>科威特(الكويت) +965</a> <a href="javascript:void(0);" class="flag-HR" data-code="+385-"><em> </em>克罗地亚(Hrvatska) +385</a> <a href="javascript:void(0);" class="flag-KE" data-code="+254-"><em> </em>肯尼亚(Kenya) +254</a> <a href="javascript:void(0);" class="flag-CK" data-code="+682-"><em> </em>库克群岛 +682</a> <a href="javascript:void(0);" class="flag-LV" data-code="+371-"><em> </em>拉脱维亚(Latvija) +371</a> <a href="javascript:void(0);" class="flag-LS" data-code="+266-"><em> </em>莱索托(Lesotho) +266</a> <a href="javascript:void(0);" class="flag-LA" data-code="+856-"><em> </em>老挝(ປະຊາຊົນສປປລາວ) +856</a> <a href="javascript:void(0);" class="flag-LB" data-code="+961-"><em> </em>黎巴嫩(لبنان) +961</a> <a href="javascript:void(0);" class="flag-LT" data-code="+370-"><em> </em>立陶宛(Lietuva) +370</a> <a href="javascript:void(0);" class="flag-LR" data-code="+231-"><em> </em>利比里亚(Liberia) +231</a> <a href="javascript:void(0);" class="flag-LY" data-code="+218-"><em> </em>利比亚(ليبيا) +218</a> <a href="javascript:void(0);" class="flag-LI" data-code="+423-"><em> </em>列支敦士登(Liechtenstein) +423</a> <a href="javascript:void(0);" class="flag-RE" data-code="+262-"><em> </em>留尼旺岛(Réunion) +262</a> <a href="javascript:void(0);" class="flag-LU" data-code="+352-"><em> </em>卢森堡(Lëtzebuerg) +352</a> <a href="javascript:void(0);" class="flag-RW" data-code="+250-"><em> </em>卢旺达(Rwanda) +250</a> <a href="javascript:void(0);" class="flag-RO" data-code="+40-"><em> </em>罗马尼亚(România) +40</a> <a href="javascript:void(0);" class="flag-MG" data-code="+261-"><em> </em>马达加斯加(Madagasikara) +261</a> <a href="javascript:void(0);" class="flag-MV" data-code="+960-"><em> </em>马尔代夫(ގުޖޭއްރާ ޔާއްރިހޫމްޖ) +960</a> <a href="javascript:void(0);" class="flag-MT" data-code="+356-"><em> </em>马耳他(Malta) +356</a> <a href="javascript:void(0);" class="flag-MW" data-code="+265-"><em> </em>马拉维(Malawi) +265</a> <a href="javascript:void(0);" class="flag-MY" data-code="+60-"><em> </em>马来西亚(Malaysia) +60</a> <a href="javascript:void(0);" class="flag-ML" data-code="+223-"><em> </em>马里(Mali) +223</a> <a href="javascript:void(0);" class="flag-MK" data-code="+389-"><em> </em>马其顿(Македонија) +389</a> <a href="javascript:void(0);" class="flag-MQ" data-code="+596-"><em> </em>马提尼克(Martinique) +596</a> <a href="javascript:void(0);" class="flag-MU" data-code="+230-"><em> </em>毛里求斯(Mauritius) +230</a> <a href="javascript:void(0);" class="flag-MR" data-code="+222-"><em> </em>毛里塔尼亚(موريتانيا) +222</a> <a href="javascript:void(0);" class="flag-US" data-code="+1-"><em> </em>美国(United States) +1</a> <a href="javascript:void(0);" class="flag-MN" data-code="+976-"><em> </em>蒙古(Монгол Улс) +976</a> <a href="javascript:void(0);" class="flag-MS" data-code="+1664-"><em> </em>蒙特塞拉特(Montserrat) +1664</a> <a href="javascript:void(0);" class="flag-BD" data-code="+880-"><em> </em>孟加拉国(বাংলাদেশ) +880</a> <a href="javascript:void(0);" class="flag-PE" data-code="+51-"><em> </em>秘鲁(Perú) +51</a> <a href="javascript:void(0);" class="flag-MD" data-code="+373-"><em> </em>摩尔多瓦(Moldova) +373</a> <a href="javascript:void(0);" class="flag-MA" data-code="+212-"><em> </em>摩洛哥(المغرب) +212</a> <a href="javascript:void(0);" class="flag-MC" data-code="+377-"><em> </em>摩纳哥(Monaco) +377</a> <a href="javascript:void(0);" class="flag-MZ" data-code="+258-"><em> </em>莫桑比克(Moçambique) +258</a> <a href="javascript:void(0);" class="flag-MX" data-code="+52-"><em> </em>墨西哥(México) +52</a> <a href="javascript:void(0);" class="flag-NA" data-code="+264-"><em> </em>纳米比亚(Namibia) +264</a> <a href="javascript:void(0);" class="flag-ZA" data-code="+27-"><em> </em>南非(South Africa) +27</a> <a href="javascript:void(0);" class="flag-SS" data-code="+211-"><em> </em>南苏丹 +211</a> <a href="javascript:void(0);" class="flag-NP" data-code="+977-"><em> </em>尼泊尔(नेपाल) +977</a> <a href="javascript:void(0);" class="flag-NI" data-code="+505-"><em> </em>尼加拉瓜(Nicaragua) +505</a> <a href="javascript:void(0);" class="flag-NE" data-code="+227-"><em> </em>尼日尔(Niger) +227</a> <a href="javascript:void(0);" class="flag-NG" data-code="+234-"><em> </em>尼日利亚(Nigeria) +234</a> <a href="javascript:void(0);" class="flag-NO" data-code="+47-"><em> </em>挪威(Norge) +47</a> <a href="javascript:void(0);" class="flag-PT" data-code="+351-"><em> </em>葡萄牙(Portugal) +351</a> <a href="javascript:void(0);" class="flag-JP" data-code="+81-"><em> </em>日本(にっぽんこく,にほんこく) +81</a> <a href="javascript:void(0);" class="flag-SE" data-code="+46-"><em> </em>瑞典(Sverige) +46</a> <a href="javascript:void(0);" class="flag-CH" data-code="+41-"><em> </em>瑞士(Schweiz) +41</a> <a href="javascript:void(0);" class="flag-SV" data-code="+503-"><em> </em>萨尔瓦多(El Salvador) +503</a> <a href="javascript:void(0);" class="flag-WS" data-code="+685-"><em> </em>萨摩亚(Samoa) +685</a> <a href="javascript:void(0);" class="flag-RS" data-code="+381-"><em> </em>塞尔维亚(Србија) +381</a> <a href="javascript:void(0);" class="flag-SL" data-code="+232-"><em> </em>塞拉利昂(Sierra Leone) +232</a> <a href="javascript:void(0);" class="flag-SN" data-code="+221-"><em> </em>塞内加尔(Sénégal) +221</a> <a href="javascript:void(0);" class="flag-CY" data-code="+357-"><em> </em>塞浦路斯(Κυπρος) +357</a> <a href="javascript:void(0);" class="flag-SC" data-code="+248-"><em> </em>塞舌尔(Seychelles) +248</a> <a href="javascript:void(0);" class="flag-SA" data-code="+966-"><em> </em>沙特阿拉伯(المملكة العربية السعودية) +966</a> <a href="javascript:void(0);" class="flag-ST" data-code="+239-"><em> </em>圣多美和普林西比 +239</a> <a href="javascript:void(0);" class="flag-KN" data-code="+1869-"><em> </em>圣基茨和尼维斯(Saint Kitts and Nevis) +1869</a> <a href="javascript:void(0);" class="flag-LC" data-code="+1758-"><em> </em>圣卢西亚(Saint Lucia) +1758</a> <a href="javascript:void(0);" class="flag-SM" data-code="+378-"><em> </em>圣马力诺(San Marino) +378</a> <a href="javascript:void(0);" class="flag-PM" data-code="+508-"><em> </em>圣皮埃尔和密克隆群岛(Saint Pierre and Miquelon) +508</a> <a href="javascript:void(0);" class="flag-VC" data-code="+1784-"><em> </em>圣文森特和格林纳丁斯(Saint Vincent and the Grenadines) +1784</a> <a href="javascript:void(0);" class="flag-LK" data-code="+94-"><em> </em>斯里兰卡(Sri Lanka) +94</a> <a href="javascript:void(0);" class="flag-SK" data-code="+421-"><em> </em>斯洛伐克(Slovensko) +421</a> <a href="javascript:void(0);" class="flag-SI" data-code="+386-"><em> </em>斯洛文尼亚(Slovenija) +386</a> <a href="javascript:void(0);" class="flag-SZ" data-code="+268-"><em> </em>斯威士兰(Swaziland) +268</a> <a href="javascript:void(0);" class="flag-SD" data-code="+249-"><em> </em>苏丹(السودان) +249</a> <a href="javascript:void(0);" class="flag-SR" data-code="+597-"><em> </em>苏里南(Suriname) +597</a> <a href="javascript:void(0);" class="flag-SO" data-code="+252-"><em> </em>索马里(Soomaaliya) +252</a> <a href="javascript:void(0);" class="flag-TJ" data-code="+992-"><em> </em>塔吉克斯坦(Тоҷикистон) +992</a> <a href="javascript:void(0);" class="flag-TW" data-code="+886-"><em> </em>台湾地区(台灣) +886</a> <a href="javascript:void(0);" class="flag-TH" data-code="+66-"><em> </em>泰国(ราชอาณาจักรไทย) +66</a> <a href="javascript:void(0);" class="flag-TZ" data-code="+255-"><em> </em>坦桑尼亚(Tanzania) +255</a> <a href="javascript:void(0);" class="flag-TO" data-code="+676-"><em> </em>汤加(Tonga) +676</a> <a href="javascript:void(0);" class="flag-TC" data-code="+1649-"><em> </em>特克斯和凯科斯群岛(Turks and Caicos Islands) +1649</a> <a href="javascript:void(0);" class="flag-TT" data-code="+1868-"><em> </em>特里尼达和多巴哥(Trinidad and Tobago) +1868</a> <a href="javascript:void(0);" class="flag-TN" data-code="+216-"><em> </em>突尼斯(تونس) +216</a> <a href="javascript:void(0);" class="flag-TR" data-code="+90-"><em> </em>土耳其(Türkiye) +90</a> <a href="javascript:void(0);" class="flag-TM" data-code="+993-"><em> </em>土库曼斯坦(Türkmenistan) +993</a> <a href="javascript:void(0);" class="flag-VU" data-code="+678-"><em> </em>瓦努阿图(Vanuatu) +678</a> <a href="javascript:void(0);" class="flag-GT" data-code="+502-"><em> </em>危地马拉(Guatemala) +502</a> <a href="javascript:void(0);" class="flag-VE" data-code="+58-"><em> </em>委内瑞拉(Venezuela) +58</a> <a href="javascript:void(0);" class="flag-BN" data-code="+673-"><em> </em>文莱(Brunei Darussalam) +673</a> <a href="javascript:void(0);" class="flag-UG" data-code="+256-"><em> </em>乌干达(Uganda) +256</a> <a href="javascript:void(0);" class="flag-UA" data-code="+380-"><em> </em>乌克兰(Україна) +380</a> <a href="javascript:void(0);" class="flag-UY" data-code="+598-"><em> </em>乌拉圭(Uruguay) +598</a> <a href="javascript:void(0);" class="flag-UZ" data-code="+998-"><em> </em>乌兹别克斯坦(O'zbekiston) +998</a> <a href="javascript:void(0);" class="flag-ES" data-code="+34-"><em> </em>西班牙(España) +34</a> <a href="javascript:void(0);" class="flag-GR" data-code="+30-"><em> </em>希腊(Ελλάς) +30</a> <a href="javascript:void(0);" class="flag-HK" data-code="+852-"><em> </em>香港地区(Hong Kong) +852</a> <a href="javascript:void(0);" class="flag-CI" data-code="+225-"><em> </em>象牙海岸(Côte d'Ivoire) +225</a> <a href="javascript:void(0);" class="flag-SG" data-code="+65-"><em> </em>新加坡(Singapura) +65</a> <a href="javascript:void(0);" class="flag-NC" data-code="+687-"><em> </em>新喀里多尼亚(New Caledonia) +687</a> <a href="javascript:void(0);" class="flag-NZ" data-code="+64-"><em> </em>新西兰(New Zealand) +64</a> <a href="javascript:void(0);" class="flag-HU" data-code="+36-"><em> </em>匈牙利(Magyarország) +36</a> <a href="javascript:void(0);" class="flag-SY" data-code="+963-"><em> </em>叙利亚(سوريا) +963</a> <a href="javascript:void(0);" class="flag-JM" data-code="+1876-"><em> </em>牙买加(Jamaica) +1876</a> <a href="javascript:void(0);" class="flag-AM" data-code="+374-"><em> </em>亚美尼亚(Հայաստան) +374</a> <a href="javascript:void(0);" class="flag-YE" data-code="+967-"><em> </em>也门(اليمن) +967</a> <a href="javascript:void(0);" class="flag-IQ" data-code="+964-"><em> </em>伊拉克(العراق) +964</a> <a href="javascript:void(0);" class="flag-IR" data-code="+98-"><em> </em>伊朗(ایران) +98</a> <a href="javascript:void(0);" class="flag-IL" data-code="+972-"><em> </em>以色列(ישראל) +972</a> <a href="javascript:void(0);" class="flag-IT" data-code="+39-"><em> </em>意大利(Italia) +39</a> <a href="javascript:void(0);" class="flag-IN" data-code="+91-"><em> </em>印度(India) +91</a> <a href="javascript:void(0);" class="flag-ID" data-code="+62-"><em> </em>印尼(Indonesia) +62</a> <a href="javascript:void(0);" class="flag-GB" data-code="+44-"><em> </em>英国(United Kingdom) +44</a> <a href="javascript:void(0);" class="flag-VG" data-code="+1340-"><em> </em>英属维尔京群岛(U.S. Virgin Islands) +1340</a> <a href="javascript:void(0);" class="flag-JO" data-code="+962-"><em> </em>约旦(الاردن) +962</a> <a href="javascript:void(0);" class="flag-VN" data-code="+84-"><em> </em>越南(Việt Nam) +84</a> <a href="javascript:void(0);" class="flag-ZM" data-code="+260-"><em> </em>赞比亚(Zambia) +260</a> <a href="javascript:void(0);" class="flag-JE" data-code="+44-"><em> </em>泽西岛(United Kingdom) +44</a> <a href="javascript:void(0);" class="flag-TD" data-code="+235-"><em> </em>乍得(Tchad) +235</a> <a href="javascript:void(0);" class="flag-GI" data-code="+350-"><em> </em>直布罗陀(Gibraltar) +350</a> <a href="javascript:void(0);" class="flag-CL" data-code="+56-"><em> </em>智利(Chile) +56</a> <a href="javascript:void(0);" class="flag-CF" data-code="+236-"><em> </em>中非共和国(République Centrafricaine) +236</a> </div>
#486
<?php /** * 基本图片处理,用于完成图片缩入,水印添加 * 当水印图超过目标图片尺寸时,水印图能自动适应目标图片而缩小 * 水印图可以设置跟背景的合并度 * * Copyright(c) 2005 by ustb99. All rights reserved * * To contact the author write to {@link mailto:ustb80@163.com} * * @author 偶然 * @version $Id: thumb.class.php,v 1.9 2006/09/30 09:31:56 zengjian Exp $ * @package system */ /** * ThumbHandler * @access public */ /* 使用方法: 自动裁切: 程序会按照图片的尺寸从中部裁切最大的正方形,并按目标尺寸进行缩略 $t->setSrcImg("img/test.jpg"); $t->setCutType(1);//这一句就OK了 $t->setDstImg("tmp/new_test.jpg"); $t->createImg(60,60); 手工裁切: 程序会按照指定的位置从源图上取图 $t->setSrcImg("img/test.jpg"); $t->setCutType(2);//指明为手工裁切 $t->setSrcCutPosition(100, 100);// 源图起点坐标 $t->setRectangleCut(300, 200);// 裁切尺寸 $t->setDstImg("tmp/new_test.jpg"); $t->createImg(300,200); */ class ThumbHandler { var $dst_img;// 目标文件 var $h_src; // 图片资源句柄 var $h_dst;// 新图句柄 var $h_mask;// 水印句柄 var $img_create_quality = 100;// 图片生成质量 var $img_display_quality = 80;// 图片显示质量,默认为75 var $img_scale = 0;// 图片缩放比例 var $src_w = 0;// 原图宽度 var $src_h = 0;// 原图高度 var $dst_w = 0;// 新图总宽度 var $dst_h = 0;// 新图总高度 var $fill_w;// 填充图形宽 var $fill_h;// 填充图形高 var $copy_w;// 拷贝图形宽 var $copy_h;// 拷贝图形高 var $src_x = 0;// 原图绘制起始横坐标 var $src_y = 0;// 原图绘制起始纵坐标 var $start_x;// 新图绘制起始横坐标 var $start_y;// 新图绘制起始纵坐标 var $mask_word;// 水印文字 var $mask_img;// 水印图片 var $mask_pos_x = 0;// 水印横坐标 var $mask_pos_y = 0;// 水印纵坐标 var $mask_offset_x = 5;// 水印横向偏移 var $mask_offset_y = 5;// 水印纵向偏移 var $font_w;// 水印字体宽 var $font_h;// 水印字体高 var $mask_w;// 水印宽 var $mask_h;// 水印高 var $mask_font_color = "#ffffff";// 水印文字颜色 var $mask_font = 2;// 水印字体 var $font_size;// 尺寸 var $mask_position = 0;// 水印位置 var $mask_img_pct = 50;// 图片合并程度,值越大,合并程序越低 var $mask_txt_pct = 50;// 文字合并程度,值越小,合并程序越低 var $img_border_size = 0;// 图片边框尺寸 var $img_border_color;// 图片边框颜色 var $_flip_x=0;// 水平翻转次数 var $_flip_y=0;// 垂直翻转次数 var $cut_type=0;// 剪切类型 var $img_type;// 文件类型 // 文件类型定义,并指出了输出图片的函数 var $all_type = array( "jpg" => array("output"=>"imagejpeg"), "gif" => array("output"=>"imagegif"), "png" => array("output"=>"imagepng"), "wbmp" => array("output"=>"image2wbmp"), "jpeg" => array("output"=>"imagejpeg")); /** * 构造函数 */ function ThumbHandler() { $this->mask_font_color = "#ffffff"; $this->font = 2; $this->font_size = 12; } /** * 取得图片的宽 */ function getImgWidth($src) { return imagesx($src); } /** * 取得图片的高 */ function getImgHeight($src) { return imagesy($src); } /** * 设置图片生成路径 * * @param string $src_img 图片生成路径 */ function setSrcImg($src_img, $img_type=null) { if(!file_exists($src_img)) { die("图片不存在"); } if(!emptyempty($img_type)) { $this->img_type = $img_type; } else { $this->img_type = $this->_getImgType($src_img); } $this->_checkValid($this->img_type); // file_get_contents函数要求php版本>4.3.0 $src = ''; if(function_exists("file_get_contents")) { $src = file_get_contents($src_img); } else { $handle = fopen ($src_img, "r"); while (!feof ($handle)) { $src .= fgets($fd, 4096); } fclose ($handle); } if(emptyempty($src)) { die("图片源为空"); } $this->h_src = @ImageCreateFromString($src); $this->src_w = $this->getImgWidth($this->h_src); $this->src_h = $this->getImgHeight($this->h_src); } /** * 设置图片生成路径 * * @param string $dst_img 图片生成路径 */ function setDstImg($dst_img) { $arr = explode('/',$dst_img); $last = array_pop($arr); $path = implode('/',$arr); $this->_mkdirs($path); $this->dst_img = $dst_img; } /** * 设置图片的显示质量 * * @param string $n 质量 */ function setImgDisplayQuality($n) { $this->img_display_quality = (int)$n; } /** * 设置图片的生成质量 * * @param string $n 质量 */ function setImgCreateQuality($n) { $this->img_create_quality = (int)$n; } /** * 设置文字水印 * * @param string $word 水印文字 * @param integer $font 水印字体 * @param string $color 水印字体颜色 */ function setMaskWord($word) { $this->mask_word .= $word; } /** * 设置字体颜色 * * @param string $color 字体颜色 */ function setMaskFontColor($color="#ffffff") { $this->mask_font_color = $color; } /** * 设置水印字体 * * @param string|integer $font 字体 */ function setMaskFont($font=2) { if(!is_numeric($font) && !file_exists($font)) { die("字体文件不存在"); } $this->font = $font; } /** * 设置文字字体大小,仅对truetype字体有效 */ function setMaskFontSize($size = "12") { $this->font_size = $size; } /** * 设置图片水印 * * @param string $img 水印图片源 */ function setMaskImg($img) { $this->mask_img = $img; } /** * 设置水印横向偏移 * * @param integer $x 横向偏移量 */ function setMaskOffsetX($x) { $this->mask_offset_x = (int)$x; } /** * 设置水印纵向偏移 * * @param integer $y 纵向偏移量 */ function setMaskOffsetY($y) { $this->mask_offset_y = (int)$y; } /** * 指定水印位置 * * @param integer $position 位置,1:左上,2:左下,3:右上,0/4:右下 */ function setMaskPosition($position=0) { $this->mask_position = (int)$position; } /** * 设置图片合并程度 * * @param integer $n 合并程度 */ function setMaskImgPct($n) { $this->mask_img_pct = (int)$n; } /** * 设置文字合并程度 * * @param integer $n 合并程度 */ function setMaskTxtPct($n) { $this->mask_txt_pct = (int)$n; } /** * 设置缩略图边框 * * @param (类型) (参数名) (描述) */ function setDstImgBorder($size=1, $color="#000000") { $this->img_border_size = (int)$size; $this->img_border_color = $color; } /** * 水平翻转 */ function flipH() { $this->_flip_x++; } /** * 垂直翻转 */ function flipV() { $this->_flip_y++; } /** * 设置剪切类型 * * @param (类型) (参数名) (描述) */ function setCutType($type) { $this->cut_type = (int)$type; } /** * 设置图片剪切 * * @param integer $width 矩形剪切 */ function setRectangleCut($width, $height) { $this->fill_w = (int)$width; $this->fill_h = (int)$height; } /** * 设置源图剪切起始坐标点 * * @param (类型) (参数名) (描述) */ function setSrcCutPosition($x, $y) { $this->src_x = (int)$x; $this->src_y = (int)$y; } /** * 创建图片,主函数 * @param integer $a 当缺少第二个参数时,此参数将用作百分比, * 否则作为宽度值 * @param integer $b 图片缩放后的高度 */ function createImg($a, $b=null) { $num = func_num_args(); if(1 == $num) { $r = (int)$a; if($r < 1) { die("图片缩放比例不得小于1"); } $this->img_scale = $r; $this->_setNewImgSize($r); } if(2 == $num) { $w = (int)$a; $h = (int)$b; if(0 == $w) { die("目标宽度不能为0"); } if(0 == $h) { die("目标高度不能为0"); } $this->_setNewImgSize($w, $h); } if($this->_flip_x%2!=0) { $this->_flipH($this->h_src); } if($this->_flip_y%2!=0) { $this->_flipV($this->h_src); } $this->_createMask(); $this->_output(); // 释放 if(imagedestroy($this->h_src) && imagedestroy($this->h_dst)) { Return true; } else { Return false; } } /** * 生成水印,调用了生成水印文字和水印图片两个方法 */ function _createMask() { if($this->mask_word) { // 获取字体信息 $this->_setFontInfo(); if($this->_isFull()) { die("水印文字过大"); } else { $this->h_dst = imagecreatetruecolor($this->dst_w, $this->dst_h); $white = ImageColorAllocate($this->h_dst,255,255,255); imagefilledrectangle($this->h_dst,0,0,$this->dst_w,$this->dst_h,$white);// 填充背景色 $this->_drawBorder(); imagecopyresampled( $this->h_dst, $this->h_src, $this->start_x, $this->start_y, $this->src_x, $this->src_y, $this->fill_w, $this->fill_h, $this->copy_w, $this->copy_h); $this->_createMaskWord($this->h_dst); } } if($this->mask_img) { $this->_loadMaskImg();//加载时,取得宽高 if($this->_isFull()) { // 将水印生成在原图上再拷 $this->_createMaskImg($this->h_src); $this->h_dst = imagecreatetruecolor($this->dst_w, $this->dst_h); $white = ImageColorAllocate($this->h_dst,255,255,255); imagefilledrectangle($this->h_dst,0,0,$this->dst_w,$this->dst_h,$white);// 填充背景色 $this->_drawBorder(); imagecopyresampled( $this->h_dst, $this->h_src, $this->start_x, $this->start_y, $this->src_x, $this->src_y, $this->fill_w, $this->start_y, $this->copy_w, $this->copy_h); } else { // 创建新图并拷贝 $this->h_dst = imagecreatetruecolor($this->dst_w, $this->dst_h); $white = ImageColorAllocate($this->h_dst,255,255,255); imagefilledrectangle($this->h_dst,0,0,$this->dst_w,$this->dst_h,$white);// 填充背景色 $this->_drawBorder(); imagecopyresampled( $this->h_dst, $this->h_src, $this->start_x, $this->start_y, $this->src_x, $this->src_y, $this->fill_w, $this->fill_h, $this->copy_w, $this->copy_h); $this->_createMaskImg($this->h_dst); } } if(emptyempty($this->mask_word) && emptyempty($this->mask_img)) { $this->h_dst = imagecreatetruecolor($this->dst_w, $this->dst_h); $white = ImageColorAllocate($this->h_dst,255,255,255); imagefilledrectangle($this->h_dst,0,0,$this->dst_w,$this->dst_h,$white);// 填充背景色 $this->_drawBorder(); imagecopyresampled( $this->h_dst, $this->h_src, $this->start_x, $this->start_y, $this->src_x, $this->src_y, $this->fill_w, $this->fill_h, $this->copy_w, $this->copy_h); } } /** * 画边框 */ function _drawBorder() { if(!emptyempty($this->img_border_size)) { $c = $this->_parseColor($this->img_border_color); $color = ImageColorAllocate($this->h_src,$c[0], $c[1], $c[2]); imagefilledrectangle($this->h_dst,0,0,$this->dst_w,$this->dst_h,$color);// 填充背景色 } } /** * 生成水印文字 */ function _createMaskWord($src) { $this->_countMaskPos(); $this->_checkMaskValid(); $c = $this->_parseColor($this->mask_font_color); $color = imagecolorallocatealpha($src, $c[0], $c[1], $c[2], $this->mask_txt_pct); if(is_numeric($this->font)) { imagestring($src, $this->font, $this->mask_pos_x, $this->mask_pos_y, $this->mask_word, $color); } else { imagettftext($src, $this->font_size, 0, $this->mask_pos_x, $this->mask_pos_y, $color, $this->font, $this->mask_word); } } /** * 生成水印图 */ function _createMaskImg($src) { $this->_countMaskPos(); $this->_checkMaskValid(); imagecopymerge($src, $this->h_mask, $this->mask_pos_x ,$this->mask_pos_y, 0, 0, $this->mask_w, $this->mask_h, $this->mask_img_pct); imagedestroy($this->h_mask); } /** * 加载水印图 */ function _loadMaskImg() { $mask_type = $this->_getImgType($this->mask_img); $this->_checkValid($mask_type); // file_get_contents函数要求php版本>4.3.0 $src = ''; if(function_exists("file_get_contents")) { $src = file_get_contents($this->mask_img); } else { $handle = fopen ($this->mask_img, "r"); while (!feof ($handle)) { $src .= fgets($fd, 4096); } fclose ($handle); } if(emptyempty($this->mask_img)) { die("水印图片为空"); } $this->h_mask = ImageCreateFromString($src); $this->mask_w = $this->getImgWidth($this->h_mask); $this->mask_h = $this->getImgHeight($this->h_mask); } /** * 图片输出 */ function _output() { $img_type = $this->img_type; $func_name = $this->all_type[$img_type]['output']; if(function_exists($func_name)) { // 判断浏览器,若是IE就不发送头 if(isset($_SERVER['HTTP_USER_AGENT'])) { $ua = strtoupper($_SERVER['HTTP_USER_AGENT']); if(!preg_match('/^.*MSIE.*\)$/i',$ua)) { header("Content-type:$img_type"); } } $func_name($this->h_dst, $this->dst_img, $this->img_display_quality); } else { Return false; } } /** * 分析颜色 * * @param string $color 十六进制颜色 */ function _parseColor($color) { $arr = array(); for($ii=1; $ii<strlen ($color); $ii++) { $arr[] = hexdec(substr($color,$ii,2)); $ii++; } Return $arr; } /** * 计算出位置坐标 */ function _countMaskPos() { if($this->_isFull()) { switch($this->mask_position) { case 1: // 左上 $this->mask_pos_x = $this->mask_offset_x + $this->img_border_size; $this->mask_pos_y = $this->mask_offset_y + $this->img_border_size; break; case 2: // 左下 $this->mask_pos_x = $this->mask_offset_x + $this->img_border_size; $this->mask_pos_y = $this->src_h - $this->mask_h - $this->mask_offset_y; break; case 3: // 右上 $this->mask_pos_x = $this->src_w - $this->mask_w - $this->mask_offset_x; $this->mask_pos_y = $this->mask_offset_y + $this->img_border_size; break; case 4: // 右下 $this->mask_pos_x = $this->src_w - $this->mask_w - $this->mask_offset_x; $this->mask_pos_y = $this->src_h - $this->mask_h - $this->mask_offset_y; break; default: // 默认将水印放到右下,偏移指定像素 $this->mask_pos_x = $this->src_w - $this->mask_w - $this->mask_offset_x; $this->mask_pos_y = $this->src_h - $this->mask_h - $this->mask_offset_y; break; } } else { switch($this->mask_position) { case 1: // 左上 $this->mask_pos_x = $this->mask_offset_x + $this->img_border_size; $this->mask_pos_y = $this->mask_offset_y + $this->img_border_size; break; case 2: // 左下 $this->mask_pos_x = $this->mask_offset_x + $this->img_border_size; $this->mask_pos_y = $this->dst_h - $this->mask_h - $this->mask_offset_y - $this->img_border_size; break; case 3: // 右上 $this->mask_pos_x = $this->dst_w - $this->mask_w - $this->mask_offset_x - $this->img_border_size; $this->mask_pos_y = $this->mask_offset_y + $this->img_border_size; break; case 4: // 右下 $this->mask_pos_x = $this->dst_w - $this->mask_w - $this->mask_offset_x - $this->img_border_size; $this->mask_pos_y = $this->dst_h - $this->mask_h - $this->mask_offset_y - $this->img_border_size; break; default: // 默认将水印放到右下,偏移指定像素 $this->mask_pos_x = $this->dst_w - $this->mask_w - $this->mask_offset_x - $this->img_border_size; $this->mask_pos_y = $this->dst_h - $this->mask_h - $this->mask_offset_y - $this->img_border_size; break; } } } /** * 设置字体信息 */ function _setFontInfo() { if(is_numeric($this->font)) { $this->font_w = imagefontwidth($this->font); $this->font_h = imagefontheight($this->font); // 计算水印字体所占宽高 $word_length = strlen($this->mask_word); $this->mask_w = $this->font_w*$word_length; $this->mask_h = $this->font_h; } else { $arr = imagettfbbox ($this->font_size,0, $this->font,$this->mask_word); $this->mask_w = abs($arr[0] - $arr[2]); $this->mask_h = abs($arr[7] - $arr[1]); } } /** * 设置新图尺寸 * * @param integer $img_w 目标宽度 * @param integer $img_h 目标高度 */ function _setNewImgSize($img_w, $img_h=null) { $num = func_num_args(); if(1 == $num) { $this->img_scale = $img_w;// 宽度作为比例 $this->fill_w = round($this->src_w * $this->img_scale / 100) - $this->img_border_size*2; $this->fill_h = round($this->src_h * $this->img_scale / 100) - $this->img_border_size*2; // 源文件起始坐标 $this->src_x = 0; $this->src_y = 0; $this->copy_w = $this->src_w; $this->copy_h = $this->src_h; // 目标尺寸 $this->dst_w = $this->fill_w + $this->img_border_size*2; $this->dst_h = $this->fill_h + $this->img_border_size*2; } if(2 == $num) { $fill_w = (int)$img_w - $this->img_border_size*2; $fill_h = (int)$img_h - $this->img_border_size*2; if($fill_w < 0 || $fill_h < 0) { die("图片边框过大,已超过了图片的宽度"); } $rate_w = $this->src_w/$fill_w; $rate_h = $this->src_h/$fill_h; switch($this->cut_type) { case 0: // 如果原图大于缩略图,产生缩小,否则不缩小 if($rate_w < 1 && $rate_h < 1) { $this->fill_w = (int)$this->src_w; $this->fill_h = (int)$this->src_h; } else { if($rate_w >= $rate_h) { $this->fill_w = (int)$fill_w; $this->fill_h = round($this->src_h/$rate_w); } else { $this->fill_w = round($this->src_w/$rate_h); $this->fill_h = (int)$fill_h; } } $this->src_x = 0; $this->src_y = 0; $this->copy_w = $this->src_w; $this->copy_h = $this->src_h; // 目标尺寸 $this->dst_w = $this->fill_w + $this->img_border_size*2; $this->dst_h = $this->fill_h + $this->img_border_size*2; break; // 自动裁切 case 1: // 如果图片是缩小剪切才进行操作 if($rate_w >= 1 && $rate_h >=1) { if($this->src_w > $this->src_h) { $src_x = round($this->src_w-$this->src_h)/2; $this->setSrcCutPosition($src_x, 0); $this->setRectangleCut($fill_h, $fill_h); $this->copy_w = $this->src_h; $this->copy_h = $this->src_h; } elseif($this->src_w < $this->src_h) { $src_y = round($this->src_h-$this->src_w)/2; $this->setSrcCutPosition(0, $src_y); $this->setRectangleCut($fill_w, $fill_h); $this->copy_w = $this->src_w; $this->copy_h = $this->src_w; } else { $this->setSrcCutPosition(0, 0); $this->copy_w = $this->src_w; $this->copy_h = $this->src_w; $this->setRectangleCut($fill_w, $fill_h); } } else { $this->setSrcCutPosition(0, 0); $this->setRectangleCut($this->src_w, $this->src_h); $this->copy_w = $this->src_w; $this->copy_h = $this->src_h; } // 目标尺寸 $this->dst_w = $this->fill_w + $this->img_border_size*2; $this->dst_h = $this->fill_h + $this->img_border_size*2; break; // 手工裁切 case 2: $this->copy_w = $this->fill_w; $this->copy_h = $this->fill_h; // 目标尺寸 $this->dst_w = $this->fill_w + $this->img_border_size*2; $this->dst_h = $this->fill_h + $this->img_border_size*2; break; default: break; } } // 目标文件起始坐标 $this->start_x = $this->img_border_size; $this->start_y = $this->img_border_size; } /** * 检查水印图是否大于生成后的图片宽高 */ function _isFull() { Return ( $this->mask_w + $this->mask_offset_x > $this->fill_w || $this->mask_h + $this->mask_offset_y > $this->fill_h) ?true:false; } /** * 检查水印图是否超过原图 */ function _checkMaskValid() { if( $this->mask_w + $this->mask_offset_x > $this->src_w || $this->mask_h + $this->mask_offset_y > $this->src_h) { die("水印图片尺寸大于原图,请缩小水印图"); } } /** * 取得图片类型 * * @param string $file_path 文件路径 */ function _getImgType($file_path) { $type_list = array("1"=>"gif","2"=>"jpg","3"=>"png","4"=>"swf","5" => "psd","6"=>"bmp","15"=>"wbmp"); if(file_exists($file_path)) { $img_info = @getimagesize ($file_path); if(isset($type_list[$img_info[2]])) { Return $type_list[$img_info[2]]; } } else { die("文件不存在,不能取得文件类型!"); } } /** * 检查图片类型是否合法,调用了array_key_exists函数,此函数要求 * php版本大于4.1.0 * * @param string $img_type 文件类型 */ function _checkValid($img_type) { if(!array_key_exists($img_type, $this->all_type)) { Return false; } } /** * 按指定路径生成目录 * * @param string $path 路径 */ function _mkdirs($path) { $adir = explode('/',$path); $dirlist = ''; $rootdir = array_shift($adir); if(($rootdir!='.'||$rootdir!='..')&&!file_exists($rootdir)) { @mkdir($rootdir); } foreach($adir as $key=>$val) { if($val!='.'&&$val!='..') { $dirlist .= "/".$val; $dirpath = $rootdir.$dirlist; if(!file_exists($dirpath)) { @mkdir($dirpath); @chmod($dirpath,0777); } } } } /** * 垂直翻转 * * @param string $src 图片源 */ function _flipV($src) { $src_x = $this->getImgWidth($src); $src_y = $this->getImgHeight($src); $new_im = imagecreatetruecolor($src_x, $src_y); for ($y = 0; $y < $src_y; $y++) { imagecopy($new_im, $src, 0, $src_y - $y - 1, 0, $y, $src_x, 1); } $this->h_src = $new_im; } /** * 水平翻转 * * @param string $src 图片源 */ function _flipH($src) { $src_x = $this->getImgWidth($src); $src_y = $this->getImgHeight($src); $new_im = imagecreatetruecolor($src_x, $src_y); for ($x = 0; $x < $src_x; $x++) { imagecopy($new_im, $src, $src_x - $x - 1, 0, $x, 0, 1, $src_y); } $this->h_src = $new_im; } } 使用实例: < ?php require_once('lib/thumb.class.php'); $t = new ThumbHandler(); $t->setSrcImg("img/test.jpg"); $t->setDstImg("tmp/new_test.jpg"); $t->setMaskImg("img/test.gif"); $t->setMaskPosition(1); $t->setMaskImgPct(80); $t->setDstImgBorder(4,"#dddddd"); // 指定缩放比例 $t->createImg(300,200); ?> <?php require_once('lib/thumb.class.php'); $t = new ThumbHandler(); // 基本使用 $t->setSrcImg("img/test.jpg"); $t->setMaskWord("test"); $t->setDstImgBorder(10,"#dddddd"); // 指定缩放比例 $t->createImg(50); ?> <?php equire_once('lib/thumb.class.php'); $t = new ThumbHandler(); // 基本使用 $t->setSrcImg("img/test.jpg"); $t->setMaskWord("test"); // 指定固定宽高 $t->createImg(200,200); ?> <?php require_once('lib/thumb.class.php'); $t = new ThumbHandler(); $t->setSrcImg("img/test.jpg"); $t->setDstImg("tmp/new_test.jpg"); $t->setMaskWord("test"); // 指定固定宽高 $t->createImg(200,200); ?> <?php require_once('lib/thumb.class.php'); $t = new ThumbHandler(); $t->setSrcImg("img/test.jpg"); // 指定字体文件地址 $t->setMaskFont("c:/winnt/fonts/arial.ttf"); $t->setMaskFontSize(20); $t->setMaskFontColor("#ffff00"); $t->setMaskWord("test3333333"); $t->setDstImgBorder(99,"#dddddd"); $t->createImg(50); ?> <?php require_once('lib/thumb.class.php'); $t = new ThumbHandler(); $t->setSrcImg("img/test.jpg"); $t->setMaskOffsetX(55); $t->setMaskOffsetY(55); $t->setMaskPosition(1); //$t->setMaskPosition(2); //$t->setMaskPosition(3); //$t->setMaskPosition(4); $t->setMaskFontColor("#ffff00"); $t->setMaskWord("test"); // 指定固定宽高 $t->createImg(50); ?> <?php require_once('lib/thumb.class.php'); $t = new ThumbHandler(); $t->setSrcImg("img/test.jpg"); $t->setMaskFont("c:/winnt/fonts/simyou.ttf"); $t->setMaskFontSize(20); $t->setMaskFontColor("#ffffff"); $t->setMaskTxtPct(20); $t->setDstImgBorder(10,"#dddddd"); $text = "中文"; $str = mb_convert_encoding($text, "UTF-8", "gb2312"); $t->setMaskWord($str); $t->setMaskWord("test"); // 指定固定宽高 $t->createImg(50);
#487
intval(3.14159); // 3 intval(3.64159); // 3 intval('ruesin'); //0
round(3.14159); // 3 round(3.64159); // 4 round(3.64159, 0); // 4 round(3.64159, 2); // 3.64 round(5.64159, 3); // 3.642 round(364159, -2); // 364200
ceil(3.14159); // 4 ceil(3.64159); // 4
floor(3.14159); // 3 floor(3.64159); // 3
#488
"\Core\Conf\convention.php
#489
#490
#491
压测命令:ab -n 10000 -c 100 http://www.appeiphone.cn/
ab -n 1000 -c 1000 -p post.txt -T 'application/x-www-form-urlencoded' http://www.app-im.cn/save.asp post.txt 内容是 u=123456&p=12345&x=4&y=10
可以用 [进程替换( Process Substitution )] ab -n 1000 -c 1000 -p <(echo 'u=123456&p=12345&x=4&y=10') -T 'application/x-www-form-urlencoded' http://www.app-im.cn/save.asp
for((i=0;i<20;++i));do while :;do {{Curl command goes here}} done;
wrk -c 1000 -d 60s -t 5 http://www.app-im.cn/
那个 还可以用 <(<<<'u=123456&p=12345&x=4&y=10') ref: http://ahei.info/bash.htm#sec-3
cd C:\apache\Apache24\bin
ab -n 100 -c 10 http://test.com/
ab [可选的参数选项] 需要进行压力测试的url 此外,我们再根据上面的用法介绍界面来详细了解每个参数选项的作用。 -n 即requests,用于指定压力测试总共的执行次数。 -c 即concurrency,用于指定的并发数。 -t 即timelimit,等待响应的最大时间(单位:秒)。 -b 即windowsize,TCP发送/接收的缓冲大小(单位:字节)。 -p 即postfile,发送POST请求时需要上传的文件,此外还必须设置-T参数。 -u 即putfile,发送PUT请求时需要上传的文件,此外还必须设置-T参数。 -T 即content-type,用于设置Content-Type请求头信息,例如:application/x-www-form-urlencoded,默认值为text/plain。 -v 即verbosity,指定打印帮助信息的冗余级别。 -w 以HTML表格形式打印结果。 -i 使用HEAD请求代替GET请求。 -x 插入字符串作为table标签的属性。 -y 插入字符串作为tr标签的属性。 -z 插入字符串作为td标签的属性。 -C 添加cookie信息,例如:"Apache=1234"(可以重复该参数选项以添加多个)。 -H 添加任意的请求头,例如:"Accept-Encoding: gzip",请求头将会添加在现有的多个请求头之后(可以重复该参数选项以添加多个)。 -A 添加一个基本的网络认证信息,用户名和密码之间用英文冒号隔开。 -P 添加一个基本的代理认证信息,用户名和密码之间用英文冒号隔开。 -X 指定使用的和端口号,例如:"126.10.10.3:88"。 -V 打印版本号并退出。 -k 使用HTTP的KeepAlive特性。 -k 使用HTTP的KeepAlive特性。 -d 不显示百分比。 -S 不显示预估和警告信息。 -g 输出结果信息到gnuplot格式的文件中。 -e 输出结果信息到CSV格式的文件中。 -r 指定接收到错误信息时不退出程序。 -h 显示用法信息,其实就是ab -help。
虽然ab可以配置的参数选项比较多,但是,一般情况下我们只需要使用形如ab -n 数字 -c 数字 url路径的命令即可。譬如,我们对位于本地Apache服务器上、URL为localhost/index.的页面进行。测试总次数为1000,并发数为100(相当于100个用户同时访问,他们总共访问1000次)。我们输入DOS命令ab -n 1000 -c 100 localhost/index.php,打印结果如下: F:\Apache2.2\bin>ab -n 1000 -c 100 localhost/index.php
@ECHO OFF cmd /k cd /d D:\d\phpStudy\Apache\bin
压力测试目录bat
ab -n 100000 -c 10000 http://www.letrue.cn/
#492
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <body> <img src="imges/01.jpg" alt="" id='img'> <button id='prev'>上一张</button> <button id='next'>下一张</button> </body> <script> window.onload = function(){ //获取要用到的元素,标签 var img = document.getElementById('img'); var prev = document.getElementById('prev'); var next = document.getElementById('next'); //定义两端的临界值, 定义活动的变量 最大5张、 var maxIndex = 5; var minIndex = 1; var activeIndex = minIndex; // 确定事件源 绑定事件函数。 prev.onclick = function(){ //当点击 上一张的时候, img的src 实现切换 img.src = 'imges/0' + activeIndex + '.jpg'; if(activeIndex === 1){ activeIndex = 5; }else{activeIndex --;} } next.onclick = function(){ if(activeIndex === 5){ activeIndex = 1; }else{ activeIndex++; } img.src = 'imges/0' + activeIndex + '.jpg'; } } </script> </html>
#493
#494
确定要清除编辑框内容吗?
该删除操作将不可恢复。
删除 取消
激活Windows
转到"设置"以激活Windows。
#476
#477
问题原因:服务器时间不对。
解决办法,更新服务器时间,或者在生成预支付订单号时,不填写time_expire字段 因为这个字段不是必须填写的。
#478
php实现远程网络文件下载到服务器指定目录
php后台远程更新下载运行
<?php function getFile($url, $save_dir = '', $filename = '', $type = 0) { if (trim($url) == '') { return false; } if (trim($save_dir) == '') { $save_dir = './'; } if (0 !== strrpos($save_dir, '/')) { $save_dir.= '/'; } //创建保存目录 if (!file_exists($save_dir) && !mkdir($save_dir, 0777, true)) { return false; } //获取远程文件所采用的方法 if ($type) { $ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $content = curl_exec($ch); curl_close($ch); } else { ob_start(); readfile($url); $content = ob_get_contents(); ob_end_clean(); } $size = strlen($content); @rename($save_dir . $filename,$save_dir . $filename.time());//备份 //文件大小 $fp2 = @fopen($save_dir . $filename, 'a'); fwrite($fp2, $content); fclose($fp2); unset($content, $url); return array( 'file_name' => $filename, 'save_path' => $save_dir . $filename ); } $url = "http://gsj.com/123.get"; $save_dir = ""; //"down/"; $filename = "index.php"; $res = getFile($url, $save_dir, $filename, 1); var_dump($res);php远程下载文件并保存到指定路径
#479
<!--[if ie]>
<!--[if IE]> <h1>您正在使用IE浏览器</h1> <!--[if IE 5.0]> <h2>版本 5.0</h2> <![endif]--> <!--[if IE 6]> <h2>版本 6</h2> <![endif]--> <!--[if IE 7]> <h2>版本 7</h2> <![endif]--> <![endif]--><!--[if lt IE 6]> IE6以及IE6以下版本可识别 <![endif]--> <!--[if gte IE 6]> IE6以及IE6以上版本可识别 <![endif]--><!--[if lte IE 6]> <!-- 如果IE浏览器版本小于等于6,调用IE.css样式表 --> <link rel="stylesheet" type="text/css" href="IE.css" /> <![endif]--><!--[if !IE]><!--> 除IE外都可识别 <!--<![endif]-->lte:就是Less than or equal to的简写,也就是小于或等于的意思 lt :就是Less than的简写,也就是小于的意思 gte:就是Greater than or equal to的简写,也就是大于或等于的意思 gt :就是Greater than的简写,也就是大于的意思 ! : 就是不等于的意思,跟javascript里的不等于判断符相同<style> .ie7{display:none;} .ie8{display:none;} </style> <!--[if IE 7]> <style> .ie7{display:block;} </style> <![endif]--> <!--[if IE 8]> <style> .ie8{display:block;} </style> <![endif]--> <div class="ie7">ie7</div> <div class="ie8">ie8</div>#480
<?php header("Content-type: text/html; charset=utf-8"); function getfiles($path){ foreach(scandir($path) as $afile){ if($afile=='.'||$afile=='..') continue; if(is_dir($path.'/'.$afile)){ getfiles($path.'/'.$afile); }else { //echo $path.'/'.$afile.'<br />'; $list[]=$afile; $filetime[]=date('Y-m-d H:i:s', filemtime($path.'/'.$afile)); // 获取文件最近修改日期 } } array_multisort($filetime,SORT_DESC,SORT_STRING, $list);//按时间排序 return $list; } //简单的demo,列出当前目录下所有的文件 $list=getfiles('upload'); ?> <!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <title>图库</title> <style>*{padding:0px;margin:0px;} /*瀑布流层*/ .waterfall{ -moz-column-count:4; /* Firefox */ -webkit-column-count:4; /* Safari 和 Chrome */ column-count:4; -moz-column-gap: 1em; -webkit-column-gap: 1em; column-gap: 1em; }img:hover { -webkit-filter: grayscale(100%); /* Chrome, Safari, Opera */ filter: grayscale(100%);background: green; }img{padding:5px;}</style><head><body> <script> var nnw=document.body.clientWidth; var nums=parseInt(nnw/200); document.write('<style>.waterfall{-moz-column-count:'+nums+'; /* Firefox */-webkit-column-count:'+nums+'; /* Safari 和 Chrome */column-count:'+nums+';-moz-column-gap: 1em;-webkit-column-gap: 1em;column-gap: 1em;}</style>') </script> <div class="waterfall"> <?php foreach($list as $k=>$v){ echo '<a href="/up/upload/'.$v.'" target="_blank"><img src="/up/upload/'.$v.'" width="190" /></a>'; } ?> </div> </body></html><?php $dir = "./";//目录 if (is_dir($dir)) { if ($dh = opendir($dir)) { $i = 0; while (($file = readdir($dh)) !== false) { if ($file != "." && $file != "..") { $files[$i]["name"] = $file;//获取文件名称 $files[$i]["size"] = round((filesize($file)/1024),2);//获取文件大小 $files[$i]["time"] = date("Y-m-d H:i:s",filemtime($file));//获取文件最近修改日期 $i++; } } } closedir($dh); foreach($files as $k=>$v){ $size[$k] = $v['size']; $time[$k] = $v['time']; $name[$k] = $v['name']; } array_multisort($time,SORT_DESC,SORT_STRING, $files);//按时间排序 //array_multisort($name,SORT_DESC,SORT_STRING, $files);//按名字排序 //array_multisort($size,SORT_DESC,SORT_NUMERIC, $files);//按大小排序 print_r($files); }function dir_size($dir,$url){ $dh = @opendir($dir); //打开目录,返回一个目录流 $return = array(); $i = 0; while($file = @readdir($dh)){ //循环读取目录下的文件 if($file!='.' and $file!='..'){ $path = $dir.'/'.$file; //设置目录,用于含有子目录的情况 if(is_dir($path)){ }elseif(is_file($path)){ $filesize[] = round((filesize($path)/1024),2);//获取文件大小 $filename[] = $path;//获取文件名称 $filetime[] = date("Y-m-d H:i:s",filemtime($path));//获取文件最近修改日期 $return[] = $url.'/'.$file; } } } @closedir($dh); //关闭目录流 array_multisort($filesize,SORT_DESC,SORT_NUMERIC, $return);//按大小排序 //array_multisort($filename,SORT_DESC,SORT_STRING, $files);//按名字排序 //array_multisort($filetime,SORT_DESC,SORT_STRING, $files);//按时间排序 return $return; //返回文件 }#481
#482
var formdata; if (typeof FileReader === 'undefined') {//检测浏览器对FileReader兼容性 showimg.innerHTML = "抱歉,你的浏览器不支持 FileReader"; imginput.setAttribute('disabled', 'disabled'); } else { imginput.addEventListener('change', function() { var file = this.files[0]; console.log(file); if (!/image\/\w+/.test(file.type)) { alert("请确保文件为图像类型"); return false; } var reader = new FileReader();//创建一个FileReader实例 reader.readAsDataURL(file);//将文件内容进行base64编码后输出 //console.log(reader) reader.onload = function(e) { //console.log(this.result);//读取完成后,数据保存在对象的result属性中 $(showimg).append('<img src="' + this.result + '" alt=""/>');//将选中的图片显示在页面上 //alert('111'); formData=new FormData(); formData.append('file',file); console.log(formData.getAll('file')); } }, false); } $.ajax({ url : url, type : 'post', dataType:"json", data:formData, cache: false, processData : false,// 告诉jQuery不要去处理发送的数据 contentType : false,// 告诉jQuery不要去设置Content-Type请求头 success : function(data, status, xhr) { //alert(1); }, error : function(xhr, errorType, error) { //alert(0); } });#483
点击即可启用adobe flash player
Google Chrome 更新至版本后,Adobe Flash Player一直加载不出来,总是提示要手动点击启动运行,并且chrome://plugins/路径打不开了
或者
#484
2、凡是每天憋尿过多的人,有高几率100年内死去!
3、据研究,毎呼吸60秒,就减少1分钟寿命。
4、当你吃下了20碗米饭,换算下来竟然相当于摄入了20碗米饭的热量。
5、谁能想到,这名16岁少女,4年前只是一位12岁少女。
6、中国人在睡觉时,大多数美国人在工作。
7、当蝴蝶在南半球拍了两下翅膀,他就会稍微飞高一些。
8、据统计:未婚生育的人中有大多数为女性。
9、如果你每天省下来一包烟钱,10天后你就能买10包烟。
10、当你左脸被打,你的左脸就会痛。
11、人被杀,就会死。
12、中国教英语方式有极大错误,在美国就连小学生都能说一口流利的英语。
#485
FunctionListRules.xml拷贝到C:\\Documents and Settings\\Administrator\\Application Data\\Notepad++\\plugins\\config下jquery清空form表单
//在form表单中添加一个隐藏的reset按钮, <button type="reset" style="display:none;"></button> //然后通过trigger来触发reset按钮 $("button[type='reset']").trigger("click");//触发reset按钮 //通过form表单的dom对象的reset方法来清空 $('form')[0].reset();NotePad大小写转换
1、小写转换大写
Ctrl + shift + U
2、大写转换小写
Ctrl + U
注册手机号区号国家号码号段国外国籍外国国旗下拉选择国号字段短信验证码老外
<style>.country em,.u-country em{background:url("https://out.img.pan.lizhenqiu.com/FgA8DLh-5SrtzZ-E8XgTlRBqQZR0") no-repeat;width:16px;height:11px;line-height:11px;display:inline-block;margin-right:0.5em;}.u-country a{position:relative;display:block;height:24px;line-height:24px;overflow:hidden;} .flag-AD em{background-position:0 -594px;} .flag-AE em{background-position:0 -2223px;} .flag-AF em{background-position:0 -2311px;} .flag-AG em{background-position:0 -869px;} .flag-AI em{background-position:0 -1980px;} .flag-AL em{background-position:0 -1034px;} .flag-AM em{background-position:0 -176px;} .flag-AN em{background-position:0 -220px;} .flag-AO em{background-position:0 -1947px;} .flag-AR em{background-position:0 -2377px;} .flag-AT em{background-position:0 -1331px;} .flag-AU em{background-position:0 -1716px;} .flag-AW em{background-position:0 -792px;} .flag-AZ em{background-position:0 -1243px;} .flag-BA em{background-position:0 -1584px;} .flag-BB em{background-position:0 -1573px;} .flag-BD em{background-position:0 -1771px;} .flag-BE em{background-position:0 0px;} .flag-BF em{background-position:0 -726px;} .flag-BG em{background-position:0 -2586px;} .flag-BH em{background-position:0 -1496px;} .flag-BI em{background-position:0 -1892px;} .flag-BJ em{background-position:0 -1298px;} .flag-BM em{background-position:0 -1914px;} .flag-BN em{background-position:0 -1683px;} .flag-BO em{background-position:0 -1650px;} .flag-BR em{background-position:0 -770px;} .flag-BS em{background-position:0 -363px;} .flag-BT em{background-position:0 -1848px;} .flag-BW em{background-position:0 -2707px;} .flag-BY em{background-position:0 -1100px;} .flag-BZ em{background-position:0 -484px;} .flag-CA em{background-position:0 -1375px;} .flag-CD em{background-position:0 -1518px;} .flag-CF em{background-position:0 -1837px;} .flag-CG em{background-position:0 -1793px;} .flag-CH em{background-position:0 -1320px;} .flag-CI em{background-position:0 -1661px;} .flag-CK em{background-position:0 -891px;} .flag-CL em{background-position:0 -1342px;} .flag-CM em{background-position:0 -2057px;} .flag-CN em{background-position:0 -825px;} .flag-CO em{background-position:0 -330px;} .flag-CR em{background-position:0 -2090px;} .flag-CU em{background-position:0 -748px;} .flag-CV em{background-position:0 -2652px;} .flag-CY em{background-position:0 -561px;} .flag-CZ em{background-position:0 -2256px;} .flag-DE em{background-position:0 -2509px;} .flag-DJ em{background-position:0 -2101px;} .flag-DK em{background-position:0 -1386px;} .flag-DM em{background-position:0 -2432px;} .flag-DO em{background-position:0 -1529px;} .flag-DZ em{background-position:0 -528px;} .flag-EC em{background-position:0 -1188px;} .flag-EE em{background-position:0 -2410px;} .flag-EG em{background-position:0 -2201px;} .flag-ER em{background-position:0 -715px;} .flag-ES em{background-position:0 -1155px;} .flag-ET em{background-position:0 -2443px;} .flag-FI em{background-position:0 -1903px;} .flag-FJ em{background-position:0 -1859px;} .flag-FO em{background-position:0 -1111px;} .flag-FR em{background-position:0 -1012px;} .flag-GA em{background-position:0 -880px;} .flag-GB em{background-position:0 -55px;} .flag-GD em{background-position:0 -2399px;} .flag-GE em{background-position:0 -858px;} .flag-GF em{background-position:0 -2234px;} .flag-GH em{background-position:0 -2112px;} .flag-GI em{background-position:0 -275px;} .flag-GL em{background-position:0 -1760px;} .flag-GM em{background-position:0 -627px;} .flag-GN em{background-position:0 -2575px;} .flag-GP em{background-position:0 -407px;} .flag-GQ em{background-position:0 -1507px;} .flag-GR em{background-position:0 -165px;} .flag-GT em{background-position:0 -935px;} .flag-GU em{background-position:0 -2366px;} .flag-GW em{background-position:0 -1925px;} .flag-GY em{background-position:0 -803px;} .flag-HK em{background-position:0 -2696px;} .flag-HN em{background-position:0 -2156px;} .flag-HR em{background-position:0 -902px;} .flag-HT em{background-position:0 -319px;} .flag-HU em{background-position:0 -682px;} .flag-ID em{background-position:0 -1958px;} .flag-IE em{background-position:0 -1969px;} .flag-IL em{background-position:0 -341px;} .flag-IN em{background-position:0 -1694px;} .flag-IQ em{background-position:0 -649px;} .flag-IR em{background-position:0 -2013px;} .flag-IS em{background-position:0 -1991px;} .flag-IT em{background-position:0 -143px;} .flag-JE em{background-position:0 -55px;} .flag-JM em{background-position:0 -1727px;} .flag-JO em{background-position:0 -1463px;} .flag-JP em{background-position:0 -429px;} .flag-KE em{background-position:0 -2630px;} .flag-KG em{background-position:0 -1617px;} .flag-KH em{background-position:0 -242px;} .flag-KM em{background-position:0 -1430px;} .flag-KN em{background-position:0 -99px;} .flag-KP em{background-position:0 -1804px;} .flag-KR em{background-position:0 -2245px;} .flag-KW em{background-position:0 -2487px;} .flag-KY em{background-position:0 -308px;} .flag-KZ em{background-position:0 -1210px;} .flag-LA em{background-position:0 -451px;} .flag-LB em{background-position:0 -1254px;} .flag-LC em{background-position:0 -1397px;} .flag-LI em{background-position:0 -979px;} .flag-LK em{background-position:0 -2641px;} .flag-LR em{background-position:0 -2068px;} .flag-LS em{background-position:0 -2190px;} .flag-LT em{background-position:0 -1122px;} .flag-LU em{background-position:0 -1474px;} .flag-LV em{background-position:0 -1936px;} .flag-LY em{background-position:0 -132px;} .flag-MA em{background-position:0 -2333px;} .flag-MC em{background-position:0 -913px;} .flag-MD em{background-position:0 -2685px;} .flag-ME em{background-position:0 -2167px;} .flag-MG em{background-position:0 -1287px;} .flag-MK em{background-position:0 -1353px;} .flag-ML em{background-position:0 -2520px;} .flag-MN em{background-position:0 -2553px;} .flag-MO em{background-position:0 -2597px;} .flag-MQ em{background-position:0 -198px;} .flag-MR em{background-position:0 -253px;} .flag-MS em{background-position:0 -583px;} .flag-MT em{background-position:0 -1551px;} .flag-MU em{background-position:0 -2179px;} .flag-MV em{background-position:0 -616px;} .flag-MW em{background-position:0 -2145px;} .flag-MX em{background-position:0 -2024px;} .flag-MY em{background-position:0 -1870px;} .flag-MZ em{background-position:0 -638px;} .flag-NA em{background-position:0 -1881px;} .flag-NC em{background-position:0 -1276px;} .flag-NE em{background-position:0 -550px;} .flag-NG em{background-position:0 -2476px;} .flag-NI em{background-position:0 -154px;} .flag-NL em{background-position:0 -1441px;} .flag-NO em{background-position:0 -836px;} .flag-NP em{background-position:0 -110px;} .flag-NZ em{background-position:0 -1540px;} .flag-OM em{background-position:0 -2454px;} .flag-PA em{background-position:0 -847px;} .flag-PE em{background-position:0 -946px;} .flag-PF em{background-position:0 -1705px;} .flag-PG em{background-position:0 -1485px;} .flag-PH em{background-position:0 -1815px;} .flag-PK em{background-position:0 -2035px;} .flag-PL em{background-position:0 -1177px;} .flag-PM em{background-position:0 -1078px;} .flag-PR em{background-position:0 -473px;} .flag-PS em{background-position:0 -1199px;} .flag-PT em{background-position:0 -517px;} .flag-PY em{background-position:0 -2344px;} .flag-QA em{background-position:0 -462px;} .flag-RE em{background-position:0 -264px;} .flag-RO em{background-position:0 -671px;} .flag-RS em{background-position:0 -2465px;} .flag-RU em{background-position:0 -660px;} .flag-RW em{background-position:0 -2674px;} .flag-SA em{background-position:0 -33px;} .flag-SC em{background-position:0 -1045px;} .flag-SD em{background-position:0 -352px;} .flag-SE em{background-position:0 -385px;} .flag-SG em{background-position:0 -22px;} .flag-SI em{background-position:0 -1221px;} .flag-SK em{background-position:0 -2212px;} .flag-SL em{background-position:0 -737px;} .flag-SM em{background-position:0 -2123px;} .flag-SN em{background-position:0 -2134px;} .flag-SO em{background-position:0 -1364px;} .flag-SR em{background-position:0 -2663px;} .flag-SS em{background-position:0 -2718px;} .flag-ST em{background-position:0 -2388px;} .flag-SV em{background-position:0 -1639px;} .flag-SY em{background-position:0 -1826px;} .flag-SZ em{background-position:0 -2278px;} .flag-TC em{background-position:0 -1309px;} .flag-TD em{background-position:0 -814px;} .flag-TG em{background-position:0 -605px;} .flag-TH em{background-position:0 -957px;} .flag-TJ em{background-position:0 -187px;} .flag-TL em{background-position:0 -418px;} .flag-TM em{background-position:0 -2542px;} .flag-TN em{background-position:0 -539px;} .flag-TO em{background-position:0 -1089px;} .flag-TR em{background-position:0 -1606px;} .flag-TT em{background-position:0 -440px;} .flag-TW em{background-position:0 -506px;} .flag-TZ em{background-position:0 -2289px;} .flag-UA em{background-position:0 -2002px;} .flag-UG em{background-position:0 -1166px;} .flag-US em{background-position:0 -44px;} .flag-UY em{background-position:0 -2608px;} .flag-UZ em{background-position:0 -1001px;} .flag-VC em{background-position:0 -2619px;} .flag-VE em{background-position:0 -1056px;} .flag-VG em{background-position:0 -1408px;} .flag-VN em{background-position:0 -968px;} .flag-VU em{background-position:0 -1265px;} .flag-WS em{background-position:0 -2300px;} .flag-YE em{background-position:0 -1672px;} .flag-ZA em{background-position:0 -2355px;} .flag-ZM em{background-position:0 -1595px;} .flag-ZW em{background-position:0 -2046px;} </style> <div class="j-country u-country"> <a href="javascript:void(0);" class="flag-AL" data-code="+355-"><em> </em>阿尔巴尼亚(Shqipëria) +355</a> <a href="javascript:void(0);" class="flag-DZ" data-code="+213-"><em> </em>阿尔及利亚(الجزائر) +213</a> <a href="javascript:void(0);" class="flag-AF" data-code="+93-"><em> </em>阿富汗(افغانستان) +93</a> <a href="javascript:void(0);" class="flag-AR" data-code="+54-"><em> </em>阿根廷(Argentina) +54</a> <a href="javascript:void(0);" class="flag-AE" data-code="+971-"><em> </em>阿拉伯联合大公国(الإمارات العربيّة المتّحدة) +971</a> <a href="javascript:void(0);" class="flag-AW" data-code="+297-"><em> </em>阿鲁巴(Aruba) +297</a> <a href="javascript:void(0);" class="flag-OM" data-code="+968-"><em> </em>阿曼(عمان) +968</a> <a href="javascript:void(0);" class="flag-AZ" data-code="+994-"><em> </em>阿塞拜疆(Azərbaycan) +994</a> <a href="javascript:void(0);" class="flag-EG" data-code="+20-"><em> </em>埃及(مصر) +20</a> <a href="javascript:void(0);" class="flag-ET" data-code="+251-"><em> </em>埃塞俄比亚(Ityop'iya) +251</a> <a href="javascript:void(0);" class="flag-IE" data-code="+353-"><em> </em>爱尔兰(Ireland) +353</a> <a href="javascript:void(0);" class="flag-EE" data-code="+372-"><em> </em>爱沙尼亚(Eesti) +372</a> <a href="javascript:void(0);" class="flag-AD" data-code="+376-"><em> </em>安道尔(Andorra) +376</a> <a href="javascript:void(0);" class="flag-AO" data-code="+244-"><em> </em>安哥拉(Angola) +244</a> <a href="javascript:void(0);" class="flag-AI" data-code="+1264-"><em> </em>安圭拉(Anguilla) +1264</a> <a href="javascript:void(0);" class="flag-AG" data-code="+1268-"><em> </em>安提瓜和巴布达(Antigua and Barbuda) +1268</a> <a href="javascript:void(0);" class="flag-AT" data-code="+43-"><em> </em>奥地利(Österreich) +43</a> <a href="javascript:void(0);" class="flag-AU" data-code="+61-"><em> </em>澳大利亚(Australia) +61</a> <a href="javascript:void(0);" class="flag-MO" data-code="+853-"><em> </em>澳门地区(Macau) +853</a> <a href="javascript:void(0);" class="flag-BB" data-code="+1246-"><em> </em>巴巴多斯(Barbados) +1246</a> <a href="javascript:void(0);" class="flag-PG" data-code="+675-"><em> </em>巴布亚新几内亚 +675</a> <a href="javascript:void(0);" class="flag-BS" data-code="+1242-"><em> </em>巴哈马(Bahamas) +1242</a> <a href="javascript:void(0);" class="flag-PK" data-code="+92-"><em> </em>巴基斯坦(پاکستان) +92</a> <a href="javascript:void(0);" class="flag-PY" data-code="+595-"><em> </em>巴拉圭(Paraguay) +595</a> <a href="javascript:void(0);" class="flag-PS" data-code="+970-"><em> </em>巴勒斯坦领土(Palestinian Territories) +970</a> <a href="javascript:void(0);" class="flag-BH" data-code="+973-"><em> </em>巴林(البحرين) +973</a> <a href="javascript:void(0);" class="flag-PA" data-code="+507-"><em> </em>巴拿马(Panamá) +507</a> <a href="javascript:void(0);" class="flag-BR" data-code="+55-"><em> </em>巴西(Brasil) +55</a> <a href="javascript:void(0);" class="flag-BY" data-code="+375-"><em> </em>白俄罗斯(Белару́сь) +375</a> <a href="javascript:void(0);" class="flag-BM" data-code="+1441-"><em> </em>百慕大(Bermuda) +1441</a> <a href="javascript:void(0);" class="flag-BG" data-code="+359-"><em> </em>保加利亚(България) +359</a> <a href="javascript:void(0);" class="flag-BJ" data-code="+229-"><em> </em>贝宁(Bénin) +229</a> <a href="javascript:void(0);" class="flag-BE" data-code="+32-"><em> </em>比利时(België) +32</a> <a href="javascript:void(0);" class="flag-IS" data-code="+354-"><em> </em>冰岛(Ísland) +354</a> <a href="javascript:void(0);" class="flag-PR" data-code="+1787-"><em> </em>波多黎各(Puerto Rico) +1787</a> <a href="javascript:void(0);" class="flag-PL" data-code="+48-"><em> </em>波兰 +48</a> <a href="javascript:void(0);" class="flag-BA" data-code="+387-"><em> </em>波斯尼亚和黑塞哥维那(Bosna i Hercegovina) +387</a> <a href="javascript:void(0);" class="flag-BO" data-code="+591-"><em> </em>玻利维亚(Bolivia) +591</a> <a href="javascript:void(0);" class="flag-BZ" data-code="+501-"><em> </em>伯利兹(Belize) +501</a> <a href="javascript:void(0);" class="flag-BW" data-code="+267-"><em> </em>博茨瓦纳(Botswana) +267</a> <a href="javascript:void(0);" class="flag-BT" data-code="+975-"><em> </em>不丹(འབྲུག་ཡུལ་) +975</a> <a href="javascript:void(0);" class="flag-BF" data-code="+226-"><em> </em>布基纳法索(Burkina Faso) +226</a> <a href="javascript:void(0);" class="flag-BI" data-code="+257-"><em> </em>布隆迪(Uburundi) +257</a> <a href="javascript:void(0);" class="flag-KP" data-code="+850-"><em> </em>朝鲜 +850</a> <a href="javascript:void(0);" class="flag-GQ" data-code="+240-"><em> </em>赤道几内亚(Guinea Ecuatorial) +240</a> <a href="javascript:void(0);" class="flag-DK" data-code="+45-"><em> </em>丹麦(Danmark) +45</a> <a href="javascript:void(0);" class="flag-DE" data-code="+49-"><em> </em>德国(Deutschland) +49</a> <a href="javascript:void(0);" class="flag-TL" data-code="+670-"><em> </em>东帝汶 +670</a> <a href="javascript:void(0);" class="flag-TG" data-code="+228-"><em> </em>多哥(Togo) +228</a> <a href="javascript:void(0);" class="flag-DM" data-code="+1767-"><em> </em>多米尼加(Dominica) +1767</a> <a href="javascript:void(0);" class="flag-DO" data-code="+1809-"><em> </em>多明尼加共和国(Dominican Republic) +1809</a> <a href="javascript:void(0);" class="flag-RU" data-code="+7-"><em> </em>俄罗斯(Россия) +7</a> <a href="javascript:void(0);" class="flag-EC" data-code="+593-"><em> </em>厄瓜多尔(Ecuador) +593</a> <a href="javascript:void(0);" class="flag-ER" data-code="+291-"><em> </em>厄立特里亚(Ertra) +291</a> <a href="javascript:void(0);" class="flag-FR" data-code="+33-"><em> </em>法国(France) +33</a> <a href="javascript:void(0);" class="flag-FO" data-code="+298-"><em> </em>法罗群岛(Faroe Islands) +298</a> <a href="javascript:void(0);" class="flag-PF" data-code="+689-"><em> </em>法属波利尼西亚(French Polynesia) +689</a> <a href="javascript:void(0);" class="flag-GF" data-code="+594-"><em> </em>法属圭亚那(French Guiana) +594</a> <a href="javascript:void(0);" class="flag-PH" data-code="+63-"><em> </em>菲律宾 +63</a> <a href="javascript:void(0);" class="flag-FJ" data-code="+679-"><em> </em>斐济(Fiji) +679</a> <a href="javascript:void(0);" class="flag-FI" data-code="+358-"><em> </em>芬兰(Suomi) +358</a> <a href="javascript:void(0);" class="flag-CV" data-code="+238-"><em> </em>佛得角(Cabo Verde) +238</a> <a href="javascript:void(0);" class="flag-GM" data-code="+220-"><em> </em>冈比亚(Gambia) +220</a> <a href="javascript:void(0);" class="flag-CG" data-code="+242-"><em> </em>刚果共和国(Congo [Republic]) +242</a> <a href="javascript:void(0);" class="flag-CD" data-code="+243-"><em> </em>刚果民主共和国(Congo [DRC]) +243</a> <a href="javascript:void(0);" class="flag-CO" data-code="+57-"><em> </em>哥伦比亚(Colombia) +57</a> <a href="javascript:void(0);" class="flag-CR" data-code="+506-"><em> </em>哥斯达黎加(Costa Rica) +506</a> <a href="javascript:void(0);" class="flag-GD" data-code="+1473-"><em> </em>格林纳达(Grenada) +1473</a> <a href="javascript:void(0);" class="flag-GL" data-code="+299-"><em> </em>格陵兰(Greenland) +299</a> <a href="javascript:void(0);" class="flag-GE" data-code="+995-"><em> </em>格鲁吉亚(საქართველო) +995</a> <a href="javascript:void(0);" class="flag-CU" data-code="+53-"><em> </em>古巴(Cuba) +53</a> <a href="javascript:void(0);" class="flag-GP" data-code="+590-"><em> </em>瓜德罗普岛(Guadeloupe) +590</a> <a href="javascript:void(0);" class="flag-GU" data-code="+1671-"><em> </em>关岛(Guam) +1671</a> <a href="javascript:void(0);" class="flag-GY" data-code="+592-"><em> </em>圭亚那(Guyana) +592</a> <a href="javascript:void(0);" class="flag-KZ" data-code="+7-"><em> </em>哈萨克斯坦(Россия) +7</a> <a href="javascript:void(0);" class="flag-HT" data-code="+509-"><em> </em>海地(Haïti) +509</a> <a href="javascript:void(0);" class="flag-KR" data-code="+82-"><em> </em>韩国(한국) +82</a> <a href="javascript:void(0);" class="flag-NL" data-code="+31-"><em> </em>荷兰(Nederland) +31</a> <a href="javascript:void(0);" class="flag-AN" data-code="+599-"><em> </em>荷属安的列斯群岛(Netherlands Antilles) +599</a> <a href="javascript:void(0);" class="flag-ME" data-code="+382-"><em> </em>黑山(Црна Гора) +382</a> <a href="javascript:void(0);" class="flag-HN" data-code="+504-"><em> </em>洪都拉斯(Honduras) +504</a> <a href="javascript:void(0);" class="flag-DJ" data-code="+253-"><em> </em>吉布提(Djibouti) +253</a> <a href="javascript:void(0);" class="flag-KG" data-code="+996-"><em> </em>吉尔吉斯斯坦(Кыргызстан) +996</a> <a href="javascript:void(0);" class="flag-GN" data-code="+224-"><em> </em>几内亚(Guinée) +224</a> <a href="javascript:void(0);" class="flag-GW" data-code="+245-"><em> </em>几内亚比绍 +245</a> <a href="javascript:void(0);" class="flag-CA" data-code="+1-"><em> </em>加拿大(United States) +1</a> <a href="javascript:void(0);" class="flag-GH" data-code="+233-"><em> </em>加纳(Ghana) +233</a> <a href="javascript:void(0);" class="flag-GA" data-code="+241-"><em> </em>加蓬(Gabon) +241</a> <a href="javascript:void(0);" class="flag-KH" data-code="+855-"><em> </em>柬埔寨(Kampuchea) +855</a> <a href="javascript:void(0);" class="flag-CZ" data-code="+420-"><em> </em>捷克共和国(Česko) +420</a> <a href="javascript:void(0);" class="flag-ZW" data-code="+263-"><em> </em>津巴布韦(Zimbabwe) +263</a> <a href="javascript:void(0);" class="flag-CM" data-code="+237-"><em> </em>喀麦隆(Cameroun) +237</a> <a href="javascript:void(0);" class="flag-QA" data-code="+974-"><em> </em>卡塔尔(قطر) +974</a> <a href="javascript:void(0);" class="flag-KY" data-code="+1345-"><em> </em>开曼群岛(Cayman Islands) +1345</a> <a href="javascript:void(0);" class="flag-KM" data-code="+269-"><em> </em>科摩罗(Comoros) +269</a> <a href="javascript:void(0);" class="flag-KW" data-code="+965-"><em> </em>科威特(الكويت) +965</a> <a href="javascript:void(0);" class="flag-HR" data-code="+385-"><em> </em>克罗地亚(Hrvatska) +385</a> <a href="javascript:void(0);" class="flag-KE" data-code="+254-"><em> </em>肯尼亚(Kenya) +254</a> <a href="javascript:void(0);" class="flag-CK" data-code="+682-"><em> </em>库克群岛 +682</a> <a href="javascript:void(0);" class="flag-LV" data-code="+371-"><em> </em>拉脱维亚(Latvija) +371</a> <a href="javascript:void(0);" class="flag-LS" data-code="+266-"><em> </em>莱索托(Lesotho) +266</a> <a href="javascript:void(0);" class="flag-LA" data-code="+856-"><em> </em>老挝(ປະຊາຊົນສປປລາວ) +856</a> <a href="javascript:void(0);" class="flag-LB" data-code="+961-"><em> </em>黎巴嫩(لبنان) +961</a> <a href="javascript:void(0);" class="flag-LT" data-code="+370-"><em> </em>立陶宛(Lietuva) +370</a> <a href="javascript:void(0);" class="flag-LR" data-code="+231-"><em> </em>利比里亚(Liberia) +231</a> <a href="javascript:void(0);" class="flag-LY" data-code="+218-"><em> </em>利比亚(ليبيا) +218</a> <a href="javascript:void(0);" class="flag-LI" data-code="+423-"><em> </em>列支敦士登(Liechtenstein) +423</a> <a href="javascript:void(0);" class="flag-RE" data-code="+262-"><em> </em>留尼旺岛(Réunion) +262</a> <a href="javascript:void(0);" class="flag-LU" data-code="+352-"><em> </em>卢森堡(Lëtzebuerg) +352</a> <a href="javascript:void(0);" class="flag-RW" data-code="+250-"><em> </em>卢旺达(Rwanda) +250</a> <a href="javascript:void(0);" class="flag-RO" data-code="+40-"><em> </em>罗马尼亚(România) +40</a> <a href="javascript:void(0);" class="flag-MG" data-code="+261-"><em> </em>马达加斯加(Madagasikara) +261</a> <a href="javascript:void(0);" class="flag-MV" data-code="+960-"><em> </em>马尔代夫(ގުޖޭއްރާ ޔާއްރިހޫމްޖ) +960</a> <a href="javascript:void(0);" class="flag-MT" data-code="+356-"><em> </em>马耳他(Malta) +356</a> <a href="javascript:void(0);" class="flag-MW" data-code="+265-"><em> </em>马拉维(Malawi) +265</a> <a href="javascript:void(0);" class="flag-MY" data-code="+60-"><em> </em>马来西亚(Malaysia) +60</a> <a href="javascript:void(0);" class="flag-ML" data-code="+223-"><em> </em>马里(Mali) +223</a> <a href="javascript:void(0);" class="flag-MK" data-code="+389-"><em> </em>马其顿(Македонија) +389</a> <a href="javascript:void(0);" class="flag-MQ" data-code="+596-"><em> </em>马提尼克(Martinique) +596</a> <a href="javascript:void(0);" class="flag-MU" data-code="+230-"><em> </em>毛里求斯(Mauritius) +230</a> <a href="javascript:void(0);" class="flag-MR" data-code="+222-"><em> </em>毛里塔尼亚(موريتانيا) +222</a> <a href="javascript:void(0);" class="flag-US" data-code="+1-"><em> </em>美国(United States) +1</a> <a href="javascript:void(0);" class="flag-MN" data-code="+976-"><em> </em>蒙古(Монгол Улс) +976</a> <a href="javascript:void(0);" class="flag-MS" data-code="+1664-"><em> </em>蒙特塞拉特(Montserrat) +1664</a> <a href="javascript:void(0);" class="flag-BD" data-code="+880-"><em> </em>孟加拉国(বাংলাদেশ) +880</a> <a href="javascript:void(0);" class="flag-PE" data-code="+51-"><em> </em>秘鲁(Perú) +51</a> <a href="javascript:void(0);" class="flag-MD" data-code="+373-"><em> </em>摩尔多瓦(Moldova) +373</a> <a href="javascript:void(0);" class="flag-MA" data-code="+212-"><em> </em>摩洛哥(المغرب) +212</a> <a href="javascript:void(0);" class="flag-MC" data-code="+377-"><em> </em>摩纳哥(Monaco) +377</a> <a href="javascript:void(0);" class="flag-MZ" data-code="+258-"><em> </em>莫桑比克(Moçambique) +258</a> <a href="javascript:void(0);" class="flag-MX" data-code="+52-"><em> </em>墨西哥(México) +52</a> <a href="javascript:void(0);" class="flag-NA" data-code="+264-"><em> </em>纳米比亚(Namibia) +264</a> <a href="javascript:void(0);" class="flag-ZA" data-code="+27-"><em> </em>南非(South Africa) +27</a> <a href="javascript:void(0);" class="flag-SS" data-code="+211-"><em> </em>南苏丹 +211</a> <a href="javascript:void(0);" class="flag-NP" data-code="+977-"><em> </em>尼泊尔(नेपाल) +977</a> <a href="javascript:void(0);" class="flag-NI" data-code="+505-"><em> </em>尼加拉瓜(Nicaragua) +505</a> <a href="javascript:void(0);" class="flag-NE" data-code="+227-"><em> </em>尼日尔(Niger) +227</a> <a href="javascript:void(0);" class="flag-NG" data-code="+234-"><em> </em>尼日利亚(Nigeria) +234</a> <a href="javascript:void(0);" class="flag-NO" data-code="+47-"><em> </em>挪威(Norge) +47</a> <a href="javascript:void(0);" class="flag-PT" data-code="+351-"><em> </em>葡萄牙(Portugal) +351</a> <a href="javascript:void(0);" class="flag-JP" data-code="+81-"><em> </em>日本(にっぽんこく,にほんこく) +81</a> <a href="javascript:void(0);" class="flag-SE" data-code="+46-"><em> </em>瑞典(Sverige) +46</a> <a href="javascript:void(0);" class="flag-CH" data-code="+41-"><em> </em>瑞士(Schweiz) +41</a> <a href="javascript:void(0);" class="flag-SV" data-code="+503-"><em> </em>萨尔瓦多(El Salvador) +503</a> <a href="javascript:void(0);" class="flag-WS" data-code="+685-"><em> </em>萨摩亚(Samoa) +685</a> <a href="javascript:void(0);" class="flag-RS" data-code="+381-"><em> </em>塞尔维亚(Србија) +381</a> <a href="javascript:void(0);" class="flag-SL" data-code="+232-"><em> </em>塞拉利昂(Sierra Leone) +232</a> <a href="javascript:void(0);" class="flag-SN" data-code="+221-"><em> </em>塞内加尔(Sénégal) +221</a> <a href="javascript:void(0);" class="flag-CY" data-code="+357-"><em> </em>塞浦路斯(Κυπρος) +357</a> <a href="javascript:void(0);" class="flag-SC" data-code="+248-"><em> </em>塞舌尔(Seychelles) +248</a> <a href="javascript:void(0);" class="flag-SA" data-code="+966-"><em> </em>沙特阿拉伯(المملكة العربية السعودية) +966</a> <a href="javascript:void(0);" class="flag-ST" data-code="+239-"><em> </em>圣多美和普林西比 +239</a> <a href="javascript:void(0);" class="flag-KN" data-code="+1869-"><em> </em>圣基茨和尼维斯(Saint Kitts and Nevis) +1869</a> <a href="javascript:void(0);" class="flag-LC" data-code="+1758-"><em> </em>圣卢西亚(Saint Lucia) +1758</a> <a href="javascript:void(0);" class="flag-SM" data-code="+378-"><em> </em>圣马力诺(San Marino) +378</a> <a href="javascript:void(0);" class="flag-PM" data-code="+508-"><em> </em>圣皮埃尔和密克隆群岛(Saint Pierre and Miquelon) +508</a> <a href="javascript:void(0);" class="flag-VC" data-code="+1784-"><em> </em>圣文森特和格林纳丁斯(Saint Vincent and the Grenadines) +1784</a> <a href="javascript:void(0);" class="flag-LK" data-code="+94-"><em> </em>斯里兰卡(Sri Lanka) +94</a> <a href="javascript:void(0);" class="flag-SK" data-code="+421-"><em> </em>斯洛伐克(Slovensko) +421</a> <a href="javascript:void(0);" class="flag-SI" data-code="+386-"><em> </em>斯洛文尼亚(Slovenija) +386</a> <a href="javascript:void(0);" class="flag-SZ" data-code="+268-"><em> </em>斯威士兰(Swaziland) +268</a> <a href="javascript:void(0);" class="flag-SD" data-code="+249-"><em> </em>苏丹(السودان) +249</a> <a href="javascript:void(0);" class="flag-SR" data-code="+597-"><em> </em>苏里南(Suriname) +597</a> <a href="javascript:void(0);" class="flag-SO" data-code="+252-"><em> </em>索马里(Soomaaliya) +252</a> <a href="javascript:void(0);" class="flag-TJ" data-code="+992-"><em> </em>塔吉克斯坦(Тоҷикистон) +992</a> <a href="javascript:void(0);" class="flag-TW" data-code="+886-"><em> </em>台湾地区(台灣) +886</a> <a href="javascript:void(0);" class="flag-TH" data-code="+66-"><em> </em>泰国(ราชอาณาจักรไทย) +66</a> <a href="javascript:void(0);" class="flag-TZ" data-code="+255-"><em> </em>坦桑尼亚(Tanzania) +255</a> <a href="javascript:void(0);" class="flag-TO" data-code="+676-"><em> </em>汤加(Tonga) +676</a> <a href="javascript:void(0);" class="flag-TC" data-code="+1649-"><em> </em>特克斯和凯科斯群岛(Turks and Caicos Islands) +1649</a> <a href="javascript:void(0);" class="flag-TT" data-code="+1868-"><em> </em>特里尼达和多巴哥(Trinidad and Tobago) +1868</a> <a href="javascript:void(0);" class="flag-TN" data-code="+216-"><em> </em>突尼斯(تونس) +216</a> <a href="javascript:void(0);" class="flag-TR" data-code="+90-"><em> </em>土耳其(Türkiye) +90</a> <a href="javascript:void(0);" class="flag-TM" data-code="+993-"><em> </em>土库曼斯坦(Türkmenistan) +993</a> <a href="javascript:void(0);" class="flag-VU" data-code="+678-"><em> </em>瓦努阿图(Vanuatu) +678</a> <a href="javascript:void(0);" class="flag-GT" data-code="+502-"><em> </em>危地马拉(Guatemala) +502</a> <a href="javascript:void(0);" class="flag-VE" data-code="+58-"><em> </em>委内瑞拉(Venezuela) +58</a> <a href="javascript:void(0);" class="flag-BN" data-code="+673-"><em> </em>文莱(Brunei Darussalam) +673</a> <a href="javascript:void(0);" class="flag-UG" data-code="+256-"><em> </em>乌干达(Uganda) +256</a> <a href="javascript:void(0);" class="flag-UA" data-code="+380-"><em> </em>乌克兰(Україна) +380</a> <a href="javascript:void(0);" class="flag-UY" data-code="+598-"><em> </em>乌拉圭(Uruguay) +598</a> <a href="javascript:void(0);" class="flag-UZ" data-code="+998-"><em> </em>乌兹别克斯坦(O'zbekiston) +998</a> <a href="javascript:void(0);" class="flag-ES" data-code="+34-"><em> </em>西班牙(España) +34</a> <a href="javascript:void(0);" class="flag-GR" data-code="+30-"><em> </em>希腊(Ελλάς) +30</a> <a href="javascript:void(0);" class="flag-HK" data-code="+852-"><em> </em>香港地区(Hong Kong) +852</a> <a href="javascript:void(0);" class="flag-CI" data-code="+225-"><em> </em>象牙海岸(Côte d'Ivoire) +225</a> <a href="javascript:void(0);" class="flag-SG" data-code="+65-"><em> </em>新加坡(Singapura) +65</a> <a href="javascript:void(0);" class="flag-NC" data-code="+687-"><em> </em>新喀里多尼亚(New Caledonia) +687</a> <a href="javascript:void(0);" class="flag-NZ" data-code="+64-"><em> </em>新西兰(New Zealand) +64</a> <a href="javascript:void(0);" class="flag-HU" data-code="+36-"><em> </em>匈牙利(Magyarország) +36</a> <a href="javascript:void(0);" class="flag-SY" data-code="+963-"><em> </em>叙利亚(سوريا) +963</a> <a href="javascript:void(0);" class="flag-JM" data-code="+1876-"><em> </em>牙买加(Jamaica) +1876</a> <a href="javascript:void(0);" class="flag-AM" data-code="+374-"><em> </em>亚美尼亚(Հայաստան) +374</a> <a href="javascript:void(0);" class="flag-YE" data-code="+967-"><em> </em>也门(اليمن) +967</a> <a href="javascript:void(0);" class="flag-IQ" data-code="+964-"><em> </em>伊拉克(العراق) +964</a> <a href="javascript:void(0);" class="flag-IR" data-code="+98-"><em> </em>伊朗(ایران) +98</a> <a href="javascript:void(0);" class="flag-IL" data-code="+972-"><em> </em>以色列(ישראל) +972</a> <a href="javascript:void(0);" class="flag-IT" data-code="+39-"><em> </em>意大利(Italia) +39</a> <a href="javascript:void(0);" class="flag-IN" data-code="+91-"><em> </em>印度(India) +91</a> <a href="javascript:void(0);" class="flag-ID" data-code="+62-"><em> </em>印尼(Indonesia) +62</a> <a href="javascript:void(0);" class="flag-GB" data-code="+44-"><em> </em>英国(United Kingdom) +44</a> <a href="javascript:void(0);" class="flag-VG" data-code="+1340-"><em> </em>英属维尔京群岛(U.S. Virgin Islands) +1340</a> <a href="javascript:void(0);" class="flag-JO" data-code="+962-"><em> </em>约旦(الاردن) +962</a> <a href="javascript:void(0);" class="flag-VN" data-code="+84-"><em> </em>越南(Việt Nam) +84</a> <a href="javascript:void(0);" class="flag-ZM" data-code="+260-"><em> </em>赞比亚(Zambia) +260</a> <a href="javascript:void(0);" class="flag-JE" data-code="+44-"><em> </em>泽西岛(United Kingdom) +44</a> <a href="javascript:void(0);" class="flag-TD" data-code="+235-"><em> </em>乍得(Tchad) +235</a> <a href="javascript:void(0);" class="flag-GI" data-code="+350-"><em> </em>直布罗陀(Gibraltar) +350</a> <a href="javascript:void(0);" class="flag-CL" data-code="+56-"><em> </em>智利(Chile) +56</a> <a href="javascript:void(0);" class="flag-CF" data-code="+236-"><em> </em>中非共和国(République Centrafricaine) +236</a> </div>#486
基本图片处理,用于完成图片缩入,水印添加,当水印图超过目标图片尺寸时,水印图能自动适应目标图片而缩小,水印图可以设置跟背景的合并度
<?php /** * 基本图片处理,用于完成图片缩入,水印添加 * 当水印图超过目标图片尺寸时,水印图能自动适应目标图片而缩小 * 水印图可以设置跟背景的合并度 * * Copyright(c) 2005 by ustb99. All rights reserved * * To contact the author write to {@link mailto:ustb80@163.com} * * @author 偶然 * @version $Id: thumb.class.php,v 1.9 2006/09/30 09:31:56 zengjian Exp $ * @package system */ /** * ThumbHandler * @access public */ /* 使用方法: 自动裁切: 程序会按照图片的尺寸从中部裁切最大的正方形,并按目标尺寸进行缩略 $t->setSrcImg("img/test.jpg"); $t->setCutType(1);//这一句就OK了 $t->setDstImg("tmp/new_test.jpg"); $t->createImg(60,60); 手工裁切: 程序会按照指定的位置从源图上取图 $t->setSrcImg("img/test.jpg"); $t->setCutType(2);//指明为手工裁切 $t->setSrcCutPosition(100, 100);// 源图起点坐标 $t->setRectangleCut(300, 200);// 裁切尺寸 $t->setDstImg("tmp/new_test.jpg"); $t->createImg(300,200); */ class ThumbHandler { var $dst_img;// 目标文件 var $h_src; // 图片资源句柄 var $h_dst;// 新图句柄 var $h_mask;// 水印句柄 var $img_create_quality = 100;// 图片生成质量 var $img_display_quality = 80;// 图片显示质量,默认为75 var $img_scale = 0;// 图片缩放比例 var $src_w = 0;// 原图宽度 var $src_h = 0;// 原图高度 var $dst_w = 0;// 新图总宽度 var $dst_h = 0;// 新图总高度 var $fill_w;// 填充图形宽 var $fill_h;// 填充图形高 var $copy_w;// 拷贝图形宽 var $copy_h;// 拷贝图形高 var $src_x = 0;// 原图绘制起始横坐标 var $src_y = 0;// 原图绘制起始纵坐标 var $start_x;// 新图绘制起始横坐标 var $start_y;// 新图绘制起始纵坐标 var $mask_word;// 水印文字 var $mask_img;// 水印图片 var $mask_pos_x = 0;// 水印横坐标 var $mask_pos_y = 0;// 水印纵坐标 var $mask_offset_x = 5;// 水印横向偏移 var $mask_offset_y = 5;// 水印纵向偏移 var $font_w;// 水印字体宽 var $font_h;// 水印字体高 var $mask_w;// 水印宽 var $mask_h;// 水印高 var $mask_font_color = "#ffffff";// 水印文字颜色 var $mask_font = 2;// 水印字体 var $font_size;// 尺寸 var $mask_position = 0;// 水印位置 var $mask_img_pct = 50;// 图片合并程度,值越大,合并程序越低 var $mask_txt_pct = 50;// 文字合并程度,值越小,合并程序越低 var $img_border_size = 0;// 图片边框尺寸 var $img_border_color;// 图片边框颜色 var $_flip_x=0;// 水平翻转次数 var $_flip_y=0;// 垂直翻转次数 var $cut_type=0;// 剪切类型 var $img_type;// 文件类型 // 文件类型定义,并指出了输出图片的函数 var $all_type = array( "jpg" => array("output"=>"imagejpeg"), "gif" => array("output"=>"imagegif"), "png" => array("output"=>"imagepng"), "wbmp" => array("output"=>"image2wbmp"), "jpeg" => array("output"=>"imagejpeg")); /** * 构造函数 */ function ThumbHandler() { $this->mask_font_color = "#ffffff"; $this->font = 2; $this->font_size = 12; } /** * 取得图片的宽 */ function getImgWidth($src) { return imagesx($src); } /** * 取得图片的高 */ function getImgHeight($src) { return imagesy($src); } /** * 设置图片生成路径 * * @param string $src_img 图片生成路径 */ function setSrcImg($src_img, $img_type=null) { if(!file_exists($src_img)) { die("图片不存在"); } if(!emptyempty($img_type)) { $this->img_type = $img_type; } else { $this->img_type = $this->_getImgType($src_img); } $this->_checkValid($this->img_type); // file_get_contents函数要求php版本>4.3.0 $src = ''; if(function_exists("file_get_contents")) { $src = file_get_contents($src_img); } else { $handle = fopen ($src_img, "r"); while (!feof ($handle)) { $src .= fgets($fd, 4096); } fclose ($handle); } if(emptyempty($src)) { die("图片源为空"); } $this->h_src = @ImageCreateFromString($src); $this->src_w = $this->getImgWidth($this->h_src); $this->src_h = $this->getImgHeight($this->h_src); } /** * 设置图片生成路径 * * @param string $dst_img 图片生成路径 */ function setDstImg($dst_img) { $arr = explode('/',$dst_img); $last = array_pop($arr); $path = implode('/',$arr); $this->_mkdirs($path); $this->dst_img = $dst_img; } /** * 设置图片的显示质量 * * @param string $n 质量 */ function setImgDisplayQuality($n) { $this->img_display_quality = (int)$n; } /** * 设置图片的生成质量 * * @param string $n 质量 */ function setImgCreateQuality($n) { $this->img_create_quality = (int)$n; } /** * 设置文字水印 * * @param string $word 水印文字 * @param integer $font 水印字体 * @param string $color 水印字体颜色 */ function setMaskWord($word) { $this->mask_word .= $word; } /** * 设置字体颜色 * * @param string $color 字体颜色 */ function setMaskFontColor($color="#ffffff") { $this->mask_font_color = $color; } /** * 设置水印字体 * * @param string|integer $font 字体 */ function setMaskFont($font=2) { if(!is_numeric($font) && !file_exists($font)) { die("字体文件不存在"); } $this->font = $font; } /** * 设置文字字体大小,仅对truetype字体有效 */ function setMaskFontSize($size = "12") { $this->font_size = $size; } /** * 设置图片水印 * * @param string $img 水印图片源 */ function setMaskImg($img) { $this->mask_img = $img; } /** * 设置水印横向偏移 * * @param integer $x 横向偏移量 */ function setMaskOffsetX($x) { $this->mask_offset_x = (int)$x; } /** * 设置水印纵向偏移 * * @param integer $y 纵向偏移量 */ function setMaskOffsetY($y) { $this->mask_offset_y = (int)$y; } /** * 指定水印位置 * * @param integer $position 位置,1:左上,2:左下,3:右上,0/4:右下 */ function setMaskPosition($position=0) { $this->mask_position = (int)$position; } /** * 设置图片合并程度 * * @param integer $n 合并程度 */ function setMaskImgPct($n) { $this->mask_img_pct = (int)$n; } /** * 设置文字合并程度 * * @param integer $n 合并程度 */ function setMaskTxtPct($n) { $this->mask_txt_pct = (int)$n; } /** * 设置缩略图边框 * * @param (类型) (参数名) (描述) */ function setDstImgBorder($size=1, $color="#000000") { $this->img_border_size = (int)$size; $this->img_border_color = $color; } /** * 水平翻转 */ function flipH() { $this->_flip_x++; } /** * 垂直翻转 */ function flipV() { $this->_flip_y++; } /** * 设置剪切类型 * * @param (类型) (参数名) (描述) */ function setCutType($type) { $this->cut_type = (int)$type; } /** * 设置图片剪切 * * @param integer $width 矩形剪切 */ function setRectangleCut($width, $height) { $this->fill_w = (int)$width; $this->fill_h = (int)$height; } /** * 设置源图剪切起始坐标点 * * @param (类型) (参数名) (描述) */ function setSrcCutPosition($x, $y) { $this->src_x = (int)$x; $this->src_y = (int)$y; } /** * 创建图片,主函数 * @param integer $a 当缺少第二个参数时,此参数将用作百分比, * 否则作为宽度值 * @param integer $b 图片缩放后的高度 */ function createImg($a, $b=null) { $num = func_num_args(); if(1 == $num) { $r = (int)$a; if($r < 1) { die("图片缩放比例不得小于1"); } $this->img_scale = $r; $this->_setNewImgSize($r); } if(2 == $num) { $w = (int)$a; $h = (int)$b; if(0 == $w) { die("目标宽度不能为0"); } if(0 == $h) { die("目标高度不能为0"); } $this->_setNewImgSize($w, $h); } if($this->_flip_x%2!=0) { $this->_flipH($this->h_src); } if($this->_flip_y%2!=0) { $this->_flipV($this->h_src); } $this->_createMask(); $this->_output(); // 释放 if(imagedestroy($this->h_src) && imagedestroy($this->h_dst)) { Return true; } else { Return false; } } /** * 生成水印,调用了生成水印文字和水印图片两个方法 */ function _createMask() { if($this->mask_word) { // 获取字体信息 $this->_setFontInfo(); if($this->_isFull()) { die("水印文字过大"); } else { $this->h_dst = imagecreatetruecolor($this->dst_w, $this->dst_h); $white = ImageColorAllocate($this->h_dst,255,255,255); imagefilledrectangle($this->h_dst,0,0,$this->dst_w,$this->dst_h,$white);// 填充背景色 $this->_drawBorder(); imagecopyresampled( $this->h_dst, $this->h_src, $this->start_x, $this->start_y, $this->src_x, $this->src_y, $this->fill_w, $this->fill_h, $this->copy_w, $this->copy_h); $this->_createMaskWord($this->h_dst); } } if($this->mask_img) { $this->_loadMaskImg();//加载时,取得宽高 if($this->_isFull()) { // 将水印生成在原图上再拷 $this->_createMaskImg($this->h_src); $this->h_dst = imagecreatetruecolor($this->dst_w, $this->dst_h); $white = ImageColorAllocate($this->h_dst,255,255,255); imagefilledrectangle($this->h_dst,0,0,$this->dst_w,$this->dst_h,$white);// 填充背景色 $this->_drawBorder(); imagecopyresampled( $this->h_dst, $this->h_src, $this->start_x, $this->start_y, $this->src_x, $this->src_y, $this->fill_w, $this->start_y, $this->copy_w, $this->copy_h); } else { // 创建新图并拷贝 $this->h_dst = imagecreatetruecolor($this->dst_w, $this->dst_h); $white = ImageColorAllocate($this->h_dst,255,255,255); imagefilledrectangle($this->h_dst,0,0,$this->dst_w,$this->dst_h,$white);// 填充背景色 $this->_drawBorder(); imagecopyresampled( $this->h_dst, $this->h_src, $this->start_x, $this->start_y, $this->src_x, $this->src_y, $this->fill_w, $this->fill_h, $this->copy_w, $this->copy_h); $this->_createMaskImg($this->h_dst); } } if(emptyempty($this->mask_word) && emptyempty($this->mask_img)) { $this->h_dst = imagecreatetruecolor($this->dst_w, $this->dst_h); $white = ImageColorAllocate($this->h_dst,255,255,255); imagefilledrectangle($this->h_dst,0,0,$this->dst_w,$this->dst_h,$white);// 填充背景色 $this->_drawBorder(); imagecopyresampled( $this->h_dst, $this->h_src, $this->start_x, $this->start_y, $this->src_x, $this->src_y, $this->fill_w, $this->fill_h, $this->copy_w, $this->copy_h); } } /** * 画边框 */ function _drawBorder() { if(!emptyempty($this->img_border_size)) { $c = $this->_parseColor($this->img_border_color); $color = ImageColorAllocate($this->h_src,$c[0], $c[1], $c[2]); imagefilledrectangle($this->h_dst,0,0,$this->dst_w,$this->dst_h,$color);// 填充背景色 } } /** * 生成水印文字 */ function _createMaskWord($src) { $this->_countMaskPos(); $this->_checkMaskValid(); $c = $this->_parseColor($this->mask_font_color); $color = imagecolorallocatealpha($src, $c[0], $c[1], $c[2], $this->mask_txt_pct); if(is_numeric($this->font)) { imagestring($src, $this->font, $this->mask_pos_x, $this->mask_pos_y, $this->mask_word, $color); } else { imagettftext($src, $this->font_size, 0, $this->mask_pos_x, $this->mask_pos_y, $color, $this->font, $this->mask_word); } } /** * 生成水印图 */ function _createMaskImg($src) { $this->_countMaskPos(); $this->_checkMaskValid(); imagecopymerge($src, $this->h_mask, $this->mask_pos_x ,$this->mask_pos_y, 0, 0, $this->mask_w, $this->mask_h, $this->mask_img_pct); imagedestroy($this->h_mask); } /** * 加载水印图 */ function _loadMaskImg() { $mask_type = $this->_getImgType($this->mask_img); $this->_checkValid($mask_type); // file_get_contents函数要求php版本>4.3.0 $src = ''; if(function_exists("file_get_contents")) { $src = file_get_contents($this->mask_img); } else { $handle = fopen ($this->mask_img, "r"); while (!feof ($handle)) { $src .= fgets($fd, 4096); } fclose ($handle); } if(emptyempty($this->mask_img)) { die("水印图片为空"); } $this->h_mask = ImageCreateFromString($src); $this->mask_w = $this->getImgWidth($this->h_mask); $this->mask_h = $this->getImgHeight($this->h_mask); } /** * 图片输出 */ function _output() { $img_type = $this->img_type; $func_name = $this->all_type[$img_type]['output']; if(function_exists($func_name)) { // 判断浏览器,若是IE就不发送头 if(isset($_SERVER['HTTP_USER_AGENT'])) { $ua = strtoupper($_SERVER['HTTP_USER_AGENT']); if(!preg_match('/^.*MSIE.*\)$/i',$ua)) { header("Content-type:$img_type"); } } $func_name($this->h_dst, $this->dst_img, $this->img_display_quality); } else { Return false; } } /** * 分析颜色 * * @param string $color 十六进制颜色 */ function _parseColor($color) { $arr = array(); for($ii=1; $ii<strlen ($color); $ii++) { $arr[] = hexdec(substr($color,$ii,2)); $ii++; } Return $arr; } /** * 计算出位置坐标 */ function _countMaskPos() { if($this->_isFull()) { switch($this->mask_position) { case 1: // 左上 $this->mask_pos_x = $this->mask_offset_x + $this->img_border_size; $this->mask_pos_y = $this->mask_offset_y + $this->img_border_size; break; case 2: // 左下 $this->mask_pos_x = $this->mask_offset_x + $this->img_border_size; $this->mask_pos_y = $this->src_h - $this->mask_h - $this->mask_offset_y; break; case 3: // 右上 $this->mask_pos_x = $this->src_w - $this->mask_w - $this->mask_offset_x; $this->mask_pos_y = $this->mask_offset_y + $this->img_border_size; break; case 4: // 右下 $this->mask_pos_x = $this->src_w - $this->mask_w - $this->mask_offset_x; $this->mask_pos_y = $this->src_h - $this->mask_h - $this->mask_offset_y; break; default: // 默认将水印放到右下,偏移指定像素 $this->mask_pos_x = $this->src_w - $this->mask_w - $this->mask_offset_x; $this->mask_pos_y = $this->src_h - $this->mask_h - $this->mask_offset_y; break; } } else { switch($this->mask_position) { case 1: // 左上 $this->mask_pos_x = $this->mask_offset_x + $this->img_border_size; $this->mask_pos_y = $this->mask_offset_y + $this->img_border_size; break; case 2: // 左下 $this->mask_pos_x = $this->mask_offset_x + $this->img_border_size; $this->mask_pos_y = $this->dst_h - $this->mask_h - $this->mask_offset_y - $this->img_border_size; break; case 3: // 右上 $this->mask_pos_x = $this->dst_w - $this->mask_w - $this->mask_offset_x - $this->img_border_size; $this->mask_pos_y = $this->mask_offset_y + $this->img_border_size; break; case 4: // 右下 $this->mask_pos_x = $this->dst_w - $this->mask_w - $this->mask_offset_x - $this->img_border_size; $this->mask_pos_y = $this->dst_h - $this->mask_h - $this->mask_offset_y - $this->img_border_size; break; default: // 默认将水印放到右下,偏移指定像素 $this->mask_pos_x = $this->dst_w - $this->mask_w - $this->mask_offset_x - $this->img_border_size; $this->mask_pos_y = $this->dst_h - $this->mask_h - $this->mask_offset_y - $this->img_border_size; break; } } } /** * 设置字体信息 */ function _setFontInfo() { if(is_numeric($this->font)) { $this->font_w = imagefontwidth($this->font); $this->font_h = imagefontheight($this->font); // 计算水印字体所占宽高 $word_length = strlen($this->mask_word); $this->mask_w = $this->font_w*$word_length; $this->mask_h = $this->font_h; } else { $arr = imagettfbbox ($this->font_size,0, $this->font,$this->mask_word); $this->mask_w = abs($arr[0] - $arr[2]); $this->mask_h = abs($arr[7] - $arr[1]); } } /** * 设置新图尺寸 * * @param integer $img_w 目标宽度 * @param integer $img_h 目标高度 */ function _setNewImgSize($img_w, $img_h=null) { $num = func_num_args(); if(1 == $num) { $this->img_scale = $img_w;// 宽度作为比例 $this->fill_w = round($this->src_w * $this->img_scale / 100) - $this->img_border_size*2; $this->fill_h = round($this->src_h * $this->img_scale / 100) - $this->img_border_size*2; // 源文件起始坐标 $this->src_x = 0; $this->src_y = 0; $this->copy_w = $this->src_w; $this->copy_h = $this->src_h; // 目标尺寸 $this->dst_w = $this->fill_w + $this->img_border_size*2; $this->dst_h = $this->fill_h + $this->img_border_size*2; } if(2 == $num) { $fill_w = (int)$img_w - $this->img_border_size*2; $fill_h = (int)$img_h - $this->img_border_size*2; if($fill_w < 0 || $fill_h < 0) { die("图片边框过大,已超过了图片的宽度"); } $rate_w = $this->src_w/$fill_w; $rate_h = $this->src_h/$fill_h; switch($this->cut_type) { case 0: // 如果原图大于缩略图,产生缩小,否则不缩小 if($rate_w < 1 && $rate_h < 1) { $this->fill_w = (int)$this->src_w; $this->fill_h = (int)$this->src_h; } else { if($rate_w >= $rate_h) { $this->fill_w = (int)$fill_w; $this->fill_h = round($this->src_h/$rate_w); } else { $this->fill_w = round($this->src_w/$rate_h); $this->fill_h = (int)$fill_h; } } $this->src_x = 0; $this->src_y = 0; $this->copy_w = $this->src_w; $this->copy_h = $this->src_h; // 目标尺寸 $this->dst_w = $this->fill_w + $this->img_border_size*2; $this->dst_h = $this->fill_h + $this->img_border_size*2; break; // 自动裁切 case 1: // 如果图片是缩小剪切才进行操作 if($rate_w >= 1 && $rate_h >=1) { if($this->src_w > $this->src_h) { $src_x = round($this->src_w-$this->src_h)/2; $this->setSrcCutPosition($src_x, 0); $this->setRectangleCut($fill_h, $fill_h); $this->copy_w = $this->src_h; $this->copy_h = $this->src_h; } elseif($this->src_w < $this->src_h) { $src_y = round($this->src_h-$this->src_w)/2; $this->setSrcCutPosition(0, $src_y); $this->setRectangleCut($fill_w, $fill_h); $this->copy_w = $this->src_w; $this->copy_h = $this->src_w; } else { $this->setSrcCutPosition(0, 0); $this->copy_w = $this->src_w; $this->copy_h = $this->src_w; $this->setRectangleCut($fill_w, $fill_h); } } else { $this->setSrcCutPosition(0, 0); $this->setRectangleCut($this->src_w, $this->src_h); $this->copy_w = $this->src_w; $this->copy_h = $this->src_h; } // 目标尺寸 $this->dst_w = $this->fill_w + $this->img_border_size*2; $this->dst_h = $this->fill_h + $this->img_border_size*2; break; // 手工裁切 case 2: $this->copy_w = $this->fill_w; $this->copy_h = $this->fill_h; // 目标尺寸 $this->dst_w = $this->fill_w + $this->img_border_size*2; $this->dst_h = $this->fill_h + $this->img_border_size*2; break; default: break; } } // 目标文件起始坐标 $this->start_x = $this->img_border_size; $this->start_y = $this->img_border_size; } /** * 检查水印图是否大于生成后的图片宽高 */ function _isFull() { Return ( $this->mask_w + $this->mask_offset_x > $this->fill_w || $this->mask_h + $this->mask_offset_y > $this->fill_h) ?true:false; } /** * 检查水印图是否超过原图 */ function _checkMaskValid() { if( $this->mask_w + $this->mask_offset_x > $this->src_w || $this->mask_h + $this->mask_offset_y > $this->src_h) { die("水印图片尺寸大于原图,请缩小水印图"); } } /** * 取得图片类型 * * @param string $file_path 文件路径 */ function _getImgType($file_path) { $type_list = array("1"=>"gif","2"=>"jpg","3"=>"png","4"=>"swf","5" => "psd","6"=>"bmp","15"=>"wbmp"); if(file_exists($file_path)) { $img_info = @getimagesize ($file_path); if(isset($type_list[$img_info[2]])) { Return $type_list[$img_info[2]]; } } else { die("文件不存在,不能取得文件类型!"); } } /** * 检查图片类型是否合法,调用了array_key_exists函数,此函数要求 * php版本大于4.1.0 * * @param string $img_type 文件类型 */ function _checkValid($img_type) { if(!array_key_exists($img_type, $this->all_type)) { Return false; } } /** * 按指定路径生成目录 * * @param string $path 路径 */ function _mkdirs($path) { $adir = explode('/',$path); $dirlist = ''; $rootdir = array_shift($adir); if(($rootdir!='.'||$rootdir!='..')&&!file_exists($rootdir)) { @mkdir($rootdir); } foreach($adir as $key=>$val) { if($val!='.'&&$val!='..') { $dirlist .= "/".$val; $dirpath = $rootdir.$dirlist; if(!file_exists($dirpath)) { @mkdir($dirpath); @chmod($dirpath,0777); } } } } /** * 垂直翻转 * * @param string $src 图片源 */ function _flipV($src) { $src_x = $this->getImgWidth($src); $src_y = $this->getImgHeight($src); $new_im = imagecreatetruecolor($src_x, $src_y); for ($y = 0; $y < $src_y; $y++) { imagecopy($new_im, $src, 0, $src_y - $y - 1, 0, $y, $src_x, 1); } $this->h_src = $new_im; } /** * 水平翻转 * * @param string $src 图片源 */ function _flipH($src) { $src_x = $this->getImgWidth($src); $src_y = $this->getImgHeight($src); $new_im = imagecreatetruecolor($src_x, $src_y); for ($x = 0; $x < $src_x; $x++) { imagecopy($new_im, $src, $src_x - $x - 1, 0, $x, 0, 1, $src_y); } $this->h_src = $new_im; } } 使用实例: < ?php require_once('lib/thumb.class.php'); $t = new ThumbHandler(); $t->setSrcImg("img/test.jpg"); $t->setDstImg("tmp/new_test.jpg"); $t->setMaskImg("img/test.gif"); $t->setMaskPosition(1); $t->setMaskImgPct(80); $t->setDstImgBorder(4,"#dddddd"); // 指定缩放比例 $t->createImg(300,200); ?> <?php require_once('lib/thumb.class.php'); $t = new ThumbHandler(); // 基本使用 $t->setSrcImg("img/test.jpg"); $t->setMaskWord("test"); $t->setDstImgBorder(10,"#dddddd"); // 指定缩放比例 $t->createImg(50); ?> <?php equire_once('lib/thumb.class.php'); $t = new ThumbHandler(); // 基本使用 $t->setSrcImg("img/test.jpg"); $t->setMaskWord("test"); // 指定固定宽高 $t->createImg(200,200); ?> <?php require_once('lib/thumb.class.php'); $t = new ThumbHandler(); $t->setSrcImg("img/test.jpg"); $t->setDstImg("tmp/new_test.jpg"); $t->setMaskWord("test"); // 指定固定宽高 $t->createImg(200,200); ?> <?php require_once('lib/thumb.class.php'); $t = new ThumbHandler(); $t->setSrcImg("img/test.jpg"); // 指定字体文件地址 $t->setMaskFont("c:/winnt/fonts/arial.ttf"); $t->setMaskFontSize(20); $t->setMaskFontColor("#ffff00"); $t->setMaskWord("test3333333"); $t->setDstImgBorder(99,"#dddddd"); $t->createImg(50); ?> <?php require_once('lib/thumb.class.php'); $t = new ThumbHandler(); $t->setSrcImg("img/test.jpg"); $t->setMaskOffsetX(55); $t->setMaskOffsetY(55); $t->setMaskPosition(1); //$t->setMaskPosition(2); //$t->setMaskPosition(3); //$t->setMaskPosition(4); $t->setMaskFontColor("#ffff00"); $t->setMaskWord("test"); // 指定固定宽高 $t->createImg(50); ?> <?php require_once('lib/thumb.class.php'); $t = new ThumbHandler(); $t->setSrcImg("img/test.jpg"); $t->setMaskFont("c:/winnt/fonts/simyou.ttf"); $t->setMaskFontSize(20); $t->setMaskFontColor("#ffffff"); $t->setMaskTxtPct(20); $t->setDstImgBorder(10,"#dddddd"); $text = "中文"; $str = mb_convert_encoding($text, "UTF-8", "gb2312"); $t->setMaskWord($str); $t->setMaskWord("test"); // 指定固定宽高 $t->createImg(50);#487
PHP取整数函数常用的四种方法:
1.直接取整,舍弃小数,保留整数:intval();
2.四舍五入取整:round();
3.向上取整,有小数就加1:ceil();
4.向下取整:floor()。
一、intval—对变数转成整数型态
intval如果是字符型的会自动转换为0。
intval(3.14159); // 3 intval(3.64159); // 3 intval('ruesin'); //0二、四舍五入:round()
根据参数2指定精度将参数1进行四舍五入。参数2可以是负数或零(默认值)。
round(3.14159); // 3 round(3.64159); // 4 round(3.64159, 0); // 4 round(3.64159, 2); // 3.64 round(5.64159, 3); // 3.642 round(364159, -2); // 364200三、向上取整,有小数就加1:ceil()
返回不小于 value 的下一个整数,value 如果有小数部分则进一位。
这个方法,在我们写分页类计算页数时经常会用到。
ceil(3.14159); // 4 ceil(3.64159); // 4四、向下取整:floor()
返回不大于 value 的下一个整数,将 value 的小数部分舍去取整。
floor(3.14159); // 3 floor(3.64159); // 3#488
"\Core\Conf\convention.php#489
各位,你们知道兔死狐悲这个成语吗?
其实,兔死狐悲是一个很有内涵的成语,它实际上包含了一个大多数人忽略掉的深刻问题:
为什么是兔死狐悲,而不是兔死兔悲呢?
兔死狐悲的童话非常简单:兔子被猎枪打死了,狐狸看到了,非常悲伤。这里狐狸悲伤被人类解释为它觉得自己有一天也会被打死。
但其实事情远没那么简单,因为它没解释为什么其他兔子们不悲伤。
真实的童话是这样的。
一天,狐狸看到猎人打死了兔子。它受到了惊吓,但远没有到悲伤的程度。而接下来它看到的画面却让它疑惑不已:一群兔子看到自己的同类被猎人打死了,却还是各忙各的,似乎无动于衷。
疑惑的狐狸决定随机采访几只看起来很可口的兔子,同时解决自己肠胃和大脑的双重饥渴,顺便看看兔子们是不是有什么阴毛,不,阴谋。
第一只:
狐狸:「你看到同伴被打死了为什么无动于衷啊?」
兔1:「啊?有兔子被打死了吗?太好了,我要赶快去把它的窝占了,把它的老婆睡了,把它的儿女卖了,把它的积蓄夺了!你快点让开!我不去别兔就要去占啦!」
狐狸听后震惊了,它一口吃了兔子1,抹抹嘴想:也许这只兔子是比较罕见的精神病,不能代表其他群众兔们的看法,还要多吃,不,多采访几只兔子才行。
第二只:
狐狸:「你看到同伴被打死了为什么无动于衷啊?对了你别想去抢它的东西了,早抢没了。」
兔子2:「哦。」
狐狸:「你说话啊,你不说话我就吃了你!」
兔子2:「哦。你想让俺说啥啊?」
狐狸露出獠牙。
兔子2:「啊啊求求你不要吃我!俺说俺说!俺知道它被打死了,但那又如何?玄学上,这是命运,科学上,这是优胜劣汰,宗教上,这是神的救赎,最重要的是,这和俺有啥关系啊!它又不是俺的亲戚朋友,死了就死了呗!」
狐狸又一次震惊了,它克制住震惊引发的食欲,问了一个问题:「你不担心同样的事情发生在你自己身上吗?」
兔子2:「俺管它个鸟,这世界上兔子这么多,俺肯定不会那么倒霉啦!再说了,担心有啥用,该死就是该死,这是时也,运也,命也……」
狐狸:「嗯,所以我吃掉你也是合乎社会习俗,法律规范,天道循环,命运轮回,自然规律,宇宙平衡的!」
兔子2:「对对对——啊不要啊!谁来救救俺啊!」
狐狸一口吃掉兔子2,抹抹嘴,指着早就在旁边吓得不敢动弹的兔子3到9说:「来,说说感想!」
兔子3到9一起鼓掌:「吃的好!吃的威武!吃出了兔子们的希望!」
狐狸:「马勒戈壁,既然吃得好,就让我带领你们实现兔子梦吧!」
于是狐狸每天都吃兔子,并鼓励兔子们互相出卖,兔子们为了暂时保命而互相出卖同伴们的藏身处,最后所有的兔子都被狐狸捉住了。
面对一群互相指责并打成一团的兔子,狐狸拍拍圆滚滚的肚子说:「都先停手!最近我很担心自己的胆固醇,所以谁来回答我一个问题,答的好我就放过你们所有兔子!」
兔子们支起了长长的耳朵。
狐狸:「你们有一百多只,团结在一起我根本打不过你们,可是为什么你们当初不能团结一致来反抗我呢?」
兔子89说:「因为狐狸大人太威猛了,我们逃不过您霹雳无敌的算计。」
狐狸一口吃掉了兔子89:「我不想被拍狐狸屁!」
兔子90:「因为我们中出了叛徒。」
狐狸点点头:「这个听着很合理,那我继续问,你们为什么要中出,不,背叛自己的同伴呢?」
兔子91:「因为我死了我的同伴就会占我的窝,睡我的妻,卖我的娃,吃我的粮!我死也不能让他们舒服地活着!」
狐狸又点点头:「那你们为什么要占死兔的窝,睡死兔的妻,卖死兔的娃,吃死兔的粮呢?」
兔子92:「有便宜不占就是王八蛋!我不占别兔会占,我凭什么不占?」
狐狸想:「怎么听着这么耳熟?好像第一只被我采访的兔子就是这么说的。」
狐狸最后宣布,刚才是逗大家玩呢,其实我要还是吃掉所有兔子。所有兔子听到这个消息,都悲伤地抱头痛哭起来。
看到哭成一团的兔子,狐狸突然开窍了:兔子们根本就没有什么阴谋,这只不过是一个极端自私的种族,它们不会为同伴而战斗,它们也不会为同伴悲伤,它们只想着过好自己的每一天,殊不知,它们自己的最好是整个种族的最坏,它们自己的幸福是整个种族的悲哀。这样的种族,其实是最弱小的,不管数量有多少,它们永远只会单打独斗,不管力量有多强,它们永远只会互相出卖。
想到这里,狐狸不禁流下了悲伤的泪水:「马勒戈壁,我回去以后一定好好教育我的孩儿,一定要让它们记住兔子的教训!一个不会为同类的死悲剧和愤怒的种族是没有未来的!」
砰砰砰!此时,再次上山的猎人把一群抱头痛哭的兔子挨个爆头,却看到一只胖乎乎的狐狸洒着泪水钻入了丛林深处。他回家后把这个奇特的景象告诉了村里的长老,长老眉头一皱:「此乃兔死狐悲也!」然后按照文中开头的套路解释了一通。
他们永远也不知道,那天那只狐狸的悲伤,不是为了几只兔子的死亡,而是为了整个兔族的冷漠。
#490
#491
压测命令:ab -n 10000 -c 100 http://www.appeiphone.cn/ab -n 1000 -c 1000 -p post.txt -T 'application/x-www-form-urlencoded' http://www.app-im.cn/save.asp post.txt 内容是 u=123456&p=12345&x=4&y=10可以用 [进程替换( Process Substitution )] ab -n 1000 -c 1000 -p <(echo 'u=123456&p=12345&x=4&y=10') -T 'application/x-www-form-urlencoded' http://www.app-im.cn/save.asp先 F12 进 Network,填好信息提交的时候按 esc,看到有一条 cancel 的记录,右键复制 copy->copy as cURL
curl 可以直接干,脚本最简单就是
for((i=0;i<20;++i));do while :;do {{Curl command goes here}} done;wrk -c 1000 -d 60s -t 5 http://www.app-im.cn/那个 还可以用 <(<<<'u=123456&p=12345&x=4&y=10') ref: http://ahei.info/bash.htm#sec-3以windows环境下,apache安装路径为C:\apache\Apache24\为例
打开终端,输入命令
cd C:\apache\Apache24\bin即可启动ab
开始测试
输入命令
ab -n 100 -c 10 http://test.com/其中-n表示请求数,-c表示并发数
其余命令请参见http://apache.jz123.cn/programs/ab.html
ab [可选的参数选项] 需要进行压力测试的url 此外,我们再根据上面的用法介绍界面来详细了解每个参数选项的作用。 -n 即requests,用于指定压力测试总共的执行次数。 -c 即concurrency,用于指定的并发数。 -t 即timelimit,等待响应的最大时间(单位:秒)。 -b 即windowsize,TCP发送/接收的缓冲大小(单位:字节)。 -p 即postfile,发送POST请求时需要上传的文件,此外还必须设置-T参数。 -u 即putfile,发送PUT请求时需要上传的文件,此外还必须设置-T参数。 -T 即content-type,用于设置Content-Type请求头信息,例如:application/x-www-form-urlencoded,默认值为text/plain。 -v 即verbosity,指定打印帮助信息的冗余级别。 -w 以HTML表格形式打印结果。 -i 使用HEAD请求代替GET请求。 -x 插入字符串作为table标签的属性。 -y 插入字符串作为tr标签的属性。 -z 插入字符串作为td标签的属性。 -C 添加cookie信息,例如:"Apache=1234"(可以重复该参数选项以添加多个)。 -H 添加任意的请求头,例如:"Accept-Encoding: gzip",请求头将会添加在现有的多个请求头之后(可以重复该参数选项以添加多个)。 -A 添加一个基本的网络认证信息,用户名和密码之间用英文冒号隔开。 -P 添加一个基本的代理认证信息,用户名和密码之间用英文冒号隔开。 -X 指定使用的和端口号,例如:"126.10.10.3:88"。 -V 打印版本号并退出。 -k 使用HTTP的KeepAlive特性。 -k 使用HTTP的KeepAlive特性。 -d 不显示百分比。 -S 不显示预估和警告信息。 -g 输出结果信息到gnuplot格式的文件中。 -e 输出结果信息到CSV格式的文件中。 -r 指定接收到错误信息时不退出程序。 -h 显示用法信息,其实就是ab -help。虽然ab可以配置的参数选项比较多,但是,一般情况下我们只需要使用形如ab -n 数字 -c 数字 url路径的命令即可。譬如,我们对位于本地Apache服务器上、URL为localhost/index.的页面进行。测试总次数为1000,并发数为100(相当于100个用户同时访问,他们总共访问1000次)。我们输入DOS命令ab -n 1000 -c 100 localhost/index.php,打印结果如下: F:\Apache2.2\bin>ab -n 1000 -c 100 localhost/index.php@ECHO OFF cmd /k cd /d D:\d\phpStudy\Apache\bin压力测试目录batab -n 100000 -c 10000 http://www.letrue.cn/#492
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <body> <img src="imges/01.jpg" alt="" id='img'> <button id='prev'>上一张</button> <button id='next'>下一张</button> </body> <script> window.onload = function(){ //获取要用到的元素,标签 var img = document.getElementById('img'); var prev = document.getElementById('prev'); var next = document.getElementById('next'); //定义两端的临界值, 定义活动的变量 最大5张、 var maxIndex = 5; var minIndex = 1; var activeIndex = minIndex; // 确定事件源 绑定事件函数。 prev.onclick = function(){ //当点击 上一张的时候, img的src 实现切换 img.src = 'imges/0' + activeIndex + '.jpg'; if(activeIndex === 1){ activeIndex = 5; }else{activeIndex --;} } next.onclick = function(){ if(activeIndex === 5){ activeIndex = 1; }else{ activeIndex++; } img.src = 'imges/0' + activeIndex + '.jpg'; } } </script> </html>#493
#494
除了少活20年我根本想不到其他方法