public function deleteUser($ids) { vendor("common"); @set_time_limit(0); if (function_exists('ini_set')) { ini_set('max_execution_time', 0); } $id_arr = explode(',', $ids); $ids = implode(',', $id_arr); if (empty($ids)) { return false; } //==================添加第三方整合会员添加 chenfq 2011-10-14================ foreach ($id_arr as $uid) { $user = $this->getById($uid); $user_field = fanweC('INTEGRATE_FIELD_ID'); $integrate_id = intval($user[$user_field]); if ($integrate_id > 0) { FS("Integrate")->adminInit(fanweC('INTEGRATE_CODE'), fanweC('INTEGRATE_CONFIG')); FS("Integrate")->delUser($integrate_id); //exit; } } //==================添加第三方整合会员添加chenfq 2011-10-14================ $condition = array('uid' => array('in', $id_arr)); if (false !== $this->where($condition)->delete()) { D('AskPost')->where($condition)->delete(); D('AskThread')->where($condition)->delete(); D('ForumPost')->where($condition)->delete(); D('ForumThread')->where($condition)->delete(); D('ManageLog')->where($condition)->delete(); D('SecondGoods')->where($condition)->delete(); D('ShareComment')->where($condition)->delete(); M()->query('DELETE FROM ' . C("DB_PREFIX") . 'share_category WHERE share_id IN (SELECT share_id FROM ' . C("DB_PREFIX") . 'share WHERE uid IN (' . $ids . '))'); M()->query('DELETE FROM ' . C("DB_PREFIX") . 'share_match WHERE share_id IN (SELECT share_id FROM ' . C("DB_PREFIX") . 'share WHERE uid IN (' . $ids . '))'); M()->query('DELETE FROM ' . C("DB_PREFIX") . 'share_tags WHERE share_id IN (SELECT share_id FROM ' . C("DB_PREFIX") . 'share WHERE uid IN (' . $ids . '))'); $res = FDB::query('SELECT share_id FROM ' . FDB::table('share') . ' WHERE uid IN (' . $ids . ')'); while ($data = FDB::fetch($res)) { $key = getDirsById($data['share_id']); clearCacheDir('share/' . $key); clearDir(PUBLIC_ROOT . './upload/share/' . $key, true); } D('Share')->where($condition)->delete(); D('ShareGoods')->where($condition)->delete(); D('SharePhoto')->where($condition)->delete(); D('UserAttention')->where($condition)->delete(); D('UserAuthority')->where($condition)->delete(); D('UserCount')->where($condition)->delete(); //删除喜欢收藏 $list = M()->query('SELECT uid,COUNT(uid) AS ccount FROM ' . C("DB_PREFIX") . 'user_collect WHERE c_uid IN (' . $ids . ') GROUP BY uid'); foreach ($list as $data) { M()->query('UPDATE ' . C("DB_PREFIX") . 'user_count SET collects = collects - ' . $data['ccount'] . ' WHERE uid = ' . $data['uid']); } M()->query('DELETE FROM ' . C("DB_PREFIX") . 'user_collect WHERE c_uid IN (' . $ids . ')'); //删除粉丝关注 $list = M()->query('SELECT uid FROM ' . C("DB_PREFIX") . 'user_follow WHERE f_uid IN (' . $ids . ') GROUP BY uid'); foreach ($list as $data) { M()->query('UPDATE ' . C("DB_PREFIX") . 'user_count SET fans = fans - 1 WHERE uid = ' . $data['uid']); } $list = M()->query('SELECT f_uid FROM ' . C("DB_PREFIX") . 'user_follow WHERE uid IN (' . $ids . ') GROUP BY f_uid'); foreach ($list as $data) { M()->query('UPDATE ' . C("DB_PREFIX") . 'user_count SET fans = follows - 1 WHERE uid = ' . $data['f_uid']); } M()->query('DELETE FROM ' . C("DB_PREFIX") . 'user_follow WHERE f_uid IN (' . $ids . ')'); M()->query('DELETE FROM ' . C("DB_PREFIX") . 'user_follow WHERE uid IN (' . $ids . ')'); D('UserDaren')->where($condition)->delete(); D('UserMedal')->where($condition)->delete(); D('UserMeTags')->where($condition)->delete(); M()->query('DELETE FROM ' . C("DB_PREFIX") . 'user_msg WHERE author_id IN (' . $ids . ')'); D('UserMsgRel')->where($condition)->delete(); D('UserNotice')->where($condition)->delete(); D('UserProfile')->where($condition)->delete(); D('UserStatistics')->where($condition)->delete(); D('UserStatus')->where($condition)->delete(); foreach ($id_arr as $uid) { $this->deleteUserAvatar($uid); } return true; } else { return false; } }
function strZTime($str) { $str = trim($str); if (empty($str)) { return 0; } $time_zone = intval(fanweC('TIME_ZONE')); $time = strtotime($str) - $time_zone * 3600; return $time; }
public function update() { $uid = intval($_REQUEST['uid']); $name = $this->getActionName(); $model = D($name); $avatar_img = ''; if ($upload_list = $this->uploadImages()) { $avatar_img = $upload_list[0]['recpath'] . $upload_list[0]['savename']; } //if (fanweC('INTEGRATE_CODE') != 'fanwe'){ //==================添加email,user_name是否允许修改判断chenfq 2011-10-14================ Vendor("common"); $old_user = $model->getById($uid); //第三方整合关联ID,在对应的user表中,要创建应该字段 $user_field = fanweC('INTEGRATE_FIELD_ID'); $integrate_id = intval($old_user[$user_field]); $old_user_name = $old_user['user_name']; $old_email = $old_user['email']; $new_user_name = $_REQUEST['user_name']; $new_email = $_REQUEST['email']; //$user_name = $old_user_name; if ($old_email == $new_email) { $new_email = ''; //新旧email一至,无需修改 } if ($old_user_name == $new_user_name) { $new_user_name = ''; //新旧email一至,无需修改 } if ($_REQUEST['password'] == '') { $new_pwd = ''; } else { $new_pwd = $_REQUEST['password']; } if (!empty($new_email) && $integrate_id > 0) { FS("Integrate")->adminInit(fanweC('INTEGRATE_CODE'), fanweC('INTEGRATE_CONFIG')); if (!FS("Integrate")->getCheckEmail($new_email, $integrate_id)) { $info = FS("Integrate")->getInfo(); $this->saveLog(0, $uid); $this->error($info); } } if (!empty($new_user_name) && $integrate_id > 0) { FS("Integrate")->adminInit(fanweC('INTEGRATE_CODE'), fanweC('INTEGRATE_CONFIG')); if (!FS("Integrate")->getCheckUserName($new_user_name, $integrate_id)) { $info = FS("Integrate")->getInfo(); $this->saveLog(0, $uid); $this->error($info); } } //==================添加email,user_name是否允许修改判断chenfq 2011-10-14================ //} if (false === ($data = $model->create())) { $this->error($model->getError()); } if ($_REQUEST['password'] == '') { unset($data['password']); } $data['user_name_match'] = segmentToUnicodeA($data['user_name']); // 更新数据 $list = $model->save($data); if (false !== $list) { if ($_REQUEST['delete_avatar'] == 1) { D('User')->deleteUserAvatar($uid); } if (!empty($avatar_img)) { FS('User')->saveAvatar($uid, FANWE_ROOT . $avatar_img); } D('UserStatus')->where('uid = ' . $uid)->save($_REQUEST['us']); D('UserProfile')->where('uid = ' . $uid)->save($_REQUEST['up']); D('UserAuthority')->where('uid = ' . $uid)->delete(); $access_list = $_REQUEST['access_node']; foreach ($access_list as $module => $actions) { $index = 0; foreach ($actions as $action) { $item = array(); $item['uid'] = $uid; $item['module'] = $module; $item['action'] = $action; $item['sort'] = $index++; D('UserAuthority')->add($item); } } //if (fanweC('INTEGRATE_CODE') == 'fanwe'){ // Vendor("common"); //} FS("User")->deleteUserCache($uid); //==================添加email,user_name修改chenfq 2011-10-14================ if ($integrate_id > 0 && (!empty($new_pwd) || !empty($new_email) || !empty($new_user_name))) { FS("Integrate")->adminInit(fanweC('INTEGRATE_CODE'), fanweC('INTEGRATE_CONFIG')); FS("Integrate")->editUser($integrate_id, $new_pwd, $new_email, $new_user_name); $info = FS("Integrate")->getInfo(); } //==================添加email,user_name修改chenfq 2011-10-14================ $this->saveLog(1, $uid); $this->assign('jumpUrl', Cookie::get('_currentUrl_')); $this->success(L('EDIT_SUCCESS')); } else { //错误提示 $this->saveLog(0, $uid); $this->error(L('EDIT_ERROR')); } }
public function deleteUser($id_arr) { $ids = implode(',', $id_arr); vendor("common"); @set_time_limit(0); if (function_exists('ini_set')) { ini_set('max_execution_time', 0); } //==================添加第三方整合会员添加 chenfq 2011-10-14================ foreach ($id_arr as $uid) { $user = $this->getById($uid); $user_field = fanweC('INTEGRATE_FIELD_ID'); $integrate_id = intval($user[$user_field]); if ($integrate_id > 0) { FS("Integrate")->adminInit(fanweC('INTEGRATE_CODE'), fanweC('INTEGRATE_CONFIG')); FS("Integrate")->delUser($integrate_id); //exit; } } //==================添加第三方整合会员添加chenfq 2011-10-14================ $condition = array('uid' => array('in', $id_arr)); if (false !== $this->where($condition)->delete()) { D('AskPost')->where($condition)->delete(); D('AskThread')->where($condition)->delete(); D('Atme')->where($condition)->delete(); D('ForumPost')->where($condition)->delete(); D('ForumThread')->where($condition)->delete(); D('ManageLog')->where($condition)->delete(); D('NedalApply')->where($condition)->delete(); D('Order')->where($condition)->delete(); D('PubSchedule')->where($condition)->delete(); D('Referrals')->where($condition)->delete(); M()->query('DELETE FROM ' . C("DB_PREFIX") . 'referrals WHERE rid IN (' . $rel_ids . '))'); M()->query('UPDATE ' . C("DB_PREFIX") . 'user SET invite_id = 0 WHERE invite_id IN (' . $rel_ids . '))'); D('SecondGoods')->where($condition)->delete(); D('ShareComment')->where($condition)->delete(); D('Sessions')->where($condition)->delete(); D('SysMsg')->where($condition)->delete(); D('SysMsgMember')->where($condition)->delete(); D('SysMsgUserNo')->where($condition)->delete(); D('SysMsgUserYes')->where($condition)->delete(); D('SysNotice')->where($condition)->delete(); D('UserAttention')->where($condition)->delete(); D('UserAuthority')->where($condition)->delete(); D('UserCount')->where($condition)->delete(); D('UserBind')->where($condition)->delete(); D('UserConsignee')->where($condition)->delete(); //删除粉丝关注 $list = M()->query('SELECT uid FROM ' . C("DB_PREFIX") . 'user_follow WHERE f_uid IN (' . $ids . ') GROUP BY uid'); foreach ($list as $data) { M()->query('UPDATE ' . C("DB_PREFIX") . 'user_count SET fans = fans - 1 WHERE uid = ' . $data['uid']); } $list = M()->query('SELECT f_uid FROM ' . C("DB_PREFIX") . 'user_follow WHERE uid IN (' . $ids . ') GROUP BY f_uid'); foreach ($list as $data) { M()->query('UPDATE ' . C("DB_PREFIX") . 'user_count SET follows = follows - 1 WHERE uid = ' . $data['f_uid']); } M()->query('DELETE FROM ' . C("DB_PREFIX") . 'user_follow WHERE f_uid IN (' . $ids . ')'); M()->query('DELETE FROM ' . C("DB_PREFIX") . 'user_follow WHERE uid IN (' . $ids . ')'); D('UserDaren')->where($condition)->delete(); D('UserMedal')->where($condition)->delete(); D('UserMeTags')->where($condition)->delete(); M()->query('DELETE FROM ' . C("DB_PREFIX") . 'user_msg WHERE author_id IN (' . $ids . ')'); D('UserMsg0')->where($condition)->delete(); D('UserMsg1')->where($condition)->delete(); D('UserMsg2')->where($condition)->delete(); D('UserMsg3')->where($condition)->delete(); D('UserMsg4')->where($condition)->delete(); D('UserMsg5')->where($condition)->delete(); D('UserMsg6')->where($condition)->delete(); D('UserMsg7')->where($condition)->delete(); D('UserMsg8')->where($condition)->delete(); D('UserMsg9')->where($condition)->delete(); D('UserMsgList')->where($condition)->delete(); D('UserMsgMember')->where($condition)->delete(); D('UserNotice')->where($condition)->delete(); D('UserProfile')->where($condition)->delete(); D('UserStatistics')->where($condition)->delete(); D('UserStatus')->where($condition)->delete(); D('UserScoreLog')->where($condition)->delete(); D('UserStatistics')->where($condition)->delete(); foreach ($id_arr as $uid) { $this->deleteUserAvatar($uid); } return true; } else { return false; } }
/** +---------------------------------------------------------- * 登录检测 +---------------------------------------------------------- */ public function checkLogin() { if (empty($_POST['admin_name'])) { $this->error(L('ADMIN_NAME_REQUIRE')); } elseif (empty($_POST['admin_pwd'])) { $this->error(L('ADMIN_PWD_REQUIRE')); } elseif (empty($_POST['verify'])) { $this->error(L('VERIFY_REQUIRE')); } //生成认证条件 $map = array(); // 支持使用绑定帐号登录 $map['admin_name'] = $_POST['admin_name']; $map["status"] = array('gt', 0); if ($_SESSION['verify'] != md5($_POST['verify'])) { $this->error(L('VERIFY_ERROR')); } import('@.ORG.RBAC'); $auth_info = RBAC::authenticate($map); //使用用户名、密码和状态的方式进行认证 if (false === $auth_info) { $this->saveLog(0, 0); $this->error(L('ADMIN_NAME_NOT_EXIST')); } else { if ($auth_info['admin_pwd'] != md5($_POST['admin_pwd'])) { $this->saveLog(0, 0); $this->error(L('ADMIN_PWD_ERROR')); } Session::setExpire(time() + fanweC("EXPIRED_TIME") * 60); $_SESSION[C('USER_AUTH_KEY')] = $auth_info['id']; $_SESSION['admin_name'] = $auth_info['admin_name']; $_SESSION['last_time'] = $auth_info['last_time']; $_SESSION['login_count'] = $auth_info['login_count']; if ($auth_info['admin_name'] == fanweC('SYS_ADMIN')) { $_SESSION[C('ADMIN_AUTH_KEY')] = true; } //保存登录信息 $admin = M(C('USER_AUTH_MODEL')); $ip = getClientIp(); $time = gmtTime(); $data = array(); $data['id'] = $auth_info['id']; $data['last_login_time'] = $time; $data['login_count'] = array('exp', 'login_count + 1'); $data['last_login_ip'] = $ip; $admin->save($data); // 缓存访问权限 RBAC::saveAccessList(); $this->saveLog(1, 0); $this->success(L('LOGIN_SUCCESS')); } }
public function edit() { /* $set_modules = true; include_once(FANWE_ROOT.'core/include/integrates/'.$_GET['code'].".php"); $set_modules = false; */ $user_field = fanweC('INTEGRATE_FIELD_ID'); $this->assign('user_field', $user_field); // $modules[0]['user_field']); if ($_GET['code'] == 'fanwe') { $this->assign('jumpUrl', U('Integrate/index')); $this->error('当您采用FANWE会员系统时,无须进行设置。'); } else { $cfg = unserialize(fanweC('INTEGRATE_CONFIG')); $this->assign('save', 1); $this->assign('set_list', $this->get_charset_list()); $this->assign('code', $_GET['code']); $this->assign('cfg', $cfg); //dump($this->get_charset_list()); $this->display('edit'); } }
protected function saveLog($result = '1', $data_id = 0, $msg = '') { if (fanweC("APP_LOG") == 0) { return; } $log_app = unserialize(fanweC("LOG_APP")); $log_module = MODULE_NAME; $log_action = ACTION_NAME; if (in_array(strtolower($log_action), $log_app[strtolower($log_module)])) { $log_data = array(); $log_data['log_module'] = $log_module; $log_data['log_action'] = $log_action; if (!$data_id) { $pk = M(MODULE_NAME)->getPk(); $data_id = intval($_REQUEST[$pk]); } $log_data['data_id'] = $data_id; $log_data['log_time'] = gmtTime(); $log_data['admin_id'] = intval($_SESSION[C("USER_AUTH_KEY")]); $log_data['ip'] = getClientIp(); $log_data['log_result'] = $result; $log_data['log_msg'] = $msg; $log_data['log_request'] = print_r($_REQUEST, true); D("AdminLog")->add($log_data); } }