本文整理汇总了PHP中spdb_select函数的典型用法代码示例。如果您正苦于以下问题:PHP spdb_select函数的具体用法?PHP spdb_select怎么用?PHP spdb_select使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了spdb_select函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sp_cron_remove_users
function sp_cron_remove_users()
{
require_once ABSPATH . 'wp-admin/includes/user.php';
# make sure auto removal is enabled
$sfuser = sp_get_option('sfuserremoval');
if ($sfuser['sfuserremove']) {
# see if removing users with no posts
if ($sfuser['sfusernoposts']) {
$users = spdb_select('set', 'SELECT ' . SFUSERS . '.ID FROM ' . SFUSERS . '
JOIN ' . SFMEMBERS . ' on ' . SFUSERS . '.ID = ' . SFMEMBERS . '.user_id
LEFT JOIN ' . SFWPPOSTS . ' ON ' . SFUSERS . '.ID = ' . SFWPPOSTS . '.post_author
WHERE user_registered < DATE_SUB(NOW(), INTERVAL ' . $sfuser['sfuserperiod'] . ' DAY)
AND post_author IS NULL
AND posts < 1');
if ($users) {
foreach ($users as $user) {
wp_delete_user($user->ID);
}
}
}
# see if removing inactive users
if ($sfuser['sfuserinactive']) {
$users = spdb_table(SFMEMBERS, 'lastvisit < DATE_SUB(NOW(), INTERVAL ' . $sfuser['sfuserperiod'] . ' DAY)');
if ($users) {
foreach ($users as $user) {
wp_delete_user($user->user_id);
}
}
}
} else {
wp_clear_scheduled_hook('sph_cron_user');
}
do_action('sph_remove_users_cron');
}
示例2: spa_get_log_data
function spa_get_log_data()
{
$sflog = array();
$sql = '
SELECT install_date, release_type, version, build, display_name
FROM ' . SFLOG . '
JOIN ' . SFMEMBERS . ' ON ' . SFLOG . '.user_id=' . SFMEMBERS . '.user_id
ORDER BY id DESC;';
$sflog = spdb_select('set', $sql, ARRAY_A);
return $sflog;
}
示例3: sp_rebuild_table_list
function sp_rebuild_table_list()
{
global $tables;
sp_delete_option('installed_tables');
$t = array();
foreach ($tables as $table => $data) {
$found = spdb_select('var', "SHOW TABLES LIKE '{$table}'");
if ($found) {
$t[] = $table;
}
}
sp_add_option('installed_tables', $t);
}
示例4: sp_update_users_newposts
function sp_update_users_newposts()
{
global $spThisUser;
# Check the users checktime against the last post timestamp to see if we need to do this
$checkTime = spdb_zone_mysql_checkdate($spThisUser->checktime);
$postTime = sp_get_option('poststamp');
if (strtotime($checkTime) > strtotime($postTime) && !isset($_GET['mark-read'])) {
return;
}
# so there must have been a new post since the last page load for this user
$newPostList = $spThisUser->newposts;
if (empty($newPostList['topics'])) {
# clean it up to be on the safe side
unset($newPostList);
$newPostList = array();
$newPostList['topics'] = array();
$newPostList['forums'] = array();
}
# create new holding array and new checktime (now)
$addPostList = array();
$addPostList['topics'] = array();
$addPostList['forums'] = array();
sp_set_server_timezone();
$newCheckTime = sp_apply_timezone(time(), 'mysql');
# Use the current checktime for any new posts since users session began
$records = spdb_select('set', "SELECT DISTINCT topic_id, forum_id FROM " . SFPOSTS . "\n\t\t\t\t\t\t\t\t WHERE post_status = 0 AND post_date > '" . $checkTime . "' AND user_id != " . $spThisUser->ID . "\n\t\t\t\t\t\t\t\t ORDER BY post_id DESC LIMIT " . $spThisUser->unreadposts . ";", ARRAY_A);
if ($records) {
foreach ($records as $r) {
if (sp_get_auth('view_forum', $r['forum_id']) && !in_array($r['topic_id'], $newPostList['topics'])) {
$addPostList['topics'][] = $r['topic_id'];
$addPostList['forums'][] = $r['forum_id'];
}
}
}
$addPostList = apply_filters('sph_new_post_list', $addPostList, $newPostList);
# now merge the arrays and truncate if necessary
$newPostList['topics'] = array_merge($addPostList['topics'], $newPostList['topics']);
$newPostList['forums'] = array_merge($addPostList['forums'], $newPostList['forums']);
if (count($newPostList['topics']) > $spThisUser->unreadposts) {
array_splice($newPostList['topics'], $spThisUser->unreadposts);
array_splice($newPostList['forums'], $spThisUser->unreadposts);
}
# update sfmembers - do it here to ensure both are updated together
spdb_query("UPDATE " . SFMEMBERS . " SET newposts='" . serialize($newPostList) . "', checktime='" . $newCheckTime . "' WHERE user_id=" . $spThisUser->ID);
$spThisUser->newpostlist = true;
$spThisUser->checktime = $newCheckTime;
$spThisUser->newposts = $newPostList;
}
示例5: sp_setup_globals
function sp_setup_globals()
{
global $spGlobals, $current_user, $spBootCache, $spMeta, $spDevice;
if ($spBootCache['globals'] == true) {
return;
}
# Main admin options
$spGlobals['admin'] = sp_get_option('sfadminsettings');
$spGlobals['lockdown'] = sp_get_option('sflockdown');
$spGlobals['editor'] = 0;
# Display array
$spGlobals['display'] = sp_get_option('sfdisplay');
# Current theme data
$spGlobals['theme'] = sp_get_current_sp_theme();
# if mobile device then force integrated editor toolbar to on
if ($spDevice == 'mobile' || $spDevice == 'tablet') {
$spGlobals['display']['editor']['toolbar'] = true;
if ($spDevice == 'mobile') {
$spGlobals['mobile-display'] = sp_get_option('sp_mobile_theme');
} else {
$spGlobals['mobile-display'] = sp_get_option('sp_tablet_theme');
}
}
# Load up sfmeta
$spMeta = spdb_table(SFMETA, 'autoload=1');
if (!empty($spMeta)) {
foreach ($spMeta as $s) {
if (!empty($s)) {
$spGlobals[$s->meta_type][$s->meta_key] = maybe_unserialize($s->meta_value);
}
}
}
# create topic/post cache if found to be missing!
if (!isset($spGlobals['topic_cache']['new']) || empty($spGlobals['topic_cache']['new'])) {
$spGlobals['topic_cache']['new'] = sp_rebuild_topic_cache();
}
# Pre-define a few others
$spGlobals['canonicalurl'] = false;
# set up array of disabled forums
$spGlobals['disabled_forums'] = spdb_select('col', 'SELECT forum_id FROM ' . SFFORUMS . ' WHERE forum_disabled=1', ARRAY_A);
$spBootCache['globals'] = true;
}
示例6: sp_rebuild_topic_cache
function sp_rebuild_topic_cache()
{
$size = sp_get_option('topic_cache');
if (!isset($size) || $size == 0) {
sp_add_option('topic_cache', 200);
}
$sql = "SELECT DISTINCTROW forum_id, topic_id, post_id, post_status\n\t\t\tFROM " . SFPOSTS . "\n\t\t\tORDER BY post_id DESC\n\t\t\tLIMIT {$size}";
$topics = spdb_select('set', $sql, ARRAY_N);
if ($topics) {
sp_add_sfmeta('topic_cache', 'new', $topics, true);
}
# Delete group level cache for good measure
spdb_query("DELETE FROM " . SFCACHE . " WHERE cache_id LIKE '%*group'");
return $topics;
}
示例7: sp_topicview_query
//.........这里部分代码省略.........
}
$records = $spdb->select();
$t = array();
if ($records) {
$tidx = $topicid;
$pidx = 0;
$r = current($records);
if (sp_get_auth('view_forum', $r->forum_id)) {
$this->topicViewStatus = 'data';
# construct the parent topic object
$t[$tidx] = new stdClass();
$t[$tidx]->topic_id = $r->topic_id;
$t[$tidx]->forum_id = $r->forum_id;
$t[$tidx]->group_id = $r->group_id;
$t[$tidx]->forum_name = sp_filter_title_display($r->forum_name);
$t[$tidx]->topic_name = sp_filter_title_display($r->topic_name);
$t[$tidx]->topic_slug = $r->topic_slug;
$t[$tidx]->topic_opened = $r->topic_opened;
$t[$tidx]->forum_status = $r->forum_status;
$t[$tidx]->topic_pinned = $r->topic_pinned;
$t[$tidx]->forum_disabled = $r->forum_disabled;
$t[$tidx]->forum_slug = $r->forum_slug;
$t[$tidx]->forum_rss_private = $r->forum_rss_private;
$t[$tidx]->topic_permalink = sp_build_url($r->forum_slug, $r->topic_slug, 1, 0);
$t[$tidx]->topic_status = $r->topic_status;
$t[$tidx]->topic_icon = sanitize_file_name($r->topic_icon);
$t[$tidx]->rss = '';
$t[$tidx]->editmode = 0;
$t[$tidx]->tools_flag = 1;
$t[$tidx]->display_page = $this->topicPage;
$t[$tidx]->posts_per_page = $ppaged;
$t[$tidx]->unread = 0;
# user calc_rows and nor post_count as - for example - some posts may be hiodden by choice.
$t[$tidx]->post_count = spdb_select('var', 'SELECT FOUND_ROWS()');
# Can the user create new topics or should we lock the forum?
$t[$tidx]->start_topics = sp_get_auth('start_topics', $r->forum_id);
$t[$tidx]->reply_topics = sp_get_auth('reply_topics', $r->forum_id);
$t[$tidx]->reply_own_topics = sp_get_auth('reply_own_topics', $r->forum_id);
# grab topic start info
$t[$tidx]->topic_starter = $r->topic_starter;
$totalPages = $r->post_count / $ppaged;
if (!is_int($totalPages)) {
$totalPages = intval($totalPages) + 1;
}
$t[$tidx]->total_pages = $totalPages;
if ($setSort xor $reverse) {
if ($cPage == 1) {
$lastpage = true;
}
} else {
if ($cPage == $totalPages) {
$lastpage = true;
}
}
$t[$tidx]->last_page = $lastpage;
$t[$tidx] = apply_filters('sph_topicview_topic_record', $t[$tidx], $r);
reset($records);
unset($r);
# now loop through the post records
$newPostFlag = false;
$firstPostPage = 1;
$pinned = 0;
# define post id and post user id arrays for plugins to use in combined filter
$p = array();
$u = array();
foreach ($records as $r) {
示例8: sp_esc_int
}
if ($action == 'del_specialrank') {
$key = sp_esc_int($_GET['key']);
$specialRank = sp_get_sfmeta('special_rank', false, $key);
# remove members rank first
spdb_query('DELETE FROM ' . SFSPECIALRANKS . ' WHERE special_rank="' . $specialRank[0]['meta_key'] . '"');
# remove the forum rank
$sql = 'DELETE FROM ' . SFMETA . " WHERE meta_type='special_rank' AND meta_id='{$key}'";
spdb_query($sql);
}
if ($action == 'show') {
$key = sp_esc_int($_GET['key']);
$specialRank = sp_get_sfmeta('special_rank', false, $key);
$users = spdb_select('col', 'SELECT display_name
FROM ' . SFSPECIALRANKS . '
JOIN ' . SFMEMBERS . ' ON ' . SFSPECIALRANKS . '.user_id = ' . SFMEMBERS . '.user_id
WHERE special_rank = "' . $specialRank[0]['meta_key'] . '"
ORDER BY display_name');
echo '<fieldset class="sfsubfieldset">';
echo '<legend>' . spa_text('Special Rank Members') . '</legend>';
if ($users) {
echo '<ul class="memberlist">';
for ($x = 0; $x < count($users); $x++) {
echo '<li>' . sp_filter_name_display($users[$x]) . '</li>';
}
echo '</ul>';
} else {
spa_etext('No users with this special rank');
}
echo '</fieldset>';
}
示例9: sp_listview_populate_newposts
function sp_listview_populate_newposts($topicIds)
{
global $spThisUser;
$newList = array();
# First filter topics by those in the users new post list
$newTopicIds = array();
foreach ($topicIds as $topic) {
if (sp_is_in_users_newposts($topic)) {
$newTopicIds[] = $topic;
}
}
if ($newTopicIds) {
# construct the query - need to add in sfwaiting for admins
$where = SFPOSTS . '.topic_id IN (' . implode(',', $newTopicIds) . ') AND (post_date > "' . spdb_zone_mysql_checkdate($spThisUser->lastvisit) . '")';
if ($spThisUser->admin || $spThisUser->moderator) {
$wPosts = spdb_select('col', 'SELECT post_id FROM ' . SFWAITING);
if ($wPosts) {
$where .= ' OR (' . SFPOSTS . '.post_id IN (' . implode(",", $wPosts) . '))';
}
}
$spdb = new spdbComplex();
$spdb->table = SFPOSTS;
$spdb->fields = SFPOSTS . '.topic_id, ' . SFPOSTS . '.post_id, post_index, ' . spdb_zone_datetime('post_date') . ',
guest_name, ' . SFPOSTS . '.user_id, display_name, post_count-post_index+1 AS new_post_count';
$spdb->left_join = array(SFMEMBERS . ' ON ' . SFMEMBERS . '.user_id = ' . SFPOSTS . '.user_id');
$spdb->join = array(SFTOPICS . ' ON ' . SFPOSTS . '.topic_id = ' . SFTOPICS . '.topic_id');
$spdb->where = $where;
$spdb->orderby = 'topic_id, post_id';
$spdb = apply_filters('sph_listview_newposts_query', $spdb, $this);
$postrecords = $spdb->select();
if ($postrecords) {
$cTopic = 0;
foreach ($postrecords as $p) {
if ($p->topic_id != $cTopic) {
$cTopic = $p->topic_id;
$newList[$cTopic] = new stdClass();
$newList[$cTopic]->topic_id = $cTopic;
$newList[$cTopic]->new_post_count = $p->new_post_count;
$newList[$cTopic]->new_post_post_id = $p->post_id;
$newList[$cTopic]->new_post_post_index = $p->post_index;
$newList[$cTopic]->new_post_post_date = $p->post_date;
$newList[$cTopic]->new_post_user_id = $p->user_id;
$newList[$cTopic]->new_post_display_name = sp_filter_name_display($p->display_name);
$newList[$cTopic]->new_post_guest_name = sp_filter_name_display($p->guest_name);
}
}
}
}
return $newList;
}
示例10: sp_is_online
function sp_is_online($userid)
{
global $session_online;
if (!$userid) {
return false;
}
if (!isset($session_online)) {
$session_online = spdb_select('col', "SELECT trackuserid FROM " . SFTRACK);
}
if (in_array($userid, $session_online)) {
return true;
}
return false;
}
示例11: sp_UserGroupList
function sp_UserGroupList($args = '', $titleLabel = '', $userGroup = 0)
{
if (!$userGroup) {
return;
}
$defs = array('tagClass' => 'spUserGroupList', 'pTitleClass' => 'spUserGroupListTitle', 'spanClass' => 'spUserGroupListList', 'link_names' => 1, 'postCount' => 1, 'echo' => 1, 'get' => 0);
$a = wp_parse_args($args, $defs);
$a = apply_filters('sph_UserGroupList_args', $a);
extract($a, EXTR_SKIP);
# sanitize before use
$tagClass = esc_attr($tagClass);
$pTitleClass = esc_attr($pTitleClass);
$spanClass = esc_attr($spanClass);
$link_names = (int) $link_names;
$postCount = (int) $postCount;
$echo = (int) $echo;
$userGroup = (int) $userGroup;
$get = (int) $get;
if (!empty($titleLabel)) {
$titleLabel = sp_filter_title_display($titleLabel);
}
# get user group member list
$sql = "SELECT " . SFMEMBERSHIPS . ".user_id, display_name, posts\n\t\t\tFROM " . SFMEMBERSHIPS . "\n\t\t\tJOIN " . SFMEMBERS . " ON " . SFMEMBERS . ".user_id = " . SFMEMBERSHIPS . ".user_id\n\t\t\tWHERE " . SFMEMBERSHIPS . ".usergroup_id=" . $userGroup . "\n\t\t\tORDER BY display_name";
$members = spdb_select('set', $sql);
if ($get) {
return $members;
}
# render the members list
$out = "<div class='{$tagClass}'>";
$out .= "<p class='{$pTitleClass}'><span class='{$pTitleClass}'>{$titleLabel}</span>";
if ($members) {
$first = true;
$out .= "<span class='{$spanClass}'>";
foreach ($members as $member) {
$comma = !$first ? ', ' : '';
if ($member->posts < 0) {
$member->posts = 0;
}
$userPosts = $postCount ? ': ' . $member->posts : '';
$out .= sp_build_name_display($member->user_id, $comma . sp_filter_name_display($member->display_name) . $userPosts);
$first = false;
}
$out .= '</span>';
}
$out .= '</p>';
# finish it up
$out .= "</div>\n";
$out = apply_filters('sph_UserGroupList', $out, $a);
if ($echo) {
echo $out;
} else {
return $out;
}
}
示例12: sp_rpx_get_wpuid_by_identifier
function sp_rpx_get_wpuid_by_identifier($identifier)
{
$sql = 'SELECT user_id FROM ' . SFUSERMETA . " WHERE meta_key = 'rpx_identifier' AND meta_value = '{$identifier}'";
$r = spdb_select('var', $sql);
if ($r) {
return $r;
} else {
return null;
}
}
示例13: spa_save_housekeeping_data
function spa_save_housekeeping_data()
{
check_admin_referer('forum-adminform_housekeeping', 'forum-adminform_housekeeping');
$mess = '';
if (isset($_POST['rebuild-fidx'])) {
$forumid = $_POST['forum_id'];
if (is_numeric($forumid)) {
$topics = spdb_table(SFTOPICS, "forum_id={$forumid}");
if ($topics) {
include_once SF_PLUGIN_DIR . '/forum/database/sp-db-management.php';
foreach ($topics as $topic) {
sp_build_post_index($topic->topic_id);
}
# after reubuilding post indexes, rebuild the forum indexes
sp_build_forum_index($forumid);
do_action('sph_toolbox_housekeeping_forum_index');
$mess = spa_text('Forum indexes rebuilt');
} else {
$mess = spa_text('Forum index rebuild failed - no topics in selected forum');
}
} else {
$mess = spa_text('Forum index rebuild failed - no forum selected');
}
}
if (isset($_POST['transient-cleanup'])) {
include_once SF_PLUGIN_DIR . '/forum/database/sp-db-management.php';
sp_transient_cleanup();
do_action('sph_toolbox_housekeeping_transient');
$mess = spa_text('WP transients cleaned');
}
if (isset($_POST['clean-newposts'])) {
$days = isset($_POST['sfdays']) ? max(sp_esc_int($_POST['sfdays']), 0) : 30;
$users = spdb_select('col', "SELECT user_id FROM " . SFMEMBERS . " WHERE lastvisit < DATE_SUB(CURDATE(), INTERVAL " . $days . " DAY)");
if ($users) {
foreach ($users as $user) {
spdb_query('UPDATE ' . SFMEMBERS . " SET newposts='a:1:{i:0;i:0;}' WHERE user_id={$user}");
}
}
do_action('sph_toolbox_housekeeping_newpost');
$mess = spa_text('New posts lists cleaned');
}
if (isset($_POST['postcount-cleanup'])) {
spdb_query('UPDATE ' . SFMEMBERS . ' SET posts = (SELECT COUNT(*) FROM ' . SFPOSTS . ' WHERE ' . SFPOSTS . '.user_id = ' . SFMEMBERS . '.user_id)');
# force stats to update
do_action('sph_stats_cron');
do_action('sph_toolbox_housekeeping_postcount');
$mess = spa_text('User post counts calculated');
}
if (isset($_POST['reset-tabs'])) {
# clear out current tabs
$tabs = sp_get_sfmeta('profile', 'tabs');
sp_delete_sfmeta($tabs[0]['meta_id']);
# start adding new ones
spa_new_profile_setup();
do_action('sph_toolbox_housekeeping_profile_tabs');
$mess = spa_text('Profile tabs reset');
}
if (isset($_POST['reset-auths'])) {
sp_reset_auths();
do_action('sph_toolbox_housekeeping_auths');
$mess = spa_text('Auths caches cleaned');
}
if (isset($_POST['reset-plugin-data'])) {
sp_reset_member_plugindata();
do_action('sph_toolbox_housekeeping_plugindata');
$mess = spa_text('Users Plugin Data reset');
}
if (isset($_POST['reset-combinedcss'])) {
sp_clear_combined_css('all');
sp_clear_combined_css('mobile');
sp_clear_combined_css('tablet');
do_action('sph_toolbox_housekeeping_ccombined_css');
$mess = spa_text('Combined CSS cache file removed');
}
if (isset($_POST['reset-combinedjs'])) {
sp_clear_combined_scripts('desktop');
sp_clear_combined_scripts('mobile');
sp_clear_combined_scripts('tablet');
do_action('sph_toolbox_housekeeping_combined_js');
$mess = spa_text('Combined scripts cache files removed');
}
if (isset($_POST['flushcache'])) {
sp_flush_cache('all');
do_action('sph_toolbox_housekeeping_flush_cache');
$mess = spa_text('General cache flushed');
}
do_action('sph_toolbox_housekeeping_save');
return $mess;
}
示例14: sp_test_table_create
function sp_test_table_create()
{
# make sure we can create database tables
$sql = '
CREATE TABLE sfCheckCreate (
id int(4) NOT NULL,
item varchar(15) default NULL,
PRIMARY KEY (id)
) ' . spdb_charset();
spdb_query($sql);
$success = spdb_select('var', 'SHOW TABLES LIKE "sfCheckCreate"');
if ($success == false) {
return false;
} else {
spdb_query('DROP TABLE sfCheckCreate');
return true;
}
}
示例15: die
$LastChangedDate: 2013-03-02 17:15:32 +0000 (Sat, 02 Mar 2013) $
$Rev: 9944 $
*/
if (preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) {
die('Access denied - you cannot directly call this file');
}
spa_admin_ahah_support();
check_admin_referer('forum-adminform_mapusers', 'forum-adminform_mapusers');
global $wp_roles;
$startSQL = sp_esc_int($_GET['startNum']);
$batchSQL = sp_esc_int($_GET['batchNum']);
$where = ' WHERE admin=0';
if ($_GET['ignoremods']) {
$where .= ' AND moderator=0';
}
$users = spdb_select('col', 'SELECT user_id FROM ' . SFMEMBERS . $where . ' ORDER BY user_id LIMIT ' . $startSQL . ', ' . $batchSQL);
if ($users) {
$value = sp_get_sfmeta('default usergroup', 'sfmembers');
$defaultUG = $value[0]['meta_value'];
foreach ($users as $thisUser) {
if ($_GET['mapoption'] == 2) {
spdb_query('DELETE FROM ' . SFMEMBERSHIPS . ' WHERE user_id=' . $thisUser);
}
$user = new WP_User($thisUser);
if (!empty($user->roles) && is_array($user->roles)) {
foreach ($user->roles as $role) {
$value = sp_get_sfmeta('default usergroup', $role);
if (!empty($value)) {
$ug = $value[0]['meta_value'];
} else {
$ug = $defaultUG;