Exemplo n.º 1
0
                 $subtypedb[] = array('fid' => $fid, 'name' => $v, 'vieworder' => $new_t_sub_view_db[$key][$k], 'upid' => $key);
             }
         }
         if ($subtypedb) {
             $db->update("REPLACE INTO pw_topictype (fid,name,vieworder,upid) VALUES " . pwSqlMulti($subtypedb));
         }
         require_once R_P . 'admin/cache.php';
         if ($addtpctype != $forumset['addtpctype']) {
             $forumset['addtpctype'] = $addtpctype;
             $forumset = serialize($forumset);
             if ($foruminfo['fid']) {
                 $db->update('UPDATE pw_forumsextra SET forumset=' . pwEscape($forumset) . ' WHERE fid=' . pwEscape($fid));
             } else {
                 $db->update('INSERT INTO pw_forumsextra SET ' . pwSqlSingle(array('fid' => $fid, 'forumset' => $forumset)));
             }
             updatecache_forums($fid);
         }
         $foruminfo = L::forum($fid);
         if ($t_type != $foruminfo['t_type']) {
             $db->update("UPDATE pw_forums SET " . pwSqlSingle(array('t_type' => $t_type)));
         }
         updatecache_f();
         refreshto("forumcp.php?action=edit&type=f_type&fid={$fid}", 'operate_success');
     }
 } elseif ($type == 'reward') {
     InitGP(array('starttime', 'endtime', 'username'));
     InitGP(array('page'), 'GP', 2);
     $page < 1 && ($page = 1);
     $limit = "LIMIT " . ($page - 1) * $db_perpage . ",{$db_perpage}";
     $sql = $url_a = '';
     $_POST['starttime'] && ($starttime = PwStrtoTime($starttime));
Exemplo n.º 2
0
function updatecommend($fid, $forumset)
{
    global $db, $timestamp;
    $forumset['commendnum'] < 1 && ($forumset['commendnum'] = 10);
    $commend = array();
    $commendlist = '';
    if ($forumset['commendlist']) {
        $commendlist = pwImplode(explode(',', $forumset['commendlist']));
        $query = $db->query("SELECT tid,authorid,author,subject FROM pw_threads WHERE tid IN({$commendlist}) AND fid=" . pwEscape($fid));
        while ($rt = $db->fetch_array($query)) {
            if ($forumset['commendlength'] && strlen($rt['subject']) > $forumset['commendlength']) {
                $rt['subject'] = substrs($rt['subject'], $forumset['commendlength']);
            }
            $commend[] = $rt;
        }
    }
    $count = count($commend);
    if ($forumset['autocommend'] && $count < $forumset['commendnum']) {
        $limit = pwLimit($forumset['commendnum'] - $count);
        switch ($forumset['autocommend']) {
            case '1':
                $orderby = 'postdate';
                break;
            case '2':
                $orderby = 'lastpost';
                break;
            case '3':
                $orderby = 'hits';
                break;
            case '4':
                $orderby = 'replies';
                break;
            default:
                $orderby = 'digest';
                break;
        }
        $sql = $forumset['commendlist'] ? " AND tid NOT IN({$commendlist})" : '';
        $query = $db->query("SELECT tid,authorid,author,subject FROM pw_threads WHERE fid=" . pwEscape($fid) . " AND topped='0' {$sql} ORDER BY {$orderby} DESC {$limit}");
        while ($rt = $db->fetch_array($query)) {
            if ($forumset['commendlength'] && strlen($rt['subject']) > $forumset['commendlength']) {
                $rt['subject'] = substrs($rt['subject'], $forumset['commendlength']);
            }
            $commend[] = $rt;
        }
    }
    $forumset['ifcommend'] = $timestamp;
    $forumsetdb = addslashes(serialize($forumset));
    $commend = $commend ? addslashes(serialize($commend)) : '';
    $db->update("UPDATE pw_forumsextra" . " SET " . pwSqlSingle(array('forumset' => $forumsetdb, 'commend' => $commend)) . ' WHERE fid=' . pwEscape($fid));
    require_once R_P . 'admin/cache.php';
    updatecache_forums($fid);
}
Exemplo n.º 3
0
function updatetop()
{
    global $db, $timestamp;
    if ($timestamp) {
        $db->update("DELETE FROM pw_poststopped WHERE pid = '0' AND fid != '0' AND overtime != '0' AND overtime < {$timestamp} ");
    }
    $fids = array();
    $query = $db->query("SELECT t.* FROM pw_poststopped t WHERE t.pid = '0' AND t.fid != '0' ");
    $fids = array();
    while ($rt = $db->fetch_array($query)) {
        $fids[$rt['fid']]['topthreads'] .= $fids[$rt['fid']]['topthreads'] ? ',' . $rt['tid'] : $rt['tid'];
        if ($rt['uptime'] == $rt['fid']) {
            $fids[$rt['fid']]['top1']++;
        } else {
            $fids[$rt['fid']]['top2']++;
        }
    }
    //update kmd threads
    $kmdService = L::loadClass('kmdservice', 'forum');
    $kmdInfo = $kmdService->getKmdInfosByStatus(KMD_THREAD_STATUS_OK);
    if (is_array($kmdInfo)) {
        $kmdTids = array();
        foreach ($kmdInfo as $v) {
            if (!$v['tid'] || !$v['fid']) {
                continue;
            }
            $kmdTids[$v['fid']][$v['tid']] = null;
        }
        foreach ($kmdTids as $fid => $v) {
            $fids[$fid]['topthreads'] .= $fids[$fid] ? ',' . implode(',', array_keys($v)) : implode(',', array_keys($v));
        }
    }
    //* $db->update("UPDATE pw_forumdata SET top1 = '', top2 = '' , topthreads = '' ");
    pwQuery::update('pw_forumdata', null, null, array('top1' => '', 'top2' => '', 'topthreads' => ''));
    $_fids = array();
    foreach ($fids as $key => $value) {
        if (is_array($value)) {
            $_fids[] = $key;
            //* $db->update("UPDATE pw_forumdata SET  " . S::sqlSingle($value) . " WHERE fid =  ".S::sqlEscape($key));
            pwQuery::update('pw_forumdata', 'fid=:fid', array($key), $value);
        }
    }
    if (!empty($_fids)) {
        require_once R_P . 'admin/cache.php';
        $_fids = S::sqlEscape($_fids);
        updatecache_forums($_fids);
    }
}
Exemplo n.º 4
0
 function alterName($uid, $oldname, $username)
 {
     global $db_plist;
     //$this->db->update("UPDATE pw_threads SET author=" . S::sqlEscape($username) . " WHERE authorid=" . S::sqlEscape($uid));
     pwQuery::update('pw_threads', 'authorid=:authorid', array($uid), array('author' => $username));
     $ptable_a = array('pw_posts');
     if ($db_plist && count($db_plist) > 1) {
         foreach ($db_plist as $key => $val) {
             if ($key == 0) {
                 continue;
             }
             $ptable_a[] = 'pw_posts' . $key;
         }
     }
     foreach ($ptable_a as $val) {
         //$this->db->update("UPDATE $val SET author=" . S::sqlEscape($username) . " WHERE authorid=" . S::sqlEscape($uid));
         pwQuery::update($val, 'authorid=:authorid', array($uid), array('author' => $username));
     }
     //* $this->db->update("UPDATE pw_cmembers SET username="******" WHERE uid=" . S::sqlEscape($uid));
     pwQuery::update('pw_cmembers', 'uid=:uid', array($uid), array('username' => $username));
     $this->db->update("UPDATE pw_area_level SET username="******" WHERE uid=" . S::sqlEscape($uid));
     //* $this->db->update("UPDATE pw_colonys SET admin=" . S::sqlEscape($username) . " WHERE admin=" . S::sqlEscape($oldname));
     pwQuery::update('pw_colonys', 'admin=:admin', array($oldname), array('admin' => $username));
     //* $this->db->update("UPDATE pw_announce SET author=" . S::sqlEscape($username) . " WHERE author=" . S::sqlEscape($oldname));
     pwQuery::update('pw_announce', 'author=:author', array($oldname), array('author' => $username));
     //$this->db->update("UPDATE pw_medalslogs SET awardee=" . S::sqlEscape($username) . " WHERE awardee=" . S::sqlEscape($oldname));
     $upfid = array();
     $query = $this->db->query("SELECT fid,forumadmin,fupadmin FROM pw_forums WHERE forumadmin LIKE " . S::sqlEscape("%,{$oldname},%", false) . " OR fupadmin LIKE " . S::sqlEscape("%,{$oldname},%", false));
     while ($rt = $this->db->fetch_array($query)) {
         $rt['forumadmin'] = str_replace(",{$oldname},", ",{$username},", $rt['forumadmin']);
         $rt['fupadmin'] = str_replace(",{$oldname},", ",{$username},", $rt['fupadmin']);
         //$this->db->update("UPDATE pw_forums SET forumadmin=" . S::sqlEscape($rt['forumadmin'], false) . ",fupadmin=" . S::sqlEscape($rt['fupadmin'], false) . " WHERE fid=" . S::sqlEscape($rt['fid'], false));
         pwQuery::update('pw_forums', 'fid=:fid', array($rt['fid']), array('forumadmin' => $rt['forumadmin'], 'fupadmin' => $rt['fupadmin']));
         $upfid[] = $rt['fid'];
     }
     if ($upfid) {
         require_once R_P . 'admin/cache.php';
         updatecache_forums($upfid);
     }
 }
Exemplo n.º 5
0
function updatecache_fd($cacheforums = true)
{
    global $db;
    $db->update("UPDATE pw_forums SET childid='0'");
    $havechild = $updatefids = array();
    $fup_a = array(0 => '');
    $query = $db->query("SELECT fid,fup,type,forumadmin,fupadmin FROM pw_forums ORDER BY type");
    while ($rt = $db->fetch_array($query)) {
        if ($rt['fup'] > 0) {
            $havechild[$rt['fup']] = 1;
        }
        $fupadmin = $fup_a[$rt['fup']];
        if ($rt['fupadmin'] != $fupadmin) {
            $db->update("UPDATE pw_forums SET fupadmin=" . pwEscape($fupadmin) . " WHERE fid=" . pwEscape($rt['fid']));
            $updatefids[] = $rt['fid'];
        }
        if ($rt['forumadmin'] = trim($rt['forumadmin'], ',')) {
            $fupadmin .= $fupadmin ? $rt['forumadmin'] . ',' : ',' . $rt['forumadmin'] . ',';
        }
        $fup_a[$rt['fid']] = $fupadmin;
    }
    if ($havechild) {
        $havechilds = array_keys($havechild);
        $updatefids = array_merge($updatefids, $havechilds);
        $db->update("UPDATE pw_forums SET childid='1' WHERE fid IN(" . pwImplode($havechilds, false) . ")");
    }
    if ($cacheforums === true && $updatefids) {
        updatecache_forums($updatefids);
    }
}
Exemplo n.º 6
0
 function updateForumsextra()
 {
     if ($this->forum->foruminfo['commend']) {
         $commend = $this->forum->foruminfo['commend'];
         $ifchange = 0;
         foreach ($commend as $key => $value) {
             if ($value['tid'] == $this->tid && $value['subject'] != $this->data['title']) {
                 $commend[$key]['subject'] = $this->data['title'];
                 $ifchange = 1;
             }
         }
         if ($ifchange) {
             $this->db->update("UPDATE pw_forumsextra SET commend = " . pwEscape(serialize($commend)) . " WHERE fid=" . $this->forum->fid);
             require_once R_P . 'admin/cache.php';
             updatecache_forums($this->forum->fid);
         }
     }
 }
Exemplo n.º 7
0
/**
 * 更新数据库与缓存文件
 * @param $forumset
 */
function updateForumset($forumset)
{
    global $db;
    foreach ($forumset as $k => $v) {
        $rs = $db->get_value('SELECT forumset FROM pw_forumsextra WHERE fid=' . pwEscape($k));
        if (empty($rs)) {
            $db->update('REPLACE INTO pw_forumsextra (fid,forumset) VALUES (' . pwEscape($k) . ',' . pwEscape(serialize($v)) . ')');
        } else {
            $forumsets = array_merge(unserialize($rs), $v);
            $db->update('UPDATE pw_forumsextra SET forumset=' . pwEscape(serialize($forumsets)) . ' WHERE fid=' . pwEscape($k));
        }
    }
    updatecache_forums(array_keys($forumset));
}
Exemplo n.º 8
0
function updatetop()
{
    global $db;
    global $timestamp;
    if ($timestamp) {
        $db->update("DELETE FROM pw_poststopped WHERE pid = '0' AND fid != '0' AND overtime != '0' AND overtime < {$timestamp} ");
    }
    $fids = array();
    $query = $db->query("SELECT t.* FROM pw_poststopped t WHERE t.pid = '0' AND t.fid != '0' ");
    $fids = array();
    while ($rt = $db->fetch_array($query)) {
        $fids[$rt['fid']]['topthreads'] .= $fids[$rt['fid']]['topthreads'] ? ',' . $rt['tid'] : $rt['tid'];
        if ($rt['uptime'] == $rt['fid']) {
            $fids[$rt['fid']]['top1']++;
        } else {
            $fids[$rt['fid']]['top2']++;
        }
    }
    $db->update("UPDATE pw_forumdata SET top1 = '', top2 = '' , topthreads = '' ");
    $_fids = array();
    foreach ($fids as $key => $value) {
        if (is_array($value)) {
            $_fids[] = $key;
            $db->update("UPDATE pw_forumdata SET  " . pwSqlSingle($value) . " WHERE fid =  " . pwEscape($key));
        }
    }
    if (!empty($_fids)) {
        require_once R_P . 'admin/cache.php';
        $_fids = pwEscape($_fids);
        updatecache_forums($_fids);
    }
}
Exemplo n.º 9
0
function updatecache_fd($cacheforums = true)
{
    global $db;
    $childfid = $havechild = $updatefids = array();
    $query = $db->query("SELECT fid FROM pw_forums WHERE childid=1");
    while ($rt = $db->fetch_array($query)) {
        $childfid[] = $rt['fid'];
    }
    $fup_a = array(0 => '');
    $query = $db->query("SELECT fid,fup,type,forumadmin,fupadmin FROM pw_forums ORDER BY type");
    while ($rt = $db->fetch_array($query)) {
        $rt['fup'] > 0 && ($havechild[$rt['fup']] = 1);
        $fupadmin = $fup_a[$rt['fup']];
        if ($rt['fupadmin'] != $fupadmin) {
            //$db->update("UPDATE pw_forums SET fupadmin=" . S::sqlEscape($fupadmin) . " WHERE fid=" . S::sqlEscape($rt['fid']));
            pwQuery::update('pw_forums', 'fid=:fid', array($rt['fid']), array('fupadmin' => $fupadmin));
            $updatefids[] = $rt['fid'];
        }
        if ($rt['forumadmin'] = trim($rt['forumadmin'], ',')) {
            $fupadmin .= $fupadmin ? $rt['forumadmin'] . ',' : ',' . $rt['forumadmin'] . ',';
        }
        $fup_a[$rt['fid']] = $fupadmin;
    }
    $havechild = array_keys($havechild);
    $fids = array_diff($childfid, $havechild);
    if ($fids) {
        //$db->update("UPDATE pw_forums SET childid='0' WHERE fid IN(".S::sqlImplode($fids,false).")");
        pwQuery::update('pw_forums', 'fid IN(:fid)', array($fids), array('childid' => 0));
    }
    $fids = array_diff($havechild, $childfid);
    if ($fids) {
        $updatefids = array_merge($updatefids, $fids);
        //$db->update("UPDATE pw_forums SET childid='1' WHERE fid IN(".S::sqlImplode($fids,false).")");
        pwQuery::update('pw_forums', 'fid IN (:fid)', array($fids), array('childid' => '1'));
    }
    if ($cacheforums === true && $updatefids) {
        $updatefids = array_unique($updatefids);
        updatecache_forums($updatefids);
    }
}