function email_fw_webmail_box($USER_ID) { $EMAIL_FW_WEBMAIL_BOX = ""; $FROM_MAIL_ID = ""; $FROM_WEBMAIL_BOX_DEFAULT = ""; $EMAIL_FW_WEBMAIL_BOX_ARRAY = array(); $query = "select * from webmail where USER_ID='" . $USER_ID . "' and EMAIL_PASS!='' order by IS_DEFAULT desc"; $cursor = exequery(TD::conn(), $query); while ($ROW = mysql_fetch_array($cursor)) { $MAIL_ID = $ROW['MAIL_ID']; $EMAIL = $ROW['EMAIL']; $IS_DEFAULT = $ROW['IS_DEFAULT']; $RECV_FW = $ROW['RECV_FW']; if ($FROM_WEBMAIL_BOX_DEFAULT == "") { $FROM_WEBMAIL_BOX_DEFAULT = $EMAIL; $FROM_MAIL_ID = $MAIL_ID; } if ($RECV_FW == 1) { $EMAIL_FW_WEBMAIL_BOX .= $EMAIL . ","; } } $EMAIL_FW_WEBMAIL_BOX_ARRAY[] = $FROM_WEBMAIL_BOX_DEFAULT; $EMAIL_FW_WEBMAIL_BOX_ARRAY[] = $EMAIL_FW_WEBMAIL_BOX; $EMAIL_FW_WEBMAIL_BOX_ARRAY[] = $FROM_MAIL_ID; return $EMAIL_FW_WEBMAIL_BOX_ARRAY; }
function add_task($file, $code) { $qry = "SELECT * FROM office_task WHERE TASK_CODE='{$code}'"; $csr = exequery(TD::conn(), $qry); if ($row = mysql_fetch_array($csr)) { } else { $qry = "INSERT INTO `office_task` (`TASK_TYPE`, `INTERVAL`, `EXEC_TIME`, `LAST_EXEC`,\n\t\t\t\t`EXEC_FLAG`, `EXEC_MSG`, `TASK_URL`, `TASK_NAME`, `TASK_DESC`, `TASK_CODE`, `USE_FLAG`,\n\t\t\t\t`SYS_TASK`, `EXT_DATA`) VALUES(\n\t\t\t\t'0',\n\t\t\t\t1,\n\t\t\t\t'00:00:00',\n\t\t\t\t'0000-00-00 00:00:00',\n\t\t\t\t1,\n\t\t\t\t'0000-00-00 00:00:00',\n\t\t\t\t'{$file}',\n\t\t\t\t'即时通讯离线消息推送',\n\t\t\t\t'定时将OA精灵离线消息推送到微信企业号',\n\t\t\t\t'{$code}',\n\t\t\t\t'1',\n\t\t\t\t'0',\n\t\t\t\t'')"; exequery(TD::conn(), $qry); //Add system parameter include_once "inc/utility_all.php"; add_sys_para(array("WEIXINQY_MSGCHECK_TIME" => "")); } }
public function createUser($user_id) { $user_ids = ""; $user_arr = explode(",", $user_id); foreach ($user_arr as $key => $value) { $user_ids .= "'" . $value . "',"; } $user_ids = rtrim($user_ids, ","); $sync = array(); $query = "SELECT USER_ID,USER_NAME,DEPT_ID,DEPT_ID_OTHER,USER_PRIV_NAME,USER_PRIV,MOBIL_NO,SEX,TEL_NO_DEPT,EMAIL FROM USER where USER_ID IN (" . $user_ids . ")"; $cursor = exequery(TD::conn(), $query); while ($ROW = mysql_fetch_array($cursor)) { $USER_ID = $ROW['USER_ID']; $USER_NAME = $ROW['USER_NAME']; $DEPT_ID = $ROW['DEPT_ID']; $DEPT_ID_OTHER = $ROW['DEPT_ID_OTHER']; $USER_PRIV_NAME = $ROW['USER_PRIV_NAME']; $USER_PRIV = $ROW['USER_PRIV']; $MOBIL_NO = $ROW['MOBIL_NO']; $SEX = $ROW['SEX']; $TEL_NO_DEPT = $ROW['TEL_NO_DEPT']; $EMAIL = $ROW['EMAIL']; if ($EMAIL == "" && !preg_match("/^([+-]?)\\d*\\.?\\d+\$/", $MOBIL_NO)) { $sync['failed'][] = sprintf("%s(%s)", $USER_NAME, $this->deptinfo[$DEPT_ID]['dept_name']); } else { $_dept = array(); $_dept[] = $this->deptinfo[$DEPT_ID]['weixin_dept_id']; if ($DEPT_ID_OTHER != "") { $_dept_arr = array_filter(explode(",", $DEPT_ID_OTHER)); foreach ($_dept_arr as $key => $value) { $_dept[] = $this->deptinfo[$value]['weixin_dept_id']; } } $rs = $this->postData($this->url['create'], array("userid" => $USER_ID, "name" => $USER_NAME, "department" => $_dept, "position" => $USER_PRIV_NAME, "mobile" => preg_match("/^([+-]?)\\d*\\.?\\d+\$/", $MOBIL_NO) ? $MOBIL_NO : "", "gender" => $SEX, "tel" => $TEL_NO_DEPT, "email" => $EMAIL)); if ($rs['errcode'] == 0) { $sync['success'][] = sprintf("%s(%s)", $USER_NAME, $this->deptinfo[$DEPT_ID]['dept_name']); } else { if ($rs['errcode'] == 60102) { $sync['exists'][] = sprintf("%s(%s)", $USER_NAME, $this->deptinfo[$DEPT_ID]['dept_name']); } } } } parent::logs("user_import", serialize($sync)); return array("success" => count($sync['success']), "failed" => count($sync['failed']), "exists" => count($sync['exists'])); }
$cursor = exequery(TD::conn(), $query); while ($ROW = mysql_fetch_array($cursor)) { if (!find_id($USER_ID_STR, $ROW['USER_ID'])) { $USER_ID_STR .= $ROW['USER_ID'] . ","; } } } $MY_ARRAY_DEPT = explode(",", $TO_ID); $ARRAY_COUNT_DEPT = sizeof($MY_ARRAY_DEPT); $I = 0; for (; $I < $ARRAY_COUNT_DEPT; ++$I) { if ($MY_ARRAY_DEPT[$I] == "") { continue; } $query_d = "select USER_ID from USER where (NOT_LOGIN = 0 or NOT_MOBILE_LOGIN = 0) and find_in_set('" . $MY_ARRAY_DEPT[$I] . "',DEPT_ID_OTHER)"; $cursor_d = exequery(TD::conn(), $query_d); while ($ROWD = mysql_fetch_array($cursor_d)) { if (!find_id($USER_ID_STR, $ROWD['USER_ID'])) { $USER_ID_STR .= $ROWD['USER_ID'] . ","; } } } $USER_ID_STR_ARRAY = explode(",", $USER_ID_STR); $USER_ID_STR_ARRAY_COUNT = sizeof($USER_ID_STR_ARRAY); $I = 0; for (; $I < $USER_ID_STR_ARRAY_COUNT; ++$I) { if (!($USER_ID_STR_ARRAY[$I] == "")) { $FUNC_ID_STR = getfunmenubyuserid($USER_ID_STR_ARRAY[$I]); if (!find_id($FUNC_ID_STR, 4)) { $USER_ID_STR = str_replace($USER_ID_STR_ARRAY[$I], "", $USER_ID_STR); }
<?php include_once "inc/conn.php"; include_once "inc/utility_all.php"; define("MSGCHECKTIME", "WEIXINQY_MSGCHECK_TIME"); $CUR_TIME = time(); $PARA_ARRAY = get_sys_para(MSGCHECKTIME, FALSE); $MSG_CHK_TIME = intval(trim($PARA_ARRAY[MSGCHECKTIME])); $BEGIN_TIME = $MSG_CHK_TIME <= 0 ? $CUR_TIME : $MSG_CHK_TIME; $query = "SELECT FROM_UID,TO_UID,CONTENT,SEND_TIME FROM MESSAGE where REMIND_FLAG='1' and MSG_TYPE='1' and\n\t\t\t FROM_UID!=0 and TO_UID!=0 and SEND_TIME>'{$BEGIN_TIME}' and SEND_TIME<='{$CUR_TIME}' order by TO_UID,FROM_UID,SEND_TIME asc"; $cursor = exequery(TD::conn(), $query); if (!$cursor) { echo "-ERR "; exit; } while ($ROW = mysql_fetch_array($cursor)) { $FROM_UID = $ROW['FROM_UID']; include_once "inc/utility_cache.php"; $FROM_USER_NAME = getuserinfobyuid($FROM_UID, "USER_NAME"); $TO_UID = $ROW['TO_UID']; $CONTENT = $ROW['CONTENT']; include_once "inc/itask/itask.php"; mobile_push_notification($TO_UID, $FROM_USER_NAME . _(":") . $CONTENT . _("【即时通讯离线消息】"), "msg"); } set_sys_para(array(MSGCHECKTIME => $CUR_TIME)); $CUR_TIME_FORMAT = date("Y-m-d H:i:s", $CUR_TIME); $qry = "UPDATE OFFICE_TASK SET LAST_EXEC='{$CUR_TIME_FORMAT}',EXEC_FLAG='1',EXEC_MSG='{$CUR_TIME_FORMAT}' WHERE TASK_CODE='inst_msg_offl_push'"; exequery(TD::conn(), $qry); echo "+OK";
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)); } } } }
$CONTENT = $COMPRESS_CONTENT; } else { $CONTENT = $ROW['CONTENT']; } $ATTACHMENT_ID = $ROW['ATTACHMENT_ID']; $ATTACHMENT_NAME = $ROW['ATTACHMENT_NAME']; $NEWS_TIME = substr($NEWS_TIME, 0, 10); if (!find_id($READERS, $_SESSION['LOGIN_USER_ID'])) { $READERS .= $_SESSION['LOGIN_USER_ID'] . ","; $query = "update news set READERS='" . $READERS . "',CLICK_COUNT='{$CLICK_COUNT}' where NEWS_ID='{$NEWS_ID}'"; } else { $query = "update NEWS set CLICK_COUNT='" . $CLICK_COUNT . "' where NEWS_ID='{$NEWS_ID}'"; } exequery(TD::conn(), $query); $query1 = "SELECT USER_NAME from USER where USER_ID='" . $PROVIDER . "'"; $cursor1 = exequery(TD::conn(), $query1); if ($ROW = mysql_fetch_array($cursor1)) { $FROM_NAME = $ROW['USER_NAME']; } else { $FROM_NAME = $FROM_ID; } if ($FORMAT == "2") { header("location: " . $CONTENT); } } else { exit; } echo "<body>\r\n<div class=\"container\">\r\n <h3 class=\"read_title fix_read_title\">"; echo $SUBJECT; echo "</h3>\r\n <div class=\"read_detail fix_read_detail read_meta\">\r\n "; if ($TYPE_NAME != "") {
exit; case "updateDept": //( ); $department = new WeiXinQYDepartment(); $rs = $department->updateDept(array("id" => intval($_POST['dept_id']), "name" => td_iconv(addslashes($_POST['dept_name']), "UTF-8", MYOA_CHARSET), "parentid" => intval($_POST['dept_parentid']))); echo json_encode($rs); exit; case "getDept": //( ); $department = new WeiXinQYDepartment(); $rs = $department->getDept(intval($_GET['dept_id'])); } exit; } $query = "SELECT COUNT(DEPT_ID) FROM DEPARTMENT WHERE WEIXIN_DEPT_ID > 0"; $cursor = exequery(TD::conn(), $query, TRUE); $row = mysql_fetch_row($cursor); $HTML_PAGE_TITLE = _("数据导入 - 组织架构初始化"); $HTML_PAGE_BASE_STYLE = FALSE; include_once "inc/header.inc.php"; echo "<body>\r\n<link rel=\"stylesheet\" type=\"text/css\" href=\""; echo MYOA_STATIC_SERVER; echo "/static/js/bootstrap/css/bootstrap.css\">\r\n<link rel=\"stylesheet\" type=\"text/css\" href=\""; echo MYOA_STATIC_SERVER; echo "/static/modules/weixinqy/style.css\">\r\n<script type=\"text/javascript\" src=\""; echo MYOA_JS_SERVER; echo "/static/js/jquery-1.10.2/jquery.min.js"; echo $GZIP_POSTFIX; echo "\"></script>\r\n<script type=\"text/javascript\">\r\n\$(function(){\r\n \$(\".func-item button\").on(\"click\", function(){\r\n \$(\".func-item button\").removeClass(\"btn-primary\");\r\n \$(\".func-item button i\").removeClass(\"icon-white\");\r\n \$(\".mod-func\").hide();\r\n var module = \$(this).attr(\"data-module\");\r\n \$(this).addClass(\"btn-primary\");\r\n \$(this).find(\"i\").addClass(\"icon-white\");\r\n \$(\"#mod-\" + module).show();\r\n });\r\n\r\n \$(\"#btn-init\").click(function(){\r\n \$(\"#dept-iframe\").contents().find(\"#btn-sync-dept\").click();\r\n \$(this).off().html('<i class=\"icon-refresh icon-white\"></i>"; echo _("正在初始化..."); echo "');\r\n });\r\n});\r\n</script>\r\n<div>\r\n <fieldset>\r\n <legend><h5>";
public function oaDeptHasChildren($dept_id) { $query = "SELECT COUNT(*) FROM department WHERE DEPT_PARENT = '" . $dept_id . "'"; $cursor = exequery(TD::conn(), $query, TRUE); $ROW = mysql_fetch_array($cursor); if (0 < $ROW[0]) { return TRUE; } return FALSE; }
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']; $WEIXINQY_SECRET = $PARA_ARRAY['WEIXINQY_SECRET']; $WEIXINQY_OAURL = $PARA_ARRAY['WEIXINQY_OAURL']; echo "<body>\r\n<link rel=\"stylesheet\" type=\"text/css\" href=\""; echo MYOA_JS_SERVER; echo "/static/js/bootstrap/css/bootstrap.css\">\r\n<link rel=\"stylesheet\" type=\"text/css\" href=\""; echo MYOA_JS_SERVER; echo "/static/modules/weixinqy/style.css\">\r\n<script type=\"text/javascript\" src=\""; echo MYOA_JS_SERVER; echo "/static/js/jquery-1.10.2/jquery.min.js"; echo $GZIP_POSTFIX;
$strSEND = ""; while ($TOK != "") { if ($TOK == "" || find_id($strSEND, $TOK)) { $TOK = strtok(","); } else { $strSEND .= $TOK . ","; $query = "insert into EMAIL(TO_ID,READ_FLAG,DELETE_FLAG,BODY_ID) values ('" . $TOK . "','0','0','{$BODY_ID}')"; exequery(TD::conn(), $query); $ROW_ID = mysql_insert_id(); $REMIND_URL = "email/inbox/read_email/read_email.php?BOX_ID=0&BTN_CLOSE=1&FROM=1&EMAIL_ID=" . $ROW_ID; $SMS_CONTENT = sprintf(_("请查收我的邮件!") . "\n" . _("主题:%s"), csubstr($SUBJECT, 0, 100)); send_sms("", $_SESSION['LOGIN_USER_ID'], $TOK, 2, $SMS_CONTENT, $REMIND_URL); $WX_NEED_USER_ID_ARR[] = $TOK; $TOK = strtok(","); } } if ($ATYPE == "fw") { $queryfw = "update EMAIL set IS_F='1' where EMAIL_ID='" . $EMAIL_ID . "'"; exequery(TD::conn(), $queryfw); } if ($ATYPE == "rp") { $queryre = "update EMAIL set IS_R='1' where EMAIL_ID='" . $EMAIL_ID . "'"; exequery(TD::conn(), $queryre); } if (0 < count($WX_NEED_USER_ID_ARR)) { include_once "inc/itask/itask.php"; $WX_OPTIONS = array("module" => "email", "module_action" => "email.read", "user" => $WX_NEED_USER_ID_ARR, "content" => $_SESSION['LOGIN_USER_NAME'] . _(":") . _("请查收我的邮件!") . _("主题:") . $SUBJECT, "params" => array("BODY_ID" => $BODY_ID)); wxqy_sms($WX_OPTIONS); } echo "OK"; exit;
public function getDeptInfo() { $data = array(); if (count($this->deptinfo) == 0) { $query = "SELECT DEPT_ID,DEPT_NAME,WEIXIN_DEPT_ID FROM department"; $cursor = exequery(TD::conn(), $query); while ($ROW = mysql_fetch_array($cursor)) { $dept_id = $ROW['DEPT_ID']; $dept_name = $ROW['DEPT_NAME']; $weixin_dept_id = $ROW['WEIXIN_DEPT_ID']; $data[$dept_id] = array("dept_id" => $dept_id, "dept_name" => $dept_name, "weixin_dept_id" => $weixin_dept_id); } $this->deptinfo = $data; } }
public function findBySql($sql) { $cursor = exequery(TD::conn(), $sql); $row = mysql_fetch_array($cursor); return $row; }