PDA

View Full Version : PowerPanel Profiles.



[Oli]
04-07-2007, 10:14 PM
Hi,

On PowerPanel's Profile system i'm having a tiny problem.

You see, when I click "update your profile", i see the form.

So i enter my email, habbo name, avatar link (avatar has right type&size)

and when i click save your settings, it gives me this reply:


Sorry! You either have a too small image or have chosen an image with an invalid type

But its all correct.
I can edit the max. sizes as admin, and it auto changes the sizes on the update profile page so it sais (100 x 100) like i had set. my avatar = 100 x 100 and .gif, i've already tried .png too & .jpg but it keeps giving that error.

heres the bit from the code:

<?php

if(isset($_POST['email']) && isset($_POST['habbo']) && isset($_POST['favhab']) && isset($_POST['avatar']) && !empty($_POST['email'])) {

$email = $_POST['email'];
$habbo = $_POST['habbo'];
$favhab = $_POST['favhab'];
$avatar = $_POST['avatar'];
$email = clean($email);
$habbo = clean($habbo);
$favhab = clean($favhab);
$avatar = clean($avatar);
$email = censor($email);
$habbo = censor($habbo);
$favhab = censor($favhab);
$avatar = censor($avatar);

if($avatar == "") {
$avatar = "images/no_ava.gif";
}
elseif($avatar == "Default Avatar") {
$avatar = "images/no_ava.gif";
}
###
$query = mysql_query("SELECT * FROM config");
while($rows = @mysql_fetch_array($query)) {

$maxh = $rows[avah];
$maxw = $rows[avaw];

}
###
list($width, $height, $type, $attr) = @getimagesize($avatar);


$mhm = explode("\"", $attr);
$height = $mhm[1];
$width = $mhm[3];

if($height == "0" || $width == "0" || $height == "" || $width == "") {
echo("<br /><strong>Sorry!</strong> You either have a too small image or have chosen an image with an invalid type");
}
elseif($height > $maxh || $width > $maxw) {
echo("<br /><strong>Sorry!</strong> You either have a too big image or have chosen an image with an invalid type");
}

else {


if(!check_email_address($email)) {
echo("<br /><strong>Error:</strong> The email you entered is <strong>not</strong> valid!<br /><br /><div id='link'><a href='?page=uprofile'>Go back</a></div>");
}

else {

$update = mysql_query("UPDATE users SET email = '$email', habbo = '$habbo', favhab = '$favhab', avatar = '$avatar' WHERE username = '$_SESSION[username]'") or die('Could not update email, Error: '. mysql_error());

echo("<br /><strong>Thanks!</strong> Your profile has been updated!<br /><br /><div id='link'><a href='?page=uprofile'>Go back</a></div>");
}

}

} elseif(isset($_POST['email']) && empty($_POST['email'])) {
echo("<br /><strong>Error:</strong> You must fill in all fields!</strong><br /><br /><div id='link'><a href='?page=uprofile'>Go back</a></div>");
} else {
?><br />Click <strong><a onClick="toggle('form');" style="cursor: pointer;">here</a></strong> to display the form.
<br /><br />
<div id="form" style="display: none"><form action="" method="POST"><strong>Email:</strong><br /><input type="text" name="email" value="<?php $data = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE username = '$_SESSION[username]'")); echo("". $data[email] .""); ?>" />
<br />
<br />
<strong>Habbo Name:</strong><br />
<label>
<input name="habbo" type="text" id="habbo" value="<?php $data = @mysql_fetch_array(mysql_query("SELECT * FROM users WHERE username = '$_SESSION[username]'")); echo("". $data[habbo] .""); ?>" />
</label>
<br />
<br />
<strong>Favourite Habbo: </strong><br />
<label>
<input name="favhab" type="text" id="favhab" value="<?php $data = @mysql_fetch_array(mysql_query("SELECT * FROM users WHERE username = '$_SESSION[username]'")); echo("". $data[favhab] .""); ?>" />
</label>
<br />
<br />
<strong>DJ Avatar</strong><em> (optional)</em><strong> :</strong><br />
<label>
<input name="avatar" type="text" id="avatar" value="<?php $data = @mysql_fetch_array(mysql_query("SELECT * FROM users WHERE username = '$_SESSION['username']'")); if($data[avatar] == "images/no_ava.gif") {
echo("Default Avatar");
}
else {
echo("". $data[avatar] ."");
} ?>" />
</label>
<br />
(<?php $data = @mysql_fetch_array(mysql_query("SELECT * FROM config")); echo("". $data[avaw] .""); ?> (W) x <?php $data = @mysql_fetch_array(mysql_query("SELECT * FROM config")); echo("". $data[avah] .""); ?> (H) max) <br />
<br /><input type="submit" value="Update My Profile" /></form
></div>

