Example #1
0
 /**
  * 发送短消息
  *
  * 前端增加站点代号 = 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);
 }
Example #2
0
 /**
  * 上传指定目录下的文件到文件管理器(http)
  *
  * @param string $filepath 文件路径
  * jute
  * 20080115
  */
 function httpuploadfile($filepath = '')
 {
     if (is_file($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=upload_tq';
         $par = array('userfile' => "@" . realpath($filepath), 'ftpdir' => $ftp_upload_path);
         return Watt_Http_Client::curlPost($url, $par);
     } else {
         return '';
     }
     return '';
 }
Example #3
0
 private static function xiamen($lang, $text)
 {
     $url = TpmPeizhiPeer::getPeizhiByPzMingcheng('SERVER_TRANSLATE');
     if (!$url) {
         //$url = 'http://mt.xmu.edu.cn/translate';
         $url = 'http://59.77.17.127/translate';
     }
     $param = array('text' => $text, 'lang' => $lang);
     $trans = null;
     watt_log::addLog('Before translate');
     $params = 'text=' . urlencode($param['text']) . '&lang=' . $param['lang'];
     $rev = Watt_Http_Client::curlPost($url, $params);
     //$rev = Watt_Http_Client::post_data( $url, $param );
     watt_log::addLog('After translate');
     $begin = '<textarea name="text" wrap="virtual"  rows=8 cols=40>';
     $firstPos = strpos($rev, $begin);
     if ($firstPos !== false) {
         $secondPos = strpos($rev, '</textarea>', $firstPos);
         $trans = substr($rev, $firstPos + strlen($begin), $secondPos - $firstPos - strlen($begin));
     }
     return $trans;
 }