Simple Machines Community Forum

SMF Support => SMF 1.1.x Support => Aiheen aloitti: alexandervba - huhtikuu 11, 2011, 09:39:11 AP

Otsikko: Error: 8: Undefined index: allowedips
Kirjoitti: alexandervba - huhtikuu 11, 2011, 09:39:11 AP
Gotta reopen this, Im getting another similar error... :(

8: Undefined index: allowedips
File: /home/foerscom/public_html/forums/Themes/default/Profile.template.php
Line: 1454


This is part of profile.template.php:

// Login Security Mod
if ($modSettings['ls_allow_ip_security'])
{
global $user_info;

echo '<tr>
<td><b>', $txt['ls_ip_address_protection'], ':</b></td>
<td>'
,$txt['ls_current_ip_address'],$user_info['ip'],'<br />
<br />
<input type="text" name="allowedips" size="30" value="', $context['member']['allowedips'], '" />
<br /><span class="smalltext">',$txt['ls_ip_address_protection_note'],'</span>
</td>
</tr>';
}


Line 1454 is <input type="text" name="allowedips" size="30" value="', $context['member']['allowedips'], '" />

What should I do to fix this?
Otsikko: Re: Error: 8: Undefined index: allowedips
Kirjoitti: Kays - huhtikuu 11, 2011, 09:57:09 AP
Hi, that code seems to belong to a security/IP related mod. Do you know which one? if not please post a list of your installed mods.

Can you also please attach Profile.php to a post?
Otsikko: Re: Error: 8: Undefined index: allowedips
Kirjoitti: alexandervba - huhtikuu 11, 2011, 10:01:04 AP
this mod: http://custom.simplemachines.org/mods/index.php?mod=2181

Otsikko: Re: Error: 8: Undefined index: allowedips
Kirjoitti: Kays - huhtikuu 11, 2011, 10:25:24 AP
I can make a suggestion to get rid of the error. But something isn't working properly as you shouldn't be getting that error in the first place. Unless the user has a blank IP address. You should be able to see that in the error message.

Parse the mod for your version SMF and verify that the changes to Profile.template.php are there. If you have a custom theme and it has a Profile.template.php then it needs to have those changes also.
Otsikko: Re: Error: 8: Undefined index: allowedips
Kirjoitti: alexandervba - huhtikuu 11, 2011, 11:04:16 AP
It fits 100%
Otsikko: Re: Error: 8: Undefined index: allowedips
Kirjoitti: Kays - huhtikuu 11, 2011, 12:18:35 IP
If you change that code to the following, It will take care of the error.


// Login Security
$allowedips = !empty($_REQUEST['allowedips']) ? $_REQUEST['allowedips'] : 0;
if ($modSettings['ls_allow_ip_security'] && !empty($allowedips))
{
global $sourcedir;
require_once($sourcedir . '/Subs-LoginSecurity.php');
UpdateAllowedIPs($memID, $allowedips);
}


However, I do suspect that the mod is not functioning correctly since $_REQUEST['allowedips'] should be set since the code to do so is there. What is the ?action in the url in the error messages.
Otsikko: Re: Error: 8: Undefined index: allowedips
Kirjoitti: alexandervba - huhtikuu 11, 2011, 01:19:41 IP
The change u made is that similar to this:

if (isset($_REQUEST['allowedips']))
$allowedips = $_REQUEST['allowedips'];


I checked the mod and i parsed it in SMF 2 RC5 just to check it out, and it looks like he made a similar change to the mod than u made. So maybe that what you did, is the actual fix?

thx
Otsikko: Re: Error: 8: Undefined index: allowedips
Kirjoitti: Kays - huhtikuu 11, 2011, 01:31:08 IP
Yes, basically. I also did make a change to line 606 so it uses $allowedips instead of $_REQUEST['allowedips']
Otsikko: Re: Error: 8: Undefined index: allowedips
Kirjoitti: alexandervba - heinäkuu 31, 2011, 06:39:06 IP
Gotta reopen this, Im getting another similar error... :(

8: Undefined index: allowedips
File: /home/foerscom/public_html/forums/Themes/default/Profile.template.php
Line: 1454


This is part of profile.template.php:

// Login Security Mod
if ($modSettings['ls_allow_ip_security'])
{
global $user_info;

echo '<tr>
<td><b>', $txt['ls_ip_address_protection'], ':</b></td>
<td>'
,$txt['ls_current_ip_address'],$user_info['ip'],'<br />
<br />
<input type="text" name="allowedips" size="30" value="', $context['member']['allowedips'], '" />
<br /><span class="smalltext">',$txt['ls_ip_address_protection_note'],'</span>
</td>
</tr>';
}


Line 1454 is <input type="text" name="allowedips" size="30" value="', $context['member']['allowedips'], '" />

What should I do to fix this?
Otsikko: Re: Error: 8: Undefined index: allowedips
Kirjoitti: Kays - elokuu 01, 2011, 07:08:10 IP
Try replacing that with:


<input type="text" name="allowedips" size="30" value="', empty($context['member']['allowedips']) ? 0 : $context['member']['allowedips'], '" />
Otsikko: Re: Error: 8: Undefined index: allowedips
Kirjoitti: alexandervba - elokuu 03, 2011, 07:13:37 IP
awesome it worked :)