Beispiel #1
0
 private function _transMessage($msgString)
 {
     $msg = array('type' => 'text', 'content' => '');
     $matches = array();
     preg_match_all('/<img.*?src="(.*?)".*?\\/>/s', $msgString, $matches, PREG_SET_ORDER);
     if (!empty($matches)) {
         foreach ($matches as $match) {
             $match[1] = WebUtils::getHttpFileName($match[1]);
             if (strpos($match[0], 'static/image/smiley') !== false || strpos($match[0], 'mobcent/app/data/phiz') !== false) {
                 $msgString = str_replace($match[0], sprintf('[mobcent_phiz=%s]', $match[1]), $msgString);
             } else {
                 $msg['type'] = 'image';
                 $msgString = ImageUtils::getThumbImage($match[1]);
                 break;
             }
         }
     }
     $matches = array();
     preg_match_all('/<a href="(.*?)".*?>(.*?)<\\/a>/s', $msgString, $matches, PREG_SET_ORDER);
     if (!empty($matches)) {
         foreach ($matches as $match) {
             $match[1] = WebUtils::getHttpFileName($match[1]);
             if (strpos($match[0], UploadUtils::getUploadAudioBaseUrlPath()) !== false) {
                 $msg['type'] = 'audio';
                 $msgString = $match[1];
                 break;
             } else {
                 // $msgString = str_replace($match[0], sprintf('[mobcent_url=%s]%s[/mobcent_url]', $match[1], $match[2]), $msgString);
                 $msgString = str_replace($match[0], sprintf(' %s %s ', $match[2], $match[1]), $msgString);
             }
         }
     }
     $msg['content'] = WebUtils::emptyHtml($msgString);
     return $msg;
 }
 /**
  * 获取附件路径 如:data/appbyme/upload/image/201412/02
  * 
  * @param mixed $type 附件的类型
  *
  * @return mixed Value.
  */
 private function _getPathFileName($type)
 {
     $path = '';
     $tempPath = $this->_getTempPath();
     $urlBasePath = '';
     switch ($type) {
         case 'audio':
             $urlBasePath = UploadUtils::getUploadAudioBaseUrlPath($tempPath);
             break;
         case 'image':
             $urlBasePath = UploadUtils::getUploadImageBaseUrlPath($tempPath);
             break;
         default:
             break;
     }
     $path = $urlBasePath . '/' . $tempPath;
     return $path;
 }
 private function _getPathFileName($type, $fileName)
 {
     $res = array('path' => '', 'file' => '');
     $tempPath = $this->_getTempPath();
     $urlBasePath = '';
     switch ($type) {
         case 'audio':
             $urlBasePath = UploadUtils::getUploadAudioBaseUrlPath($tempPath);
             break;
         case 'image':
             $urlBasePath = UploadUtils::getUploadImageBaseUrlPath($tempPath);
             break;
         default:
             break;
     }
     $res['path'] = $urlBasePath . '/' . $tempPath;
     $res['file'] = $this->_getRondomFileName($type, $fileName);
     return $res;
 }