返回列表 发帖

uchome 通用方法汇总

本帖最后由 沟渠王子 于 2009-7-4 06:40 编辑

了解了以下UCHOME的通用方法,将对我们的二次开发非常的有效,对于开发插件将更加的方便快捷
版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://remindme.blogbus.com/logs/30441570.html




function_common.php
引用:
//SQL ADDSLASHES
function saddslashes($string)   return $string;

//取消HTML代码
function shtmlspecialchars($string)  return $string;

//字符串解密加密
function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0)

//清空cookie
function clearcookie()

//cookie设置
function ssetcookie($var, $value, $life=0)

//数据库连接
function dbconnect()

//获取在线IP
function getonlineip($format=0)

//判断当前用户登录状态
function checkauth()

//获取用户app列表
function getuserapp($uid=0)

//获取到表名
function tname($name)

//对话框
function showmessage($msgkey, $url_forward='', $second=1, $values=array())

//判断提交是否正确
function submitcheck($var)

//添加数据
function inserttable($tablename, $insertsqlarr, $returnid=0, $replace = false, $silent=0)  return insert_id;

//更新数据
function updatetable($tablename, $setsqlarr, $wheresqlarr, $silent=0)

//获取用户空间信息
function getspace($key, $indextype='uid')

//获取当前用户信息
function getmember()

//检查隐私
function ckprivacy($type, $feedmode=0)

//检查APP隐私
function app_ckprivacy($privacy)


//获取用户组
function getgroupid($credit, $gid=0)

//检查权限
function checkperm($permtype)

//写运行日志
function runlog($file, $log, $halt=0)

//获取字符串
function getstr($string, $length, $in_slashes=0, $out_slashes=0, $censor=0, $bbcode=0, $html=0)

//时间格式化
function sgmdate($dateformat, $timestamp='', $format=0)

//字符串时间化
function sstrtotime($string)

//分页
function multi($num, $perpage, $curpage, $mpurl)

//ob
function obclean()

//模板调用
function template($name)

//子模板更新检查
function subtplcheck($subfiles, $mktime, $tpl)

//模块
function block($param)

//获取数目
function getcount($tablename, $wherearr, $get='COUNT(*)')

//调整输出
function ob_out()

//rewrite链接
function rewrite_url($pre, $para)

//外链
function iframe_url($url)

//处理搜索关键字
function stripsearchkey($string)

//是否屏蔽二级域名
function isholddomain($domain)

//连接字符
function simplode($ids)


//显示进程处理时间
function debuginfo()

//格式化大小函数
function formatsize($size)

//获取文件内容
function sreadfile($filename)

//写入文件
function swritefile($filename, $writetext, $openmod='w')

//产生随机字符
function random($length, $numeric = 0)

//判断字符串是否存在
function strexists($haystack, $needle)

//获取数据
function data_get($var, $isarray=0)

//更新数据
function data_set($var, $datavalue, $clean=0)

//检查站点是否关闭
function checkclose()

//站点链接
function getsiteurl()

//获取文件名后缀
function fileext($filename)

//积分
function creditrule($mode, $type)

//更新积分
function updatespacestatus($creditmode, $optype)

//去掉slassh
function sstripslashes($string)

//显示广告
function adshow($pagetype)

//编码转换
function siconv($str, $out_charset, $in_charset='')

//获取用户数据
function getpassport($username, $password)

//用户操作时间间隔检查
function interval_check($type)

//处理上传图片连接
function mkpicurl($pic, $thumb=1)

//处理网络图片链接
function getpicurl($picurl, $maxlenth='200')

//处理积分星星
function getstar($credit)

//处理分页
function smulti($start, $perpage, $count, $url, $ajaxdiv='')

//获取好友状态
function getfriendstatus($uid, $fuid)

//重新组建
function renum($array)

//检查定向
function ckfriend($invalue)

//整理feed
function mkfeed($feed, $actors=array())

//整理分享
function mkshare($share)

//ip访问允许
function ipaccess($ipaccess)

