1 Star 0 Fork 12

hlbejy/poscms_xcx

forked from dayrui/poscms_xcx 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
my_helper.php 2.08 KB
一键复制 编辑 原始数据 按行查看 历史
dayrui 提交于 2017-09-21 10:17 . 更新 my_helper.php
<?php
// 此文件放到cms目录下:\diy\dayrui\helpers\my_helper.php
// 如果你cms已经定义过自定义函数的话,直接把下面三个函数放在原文件的下面即可
// 格式化查询列表list
function dr_my_list($data) {
if ($data['return']) {
$rt = array();
foreach ($data['return'] as $t) {
if (is_numeric($t['inputtime'])) {
$t['inputtime'] = dr_date( $t['inputtime']);
}
if (is_numeric($t['uid'])) {
$t['avatar'] = dr_avatar( $t['uid']);
}
$t['thumb'] = dr_url_prefix(dr_thumb( $t['thumb']));
$rt[] = $t;
}
$data['return'] = $rt;
}
return $data;
}
// 我的收藏
function dr_my_favorite($mid, $uid, $pagesize, $page = 1) {
$mid = dr_safe_replace($mid);
$uid = intval($uid);
$page = max(1, intval($page));
$e = intval($pagesize);
$s = ($page-1) * $e;
$ci = &get_instance();
$prefix = $ci->db->dbprefix(SITE_ID.'_'.$mid);
$sql = "select * from {$prefix} where id in(select cid from `{$prefix}_favorite` where uid={$uid} order by inputtime) Limit {$s},{$e}";
$data = $ci->db->query($sql)->result_array();
$now = array();
foreach ($data as $t) {
$t['thumb'] = dr_url_prefix(dr_thumb( $t['thumb']));
$t['inputtime'] = dr_date( $t['inputtime']);
$now[] = $t;
}
return $now;
}
// 我的评论
function dr_my_comment($mid, $uid, $pagesize, $page = 1) {
$mid = dr_safe_replace($mid);
$uid = intval($uid);
$page = max(1, intval($page));
$e = intval($pagesize);
$s = ($page-1) * $e;
$ci = &get_instance();
$prefix = $ci->db->dbprefix(SITE_ID.'_'.$mid);
$sql = "select a.* from `{$prefix}_comment_data_0` as a where a.uid={$uid} order by a.inputtime Limit {$s},{$e}";
$data = $ci->db->query($sql)->result_array();
$now = array();
foreach ($data as $t) {
$t['inputtime'] = dr_date( $t['inputtime']);
$now[] = $t;
}
return $now;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
微信
1
https://gitee.com/hlbejy/poscms_xcx.git
git@gitee.com:hlbejy/poscms_xcx.git
hlbejy
poscms_xcx
poscms_xcx
master

搜索帮助