Line 479 | Line 479 |
---|
/** * Get physical file listing */
|
/** * Get physical file listing */
|
function filelist($rootdir, $dir = '', $type = 'gif|jpg|jpeg|png')
| function filelist($rootdir, $dir = '', $type = 'gif|jpg|jpeg|png|svg|webp')
|
{ $matches = array($dir => array());
| { $matches = array($dir => array());
|
Line 1324 | Line 1324 |
---|
*/ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $sync_extra = false) {
|
*/ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $sync_extra = false) {
|
global $db;
| global $db, $phpbb_dispatcher;
|
if (is_array($where_ids)) {
| if (is_array($where_ids)) {
|
Line 1826 | Line 1826 |
---|
// 5: Retrieve last_post infos if (count($post_ids)) {
|
// 5: Retrieve last_post infos if (count($post_ids)) {
|
$sql = 'SELECT p.post_id, p.poster_id, p.post_subject, p.post_time, p.post_username, u.username, u.user_colour FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u WHERE ' . $db->sql_in_set('p.post_id', $post_ids) . ' AND p.poster_id = u.user_id'; $result = $db->sql_query($sql);
| $sql_ary = array( 'SELECT' => 'p.post_id, p.poster_id, p.post_subject, p.post_time, p.post_username, u.username, u.user_colour', 'FROM' => array( POSTS_TABLE => 'p', USERS_TABLE => 'u', ), 'WHERE' => $db->sql_in_set('p.post_id', $post_ids) . ' AND p.poster_id = u.user_id', );
/** * Event to modify the SQL array to get the post and user data from all forums' last posts * * @event core.sync_forum_last_post_info_sql * @var array sql_ary SQL array with some post and user data from the last posts list * @since 3.3.5-RC1 */ $vars = ['sql_ary']; extract($phpbb_dispatcher->trigger_event('core.sync_forum_last_post_info_sql', compact($vars))); $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary));
|
while ($row = $db->sql_fetchrow($result)) {
| while ($row = $db->sql_fetchrow($result)) {
|
Line 1862 | Line 1877 |
---|
} } }
|
} } }
|
unset($post_info);
| |
}
// 6: Now do that thing
| }
// 6: Now do that thing
|
Line 1872 | Line 1886 |
---|
{ array_push($fieldnames, 'posts_approved', 'posts_unapproved', 'posts_softdeleted', 'topics_approved', 'topics_unapproved', 'topics_softdeleted'); }
|
{ array_push($fieldnames, 'posts_approved', 'posts_unapproved', 'posts_softdeleted', 'topics_approved', 'topics_unapproved', 'topics_softdeleted'); }
|
| /** * Event to modify the SQL array to get the post and user data from all forums' last posts * * @event core.sync_modify_forum_data * @var array forum_data Array with data to update for all forum ids * @var array post_info Array with some post and user data from the last posts list * @var array fieldnames Array with the partial column names that are being updated * @since 3.3.5-RC1 */ $vars = [ 'forum_data', 'post_info', 'fieldnames', ]; extract($phpbb_dispatcher->trigger_event('core.sync_modify_forum_data', compact($vars))); unset($post_info);
|
foreach ($forum_data as $forum_id => $row) {
| foreach ($forum_data as $forum_id => $row) {
|
Line 2041 | Line 2072 |
---|
unset($delete_topics, $delete_topic_ids); }
|
unset($delete_topics, $delete_topic_ids); }
|
$sql = 'SELECT p.post_id, p.topic_id, p.post_visibility, p.poster_id, p.post_subject, p.post_username, p.post_time, u.username, u.user_colour FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u WHERE ' . $db->sql_in_set('p.post_id', $post_ids) . ' AND u.user_id = p.poster_id'; $result = $db->sql_query($sql);
| $sql_ary = array( 'SELECT' => 'p.post_id, p.topic_id, p.post_visibility, p.poster_id, p.post_subject, p.post_username, p.post_time, u.username, u.user_colour', 'FROM' => array( POSTS_TABLE => 'p', USERS_TABLE => 'u', ), 'WHERE' => $db->sql_in_set('p.post_id', $post_ids) . ' AND u.user_id = p.poster_id', );
$custom_fieldnames = []; /** * Event to modify the SQL array to get the post and user data from all topics' last posts * * @event core.sync_topic_last_post_info_sql * @var array sql_ary SQL array with some post and user data from the last posts list * @var array custom_fieldnames Empty array for custom fieldnames to update the topics_table with * @since 3.3.5-RC1 */ $vars = [ 'sql_ary', 'custom_fieldnames', ]; extract($phpbb_dispatcher->trigger_event('core.sync_topic_last_post_info_sql', compact($vars))); $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary));
|
while ($row = $db->sql_fetchrow($result)) {
| while ($row = $db->sql_fetchrow($result)) {
|
Line 2067 | Line 2118 |
---|
$topic_data[$topic_id]['last_poster_name'] = ($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : $row['username']; $topic_data[$topic_id]['last_poster_colour'] = $row['user_colour']; }
|
$topic_data[$topic_id]['last_poster_name'] = ($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : $row['username']; $topic_data[$topic_id]['last_poster_colour'] = $row['user_colour']; }
|
| /** * Event to modify the topic_data when syncing topics * * @event core.sync_modify_topic_data * @var array topic_data Array with the topics' data we are syncing * @var array row Array with some of the current user and post data * @var int topic_id The current topic_id of $row * @since 3.3.5-RC1 */ $vars = [ 'topic_data', 'row', 'topic_id', ]; extract($phpbb_dispatcher->trigger_event('core.sync_modify_topic_data', compact($vars)));
|
} $db->sql_freeresult($result);
| } $db->sql_freeresult($result);
|
Line 2181 | Line 2248 |
---|
// These are fields that will be synchronised $fieldnames = array('time', 'visibility', 'posts_approved', 'posts_unapproved', 'posts_softdeleted', 'poster', 'first_post_id', 'first_poster_name', 'first_poster_colour', 'last_post_id', 'last_post_subject', 'last_post_time', 'last_poster_id', 'last_poster_name', 'last_poster_colour');
|
// These are fields that will be synchronised $fieldnames = array('time', 'visibility', 'posts_approved', 'posts_unapproved', 'posts_softdeleted', 'poster', 'first_post_id', 'first_poster_name', 'first_poster_colour', 'last_post_id', 'last_post_subject', 'last_post_time', 'last_poster_id', 'last_poster_name', 'last_poster_colour');
|
| // Add custom fieldnames $fieldnames = array_merge($fieldnames, $custom_fieldnames); unset($custom_fieldnames);
|
if ($sync_extra) {
| if ($sync_extra) {
|
Line 2375 | Line 2446 |
---|
/** * Function auto_prune(), this function now relies on passed vars */
|
/** * Function auto_prune(), this function now relies on passed vars */
|
function auto_prune($forum_id, $prune_mode, $prune_flags, $prune_days, $prune_freq)
| function auto_prune($forum_id, $prune_mode, $prune_flags, $prune_days, $prune_freq, $log_prune = true)
|
{ global $db, $user, $phpbb_log;
| { global $db, $user, $phpbb_log;
|
Line 2395 | Line 2466 |
---|
if ($result['topics'] == 0 && $result['posts'] == 0) {
|
if ($result['topics'] == 0 && $result['posts'] == 0) {
|
| $column = $prune_mode === 'shadow' ? 'prune_shadow_next' : 'prune_next';
|
$sql = 'UPDATE ' . FORUMS_TABLE . "
|
$sql = 'UPDATE ' . FORUMS_TABLE . "
|
SET prune_next = $next_prune
| SET $column = $next_prune
|
WHERE forum_id = $forum_id"; $db->sql_query($sql); }
|
WHERE forum_id = $forum_id"; $db->sql_query($sql); }
|
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_AUTO_PRUNE', false, array($row['forum_name']));
| if ($log_prune) { $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_AUTO_PRUNE', false, [$row['forum_name']]); }
|
}
return;
| }
return;
|
Line 2413 | Line 2489 |
---|
* must be carried through for the moderators table. * * @param \phpbb\db\driver\driver_interface $db Database connection
|
* must be carried through for the moderators table. * * @param \phpbb\db\driver\driver_interface $db Database connection
|
* @param \phpbb\cache\driver\driver_interface Cache driver
| * @param \phpbb\cache\driver\driver_interface $cache Cache driver
|
* @param \phpbb\auth\auth $auth Authentication object * @return null */
| * @param \phpbb\auth\auth $auth Authentication object * @return null */
|
Line 2600 | Line 2676 |
---|
* @param mixed $forum_id Restrict the log entries to the given forum_id (can also be an array of forum_ids) * @param int $topic_id Restrict the log entries to the given topic_id * @param int $user_id Restrict the log entries to the given user_id
|
* @param mixed $forum_id Restrict the log entries to the given forum_id (can also be an array of forum_ids) * @param int $topic_id Restrict the log entries to the given topic_id * @param int $user_id Restrict the log entries to the given user_id
|
* @param int $log_time Only get log entries newer than the given timestamp
| * @param int $limit_days Only get log entries newer than the given timestamp
|
* @param string $sort_by SQL order option, e.g. 'l.log_time DESC' * @param string $keywords Will only return log entries that have the keywords in log_operation or log_data *
| * @param string $sort_by SQL order option, e.g. 'l.log_time DESC' * @param string $keywords Will only return log entries that have the keywords in log_operation or log_data *
|
Line 2827 | Line 2903 |
---|
/** * Get database size
|
/** * Get database size
|
* Currently only mysql and mssql are supported
| |
*/ function get_database_size() {
|
*/ function get_database_size() {
|
global $db, $user, $table_prefix;
| global $db, $user;
|
$database_size = false;
|
$database_size = false;
|
// This code is heavily influenced by a similar routine in phpMyAdmin 2.2.0
| |
switch ($db->get_sql_layer()) { case 'mysqli':
|
switch ($db->get_sql_layer()) { case 'mysqli':
|
$sql = 'SELECT VERSION() AS mysql_version'; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result);
if ($row) { $version = $row['mysql_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]\.|10\.[0-9]\.[0-9]{1,2}-+Maria#', $version)) ? "`{$db->get_db_name()}`" : $db->get_db_name();
| $mysql_engine = ['MyISAM', 'InnoDB', 'Aria']; $db_name = $db->get_db_name(); $database_size = 0;
|
$sql = 'SHOW TABLE STATUS
|
$sql = 'SHOW TABLE STATUS
|
FROM ' . $db_name;
| FROM ' . $db->sql_quote($db_name);
|
$result = $db->sql_query($sql, 7200);
|
$result = $db->sql_query($sql, 7200);
|
$database_size = 0;
| |
while ($row = $db->sql_fetchrow($result)) {
|
while ($row = $db->sql_fetchrow($result)) {
|
if ((isset($row['Type']) && $row['Type'] != 'MRG_MyISAM') || (isset($row['Engine']) && ($row['Engine'] == 'MyISAM' || $row['Engine'] == 'InnoDB' || $row['Engine'] == 'Aria'))) { if ($table_prefix != '') { if (strpos($row['Name'], $table_prefix) !== false)
| if (isset($row['Engine']) && in_array($row['Engine'], $mysql_engine))
|
{ $database_size += $row['Data_length'] + $row['Index_length']; } }
|
{ $database_size += $row['Data_length'] + $row['Index_length']; } }
|
else { $database_size += $row['Data_length'] + $row['Index_length']; } } }
|
|
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
} }
| $database_size = $database_size ? $database_size : false;
|
break;
case 'sqlite3':
| break;
case 'sqlite3':
|
Line 2915 | Line 2971 |
---|
break;
case 'postgres':
|
break;
case 'postgres':
|
$sql = "SELECT proname FROM pg_proc WHERE proname = 'pg_database_size'"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result);
| $database = $db->get_db_name();
|
|
|
if ($row['proname'] == 'pg_database_size') { $database = $db->get_db_name();
| |
if (strpos($database, '.') !== false) {
|
if (strpos($database, '.') !== false) {
|
list($database, ) = explode('.', $database);
| $database = explode('.', $database)[0];
|
}
|
}
|
$sql = "SELECT oid FROM pg_database WHERE datname = '$database'"; $result = $db->sql_query($sql);
| $sql = "SELECT pg_database_size('" . $database . "') AS dbsize"; $result = $db->sql_query($sql, 7200);
|
$row = $db->sql_fetchrow($result);
|
$row = $db->sql_fetchrow($result);
|
| $database_size = !empty($row['dbsize']) ? $row['dbsize'] : false;
|
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
$oid = $row['oid'];
$sql = 'SELECT pg_database_size(' . $oid . ') as size'; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result);
$database_size = $row['size']; }
| |
break;
case 'oracle':
| break;
case 'oracle':
|
Line 3093 | Line 3130 |
---|
SET ' . $column_name . ' = ' . $db->sql_bit_or($column_name, $flag) . ' ' . $sql_more; $db->sql_query($sql);
|
SET ' . $column_name . ' = ' . $db->sql_bit_or($column_name, $flag) . ' ' . $sql_more; $db->sql_query($sql);
|
| }
function display_ban_end_options() { global $user, $template;
// Ban length options $ban_end_text = array(0 => $user->lang['PERMANENT'], 30 => $user->lang['30_MINS'], 60 => $user->lang['1_HOUR'], 360 => $user->lang['6_HOURS'], 1440 => $user->lang['1_DAY'], 10080 => $user->lang['7_DAYS'], 20160 => $user->lang['2_WEEKS'], 40320 => $user->lang['1_MONTH'], -1 => $user->lang['UNTIL'] . ' -> ');
$ban_end_options = ''; foreach ($ban_end_text as $length => $text) { $ban_end_options .= '<option value="' . $length . '">' . $text . '</option>'; }
$template->assign_vars(array( 'S_BAN_END_OPTIONS' => $ban_end_options )); }
/** * Display ban options */ function display_ban_options($mode) { global $user, $db, $template;
switch ($mode) { case 'user':
$field = 'username';
$sql = 'SELECT b.*, u.user_id, u.username, u.username_clean FROM ' . BANLIST_TABLE . ' b, ' . USERS_TABLE . ' u WHERE (b.ban_end >= ' . time() . ' OR b.ban_end = 0) AND u.user_id = b.ban_userid ORDER BY u.username_clean ASC'; break;
case 'ip':
$field = 'ban_ip';
$sql = 'SELECT * FROM ' . BANLIST_TABLE . ' WHERE (ban_end >= ' . time() . " OR ban_end = 0) AND ban_ip <> '' ORDER BY ban_ip"; break;
case 'email':
$field = 'ban_email';
$sql = 'SELECT * FROM ' . BANLIST_TABLE . ' WHERE (ban_end >= ' . time() . " OR ban_end = 0) AND ban_email <> '' ORDER BY ban_email"; break; } $result = $db->sql_query($sql);
$banned_options = $excluded_options = array(); while ($row = $db->sql_fetchrow($result)) { $option = '<option value="' . $row['ban_id'] . '">' . $row[$field] . '</option>';
if ($row['ban_exclude']) { $excluded_options[] = $option; } else { $banned_options[] = $option; }
$time_length = ($row['ban_end']) ? ($row['ban_end'] - $row['ban_start']) / 60 : 0;
if ($time_length == 0) { // Banned permanently $ban_length = $user->lang['PERMANENT']; } else if (isset($ban_end_text[$time_length])) { // Banned for a given duration $ban_length = $user->lang('BANNED_UNTIL_DURATION', $ban_end_text[$time_length], $user->format_date($row['ban_end'], false, true)); } else { // Banned until given date $ban_length = $user->lang('BANNED_UNTIL_DATE', $user->format_date($row['ban_end'], false, true)); }
$template->assign_block_vars('bans', array( 'BAN_ID' => (int) $row['ban_id'], 'LENGTH' => $ban_length, 'A_LENGTH' => addslashes($ban_length), 'REASON' => $row['ban_reason'], 'A_REASON' => addslashes($row['ban_reason']), 'GIVE_REASON' => $row['ban_give_reason'], 'A_GIVE_REASON' => addslashes($row['ban_give_reason']), )); } $db->sql_freeresult($result);
$options = ''; if ($excluded_options) { $options .= '<optgroup label="' . $user->lang['OPTIONS_EXCLUDED'] . '">'; $options .= implode('', $excluded_options); $options .= '</optgroup>'; }
if ($banned_options) { $options .= '<optgroup label="' . $user->lang['OPTIONS_BANNED'] . '">'; $options .= implode('', $banned_options); $options .= '</optgroup>'; }
$template->assign_vars(array( 'S_BANNED_OPTIONS' => ($banned_options || $excluded_options) ? true : false, 'BANNED_OPTIONS' => $options, ));
|
}
| }
|