Cronwerks MCCode/MCCodes Forums

Please login or register.

Login with username, password and session length

News:

After purchasing with us the download link will be delivered to your forum message box.


This forum is now closed and has moved to a new location! Click here to find out why.

AuthorTopic: new prefs page  (Read 903 times)

catles

  • Basic Member
  • *
  • Reputation Power: 24
  • catles has no influence.
  • Offline Offline
  • Posts: 26
    • View Profile
    • WWW
    • Email
new prefs page
« on: March 25, 2010, 05:44:38 PM »
note!:this code is done for my game and you will have to change a few things for it to 100% work on your site (more so just remove 1 or 2 things)
Code: [Select]
<?php
include "globals.php";
switch(
$_GET['action'])
{
case 
'passchange2':do_pass_change();break;
case 
'passchange':pass_change();break;
default:
prefs_home();break;
}
function 
prefs_home()
{
global 
$db,$ir,$c,$userid,$h;

if(
$_POST['submit'])
{
$_POST['name']=str_replace(array("<"">""\\\'"), array("."".""."), $_POST['name']);
$_POST['name']=mysql_real_escape_string($_POST['name']);
$db->query("UPDATE users SET username='{$_POST['name']}' WHERE userid=$userid");
$_POST['color']=mysql_real_escape_string($_POST['color']);
$db->query("UPDATE users SET color='{$_POST['color']}' WHERE userid=$userid");
$db->query("UPDATE users SET gender='{$_POST['gender']}' WHERE userid=$userid");
$_POST['pic']=str_replace(array("<"">""\\\'"), array("."".""."), $_POST['pic']);
$_POST['pic']=mysql_real_escape_string($_POST['pic']);
$db->query("UPDATE users SET display_pic='{$_POST['pic']}' WHERE userid=$userid");
$_POST['pic2']=str_replace(array("<"">"), array("&lt;""&gt;"), $_POST['pic2']);
$_POST['pic2']=mysql_real_escape_string($_POST['pic2']);
$db->query("UPDATE users SET forums_avatar='{$_POST['pic2']}' WHERE userid=$userid");
$_POST['signature']=str_replace(array("<"">"), array("[""]"), $_POST['signature']);
$_POST['signature']=mysql_real_escape_string($_POST['signature']);
$db->query("UPDATE users SET sig='{$_POST['signature']}' WHERE userid=$userid");
$_POST['forums_signature']=str_replace(array("<"">"), array("[""]"), $_POST['forums_signature']);
$_POST['forums_signature']=mysql_real_escape_string($_POST['forums_signature']);
$db->query("UPDATE users SET forums_signature='{$_POST['forums_signature']}' WHERE userid=$userid");
print 
"Settings updated!<br />";
$h->endpage();
exit;
}
$ir['sig']=stripslashes($ir['sig']);
?>

<script type="text/javascript" language="javascript" src="js/colorPicker.js"></script>
<link rel="stylesheet" href="css/colorPicker.css" type="text/css"></link>
<h3>Preferences</h3>
<form action='preferences.php' method='post'>
<input type='hidden' name='submit' value='1' />
<table width="100%" border="0" cellpadding="4" cellspacing="3" style="border:1px solid #333333; background-color:#010101;">
<tr>
<td width="70%" height="30"><strong>User Settings</strong></td>
<td></td>
</tr>
<tr>
<td height="30" bgcolor="#333030">Name (names must be atlest 3 chars long)</td>
<td bgcolor="#333030"><input type="text" name="name" value="<?php echo $ir['username'];?>" style="color: <?php echo $ir['color']; ?>;" />
</td>
</tr>
<tr>
<td height="30" bgcolor="#333030">Name Colour</td>
<td bgcolor="#333030">
<input type="text" name="color" value="<?php echo $ir['color'];?>" onclick="startColorPicker(this)" onkeyup="maskedHex(this)" style="color: <?php echo $ir['color']; ?>;" />
</td>
</tr>
<tr>
<td height="30" bgcolor="#333030">Gender </td>
<td bgcolor="#333030">
<select name='gender' type='dropdown' >
<option value='Male' <?PHP if($ir['gender']==Male) echo "selected";?>>Male
<option value='Female'  <?PHP if($ir['gender']==Female) echo "selected";?>>Female</select>
</select>
</td>
</tr>
<tr>
<td height="30" bgcolor="#333030">password</td>
<td bgcolor="#333030"><a href='preferences.php?action=passchange'>Change</a>
</td>
</tr>
</table>

<table width="100%" border="0" cellpadding="4" cellspacing="3" style="border:1px solid #333333; background-color:#010101;">
<tr>
<td height="30" colspan=2><strong> Avatar Settings</strong></td>
</tr>
<tr>
<td align=left valign="button" width=100 height=100 bgcolor="#333030">
<?php
if(!$ir['display_pic'])
{
print 
"No profile Display Picture";
}
else
{
print 
"
<img src='{$ir['display_pic']}' width=100 height=100 />"
;
}
?>

</td>
<td bgcolor="#333030" valign="bottom">
Profile Avatar<br />
<input type='text' name='pic' size="100" value='<?php echo $ir['display_pic'?>' />
</td>
</tr>
<tr>
<td align=left width=100 height=100 bgcolor="#333030">
<?php
if(!$ir['forums_avatar'])
{
print 
"No Forum Avatar";
}
else
{
print 
"<img src='{$ir['forums_avatar']}' width=100 height=100 />";
}
?>

</td>
<td bgcolor="#333030" valign="bottom">
Forum Avatar<br />
<input type='text' name='pic2' size="100" value='<?php echo $ir['forums_avatar'?>' />
</td>
</tr>
</table>

<table width="100%" border="0" cellpadding="4" cellspacing="3" style="border:1px solid #333333; background-color:#010101;">
<tr>
<td height="30" colspan=2><strong>Signature Settings(BB code allowed)</strong></td>
</tr>
<tr>
<td height="30"><strong>Profile Signature</strong></td>
<td height="30"><strong>Forum Signature</strong></td>
</tr>
<tr>
<td align=left valign="button" width=50% height=200 bgcolor="#0F0F0F">
<textarea class=textbox rows=12 cols=87 name='signature'> <?php echo $ir['sig'?> </textarea>
</td>
<td align=left valign="button" width=50% height=200 bgcolor="#0F0F0F">
<textarea class=textbox rows=12 cols=87 name='forums_signature'> <?php echo $ir['forums_signature'?> </textarea>

</td>
</tr>
</table>
<input type='submit' value='Update Settings' />
</form>

<?php
}
function 
pass_change()
{
global 
$ir,$c,$userid,$h;
print 
"<h3>Password Change</h3><form action='preferences.php?action=passchange2' method='post'>Current Password: <input class=textbox type='password' name='oldpw' /><br />
New Password: <input class=textbox type='password' name='newpw' /><br />
Confirm: <input class=textbox type='password' name='newpw2' /><br />
<input class=textbox type='submit' value='Change PW' /></form>"
;
}
function 
do_pass_change()
{
global 
$db,$ir,$c,$userid,$h;
if(
md5($_POST['oldpw']) != $ir['userpass'])
{
print 
"The current password you entered was wrong.<br />
<a href='preferences.php?action=passchange'>&gt; Back</a>"
;
}
else if(
$_POST['newpw'] !== $_POST['newpw2'])
{
print 
"The new passwords you entered did not match!<br />
<a href='preferences.php?action=passchange'>&gt; Back</a>"
;
}
else
{
$db->query("UPDATE users SET userpass=md5('{$_POST['newpw']}') WHERE userid=$userid");
print 
"Password changed!";
}
}
$h->endpage();
?>

Screen shot
Logged

JoshuaDams

  • Active Member
  • **
  • Reputation Power: 129
  • JoshuaDams is working their way up.JoshuaDams is working their way up.JoshuaDams is working their way up.
  • Offline Offline
  • Posts: 240
    • MSN Messenger - immortalthug4ever@hotmail.com
    • View Profile
    • WWW
Re: new prefs page
« Reply #1 on: March 25, 2010, 10:04:54 PM »
Looking good, Need to secure the username bit a little more, but overall not bad :)

Danny696

  • Senior Member
  • ****
  • Reputation Power: 317
  • Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.
  • Offline Offline
  • Posts: 540
    • View Profile
    • WWW
Re: new prefs page
« Reply #2 on: March 26, 2010, 11:16:02 AM »
No security :S
Logged
Project Choosen - 10%
Daniel - Hanson . Com

JoshuaDams

  • Active Member
  • **
  • Reputation Power: 129
  • JoshuaDams is working their way up.JoshuaDams is working their way up.JoshuaDams is working their way up.
  • Offline Offline
  • Posts: 240
    • MSN Messenger - immortalthug4ever@hotmail.com
    • View Profile
    • WWW
Re: new prefs page
« Reply #3 on: March 26, 2010, 04:07:48 PM »
I was being nice, he did well on the looks :)

