/** * 发送短消息 * * 前端增加站点代号 = EpollGroupId * 前端增加系统代号 = 1 (TPM = 1) * * 要求: $from_mobile 是已经由各业务单元增加了业务代码的号码 * * @param string $to * @param string[UTF-8] $msg * @param string $from_mobile * @param int $msgid * @return string[UTF-8] */ public static function sendSms($to, $msg, $from_mobile, $msgid = 0, $tag = '') { /* $to = '13683078625'; $source = '00'; $msg = 'test'; $string = "&to={$to}&source={$source}&msg={$msg}"; */ self::_init(); $msgid = mt_rand(1, 999); $toMsg = iconv('UTF-8', 'GB2312', $msg); /** * 发送出的短信,将本地号码加. * 前端增加站点代号 = EpollGroupId * 前端增加系统代号 = 1 (TPM = 1) */ $source = self::addSystemCode($from_mobile); //($from_mobile?$from_mobile:'00'); //$other = '&mobile=wattcan&pwd=h2175&action=sendmsg'; $other = ''; //action 与 Watt 框架冲突 $string = "tmobile={$to}&msgid={$msgid}&msg={$toMsg}{$other}&source={$source}&tag={$tag}"; //发送到短信提供商 $sms_url = Watt_Config::getCfg('SMS_CENTER'); $data = Watt_Http_Client::curlPost($sms_url, $string); Watt_Log::addLog("Send Sms [{$msg}] From [{$from_mobile}] To [{$to}] Ok ( Source Code[{$source}] URL[ " . $sms_url . $string . " ] REV[{$data}] ).", Watt_Log::LEVEL_INFO, 'MSG_SMS'); return iconv('GB2312', 'UTF-8', $data); }
/** * 获得一个 PHPMailer 对象,已经作了基本配置, * SMTP * * @return PHPMailer */ public static function getPhpMailerWithDefaultConfig() { include_once Watt_Config::getLibPath() . 'Third/phpmailer/class.phpmailer.php'; $mail = new PHPMailer(); $mail->IsSMTP(); // 设置使用 SMTP 与发件人相同 $mail->Host = Watt_Config::getCfg("MAIL_SMTP_HOST"); // 指定的 SMTP 服务器地址 $mail->Username = Watt_Config::getCfg("MAIL_SMTP_USERNAME"); // SMTP 发邮件人的用户名 $mail->Password = Watt_Config::getCfg("MAIL_SMTP_PASSWORD"); // SMTP 密码 $mail->SMTPAuth = Watt_Config::getCfg("MAIL_SMTP_AUTH"); // 设置为安全验证方式 $mail->From = Watt_Config::getCfg("MAIL_SMTP_ADDR"); // 发件人地址 //"*****@*****.**" ; return $mail; }
/** * 下载文件(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); }
private function _connectMemcache() { if (!$this->_memcache) { $memcacheHost = Watt_Config::getCfg("MEMCACHE_HOST"); $memcachePort = Watt_Config::getCfg("MEMCACHE_PORT"); if ($memcacheHost && $memcachePort) { $memcache = new Memcache(); if ($memcache->connect($memcacheHost, $memcachePort)) { $this->_memcache = $memcache; } } } return $this->_memcache; }
/** * 循环进行 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"]); } }