private function getTokens() { if ($this->tokens != "") { return $this->tokens; } $tokens = TD::get_cache("WEIXINQY_TOKENS"); if ($tokens === FALSE) { $request_str = http_build_query(array("corpid" => $this->corpid, "corpsecret" => $this->corpsecret)); if ($request_str != "") { $request_url = $this->base_url . $this->weixinqy_token_url . "?" . $request_str; } $result = file_get_contents($request_url); if ($result === FALSE) { echo _("ERR: 无法连接到微信企业微信官方平台获取Tokens"); exit; } $data = json_decode($result, TRUE); $this->tokens = $data['access_token']; TD::set_cache("WEIXINQY_TOKENS", $this->tokens, $data['expires_in']); } else { $this->tokens = $tokens; } }
function mobile_push_notification($uid_sent, $content, $module, $options = NULL) { $org_content = $content; $PARA_ARRAY = get_sys_para("MOBILE_PUSH_OPTION,PCONLINE_MOBILE_PUSH", FALSE); while (list($PARA_NAME, $PARA_VALUE) = each(&$PARA_ARRAY)) { ${$PARA_NAME} = $PARA_VALUE; } if ($MOBILE_PUSH_OPTION == "1") { if ($uid_sent == "") { return; } if (substr($uid_sent, -1) != ",") { $uid_sent .= ","; } $module = strtolower($module); $mp_to_uids = td_trim($uid_sent); $a_uid_sent = $a_unpush_uid = array(); $a_uid_sent = explode(",", $mp_to_uids); if ($PCONLINE_MOBILE_PUSH == "0") { $query = "select DISTINCT(UID) from user_online where UID in(" . $mp_to_uids . ") and CLIENT!=5 and CLIENT!=6"; $cursor = exequery(TD::conn(), $query); while ($ROW = mysql_fetch_array($cursor)) { $a_unpush_uid[] = $ROW['UID']; } foreach ($a_uid_sent as $k => $v) { if (!($PCONLINE_MOBILE_PUSH == "0") && !is_array($a_unpush_uid) && !in_array($v, $a_unpush_uid)) { unset($a_uid_sent[$k]); } } $a_uid_sent = array_filter($a_uid_sent); $uid_sent = implode(",", $a_uid_sent); $uid_sent .= ","; } if ($module == "message") { include_once "task/message_push/funcs.php"; $C_MOBILE_DEVICES = TD::get_cache("C_MOBILE_DEVICES"); if ($C_MOBILE_DEVICES === FALSE) { rebuildmobilecache(); $C_MOBILE_DEVICES = TD::get_cache("C_MOBILE_DEVICES"); } if ($C_MOBILE_DEVICES && 0 < count($C_MOBILE_DEVICES)) { $M_STA = $M_ENT = array(); foreach ($a_uid_sent as $k => $v) { if ($C_MOBILE_DEVICES[$v]) { if ($C_MOBILE_DEVICES[$v]['client_ver'] == 1) { $M_STA[$v][] = array("content" => $content, "module" => "message"); } else { if ($C_MOBILE_DEVICES[$v]['client_ver'] == 2) { $M_ENT[$v][] = array("content" => $content, "module" => "message"); } } } } } tdmobilepush(array("sta" => $M_STA, "ent" => $M_ENT)); } $content = $org_content = strip_tags($content); if (strtolower(MYOA_CHARSET) != "utf-8") { $content = td_iconv($content, MYOA_CHARSET, "UTF-8"); } imtask("C^m^n^" . $uid_sent . "^" . $module . "^" . $content); if (!$MYOA_WEIXINQY_PUSH_ACTIVE) { $useble_module = array("email", "news", "notify"); if (!in_array($module, $useble_module)) { $uid_sents = td_trim($uid_sent); $query = "SELECT USER_ID FROM USER WHERE UID IN (" . $uid_sents . ")"; $cursor = exequery(TD::conn(), $query); while ($ROW = mysql_fetch_array($cursor)) { $user_id_arr[] = $ROW['USER_ID']; } wxqy_sms(array("user" => $user_id_arr, "module" => $module, "content" => $org_content)); } } } }
exit; } echo "failed"; exit; } if ($_SERVER['REQUEST_METHOD'] == "POST") { if ($_POST['WEIXINQY_OAURL'] != "") { $WEIXINQY_OAURL = htmlspecialchars($_POST['WEIXINQY_OAURL']); set_sys_para(array("WEIXINQY_OAURL" => "{$WEIXINQY_OAURL}")); } if ($_POST['WEIXINQY_SECRET'] != "" && $_POST['WEIXINQY_CORPID'] != "") { $WEIXINQY_CORPID = htmlspecialchars($_POST['WEIXINQY_CORPID']); $WEIXINQY_SECRET = htmlspecialchars($_POST['WEIXINQY_SECRET']); set_sys_para(array("WEIXINQY_SECRET" => "{$WEIXINQY_SECRET}", "WEIXINQY_CORPID" => "{$WEIXINQY_CORPID}")); include_once "inc/utility_cache.php"; $WEIXINQY_TOKENS = TD::get_cache("WEIXINQY_TOKENS"); if ($WEIXINQY_TOKENS !== FALSE) { TD::set_cache("WEIXINQY_TOKENS", NULL); } } } include_once "inc/conn.php"; include_once "inc/utility_update.php"; if (!field_exists("DEPARTMENT", "WEIXIN_DEPT_ID")) { $query = "ALTER TABLE `department` ADD COLUMN `WEIXIN_DEPT_ID` int(11) NOT NULL DEFAULT 0 AFTER `DEPT_EMAIL_AUDITS_IDS`"; exequery(TD::conn(), $query, TRUE); add_sys_para(array("WEIXINQY_SECRET" => "", "WEIXINQY_CORPID" => "", "WEIXINQY_OAURL" => "", "WEIXINQY_APP_SMS" => "")); cache_sys_para(); } $PARA_ARRAY = get_sys_para("WEIXINQY_CORPID,WEIXINQY_SECRET,WEIXINQY_OAURL"); $WEIXINQY_CORPID = $PARA_ARRAY['WEIXINQY_CORPID'];
<?php include "../header_wx.php"; include "inc/utility_file.php"; $NOTIFY_ID = intval($_GET['NOTIFY_ID']); $query = "SELECT * from NOTIFY where NOTIFY_ID='" . $NOTIFY_ID . "' and PUBLISH='1'"; $cursor = exequery(TD::conn(), $query); if ($ROW = mysql_fetch_array($cursor)) { $FROM_DEPT = $ROW['FROM_DEPT']; $DEPARTMENT_ARRAY = TD::get_cache("SYS_DEPARTMENT"); $FROM_DEPT_NAME = $DEPARTMENT_ARRAY[$FROM_DEPT]['DEPT_NAME']; $FROM_ID = $ROW['FROM_ID']; $SUBJECT_COLOR = $ROW['SUBJECT_COLOR']; $SUBJECT = $ROW['SUBJECT']; $ORG_SUBJECT = $SUBJECT; $FORMAT = $ROW['FORMAT']; $COMPRESS_CONTENT = @gzuncompress($ROW['COMPRESS_CONTENT']); if ($COMPRESS_CONTENT != "" && $FORMAT != "2") { $CONTENT = $COMPRESS_CONTENT; } else { $CONTENT = $ROW['CONTENT']; } $ATTACHMENT_ID = $ROW['ATTACHMENT_ID']; $ATTACHMENT_NAME = $ROW['ATTACHMENT_NAME']; $FORMAT = $ROW['FORMAT']; $READERS = $ROW['READERS']; $SUBJECT = htmlspecialchars($SUBJECT); $TYPE_ID = $ROW['TYPE_ID']; $TYPE_NAME = get_code_name($TYPE_ID, "NOTIFY"); $DOWNLOAD = $ROW['DOWNLOAD']; $SUBJECT = "<font color='" . $SUBJECT_COLOR . "'>" . $SUBJECT . "</font>";