您的位置:首页 > 编程语言 > PHP开发

phpcms常用函数

2015-08-12 14:48 204 查看
1、./libs/functions/global.func.php

--------------------------------------------------
字符串安全处理函数
-------------------------------------------------------
new_addslashes($string) 返回经 addslashes处理过得字符或数组

new_stripslashes($string)返回经stripslashes处理过得字符或数组

new_htmlspecialchars($string)返回经htmlspecialchars处理过得字符或数组

safe_replace($string) 安全过滤函数

trim_textarea($string) 格式化文本域: 新行前添加换行标记,空格转为 

trim_script 转义 javascript 代码标记

str_cut($string/字符串, $length/截取长度, $dot = '...'/结尾填充) 支持UTF8/GBK
-----------------------------------------
get_url() 获取当前页面完整URL地址

ip() 获取请求IP
------------------------------------------
字符串操作类函数
----------------------------------------------
random($length, $chars = '0123456789') 产生随机字符串

生成随机字符串create_randomstr($lenth = 6) 范围:'123456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ'

string2array($data) 字符串转为数组

array2string($data, $isformdata = 1) 数组转为字符串

--------------------
字符串加密解密
--------------------
sys_auth($string, $operation = 'ENCODE'/ENCODE加密,DECODE为解密,默认为ENCODE, $key = ''密钥, $expiry = 0/过期时间)

--------------------------------------------------
语言方法
L ($language = '数组中的键名',$pars = array(), $modules = '对应模块语言') //$modules=''时默认为system.lang.php 返回键值
---------------------------------------------
调用前台模板
===============
template($module = 'content'/对应模块, $template = 'index'/页面, $style = '')

调用后台模板

admin::admin_tpl($file/文件名, $m = ''/默认为文件所在模块)
------------------------------------------------------------------
提示信息页面跳转 showmessage($msg/信息, $url_forward = 'goback'/跳转位置, $ms = 1250, $dialog = '', $returnjs = '') //有待更改默认后台跳到admin,前台:content
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

fileext($filename) 取得文件扩展名

|||||||||||||||||||||||||||||||||||||||||||||||||||||

缓存操作
--------------
写入缓存 setcache($name/
名称, $data/数据, $filepath=''/路径(默认caches/caches_$filepath/caches_data/),
$type='file'(默认)/缓存类型[file,memcache,apc], $config='', $timeout=0/过期时间)

加载模板标签缓存 tpl_cache($name,$times = 0) 目的文件:caches/caches_$filepath/caches_data/$name.cache.php

读取缓存 getcache($name, $filepath='', $type='file', $config='')

删除缓存 delcache($name, $filepath='', $type='file', $config='')

读取缓存文件信息 getcacheinfo($name, $filepath='', $type='file', $config='')
|||||||||||||||||||||||||||||||||||||||||||||||||||||

分页函数 pages($num, $curr_page, $perpage = 20, $urlrule = '', $array = array(),$setpages = 10) 返回分页

信息总数, 当前分页, 每页显示数, URL规则...

URL路径解析,pages 函数的辅助函数 url_par($par, $url = '') $par 默认为page={$page} 返回URL

验证邮箱 is_email($email)

检查用户名是否符合规定 is_username($username)

///////////////////////////////////////////////

网站一些参数获取
==================

获取当前的站点ID get_siteid()

获取用户昵称 get_nickname($userid='', $field='') 不传入userid取当前用户nickname,如果nickname为空取username||传入field,取用户$field字段信息

通过ID获取用户信息 get_memberinfo($userid, $field='') 不传入$field返回用户所有信息,传入field,取用户$field字段信息

通过 username 值,获取用户所有信息 get_memberinfo_buyusername($username, $field='')

获取用户头像,建议传入phpssouid get_memberavatar($uid/默认为phpssouid, $is_userid='', $size='30')

///////////////////////////////////////////////

判断IE浏览器 is_ie()

文件下载 file_down($filepath/文件路径, $filename = ''/文件名称)

对用户的密码进行加密 password($password, $encrypt='')

对(字符串或数组)数据进行编码转换 array_iconv($data, $input = 'gbk', $output = 'utf-8')

生成缩略图函数 thumb($imgurl, $width = 100, $height = 100 ,$autocut = 1, $smallpic = 'nopic.gif')

水印添加 watermark($source, $target = '',$siteid)
===========================================================================

生成SEO seo($siteid, $catid = '', $title = '', $description = '', $keyword = '') 返回数组

站点ID ,栏目ID, 标题 , 描述 ,关键词

获取站点的信息 siteinfo($siteid)

生成CNZZ统计代码tjcode()

获取站点域名siteurl($siteid)

文本转换为图片 string2img($txt, $fonttype = 5, $fontsize = 16, $font = '', $fontcolor = 'FF0000',$transparent = '1')

|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
----------------------------------------------- -----------------------------------
2、./libs/functions/iconv.func.php 字符编码转换函数

3、./libs/functions/mail.func.php 发邮件函数

4、./libs/functions/extention.func.php 扩展函数
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: