function get_user_profile($netid)
{
    $user = get_user($netid);
    $profile = $user->getmemberProfile();
    if (!$profile) {
        $profile = new memberProfile();
        $profile->setUser($user);
        $profile->save();
    }
    return $profile;
}
Exemple #2
0
 public function parseTopic($_G, $postlist, $forumclass, $uid, $temp)
 {
     foreach ($postlist as $pid => $post) {
         //print_r($postlist);exit;
         if (!empty($post['tid'])) {
             $topicRemote = DB::fetch(DB::query("SELECT remote FROM " . DB::table('forum_threadimage') . " where tid=" . $post['tid']));
             //print_r($topicRemote);exit;
         }
         $uids[] = $post['authorid'];
         preg_match_all("/\\[attach\\](\\d+)\\[\\/attach\\]/i", $postlist[$pid]['message'], $matches);
         $aids = $matches['1'];
         $matches = array_filter($matches);
         foreach (C::t('forum_attachment_n')->fetch_all_by_id('tid:' . $post['tid'], 'pid', $post['pid']) as $attach) {
             $Allaids[] = $attach['aid'];
         }
         if (count($aids) !== count($Allaids)) {
             $tableid = getattachtableid($post['tid']);
             $attachmentAid = C::t('forum_attachment')->fetch_all_by_id('pid', $post['pid']);
             foreach ($attachmentAid as $key => $val) {
                 if (in_array($key, $aids)) {
                     continue;
                 }
                 $path = DB::fetch_first("SELECT * FROM %t WHERE %i AND isimage IN ('1', '-1') ", array('forum_attachment_' . $tableid, DB::field('aid', $val['aid'])));
                 if (!empty($path)) {
                     $filename = $this->parseTargeImage($path);
                     $imgs[] = '<img src="' . $filename . '" />';
                     $attachmentId = $key;
                     $attachmentAId[] = $path['aid'];
                     $postlist[$pid]['message'] = $postlist[$pid]['message'] . '[attach]' . $key . '[/attach]';
                     $pattern[] = "#\\[attach\\]" . $key . "\\[\\/attach\\]#i";
                 }
             }
         }
         if (!empty($matches) && is_array($matches)) {
             foreach ($matches[1] as $k => $v) {
                 $dataImg['attachment'] = $post['attachments'][$v]['attachment'];
                 $dataImg['dateline'] = $post['dateline'];
                 $dataImg['remote'] = $post['attachments'][$v]['remote'];
                 $filename = $this->parseTargeImage($dataImg);
                 $imgs[] = '<img src="' . $filename . '" />';
                 $attachmentId = $v;
             }
         }
         foreach ($matches[1] as $k => $v) {
             $pattern[] = "#\\[attach\\]" . $v . "\\[\\/attach\\]#i";
         }
         $message_string = preg_replace($pattern, $imgs, $postlist[$pid]['message']);
         if ($message_string) {
             $postlist[$pid]['message'] = $message_string;
         }
         $tempPostlist = $forumclass->viewthread_procpost($postlist[$pid], $_G['member']['lastvisit'], 2, 2);
         /*$ti1=Common::get_web_unicode_charset('\u6e38\u5ba2');
         			$tempPostlist[message]=str_replace($ti1,'',$tempPostlist[message]);
         		echo ($tempPostlist[message]);exit;*/
         $topicContent = text_replace($tempPostlist['message']);
         $topicContent = discuzcode($topicContent, $post['smileyoff'], $post['bbcodeoff']);
         $topicContent = str_replace('<img src="static/', '<img src="/static/', $topicContent);
         $postlist[$pid]['message'] = text_replace($topicContent);
         $postlist[$pid]['message'] = preg_replace("/\\<font class=\"jammer\">.+\\<\\/font>/i", '', $postlist[$pid]['message']);
         $postlist[$pid]['message'] = preg_replace("/\\<span style=\"display:none\">.+\\<\\/span>/i", '', $postlist[$pid]['message']);
         $img_url = $post['attachments'][$attachmentId]['url'];
         $font[$pid]['quote_content'] = getContent($post['quotemessage']);
         $font[$pid]['quote_content'] = preg_replace("/\\[attach\\]\\d+\\[\\/attach\\]/i", '', $font[$pid]['quote_content']);
         $tempPostlist_quote_content = $forumclass->viewthread_procpost($post, $_G['member']['lastvisit'], 2, 2);
         $topicContent_quote_content = text_replace($tempPostlist_quote_content['quotemessage']);
         $topicContent_quote_content = discuzcode($topicContent_quote_content, $post['smileyoff'], $post['bbcodeoff']);
         $topicContent_quote_content = str_replace('<img src="static/', '<img src="/static/', $topicContent_quote_content);
         $font[$pid]['quote_content'] = text_replace($topicContent_quote_content);
     }
     $uids = array_unique($uids);
     empty($uid) ? 0 : $uid;
     $uidsql = ' AND ' . DB::field('uid', $uid);
     $fav = DB::fetch_first("SELECT * FROM %t WHERE id=%d AND idtype=%s {$uidsql}", array('home_favorite', $_G['tid'], 'tid'));
     if ($fav) {
         $is_favor = 1;
     } else {
         $is_favor = 0;
     }
     $profile = new memberProfile();
     $profile_list = $profile->get_profile_by_uid($uids, 'gender');
     foreach ($profile_list as $k => $v) {
         $data_profile[$v['uid']]['gender'] = $v['gender'];
         $data_profile[$v['uid']]['level'] = (int) $v['stars'];
     }
     $member = commonMember::getUserStatus($uids);
     $special = get_special_by_tid($_G['tid']);
     if ($special == 2) {
         $i = 0;
         foreach ($postlist as $key => $val) {
             if ($i == 1) {
                 $key1 = $key;
             }
             $i++;
         }
     }
     unset($postlist[$key1]);
     $_user = Anonymous_User($_G['tid']);
     $content = $this->parseTradeTopic($_G, $post);
     foreach ($postlist as $key => $val) {
         $post = $tags = array();
         $thread = C::t('forum_thread')->fetch($val['tid']);
         $post['gender'] = $data_profile[$val['authorid']]['gender'];
         $post['level'] = $data_profile[$val['authorid']]['level'];
         $tags = explode(',', $val['tags']);
         global $_G;
         preg_match_all("/\\[(\\d+)\\]+/i", $val['message'], $smailyArr);
         $thisUrl = dirname('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']) . '/../../';
         foreach ($smailyArr[1] as $key => $Sval) {
             /*rx 20131016 tie zi xiang qing biao qing chu li*/
             $smArr = DB::fetch(DB::query("SELECT * FROM " . DB::table('common_smiley') . " where id=" . $Sval));
             $smTypeArr = DB::fetch(DB::query("SELECT directory FROM " . DB::table('forum_imagetype') . " where typeid=" . $smArr['typeid']));
             $smUrl = $thisUrl . 'static/image/' . $smArr['type'] . '/' . $smTypeArr['directory'] . '/' . $smArr['url'];
             $smile .= "[mobcent_phiz=" . $smUrl . "]";
             /*end rx 20131016*/
             $_G['cache']['smilies']['searcharray'][$Sval] = str_replace('/', "", $_G['cache']['smilies']['searcharray'][$Sval]);
             $val['message'] = str_replace($smailyArr[0][$key], $smile, $val['message']);
             unset($smile);
         }
         if ($tags[0] > 0 || $val['position'] == 1) {
             $message1 = doContent($val['message'], $val[imagelist]);
             $message2 = getContentFont($val['message']);
             foreach ($message1 as $k => $v) {
                 if ($v['type'] == 0) {
                     unset($message1[$k]);
                 } else {
                 }
             }
             $message_array2 = explode('|~|', $message2);
             $message2 = str_replace('[', '1', $message2);
             $message2 = str_replace(']', '1', $message2);
             if (is_array($message_array2) && count($message_array2) > 0) {
                 foreach ($message_array2 as $k => $v) {
                     $message[] = array("infor" => $v, "originalInfo" => '', "type" => 0);
                     if ($message1[$k]["infor"] && !empty($message1)) {
                         $message[] = $message1[$k];
                     }
                 }
             } else {
                 $message = getContentFont($val['message']);
             }
             $post['hits'] = (int) $thread['views'];
             $post['replies'] = (int) $thread['replies'];
             $post['essence'] = (int) $thread['digest'] > 0 || (int) $thread['icon'] == 9 || (int) $thread['stamp'] == 0 ? 1 : 0;
             $post['content'] = $message;
             $post['create_date'] = $val['dateline'] . "000";
             $post['icon'] = userIconImg($val['authorid']);
             $post['is_favor'] = (int) $is_favor;
             if ($val['invisible'] == -5 || $val['invisible'] == -1) {
                 $post['status'] = (int) 0;
                 $arr['rs'] = 0;
                 $arr['errcode'] = '01040007';
                 return $arr;
                 exit;
             } else {
                 if ($thread['closed'] == 1) {
                     $post['status'] = 2;
                 } else {
                     $post['status'] = 1;
                 }
             }
             $post['title'] = $val['subject'];
             $post['topic_id'] = (int) $val['tid'];
             $post['user_id'] = (int) $val['authorid'];
             if (empty($val['author']) && isset($val['authorid']) && !empty($val['authorid'])) {
                 $post['reply_status'] = (int) '-1 ';
                 $post['user_nick_name'] = Common::get_unicode_charset('\\u8be5\\u7528\\u6237\\u5df2\\u88ab\\u5220\\u9664');
             } else {
                 if (empty($val['author']) && empty($val['authorid'])) {
                     $post['reply_status'] = (int) '0 ';
                     $post['user_nick_name'] = Common::get_unicode_charset('\\u533f\\u540d\\u7528\\u6237');
                 } else {
                     $post['reply_status'] = (int) '1 ';
                     $post['user_nick_name'] = $val['author'];
                 }
             }
             $post['reply_posts_id'] = (int) $val['pid'];
             $info = surround_user::fetch_all_by_pid($val['tid']);
             if (empty($info)) {
                 $post['location'] = '';
             } else {
                 $post['location'] = $info['location'];
             }
             $data_post["topic"] = $post;
         } else {
             $message1 = doContent($val['message'], $val[imagelist]);
             $message2 = getContentFont($val['message']);
             foreach ($message1 as $k => $v) {
                 if ($v['type'] == 0) {
                     unset($message1[$k]);
                 } else {
                 }
             }
             $message_array2 = explode('|~|', $message2);
             $message2 = str_replace('[', '1', $message2);
             $message2 = str_replace(']', '1', $message2);
             if (is_array($message_array2) && count($message_array2) > 0) {
                 foreach ($message_array2 as $k => $v) {
                     $message[] = array("infor" => $v, "originalInfo" => '', "type" => 0);
                     if ($message1[$k]["infor"] && !empty($message1)) {
                         $message[] = $message1[$k];
                     }
                 }
             } else {
                 $message = getContentFont($val['message']);
             }
             $post['location'] = "";
             $post['icon'] = userIconImg($val['authorid']);
             $post['posts_date'] = $val['dateline'] . "000";
             $post['reply_content'] = $message;
             $post['reply_id'] = (int) $val['authorid'];
             if (empty($val['author']) && isset($val['authorid']) && !empty($val['authorid'])) {
                 $post['reply_status'] = (int) '-1 ';
                 $post['reply_name'] = Common::get_unicode_charset('\\u8be5\\u7528\\u6237\\u5df2\\u88ab\\u5220\\u9664');
             } else {
                 if (empty($val['author']) && empty($val['authorid'])) {
                     $post['reply_status'] = (int) '0 ';
                     $post['reply_name'] = Common::get_unicode_charset('\\u533f\\u540d\\u7528\\u6237');
                 } else {
                     $post['reply_status'] = (int) '1 ';
                     $post['reply_name'] = $val['author'];
                 }
             }
             $post['reply_posts_id'] = (int) $val['pid'];
             if ($val['invisible'] == -5) {
                 $post['status'] = (int) 0;
             } else {
                 if ($thread['closed'] == 1) {
                     $post['status'] = 2;
                 } else {
                     $post['status'] = 1;
                 }
             }
             $post['title'] = preg_replace("#(\\w*)\\<.*?\\>(\\w*)#", "\$1\$2", $val['subject']);
             $post['role_num'] = $val['groupid'];
             $post['is_quote'] = (bool) $val['is_quote'];
             $post['quote_pid'] = $val['quote_pid'];
             if ((bool) $val['is_quote'] != false) {
                 $post["quote_content"] = preg_replace("/\\[attach\\]\\d+\\[\\/attach\\]/i", '', preg_replace("#(\\w*)\\<.*?\\>(\\w*)#", "\$1\$2", $font[$post['reply_posts_id']]['quote_content']));
             } else {
                 $post["quote_content"] = '';
             }
             $post["quote_user_name"] = null;
             $post['position'] = $val['position'];
             $info = surround_user::fetch_all_by_pid($val['tid']);
             if (empty($info)) {
                 $post['location'] = '';
             } else {
                 $post['location'] = $info['location'];
             }
             $data_post['list'][] = $post;
             unset($quote);
             unset($pid);
             $temp++;
         }
         unset($post);
         unset($message);
     }
     return $data_post;
 }
 /**
  * Exclude object from result
  *
  * @param   memberProfile $memberProfile Object to remove from the list of results
  *
  * @return memberProfileQuery The current query, for fluid interface
  */
 public function prune($memberProfile = null)
 {
     if ($memberProfile) {
         $this->addUsingAlias(memberProfilePeer::ID, $memberProfile->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param memberProfile $obj A memberProfile object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool($obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         memberProfilePeer::$instances[$key] = $obj;
     }
 }
 /**
  * Filter the query by a related memberProfile object
  *
  * @param   memberProfile|PropelObjectCollection $memberProfile  the related object to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 UserQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterBymemberProfile($memberProfile, $comparison = null)
 {
     if ($memberProfile instanceof memberProfile) {
         return $this->addUsingAlias(UserPeer::ID, $memberProfile->getId(), $comparison);
     } elseif ($memberProfile instanceof PropelObjectCollection) {
         return $this->usememberProfileQuery()->filterByPrimaryKeys($memberProfile->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterBymemberProfile() only accepts arguments of type memberProfile or PropelCollection');
     }
 }