示例#1
0
 public function sendSMSAction($mobiles, $msg)
 {
     $SmsFunction = null;
     try {
         $syspara = new \Justsy\BaseBundle\DataAccess\SysParam($this->container);
         $SmsFunction = $syspara->GetSysParam('SMS_FUNCTION_NAME', '');
     } catch (\Exception $e) {
         return Utils::WrapResultError($e->getMessage());
     }
     if (!empty($SmsFunction)) {
         $re = call_user_func(array($this, $SmsFunction), $mobiles, $msg);
         return $re;
     }
     $SMS_ACT = $this->container->getParameter('SMS_ACT');
     $SMS_PWD = $this->container->getParameter('SMS_PWD');
     $SMS_URL = $this->container->getParameter('SMS_URL');
     $mobiles = str_replace(";", ",", $mobiles);
     $content = urlEncode(urlEncode(mb_convert_encoding($msg, 'gb2312', 'utf-8')));
     $pwd = md5($SMS_PWD);
     $apidata = "func=sendsms&username={$SMS_ACT}&password={$pwd}&mobiles={$mobiles}&message={$content}&smstype=0&timerflag=0&timervalue=&timertype=0&timerid=0";
     $this->get("logger")->err($SMS_URL . "?" . $apidata);
     $result = mb_convert_encoding($this->do_post_request($SMS_URL . "?" . $apidata, null), 'utf-8', 'gb2312');
     $this->get("logger")->err($result);
     return Utils::WrapResultOK('');
 }
示例#2
0
 public function imServerCtl($paraObj)
 {
     $command = $paraObj['command'];
     if (empty($command)) {
         $result = Utils::WrapResultError("无效的命令");
         return $this->responseJson($result);
     }
     try {
         $syspara = new \Justsy\BaseBundle\DataAccess\SysParam($this->container);
         $ejabberd_server_path = $syspara->GetSysParam('ejabberd_server_path', '');
         if (empty($ejabberd_server_path)) {
             return Utils::WrapResultError('请检查参数ejabberd_server_path设置是否正确有效!');
         }
         if ($command == "start") {
             $command = $ejabberd_server_path . "/bin/ejabberdctl status";
             $data = shell_exec($command);
             if (strpos($data, 'is running') !== false) {
                 $data = shell_exec($ejabberd_server_path . "/bin/ejabberdctl restart");
             } else {
                 if (strpos($dta, 'nodedown') !== false) {
                     $data = shell_exec($ejabberd_server_path . "/bin/ejabberdctl start");
                 }
             }
             return Utils::WrapResultOK($data);
         } else {
             if ($command == "status") {
                 $command = $ejabberd_server_path . "/bin/ejabberdctl status";
                 $data = shell_exec($command);
                 return Utils::WrapResultOK($data);
             } else {
                 if ($command == "stop") {
                     $command = $ejabberd_server_path . "/bin/ejabberdctl stop";
                     $data = shell_exec($command);
                     return Utils::WrapResultOK($data);
                 }
             }
         }
         return Utils::WrapResultError('无效的命令' . $command);
     } catch (\Exception $e) {
         $this->logger->err($e);
         return Utils::WrapResultError($e->getMessage());
     }
 }
