protected function lists($offset) { $where['status'] = 1; if ($offset) { $where = array('id' => array('gt', $offset)); } else { $limit = 10; } $data = $this->order('id desc')->limit($limit)->where($where)->select(array('hy' => true)); if (!is_array($data) || !count($data)) { return false; } $max = $data[0]['id']; $data = array_reverse($data); $userId = ss_uid(); foreach ($data as $k => &$v) { $v['user_id_text'] = $v['user_id_text']; $v['create_time'] = to_time($v['create_time'], 5); if ($userId == $v['user_id']) { $v['avatar_file'] = session('avatarFile'); } else { $v['avatar_file'] = avatar_file($v['avatar_file']); } unset($v['id']); } return array('list' => $data, 'offset' => $max); }
function ckavatar($uid) { $_SCONFIG['uc_dir'] = '/home/apache/data/html/ucenter/ucenter'; $file = $_SCONFIG['uc_dir'] . './data/avatar/' . avatar_file($uid, 'middle'); return file_exists($file) ? 1 : 0; }
function ckavatar($uid) { global $_SC, $_SCONFIG; $type = empty($_SCONFIG['avatarreal'])?'virtual':'real'; if(empty($_SCONFIG['uc_dir'])) { include_once(S_ROOT.'./uc_client/client.php'); $file_exists = uc_check_avatar($uid, 'middle', $type); return $file_exists; } else { $file = $_SCONFIG['uc_dir'].'./data/avatar/'.avatar_file($uid, 'middle'); return file_exists($file)?1:0; } }
/** * 用户头像HTML * @param number $id 头像fileId * @return string */ public static function getAvatarTpl($id) { return '<div class="img-thumbnail"><div style="width:200px;height:200px;background:url(' . avatar_file($id) . ') no-repeat;background-size:cover;"></div></div>'; }
function avatar($uid, $size = 'small', $returnsrc = FALSE) { global $_SCONFIG, $_SN; $size = in_array($size, array('big', 'middle', 'small')) ? $size : 'small'; $avatarfile = avatar_file($uid, $size); $avatarurl = UC_API . '/data/avatar/' . $avatarfile; $noavatarurl = UC_API . '/images/noavatar_' . $size . '.gif'; return $returnsrc ? $avatarurl : '<img src="' . $avatarurl . '" onerror="this.onerror=null;this.src=\'' . $noavatarurl . '\'">'; }
$dateline = $value['dateline']; $wheresql = "id = {$vid} AND idtype = 'videoid'"; $count = $_SGLOBAL['db']->result($_SGLOBAL['db']->query("SELECT COUNT(*) FROM " . tname('comment') . " WHERE {$wheresql} ")); $perpage = 5; $perpage = mob_perpage($perpage); $page = empty($_GET['page']) ? 0 : intval($_GET['page']); if ($page < 1) { $page = 1; } $start = ($page - 1) * $perpage; ckstart($start, $perpage); $theurl = "plugin.php?pluginid=video&ac=view&vid={$vid}"; $multi = multi($count, $perpage, $page, $theurl); $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname(comment) . " WHERE {$wheresql} ORDER BY dateline ASC LIMIT " . $start . "," . $perpage); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $avatar = avatar_file($value['authorid'], 'middle'); $value['avatar'] = $avatar; $comment[] = $value; } $res = array("id" => $id, "url" => $url, "title" => $title, "desc" => $desc, "author" => $author, "date" => $dateline, "comment" => $comment, "page" => $page, "count" => $count); } include_once template("/plugin/video/template/view"); } elseif ($ac == 'delete') { $vid = $_GET['vid']; $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname(video) . " WHERE id = {$vid} "); if ($value = $_SGLOBAL['db']->fetch_array($query)) { $video[] = $value; $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname(comment) . " WHERE vid = {$vid} AND idtype = 'videoid' ORDER BY datetime ASC "); while ($value = $_SGLOBAL['db']->query($query)) { $comment[] = $value; }
/** * 个人照片修改入口 * @param array $json */ public function ajax_avatar(&$json) { $this->updateFields[] = 'avatar_file'; $_POST['avatar_file'] = val_encrypt(token_validator(I('avatar_file'))); $json['status'] = !!$this->update(ss_uid()); if ($json['status']) { session('avatarFile', avatar_file($_POST['avatar_file'])); $json['reload'] = true; return $json['info'] = '头像修改成功!'; } $json['info'] = $this->getError() ?: '头像修改失败!'; }
/** * AJAX入口 */ public function ajax() { $logStep .= "登录验证"; $json = array('status' => false, 'info' => '', 'data' => ''); $u = aes_decrypt_base(I('u'), session('LOGIN_KEY')); $this->model = new HyAccountModel(); switch (I('get.q')) { // 登录验证 case 'login': if (!($user = $this->model->login($u))) { $json['info'] = '账号不存在或已禁用!' . $u; break; } $key = substr($user['password'], 5, 32); $true = aes_decrypt_base(I('p'), $key); if ($user['password'] != $true) { $json['info'] = '输入的密码有误!'; $logStep .= " >> <span class='text-warning'>密码错误</span>"; break; } // 单点登录限制 if (C('SINGLE_POINT_ONLINE') && $user['session_id'] && $user['session_id'] != session_id()) { $lastTime = M(ltrim(C('SESSION_TABLE'), C('DB_PREFIX')))->getFieldBySession_id($user['session_id'], 'session_expire'); if ($lastTime && TIME - $lastTime < C('SESSION_OPTIONS.expire')) { $json['info'] = '用户已经在线!如非正常退出,请稍后再试!'; break; } } $logStep .= " >> <span class='text-success'>成功</span>"; $json['info'] = '用户身份验证成功,玩命加载中...'; $json['data'] = rand(10000000, 99999999); // 缓存身份认证信息 session('USER_AGENT', $_SERVER['HTTP_USER_AGENT']); session('HOMYIT_BASE_AUTH_COUNTER', $json['data']); session('HOMYIT_BASE_AUTH_SEED', substr(sha1($user['password'] . '#' . $json['data']), 7, 32)); // 更新登录记录 $data['id'] = $user['id']; $data['login_last_time'] = time(); $data['login_times'] = ++$user['login_times']; $data['session_id'] = session_id(); $this->model->save($data); // 用户信息缓存 session('userId', $user['id']); session('userName', $user['name']); session('avatarFile', avatar_file($user['avatar_file'])); // 登录成功后置方法 $this->model->onLoginPass($user); // 角色信息缓存 $roleIdArr = array_unique(explode(',', trim($user['roles'], ','))); session('roleIdArr', $roleIdArr); $this->roleCache($roleIdArr[0]); $json['status'] = true; break; // 忘记密码 - 发送验证码 // 忘记密码 - 发送验证码 case 'forgetSendVerify': $email = trim(I('e')); $user = $this->model->where(array('user_no' => $u, 'status' => 1))->find(); if (!$user) { $json['info'] = '账号不存在或已禁用!'; break; } if (sha1(val_decrypt($user['email'])) != $email) { $logStep .= " >> <span class='text-warning'>忘记密码重置 - 邮箱验证失败!</span>"; $json['info'] = '您输入的邮箱地址与系统中保存的不一致,如有异议可联系辅导员!'; break; } if (!preg_match('/^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$/', $user['email'])) { $logStep .= " >> <span class='text-warning'>忘记密码重置 - 系统中的邮箱不合法!</span>"; $json['info'] = '邮箱地址不合法!'; break; } if (!($verify = $this->model->forgetPwdSendVerify($user['email']))) { $json['info'] = '邮件发送失败,请稍后重试!'; break; } session($user['user_no'] . '_forgetVerify', $verify); $json['status'] = true; $json['info'] = '邮件发送成功,请查收发送的验证码,并填入下框'; break; // 忘记密码 - 重置密码 // 忘记密码 - 重置密码 case 'forgetRestPwd': $user = $this->model->where(array('user_no' => $u, 'status' => 1))->find(); if (!$user) { $logStep .= " >> <span class='text-danger'>疑似攻击,已成功拦截!</span>"; $json['info'] = '请勿非法操作!'; break; } $verify = trim(I('v')); if (!$verify || $verify != session($user['user_no'] . '_forgetVerify')) { session($user['user_no'] . '_forgetVerify', null); $logStep .= " >> <span class='text-warning'>忘记密码重置 - 邮箱验证码无效!</span>"; $json['info'] = '您输入的验证码不正确,请重试!'; break; } $this->model->where(array('id' => $user['id']))->save(array('password' => D('HyAccount')->pwdEncrypt(trim(I('p')), true))); $json['status'] = true; $json['info'] = '密码重置成功,请重新登录!'; break; } // 登录日志 if ($user['id']) { $log = array('user_id' => $user['id'], 'controller' => CONTROLLER_NAME, 'action' => ACTION_NAME, 'post' => json_encode(I('post.')), 'description' => ' >> ' . $logStep, 'ip' => get_client_ip(), 'create_time' => time()); M('frame_log')->add($log); } $this->ajaxReturn($json); }
function capi_avatar($uid, $size = 'small') { global $_SCONFIG, $_SN; $size = in_array($size, array('big', 'middle', 'small')) ? $size : 'small'; $avatarfile = avatar_file($uid, $size); $url = UC_API . '/data/avatar/' . $avatarfile; /*if (file_get_contents($url,0,null,0,1)){ return $url; }*/ if (file_exists(S_ROOT . './center/data/avatar/' . $avatarfile)) { return $url; } else { return UC_API . '/images/noavatar_' . $size . '.gif'; } }
function public_interface($uid, $username, $cat) { global $_SGLOBAL; $cat_rel = array("1" => "学院", "2" => "部处", "3" => "名人", "4" => "学生组织", "5" => "兴趣社团", "6" => "学生党组织", "7" => "活动主页", "8" => "品牌主页", "20" => "班级主页", "100" => "航路研语", "200" => "名师工作坊"); if ($cat) { foreach ($cat_rel as $key => $value) { if ($value == $cat) { $cat = $key; break; } } } if ($uid) { $sql = "SELECT uid,username,pptype FROM ihome_space where uid=" . $uid . " and groupid=3"; $res = $_SGLOBAL['db']->query($sql); $arr = array(); if (empty($res)) { $arr = array("status" => "This uid not exists or not a public page!"); } else { $resuid = $uid; $resusername = ""; $rescat = ""; $cat_id = ""; while ($value = $_SGLOBAL['db']->fetch_array($res)) { $resusername = $value['username']; $rescat = $cat_rel[$value['pptype']]; $cat_id = $value['pptype']; } $r = $_SGLOBAL['db']->query('SELECT body_data,image_1,title_template FROM ihome.ihome_feed where uid=' . $uid . ' and image_2 = "" order by dateline desc limit 1'); $body_data = ""; $image = ""; $title_template = ""; while ($value = $_SGLOBAL['db']->fetch_array($r)) { $body_data = $value['body_data']; $image = $value['image_1']; $title_template = $value['title_tamplate']; } $arr = array("status" => "success", "uid" => $resuid, "username" => $resusername, "cat_id" => $cat_id, "avatar" => avatar_file($uid, 'middle'), "body_data" => $body_data, "title_template" => $title_template, "image" => $image, "category" => $rescat); } echo json_encode($arr); return json_encode($arr); } elseif ($username) { $sql = "SELECT uid,username,pptype FROM ihome_space where username='******' and groupid=3"; $res = $_SGLOBAL['db']->query($sql); $arr = array(); if (empty($res)) { $arr = array("status" => "This username not exists or not a public page!"); } else { $resuid = $uid; $resusername = ""; $rescat = ""; $cat_id = ""; while ($value = $_SGLOBAL['db']->fetch_array($res)) { $resusername = $value['username']; $rescat = $cat_rel[$value['pptype']]; $cat_id = $value['pptype']; } $r = $_SGLOBAL['db']->query('SELECT body_data,image_1,title_template FROM ihome.ihome_feed where username="******" and image_2 = "" order by dateline desc limit 1'); $body_data = ""; $image = ""; $title_template = ""; while ($value = $_SGLOBAL['db']->fetch_array($r)) { $body_data = $value['body_data']; $image = $value['image_1']; $title_template = $value['title_template']; } $arr = array("status" => "success", "uid" => $resuid, "username" => $resusername, "cat_id" => $cat_id, "avatar" => avatar_file($uid, 'middle'), "body_data" => $body_data, "title_template" => $value['title_template'], "image" => $image, "category" => $rescat); } echo json_encode($arr); return json_encode($arr); } elseif ($cat) { $sql = "SELECT uid,username,pptype FROM ihome_space where pptype=" . $cat . " and groupid=3"; $res = $_SGLOBAL['db']->query($sql); $arr = array(); if (empty($res)) { $arr = array("status" => "This category not exists or not a public page!"); } else { $resuid = $uid; $resusername = ""; $rescat = ""; $cats = array(); while ($value = $_SGLOBAL['db']->fetch_array($res)) { $resusername = $value['username']; $rescat = $value['pptype']; $resuid = $value['uid']; $r = $_SGLOBAL['db']->query('SELECT body_data,image_1,title_template FROM ihome.ihome_feed where uid=' . $resuid . ' and image_2 = "" order by dateline desc limit 1'); $body_data = ""; $image = ""; $title_template = ""; while ($value = $_SGLOBAL['db']->fetch_array($r)) { $body_data = $value['body_data']; $image = $value['image_1']; $title_template = $value['title_template']; } $cats[] = array("uid" => $value['uid'], "username" => $value['username'], "category" => $cat_rel[$value['pptype']], "body_data" => $body_data, "title_template" => $title_template, "image" => $image); } $arr = array("status" => "success", "categroies" => $cats); } echo json_encode($arr); return json_encode($arr); } else { echo json_encode($cat_rel); return json_encode($cat_rel); } }