Help

Since Opentools.de has now gone away I've created this forum to house FAQs and support for this mod in phpBB2.

Moderator: Experts

Locked
vikul
Posts: 4
Joined: Mon Oct 30, 2006 1:25 am
Contact:

Help

Post by vikul »

Hi David and BRF,
I really need ur help man .. I have installed the latest version of this mod. I am getting some strange errors . On debugging i found some issues , need ur comments on these . In posting_attachments ...

________________________________________
// Get those attach_ids allowed for lists from the attachments table...
$allowed_attach_ids = array();
if ($post_id)
{
$sql = 'SELECT attach_id
FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . $sql_id . ' = ' . $post_id;
$result = $db->sql_query($sql);

if (!$result)
{
message_die(GENERAL_ERROR, 'Unable to get attachment information.', '', __LINE__, __FILE__, $sql);
}

while ($_row = $db->sql_fetchrow($result))
{
$allowed_attach_ids[] = $_row['attach_id'];
}
$db->sql_freeresult($result);
}

// Check the submitted variables - do not allow wrong values
$actual_id_list = get_var('attach_id_list', array(0));
$actual_list = get_var('attachment_list', array(''));

for ($i = 0; $i < sizeof($actual_list); $i++)
{
if ($actual_id_list[$i] != 0)
{
if (!in_array($actual_id_list[$i], $allowed_attach_ids))
{
message_die(CRITICAL_ERROR, 'You tried to change an attachment you do not have access to', '');
}
}
else
{
// Really new attachment? If so, the filename should be unique...
if (physical_filename_already_stored($actual_list[$i]))
{
message_die(CRITICAL_ERROR, 'You tried to change an attachment you do not have access to', '');
}
}
}




----------------------------

$actual_id_list = get_var('attach_id_list', array(0));
this returns a multidimensional array ... which I belive is not expected here .. all thru the code a one dimensional array is expected by the code.

Reasons why I suspect this :

I upload an attachment --> Success
I go back to the topic and try editing the post ( same user ) and upload a new attachment or delete an existing one , I get a critical error .
(CRITICAL_ERROR, 'You tried to change an attachment you do not have access to',
. On debugging I found that this check was failing

if (!in_array($actual_id_list[$i], $allowed_attach_ids))

If i change this code to
for ($j = 0; $j < sizeof($actual_id_list[$i]); $i++)
if (!in_array($actual_id_list[$i][$j], $allowed_attach_ids)) ..

it works

But this is not the end it starts failing at the next place where a single dimensional array was assumed.

I am not an expert so was wondering if there is some misunderstanding on my part ... I have revisited all the changes that need to be done and can confirm that all have been done as per the install instructions.

One Place where i suspect the issue to be is the attach_mod/includes/function_attach -> get_var function .
I know that this mod has been there for so long and such an error would have been long caught. But I am getting these errors which no one else seem to be getting .. Any help from u guys will be highly appreciated.
Last edited by vikul on Mon Oct 30, 2006 2:48 pm, edited 2 times in total.
vikul
Posts: 4
Joined: Mon Oct 30, 2006 1:25 am
Contact:

Post by vikul »

I tried the upload and delete on ur website and it works like a charm .. So probably it is some mistake on my end only ... Are u using the latest version..


BTW : Don't know if it makes a difference . I am using these mods:

1) LDAP auth mod.
2) Form to post mod.

The website is an internal one with a private IP so can't give u the access but can send u any file/detail u require.

Thanks again for looking.
DavidIQ
Site Admin
Posts: 619
Joined: Thu Sep 07, 2006 4:31 pm
Location: Earth
Contact:

Post by DavidIQ »

What's "Form to post mod"?

Reason I had asked about your php and mysql versions was to maybe start poking through your server configuration. But this might be a bad edit. Post in txt format your posting.php file (save as posting.txt and attach).
vikul
Posts: 4
Joined: Mon Oct 30, 2006 1:25 am
Contact:

Post by vikul »

Form to Post allows me to create a form which the users fillup and that creates a post in a dynamically selected forum. I use this to make sure that the posts that are created in the forum are as per a pre-defined format. Lemme know if u want to know more . I have worked a lot on the original MOD and modified it to a more useful version.

Please find attached the posting.txt as requested.
Attachments
posting.txt
(36 KiB) Downloaded 398 times
vikul
Posts: 4
Joined: Mon Oct 30, 2006 1:25 am
Contact:

Finally got the solution

Post by vikul »

I finally managed to make it work... really wondering how it is working for the rets of the gang...

Anyways I had to make changes to function_attach.php get_var function to make this work... So if any of u get the error I explained above .. do this

Code: Select all

function get_var($var_name, $default, $multibyte = false)
{
	global $HTTP_POST_VARS, $HTTP_GET_VARS;

	$request_var = (isset($HTTP_POST_VARS[$var_name])) ? $HTTP_POST_VARS : $HTTP_GET_VARS;

	if (!isset($request_var[$var_name]) || (is_array($request_var[$var_name]) && !is_array($default)) || (is_array($default) && !is_array($request_var[$var_name])))
	{
		return (is_array($default)) ? array() : $default;
	}

	$var = $request_var[$var_name];

	if (!is_array($default))
	{
		$type = gettype($default);
	}
	else
	{
		list($key_type, $type) = each($default);
		$type = gettype($type);
		$key_type = gettype($key_type);
	}

	if (is_array($var))
	{


		$_var = $var;
		$var = array();

		foreach ($_var as $k => $v)
		{
			if (is_array($v))
			{

				if (count($v) > "1")
				{

					foreach ($v as $_k => $_v)
					{
						_set_var($k, $k, $key_type);
						_set_var($_k, $_k, $key_type);
						_set_var($var[$k][$_k], $_v, $type, $multibyte);
					}
				}
				// If it is a multidimensional array but with just one element.
				else
				{
					foreach ($v as $_k => $_v)
					{
						_set_var($_k, $_k, $key_type);
						_set_var($var[$_k], $_v, $type, $multibyte);
					}
				}
			}
			else
			{
				_set_var($k, $k, $key_type);
				_set_var($var[$k], $v, $type, $multibyte);
			}
		}
	}
	else
	{
		_set_var($var, $var, $type, $multibyte);
	}

	return $var;
}
DavidIQ
Site Admin
Posts: 619
Joined: Thu Sep 07, 2006 4:31 pm
Location: Earth
Contact:

Post by DavidIQ »

Glad you were able to figure it out. With a little bit of brain storming anything's achievable ;-)
Locked