示例#1
0
 public function GetByIM($grouid, $refreshCache = false)
 {
     try {
         $data = Cache_Enterprise::get("group_", $grouid, $this->container);
     } catch (\Exception $e) {
         $this->logger->err($e);
         $data = null;
     }
     if (empty($data) || $refreshCache === true) {
         $url = $this->container->getParameter('FILE_WEBSERVER_URL');
         $sql = "select a.*, b.employeename create_staff_name from im_group a left join im_employee b on b.loginname=a.creator where a.groupid=?";
         $params = array();
         $params[] = (string) $grouid;
         $ds = $this->conn_im->GetData("we_groups", $sql, $params);
         if (count($ds["we_groups"]["rows"]) > 0) {
             if (!empty($ds["we_groups"]["rows"][0]['logo'])) {
                 $ds["we_groups"]["rows"][0]['logo'] = $url . $ds["we_groups"]["rows"][0]['logo'];
             }
             Cache_Enterprise::set("group_", $grouid, json_encode($ds["we_groups"]["rows"][0]), 0, $this->container);
             return $ds["we_groups"]["rows"][0];
         } else {
             Cache_Enterprise::delete("group_", $grouid, $this->container);
             return null;
         }
     }
     $returnObj = json_decode($data, true);
     return $returnObj;
 }
示例#2
0
 private function getFunctionCode($roleid)
 {
     $data = Cache_Enterprise::get(Cache_Enterprise::$EN_FUNCTION, $roleid);
     if (empty($data)) {
         $sql = "select DISTINCT b.code from we_role_function a,we_function b where a.functionid=b.id and a.roleid=? and b.code is not null";
         $para = array((string) $roleid);
         $data = $this->conn->GetData("dt", $sql, $para);
         Cache_Enterprise::set(Cache_Enterprise::$EN_FUNCTION, $roleid, json_encode($data["dt"]["rows"]));
         return $data["dt"]["rows"];
     } else {
         return json_decode($data, true);
     }
 }
示例#3
0
 public static function ssoAction($controller, $conn, $appid, $openid, $token, $encrypt)
 {
     //重新授权
     $app = new \Justsy\BaseBundle\Management\App($controller->container);
     $appdata = $app->getappinfo(array("appid" => $appid));
     if (empty($appdata)) {
         $resp = new Response("无效的APPID");
         $resp->headers->set('Content-Type', 'text/html');
         return $resp;
     }
     $agent = $appdata["clientid"];
     if (empty($agent)) {
         $resp = new Response("未正确配置认证信息的appkey项");
         $resp->headers->set('Content-Type', 'text/html');
         return $resp;
     }
     //判断是否绑定
     $bindinfo = $app->getappbind(array("appid" => $appid, "openid" => $openid));
     if (empty($bindinfo)) {
         //$controller->get("logger")->err("================not bind");
         //重定向到绑定页面
         return $controller->render("JustsyBaseBundle:AppCenter:h5bundle.html.twig", array('appid' => $appid, 'openid' => $openid, 'ssomodule' => self::$bind_type . "Controller"));
     }
     $ldap_uid = $bindinfo["bind_uid"];
     $cacheKey = md5($appid . $openid);
     $data = Cache_Enterprise::get(Cache_Enterprise::$EN_OAUTH2, $cacheKey, $this->containerObj);
     $acctoken = $data["access_token"];
     //获取authkey
     $url = "http://openapi.exmail.qq.com:12211/openapi/mail/authkey";
     $authkey = Utils::do_post_request($url, "alias=" . $ldap_uid . "&access_token=" . $acctoken);
     if (empty($authkey)) {
         $resp = new Response("腾讯企业邮箱登录失败");
         $resp->headers->set('Content-Type', 'text/html');
         return $resp;
     }
     $authkey = json_decode($authkey, true);
     if (!isset($authkey)) {
         $resp = new Response("腾讯企业邮箱登录失败:<br>" . json_encode($authkey));
         $resp->headers->set('Content-Type', 'text/html');
         return $resp;
     }
     $authkey = $authkey["auth_key"];
     $login_url = "https://exmail.qq.com/cgi-bin/login?fun=bizopenssologin&method=bizauth&agent=" . $agent . "&user="******"&ticket=" . $authkey;
     return Utils::http_redirect($login_url);
 }
