本文整理汇总了PHP中spdb_query函数的典型用法代码示例。如果您正苦于以下问题:PHP spdb_query函数的具体用法?PHP spdb_query怎么用?PHP spdb_query使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了spdb_query函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sp_rebuild_schema
function sp_rebuild_schema($start, $end)
{
global $tables, $wpdb;
# prepare the one exception!
$opTable = $wpdb->prefix . 'sfoptions';
$opKey = 'option_id';
$t = sp_get_option('installed_tables');
for ($x = $start; $x < $end + 1; $x++) {
if ($t[$x]) {
# get list of indexes
$data = $wpdb->get_results("SHOW INDEXES FROM {$t[$x]}");
if ($data) {
foreach ($data as $item) {
if ($item->Key_name != 'PRIMARY' && ($t[$x] != $opTable && $item->Key_name != $opKey)) {
# remove current index
spdb_query('ALTER TABLE ' . $t[$x] . " DROP INDEX {$item->Key_name}");
}
}
}
# grab list of table actions
$actions = $tables[$t[$x]];
if ($actions) {
foreach ($actions as $sql) {
# add back index
spdb_query($sql);
}
}
}
}
}
示例2: 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;
}
示例3: sp_admin_bar_do_uninstall
function sp_admin_bar_do_uninstall()
{
global $spGlobals;
sp_delete_option('spAdminBar');
sp_delete_option('spAkismet');
# remove the auth
if (!empty($spGlobals['auths_map']['bypass_akismet'])) {
sp_delete_auth('bypass_akismet');
}
# remove our auto update stuff
$up = sp_get_sfmeta('autoupdate', 'admin');
if ($up) {
sp_delete_sfmeta($up[0]['meta_id']);
}
# empty out the sfwaiting table
spdb_query('TRUNCATE ' . SFWAITING);
}
示例4: 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;
}
}
示例5: 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;
}
示例6: spa_update_specialrank
function spa_update_specialrank($id)
{
check_admin_referer('special-rank-update', 'special-rank-update');
# save special forum ranks
if (!empty($_POST['specialrankdesc'])) {
$desc = $_POST['specialrankdesc'];
$badge = $_POST['specialrankbadge'];
$rank = sp_get_sfmeta('special_rank', false, $id);
$rank[0]['meta_value']['badge'] = sp_filter_filename_save($badge[$id]);
sp_update_sfmeta('special_rank', sp_filter_title_save(trim($desc[$id])), $rank[0]['meta_value'], $id, 1);
if ($_POST['currentname'][$id] != $desc[$id]) {
spdb_query("UPDATE " . SFSPECIALRANKS . "\n\t\t\t\t\t\tSET special_rank = '" . $desc[$id] . "'\n\t\t\t\t\t\tWHERE special_rank = '" . $_POST['currentname'][$id] . "'");
}
}
do_action('sph_component_srank_update_save');
$mess = spa_text('Special ranks updated');
return $mess;
}
示例7: sp_delete_notice
function sp_delete_notice($col, $data)
{
$sql = 'DELETE FROM ' . SFNOTICES . ' WHERE ';
if (is_numeric($data)) {
$sql .= "{$col} = {$data}";
} else {
$sql .= "{$col} = '{$data}'";
}
spdb_query($sql);
}
示例8: sp_esc_int
global $spPaths;
$action = $_GET['action'];
if ($action == 'del_rank') {
$key = sp_esc_int($_GET['key']);
# remove the forum rank
$sql = 'DELETE FROM ' . SFMETA . " WHERE meta_type='forum_rank' AND meta_id='{$key}'";
spdb_query($sql);
}
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>';
示例9: sp_update_post_urls
function sp_update_post_urls($old, $new)
{
global $wpdb;
if (empty($old) || empty($new)) {
return;
}
$posts = spdb_table(SFPOSTS, 'post_content LIKE "%/' . esc_sql($wpdb->esc_like($old)) . '%"', '');
if (!empty($posts)) {
foreach ($posts as $p) {
$pc = str_replace('/' . $old, '/' . $new, sp_filter_content_edit($p->post_content));
$pc = sp_filter_content_save($pc, 'edit');
spdb_query('UPDATE ' . SFPOSTS . " SET post_content = '{$pc}' WHERE post_id=" . $p->post_id);
}
}
}
示例10: spa_update_parent_group
function spa_update_parent_group($currentGroupId, $newGroupId, $forumParent)
{
$forums = spdb_table(SFFORUMS, "group_id={$currentGroupId} AND parent={$forumParent}");
if ($forums) {
foreach ($forums as $forum) {
# update the old group ID to new one
$sql = 'UPDATE ' . SFFORUMS . " SET group_id={$newGroupId} WHERE forum_id={$forum->forum_id}";
spdb_query($sql);
if ($forum->children) {
$childlist = array(unserialize($forum->children));
if (count($childlist) > 0) {
spa_update_parent_group($currentGroupId, $newGroupId, $forum->forum_id);
}
}
}
}
}
示例11: insert
function insert()
{
if (empty($this->table) || empty($this->fields) || empty($this->data) || !is_array($this->data) || !is_array($this->fields)) {
return false;
}
$table = $this->table;
$values = array();
foreach ($this->data as $val) {
if (!is_numeric($val)) {
$val = "'" . $val . "'";
}
$values[] = $val;
}
$sql = "INSERT INTO {$table} (" . implode(', ', $this->fields) . ') VALUES (' . implode(', ', $values) . ')';
if ($this->show) {
spdb_show_result($sql, $this->inspect);
}
$result = spdb_query($sql);
return $result;
}
示例12: sp_rpx_create_wp_user
function sp_rpx_create_wp_user($auth_info)
{
$p = $auth_info['profile'];
$rid = $p['identifier'];
$provider_name = $p['providerName'];
$username = $p['preferredUsername'];
if (!$username || sp_rpx_username_taken($username)) {
$username = sp_rpx_get_user_login_name($rid);
}
$last_name = null;
$first_name = null;
if (!empty($p['name'])) {
$first_name = $p['name']['givenName'];
$last_name = $p['name']['familyName'];
}
$email = 'dummy@simple-press.com';
if (!empty($p['email'])) {
$email = sp_filter_email_save($p['email']);
}
$userdata = array('user_pass' => wp_generate_password(), 'user_login' => $username, 'display_name' => sp_filter_name_save($p['displayName']), 'user_url' => $p['url'], 'user_email' => $email, 'first_name' => $first_name, 'last_name' => $last_name, 'nickname' => $p['displayName']);
# try to create new user
$wpuid = wp_insert_user($userdata);
if ($wpuid && !is_wp_error($wpuid)) {
update_user_meta($wpuid, 'rpx_identifier', $rid);
# remove temp email?
if ($email == 'dummy@simple-press.com') {
spdb_query('UPDATE ' . SFUSERS . " SET user_email='' WHERE ID={$wpuid}");
}
}
return $wpuid;
}
示例13: spa_check_warnings
function spa_check_warnings()
{
global $spGlobals;
# not perfect but we can use this call tyo perform any minor
# cleanups that may be necessary... so
# drop any existing temp members table...
spdb_query('DROP TABLE IF EXISTS sftempmembers');
$mess = '';
# check if sp core, plugins or themes update available
$update = false;
$update_msg = '';
$up = get_site_transient('update_plugins');
if (!empty($up->response)) {
foreach ($up->response as $plugin) {
if ($plugin->slug == 'simple-press') {
$msg = apply_filters('sph_core_update_notice', spa_text('There is a Simple:Press core update available.'));
if (!empty($msg)) {
$update = true;
$update_msg .= $msg . '<br />';
}
break;
}
}
}
$up = get_site_transient('sp_update_plugins');
if (!empty($up)) {
$msg = apply_filters('sph_plugins_update_notice', spa_text('There is one or more Simple:Press plugin updates available'));
if (!empty($msg)) {
$update = true;
$update_msg .= $msg . '<br />';
}
}
$up = get_site_transient('sp_update_themes');
if (!empty($up)) {
$msg = apply_filters('sph_themes_update_notice', spa_text('There is one or more Simple:Press theme updates available'));
if (!empty($msg)) {
$update = true;
$update_msg .= $msg . '<br />';
}
}
if ($update) {
if (is_main_site()) {
$mess .= apply_filters('sph_updates_notice', spa_message($update_msg . '<a href="' . self_admin_url('update-core.php') . '">' . spa_text('Click here to view any updates.') . '</a>'));
} else {
$mess .= apply_filters('sph_updates_notice', spa_message(spa_text('There are some Simple:Press updates avaialable. You may want to notify the network site admin.')));
}
}
# output warning if no SPF admins are defined
$a = $spGlobals['forum-admins'];
if (empty($a)) {
$mess .= spa_message(spa_text('Warning - There are no SPF admins defined! All WP admins now have SP backend access'), 'error');
}
# Check if desktop, tablet and mobile themes are selected and available
$cur = sp_get_option('sp_current_theme');
if (empty($cur)) {
$mess .= spa_message(spa_text('No main theme has been selected and SP will be unable to display correctly. Please select a theme from the Themes panel'), 'error');
} else {
$nostylesheet = !file_exists(SPTHEMEBASEDIR . $cur['theme'] . '/styles/' . $cur['style']);
$nooverlay = !empty($cur['color']) && !file_exists(SPTHEMEBASEDIR . $cur['theme'] . '/styles/overlays/' . $cur['color'] . '.php');
$nopoverlay = !empty($cur['color']) && !empty($cur['parent']) && !file_exists(SPTHEMEBASEDIR . $cur['parent'] . '/styles/overlays/' . $cur['color'] . '.php');
if ($nostylesheet || $nooverlay && $nopoverlay) {
$mess .= spa_message(spa_text('Either the theme CSS file and/or color Overlay file from the selected theme is missing'), 'error');
}
}
$mobile = sp_get_option('sp_mobile_theme');
if (!empty($mobile) && $mobile['active']) {
$nostylesheet = !file_exists(SPTHEMEBASEDIR . $mobile['theme'] . '/styles/' . $mobile['style']);
$nooverlay = !empty($mobile['color']) && !file_exists(SPTHEMEBASEDIR . $mobile['theme'] . '/styles/overlays/' . $mobile['color'] . '.php');
$nopoverlay = !empty($mobile['color']) && !empty($mobile['parent']) && !file_exists(SPTHEMEBASEDIR . $mobile['parent'] . '/styles/overlays/' . $mobile['color'] . '.php');
if ($nostylesheet || $nooverlay && $nopoverlay) {
$mess .= spa_message(spa_text('Either the mobile theme CSS file and/or color Overlay file from the selected mobile theme is missing'), 'error');
}
}
$tablet = sp_get_option('sp_tablet_theme');
if (!empty($tablet) && $tablet['active']) {
$nostylesheet = !file_exists(SPTHEMEBASEDIR . $tablet['theme'] . '/styles/' . $tablet['style']);
$nooverlay = !empty($tablet['color']) && !file_exists(SPTHEMEBASEDIR . $tablet['theme'] . '/styles/overlays/' . $tablet['color'] . '.php');
$nopoverlay = !empty($tablet['color']) && !empty($tablet['parent']) && !file_exists(SPTHEMEBASEDIR . $tablet['parent'] . '/styles/overlays/' . $tablet['color'] . '.php');
if ($nostylesheet || $nooverlay && $nopoverlay) {
$mess .= spa_message(spa_text('Either the tablet theme CSS file and/or color Overlay file from the selected tablet theme is missing'), 'error');
}
}
# check for missing default members user group
$value = sp_get_sfmeta('default usergroup', 'sfmembers');
$ugid = spdb_table(SFUSERGROUPS, "usergroup_id={$value[0]['meta_value']}", 'usergroup_id');
if (empty($ugid)) {
$mess .= spa_message(spa_text('Warning - The default user group for new members is undefined! Please visit the SP usergroups admin page, map users to usergroups tab and set the default user group'), 'error');
}
# check for missing default guest user group
$value = sp_get_sfmeta('default usergroup', 'sfguests');
$ugid = spdb_table(SFUSERGROUPS, "usergroup_id={$value[0]['meta_value']}", 'usergroup_id');
if (empty($ugid)) {
$mess .= spa_message(spa_text('Warning - The default user group for guests is undefined! Please visit the SP usergroups admin page, map users to usergroups tab and set the default user group'), 'error');
}
# check for unreachable forums because of permissions
$usergroups = spdb_table(SFUSERGROUPS);
if ($usergroups) {
$has_members = false;
foreach ($usergroups as $usergroup) {
$members = spdb_table(SFMEMBERSHIPS, "usergroup_id={$usergroup->usergroup_id}", 'row', '', '1');
//.........这里部分代码省略.........
示例14: 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;
}
示例15: die
<?php
/*
Simple:Press
Remove a user notice in demand
$LastChangedDate: 2012-11-19 14:00:20 -0800 (Mon, 19 Nov 2012) $
$Rev: 9330 $
*/
if (preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) {
die('Access denied - you cannot directly call this file');
}
sp_forum_api_support();
if (isset($_GET['notice'])) {
$id = (int) $_GET['notice'];
if ($id) {
spdb_query('DELETE FROM ' . SFNOTICES . " WHERE notice_id={$id}");
}
}
die;