include/libfunction.base.php

Constants

EMLOG_LANGUAGE_DIR

EMLOG_LANGUAGE_DIR = 'ltr'

EMLOG_LANGUAGES

EMLOG_LANGUAGES = \Option::get('language')

Functions

__autoload()

__autoload(  $class) 

基础函数库

Parameters

$class

doStripslashes()

doStripslashes() 

去除多余的转义字符

stripslashesDeep()

stripslashesDeep(  $value) 

递归去除转义字符

Parameters

$value

htmlClean()

htmlClean(\unknown_type  $content,   $nl2br = true) 

转换HTML代码函数

Parameters

\unknown_type $content
$nl2br

getIp()

getIp() 

获取用户ip地址

getBlogUrl()

getBlogUrl() 

获取站点地址(仅限根目录脚本使用,目前仅用于首页ajax请求)

realUrl()

realUrl() 

获取当前访问的base url

isIE6Or7()

isIE6Or7() 

checkPlugin()

checkPlugin(  $plugin) 

检查插件

Parameters

$plugin

loadJQuery()

loadJQuery() 

emLoadJQuery()

emLoadJQuery() 

加载jQuery

checkMail()

checkMail(  $email) 

验证email地址格式

Parameters

$email

subString()

subString(string  $strings, integer  $start, integer  $length) 

截取编码为utf8的字符串

Parameters

string $strings

预处理字符串

integer $start

开始处 eg:0

integer $length

截取长度

extractHtmlData()

extractHtmlData(string  $data, integer  $len) 

从可能包含html标记的内容中萃取纯文本摘要

Parameters

string $data
integer $len

changeFileSize()

changeFileSize(string  $fileSize) 

转换附件大小单位

Parameters

string $fileSize

文件大小 kb

getFileSuffix()

getFileSuffix(  $fileName) 

获取文件名后缀

Parameters

$fileName

pagination()

pagination(integer  $count, integer  $perlogs, integer  $page, string  $url,   $anchor = '') 

分页函数

Parameters

integer $count

条目总数

integer $perlogs

每页显示条数目

integer $page

当前页码

string $url

页码的地址

$anchor

addAction()

addAction(string  $hook, string  $actionFunc) : \boolearn

该函数在插件中调用,挂载插件函数到预留的钩子上

Parameters

string $hook
string $actionFunc

Returns

\boolearn

doAction()

doAction(string  $hook) 

执行挂在钩子上的函数,支持多参数 eg:doAction('post_comment', $author, $email, $url, $comment);

Parameters

string $hook

breakLog()

breakLog(string  $content, integer  $lid) 

文章分割

Parameters

string $content

文章内容

integer $lid

文章id

rmBreak()

rmBreak(string  $content) 

删除[break]标签

Parameters

string $content

文章内容

smartDate()

smartDate(  $datetemp) : string

时间转化函数

Parameters

$datetemp

Returns

string

getRandStr()

getRandStr(integer  $length = 12, boolean  $special_chars = true) : string

生成一个随机的字符串

Parameters

integer $length
boolean $special_chars

Returns

string

findArray()

findArray(  $array1,   $array2) 

寻找两数组所有不同元素

Parameters

$array1
$array2

uploadFile()

uploadFile(  $fileName,   $errorNum,   $tmpFile,   $fileSize,   $type,   $isIcon = false,   $is_thumbnail = true) 

Parameters

$fileName
$errorNum
$tmpFile
$fileSize
$type
$isIcon
$is_thumbnail

uploadFileBySwf()

uploadFileBySwf(  $fileName,   $errorNum,   $tmpFile,   $fileSize,   $type,   $isIcon = false,   $is_thumbnail = true) 

Parameters

$fileName
$errorNum
$tmpFile
$fileSize
$type
$isIcon
$is_thumbnail

upload()

upload(string  $fileName, string  $errorNum, string  $tmpFile, string  $fileSize, array  $type, boolean  $isIcon = false, boolean  $is_thumbnail = true) : array

文件上传

