//循环删除目录和文件函数 public static function delDirAndFile($dirName, $delDir = 0) { if ($handle = opendir("$dirName")) { while (false !== ( $item = readdir($handle) )) { if ($item != "." && $item != ".."...
/**$sourcestr 是要处理的字符串$cutlength 为截取的长度(即字数) */static function cut_str($sourcestr, $cutlength, $type = true){$returnstr = ''; $i = 0; $n = 0; $str_length = strlen(trim($sourcestr)); //字符串的字节数 while (($n < $cutlength) and ($i <= $str_length)) { $temp_str = substr($sourcestr, $i, 1); ...
/**下载到本地 */ static function httpcopy($url, $file = "", $timeout = 600) { if (empty($file)) return false; $dir = pathinfo($file, PATHINFO_DIRNAME); !is_dir($dir) && @mkdir($dir, 0755, true); $url = str_replace(" &q...
/** * 判断是否为utf8字符串 * @parem $str * @return bool 180it.com */ function is_utf8($str) { if ($str === mb_convert_encoding(mb_convert_encoding($str, "UTF-32", "UTF-8"), "UTF-8", "UTF-32")) { return true; ...
/**检查路径是否存在@parem $path@return bool */function path_exists($path){$pathinfo = pathinfo($path . '/tmp.txt'); if (!empty($pathinfo ['dirname'])) { if (file_exists($pathinfo ['dirname']) === false) { if (mkdir($pathinfo ['dirname'], 0777, true) === false) { return...
/** * 写文件 */ function put_file($file, $content, $flag = 0) { $pathinfo = pathinfo($file); if (!empty($pathinfo ['dirname'])) { if (file_exists($pathinfo ['dirname']) === false) { if (@mkdir($pathinfo ['dirname'], 0...
/**获得用户的真实IP 地址 *@param 多个用多行分开@return void */public static function get_client_ip(){static $realip = NULL; if (self::$client_ip !== NULL) { return self::$client_ip; } if (isset($_SERVER['HTTP_X_FORWARDED_FOR2'])) { $arr = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR2']); foreach ($arr...
/** * 获取远程数据 * @param $url 地址 * @param $post_data 参数 * @param $method 方法 * @param $timeout 延时 */ function send($url = "", $post_data = '', $method = 'POST', $timeout = 20) { if ($method == 'GET'){ if(is_array($post_data)){ $post_data = implode("&am...
/** * url 跳转 * @param $url 跳转的url * @param $type 跳转类型 301 404 * @param $tip 提示信息 */ function redirect($url = '/', $type = '', $tip = '') { if ($type == '301') { Header('HTTP/1.1 301 Moved Permanently'); } elseif ($type == '404') { Header('HTTP/1.1 404 Not Fo...
//记录日志 function logs($channel, $contents) { $path = PATH_ROOT . '/data/log/'; if (!is_dir($path)) { if (!@mkdir($path, 0777, true)) { exit("无法创建目录{$path},请检查是否具有相应目录的写权限"); } } if (!is_writable($path)) { exit("目录{$path}没有写权限,...