Finished drafts, one bit is remaining though.

added file and disk space statistics.
some minor changes here and there.


git-svn-id: file:///svn/phpbb/trunk@4668 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2003-11-16 21:53:56 +00:00
parent e80f40d5bb
commit 306d36f03d
17 changed files with 428 additions and 258 deletions

View file

@ -36,9 +36,6 @@ $submit = (isset($_POST['submit'])) ? true : false;
$error = $notify = array(); $error = $notify = array();
// Adjust the Upload Directory. Relative or absolute, this is the question here.
$upload_dir = ($config['upload_dir'][0] == '/' || ($config['upload_dir'][0] != '/' && $config['upload_dir'][1] == ':')) ? $config['upload_dir'] : $phpbb_root_path . $config['upload_dir'];
switch ($mode) switch ($mode)
{ {
case 'extensions': case 'extensions':
@ -310,7 +307,8 @@ if ($submit && $mode == 'orphan')
foreach ($delete_files as $delete) foreach ($delete_files as $delete)
{ {
phpbb_unlink($upload_dir . '/' . $delete); phpbb_unlink($config['upload_dir'] . '/' . $delete);
phpbb_unlink($config['upload_dir'] . '/thumb_' . $delete);
} }
if (sizeof($delete_files)) if (sizeof($delete_files))
@ -362,7 +360,7 @@ if ($submit && $mode == 'orphan')
} }
else else
{ {
upload_file($row['post_id'], $row['topic_id'], $row['forum_id'], $upload_dir, $upload_list[$row['post_id']]); upload_file($row['post_id'], $row['topic_id'], $row['forum_id'], $config['upload_dir'], $upload_list[$row['post_id']]);
} }
} }
} }
@ -468,19 +466,13 @@ if ($mode == 'ext_groups')
<table class="bg" cellspacing="1" cellpadding="4" border="0" align="center" width="99%"> <table class="bg" cellspacing="1" cellpadding="4" border="0" align="center" width="99%">
<tr> <tr>
<th align="center" colspan="7"><?php echo $user->lang['EXTENSION_GROUPS_TITLE']; ?></th> <th>&nbsp;<?php echo $user->lang['EXTENSION_GROUP']; ?>&nbsp;</th>
</tr> <th>&nbsp;<?php echo $user->lang['SPECIAL_CATEGORY']; ?>&nbsp;</th>
<tr> <th>&nbsp;<?php echo $user->lang['ALLOWED']; ?>&nbsp;</th>
<td class="spacer" colspan="2" height="1"><img src="../images/spacer.gif" alt="" width="1" height="1" /></td> <th>&nbsp;<?php echo $user->lang['DOWNLOAD_MODE']; ?>&nbsp;</th>
</tr> <th>&nbsp;<?php echo $user->lang['UPLOAD_ICON']; ?>&nbsp;</th>
<tr> <th>&nbsp;<?php echo $user->lang['MAX_EXTGROUP_FILESIZE']; ?>&nbsp;</th>
<th>&nbsp;<?php echo $user->lang['EXTENSION_GROUP']; ?>&nbsp;</th> <th>&nbsp;<?php echo $user->lang['ADD']; ?>&nbsp;</th>
<th>&nbsp;<?php echo $user->lang['SPECIAL_CATEGORY']; ?>&nbsp;</th>
<th>&nbsp;<?php echo $user->lang['ALLOWED']; ?>&nbsp;</th>
<th>&nbsp;<?php echo $user->lang['DOWNLOAD_MODE']; ?>&nbsp;</th>
<th>&nbsp;<?php echo $user->lang['UPLOAD_ICON']; ?>&nbsp;</th>
<th>&nbsp;<?php echo $user->lang['MAX_EXTGROUP_FILESIZE']; ?>&nbsp;</th>
<th>&nbsp;<?php echo $user->lang['ADD']; ?>&nbsp;</th>
</tr> </tr>
<tr> <tr>
<td class="row1" align="center" valign="middle"> <td class="row1" align="center" valign="middle">
@ -509,13 +501,13 @@ if ($mode == 'ext_groups')
<td class="cat" colspan="7"><input type="submit" name="submit" value="<?php echo $user->lang['SUBMIT']; ?>" class="btnmain" /></td> <td class="cat" colspan="7"><input type="submit" name="submit" value="<?php echo $user->lang['SUBMIT']; ?>" class="btnmain" /></td>
</tr> </tr>
<tr> <tr>
<th>&nbsp;<?php echo $user->lang['EXTENSION_GROUP']; ?>&nbsp;</th> <th>&nbsp;<?php echo $user->lang['EXTENSION_GROUP']; ?>&nbsp;</th>
<th>&nbsp;<?php echo $user->lang['SPECIAL_CATEGORY']; ?>&nbsp;</th> <th>&nbsp;<?php echo $user->lang['SPECIAL_CATEGORY']; ?>&nbsp;</th>
<th>&nbsp;<?php echo $user->lang['ALLOWED']; ?>&nbsp;</th> <th>&nbsp;<?php echo $user->lang['ALLOWED']; ?>&nbsp;</th>
<th>&nbsp;<?php echo $user->lang['DOWNLOAD_MODE']; ?>&nbsp;</th> <th>&nbsp;<?php echo $user->lang['DOWNLOAD_MODE']; ?>&nbsp;</th>
<th>&nbsp;<?php echo $user->lang['UPLOAD_ICON']; ?>&nbsp;</th> <th>&nbsp;<?php echo $user->lang['UPLOAD_ICON']; ?>&nbsp;</th>
<th>&nbsp;<?php echo $user->lang['MAX_EXTGROUP_FILESIZE']; ?>&nbsp;</th> <th>&nbsp;<?php echo $user->lang['MAX_EXTGROUP_FILESIZE']; ?>&nbsp;</th>
<th>&nbsp;<?php echo $user->lang['DELETE']; ?>&nbsp;</th> <th>&nbsp;<?php echo $user->lang['DELETE']; ?>&nbsp;</th>
</tr> </tr>
<? <?
@ -528,7 +520,7 @@ if ($mode == 'ext_groups')
// Format the filesize // Format the filesize
if ($row['max_filesize'] == 0) if ($row['max_filesize'] == 0)
{ {
$row['max_filesize'] = intval($config['max_filesize']); $row['max_filesize'] = (int) $config['max_filesize'];
} }
$size_format = ($row['max_filesize'] >= 1048576) ? 'mb' : (($row['max_filesize'] >= 1024) ? 'kb' : 'b'); $size_format = ($row['max_filesize'] >= 1048576) ? 'mb' : (($row['max_filesize'] >= 1024) ? 'kb' : 'b');
@ -552,7 +544,7 @@ if ($mode == 'ext_groups')
$selected = ($edit_img == $img) ? ' selected="selected"' : ''; $selected = ($edit_img == $img) ? ' selected="selected"' : '';
} }
$filename_list .= '<option value="' . htmlspecialchars($img) . '"' . $selected . '>' . $img . '</option>'; $filename_list .= '<option value="' . htmlspecialchars($img) . '"' . $selected . '>' . htmlspecialchars($img) . '</option>';
} }
?> ?>
<tr> <tr>
@ -583,7 +575,7 @@ if ($mode == 'ext_groups')
if ($viewgroup && $viewgroup == $row['group_id']) if ($viewgroup && $viewgroup == $row['group_id'])
{ {
$sql = 'SELECT comment, extension $sql = 'SELECT extension
FROM ' . EXTENSIONS_TABLE . " FROM ' . EXTENSIONS_TABLE . "
WHERE group_id = $viewgroup"; WHERE group_id = $viewgroup";
$e_result = $db->sql_query($sql); $e_result = $db->sql_query($sql);
@ -604,7 +596,7 @@ if ($mode == 'ext_groups')
} }
?> ?>
<tr> <tr>
<td class="cat" colspan="7" align="center"><input type="submit" name="submit" value="<?php echo $user->lang['SUBMIT']; ?>" class="btnmain" />&nbsp;&nbsp;<input type="reset" value="<?php echo $user->lang['RESET']; ?>" class="btnlite" /></td> <td class="cat" colspan="7" align="right"><input type="submit" name="submit" value="<?php echo $user->lang['SUBMIT']; ?>" class="btnmain" />&nbsp;&nbsp;<input type="reset" value="<?php echo $user->lang['RESET']; ?>" class="btnlite" /></td>
</tr> </tr>
</table> </table>
<? <?
@ -616,12 +608,6 @@ if ($mode == 'extensions')
{ {
?> ?>
<table class="bg" cellspacing="1" cellpadding="4" border="0" align="center" width="99%"> <table class="bg" cellspacing="1" cellpadding="4" border="0" align="center" width="99%">
<tr>
<th align="center" colspan="3"><?php echo $user->lang['MANAGE_EXTENSIONS']; ?></th>
</tr>
<tr>
<td class="spacer" colspan="2" height="1"><img src="../images/spacer.gif" alt="" width="1" height="1" /></td>
</tr>
<tr> <tr>
<th>&nbsp;<?php echo $user->lang['EXTENSION']; ?>&nbsp;</th> <th>&nbsp;<?php echo $user->lang['EXTENSION']; ?>&nbsp;</th>
<th>&nbsp;<?php echo $user->lang['EXTENSION_GROUP']; ?>&nbsp;</th> <th>&nbsp;<?php echo $user->lang['EXTENSION_GROUP']; ?>&nbsp;</th>
@ -675,7 +661,7 @@ if ($mode == 'extensions')
} }
?> ?>
<tr> <tr>
<td class="cat" colspan="3" align="center"><input type="submit" name="submit" value="<?php echo $user->lang['SUBMIT']; ?>" class="btnmain" />&nbsp;&nbsp;<input type="reset" value="<?php echo $user->lang['RESET']; ?>" class="btnlite" /></td> <td class="cat" colspan="3" align="right"><input type="submit" name="submit" value="<?php echo $user->lang['SUBMIT']; ?>" class="btnmain" />&nbsp;&nbsp;<input type="reset" value="<?php echo $user->lang['RESET']; ?>" class="btnlite" /></td>
</tr> </tr>
</table> </table>
<? <?
@ -686,10 +672,10 @@ if ($mode == 'orphan')
{ {
$attach_filelist = array(); $attach_filelist = array();
$dir = @opendir($upload_dir); $dir = @opendir($config['upload_dir']);
while ($file = @readdir($dir)) while ($file = @readdir($dir))
{ {
if (is_file($upload_dir . '/' . $file) && filesize($upload_dir . '/' . $file) && $file != '.htaccess') if (is_file($config['upload_dir'] . '/' . $file) && filesize($config['upload_dir'] . '/' . $file) && $file{0} != '.' && $file != 'index.htm' && !preg_match('#^thumb\_#', $file))
{ {
$attach_filelist[$file] = $file; $attach_filelist[$file] = $file;
} }
@ -729,17 +715,11 @@ function marklist(match, name, status)
<table class="bg" cellspacing="1" cellpadding="4" border="0" align="center" width="99%"> <table class="bg" cellspacing="1" cellpadding="4" border="0" align="center" width="99%">
<tr> <tr>
<th align="center" colspan="5">Orphan Attachments</th> <th>&nbsp;<?php echo $user->lang['FILENAME']; ?>&nbsp;</th>
</tr> <th>&nbsp;<?php echo $user->lang['FILESIZE']; ?>&nbsp;</th>
<tr> <th>&nbsp;<?php echo $user->lang['ATTACH_POST_ID']; ?>&nbsp;</th>
<td class="spacer" colspan="5" height="1"><img src="../images/spacer.gif" alt="" width="1" height="1" /></td> <th>&nbsp;<?php echo $user->lang['ATTACH_TO_POST']; ?>&nbsp;</th>
</tr> <th>&nbsp;<?php echo $user->lang['DELETE']; ?>&nbsp;</th>
<tr>
<th>&nbsp;<?php echo $user->lang['FILENAME']; ?>&nbsp;</th>
<th>&nbsp;<?php echo $user->lang['FILESIZE']; ?>&nbsp;</th>
<th>&nbsp;<?php echo $user->lang['ATTACH_POST_ID']; ?>&nbsp;</th>
<th>&nbsp;<?php echo $user->lang['ATTACH_TO_POST']; ?>&nbsp;</th>
<th>&nbsp;<?php echo $user->lang['DELETE']; ?>&nbsp;</th>
</tr> </tr>
<?php <?php
@ -747,17 +727,17 @@ function marklist(match, name, status)
foreach ($attach_filelist as $file) foreach ($attach_filelist as $file)
{ {
$row_class = (++$i % 2 == 0) ? 'row2' : 'row1'; $row_class = (++$i % 2 == 0) ? 'row2' : 'row1';
$filesize = @filesize($upload_dir . '/' . $file); $filesize = @filesize($config['upload_dir'] . '/' . $file);
$size_lang = ($filesize >= 1048576) ? $user->lang['MB'] : ( ($filesize >= 1024) ? $user->lang['KB'] : $user->lang['BYTES'] ); $size_lang = ($filesize >= 1048576) ? $user->lang['MB'] : ( ($filesize >= 1024) ? $user->lang['KB'] : $user->lang['BYTES'] );
$filesize = ($filesize >= 1048576) ? round((round($filesize / 1048576 * 100) / 100), 2) : (($filesize >= 1024) ? round((round($filesize / 1024 * 100) / 100), 2) : $filesize); $filesize = ($filesize >= 1048576) ? round((round($filesize / 1048576 * 100) / 100), 2) : (($filesize >= 1024) ? round((round($filesize / 1024 * 100) / 100), 2) : $filesize);
?> ?>
<tr> <tr>
<td class="<?php echo $row_class; ?>"><a href="<?php echo $upload_dir . '/' . $file; ?>" class="gen" target="file"><?php echo $file; ?></a></td> <td class="<?php echo $row_class; ?>"><a href="<?php echo $config['upload_dir'] . '/' . $file; ?>" class="gen" target="file"><?php echo $file; ?></a></td>
<td class="<?php echo $row_class; ?>"><?php echo $filesize . ' ' . $size_lang; ?></td> <td class="<?php echo $row_class; ?>"><?php echo $filesize . ' ' . $size_lang; ?></td>
<td class="<?php echo $row_class; ?>"><b class="gen">ID: </b><input type="text" name="post_id[<?php echo $file; ?>]" class="post" size="7" maxlength="10" value="<?php echo (!empty($post_ids[$file])) ? $post_ids[$file] : ''; ?>" /></td> <td class="<?php echo $row_class; ?>"><b class="gen">ID: </b><input type="text" name="post_id[<?php echo $file; ?>]" class="post" size="7" maxlength="10" value="<?php echo (!empty($post_ids[$file])) ? $post_ids[$file] : ''; ?>" /></td>
<td class="<?php echo $row_class; ?>"><input type="checkbox" name="add[<?php echo $file; ?>]" /></td> <td class="<?php echo $row_class; ?>"><input type="checkbox" name="add[<?php echo $file; ?>]" /></td>
<td class="<?php echo $row_class; ?>"><input type="checkbox" name="delete[<?php echo $file; ?>]" /></td> <td class="<?php echo $row_class; ?>"><input type="checkbox" name="delete[<?php echo $file; ?>]" /></td>
</tr> </tr>
<?php <?php
} }

View file

@ -180,7 +180,7 @@ if ($submit)
{ {
// Check Settings // Check Settings
test_upload($error, $new['upload_dir'], false); test_upload($error, $new['upload_dir'], false);
test_upload($error, $new['upload_dir'] . '/thumbs', true); // test_upload($error, $new['upload_dir'] . '/thumbs', true);
} }
if (!sizeof($error)) if (!sizeof($error))

View file

@ -148,7 +148,7 @@ elseif ($pane == 'right')
if (!$delete) if (!$delete)
{ {
set_config('num_users', $config['num_users'] + $db->affected_rows()); set_config('num_users', $config['num_users'] + $db->affected_rows(), true);
} }
$log_action = ($activate) ? 'log_index_activate' : 'log_index_delete'; $log_action = ($activate) ? 'log_index_activate' : 'log_index_delete';
@ -224,8 +224,8 @@ elseif ($pane == 'right')
trigger_error($user->lang['NO_ADMIN']); trigger_error($user->lang['NO_ADMIN']);
} }
set_config('record_online_users', 1); set_config('record_online_users', 1, true);
set_config('record_online_date', time()); set_config('record_online_date', time(), true);
add_log('admin', 'LOG_RESET_ONLINE'); add_log('admin', 'LOG_RESET_ONLINE');
break; break;
@ -242,7 +242,7 @@ elseif ($pane == 'right')
$row = $db->sql_fetchrow($result); $row = $db->sql_fetchrow($result);
$db->sql_freeresult($result); $db->sql_freeresult($result);
set_config('num_posts', $row['stat']); set_config('num_posts', (int) $row['stat'], true);
$sql = 'SELECT COUNT(topic_id) AS stat $sql = 'SELECT COUNT(topic_id) AS stat
FROM ' . TOPICS_TABLE . ' FROM ' . TOPICS_TABLE . '
@ -251,7 +251,7 @@ elseif ($pane == 'right')
$row = $db->sql_fetchrow($result); $row = $db->sql_fetchrow($result);
$db->sql_freeresult($result); $db->sql_freeresult($result);
set_config('num_topics', $row['stat']); set_config('num_topics', (int) $row['stat'], true);
$sql = 'SELECT COUNT(user_id) AS stat $sql = 'SELECT COUNT(user_id) AS stat
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
@ -260,7 +260,21 @@ elseif ($pane == 'right')
$row = $db->sql_fetchrow($result); $row = $db->sql_fetchrow($result);
$db->sql_freeresult($result); $db->sql_freeresult($result);
set_config('num_users', $row['stat']); set_config('num_users', (int) $row['stat'], true);
$sql = 'SELECT COUNT(attach_id) as stat
FROM ' . ATTACHMENTS_TABLE;
$result = $db->sql_query($sql);
set_config('num_files', (int) $db->sql_fetchfield('stat', 0, $result), true);
$db->sql_freeresult($result);
$sql = 'SELECT SUM(filesize) as stat
FROM ' . ATTACHMENTS_TABLE;
$result = $db->sql_query($sql);
set_config('upload_dir_size', (int) $db->sql_fetchfield('stat', 0, $result), true);
$db->sql_freeresult($result);
add_log('admin', 'LOG_RESYNC_STATS'); add_log('admin', 'LOG_RESYNC_STATS');
break; break;
@ -271,7 +285,7 @@ elseif ($pane == 'right')
trigger_error($user->lang['NO_ADMIN']); trigger_error($user->lang['NO_ADMIN']);
} }
set_config('board_startdate', time() - 1); set_config('board_startdate', time() - 1, true);
add_log('admin', 'LOG_RESET_DATE'); add_log('admin', 'LOG_RESET_DATE');
break; break;
} }
@ -280,6 +294,7 @@ elseif ($pane == 'right')
$total_posts = $config['num_posts']; $total_posts = $config['num_posts'];
$total_topics = $config['num_topics']; $total_topics = $config['num_topics'];
$total_users = $config['num_users']; $total_users = $config['num_users'];
$total_files = $config['num_files'];
$start_date = $user->format_date($config['board_startdate']); $start_date = $user->format_date($config['board_startdate']);
@ -288,6 +303,9 @@ elseif ($pane == 'right')
$posts_per_day = sprintf('%.2f', $total_posts / $boarddays); $posts_per_day = sprintf('%.2f', $total_posts / $boarddays);
$topics_per_day = sprintf('%.2f', $total_topics / $boarddays); $topics_per_day = sprintf('%.2f', $total_topics / $boarddays);
$users_per_day = sprintf('%.2f', $total_users / $boarddays); $users_per_day = sprintf('%.2f', $total_users / $boarddays);
$files_per_day = sprintf('%.2f', $total_files / $boarddays);
$upload_dir_size = ($config['upload_dir_size'] >= 1048576) ? sprintf('%.2f ' . $user->lang['MB'], ($config['upload_dir_size'] / 1048576)) : (($config['upload_dir_size'] >= 1024) ? sprintf('%.2f ' . $user->lang['KB'], ($config['upload_dir_size'] / 1024)) : sprintf('%.2f ' . $user->lang['BYTES'], $config['upload_dir_size']));
$avatar_dir_size = 0; $avatar_dir_size = 0;
@ -305,19 +323,7 @@ elseif ($pane == 'right')
// This bit of code translates the avatar directory size into human readable format // This bit of code translates the avatar directory size into human readable format
// Borrowed the code from the PHP.net annoted manual, origanally written by: // Borrowed the code from the PHP.net annoted manual, origanally written by:
// Jesse (jesse@jess.on.ca) // Jesse (jesse@jess.on.ca)
if ($avatar_dir_size >= 1048576) $avatar_dir_size = ($avatar_dir_size >= 1048576) ? sprintf('%.2f ' . $user->lang['MB'], ($avatar_dir_size / 1048576)) : (($avatar_dir_size >= 1024) ? sprintf('%.2f ' . $user->lang['KB'], ($avatar_dir_size / 1024)) : sprintf('%.2f ' . $user->lang['BYTES'], $avatar_dir_size));
{
$avatar_dir_size = round($avatar_dir_size / 1048576 * 100) / 100 . ' MB';
}
else if ($avatar_dir_size >= 1024)
{
$avatar_dir_size = round($avatar_dir_size / 1024 * 100) / 100 . ' KB';
}
else
{
$avatar_dir_size = $avatar_dir_size . ' Bytes';
}
} }
else else
{ {
@ -340,6 +346,11 @@ elseif ($pane == 'right')
$users_per_day = $total_users; $users_per_day = $total_users;
} }
if ($files_per_day > $total_files)
{
$files_per_day = $total_files;
}
// DB size ... MySQL only // DB size ... MySQL only
// This code is heavily influenced by a similar routine // This code is heavily influenced by a similar routine
// in phpMyAdmin 2.2.0 // in phpMyAdmin 2.2.0
@ -403,7 +414,7 @@ elseif ($pane == 'right')
if (is_int($dbsize)) if (is_int($dbsize))
{ {
$dbsize = ($dbsize >= 1048576) ? sprintf('%.2f MB', ($dbsize / 1048576)) : (($dbsize >= 1024) ? sprintf('%.2f KB', ($dbsize / 1024)) : sprintf('%.2f Bytes', $dbsize)); $dbsize = ($dbsize >= 1048576) ? sprintf('%.2f ' . $user->lang['MB'], ($dbsize / 1048576)) : (($dbsize >= 1024) ? sprintf('%.2f ' . $user->lang['KB'], ($dbsize / 1024)) : sprintf('%.2f ' . $user->lang['BYTES'], $dbsize));
} }
adm_page_header($user->lang['ADMIN_INDEX']); adm_page_header($user->lang['ADMIN_INDEX']);
@ -453,6 +464,12 @@ elseif ($pane == 'right')
<td class="row1" nowrap="nowrap"><?php echo $user->lang['USERS_PER_DAY']; ?>:</td> <td class="row1" nowrap="nowrap"><?php echo $user->lang['USERS_PER_DAY']; ?>:</td>
<td class="row2"><b><?php echo $users_per_day; ?></b></td> <td class="row2"><b><?php echo $users_per_day; ?></b></td>
</tr> </tr>
<tr>
<td class="row1" nowrap="nowrap"><?php echo $user->lang['NUMBER_FILES']; ?>:</td>
<td class="row2"><b><?php echo $total_files; ?></b></td>
<td class="row1" nowrap="nowrap"><?php echo $user->lang['FILES_PER_DAY']; ?>:</td>
<td class="row2"><b><?php echo $files_per_day; ?></b></td>
</tr>
<tr> <tr>
<td class="row1" nowrap="nowrap"><?php echo $user->lang['BOARD_STARTED']; ?>:</td> <td class="row1" nowrap="nowrap"><?php echo $user->lang['BOARD_STARTED']; ?>:</td>
<td class="row2"><b><?php echo $start_date; ?></b></td> <td class="row2"><b><?php echo $start_date; ?></b></td>
@ -462,8 +479,14 @@ elseif ($pane == 'right')
<tr> <tr>
<td class="row1" nowrap="nowrap"><?php echo $user->lang['DATABASE_SIZE']; ?>:</td> <td class="row1" nowrap="nowrap"><?php echo $user->lang['DATABASE_SIZE']; ?>:</td>
<td class="row2"><b><?php echo $dbsize; ?></b></td> <td class="row2"><b><?php echo $dbsize; ?></b></td>
<td class="row1" nowrap="nowrap"><?php echo $user->lang['UPLOAD_DIR_SIZE']; ?>:</td>
<td class="row2"><b><?php echo $upload_dir_size; ?></b></td>
</tr>
<tr>
<td class="row1" nowrap="nowrap"><?php echo $user->lang['GZIP_COMPRESSION']; ?>:</td> <td class="row1" nowrap="nowrap"><?php echo $user->lang['GZIP_COMPRESSION']; ?>:</td>
<td class="row2"><b><?php echo ($config['gzip_compress']) ? $user->lang['ON'] : $user->lang['OFF']; ?></b></td> <td class="row2"><b><?php echo ($config['gzip_compress']) ? $user->lang['ON'] : $user->lang['OFF']; ?></b></td>
<td class="row1" nowrap="nowrap">&nbsp;</td>
<td class="row2">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td class="cat" colspan="4" align="right"><select name="action"><option value="online"><?php echo $user->lang['RESET_ONLINE']; ?></option><option value="date"><?php echo $user->lang['RESET_DATE']; ?></option><option value="stats"><?php echo $user->lang['RESYNC_STATS']; ?></option></select> <input class="btnlite" type="submit" name="submit" value="<?php echo $user->lang['SUBMIT']; ?>" />&nbsp;</td> <td class="cat" colspan="4" align="right"><select name="action"><option value="online"><?php echo $user->lang['RESET_ONLINE']; ?></option><option value="date"><?php echo $user->lang['RESET_DATE']; ?></option><option value="stats"><?php echo $user->lang['RESYNC_STATS']; ?></option></select> <input class="btnlite" type="submit" name="submit" value="<?php echo $user->lang['SUBMIT']; ?>" />&nbsp;</td>

