public static function bindAction($controller, $con, $appid, $openid, $params) { $re = array("returncode" => "0000"); try { $bindinfo = $params->get("auth"); $bindinfo = explode(",", $bindinfo); $bind_uid = $bindinfo[0]; $authkey = count($bindinfo) == 1 ? "" : DES::encrypt($bindinfo[1]); $app = new \Justsy\BaseBundle\Management\App($controller->container); $appdata = $app->getappinfo(array("appid" => $appid)); //获取应用信息 //自动身份认证 $cookie_key = self::$bind_type . "_" . $openid; $loginUrl = $appdata["authorization_url"]; if (!empty($loginUrl)) { $authResult = Utils::do_get_request_cookie($loginUrl . "&" . http_build_query(array("uid" => $bind_uid, "upwd" => md5(DES::decrypt($authkey)))), null, null, $cookie_key); $authResult = json_decode($authResult, true); if (!isset($authResult["islogin"]) || $authResult["islogin"] != "1") { return $controller->render("JustsyBaseBundle:AppCenter:h5bundle.html.twig", array('appid' => $appid, 'openid' => $openid, 'errormsg' => '绑定的帐号或密码不正确', 'ssomodule' => self::$bind_type . "Controller")); } } $app->setappbind(array("appid" => $appid, "openid" => $openid, "bind_type" => self::$bind_type, "bind_uid" => $bind_uid, "authkey" => $authkey)); } catch (\Exception $e) { $response = new Response($e->getMessage()); $response->headers->set('Content-Type', 'text/html'); return $response; } return self::responseJson(json_encode($re)); }
public static function userAuthAction($container, $request, $dbcon, $con_im, $login_account, $password, $comefrom) { $login_account = strtolower($login_account); try { $Obj = new \Justsy\BaseBundle\Login\UserProvider($container); $user = $Obj->loadUserByUsername($login_account, $comefrom); $logined = 1; //$container->get("logger")->err(json_encode($user)); $user2 = new UserSession($user->getusername(), $password, $user->getusername(), array("ROLE_USER")); $factory = $container->get("security.encoder_factory"); $encoder = $factory->getEncoder($user2); $password_enc = $encoder->encodePassword($password, $user2->getSalt()); /*$factory = $container->get('security.encoder_factory'); $encoder = $factory->getEncoder($user); $password_enc = $encoder->encodePassword($password, $user->getSalt()); $logined= 1;*/ if ($user->getPassword() != $password_enc) { //如果密码不正确时,有可能是修改了密码,只刷新了一台服务器上的缓存,其他集群环境中的还是原来的缓存 //刷新当前服务器的人员信息才重试 $u_staff = new \Justsy\BaseBundle\Management\Staff($dbcon, $con_im, $user->getusername(), $container->get('logger'), $container); $user = $u_staff->getInfo(true); //刷新人员信息 //$container->get("logger")->err("refresh cache data....."); $user = $Obj->loadUserByUsername($login_account, $comefrom); if ($user->getPassword() != $password_enc) { $container->get("logger")->err($login_account . "==>" . $password . "=>" . $password_enc . "=>" . $user->getPassword()); $re["returncode"] = ReturnCode::$ERROFUSERORPWD; $logined = null; } } if (!empty($logined)) { $user->comefrom = $comefrom; //登录源 //�Ǽ�seesion //$token = new \Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken($user, $user->getPassword(), "secured_area", $user->getRoles()); //$container->get("security.context")->setToken($token); //$session = $request->getSession()->set('_security_'.'secured_area', serialize($token)); //$event = new \Symfony\Component\Security\Http\Event\InteractiveLoginEvent($request, $token); //$container->get("event_dispatcher")->dispatch("security.interactive_login", $event); $re["returncode"] = ReturnCode::$SUCCESS; $re["openid"] = $user->openid; $re["login_account"] = $user->getusername(); $re["ldap_uid"] = $user->ldap_uid; $re["jid"] = $user->fafa_jid; $re["des"] = DES::encrypt($user->t_code); //im登录密码。生成session时对该属性解密,在些进行重新加密得到 } } catch (\Symfony\Component\Security\Core\Exception\UsernameNotFoundException $e) { $re["returncode"] = ReturnCode::$ERROFUSERORPWD; } catch (\Exception $e) { $re["returncode"] = ReturnCode::$SYSERROR; } return $re; }
public function saveAction() { $reslt = array(); $request = $this->get("request"); $uid = isset($_SESSION["uid"]) ? $_SESSION["uid"] : ""; if (empty($uid)) { $reslt["s"] = "0"; $reslt["msg"] = "微博登录失败或超时,请重新通过微博登录!"; $response = new Response(json_encode($reslt)); $response->headers->set('Content-Type', 'text/json'); return $response; } $type = $request->get("bind_type"); $login_account = $request->get("login_account"); $pwd = $request->get("pwd"); try { //校验wefafa帐号和密码 $staffMgr = new Staff($this->get('we_data_access'), null, $login_account, $this->get('logger')); $staffInfo = $staffMgr->getInfo(); if (empty($staffInfo)) { $reslt["s"] = "0"; $reslt["msg"] = "帐号[" . $login_account . "]不存在!"; } else { $tcode = $staffInfo["t_code"]; $p_code = DES::encrypt($pwd); if ($tcode != $p_code) { $reslt["s"] = "0"; $reslt["msg"] = "帐号或密码不正确!"; } else { $accountbind = new \Justsy\BaseBundle\Management\StaffAccountBind($this->get('we_data_access'), null, $this->get('logger')); $r = $accountbind->Bind($type, "", $login_account, $uid); $this->get('logger')->err($type . "," . $uid . "," . $login_account . "," . $uid); $reslt["s"] = $r; } } } catch (\Exception $e) { $this->get('logger')->err($e); $reslt["s"] = "0"; $reslt["msg"] = "绑定失败,请检查帐号是否填写正确!"; } $response = new Response(json_encode($reslt)); $response->headers->set('Content-Type', 'text/json'); return $response; }
public function saveAction() { //try{ $request = $this->get("request"); $user = $this->get('security.context')->getToken()->getUser(); $da = $this->get("we_data_access"); $new_id = \Justsy\BaseBundle\DataAccess\SysSeq::GetSeqNextValue($da, "we_sys_feedback", "id"); $sql = "insert into we_sys_feedback (id,login_account,ip,feedback_con,feedback_date)values(?,?,?,?,now())"; $da->ExecSQL($sql, array((string) $new_id, (string) $user->getUserName(), "", (string) $request->get("txt"))); //查询出开发公司的圈子id $sql = "select * from we_circle where network_domain='fafatime.com'"; $ds = $da->GetData("tmp", $sql); $circle_id = $ds["tmp"]["rows"][0]["circle_id"]; //发公告 $txt = "用户反馈:" . $request->get("txt"); //发送站内消息 $msgId = \Justsy\BaseBundle\DataAccess\SysSeq::GetSeqNextValue($da, "we_bulletin", "bulletin_id"); $sql = "insert into we_bulletin(bulletin_id,circle_id,group_id,bulletin_date,bulletin_desc)values(?,?,?,now(),?)"; $da->ExecSQL($sql, array((int) $msgId, (string) $circle_id, "ALL", $txt)); //通知圈子成员 $members = $this->notifyCircleMember($da, $circle_id); for ($i = 0; $i < count($members); $i++) { $membersrow = $members[$i]; if ($membersrow["login_account"] == $user->getUserName()) { continue; } $sql = "insert into we_notify(notify_type, msg_id,notify_staff)values('01',?,?)"; $da->ExecSQL($sql, array((int) $msgId, (string) (string) $user->getUserName())); //向对方发送及时消息 //认证码格式:当前人员企业号、帐号、密码(空)、空、空 $encode = $user->eno . "," . $user->fafa_jid . ",,,"; $encode = "00442," . DES::encrypt($encode); $url = $this->container->getParameter("FAFA_REG_JID_URL"); //Utils::sendImMessage($url,"",$user->fafa_jid,$row["fafa_jid"],$txt); } return new Response("1"); //} //catch(\Exception $e) //{ // return new Response("0"); //} }
public function importEmployeeAction($network_domain) { $request = $this->get("request"); $user = $this->get('security.context')->getToken()->getUser(); //判断当前导入人员是否是企业邮箱 $userDomain = explode("@", $user->getUserName()); $da = $this->get("we_data_access"); $sql = "select 1 from we_public_domain where domain_name=?"; $ds = $da->GetData("mt", $sql, array((string) $userDomain[1])); $mailType = count($ds["mt"]["rows"]) > 0 ? "0" : "1"; //1表示是企业邮箱 try { $upfile = $request->files->get("filedata"); $tmpPath = $upfile->getPathname(); $oldName = $upfile->getClientOriginalName(); $fixs = explode(".", strtolower($oldName)); if (count($fixs) < 2) { $re = array('s' => 0, 'message' => "文件类型不正确"); } else { $fixedType = $fixs[count($fixs) - 1]; if ($fixedType != "xlsx" && $fixedType != "xls") { $re = array('s' => 0, 'message' => "文件类型不正确"); } else { $newFileName = $user->openid . date('y-m-d-H-m-s') . "." . $fixedType; if (move_uploaded_file($tmpPath, 'upload/' . $newFileName)) { $da = $this->container->get('we_data_access'); $objReader = \PHPExcel_IOFactory::createReader($fixedType == "xlsx" ? 'Excel2007' : "Excel5"); //use excel2007 for 2007 format $objPHPExcel = $objReader->load($_SERVER['DOCUMENT_ROOT'] . '/upload/' . $newFileName); $objWorksheet = $objPHPExcel->getActiveSheet(); $highestRow = $objWorksheet->getHighestRow(); $highestColumn = $objWorksheet->getHighestColumn(); $highestColumnIndex = \PHPExcel_Cell::columnIndexFromString($highestColumn); //总列数 //获取标题行 $titleAry = array(); $account_index = 0; $name_index = 0; $mobile_index = 0; $pwd_index = 0; for ($row = 0; $row <= 1; $row++) { for ($col = 0; $col < $highestColumnIndex; $col++) { $titleAry[$col] = $objWorksheet->getCellByColumnAndRow($col, $row)->getValue(); if (strpos($titleAry[$col], "邮箱") !== false) { $account_index = $col; } else { if (strpos($titleAry[$col], "姓名") !== false) { $name_index = $col; } else { if (strpos($titleAry[$col], "手机") !== false) { $mobile_index = $col; } else { if (strpos($titleAry[$col], "密码") !== false) { $pwd_index = $col; } } } } } } $titleAry[] = "eno"; $err_list = array(); $da = $this->get("we_data_access"); $dm = $this->get("we_data_access_im"); //获取数据行 for ($row = 2; $row <= $highestRow; $row++) { $strs = array(); for ($col = 0; $col < $highestColumnIndex; $col++) { $strs[$col] = trim((string) $objWorksheet->getCellByColumnAndRow($col, $row)->getValue()); } $strs[] = $user->eno; $name = $strs[$name_index]; if (empty($name)) { $err_list[] = array("name" => "", "row" => $row, "msg" => "姓名不能为空"); continue; } if (strlen($name) == 1) { $err_list[] = array("name" => "", "row" => $row, "msg" => "姓名不能少于2个字符"); continue; } //获取填写的帐号 $account = $strs[$account_index]; if (empty($account)) { $err_list[] = array("name" => $name, "row" => $row, "msg" => "邮箱帐号不能为空"); continue; } if (!Utils::validateEmail($account)) { $err_list[] = array("name" => $name, "row" => $row, "msg" => "邮箱帐号格式不正确"); continue; } $staffmgr = new Staff($da, $dm, $account); if ($staffmgr->checkNickname($user->eno, $name) === true) { $err_list[] = array("name" => "", "row" => $row, "msg" => "[" . $name . "]已经注册,请检查!"); continue; } //if($mailType=="1" && explode("@",$account)[1]!=$userDomain[1] ) //{ // $err_list[]=array("name"=>$name,"row"=>($row),"msg"=>"不允许导入公共邮箱$account"); // continue; //} $mobile = $strs[$mobile_index]; if (!empty($mobile)) { if (!Utils::validateMobile($mobile)) { $err_list[] = array("name" => $name, "row" => $row, "msg" => "手机号码格式不正确"); continue; } } //判断帐号是否已经注册 $isexist = $staffmgr->isExist($mobile); if (!empty($isexist)) { //已注册 $err_list[] = array("name" => $name, "msg" => "邮箱或手机号已被使用"); continue; } //判断是否已导入,已导入,则不再发邮件 $isImport = false; try { $isImport = $staffmgr->getImportInfo(); } catch (\Exception $err) { } try { $staffmgr->importReg($titleAry, $strs); //判断是否设置了密码 $pwd = $strs[$pwd_index]; if (!empty($pwd)) { $sql = "select ename from we_enterprise where eno=?"; $ds = $da->GetData("t", $sql, array((string) $user->eno)); //自动激活 $active = new \Justsy\BaseBundle\Controller\ActiveController(); $active->setContainer($this->container); $active->doSave(array('account' => $account, 'realName' => $name, 'passWord' => $pwd, 'eno' => $user->eno, 'ename' => $ds["t"]["rows"][0]["ename"], 'isNew' => '0', 'mailtype' => "1", 'isSendMessage' => "N", 'import' => '1')); $staffmgr = new Staff($da, $dm, $account); $importData = $staffmgr->getImportInfo(); $staffmgr->updateByImport($importData); $staffmgr->deleteImportPhy(); } else { if ($isImport === false) { //发送邮件 $activeurl = $this->generateUrl("JustsyBaseBundle_empimport_setpass", array('account' => DES::encrypt($account)), true); $txt = $this->renderView('JustsyBaseBundle:Register:mail.html.twig', array('realName' => $user->nick_name, 'account' => $account, 'activeurl' => $activeurl)); Utils::saveMail($da, $this->container->getParameter('mailer_user'), $account, "欢迎加入Wefafa企业协作网络", $txt); } } } catch (\Exception $err) { //写导入数据发生异常 $err_list[] = array("name" => $name, "msg" => "导入失败:" . $err->getMessage()); continue; } } $re = array('s' => 1, 'error_list' => $err_list); } else { $re = array('s' => 0, 'message' => "文件上传失败"); } try { unlink($tmpPath); } catch (\Exception $e) { } } } } catch (\Exception $ex) { $re = array('s' => 0, 'message' => "导入失败"); } $response = new Response("<script>parent.import_callback(" . json_encode($re) . ")</script>"); $response->headers->set('Content-Type', 'text/html'); return $response; }
public function getTmpAuthCodeAction() { $ts = time(); $ts = DES::encrypt($ts); $response = new Response($ts); return $response; }
if ($b) { $da->ExecSQLs($sqls, $paras); return new Response("1"); } else { return new Response("0"); } } catch (\Exception $e) { $logger = $this->get('logger')->err($e); return new Response("0"); } } public function applyCancelAction($groupid) { $da = $this->get("we_data_access"); $user = $this->get('security.context')->getToken()->getUser(); $apply = new \Justsy\BaseBundle\Management\ApplyMgr($da, null); $apply->SetGroupApplyInvalid($user->GetUserName(), $groupid); $re = array(); $re["success"] = "1"; $response = new Response(json_encode($re)); $response->headers->set('Content-Type', 'text/json'); return $response; } //申请加入群组 public function applyJoinGroupAction() { $da = $this->get("we_data_access"); $user = $this->get('security.context')->getToken()->getUser(); $group_id = $this->get('request')->request->get('group_id'); $group_name = $this->get('request')->request->get('group_name'); $create_staff = $this->get('request')->request->get('create_staff'); $network_domain = $this->get('request')->request->get('network_domain'); //判断加入群组数是否超过了限制 $ec = new \Justsy\BaseBundle\Management\EnoParamManager($da, $this->get('logger')); if ($ec->IsBeyondJoinGroup($user->getUserName())) { return new Response("-2");
public function appbizproxyurlAction(Request $request) { $appid = $request->get("appid"); $action = $request->get("action"); $da = $this->get('we_data_access'); if ($action == "download") { $sql = "select a.*,b.number from we_appcenter_apps a,we_micro_account b where a.appid=b.micro_source and a.appid=?"; $ds = $da->GetData("t", $sql, array((string) $appid)); $ds["t"]["rows"][0]["appkey"] = DES::encrypt($ds["t"]["rows"][0]["appkey"]); $appInfo = array('s' => 1, "data" => $ds["t"]["rows"][0]); $resp = new Response(json_encode($appInfo)); $resp->headers->set('Content-Type', 'text/json'); return $resp; } else { $result = array("s" => 1); try { $sql = "select count(1) cnt from we_appcenter_apps a "; $ds = $da->GetData("t", $sql, array()); $curuser = $this->get('security.context')->getToken()->getUser(); $maxNo = $curuser->eno . ((int) $ds["t"]["rows"][0]["cnt"] + 1); $sql = "select a.* from we_appcenter_apps a where a.appid=?"; $ds = $da->GetData("t", $sql, array((string) $appid)); if ($ds && count($ds["t"]["rows"]) > 0) { $appInfo = $ds["t"]["rows"][0]; $factory = $this->get('security.encoder_factory'); $dm = $this->get('doctrine.odm.mongodb.document_manager'); $account = strtolower("mapp" . $maxNo . "@" . $curuser->edomain); if (strpos($account, ".") === false) { $account = $account . ".com"; } $MicroAccountMgr = new \Justsy\BaseBundle\Management\MicroAccountMgr($da, $this->get('we_data_access_im'), $curuser, $this->get("logger"), $this->container); $re = $MicroAccountMgr->register("", $account, $appInfo["appname"], "1", "1", "", "1", "", "1", $appInfo["appkey"], $appInfo["logo"], $appInfo["logo"], $appInfo["logo"], $factory, $dm, $appid); } } catch (\Exception $e) { $result = array("s" => 0, 'msg' => $e->getMessage()); } $resp = new Response(json_encode($result)); $resp->headers->set('Content-Type', 'text/json'); return $resp; } }
public function resetPwdSaveAction(Request $request) { $da = $this->get('we_data_access'); $login_account = $request->get('login_account'); $pwd = $request->request->get('pwd'); $id = $request->get('id'); $t_code = DES::encrypt($pwd); $user = new UserSession($login_account, $pwd, $login_account, array("ROLE_USER")); $factory = $this->get("security.encoder_factory"); $encoder = $factory->getEncoder($user); $pwd = $encoder->encodePassword($pwd, $user->getSalt()); $sql = "update we_staff set password=?,t_code=? where login_account=?"; $da->ExecSQL($sql, array((string) $pwd, (string) $t_code, (string) $login_account)); $sql = "update we_retrieve_password set valid='0' where id=? and login_account=?"; $da->ExecSQL($sql, array((string) $id, (string) $login_account)); //更改im密码 $da_im = $this->get('we_data_access_im'); $pwd = $this->get('request')->request->get('pwd'); $sql = "select fafa_jid from we_staff where login_account=?"; $ds = $da->GetData('we_staff', $sql, array((string) $login_account)); if ($ds && $ds['we_staff']['recordcount'] > 0) { $fafa_jid = $ds['we_staff']['rows'][0]['fafa_jid']; $sqls[] = "update im_employee set password=? where loginname=?"; $sqls[] = "update users set password=? where username=?"; $paras[] = array((string) $pwd, (string) $fafa_jid); $paras[] = array((string) $pwd, (string) $fafa_jid); $da_im->ExecSQLs($sqls, $paras); } $result = array("succeed" => true, "url" => $this->generateUrl('root')); $response = new Response(json_encode($result)); $response->headers->set('Content-Type', 'text/json'); return $response; }
public function sendInvitationAction() { $res = $this->getRequest(); $im_sender = $this->container->getParameter('im_sender'); $acts = $res->get('acts'); $logger = $this->get('logger'); $da = $this->get('we_data_access'); $user = $this->get('security.context')->getToken()->getUser(); $circleId = $res->get("circleId"); $eno = $res->get('eno'); $invMsg = $res->get('invMsg'); $subject = $res->get('subject'); $invRela = $res->get('invRela'); $circleName = ""; if (!empty($circleId)) { $circleMgr = new \Justsy\BaseBundle\Management\CircleMgr($da, $this->get('we_data_access_im'), null); $circleObj = $circleMgr->Get($circleId); if ($circleObj == null && (empty($eno) || $eno == "-1")) { return new Response('1'); } $circleName = $circleObj["circle_name"]; } $invInfo = array('inv_send_acc' => $user->getUsername(), 'inv_recv_acc' => '', 'eno' => '', 'inv_rela' => $invRela, 'inv_title' => '', 'inv_content' => '', 'active_addr' => ''); $photourl = $this->container->getParameter('FILE_WEBSERVER_URL'); $staff_e = array(); $staff_c = array(); $sql = "select c.login_account,c.nick_name,concat('" . $photourl . "',case trim(ifnull(c.photo_path,'')) when '' then null else c.photo_path end) as photo_path \nfrom we_staff c inner join we_circle_staff d on c.login_account=d.login_account where d.circle_id=(\nselect b.circle_id from we_staff a inner join we_circle b on a.eno=b.enterprise_no and a.login_account=?) limit 0,9"; $ds = $da->GetData("staff", $sql, array((string) $user->getUsername())); if ($ds && $ds['staff']['recordcount'] > 0) { $staff_e = $ds['staff']['rows']; } $sql = "select a.login_account,a.nick_name,concat('" . $photourl . "',case trim(ifnull(a.photo_path,'')) when '' then null else a.photo_path end) as photo_path \nfrom we_staff a inner join we_circle_staff b on a.login_account=b.login_account\nwhere a.eno=(select eno from we_staff where login_account=?) and b.circle_id=? limit 0,9"; $ds = $da->GetData("staff", $sql, array((string) $user->getUsername(), (string) $circleId)); if ($ds && $ds['staff']['recordcount'] > 0) { $staff_c = $ds['staff']['rows']; } try { foreach ($acts as $key => $value) { $invacc = trim($value); $invInfo['inv_recv_acc'] = $invacc; //排除自己 if ($invacc == $user->getUsername()) { continue; } $sql = "select fafa_jid from we_staff where login_account=?"; $ds = $da->GetData("we_staff", $sql, array((string) $invacc)); $isReg = $ds && $ds['we_staff']['recordcount'] > 0; //是否已注册 if (empty($eno) || $eno == "-1") { //加入圈子 if ($isReg) { //1.帐号存在,直接加入圈子 //受邀人员帐号,圈子id,邀请人帐号 $encode = DES::encrypt("{$invacc},{$circleId}," . $user->getUsername()); $activeurl = $this->generateUrl("JustsyBaseBundle_invite_agreejoincircle", array('para' => $encode, 'eno' => 'c' . $circleId), true); $rejectactiveurl = $this->generateUrl("JustsyBaseBundle_invite_refuse", array('para' => $encode, 'eno' => 'c' . $circleId), true); $txt = $this->renderView('JustsyBaseBundle:Invite:circle_invitation_msg.html.twig', array("ename" => $user->ename, "nick_name" => $user->nick_name, "activeurl" => $activeurl, 'circle_name' => $circleName, 'invMsg' => $invMsg)); $invInfo['eno'] = "c{$circleId}"; if (empty($subject)) { if ($circleId == "9999") { $invInfo['inv_title'] = $user->nick_name . " 邀请您加入TA的人脉圈"; } else { $invInfo['inv_title'] = $user->nick_name . " 邀请您加入圈子【" . Utils::makeCircleTipHTMLTag($circleId, $circleName) . "】"; } } else { $invInfo['inv_title'] = $subject; } $invInfo['inv_content'] = $invMsg; $invInfo['active_addr'] = $activeurl; //保存邀请信息 InviteController::saveWeInvInfo($da, $invInfo); //发送即时消息 $fafa_jid = $ds['we_staff']['rows'][0]['fafa_jid']; if ($circleId == "9999") { $message = Utils::makeHTMLElementTag('employee', $user->fafa_jid, $user->nick_name) . "邀请您加入TA的人脉圈"; } else { $message = Utils::makeHTMLElementTag('employee', $user->fafa_jid, $user->nick_name) . "邀请您加入圈子【" . Utils::makeHTMLElementTag('circle', $circleObj["fafa_groupid"], $circleName) . "】"; } $buttons = array(); $buttons[] = array("text" => "拒绝", "code" => "agree", "value" => "0", "link" => $rejectactiveurl); $buttons[] = array("text" => "立即加入", "code" => "agree", "value" => "1", "link" => $activeurl); Utils::sendImMessage($user->fafa_jid, $fafa_jid, "邀请加入圈子", $message, $this->container, "", Utils::makeBusButton($buttons), false, Utils::$systemmessage_code, "1"); } else { //2.帐号不存在 $tmp = explode("@", $invacc); $tmp = count($tmp) > 1 ? $tmp[1] : 'fafatime.com'; $sql = "select count(1) as cnt from we_public_domain where domain_name=?"; $ds = $da->GetData("we_public_domain", $sql, array((string) $tmp)); if ($ds && $ds['we_public_domain']['rows'][0]['cnt'] == 0) { //2.1企业邮箱 $sql = "select eno from we_enterprise where edomain=?"; $ds = $da->GetData("we_enterprise", $sql, array((string) $tmp)); if ($ds && $ds['we_enterprise']['recordcount'] > 0) { //2.1.1企业已创建 帐号,圈子id,企业edomain des encode $eno = $ds['we_enterprise']['rows'][0]['eno']; $encode = DES::encrypt($user->getUsername() . ",{$circleId},{$eno}"); $eno = ""; $activeurl = $this->generateUrl("JustsyBaseBundle_active_inv_s1", array('account' => DES::encrypt($invacc), 'invacc' => $encode), true); $staff_t = $staff_e; $has_e = "1"; } else { //2.1.2企业未创建 $sql = "insert into we_register (login_account,ename,credential_path,active_code,ip,email_type,first_reg_date,last_reg_date,register_date,state_id) " . "select ?,'','','" . strtoupper(substr(uniqid(), 3, 10)) . "','" . $_SERVER['REMOTE_ADDR'] . "','1',now(),now(),now(),'0' from dual " . "where not exists (select 1 from we_register where login_account=?)"; $para = array($invacc, $invacc); $da->ExecSQL($sql, $para); //发送邮件 帐号,圈子id,邀请发送者帐号,邀请人企业名 des encode $encode = DES::encrypt("{$invacc},{$circleId}," . $user->getUserName() . "," . $user->ename); $activeurl = $this->generateUrl("JustsyBaseBundle_active_reg_s1", array('account' => $encode), true); $staff_t = array(); $has_e = "0"; } //保存邀请信息 circleid保存到eno字段,以字母'c'开头 if ($circleId == "-1") { $invInfo['eno'] = "-1"; $title = empty($subject) ? $user->nick_name . " 邀请您加入Wefafa企业协作网络" : $subject; $txt = $this->renderView("JustsyBaseBundle:Invite:enterprise_invitation.html.twig", array("ename" => $user->ename, "realName" => $user->nick_name, "activeurl" => $activeurl, "invMsg" => $invMsg, "staff" => $staff_t, "has_e" => $has_e)); } else { if ($invRela == "0") { $has_e = "1"; $staff_t = $staff_e; } else { $has_e = "0"; $staff_t = array(); } $invInfo['eno'] = "c{$circleId}"; $title = empty($subject) ? $user->nick_name . " 邀请您加入 " . Utils::makeCircleTipHTMLTag($circleId, $circleName) . " 协作网络" : $subject; $txt = $this->renderView('JustsyBaseBundle:Invite:circle_invitation.html.twig', array("ename" => $user->ename, "nick_name" => $user->nick_name, "activeurl" => $activeurl, 'circle_name' => $circleName, 'invMsg' => $invMsg, "staff" => $staff_t, "has_e" => $has_e)); } $invInfo['inv_title'] = $title; $invInfo['inv_content'] = $txt; $invInfo['active_addr'] = $activeurl; InviteController::saveWeInvInfo($da, $invInfo); $title = empty($subject) ? $user->nick_name . " 邀请您加入 " . $circleName . " 协作网络" : $subject; Utils::saveMail($da, $user->getUsername(), $invacc, $title, $txt, $invInfo['eno']); //Utils::sendMail($this->get('mailer'),$title,$this->container->getParameter('mailer_user'),null,$invacc,$txt); } else { //2.2公共邮箱 if ($invRela == "0") { //邀请同事 $eno = $user->eno; $encode = DES::encrypt($user->getUsername() . ",{$circleId},{$eno}"); $eno = ""; $activeurl = $this->generateUrl("JustsyBaseBundle_active_inv_s1", array('account' => DES::encrypt($invacc), 'invacc' => $encode), true); $txt = $this->renderView('JustsyBaseBundle:Invite:circle_invitation.html.twig', array("ename" => $user->ename, "nick_name" => $user->nick_name, "activeurl" => $activeurl, 'circle_name' => $circleName, 'invMsg' => $invMsg, "staff" => $staff_c, "has_e" => "1")); //保存邀请信息 circleid保存到eno字段,以字母'c'开头 $invInfo['eno'] = "c{$circleId}"; $invInfo['inv_title'] = empty($subject) ? $user->nick_name . " 邀请您加入 " . Utils::makeCircleTipHTMLTag($circleId, $circleName) . " 协作网络" : $subject; $invInfo['inv_content'] = $txt; $invInfo['active_addr'] = $activeurl; InviteController::saveWeInvInfo($da, $invInfo); $invInfo['inv_title'] = empty($subject) ? $user->nick_name . " 邀请您加入 " . $circleName . " 协作网络" : $subject; Utils::saveMail($da, $user->getUsername(), $invacc, $invInfo['inv_title'], $txt, $invInfo['eno']); //Utils::sendMail($this->get('mailer'),"邀请加入圈子【".$circleName."】",$this->container->getParameter('mailer_user'),null,$invacc,$txt); } else { $sql = "insert into we_register (login_account,ename,credential_path,active_code,ip,email_type,first_reg_date,last_reg_date,register_date,state_id) " . "select ?,'','','" . strtoupper(substr(uniqid(), 3, 10)) . "','" . $_SERVER['REMOTE_ADDR'] . "','0',now(),now(),now(),'2' from dual " . "where not exists (select 1 from we_register where login_account=?)"; $para = array($invacc, $invacc); $da->ExecSQL($sql, $para); //发送邮件 帐号,圈子id,邀请发送者帐号,邀请人企业名 des encode $encode = DES::encrypt("{$invacc},{$circleId}," . $user->getUserName() . "," . $user->ename); $activeurl = $this->generateUrl("JustsyBaseBundle_active_reg_s1", array('account' => $encode), true); if ($circleId == "-1") { $invInfo['eno'] = "-1"; $circleName = "Wefafa企业"; $title = empty($subject) ? $user->nick_name . " 邀请您加入" . $circleName . "协作网络" : $subject; $txt = $this->renderView("JustsyBaseBundle:Invite:enterprise_invitation.html.twig", array("ename" => $user->ename, "realName" => $user->nick_name, "activeurl" => $activeurl, "invMsg" => $invMsg, "staff" => array())); } else { $invInfo['eno'] = "c{$circleId}"; $title = empty($subject) ? $user->nick_name . " 邀请您加入 " . Utils::makeCircleTipHTMLTag($circleId, $circleName) . " 协作网络" : $subject; $txt = $this->renderView('JustsyBaseBundle:Invite:circle_invitation.html.twig', array("ename" => $user->ename, "nick_name" => $user->nick_name, "activeurl" => $activeurl, 'circle_name' => $circleName, 'invMsg' => $invMsg, "staff" => array())); } //保存邀请信息 $invInfo['inv_title'] = $title; $invInfo['inv_content'] = $txt; $invInfo['active_addr'] = $activeurl; InviteController::saveWeInvInfo($da, $invInfo); $invInfo['inv_title'] = empty($subject) ? $user->nick_name . " 邀请您加入 " . $circleName . " 协作网络" : $subject; Utils::saveMail($da, $user->getUsername(), $invacc, $title, $txt, $invInfo['eno']); //Utils::sendMail($this->get('mailer'),$title,$this->container->getParameter('mailer_user'),null,$invacc,$txt); } } } } else { //判断受邀请人是否已注册,已注册的不能再邀请加个企业圈子 //与邀请人不同企业域的其他企业邮箱不能加入 if (!$isReg) { //加入企业 $activeurl = $this->generateUrl("JustsyBaseBundle_active_inv_s1", array('account' => DES::encrypt($invacc), 'invacc' => DES::encrypt($user->getUsername())), true); $txt = $this->renderView("JustsyBaseBundle:Invite:enterprise_invitation.html.twig", array("ename" => $user->ename, "realName" => $user->nick_name, "activeurl" => $activeurl, "invMsg" => $invMsg, "staff" => $staff_e, "has_e" => "1")); //保存邀请信息 $invInfo['eno'] = $eno; $invInfo['inv_title'] = empty($subject) ? "您的同事 " . $user->nick_name . " 邀请您加入Wefafa企业协作网络" : $subject; $invInfo['inv_content'] = $txt; $invInfo['active_addr'] = $activeurl; InviteController::saveWeInvInfo($da, $invInfo); Utils::saveMail($da, $user->getUsername(), $invacc, $invInfo['inv_title'], $txt, $invInfo['eno']); } } } } catch (\Exception $e) { $logger->err($e); return new Response('0'); } return new Response('1'); }
public function invitedmemebersAction() { $re = array("returncode" => ReturnCode::$SUCCESS); $user = $this->get('security.context')->getToken()->getUser(); $request = $this->getRequest(); $group_id = $request->get("group_id"); $circle_id = $request->get("circle_id"); $group_name = $request->get("group_name"); $fafa_groupid = $request->get('fafa_groupid'); $invitedmemebers = $request->get("invitedmemebers"); $im_sender = $this->container->getParameter('im_sender'); $da = $this->get('we_data_access'); try { if (empty($circle_id) || empty($group_id) || empty($fafa_groupid) || empty($invitedmemebers)) { $re["returncode"] = ReturnCode::$SYSERROR; $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re)); $response->headers->set('Content-Type', 'text/json'); return $response; } $invs = explode(";", $invitedmemebers); $title = "邀请加入群组"; $groupStaffs = array(); $sql = "select login_account from we_group_staff where group_id=?"; $ds = $da->GetData("group_staffs", $sql, array($group_id)); if ($ds && $ds["group_staffs"]["recordcount"] > 0) { foreach ($ds["group_staffs"]["rows"] as &$row) { $groupStaffs[] = $row['login_account']; } } foreach ($invs as $key => $value) { if (empty($value)) { continue; } if (count($groupStaffs) > 0 && in_array($value, $groupStaffs)) { continue; } //群编号,被邀请人帐号,network_domain,fafa_groupid $encode = DES::encrypt("{$group_id},{$value},{$circle_id}," . $fafa_groupid); $activeurl = $this->generateUrl("JustsyBaseBundle_group_invjoin", array('para' => $encode), true); $txt = $this->renderView("JustsyBaseBundle:Group:message.html.twig", array("ename" => $user->ename, "realName" => $user->nick_name, "activeurl" => $activeurl, 'gname' => $group_name)); //发送站内消息 $msgId = SysSeq::GetSeqNextValue($da, "we_message", "msg_id"); $sql = "insert into we_message(msg_id,sender,recver,title,content,send_date)values(?,?,?,?,?,now())"; $da->ExecSQL($sql, array((int) $msgId, (string) $user->getUserName(), (string) $value, "邀请加入群组", $txt)); //发送即时消息 $fafa_jid = Utils::getJidByAccount($da, $value); //$this->get("logger")->info(Utils::makeHTMLElementTag('employee',$user->fafa_jid,$user->nick_name)); $message = Utils::makeHTMLElementTag('employee', $user->fafa_jid, $user->nick_name) . "邀请您加入群组【" . Utils::makeHTMLElementTag('group', $fafa_groupid, $group_name) . "】"; $buttons = array(); $buttons[] = array("text" => "拒绝", "code" => "agree", "value" => "0"); $buttons[] = array("text" => "立即加入", "code" => "agree", "value" => "1"); Utils::sendImMessage($im_sender, $fafa_jid, $title, $message, $this->container, $activeurl . "?invite_user="******"1"); } $re["returncode"] = ReturnCode::$SUCCESS; } catch (\Exception $e) { $re["returncode"] = ReturnCode::$SYSERROR; $this->get('logger')->err($e); } $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re)); $response->headers->set('Content-Type', 'text/json'); return $response; }
public function invitedmemebersAction() { $re = array("returncode" => ReturnCode::$SUCCESS); $user = $this->get('security.context')->getToken()->getUser(); $request = $this->getRequest(); $circle_id = $request->get("circle_id"); $invitedmemebers = $request->get("invitedmemebers"); $da = $this->get('we_data_access'); $da_im = $this->get('we_data_access_im'); try { if (empty($invitedmemebers) || empty($circle_id)) { $re["returncode"] = ReturnCode::$SYSERROR; $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re)); $response->headers->set('Content-Type', 'text/json'); return $response; } $circlename = ""; $fafa_groupid = ""; $user = $this->get('security.context')->getToken()->getUser(); $invInfo = array('inv_send_acc' => $user->getUsername(), 'inv_recv_acc' => '', 'eno' => '', 'inv_rela' => '', 'inv_title' => '', 'inv_content' => '', 'active_addr' => ''); $invitedmemebersLst = explode(";", $invitedmemebers); $circleStaffs = array(); $sql = "select login_account from we_circle_staff where circle_id=?"; $ds = $da->GetData("circle_staffs", $sql, array($circle_id)); if ($ds && $ds["circle_staffs"]["recordcount"] > 0) { foreach ($ds["circle_staffs"]["rows"] as &$row) { $circleStaffs[] = $row['login_account']; } } $sql = "select circle_name,fafa_groupid from we_circle where circle_id=?"; $ds = $da->GetData("circle", $sql, array($circle_id)); if ($ds && $ds["circle"]["recordcount"] > 0) { $circlename = $ds["circle"]["rows"][0]['circle_name']; $fafa_groupid = $ds["circle"]["rows"][0]['fafa_groupid']; } foreach ($invitedmemebersLst as $key => $value) { $invacc = trim($value); if (empty($invacc)) { continue; } $invInfo['inv_recv_acc'] = $invacc; $sql = "select eno,fafa_jid from we_staff where login_account=?"; $ds = $da->GetData("we_staff", $sql, array((string) $invacc)); //帐号存在 if ($ds && $ds['we_staff']['recordcount'] > 0) { if (count($circleStaffs) > 0 && in_array($invacc, $circleStaffs)) { continue; } //1.帐号存在,直接加入圈子 //受邀人员帐号,圈子id,邀请人帐号 $encode = DES::encrypt("{$invacc},{$circle_id}," . $user->getUsername()); $activeurl = $this->generateUrl("JustsyBaseBundle_invite_agreejoincircle", array('para' => $encode, 'eno' => 'c' . $circle_id), true); $rejectactiveurl = $this->generateUrl("JustsyBaseBundle_invite_refuse", array('para' => $encode, 'eno' => 'c' . $circle_id), true); $txt = $this->renderView('JustsyBaseBundle:Invite:circle_invitation_msg.html.twig', array("ename" => $user->ename, "nick_name" => $user->nick_name, "activeurl" => $activeurl, 'circle_name' => $circlename, 'invMsg' => '', 'staff' => array())); $invInfo['eno'] = "c{$circle_id}"; $invInfo['inv_title'] = "邀请您加入圈子【" . Utils::makeCircleTipHTMLTag($circle_id, $circlename) . "】"; $invInfo['inv_content'] = ''; $invInfo['active_addr'] = $activeurl; //保存邀请信息 InviteController::saveWeInvInfo($da, $invInfo); //发送即时消息 $fafa_jid = $ds['we_staff']['rows'][0]['fafa_jid']; $message = Utils::makeHTMLElementTag('employee', $user->fafa_jid, $user->nick_name) . "邀请您加入圈子【" . Utils::makeHTMLElementTag('circle', $fafa_groupid, $circlename) . "】"; $buttons = array(); $buttons[] = array("text" => "拒绝", "code" => "agree", "value" => "0", "link" => $rejectactiveurl); $buttons[] = array("text" => "立即加入", "code" => "agree", "value" => "1", "link" => $activeurl); Utils::sendImMessage($im_sender, $fafa_jid, "邀请加入圈子", $message, $this->container, "", Utils::makeBusButton($buttons), false, Utils::$systemmessage_code); } else { //2.帐号不存在 $tmp = explode("@", $invacc); $tmp = count($tmp) > 1 ? $tmp[1] : 'fafatime.com'; $sql = "select count(1) as cnt from we_public_domain where domain_name=?"; $ds = $da->GetData("we_public_domain", $sql, array((string) $tmp)); if ($ds && $ds['we_public_domain']['rows'][0]['cnt'] == 0) { //2.1企业邮箱 $sql = "select eno from we_enterprise where edomain=?"; $ds = $da->GetData("we_enterprise", $sql, array((string) $tmp)); if ($ds && $ds['we_enterprise']['recordcount'] > 0) { //2.1.1企业已创建 帐号,圈子id,企业edomain des encode $eno = $ds['we_enterprise']['rows'][0]['eno']; $encode = DES::encrypt($user->getUsername() . ",{$circle_id},{$eno}"); $activeurl = $this->generateUrl("JustsyBaseBundle_active_inv_s1", array('account' => DES::encrypt($invacc), 'invacc' => $encode), true); } else { //2.1.2企业未创建 $sql = "insert into we_register (login_account,ename,credential_path,active_code,ip,email_type,first_reg_date,last_reg_date,register_date,state_id)" . " values (?,?,?,?,?,?,now(),now(),now(),'0')"; $para = array($invacc, '', '', strtoupper(substr(uniqid(), 3, 10)), $_SERVER['REMOTE_ADDR'], '1'); $da->ExecSQL($sql, $para); //发送邮件 帐号,圈子id,邀请发送者帐号,邀请人企业名 des encode $encode = DES::encrypt("{$invacc},{$circle_id}," . $user->getUserName() . "," . $user->ename); $activeurl = $this->generateUrl("JustsyBaseBundle_active_reg_s1", array('account' => $encode), true); } //保存邀请信息 circleid保存到eno字段,以字母'c'开头 $invInfo['eno'] = "c{$circle_id}"; $title = $user->nick_name . " 邀请您加入 " . Utils::makeCircleTipHTMLTag($circle_id, $circlename) . " 协作网络"; $txt = $this->renderView('JustsyBaseBundle:Invite:circle_invitation.html.twig', array("ename" => $user->ename, "nick_name" => $user->nick_name, "activeurl" => $activeurl, 'circle_name' => $circlename, 'invMsg' => '', 'staff' => array())); $invInfo['inv_title'] = $title; $invInfo['inv_content'] = $txt; $invInfo['active_addr'] = $activeurl; InviteController::saveWeInvInfo($da, $invInfo); Utils::saveMail($da, $user->getUsername(), $invacc, $title, $txt, $invInfo['eno']); } else { //公共邮箱 $sql = "insert into we_register (login_account,ename,credential_path,active_code,ip,email_type,first_reg_date,last_reg_date,register_date,state_id) " . "select ?,'','','" . strtoupper(substr(uniqid(), 3, 10)) . "','" . $_SERVER['REMOTE_ADDR'] . "','0',now(),now(),now(),'2' from dual " . "where not exists (select 1 from we_register where login_account=?)"; $para = array($invacc, $invacc); $da->ExecSQL($sql, $para); //发送邮件 帐号,圈子id,邀请发送者帐号,邀请人企业名 des encode $encode = DES::encrypt("{$invacc},{$circle_id}," . $user->getUserName() . "," . $user->ename); $activeurl = $this->generateUrl("JustsyBaseBundle_active_reg_s1", array('account' => $encode), true); $invInfo['eno'] = "c{$circle_id}"; $title = $user->nick_name . " 邀请您加入 " . Utils::makeCircleTipHTMLTag($circle_id, $circlename) . " 协作网络"; $txt = $this->renderView('JustsyBaseBundle:Invite:circle_invitation.html.twig', array("ename" => $user->ename, "nick_name" => $user->nick_name, "activeurl" => $activeurl, 'circle_name' => $circlename, 'invMsg' => '', 'staff' => array())); //保存邀请信息 $invInfo['inv_title'] = $title; $invInfo['inv_content'] = $txt; $invInfo['active_addr'] = $activeurl; InviteController::saveWeInvInfo($da, $invInfo); Utils::saveMail($da, $user->getUsername(), $invacc, $title, $txt, $invInfo['eno']); } } } $re["returncode"] = ReturnCode::$SUCCESS; } catch (\Exception $e) { $re["returncode"] = ReturnCode::$SYSERROR; $this->get('logger')->err($e); } $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re)); $response->headers->set('Content-Type', 'text/json'); return $response; }
public function resetMicroPwdAction($network_domain) { $re = array('s' => 1, 'm' => ''); try { $conn = $this->get('we_data_access'); $conn_im = $this->get('we_data_access_im'); $userinfo = $this->get('security.context')->getToken()->getUser(); $getRequest = $this->getRequest(); $micro_account = $getRequest->get("micro_account"); $newpwd = $getRequest->get("newpwd"); $factory = $this->get('security.encoder_factory'); $encoder = $factory->getEncoder($userinfo); $t_code = DES::encrypt($newpwd); $micro_password = $encoder->encodePassword($newpwd, $micro_account); $sql = "update we_staff set password=? where login_account=?"; $params = array($micro_password, $micro_account); $conn->ExecSQL($sql, $params); } catch (\Exception $e) { $this->get('logger')->err($e->getMessage()); $re['s'] = 0; $re['m'] = '重设密码失败'; } $response = new Response(json_encode($re)); $response->headers->set('Content-Type', 'text/json'); return $response; }
public static function userAuthAction($container, $request, $dbcon, $con_im, $login_account, $password, $comefrom) { $login_account = strtolower($login_account); try { $password = strtoupper(md5($password)); //$container->get("logger")->err($password); $staff = new Staff($dbcon, $con_im, strtolower($login_account)); $user = $staff->getInfo(); if ($user == null || $user["state_id"] != "1") { $re["returncode"] = ReturnCode::$ERROFUSERORPWD; return $re; } $login_account = $user["login_account"]; $Obj = new \Justsy\BaseBundle\Login\UserProvider($container); // $factory = $container->get('security.encoder_factory'); //判断是否修改过密码.这时针对从第三方注册的帐号的密码为不可解开密文的情况时,sns中的密码和t_code字段临时存储为完全相同的数据 //程序判断到这种情况 时,需要进行内部自动更改密码操作,之前的临时数据即为用户新密码 //$container->get("logger")->err($user["password"]."==".$user["t_code"]); if ($user["password"] == $user["t_code"]) { $tmpPass = DES::encrypt($password); if ($tmpPass != $user["t_code"]) { $re["returncode"] = ReturnCode::$ERROFUSERORPWD; } //更新密码 $staff->changepassword($login_account, $password, $factory); } $user = new UserSession($login_account, $password, $login_account, array("ROLE_USER")); $encoder = $factory->getEncoder($user); $password_enc = $encoder->encodePassword($password, $login_account); $user = $Obj->loadUserByUsername($login_account, $comefrom); //$container->get("logger")->err($user->getPassword()."==".$password_enc); $logined = 1; if ($user->getPassword() != $password_enc) { //如果密码不正确时,有可能是修改了密码,只刷新了一台服务器上的缓存,其他集群环境中的还是原来的缓存 //刷新当前服务器的人员信息才重试 $u_staff = new Staff($dbcon, $con_im, $user->getusername(), $container->get('logger')); $user = $u_staff->getInfo(true); //刷新人员信息 //$container->get("logger")->err("refresh cache data....."); $user = $Obj->loadUserByUsername($login_account, $comefrom); if ($user->getPassword() != $password_enc) { $container->get("logger")->err($login_account . "==>" . $password . "=>" . $password_enc . "=>" . $user->getPassword()); $re["returncode"] = ReturnCode::$ERROFUSERORPWD; $logined = null; } } if (!empty($logined)) { //�Ǽ�seesion $token = new \Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken($user, $user->getPassword(), "secured_area", $user->getRoles()); $container->get("security.context")->setToken($token); $session = $request->getSession()->set('_security_' . 'secured_area', serialize($token)); $event = new \Symfony\Component\Security\Http\Event\InteractiveLoginEvent($request, $token); $container->get("event_dispatcher")->dispatch("security.interactive_login", $event); $re["returncode"] = ReturnCode::$SUCCESS; $re["openid"] = $user->openid; $re["login_account"] = $login_account; $re["ldap_uid"] = $user->ldap_uid; $re["jid"] = $user->fafa_jid; $re["des"] = $user->t_code; } } catch (\Symfony\Component\Security\Core\Exception\UsernameNotFoundException $e) { $re["returncode"] = ReturnCode::$ERROFUSERORPWD; } catch (\Exception $e) { $container->get("logger")->err($e); $re["returncode"] = ReturnCode::$SYSERROR; } return $re; }
public function updatepassword($parameter) { $re = array(); $user = $parameter["user"]; $factory = $this->container->get('security.encoder_factory'); $encoder = $factory->getEncoder($user); $oldpwd = $parameter['txtoldpwd']; $pwd = $parameter["txtnewpwd"]; if (empty($oldpwd)) { return Utils::WrapResultError("原密码不能为空"); } if (empty($pwd)) { return Utils::WrapResultError("新密码不能为空"); } $da = $this->conn; $da_im = $this->conn_im; $Jid = $user->fafa_jid; $eno = $user->eno; $OldPass = $user->getPassword(); $Old_t_code = $user->t_code; $oldpwd = $encoder->encodePassword($oldpwd, $user->getSalt()); if ($oldpwd != $OldPass) { return Utils::WrapResultError("原密码不正确"); } $t_code = DES::encrypt($pwd); $sql = "update we_staff set password=?,t_code=? where login_account=?"; $paras[0] = $encoder->encodePassword($pwd, $user->getSalt()); $paras[1] = $t_code; $paras[2] = $user->getUsername(); try { $da->ExecSQL($sql, $paras); //同步ejabberd try { $jid = $user->fafa_jid; $sqls_im = array("update im_employee set password=? where loginname=?"); $paras_im = array(array((string) $t_code, (string) $jid)); $sqls_im[] = "update users set password=? where username=?"; $paras_im[] = array((string) $t_code, (string) $jid); $da_im->ExecSQLs($sqls_im, $paras_im); $this->getInfo(true); return Utils::WrapResultOK(true); } catch (\Exception $e) { //还原原密码 $sql = "update we_staff set password=?,t_code=? where login_account=?"; $paras[0] = $OldPass; $paras[1] = $Old_t_code; $paras[2] = $user->getUsername(); $da->ExecSQL($sql, $paras); return Utils::WrapResultError("同步密码出错"); } } catch (\Exception $e) { return Utils::WrapResultError("系统出错"); } }
public function updatepasswordAction() { $re = array(); $request = $this->getRequest(); $user = $this->get('security.context')->getToken()->getUser(); $factory = $this->get('security.encoder_factory'); $encoder = $factory->getEncoder($user); $oldpwd = $request->get('txtoldpwd'); $pwd = $request->get("txtnewpwd"); if (empty($oldpwd)) { $re["returncode"] = ReturnCode::$SYSERROR; $re["msg"] = "原始密码不能为空"; $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re)); $response->headers->set('Content-Type', 'text/json'); return $response; } if (empty($pwd)) { $re["returncode"] = ReturnCode::$SYSERROR; $re["msg"] = "新密码不能为空"; $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re)); $response->headers->set('Content-Type', 'text/json'); return $response; } $da = $this->get("we_data_access"); $table = $da->GetData("staff", "select eno, password, fafa_jid,t_code from we_staff where login_account=?", array((string) $user->getUsername())); $Jid = $table["staff"]["rows"][0]["fafa_jid"]; $eno = $table["staff"]["rows"][0]["eno"]; $OldPass = $table["staff"]["rows"][0]["password"]; $Old_t_code = $table["staff"]["rows"][0]["t_code"]; $oldpwd = $encoder->encodePassword($oldpwd, $user->getSalt()); if ($oldpwd != $OldPass) { $re["returncode"] = ReturnCode::$SYSERROR; $re["msg"] = "原始密码不正确"; $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re)); $response->headers->set('Content-Type', 'text/json'); return $response; } $sql = "update we_staff set password=?,t_code=? where login_account=?"; $paras[0] = $encoder->encodePassword($pwd, $user->getSalt()); $paras[1] = DES::encrypt($pwd); $paras[2] = $user->getUsername(); try { $da->ExecSQL($sql, $paras); //同步ejabberd try { $sql_im = "update users set password=? where username=?"; $para_im = array(); $para_im[] = (string) $pwd; $para_im[] = (string) $user->fafa_jid; $da_im = $this->get('we_data_access_im'); $da_im->ExecSQL($sql_im, $para_im); $re["returncode"] = ReturnCode::$SUCCESS; $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re)); $response->headers->set('Content-Type', 'text/json'); return $response; } catch (\Exception $e) { //还原原密码 $sql = "update we_staff set password=?,t_code=? where login_account=?"; $paras[0] = $OldPass; $paras[1] = $Old_t_code; $paras[2] = $user->getUsername(); $da->ExecSQL($sql, $paras); $re["returncode"] = ReturnCode::$SYSERROR; $re["msg"] = "同步密码出错"; $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re)); $response->headers->set('Content-Type', 'text/json'); return $response; } } catch (\Exception $e) { $re["returncode"] = ReturnCode::$SYSERROR; $re["msg"] = "系统出错"; $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re)); $response->headers->set('Content-Type', 'text/json'); return $response; } }
public function applyJoinAction() { $da = $this->get("we_data_access"); $user = $this->get('security.context')->getToken()->getUser(); $circleId = $this->get('request')->request->get('circleId'); $apply = new \Justsy\BaseBundle\Management\ApplyMgr($da, null); //判断是否已加入该圈子 $sql = "select count(1) as cnt from we_circle_staff where circle_id=? and login_account=?"; $ds = $da->GetData('we_circle_staff', $sql, array((string) $circleId, (string) $user->getUserName())); if (!$ds || $ds['we_circle_staff']['recordcount'] == 0) { //已经是该圈子成员 return new Response("-1"); } //判断是否已超出加入圈子数量的限制 $ec = new \Justsy\BaseBundle\Management\EnoParamManager($da, $this->get('logger')); if ($ec->IsBeyondJoinCircle($user->getUserName())) { return new Response("-2"); } //判断改圈子成员数是否已满 if ($ec->IsBeyondCircleMembers($circleId)) { return new Response("-3"); } //判断是否已申请或者超出申请限制 $result = $apply->ApplyJoinCircle($user->getUsername(), $circleId, ""); if ($result == 0 || $result == 99999) { return new Response((string) $result); } $circleObj = new \Justsy\BaseBundle\Management\CircleMgr($da, null, $circleId); $circle = $circleObj->Get(); if ($circle == null) { return new Response("0"); } $createStaff = $circle["create_staff"]; $circleName = $circle["circle_name"]; //para 圈子ID,申请人帐号,申请人姓名,圈子名称 DES加密 $para = DES::encrypt($circleId . "," . $user->getUserName() . "," . $user->nick_name . "," . $circleName); $addurl = $this->generateUrl("JustsyBaseBundle_publicpage_agreejoincircle", array('para' => $para), true); $refuseurl = $this->generateUrl("JustsyBaseBundle_circle_refusejoincircle", array(), true); $txt = $this->renderView("JustsyBaseBundle:Circle:mail_apply_join.html.twig", array("ename" => $user->ename, "realName" => $user->nick_name, "account" => DES::encrypt($user->getUserName()), "activeurl" => $addurl, "circlename" => $circleName, "refuseurl" => $refuseurl, "para" => $para)); //发送站内消息 $sqls = array(); $paras = array(); $msgId = SysSeq::GetSeqNextValue($da, "we_message", "msg_id"); $sqls[] = "insert into we_message(msg_id,sender,recver,send_date,title,content)values(?,?,?,now(),?,?)"; //$sqls[] = "insert into we_notify(notify_type, msg_id,notify_staff)values('01',?,?)"; $paras[] = array((int) $msgId, (string) $user->getUserName(), (string) $createStaff, "申请加入圈子", $txt); //$paras[] = array((int)$msgId,(string)$createStaff); $da->ExecSQLs($sqls, $paras); Utils::saveMail($da, $user->getUsername(), $createStaff, "申请加入圈子", $txt, $circleId); //Utils::sendMail($this->get('mailer'),"申请加入微发发企业社交圈子",$this->container->getParameter('mailer_user'),null,$createStaff,$txt); //发送即时消息 $im_sender = $this->container->getParameter('im_sender'); $fafa_jid = $circle["fafa_jid"]; $message = Utils::makeHTMLElementTag('employee', $user->fafa_jid, $user->nick_name) . "申请加入您的圈子【" . $circleName . "】"; $buttons = array(); $buttons[] = array("text" => "拒绝", "code" => "agree", "value" => "0", "link" => $refuseurl . "?para=" . $para); $buttons[] = array("text" => "同意", "code" => "agree", "value" => "1", "link" => $addurl); Utils::sendImMessage($im_sender, $fafa_jid, "申请加入圈子", $message, $this->container, "", Utils::makeBusButton($buttons), false, Utils::$systemmessage_code); return new Response("1"); }