当前位置: 首页>>代码示例>>PHP>>正文


PHP sync函数代码示例

本文整理汇总了PHP中sync函数的典型用法代码示例。如果您正苦于以下问题:PHP sync函数的具体用法?PHP sync怎么用?PHP sync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sync函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sync

function sync($type, $id = false)
{
    global $db;
    switch ($type) {
        case 'all forums':
            $sql = "SELECT forum_id\n\t\t\t\tFROM " . FORUMS_TABLE;
            if (!($result = $db->sql_query($sql))) {
                message_die(GENERAL_ERROR, 'Could not get forum IDs', '', __LINE__, __FILE__, $sql);
            }
            while ($row = $db->sql_fetchrow($result)) {
                sync('forum', $row['forum_id']);
            }
            break;
        case 'all topics':
            $sql = "SELECT topic_id\n\t\t\t\tFROM " . TOPICS_TABLE;
            if (!($result = $db->sql_query($sql))) {
                message_die(GENERAL_ERROR, 'Could not get topic ID', '', __LINE__, __FILE__, $sql);
            }
            while ($row = $db->sql_fetchrow($result)) {
                sync('topic', $row['topic_id']);
            }
            break;
        case 'forum':
            $sql = "SELECT MAX(post_id) AS last_post, COUNT(post_id) AS total \n\t\t\t\tFROM " . POSTS_TABLE . "  \n\t\t\t\tWHERE forum_id = {$id}";
            if (!($result = $db->sql_query($sql))) {
                message_die(GENERAL_ERROR, 'Could not get post ID', '', __LINE__, __FILE__, $sql);
            }
            if ($row = $db->sql_fetchrow($result)) {
                $last_post = $row['last_post'] ? $row['last_post'] : 0;
                $total_posts = $row['total'] ? $row['total'] : 0;
            } else {
                $last_post = 0;
                $total_posts = 0;
            }
            $sql = "SELECT COUNT(topic_id) AS total\n\t\t\t\tFROM " . TOPICS_TABLE . "\n\t\t\t\tWHERE forum_id = {$id}";
            if (!($result = $db->sql_query($sql))) {
                message_die(GENERAL_ERROR, 'Could not get topic count', '', __LINE__, __FILE__, $sql);
            }
            $total_topics = ($row = $db->sql_fetchrow($result)) ? $row['total'] ? $row['total'] : 0 : 0;
            $sql = "UPDATE " . FORUMS_TABLE . "\n\t\t\t\tSET forum_last_post_id = {$last_post}, forum_posts = {$total_posts}, forum_topics = {$total_topics}\n\t\t\t\tWHERE forum_id = {$id}";
            if (!$db->sql_query($sql)) {
                message_die(GENERAL_ERROR, 'Could not update forum', '', __LINE__, __FILE__, $sql);
            }
            break;
        case 'topic':
            $sql = "SELECT MAX(post_id) AS last_post, MIN(post_id) AS first_post, COUNT(post_id) AS total_posts\n\t\t\t\tFROM " . POSTS_TABLE . "\n\t\t\t\tWHERE topic_id = {$id}";
            if (!($result = $db->sql_query($sql))) {
                message_die(GENERAL_ERROR, 'Could not get post ID', '', __LINE__, __FILE__, $sql);
            }
            if ($row = $db->sql_fetchrow($result)) {
                $sql = $row['total_posts'] ? "UPDATE " . TOPICS_TABLE . " SET topic_replies = " . ($row['total_posts'] - 1) . ", topic_first_post_id = " . $row['first_post'] . ", topic_last_post_id = " . $row['last_post'] . " WHERE topic_id = {$id}" : "DELETE FROM " . TOPICS_TABLE . " WHERE topic_id = {$id}";
                if (!$db->sql_query($sql)) {
                    message_die(GENERAL_ERROR, 'Could not update topic', '', __LINE__, __FILE__, $sql);
                }
            }
            attachment_sync_topic($id);
            break;
    }
    return true;
}
开发者ID:puring0815,项目名称:OpenKore,代码行数:60,代码来源:functions_admin.php

示例2: sync