示例#4
0
 public function GetSysParam($ParamName, $defaultvalue = '', $isfresh = false)
 {
     $data = "";
     try {
         $data = Cache_Enterprise::get(Cache_Enterprise::$SYS, $ParamName, $this->container);
     } catch (\Exception $e) {
         $this->logger->err($e);
         $data = null;
     }
     if (empty($data) || $isfresh) {
         $dataaccess = $this->container->get('we_data_access');
         $dataset = $dataaccess->GetData("we_sys_param", "select param_name, param_value from we_sys_param where param_name = ? ", array((string) $ParamName));
         if ($dataset && count($dataset["we_sys_param"]["rows"]) > 0) {
             $data = $dataset["we_sys_param"]["rows"][0]["param_value"];
             Cache_Enterprise::set(Cache_Enterprise::$SYS, $ParamName, $data, 0, $this->container);
         } else {
             $dataaccess->ExecSQL('insert into we_sys_param(param_name, param_value)values(?,?)', array((string) $ParamName, (string) $defaultvalue));
             $data = $defaultvalue;
         }
     }
     return $data;
 }
示例#5
0
文件: App.php 项目: 3116246/haolinju
 public function getappsession($parameter)
 {
     $appid = $parameter["appid"];
     $openid = $parameter["openid"];
     $key = md5($appid . $openid);
     $appdata = Cache_Enterprise::get(Cache_Enterprise::$EN_OAUTH2, $key, $this->containerObj);
     if (!empty($appdata)) {
         return json_decode($appdata, true);
     }
     $sql = "select access_token,refresh_token,access_token_expires expires_in from we_app_oauth_sessions where appid=? and userid=?";
     $dsset = $this->conn->getdata("t", $sql, array((string) $appid, (string) $openid));
     if (count($dsset["t"]["rows"]) > 0) {
         Cache_Enterprise::set(Cache_Enterprise::$EN_APP_BIND, $key, json_encode($dsset["t"]["rows"][0]), 0, $this->containerObj);
         return $dsset["t"]["rows"][0];
     }
     return null;
 }
示例#6
0
 private function getSecurityDomains()
 {
     $securityDomains = \Justsy\BaseBundle\Common\Cache_Enterprise::get("securityDomains", "", $this->container);
     if (!empty($securityDomains)) {
         return json_decode($securityDomains, true);
     }
     $mayDomain = array("localhost", "127.0.0.1");
     $configWeFaFa = $this->container->getParameter('open_api_url');
     //获取配置的wefafa地址
     $tmp = parse_url($configWeFaFa);
     $host = $tmp["host"];
     //$this->get("logger")->err(">>>>>>>>>>>>>>>>>>>open_api_url>host:".$host);
     if (Utils::is_ip($host)) {
         $mayDomain[] = $host;
     } else {
         $host = substr($host, strpos($host, ".") + 1);
         $mayDomain[] = $host;
     }
     $configWeFaFa = $this->container->getParameter('fafa_appcenter_url');
     //获取配置的应用中心地址
     $tmp = parse_url($configWeFaFa);
     $host = $tmp["host"];
     //$this->get("logger")->err(">>>>>>>>>>>>>>>>>>>fafa_appcenter_url>host:".$host);
     if (Utils::is_ip($host)) {
         $mayDomain[] = $host;
     } else {
         $host = substr($host, strpos($host, ".") + 1);
         $mayDomain[] = $host;
     }
     //ApiController::$securityDomains = $mayDomain;
     \Justsy\BaseBundle\Common\Cache_Enterprise::set("securityDomains", "", json_encode($mayDomain), 0, $this->container);
     return $mayDomain;
 }
