Esempio n. 1
0
 public function sendAvicSMSAction($mobiles, $msg)
 {
     $SMS_ACT = $this->container->getParameter('SMS_ACT');
     $SMS_PWD = $this->container->getParameter('SMS_PWD');
     $SMS_URL = $this->container->getParameter('SMS_URL');
     $SMS_EID = $this->container->getParameter('SMS_EID');
     $mobiles = str_replace(";", ",", $mobiles);
     $content = urlEncode(urlEncode(mb_convert_encoding($msg, 'gb2312', 'utf-8')));
     $pwd = md5($SMS_PWD);
     $apidata = "username={$SMS_ACT}&password={$pwd}&message={$content}&phone={$mobiles}&epid={$SMS_EID}&linkid=&subcode=";
     $this->get("logger")->err($SMS_URL . "?" . $apidata);
     $result = mb_convert_encoding($this->do_post_request($SMS_URL . "?" . $apidata, null), 'utf-8', 'gb2312');
     $this->get("logger")->err($result);
     return Utils::WrapResultOK('');
 }
Esempio n. 2
0
 public function e($parameters)
 {
     if (count($parameters) == 0) {
         return Utils::WrapResultError("无效的eno参数");
     }
     $eno = $parameters[0];
     if (empty($eno)) {
         return Utils::WrapResultError("无效的eno参数");
     }
     $staffMgr = new Enterprise($this->conn, $this->logger, $this->container);
     $staffdata = $staffMgr->getInfo($eno);
     if (empty($staffdata)) {
         return Utils::WrapResultError("未查找到企业信息");
     }
     return Utils::WrapResultOK($staffdata);
 }
Esempio n. 3
0
 public function webServerCtl($paraObj)
 {
     $command = $paraObj['command'];
     if (empty($command)) {
         $result = Utils::WrapResultError("无效的命令");
         return $this->responseJson($result);
     }
     try {
         $dir = explode("src", __DIR__);
         if ($command == "start") {
             $str = "php {$dir[0]}app/console cache:clear --env=prod --no-debug\nchmod -R 777 {$dir[0]}app";
             $command = $dir[0] . 'clear_cache_prod.sh';
             $data = shell_exec($command);
             if (strpos($data, 'Clearing the cache for the prod environment with debug false') === false) {
                 throw new Exception($data);
             }
             return Utils::WrapResultOK($data);
         }
         return Utils::WrapResultError('无效的命令' . $command);
     } catch (\Exception $e) {
         $this->logger->err($e);
         return Utils::WrapResultError($e->getMessage());
     }
 }
Esempio n. 4
0
 public function setCovert($parameter)
 {
     $groupid = isset($parameter["groupid"]) ? $parameter["groupid"] : null;
     $jid = isset($parameter["jid"]) ? $parameter["jid"] : null;
     $state = isset($parameter["state"]) ? $parameter["state"] : "1";
     //默认为添加
     $success = true;
     $msg = "";
     if (empty($groupid)) {
         return Utils::WrapResultError('群编号不能为空');
     } else {
         if (empty($jid)) {
             return Utils::WrapResultError('设置的成员帐号不能为空');
         }
     }
     $sql = "";
     $para = array();
     if ($state == "1") {
         $sql = "insert into im_groupemployee_covert(groupid,jid)values(?,?);";
     } else {
         $sql = "delete from im_groupemployee_covert where groupid=? and jid=?;";
     }
     try {
         $this->conn_im->ExecSQL($sql, array((string) $groupid, (string) $jid));
         //向成员发送出席
         $user = $parameter["user"];
         $title = $state == "1" ? "set_covert" : "cancel_covert";
         $message = $state == "1" ? "设置了您的屏蔽群消息" : "取消了您的屏蔽群消息";
         Utils::sendImPresence($user->fafa_jid, $jid, $title, $message, $this->container, "", "", true, '', '0');
     } catch (\Exception $e) {
         $success = false;
         $msg = $state == "1" ? "设置屏蔽成员失败!" : "取消屏蔽成员失败!";
         return Utils::WrapResultError($e->getMessage());
     }
     return Utils::WrapResultOK('1');
 }