function sync($type, $id = false)
{
    global $db;
    switch ($type) {
        case 'all forums':
            $result = $db->sql_query("SELECT forum_id FROM " . FORUMS_TABLE);
            while ($row = $db->sql_fetchrow($result)) {
                sync('forum', $row['forum_id']);
            }
            break;
        case 'all topics':
            $result = $db->sql_query("SELECT topic_id FROM " . TOPICS_TABLE);
            while ($row = $db->sql_fetchrow($result)) {
                sync('topic', $row['topic_id']);
            }
            break;
        case 'forum':
            $sql = "SELECT MAX(post_id) AS last_post, COUNT(post_id) AS total\n\t\t\t\tFROM " . POSTS_TABLE . " WHERE forum_id = {$id}";
            $result = $db->sql_query($sql);
            if ($row = $db->sql_fetchrow($result)) {
                $last_post = $row['last_post'] ? $row['last_post'] : 0;
                $total_posts = $row['total'] ? $row['total'] : 0;
            } else {
                $last_post = 0;
                $total_posts = 0;
            }
            $result = $db->sql_query("SELECT COUNT(topic_id) AS total FROM " . TOPICS_TABLE . " WHERE forum_id = {$id}");
            $total_topics = ($row = $db->sql_fetchrow($result)) ? $row['total'] ? $row['total'] : 0 : 0;
            $sql = "UPDATE " . FORUMS_TABLE . "\n\t\t\t\tSET forum_last_post_id = {$last_post}, forum_posts = {$total_posts}, forum_topics = {$total_topics}\n\t\t\t\tWHERE forum_id = {$id}";
            $db->sql_query($sql);
            break;
        case 'topic':
            $sql = "SELECT MAX(post_id) AS last_post, MIN(post_id) AS first_post, COUNT(post_id) AS total_posts\n\t\t\t\tFROM " . POSTS_TABLE . " WHERE topic_id = {$id}";
            $result = $db->sql_query($sql);
            if ($row = $db->sql_fetchrow($result)) {
                $sql = $row['total_posts'] ? "UPDATE " . TOPICS_TABLE . " SET topic_replies = " . ($row['total_posts'] - 1) . ", topic_first_post_id = " . $row['first_post'] . ", topic_last_post_id = " . $row['last_post'] : "DELETE FROM " . TOPICS_TABLE;
                $db->sql_query($sql . " WHERE topic_id = {$id}");
            }
            //			  if (defined('BBAttach_mod')) {
            attachment_sync_topic($id);
            break;
    }
    return true;
}
开发者ID:cbsistem,项目名称:nexos,代码行数:44,代码来源:functions_admin.php

示例3: switch

    $op = $_GET['op'];
}
if (isset($_POST['op'])) {
    $op = $_POST['op'];
}
switch ($op) {
    case "del":
        $post_handler =& xoops_getmodulehandler('post', 'newbb');
        if (!empty($ok)) {
            if (!empty($post_id)) {
                $post =& $post_handler->get($post_id);
                if ($ok == 2 && isset($post)) {
                    $post_handler->delete($post, true);
                }
                sync($post->getVar('forum_id'), "forum");
                sync($post->getVar('topic_id'), "topic");
            }
            if ($post->istopic()) {
                redirect_header("index.php", 2, _AM_NEWBB_POSTSDELETED);
                exit;
            } else {
                redirect_header("index.php", 2, _AM_NEWBB_POSTSDELETED);
                exit;
            }
        } else {
            xoops_cp_header();
            xoops_confirm(array('post_id' => $post_id, 'op' => 'del', 'ok' => 2), 'index.php', _AM_NEWBB_DEL_ONE);
            xoops_cp_footer();
        }
        exit;
        break;
开发者ID:BackupTheBerlios,项目名称:soopa,代码行数:31,代码来源:index.php

示例4: intval

            break;
        case 'cat_order':
            //
            // Change order of categories in the DB
            //
            $move = intval($HTTP_GET_VARS['move']);
            $cat_id = intval($HTTP_GET_VARS[POST_CAT_URL]);
            $sql = "UPDATE " . CATEGORIES_TABLE . "\n\t\t\t\tSET cat_order = cat_order + {$move}\n\t\t\t\tWHERE cat_id = {$cat_id}";
            if (!($result = $db->sql_query($sql))) {
                message_die(GENERAL_ERROR, "Couldn't change category order", "", __LINE__, __FILE__, $sql);
            }
            renumber_order('category');
            $show_index = TRUE;
            break;
        case 'forum_sync':
            sync('forum', intval($HTTP_GET_VARS[POST_FORUM_URL]));
            $show_index = TRUE;
            break;
        default:
            message_die(GENERAL_MESSAGE, $lang['No_mode']);
            break;
    }
    if ($show_index != TRUE) {
        include './page_footer_admin.' . $phpEx;
        exit;
    }
}
//
// Start page proper
//
$template->set_filenames(array("body" => "admin/forum_admin_body.tpl"));
开发者ID:puring0815,项目名称:OpenKore,代码行数:31,代码来源:admin_forums.php

示例5: logwrite