示例#7
0
 public function executeBydsid($user, $dsid, $inf_parameters, &$err)
 {
     $logger = $this->container->get("logger");
     //判断是否有缓存数据
     $cache_key = md5($dsid . $inf_parameters);
     try {
         $data = Cache_Enterprise::get(Cache_Enterprise::$EN_DATAINF, $cache_key, $this->container);
     } catch (\Exception $e) {
         $logger->err($e);
         $data = null;
     }
     if (!empty($data)) {
         $logger->err(Cache_Enterprise::$EN_DATAINF . $cache_key . "-------------get cache data------------");
         $result = json_decode($data, true);
         return $result;
     }
     try {
         $re = "";
         $dataaccess = $this->container->get('we_data_access');
         $dataset = $dataaccess->GetData("ds", "select * from mapp_datasource where id=? ", array((string) $dsid));
         if ($dataset && count($dataset["ds"]["rows"]) > 0) {
             $re = $dataset["ds"]["rows"][0];
             $inf_type = $re["inf_type"];
             //静态数据直接返回
             if ($re["inf_type"] == "Static") {
                 $result = json_decode($re["inf_url"], true);
                 $ztree = new ZtreeTransfer($this->container);
                 $returndata = $ztree->dataToTree($result);
                 return array("returncode" => "0000", "list" => $returndata);
             }
             $classname = "\\Justsy\\BaseBundle\\DataAccess\\DataExtract";
             $classname = $classname . "\\" . ucfirst($inf_type);
             try {
                 $returndata = null;
                 $http_data = call_user_func(array($classname, 'getByDsid'), $user, $re, $inf_parameters, $this->container);
                 if (is_string($http_data)) {
                     $returndata = json_decode($http_data, true);
                 } else {
                     $returndata = $http_data;
                 }
                 //转换数据
                 $ztree = new ZtreeTransfer($this->container);
                 $returndata = $ztree->dataToTree($returndata);
                 $result = array("returncode" => "0000", "list" => $returndata);
                 Cache_Enterprise::set(Cache_Enterprise::$EN_DATAINF, $cache_key, json_encode($result), 30, $this->container);
                 return $result;
             } catch (\Exception $e) {
                 $re = array("returncode" => "9999", "msg" => $e->getMessage());
             }
         } else {
             $re = array("returncode" => "9999", "msg" => "数据源id不存在");
         }
         return $re;
     } catch (\Exception $e) {
         return array("returncode" => "9999", "msg" => $e->getMessage());
     }
 }
示例#8
0
文件: Role.php 项目: 3116246/haolinju
 public function GetRoleDataByCode($code)
 {
     $data = Cache_Enterprise::get(Cache_Enterprise::$EN_ROLE, $code);
     if (empty($data)) {
         $sql = "select id,name,code from we_role where code=?";
         $para = array((string) $code);
         $data = $this->conn->GetData("dt", $sql, $para);
         $datarow = $data["dt"]["rows"];
         Cache_Enterprise::set(Cache_Enterprise::$EN_ROLE, $code, json_encode($datarow));
         return $data["dt"]["rows"];
     } else {
         return json_decode($data, true);
     }
 }
示例#9
0
 public function getInfoByName($name)
 {
     try {
         $data = Cache_Enterprise::get(Cache_Enterprise::$EN_INFO, md5($name), $this->container);
     } catch (\Exception $e) {
         $this->logger->err($e);
         $data = null;
     }
     if (empty($data) || $data == "null") {
         $photo_url = $this->container->getParameter('FILE_WEBSERVER_URL');
         $sql = " select a.*,concat('{$photo_url}',ifnull(a.logo_path,'')) logo_path,wc.circle_id,wc.circle_name from we_enterprise a " . " left join we_circle wc on a.eno=wc.enterprise_no and a.edomain=wc.network_domain where a.enoname=?";
         $params = array((string) $name);
         $ds = $this->da->Getdata('main', $sql, $params);
         $data = empty($ds) || count($ds["main"]["rows"]) == 0 ? null : $ds["main"]["rows"][0];
         Cache_Enterprise::set(Cache_Enterprise::$EN_INFO, md5($name), json_encode($data), 0, $this->container);
     } else {
         return json_decode($data, true);
     }
     return $data;
 }