//ip访问禁止
function ipbanned($ipbanned)

//检查start
function ckstart($start, $perpage)

//处理头像
function avatar($uid, $size='small')

//检查是否登录
function checklogin()

//获得前台语言
function lang($key, $vars=array())

//获得后台语言
function cplang($key, $vars=array())

//语言替换
function lang_replace($text, $vars)

//获得用户组名
function getfriendgroup()

//截取链接
function sub_url($url, $length)

//获取用户名
function realname_set($uid, $username, $name='', $namestatus=0)

//获取实名
function realname_get()

//添加窗口标题
function window_set($title, $url, $icon='')

//更新用户配置
function update_space_setting()

//群组信息
function getmtag($id)

//取数组中的随机个
function sarray_rand($arr, $num)

//获得用户唯一串
function space_key($space)

//产生form防伪码
function formhash()
function_cache.php
引用:
//更新配置文件
function config_cache($updatedata=true)

//更新用户组CACHE
function usergroup_cache()

//更新用户栏目缓存
function profilefield_cache()

//更新群组栏目缓存
function profield_cache()

//更新词语屏蔽
function censor_cache()

//更新积分规则
function creditrule_cache()

//更新广告缓存
function ad_cache()

//更新用户向导任务
function task_cache()

//更新模块
function block_cache()

//更新模板文件
function tpl_cache()

//更新模块缓存
function block_data_cache()

//更新应用名
function app_cache()

//递归清空目录
function deltreedir($dir)

//数组转换成字串
function arrayeval($array, $level = 0)

//写入
function cache_write($name, $var, $values)
function_cp.php
引用:
//保存图片
function pic_save($FILE, $albumid, $title ,$tid = 0)

//数据流保存,所有数据均为存放相册的所以写入的数据一定只能是图片
function stream_save($strdata, $albumid = 0, $fileext = 'jpg')

//创建相册
function album_creat($arr)

//获取上传路径
function getfilepath($fileext, $mkdir=false)

//获取目录
function sreaddir($dir, $extarr=array())

//检查邮箱是否有效
function isemail($email)

//获取相册封面图片
function getalbumpic($uid, $id)

//获取个人分类
function getclassarr($uid)

//获取相册
function getalbums($uid)

//事件发布
function feed_add($icon, $title_template='', $title_data=array(), $body_template='', $body_data=array(),

$body_general='', $images=array(), $image_links=array(), $target_ids='', $friend='', $appid=UC_APPID,

$returnid=0, $system=0)

//分享发布
function share_add($type, $title_template, $body_template, $body_data, $body_general, $image='',

$image_link='')

//通知
function notification_add($uid, $type, $note, $returnid=0)

//更新好友状态
function friend_update($uid, $username, $fuid, $fusername, $op='add', $gid=0)

//更新好友缓存
function friend_cache($uid)

//检查验证码
function ckseccode($seccode)

//相册产生feed
function album_feed($albumid)

//更新隐私设置
function privacy_update()

//邀请好友
function invite_update($inviteid, $uid, $username, $m_uid, $m_username)

//获得邀请
function invite_get($uid, $code)

//实名认证
function ckrealname($type)

//邮件队列
function addmailcron($touid, $email, $subject, $message='', $mailtype='')

//检查头像是否上传
function ckavatar($uid)

//检查黑名单
function isblacklist($to_uid)
//管理后台通用方法

function_admincp.php

//获取限制条件
function getwheres($intkeys, $strkeys, $randkeys, $likekeys, $pre='')

//获取排序
function getorders($alloworders, $default, $pre='')

//对话框
function cpmessage($msgkey, $url_forward='', $second=1, $values=array())

//检查是否操作创始人
function ckfounder($uid)

//生成站点key
function mksitekey()

//统计数据
function getstatistics()

//日志
function admincp_log()
function_op.php    //帖子操作方法

//合并tag
function mergetag($tagids, $newtagid)

//锁定/开放tag
function closetag($tagids, $optype)

//合并mtag
function mergemtag($tagids, $newtagid)