返回的数组索引 mime_type 文件类型 size 文件大小(单位KB) file_path 文件路径 width 宽度 height 高度 可选值(仅在上传文件是图片且系统开启缩略图时起作用) thum_file 缩略图的路径 thum_width 缩略图宽度 thum_height 缩略图高度 thum_size 缩略图大小(单位KB)

Parameters

string $fileName

文件名

string $errorNum

错误码:$_FILES['error']

string $tmpFile

上传后的临时文件

string $fileSize

文件大小 KB

array $type

允许上传的文件类型

boolean $isIcon

是否为上传头像

boolean $is_thumbnail

是否生成缩略图

Returns

array —

文件数据 索引

resizeImage()

resizeImage(string  $img, string  $thum_path, integer  $max_w, integer  $max_h) : \unknown

图片生成缩略图

Parameters

string $img

预缩略的图片

string $thum_path

生成缩略图路径

integer $max_w

缩略图最大宽度 px

integer $max_h

缩略图最大高度 px

Returns

\unknown

imageCropAndResize()

imageCropAndResize(string  $src_image, string  $dst_path, integer  $dst_x, integer  $dst_y, integer  $src_x, integer  $src_y, integer  $dst_w, integer  $dst_h, integer  $src_w, integer  $src_h) 

裁剪、缩放图片

Parameters

string $src_image

原始图

string $dst_path

裁剪后的图片保存路径

integer $dst_x

新图坐标x

integer $dst_y

新图坐标y

integer $src_x

原图坐标x

integer $src_y

原图坐标y

integer $dst_w

新图宽度

integer $dst_h

新图高度

integer $src_w

原图宽度

integer $src_h

原图高度

chImageSize()

chImageSize(string  $img, integer  $max_w, integer  $max_h) : array

按比例计算图片缩放尺寸

Parameters

string $img

图片路径

integer $max_w

最大缩放宽

integer $max_h

最大缩放高

Returns

array

getGravatar()

getGravatar(  $email,   $s = 40,   $d = 'mm',   $g = 'g') 

Parameters

$email
$s
$d
$g

getTimeZoneOffset()

getTimeZoneOffset(string  $remote_tz, string  $origin_tz = 'UTC') 

计算时区的时差

Parameters

string $remote_tz

远程时区

string $origin_tz

标准时区

getMonthDayNum()

getMonthDayNum(  $month,   $year) 

获取指定月份的天数

Parameters

$month
$year

emUnZip()

emUnZip(\type  $zipfile, \type  $path, \type  $type = 'tpl') : integer

解压zip

Parameters

\type $zipfile

要解压的文件

\type $path

解压到该目录

\type $type

Returns

integer

emZip()

emZip(  $orig_fname,   $content) 

zip压缩

Parameters

$orig_fname
$content

emFecthFile()

emFecthFile(\type  $source) : \临时文件地址

获取远程文件

Parameters

\type $source

远程文件地址

Returns

\临时文件地址

emDeleteFile()

emDeleteFile(  $file) 

删除文件或目录

Parameters

$file

emDirect()

emDirect(  $directUrl) 

页面跳转

Parameters

$directUrl

emMsg()

emMsg(string  $msg, string  $url = 'javascript:history.back(-1);', boolean  $isAutoGo = false) 

显示系统信息

Parameters

string $msg

信息

string $url

返回地址

boolean $isAutoGo

是否自动返回 true false

show_404_page()

show_404_page() 

显示404错误页面

emoFormat()

emoFormat(  $t) 

替换表情

Parameters

$t

hash_hmac()

hash_hmac(  $algo,   $data,   $key) 

Parameters

$algo
$data
$key

udir()

udir(string  $file = '', boolean  $remove_drive = false) : \unix

Unix Style Dir Name

Parameters

string $file

//original path

boolean $remove_drive

//If need to remove the Windows-like drive, i.e. C:\windows\system32...

Returns

\unix —

style path

get_mimetype()

get_mimetype(string  $extension) : string

根据文件后缀获取其mine类型

Parameters

string $extension

Returns

string