示例#10
0
 private function updatedeptversion($im_deptid)
 {
     $conn_im = $this->containter->get("we_data_access_im");
     $cache = Cache_Enterprise::get("d_ver_", $im_deptid, $this->containter);
     if (!empty($cache)) {
         $cache = (int) $cache + 1;
         $conn_im->ExecSQL("update im_dept_version set version=? where us=?", array((string) $cache, (string) $im_deptid));
     } else {
         $conn_im = $this->containter->get("we_data_access_im");
         $sql = "select * from im_dept_version where us=?";
         $v_ds = $conn_im->GetData("t", $sql, array((string) $im_deptid));
         if (count($v_ds["t"]["rows"]) == 0) {
             $cache = 1;
             $conn_im->ExecSQL("insert into im_dept_version(us,version)values(?,?)", array((string) $im_deptid, (string) $cache));
         } else {
             $cache = (int) $v_ds["t"]["rows"][0]["version"] + 1;
             $conn_im->ExecSQL("update im_dept_version set version=? where us=?", array((string) $cache, (string) $im_deptid));
         }
         Cache_Enterprise::set("d_ver_", $im_deptid, (string) $cache, 0, $this->containter);
     }
 }
示例#11
0
 public static function rest($controller, $user, $re, $parameters, $need_params)
 {
     $api_parameter = "";
     $appid = $parameters["appid"];
     $openid = $user->openid;
     $cacheKey = md5($appid . $openid);
     $data = Cache_Enterprise::get(Cache_Enterprise::$EN_OAUTH2, $cacheKey, $controller);
     if ($data == null) {
         throw new \Exception("token 已过期,请重新获取");
     }
     if (isset($data["expires_in"]) && (int) $data["expires_in"] < time()) {
         throw new \Exception("token 已过期,请重新获取");
     }
     $access_token = json_decode($data, true);
     $str_para = array();
     if (!empty($parameters)) {
         //将参数数组转化为字符串
         if (is_array($parameters) && !empty($need_params)) {
             for ($i = 0; $i < count($need_params); $i++) {
                 $pname = $need_params[$i]["paramname"];
                 if (!empty($access_token) && isset($access_token[$pname])) {
                     //先从授权结果中匹配
                     $val = $access_token[$key];
                 } else {
                     $val = isset($parameters[$pname]) ? $parameters[$pname] : $need_params[$i]["paramvalue"];
                 }
                 $str_para[$pname] = $val;
             }
         }
     }
     $restUrl = $re["inf_url"];
     if (strpos($restUrl, "?") === false) {
         $restUrl = $restUrl . "?" . http_build_query($str_para);
     } else {
         $restUrl = $restUrl . "&" . http_build_query($str_para);
     }
     $controller->get("logger")->err("===============restUrl:" . $restUrl);
     $re = Utils::do_post_request($restUrl, null, null);
     return $re;
 }
示例#12
0
文件: Dept.php 项目: 3116246/haolinju
 public function getDefaultDept($eno)
 {
     try {
         $result = Cache_Enterprise::get(Cache_Enterprise::$EN_DEPT . "_defaultdept", $eno, $this->container);
     } catch (\Exception $e) {
         $this->logger->err($e);
         $result = null;
     }
     if (!empty($result)) {
         return json_decode($result, true);
     }
     $result = $this->getIdByName($eno, "体验部门");
     if (!empty($result)) {
         $result["dept_id"] = $result["deptid"];
     } else {
         //没有体验部门时获取根部门
         $rootdeptid = 'v' . $eno;
         $result = $this->getinfo($rootdeptid);
         $result["fafa_deptid"] = $rootdeptid;
     }
     Cache_Enterprise::set(Cache_Enterprise::$EN_DEPT . "_defaultdept", $eno, json_encode($result), 0, $this->container);
     return $result;
 }