<? } ?></div>
<?php
} else {
header('location: index.php');
die();
}
?>

Anyone capeble of helping me? or sending my your working uprofile.php so i can find out what went wrong.

Scania
04-07-2007, 11:14 PM
Im also having the same issue

Tomm
05-07-2007, 07:04 AM
Try this:

Not tested and I don't know how PowerPanel works.. but I do know that the getimagesize stuff is coded incorrectly.

Also I am assuming that the height is in pixels and is a number in the config table.

Furthermore, I would like to point out that is does not check the file type as well nor the actual diskspace size of the image.


<?php

if(isset($_POST['email']) && isset($_POST['habbo']) && isset($_POST['favhab']) && isset($_POST['avatar']) && !empty($_POST['email'])) {

$email = $_POST['email'];
$habbo = $_POST['habbo'];
$favhab = $_POST['favhab'];
$avatar = $_POST['avatar'];
$email = clean($email);
$habbo = clean($habbo);
$favhab = clean($favhab);
$avatar = clean($avatar);
$email = censor($email);
$habbo = censor($habbo);
$favhab = censor($favhab);
$avatar = censor($avatar);

if($avatar == "") {
$avatar = "images/no_ava.gif";
}
elseif($avatar == "Default Avatar") {
$avatar = "images/no_ava.gif";
}
###
$query = mysql_query("SELECT * FROM config");
while($rows = @mysql_fetch_array($query)) {

$maxh = $rows[avah];
$maxw = $rows[avaw];

}
###
$imgdata = @getimagesize($avatar);

$width = $imgdata[1];
$height = $imgdata[2];

if($height == "0" || $width == "0" || $height == "" || $width == "") {
echo("<br /><strong>Sorry!</strong> You either have a too small image or have chosen an image with an invalid type");
}
elseif($height > $maxh || $width > $maxw) {
echo("<br /><strong>Sorry!</strong> You either have a too big image or have chosen an image with an invalid type");
}

else {


if(!check_email_address($email)) {
echo("<br /><strong>Error:</strong> The email you entered is <strong>not</strong> valid!<br /><br /><div id='link'><a href='?page=uprofile'>Go back</a></div>");
}

else {

$update = mysql_query("UPDATE users SET email = '$email', habbo = '$habbo', favhab = '$favhab', avatar = '$avatar' WHERE username = '$_SESSION[username]'") or die('Could not update email, Error: '. mysql_error());

echo("<br /><strong>Thanks!</strong> Your profile has been updated!<br /><br /><div id='link'><a href='?page=uprofile'>Go back</a></div>");
}

}

} elseif(isset($_POST['email']) && empty($_POST['email'])) {
echo("<br /><strong>Error:</strong> You must fill in all fields!</strong><br /><br /><div id='link'><a href='?page=uprofile'>Go back</a></div>");
} else {
?><br />Click <strong><a onClick="toggle('form');" style="cursor: pointer;">here</a></strong> to display the form.
<br /><br />
<div id="form" style="display: none"><form action="" method="POST"><strong>Email:</strong><br /><input type="text" name="email" value="<?php $data = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE username = '$_SESSION[username]'")); echo("". $data[email] .""); ?>" />
<br />
<br />
<strong>Habbo Name:</strong><br />
<label>
<input name="habbo" type="text" id="habbo" value="<?php $data = @mysql_fetch_array(mysql_query("SELECT * FROM users WHERE username = '$_SESSION[username]'")); echo("". $data[habbo] .""); ?>" />
</label>
<br />
<br />
<strong>Favourite Habbo: </strong><br />
<label>
<input name="favhab" type="text" id="favhab" value="<?php $data = @mysql_fetch_array(mysql_query("SELECT * FROM users WHERE username = '$_SESSION[username]'")); echo("". $data[favhab] .""); ?>" />
</label>
<br />
<br />
<strong>DJ Avatar</strong><em> (optional)</em><strong> :</strong><br />
<label>
<input name="avatar" type="text" id="avatar" value="<?php $data = @mysql_fetch_array(mysql_query("SELECT * FROM users WHERE username = '$_SESSION['username']'")); if($data[avatar] == "images/no_ava.gif") {
echo("Default Avatar");
}
else {
echo("". $data[avatar] ."");
} ?>" />
</label>
<br />
(<?php $data = @mysql_fetch_array(mysql_query("SELECT * FROM config")); echo("". $data[avaw] .""); ?> (W) x <?php $data = @mysql_fetch_array(mysql_query("SELECT * FROM config")); echo("". $data[avah] .""); ?> (H) max) <br />
<br /><input type="submit" value="Update My Profile" /></form
></div>

