本文整理汇总了PHP中set_config_count函数的典型用法代码示例。如果您正苦于以下问题:PHP set_config_count函数的具体用法?PHP set_config_count怎么用?PHP set_config_count使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_config_count函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: dec
public static function dec($config_name, $decrement)
{
if (gettype(self::$default_config[$config_name]) != 'int' && gettype(self::$default_config[$config_name]) != 'integer') {
return false;
}
set_config_count(self::$prefix . $config_name, 0 - (int) $decrement, self::is_dynamic($config_name));
self::$config[$config_name] -= (int) $decrement;
return true;
}
开发者ID:phpbbgallery,项目名称:phpbb-gallery,代码行数:9,代码来源:config.php
示例2: setUp
protected function setUp()
{
parent::setUp();
global $cache, $config, $db, $phpbb_dispatcher, $phpbb_container;
$db = $this->db = $this->new_dbal();
$config = new \phpbb\config\config(array('load_online_time' => 5, 'search_type' => '\\phpbb\\search\\fulltext_mysql'));
set_config(false, false, false, $config);
set_config_count(false, false, false, $config);
$cache = new phpbb_mock_null_cache();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$phpbb_container = new phpbb_mock_container_builder();
$phpbb_container->set('notification_manager', new phpbb_mock_notification_manager());
}
开发者ID:Voxel37,项目名称:phpbb,代码行数:13,代码来源:delete_user_test.php
示例3: setUp
public function setUp()
{
global $phpbb_root_path, $phpEx, $phpbb_dispatcher, $user, $cache, $auth;
parent::setUp();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$db = $this->new_dbal();
$config = new \phpbb\config\config(array());
set_config(null, null, null, $config);
set_config_count(null, null, null, $config);
$cache = new \phpbb\cache\service(new \phpbb\cache\driver\null(), $config, $db, $phpbb_root_path, $phpEx);
$auth = $this->getMock('\\phpbb\\auth\\auth');
$auth->expects($this->any())->method('acl_get')->with($this->stringContains('_'), $this->anything())->will($this->returnValueMap(array(array('u_viewprofile', 1, false))));
$user = new \phpbb\user('\\phpbb\\datetime');
$user->data = array('user_lang' => 'en');
$user->add_lang('common');
$user_loader = new phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE);
$user_loader->load_users(array(2, 3, 4, 5, 6));
$this->notification = new phpbb_mock_notification_type_post($user_loader, null, null, $user, null, null, $phpbb_root_path, $phpEx, null, null, null);
}
开发者ID:Voxel37,项目名称:phpbb,代码行数:19,代码来源:user_list_trim_test.php
示例4: setUp
public function setUp()
{
parent::setUp();
global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $user, $request, $phpEx, $phpbb_root_path;
// Database
$this->db = $this->new_dbal();
$db = $this->db;
// Auth
$auth = $this->getMock('\\phpbb\\auth\\auth');
$auth->expects($this->any())->method('acl_get')->with($this->stringContains('_'), $this->anything())->will($this->returnValueMap(array(array('f_noapprove', 1, true), array('f_postcount', 1, true), array('m_edit', 1, false))));
// Config
$config = new \phpbb\config\config(array('num_topics' => 1, 'num_posts' => 1));
set_config(null, null, null, $config);
set_config_count(null, null, null, $config);
$cache = new \phpbb\cache\service(new \phpbb\cache\driver\null(), $config, $db, $phpbb_root_path, $phpEx);
// Event dispatcher
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
// User
$user = $this->getMock('\\phpbb\\user', array(), array('\\phpbb\\datetime'));
$user->ip = '';
$user->data = array('user_id' => 2, 'username' => 'user-name', 'is_registered' => true, 'user_colour' => '');
// Request
$type_cast_helper = $this->getMock('\\phpbb\\request\\type_cast_helper_interface');
$request = $this->getMock('\\phpbb\\request\\request');
// Container
$phpbb_container = new phpbb_mock_container_builder();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE));
$user_loader = new \phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE);
// Notification Types
$notification_types = array('quote', 'bookmark', 'post', 'post_in_queue', 'topic', 'topic_in_queue', 'approve_topic', 'approve_post');
$notification_types_array = array();
foreach ($notification_types as $type) {
$class_name = '\\phpbb\\notification\\type\\' . $type;
$class = new $class_name($user_loader, $db, $cache->get_driver(), $user, $auth, $config, $phpbb_root_path, $phpEx, NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE);
$phpbb_container->set('notification.type.' . $type, $class);
$notification_types_array['notification.type.' . $type] = $class;
}
// Notification Manager
$phpbb_notifications = new \phpbb\notification\manager($notification_types_array, array(), $phpbb_container, $user_loader, $config, $phpbb_dispatcher, $db, $cache, $user, $phpbb_root_path, $phpEx, NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE);
$phpbb_container->set('notification_manager', $phpbb_notifications);
}
开发者ID:Voxel37,项目名称:phpbb,代码行数:42,代码来源:submit_post_base.php
示例5: test_delete_post
/**
* @dataProvider delete_post_data
*/
public function test_delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason, $expected_posts, $expected_topic, $expected_forum, $expected_user)
{
global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx;
$config['search_type'] = 'phpbb_mock_search';
$cache = new phpbb_mock_cache();
$db = $this->new_dbal();
$phpbb_config = new \phpbb\config\config(array('num_posts' => 3, 'num_topics' => 1));
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
set_config_count(null, null, null, $phpbb_config);
// Create auth mock
$auth = $this->getMock('\\phpbb\\auth\\auth');
$auth->expects($this->any())->method('acl_get')->with($this->stringContains('_'), $this->anything())->will($this->returnValueMap(array(array('m_approve', 1, true))));
$user = new \phpbb\user('\\phpbb\\datetime');
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$phpbb_container = new phpbb_mock_container_builder();
$phpbb_container->set('notification_manager', new phpbb_mock_notification_manager());
$phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $phpbb_config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE));
delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason);
$result = $db->sql_query('SELECT post_id, post_visibility, post_delete_reason
FROM phpbb_posts
WHERE topic_id = ' . $topic_id . '
ORDER BY post_id ASC');
$this->assertEquals($expected_posts, $db->sql_fetchrowset($result));
$db->sql_freeresult($result);
$result = $db->sql_query('SELECT topic_visibility, topic_first_post_id, topic_last_post_id, topic_posts_approved, topic_posts_unapproved, topic_posts_softdeleted, topic_delete_reason
FROM phpbb_topics
WHERE topic_id = ' . $topic_id);
$this->assertEquals($expected_topic, $db->sql_fetchrowset($result));
$db->sql_freeresult($result);
$result = $db->sql_query('SELECT forum_posts_approved, forum_posts_unapproved, forum_posts_softdeleted, forum_topics_approved, forum_topics_unapproved, forum_topics_softdeleted, forum_last_post_id
FROM phpbb_forums
WHERE forum_id = ' . $forum_id);
$this->assertEquals($expected_forum, $db->sql_fetchrowset($result));
$db->sql_freeresult($result);
$sql = 'SELECT user_posts
FROM ' . USERS_TABLE . '
WHERE user_id = ' . (int) $data['poster_id'];
$result = $db->sql_query($sql);
$this->assertEquals($expected_user, $db->sql_fetchrowset($result));
$db->sql_freeresult($result);
}
开发者ID:Voxel37,项目名称:phpbb,代码行数:44,代码来源:delete_post_test.php
示例6: register_compatibility_globals
/**
* Sets compatibility globals in the global scope
*
* This function registers compatibility variables to the global
* variable scope. This is required to make it possible to include this file
* in a service.
*/
function register_compatibility_globals()
{
global $phpbb_container;
global $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log;
global $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template;
// set up caching
/* @var $cache \phpbb\cache\service */
$cache = $phpbb_container->get('cache');
// Instantiate some basic classes
/* @var $phpbb_dispatcher \phpbb\event\dispatcher */
$phpbb_dispatcher = $phpbb_container->get('dispatcher');
/* @var $request \phpbb\request\request_interface */
$request = $phpbb_container->get('request');
// Inject request instance, so only this instance is used with request_var
request_var('', 0, false, false, $request);
/* @var $user \phpbb\user */
$user = $phpbb_container->get('user');
/* @var $auth \phpbb\auth\auth */
$auth = $phpbb_container->get('auth');
/* @var $db \phpbb\db\driver\driver_interface */
$db = $phpbb_container->get('dbal.conn');
// Grab global variables, re-cache if necessary
/* @var $config phpbb\config\db */
$config = $phpbb_container->get('config');
set_config('', '', false, $config);
set_config_count('', 0, false, $config);
/* @var $phpbb_log \phpbb\log\log_interface */
$phpbb_log = $phpbb_container->get('log');
/* @var $symfony_request \phpbb\symfony_request */
$symfony_request = $phpbb_container->get('symfony_request');
/* @var $phpbb_filesystem \phpbb\filesystem\filesystem_interface */
$phpbb_filesystem = $phpbb_container->get('filesystem');
/* @var $phpbb_path_helper \phpbb\path_helper */
$phpbb_path_helper = $phpbb_container->get('path_helper');
// load extensions
/* @var $phpbb_extension_manager \phpbb\extension\manager */
$phpbb_extension_manager = $phpbb_container->get('ext.manager');
/* @var $template \phpbb\template\template */
$template = $phpbb_container->get('template');
}
开发者ID:phpbb,项目名称:phpbb,代码行数:47,代码来源:compatibility_globals.php
示例7: user_active_flip
/**
* Flips user_type from active to inactive and vice versa, handles group membership updates
*
* @param string $mode can be flip for flipping from active/inactive, activate or deactivate
*/
function user_active_flip($mode, $user_id_ary, $reason = INACTIVE_MANUAL)
{
global $config, $db, $user, $auth;
$deactivated = $activated = 0;
$sql_statements = array();
if (!is_array($user_id_ary)) {
$user_id_ary = array($user_id_ary);
}
if (!sizeof($user_id_ary)) {
return;
}
$sql = 'SELECT user_id, group_id, user_type, user_inactive_reason
FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', $user_id_ary);
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$sql_ary = array();
if ($row['user_type'] == USER_IGNORE || $row['user_type'] == USER_FOUNDER || $mode == 'activate' && $row['user_type'] != USER_INACTIVE || $mode == 'deactivate' && $row['user_type'] == USER_INACTIVE) {
continue;
}
if ($row['user_type'] == USER_INACTIVE) {
$activated++;
} else {
$deactivated++;
// Remove the users session key...
$user->reset_login_keys($row['user_id']);
}
$sql_ary += array('user_type' => $row['user_type'] == USER_NORMAL ? USER_INACTIVE : USER_NORMAL, 'user_inactive_time' => $row['user_type'] == USER_NORMAL ? time() : 0, 'user_inactive_reason' => $row['user_type'] == USER_NORMAL ? $reason : 0);
$sql_statements[$row['user_id']] = $sql_ary;
}
$db->sql_freeresult($result);
if (sizeof($sql_statements)) {
foreach ($sql_statements as $user_id => $sql_ary) {
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . $user_id;
$db->sql_query($sql);
}
$auth->acl_clear_prefetch(array_keys($sql_statements));
}
if ($deactivated) {
set_config_count('num_users', $deactivated * -1, true);
}
if ($activated) {
set_config_count('num_users', $activated, true);
}
// Update latest username
update_last_username();
}
开发者ID:eyumay,项目名称:ju.ejhs,代码行数:54,代码来源:functions_user.php
示例8: submit_post
//.........这里部分代码省略.........
* @var bool sql_data Array with the data for the posting SQL query
* @var string subject Variable containing post subject value
* @var int topic_type Variable containing topic type value
* @var string username Variable containing post author name
* @since 3.1.3-RC1
*/
$vars = array('data', 'poll', 'post_mode', 'sql_data', 'subject', 'topic_type', 'username');
extract($phpbb_dispatcher->trigger_event('core.submit_post_modify_sql_data', compact($vars)));
// Submit new topic
if ($post_mode == 'post') {
$sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_data[TOPICS_TABLE]['sql']);
$db->sql_query($sql);
$data['topic_id'] = $db->sql_nextid();
$sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array('topic_id' => $data['topic_id']));
unset($sql_data[TOPICS_TABLE]['sql']);
}
// Submit new post
if ($post_mode == 'post' || $post_mode == 'reply') {
if ($post_mode == 'reply') {
$sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array('topic_id' => $data['topic_id']));
}
$sql = 'INSERT INTO ' . POSTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_data[POSTS_TABLE]['sql']);
$db->sql_query($sql);
$data['post_id'] = $db->sql_nextid();
if ($post_mode == 'post' || $post_visibility == ITEM_APPROVED) {
$sql_data[TOPICS_TABLE]['sql'] = array('topic_last_post_id' => $data['post_id'], 'topic_last_post_time' => $current_time, 'topic_last_poster_id' => $sql_data[POSTS_TABLE]['sql']['poster_id'], 'topic_last_poster_name' => $user->data['user_id'] == ANONYMOUS ? $sql_data[POSTS_TABLE]['sql']['post_username'] : $user->data['username'], 'topic_last_poster_colour' => $user->data['user_colour'], 'topic_last_post_subject' => (string) $subject);
}
if ($post_mode == 'post') {
$sql_data[TOPICS_TABLE]['sql']['topic_first_post_id'] = $data['post_id'];
}
// Update total post count and forum information
if ($post_visibility == ITEM_APPROVED) {
if ($post_mode == 'post') {
set_config_count('num_topics', 1, true);
}
set_config_count('num_posts', 1, true);
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = ' . $data['post_id'];
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . $db->sql_escape($subject) . "'";
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = ' . $current_time;
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = ' . (int) $user->data['user_id'];
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape(!$user->data['is_registered'] && $username ? $username : ($user->data['user_id'] != ANONYMOUS ? $user->data['username'] : '')) . "'";
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = '" . $db->sql_escape($user->data['user_colour']) . "'";
}
unset($sql_data[POSTS_TABLE]['sql']);
}
// Update the topics table
if (isset($sql_data[TOPICS_TABLE]['sql'])) {
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_data[TOPICS_TABLE]['sql']) . '
WHERE topic_id = ' . $data['topic_id'];
$db->sql_query($sql);
unset($sql_data[TOPICS_TABLE]['sql']);
}
// Update the posts table
if (isset($sql_data[POSTS_TABLE]['sql'])) {
$sql = 'UPDATE ' . POSTS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_data[POSTS_TABLE]['sql']) . '
WHERE post_id = ' . $data['post_id'];
$db->sql_query($sql);
unset($sql_data[POSTS_TABLE]['sql']);
}
// Update Poll Tables
if (isset($poll['poll_options'])) {
$cur_poll_options = array();
if ($mode == 'edit') {
$sql = 'SELECT *
开发者ID:Tarendai,项目名称:spring-website,代码行数:67,代码来源:functions_posting.php
示例9: submit_pm
//.........这里部分代码省略.........
$query = '';
if ($mode == 'post' || $mode == 'reply' || $mode == 'quote' || $mode == 'quotepost' || $mode == 'forward') {
$db->sql_query('INSERT INTO ' . PRIVMSGS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_data));
$data['msg_id'] = $db->sql_nextid();
} else {
if ($mode == 'edit') {
$sql = 'UPDATE ' . PRIVMSGS_TABLE . '
SET message_edit_count = message_edit_count + 1, ' . $db->sql_build_array('UPDATE', $sql_data) . '
WHERE msg_id = ' . $data['msg_id'];
$db->sql_query($sql);
}
}
}
if ($mode != 'edit') {
if ($sql) {
$db->sql_query($sql);
}
unset($sql);
$sql_ary = array();
foreach ($recipients as $user_id => $type) {
$sql_ary[] = array('msg_id' => (int) $data['msg_id'], 'user_id' => (int) $user_id, 'author_id' => (int) $data['from_user_id'], 'folder_id' => PRIVMSGS_NO_BOX, 'pm_new' => 1, 'pm_unread' => 1, 'pm_forwarded' => $mode == 'forward' ? 1 : 0);
}
$db->sql_multi_insert(PRIVMSGS_TO_TABLE, $sql_ary);
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_new_privmsg = user_new_privmsg + 1, user_unread_privmsg = user_unread_privmsg + 1, user_last_privmsg = ' . time() . '
WHERE ' . $db->sql_in_set('user_id', array_keys($recipients));
$db->sql_query($sql);
// Put PM into outbox
if ($put_in_outbox) {
$db->sql_query('INSERT INTO ' . PRIVMSGS_TO_TABLE . ' ' . $db->sql_build_array('INSERT', array('msg_id' => (int) $data['msg_id'], 'user_id' => (int) $data['from_user_id'], 'author_id' => (int) $data['from_user_id'], 'folder_id' => PRIVMSGS_OUTBOX, 'pm_new' => 0, 'pm_unread' => 0, 'pm_forwarded' => $mode == 'forward' ? 1 : 0)));
}
}
// Set user last post time
if ($mode == 'reply' || $mode == 'quote' || $mode == 'quotepost' || $mode == 'forward' || $mode == 'post') {
$sql = 'UPDATE ' . USERS_TABLE . "\n\t\t\tSET user_lastpost_time = {$current_time}\n\t\t\tWHERE user_id = " . $data['from_user_id'];
$db->sql_query($sql);
}
// Submit Attachments
if (!empty($data['attachment_data']) && $data['msg_id'] && in_array($mode, array('post', 'reply', 'quote', 'quotepost', 'edit', 'forward'))) {
$space_taken = $files_added = 0;
$orphan_rows = array();
foreach ($data['attachment_data'] as $pos => $attach_row) {
$orphan_rows[(int) $attach_row['attach_id']] = array();
}
if (sizeof($orphan_rows)) {
$sql = 'SELECT attach_id, filesize, physical_filename
FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . $db->sql_in_set('attach_id', array_keys($orphan_rows)) . '
AND in_message = 1
AND is_orphan = 1
AND poster_id = ' . $user->data['user_id'];
$result = $db->sql_query($sql);
$orphan_rows = array();
while ($row = $db->sql_fetchrow($result)) {
$orphan_rows[$row['attach_id']] = $row;
}
$db->sql_freeresult($result);
}
foreach ($data['attachment_data'] as $pos => $attach_row) {
if ($attach_row['is_orphan'] && !isset($orphan_rows[$attach_row['attach_id']])) {
continue;
}
if (!$attach_row['is_orphan']) {
// update entry in db if attachment already stored in db and filespace
$sql = 'UPDATE ' . ATTACHMENTS_TABLE . "\n\t\t\t\t\tSET attach_comment = '" . $db->sql_escape($attach_row['attach_comment']) . "'\n\t\t\t\t\tWHERE attach_id = " . (int) $attach_row['attach_id'] . '
AND is_orphan = 0';
$db->sql_query($sql);
} else {
// insert attachment into db
if (!@file_exists($phpbb_root_path . $config['upload_path'] . '/' . utf8_basename($orphan_rows[$attach_row['attach_id']]['physical_filename']))) {
continue;
}
$space_taken += $orphan_rows[$attach_row['attach_id']]['filesize'];
$files_added++;
$attach_sql = array('post_msg_id' => $data['msg_id'], 'topic_id' => 0, 'is_orphan' => 0, 'poster_id' => $data['from_user_id'], 'attach_comment' => $attach_row['attach_comment']);
$sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $attach_sql) . '
WHERE attach_id = ' . $attach_row['attach_id'] . '
AND is_orphan = 1
AND poster_id = ' . $user->data['user_id'];
$db->sql_query($sql);
}
}
if ($space_taken && $files_added) {
set_config_count('upload_dir_size', $space_taken, true);
set_config_count('num_files', $files_added, true);
}
}
// Delete draft if post was loaded...
$draft_id = request_var('draft_loaded', 0);
if ($draft_id) {
$sql = 'DELETE FROM ' . DRAFTS_TABLE . "\n\t\t\tWHERE draft_id = {$draft_id}\n\t\t\t\tAND user_id = " . $data['from_user_id'];
$db->sql_query($sql);
}
$db->sql_transaction('commit');
// Send Notifications
if ($mode != 'edit') {
pm_notification($mode, $data['from_username'], $recipients, $subject, $data['message']);
}
return $data['msg_id'];
}
开发者ID:BACKUPLIB,项目名称:mwenhanced,代码行数:101,代码来源:functions_privmsgs.php
示例10: submit_post
//.........这里部分代码省略.........
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts + 1';
}
break;
case 'edit_topic':
case 'edit_first_post':
if (isset($poll['poll_options'])) {
$poll_start = $poll['poll_start'] || empty($poll['poll_options']) ? $poll['poll_start'] : $current_time;
$poll_length = $poll['poll_length'] * 86400;
if ($poll_length < 0) {
$poll_start = $poll_start + $poll_length;
if ($poll_start < 0) {
$poll_start = 0;
}
$poll_length = 1;
}
}
$sql_data[TOPICS_TABLE]['sql'] = array('forum_id' => $topic_type == POST_GLOBAL ? 0 : $data['forum_id'], 'icon_id' => $data['icon_id'], 'topic_approved' => !$post_approval ? 0 : $data['topic_approved'], 'topic_title' => $subject, 'topic_first_poster_name' => $username, 'topic_type' => $topic_type, 'topic_time_limit' => $topic_type == POST_STICKY || $topic_type == POST_ANNOUNCE ? $data['topic_time_limit'] * 86400 : 0, 'poll_title' => isset($poll['poll_options']) ? $poll['poll_title'] : '', 'poll_start' => isset($poll['poll_options']) ? $poll_start : 0, 'poll_max_options' => isset($poll['poll_options']) ? $poll['poll_max_options'] : 1, 'poll_length' => isset($poll['poll_options']) ? $poll_length : 0, 'poll_vote_change' => isset($poll['poll_vote_change']) ? $poll['poll_vote_change'] : 0, 'topic_last_view_time' => $current_time, 'topic_attachment' => !empty($data['attachment_data']) ? 1 : (isset($data['topic_attachment']) ? $data['topic_attachment'] : 0));
// Correctly set back the topic replies and forum posts... only if the topic was approved before and now gets disapproved
if (!$post_approval && $data['topic_approved']) {
// Do we need to grab some topic informations?
if (!sizeof($topic_row)) {
$sql = 'SELECT topic_type, topic_replies, topic_replies_real, topic_approved
FROM ' . TOPICS_TABLE . '
WHERE topic_id = ' . $data['topic_id'];
$result = $db->sql_query($sql);
$topic_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
}
// If this is the only post remaining we do not need to decrement topic_replies.
// Also do not decrement if first post - then the topic_replies will not be adjusted if approving the topic again.
// If this is an edited topic or the first post the topic gets completely disapproved later on...
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics = forum_topics - 1';
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts - ' . ($topic_row['topic_replies'] + 1);
set_config_count('num_topics', -1, true);
set_config_count('num_posts', ($topic_row['topic_replies'] + 1) * -1, true);
// Only decrement this post, since this is the one non-approved now
if ($auth->acl_get('f_postcount', $data['forum_id'])) {
$sql_data[USERS_TABLE]['stat'][] = 'user_posts = user_posts - 1';
}
}
break;
case 'edit':
case 'edit_last_post':
// Correctly set back the topic replies and forum posts... but only if the post was approved before.
if (!$post_approval && $data['post_approved']) {
$sql_data[TOPICS_TABLE]['stat'][] = 'topic_replies = topic_replies - 1, topic_last_view_time = ' . $current_time;
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts - 1';
set_config_count('num_posts', -1, true);
if ($auth->acl_get('f_postcount', $data['forum_id'])) {
$sql_data[USERS_TABLE]['stat'][] = 'user_posts = user_posts - 1';
}
}
break;
}
// Submit new topic
if ($post_mode == 'post') {
$sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_data[TOPICS_TABLE]['sql']);
$db->sql_query($sql);
$data['topic_id'] = $db->sql_nextid();
$sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array('topic_id' => $data['topic_id']));
unset($sql_data[TOPICS_TABLE]['sql']);
}
// Submit new post
if ($post_mode == 'post' || $post_mode == 'reply') {
if ($post_mode == 'reply') {
$sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array('topic_id' => $data['topic_id']));
开发者ID:tuxmania87,项目名称:GalaxyAdventures,代码行数:67,代码来源:functions_posting.php
示例11: main
function main($mode, $sub)
{
global $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language;
global $request, $phpbb_admin_path, $phpbb_adm_relative_path, $phpbb_container, $phpbb_config_php_file;
// We must enable super globals, otherwise creating a new instance of the request class,
// using the new container with a dbal connection will fail with the following PHP Notice:
// Object of class phpbb_request_deactivated_super_global could not be converted to int
$request->enable_super_globals();
// Create a normal container now
$phpbb_container_builder = new \phpbb\di\container_builder($phpbb_config_php_file, $phpbb_root_path, $phpEx);
$phpbb_container_builder->set_dump_container(false);
$phpbb_container_builder->set_use_extensions(false);
if (file_exists($phpbb_root_path . 'install/update/new/config')) {
$phpbb_container_builder->set_config_path($phpbb_root_path . 'install/update/new/config');
}
$phpbb_container = $phpbb_container_builder->get_container();
// Writes into global $cache
$cache = $phpbb_container->get('cache');
$this->tpl_name = 'install_update';
$this->page_title = 'UPDATE_INSTALLATION';
$this->old_location = $phpbb_root_path . 'install/update/old/';
$this->new_location = $phpbb_root_path . 'install/update/new/';
// Init DB
extract($phpbb_config_php_file->get_all());
require $phpbb_root_path . 'includes/constants.' . $phpEx;
// Special options for conflicts/modified files
define('MERGE_NO_MERGE_NEW', 1);
define('MERGE_NO_MERGE_MOD', 2);
define('MERGE_NEW_FILE', 3);
define('MERGE_MOD_FILE', 4);
$dbms = $phpbb_config_php_file->convert_30_dbms_to_31($dbms);
$db = new $dbms();
// Connect to DB
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false);
// We do not need this any longer, unset for safety purposes
unset($dbpasswd);
// We need to fill the config to let internal functions correctly work
$config = new \phpbb\config\db($db, new \phpbb\cache\driver\null(), CONFIG_TABLE);
set_config(null, null, null, $config);
set_config_count(null, null, null, $config);
// Force template recompile
$config['load_tplcompile'] = 1;
// First of all, init the user session
$user->session_begin();
$auth->acl($user->data);
// Overwrite user's language with the selected one.
// Config needs to be changed to ensure that guests also get the selected language.
$config_default_lang = $config['default_lang'];
$config['default_lang'] = $language;
$user->data['user_lang'] = $language;
$user->add_lang(array('common', 'acp/common', 'acp/board', 'install', 'posting'));
// Reset the default_lang
$config['default_lang'] = $config_default_lang;
unset($config_default_lang);
// If we are within the intro page we need to make sure we get up-to-date version info
if ($sub == 'intro') {
$cache->destroy('_version_info');
}
// Set custom template again. ;)
$paths = array($phpbb_root_path . 'install/update/new/adm/style', $phpbb_admin_path . 'style');
$paths = array_filter($paths, 'is_dir');
$template->set_custom_style(array(array('name' => 'adm', 'ext_path' => 'adm/style/')), $paths);
$template->assign_vars(array('S_USER_LANG' => $user->lang['USER_LANG'], 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'], 'S_CONTENT_ENCODING' => 'UTF-8', 'S_CONTENT_FLOW_BEGIN' => $user->lang['DIRECTION'] == 'ltr' ? 'left' : 'right', 'S_CONTENT_FLOW_END' => $user->lang['DIRECTION'] == 'ltr' ? 'right' : 'left'));
// Get current and latest version
$version_helper = $phpbb_container->get('version_helper');
try {
$this->latest_version = $version_helper->get_latest_on_current_branch(true);
} catch (\RuntimeException $e) {
$this->latest_version = false;
$update_info = array();
include $phpbb_root_path . 'install/update/index.' . $phpEx;
$info = empty($update_info) || !is_array($update_info) ? false : $update_info;
if ($info !== false) {
$this->latest_version = !empty($info['version']['to']) ? trim($info['version']['to']) : false;
}
}
// For the current version we trick a bit. ;)
$this->current_version = !empty($config['version_update_from']) ? $config['version_update_from'] : $config['version'];
$up_to_date = version_compare(str_replace('rc', 'RC', strtolower($this->current_version)), str_replace('rc', 'RC', strtolower($this->latest_version)), '<') ? false : true;
// Check for a valid update directory, else point the user to the phpbb.com website
if (!file_exists($phpbb_root_path . 'install/update') || !file_exists($phpbb_root_path . 'install/update/index.' . $phpEx) || !file_exists($this->old_location) || !file_exists($this->new_location)) {
$template->assign_vars(array('S_ERROR' => true, 'ERROR_MSG' => $up_to_date ? $user->lang['NO_UPDATE_FILES_UP_TO_DATE'] : sprintf($user->lang['NO_UPDATE_FILES_OUTDATED'], $config['version'], $this->current_version, $this->latest_version)));
return;
}
$this->update_info = $this->get_file('update_info');
// Make sure the update directory holds the correct information
// Since admins are able to run the update/checks more than once we only check if the current version is lower or equal than the version to which we update to.
if (version_compare(str_replace('rc', 'RC', strtolower($this->current_version)), str_replace('rc', 'RC', strtolower($this->update_info['version']['to'])), '>')) {
$template->assign_vars(array('S_ERROR' => true, 'ERROR_MSG' => sprintf($user->lang['INCOMPATIBLE_UPDATE_FILES'], $config['version'], $this->update_info['version']['from'], $this->update_info['version']['to'])));
return;
}
// Check if the update files are actually meant to update from the current version
if ($this->current_version != $this->update_info['version']['from']) {
$template->assign_vars(array('S_ERROR' => true, 'ERROR_MSG' => sprintf($user->lang['INCOMPATIBLE_UPDATE_FILES'], $this->current_version, $this->update_info['version']['from'], $this->update_info['version']['to'])));
}
// Check if the update files stored are for the latest version...
if (version_compare(strtolower($this->latest_version), strtolower($this->update_info['version']['to']), '>')) {
$template->assign_vars(array('S_WARNING' => true, 'WARNING_MSG' => sprintf($user->lang['OLD_UPDATE_FILES'], $this->update_info['version']['from'], $this->update_info['version']['to'], $this->latest_version)));
}
// We store the "update to" version, because it is not always the latest. ;)
//.........这里部分代码省略.........
开发者ID:Voxel37,项目名称:phpbb,代码行数:101,代码来源:install_update.php
示例12: convert_data
/**
* The function which does the actual work (or dispatches it to the relevant places)
*/
function convert_data($sub)
{
global $template, $user, $phpbb_root_path, $phpEx, $db, $lang, $config, $cache, $auth;
global $convert, $convert_row, $message_parser, $skip_rows, $language;
global $request, $phpbb_config_php_file;
extract($phpbb_config_php_file->get_all());
require $phpbb_root_path . 'includes/constants.' . $phpEx;
require $phpbb_root_path . 'includes/functions_convert.' . $phpEx;
$dbms = $phpbb_config_php_file->convert_30_dbms_to_31($dbms);
$db = new $dbms();
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true);
unset($dbpasswd);
// We need to fill the config to let internal functions correctly work
$config = new \phpbb\config\db($db, new \phpbb\cache\driver\null(), CONFIG_TABLE);
set_config(null, null, null, $config);
set_config_count(null, null, null, $config);
// Override a couple of config variables for the duration
$config['max_quote_depth'] = 0;
// @todo Need to confirm that max post length in source is <= max post length in destination or there may be interesting formatting issues
$config['max_post_chars'] = $config['min_post_chars'] = 0;
// Set up a user as well. We _should_ have enough of a database here at this point to do this
// and it helps for any core code we call
$user->session_begin();
$user->page = $user->extract_current_page($phpbb_root_path);
// This is a little bit of a fudge, but it allows the language entries to be available to the
// core code without us loading them again
$user->lang =& $lang;
$this->page_title = $user->lang['STAGE_IN_PROGRESS'];
$convert->options = array();
if (isset($config['convert_progress'])) {
$convert->options = unserialize($config['convert_progress']);
$convert->options = array_merge($convert->options, unserialize($config['convert_db_server']), unserialize($config['convert_db_user']), unserialize($config['convert_options']));
}
// This information should have already been checked once, but do it again for safety
if (empty($convert->options) || empty($convert->options['tag']) || !isset($convert->options['dbms']) || !isset($convert->options['dbhost']) || !isset($convert->options['dbport']) || !isset($convert->options['dbuser']) || !isset($convert->options['dbpasswd']) || !isset($convert->options['dbname']) || !isset($convert->options['table_prefix'])) {
$this->p_master->error($user->lang['NO_CONVERT_SPECIFIED'], __LINE__, __FILE__);
}
// Make some short variables accessible, for easier referencing
$convert->convertor_tag = basename($convert->options['tag']);
$convert->src_dbms = $convert->options['dbms'];
$convert->src_dbhost = $convert->options['dbhost'];
$convert->src_dbport = $convert->options['dbport'];
$convert->src_dbuser = $convert->options['dbuser'];
$convert->src_dbpasswd = $convert->options['dbpasswd'];
$convert->src_dbname = $convert->options['dbname'];
$convert->src_table_prefix = $convert->options['table_prefix'];
// initiate database connection to old db if old and new db differ
global $src_db, $same_db;
$src_db = $same_db = null;
if ($convert->src_dbms != $dbms || $convert->src_dbhost != $dbhost || $convert->src_dbport != $dbport || $convert->src_dbname != $dbname || $convert->src_dbuser != $dbuser) {
$dbms = $convert->src_dbms;
$src_db = new $dbms();
$src_db->sql_connect($convert->src_dbhost, $convert->src_dbuser, htmlspecialchars_decode($convert->src_dbpasswd), $convert->src_dbname, $convert->src_dbport, false, true);
$same_db = false;
} else {
$src_db = $db;
$same_db = true;
}
$convert->mysql_convert = false;
switch ($src_db->sql_layer) {
case 'sqlite':
case 'sqlite3':
$convert->src_truncate_statement = 'DELETE FROM ';
break;
// Thanks MySQL, for silently converting...
// Thanks MySQL, for silently converting...
case 'mysql':
case 'mysql4':
if (version_compare($src_db->sql_server_info(true, false), '4.1.3', '>=')) {
$convert->mysql_convert = true;
}
$convert->src_truncate_statement = 'TRUNCATE TABLE ';
break;
case 'mysqli':
$convert->mysql_convert = true;
$convert->src_truncate_statement = 'TRUNCATE TABLE ';
break;
default:
$convert->src_truncate_statement = 'TRUNCATE TABLE ';
break;
}
if ($convert->mysql_convert && !$same_db) {
$src_db->sql_query("SET NAMES 'binary'");
}
switch ($db->get_sql_layer()) {
case 'sqlite':
case 'sqlite3':
$convert->truncate_statement = 'DELETE FROM ';
break;
default:
$convert->truncate_statement = 'TRUNCATE TABLE ';
break;
}
$get_info = false;
// check security implications of direct inclusion
if (!file_exists('./convertors/convert_' . $convert->convertor_tag . '.' . $phpEx)) {
$this->p_master->error($user->lang['CONVERT_NOT_EXIST'], __LINE__, __FILE__);
//.........这里部分代码省略.........
开发者ID:Voxel37,项目名称:phpbb,代码行数:101,代码来源:install_convert.php
示例13: delete_attachments
//.........这里部分代码省略.........
}
// Delete attachments from filesystem
$space_removed = $files_removed = 0;
foreach ($physical as $file_ary) {
if (phpbb_unlink($file_ary['filename'], 'file', true) && !$file_ary['is_orphan']) {
// Only non-orphaned files count to the file size
$space_removed += $file_ary['filesize'];
$files_removed++;
}
if ($file_ary['thumbnail']) {
phpbb_unlink($file_ary['filename'], 'thumbnail', true);
}
}
/**
* Perform additional actions after attachment(s) deletion from the filesystem
*
* @event core.delete_attachments_from_filesystem_after
* @var string mode Variable containing attachments deletion mode, can be: post|message|topic|attach|user
* @var mixed ids Array or comma separated list of ids corresponding to the mode
* @var bool resync Flag indicating if posts/messages/topics should be synchronized
* @var string sql_id The field name to collect/delete data for depending on the mode
* @var array post_ids Array with post ids for deleted attachment(s)
* @var array topic_ids Array with topic ids for deleted attachment(s)
* @var array message_ids Array with private message ids for deleted attachment(s)
* @var array physical Array with deleted attachment(s) physical file(s) data
* @var int num_deleted The number of deleted attachment(s) from the database
* @var int space_removed The size of deleted files(s) from the filesystem
* @var int files_removed The number of deleted file(s) from the filesystem
* @since 3.1.7-RC1
*/
$vars = array('mode', 'ids', 'resync', 'sql_id', 'post_ids', 'topic_ids', 'message_ids', 'physical', 'num_deleted', 'space_removed', 'files_removed');
extract($phpbb_dispatcher->trigger_event('core.delete_attachments_from_filesystem_after', compact($vars)));
if ($space_removed || $files_removed) {
set_config_count('upload_dir_size', $space_removed * -1, true);
set_config_count('num_files', $files_removed * -1, true);
}
// If we do not resync, we do not need to adjust any message, post, topic or user entries
if (!$resync) {
return $num_deleted;
}
// No more use for the original ids
unset($ids);
// Now, we need to resync posts, messages, topics. We go through every one of them
$post_ids = array_unique($post_ids);
$message_ids = array_unique($message_ids);
$topic_ids = array_unique($topic_ids);
// Update post indicators for posts now no longer having attachments
if (sizeof($post_ids)) {
// Just check which posts are still having an assigned attachment not orphaned by querying the attachments table
$sql = 'SELECT post_msg_id
FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . $db->sql_in_set('post_msg_id', $post_ids) . '
AND in_message = 0
AND is_orphan = 0';
$result = $db->sql_query($sql);
$remaining_ids = array();
while ($row = $db->sql_fetchrow($result)) {
$remaining_ids[] = $row['post_msg_id'];
}
$db->sql_freeresult($result);
// Now only unset those ids remaining
$post_ids = array_diff($post_ids, $remaining_ids);
if (sizeof($post_ids)) {
$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_attachment = 0
WHERE ' . $db->sql_in_set('post_id', $post_ids);
开发者ID:WarriorMachines,项目名称:warriormachines-phpbb,代码行数:67,代码来源:functions_admin.php
示例14: add_cur_topic
//.........这里部分代码省略.........
// Create the topic
$sql_data = array('topic_poster' => $poster_data['user_id'], 'topic_time' => $forum_time, 'topic_last_view_time' => $forum_time, 'topic_last_post_time' => $forum_time, 'forum_id' => $forum_id, 'topic_title' => (string) $topic_elm['title'], 'topic_first_poster_name' => $poster_name, 'topic_first_poster_colour' => $poster_data['colour'], 'topic_type' => POST_NORMAL, 'topic_visibility' => 1);
$sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_data);
$db->sql_query($sql);
$topic_id = $db->sql_nextid();
unset($sql_data);
if (isset($topic_elm['oldtopicno'])) {
// Create the topic old number
$sql_data = array('oldpostid' => (int) $topic_elm['oldtopicno'], 'newpostid' => $topic_id);
$sql = 'INSERT INTO phpbb_posts_convert ' . $db->sql_build_array('INSERT', $sql_data);
$db->sql_query($sql);
unset($sql_data);
}
// Add the topic posts
foreach ($topic_elm as $msg_index => $msg_data) {
$msg_date = $msg_data['date'];
$poster_name = (string) $msg_data['by'];
$poster_data =& $this->poster_ary[$poster_name];
if ($poster_data === false || !is_numeric($poster_data['user_id'])) {
$poster_data = array('
|
请发表评论