if ($write == 2) {
    $act = "Write tbldata {$tbl}";
    logwrite($act);
    writeconfigtbl();
    dispref();
    exit;
}
if ($write == 3) {
    $act = "Write GMdata " . $prauth[$ADMM][0] . " {$ADMM} ";
    logwrite($act);
    writeconfigtblsd();
    dispref();
    exit;
}
if ($write == cmsg("SYNC")) {
    sync("");
    exit;
}
if ($write == cmsg("SYNC_ST")) {
    autoupdatecfgs($files);
    exit;
}
if ($write == cmsg("SVN_UPD")) {
    syncsvn("");
    exit;
}
function sync($conf)
{
    global $mirroraddress, $pr;
    //$mirroraddress="http://la2.chg.su/dbs4/_conf/";
    $mirroraddress = $pr[96];
开发者ID:serj-43,项目名称:db-script,代码行数:31,代码来源:admin.php

示例6: addSecurityToken

 private function addSecurityToken($token, $name = 'Endgerät')
 {
     $json = DatabaseManager::$table2;
     $json = json_decode($json);
     $databaseManagerSecurityToken = new DatabaseManager();
     $databaseManagerSecurityToken->openTable("authtokens", $json);
     $userId = $this->getId();
     if (!empty($_SERVER['REMOTE_ADDR'])) {
         $array['name'] = array('value' => $name . ' - ' . $_SERVER['REMOTE_ADDR']);
     } else {
         $array['name'] = array('value' => $name . ' - ' . uniquid());
     }
     $array['authtoken'] = array('value' => $token);
     $array['user'] = array('value' => $userId);
     $databaseManagerSecurityToken->insertValue($array);
     sync(AUTHTOKENS);
 }
开发者ID:michaelsoftware1997,项目名称:vision-server,代码行数:17,代码来源:LoginManager.php

示例7: main


//.........这里部分代码省略.........
                                    } else {
                                        $move_post_ary[$row['topic_id']]['title'] = $row['topic_title'];
                                        $move_post_ary[$row['topic_id']]['attach'] = $row['attach'] ? 1 : 0;
                                    }
                                    $forum_id_ary[] = $row['forum_id'];
                                }
                                $db->sql_freeresult($result);
                            }
                            // Entire topic comprises posts by this user, move these topics
                            if (sizeof($move_topic_ary)) {
                                move_topics($move_topic_ary, $new_forum_id, false);
                            }
                            if (sizeof($move_post_ary)) {
                                // Create new topic
                                // Update post_ids, report_ids, attachment_ids
                                foreach ($move_post_ary as $topic_id => $post_ary) {
                                    // Create new topic
                                    $sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', array('topic_poster' => $user_id, 'topic_time' => time(), 'forum_id' => $new_forum_id, 'icon_id' => 0, 'topic_approved' => 1, 'topic_title' => $post_ary['title'], 'topic_first_poster_name' => $user_row['username'], 'topic_type' => POST_NORMAL, 'topic_time_limit' => 0, 'topic_attachment' => $post_ary['attach']));
                                    $db->sql_query($sql);
                                    $new_topic_id = $db->sql_nextid();
                                    // Move posts
                                    $sql = 'UPDATE ' . POSTS_TABLE . "\n\t\t\t\t\t\t\t\t\t\tSET forum_id = {$new_forum_id}, topic_id = {$new_topic_id}\n\t\t\t\t\t\t\t\t\t\tWHERE topic_id = {$topic_id}\n\t\t\t\t\t\t\t\t\t\t\tAND poster_id = {$user_id}";
                                    $db->sql_query($sql);
                                    if ($post_ary['attach']) {
                                        $sql = 'UPDATE ' . ATTACHMENTS_TABLE . "\n\t\t\t\t\t\t\t\t\t\t\tSET topic_id = {$new_topic_id}\n\t\t\t\t\t\t\t\t\t\t\tWHERE topic_id = {$topic_id}\n\t\t\t\t\t\t\t\t\t\t\t\tAND poster_id = {$user_id}";
                                        $db->sql_query($sql);
                                    }
                                    $new_topic_id_ary[] = $new_topic_id;
                                }
                            }
                            $forum_id_ary = array_unique($forum_id_ary);
                            $topic_id_ary = array_unique(array_merge($topic_id_ary, $new_topic_id_ary));
                            if (sizeof($topic_id_ary)) {
                                sync('reported', 'topic_id', $topic_id_ary);
                                sync('topic', 'topic_id', $topic_id_ary);
                            }
                            if (sizeof($forum_id_ary)) {
                                sync('forum', 'forum_id', $forum_id_ary);
                            }
                            $sql = 'SELECT forum_name
								FROM ' . FORUMS_TABLE . "\n\t\t\t\t\t\t\t\tWHERE forum_id = {$new_forum_id}";
                            $result = $db->sql_query($sql, 3600);
                            $forum_info = $db->sql_fetchrow($result);
                            $db->sql_freeresult($result);
                            add_log('admin', 'LOG_USER_MOVE_POSTS', $user_row['username'], $forum_info['forum_name']);
                            add_log('user', $user_id, 'LOG_USER_MOVE_POSTS_USER', $forum_info['forum_name']);
                            trigger_error($user->lang['USER_POSTS_MOVED'] . adm_back_link($this->u_action . '&u=' . $user_id));
                            break;
                    }
                    $data = array();
                    // Handle registration info updates
                    $var_ary = array('user' => (string) $user_row['username'], 'user_founder' => (int) ($user_row['user_type'] == USER_FOUNDER ? 1 : 0), 'user_email' => (string) $user_row['user_email'], 'email_confirm' => (string) '', 'user_password' => (string) '', 'password_confirm' => (string) '', 'warnings' => (int) $user_row['user_warnings']);
                    // Get the data from the form. Use data from the database if no info is provided
                    foreach ($var_ary as $var => $default) {
                        $data[$var] = request_var($var, $default);
                    }
                    // We use user within the form to circumvent auto filling
                    $data['username'] = $data['user'];
                    unset($data['user']);
                    // Validation data
                    $var_ary = array('password_confirm' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), 'user_password' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), 'warnings' => array('num'));
                    // Check username if altered
                    if ($data['username'] != $user_row['username']) {
                        $var_ary += array('username' => array(array('string', false, $config['min_name_chars'], $config['max_name_chars']), array('username', $user_row['username'])));
                    }
                    // Check email if altered