示例#13
0
 public function getStaffInfo($staff, $refreshCache = false)
 {
     if (empty($staff)) {
         return null;
     }
     try {
         $data = null;
         if (!$refreshCache) {
             $data = Cache_Enterprise::get(Cache_Enterprise::$EN_STAFF, $staff, $this->container);
             if (empty($data)) {
                 //判断是否是影射到帐号上的其他属性
                 $mapp_login_account = Cache_Enterprise::get('staff_mapp_', $staff, $this->container);
                 if (!empty($mapp_login_account)) {
                     $data = Cache_Enterprise::get(Cache_Enterprise::$EN_STAFF, $mapp_login_account, $this->container);
                 }
             }
         }
     } catch (\Exception $e) {
         $this->logger->err($e);
         $data = null;
     }
     if (empty($data)) {
         if (Utils::validateMobile($staff)) {
             $sql = "select a.nick_name, a.login_account,a.self_desc,a.sex_id,a.mobile_bind,a.state_id,a.photo_path_big photo_path, a.dept_id, a.eno,a.fafa_jid,a.fafa_jid jid,a.duty,a.openid from we_staff a where a.mobile_bind=? ";
             $ds = $this->conn->getData("t", $sql, array((string) $staff));
         } else {
             if (strlen($staff) >= 30) {
                 $sql = "select a.nick_name, a.login_account,a.self_desc,a.sex_id,a.mobile_bind,a.state_id,a.photo_path_big photo_path, a.dept_id, a.eno,a.fafa_jid,a.fafa_jid jid,a.duty,a.openid from we_staff a  where a.openid=? ";
                 $ds = $this->conn->getData("t", $sql, array((string) $staff));
             } else {
                 $sql = "select a.nick_name, a.login_account,a.self_desc,a.sex_id,a.mobile_bind,a.state_id,a.photo_path_big photo_path, a.dept_id, a.eno,a.fafa_jid,a.fafa_jid jid,a.duty,a.openid from we_staff a where a.login_account=? or a.fafa_jid=? or a.ldap_uid=?";
                 $ds = $this->conn->getData("t", $sql, array((string) $staff, (string) $staff, (string) $staff));
             }
         }
         if ($ds && count($ds["t"]["rows"]) > 0) {
             $fileurl = $this->container->getParameter("FILE_WEBSERVER_URL");
             $returnObj = $ds["t"]["rows"][0];
             if (!empty($returnObj["photo_path"])) {
                 $returnObj["photo_path"] = $fileurl . $returnObj["photo_path"];
             }
             $dept = new Dept($this->conn, $this->conn_im, $this->container);
             $d_info = $dept->getinfo($returnObj['dept_id']);
             $returnObj['dept_name'] = empty($d_info) ? '' : $d_info['deptname'];
             $en = new Enterprise($this->conn, $this->logger, $this->container);
             $e_info = $en->getinfo($returnObj['eno']);
             $returnObj['ename'] = empty($e_info) ? '' : $e_info['ename'];
             if ($staff != $returnObj["login_account"]) {
                 //非帐号时,做缓存影射
                 Cache_Enterprise::set('staff_mapp_', $staff, $returnObj["login_account"], 0, $this->container);
             }
             $staff = $returnObj["login_account"];
             Cache_Enterprise::delete(Cache_Enterprise::$EN_STAFF, $staff, $this->container);
             //判断人员状态。如果不正常朋需要刷新缓存时,从缓存中删除
             if ($returnObj["state_id"] == "1") {
                 Cache_Enterprise::set(Cache_Enterprise::$EN_STAFF, $staff, json_encode($returnObj), 0, $this->container);
             }
             return $returnObj;
         } else {
             //没有获取到人员时,从缓存中删除
             Cache_Enterprise::delete(Cache_Enterprise::$EN_STAFF, $staff, $this->container);
             return null;
         }
     }
     $returnObj = json_decode($data, true);
     return $returnObj;
 }
 public function tencentexmailloginAction()
 {
     $request = $this->getRequest();
     $param = $request->get("params");
     if (empty($param)) {
         $param = array();
     } else {
         if (is_string($param)) {
             $param = json_decode($param, true);
         }
     }
     if (!isset($param["appid"])) {
         $param["appid"] = $request->get("appid");
     }
     $openid = $request->get("openid");
     $staffObj = new \Justsy\BaseBundle\Management\Staff($this->get('we_data_access'), $this->get('we_data_access_im'), $openid, $this->get("logger"));
     $user = $staffObj->getSessionUser();
     $appid = $param["appid"];
     //$openid = $user->openid;
     //$ldap_uid = $user->ldap_uid;
     //判断是否绑定
     $app = new \Justsy\BaseBundle\Management\App($this->container);
     $appdata = $app->getappinfo(array("appid" => $appid));
     if (empty($appdata)) {
         $resp = new Response("无效的APPID");
         $resp->headers->set('Content-Type', 'text/html');
         return $resp;
     }
     $agent = $appdata["clientid"];
     //判断是否绑定
     $bindinfo = $app->getappbind(array("appid" => $appid, "openid" => $openid));
     if (empty($bindinfo)) {
         //$controller->get("logger")->err("================not bind");
         //重定向到绑定页面
         return $this->render("JustsyBaseBundle:AppCenter:h5bundle.html.twig", array('appid' => $appid, 'openid' => $openid, 'ssomodule' => "OAuth2"));
     }
     $ldap_uid = $bindinfo["bind_uid"];
     $cacheKey = md5($appid . $openid);
     $data = Cache_Enterprise::get(Cache_Enterprise::$EN_OAUTH2, $cacheKey, $this->container);
     if (empty($data)) {
         $this->get("logger")->err("{$appid}.{$openid}");
         $resp = new Response("太长时间未操作,请重新进入应用");
         $resp->headers->set('Content-Type', 'text/html');
         return $resp;
     }
     $data = json_decode($data, true);
     $acctoken = $data["access_token"];
     //$this->get("logger")->err($acctoken);
     //获取authkey
     $url = "http://openapi.exmail.qq.com:12211/openapi/mail/authkey";
     $authkey = Utils::do_post_request($url, "alias=" . $ldap_uid . "&access_token=" . $acctoken);
     //$this->get("logger")->err($url."?"."alias=".$ldap_uid."&access_token=".$acctoken);
     //$this->get("logger")->err($authkey);
     if (empty($authkey)) {
         $resp = new Response("腾讯企业邮箱登录失败");
         $resp->headers->set('Content-Type', 'text/html');
         return $resp;
     }
     $authkey = json_decode($authkey, true);
     if (!isset($authkey["auth_key"])) {
         if ($authkey["error"] == "invalid_token") {
             Cache_Enterprise::delete(Cache_Enterprise::$EN_OAUTH2, $cacheKey, $this->container);
             $resp = new Response("腾讯企业邮箱登录失败:<br>token无效或已经过期,请稍后重试!");
         } else {
             $resp = new Response("腾讯企业邮箱登录失败:<br>" . json_encode($authkey));
         }
         $resp->headers->set('Content-Type', 'text/html');
         return $resp;
     }
     $authkey = $authkey["auth_key"];
     $login_url = "https://exmail.qq.com/cgi-bin/login?fun=bizopenssologin&method=bizauth&agent=" . $agent . "&user="******"&ticket=" . $authkey;
     //$this->get("logger")->err($login_url);
     return Utils::http_redirect($login_url);
 }