Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 public function loadUserByUsername($username, $comeform = "")
 {
     if (Utils::validateMobile($username)) {
         //手机登录
         return $this->loadUserByUsernameWithMobile($username);
     }
     $DataAccess = $this->container->get('we_data_access');
     $staff = new \Justsy\BaseBundle\Management\Staff($DataAccess, $this->container->get('we_data_access_im'), $username, $this->container->get("logger"), $this->container);
     $us = $staff->getInfo();
     if (!empty($us)) {
         $us = $staff->getSessionUser($us);
         return $us;
     } else {
         throw new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username));
     }
 }
Exemplo n.º 3
0
 public function TencentLoginAction()
 {
     $da = $this->get("we_data_access");
     $request = $this->getRequest();
     $openid = $request->get("openid");
     //普通用户的标识,对当前开发者帐号唯一
     $logintype = $request->get("logintype");
     $logintype = empty($logintype) ? "02" : $logintype;
     $ldap_uid = "";
     $login_account = $openid . "@fafatime.com";
     $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $this->get('we_data_access_im'), $login_account, $this->get("logger"), $this->container);
     $staffdata = $staffMgr->getInfo();
     $re = array("returncode" => ReturnCode::$SYSERROR, "msg" => "");
     $password = "";
     //账号为空表示不存在
     if (empty($staffdata)) {
         $sex = $request->get("gender");
         if (trim($sex) == "男") {
             $sex = 1;
         } else {
             if (trim($sex) == "女") {
                 $sex = 2;
             } else {
                 $sex = 0;
             }
         }
         $parameter = array("appid" => $request->get("appid"), "province" => $request->get("province"), "city" => $request->get("city"), "account" => $login_account, "nick_name" => $request->get("nickname"), "eno" => $request->get("eno"), "ldap_uid" => $openid, "openid" => $openid, "sex" => $sex, "headimgurl" => $request->get("figureurl_2"), "type" => "tencent");
         $registerInfo = $staffMgr->createstaff($parameter);
         if ($registerInfo["returncode"] == ReturnCode::$SUCCESS) {
             $re = $this->autologin($login_account, $logintype);
         } else {
             $re = $registerInfo;
         }
     } else {
         $re = $this->autologin($login_account, $logintype);
     }
     $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
Exemplo n.º 4
0
 public function joinCircle($account, $nick_name = null)
 {
     $falg = $this->IsExist($account);
     if ($falg) {
         return false;
     }
     $staffMgr = new \Justsy\BaseBundle\Management\Staff($this->conn, $this->conn_im, $account);
     $staffObj = $staffMgr->getInfo();
     if ($staffObj == null) {
         return false;
     }
     if (empty($nick_name)) {
         $nick_name = $staffObj["nick_name"];
     }
     $falg = $this->NicknameIsExist($nick_name);
     if ($falg) {
         $enoInfo = $staffMgr->getEnInfo();
         $nick_name = $nick_name . "(" . $enoInfo["eshortname"] . ")";
     }
     $sql = "insert into we_circle_staff (circle_id,login_account,nick_name) values (?,?,?)";
     $this->conn->ExecSQL($sql, array((string) $this->circleid, (string) $account, (string) $nick_name));
     return true;
 }