开发者ID:yunsite,项目名称:gloryroad,代码行数:67,代码来源:acp_users.php

示例8: change_poster

/**
* Change a post's poster
*/
function change_poster(&$post_info, $userdata)
{
    global $auth, $db, $config, $phpbb_root_path, $phpEx, $user, $phpbb_dispatcher;
    if (empty($userdata) || $userdata['user_id'] == $post_info['user_id']) {
        return;
    }
    $post_id = $post_info['post_id'];
    $sql = 'UPDATE ' . POSTS_TABLE . "\n\t\tSET poster_id = {$userdata['user_id']}\n\t\tWHERE post_id = {$post_id}";
    $db->sql_query($sql);
    // Resync topic/forum if needed
    if ($post_info['topic_last_post_id'] == $post_id || $post_info['forum_last_post_id'] == $post_id || $post_info['topic_first_post_id'] == $post_id) {
        sync('topic', 'topic_id', $post_info['topic_id'], false, false);
        sync('forum', 'forum_id', $post_info['forum_id'], false, false);
    }
    // Adjust post counts... only if the post is approved (else, it was not added the users post count anyway)
    if ($post_info['post_postcount'] && $post_info['post_visibility'] == ITEM_APPROVED) {
        $sql = 'UPDATE ' . USERS_TABLE . '
			SET user_posts = user_posts - 1
			WHERE user_id = ' . $post_info['user_id'] . '
			AND user_posts > 0';
        $db->sql_query($sql);
        $sql = 'UPDATE ' . USERS_TABLE . '
			SET user_posts = user_posts + 1
			WHERE user_id = ' . $userdata['user_id'];
        $db->sql_query($sql);
    }
    // Add posted to information for this topic for the new user
    markread('post', $post_info['forum_id'], $post_info['topic_id'], time(), $userdata['user_id']);
    // Remove the dotted topic option if the old user has no more posts within this topic
    if ($config['load_db_track'] && $post_info['user_id'] != ANONYMOUS) {
        $sql = 'SELECT topic_id
			FROM ' . POSTS_TABLE . '
			WHERE topic_id = ' . $post_info['topic_id'] . '
				AND poster_id = ' . $post_info['user_id'];
        $result = $db->sql_query_limit($sql, 1);
        $topic_id = (int) $db->sql_fetchfield('topic_id');
        $db->sql_freeresult($result);
        if (!$topic_id) {
            $sql = 'DELETE FROM ' . TOPICS_POSTED_TABLE . '
				WHERE user_id = ' . $post_info['user_id'] . '
					AND topic_id = ' . $post_info['topic_id'];
            $db->sql_query($sql);
        }
    }
    // change the poster_id within the attachments table, else the data becomes out of sync and errors displayed because of wrong ownership
    if ($post_info['post_attachment']) {
        $sql = 'UPDATE ' . ATTACHMENTS_TABLE . '
			SET poster_id = ' . $userdata['user_id'] . '
			WHERE poster_id = ' . $post_info['user_id'] . '
				AND post_msg_id = ' . $post_info['post_id'] . '
				AND topic_id = ' . $post_info['topic_id'];
        $db->sql_query($sql);
    }
    // refresh search cache of this post
    $search_type = $config['search_type'];
    if (class_exists($search_type)) {
        // We do some additional checks in the module to ensure it can actually be utilised
        $error = false;
        $search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);
        if (!$error && method_exists($search, 'destroy_cache')) {
            $search->destroy_cache(array(), array($post_info['user_id'], $userdata['user_id']));
        }
    }
    $from_username = $post_info['username'];
    $to_username = $userdata['username'];
    /**
     * This event allows you to perform additional tasks after changing a post's poster
     *
     * @event core.mcp_change_poster_after
     * @var	array	userdata	Information on a post's new poster
     * @var	array	post_info	Information on the affected post
     * @since 3.1.6-RC1
     * @changed 3.1.7-RC1		Change location to prevent post_info from being set to the new post information
     */
    $vars = array('userdata', 'post_info');
    extract($phpbb_dispatcher->trigger_event('core.mcp_change_poster_after', compact($vars)));
    // Renew post info
    $post_info = phpbb_get_post_data(array($post_id), false, true);
    if (!sizeof($post_info)) {
        trigger_error('POST_NOT_EXIST');
    }
    $post_info = $post_info[$post_id];
    // Now add log entry
    add_log('mod', $post_info['forum_id'], $post_info['topic_id'], 'LOG_MCP_CHANGE_POSTER', $post_info['topic_title'], $from_username, $to_username);
}
开发者ID:WarriorMachines,项目名称:warriormachines-phpbb,代码行数:88,代码来源:mcp_post.php

