/** * 功能:自动生成邮箱地址 * @author wxb * 日期:2013/10/31 * */ function act_createEmailField() { $table = "power_global_user"; $filed = "global_user_id"; $where = " global_user_is_delete = 0 AND global_user_status = 1 "; $ret = NoticeApiModel::selectOneTable($table, $filed, $where); if (!$ret) { exit('search user fail'); } $err = array(); $rightCount = 0; foreach ($ret as $val) { $where = " global_user_status = 1 AND global_user_is_delete = 0 AND global_user_id = '{$val['global_user_id']}' "; $loginName = NoticeApiModel::selectOneTable($table, 'global_user_login_name', $where); if (!$loginName[0]['global_user_login_name']) { $err[] = $val['global_user_id']; continue; } $loginName = $loginName[0]['global_user_login_name']; $email = $loginName . "@sailvan.com"; $res = UserModel::createEmailField($email, $where); if (!$res) { $err[] = $val['global_user_id']; } else { $rightCount++; } } var_dump(count($ret), $rightCount, $err); }
public function selectOneTable($table, $filed, $where) { return NoticeApiModel::selectOneTable($table, $filed, $where); }
/** * 从邮件分表中获取某条完全的内容 * @param str $pageToken * @author wxb * 2104/01/20 */ function getEmailByMain($pageToken) { $con = ''; $fields = 'content'; $where = "is_delete = 0 AND main_number = '{$pageToken}'"; $cons = NoticeApiModel::getEmailDetail($fields, $where); if (!$cons) { return false; } foreach ($cons as $val) { $con .= base64_decode($val['content']); } return $con; }
/** * UserModel::userLogin() * 用户登录走开放系统 * add by 管拥军 2013-08-21 * * @return bool */ public static function userLogin($username, $password) { $paramArr = array('method' => 'power.user.login.get', 'format' => 'json', 'v' => '1.0', 'username' => 'notice', 'user_name' => $username, 'pwd' => rawurldecode($password), 'sysName' => self::$sysName, 'sysToken' => self::$sysToken); $loginInfo = callOpenSystem($paramArr); unset($paramArr); $loginInfo = json_decode($loginInfo); if (isset($loginInfo->errCode)) { echo $loginInfo->errMsg; self::$errCode = $loginInfo->errCode; self::$errMsg = $loginInfo->errMsg; return false; } if (isset($loginInfo->error_response)) { echo $loginInfo->error_response->msg; self::$errCode = $loginInfo->error_response->code; self::$errMsg = $loginInfo->error_response->msg; return false; } $_SESSION['userToken'] = $loginInfo->userToken; $_SESSION['sysUserId'] = $loginInfo->userId; // 分系统用户ID $_SESSION['userId'] = $loginInfo->globalUserId; // 统一用户系统ID $_SESSION['userName'] = $loginInfo->userName; $_SESSION['companyId'] = $loginInfo->company; //获取中文名 $table = "`power_global_user`"; $filed = "global_user_name"; $where = " global_user_is_delete = 0 AND global_user_status = 1 AND global_user_login_name='{$username}' LIMIT 1"; $ret = NoticeApiModel::selectOneTable($table, $filed, $where); if ($ret) { $cnName = $ret[0]['global_user_name']; } $_SESSION['cnName'] = $cnName; $isAdmin = '0'; $_SESSION['isAdmin'] = $isAdmin; log::write(var_export($_SESSION, true), log::DEBUG); return "ok"; }
public static function insert($data, $table) { self::initDB(); $sql = array2sql($data); $sql = "INSERT INTO `" . $table . "` SET " . $sql; //echo $sql; $query = self::$dbConn->query($sql); if ($query) { $affectedrows = self::$dbConn->affected_rows(); return $affectedrows; } else { self::$errCode = "1060"; self::$errMsg = "获取数据失败"; return false; } }