06 2017 档案
12 使用 imagebrick 进行 pdf 到图像的转换
摘要:function change() { $pdf_file = './pdf/demo.pdf'; $save_to = './jpg/demo.jpg'; //make sure that apache has permissions to write in this folder! (common problem)//execute ImageMagick command 'co... 阅读全文
posted @ 2017-06-06 18:00 泪滴 阅读(145) 评论(0) 推荐(0)
12 生成二维码
摘要:function qr_code($data, $type = "TXT", $size = '150', $ec = 'L', $margin = '0') { $types = array("URL" => "http://", "TEL" => "TEL:", "TXT" => "", "EMAIL" => "MAILTO:"); if ( 阅读全文
posted @ 2017-06-06 17:59 泪滴 阅读(127) 评论(0) 推荐(0)
11 删除文件夹内容
摘要:function Delete($path) { if (is_dir($path) === true) { $files = array_diff(scandir($path), array('.', '..')); foreach ($files as $file) { Delete(realpath($path) . '/' . $file); } ... 阅读全文
posted @ 2017-06-06 17:29 泪滴 阅读(103) 评论(0) 推荐(0)
10 把秒转换为天数,小时和分
摘要:function secsToStr($secs) { if ($secs >= 86400) { $days = floor($secs / 86400); $secs = $secs % 86400; $r = $days . ' day'; if ($days 1) { $r .= 's'; }if ($secs > 0) { ... 阅读全文
posted @ 2017-06-06 17:26 泪滴 阅读(310) 评论(0) 推荐(0)
9 这个代码片段可以方便你禁止某些特定的 IP 地址访问你的网站
摘要:function deny() { if (!file_exists('blocked_ips.txt')) { $deny_ips = array( '127.0.0.1', '192.168.1.1', '83.76.27.9', '192.168.1.163' ); } else { $deny_ips = f... 阅读全文
posted @ 2017-06-06 17:23 泪滴 阅读(181) 评论(0) 推荐(0)
8 URL 字符串就可以自动的转换为超链接
摘要:function makeClickableLinks($text) { $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?&//=]+)', '\1', $text); $text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)'... 阅读全文
posted @ 2017-06-06 17:22 泪滴 阅读(176) 评论(0) 推荐(0)
6 验证邮箱地址
摘要:function is_validemail($email) { $check = 0; if (filter_var($email, FILTER_VALIDATE_EMAIL)) { $check = 1; } return $check; } 阅读全文
posted @ 2017-06-06 17:21 泪滴 阅读(115) 评论(0) 推荐(0)
7 获取用户的真实的IP
摘要:function getRealIpAddr() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { //to check ip is pass from pro... 阅读全文
posted @ 2017-06-06 17:21 泪滴 阅读(103) 评论(0) 推荐(0)
获取任意 Web 页面的 HTML 代码
摘要:function display_sourcecode($url) { $lines = file($url); $output = ""; foreach ($lines as $line_num => $line) { // loop thru each line and prepend line numbers $output .= "Line #{$line_... 阅读全文
posted @ 2017-06-06 17:20 泪滴 阅读(182) 评论(0) 推荐(0)
检测用户是那个城市访问你的网站的
摘要:function detect_city($ip) { $default = 'UNKNOWN'; $curlopt_useragent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)'; $url = 'ht... 阅读全文
posted @ 2017-06-06 17:19 泪滴 阅读(116) 评论(0) 推荐(0)
阻止sql注入
摘要:function clean($input) { if (is_array($input)) { foreach ($input as $key => $val) { $output[$key] = clean($val); // $output[$key] = $this->clean($val); } } else { $output ... 阅读全文
posted @ 2017-06-06 17:17 泪滴 阅读(118) 评论(0) 推荐(0)
linux命令行
摘要:du -sh /文件夹 统计某个问件的大小 cat 文件 读取文件内容并显示 -n 从第一行开始对问价编号 -b 忽略对空白行的编号 -s 两行空白行合并为一行 chmod 更改文件的权限 +为某个文件添加权限 -为减少权限 -R 以递归的方式更改 r可读 w可写 x可执行 阅读全文
posted @ 2017-06-05 16:36 泪滴 阅读(93) 评论(0) 推荐(0)