Esempio n. 5
0
 public function removeapply($paraObj)
 {
     $wfl = new \Justsy\BaseBundle\Business\WeWorkflow($this->container);
     $re = $wfl->cancel($paraObj);
     //消息通知
     if ($re) {
         $message = "申请取消成功";
         Utils::sendImMessage("", $paraObj["user"]->fafa_jid, "bus_apply_remove", $message, $this->container, "", "", false, '', '0');
         //通知所有的节点处理人
         $dealstaffJids = isset($re["dealstaffs"]) ? $re["dealstaffs"] : "";
         if (!empty($dealstaffJids)) {
             $to = explode(",", $dealstaffJids);
             Utils::sendImMessage("", $to, "bus_apply_remove", json_encode($re), $this->container, "", "", false, '', '0');
         }
     }
     return Utils::WrapResultOK($re);
 }
Esempio n. 6
0
 public function getProxytokenAction()
 {
     $request = $this->getRequest();
     if ($_SERVER['REQUEST_METHOD'] != "POST") {
         return $this->responseJson($request, array("error" => "10009", "msg" => "HTTP请求仅支持POST提交方式"));
     }
     $conn = $this->get("we_data_access");
     $conn_im = $this->get("we_data_access_im");
     $appid = trim($request->get("appid"));
     $openid = trim($request->get("openid"));
     $code = trim($request->get("code"));
     $grant_type = trim($request->get("grant_type"));
     $state = trim($request->get("state"));
     if (empty($appid)) {
         return $this->responseJson($request, array("error" => ReturnCode::$SYSERROR, "msg" => "应用ID不能为空。"));
     }
     if (empty($code)) {
         return $this->responseJson($request, array("error" => ReturnCode::$SYSERROR, "msg" => "动态授权码不能为空。"));
     }
     if (empty($grant_type)) {
         return $this->responseJson($request, array("error" => ReturnCode::$SYSERROR, "msg" => "固定值grant_type不能为空。"));
     }
     if ($grant_type !== "proxy") {
         return $this->responseJson($request, array("error" => ReturnCode::$SYSERROR, "msg" => "固定值grant_type不正确。"));
     }
     $sql_app = "select appkey from we_appcenter_apps where appid=?";
     $para_app = array($appid);
     $data_app = $conn->GetData("dt", $sql_app, $para_app);
     if ($data_app == null || count($data_app["dt"]["rows"]) == 0 || empty($data_app["dt"]["rows"][0]["appkey"])) {
         return $this->responseJson($request, array("returncode" => ReturnCode::$SYSERROR, "msg" => "应用ID不正确。"));
     }
     $appkey = $data_app["dt"]["rows"][0]["appkey"];
     if (strtolower($code) != strtolower(MD5($appid . $appkey))) {
         return $this->responseJson($request, array("returncode" => ReturnCode::$SYSERROR, "msg" => "动态授权码不正确。"));
     }
     $json = $this->getProxySession($appid, $code, $state, $openid);
     $json = Utils::WrapResultOK($json);
     return $this->responseJson($request, $json);
 }
Esempio n. 7
0
 public function getReplyList($data)
 {
     $noticeid = $data['noticeid'];
     $lastreadid = isset($data['lastreadid']) ? $data['lastreadid'] : '';
     if (empty($lastreadid)) {
         //$sql = 'select ifnull(lastread_reply,0) lastread_reply from im_pushnotice_memebr where noticeid=? and employeeid=?';
         //$ds = $this->conn_im->Getdata('t',$sql,array((int)$noticeid,(string)$this->user['jid']));
         $lastread_reply = 0;
         //$ds['t']['rows'][0]['lastread_reply'];
         $sql = 'select a.msg from im_pushnotice_msg a where a.replyid=? and a.id>? order by a.id desc limit 0,30';
         $ds = $this->conn_im->Getdata('t', $sql, array((int) $noticeid, (int) $lastread_reply));
     } else {
         $sql = 'select a.msg from im_pushnotice_msg a where a.replyid=? and a.id<? order by a.id desc limit 0,30';
         $ds = $this->conn_im->Getdata('t', $sql, array((int) $noticeid, (int) $lastreadid));
     }
     if (empty($lastreadid)) {
         $this->conn_im->ExecSQL('update im_pushnotice_memebr set lastread_reply=(select max(id) from im_pushnotice_msg where replyid=?) where noticeid=? and employeeid=?', array((int) $noticeid, (int) $noticeid, (string) $this->user['jid']));
     }
     $result = array();
     foreach ($ds['t']['rows'] as $key => $value) {
         $result[] = json_decode($value['msg'], true);
     }
     return Utils::WrapResultOK($result);
 }