示例#3
0
 public function addGroupEmployeeMulti($parameter)
 {
     $da_im = $this->conn_im;
     $sql = "";
     $para = array();
     $groupid = $parameter["groupid"];
     $deptid = $parameter["deptid"];
     //允许加入的部门
     $allow_jid = $parameter["allow_jid"];
     //允许加入的特定人员
     $user = $parameter["user"];
     $user_jid = $user->fafa_jid;
     $eno = $user->eno;
     $groupname = $parameter["groupname"];
     $sql = "select loginname,employeename from im_employee ";
     $condition = "";
     //取部门下的人员
     if (count($deptid) > 0) {
         $deptid = $this->getChildrenDept($eno, $deptid);
         $condition = " where deptid in(";
         for ($i = 0; $i < count($deptid); $i++) {
             $condition = $condition . "?,";
             array_push($para, (string) $deptid[$i]);
         }
         $condition = rtrim($condition, ",") . ")";
     }
     //允许人员
     if (!empty($allow_jid) && count($allow_jid) > 0) {
         $condition .= empty($condition) ? " where loginname in(" : " or loginname in(";
         for ($i = 0; $i < count($allow_jid); $i++) {
             $condition = $condition . "?,";
             array_push($para, (string) $allow_jid[$i]);
         }
         $condition = rtrim($condition, ",") . ")";
     }
     //总是将创建人员加入人员列表
     $condition .= empty($condition) ? " where loginname=?" : " or loginname=?";
     array_push($para, (string) $user_jid);
     $sql = $sql . $condition;
     $success = true;
     $msg = "";
     try {
         $ds = $da_im->GetData("table", $sql, $para);
         if ($ds && $ds["table"]["recordcount"] > 0) {
             $syspara = new \Justsy\BaseBundle\DataAccess\SysParam($this->container);
             $grouplimit = $syspara->GetSysParam('grouplimit', '1000');
             if ($ds["table"]["recordcount"] > (int) $grouplimit) {
                 return array('success' => false, 'msg' => '人数超过群成员最大限制' . $grouplimit);
             }
             $sql = "select employeeid from im_groupemployee where groupid=?";
             $old_ds = $da_im->GetData("members", $sql, array((string) $groupid));
             $oldMembers = array();
             foreach ($old_ds["members"]["rows"] as $key => $value) {
                 $oldMembers[] = $value['employeeid'];
             }
             $grouprole = "";
             $newJid = array();
             $newNick = array();
             foreach ($ds["table"]["rows"] as $key => $value) {
                 $newJid[] = $value['loginname'];
                 $newNick[$value['loginname']] = $value['employeename'];
             }
             //获取需要删除的人员。求差集
             $needSubLst = Utils::array_diff_ex($oldMembers, $newJid);
             //获取需要新加的人员
             $needJoinLst = Utils::array_diff_ex($newJid, $oldMembers);
             //获取未变动的人员
             $noticeLst = Utils::array_intersect_ex($newJid, $oldMembers);
             $sqls = array();
             foreach ($needSubLst as $key => $value) {
                 $sqls[] = 'delete from im_groupemployee where employeeid=\'' . $value . '\'';
             }
             $intSql = 'insert into im_groupemployee(employeeid,groupid,grouprole,employeenick)values';
             $values = array();
             foreach ($needJoinLst as $key => $value) {
                 if ($user_jid == $value) {
                     $grouprole = "owner";
                 } else {
                     $grouprole = "normal";
                 }
                 $values[] = '(\'' . $value . '\',\'' . $groupid . '\',\'' . $grouprole . '\',\'' . $newNick[$value] . '\')';
             }
             if (count($values) > 0) {
                 $sqls[] = $intSql . implode(',', $values);
             }
             $sqls[] = 'update im_group set number=(select count(1) from im_groupemployee where groupid=\'' . $groupid . '\') where groupid=\'' . $groupid . '\'';
             if (count($sqls) > 0) {
                 $da_im->ExecSQLs($sqls, array());
             }
             $groupinfo = $this->GetByIM($groupid);
             $groupinfo = array('groupname' => $groupinfo['groupname'], 'groupid' => $groupinfo['groupid'], 'logo' => $groupinfo['logo']);
             if (count($needSubLst) > 0) {
                 $iconUrl = $groupinfo['logo'];
                 $noticeinfo = Utils::WrapMessageNoticeinfo('你已退出企业群组 ' . $groupinfo['groupname'], $user->nick_name, null, $iconUrl);
                 $msg = Utils::WrapMessage("exit_group", $groupinfo, $noticeinfo);
                 Utils::sendImMessage($user_jid, $needSubLst, "exit_group", json_encode($msg), $this->container, "", "", false, Utils::$systemmessage_code);
             }
             if (count($needJoinLst) > 0) {
                 $iconUrl = $groupinfo['logo'];
                 $noticeinfo = Utils::WrapMessageNoticeinfo('你已受邀加入企业群组 ' . $groupinfo['groupname'], $user->nick_name, null, $iconUrl);
                 $msg = Utils::WrapMessage("join_group", $groupinfo, $noticeinfo);
                 //添加成员成功发送消息
                 Utils::sendImMessage($user_jid, $needJoinLst, "join_group", json_encode($msg), $this->container, "", "", false, '');
             }
             if (count($noticeLst) > 0) {
                 //通知这部分成员需要更新群信息
                 $noticeinfo = array();
                 $msg = Utils::WrapMessage("update_group", $groupinfo, $noticeinfo);
                 Utils::sendImMessage($user_jid, $noticeLst, "update_group", json_encode($msg), $this->container, "", "", false, '');
             }
         }
     } catch (\Exception $e) {
         $success = false;
         $msg = "";
     }
     return array("success" => $success, "msg" => $msg);
 }
