Exemplo n.º 1
0
        $daycount = $_G['setting']['recommendthread']['daycount'] - $recommendcount;
        showmessage('recommend_daycount_succed', '', array('recommendv' => $recommendv, 'recommendc' => $thread['recommends'], 'daycount' => $daycount), array('msgtype' => 3));
    } else {
        showmessage('recommend_succed', '', array('recommendv' => $recommendv, 'recommendc' => $thread['recommends']), array('msgtype' => 3));
    }
} elseif ($_GET['action'] == 'protectsort') {
    $tid = $_GET['tid'];
    $optionid = $_GET['optionid'];
    include template('common/header_ajax');
    $typeoptionvarvalue = C::t('forum_typeoptionvar')->fetch_all_by_tid_optionid($tid, $optionid);
    $typeoptionvarvalue[0]['expiration'] = $typeoptionvarvalue[0]['expiration'] && $typeoptionvarvalue[0]['expiration'] <= TIMESTAMP ? 1 : 0;
    $option = C::t('forum_typeoption')->fetch($optionid);
    if ($option['expiration'] && !$typeoptionvarvalue[0]['expiration'] || empty($option['expiration'])) {
        $protect = dunserialize($option['protect']);
        include_once libfile('function/threadsort');
        if (protectguard($protect)) {
            if (empty($option['permprompt'])) {
                echo lang('forum/misc', 'view_noperm');
            } else {
                echo $option['permprompt'];
            }
        } else {
            echo nl2br($typeoptionvarvalue[0]['value']);
        }
    } else {
        echo lang('forum/misc', 'has_expired');
    }
    include template('common/footer_ajax');
} elseif ($_GET['action'] == 'usertag') {
    if ($_G['tid']) {
        if (!submitcheck('addusertag')) {
function threadsortshow($sortid, $tid)
{
    global $_G;
    loadcache(array('threadsort_option_' . $sortid, 'threadsort_template_' . $sortid));
    $sortoptionarray = $_G['cache']['threadsort_option_' . $sortid];
    $templatearray = $_G['cache']['threadsort_template_' . $sortid];
    $threadsortshow = $optiondata = $searchtitle = $searchvalue = $searchunit = $memberinfofield = $_G['forum_option'] = array();
    if ($sortoptionarray) {
        foreach (C::t('forum_typeoptionvar')->fetch_all_by_tid_optionid($tid) as $option) {
            $optiondata[$option['optionid']]['value'] = $option['value'];
            $optiondata[$option['optionid']]['expiration'] = $option['expiration'] && $option['expiration'] <= TIMESTAMP ? 1 : 0;
            $sortdataexpiration = $option['expiration'];
        }
        foreach ($sortoptionarray as $optionid => $option) {
            $_G['forum_option'][$option['identifier']]['title'] = $option['title'];
            $_G['forum_option'][$option['identifier']]['unit'] = $option['unit'];
            $_G['forum_option'][$option['identifier']]['type'] = $option['type'];
            if ($option['expiration'] && !$optiondata[$optionid]['expiration'] || empty($option['expiration'])) {
                if (!protectguard($option['protect'])) {
                    if ($option['type'] == 'checkbox') {
                        $_G['forum_option'][$option['identifier']]['value'] = '';
                        foreach (explode("\t", $optiondata[$optionid]['value']) as $choiceid) {
                            $_G['forum_option'][$option['identifier']]['value'] .= $option['choices'][$choiceid] . '&nbsp;';
                        }
                    } elseif ($option['type'] == 'radio') {
                        $_G['forum_option'][$option['identifier']]['value'] = $option['choices'][$optiondata[$optionid]['value']];
                    } elseif ($option['type'] == 'select') {
                        $tmpchoiceid = $tmpidentifiervalue = array();
                        foreach (explode('.', $optiondata[$optionid]['value']) as $choiceid) {
                            $tmpchoiceid[] = $choiceid;
                            $tmpidentifiervalue[] = $option['choices'][implode('.', $tmpchoiceid)];
                        }
                        $_G['forum_option'][$option['identifier']]['value'] = implode(' &raquo; ', $tmpidentifiervalue);
                        unset($tmpchoiceid, $tmpidentifiervalue);
                    } elseif ($option['type'] == 'image') {
                        $imgoptiondata = dunserialize($optiondata[$optionid]['value']);
                        $threadsortshow['sortaids'][] = $imgoptiondata['aid'];
                        if (empty($templatearray['viewthread'])) {
                            $maxwidth = $option['maxwidth'] ? 'width="' . $option['maxwidth'] . '"' : '';
                            $maxheight = $option['maxheight'] ? 'height="' . $option['maxheight'] . '"' : '';
                            if (!defined('IN_MOBILE')) {
                                $_G['forum_option'][$option['identifier']]['value'] = $imgoptiondata['url'] ? "<img src=\"" . $imgoptiondata['url'] . "\" onload=\"thumbImg(this)\" {$maxwidth} {$maxheight} border=\"0\">" : '';
                            } else {
                                $_G['forum_option'][$option['identifier']]['value'] = $imgoptiondata['url'] ? "<a href=\"" . $imgoptiondata['url'] . "\" target=\"_blank\">" . lang('forum/misc', 'click_view') . "</a>" : '';
                            }
                        } else {
                            $_G['forum_option'][$option['identifier']]['value'] = $imgoptiondata['url'] ? $imgoptiondata['url'] : './static/image/common/nophoto.gif';
                        }
                    } elseif ($option['type'] == 'url') {
                        $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'] ? "<a href=\"" . $optiondata[$optionid]['value'] . "\" target=\"_blank\">" . $optiondata[$optionid]['value'] . "</a>" : '';
                    } elseif ($option['type'] == 'number') {
                        $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'];
                    } else {
                        if ($option['protect']['status'] && $optiondata[$optionid]['value']) {
                            $optiondata[$optionid]['value'] = $option['protect']['mode'] == 1 ? '<image src="' . stringtopic($optiondata[$optionid]['value']) . '">' : (!defined('IN_MOBILE') ? '<span id="sortmessage_' . $option['identifier'] . '"><a href="###" onclick="ajaxget(\'forum.php?mod=misc&action=protectsort&tid=' . $tid . '&optionid=' . $optionid . '\', \'sortmessage_' . $option['identifier'] . '\');return false;">' . lang('forum/misc', 'click_view') . '</a></span>' : $optiondata[$optionid]['value']);
                            $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'] ? $optiondata[$optionid]['value'] : $option['defaultvalue'];
                        } elseif ($option['type'] == 'textarea') {
                            $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'] != '' ? nl2br($optiondata[$optionid]['value']) : '';
                        } else {
                            $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'] != '' ? $optiondata[$optionid]['value'] : $option['defaultvalue'];
                        }
                    }
                } else {
                    if (empty($option['permprompt'])) {
                        $_G['forum_option'][$option['identifier']]['value'] = lang('forum/misc', 'view_noperm');
                    } else {
                        $_G['forum_option'][$option['identifier']]['value'] = $option['permprompt'];
                    }
                }
            } else {
                $_G['forum_option'][$option['identifier']]['value'] = lang('forum/misc', 'has_expired');
            }
        }
        $typetemplate = '';
        if ($templatearray['viewthread']) {
            foreach ($sortoptionarray as $option) {
                $searchtitle[] = '/{(' . $option['identifier'] . ')}/e';
                $searchvalue[] = '/\\[(' . $option['identifier'] . ')value\\]/e';
                $searchvalue[] = '/{(' . $option['identifier'] . ')_value}/e';
                $searchunit[] = '/\\[(' . $option['identifier'] . ')unit\\]/e';
                $searchunit[] = '/{(' . $option['identifier'] . ')_unit}/e';
            }
            $threadexpiration = $sortdataexpiration ? dgmdate($sortdataexpiration) : lang('forum/misc', 'never_expired');
            $typetemplate = preg_replace(array("/\\{expiration\\}/i"), array($threadexpiration), stripslashes($templatearray['viewthread']));
            $typetemplate = preg_replace($searchtitle, "showoption('\\1', 'title')", $typetemplate);
            $typetemplate = preg_replace($searchvalue, "showoption('\\1', 'value')", $typetemplate);
            $typetemplate = preg_replace($searchunit, "showoption('\\1', 'unit')", $typetemplate);
        }
    }
    $threadsortshow['optionlist'] = !$optionexpiration ? $_G['forum_option'] : 'expire';
    $threadsortshow['typetemplate'] = $typetemplate;
    $threadsortshow['expiration'] = dgmdate($sortdataexpiration, 'd');
    return $threadsortshow;
}
function threadsortshow($sortid, $tid)
{
    global $_G;
    loadcache(array('threadsort_option_' . $sortid, 'threadsort_template_' . $sortid));
    $sortoptionarray = $_G['cache']['threadsort_option_' . $sortid];
    $templatearray = $_G['cache']['threadsort_template_' . $sortid];
    $threadsortshow = $optiondata = $searchtitle = $searchvalue = $searchunit = $memberinfofield = $_G['forum_option'] = array();
    $sql = "SELECT p.pid,p.fid,p.authorid FROM " . DB::table('forum_post') . " p WHERE p.tid =" . $tid . " and p.position=1 LIMIT 0, 1";
    $query = DB::query($sql);
    $vanfon_tid = 0;
    $vanfon_fid = 0;
    $vanfon_uid = 0;
    while ($result = DB::fetch($query)) {
        $vanfon_tid = $result['pid'];
        $vanfon_fid = $result['fid'];
        $vanfon_uid = $result['authorid'];
    }
    $vanfon_verify = '';
    $verifyuids = array();
    $verifyuids[$vanfon_uid] = $vanfon_uid;
    foreach (C::t('common_member_verify')->fetch_all($verifyuids) as $value) {
        foreach ($_G['setting']['verify'] as $vid => $vsetting) {
            if ($vsetting['available'] && $vsetting['showicon'] && $value['verify' . $vid] == 1) {
                $srcurl = '';
                if (!empty($vsetting['icon'])) {
                    $srcurl = $vsetting['icon'];
                }
                $vanfon_verify .= "<a href=\"home.php?mod=spacecp&ac=profile&op=verify&vid={$vid}\" target=\"_blank\">" . (!empty($srcurl) ? '<img src="' . $srcurl . '" class="vm" alt="' . $vsetting['title'] . '" title="' . $vsetting['title'] . '" />' : $vsetting['title']) . '</a>';
            } else {
                /*$srcurl = '';
                		$srcurl =   $vsetting['unverifyicon'];
                			$vanfon_verify .= "<a href=\"home.php?mod=spacecp&ac=profile&op=verify&vid=$vid\" target=\"_blank\">".(!empty($srcurl) ? '<img src="'.$srcurl.'" class="vm" alt="'.$vsetting['title'].'" title="'.$vsetting['title'].'" />' : $vsetting['title']).'</a>';*/
            }
        }
    }
    $sql = "SELECT m.groupid,g.icon FROM " . DB::table('common_member') . " m ," . DB::table('common_usergroup') . " g WHERE m.uid =" . $vanfon_uid . " and m.groupid=g.groupid LIMIT 0, 1";
    $query = DB::query($sql);
    $vanfon_usergroup = 0;
    while ($result = DB::fetch($query)) {
        $vanfon_usergroup = $result['icon'];
    }
    if ($sortoptionarray) {
        foreach (C::t('forum_typeoptionvar')->fetch_all_by_tid_optionid($tid) as $option) {
            $optiondata[$option['optionid']]['value'] = $option['value'];
            $optiondata[$option['optionid']]['expiration'] = $option['expiration'] && $option['expiration'] <= TIMESTAMP ? 1 : 0;
            $sortdataexpiration = $option['expiration'];
        }
        foreach ($sortoptionarray as $optionid => $option) {
            $_G['forum_option'][$option['identifier']]['title'] = $option['title'];
            $_G['forum_option'][$option['identifier']]['unit'] = $option['unit'];
            $_G['forum_option'][$option['identifier']]['type'] = $option['type'];
            if ($option['expiration'] && !$optiondata[$optionid]['expiration'] || empty($option['expiration'])) {
                if (!protectguard($option['protect'])) {
                    if ($option['type'] == 'checkbox') {
                        $_G['forum_option'][$option['identifier']]['value'] = '';
                        foreach (explode("\t", $optiondata[$optionid]['value']) as $choiceid) {
                            $_G['forum_option'][$option['identifier']]['value'] .= $option['choices'][$choiceid] . '&nbsp;';
                        }
                    } elseif ($option['type'] == 'radio') {
                        $_G['forum_option'][$option['identifier']]['value'] = $option['choices'][$optiondata[$optionid]['value']];
                    } elseif ($option['type'] == 'select') {
                        $tmpchoiceid = $tmpidentifiervalue = array();
                        foreach (explode('.', $optiondata[$optionid]['value']) as $choiceid) {
                            $tmpchoiceid[] = $choiceid;
                            $tmpidentifiervalue[] = $option['choices'][implode('.', $tmpchoiceid)];
                        }
                        $_G['forum_option'][$option['identifier']]['value'] = implode(' &raquo; ', $tmpidentifiervalue);
                        unset($tmpchoiceid, $tmpidentifiervalue);
                    } elseif ($option['type'] == 'image') {
                        $imgoptiondata = dunserialize($optiondata[$optionid]['value']);
                        $threadsortshow['sortaids'][] = $imgoptiondata['aid'];
                        if (empty($templatearray['viewthread'])) {
                            $maxwidth = $option['maxwidth'] ? 'width="' . $option['maxwidth'] . '"' : '';
                            $maxheight = $option['maxheight'] ? 'height="' . $option['maxheight'] . '"' : '';
                            if (!defined('IN_MOBILE')) {
                                $_G['forum_option'][$option['identifier']]['value'] = $imgoptiondata['url'] ? "<img src=\"" . $imgoptiondata['url'] . "\" onload=\"thumbImg(this)\" {$maxwidth} {$maxheight} border=\"0\">" : '';
                            } else {
                                $_G['forum_option'][$option['identifier']]['value'] = $imgoptiondata['url'] ? "<a href=\"" . $imgoptiondata['url'] . "\" target=\"_blank\">" . lang('forum/misc', 'click_view') . "</a>" : '';
                            }
                        } else {
                            $_G['forum_option'][$option['identifier']]['value'] = $imgoptiondata['url'] ? $imgoptiondata['url'] : './static/image/common/nophoto.gif';
                        }
                    } elseif ($option['type'] == 'face') {
                        $faceoptiondata = dunserialize($optiondata[$optionid]['value']);
                        $_G['forum_option'][$option['identifier']]['value'] = "forum.php?mod=attachment&aid=" . aidencode($faceoptiondata['aid']);
                        $attach = C::t('forum_attachment')->fetch($faceoptiondata['aid']);
                        $_G['forum_option'][$option['identifier']]['downloads'] = $attach['downloads'];
                        $threadsortshow['sortaids'][] = $faceoptiondata['aid'];
                    } elseif ($option['type'] == 'url') {
                        $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'] ? "<a href=\"" . $optiondata[$optionid]['value'] . "\" target=\"_blank\">" . $optiondata[$optionid]['value'] . "</a>" : '';
                    } elseif ($option['type'] == 'number') {
                        $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'];
                    } else {
                        if ($option['protect']['status'] && $optiondata[$optionid]['value']) {
                            $optiondata[$optionid]['value'] = $option['protect']['mode'] == 1 ? '<image src="' . stringtopic($optiondata[$optionid]['value']) . '">' : (!defined('IN_MOBILE') ? '<span id="sortmessage_' . $option['identifier'] . '"><a href="###" onclick="ajaxget(\'forum.php?mod=misc&action=protectsort&tid=' . $tid . '&optionid=' . $optionid . '\', \'sortmessage_' . $option['identifier'] . '\');return false;">' . lang('forum/misc', 'click_view') . '</a></span>' : $optiondata[$optionid]['value']);
                            $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'] ? $optiondata[$optionid]['value'] : $option['defaultvalue'];
                        } elseif ($option['type'] == 'textarea') {
                            $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'] ? nl2br($optiondata[$optionid]['value']) : '';
                        } else {
                            $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'] ? $optiondata[$optionid]['value'] : $option['defaultvalue'];
                        }
                    }
                } else {
                    if (empty($option['permprompt'])) {
                        $_G['forum_option'][$option['identifier']]['value'] = lang('forum/misc', 'view_noperm');
                    } else {
                        $_G['forum_option'][$option['identifier']]['value'] = $option['permprompt'];
                    }
                }
            } else {
                $_G['forum_option'][$option['identifier']]['value'] = lang('forum/misc', 'has_expired');
            }
        }
        $typetemplate = '';
        if ($templatearray['viewthread']) {
            foreach ($sortoptionarray as $option) {
                $searchtitle[] = '/{(' . $option['identifier'] . ')}/e';
                $searchvalue[] = '/\\[(' . $option['identifier'] . ')value\\]/e';
                $searchvalue[] = '/{(' . $option['identifier'] . ')_value}/e';
                $searchunit[] = '/\\[(' . $option['identifier'] . ')unit\\]/e';
                $searchunit[] = '/{(' . $option['identifier'] . ')_unit}/e';
                $searchdownloads[] = '/\\[(' . $option['identifier'] . ')downloads\\]/e';
                $searchdownloads[] = '/{(' . $option['identifier'] . ')_downloads}/e';
            }
            $threadexpiration = $sortdataexpiration ? dgmdate($sortdataexpiration) : lang('forum/misc', 'never_expired');
            $typetemplate = preg_replace(array("/\\{expiration\\}/i"), array($threadexpiration), stripslashes($templatearray['viewthread']));
            $typetemplate = preg_replace($searchtitle, "showoption('\\1', 'title')", $typetemplate);
            $typetemplate = preg_replace($searchvalue, "showoption('\\1', 'value')", $typetemplate);
            $typetemplate = preg_replace($searchunit, "showoption('\\1', 'unit')", $typetemplate);
            $typetemplate = preg_replace($searchdownloads, "showoption('\\1', 'downloads')", $typetemplate);
            $typetemplate = str_replace("{vanfon_uid}", $vanfon_uid, $typetemplate);
            $typetemplate = str_replace("{vanfon_pid}", $vanfon_tid, $typetemplate);
            $typetemplate = str_replace("{vanfon_tid}", $tid, $typetemplate);
            $typetemplate = str_replace("{vanfon_fid}", $vanfon_fid, $typetemplate);
            $typetemplate = str_replace("{vanfon_verify}", $vanfon_verify, $typetemplate);
            $typetemplate = str_replace("{vanfon_usergroup}", $vanfon_usergroup, $typetemplate);
        }
    }
    $threadsortshow['optionlist'] = !$optionexpiration ? $_G['forum_option'] : 'expire';
    $threadsortshow['typetemplate'] = $typetemplate;
    $threadsortshow['expiration'] = dgmdate($sortdataexpiration, 'd');
    return $threadsortshow;
}
Exemplo n.º 4
0
 private function _getProtectSortOptionListValue($tid, $optionid)
 {
     $value = '';
     $typeoptionvarvalue = C::t('forum_typeoptionvar')->fetch_all_by_tid_optionid($tid, $optionid);
     $typeoptionvarvalue[0]['expiration'] = $typeoptionvarvalue[0]['expiration'] && $typeoptionvarvalue[0]['expiration'] <= TIMESTAMP ? 1 : 0;
     $option = C::t('forum_typeoption')->fetch($optionid);
     if ($option['expiration'] && !$typeoptionvarvalue[0]['expiration'] || empty($option['expiration'])) {
         $protect = dunserialize($option['protect']);
         include_once libfile('function/threadsort');
         if (protectguard($protect)) {
             if (empty($option['permprompt'])) {
                 $value = lang('forum/misc', 'view_noperm');
             } else {
                 $value = $option['permprompt'];
             }
         } else {
             $value = nl2br($typeoptionvarvalue[0]['value']);
         }
     } else {
         $value = lang('forum/misc', 'has_expired');
     }
     return $value;
 }