Esempio n. 8
0
 public function changeLoginAccount($newAccount, $factory)
 {
     $oldUser = $this->getInfo();
     //原用户信息
     $jid = $oldUser["fafa_jid"];
     $t_code = $oldUser["t_code"];
     $ldap_uid = $oldUser["ldap_uid"];
     $pass = DES::decrypt($t_code);
     if (!strpos($newAccount, "@")) {
         $domain = $this->container->getParameter('edomain');
         $ldap_uid = $newAccount;
         $newAccount .= "@" . $domain;
     }
     $user = new \Justsy\BaseBundle\Login\UserSession($newAccount, $pass, $newAccount, array("ROLE_USER"));
     $encoder = $factory->getEncoder($user);
     $micro_password = $encoder->encodePassword($pass, $newAccount);
     $sql = "update we_staff set password=?,t_code=?,ldap_uid=? where login_account=?";
     $paras = array((string) $micro_password, (string) $t_code, (string) $ldap_uid, (string) $this->account);
     $result = array();
     try {
         $dataexec = $this->conn->ExecSQL($sql, $paras);
         //更新帐号
         $this->conn->ExecSQL("call p_change_login_account(?,?)", array((string) $this->account, (string) $newAccount));
         //刷新缓存
         $this->getInfo(true);
         $result = Utils::WrapResultOK("");
     } catch (\Exception $e) {
         $result = Utils::WrapResultError($e->getMessage());
     }
     return $result;
 }
Esempio n. 9
0
 public function validcodeAction()
 {
     $request = $this->getRequest();
     $account = $request->get("account");
     $type = $request->get("type");
     if (empty($type)) {
         $type = "FP";
         //未指定验证码类型时,默认为找回密码类型
     }
     $da = $this->get("we_data_access");
     $re = array("returncode" => ReturnCode::$SUCCESS);
     if (empty($account)) {
         return $this->responseJson(Utils::WrapResultError("帐号不能为空"), $request->get('jsoncallback'));
     }
     try {
         $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, $this->get("we_data_access_im"), $account, $this->get('logger'));
         $staffinfo = $u_staff->getInfo();
         if (empty($staffinfo)) {
             return $this->responseJson(Utils::WrapResultError("帐号不正确,请您重新输入"), $request->get('jsoncallback'));
         }
         if ($isEmail) {
             $mobile = $staffinfo["mobile_bind"];
             if (empty($mobile)) {
                 return $this->responseJson(Utils::WrapResultOK("该帐号未绑定手机号,你可以通过网页版找回密码"), $request->get('jsoncallback'));
             }
         } else {
             $mobile = $account;
         }
         //验证码获取检查
         $sql = "select (select unix_timestamp( now())-unix_timestamp(req_date) maxlong from we_mobilebind_validcode where login_account=? and actiontype='" . $type . "' and req_date>=SUBDATE(now(),INTERVAL 8 HOUR) order by req_date desc limit 0,1) maxlong,(select count(1) cnt FROM we_mobilebind_validcode where login_account=? and actiontype='" . $type . "' and date(req_date)=date(now())) num";
         $ds = $da->Getdata('wnvc', $sql, array((string) $account, (string) $account));
         $lastgetmobilevaildcodetime = $ds["wnvc"]["rows"][0]["maxlong"];
         $getmobilevaildcodenums = $ds["wnvc"]["rows"][0]["num"];
         if (!empty($lastgetmobilevaildcodetime) && $lastgetmobilevaildcodetime < 60) {
             return $this->responseJson(Utils::WrapResultError("你获取验证码的次数太频繁!每分钟内只能取一次!"), $request->get('jsoncallback'));
         }
         if ($getmobilevaildcodenums >= 5) {
             return $this->responseJson(Utils::WrapResultError("你获取验证码的次数太多!每天最多只能取5次!"), $request->get('jsoncallback'));
         }
         $mobilevaildcode = rand(100000, 999999);
         //根据邮箱找回且没有绑定手机时,发送邮件
         $id = SysSeq::GetSeqNextValue($da, "we_mobilebind_validcode", "id");
         $req_date = getdate();
         if (!empty($mobile)) {
             $content = "验证码:" . $mobilevaildcode . ",2分钟内有效,仅用于" . ($type == "FP" ? "找回密码" : "绑定手机号") . "。 【Wefafa】";
             $ec = new \Justsy\BaseBundle\Controller\SendSMSController();
             $ec->setContainer($this->container);
             $ret = $ec->sendSMSAction($mobile, $content);
             if (strpos($ret, "<errorcode>0</errorcode>") > 0) {
                 $da->ExecSQLs(array("delete from we_mobilebind_validcode where login_account=? and actiontype='" . $type . "' and req_date<date(now())", "insert into we_mobilebind_validcode (id,login_account,req_date,valid_date,validcode,actiontype,mobileno) values\n              (?,?,now(),date_add(now(),interval 2 minute),?,?,?)"), array(array((string) $account), array((string) $id, (string) $account, (string) $mobilevaildcode, (string) $type, (string) $mobile)));
                 return $this->responseJson(Utils::WrapResultOK("验证码已发送到您的手机,收到验证码后进行" . ($type == "FP" ? "重置密码" : "绑定手机号") . "操作"), $request->get('jsoncallback'));
             } else {
                 return $this->responseJson(Utils::WrapResultError("验证码短信发送失败!请稍后重试"), $request->get('jsoncallback'));
             }
         }
     } catch (Exception $e) {
         $this->get('logger')->err($e);
         return $this->responseJson(Utils::WrapResultError("获取验证码错误!请稍后重试"), $request->get('jsoncallback'));
     }
 }