示例#4
0
 public function resetpwdAction()
 {
     $request = $this->getRequest();
     $account = $request->get("account");
     $txtvaildcode = $request->get("txtvaildcode");
     $pwd = $request->get("txtnewpwd");
     $pwd_im = $pwd;
     $da = $this->get("we_data_access");
     $da_im = $this->get("we_data_access_im");
     $re = array("returncode" => ReturnCode::$SUCCESS);
     if (empty($account)) {
         return $this->responseJson(Utils::WrapResultError("帐号不能为空"), $request->get('jsoncallback'));
     }
     if (empty($txtvaildcode)) {
         return $this->responseJson(Utils::WrapResultError("验证码不能为空"), $request->get('jsoncallback'));
     }
     //验证帐号及验证码
     $isEmail = Utils::validateEmail($account);
     $isMobile = Utils::validateMobile($account);
     if (!$isEmail && !$isMobile) {
         return $this->responseJson(Utils::WrapResultError("帐号格式不正确,仅支持邮箱或手机帐号"), $request->get('jsoncallback'));
     }
     $u_staff = new \Justsy\BaseBundle\Management\Staff($da, $da_im, $account, $this->get('logger'), $this->container);
     $targetStaffInfo = $u_staff->getInfo();
     if (empty($targetStaffInfo)) {
         return $this->responseJson(Utils::WrapResultError("帐号无效"), $request->get('jsoncallback'));
     }
     $sysparam = new \Justsy\BaseBundle\DataAccess\SysParam($this->container);
     $wn_code = $sysparam->GetSysParam("mobile_active_code");
     if ($txtvaildcode != $wn_code) {
         $sql = "select * from we_mobilebind_validcode where login_account=? and actiontype='FP' and valid_date>now() order by valid_date desc limit 0,1";
         $ds = $da->GetData('t', $sql, array((string) $account));
         if ($txtvaildcode != $ds["t"]["rows"][0]["validcode"]) {
             return $this->responseJson(Utils::WrapResultError("验证码无效"), $request->get('jsoncallback'));
         }
     }
     try {
         $login_account = $targetStaffInfo['login_account'];
         $re = $u_staff->changepassword($login_account, $pwd, $this->get('security.encoder_factory'));
         return $this->responseJson($re, $request->get('jsoncallback'));
     } catch (Exception $e) {
         return $this->responseJson(Utils::WrapResultError("重置密码失败,请稍后重试"), $request->get('jsoncallback'));
     }
 }
