Example #1
0
 function checkTableField($table, $field)
 {
     list($table, $field) = array(trim($table), trim($field));
     if (!$table || !$field) {
         return $this->buildResponse(SITE_INVALID_PARAMS);
     }
     $result = $GLOBALS['db']->get_one(sprintf('SHOW COLUMNS FROM %s LIKE %s', S::sqlMetadata($table), S::sqlEscape($field)));
     return $this->buildResponse(S::isArray($result) ? 0 : 1);
 }
 function _logDelta($tableName, $ids, $state)
 {
     if (!S::isArray($ids)) {
         return false;
     }
     $_tmp = array();
     foreach ($ids as $id) {
         $_tmp[] = array('id' => $id, 'state' => $state);
     }
     $GLOBALS['db']->update("REPLACE INTO " . S::sqlMetadata($tableName) . " (id,state) VALUES " . S::sqlMulti($_tmp));
 }
Example #3
0
 function shieldPost($pid, $tid)
 {
     list($pid, $tid) = array(intval($pid), intval($tid));
     if ($pid < 1 || $tid < 1) {
         return $this->buildResponse(POST_INVALID_PARAMS);
     }
     $postTable = GetPtable('N', $tid);
     $GLOBALS['db']->query("UPDATE " . S::sqlMetadata($postTable) . " SET ifshield=1 WHERE pid=" . S::sqlEscape($pid));
     $bool = $GLOBALS['db']->affected_rows();
     return $this->buildResponse($bool == 1 ? 0 : 1);
 }
Example #4
0
 /**
  * 获取数据
  * @param $table
  * @param $start
  * @param $num
  */
 function _selectData($table, $start, $num)
 {
     list($start, $num) = array(intval($start), intval($num));
     $sqlLimit = S::sqlLimit($start, $num);
     $query = $this->db->query('SELECT * FROM ' . S::sqlMetadata($table) . $sqlLimit);
     $fieldNum = $this->db->num_fields($query);
     return array($query, $fieldNum);
 }