Esempio n. 10
0
 public function SearchVersionAction()
 {
     $da = $this->get("we_data_access");
     $request = $this->getRequest();
     $pageindex = (int) $request->get("pageindex");
     $pagenumber = (int) $request->get("record");
     $success = true;
     $msg = "";
     $limit = " limit " . ($pageindex - 1) * $pagenumber . "," . $pagenumber;
     $para = array();
     $url = $this->container->getParameter('FILE_WEBSERVER_URL');
     $sql = "select a.id,version,case type when 0 then 'PC版' when 1 then 'Android版' when 2 then 'IOS版' end apptype,update_content,\n                   concat('{$url}',fileid) down_url,date_format(date,'%Y-%m-%d %H:%i') date,nick_name\n            from we_version a inner join we_staff b on staffid=login_account order by date desc,type desc " . $limit;
     try {
         $ds = $da->GetData("table", $sql, $para);
     } catch (\Exception $e) {
         $this->get("logger")->err($e->getMessage());
         return Utils::WrapResultError($e->getMessage());
     }
     $data = $ds["table"]["rows"];
     $recordcount = 0;
     if ($pageindex == 1) {
         //如果为第一页时返回记录总数
         $sql = " select count(*) recordcount from we_version;";
         if (count($para) > 0) {
             $ds = $da->GetData("table", $sql, $para);
         } else {
             $ds = $da->GetData("table", $sql);
         }
         if ($ds && $ds["table"]["recordcount"] > 0) {
             $recordcount = $ds["table"]["rows"][0]["recordcount"];
         }
     }
     return Utils::WrapResultOK($data);
 }
Esempio n. 11
0
 public function dealapplylist($paraObj)
 {
     $currUser = $paraObj["user"];
     if (empty($currUser)) {
         return Utils::WrapResultError("请登录后重试", ReturnCode::$NOTLOGIN);
     }
     $wfl = new \Justsy\BaseBundle\Business\WeWorkflow($this->container);
     if (isset($paraObj["status"])) {
         if ($paraObj["status"] == "todo") {
             return Utils::WrapResultOK($wfl->listtodo($paraObj));
         }
         if ($paraObj["status"] == "did") {
             return Utils::WrapResultOK($wfl->listtdid($paraObj));
         }
     }
     return Utils::WrapResultOK($wfl->listall($paraObj));
 }
