phpBB

Code Changes

File: includes/acp/acp_attachments.php

  Unmodified   Added   Modified   Removed
Line 190Line 190
				validate_config_vars($display_vars['vars'], $cfg_array, $error);

// Do not write values if there is an error

				validate_config_vars($display_vars['vars'], $cfg_array, $error);

// Do not write values if there is an error

				if (sizeof($error))

				if (count($error))

				{
$submit = false;
}

				{
$submit = false;
}

Line 226Line 226
					// Check Settings
$this->test_upload($error, $this->new_config['upload_path'], false);


					// Check Settings
$this->test_upload($error, $this->new_config['upload_path'], false);


					if (!sizeof($error))

					if (!count($error))

					{
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
}

					{
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
}

Line 256Line 256
				$supported_types = get_supported_image_types();

// Check Thumbnail Support

				$supported_types = get_supported_image_types();

// Check Thumbnail Support

				if (!$this->new_config['img_imagick'] && (!isset($supported_types['format']) || !sizeof($supported_types['format'])))

				if (!$this->new_config['img_imagick'] && (!isset($supported_types['format']) || !count($supported_types['format'])))

				{
$this->new_config['img_create_thumbnail'] = 0;
}

$template->assign_vars(array(
'U_SEARCH_IMAGICK' => $this->u_action . '&action=imgmagick',

				{
$this->new_config['img_create_thumbnail'] = 0;
}

$template->assign_vars(array(
'U_SEARCH_IMAGICK' => $this->u_action . '&action=imgmagick',

					'S_THUMBNAIL_SUPPORT'	=> (!$this->new_config['img_imagick'] && (!isset($supported_types['format']) || !sizeof($supported_types['format']))) ? false : true)

					'S_THUMBNAIL_SUPPORT'	=> (!$this->new_config['img_imagick'] && (!isset($supported_types['format']) || !count($supported_types['format']))) ? false : true)

				);

// Secure Download Options - Same procedure as with banning

				);

// Secure Download Options - Same procedure as with banning