<? } ?></div>
<?php
} else {
header('location: index.php');
die();
}
?>

[Oli]
05-07-2007, 11:46 AM
Try this:

Not tested and I don't know how PowerPanel works.. but I do know that the getimagesize stuff is coded incorrectly.

Also I am assuming that the height is in pixels and is a number in the config table.

Furthermore, I would like to point out that is does not check the file type as well nor the actual diskspace size of the image.


<?php

if(isset($_POST['email']) && isset($_POST['habbo']) && isset($_POST['favhab']) && isset($_POST['avatar']) && !empty($_POST['email'])) {

$email = $_POST['email'];
$habbo = $_POST['habbo'];
$favhab = $_POST['favhab'];
$avatar = $_POST['avatar'];
$email = clean($email);
$habbo = clean($habbo);
$favhab = clean($favhab);
$avatar = clean($avatar);
$email = censor($email);
$habbo = censor($habbo);
$favhab = censor($favhab);
$avatar = censor($avatar);

if($avatar == "") {
$avatar = "images/no_ava.gif";
}
elseif($avatar == "Default Avatar") {
$avatar = "images/no_ava.gif";
}
###
$query = mysql_query("SELECT * FROM config");
while($rows = @mysql_fetch_array($query)) {

$maxh = $rows[avah];
$maxw = $rows[avaw];

}
###
$imgdata = @getimagesize($avatar);

$width = $imgdata[1];
$height = $imgdata[2];

if($height == "0" || $width == "0" || $height == "" || $width == "") {
echo("<br /><strong>Sorry!</strong> You either have a too small image or have chosen an image with an invalid type");
}
elseif($height > $maxh || $width > $maxw) {
echo("<br /><strong>Sorry!</strong> You either have a too big image or have chosen an image with an invalid type");
}

else {


if(!check_email_address($email)) {
echo("<br /><strong>Error:</strong> The email you entered is <strong>not</strong> valid!<br /><br /><div id='link'><a href='?page=uprofile'>Go back</a></div>");
}

else {

$update = mysql_query("UPDATE users SET email = '$email', habbo = '$habbo', favhab = '$favhab', avatar = '$avatar' WHERE username = '$_SESSION[username]'") or die('Could not update email, Error: '. mysql_error());

echo("<br /><strong>Thanks!</strong> Your profile has been updated!<br /><br /><div id='link'><a href='?page=uprofile'>Go back</a></div>");
}

}

} elseif(isset($_POST['email']) && empty($_POST['email'])) {
echo("<br /><strong>Error:</strong> You must fill in all fields!</strong><br /><br /><div id='link'><a href='?page=uprofile'>Go back</a></div>");
} else {
?><br />Click <strong><a onClick="toggle('form');" style="cursor: pointer;">here</a></strong> to display the form.
<br /><br />
<div id="form" style="display: none"><form action="" method="POST"><strong>Email:</strong><br /><input type="text" name="email" value="<?php $data = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE username = '$_SESSION[username]'")); echo("". $data[email] .""); ?>" />
<br />
<br />
<strong>Habbo Name:</strong><br />
<label>
<input name="habbo" type="text" id="habbo" value="<?php $data = @mysql_fetch_array(mysql_query("SELECT * FROM users WHERE username = '$_SESSION[username]'")); echo("". $data[habbo] .""); ?>" />
</label>
<br />
<br />
<strong>Favourite Habbo: </strong><br />
<label>
<input name="favhab" type="text" id="favhab" value="<?php $data = @mysql_fetch_array(mysql_query("SELECT * FROM users WHERE username = '$_SESSION[username]'")); echo("". $data[favhab] .""); ?>" />
</label>
<br />
<br />
<strong>DJ Avatar</strong><em> (optional)</em><strong> :</strong><br />
<label>
<input name="avatar" type="text" id="avatar" value="<?php $data = @mysql_fetch_array(mysql_query("SELECT * FROM users WHERE username = '$_SESSION['username']'")); if($data[avatar] == "images/no_ava.gif") {
echo("Default Avatar");
}
else {
echo("". $data[avatar] ."");
} ?>" />
</label>
<br />
(<?php $data = @mysql_fetch_array(mysql_query("SELECT * FROM config")); echo("". $data[avaw] .""); ?> (W) x <?php $data = @mysql_fetch_array(mysql_query("SELECT * FROM config")); echo("". $data[avah] .""); ?> (H) max) <br />
<br /><input type="submit" value="Update My Profile" /></form
></div>