示例9: unset

             unset($pieces[$k]);
         }
     }
     $alias = join(' ', $pieces);
     if (!$alias) {
         $alias = 'x';
     }
     $res = $pdo->update('site', array('aliases' => $alias), "name='{$name}'");
     if ($res) {
         $message = t("Httpd configuration saved.");
     }
     if ($removed) {
         $message = t("Alias invalid or occupied: ") . "<br />" . join(', ', $removed);
     }
     $type = $removed ? 'warning' : 'notice';
     sync();
     setmsg($message, $type, 'self');
 }
 if (checktoken() && 'remove' == $_REQUEST['op']) {
     if (ZVhosts::removeVhost($name)) {
         setmsg(t('Site removed.'), 'notice');
     } else {
         setmsg(t('Error'));
     }
 }
 if (checktoken() && 'chDocRoot' == $_REQUEST['op']) {
     $root = $_REQUEST['root'];
     if (ZVhosts::changeDocRoot($name, $root)) {
         setmsg(t('Site updated.'), 'notice');
     } else {
         setmsg(t('Error'));
开发者ID:BGCX261,项目名称:zhpanel-svn-to-git,代码行数:31,代码来源:site.php

示例10: array

}
$forum_rows = array();
while ($row = $db->sql_fetchrow($result)) {
    $forum_rows[] = $row;
}
//
// Check for submit to be equal to Prune. If so then proceed with the pruning.
//
if (isset($HTTP_POST_VARS['doprune'])) {
    $prunedays = isset($HTTP_POST_VARS['prunedays']) ? intval($HTTP_POST_VARS['prunedays']) : 0;
    // Convert days to seconds for timestamp functions...
    $prunedate = time() - $prunedays * 86400;
    $template->set_filenames(array('body' => 'forum_prune_result_body.tpl'));
    for ($i = 0; $i < count($forum_rows); $i++) {
        $p_result = prune($forum_rows[$i]['forum_id'], $prunedate);
        sync('forum', $forum_rows[$i]['forum_id']);
        $row_color = !($i % 2) ? $theme['td_color1'] : $theme['td_color2'];
        $row_class = !($i % 2) ? $theme['td_class1'] : $theme['td_class2'];
        $template->assign_block_vars('prune_results', array('ROW_COLOR' => '#' . $row_color, 'ROW_CLASS' => $row_class, 'FORUM_NAME' => $forum_rows[$i]['forum_name'], 'FORUM_TOPICS' => $p_result['topics'], 'FORUM_POSTS' => $p_result['posts']));
    }
    $template->assign_vars(array('L_FORUM_PRUNE' => $lang['Forum_Prune'], 'L_FORUM' => $lang['Forum'], 'L_TOPICS_PRUNED' => $lang['Topics_pruned'], 'L_POSTS_PRUNED' => $lang['Posts_pruned'], 'L_PRUNE_RESULT' => $lang['Prune_success']));
} else {
    //
    // If they haven't selected a forum for pruning yet then
    // display a select box to use for pruning.
    //
    if (empty($HTTP_POST_VARS[POST_FORUM_URL])) {
        //
        // Output a selection table if no forum id has been specified.
        //
        $template->set_filenames(array('body' => 'forum_prune_select_body.tpl'));
开发者ID:BackupTheBerlios,项目名称:phpbbsfp,代码行数:31,代码来源:admin_forum_prune.php

示例11: delete_post


//.........这里部分代码省略.........
            $update_sql = update_post_information('forum', $forum_id, true);
            if (sizeof($update_sql)) {
                $sql_data[FORUMS_TABLE] .= $sql_data[FORUMS_TABLE] ? ', ' : '';
                $sql_data[FORUMS_TABLE] .= implode(', ', $update_sql[$forum_id]);
            }
            break;
        case 'delete_first_post':
            $sql = 'SELECT p.post_id, p.poster_id, p.post_time, p.post_username, u.username, u.user_colour
				FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u\n\t\t\t\tWHERE p.topic_id = {$topic_id}\n\t\t\t\t\tAND p.poster_id = u.user_id\n\t\t\t\tORDER BY p.post_time ASC";
            $result = $db->sql_query_limit($sql, 1);
            $row = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            if ($data['topic_type'] != POST_GLOBAL) {
                $sql_data[FORUMS_TABLE] = $data['post_approved'] ? 'forum_posts = forum_posts - 1' : '';
            }
            $sql_data[TOPICS_TABLE] = 'topic_poster = ' . intval($row['poster_id']) . ', topic_first_post_id = ' . intval($row['post_id']) . ", topic_first_poster_colour = '" . $db->sql_escape($row['user_colour']) . "', topic_first_poster_name = '" . ($row['poster_id'] == ANONYMOUS ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "', topic_time = " . (int) $row['post_time'];
            // Decrementing topic_replies here is fine because this case only happens if there is more than one post within the topic - basically removing one "reply"
            $sql_data[TOPICS_TABLE] .= ', topic_replies_real = topic_replies_real - 1' . ($data['post_approved'] ? ', topic_replies = topic_replies - 1' : '');
            $next_post_id = (int) $row['post_id'];
            break;
        case 'delete_last_post':
            if ($data['topic_type'] != POST_GLOBAL) {
                $sql_data[FORUMS_TABLE] = $data['post_approved'] ? 'forum_posts = forum_posts - 1' : '';
            }
            $update_sql = update_post_information('forum', $forum_id, true);
            if (sizeof($update_sql)) {
                $sql_data[FORUMS_TABLE] .= $sql_data[FORUMS_TABLE] ? ', ' : '';
                $sql_data[FORUMS_TABLE] .= implode(', ', $update_sql[$forum_id]);
            }
            $sql_data[TOPICS_TABLE] = 'topic_bumped = 0, topic_bumper = 0, topic_replies_real = topic_replies_real - 1' . ($data['post_approved'] ? ', topic_replies = topic_replies - 1' : '');
            $update_sql = update_post_information('topic', $topic_id, true);
            if (sizeof($update_sql)) {
                $sql_data[TOPICS_TABLE] .= ', ' . implode(', ', $update_sql[$topic_id]);
                $next_post_id = (int) str_replace('topic_last_post_id = ', '', $update_sql[$topic_id][0]);
            } else {
                $sql = 'SELECT MAX(post_id) as last_post_id
					FROM ' . POSTS_TABLE . "\n\t\t\t\t\tWHERE topic_id = {$topic_id} " . (!$auth->acl_get('m_approve', $forum_id) ? 'AND post_approved = 1' : '');
                $result = $db->sql_query($sql);
                $row = $db->sql_fetchrow($result);
                $db->sql_freeresult($result);
                $next_post_id = (int) $row['last_post_id'];
            }
            break;
        case 'delete':
            $sql = 'SELECT post_id
				FROM ' . POSTS_TABLE . "\n\t\t\t\tWHERE topic_id = {$topic_id} " . (!$auth->acl_get('m_approve', $forum_id) ? 'AND post_approved = 1' : '') . '
					AND post_time > ' . $data['post_time'] . '
				ORDER BY post_time ASC';
            $result = $db->sql_query_limit($sql, 1);
            $row = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            if ($data['topic_type'] != POST_GLOBAL) {
                $sql_data[FORUMS_TABLE] = $data['post_approved'] ? 'forum_posts = forum_posts - 1' : '';
            }
            $sql_data[TOPICS_TABLE] = 'topic_replies_real = topic_replies_real - 1' . ($data['post_approved'] ? ', topic_replies = topic_replies - 1' : '');
            $next_post_id = (int) $row['post_id'];
            break;
    }
    if ($post_mode == 'delete' || $post_mode == 'delete_last_post' || $post_mode == 'delete_first_post') {
        $sql = 'SELECT 1 AS has_attachments
			FROM ' . ATTACHMENTS_TABLE . '
			WHERE topic_id = ' . $topic_id;
        $result = $db->sql_query_limit($sql, 1);
        $has_attachments = (int) $db->sql_fetchfield('has_attachments');
        $db->sql_freeresult($result);
        if (!$has_attachments) {
            $sql_data[TOPICS_TABLE] .= ', topic_attachment = 0';
        }
    }
    //	$sql_data[USERS_TABLE] = ($data['post_postcount']) ? 'user_posts = user_posts - 1' : '';
    $db->sql_transaction('begin');
    $where_sql = array(FORUMS_TABLE => "forum_id = {$forum_id}", TOPICS_TABLE => "topic_id = {$topic_id}", USERS_TABLE => 'user_id = ' . $data['poster_id']);
    foreach ($sql_data as $table => $update_sql) {
        if ($update_sql) {
            $db->sql_query("UPDATE {$table} SET {$update_sql} WHERE " . $where_sql[$table]);
        }
    }
    // Adjust posted info for this user by looking for a post by him/her within this topic...
    if ($post_mode != 'delete_topic' && $config['load_db_track'] && $data['poster_id'] != ANONYMOUS) {
        $sql = 'SELECT poster_id
			FROM ' . POSTS_TABLE . '
			WHERE topic_id = ' . $topic_id . '
				AND poster_id = ' . $data['poster_id'];
        $result = $db->sql_query_limit($sql, 1);
        $poster_id = (int) $db->sql_fetchfield('poster_id');
        $db->sql_freeresult($result);
        // The user is not having any more posts within this topic
        if (!$poster_id) {
            $sql = 'DELETE FROM ' . TOPICS_POSTED_TABLE . '
				WHERE topic_id = ' . $topic_id . '
					AND user_id = ' . $data['poster_id'];
            $db->sql_query($sql);
        }
    }
    $db->sql_transaction('commit');
    if ($data['post_reported'] && $post_mode != 'delete_topic') {
        sync('topic_reported', 'topic_id', array($topic_id));
    }
    return $next_post_id;
}
开发者ID:tuxmania87,项目名称:GalaxyAdventures,代码行数:101,代码来源:functions_posting.php

示例12: main


//.........这里部分代码省略.........
										'topic_type'				=> POST_NORMAL,
										'topic_time_limit'			=> 0,
										'topic_attachment'			=> $post_ary['attach'])
									);
									$db->sql_query($sql);

									$new_topic_id = $db->sql_nextid();

									// Move posts
									$sql = 'UPDATE ' . POSTS_TABLE . "
										SET forum_id = $new_forum_id, topic_id = $new_topic_id
										WHERE topic_id = $topic_id
											AND poster_id = $user_id";
									$db->sql_query($sql);

									if ($post_ary['attach'])
									{
										$sql = 'UPDATE ' . ATTACHMENTS_TABLE . "
											SET topic_id = $new_topic_id
											WHERE topic_id = $topic_id
												AND poster_id = $user_id";
										$db->sql_query($sql);
									}

									$new_topic_id_ary[] = $new_topic_id;
								}
							}

							$forum_id_ary = array_unique($forum_id_ary);
							$topic_id_ary = array_unique(array_merge($topic_id_ary, $new_topic_id_ary));

							if (sizeof($topic_id_ary))
							{
								sync('reported', 'topic_id', $topic_id_ary);
								sync('topic', 'topic_id', $topic_id_ary);
							}

							if (sizeof($forum_id_ary))
							{
								sync('forum', 'forum_id', $forum_id_ary, false, true);
							}


							add_log('admin', 'LOG_USER_MOVE_POSTS', $user_row['username'], $forum_info['forum_name']);
							add_log('user', $user_id, 'LOG_USER_MOVE_POSTS_USER', $forum_info['forum_name']);

							trigger_error($user->lang['USER_POSTS_MOVED'] . adm_back_link($this->u_action . '&amp;u=' . $user_id));

						break;
					}

					// Handle registration info updates
					$data = array(
						'username'			=> utf8_normalize_nfc(request_var('user', $user_row['username'], true)),
						'user_founder'		=> request_var('user_founder', ($user_row['user_type'] == USER_FOUNDER) ? 1 : 0),
						'email'				=> strtolower(request_var('user_email', $user_row['user_email'])),
						'email_confirm'		=> strtolower(request_var('email_confirm', '')),
						'new_password'		=> request_var('new_password', '', true),
						'password_confirm'	=> request_var('password_confirm', '', true),
					);

					// Validation data - we do not check the password complexity setting here
					$check_ary = array(
						'new_password'		=> array(
							array('string', true, $config['min_pass_chars'], $config['max_pass_chars']),
							array('password')),
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:67,代码来源:acp_users.php

示例13: IN

         $new_topic_id = $db->sql_nextid();
         // Update topic watch table, switch users whose posts
         // have moved, over to watching the new topic
         $sql = "UPDATE " . TOPICS_WATCH_TABLE . " \n\t\t\t\t\tSET topic_id = {$new_topic_id} \n\t\t\t\t\tWHERE topic_id = {$topic_id} \n\t\t\t\t\t\tAND user_id IN ({$user_id_sql})";
         if (!$db->sql_query($sql)) {
             message_die(GENERAL_ERROR, 'Could not update topics watch table', '', __LINE__, __FILE__, $sql);
         }
         $sql_where = !empty($HTTP_POST_VARS['split_type_beyond']) ? " post_time >= {$post_time} AND topic_id = {$topic_id}" : "post_id IN ({$post_id_sql})";
         $sql = "UPDATE " . POSTS_TABLE . "\n\t\t\t\t\tSET topic_id = {$new_topic_id}, forum_id = {$new_forum_id} \n\t\t\t\t\tWHERE {$sql_where}";
         if (!$db->sql_query($sql, END_TRANSACTION)) {
             message_die(GENERAL_ERROR, 'Could not update posts table', '', __LINE__, __FILE__, $sql);
         }
         sync('topic', $new_topic_id);
         sync('topic', $topic_id);
         sync('forum', $new_forum_id);
         sync('forum', $forum_id);
         $template->assign_vars(array('META' => '<meta http-equiv="refresh" content="3;url=' . "viewtopic.{$phpEx}?" . POST_TOPIC_URL . "={$topic_id}&amp;sid=" . $userdata['session_id'] . '">'));
         $message = $lang['Topic_split'] . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . "viewtopic.{$phpEx}?" . POST_TOPIC_URL . "={$topic_id}&amp;sid=" . $userdata['session_id'] . '">', '</a>');
         message_die(GENERAL_MESSAGE, $message);
     }
 } else {
     //
     // Set template files
     //
     $template->set_filenames(array('split_body' => 'modcp_split.tpl'));
     $sql = "SELECT u.username, p.*, pt.post_text, pt.bbcode_uid, pt.post_subject, p.post_username\n\t\t\t\tFROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt\n\t\t\t\tWHERE p.topic_id = {$topic_id}\n\t\t\t\t\tAND p.poster_id = u.user_id\n\t\t\t\t\tAND p.post_id = pt.post_id\n\t\t\t\tORDER BY p.post_time ASC";
     if (!($result = $db->sql_query($sql))) {
         message_die(GENERAL_ERROR, 'Could not get topic/post information', '', __LINE__, __FILE__, $sql);
     }
     $s_hidden_fields = '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" /><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" /><input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '" /><input type="hidden" name="mode" value="split" />';
     if (($total_posts = $db->sql_numrows($result)) > 0) {
开发者ID:damncabbage,项目名称:publicwhip,代码行数:31,代码来源:modcp.php

示例14: move_forum_content

 /**
  * Move forum content from one to another forum
  */
 function move_forum_content($from_id, $to_id, $sync = true)
 {
     global $db;
     $table_ary = array(LOG_TABLE, POSTS_TABLE, TOPICS_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE);
     foreach ($table_ary as $table) {
         $sql = "UPDATE {$table}\n\t\t\t\tSET forum_id = {$to_id}\n\t\t\t\tWHERE forum_id = {$from_id}";
         $db->sql_query($sql);
     }
     unset($table_ary);
     $table_ary = array(FORUMS_ACCESS_TABLE, FORUMS_TRACK_TABLE, FORUMS_WATCH_TABLE, MODERATOR_CACHE_TABLE);
     foreach ($table_ary as $table) {
         $sql = "DELETE FROM {$table}\n\t\t\t\tWHERE forum_id = {$from_id}";
         $db->sql_query($sql);
     }
     if ($sync) {
         // Delete ghost topics that link back to the same forum then resync counters
         sync('topic_moved');
         sync('forum', 'forum_id', $to_id, false, true);
     }
     return array();
 }
开发者ID:PetsFundation,项目名称:Pets,代码行数:24,代码来源:acp_forums.php

示例15: change_poster

/**
* Change a post's poster
*/
function change_poster(&$post_info, $userdata)
{
    global $auth, $db, $config, $phpbb_root_path, $phpEx;
    if (empty($userdata) || $userdata['user_id'] == $post_info['user_id']) {
        return;
    }
    $post_id = $post_info['post_id'];
    $sql = 'UPDATE ' . POSTS_TABLE . "\n\t\tSET poster_id = {$userdata['user_id']}\n\t\tWHERE post_id = {$post_id}";
    $db->sql_query($sql);
    // Resync topic/forum if needed
    if ($post_info['topic_last_post_id'] == $post_id || $post_info['forum_last_post_id'] == $post_id || $post_info['topic_first_post_id'] == $post_id) {
        sync('topic', 'topic_id', $post_info['topic_id'], false, false);
        sync('forum', 'forum_id', $post_info['forum_id'], false, false);
    }
    // Adjust post counts... only if the post is approved (else, it was not added the users post count anyway)
    if ($post_info['post_postcount'] && $post_info['post_approved']) {
        $sql = 'UPDATE ' . USERS_TABLE . '
			SET user_posts = user_posts - 1
			WHERE user_id = ' . $post_info['user_id'] . '
			AND user_posts > 0';
        $db->sql_query($sql);
        $sql = 'UPDATE ' . USERS_TABLE . '
			SET user_posts = user_posts + 1
			WHERE user_id = ' . $userdata['user_id'];
        $db->sql_query($sql);
    }
    // Add posted to information for this topic for the new user
    markread('post', $post_info['forum_id'], $post_info['topic_id'], time(), $userdata['user_id']);
    // Remove the dotted topic option if the old user has no more posts within this topic
    if ($config['load_db_track'] && $post_info['user_id'] != ANONYMOUS) {
        $sql = 'SELECT topic_id
			FROM ' . POSTS_TABLE . '
			WHERE topic_id = ' . $post_info['topic_id'] . '
				AND poster_id = ' . $post_info['user_id'];
        $result = $db->sql_query_limit($sql, 1);
        $topic_id = (int) $db->sql_fetchfield('topic_id');
        $db->sql_freeresult($result);
        if (!$topic_id) {
            $sql = 'DELETE FROM ' . TOPICS_POSTED_TABLE . '
				WHERE user_id = ' . $post_info['user_id'] . '
					AND topic_id = ' . $post_info['topic_id'];
            $db->sql_query($sql);
        }
    }
    // change the poster_id within the attachments table, else the data becomes out of sync and errors displayed because of wrong ownership
    if ($post_info['post_attachment']) {
        $sql = 'UPDATE ' . ATTACHMENTS_TABLE . '
			SET poster_id = ' . $userdata['user_id'] . '
			WHERE poster_id = ' . $post_info['user_id'] . '
				AND post_msg_id = ' . $post_info['post_id'] . '
				AND topic_id = ' . $post_info['topic_id'];
        $db->sql_query($sql);
    }
    // refresh search cache of this post
    $search_type = basename($config['search_type']);
    if (file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx)) {
        require "{$phpbb_root_path}includes/search/{$search_type}.{$phpEx}";
        // We do some additional checks in the module to ensure it can actually be utilised
        $error = false;
        $search = new $search_type($error);
        if (!$error && method_exists($search, 'destroy_cache')) {
            $search->destroy_cache(array(), array($post_info['user_id'], $userdata['user_id']));
        }
    }
    $from_username = $post_info['username'];
    $to_username = $userdata['username'];
    // Renew post info
    $post_info = get_post_data(array($post_id), false, true);
    if (!sizeof($post_info)) {
        trigger_error('POST_NOT_EXIST');
    }
    $post_info = $post_info[$post_id];
    // Now add log entry
    add_log('mod', $post_info['forum_id'], $post_info['topic_id'], 'LOG_MCP_CHANGE_POSTER', $post_info['topic_title'], $from_username, $to_username);
}
开发者ID:ahmatjan,项目名称:Crimson,代码行数:78,代码来源:mcp_post.php


注:本文中的sync函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。