I may take some time later to secure after i'm done with this one click attack

catles

  • Basic Member
  • *
  • Reputation Power: 24
  • catles has no influence.
  • Offline Offline
  • Posts: 26
    • View Profile
    • WWW
    • Email
Re: new prefs page
« Reply #4 on: March 26, 2010, 04:09:41 PM »
lol i no its alot on the weak side for security only thing i realy no is mysql_real_escape_string witch has not failed me yet lol
Logged

JoshuaDams

  • Active Member
  • **
  • Reputation Power: 129
  • JoshuaDams is working their way up.JoshuaDams is working their way up.JoshuaDams is working their way up.
  • Offline Offline
  • Posts: 240
    • MSN Messenger - immortalthug4ever@hotmail.com
    • View Profile
    • WWW
Re: new prefs page
« Reply #5 on: March 26, 2010, 08:01:20 PM »
It will on an XSS attempt lol ;-)

Still did well on the look and feel :)

i'm workin on this attack system for the next day or so then i'll run thru it

Danny696

  • Senior Member
  • ****
  • Reputation Power: 317
  • Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.
  • Offline Offline
  • Posts: 540
    • View Profile
    • WWW
Re: new prefs page
« Reply #6 on: March 27, 2010, 04:38:56 AM »
profile pic -> logout.php -.-
Logged
Project Choosen - 10%
Daniel - Hanson . Com
 


This forum is now closed and has moved to a new location! Click here to find out why.