/**
  * 获取转发主题信息 For DiscuzX1.5
  * @param $tid int 论坛thread id
  * @return array
  */
 function forShare($tid)
 {
     /* 主题URL */
     $baseurl = XWB_plugin::siteUrl();
     $topic_url = $baseurl . 'index.php?mod=topic&code=' . $tid;
     if (function_exists('get_full_url')) {
         $topic_url = get_full_url($baseurl, 'index.php?mod=topic&code=' . $tid);
     }
     $url = ' ' . $topic_url;
     /* 获取微博信息 */
     $db = XWB_plugin::getDB();
     $topic = $db->fetch_first("SELECT `tid`,`content`,`imageid` FROM " . XWB_S_TBPRE . "topic WHERE tid='{$tid}'");
     if (empty($topic)) {
         return FALSE;
     }
     /* 转码 */
     $message = $this->_convert(trim($topic['content']));
     /* 过滤UBB与表情 */
     $message = $this->_filter($message);
     $message = strip_tags($message);
     /* 将最后附带的url给删除 */
     $message = preg_replace("|\\s*http:/" . "/[a-z0-9-\\.\\?\\=&_@/%#]*\$|sim", "", $message);
     /* 合并标题和链接 */
     $message = $message . $url;
     // 取出所有图片
     $img_urls = array();
     if ($topic['imageid'] && XWB_plugin::pCfg('is_upload_image')) {
         $image_file = "/images/topic/" . jsg_face_path($topic['imageid']) . $topic['imageid'] . "_o.jpg";
         if (is_file(XWB_S_ROOT . $image_file)) {
             $img_urls[] = $baseurl . $image_file;
         }
     }
     return array('url' => $topic_url, 'message' => $message, 'pics' => array_map('trim', $img_urls));
 }
 /**
  * 同步头像到指定的DZ uid(同步到DZ)。
  * 适用于没有安装UC的DZ。普通站长一般是DZ6.0.0
  *
  * @param integer $uid DZ uid
  * @return integer 同步结果。正常为0,否则:
  *  -1到-10:此错误码预留给_getFaceAndCreateTemp方法,请自行参阅该方法的注释
  *
  * 	-20:要复制的中等头像不存在
  * 	-21:论坛设置不允许该用户所在用户组上传头像
  * 	-22:复制头像到指定论坛头像目录失败
  */
 function syncToNoUC($uid)
 {
     $step1result = $this->_getFaceAndCreateTemp($uid);
     if ($step1result < 0) {
         return $step1result;
     }
     $db = XWB_plugin::getDB();
     //由于中等头像经大头像创建,而大头像已经经过安全检测,因此在这里只需要检测中等头像是否存在即可。
     if (!file_exists($this->faceTempPath[3])) {
         $this->_delTempFace();
         return -20;
     }
     $_destPrefix = './images/face/' . jsg_face_path($this->uid) . $this->uid;
     $image_file_small = $destPath = $_destPrefix . '_s.jpg';
     $image_file = $_destPrefix . '_b.jpg';
     $destRealPath = XWB_S_ROOT . $destPath;
     if (!is_dir(dirname($destPath))) {
         jmkdir(dirname($destPath));
     }
     copy($this->faceTempPath[2], XWB_S_ROOT . $image_file);
     $copyresult = copy($this->faceTempPath[3], $destRealPath);
     $this->_delTempFace();
     if (false == $copyresult) {
         return -22;
     } else {
         $face_url = '';
         if ($GLOBALS['_J']['config']['ftp_enable']) {
             $ftp_key = randgetftp();
             $get_ftps = jconf::get('ftp');
             $face_url = $get_ftps[$ftp_key]['attachurl'];
             $ftp_result = ftpcmd('upload', $image_file, '', $ftp_key);
             if ($ftp_result > 0) {
                 ftpcmd('upload', $image_file_small, '', $ftp_key);
                 @unlink($image_file);
                 @unlink($image_file_small);
             }
         }
         $destPath = mysql_real_escape_string($destPath);
         $db->result_first("UPDATE " . XWB_S_TBPRE . "members SET `face_url`='{$face_url}', `face`= '" . $destPath . "' WHERE uid = '" . $this->uid . "' LIMIT 1");
         return 0;
     }
 }