Esempio n. 12
0
 public function getatten_staff_setup($paramObj)
 {
     $staff = $paramObj['staff'];
     $user = $paramObj['user'];
     $eno = $user->eno;
     $sql = 'select * from ma_checkatten_setup where object_id=? and eno=? and object_type=3 and setup_statu=1';
     $ds = $this->conn->GetData('t', $sql, array((string) $staff, (string) $user->eno));
     if (count($ds['t']['rows']) == 0) {
         $staffMgr = new Staff($this->conn, $this->conn_im, $staff, $this->logger, $this->container);
         $data = $staffMgr->getInfo();
         $paramObj['deptid'] = $data['dept_id'];
         return $this->getatten_dept_setup($paramObj);
     }
     return Utils::WrapResultOK($ds['t']['rows']);
 }
Esempio n. 13
0
 private function parseEjabberdCfg($cfgPath)
 {
     $data = array();
     $handle = @fopen($cfgPath, "r");
     if ($handle) {
         while (($buffer = fgets($handle)) !== false) {
             $buffer = trim($buffer);
             if (empty($buffer) || $buffer[0] == '%') {
                 //$data[] = $buffer;
             } else {
                 $data[] = $buffer[strlen($buffer) - 1] == '.' ? rtrim($buffer, '.') . '\\n' : $buffer;
             }
         }
         if (!feof($handle)) {
             return Utils::WrapResultError($cfgPath . '文件上调用fgets函数失败!');
         }
         fclose($handle);
         $formatContent = implode('', $data);
         $data = explode('\\n', $formatContent);
         return Utils::WrapResultOK($data);
     } else {
         return Utils::WrapResultError($cfgPath . '文件打开失败,请检查参数ejabberd_server_path设置及文件是否存在!');
     }
 }
Esempio n. 14
0
 public function cancelAutoFriend($parameter)
 {
     $userinfo = $parameter["user"];
     $user = array();
     $user["login_account"] = $userinfo->getUserName();
     $user["fafa_jid"] = $userinfo->fafa_jid;
     $deptids = $parameter["deptid"];
     $success = true;
     $message = array();
     for ($i = 0; $i < count($deptids); $i++) {
         $deptid = $deptids[$i];
         $sql = 'update im_base_dept set friend=0 where deptid=?';
         $this->conn_im->ExecSQL($sql, array((string) $deptid));
         $this->getinfo($deptid, true);
     }
     return Utils::WrapResultOK('');
 }
Esempio n. 15
0
 public function getMessageDetail($parameter)
 {
     $msgid = $parameter["msgid"];
     $sql = "select msg_title,msg_type,case when msg_type='TEXT' then msg_text else msg_content end as msg_content,ifnull(msg_summary,'') msg_summary,msg_img_url \n              from we_micro_message where send_id=?;";
     $success = true;
     $returndata = array();
     $msg_type = "";
     try {
         $ds = $this->conn->GetData("table", $sql, array((string) $msgid));
         if ($ds && $ds["table"]["recordcount"] > 0) {
             $returndata = $ds["table"]["rows"];
             $msg_type = strtolower($ds["table"]["rows"][0]["msg_type"]);
         }
     } catch (\Exception $e) {
         $success = false;
         $this->logger->err($e->getMessage());
         return Utils::WrapResultError($e->getMessage());
     }
     return Utils::WrapResultOK($returndata);
 }