示例#5
0
 public function joinbycode($paraObj)
 {
     $currUser = $paraObj["user"];
     if (empty($currUser)) {
         return Utils::WrapResultError("请登录后重试", ReturnCode::$NOTLOGIN);
     }
     if ($currUser->eno != Utils::$PUBLIC_ENO) {
         return Utils::WrapResultError("你已加入企业");
     }
     $invitecode = $paraObj["invitecode"];
     if (empty($invitecode)) {
         return Utils::WrapResultError("邀请码不能为空");
     }
     //获取设置的邀请码过期小时数,默认为1小时
     //企业参数名称:invitecode_expire_hour
     $sys = new \Justsy\BaseBundle\DataAccess\SysParam($this->container);
     $hour = $sys->GetSysParam("invitecode_expire_hour");
     if (empty($hour)) {
         $hour = 1;
     }
     $sql = "select eno,review_staff from we_register where active_code=? and register_date>date_sub(now(),interval " . $hour . " hour)";
     $dataset = $this->da->GetData("t", $sql, array((string) $invitecode));
     if (count($dataset["t"]["rows"]) > 0) {
         $eno = $dataset["t"]["rows"][0]["eno"];
         if (empty($eno)) {
             return Utils::WrapResultError("邀请码已过期");
         }
         if ($currUser->eno == $eno) {
             return Utils::WrapResultError("你已经是该企业员工");
         }
         //消息通知
         $message = "你已成功加入企业";
         Utils::sendImPresence("", $currUser->fafa_jid, "enterprise_joinagree", $message, $this->container, "", "", false, '', '0');
         //加入企业
         $jid = SysSeq::GetSeqNextValue($this->da, "we_staff", "fafa_jid");
         $jid .= "-" . $eno . "@fafacn.com";
         $staffobj = new \Justsy\BaseBundle\Management\Staff($this->da, $this->container->get("we_data_access_im"), $currUser->getUsername(), $this->logger, $this->container);
         $tr = $staffobj->swtichEno($eno);
         //更换企业号
         if ($tr) {
             $staffobj->updateJid($currUser->fafa_jid, $jid);
         }
         //更新im库中的jid
         //申请人和邀请人成为好友
         $staffobj->bothAddFriend($this->container, $dataset["t"]["rows"][0]["review_staff"]);
         $newinfo = $staffobj->getInfo();
         $enodata = $this->getInfo($eno);
         return Utils::WrapResultOK($enodata);
     }
     return Utils::WrapResultError("无效的邀请码");
 }
 public function mobilenumactiveAction()
 {
     $deploy_mode = $this->container->getParameter('deploy_mode');
     $request = $this->getRequest();
     $mobile_num = $request->get('mobile_num');
     $mobile_pwd = $request->get('mobile_pwd');
     //$eno = $request->get('eno');
     $eno = $deploy_mode == "C" ? Utils::$PUBLIC_ENO : $this->container->getParameter("ENO");
     //企业独立部署时企业不设置,从配置文件中获取固定的企业号
     $ename = $request->get('ename');
     $nick_name = $request->get('nick_name');
     $active_code = $request->get('active_code');
     $login_account = $mobile_num;
     $ldap_uid = $request->get("ldap_uid");
     if (empty($active_code)) {
         return $this->getResponse(ReturnCode::$OTHERERROR, "请输入短信验证码!");
     }
     if (empty($mobile_pwd)) {
         return $this->getResponse(ReturnCode::$OTHERERROR, "请输入密码!");
     }
     if (empty($nick_name)) {
         return $this->getResponse(ReturnCode::$OTHERERROR, "请输入姓名!");
     }
     $da = $this->get('we_data_access');
     $da_im = $this->get('we_data_access_im');
     $cacheobj = new \Justsy\BaseBundle\Management\Enterprise($da, $this->get("logger"), $this->container);
     if (!strpos($login_account, "@")) {
         $domain = $this->container->getParameter('edomain');
         $login_account .= "@" . $domain;
     }
     $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $da_im, $login_account, $this->get("logger"), $this->container);
     $had = $staffMgr->getInfo();
     if (!empty($had)) {
         return $this->getResponse(ReturnCode::$OTHERERROR, "该手机号已注册,继续使用请先找回密码");
     }
     //判断手机号是否已经被使用
     if ($staffMgr->checkUser($mobile_num)) {
         return $this->getResponse(ReturnCode::$OTHERERROR, "该手机号已被绑定,请解绑后重试");
     }
     $sysparam = new \Justsy\BaseBundle\DataAccess\SysParam($this->container);
     $wn_code = $sysparam->GetSysParam("mobile_active_code");
     try {
         if ($wn_code != $active_code) {
             $sql = "select state_id,active_code,review_note from we_register where login_account=?";
             $ds = $da->GetData("we_register", $sql, array($login_account));
             if ($ds && $ds['we_register']['recordcount'] <= 0) {
                 return $this->getResponse(ReturnCode::$OTHERERROR, "未找到该手机号的注册信息!");
             }
             if ($ds['we_register']['rows'][0]['state_id'] == '3') {
                 return $this->getResponse(ReturnCode::$OTHERERROR, "该手机号已被注册!");
             }
             if ((empty($ds['we_register']['rows'][0]['review_note']) ? 0 : $ds['we_register']['rows'][0]['review_note']) >= 5) {
                 return $this->getResponse(ReturnCode::$OTHERERROR, "抱歉,验证码请求次数过多,如果获取不到验证码请根据下方提示与我们联系");
             }
             if ($ds['we_register']['rows'][0]['active_code'] != $active_code) {
                 $num = 5 - (empty($ds['we_register']['rows'][0]['review_note']) ? 0 : $ds['we_register']['rows'][0]['review_note']);
                 $sql = "update we_register set review_note=ifnull(review_note,0)+1 where login_account=?";
                 $da->ExecSQL($sql, array($login_account));
                 return $this->getResponse(ReturnCode::$OTHERERROR, "验证码错误,请重新输入。");
             }
         }
         $para = array();
         $para['account'] = $mobile_num;
         $para['password'] = $mobile_pwd;
         $para['deptid'] = '';
         $para['nick_name'] = $nick_name;
         $para['ldap_uid'] = '';
         $re = $staffMgr->createstaff($para);
     } catch (\Exception $e) {
         $re = Utils::WrapResultError($e->getMessage());
     }
     return $this->getResponse($re['returncode'], $re['msg']);
 }