<? } ?></div>
<?php
} else {
header('location: index.php');
die();
}
?>

Thanks for trying to help out, even if you don't know how powerpanel works ;) (il +rep you).(EDIT: g2spread first.. i'l rep you as soon as i can ;))

but with your edit i get this;

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/planonet/public_html/phpanel/uprofile.php on line 96

now i'll get the line:
...

<input name="avatar" type="text" id="avatar" value="<?php $data = @mysql_fetch_array(mysql_query("SELECT * FROM users WHERE username = '$_SESSION['username']'")); if($data[avatar] == "images/no_ava.gif") {
echo("Default Avatar");
}
else {
echo("". $data[avatar] ."");
} ?>" />

I'll look too now, see if i can find something.

[Oli]
05-07-2007, 11:57 AM
sorry for 2x post but i fixed the error:

Avatar has to be right size, and seems like it has to be a .gif
my .png doesn't work.

Find: (line: 96);

<input name="avatar" type="text" id="avatar" value="<?php $data = @mysql_fetch_array(mysql_query("SELECT * FROM users WHERE username = '$_SESSION['username']'")); if($data[avatar] == "images/no_ava.gif") {
echo("Default Avatar");
}
else {
echo("". $data[avatar] ."");
} ?>" />

Replace with:

<input name="avatar" type="text" id="avatar" value="<?php $data = @mysql_fetch_array(mysql_query("SELECT * FROM users WHERE username = '{$_SESSION['username']}'")); if("{$data['avatar']}" == "images/no_ava.gif") {
echo("Default Avatar");
}
else {
echo("". $data[avatar] ."");
} ?>" />

Edit, hmm it doesn't seem to save the avatar though.

EDIT2= Ok, it does save the avatar link, it just shows the default avatar on dj list, so that problem would be with the dj list file then, i think.

EDIT3: Ok, it Dj pofile works in frontend file.
but the avatar doesn't show on the profile page inside the panel..

Here's how to fix (easy but ah well..)
Open djprofile.php from your powerpanel folder. (not frontend folder)

Find: (line 62:)

$avatar = $account["frontend/avatar"];


Replace with:

$avatar = $account["avatar"];


Now it should all work ;)

Want to hide these adverts? Register an account for free!