View file

@ -256,6 +256,9 @@ if (time() - $config['cache_interval'] >= $config['cache_last_gc'])
} }
*/ */
// Adjust storage path's
$config['upload_dir'] = ($config['upload_dir']{0} == '/' || ($config['upload_dir']{0} != '/' && $config['upload_dir']{1} == ':')) ? $config['upload_dir'] : $phpbb_root_path . $config['upload_dir'];
// Handle email/cron queue. // Handle email/cron queue.
if (time() - $config['queue_interval'] >= $config['last_queue_run'] && !defined('IN_ADMIN')) if (time() - $config['queue_interval'] >= $config['last_queue_run'] && !defined('IN_ADMIN'))
{ {

View file

@ -78,11 +78,10 @@ if (!in_array($attachment['extension'], $extensions['_allowed_']))
} }
$download_mode = (int) $extensions[$attachment['extension']]['download_mode']; $download_mode = (int) $extensions[$attachment['extension']]['download_mode'];
$upload_dir = ($config['upload_dir'][0] == '/' || ($config['upload_dir'][0] != '/' && $config['upload_dir'][1] == ':')) ? $config['upload_dir'] : $phpbb_root_path . $config['upload_dir'];
if ($thumbnail) if ($thumbnail)
{ {
$attachment['physical_filename'] = 'thumbs/t_' . $attachment['physical_filename']; $attachment['physical_filename'] = 'thumb_' . $attachment['physical_filename'];
} }
else else
{ {
@ -96,16 +95,16 @@ else
// Determine the 'presenting'-method // Determine the 'presenting'-method
if ($download_mode == PHYSICAL_LINK) if ($download_mode == PHYSICAL_LINK)
{ {
if (!@is_dir($upload_dir)) if (!@is_dir($config['upload_dir']))
{ {
trigger_error($user->lang['PHYSICAL_DOWNLOAD_NOT_POSSIBLE']); trigger_error($user->lang['PHYSICAL_DOWNLOAD_NOT_POSSIBLE']);
} }
redirect($upload_dir . '/' . $attachment['physical_filename']); redirect($config['upload_dir'] . '/' . $attachment['physical_filename']);
} }
else else
{ {
send_file_to_browser($attachment, $upload_dir, $extensions[$attachment['extension']]['display_cat']); send_file_to_browser($attachment, $config['upload_dir'], $extensions[$attachment['extension']]['display_cat']);
exit; exit;
} }

View file

@ -514,7 +514,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = TRUE)
// resync => set this to false if you are deleting posts or topics... // resync => set this to false if you are deleting posts or topics...
function delete_attachments($mode, $ids, $resync = TRUE) function delete_attachments($mode, $ids, $resync = TRUE)
{ {
global $db; global $db, $config;
if (is_array($ids)) if (is_array($ids))
{ {
@ -533,7 +533,7 @@ function delete_attachments($mode, $ids, $resync = TRUE)
// Collect post and topics ids for later use // Collect post and topics ids for later use
if ($mode == 'attach' || $mode == 'user' || ($mode == 'topic' && $resync)) if ($mode == 'attach' || $mode == 'user' || ($mode == 'topic' && $resync))
{ {
$sql = 'SELECT post_id, topic_id, physical_filename, thumbnail $sql = 'SELECT post_id, topic_id, physical_filename, thumbnail, filesize
FROM ' . ATTACHMENTS_TABLE . ' FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . $sql_id . ' IN (' . implode(', ', $ids) . ')'; WHERE ' . $sql_id . ' IN (' . implode(', ', $ids) . ')';
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
@ -542,14 +542,14 @@ function delete_attachments($mode, $ids, $resync = TRUE)
{ {
$post_ids[] = $row['post_id']; $post_ids[] = $row['post_id'];
$topic_ids[] = $row['topic_id']; $topic_ids[] = $row['topic_id'];
$physical[] = array('filename' => $row['physical_filename'], 'thumbnail' => $row['thumbnail']); $physical[] = array('filename' => $row['physical_filename'], 'thumbnail' => $row['thumbnail'], 'filesize' => $row['filesize']);
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
} }
if ($mode == 'post') if ($mode == 'post')
{ {
$sql = 'SELECT topic_id, physical_filename, thumbnail $sql = 'SELECT topic_id, physical_filename, thumbnail, filesize
FROM ' . ATTACHMENTS_TABLE . ' FROM ' . ATTACHMENTS_TABLE . '
WHERE post_id IN (' . implode(', ', $ids) . ')'; WHERE post_id IN (' . implode(', ', $ids) . ')';
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
@ -557,7 +557,7 @@ function delete_attachments($mode, $ids, $resync = TRUE)
while ($row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))
{ {
$topic_ids[] = $row['topic_id']; $topic_ids[] = $row['topic_id'];
$physical[] = array('filename' => $row['physical_filename'], 'thumbnail' => $row['thumbnail']); $physical[] = array('filename' => $row['physical_filename'], 'thumbnail' => $row['thumbnail'], 'filesize' => $row['filesize']);
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
} }
@ -567,14 +567,22 @@ function delete_attachments($mode, $ids, $resync = TRUE)
$num_deleted = $db->sql_affectedrows(); $num_deleted = $db->sql_affectedrows();
// Delete attachments from filesystem // Delete attachments from filesystem
$space_removed = $files_removed = 0;
foreach ($physical as $file_ary) foreach ($physical as $file_ary)
{ {
phpbb_unlink($file_ary['filename'], 'file'); if (phpbb_unlink($file_ary['filename'], 'file'))
{
$space_removed += $file_ary['filesize'];
$files_removed++;
}
if ($file_ary['thumbnail']) if ($file_ary['thumbnail'])
{ {
phpbb_unlink($file_ary['filename'], 'thumbnail'); phpbb_unlink($file_ary['filename'], 'thumbnail');
} }
} }
set_config('upload_dir_size', $config['upload_dir_size'] - $space_removed, true);
set_config('num_files', $config['num_files'] - $files_removed, true);
if ($mode == 'topic' && !$resync) if ($mode == 'topic' && !$resync)
{ {
@ -712,9 +720,7 @@ function phpbb_unlink($filename, $mode = 'file')
{ {
global $config, $user, $phpbb_root_path; global $config, $user, $phpbb_root_path;
$upload_dir = ($config['upload_dir'][0] == '/' || ($config['upload_dir'][0] != '/' && $config['upload_dir'][1] == ':')) ? $config['upload_dir'] : $phpbb_root_path . $config['upload_dir']; $filename = ($mode == 'thumbnail') ? $config['upload_dir'] . '/thumb_' . $filename : $config['upload_dir'] . '/' . $filename;
$filename = ($mode == 'thumbnail') ? $upload_dir . '/thumbs/t_' . $filename : $upload_dir . '/' . $filename;
$deleted = @unlink($filename); $deleted = @unlink($filename);
if (file_exists($filename)) if (file_exists($filename))
@ -724,6 +730,7 @@ function phpbb_unlink($filename, $mode = 'file')
if (file_exists($filename)) if (file_exists($filename))
{ {
$filename = realpath($filename);
@chmod($filename, 0777); @chmod($filename, 0777);
if (!($deleted = @unlink($filename))) if (!($deleted = @unlink($filename)))
{ {

View file

@ -295,7 +295,6 @@ function display_attachments($blockname, $attachment_data, &$update_count, $forc
// $starttime = explode(' ', microtime()); // $starttime = explode(' ', microtime());
// $starttime = $starttime[1] + $starttime[0]; // $starttime = $starttime[1] + $starttime[0];
$upload_dir = ($config['upload_dir'][0] == '/' || ($config['upload_dir'][0] != '/' && $config['upload_dir'][1] == ':')) ? $config['upload_dir'] : $phpbb_root_path . $config['upload_dir'];
$blocks = array(WM_CAT => 'WM_STREAM', RM_CAT => 'RM_STREAM', THUMB_CAT => 'THUMBNAIL', IMAGE_CAT => 'IMAGE'); $blocks = array(WM_CAT => 'WM_STREAM', RM_CAT => 'RM_STREAM', THUMB_CAT => 'THUMBNAIL', IMAGE_CAT => 'IMAGE');
if (!isset($attachment_tpl)) if (!isset($attachment_tpl))
@ -349,8 +348,8 @@ function display_attachments($blockname, $attachment_data, &$update_count, $forc
{ {
// Some basics... // Some basics...
$attachment['extension'] = strtolower(trim($attachment['extension'])); $attachment['extension'] = strtolower(trim($attachment['extension']));
$filename = $upload_dir . '/' . $attachment['physical_filename']; $filename = $config['upload_dir'] . '/' . $attachment['physical_filename'];
$thumbnail_filename = $upload_dir . '/thumbs/t_' . $attachment['physical_filename']; $thumbnail_filename = $config['upload_dir'] . '/thumb_' . $attachment['physical_filename'];
$upload_image = ''; $upload_image = '';

View file

@ -140,8 +140,7 @@ function update_last_post_information($type, $id)
switch ($type) switch ($type)
{ {
case 'forum': case 'forum':
// Anyone having any ideas how to optimize this? // Splitted query - performance gain
// This query is very time consuming on large boards (already optimized this by 50%)
$sql = 'SELECT MAX(post_time) AS max_post_time FROM ' . POSTS_TABLE . ' $sql = 'SELECT MAX(post_time) AS max_post_time FROM ' . POSTS_TABLE . '
WHERE post_approved = 1 WHERE post_approved = 1
AND forum_id = ' . $id; AND forum_id = ' . $id;
@ -210,7 +209,7 @@ function upload_attachment($filename, $local = false, $local_storage = '')
$file = (!$local) ? $_FILES['fileupload']['tmp_name'] : $local_storage; $file = (!$local) ? $_FILES['fileupload']['tmp_name'] : $local_storage;
$filedata['mimetype'] = (!$local) ? $_FILES['fileupload']['type'] : 'application/octet-stream'; $filedata['mimetype'] = (!$local) ? $_FILES['fileupload']['type'] : 'application/octet-stream';
// Opera add the name to the mime type // Opera adds the name to the mime type
$filedata['mimetype'] = ( strstr($filedata['mimetype'], '; name') ) ? str_replace(strstr($filedata['mimetype'], '; name'), '', $filedata['mimetype']) : $filedata['mimetype']; $filedata['mimetype'] = ( strstr($filedata['mimetype'], '; name') ) ? str_replace(strstr($filedata['mimetype'], '; name'), '', $filedata['mimetype']) : $filedata['mimetype'];
$filedata['extension'] = array_pop(explode('.', strtolower($filename))); $filedata['extension'] = array_pop(explode('.', strtolower($filename)));
$filedata['filesize'] = (!@filesize($file)) ? intval($_FILES['size']) : @filesize($file); $filedata['filesize'] = (!@filesize($file)) ? intval($_FILES['size']) : @filesize($file);
@ -254,7 +253,7 @@ function upload_attachment($filename, $local = false, $local_storage = '')
{ {
if ($width > $config['img_max_width'] || $height > $config['img_max_height']) if ($width > $config['img_max_width'] || $height > $config['img_max_height'])
{ {
$filedata['error'][] = sprintf($user->lang['Error_imagesize'], $config['img_max_width'], $config['img_max_height']); $filedata['error'][] = sprintf($user->lang['ERROR_IMAGESIZE'], $config['img_max_width'], $config['img_max_height']);
$filedata['post_attach'] = FALSE; $filedata['post_attach'] = FALSE;
return $filedata; return $filedata;
} }
@ -262,7 +261,7 @@ function upload_attachment($filename, $local = false, $local_storage = '')
} }
// check Filesize // check Filesize
if ($allowed_filesize != 0 && $filedata['filesize'] > $allowed_filesize && !$auth->acl_gets('m_', 'a_')) if ($allowed_filesize && $filedata['filesize'] > $allowed_filesize && !$auth->acl_gets('m_', 'a_'))
{ {
$size_lang = ($allowed_filesize >= 1048576) ? $user->lang['MB'] : ( ($allowed_filesize >= 1024) ? $user->lang['KB'] : $user->lang['BYTES'] ); $size_lang = ($allowed_filesize >= 1048576) ? $user->lang['MB'] : ( ($allowed_filesize >= 1024) ? $user->lang['KB'] : $user->lang['BYTES'] );
@ -274,9 +273,9 @@ function upload_attachment($filename, $local = false, $local_storage = '')
} }
// Check our complete quota // Check our complete quota
if ($config['attachment_quota'] != 0) if ($config['attachment_quota'])
{ {
if ($config['total_filesize'] + $filedata['filesize'] > $config['attachment_quota']) if ($config['upload_dir_size'] + $filedata['filesize'] > $config['attachment_quota'])
{ {
$filedata['error'][] = $user->lang['ATTACH_QUOTA_REACHED']; $filedata['error'][] = $user->lang['ATTACH_QUOTA_REACHED'];
$filedata['post_attach'] = FALSE; $filedata['post_attach'] = FALSE;
@ -284,6 +283,20 @@ function upload_attachment($filename, $local = false, $local_storage = '')
} }
} }
/*
// TODO
// Check Free Disk Space - need testing under windows [commented out]
if ($free_space = disk_free_space($config['upload_dir']))
{
if ($free_space <= $filedata['filesize'])
{
$filedata['error'][] = $user->lang['ATTACH_QUOTA_REACHED'];
$filedata['post_attach'] = FALSE;
return $filedata;
}
}
*/
$filedata['thumbnail'] = 0; $filedata['thumbnail'] = 0;
// Prepare Values // Prepare Values
@ -321,52 +334,51 @@ function move_uploaded_attachment($upload_mode, $source_filename, &$filedata)
{ {
global $user, $config, $phpbb_root_path; global $user, $config, $phpbb_root_path;
$upload_dir = ($config['upload_dir'][0] == '/' || ($config['upload_dir'][0] != '/' && $config['upload_dir'][1] == ':')) ? $config['upload_dir'] : $phpbb_root_path . $config['upload_dir'];
$destination_filename = $filedata['destination_filename']; $destination_filename = $filedata['destination_filename'];
$thumbnail = (isset($filedata['thumbnail'])) ? $filedata['thumbnail'] : FALSE; $thumbnail = (isset($filedata['thumbnail'])) ? $filedata['thumbnail'] : FALSE;
switch ($upload_mode) switch ($upload_mode)
{ {
case 'copy': case 'copy':
if ( !@copy($source_filename, $upload_dir . '/' . $destination_filename) ) if ( !@copy($source_filename, $config['upload_dir'] . '/' . $destination_filename) )
{ {
if ( !@move_uploaded_file($source_filename, $upload_dir . '/' . $destination_filename) ) if ( !@move_uploaded_file($source_filename, $config['upload_dir'] . '/' . $destination_filename) )
{ {
return sprintf($user->lang['GENERAL_UPLOAD_ERROR'], $upload_dir . '/' . $destination_filename); return sprintf($user->lang['GENERAL_UPLOAD_ERROR'], $config['upload_dir'] . '/' . $destination_filename);
} }
} }
@chmod($upload_dir . '/' . $destination_filename, 0666); @chmod($config['upload_dir'] . '/' . $destination_filename, 0666);
break; break;
case 'move': case 'move':
if ( !@move_uploaded_file($source_filename, $upload_dir . '/' . $destination_filename) ) if ( !@move_uploaded_file($source_filename, $config['upload_dir'] . '/' . $destination_filename) )
{ {
if ( !@copy($source_file, $upload_dir . '/' . $destination_filename) ) if ( !@copy($source_filename, $config['upload_dir'] . '/' . $destination_filename) )
{ {
return sprintf($user->lang['GENERAL_UPLOAD_ERROR'], $upload_dir . '/' . $destination_filename); return sprintf($user->lang['GENERAL_UPLOAD_ERROR'], $config['upload_dir'] . '/' . $destination_filename);
} }
} }
@chmod($upload_dir . '/' . $destination_filename, 0666); @chmod($config['upload_dir'] . '/' . $destination_filename, 0666);
break; break;
case 'local': case 'local':
if (!@copy($source_filename, $upload_dir . '/' . $destination_filename)) if (!@copy($source_filename, $config['upload_dir'] . '/' . $destination_filename))
{ {
return sprintf($user->lang['GENERAL_UPLOAD_ERROR'], $upload_dir . '/' . $destination_filename); return sprintf($user->lang['GENERAL_UPLOAD_ERROR'], $config['upload_dir'] . '/' . $destination_filename);
} }
@chmod($upload_dir . '/' . $destination_filename, 0666); @chmod($config['upload_dir'] . '/' . $destination_filename, 0666);
@unlink($source_filename); @unlink($source_filename);
break; break;
} }
if ($filedata['thumbnail']) if ($filedata['thumbnail'])
{ {
$source = $upload_dir . '/' . $destination_filename; $source = $config['upload_dir'] . '/' . $destination_filename;
$destination = $upload_dir . '/thumbs/t_' . $destination_filename; $destination = $config['upload_dir'] . '/thumb_' . $destination_filename;
if (!create_thumbnail($source, $destination, $filedata['mimetype'])) if (!create_thumbnail($source_filename, $destination_filename, $filedata['mimetype']))
{ {
if (!create_thumbnail($source_filename, $destination_filename, $filedata['mimetype'])) if (!create_thumbnail($source, $destination, $filedata['mimetype']))
{ {
$filedata['thumbnail'] = 0; $filedata['thumbnail'] = 0;
} }
@ -518,6 +530,7 @@ function create_thumbnail($source, $new_file, $mimetype)
return FALSE; return FALSE;
} }
@chmod($new_file, 0666); @chmod($new_file, 0666);
return TRUE; return TRUE;

View file

@ -741,7 +741,7 @@ class parse_message
if ($this->attachment_data[$index]['thumbnail']) if ($this->attachment_data[$index]['thumbnail'])
{ {
phpbb_unlink('t_' . $this->attachment_data[$index]['physical_filename'], 'thumbnail'); phpbb_unlink($this->attachment_data[$index]['physical_filename'], 'thumbnail');
} }
} }
else else

View file

@ -506,13 +506,13 @@ class ucp_main extends module
$draft_id = ($edit) ? intval($_REQUEST['edit']) : 0; $draft_id = ($edit) ? intval($_REQUEST['edit']) : 0;
$s_hidden_fields = ($edit) ? '<input type="hidden" name="edit" value="' . $draft_id . '" />' : ''; $s_hidden_fields = ($edit) ? '<input type="hidden" name="edit" value="' . $draft_id . '" />' : '';
$draft_title = $post_subject = $post_message = ''; $draft_subject = $draft_message = '';
if ($_POST['delete']) if ($_POST['delete'])
{ {
$drafts = (isset($_POST['d'])) ? implode(', ', array_map('intval', array_keys($_POST['d']))) : false; $drafts = (isset($_POST['d'])) ? implode(', ', array_map('intval', array_keys($_POST['d']))) : '';
if ($drafts) if (!empty($drafts))
{ {
$sql = 'DELETE FROM ' . DRAFTS_TABLE . " $sql = 'DELETE FROM ' . DRAFTS_TABLE . "
WHERE draft_id IN ($drafts) WHERE draft_id IN ($drafts)
@ -528,16 +528,15 @@ class ucp_main extends module
if ($submit && $edit) if ($submit && $edit)
{ {
$draft_title = (isset($_POST['draft_title'])) ? trim(htmlspecialchars($_POST['draft_title'])) : ''; $draft_subject = preg_replace('#&amp;(\#[0-9]+;)#', '&\1', request_var('subject', ''));
$post_subject = (isset($_POST['subject'])) ? trim(htmlspecialchars($_POST['subject'])) : ''; $draft_message = (isset($_POST['message'])) ? htmlspecialchars(trim(str_replace(array('\\\'', '\\"', '\\0', '\\\\'), array('\'', '"', '\0', '\\'), $_POST['message']))) : '';
$post_message = (isset($_POST['message'])) ? trim(str_replace(array('\\\'', '\\"', '\\0', '\\\\'), array('\'', '"', '\0', '\\'), htmlspecialchars($_POST['message']))) : ''; $draft_message = preg_replace('#&amp;(\#[0-9]+;)#', '&\1', $draft_message);
if ($post_message != '' && $draft_title != '') if ($draft_message != '' && $draft_subject != '')
{ {
$draft_row = array( $draft_row = array(
'title' => $draft_title, 'draft_subject' => $draft_subject,
'post_subject' => $post_subject, 'draft_message' => $draft_message
'post_message' => $post_message
); );
$sql = 'UPDATE ' . DRAFTS_TABLE . ' $sql = 'UPDATE ' . DRAFTS_TABLE . '
@ -553,18 +552,19 @@ class ucp_main extends module
} }
else else
{ {
$template->assign_var('ERROR', ($post_message == '') ? $user->lang['EMPTY_DRAFT'] : (($draft_title == '') ? $user->lang['EMPTY_DRAFT_TITLE'] : '')); $template->assign_var('ERROR', ($draft_message == '') ? $user->lang['EMPTY_DRAFT'] : (($draft_subject == '') ? $user->lang['EMPTY_DRAFT_TITLE'] : ''));
} }
} }
$sql = 'SELECT * $sql = 'SELECT d.*, f.forum_name
FROM ' . DRAFTS_TABLE . ' FROM ' . DRAFTS_TABLE . ' d, ' . FORUMS_TABLE . ' f
WHERE user_id = ' . $user->data['user_id'] . ' ' . WHERE d.user_id = ' . $user->data['user_id'] . ' ' .
(($edit) ? "AND draft_id = $draft_id" : '') . ' (($edit) ? "AND d.draft_id = $draft_id" : '') . '
AND f.forum_id = d.forum_id
ORDER BY save_time DESC'; ORDER BY save_time DESC';
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$draftrows = $topic_ids = $topic_rows = array(); $draftrows = $topic_ids = array();
while ($row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))
{ {
@ -601,42 +601,41 @@ class ucp_main extends module
$row_count = 0; $row_count = 0;
foreach ($draftrows as $draft) foreach ($draftrows as $draft)
{ {
$title = $draft['title']; $link_topic = $link_forum = 0;
if (strlen($title) > 30) $insert_url = $view_url = $title = '';
{
$title = substr($title, 0, 27) . '...';
}
if (isset($topic_rows[$draft['topic_id']])) if (isset($topic_rows[$draft['topic_id']]) && $auth->acl_get('f_read', $topic_rows[$draft['topic_id']]['forum_id']))
{ {
$view_topic_url = ($auth->acl_get('f_read', $topic_rows[$draft['topic_id']]['forum_id'])) ? "viewtopic.$phpEx$SID&amp;f=" . $topic_rows[$draft['topic_id']]['forum_id'] . "&amp;t=" . $draft['topic_id'] : ''; $link_topic = true;
} $view_url = "viewtopic.$phpEx$SID&amp;f=" . $topic_rows[$draft['topic_id']]['forum_id'] . "&amp;t=" . $draft['topic_id'];
else $title = $topic_rows[$draft['topic_id']]['topic_title'];
{
$view_topic_url = '';
}
$topic_title = ($view_topic_url != '') ? $topic_rows[$draft['topic_id']]['topic_title'] : '';
if (strlen($topic_title) > 30) $insert_url = "posting.$phpEx$SID&amp;f=" . $topic_rows[$draft['topic_id']]['forum_id'] . '&amp;t=' . $draft['topic_id'] . '&amp;mode=reply&amp;d=' . $draft['draft_id'];
}
else if ($auth->acl_get('f_read', $draft['forum_id']))
{ {
$topic_title = substr($topic_title, 0, 27) . '...'; $link_forum = true;
$view_url = "viewforum.$phpEx$SID&amp;f=" . $draft['forum_id'];
$title = $draft['forum_name'];
$insert_url = "posting.$phpEx$SID&amp;f=" . $draft['forum_id'] . '&amp;mode=post&amp;d=' . $draft['draft_id'];
} }
$template_row = array( $template_row = array(
'DRAFT_ID' => $draft['draft_id'], 'DRAFT_ID' => $draft['draft_id'],
'DATE' => $user->format_date($draft['save_time']), 'DATE' => $user->format_date($draft['save_time']),
'DRAFT_MESSAGE' => ($submit) ? $draft_message : $draft['draft_message'],
'DRAFT_SUBJECT' => ($submit) ? $draft_subject : $draft['draft_subject'],
'TITLE' => $title, 'TITLE' => $title,
'TOPIC_TITLE' => ($view_topic_url != '') ? $topic_title : '', 'U_VIEW' => $view_url,
'DRAFT_TITLE' => ($submit) ? $draft_title : $draft['title'],
'POST_MESSAGE' => ($submit) ? $post_message : $draft['post_message'],
'POST_SUBJECT' => ($submit) ? $post_subject : $draft['post_subject'],
'U_VIEW_TOPIC' => $view_topic_url,
'U_VIEW_EDIT' => "ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode&amp;edit=" . $draft['draft_id'], 'U_VIEW_EDIT' => "ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode&amp;edit=" . $draft['draft_id'],
'U_INSERT' => $insert_url,
'S_ROW_COUNT' => $row_count++, 'S_ROW_COUNT' => $row_count++,
'S_HIDDEN_FIELDS' => $s_hidden_fields 'S_HIDDEN_FIELDS' => $s_hidden_fields,
'S_LINK_TOPIC' => $link_topic,
'S_LINK_FORUM' => $link_forum
); );
if ($edit) if ($edit)
@ -659,7 +658,7 @@ class ucp_main extends module
'S_DISPLAY_MARK_ALL' => ($mode == 'watched' || ($mode == 'drafts' && !isset($_GET['edit']))) ? true : false, 'S_DISPLAY_MARK_ALL' => ($mode == 'watched' || ($mode == 'drafts' && !isset($_GET['edit']))) ? true : false,
'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_HIDDEN_FIELDS' => $s_hidden_fields,
'S_UCP_ACTION' => "ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode") 'S_UCP_ACTION' => $phpbb_root_path . "ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode")
); );
$this->display($user->lang['UCP_MAIN'], 'ucp_main_' . $mode . '.html'); $this->display($user->lang['UCP_MAIN'], 'ucp_main_' . $mode . '.html');

View file

@ -4,7 +4,7 @@
# $Id$ # $Id$
# #
# Table: phpbb_attachments_desc # Table: phpbb_attachments
CREATE TABLE phpbb_attachments ( CREATE TABLE phpbb_attachments (
attach_id mediumint(8) UNSIGNED NOT NULL auto_increment, attach_id mediumint(8) UNSIGNED NOT NULL auto_increment,
post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
@ -146,12 +146,12 @@ CREATE TABLE phpbb_drafts (
draft_id mediumint(8) UNSIGNED NOT NULL auto_increment, draft_id mediumint(8) UNSIGNED NOT NULL auto_increment,
user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
save_time int(11) UNSIGNED DEFAULT '0' NOT NULL, save_time int(11) UNSIGNED DEFAULT '0' NOT NULL,
title varchar(60) DEFAULT '' NOT NULL, draft_subject varchar(60),
post_subject varchar(60), draft_message text DEFAULT '' NOT NULL,
post_message text DEFAULT '' NOT NULL,
PRIMARY KEY (draft_id), PRIMARY KEY (draft_id),
KEY user_id (user_id,save_time) KEY save_time (save_time)
); );
# Table: 'phpbb_extensions' # Table: 'phpbb_extensions'

View file

@ -157,6 +157,8 @@ INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('newest
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('num_users', '1', 1); INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('num_users', '1', 1);
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('num_posts', '1', 1); INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('num_posts', '1', 1);
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('num_topics', '1', 1); INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('num_topics', '1', 1);
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('num_files', '0', 1);
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('upload_dir_size', '0', 1);
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('session_last_gc', '0', 1); INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('session_last_gc', '0', 1);
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('search_last_gc', '0', 1); INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('search_last_gc', '0', 1);
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('last_queue_run', '0', 1); INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('last_queue_run', '0', 1);

View file

@ -248,8 +248,11 @@ $lang += array(
'TOPICS_PER_DAY'=> 'Topics per day', 'TOPICS_PER_DAY'=> 'Topics per day',
'NUMBER_USERS' => 'Number of users', 'NUMBER_USERS' => 'Number of users',
'USERS_PER_DAY' => 'Users per day', 'USERS_PER_DAY' => 'Users per day',
'NUMBER_FILES' => 'Number of Attachments',
'FILES_PER_DAY' => 'Attachments per day',
'BOARD_STARTED' => 'Board started', 'BOARD_STARTED' => 'Board started',
'AVATAR_DIR_SIZE' => 'Avatar directory size', 'AVATAR_DIR_SIZE' => 'Avatar directory size',
'UPLOAD_DIR_SIZE' => 'Upload directory size',
'DATABASE_SIZE' => 'Database size', 'DATABASE_SIZE' => 'Database size',
'GZIP_COMPRESSION' => 'Gzip compression', 'GZIP_COMPRESSION' => 'Gzip compression',
'NOT_AVAILABLE' => 'Not available', 'NOT_AVAILABLE' => 'Not available',

View file

@ -638,18 +638,19 @@ $lang += array(
'SAVE' => 'Save', 'SAVE' => 'Save',
'LOAD' => 'Load', 'LOAD' => 'Load',
'DRAFT_SAVED' => 'Post contents successfully saved as draft.<br />You are able to load this draft to posts you make, or view and edit them within your User Control Panel.',
'ENTER_DRAFT_TITLE' => 'Enter draft title',
'DRAFT_TITLE_EXPLAIN' => 'Now you are able to change the draft title directly. At the moment the draft title is similar to the post subject.',
'UPDATE' => 'Update', 'UPDATE' => 'Update',
'LOAD_DRAFT' => 'Load Draft',
'LOAD_DRAFT_EXPLAIN'=> 'Here you are able to select the draft you want to continue writing. Your current post will be canceled, all current post contents will be deleted. View, edit and delete drafts within your User Control Panel.',
'DRAFT_SAVED' => 'Draft successfully saved.',
'DRAFT_LOADED' => 'Draft loaded into posting area, you may want to finish your post now.<br />Your Draft will be deleted after submitting this post.',
'CURRENT_TOPIC' => 'Current Topic',
'POST_STORED' => 'Your message has been posted successfully', 'POST_STORED' => 'Your message has been posted successfully',
'POST_STORED_MOD' => 'Your message has been saved but requires approval', 'POST_STORED_MOD' => 'Your message has been saved but requires approval',
'POST_DELETED' => 'Your message has been deleted successfully', 'POST_DELETED' => 'Your message has been deleted successfully',
'TOPIC_BUMPED' => 'Topic has been bumped successfully', 'TOPIC_BUMPED' => 'Topic has been bumped successfully',
'Poll_delete' => 'Your poll has been deleted successfully', 'POLL_DELETED' => 'Your poll has been deleted successfully',
'Topic_reply_notification' => 'Topic Reply Notification',
'TOO_FEW_POLL_OPTIONS' => 'You must enter at least two poll options', 'TOO_FEW_POLL_OPTIONS' => 'You must enter at least two poll options',
'TOO_MANY_POLL_OPTIONS' => 'You have tried to enter too many poll options', 'TOO_MANY_POLL_OPTIONS' => 'You have tried to enter too many poll options',
@ -664,12 +665,13 @@ $lang += array(
'ALLOWED' => 'Allowed', 'ALLOWED' => 'Allowed',
'ATTACHMENT_PHP_SIZE_NA' => 'The attachment is too big.<br />Could not get determine the maximum size defined by PHP in php.ini.', 'ATTACHMENT_PHP_SIZE_NA' => 'The attachment is too big.<br />Could not get determine the maximum size defined by PHP in php.ini.',
'ATTACHMENT_PHP_SIZE_OVERRUN'=> 'The attachment is too big, maximum upload size is %d MB.<br />Please note this is set in php.ini and cannot be overriden.', 'ATTACHMENT_PHP_SIZE_OVERRUN'=> 'The attachment is too big, maximum upload size is %d MB.<br />Please note this is set in php.ini and cannot be overriden.',
'ATTACHMENT_TOO_BIG' => 'The attachment is too big, maximum size is %1d %2s', 'ATTACHMENT_TOO_BIG' => 'The attachment is too big, maximum allowed size is %1d %2s',
'ATTACH_QUOTA_REACHED' => 'Sorry, the board attachment quota has been reached.', 'ATTACH_QUOTA_REACHED' => 'Sorry, the board attachment quota has been reached.',
'BYTES' => 'Bytes', 'BYTES' => 'Bytes',
'KB' => 'KB', 'KB' => 'KB',
'MB' => 'MB', 'MB' => 'MB',
'DOWNLOAD_NOTICE' => 'You do not have the required permissions to view the files attached to this post.', // Differate the case more? 'DOWNLOAD_NOTICE' => 'You do not have the required permissions to view the files attached to this post.', // Differate the case more?
'ERROR_IMAGESIZE' => 'The Image you tried to attach is too big, maximum allowed dimensions are %1d px X %2d px.',
'EXTENSION_DISABLED_AFTER_POSTING' => 'The extension <b>%s</b> has been deactivated and can no longer be displayed.', // used in Posts and PM's, replace %s with extension 'EXTENSION_DISABLED_AFTER_POSTING' => 'The extension <b>%s</b> has been deactivated and can no longer be displayed.', // used in Posts and PM's, replace %s with extension
'DESCRIPTION' => 'Description', 'DESCRIPTION' => 'Description',
@ -726,7 +728,6 @@ $lang += array(
'VIEW_EDIT' => 'View/Edit', 'VIEW_EDIT' => 'View/Edit',
'DRAFT_TITLE' => 'Draft Title', 'DRAFT_TITLE' => 'Draft Title',
'SAVE_DATE' => 'Saved at', 'SAVE_DATE' => 'Saved at',
'NEW_OR_DELETED_TOPIC' => 'New topic or deleted',
'EDIT_DRAFT_EXPLAIN' => 'Here you are able to edit your draft.', 'EDIT_DRAFT_EXPLAIN' => 'Here you are able to edit your draft.',
'DRAFTS_DELETED' => 'All selected drafts were successfully deleted.', 'DRAFTS_DELETED' => 'All selected drafts were successfully deleted.',
'DRAFT_UPDATED' => 'Draft successfully updated.', 'DRAFT_UPDATED' => 'Draft successfully updated.',
@ -1380,8 +1381,10 @@ $lang += array(
'NO_SUBJECT' => '&lt;No subject&gt;', 'NO_SUBJECT' => '&lt;No subject&gt;',
'logm_lock' => '<b>Locked topic</b>', 'LOGM_LOCK' => '<b>Locked topic</b><br />&#187; %s',
'logm_unlock' => '<b>Unlocked topic</b>', 'LOGM_UNLOCK' => '<b>Unlocked topic</b><br />&#187; %s',
'LOGM_USER_LOCK' => '<b>Poster Locked topic</b><br />&#187; %s',
'LOGM_USER_UNLOCK' => '<b>Poster Unlocked topic</b><br />&#187; %s',
'logm_move' => '<b>Moved topic</b> from %s', 'logm_move' => '<b>Moved topic</b> from %s',
'logm_fork' => '<b>Copied topic</b> from %s', 'logm_fork' => '<b>Copied topic</b> from %s',
'logm_split' => '<b>Split topic</b> from topic %s', 'logm_split' => '<b>Split topic</b> from topic %s',

View file

@ -30,16 +30,18 @@ $mode = request_var('mode', '');
$post_id = request_var('p', 0); $post_id = request_var('p', 0);
$topic_id = request_var('t', 0); $topic_id = request_var('t', 0);
$forum_id = request_var('f', 0); $forum_id = request_var('f', 0);
$draft_id = request_var('d', 0);
$lastclick = request_var('lastclick', 0); $lastclick = request_var('lastclick', 0);
$submit = (isset($_POST['post'])) ? TRUE : FALSE; $submit = (isset($_POST['post'])) ? TRUE : FALSE;
$preview = (isset($_POST['preview'])) ? TRUE : FALSE; $preview = (isset($_POST['preview'])) ? TRUE : FALSE;
$save = (isset($_POST['save'])) ? TRUE : FALSE; $save = (isset($_POST['save'])) ? TRUE : FALSE;
$load = (isset($_POST['load'])) ? TRUE : FALSE;
$cancel = (isset($_POST['cancel'])) ? TRUE : FALSE; $cancel = (isset($_POST['cancel'])) ? TRUE : FALSE;
$confirm = (isset($_POST['confirm'])) ? TRUE : FALSE; $confirm = (isset($_POST['confirm'])) ? TRUE : FALSE;
$delete = (isset($_POST['delete'])) ? TRUE : FALSE; $delete = (isset($_POST['delete'])) ? TRUE : FALSE;
$refresh = isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['edit_comment']) || isset($_POST['cancel_unglobalise']) || isset($_POST['draft_save']) || $save; $refresh = isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['edit_comment']) || isset($_POST['cancel_unglobalise']) || $save || $load;
if ($delete && !$preview && !$refresh && $submit) if ($delete && !$preview && !$refresh && $submit)
{ {
@ -219,13 +221,16 @@ if ($sql)
$enable_magic_url = $drafts = FALSE; $enable_magic_url = $drafts = FALSE;
// User owns some drafts? // User own some drafts?
if ($user->data['user_id'] != ANONYMOUS && $auth->acl_get('u_savedrafts')) if ($user->data['user_id'] != ANONYMOUS && $auth->acl_get('u_savedrafts'))
{ {
$sql = 'SELECT draft_id $sql = 'SELECT draft_id
FROM ' . DRAFTS_TABLE . ' FROM ' . DRAFTS_TABLE . '
WHERE user_id = ' . $user->data['user_id']; WHERE (forum_id = ' . $forum_id . (($topic_id) ? " OR topic_id = $topic_id" : '') . ')
AND user_id = ' . $user->data['user_id'] .
(($draft_id) ? " AND draft_id <> $draft_id" : '');
$result = $db->sql_query_limit($sql, 1); $result = $db->sql_query_limit($sql, 1);
if ($db->sql_fetchrow($result)) if ($db->sql_fetchrow($result))
{ {
$drafts = TRUE; $drafts = TRUE;
@ -412,55 +417,74 @@ else if ($mode == 'bump')
trigger_error('BUMP_ERROR'); trigger_error('BUMP_ERROR');
} }
// Save Draft // Save Draft
if (($save || isset($_POST['draft_save'])) && $user->data['user_id'] != ANONYMOUS && $auth->acl_get('u_savedrafts')) if ($save && $user->data['user_id'] != ANONYMOUS && $auth->acl_get('u_savedrafts'))
{ {
$draft_id = request_var('draft_id', 0); $subject = preg_replace('#&amp;(\#[0-9]+;)#', '&\1', request_var('subject', ''));
$draft_title = request_var('draft_title', ''); $subject = ($subject == '' && $mode != 'post') ? $topic_title : $subject;
$message = (isset($_POST['message'])) ? htmlspecialchars(trim(str_replace(array('\\\'', '\\"', '\\0', '\\\\'), array('\'', '"', '\0', '\\'), $_POST['message']))) : '';
$message = preg_replace('#&amp;(\#[0-9]+;)#', '&\1', $message);
if (isset($_POST['draft_title_update']) && $draft_id && $draft_title != '') if ($subject != '' && $message != '')
{ {
$sql = 'UPDATE ' . DRAFTS_TABLE . " $sql = 'INSERT INTO ' . DRAFTS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
SET title = '" . $db->sql_escape($draft_title) . "' 'user_id' => $user->data['user_id'],
WHERE draft_id = $draft_id 'topic_id' => $topic_id,
AND user_id = " . $user->data['user_id']; 'forum_id' => $forum_id,
'save_time' => $current_time,
'draft_subject' => $subject,
'draft_message' => $message));
$db->sql_query($sql); $db->sql_query($sql);
}
else
{
$subject = preg_replace('#&amp;(\#[0-9]+;)#', '&\1', request_var('subject', ''));
$message = (isset($_POST['message'])) ? htmlspecialchars(trim(str_replace(array('\\\'', '\\"', '\\0', '\\\\'), array('\'', '"', '\0', '\\'), $_POST['message']))) : '';
$message = preg_replace('#&amp;(\#[0-9]+;)#', '&\1', $message);
if ($message != '') if ($mode == 'post')
{ {
$sql = 'INSERT INTO ' . DRAFTS_TABLE . ' ' . $db->sql_build_array('INSERT', array( $meta_info = "viewforum.$phpEx$SID&amp;f=$forum_id";
'user_id' => $user->data['user_id'],
'topic_id' => $topic_id,
'save_time' => $current_time,
'title' => $subject,
'post_subject' => $subject,
'post_message' => $message));
$db->sql_query($sql);
$drafts = TRUE;
$template->assign_var('DRAFT_ID', $db->sql_nextid());
} }
else else
{ {
$save = FALSE; $meta_info = "viewtopic.$phpEx$SID&amp;f=$forum_id&amp;t=$topic_id";
} }
unset($subject); meta_refresh(3, $meta_info);
unset($message);
$message = $user->lang['DRAFT_SAVED'] . '<br /><br />';
$message .= ($mode != 'post') ? sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $meta_info . '">', '</a>') . '<br /><br />' : '';
$message .= sprintf($user->lang['RETURN_FORUM'], '<a href="viewforum.' . $phpEx . $SID . '&amp;f=' . $forum_id . '">', '</a>');
trigger_error($message);
} }
unset($draft_id); unset($subject);
unset($draft_title); unset($message);
} }
// Load Draft
if ($draft_id && $user->data['user_id'] != ANONYMOUS && $auth->acl_get('u_savedrafts'))
{
$sql = 'SELECT draft_subject, draft_message
FROM ' . DRAFTS_TABLE . "
WHERE draft_id = $draft_id
AND user_id = " . $user->data['user_id'];
$result = $db->sql_query_limit($sql, 1);
if ($row = $db->sql_fetchrow($result))
{
$_REQUEST['subject'] = $row['draft_subject'];
$_POST['message'] = $row['draft_message'];
$refresh = true;
$template->assign_var('S_DRAFT_LOADED', true);
}
else
{
$draft_id = 0;
}
}
// Load Drafts
if ($load && $drafts)
{
load_drafts($topic_id, $forum_id);
}
if ($submit || $preview || $refresh) if ($submit || $preview || $refresh)
{ {
@ -533,7 +557,7 @@ if ($submit || $preview || $refresh)
// If replying/quoting and last post id has changed // If replying/quoting and last post id has changed
// give user option to continue submit or return to post // give user option to continue submit or return to post
// notify and show user the post made between his request and the final submit // notify and show user the post made between his request and the final submit
if (($mode == 'reply' || $mode == 'quote') && $topic_cur_post_id != $topic_last_post_id) if (($mode == 'reply' || $mode == 'quote') && $topic_cur_post_id && $topic_cur_post_id != $topic_last_post_id)
{ {
if (topic_review($topic_id, $forum_id, 'post_review', $topic_cur_post_id)) if (topic_review($topic_id, $forum_id, 'post_review', $topic_cur_post_id))
{ {
@ -706,7 +730,8 @@ if ($submit || $preview || $refresh)
AND topic_moved_id = 0"; AND topic_moved_id = 0";
$db->sql_query($sql); $db->sql_query($sql);
add_log('mod', $forum_id, $topic_id, 'logm_' . (($change_topic_status == ITEM_LOCKED) ? 'lock' : 'unlock')); $user_lock = ($auth->acl_get('f_user_lock', $forum_id) && $user->data['user_id'] != ANONYMOUS && $user->data['user_id'] == $topic_poster) ? 'USER_' : '';
add_log('mod', $forum_id, $topic_id, sprintf($user->lang['LOGM_' . $user_lock . (($change_topic_status == ITEM_LOCKED) ? 'LOCK' : 'UNLOCK')], '<a href="' . generate_board_url() . "/viewtopic.$phpEx$SID&amp;f=$forum_id&amp;t=$topic_id" . '" class="gen" target="_blank">' . $topic_title . '</a>'));
} }
// Lock/Unlock Post Edit // Lock/Unlock Post Edit
@ -734,6 +759,7 @@ if ($submit || $preview || $refresh)
'enable_html' => (bool) $enable_html, 'enable_html' => (bool) $enable_html,
'enable_smilies' => (bool) $enable_smilies, 'enable_smilies' => (bool) $enable_smilies,
'enable_urls' => (bool) $enable_urls, 'enable_urls' => (bool) $enable_urls,
'enable_indexing' => (bool) $enable_indexing,
'message_md5' => (int) $message_md5, 'message_md5' => (int) $message_md5,
'post_checksum' => (int) $post_checksum, 'post_checksum' => (int) $post_checksum,
'forum_parents' => $forum_parents, 'forum_parents' => $forum_parents,
@ -744,6 +770,7 @@ if ($submit || $preview || $refresh)
'post_edit_locked' => (int) $post_edit_locked, 'post_edit_locked' => (int) $post_edit_locked,
'bbcode_bitfield' => (int) $message_parser->bbcode_bitfield 'bbcode_bitfield' => (int) $message_parser->bbcode_bitfield
); );
submit_post($mode, $message_parser->message, $subject, $username, $topic_type, $message_parser->bbcode_uid, $poll, $message_parser->attachment_data, $message_parser->filename_data, $post_data); submit_post($mode, $message_parser->message, $subject, $username, $topic_type, $message_parser->bbcode_uid, $poll, $message_parser->attachment_data, $message_parser->filename_data, $post_data);
} }
} }
@ -962,6 +989,7 @@ generate_forum_nav($forum_data);
$s_hidden_fields = ($mode == 'reply' || $mode == 'quote') ? '<input type="hidden" name="topic_cur_post_id" value="' . $topic_last_post_id . '" />' : ''; $s_hidden_fields = ($mode == 'reply' || $mode == 'quote') ? '<input type="hidden" name="topic_cur_post_id" value="' . $topic_last_post_id . '" />' : '';
$s_hidden_fields .= '<input type="hidden" name="lastclick" value="' . $current_time . '" />'; $s_hidden_fields .= '<input type="hidden" name="lastclick" value="' . $current_time . '" />';
$s_hidden_fields .= (isset($check_value)) ? '<input type="hidden" name="status_switch" value="' . $check_value . '" />' : ''; $s_hidden_fields .= (isset($check_value)) ? '<input type="hidden" name="status_switch" value="' . $check_value . '" />' : '';
$s_hidden_fields .= ($draft_id || isset($_REQUEST['draft_loaded'])) ? '<input type="hidden" name="draft_loaded" value="' . ((isset($_REQUEST['draft_loaded'])) ? intval($_REQUEST['draft_loaded']) : $draft_id) . '" />' : '';
$form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || @ini_get('file_uploads') == '0' || !$config['allow_attachments'] || !$auth->acl_gets('f_attach', 'u_attach', $forum_id)) ? '' : 'enctype="multipart/form-data"'; $form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || @ini_get('file_uploads') == '0' || !$config['allow_attachments'] || !$auth->acl_gets('f_attach', 'u_attach', $forum_id)) ? '' : 'enctype="multipart/form-data"';
@ -1017,7 +1045,6 @@ $template->assign_vars(array(
'S_TYPE_TOGGLE' => $topic_type_toggle, 'S_TYPE_TOGGLE' => $topic_type_toggle,
'S_SAVE_ALLOWED' => ($auth->acl_get('u_savedrafts') && $user->data['user_id'] != ANONYMOUS) ? TRUE : FALSE, 'S_SAVE_ALLOWED' => ($auth->acl_get('u_savedrafts') && $user->data['user_id'] != ANONYMOUS) ? TRUE : FALSE,
'S_HAS_DRAFTS' => ($auth->acl_get('u_savedrafts') && $user->data['user_id'] != ANONYMOUS && $drafts) ? TRUE : FALSE, 'S_HAS_DRAFTS' => ($auth->acl_get('u_savedrafts') && $user->data['user_id'] != ANONYMOUS && $drafts) ? TRUE : FALSE,
'S_DRAFT_SAVED' => $save,
'S_FORM_ENCTYPE' => $form_enctype, 'S_FORM_ENCTYPE' => $form_enctype,
'S_POST_ACTION' => $s_action, 'S_POST_ACTION' => $s_action,
@ -1923,6 +1950,7 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
// Submit Attachments // Submit Attachments
if (count($attach_data) && !empty($data['post_id']) && in_array($mode, array('post', 'reply', 'quote', 'edit'))) if (count($attach_data) && !empty($data['post_id']) && in_array($mode, array('post', 'reply', 'quote', 'edit')))
{ {
$space_taken = $files_added = 0;
foreach ($attach_data as $attach_row) foreach ($attach_data as $attach_row)
{ {
if ($attach_row['attach_id']) if ($attach_row['attach_id'])
@ -1953,6 +1981,9 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
$sql = 'INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . $sql = 'INSERT INTO ' . ATTACHMENTS_TABLE . ' ' .
$db->sql_build_array('INSERT', $attach_sql); $db->sql_build_array('INSERT', $attach_sql);
$db->sql_query($sql); $db->sql_query($sql);
$space_taken += $attach_row['filesize'];
$files_added++;
} }
} }
@ -1969,6 +2000,8 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
$db->sql_query($sql); $db->sql_query($sql);
} }
set_config('upload_dir_size', $config['upload_dir_size'] + $space_taken, TRUE);
set_config('num_files', $config['num_files'] + $files_added, TRUE);
} }
$db->sql_transaction('commit'); $db->sql_transaction('commit');
@ -2004,10 +2037,10 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
$sql_data['topic']['stat'] = implode(', ', update_last_post_information('topic', $data['topic_id'])); $sql_data['topic']['stat'] = implode(', ', update_last_post_information('topic', $data['topic_id']));
} }
// Update total post count, even if the topic/post has to be approved // Update total post count, do not consider moderated posts/topics
// Mental Note: adjust Resync Stats in admin index if you delete this comments. // Mental Note: adjust Resync Stats in admin index if you delete these comments.
// if (!$auth->acl_get('f_moderate', $data['forum_id'])) if (!$auth->acl_get('f_moderate', $data['forum_id']))
// { {
if ($post_mode == 'post') if ($post_mode == 'post')
{ {
set_config('num_topics', $config['num_topics'] + 1, TRUE); set_config('num_topics', $config['num_topics'] + 1, TRUE);
@ -2018,7 +2051,7 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
{ {
set_config('num_posts', $config['num_posts'] + 1, TRUE); set_config('num_posts', $config['num_posts'] + 1, TRUE);
} }
// } }
// Update forum stats // Update forum stats
$db->sql_transaction(); $db->sql_transaction();
@ -2052,15 +2085,21 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
} }
// Fulltext parse // Fulltext parse
if ($data['message_md5'] != $data['post_checksum'] && $enable_indexing) if ($data['message_md5'] != $data['post_checksum'] && $data['enable_indexing'])
{ {
echo "HERE";
$search = new fulltext_search(); $search = new fulltext_search();
$result = $search->add($mode, $data['post_id'], $message, $subject); $result = $search->add($mode, $data['post_id'], $message, $subject);
} }
$db->sql_transaction('commit'); $db->sql_transaction('commit');
// Delete draft if post was loaded...
$draft_id = request_var('draft_loaded', 0);
if ($draft_id)
{
$db->sql_query('DELETE FROM ' . DRAFTS_TABLE . " WHERE draft_id = $draft_id AND user_id = " . $user->data['user_id']);
}
// Topic Notification // Topic Notification
if (!$data['notify_set'] && $data['notify']) if (!$data['notify_set'] && $data['notify'])
{ {
@ -2093,6 +2132,90 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
trigger_error($message); trigger_error($message);
} }
// Load Drafts
function load_drafts($topic_id = 0, $forum_id = 0)
{
global $user, $db, $template, $phpEx, $SID, $auth;
// Only those fitting into this forum...
$sql = 'SELECT d.draft_id, d.topic_id, d.forum_id, d.draft_subject, d.save_time, f.forum_name
FROM ' . DRAFTS_TABLE . ' d, ' . FORUMS_TABLE . ' f
WHERE d.user_id = ' . $user->data['user_id'] . '
AND f.forum_id = d.forum_id ' .
(($forum_id) ? " AND f.forum_id = $forum_id" : '') . '
ORDER BY save_time DESC';
$result = $db->sql_query($sql);
$draftrows = $topic_ids = array();
while ($row = $db->sql_fetchrow($result))
{
if ($row['topic_id'])
{
$topic_ids[] = (int) $row['topic_id'];
}
$draftrows[] = $row;
}
$db->sql_freeresult($result);
if (sizeof($topic_ids))
{
$sql = 'SELECT topic_id, forum_id, topic_title
FROM ' . TOPICS_TABLE . '
WHERE topic_id IN (' . implode(',', array_unique($topic_ids)) . ')';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$topic_rows[$row['topic_id']] = $row;
}
$db->sql_freeresult($result);
}
unset($topic_ids);
if (sizeof($draftrows))
{
$row_count = 0;
$template->assign_var('S_SHOW_DRAFTS', true);
foreach ($draftrows as $draft)
{
$link_topic = $link_forum = 0;
$insert_url = $view_url = $title = '';
if (isset($topic_rows[$draft['topic_id']]) && $auth->acl_get('f_read', $topic_rows[$draft['topic_id']]['forum_id']))
{
$link_topic = true;
$view_url = "viewtopic.$phpEx$SID&amp;f=" . $topic_rows[$draft['topic_id']]['forum_id'] . "&amp;t=" . $draft['topic_id'];
$title = ($draft['topic_id'] == $topic_id && $topic_id) ? $user->lang['CURRENT_TOPIC'] : $topic_rows[$draft['topic_id']]['topic_title'];
$insert_url = "posting.$phpEx$SID&amp;f=" . $topic_rows[$draft['topic_id']]['forum_id'] . '&amp;t=' . $draft['topic_id'] . '&amp;mode=reply&amp;d=' . $draft['draft_id'];
}
else if ($auth->acl_get('f_read', $draft['forum_id']))
{
$link_forum = true;
$view_url = "viewforum.$phpEx$SID&amp;f=" . $draft['forum_id'];
$title = $draft['forum_name'];
$insert_url = "posting.$phpEx$SID&amp;f=" . $draft['forum_id'] . '&amp;mode=post&amp;d=' . $draft['draft_id'];
}
$template->assign_block_vars('draftrow', array(
'DRAFT_ID' => $draft['draft_id'],
'DATE' => $user->format_date($draft['save_time']),
'DRAFT_SUBJECT' => $draft['draft_subject'],
'TITLE' => $title,
'U_VIEW' => $view_url,
'U_INSERT' => $insert_url,
'S_ROW_COUNT' => $row_count++,
'S_LINK_TOPIC' => $link_topic,
'S_LINK_FORUM' => $link_forum)
);
}
}
}
function prepare_data(&$variable, $change = FALSE) function prepare_data(&$variable, $change = FALSE)
{ {

View file

@ -54,24 +54,44 @@ function checkForm()
</tr> </tr>
</table> </table>
<!-- IF S_DRAFT_SAVED --> <!-- IF S_DRAFT_LOADED -->
<table class="tablebg" width="95%" border="0" cellspacing="1" cellpadding="4" align="center"> <table class="tablebg" width="95%" border="0" cellspacing="1" cellpadding="4" align="center">
<tr> <tr>
<th height="28" align="center">{L_INFORMATION}</th> <th height="28" align="center">{L_INFORMATION}</th>
</tr> </tr>
<tr> <tr>
<td class="row1" align="center"><span class="gen">{L_DRAFT_SAVED}</span></td> <td class="row1" align="center"><span class="gen">{L_DRAFT_LOADED}</span></td>
</tr>
</table>
<br />
<!-- ENDIF -->
<!-- IF S_SHOW_DRAFTS -->
<table class="tablebg" width="95%" border="0" cellspacing="1" cellpadding="4" align="center">
<tr>
<th colspan="3" height="28" align="center">{L_LOAD_DRAFT}</th>
</tr>
<tr class="row1">
<td colspan="3" class="gen" align="center">{L_LOAD_DRAFT_EXPLAIN}</td>
</tr> </tr>
<tr> <tr>
<td class="spacer" height="1"><img src="images/spacer.gif" alt="" width="1" height="1" /></td> <th>{L_SAVE_DATE}</th>
</tr> <th>{L_DRAFT_TITLE}</th>
<tr> <th>{L_OPTIONS}</th>
<td class="row2" align="center"><span class="gen">{L_DRAFT_TITLE_EXPLAIN}<br /><br />{L_ENTER_DRAFT_TITLE}&nbsp;&nbsp;</span><input class="post" style="width:450px" type="text" name="draft_title" size="45" maxlength="60" tabindex="2" value="{SUBJECT}" /><br /><br />
<input class="btnmain" type="submit" name="draft_save" value="{L_UPDATE}" />
<input type="hidden" name="draft_title_update" value="1" />
<input type="hidden" name="draft_id" value="{DRAFT_ID}" />
</td>
</tr> </tr>
<!-- BEGIN draftrow -->
<!-- IF draftrow.S_ROW_COUNT is even -->
<tr class="row1">
<!-- ELSE -->
<tr class="row2">
<!-- ENDIF -->
<td class="postdetails">{draftrow.DATE}</td>
<td><b class="gen">{draftrow.DRAFT_SUBJECT}</b><!-- IF draftrow.S_LINK_TOPIC --><br /><span class="gensmall">{L_TOPIC}: <a href="{draftrow.U_VIEW}">{draftrow.TITLE}</a></span><!-- ELSEIF draftrow.S_LINK_FORUM --><br /><span class="gensmall">{L_FORUM}: <a href="{draftrow.U_VIEW}">{draftrow.TITLE}</a></span><!-- ELSE --><br /><span class="gensmall">{L_NO_TOPIC_FORUM}</span><!-- ENDIF --></td>
<td align="center"><span class="gen"><a href="{draftrow.U_INSERT}">{L_LOAD_DRAFT}</a></td>
</tr>
<!-- END draftrow -->
</table> </table>
<br /> <br />
<!-- ENDIF --> <!-- ENDIF -->
@ -366,7 +386,7 @@ function checkForm()
<!-- ENDIF --> <!-- ENDIF -->
<!-- IF S_SHOW_ATTACH_BOX or S_SHOW_POLL_BOX --> <!-- IF S_SHOW_ATTACH_BOX or S_SHOW_POLL_BOX -->
<tr> <tr>
<td class="cat" colspan="2" align="center"><input class="btnlite" type="submit" tabindex="5" name="preview" value="{L_PREVIEW}" />&nbsp; <input class="btnmain" type="submit" accesskey="s" tabindex="6" name="post" value="{L_SUBMIT}" /><!-- IF S_SAVE_ALLOWED -->&nbsp; <input class="btnlite" type="submit" accesskey="k" tabindex="8" name="save" value="{L_SAVE}" /><!-- ENDIF --><!-- IF S_HAS_DRAFTS -->&nbsp; <input class="btnlite" type="submit" accesskey="d" tabindex="9" name="load_draft" value="{L_LOAD}" /><!-- ENDIF -->&nbsp; <input class="btnlite" type="submit" accesskey="c" tabindex="7" name="cancel" value="{L_CANCEL}" /></td> <td class="cat" colspan="2" align="center"><input class="btnlite" type="submit" tabindex="5" name="preview" value="{L_PREVIEW}" />&nbsp; <input class="btnmain" type="submit" accesskey="s" tabindex="6" name="post" value="{L_SUBMIT}" /><!-- IF S_SAVE_ALLOWED -->&nbsp; <input class="btnlite" type="submit" accesskey="k" tabindex="8" name="save" value="{L_SAVE}" /><!-- ENDIF --><!-- IF S_HAS_DRAFTS -->&nbsp; <input class="btnlite" type="submit" accesskey="d" tabindex="9" name="load" value="{L_LOAD}" /><!-- ENDIF -->&nbsp; <input class="btnlite" type="submit" accesskey="c" tabindex="7" name="cancel" value="{L_CANCEL}" /></td>
</tr> </tr>
<!-- ENDIF --> <!-- ENDIF -->
<!-- IF S_SHOW_ATTACH_BOX --> <!-- IF S_SHOW_ATTACH_BOX -->
@ -381,7 +401,7 @@ function checkForm()
</tr> </tr>
<!-- ENDIF --> <!-- ENDIF -->
<tr> <tr>
<td class="cat" colspan="2" align="center">{S_HIDDEN_FIELDS}<input class="btnlite" type="submit" tabindex="5" name="preview" value="{L_PREVIEW}" />&nbsp; <input class="btnmain" type="submit" accesskey="s" tabindex="6" name="post" value="{L_SUBMIT}" /><!-- IF S_SAVE_ALLOWED -->&nbsp; <input class="btnlite" type="submit" accesskey="k" tabindex="8" name="save" value="{L_SAVE}" /><!-- ENDIF --><!-- IF S_HAS_DRAFTS -->&nbsp; <input class="btnlite" type="submit" accesskey="d" tabindex="9" name="load_draft" value="{L_LOAD}" /><!-- ENDIF -->&nbsp; <input class="btnlite" type="submit" accesskey="c" tabindex="7" name="cancel" value="{L_CANCEL}" /></td> <td class="cat" colspan="2" align="center">{S_HIDDEN_FIELDS}<input class="btnlite" type="submit" tabindex="5" name="preview" value="{L_PREVIEW}" />&nbsp; <input class="btnmain" type="submit" accesskey="s" tabindex="6" name="post" value="{L_SUBMIT}" /><!-- IF S_SAVE_ALLOWED -->&nbsp; <input class="btnlite" type="submit" accesskey="k" tabindex="8" name="save" value="{L_SAVE}" /><!-- ENDIF --><!-- IF S_HAS_DRAFTS -->&nbsp; <input class="btnlite" type="submit" accesskey="d" tabindex="9" name="load" value="{L_LOAD}" /><!-- ENDIF -->&nbsp; <input class="btnlite" type="submit" accesskey="c" tabindex="7" name="cancel" value="{L_CANCEL}" /></td>
</tr> </tr>
</table> </table>

View file

@ -1,15 +1,17 @@
<!-- $Id$ -->
<!-- INCLUDE ucp_header.html --> <!-- INCLUDE ucp_header.html -->
<table class="tablebg" width="80%" cellspacing="1" cellpadding="4" border="0" align="right"> <table class="tablebg" width="80%" cellspacing="1" cellpadding="4" border="0" align="right">
<tr> <tr>
<th colspan="5" height="28">{L_UCP}</th> <th colspan="4" height="28">{L_UCP}</th>
</tr> </tr>
<tr> <tr class="row1">
<td colspan="5" class="row3" align="center"><span class="gensmall">{L_DRAFTS_EXPLAIN}</span></td> <td colspan="4" align="center" class="genmed">{L_DRAFTS_EXPLAIN}</td>
</tr> </tr>
<!-- IF ERROR --> <!-- IF ERROR -->
<tr> <tr class="row1">
<td class="row3" colspan="2" align="center"><span class="gensmall" style="color:red">{ERROR}</span></td> <td colspan="2" align="center" class="genmed"><span style="color:red">{ERROR}</span></td>
</tr> </tr>
<!-- ENDIF --> <!-- ENDIF -->
@ -19,7 +21,6 @@
<tr> <tr>
<th>{L_SAVE_DATE}</th> <th>{L_SAVE_DATE}</th>
<th>{L_DRAFT_TITLE}</th> <th>{L_DRAFT_TITLE}</th>
<th>{L_TOPIC}</th>
<th>{L_OPTIONS}</th> <th>{L_OPTIONS}</th>
<th>{L_DELETE}</th> <th>{L_DELETE}</th>
</tr> </tr>
@ -34,29 +35,24 @@
<!-- ENDIF --> <!-- ENDIF -->
<td class="postdetails">{draftrow.DATE}</td> <td class="postdetails">{draftrow.DATE}</td>
<td><b class="topictitle">{draftrow.TITLE}</b></td> <td><b class="gen">{draftrow.DRAFT_SUBJECT}</b><!-- IF draftrow.S_LINK_TOPIC --><br /><span class="gensmall">{L_TOPIC}: <a href="{draftrow.U_VIEW}">{draftrow.TITLE}</a></span><!-- ELSEIF draftrow.S_LINK_FORUM --><br /><span class="gensmall">{L_FORUM}: <a href="{draftrow.U_VIEW}">{draftrow.TITLE}</a></span><!-- ELSE --><br /><span class="gensmall">{L_NO_TOPIC_FORUM}</span><!-- ENDIF --></td>
<td class="topictitle"><!-- IF draftrow.S_POST_TOPIC -->{L_CURRENT_TOPIC}<!-- ELSEIF draftrow.TOPIC_TITLE --><a href="{draftrow.U_VIEW_TOPIC}" target="_blank">{draftrow.TOPIC_TITLE}</a><!-- ELSE --><i>{L_NEW_OR_DELETED_TOPIC}</i><!-- ENDIF --></td> <td align="center"><span class="gen"><!-- IF draftrow.U_INSERT --><a href="{draftrow.U_INSERT}">{L_LOAD_DRAFT}</a><br /><!-- ENDIF --><a href="{draftrow.U_VIEW_EDIT}">{L_VIEW_EDIT}</a></td>
<td align="center"><span class="gen"><!-- IF draftrow.S_FROM_POST --><a href="">{L_INSERT}</a><br /><!-- ENDIF --><a href="{draftrow.U_VIEW_EDIT}">{L_VIEW_EDIT}</a></td>
<td align="center"><input type="checkbox" name="d[{draftrow.DRAFT_ID}]" /></td> <td align="center"><input type="checkbox" name="d[{draftrow.DRAFT_ID}]" /></td>
</tr> </tr>
<!-- BEGINELSE --> <!-- BEGINELSE -->
<tr class="row1"> <tr class="row1">
<td colspan="5" height="25" align="center"><b class="genmed">{L_NO_SAVED_DRAFTS}</b></td> <td colspan="4" height="25" align="center"><b class="genmed">{L_NO_SAVED_DRAFTS}</b></td>
</tr> </tr>
<!-- END draftrow --> <!-- END draftrow -->
<tr> <tr>
<td class="cat" colspan="5" height="28" align="right"><input class="btnlite" type="submit" name="delete" value="{L_DELETE_MARKED}" />&nbsp;</td> <td class="cat" colspan="4" height="28" align="right"><input class="btnlite" type="submit" name="delete" value="{L_DELETE_MARKED}" />&nbsp;</td>
</tr> </tr>
<!-- ELSEIF S_EDIT_DRAFT --> <!-- ELSEIF S_EDIT_DRAFT -->
<tr>
<td class="row1" width="22%"><b class="genmed">{L_DRAFT_TITLE}:</b></td>
<td class="row2" width="78%"><input class="post" style="width:450px" type="text" name="draft_title" size="45" maxlength="60" tabindex="1" value="{DRAFT_TITLE}" /></td>
</tr>
<tr> <tr>
<td class="row1" width="22%"><b class="genmed">{L_SUBJECT}:</b></td> <td class="row1" width="22%"><b class="genmed">{L_SUBJECT}:</b></td>
<td class="row2"><input class="post" style="width:450px" type="text" name="subject" size="45" maxlength="60" tabindex="2" value="{POST_SUBJECT}" /></td> <td class="row2"><input class="post" style="width:450px" type="text" name="subject" size="45" maxlength="60" tabindex="2" value="{DRAFT_SUBJECT}" /></td>
</tr> </tr>
<tr> <tr>
<td class="row1" width="22%"><b class="genmed">{L_MESSAGE}: </b><br /><span class="gensmall">{L_EDIT_DRAFT_EXPLAIN}</span></td> <td class="row1" width="22%"><b class="genmed">{L_MESSAGE}: </b><br /><span class="gensmall">{L_EDIT_DRAFT_EXPLAIN}</span></td>
@ -90,11 +86,11 @@
<td colspan="9"><input class="helpline" type="text" name="helpbox" size="45" maxlength="100" value="{L_STYLES_TIP}" /></td> <td colspan="9"><input class="helpline" type="text" name="helpbox" size="45" maxlength="100" value="{L_STYLES_TIP}" /></td>
</tr> </tr>
<tr> <tr>
<td colspan="9"><textarea class="post" name="message" rows="10" cols="76" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);">{POST_MESSAGE}</textarea></td> <td colspan="9"><textarea class="post" name="message" rows="10" cols="76" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);">{DRAFT_MESSAGE}</textarea></td>
</tr> </tr>
</table></td> </table></td>
</tr> </tr>
<tr class="row3"> <tr class="row1">
<td colspan="9" align="left" class="topictitle"><a href="{S_UCP_ACTION}">{L_BACK_TO_DRAFTS}</a></td> <td colspan="9" align="left" class="topictitle"><a href="{S_UCP_ACTION}">{L_BACK_TO_DRAFTS}</a></td>
</tr> </tr>
<tr> <tr>