Exemplo n.º 5
0
 public function getuseropenidAction($account)
 {
     $re = array("returncode" => ReturnCode::$SUCCESS);
     $request = $this->get("request");
     $uEno = "";
     if (empty($account)) {
         $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;
     }
     $currUser = $this->get('security.context')->getToken();
     if (!empty($currUser)) {
         $user = $currUser->getUser();
         $uEno = $user->eno;
         //当前登录人企业 号
     } else {
         $ds = $this->getstaffinfo($request->get("Openid") . $request->get("openid"));
         $uEno = $ds["eno"];
     }
     //获取目标帐号的所在企业及openid信息
     $staffMgr = new \Justsy\BaseBundle\Management\Staff($this->get('we_data_access'), $this->get('we_data_access_im'), $account, $this->get("logger"));
     $staff = $staffMgr->getInfo();
     if (empty($staff)) {
         $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 ($uEno != $staff["eno"]) {
         $notaccess = true;
         //没权限访问
         //判断当前帐号是否是微应用。是则需要判断该帐号是否已关注了当前微应用,成功关注的才能获取对应的openid
         if (!empty($user)) {
             $biz_sql = "select 1 from we_micro_account where number=?";
             $da = $this->get('we_data_access');
             $biz_ds = $da->GetData("biz", $biz_sql, array((string) $user->getUserName()));
             if ($biz_ds && count($biz_ds["biz"]["rows"]) > 0) {
                 //当前登录帐号是微应用,判断获取openid的帐号是否关注了微应用
                 $biz_sql = "select 1 from we_staff_atten where login_account=? and atten_id=?";
                 $biz_atten_ds = $da->GetData("biz_atten", $biz_sql, array((string) $staff["login_account"], (string) $user->getUserName()));
                 if ($biz_atten_ds && count($biz_atten_ds["biz_atten"]["rows"]) > 0) {
                     $notaccess = false;
                 }
             }
         }
         if ($notaccess) {
             $re["returncode"] = ReturnCode::$NOTACCESS;
             $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;
         }
     }
     $re["login_account"] = $staff["login_account"];
     $re["nick_name"] = $staff["nick_name"];
     $re["openid"] = $staff["openid"];
     $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
Exemplo n.º 6
0
 public function SendMsgAction()
 {
     $conn = $this->get("we_data_access");
     $conn_im = $this->get("we_data_access_im");
     $request = $this->getRequest();
     $currUser = $this->get('security.context')->getToken();
     if ($currUser == null) {
         $openid = $request->get('openid');
         $staffinfo = new \Justsy\BaseBundle\Management\Staff($conn, $conn_im, $openid, $this->get("logger"), $this->container);
         $staffdata = $staffinfo->getInfo();
         if (empty($staffdata)) {
             $re = array('returncode' => '9999', 'msg' => '无效的操作人');
             return $this->responseJson(json_encode($re));
         }
         $user = $staffinfo->getSessionUser($staffdata);
     } else {
         $user = $this->get('security.context')->getToken()->getUser();
     }
     //公众号相关参数
     $microObj = $request->get('microObj');
     $microName = $microObj["microName"];
     //接收对象(公众号名称)
     $microNumber = $microObj["microNumber"];
     //接收对象(公众号帐号)
     $microOpenid = $microObj["microOpenid"];
     //接收对象(公众号Openid)
     $microType = $microObj["microType"];
     //接收对象(公众号类型,内部或外部)
     $microUse = $microObj["microUse"];
     //接收对象(是公众号还是微应用)
     $microGroupId = "";
     //$microObj["microGroupId"]; //接收对象(公众号分组主键)
     //消息参数
     $msgType = "";
     //消息类型
     $msgContent = "";
     //消息内容(XML拼接Json字符串,包括标题,图片,摘要等)
     $msgContentHtml = "";
     //消息内容(HTML内容)
     $msgTitle = "";
     //消息标题
     $imgUrl = "";
     //图片地址
     $formid = "";
     //表单编号。推送表单时设置
     $webpage_url = "";
     //网页地址。推送网页地址时设置
     $msgObj_list = $request->get('msgObj');
     //消息对象
     if (!empty($msgObj_list)) {
         foreach ($msgObj_list as $key => $val) {
             if ($key == "type") {
                 $msgType = $val;
             } else {
                 if ($key == "msgContent") {
                     $msgContent = $val;
                 } else {
                     if ($key == "contentHtml") {
                         $msgContentHtml = $val;
                     } else {
                         if ($key == "title") {
                             $msgTitle = $val;
                         } else {
                             if ($key == "imgUrl") {
                                 $imgUrl = $val;
                             } else {
                                 if ($key == "formid") {
                                     $formid = $val;
                                 } else {
                                     if ($key == "webpage_url") {
                                         $webpage_url = $val;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $staffinfo = new \Justsy\BaseBundle\Management\Staff($conn, $conn_im, empty($microNumber) ? $microOpenid : $microNumber, $this->get("logger"), $this->container);
     $staffdata = $staffinfo->getInfo();
     if (empty($staffdata)) {
         $re = array('returncode' => '9999', 'msg' => '请选择接收对象');
         return $this->responseJson(json_encode($re));
     } else {
         $microOpenid = $staffdata["openid"];
         $microNumber = $staffdata["login_account"];
     }
     $re = array('returncode' => '0000');
     $sqls = array();
     $paras = array();
     $send_state = '2';
     $id = SysSeq::GetSeqNextValue($conn, 'we_micro_send_message', 'id');
     $sqls[] = "insert into `we_micro_send_message` (`id`, `send_account`, `send_groupid`, `send_datetime`, `send_state`, `send_isbutton`, `send_source`,`send_type`) VALUES (?, ?, ?, now(), ?, ?, ?,?);";
     $paras[] = array($id, $microNumber, $microGroupId, $send_state, false, 'wefafa', $msgType);
     $error = array('returncode' => '9999', 'msg' => '消息内容有误,请检查');
     //处理消息
     switch ($msgType) {
         case 'PICTURE':
             $title = '';
             //标题
             $image_type = '';
             //图片类型  URL或CODE
             $image_value = '';
             //图片地址
             $content = '';
             //摘要
             $link = '';
             //手机端点击之后连接地址
             try {
                 foreach ($msgContent as $key => $value) {
                     if ($key == 'picturemsg') {
                         $picturemsg = $value;
                         //判断参数是否为空。并返回错误提示
                         if (empty($picturemsg)) {
                             return $this->responseJson(json_encode($error));
                         }
                         foreach ($picturemsg as $pkey => $pvalue) {
                             if ($pkey == 'headitem') {
                                 $headitem = $pvalue;
                                 //判断参数是否为空。并返回错误提示
                                 if (empty($headitem)) {
                                     return $this->responseJson(json_encode($error));
                                 }
                                 foreach ($headitem as $hkey => $hvalue) {
                                     if ($hkey == 'title') {
                                         $title = $hvalue;
                                     } else {
                                         if ($hkey == 'image') {
                                             $image = $hvalue;
                                             //判断参数是否为空。并返回错误提示
                                             if (empty($image)) {
                                                 return $this->responseJson(json_encode($error));
                                             }
                                             foreach ($image as $ikey => $ivalue) {
                                                 if ($ikey == 'type') {
                                                     $image_type = $ivalue;
                                                 } else {
                                                     if ($ikey == 'value') {
                                                         $image_value = $ivalue;
                                                     }
                                                 }
                                             }
                                         } else {
                                             if ($hkey == 'content') {
                                                 $content = $hvalue;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             } catch (Exception $e) {
                 $this->get('logger')->err($e->getMessage());
                 return $this->responseJson(json_encode($error));
             }
             if (!empty($webpage_url)) {
                 $link = $webpage_url;
                 $uniqid = $webpage_url;
             } else {
                 $uniqid = str_replace('.', '', uniqid('', true));
                 $link = !empty($formid) ? $this->getWebFormLink($formid) : $this->getLink($uniqid);
                 if (!empty($formid)) {
                     $uniqid = $link;
                 }
             }
             $noticeinfo = Utils::WrapMessageNoticeinfo($title, $microName);
             $msgContent = Utils::WrapMessage("mm-picturemsg", array('headitem' => array('title' => $title, 'image' => array('type' => $image_type, 'value' => $image_value), 'content' => $content, 'link' => $link)), $noticeinfo);
             //$msgContent= array('picturemsg'=>array('headitem'=>array('title'=>$title,'image'=>array('type'=>$image_type,'value'=>$image_value),'content'=>$content,'link'=>$link)));
             $msgid = SysSeq::GetSeqNextValue($conn, 'we_micro_message', 'id');
             $sqls[] = "insert into `we_micro_message` (`id`, `send_id`, `msg_title`, `msg_type`, `msg_text`, `msg_content`, `msg_summary`, `msg_img_type`, `msg_img_url`, `msg_web_url`, `ishead`, `isread`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
             $msgContentHtml = $this->SetElementStyle($msgContentHtml);
             $paras[] = array($msgid, $id, $title, $msgType, null, $msgContentHtml, $content, $image_type, $image_value, $uniqid, true, false);
             break;
         case 'TEXTPICTURE':
             try {
                 $headitem = array();
                 $items = array();
                 foreach ($msgContent as $key => $value) {
                     if ($key == 'textpicturemsg') {
                         $textpicturemsg = $value;
                         if (empty($textpicturemsg)) {
                             return $this->responseJson(json_encode($error));
                         }
                         foreach ($textpicturemsg as $tpmkey => $tpmvalue) {
                             if ($tpmkey == 'headitem') {
                                 $headitem = $tpmvalue;
                                 if (empty($headitem)) {
                                     return $this->responseJson(json_encode($error));
                                 }
                                 $head_title = '';
                                 $head_img_type = '';
                                 $head_img_url = '';
                                 $head_contentHtml = '';
                                 $head_link = '';
                                 $formid = "";
                                 foreach ($headitem as $hkey => $hvalue) {
                                     if ($hkey == 'title') {
                                         $head_title = $hvalue;
                                     } else {
                                         if ($hkey == 'image') {
                                             $image = $hvalue;
                                             if (empty($image)) {
                                                 return $this->responseJson(json_encode($error));
                                             }
                                             foreach ($image as $imgkey => $imgvalue) {
                                                 if ($imgkey == 'type') {
                                                     $head_img_type = $imgvalue;
                                                 } else {
                                                     if ($imgkey == 'value') {
                                                         $head_img_url = $imgvalue;
                                                     }
                                                 }
                                             }
                                         } else {
                                             if ($hkey == 'content') {
                                                 $head_contentHtml = $hvalue;
                                             } else {
                                                 if ($hkey == 'formid') {
                                                     $formid = $hvalue;
                                                 }
                                             }
                                         }
                                     }
                                 }
                                 $uniqid = str_replace('.', '', uniqid('', true));
                                 $head_link = !empty($formid) ? $this->getWebFormLink($formid) : $this->getLink($uniqid);
                                 $headitem = array('title' => $head_title, 'image' => array('type' => $head_img_type, 'value' => $head_img_url), 'link' => $head_link);
                                 $msgid = SysSeq::GetSeqNextValue($conn, 'we_micro_message', 'id');
                                 $sqls[] = "insert into `we_micro_message` (`id`, `send_id`, `msg_title`, `msg_type`, `msg_text`, `msg_content`, `msg_summary`, `msg_img_type`, `msg_img_url`, `msg_web_url`, `ishead`, `isread`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
                                 $head_contentHtml = $this->SetElementStyle($head_contentHtml);
                                 $paras[] = array($msgid, $id, $head_title, $msgType, null, $head_contentHtml, null, $head_img_type, $head_img_url, $uniqid, true, false);
                             } else {
                                 if ($tpmkey == 'item') {
                                     $item = $tpmvalue;
                                     if (empty($item)) {
                                         return $this->responseJson(json_encode($error));
                                     }
                                     $item_array = array();
                                     for ($i = 0; $i < count($item); $i++) {
                                         $item_title = '';
                                         $item_img_type = '';
                                         $item_img_url = '';
                                         $item_contentHtml = '';
                                         $item_link = '';
                                         $formid = "";
                                         foreach ($item[$i] as $itemkey => $itemvalue) {
                                             if ($itemkey == 'title') {
                                                 $item_title = $itemvalue;
                                             } else {
                                                 if ($itemkey == 'image') {
                                                     $image = $itemvalue;
                                                     if (empty($image)) {
                                                         return $this->responseJson(json_encode($error));
                                                     }
                                                     foreach ($image as $imgkey => $imgvalue) {
                                                         if ($imgkey == 'type') {
                                                             $item_img_type = $imgvalue;
                                                         } else {
                                                             if ($imgkey == 'value') {
                                                                 $item_img_url = $imgvalue;
                                                             }
                                                         }
                                                     }
                                                 } else {
                                                     if ($itemkey == 'content') {
                                                         $item_contentHtml = $itemvalue;
                                                     } else {
                                                         if ($itemkey == 'formid') {
                                                             $formid = $itemvalue;
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                         $uniqid = str_replace('.', '', uniqid('', true));
                                         $item_link = !empty($formid) ? $this->getWebFormLink($formid) : $this->getLink($uniqid);
                                         $item_array = array('title' => $item_title, 'image' => array('type' => $item_img_type, 'value' => $item_img_url), 'link' => $item_link);
                                         array_push($items, $item_array);
                                         $msgid = SysSeq::GetSeqNextValue($conn, 'we_micro_message', 'id');
                                         $sqls[] = "INSERT INTO `we_micro_message` (`id`, `send_id`, `msg_title`, `msg_type`, `msg_text`, `msg_content`, `msg_summary`, `msg_img_type`, `msg_img_url`, `msg_web_url`, `ishead`, `isread`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
                                         $paras[] = array($msgid, $id, $item_title, $msgType, null, $item_contentHtml, null, $item_img_type, $item_img_url, $uniqid, false, false);
                                     }
                                 }
                             }
                         }
                     }
                 }
                 $noticeinfo = Utils::WrapMessageNoticeinfo($headitem["title"], $microName);
                 $msgContent = Utils::WrapMessage("mm-textpicturemsg", array('headitem' => $headitem, 'item' => $items), $noticeinfo);
                 //$msgContent= array('textpicturemsg'=>array('headitem'=>$headitem,'item'=>$items));
             } catch (\Exception $e) {
                 $this->get('logger')->err($e->getMessage());
                 return $this->responseJson(json_encode($error));
             }
             break;
         case 'TEXT':
             foreach ($msgContent as $key => $value) {
                 if ($key == 'textmsg') {
                     $textmsg = $value;
                     //判断参数是否为空。并返回错误提示
                     if (empty($textmsg)) {
                         return $this->responseJson(json_encode($error));
                     }
                     foreach ($textmsg as $tkey => $tvalue) {
                         if ($tkey == 'item') {
                             $items = $tvalue;
                             //判断参数是否为空。并返回错误提示
                             if (empty($items)) {
                                 return $this->responseJson(json_encode($error));
                             }
                             $new_items = array();
                             for ($i = 0; $i < count($items); $i++) {
                                 $title = '';
                                 $content = '';
                                 foreach ($items[$i] as $itemkey => $itemvalue) {
                                     if ($itemkey == 'title') {
                                         $title = $itemvalue;
                                     } else {
                                         if ($itemkey == 'content') {
                                             $content = $itemvalue;
                                         }
                                     }
                                 }
                                 if (empty($title)) {
                                     return $this->responseJson(json_encode($error));
                                 }
                                 if (empty($content)) {
                                     return $this->responseJson(json_encode($error));
                                 }
                                 array_push($new_items, array('title' => $title, 'content' => $content));
                                 $msgid = SysSeq::GetSeqNextValue($conn, 'we_micro_message', 'id');
                                 $sqls[] = "INSERT INTO `we_micro_message` (`id`, `send_id`, `msg_title`, `msg_type`, `msg_text`, `msg_content`, `msg_summary`, `msg_img_type`, `msg_img_url`, `msg_web_url`, `ishead`, `isread`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
                                 $paras[] = array($msgid, $id, $title, $msgType, $content, null, null, null, null, null, false, false);
                             }
                             $noticeinfo = Utils::WrapMessageNoticeinfo($title, $microName);
                             $msgContent = Utils::WrapMessage("mm-textmsg", array('item' => $new_items), $noticeinfo);
                             // array('code'=>'textmsg','data'=>array('item'=>$new_items),'noticeinfo'=>'');
                         }
                     }
                 }
             }
             break;
         default:
             //消息类型有误
             return $this->responseJson(json_encode($error));
             break;
     }
     $msgContent = json_encode($msgContent);
     try {
         $staffMgr = new \Justsy\BaseBundle\Management\Staff($conn, $conn_im, $microNumber, $this->get("logger"), $this->container);
         $microData = $staffMgr->getInfo();
         $mic_jid = $microData["fafa_jid"];
         $msgxml = Utils::WrapMicroMessageXml($mic_jid, $msgContent, $id);
         $im_msg_sql = "insert into im_microaccount_msg(microaccount,msg,created,us,msgid)values(?,?,now(),?,?)";
         $conn_im->ExecSQL($im_msg_sql, array((string) $mic_jid, (string) $msgxml, "", (string) $id));
         $fafa_jids = array();
         $sqls_staff = array();
         $paras_staff = array();
         $apicontroller = new \Justsy\OpenAPIBundle\Controller\ApiController();
         $apicontroller->setContainer($this->container);
         $serviceMgr = new \Justsy\BaseBundle\Management\Service($this->container);
         //$this->get('logger')->err("================1:".time());
         $fafa_jids = $serviceMgr->service_sendjid($mic_jid, true);
         //$this->get('logger')->err("================:".json_encode($fafa_jids));
         if (!empty($fafa_jids)) {
             $jids = array();
             $count = count($fafa_jids);
             for ($i = 0; $i < $count; $i++) {
                 array_push($jids, (string) $fafa_jids[$i]);
                 if ($i > 0 && $i % 5000 == 0) {
                     $re = $apicontroller->sendMsg2($microOpenid, implode(",", $jids), $msgContent, $msgType, false, "0", $id);
                     $jids = array();
                 }
             }
             if (!empty($jids) && count($jids) > 0) {
                 $re = $apicontroller->sendMsg2($microOpenid, implode(",", $jids), $msgContent, $msgType, false, "0", $id);
             }
         }
         //$this->get('logger')->err("================3:".time());
         if (!empty($re['returncode']) && $re['returncode'] == '0000') {
             //添加发送消息数据
             if (!empty($sqls)) {
                 $conn->ExecSQLs($sqls, $paras);
             }
             //添加接收人员
             if (!empty($sqls_staff)) {
                 $conn->ExecSQLs($sqls_staff, $paras_staff);
             }
         }
     } catch (\Exception $e) {
         $this->get('logger')->err($e->getMessage());
         $re = array('returncode' => '9999', 'msg' => '消息发送失败');
     }
     return $this->responseJson(json_encode($re));
 }
Exemplo n.º 7
0
 public function write_msg($fromjid, $msgxml, $msgid)
 {
     if (empty($fromjid)) {
         $domain = $this->container->getParameter('edomain');
         $staffinfo = new \Justsy\BaseBundle\Management\Staff($this->conn, $this->conn_im, 'admin@' . $domain, $this->container->get("logger"), $this->container);
         $staffdata = $staffinfo->getInfo();
         $fromjid = $staffdata['jid'];
     }
     if (empty($msgid)) {
         $msgid = split("@", $fromjid);
         $msgid = $msgid[0] . time();
     }
     //存储业务消息
     $xml = Utils::WrapMessageXml($fromjid, $msgxml, $msgid);
     $sql = 'insert into im_b_msg(msg,created,us,msgid)values(?,now(),?,?)';
     $para = array((string) $xml, (string) $fromjid, (string) $msgid);
     $this->conn_im->ExecSQL($sql, $para);
 }
Exemplo n.º 8
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'));
     }
 }
Exemplo n.º 9
0
 public function UploadFileAction()
 {
     $da = $this->get('we_data_access');
     $da_im = $this->get('we_data_access_im');
     $request = $this->getRequest();
     $content = $request->get("update_content");
     $version1 = $request->get("version_1");
     $version2 = $request->get("version_2");
     $version3 = $request->get("version_3");
     $version4 = $request->get("version_4");
     $version = $version1 . "." . $version2 . "." . $version3 . "." . $version4;
     $plist_url = $request->get("plist_url");
     $plist_url = empty($plist_url) ? null : $plist_url;
     $openid = $request->get('openid');
     $staffinfo = new \Justsy\BaseBundle\Management\Staff($da, $this->get("we_data_access_im"), $openid, $this->get("logger"), $this->container);
     $staffdata = $staffinfo->getInfo();
     $login_account = $staffdata["login_account"];
     $fileElementName = 'filedata';
     $success = true;
     $msg = "";
     try {
         $filename = $_FILES[$fileElementName]['name'];
         $filesize = $_FILES[$fileElementName]['size'];
         $filetemp = $_FILES[$fileElementName]['tmp_name'];
         //判断文件类型
         $file_name = basename($filename);
         $fixedType = explode(".", strtolower($file_name));
         $fixedType = $fixedType[count($fixedType) - 1];
         $type = 0;
         if ($fixedType == "apk") {
             $type = 1;
         } else {
             if ($fixedType == "ipa") {
                 $type = 2;
             }
         }
         //比较版本号
         $sql = "select max(replace(version,'.','')) version from we_version where type=?;";
         try {
             $ds = $da->GetData("table", $sql, array((string) $type));
             if ($ds && $ds["table"]["recordcount"] > 0) {
                 $old_ver = (int) $ds["table"]["rows"][0]["version"];
                 $new_ver = $version1 . $version2 . $version3 . $version4;
                 $new_ver = (int) $new_ver;
                 if ($new_ver <= $old_ver) {
                     return Utils::WrapResultError("你输入的版本号比数据库里的小,请重新输入");
                 }
             }
         } catch (\Exception $e) {
             return Utils::WrapResultError($e->getMessage());
         }
         $fileid = $this->saveCertificate($filetemp, $filename);
         if (!empty($fileid)) {
             //上传文件成功后返回文件id
             $url = $this->container->getParameter('FILE_WEBSERVER_URL');
             $path = $_SERVER['DOCUMENT_ROOT'] . "/download/app";
             $dir = explode('src', __DIR__);
             if (!is_dir($dir[0] . '/download/app')) {
                 mkdir($dir[0] . '/download/app', 0777, true);
             }
             $path = $path . "/";
             $dowurl = $url . $fileid;
             $id = SysSeq::GetSeqNextValue($da, "we_version", "id");
             $sql = "insert into we_version(id,version,type,update_content,filename,date,staffid,fileid,plist_url)values(?,?,?,?,?,now(),?,?,?)";
             $para = array((string) $id, (string) $version, (string) $type, (string) $content, (string) $file_name, (string) $login_account, (string) $fileid, $plist_url);
             try {
                 $da->ExecSQL($sql, $para);
                 //发送出席
                 $presence = new \Justsy\OpenAPIBundle\Controller\ApiController();
                 $presence->setContainer($this->container);
                 $my_jid = $staffdata['jid'];
                 $sql = "select distinct us from global_session;";
                 $ds = $da_im->GetData("us", $sql);
                 $tojids = array();
                 $title = "";
                 if ($type == 1) {
                     $title = "andorid";
                 } else {
                     if ($type == 2) {
                         $title = "ios";
                     } else {
                         $title = "pc";
                     }
                 }
                 $sendMessage = new \Justsy\BaseBundle\Common\SendMessage($da, $da_im);
                 $body = "有新版本(" . $version . "),请及时更新!";
                 $notice = Utils::WrapMessageNoticeinfo($body, '系统通知', null, null);
                 $msg = json_encode(Utils::WrapMessage('newversion', array('type' => $title), $notice));
                 $parameter = array("eno" => $staffdata['eno'], "flag" => "all", "title" => "newversion", "message" => $msg, "container" => $this->container);
                 $sendMessage->sendImMessage($parameter);
             } catch (\Exception $e) {
                 $success = false;
                 $this->get("logger")->err($e->getMessage());
                 $msg = "添加数据记录失败!";
                 return Utils::WrapResultError($e->getMessage());
             }
         } else {
             $success = false;
             $msg = "上传安装包文件失败";
             return Utils::WrapResultError($msg);
         }
     } catch (\Exception $e) {
         $success = false;
         $msg = "上传安装包失败。";
         $this->get("logger")->err($e->getMessage());
         return Utils::WrapResultError($e->getMessage());
     }
     //删除上传的文件
     @unlink($_FILES[$fileElementName]);
     return Utils::WrapResultOK("");
 }
Exemplo n.º 10
0
 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']);
 }
Exemplo n.º 11
0
 public function rejectjoin($paraObj)
 {
     $currUser = $paraObj["user"];
     if (empty($currUser)) {
         return Utils::WrapResultError("请登录后重试", ReturnCode::$NOTLOGIN);
     }
     $wfl = new \Justsy\BaseBundle\Business\WeWorkflow($this->container);
     //根据申请帐号处理
     $account = isset($paraObj["staff"]) ? $paraObj["staff"] : "";
     if (!empty($account)) {
         $paraObj["appid"] = $paraObj["user"]->eno;
         $paraObj["submit_staff"] = $account;
     }
     $nodeinfo = $wfl->getNode($paraObj);
     if (empty($nodeinfo)) {
         return Utils::WrapResultError("申请已被取消或删除");
     }
     //判断申请人是否已加入企业
     $staffobj = new \Justsy\BaseBundle\Management\Staff($this->da, $this->container->get('we_data_access_im'), $paraObj["submit_staff"], $this->logger, $this->container);
     $staffata = $staffobj->getInfo();
     if ($staffata["eno"] != Utils::$PUBLIC_ENO) {
         if ($staffata["eno"] == $currUser->eno) {
             return Utils::WrapResultError("该帐号已加入企业");
         } else {
             return Utils::WrapResultError("该帐号已加入其他企业");
         }
     }
     $paraObj["node_id"] = $nodeinfo["node_id"];
     //申请状态处理
     $re = $wfl->reject($paraObj);
     //消息通知
     if (!empty($re)) {
         $message = "你的企业加入申请已被拒绝,请联系企业管理员";
         Utils::sendImMessage("", $re["submit_staff"], "enterprise_joinreject", $message, $this->container, "", "", true, '', '0');
         //通知企业其他管理员
         $endata = $this->getInfo($currUser->eno);
         $to = $endata["sys_manager"];
         if (empty($to)) {
             $to = $endata["create_staff"];
         }
         Utils::sendImMessage("", explode(";", $to), "enterprise_joinreject", json_encode($re), $this->container, "", "", true, '', '0');
     }
     return Utils::WrapResultOK($re);
 }
Exemplo n.º 12
0
 public function refuseAction()
 {
     $logger = $this->get('logger');
     $user = $this->get('security.context')->getToken()->getUser();
     $account = $user->getUsername();
     $da = $this->get('we_data_access');
     $request = $this->getRequest();
     $invite_send_email = $request->get("invite_send_email");
     $eno = $request->get("eno");
     $para = $request->get("para");
     $paraArr = array();
     if (!empty($para)) {
         $paraArr = explode(",", trim(DES::decrypt($para)));
         $invite_send_email = $paraArr[2];
     }
     $name = "";
     if (substr($eno, 0, 1) == "c") {
         //圈子邀请
         $sql = "select circle_name from we_circle where circle_id=?";
         $ds = $da->GetData("c", $sql, array((string) substr($eno, 1)));
         if ($ds && count($ds["c"]["rows"]) > 0) {
             $name = "拒绝了加入圈子【" . $ds["c"]["rows"][0]["circle_name"] . "】的邀请!";
         } else {
             $name = "拒绝了您的邀请!";
         }
     } else {
         if ($eno != "-1") {
             $name = "拒绝了加入企业的邀请!";
         } else {
             $name = "拒绝了注册Wefafa的邀请!";
         }
     }
     $msgId = SysSeq::GetSeqNextValue($da, "we_message", "msg_id");
     $sqls[] = "insert into we_message(msg_id,sender,recver,title,content,send_date)values(?,?,?,?,?,now())";
     $paras[] = array((string) $msgId, (string) $account, (string) $invite_send_email, "拒绝邀请", "【" . $user->nick_name . "】" . $name);
     $sqls[] = "update we_invite set status='1' where invite_recv_email=? and invite_send_email=? and eno=?";
     $paras[] = array((string) $account, (string) $invite_send_email, (string) $eno);
     try {
         $da->ExecSQLs($sqls, $paras);
     } catch (\Exception $e) {
         $logger->err($e);
         return new Response('0');
     }
     if (!empty($para)) {
         $im_sender = $this->container->getParameter('im_sender');
         //向邀请人发送拒绝消息
         $staff = new \Justsy\BaseBundle\Management\Staff($da, null, $invite_send_email);
         $getInfo = $staff->getInfo();
         if ($getInfo == null) {
             return;
         }
         $message = "【" . $user->nick_name . "】" . $name;
         Utils::sendImMessage($im_sender, $getInfo["fafa_jid"], "拒绝加入圈子", $message, $this->container, "", "", false, Utils::$systemmessage_code);
     }
     return new Response('1');
 }
Exemplo n.º 13
0
 public function getNode($parameter)
 {
     $file_url = $this->containerObj->getParameter("FILE_WEBSERVER_URL");
     $node_id = isset($parameter["node_id"]) ? $parameter["node_id"] : "";
     $appid = isset($parameter["appid"]) ? $parameter["appid"] : "";
     $wftype = isset($parameter["wf_type"]) ? $parameter["wf_type"] : "";
     $submit_staff = isset($parameter["submit_staff"]) ? $parameter["submit_staff"] : "";
     $sql = "select b.eno,b.appid,e.ename,concat('{$file_url}',e.logo_path_big) logo_path,a.*,b.wf_name,b.content from we_app_workflow_node a,we_app_businessworkflow b,we_enterprise e where a.wf_id=b.wf_id and b.eno=e.eno ";
     $para = array();
     if (!empty($node_id)) {
         $sql .= " and a.node_id=?";
         $para[] = (string) $node_id;
     }
     if (!empty($appid)) {
         $sql .= " and exists (select 1 from we_app_businessworkflow w where a.wf_id=w.wf_id and w.appid=?)";
         $para[] = (string) $appid;
     }
     if (!empty($submit_staff)) {
         $sql .= " and a.submit_staff=?";
         $para[] = (string) $submit_staff;
     }
     if (!empty($wftype)) {
         $sql .= " and exists (select 1 from we_app_businessworkflow w where a.wf_id=w.wf_id and w.wf_type=?)";
         $para[] = (string) $wftype;
     }
     $re = $this->conn->GetData("t", $sql, $para);
     $re = count($re["t"]["rows"]) > 0 ? $re["t"]["rows"][0] : null;
     if (!empty($re)) {
         $staff = new \Justsy\BaseBundle\Management\Staff($this->conn, $this->conn_im, $re["submit_staff"], $this->logger, $this->containerObj);
         $staffdata = $staff->getInfo();
         $re["nick_name"] = empty($staffdata) ? "" : $staffdata["nick_name"];
         //获取节点附件
         $sql = "select * from we_app_workflow_attachment where node_id=?";
         $ds = $this->conn->GetData("att", $sql, array((string) $re["node_id"]));
         $attachment = array();
         for ($i = 0; $i < count($ds["att"]["rows"]); $i++) {
             $attachment[] = $ds["att"]["rows"][$i]["file_id"];
         }
         $re["attachment"] = implode(",", $attachment);
         //获取共同处理人
         $sql = "select * from we_app_workflow_nodesetting where node_id=?";
         $ds = $this->conn->GetData("att", $sql, array((string) $re["node_id"]));
         $dealstaffs = array();
         for ($i = 0; $i < count($ds["att"]["rows"]); $i++) {
             $dealstaffs[] = $ds["att"]["rows"][$i]["staff_jid"];
         }
         $re["dealstaffs"] = implode(",", $dealstaffs);
     }
     return $re;
 }
Exemplo n.º 14
0
 public function service_revoke($parameter)
 {
     $msgid = $parameter["msgid"];
     $login_account = $parameter["login_account"];
     $user = $parameter["user"];
     $send_jid = $user->fafa_jid;
     $staffMgr = new \Justsy\BaseBundle\Management\Staff($this->conn, $this->conn_im, $login_account, $this->container->get("logger"), $this->container);
     $microData = $staffMgr->getInfo();
     $jid = $this->service_sendjid($microData["fafa_jid"]);
     $to_jid = implode(",", $jid);
     $notice = array();
     $message = json_encode(Utils::WrapMessage('message_revoke', array('type' => 'serviceaccount', 'msgid' => $msgid), $notice));
     $success = Utils::sendImMessage($send_jid, $to_jid, "message_revoke", $message, $this->container, "", "", false, Utils::$systemmessage_code);
     if ($success) {
         //删除推送消息记录
         $sqls = array();
         $paras = array();
         $sql = "delete from we_micro_send_message where id=?;";
         array_push($sqls, $sql);
         array_push($paras, array((string) $msgid));
         $sql = "delete from we_micro_message where send_id=?;";
         array_push($sqls, $sql);
         array_push($paras, array((string) $msgid));
         try {
             $this->conn->ExecSQLS($sqls, $paras);
             $sql = 'delete from im_microaccount_msg where msgid=?';
             $this->conn_im->ExecSQL($sql, array((string) $msgid));
         } catch (\Exception $e) {
             $success = false;
             $this->logger->err($e->getMessage());
             return Utils::WrapResultError($e->getMessage());
         }
     }
     return Utils::WrapResultOK("");
 }