public static function test() { set_time_limit(10); $url = Watt_Util_Net::isLANIp($_SERVER['SERVER_ADDR']); $epollServer = Watt_Config::getEpollServer(); /* $epoll_url = Watt_Config::getEpollServer(); if($url)//判断是否内网IP { if(preg_match("/\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}/",$epoll_url))//判断是否IP { $epollUpdateUrl = $epoll_url; } else //是否域名 { $epollUpdateUrl = "in".$epoll_url; } } else { $epollUpdateUrl = $epoll_url; } $epollServer = $epollUpdateUrl; */ $port = Watt_Config::getEpollServerPort(); $epollClient = new Watt_Net_EpollClient($epollServer, $port); $fromId = 4040; $epollClient->login($fromId); $epollClient->sendTpmMsg($fromId, 151017933, 1, 'Title', 'Link', 'test消息', 'msn', 'qq18076495', 'extmsg', 1); // $list = $epollClient->getOnlineList( $fromId ); // echo "<pre>Terry at [".__FILE__."(line:".__LINE__.")]\nWhen [Fri Jun 13 19:46:17 CST 2008] :\n "; // var_dump( $list ); // echo "</pre>"; //exit(); // echo "<pre>Terry at [".__FILE__."(line:".__LINE__.")]\nWhen [Thu Jun 26 20:28:09 CST 2008] :\n "; // var_dump( strToHex( iconv('ISO-8859-1','UTF-8','消息' ) ) ); // var_dump( ( urlencode('消息') ) ); // var_dump( pack( "H*","886D6F60" ) ); // echo "</pre>"; //exit(); Watt_Debug::getDefaultDebug()->addInfo('After login'); // $docHeader = pack( 'H*', 'D0CF11E0A1B11AE1' ); // $docHeader = pack( 'H*', 'FFFE' ); // $total = pack('H*','00910001000003EA'); // echo "<pre>Terry at [".__FILE__."(line:".__LINE__.")]\nWhen [Fri Jun 13 17:13:46 CST 2008] :\n "; // var_dump( strToHex($total) ); // echo "</pre>"; // // $total = pack('nnN',0x0091,0x0001,0x000003EA); // echo "<pre>Terry at [".__FILE__."(line:".__LINE__.")]\nWhen [Fri Jun 13 17:13:46 CST 2008] :\n "; // var_dump( strToHex($total) ); // echo "</pre>"; // // $rev = unpack('nlen/ncmd/Nepollid/', $total); // echo "<pre>Terry at [".__FILE__."(line:".__LINE__.")]\nWhen [Fri Jun 13 14:24:03 CST 2008] :\n "; // var_dump( $rev ); // echo "</pre>"; // //exit(); // // $total = pack( 'H*', '00910001000003EA50F1120058DBEEBFAAC1040880DBEEBF50DBEEBF68DBEEBFD8C1040884DBEEBFC8DCEE00000012F12800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' ); // echo "<pre>Terry at [".__FILE__."(line:".__LINE__.")]\nWhen [Fri Jun 13 17:13:46 CST 2008] :\n "; // var_dump( strToHex($total) ); // echo "</pre>"; // // $rev = unpack( "nlen/ncmd/Nepollid/a".self::MAX_USER_NAME_EX."user/a".self::MAX_PASSWD_LEN_EX."pwd/Nip/Naction/a*memo/",$total ); // echo "<pre>Terry at [".__FILE__."(line:".__LINE__.")]\nWhen [Fri Jun 13 14:24:03 CST 2008] :\n "; // var_dump( $rev ); // echo "</pre>"; // exit(); /* 0091 0001 000003EA 50F1120058DBEEBFAAC1040880DBEEBF50DBEEBF68DBEEBFD8C1040884DBEEBF C8DCEE00000012F1280000000000000000000000000000000000000000000000 00000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' */ }
/** * 下载文件(http) * * @param unknown_type $filepath * @return unknown * jute * 20080115 */ function httpdownloadfile($filepath = '') { if (Watt_Util_Net::isLANIp($_SERVER['SERVER_ADDR'])) { $filemanager = Watt_Config::getCfg('TQ_FTP_MANAGER'); $ftp_upload_path = Watt_Config::getFtpDir(); } else { $filemanager = Watt_Config::getCfg('FtpServerOuterManager'); $ftp_upload_path = Watt_Config::getCfg('FtpDirOuter'); } //$filemanager ="http://filemanager.transn.net/"; $url = $filemanager . '?do=download'; $url = $url . "&ftpRelPath=" . $ftp_upload_path . "&ftpName=" . $filepath; return file_get_contents($url); }
/** * EpollServer=Epoll服务器地址: EpollServerPort=Epoll服务器端口: EpollHeartBeat=心跳时间: FtpServer=Ftp服务器地址: FtpServerPort=Ftp服务器端口: FtpUserName=Ftp用户名: FtpPassword=Ftp密码 FtpDir=ftp路径 * * */ public static function getEpollServer($secondary = 0) { /** * 内外网在此判断,外部可放心的使用此方法了 * @author terry * @version 0.1.0 * Wed Nov 26 15:22:08 CST 2008 */ $url = Watt_Util_Net::isLANIp($_SERVER['REMOTE_ADDR']); $epoll_url = self::_getCfgByName("EpollServer", $secondary); if ($url) { //无服务器配置或是IP均直接提供地址 if (!$epoll_url || preg_match("/\\d{1,3}.\\d{1,3}.\\d{1,3}.\\d{1,3}/", $epoll_url)) { $epollUpdateUrl = $epoll_url; } else { $epollUpdateUrl = "in" . $epoll_url; } } else { $epollUpdateUrl = $epoll_url; } $epollServer = $epollUpdateUrl; return $epollServer; }
/** * 循环进行 do 的处理 * */ function dispatch() { /** * 因为Tq是用Post传递参数过来的,所以不能用$_GET */ $do = empty($_REQUEST["do"]) ? "index" : trim($_REQUEST["do"]); /** * 这是为了兼容 do=xxx&action=yyy 的形式 */ $a = empty($_REQUEST["action"]) ? "" : trim($_REQUEST["action"]); if ($a) { $do .= "_" . $a; } /** * 获取view的type */ $v = empty($_REQUEST["v"]) ? "Html" : trim($_REQUEST["v"]); //TQ任务LINK //http://testtpm.transn.net/index.php?do=if_renwu_detail&sj_id=35c55571-80bb-c18b-6078-465a87c329bd&Username=dGVzdC1wcjE=&Password=MjAyY2I5NjJhYzU5MDc1Yjk2NGIwNzE1MmQyMzRiNzA=&pwdway=md5 /** * 获取用户名和密码进行快速登录 */ $accounts = ''; $pwd = ''; if (r('pwdway')) { if (!Watt_Session::getSession()->getUserId()) { //这个判断是为了不让TQ登录后,访问此链接时,冲掉session中[是否TQ]那个设置 $accounts = iconv('GB2312', 'UTF-8', base64_decode(str_replace(' ', '+', r("Username")))); $pwd = iconv('GB2312', 'UTF-8', base64_decode(str_replace(' ', '+', r("Password")))); } } else { //if( r( 'login' ) == 'ok' ){ if (r('login')) { /** * 这是为了兼容TQ的那个点击“查收我的订单”,导致Web重登录的问题。 * @author terry * @version 0.1.0 * Thu Sep 06 16:44:53 CST 2007 */ $accounts = ''; $pwd = ''; } else { // if(r('yh_xiaoshou_id')){ // $wkh_id = r( "yh_waibukehu_id" ); // $yh_xiaoshou_id = r( "yh_xiaoshou_id" ); // $yh_xiaoshou_name = TpmYonghuPeer::getYhZhanghuByYhId($yh_xiaoshou_id); // $nkh_id = TpmKehufromkehuPeer::getNkIdByWkId($wkh_id,$yh_xiaoshou_name); // $accounts = TpmYonghuPeer::getYhZhanghuByYhId($nkh_id) ; // $pwd = r( "user_pw" ); // if($pwd==''){ // $pwd = r('yh_xiaoshou_id'); // } // }else{ $accounts = r("user_name"); $pwd = r("user_pw"); //} } } //var_dump(); //exit; if ($accounts && $pwd) { $login_rev = 0; $user = TpmYonghuPeer::checkUserLogin($accounts, $pwd, $login_rev); if ($login_rev == TpmYonghuPeer::USER_LOGIN_OK) { // 用户登陆成功后如果密码安全强度不够,跳转到修改密码页提示用户设置安全的密码 $pswdChecker = new Tpm_Passwordchecker($pwd); $cfgLevel = Watt_Config::getCfg('PSWD_CHECK_LEVEL'); if ($cfgLevel == '') { $cfgLevel = '0'; } if ($pswdChecker->getSecurityLevel() < $cfgLevel) { $_SESSION['LOW_PASSWORD'] = true; // header('Location:?do=ps_yonghu_changepwd&nosecurity=true'); // exit; } Watt_Log::addLog('Login ok, accounts[' . $accounts . '],[' . session_name() . '=' . session_id() . ']', Watt_Log::LEVEL_INFO, 'LOGIN_WEB_DIRECT_LOGIN'); } else { if ($login_rev == TpmYonghuPeer::USER_LOGIN_SHOUQUANOK) { //授权密码登录 jute 20071220 Watt_Log::addLog('Authorizepwd Login ok, accounts[' . $accounts . ']', Watt_Log::LEVEL_INFO, 'LOGIN_WEB_DIRECT_LOGIN'); } } } //如密码强度不够, 强制修改密码 $superDoList = array('ps_yonghu_changepwd', 'login_logout', ''); // 数组中的Action不在强制之列 if (@$_SESSION['LOW_PASSWORD'] && !in_array($do, $superDoList)) { header('Location:?do=ps_yonghu_changepwd&nosecurity=true'); exit; } /** * 除了译员和客户,只能从内部登录 * @author terry * @version 0.1.0 * Mon Mar 31 23:24:00 CST 2008 */ if (Watt_Session::getSession()->getUserName()) { if (!Watt_Util_Net::isLANIp($_SERVER['REMOTE_ADDR']) && r('do') != 'main_home') { if (!(Watt_Session::getSession()->getYhShifouWaibuDenglu() || Watt_Session::getSession()->getJsShifouWaibuDenglu())) { echo '您没有外部访问权限,请联系企业管理员开通'; Watt_Session::getSession()->clearUserSessionInfo(); exit; } } } $i = $this->_maxToDo; while ($do != "" && $i-- > 0) { $do = $this->processDo($do, $v); } //如果是渠道代理商客户,传神客户,客户则记录日志 2007-7-9 john if (Watt_Session::getSession()->getRoleShortname() == "QDKH" || Watt_Session::getSession()->getRoleShortname() == "CSKH" || Watt_Session::getSession()->getRoleShortname() == "CR") { $accessLoger = new Watt_Log_Db('tpm_rizhi_fangwen'); $accessLoger->log("", 0, $_REQUEST["do"]); } }