示例#7
0
 public function saveSysparam($paraObj)
 {
     $syspara = new \Justsy\BaseBundle\DataAccess\SysParam($this->container);
     $list = $paraObj['list'];
     $content = array('[parameters]');
     $sqls = array();
     $dir = explode("src", __DIR__);
     $path = $dir[0] . 'app/config/parameters.ini';
     $data = parse_ini_file($path);
     $needUpdateCache = array();
     foreach ($list as $key => $value) {
         if (strpos($key, 'db_') === 0) {
             $key = str_replace('db_', '', $key);
             $sqls[] = 'update we_sys_param set param_value=\'' . $value . '\' where param_name=\'' . $key . '\'';
             $needUpdateCache[] = $key;
             continue;
         }
         $data[substr($key, 1)] = $value;
     }
     if (count($sqls) > 0) {
         try {
             $this->da->ExecSQLs($sqls, array());
             foreach ($needUpdateCache as $key => $value) {
                 $syspara->GetSysParam($value, '', true);
                 //更新缓存
             }
         } catch (\Exception $e) {
             $this->writelog($e);
         }
     }
     if (count($sqls) == count($list)) {
         return Utils::WrapResultOK('');
     }
     foreach ($data as $key => $value) {
         $content[] = $key . '= "' . $value . '"';
     }
     if (!($handle = fopen($path, 'w+'))) {
         return Utils::WrapResultError('打开参数文件失败!');
     }
     if (!fwrite($handle, implode("\n", $content))) {
         return Utils::WrapResultError('写入参数文件失败!');
     }
     fclose($handle);
     //如果修改了im数据连接,同步更改ejabberd配置
     if (isset($data['database_host_im']) || isset($data['database_port_im']) || isset($data['database_name_im']) || isset($data['database_user_im']) || isset($data['database_password_im'])) {
     }
     try {
         //发布php
         $str = "php {$dir[0]}app/console cache:clear --env=prod --no-debug\nchmod -R 777 {$dir[0]}app";
         $command = $dir[0] . 'clear_cache_prod.sh';
         if (!($handle = fopen($command, 'w+'))) {
             throw new Exception("脚本文件[{$command}]打开失败,请检查文件是否有效!");
         }
         if (!fwrite($handle, $str)) {
             throw new Exception("脚本文件[{$command}]写入失败,请检查文件是否有效或权限是否正确!");
         }
         fclose($handle);
         $data = shell_exec($command);
         if (strpos($data, 'Clearing the cache for the prod environment with debug false') === false) {
             throw new Exception($data);
         }
     } catch (\Exception $e) {
         return Utils::WrapResultError('发布系统错误:' . $e->getMessage());
     }
     return Utils::WrapResultOK('');
 }
