Пример #1
0
 function update($uploaddb)
 {
     foreach ($uploaddb as $key => $value) {
         if ($value['attname'] == 'postcate' && ($value['id'] == '13' || $value['id'] == '27')) {
             $fieldname = 'pcattach';
         } else {
             $fieldname = 'field' . $value['id'];
         }
         $this->attachs[$fieldname] = $value['fileuploadurl'];
         if ($value['attname'] == 'topic') {
             $tablename = GetTopcitable($this->pcid);
         } elseif ($value['attname'] == 'postcate') {
             $tablename = GetPcatetable($this->pcid);
         }
         if ($this->attachs) {
             $this->db->update("UPDATE {$tablename} SET " . pwSqlSingle($this->attachs) . " WHERE tid=" . pwEscape($this->tid));
         }
     }
 }
Пример #2
0
 function update($uploaddb)
 {
     foreach ($uploaddb as $key => $value) {
         if ($value['id']) {
             $attach = $this->db->get_one("SELECT fieldname FROM pw_pcfield WHERE fieldid=" . S::sqlEscape($value['id']));
         }
         if ($value['attname'] == 'postcate' && $attach['fieldname'] == 'pcattach') {
             $fieldname = 'pcattach';
         } else {
             $fieldname = 'field' . $value['id'];
         }
         $this->attachs[$fieldname] = $value['fileuploadurl'];
         if ($value['attname'] == 'topic') {
             $tablename = GetTopcitable($this->pcid);
         } elseif ($value['attname'] == 'postcate') {
             $tablename = GetPcatetable($this->pcid);
         }
     }
     if ($this->attachs) {
         $this->db->update("UPDATE {$tablename} SET " . S::sqlSingle($this->attachs) . " WHERE tid=" . S::sqlEscape($this->tid));
     }
     return true;
 }
Пример #3
0
function _delPcTopic($pcdb)
{
    global $db;
    foreach ($pcdb as $key => $value) {
        $pcids = S::sqlImplode($value);
        $key = $key > 20 ? $key - 20 : 0;
        $key = (int) $key;
        $pcvaluetable = GetPcatetable($key);
        $db->update("DELETE FROM {$pcvaluetable} WHERE tid IN({$pcids})");
    }
}
Пример #4
0
 function _RecyclePcTopic($pcdb)
 {
     foreach ($pcdb as $key => $value) {
         $pcids = S::sqlImplode($value);
         $key = $key > 20 ? $key - 20 : 0;
         $pcvaluetable = GetPcatetable($key);
         $this->db->update("UPDATE {$pcvaluetable} SET ifrecycle='1' WHERE tid IN({$pcids})");
     }
 }