//锁定/开放tag
function closemtag($tagids, $optype)

//话题精华
function digestthreads($tagid, $tids, $v)

//话题置顶
function topthreads($tagid, $tids, $v)
//模块解析通用方法
function_block.php        
        
//处理模块
function block_batch($param)

//获取模块缓存
function block_get($cachekey)

//更新模块
function block_set($cachekey, $blockarr)

//字符串解析
function parseparameter($param)

//获取缓存分类名
function getcachedirname($cachekey, $ext='')

//MD5规则取缓存名
function smd5($str)

//获取数量sql
function getcountsql($sqlstring, $rule, $tablename, $where)

//获取数量和查询语句
function getparamsql($paramarr)

function mksqltime($time)

我本将心像明月,奈何明月照......

好东西,谢谢分享

TOP

细化下几个必须会用的:
希望能和大家一起学习。使用好uchome的这些常用函数,就可以更灵活的修改、订制自己想要的一些简单功能。

showmessage();
函数作用:对话框,用于信息提示,跳转功能。
代码片断:showmessage(‘操作成功!’,’index.php’,5);
解释:符合特定条件后,提示“操作成功!”5秒后跳转到index.php页。

inserttable();
函数作用:向数据库中某表插入记录。
代码片断:$userinfo=array(‘username’ => ‘wufujun2000’,’sex’=>’男’);
               $uid = inserttable(‘member’, $userinfo, 1);
              if($uid){
                  showmessage(‘用户注册成功’,’index.php’);
              }else{
                 showmessage(‘注册失败’);
              }
解释:建立一个数组,脚标分别对应数据库中的字段名,username赋值为wufujun,sex赋值为男,通过inserttable函数向数据库中的member表中插入记录,记录内容为$userinfo中的内容,参数1表示,插入成功后返回新插入记录的ID号,插入失败则不返回,通过判断$uid是否有值,来确定数据是否插入成功。


updatetable();
函数作用:更新数据库中某表符合条件的记录。
代码片断:$uid = 1
               $userinfo=array(’sex’=>’女’);
               updatetable(‘member’,$userinfo,array(‘uid’=>$uid));
解释:更新member表中uid=1的记录,把sex的值改为‘女’。


getspace();
函数作用:获取用户空间信息。
代码片断:$uid = 1
               $space = getspace($uid,’uid’,0);
解释:获取uid=1的用户空间信息。获取后的$space为数组变量,通过脚标得到最终想要的数据,如想获取用户名可以写成$username = $space[‘username’],其它空间信息数据以此类推。


avatar ();
函数作用:获取用户头像。
代码片断:$uid = 1
               avatar($uid,’small’);
解释:此函数一般用于模板之中,获取用户头像。上面的片断为获取uid=1的用户的小头像,如要获取中或者大的头像,把’small’改成想应的’middle’或’big’。

先总结这5个最常用的,我会继续整理,不断总结。

再总结两个简单的,也很常用的


checkclose();
函数作用:判断站点是否关闭。
代码片断:checkclose();
解释:这个函数一般写在代码的最开始,用于判断站点否关闭,如果在后台设置了站点关闭,那么在访问代码的时候,除了管理员,都会提示在后台设的站点关闭提示语.


getstr();
函数作用:获取字符串。这个函数是对字符串操作的,通过参数设定有很多的用处,比如可以去掉字符串里的html代码,词语屏蔽等功能,这里只介绍最常用也是最实用的功能--字符串截取。
代码片断:$summarylen = 6;
               $title = "好好学习天天向上";
               $showtitle = getstr($showtitle, $summarylen);
解释:把“好好学习天天向上”截取3个字,最后$showtitle的值为“好好学”,对于GBK的编码来说,一个汉字等于2个字节,也就是$summarylen=6截取的是3个汉字,UTF8的编码一个汉字等于3个字节,所以这段代码在UFT8的编码下最后$showtitle的值为 “好好”。
我酒量、二两!
             陪你、舍命!

TOP

返回列表