示例#8
0
 public static function tokenAction($container, $con, $appid, $code, $encrypt)
 {
     $app = new \Justsy\BaseBundle\Management\App($container->container);
     $stat_v = explode(",", $appid);
     $appid = $stat_v[0];
     $openid = $stat_v[1];
     $isLogin = null;
     if (strpos($appid, "SSO_") !== false) {
         $isLogin = $appid;
         //新浪微博集成登录
         //获取微博对应的业务系统认证配置
         $syspara = new \Justsy\BaseBundle\DataAccess\SysParam($container);
         $appid = $syspara->GetSysParam(strtolower($appid) . "_appid");
         if (empty($appid)) {
             $resp = new Response("未配置微博业务系统或参数sso_sina_appid");
             $resp->headers->set('Content-Type', 'text/html');
             return $resp;
         }
         $appdata = $app->getbussysteminfo(array("appid" => $appid));
         $appid = $isLogin;
         //把appid还原成sso集成登录标识
     } else {
         if (strpos($appid, "SYS_") !== false) {
             //业务系统直接对接
             $appdata = $app->getbussysteminfo(array("appid" => substr($appid, 4)));
         } else {
             $appdata = $app->getappinfo(array("appid" => $appid));
         }
     }
     if (empty($appdata)) {
         return "无效的APPID";
     }
     $token_url = $appdata["token_url"];
     if (empty($token_url)) {
         return "无效的配置:令牌获取地址无效";
     }
     $token_method = $appdata["token_method"];
     $token_method = empty($token_method) ? "POST" : $token_method;
     $auth_url = $token_url;
     $para_name = $appdata["redirecturl_para_name"];
     if (empty($para_name)) {
         $para_name = "redirect_uri";
     }
     $paraString = "";
     if (empty($code)) {
         $paraString .= "grant_type=client_credentials&" . $para_name . "=" . $appdata["redirection_url"];
     } else {
         $paraString .= "grant_type=authorization_code&" . $para_name . "=" . $appdata["redirection_url"];
     }
     $para_name = $appdata["clientid_para_name"];
     if (empty($para_name)) {
         $para_name = "client_id";
     }
     $paraString .= "&" . $para_name . "=" . $appdata["clientid"];
     $para_name = $appdata["clientkey_para_name"];
     if (empty($para_name)) {
         $para_name = "client_secret";
     }
     $paraString .= "&" . $para_name . "=" . $appdata["clientkey"];
     $paraString .= "&code=" . $code;
     $paraString .= "&state=" . $appid . "," . $openid;
     $container->get("logger")->err($auth_url . " -- " . $paraString);
     if (strtoupper($token_method) == "POST") {
         $token = Utils::do_post_request($auth_url, $paraString);
     } else {
         $token = Utils::do_post_request($auth_url . "?" . $paraString, null);
     }
     $container->get("logger")->err("token value:" . $token);
     $retuenAry = array();
     if (substr($token, 0, 1) == "{") {
         $retuenAry = json_decode($token, true);
     } else {
         $rv = explode("&", $token);
         for ($i = 0; $i < count($rv); $i++) {
             $rv_i = explode("=", $rv[$i]);
             $retuenAry[$rv_i[0]] = preg_replace("/'/is", "", $rv_i[1]);
         }
     }
     $result = array("returncode" => "0000", "data" => null);
     $para_name = $appdata["token_para_name"];
     if (empty($para_name)) {
         $para_name = "access_token";
     }
     if (isset($retuenAry[$para_name])) {
         $retuenAry[$appdata["clientid_para_name"]] = $appdata["clientid"];
         $retuenAry[$appdata["clientkey_para_name"]] = $appdata["clientkey"];
         $result["returncode"] = "0000";
         $retuenAry[$appdata["token_para_name"]] = $retuenAry[$para_name];
         $app->setappsession(array("session" => $retuenAry, "openid" => $openid, "appid" => $appid));
     } else {
         $result["returncode"] = "9999";
     }
     $result["data"] = $retuenAry;
     if (!empty($isLogin)) {
         if (strpos($isLogin, "SSO_") !== false) {
             if ($isLogin == "SSO_SINA") {
                 $uid = $retuenAry["uid"];
             } else {
                 if ($isLogin == "SSO_WECHAT") {
                     $uid = $retuenAry["openid"];
                 }
             }
             //判断并注册用户
             $staffobj = new \Justsy\BaseBundle\Management\Staff($container->get("we_data_access"), $container->get("we_data_access_im"), $uid, null, $container->container);
             $re = $staffobj->createstaff(array("password" => rand(100000, 999999), "eno" => Utils::$PUBLIC_ENO, "nick_name" => $uid, "ldap_uid" => $uid, "account" => ""));
             $re["data"]["des"] = DES::decrypt($re["data"]["t_code"]);
         }
         return self::responseLoginJson(json_encode($re));
     } else {
         if (strpos($appid, "SYS_") !== false) {
             return self::responseJsonStr(json_encode($result));
         } else {
             return self::responseJson(json_encode($result));
         }
     }
 }