Example #5
0
L::loadClass('forum', 'forum', false);
require_once R_P . 'require/bbscode.php';
//* include_once pwCache::getPath(D_P.'data/bbscache/cache_read.php',true);
pwCache::getData(D_P . 'data/bbscache/cache_read.php');
S::gp(array('tid'));
if (Perf::checkMemcache()) {
    $_cacheService = Perf::getCacheService();
    $_thread = $_cacheService->get('thread_tid_' . $tid);
    $_thread && ($_tmsg = $_cacheService->get('thread_tmsg_tid_' . $tid));
    $read = $_thread && $_tmsg ? array_merge($_thread, $_tmsg) : false;
    if (!$read) {
        $_cacheService = Perf::gatherCache('pw_threads');
        $read = $page > 1 ? $_cacheService->getThreadByThreadId($tid) : $_cacheService->getThreadAndTmsgByThreadId($tid);
    }
} else {
    $read = $db->get_one("SELECT t.* ,tm.* FROM pw_threads t LEFT JOIN " . S::sqlMetadata(GetTtable($tid)) . " tm ON t.tid=tm.tid WHERE t.tid=" . S::sqlEscape($tid));
}
!$read && Showmsg('illegal_tid');
$postdate = get_date($read['postdate'], 'Y-m-d');
list($fid, $ptable, $ifcheck, $openIndex, $topped_count, $subject, $authorid, $author) = array($read['fid'], $read['ptable'], $read['ifcheck'], getstatus($read['tpcstatus'], 2), $read['topreplays'], $read['subject'], $read['authorid'], $read['author']);
$pw_posts = GetPtable($ptable);
$pwforum = new PwForum($fid);
if (!$pwforum->isForum()) {
    Showmsg('data_error');
}
$foruminfo =& $pwforum->foruminfo;
$forumset =& $pwforum->forumset;
if (!S::inArray($windid, $manager)) {
    $pwforum->forumcheck($winddb, $groupid);
}
if (!$foruminfo['allowvisit'] && $_G['allowread'] == 0 && $_COOKIE) {
Example #6
0
 function sendMobilePost($tid, $uid, $title, $content, $mobileType)
 {
     list($code, $data) = $this->sendPost($tid, $uid, $title, $content);
     if ($code) {
         return $this->buildResponse($code, $data);
     }
     $postTable = GetPtable('N', $tid);
     $GLOBALS['db']->query(sprintf("UPDATE %s SET frommob = %s WHERE pid = %s", S::sqlMetadata($postTable), intval($mobileType), S::sqlEscape($data['pid'])));
     return $this->buildResponse($code, $data);
 }
Example #7
0
 /**
  * 组装单条 key=value 形式的SQL查询语句值 insert/update
  * @param $array
  * @param $strip
  * @return string
  */
 function sqlSingle($array, $strip = true)
 {
     if (!S::isArray($array)) {
         return '';
     }
     // modified@2010-7-2
     $array = S::sqlEscape($array, $strip, true);
     $str = '';
     foreach ($array as $key => $val) {
         $str .= ($str ? ', ' : ' ') . S::sqlMetadata($key) . '=' . $val;
     }
     return $str;
 }
Example #8
0
} elseif ($pctype == 'postcate') {
    $tablename = GetPcatetable($id);
    $fieldTable = 'pw_pcfield';
}
$fieldname = $db->get_value("SELECT fieldname FROM {$fieldTable} WHERE fieldid=" . S::sqlEscape($fieldid));
if (!$tablename || !$fieldname) {
    echo 'fail';
    ajax_footer();
}
$path = $db->get_value("SELECT " . S::sqlMetadata($fieldname) . " FROM " . S::sqlMetadata($tablename) . " WHERE tid=" . S::sqlEscape($tid));
if (strpos($path, '..') !== false) {
    echo 'fail';
    ajax_footer();
}
$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}");
    if (file_exists("{$attachdir}/{$s_path}")) {
        P_unlink("{$attachdir}/{$s_path}");
    }
}
$db->update("UPDATE " . S::sqlMetadata($tablename) . " SET " . S::sqlMetadata($fieldname) . "='' WHERE tid=" . S::sqlEscape($tid));
echo 'success';
ajax_footer();
Example #9
0
         Perf::gatherInfo('changeThreadListWithThreadIds', array('tid' => $tstart + 1));
         if ($end < $tend) {
             $step++;
             $end++;
             $j_url = "{$basename}&action={$action}&step={$step}&tstart={$end}&tend={$tend}&tfrom={$tfrom}&tto={$tto}&lines={$lines}";
             adminmsg('table_change', EncodeUrl($j_url), 2);
         } else {
             //* $_cache = getDatastore();
             //* $_cache->flush();
             $_cacheService = perf::gatherCache('pw_membersdbcache');
             $_cacheService->flush();
             if (Perf::checkMemcache()) {
                 $_cacheService = L::loadClass('cacheservice', 'utility');
                 $_cacheService->flush(PW_CACHE_MEMCACHE);
             }
             $db->query('OPTIMIZE TABLE ' . S::sqlMetadata($ftable));
             adminmsg('operate_success');
         }
     }
 } elseif ($action == 'movetmsg') {
     S::gp(array('step', 'id'));
     $tlistdb = $db_tlist;
     if (!$step) {
         $id < 1 && ($id = '');
         $pw_tmsgs = 'pw_tmsgs' . ($id > 0 ? intval($id) : '');
         @extract($db->get_one("SELECT MIN(tid) AS tmin,MAX(tid) AS tmax FROM {$pw_tmsgs}"));
         list($tidmin, $tidmax) = maxmin($id);
         $tiderror = '';
         $tmin <= $tidmin && ($tiderror .= "{$tmin} - " . ($tmax > $tidmin ? $tidmin : $tmax) . " &nbsp;&nbsp;");
         $tidmax && $tmax > $tidmax && ($tiderror .= $tidmax + 1 . " - {$tmax}");
         $tiderror == '' && adminmsg('operate_undefined');
 /**
  * 私用解析排序语句
  * @param $orderBy
  */
 function _parseOrderBy($orderBy)
 {
     if (!$orderBy) {
         return '';
     }
     $orderBy = is_array($orderBy) ? $orderBy : array($orderBy);
     $sql = " ORDER BY ";
     foreach ($orderBy as $field => $sort) {
         if (!in_array(strtolower($sort), array(PW_DESC, PW_ASC))) {
             continue;
         }
         $sql .= S::sqlMetadata($field) . " " . $sort . ",";
     }
     $sql = rtrim($sql, ',');
     return $sql;
 }