Line 65 | Line 65 |
---|
*/ function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl = false, $ignore_nonpost = false, $ignore_emptycat = true, $only_acl_post = false, $return_array = false) {
|
*/ function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl = false, $ignore_nonpost = false, $ignore_emptycat = true, $only_acl_post = false, $return_array = false) {
|
global $db, $user, $auth;
| global $db, $user, $auth, $phpbb_dispatcher;
|
// This query is identical to the jumpbox one $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, forum_flags, forum_options, left_id, right_id FROM ' . FORUMS_TABLE . ' ORDER BY left_id ASC'; $result = $db->sql_query($sql, 600);
|
// This query is identical to the jumpbox one $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, forum_flags, forum_options, left_id, right_id FROM ' . FORUMS_TABLE . ' ORDER BY left_id ASC'; $result = $db->sql_query($sql, 600);
|
| $rowset = array(); while ($row = $db->sql_fetchrow($result)) { $rowset[(int) $row['forum_id']] = $row; } $db->sql_freeresult($result);
|
$right = 0; $padding_store = array('0' => ''); $padding = ''; $forum_list = ($return_array) ? array() : '';
|
$right = 0; $padding_store = array('0' => ''); $padding = ''; $forum_list = ($return_array) ? array() : '';
|
| /** * Modify the forum list data * * @event core.make_forum_select_modify_forum_list * @var array rowset Array with the forums list data * @since 3.1.10-RC1 */ $vars = array('rowset'); extract($phpbb_dispatcher->trigger_event('core.make_forum_select_modify_forum_list', compact($vars)));
|
// Sometimes it could happen that forums will be displayed here not be displayed within the index page // This is the result of forums not displayed at index, having list permissions and a parent of a forum with no permissions. // If this happens, the padding could be "broken"
|
// Sometimes it could happen that forums will be displayed here not be displayed within the index page // This is the result of forums not displayed at index, having list permissions and a parent of a forum with no permissions. // If this happens, the padding could be "broken"
|
while ($row = $db->sql_fetchrow($result))
| foreach ($rowset as $row)
|
{ if ($row['left_id'] < $right) {
| { if ($row['left_id'] < $right) {
|
Line 133 | Line 150 |
---|
$forum_list .= '<option value="' . $row['forum_id'] . '"' . (($disabled) ? ' disabled="disabled" class="disabled-option"' : $selected) . '>' . $padding . $row['forum_name'] . '</option>'; } }
|
$forum_list .= '<option value="' . $row['forum_id'] . '"' . (($disabled) ? ' disabled="disabled" class="disabled-option"' : $selected) . '>' . $padding . $row['forum_name'] . '</option>'; } }
|
$db->sql_freeresult($result); unset($padding_store);
| unset($padding_store, $rowset);
|
return $forum_list; }
| return $forum_list; }
|
Line 201 | Line 217 |
---|
*/ function get_forum_list($acl_list = 'f_list', $id_only = true, $postable_only = false, $no_cache = false) {
|
*/ function get_forum_list($acl_list = 'f_list', $id_only = true, $postable_only = false, $no_cache = false) {
|
global $db, $auth;
| global $db, $auth, $phpbb_dispatcher;
|
static $forum_rows;
if (!isset($forum_rows))
| static $forum_rows;
if (!isset($forum_rows))
|
Line 255 | Line 271 |
---|
$rowset[] = ($id_only) ? (int) $row['forum_id'] : $row; } }
|
$rowset[] = ($id_only) ? (int) $row['forum_id'] : $row; } }
|
| /** * Modify the forum list data * * @event core.get_forum_list_modify_data * @var array rowset Array with the forum list data * @since 3.1.10-RC1 */ $vars = array('rowset'); extract($phpbb_dispatcher->trigger_event('core.get_forum_list_modify_data', compact($vars)));
|
return $rowset; }
| return $rowset; }
|
Line 500 | Line 526 |
---|
*/ function move_topics($topic_ids, $forum_id, $auto_sync = true) {
|
*/ function move_topics($topic_ids, $forum_id, $auto_sync = true) {
|
global $db;
| global $db, $phpbb_dispatcher;
|
if (empty($topic_ids)) {
| if (empty($topic_ids)) {
|
Line 534 | Line 560 |
---|
}
$table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE);
|
}
$table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE);
|
| /** * Perform additional actions before topics move * * @event core.move_topics_before_query * @var array table_ary Array of tables from which forum_id will be updated for all rows that hold the moved topics * @var array topic_ids Array of the moved topic ids * @var string forum_id The forum id from where the topics are moved * @var array forum_ids Array of the forums where the topics are moving (includes also forum_id) * @var bool auto_sync Whether or not to perform auto sync * @since 3.1.5-RC1 */ $vars = array( 'table_ary', 'topic_ids', 'forum_id', 'forum_ids', 'auto_sync', ); extract($phpbb_dispatcher->trigger_event('core.move_topics_before_query', compact($vars)));
|
foreach ($table_ary as $table) { $sql = "UPDATE $table
| foreach ($table_ary as $table) { $sql = "UPDATE $table
|
Line 555 | Line 602 |
---|
*/ function move_posts($post_ids, $topic_id, $auto_sync = true) {
|
*/ function move_posts($post_ids, $topic_id, $auto_sync = true) {
|
global $db;
| global $db, $phpbb_dispatcher;
|
if (!is_array($post_ids)) {
| if (!is_array($post_ids)) {
|
Line 588 | Line 635 |
---|
{ trigger_error('NO_TOPIC'); }
|
{ trigger_error('NO_TOPIC'); }
|
| /** * Perform additional actions before moving posts * * @event core.move_posts_before * @var array post_ids Array of post ids to move * @var int topic_id The topic id the posts are moved to * @var bool auto_sync Whether or not to perform auto sync * @var array forum_ids Array of the forum ids the posts are moved from * @var array topic_ids Array of the topic ids the posts are moved from * @var array forum_row Array with the forum id of the topic the posts are moved to * @since 3.1.7-RC1 */ $vars = array( 'post_ids', 'topic_id', 'auto_sync', 'forum_ids', 'topic_ids', 'forum_row', ); extract($phpbb_dispatcher->trigger_event('core.move_posts_before', compact($vars)));
|
$sql = 'UPDATE ' . POSTS_TABLE . ' SET forum_id = ' . (int) $forum_row['forum_id'] . ", topic_id = $topic_id
| $sql = 'UPDATE ' . POSTS_TABLE . ' SET forum_id = ' . (int) $forum_row['forum_id'] . ", topic_id = $topic_id
|
Line 598 | Line 667 |
---|
SET topic_id = $topic_id, in_message = 0 WHERE " . $db->sql_in_set('post_msg_id', $post_ids); $db->sql_query($sql);
|
SET topic_id = $topic_id, in_message = 0 WHERE " . $db->sql_in_set('post_msg_id', $post_ids); $db->sql_query($sql);
|
| /** * Perform additional actions after moving posts * * @event core.move_posts_after * @var array post_ids Array of the moved post ids * @var int topic_id The topic id the posts are moved to * @var bool auto_sync Whether or not to perform auto sync * @var array forum_ids Array of the forum ids the posts are moved from * @var array topic_ids Array of the topic ids the posts are moved from * @var array forum_row Array with the forum id of the topic the posts are moved to * @since 3.1.7-RC1 */ $vars = array( 'post_ids', 'topic_id', 'auto_sync', 'forum_ids', 'topic_ids', 'forum_row', ); extract($phpbb_dispatcher->trigger_event('core.move_posts_after', compact($vars)));
|
if ($auto_sync) {
| if ($auto_sync) {
|
Line 607 | Line 698 |
---|
sync('topic_attachment', 'topic_id', $topic_ids); sync('topic', 'topic_id', $topic_ids, true); sync('forum', 'forum_id', $forum_ids, true, true);
|
sync('topic_attachment', 'topic_id', $topic_ids); sync('topic', 'topic_id', $topic_ids, true); sync('forum', 'forum_id', $forum_ids, true, true);
|
| /** * Perform additional actions after move post sync * * @event core.move_posts_sync_after * @var array post_ids Array of the moved post ids * @var int topic_id The topic id the posts are moved to * @var bool auto_sync Whether or not to perform auto sync * @var array forum_ids Array of the forum ids the posts are moved from * @var array topic_ids Array of the topic ids the posts are moved from * @var array forum_row Array with the forum id of the topic the posts are moved to * @since 3.1.11-RC1 */ $vars = array( 'post_ids', 'topic_id', 'auto_sync', 'forum_ids', 'topic_ids', 'forum_row', ); extract($phpbb_dispatcher->trigger_event('core.move_posts_sync_after', compact($vars)));
|
}
// Update posted information
| }
// Update posted information
|
Line 618 | Line 731 |
---|
*/ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_sync = true, $call_delete_posts = true) {
|
*/ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_sync = true, $call_delete_posts = true) {
|
global $db, $config, $phpbb_container;
| global $db, $config, $phpbb_container, $phpbb_dispatcher;
|
$approved_topics = 0; $forum_ids = $topic_ids = array();
| $approved_topics = 0; $forum_ids = $topic_ids = array();
|
Line 671 | Line 784 |
---|
$db->sql_transaction('begin');
$table_ary = array(BOOKMARKS_TABLE, TOPICS_TRACK_TABLE, TOPICS_POSTED_TABLE, POLL_VOTES_TABLE, POLL_OPTIONS_TABLE, TOPICS_WATCH_TABLE, TOPICS_TABLE);
|
$db->sql_transaction('begin');
$table_ary = array(BOOKMARKS_TABLE, TOPICS_TRACK_TABLE, TOPICS_POSTED_TABLE, POLL_VOTES_TABLE, POLL_OPTIONS_TABLE, TOPICS_WATCH_TABLE, TOPICS_TABLE);
|
| /** * Perform additional actions before topic(s) deletion * * @event core.delete_topics_before_query * @var array table_ary Array of tables from which all rows will be deleted that hold a topic_id occuring in topic_ids * @var array topic_ids Array of topic ids to delete * @since 3.1.4-RC1 */ $vars = array( 'table_ary', 'topic_ids', ); extract($phpbb_dispatcher->trigger_event('core.delete_topics_before_query', compact($vars)));
|
foreach ($table_ary as $table) {
| foreach ($table_ary as $table) {
|
Line 679 | Line 806 |
---|
$db->sql_query($sql); } unset($table_ary);
|
$db->sql_query($sql); } unset($table_ary);
|
| /** * Perform additional actions after topic(s) deletion * * @event core.delete_topics_after_query * @var array topic_ids Array of topic ids that were deleted * @since 3.1.4-RC1 */ $vars = array( 'topic_ids', ); extract($phpbb_dispatcher->trigger_event('core.delete_topics_after_query', compact($vars)));
|
$moved_topic_ids = array();
| $moved_topic_ids = array();
|
Line 738 | Line 877 |
---|
'notification.type.quote', 'notification.type.approve_post', 'notification.type.post_in_queue',
|
'notification.type.quote', 'notification.type.approve_post', 'notification.type.post_in_queue',
|
| 'notification.type.report_post',
|
);
/**
| );
/**
|
Line 838 | Line 978 |
---|
$db->sql_transaction('begin');
$table_ary = array(POSTS_TABLE, REPORTS_TABLE);
|
$db->sql_transaction('begin');
$table_ary = array(POSTS_TABLE, REPORTS_TABLE);
|
| /** * Perform additional actions during post(s) deletion before running the queries * * @event core.delete_posts_in_transaction_before * @var array post_ids Array with deleted posts' ids * @var array poster_ids Array with deleted posts' author ids * @var array topic_ids Array with deleted posts' topic ids * @var array forum_ids Array with deleted posts' forum ids * @var string where_type Variable containing posts deletion mode * @var mixed where_ids Array or comma separated list of post ids to delete * @var array delete_notifications_types Array with notifications types to delete * @var array table_ary Array with table names to delete data from * @since 3.1.7-RC1 */ $vars = array( 'post_ids', 'poster_ids', 'topic_ids', 'forum_ids', 'where_type', 'where_ids', 'delete_notifications_types', 'table_ary', ); extract($phpbb_dispatcher->trigger_event('core.delete_posts_in_transaction_before', compact($vars)));
|
foreach ($table_ary as $table) {
| foreach ($table_ary as $table) {
|
Line 894 | Line 1060 |
---|
}
$error = false;
|
}
$error = false;
|
$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user);
| $search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);
|
if ($error) {
| if ($error) {
|
Line 995 | Line 1161 |
---|
*/ function delete_attachments($mode, $ids, $resync = true) {
|
*/ function delete_attachments($mode, $ids, $resync = true) {
|
global $db, $config;
| global $db, $config, $phpbb_dispatcher;
|
// 0 is as bad as an empty array if (empty($ids))
| // 0 is as bad as an empty array if (empty($ids))
|
Line 1039 | Line 1205 |
---|
}
$post_ids = $message_ids = $topic_ids = $physical = array();
|
}
$post_ids = $message_ids = $topic_ids = $physical = array();
|
| /** * Perform additional actions before collecting data for attachment(s) deletion * * @event core.delete_attachments_collect_data_before * @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 * @since 3.1.7-RC1 */ $vars = array( 'mode', 'ids', 'resync', 'sql_id', ); extract($phpbb_dispatcher->trigger_event('core.delete_attachments_collect_data_before', compact($vars)));
|
// Collect post and topic ids for later use if we need to touch remaining entries (if resync is enabled) $sql = 'SELECT post_msg_id, topic_id, in_message, physical_filename, thumbnail, filesize, is_orphan
| // Collect post and topic ids for later use if we need to touch remaining entries (if resync is enabled) $sql = 'SELECT post_msg_id, topic_id, in_message, physical_filename, thumbnail, filesize, is_orphan
|
Line 1068 | Line 1252 |
---|
$physical[] = array('filename' => $row['physical_filename'], 'thumbnail' => $row['thumbnail'], 'filesize' => $row['filesize'], 'is_orphan' => $row['is_orphan']); } $db->sql_freeresult($result);
|
$physical[] = array('filename' => $row['physical_filename'], 'thumbnail' => $row['thumbnail'], 'filesize' => $row['filesize'], 'is_orphan' => $row['is_orphan']); } $db->sql_freeresult($result);
|
| /** * Perform additional actions before attachment(s) deletion * * @event core.delete_attachments_before * @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 * @since 3.1.7-RC1 */ $vars = array( 'mode', 'ids', 'resync', 'sql_id', 'post_ids', 'topic_ids', 'message_ids', 'physical', ); extract($phpbb_dispatcher->trigger_event('core.delete_attachments_before', compact($vars)));
|
// Delete attachments $sql = 'DELETE FROM ' . ATTACHMENTS_TABLE . '
| // Delete attachments $sql = 'DELETE FROM ' . ATTACHMENTS_TABLE . '
|
Line 1077 | Line 1287 |
---|
$db->sql_query($sql); $num_deleted = $db->sql_affectedrows();
|
$db->sql_query($sql); $num_deleted = $db->sql_affectedrows();
|
| /** * Perform additional actions after attachment(s) deletion from the database * * @event core.delete_attachments_from_database_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 * @since 3.1.7-RC1 */ $vars = array( 'mode', 'ids', 'resync', 'sql_id', 'post_ids', 'topic_ids', 'message_ids', 'physical', 'num_deleted', ); extract($phpbb_dispatcher->trigger_event('core.delete_attachments_from_database_after', compact($vars)));
|
if (!$num_deleted) {
| if (!$num_deleted) {
|
Line 1099 | Line 1337 |
---|
phpbb_unlink($file_ary['filename'], 'thumbnail', true); } }
|
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) {
| if ($space_removed || $files_removed) {
|
Line 2309 | Line 2579 |
---|
/** * Prune function */
|
/** * Prune function */
|
function prune($forum_id, $prune_mode, $prune_date, $prune_flags = 0, $auto_sync = true)
| function prune($forum_id, $prune_mode, $prune_date, $prune_flags = 0, $auto_sync = true, $prune_limit = 0)
|
{
|
{
|
global $db;
| global $db, $phpbb_dispatcher;
|
if (!is_array($forum_id)) {
| if (!is_array($forum_id)) {
|
Line 2350 | Line 2620 |
---|
{ $sql_and .= ' AND topic_status = ' . ITEM_MOVED . " AND topic_last_post_time < $prune_date"; }
|
{ $sql_and .= ' AND topic_status = ' . ITEM_MOVED . " AND topic_last_post_time < $prune_date"; }
|
| /** * Use this event to modify the SQL that selects topics to be pruned * * @event core.prune_sql * @var string forum_id The forum id * @var string prune_mode The prune mode * @var string prune_date The prune date * @var int prune_flags The prune flags * @var bool auto_sync Whether or not to perform auto sync * @var string sql_and SQL text appended to where clause * @var int prune_limit The prune limit * @since 3.1.3-RC1 * @changed 3.1.10-RC1 Added prune_limit */ $vars = array( 'forum_id', 'prune_mode', 'prune_date', 'prune_flags', 'auto_sync', 'sql_and', 'prune_limit', ); extract($phpbb_dispatcher->trigger_event('core.prune_sql', compact($vars)));
|
$sql = 'SELECT topic_id FROM ' . TOPICS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_id) . " AND poll_start = 0 $sql_and";
|
$sql = 'SELECT topic_id FROM ' . TOPICS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_id) . " AND poll_start = 0 $sql_and";
|
$result = $db->sql_query($sql);
| $result = $db->sql_query_limit($sql, $prune_limit);
|
$topic_list = array(); while ($row = $db->sql_fetchrow($result))
| $topic_list = array(); while ($row = $db->sql_fetchrow($result))
|
Line 2373 | Line 2668 |
---|
AND poll_start > 0 AND poll_last_vote < $prune_date $sql_and";
|
AND poll_start > 0 AND poll_last_vote < $prune_date $sql_and";
|
$result = $db->sql_query($sql);
| $result = $db->sql_query_limit($sql, $prune_limit);
|
while ($row = $db->sql_fetchrow($result)) {
| while ($row = $db->sql_fetchrow($result)) {
|
Line 2406 | Line 2701 |
---|
$prune_date = time() - ($prune_days * 86400); $next_prune = time() + ($prune_freq * 86400);
|
$prune_date = time() - ($prune_days * 86400); $next_prune = time() + ($prune_freq * 86400);
|
prune($forum_id, $prune_mode, $prune_date, $prune_flags, true);
| $result = prune($forum_id, $prune_mode, $prune_date, $prune_flags, true, 300);
|
|
|
| if ($result['topics'] == 0 && $result['posts'] == 0) {
|
$sql = 'UPDATE ' . FORUMS_TABLE . " SET prune_next = $next_prune WHERE forum_id = $forum_id"; $db->sql_query($sql);
|
$sql = 'UPDATE ' . FORUMS_TABLE . " SET prune_next = $next_prune WHERE forum_id = $forum_id"; $db->sql_query($sql);
|
| }
|
add_log('admin', 'LOG_AUTO_PRUNE', $row['forum_name']); }
| add_log('admin', 'LOG_AUTO_PRUNE', $row['forum_name']); }
|
Line 2512 | Line 2810 |
---|
{ $usernames_ary[$row['user_id']] = $row['username']; }
|
{ $usernames_ary[$row['user_id']] = $row['username']; }
|
| $db->sql_freeresult($result);
|
foreach ($hold_ary as $user_id => $forum_id_ary) {
| foreach ($hold_ary as $user_id => $forum_id_ary) {
|
Line 2806 | Line 3105 |
---|
$users[] = $row; }
|
$users[] = $row; }
|
| $db->sql_freeresult($result);
|
return $offset; }
| return $offset; }
|
Line 2862 | Line 3162 |
---|
{ $version = $row['mysql_version'];
|
{ $version = $row['mysql_version'];
|
if (preg_match('#(3\.23|[45]\.)#', $version))
| if (preg_match('#(3\.23|[45]\.|10\.[0-9]\.[0-9]{1,2}-+Maria)#', $version))
|
{
|
{
|
$db_name = (preg_match('#^(?:3\.23\.(?:[6-9]|[1-9]{2}))|[45]\.#', $version)) ? "`{$db->get_db_name()}`" : $db->get_db_name();
| $db_name = (preg_match('#^(?:3\.23\.(?:[6-9]|[1-9]{2}))|[45]\.|10\.[0-9]\.[0-9]{1,2}-+Maria#', $version)) ? "`{$db->get_db_name()}`" : $db->get_db_name();
|
$sql = 'SHOW TABLE STATUS FROM ' . $db_name;
| $sql = 'SHOW TABLE STATUS FROM ' . $db_name;
|
Line 2873 | Line 3173 |
---|
$database_size = 0; while ($row = $db->sql_fetchrow($result)) {
|
$database_size = 0; while ($row = $db->sql_fetchrow($result)) {
|
if ((isset($row['Type']) && $row['Type'] != 'MRG_MyISAM') || (isset($row['Engine']) && ($row['Engine'] == 'MyISAM' || $row['Engine'] == 'InnoDB')))
| if ((isset($row['Type']) && $row['Type'] != 'MRG_MyISAM') || (isset($row['Engine']) && ($row['Engine'] == 'MyISAM' || $row['Engine'] == 'InnoDB' || $row['Engine'] == 'Aria')))
|
{ if ($table_prefix != '') {
| { if ($table_prefix != '') {
|
Line 2980 | Line 3280 |
---|
/** * Retrieve contents from remotely stored file
|
/** * Retrieve contents from remotely stored file
|
| * * @deprecated 3.1.2 Use file_downloader instead
|
*/ function get_remote_file($host, $directory, $filename, &$errstr, &$errno, $port = 80, $timeout = 6) {
|
*/ function get_remote_file($host, $directory, $filename, &$errstr, &$errno, $port = 80, $timeout = 6) {
|
global $user;
| global $phpbb_container;
|
|
|
if ($fsock = @fsockopen($host, $port, $errno, $errstr, $timeout)) { @fputs($fsock, "GET $directory/$filename HTTP/1.0\r\n"); @fputs($fsock, "HOST: $host\r\n"); @fputs($fsock, "Connection: close\r\n\r\n");
| // Get file downloader and assign $errstr and $errno $file_downloader = $phpbb_container->get('file_downloader');
|
|
|
$timer_stop = time() + $timeout; stream_set_timeout($fsock, $timeout);
| $file_data = $file_downloader->get($host, $directory, $filename, $port, $timeout); $errstr = $file_downloader->get_error_string(); $errno = $file_downloader->get_error_number();
|
|
|
$file_info = ''; $get_info = false;
while (!@feof($fsock)) { if ($get_info) { $file_info .= @fread($fsock, 1024); } else { $line = @fgets($fsock, 1024); if ($line == "\r\n") { $get_info = true; } else if (stripos($line, '404 not found') !== false) { $errstr = $user->lang('FILE_NOT_FOUND', $filename); return false; } }
$stream_meta_data = stream_get_meta_data($fsock);
if (!empty($stream_meta_data['timed_out']) || time() >= $timer_stop) { $errstr = $user->lang['FSOCK_TIMEOUT']; return false; } } @fclose($fsock); } else { if ($errstr) { $errstr = utf8_convert_message($errstr); return false; } else { $errstr = $user->lang['FSOCK_DISABLED']; return false; } }
return $file_info;
| return $file_data;
|
}
/*
| }
/*
|
Line 3128 | Line 3381 |
---|
*/ function add_permission_language() {
|
*/ function add_permission_language() {
|
global $user, $phpEx, $phpbb_extension_manager;
| global $config, $user, $phpEx, $phpbb_extension_manager;
|
// add permission language files from extensions $finder = $phpbb_extension_manager->get_finder();
|
// add permission language files from extensions $finder = $phpbb_extension_manager->get_finder();
|
$lang_files = $finder
| // We grab the language files from the default, English and user's language. // So we can fall back to the other files like we do when using add_lang() $default_lang_files = $english_lang_files = $user_lang_files = array();
// Search for board default language if it's not the user language if ($config['default_lang'] != $user->lang_name) { $default_lang_files = $finder ->prefix('permissions_') ->suffix(".$phpEx") ->core_path('language/' . basename($config['default_lang']) . '/') ->extension_directory('/language/' . basename($config['default_lang'])) ->find(); }
// Search for english, if its not the default or user language if ($config['default_lang'] != 'en' && $user->lang_name != 'en') { $english_lang_files = $finder ->prefix('permissions_') ->suffix(".$phpEx") ->core_path('language/en/') ->extension_directory('/language/en') ->find(); }
// Find files in the user's language $user_lang_files = $finder
|
->prefix('permissions_') ->suffix(".$phpEx") ->core_path('language/' . $user->lang_name . '/') ->extension_directory('/language/' . $user->lang_name) ->find();
|
->prefix('permissions_') ->suffix(".$phpEx") ->core_path('language/' . $user->lang_name . '/') ->extension_directory('/language/' . $user->lang_name) ->find();
|
| $lang_files = array_merge($english_lang_files, $default_lang_files, $user_lang_files);
|
foreach ($lang_files as $lang_file => $ext_name) {
| foreach ($lang_files as $lang_file => $ext_name) {
|