示例#9
0
 public function createstaff($parameter)
 {
     $deploy_mode = $this->container->getParameter('deploy_mode');
     $mobile_num = $parameter['account'];
     $mobile_pwd = $parameter['password'];
     $org_pwd = $mobile_pwd;
     //原始密码
     $deptid = isset($parameter['deptid']) ? $parameter['deptid'] : "";
     $eno = isset($parameter['eno']) ? $parameter['eno'] : $this->container->getParameter('ENO');
     $nick_name = $parameter['nick_name'];
     $ldap_uid = isset($parameter["ldap_uid"]) ? $parameter["ldap_uid"] : "";
     //优先采用第三方标识做为帐号,其次使用手机号做为帐号
     $login_account = empty($ldap_uid) ? $mobile_num : $ldap_uid;
     if (empty($login_account)) {
         return Utils::WrapResultError("请输入帐号!");
     }
     if (empty($mobile_pwd)) {
         return Utils::WrapResultError("请输入密码!");
     }
     if (empty($nick_name)) {
         return Utils::WrapResultError("请输入昵称!");
     }
     if (!strpos($login_account, "@")) {
         $domain = $this->container->getParameter('edomain');
         $login_account .= "@" . $domain;
     }
     $this->account = $login_account;
     $isHd = $this->getInfo();
     if (!empty($isHd)) {
         //已经注册,直接返回
         return Utils::WrapResultOK($isHd);
     }
     if (!empty($mobile_num) && Utils::validateMobile($mobile_num)) {
         if ($this->checkUser($mobile_num)) {
             return Utils::WrapResultError("该手机号已被绑定,请解绑后重试");
         }
     }
     $da = $this->conn;
     $da_im = $this->conn_im;
     try {
         //同步人员到业务系统
         $syncurl = null;
         try {
             //判断是否需要同步到其他系统
             $syspara = new \Justsy\BaseBundle\DataAccess\SysParam($this->container);
             $syncurl = $syspara->GetSysParam('staff_sync_url', '');
         } catch (\Exception $e) {
         }
         $cacheobj = new \Justsy\BaseBundle\Management\Enterprise($da, $this->logger, $this->container);
         //获取用户认证模块
         $authConfig = $cacheobj->getUserAuth();
         if (!empty($syncurl) && !empty($authConfig)) {
             try {
                 $classname = $authConfig["ssoauthmodule"];
                 if (!empty($classname)) {
                     $parameters = array("nick_name" => $nick_name, "mobile" => $login_account, "password" => $mobile_pwd);
                     $classname = "\\Justsy\\InterfaceBundle\\SsoAuth\\Sso" . $classname;
                     $re = call_user_func(array($classname, 'createUser'), $this->container, $parameters);
                     $ldap_uid = $re["ldap_uid"];
                     //该 属性必须由对应用户认证模块的方法createUser返回
                 }
             } catch (\Exception $e) {
                 $this->get("logger")->err($e);
                 return Utils::WrapResultError($e->getMessage());
             }
         }
         if (!empty($authConfig) && empty($eno)) {
             $eno = $authConfig["ENO"];
         }
         //验证企业号
         if (!empty($eno)) {
             $enterinfo = $cacheobj->getInfo($eno);
             if ($enterinfo == null) {
                 return Utils::WrapResultError("未找到您注册的企业!");
             }
             $edomain = $enterinfo['edomain'];
         }
         if (empty($deptid)) {
             $deptinfo = new \Justsy\BaseBundle\Management\Dept($da, $da_im);
             $deptid = $deptinfo->getDefaultDept($eno);
             $fafa_deptid = $deptid["deptid"];
             $deptid = $deptid["deptid"];
         } else {
             $deptinfo = new \Justsy\BaseBundle\Management\Dept($da, $da_im);
             $deptid = $deptinfo->getinfo($deptid);
             $fafa_deptid = $deptid["deptid"];
             $deptid = $deptid["deptid"];
         }
         $auth_level = "S";
         $eno_vip = $enterinfo['vip_level'];
         $eno_level = $enterinfo['eno_level'];
         $edomain = $enterinfo['edomain'];
         $circleId = $enterinfo['circle_id'];
         //注册jid
         $jid = SysSeq::GetSeqNextValue($da, "we_staff", "fafa_jid");
         $jid .= "-" . $eno . "@" . $edomain;
         //生成密码
         $user = new UserSession($login_account, $mobile_pwd, $login_account, array("ROLE_USER"));
         $factory = $this->container->get("security.encoder_factory");
         $encoder = $factory->getEncoder($user);
         $pwd = $encoder->encodePassword($mobile_pwd, $user->getSalt());
         $mobile_pwd = DES::encrypt($mobile_pwd);
         $istester = "";
         //是否是通过万能验证码激活的测试人员
         //插入人员、圈子信息
         $sqls[] = "insert into we_staff (dept_id,login_account,eno,password,nick_name,photo_path,state_id,fafa_jid,photo_path_small,photo_path_big,openid,register_date,active_date,t_code,auth_level,mobile,mobile_bind,ldap_uid,login_source) values (?,?,?,?,?,?,?,?,?,?,?,(select register_date from we_register where login_account=?),now(),?,?,?,?,?,?)";
         $sqls[] = "insert into we_circle_staff (circle_id,login_account,nick_name) values (?,?,?)";
         $sqls[] = "update we_register set state_id='3' where login_account=?";
         $paras[] = array((string) $deptid, (string) $login_account, (string) $eno, (string) $pwd, (string) $nick_name, (string) '', (string) "1", (string) $jid, (string) '', (string) '', (string) md5($eno . $login_account), (string) $login_account, (string) $mobile_pwd, (string) $auth_level, empty($mobile_num) ? null : (string) $mobile_num, empty($mobile_num) ? null : (string) $mobile_num, (string) $ldap_uid, $istester);
         $paras[] = array((string) $circleId, (string) $login_account, (string) $nick_name);
         $paras[] = array((string) $login_account);
         $da->ExecSQLs($sqls, $paras);
         //向RBAC跟新用户身份
         //$staffRole=new \Justsy\BaseBundle\Rbac\StaffRole($da,$da_im,$this->logger);
         //$staffRole->InsertStaffRoleByCode($login_account,$auth_level.$eno_vip,$eno);
     } catch (\Exception $e) {
         $this->logger->err($e);
         return Utils::WrapResultError($e->getMessage());
     }
     //写we_im库
     $sqls = array();
     $paras = array();
     try {
         //写入人员 如果$jid_old为空执行原有逻辑,否则更新旧jid数据
         if (empty($jid_old)) {
             $sqls = array();
             $paras = array();
             $pinyin = Utils::Pinyin($nick_name);
             $employeeid = SysSeq::GetSeqNextValue($da_im, "im_employee", "employeeid");
             $sqls[] = "insert into im_employee (employeeid, deptid, loginname, password, employeename,spell) values (?, ?, ?, ?, ?,?)";
             $paras[] = array((string) $employeeid, (string) $fafa_deptid, (string) $jid, (string) $mobile_pwd, (string) $nick_name, (string) $pinyin);
             $sqls[] = "insert into users (username, password, created_at) values (?, ?, now())";
             $paras[] = array((string) $jid, (string) $mobile_pwd);
             $sqls[] = "insert into im_b_msg_read (employeeid, lastid, readdatetime) values (?, (select max(id) from im_b_msg), now())";
             $paras[] = array((string) $jid);
             $da_im->ExecSQLs($sqls, $paras);
             try {
                 $da_im->ExecSQL("call dept_emp_stat(?)", array((string) $jid));
             } catch (\Exception $e) {
             }
             $this->syncAttrsToIM();
             $jid_old = $jid;
         }
     } catch (\Exception $e) {
         $this->logger->err($e);
         return Utils::WrapResultError($e->getMessage());
     }
     //关注自己所属企业的开放的内部公众号
     $mac = new \Justsy\BaseBundle\Management\MicroAccountMgr($da, $da_im, $login_account, $this->logger, $this->container);
     $mac->attenCompanyOpenAccount();
     //自动关注当前企业的开放公众号
     $re = $this->getInfo();
     return Utils::WrapResultOK($re);
 }
