Ejemplo n.º 1
0
 static function callback2($matches)
 {
     global $_G;
     $collect =& BigAppAPI::$collect;
     $attachments =& BigAppAPI::$attachments;
     if (isset($matches[1]) && !empty($matches[1])) {
         return '<br />';
     }
     //回车、换行或者swf格式,直接删除
     if (isset($matches[2]) && !empty($matches[2]) || isset($matches[3]) && !empty($matches[3]) || isset($matches[9]) && !empty($matches[9])) {
         return '';
     }
     //非链接形式的URL地址,增加可点击
     if (isset($matches[12])) {
         $url = $matches[0];
         if (empty($matches[12])) {
             $url = 'http://' . $url;
         }
         return '<a href="' . $url . '" target="_blank">' . $matches[0] . '</a>';
     }
     //普通形式的、可点击的,直接返回
     if (isset($matches[10]) || isset($matches[11])) {
         return $matches[0];
     }
     //图片或表情
     $smiles = array('smile.gif' => "😌", 'sad.gif' => "😔", 'biggrin.gif' => "😃", 'cry.gif' => "😭", 'huffy.gif' => "😠", 'shocked.gif' => "😲", 'shocked.png' => "😲", 'tongue.gif' => "😜", 'shy.gif' => "😆", 'titter.gif' => "😝", 'sweat.gif' => "😓", 'mad.gif' => "😫", 'lol.gif' => "😁", 'loveliness.gif' => "😊", 'funk.gif' => "😱", 'curse.gif' => "😤", 'dizzy.gif' => "😖", 'shutup.gif' => "😷", 'sleepy.gif' => "😪", 'hug.gif' => "😚", 'victory.gif' => "✌", 'time.gif' => "⏰", 'kiss.gif' => "💋", 'handshake.gif' => "👌", 'call.gif' => "📞", 'sun.png' => "🌞");
     if (isset($matches[4]) && !empty($matches[4])) {
         /*			$out = preg_match('/smile.gif|sad.gif|biggrin.gif|cry.gif|huffy.gif|shocked.gif|shocked.png|tongue.gif|shy.gif|titter.gif|sweat.gif|' .
         					'mad.gif|lol.gif|loveliness.gif|funk.gif|curse.gif|dizzy.gif|shutup.gif|sleepy.gif|hug.gif|victory.gif|time.gif|' . 
         					'kiss.gif|handshake.gif|call.gif|sun.png/', $matches[4], $_matches); */
         $out = preg_match('/static\\/image\\/smiley/', $matches[4], $_matches);
         if (1 === $out && 1 === count($_matches)) {
             $out2 = preg_match('/\\/[a-zA-Z0-9_]*.gif|.png|.jpg$/', $matches[4], $_matches);
             if (1 === $out && 1 === count($_matches)) {
                 $url = $matches[4];
                 $url = str_replace('source/plugin/mobile/', '', $url);
                 $url = str_replace('source/plugin/bigapp/', '', $url);
                 $ret = '<img class="smile-png" src="' . $url . '?id=bigapp:getsmile" />';
                 return $ret;
             }
             //return $smiles[$_matches[0]];
         }
         //src matched
         $arrUrl = parse_url($matches[4]);
         if (!isset($arrUrl['scheme'])) {
             $ret = ApiUtils::getDzRoot() . $matches[4];
         } else {
             $ret = str_replace('source/plugin/mobile/', '', $matches[4]);
             $ret = str_replace('source/plugin/bigapp/', '', $ret);
         }
         if (true === BigAppConf::$enablePicOpt && ApiUtils::isOptFix($ret) && (!isset($_GET['pad']) || !$_GET['pad'])) {
             $ret = rtrim($_G['siteurl'], '/') . '/plugin.php?id=bigapp:optpic&mod=__x__&size=' . urlencode(BigAppConf::$detailSize) . '&url=' . urlencode($ret);
         }
         $collect[] = array('type' => 1, 'url' => $ret);
         //orginal picture
         $ret = str_replace($matches[4], $ret, $matches[0]);
         return $ret;
     }
     if (isset($matches[5]) && !empty($matches[5]) || isset($matches[8]) && !empty($matches[8])) {
         $i = isset($matches[5]) && !empty($matches[5]) ? 5 : 8;
         $tmp = BigAppAPI::_parseMedia($matches[$i]);
         if (false === $tmp) {
             return $matches[0];
         }
         return $tmp;
     }
     if (isset($matches[6]) && !empty($matches[6])) {
         static $idx = 1000;
         $matches[0] = preg_replace('/height=\\d+/', '', $matches[0]);
         $matches[0] = preg_replace('/width=\\d+/', '', $matches[0]);
         $ret = str_replace('<iframe', '<iframe id="iyouzu_youku_' . $idx . '"', $matches[0]);
         $ret = '<div class="iyouzu_video">' . $ret . '</div>';
         $idx++;
         return $ret;
     }
     //attach matched
     if (!isset($matches[7])) {
         return $matches[0];
     }
     if (!isset($attachments[$matches[7]])) {
         return $matches[0];
     }
     if (!$attachments[$matches[7]]['isimage']) {
         return '';
         //if not an image, ignore
     }
     $url = $attachments[$matches[7]]['url'] . $attachments[$matches[7]]['attachment'];
     $tmp = parse_url($url);
     if (!isset($tmp['scheme'])) {
         $url = ApiUtils::getDzRoot() . $attachments[$matches[7]]['url'] . $attachments[$matches[7]]['attachment'];
     }
     if (true === BigAppConf::$enablePicOpt && ApiUtils::isOptFix($url) && (!isset($_GET['pad']) || !$_GET['pad'])) {
         $url = rtrim($_G['siteurl'], '/') . '/plugin.php?id=bigapp:optpic&mod=__x__&size=' . urlencode(BigAppConf::$detailSize) . '&url=' . urlencode($url);
         $url = str_replace('source/plugin/mobile/', '', $url);
         $url = str_replace('source/plugin/bigapp/', '', $url);
     }
     $collect = array('type' => 2, 'url' => $url, 'description' => isset($attachments[$matches[7]]['description']) ? $attachments[$matches[7]]['description'] : '');
     unset($attachments[$matches[7]]);
     return '<img src="' . $url . '"></img>';
 }