Пример #5
0
         if ($rt['ifsearch'] == 1) {
             $searchhtml .= getSearchHtml($rt);
         } elseif ($rt['ifasearch'] == 1) {
             $asearchhtml .= getSearchHtml($rt);
         }
     }
     $searchhtml .= '</span>';
     $asearchhtml .= '</span>';
     if (strpos($searchhtml, '</span></span>') !== false) {
         $searchhtml = str_replace('</span></span>', '</span>', $searchhtml);
     }
     if (strpos($asearchhtml, '</span></span>') !== false) {
         $asearchhtml = str_replace('</span></span>', '</span>', $asearchhtml);
     }
     $pcid = (int) $pcid;
     $pcvaluetable = GetPcatetable($pcid);
 }
 if ($step == 'search') {
     require_once R_P . 'lib/postcate.class.php';
     $searchPostcate = new postCate($field);
     if (!$newfield) {
         $newfield = StrCode(serialize($field));
     }
     list($count, $tiddb, $alltiddb) = $searchPostcate->getSearchvalue($newfield, 'one', true, true);
     is_array($tiddb) && ($sql .= " AND pv.tid IN(" . pwImplode($tiddb) . ")");
     is_array($alltiddb) && ($alltids = implode(',', $alltiddb));
 }
 if ($step != 'search' || !$count) {
     $alltiddb = $threadb = $newtiddb = array();
     $alltiddb = array();
     $query = $db->query("SELECT tid FROM {$pcvaluetable} WHERE ifrecycle=0");
Пример #6
0
    $trade = unserialize($trade['tradeinfo']);
    if (!$trade['alipay']) {
        echo 'fail';
    }
    ajax_footer();
} elseif ($action == 'pcdelimg') {
    InitGP(array('fieldname', 'pctype'));
    InitGP(array('tid', 'id'), 2);
    if (!$tid || !$id || !$fieldname || !$pctype) {
        echo 'fail';
    }
    $id = (int) $id;
    if ($pctype == 'topic') {
        $tablename = GetTopcitable($id);
    } elseif ($pctype == 'postcate') {
        $tablename = GetPcatetable($id);
    }
    $path = $db->get_value("SELECT {$fieldname} FROM {$tablename} WHERE tid=" . pwEscape($tid));
    if (strpos($path, '..') !== false) {
        return false;
    }
    $lastpos = strrpos($path, '/') + 1;
    $s_path = substr($path, 0, $lastpos) . 's_' . substr($path, $lastpos);
    if (!file_exists("{$attachpath}/{$path}")) {
        if (pwFtpNew($ftp, $db_ifftp)) {
            $ftp->delete($path);
            $ftp->delete($s_path);
            pwFtpClose($ftp);
        }
    } else {
        P_unlink("{$attachdir}/{$path}");
Пример #7
0
 function getSearchvalue($field, $type, $alltidtype = false, $backtype = false)
 {
     /*获取搜索结果*/
     global $db_perpage, $page, $pcid, $fid, $basename;
     $field = unserialize(StrCode($field, 'DECODE'));
     $sqladd = '';
     $fid && ($sqladd .= " fid=" . S::sqlEscape($fid));
     $fielddb = postCate::getFieldData($pcid, $type);
     foreach ($field as $key => $value) {
         if ($value) {
             if (in_array($fielddb[$key]['type'], array('number', 'radio', 'select'))) {
                 $sqladd .= $sqladd ? " AND " . $fielddb[$key]['fieldname'] . "=" . S::sqlEscape($value) : $fielddb[$key]['fieldname'] . "=" . S::sqlEscape($value);
             } elseif ($fielddb[$key]['type'] == 'checkbox') {
                 $checkboxs = '';
                 foreach ($value as $cv) {
                     $checkboxs .= $checkboxs ? ',' . $cv : $cv;
                 }
                 $value = '%,' . $checkboxs . ',%';
                 $sqladd .= $sqladd ? " AND " . $fielddb[$key]['fieldname'] . " LIKE(" . S::sqlEscape($value) . ")" : $fielddb[$key]['fieldname'] . " LIKE(" . S::sqlEscape($value) . ")";
             } elseif ($fielddb[$key]['type'] == 'calendar' && ($value['start'] || $value['end'])) {
                 $value['start'] && ($value['start'] = PwStrtoTime($value['start']));
                 $value['end'] && ($value['end'] = PwStrtoTime($value['end']));
                 if ($value['start'] > $value['end'] && $value['start'] && $value['end']) {
                     Showmsg('calendar_error');
                 }
                 $calendarEnd = trim(S::sqlEscape($value['end']));
                 $sqladd .= $sqladd ? " AND " . $fielddb[$key]['fieldname'] . ">=" . S::sqlEscape($value['start']) . ($calendarEnd == "''" ? '' : " AND " . $fielddb[$key]['fieldname'] . '<=' . $calendarEnd) : $fielddb[$key]['fieldname'] . ">=" . S::sqlEscape($value['start']) . ($calendarEnd == "''" ? '' : " AND " . $fielddb[$key]['fieldname'] . '<=' . $calendarEnd);
             } elseif (in_array($fielddb[$key]['type'], array('text', 'url', 'email', 'textarea'))) {
                 $value = '%' . $value . '%';
                 $sqladd .= $sqladd ? " AND " . $fielddb[$key]['fieldname'] . " LIKE(" . S::sqlEscape($value) . ")" : $fielddb[$key]['fieldname'] . " LIKE(" . S::sqlEscape($value) . ")";
             } elseif ($fielddb[$key]['type'] == 'range' && $value['min'] && $value['max']) {
                 $sqladd .= $sqladd ? " AND " . $fielddb[$key]['fieldname'] . ">=" . S::sqlEscape($value['min']) . " AND " . $fielddb[$key]['fieldname'] . "<=" . S::sqlEscape($value['max']) : $fielddb[$key]['fieldname'] . ">=" . S::sqlEscape($value['min']) . " AND " . $fielddb[$key]['fieldname'] . "<=" . S::sqlEscape($value['max']);
             } else {
                 $sqladd .= '';
             }
         }
     }
     if ($sqladd) {
         !$page && ($page = 1);
         $start = ($page - 1) * $db_perpage;
         $limit = S::sqlLimit($start, $db_perpage);
         $pcvaluetable = GetPcatetable($pcid);
         $sqladd .= $sqladd ? " AND ifrecycle=0" : " ifrecycle=0";
         $count = $this->db->get_value("SELECT COUNT(*) as count FROM {$pcvaluetable} WHERE {$sqladd}");
         $query = $this->db->query("SELECT tid FROM {$pcvaluetable} WHERE {$sqladd} {$limit}");
         while ($rt = $this->db->fetch_array($query)) {
             $tiddb[] = $rt['tid'];
         }
         if ($alltidtype) {
             $query = $this->db->query("SELECT tid FROM {$pcvaluetable} WHERE {$sqladd}");
             while ($rt = $this->db->fetch_array($query)) {
                 $alltiddb[] = $rt['tid'];
             }
         }
         !$count && ($count = -1);
     } else {
         if ($backtype) {
             adminmsg('topic_search_none', "{$basename}&action=postcate&pcid={$pcid}");
         }
         Showmsg('topic_search_none');
     }
     return array($count, $tiddb, $alltiddb);
 }
Пример #8
0
     foreach (array_keys($modeliddb) as $value) {
         if ($value != 'fid' && $value != 'tid') {
             $mSqldb[$value] = $modeliddb[$value];
         }
     }
     $mSqldb['tid'] = $newtid;
     $mSqldb['fid'] = $to_id;
     $pwSQL = S::sqlSingle($mSqldb);
     $db->update("INSERT INTO {$tablename} SET {$pwSQL}");
 }
 //分类信息处理
 //团购处理
 if ($special > 20) {
     $pcid = $special - 20;
     $pcid = (int) $pcid;
     $tablename = GetPcatetable($pcid);
     $pcdb = $mSqldb = array();
     $pcdb = $db->get_one("SELECT * FROM {$tablename} WHERE tid=" . S::sqlEscape($tid));
     foreach (array_keys($pcdb) as $value) {
         if ($value != 'fid' && $value != 'tid') {
             $mSqldb[$value] = $pcdb[$value];
         }
     }
     $mSqldb['tid'] = $newtid;
     $mSqldb['fid'] = $to_id;
     $pwSQL = S::sqlSingle($mSqldb);
     $db->update("INSERT INTO {$tablename} SET {$pwSQL}");
 }
 //团购处理
 # memcache refresh
 // $threadList = L::loadClass("threadlist", 'forum');
Пример #9
0
function RevertPcTopic($pcdb)
{
    global $db;
    foreach ($pcdb as $key => $value) {
        $pcids = S::sqlImplode($value);
        $key = $key > 20 ? $key - 20 : 0;
        $pcvaluetable = GetPcatetable($key);
        $db->update("UPDATE {$pcvaluetable} SET ifrecycle='0' WHERE tid IN({$pcids})");
    }
}
Пример #10
0
 function parseThread($tpcdb)
 {
     global $isGM, $pwSystem, $foruminfo, $forumset, $db_readdir, $viewbbs, $page, $managemode, $imgpath, $stylepath, $db_readperpage, $managecheck, $db_threademotion, $winduid, $db_anonymousname, $modelid, $pcid, $actmid, $timestamp;
     $this->analyseDataToCache($tpcdb);
     $pwAnonyHide = $isGM || $pwSystem['anonyhide'];
     $updatetop = 0;
     $threaddb = $rewids = $cyids = $replyReward = array();
     $arrStatus = array(1 => 'vote', 2 => 'active', 3 => 'reward', 4 => 'trade', 5 => 'debate');
     $attachtype = array('1' => 'img', '2' => 'txt', '3' => 'zip');
     foreach ($tpcdb as $key => $thread) {
         $foruminfo['allowhtm'] == 1 && ($htmurl = $db_readdir . '/' . $this->fid . '/' . date('ym', $thread['postdate']) . '/' . $thread['tid'] . '.html');
         $thread['tpcurl'] = "read.php?tid={$thread[tid]}{$viewbbs}" . ($page > 1 ? "&fpage={$page}" : '');
         if ($managemode == 1) {
             $thread['tpcurl'] .= '&toread=1';
         } elseif (!$foruminfo['cms'] && $foruminfo['allowhtm'] == 1 && file_exists(R_P . $htmurl)) {
             $thread['tpcurl'] = "{$htmurl}";
         }
         if ($thread['toolfield']) {
             list($t, $e, $m) = explode(',', $thread['toolfield']);
             $sqladd = '';
             if ($t && $t < $timestamp) {
                 $sqladd .= ",toolinfo='',specialsort=0,topped='0'";
                 $t = '';
                 $thread['topped'] > 0 && ($updatetop = 1);
             }
             if ($e && $e < $timestamp) {
                 $sqladd .= ",titlefont=''";
                 $thread['titlefont'] = '';
                 $e = '';
             }
             if ($m && $m < $timestamp) {
                 $sqladd .= ",specialsort=0";
                 $m = '';
                 $kmdService = L::loadClass('kmdservice', 'forum');
                 $kmdService->initKmdInfoByTid($thread['tid']);
             }
             if ($sqladd) {
                 $thread['toolfield'] = implode(',', array(0 => $t, 1 => $e, 2 => $m));
                 $this->db->update(pwQuery::buildClause("UPDATE :pw_table SET toolfield=:toolfield {$sqladd} WHERE tid=:tid", array('pw_threads', $thread['toolfield'], $thread['tid'])));
                 //* $threads = L::loadClass('Threads', 'forum');
                 //* $threads->delThreads($thread['tid']);
             }
         }
         $forumset['cutnums'] && ($thread['subject'] = substrs($thread['subject'], $forumset['cutnums']));
         $forumset['cutnums'] > 80 && ($thread['subject'] = substrs(str_replace('&nbsp;', ' ', $thread['subject']), 80));
         if ($thread['titlefont']) {
             $titledetail = explode("~", $thread['titlefont']);
             if ($titledetail[0]) {
                 $thread['subject'] = "<font color={$titledetail['0']}>{$thread['subject']}</font>";
             }
             if ($titledetail[1]) {
                 $thread['subject'] = "<b>{$thread['subject']}</b>";
             }
             if ($titledetail[2]) {
                 $thread['subject'] = "<i>{$thread['subject']}</i>";
             }
             if ($titledetail[3]) {
                 $thread['subject'] = "<u>{$thread['subject']}</u>";
             }
         }
         if ($thread['ifshield']) {
             $thread['subject'] = threadShield('shield_title');
         }
         if ($thread['ifmark']) {
             $thread['ifmark'] = $thread['ifmark'] > 0 ? "<span class='gray tpage w'>&#xFF08;+{$thread['ifmark']}&#xFF09;</span>" : "<span class='gray tpage w'>&#xFF08;{$thread['ifmark']}&#xFF09;</span>";
         } else {
             unset($thread['ifmark']);
         }
         if (isset($arrStatus[$thread['special']])) {
             $p_status = $thread['locked'] % 3 == 0 ? $arrStatus[$thread['special']] : $arrStatus[$thread['special']] . 'lock';
         } elseif ($thread['locked'] % 3 != 0) {
             $p_status = $thread['locked'] % 3 == 1 ? 'topiclock' : 'topicclose';
         } else {
             $p_status = $thread['ifmagic'] ? 'magic' : ($thread['replies'] >= 10 ? 'topichot' : 'topicnew');
         }
         if ($thread['special'] == 8 && $p_status == 'topicnew') {
             //活动帖图标展示
             $p_status = 'activity';
         }
         $thread['inspect'] && ($thread['inspect'] = explode("\t", $thread['inspect']));
         if ($thread['inspect'] && $thread['inspect'][0] == 0) {
             $thread['inspect'][0] = '主';
         }
         $thread['tooltip'] = $p_status;
         $thread['status'] = "<img src=\"{$imgpath}/{$stylepath}/thread/" . $p_status . ".gif\" align=\"absmiddle\">";
         if ($thread['special'] == 8 && $p_status == 'activity') {
             //活动帖图标展示
             $thread['status'] = "<img src=\"{$imgpath}/activity/" . $p_status . ".gif\" border=0 align=\"absmiddle\">";
         }
         $thread['topped'] && ($GLOBALS['ifsort'] = 1);
         $thread['ispage'] = '';
         if ($thread['topreplays'] + $thread['replies'] + 1 > $db_readperpage) {
             $numofpage = ceil(($thread['topreplays'] + $thread['replies'] + 1) / $db_readperpage);
             $fpage = $page > 1 ? "&fpage={$page}" : "";
             $thread['ispage'] = ' ';
             $thread['ispage'] .= "&nbsp;<img src=\"{$imgpath}/{$stylepath}/file/multipage.gif\" align=\"absmiddle\" alt=\"pages\">&nbsp;<span class=\"tpage\">";
             for ($j = 1; $j <= $numofpage; $j++) {
                 if ($j == 6 && $j + 1 < $numofpage) {
                     $thread['ispage'] .= " .. <a href=\"read.php?tid={$thread['tid']}{$fpage}&page={$numofpage}\">{$numofpage}</a>";
                     break;
                 } elseif ($j == 1) {
                     $thread['ispage'] .= "";
                     //				$thread['ispage'].=" <a href=\"read.php?tid=$thread[tid]$fpage\">$j</a>";
                 } else {
                     $thread['ispage'] .= " <a href=\"read.php?tid={$thread['tid']}{$fpage}&page={$j}\">{$j}</a>";
                 }
             }
             $thread['ispage'] .= '</span> ';
         }
         $postdetail = explode(",", $thread['lastpost']);
         if ($thread['ifupload']) {
             $atype = $attachtype[$thread['ifupload']];
             $thread['titleadd'] = " <img src=\"{$imgpath}/{$stylepath}/file/{$atype}.gif\" alt=\"{$atype}\" align=\"absmiddle\">";
         } else {
             $thread['titleadd'] = "";
         }
         /*if ($managecheck) {
         			if ($thread['fid'] == $this->fid) {
         				$thread['adminbox'] = "<input type=\"checkbox\" autocomplete=\"off\" name=\"tidarray[]\" id=tid_{$thread[tid]} value=\"$thread[tid]\" onclick=\"postManage.show('postbatch','a_ajax_{$thread[tid]}')\" />";
         			} else {
         				$thread['adminbox'] = "&nbsp;&nbsp;&nbsp;";
         			}
         		}*/
         if ($db_threademotion) {
             if ($thread['icon'] == "R" || !$thread['icon']) {
                 $thread['useriocn'] = '';
             } else {
                 $thread['useriocn'] = "<img src=\"{$imgpath}/post/emotion/{$thread['icon']}.gif\" alt=\"{$thread['icon']}\" align=\"absmiddle\"> ";
             }
         }
         if ($thread['anonymous'] && $thread['authorid'] != $winduid && !$pwAnonyHide) {
             $thread['author'] = $db_anonymousname;
             $thread['authorid'] = 0;
         }
         if ($thread['special'] == 3 && $thread['state'] < 1) {
             $rewids[] = $thread['tid'];
         }
         //获取分类信息的帖子id
         if ($modelid > 0) {
             $topicids[] = $thread['tid'];
         }
         //获取团购的帖子id
         if ($pcid > 0) {
             $postcatepcids[] = $thread['tid'];
         }
         //获取活动的帖子id
         if ($actmid > 0 || $thread['special'] == 8) {
             $activitytiddb[] = $thread['tid'];
         }
         if (getstatus($thread['tpcstatus'], 1)) {
             $cyids[] = $thread['tid'];
         }
         if (getstatus($thread['tpcstatus'], 8)) {
             $replyReward[] = $thread['tid'];
         }
         $threaddb[$thread['tid']] = $thread;
     }
     if ($rewids) {
         $rewids = S::sqlImplode($rewids);
         $query = $this->db->query("SELECT tid,cbval,caval FROM pw_reward WHERE tid IN({$rewids})");
         while ($rt = $this->db->fetch_array($query)) {
             $threaddb[$rt['tid']]['rewcredit'] = $rt['cbval'] + $rt['caval'];
         }
     }
     if ($cyids && !$cyid) {
         $query = $this->db->query("SELECT a.tid,a.cyid,c.cname FROM pw_argument a LEFT JOIN pw_colonys c ON a.cyid=c.id WHERE tid IN (" . S::sqlImplode($cyids) . ')');
         while ($rt = $this->db->fetch_array($query)) {
             $threaddb[$rt['tid']]['colony'] = $rt;
         }
     }
     if ($topicids) {
         $topicvaluetable = GetTopcitable($modelid);
         $query = $this->db->query("SELECT * FROM {$topicvaluetable} WHERE tid IN (" . S::sqlImplode($topicids) . ")");
         while ($rt = $this->db->fetch_array($query)) {
             $threaddb[$rt['tid']]['topic'] = $rt;
         }
     }
     if ($postcatepcids) {
         //团购
         $pcvaluetable = GetPcatetable($pcid);
         $query = $this->db->query("SELECT * FROM {$pcvaluetable} WHERE tid IN (" . S::sqlImplode($postcatepcids) . ")");
         while ($rt = $this->db->fetch_array($query)) {
             $threaddb[$rt['tid']]['topic'] = $rt;
         }
     }
     if ($activitytiddb) {
         //活动
         global $threadshowfield, $postActForBbs;
         $defaultValueTableName = getActivityValueTableNameByActmid();
         if ($actmid) {
             $userDefinedValueTableName = getActivityValueTableNameByActmid($actmid, 1, 1);
             $query = $this->db->query("SELECT actmid,recommend,starttime,endtime,location,contact,telephone,picture1,picture2,picture3,picture4,picture5,signupstarttime,signupendtime,minparticipant,maxparticipant,userlimit,specificuserlimit,genderlimit,fees,feesdetail,paymethod,ut.* FROM {$defaultValueTableName} dt LEFT JOIN {$userDefinedValueTableName} ut USING(tid) WHERE dt.tid IN(" . S::sqlImplode($activitytiddb) . ")");
         } else {
             $query = $this->db->query("SELECT * FROM {$defaultValueTableName} WHERE tid IN(" . S::sqlImplode($activitytiddb) . ")");
         }
         while ($rt = $this->db->fetch_array($query)) {
             if ($rt['recommend'] == 1) {
                 $threaddb[$rt['tid']]['recommendadd'] = " <img src=\"{$imgpath}/activity/actrecommend.gif\" border=0 align=\"absmiddle\" title=\"" . getLangInfo('other', 'act_recommend') . "\">";
             } else {
                 $threaddb[$rt['tid']]['recommendadd'] = "";
             }
             if ($threadshowfield) {
                 foreach ($threadshowfield as $key => $column) {
                     $i = 0;
                     $columnHtml = '';
                     foreach ($column as $field) {
                         // 如人数限制值为0,视为空
                         if (in_array($field['fieldname'], array('minparticipant', 'maxparticipant')) && $rt[$field['fieldname']] == 0) {
                             $rt[$field['fieldname']] = '';
                         }
                         if ($rt[$field['fieldname']] !== '') {
                             $names = $postActForBbs->getNamePartsByName($field['name']);
                             if ($i != 0) {
                                 $columnHtml .= ' ' . $names[0];
                             }
                             $columnHtml .= $names[1] . ' ';
                             $fieldValueHtml = $postActForBbs->getThreadFieldValueHtml($field['type'], $rt[$field['fieldname']], $field['rules'], $field['fieldname']);
                             $columnHtml .= $fieldValueHtml;
                             $columnHtml .= $names[2];
                             $columnHtml = trim($columnHtml);
                         }
                         $i++;
                     }
                     $threaddb[$rt['tid']]['topic'][$key] = $columnHtml ? $columnHtml : '';
                 }
             }
         }
     }
     if ($replyReward) {
         $replyRewardService = L::loadClass('ReplyReward', 'forum');
         /* @var $replyRewardService PW_ReplyReward */
         $replyRewardInfos = $replyRewardService->getRewardByTids($replyReward);
         foreach ($replyRewardInfos as $value) {
             $threaddb[$value['tid']]['replyrewardtip'] = '[回帖奖励' . intval($value['creditnum'] * $value['lefttimes']) . ']';
         }
     }
     if ($updatetop) {
         require_once R_P . 'require/updateforum.php';
         updatetop();
     }
     return $threaddb;
 }