Line 290Line 290
				$template->assign_vars(array(
'S_SECURE_DOWNLOADS' => $this->new_config['secure_downloads'],
'S_DEFINED_IPS' => ($defined_ips != '') ? true : false,

				$template->assign_vars(array(
'S_SECURE_DOWNLOADS' => $this->new_config['secure_downloads'],
'S_DEFINED_IPS' => ($defined_ips != '') ? true : false,

					'S_WARNING'				=> (sizeof($error)) ? true : false,

					'S_WARNING'				=> (count($error)) ? true : false,


'WARNING_MSG' => implode('<br />', $error),
'DEFINED_IPS' => $defined_ips,


'WARNING_MSG' => implode('<br />', $error),
'DEFINED_IPS' => $defined_ips,

Line 363Line 363
						// Generate correct Change List
$extensions = array();


						// Generate correct Change List
$extensions = array();


						for ($i = 0, $size = sizeof($extension_change_list); $i < $size; $i++)

						for ($i = 0, $size = count($extension_change_list); $i < $size; $i++)

						{
$extensions[$extension_change_list[$i]]['group_id'] = $group_select_list[$i];
}

						{
$extensions[$extension_change_list[$i]]['group_id'] = $group_select_list[$i];
}

Line 390Line 390
						// Delete Extension?
$extension_id_list = $request->variable('extension_id_list', array(0));


						// Delete Extension?
$extension_id_list = $request->variable('extension_id_list', array(0));


						if (sizeof($extension_id_list))

						if (count($extension_id_list))

						{
$sql = 'SELECT extension
FROM ' . EXTENSIONS_TABLE . '

						{
$sql = 'SELECT extension
FROM ' . EXTENSIONS_TABLE . '

Line 420Line 420

if ($add_extension && $add)
{


if ($add_extension && $add)
{

						if (!sizeof($error))

						if (!count($error))

						{
$sql = 'SELECT extension_id
FROM ' . EXTENSIONS_TABLE . "

						{
$sql = 'SELECT extension_id
FROM ' . EXTENSIONS_TABLE . "

Line 433Line 433
							}
$db->sql_freeresult($result);


							}
$db->sql_freeresult($result);


							if (!sizeof($error))

							if (!count($error))

							{
$sql_ary = array(
'group_id' => $add_extension_group,

							{
$sql_ary = array(
'group_id' => $add_extension_group,

Line 447Line 447
						}
}


						}
}


					if (!sizeof($error))

					if (!count($error))

					{
$notify[] = $user->lang['EXTENSIONS_UPDATED'];
}

					{
$notify[] = $user->lang['EXTENSIONS_UPDATED'];
}

Line 558Line 558
						$db->sql_freeresult($result);
}


						$db->sql_freeresult($result);
}


					if (!sizeof($error))

					if (!count($error))

					{
// Ok, build the update/insert array
$upload_icon = $request->variable('upload_icon', 'no_image');

					{
// Ok, build the update/insert array
$upload_icon = $request->variable('upload_icon', 'no_image');

Line 575Line 575
							$max_filesize = 0;
}


							$max_filesize = 0;
}


						if (!sizeof($allowed_forums))

						if (!count($allowed_forums))

						{
$forum_select = false;
}

						{
$forum_select = false;
}

Line 612Line 612

$extension_list = $request->variable('extensions', array(0));



$extension_list = $request->variable('extensions', array(0));


					if ($action == 'edit' && sizeof($extension_list))

					if ($action == 'edit' && count($extension_list))

					{
$sql = 'UPDATE ' . EXTENSIONS_TABLE . "
SET group_id = 0

					{
$sql = 'UPDATE ' . EXTENSIONS_TABLE . "
SET group_id = 0

Line 620Line 620
						$db->sql_query($sql);
}


						$db->sql_query($sql);
}


					if (sizeof($extension_list))

					if (count($extension_list))

					{
$sql = 'UPDATE ' . EXTENSIONS_TABLE . "
SET group_id = $group_id

					{
$sql = 'UPDATE ' . EXTENSIONS_TABLE . "
SET group_id = $group_id

Line 630Line 630

$cache->destroy('_extensions');



$cache->destroy('_extensions');


					if (!sizeof($error))

					if (!count($error))

					{
$notify[] = $user->lang['SUCCESS_EXTENSION_GROUP_' . strtoupper($action)];
}

					{
$notify[] = $user->lang['SUCCESS_EXTENSION_GROUP_' . strtoupper($action)];
}

Line 806Line 806
							'S_FILENAME_LIST'			=> $filename_list,
'S_EDIT_GROUP' => true,
'S_NO_IMAGE' => $no_image_select,

							'S_FILENAME_LIST'			=> $filename_list,
'S_EDIT_GROUP' => true,
'S_NO_IMAGE' => $no_image_select,

							'S_FORUM_IDS'				=> (sizeof($forum_ids)) ? true : false,

							'S_FORUM_IDS'				=> (count($forum_ids)) ? true : false,


'U_EXTENSIONS' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=$id&amp;mode=extensions"),
'U_BACK' => $this->u_action,


'U_EXTENSIONS' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=$id&amp;mode=extensions"),
'U_BACK' => $this->u_action,

Line 921Line 921
			break;

case 'orphan':

			break;

case 'orphan':

 

/* @var $pagination \phpbb\pagination */
$pagination = $this->phpbb_container->get('pagination');


if ($submit)
{


if ($submit)
{

Line 928Line 931
					$add_files = (isset($_POST['add'])) ? array_keys($request->variable('add', array('' => 0))) : array();
$post_ids = $request->variable('post_id', array('' => 0));


					$add_files = (isset($_POST['add'])) ? array_keys($request->variable('add', array('' => 0))) : array();
$post_ids = $request->variable('post_id', array('' => 0));


					if (sizeof($delete_files))

					if (count($delete_files))

					{
$sql = 'SELECT *
FROM ' . ATTACHMENTS_TABLE . '

					{
$sql = 'SELECT *
FROM ' . ATTACHMENTS_TABLE . '

Line 951Line 954
						$db->sql_freeresult($result);
}


						$db->sql_freeresult($result);
}


					if (sizeof($delete_files))

					if (count($delete_files))

					{
$sql = 'DELETE FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . $db->sql_in_set('attach_id', array_keys($delete_files));

					{
$sql = 'DELETE FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . $db->sql_in_set('attach_id', array_keys($delete_files));

Line 971Line 974
					}
unset($add_files);


					}
unset($add_files);


					if (sizeof($upload_list))

					if (count($upload_list))

					{
$template->assign_var('S_UPLOADING_FILES', true);


					{
$template->assign_var('S_UPLOADING_FILES', true);


Line 1063Line 1066
				$template->assign_vars(array(
'S_ORPHAN' => true)
);

				$template->assign_vars(array(
'S_ORPHAN' => true)
);

 

$attachments_per_page = (int) $config['topics_per_page'];

// Get total number or orphans older than 3 hours
$sql = 'SELECT COUNT(attach_id) as num_files, SUM(filesize) as total_size
FROM ' . ATTACHMENTS_TABLE . '
WHERE is_orphan = 1
AND filetime < ' . (time() - 3*60*60);
$result = $this->db->sql_query($sql);
$row = $this->db->sql_fetchrow($result);
$num_files = (int) $row['num_files'];
$total_size = (int) $row['total_size'];
$this->db->sql_freeresult($result);

$start = $request->variable('start', 0);
$start = $pagination->validate_start($start, $attachments_per_page, $num_files);


// Just get the files with is_orphan set and older than 3 hours
$sql = 'SELECT *


// Just get the files with is_orphan set and older than 3 hours
$sql = 'SELECT *

Line 1070Line 1089
					WHERE is_orphan = 1
AND filetime < ' . (time() - 3*60*60) . '
ORDER BY filetime DESC';

					WHERE is_orphan = 1
AND filetime < ' . (time() - 3*60*60) . '
ORDER BY filetime DESC';

				$result = $db->sql_query($sql);

				$result = $db->sql_query_limit($sql, $attachments_per_page, $start);


while ($row = $db->sql_fetchrow($result))
{


while ($row = $db->sql_fetchrow($result))
{

Line 1085Line 1104
					);
}
$db->sql_freeresult($result);

					);
}
$db->sql_freeresult($result);

 

$pagination->generate_template_pagination(
$this->u_action,
'pagination',
'start',
$num_files,
$attachments_per_page,
$start
);

$template->assign_vars(array(
'TOTAL_FILES' => $num_files,
'TOTAL_SIZE' => get_formatted_filesize($total_size),
));


break;



break;


Line 1094Line 1127
				{
$delete_files = (isset($_POST['delete'])) ? array_keys($request->variable('delete', array('' => 0))) : array();


				{
$delete_files = (isset($_POST['delete'])) ? array_keys($request->variable('delete', array('' => 0))) : array();


					if (sizeof($delete_files))

					if (count($delete_files))

					{
// Select those attachments we want to delete...
$sql = 'SELECT real_filename

					{
// Select those attachments we want to delete...
$sql = 'SELECT real_filename

Line 1110Line 1143

if ($num_deleted = $this->attachment_manager->delete('attach', $delete_files))
{


if ($num_deleted = $this->attachment_manager->delete('attach', $delete_files))
{

							if (sizeof($delete_files) != $num_deleted)

							if (count($delete_files) != $num_deleted)

							{
$error[] = $user->lang['FILES_GONE'];
}

							{
$error[] = $user->lang['FILES_GONE'];
}

Line 1231Line 1264
				// Grab extensions
$extensions = $cache->obtain_attach_extensions(true);


				// Grab extensions
$extensions = $cache->obtain_attach_extensions(true);


				for ($i = 0, $end = sizeof($attachments_list); $i < $end; ++$i)

				for ($i = 0, $end = count($attachments_list); $i < $end; ++$i)

				{
$row = $attachments_list[$i];


				{
$row = $attachments_list[$i];


Line 1266Line 1299
			break;
}


			break;
}


		if (sizeof($error))

		if (count($error))

		{
$template->assign_vars(array(
'S_WARNING' => true,

		{
$template->assign_vars(array(
'S_WARNING' => true,

Line 1274Line 1307
			);
}


			);
}


		if (sizeof($notify))

		if (count($notify))

		{
$template->assign_vars(array(
'S_NOTIFY' => true,

		{
$template->assign_vars(array(
'S_NOTIFY' => true,

Line 1443Line 1476
		$row['group_name'] = $user->lang['NOT_ASSIGNED'];
$group_name[] = $row;


		$row['group_name'] = $user->lang['NOT_ASSIGNED'];
$group_name[] = $row;


		for ($i = 0, $groups_size = sizeof($group_name); $i < $groups_size; $i++)

		for ($i = 0, $groups_size = count($group_name); $i < $groups_size; $i++)

		{
if ($default_group === false)
{

		{
if ($default_group === false)
{

Line 1676Line 1709
			}
$db->sql_freeresult($result);


			}
$db->sql_freeresult($result);


			if (sizeof($iplist))

			if (count($iplist))

			{
foreach ($iplist as $ip_entry)
{

			{
foreach ($iplist as $ip_entry)
{

Line 1686Line 1719
				}
}


				}
}


			if (sizeof($hostlist))

			if (count($hostlist))

			{
foreach ($hostlist as $host_entry)
{

			{
foreach ($hostlist as $host_entry)
{

Line 1709Line 1742
		{
$unip_sql = $request->variable('unip', array(0));


		{
$unip_sql = $request->variable('unip', array(0));


			if (sizeof($unip_sql))

			if (count($unip_sql))

			{
$l_unip_list = '';


			{
$l_unip_list = '';