示例#10
0
 public function ssoAction()
 {
     $request = $this->get("request");
     $classname = $request->get("ssomodule");
     $appid = $request->get("appid");
     $openid = $request->get("openid");
     $token = $request->get("token");
     $encrypt = $request->get("encrypt");
     $isLogin = null;
     $app = new \Justsy\BaseBundle\Management\App($this->container);
     if (strpos($appid, "SSO_") !== false) {
         $isLogin = $appid;
         //新浪微博集成登录
         //获取微博对应的业务系统认证配置
         $syspara = new \Justsy\BaseBundle\DataAccess\SysParam($this->container);
         $appid = $syspara->GetSysParam(strtolower($appid) . "_appid");
         if (empty($appid)) {
             $resp = new Response("未配置集成登录业务系统或参数" . strtolower($isLogin) . "_appid");
             $resp->headers->set('Content-Type', 'text/html');
             return $resp;
         }
         $appinfo = $app->getbussysteminfo(array("appid" => $appid));
         $appid = $isLogin;
         //把appid还原成sso集成登录标识
     } else {
         if (strpos($appid, "SYS_") !== false) {
             //业务系统直接对接
             $appinfo = $app->getbussysteminfo(array("appid" => substr($appid, 4)));
         } else {
             $appinfo = $app->getappinfo(array("appid" => $appid));
         }
     }
     if (empty($appinfo)) {
         $resp = new Response("invalid appid:{$appid}");
         $resp->headers->set('Content-Type', 'text/html');
         return $resp;
     }
     $classname = ucfirst($appinfo["authtype"]) . "Controller";
     if (empty($classname) || $classname == "null") {
         //$classname = "SsoWefafaController";
         //$resp = new Response($request->get('jsoncallback') ? $request->get('jsoncallback')."(".json_encode($row).");" : json_encode($row));
         $resp = new Response("invalid ssomodule");
         $resp->headers->set('Content-Type', 'text/html');
         return $resp;
     }
     try {
         $classname = "\\Justsy\\OpenAPIBundle\\Controller\\Sso" . $classname;
         return call_user_func(array($classname, 'ssoAction'), $this, $this->get("we_data_access"), $appid, $openid, $token, $encrypt);
     } catch (\Exception $e) {
         $this->get("logger")->err($e);
         $resp = new Response("invalid ssomodule");
         $resp->headers->set('Content-Type', 'text/html');
         return $resp;
     }
 }
 public function qrcodeAction($type, $code)
 {
     $syspara = new \Justsy\BaseBundle\DataAccess\SysParam($this->container);
     $downappUrl = $syspara->GetSysParam('app_download_page');
     if (empty($downappUrl)) {
         return $this->responseJson("系统配置误:app_download_page");
     }
     return Utils::http_redirect($downappUrl);
     /*$request = $this->getRequest();
       $openid = $request->get("openid");
       $qrcodeMgr = new \Justsy\BaseBundle\Management\QrcodeMgr($this->container);
       return $qrcodeMgr->getData($openid,$type,$code);*/
 }