functionincphp超越php

functionincphp超越php

内容导读

收集整理的这篇技术教程文章主要介绍了functionincphp超越php,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含11100字,纯文字阅读大概需要16分钟

内容图文

/**
* Global Function
*
* @author Avenger
* @version https://www.gxlcms.com/1.https://www.gxlcms.com/14 $Id 2003-05-30 https://www.gxlcms.com/10:https://www.gxlcms.com/10:08 $
*/
/**
* 弹出提示框
*
* @access public
* @param string $txt 弹出一个提示框,$txt为要弹出的内容
* @return void
*/
function popbox($txt) {
echo "";
}
/**
* 非法操作警告
*
* @access public
* @param string $C_alert 提示的错误信息
* @param string $I_goback 返回后返回到哪一页,不指定则不返回
* @return void
*/
function alert($C_alert,$I_goback='main.php') {
if(!empty($I_goback)) {
echo "";
} else {
echo "";
}
}
/**
* 产生随机字符串
*
* 产生一个指定长度的随机字符串,并返回给用户
*
* @access public
* @param int $len 产生字符串的位数
* @return string
*/
function randstr($len=6) {
$chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0https://www.gxlcms.com/123456789-@#~'; // characters to build the password from
mt_srand((double)microtime()*https://www.gxlcms.com/1000000*getmypid()); // seed the random number generater (must be done)
$password='';
while(strlen($password)<$len)
$password.=substr($chars,(mt_rand()%strlen($chars)),https://www.gxlcms.com/1);
return $password;
}
/**
* 判断下拉菜音的选取项
*
* 可以判断字符串一和字符串二是否相等.从而使相等的项目在下拉菜单中被选择
*
* @access public
* @param string $strhttps://www.gxlcms.com/1 要比较的字符串一
* @param string $str2 要比较的字符串二
* @return string 相等返回字符串"selected",否则返回空字符串
*/
function ckselect($strhttps://www.gxlcms.com/1,$str2) {
if($strhttps://www.gxlcms.com/1==$str2) {
return ' selected';
}
return '';
}
/**
* 一个自定义的Ftp函数
*
* @access private
* @return void
*/
function myftp($ftp_server,$ftp_port,$ftp_username,$ftp_password,$ftp_path='/') {
$ftpid=@ftp_connect($ftp_server,$ftp_port) or die('Connect To Ftp Server Error!');
@ftp_login($ftpid,$ftp_username,$ftp_password) or die('Login Ftp Error!');
@ftp_chdir($ftpid,'/'.$ftp_path) or die('Chdir Error!');
return $ftpid;
}
/**
* 截取中文部分字符串
*
* 截取指定字符串指定长度的函数,该函数可自动判定中英文,不会出现乱码
*
* @access public
* @param string $str 要处理的字符串
* @param int $strlen 要截取的长度默认为https://www.gxlcms.com/10
* @param string $other 是否要加上省略号,默认会加上
* @return string
*/
function showtitle($str,$strlen=https://www.gxlcms.com/10,$other=true) {
$j = 0;
for($i=0;$i<$strlen;$i++)
if(ord(substr($str,$i,https://www.gxlcms.com/1))>0xa0) $j++;
if($j%2!=0) $strlen++;
$rstr=substr($str,0,$strlen);
if (strlen($str)>$strlen && $other) {$rstr.='...';}
return $rstr;
}
/**
* 制作链接
*
* @access public
* @param string url 要链接到的网址
* @param string linktext 显示的链接文字
* @param string target 目标框架
* @param string extras 扩展参数
* @return string
*/
function make_link ($url, $linktext=false, $target=false, $extras=false) {
return sprintf("%s",
$url,
($target ? ' target="'.$target.'"' : ''),
($extras ? ' '.$extras : ''),
($linktext ? $linktext : $url)
);
}
/**
* 格式化用户评论
*
* @access public
* @param string
* @return void
*/
function clean_note($text) {
$text = htmlspecialchars(trim($text));
/* turn urls into links */
$text = preg_replace("/((mailto|http|ftp|nntp|news):.+?)(>|s|)|"|.s|$)/","https://www.gxlcms.com/13",$text);
/* this 'fixing' code will go away eventually. */
$fixes = array('
', '

', '

');
reset($fixes);
while (list(,$f) = each($fixes)) {
$text = str_replace(htmlspecialchars($f), $f, $text);
$text = str_replace(htmlspecialchars(strtoupper($f)), $f, $text);
}
/*

tags make things look awfully weird (breaks things out of the
tag). Just convert them to
's
*/
$text = str_replace (array ('

', '

'), '
', $text);
/* Remove

tags to prevent it from showing up in the note */
$text = str_replace (array ('

', '

'), '', $text);
/* preserve linebreaks */
$text = str_replace("n", "
", $text);
/* this will only break long lines */
if (function_exists("wordwrap")) {
$text = wordwrap($text);
}
// Preserve spacing of user notes
$text = str_replace(" ", " ", $text);
return $text;
}
/**
* 获取图象信息的函数
*
* 一个全面获取图象信息的函数
*
* @access public
* @param string $img 图片路径
* @return array
*/
function getimageinfo($img) {
$img_info = getimagesize($img);
switch ($img_info[2]) {
case https://www.gxlcms.com/1:
$imgtype = "GIF";
break;
case 2:
$imgtype = "JPG";
break;
case 3:
$imgtype = "PNG";
break;
}
$img_size = ceil(filesize($img)/https://www.gxlcms.com/1000)."k";
$new_img_info = array (
"width"=>$img_info[0],
"height"=>$img_info[https://www.gxlcms.com/1],
"type"=>$imgtype,
"size"=>$img_size
);
return $new_img_info;
}
/**
* 计算当前时间
*
* 以微秒为单位返回当前系统的时间
*
* @access public
* @return real
*/
function getmicrotime() {
$tmp = explode(' ', microtime());
return (real)$tmp[https://www.gxlcms.com/1]. substr($tmp[0], https://www.gxlcms.com/1);
}
/**
* 写文件操作
*
* @access public
* @param bool
* @return void
*/
function wfile($file,$content,$mode='w') {
$oldmask = umask(0);
$fp = fopen($file, $mode);
if (!$fp) return false;
fwrite($fp,$content);
fclose($fp);
umask($oldmask);
return true;
}
/**
* 加载模板文件
*
* @access public
* @return void
*/
function tpl_load($tplfile,$path='./templates/',$empty='remove') {
global $tpl;
$path ? '' : $path='./templates/';
require_once 'HTML/Template/PHPLIB.php';
$tpl = new Template_PHPLIB($path,$empty);
$tpl->setFile('main',$tplfile);
}
/**
* 模板解析输出
*
* @access public
* @return void
*/
function tpl_output() {
global $tpl;
$tpl->parse('output','main');
$tpl->p('output');
}
/**
* 邮件发送函数
*
* @access public private
* @param bool
* @return void
*/
function mailSender($from, $to, $title, $content) {
$from ? $from = 'sender@phpe.net' : '';
$title ? $title = 'From Exceed PHP...' : '';
$sig = "
感谢您使用我们的服务.nn
Exceed PHP(超越PHP)n
$maildatenn
---------------------------------------------------------------------------------------
nn
去发现极限方法的唯一办法就是去超越它n
超越PHP欢迎您(http://www.phpe.net)n
";
$content .= $sig;
if (@mail($to, $title, $content, "From:$fromnReply-To:$from")) {
return true;
} else {
return false;
}
}
function br2none($str) {
return str_replace(array('
', '
'), "", $str);
}
/**
* UBB解析
*
* @param none
* @access public
* @return void
*/
function ubbParse($txt, $coverhtml=0) {
if ($coverhtml == 0) $txt = nl2br(new_htmlspecialchars($txt)); //BR和HTML转换
//只转换BR,不转换HTML
if ($coverhtml == https://www.gxlcms.com/1) {
if (!preg_match('//is', $txt) && !preg_match('//is', $txt)) {
$txt = strip_tags($txt);
$txt = nl2br($txt);
} else {
$txt = str_replace(' }
}
// pre and quote
//error_reporting(E_ALL);
$txt = preg_replace( "#[quote](.+?)[/quote]#is", "
https://www.gxlcms.com/1
", $txt );
$txt = preg_replace( "#[code](.+?)[/code]#ise", "'
'.br2none('').'
'", $txt );
// Colors 支持篏套
while( preg_match( "#[color=([^]]+)](.+?)[/color]#is", $txt ) ) {
$txt = preg_replace( "#[color=([^]]+)](.+?)[/color]#is", "2", $txt );
}
// Align
$txt = preg_replace( "#[center](.+?)[/center]#is", "
https://www.gxlcms.com/1
", $txt );
$txt = preg_replace( "#[left](.+?)[/left]#is", "https://www.gxlcms.com/1", $txt );
$txt = preg_replace( "#[right](.+?)[/right]#is", "https://www.gxlcms.com/1", $txt );
// Sub & sup
$txt = preg_replace( "#[sup](.+?)[/sup]#is", "https://www.gxlcms.com/1", $txt );
$txt = preg_replace( "#[sub](.+?)[/sub]#is", "https://www.gxlcms.com/1", $txt );
// email tags
// [email]avenger@php.com[/email] [email=avenger@php.com]Email me[/email]
$txt = preg_replace( "#[email](S+?)[/email]#i" , "https://www.gxlcms.com/1", $txt );
$txt = preg_replace( "#[emails*=s*"([.w-]+@[.w-]+.[.w-]+)s*"s*](.*?)[/email]#i" , "2", $txt );
$txt = preg_replace( "#[emails*=s*([.w-]+@[.w-]+.[w-]+)s*](.*?)[/email]#i" , "2", $txt );
// url tags
// [url]http://www.phpe.net[/url] [url=http://www.phpe.net]Exceed PHP![/url]
$txt = preg_replace( "#[url](S+?)[/url]#i" , "https://www.gxlcms.com/1", $txt );
$txt = preg_replace( "#[urls*=s*"s*(S+?)s*"s*](.*?)[/url]#i" , "2", $txt );
$txt = preg_replace( "#[urls*=s*(S+?)s*](.*?)[/url]#i" , "2", $txt );
// Start off with the easy stuff
$txt = preg_replace( "#[b](.+?)[/b]#is", "https://www.gxlcms.com/1", $txt );
$txt = preg_replace( "#[i](.+?)[/i]#is", "https://www.gxlcms.com/1", $txt );
$txt = preg_replace( "#[u](.+?)[/u]#is", "https://www.gxlcms.com/1", $txt );
$txt = preg_replace( "#[s](.+?)[/s]#is", "https://www.gxlcms.com/1", $txt );
// Header text
$txt = preg_replace( "#[h([https://www.gxlcms.com/1-6])](.+?)[/h[https://www.gxlcms.com/1-6]]#is", "2", $txt );
// Images
$txt = preg_replace( "#[img](.+?)[/img]#i", " $sec = time() - $date;
//Sec https://www.gxlcms.com/1 day is 86400
if ($sec < 86400) {
return round($sec/3600). ' hours ago';
} elseif ($sec < (86400 * 7)) {
return round($sec/86400). ' days ago';
} elseif ($sec < (86400 * 7 * 4)) {
return round($sec/(86400*7)). ' weeks ago';
} else {
return date('Y-m-d', $date);
}
}
?>

以上就介绍了 functionincphp超越php,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

PHP教程热搜

登录

忘记密码?

登录

注册

本站所有资源全部来源于网络,若本站发布的内容侵害到您的隐私或者利益,请联系我们删除!合作方式

Copyright © 2004-2018 https://www.gxlcms.com/. All Rights Reserved. 豫ICP备19030742号

内容总结

以上是为您收集整理的functionincphp超越php全部内容,希望文章能够帮你解决functionincphp超越php所遇到的程序开发问题。 如果觉得技术教程内容还不错,欢迎将网站推荐给程序员好友。

内容备注

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。


本文关键词:

dobAdodb的十个实例清晰版
上一篇
谈谈新手如何学习PHP
下一篇

相关文章

联系我们

在线咨询:点击这里给我发消息

邮件:w420220301@qq.com