Esempio n. 16
0
 public function monitorlistAction()
 {
     $da = $this->get("we_data_access");
     $da_im = $this->get('we_data_access_im');
     $request = $this->getRequest();
     //访问权限校验
     $api = new ApiController();
     $api->setContainer($this->container);
     $isWeFaFaDomain = $api->checkWWWDomain();
     if (!$isWeFaFaDomain) {
         $token = $api->checkAccessToken($request, $da);
         if (!$token) {
             $re = array("returncode" => "9999");
             $re["code"] = "err0105";
             $re["msg"] = "参数Appid或Openid或Access_token未指定或无效.";
             return $this->responseJson($request, $re);
         }
     }
     $openid = $request->get("openid");
     $staffinfo = new Staff($da, $da_im, $openid, $this->get("logger"), $this->container);
     $staffdata = $staffinfo->getInfo();
     if (empty($staffdata)) {
         $result = Utils::WrapResultError("无效操作帐号");
         return $this->responseJson($request, $result);
     }
     $limit = $request->get("limit");
     $pageIndex = $request->get("page_index");
     /*$sql = 'select a.*,b.nick_name,b.photo_path_big photo_path,1 online ,c.dept_name,b.login_account ,m.address ,m.ctime'
     			.' from t_module_location_monitor a ,we_staff b ,we_department c ,'
     			.' (select l.*from t_module_location l,(select max(t.ctime) ctime,t.staff from t_module_location t group by staff) as temp where l.staff = temp.staff and l.ctime = temp.ctime) m '
     			.' where a.staff=b.fafa_jid and b.dept_id=c.dept_id and a.eno=? and m.staff=b.login_account order by a.jiondate limit '.($pageIndex-1)*$limit.','.$limit;
     		*/
     $sql = " select m.login_account,m.state,1 online,l.address,l.ctime" . " from t_module_location_monitor m left join " . " (select l.*from t_module_location l,(select max(t.ctime) ctime,t.staff" . " from t_module_location t group by staff) as temp where l.staff = temp.staff and l.ctime = temp.ctime) l" . " on m.login_account=l.staff" . " where m.eno=?" . " order by m.jiondate limit " . ($pageIndex - 1) * $limit . ',' . $limit;
     $ds = $da->GetData('t', $sql, array((string) $staffdata["eno"]));
     foreach ($ds['t']['rows'] as $key => $value) {
         $staff = $staffinfo->getStaffInfo($ds['t']['rows'][$key]['login_account']);
         $ds['t']['rows'][$key]['dept_name'] = $staff['dept_name'];
         $ds['t']['rows'][$key]['nick_name'] = $staff['nick_name'];
         $ds['t']['rows'][$key]['photo_path'] = $staff['photo_path'];
     }
     $result = Utils::WrapResultOK($ds['t']['rows']);
     return $this->responseJson($request, $result);
 }
Esempio n. 17
0
 public function search($parameter)
 {
     $userinfo = $parameter["user"];
     $appname = isset($parameter["appname"]) ? $parameter["appname"] : "";
     if (!empty($appid)) {
         return $this->getappinfo(array("appid" => $appid));
     }
     $url = $this->containerObj->getParameter('FILE_WEBSERVER_URL');
     $pageno = isset($parameter["pageno"]) ? $parameter["pageno"] : 0;
     //获取列表的起始位置
     $pagesize = isset($parameter["pagesize"]) ? $parameter["pagesize"] : 50;
     $ordertype = isset($parameter["ordertype"]) ? $parameter["ordertype"] : "";
     //排序类型。默认按发布日期
     $sql = "select a.appid,a.appkey,a.appname,a.appdeveloper,a.version,a.show_type,a.apptype,concat('{$url}',a.logo) logo,case a.show_type when '01' then '企业应用' else '个人应用' end show_type_name " . " from we_appcenter_apps a where 1=1 ";
     $para = array();
     if (!empty($appname)) {
         $sql .= " and a.appname like concat('%',?,'%')";
         $para[] = (string) $appname;
     }
     $sql .= " order by a.sortid ";
     $startno = $pageno * $pagesize;
     $sql .= " limit {$startno},{$pagesize} ";
     $ds = $this->conn->GetData("table", $sql, $para);
     return Utils::WrapResultOK($ds["table"]["rows"]);
 }
Esempio n. 18
0
 public function receipt($parameters)
 {
     $currUser = $parameters["user"];
     if (empty($currUser)) {
         return Utils::WrapResultError("请登录后重试", ReturnCode::$NOTLOGIN);
     }
     $this->conn->ExecSQL("update we_app_bus_receipt set receiptdate=now() where appid=? and bus_id=? and staffid=?", array((string) $parameters["appid"], (string) $parameters["id"], (string) $currUser->getUserName()));
     return Utils::WrapResultOK("");
 }