Jump to content
MakeWebGames

Recommended Posts

Posted

I have added Magictallguy's style switcher modification and I have a problem, When I cilck style change nothing happens I remain on the same page

 

<?php
include_once (DIRNAME(__FILE__). '/globals.php');

if (!function_exists('error'))
{
function error( $msg = null )
{
global $h;
echo is_null($msg) ? "Invalid Page" : $msg;
$h->endpage();
exit;
}
}

// XSS Prevention
function NoXSS($Var) {
return (get_magic_quotes_gpc()) ? htmlspecialchars($Var) : addslashes(htmlspecialchars($Var));
}

$_GET['act'] = isset($_GET['act']) && ctype_alpha($_GET['act']) ? trim($_GET['act']) : null;
switch ($_GET['act']) {
case 'SexChange': SexChange(); break;
case 'PassChange': PassChange(); break;
case 'NameChange': NameChange(); break;
case 'DPChange': DPChange(); break;
case 'ForumSig': ForumSig(); break;
case 'ProfileSig': ProfileSig(); break;
case 'styleswitch':style_switch(); break;
case 'styleswitch2':style_switch_sub(); break;
case 'stylerand': style_rand(); break;

default: Index(); break;
}

// Index Function
function Index() {
echo '<h3 style="text-decoration: underline;">Your Preferences</h3>
[url="preferences.php?act=SexChange"]Sex Change[/url]

[url="preferences.php?act=PassChange"]Password Change[/url]

[url="preferences.php?act=NameChange"]Username Change[/url]

[url="preferences.php?act=DPChange"]Display Picture Change[/url]

[url="preferences.php?act=ForumSig"]Forum Info Change[/url]

[url="preferences.php?act=ProfileSig"]Profile Sig Change[/url]

[url="preferences.php?act=StyleSwitch"]Change Game Styles[/url]
';
}

// Sex Change Function
function SexChange() {
global $ir, $db;
$NewGender = ($ir['gender'] == 'Male') ? 'Female' : 'Male';
if (isset($_POST['NewGender'])) {
$db->query(sprintf("UPDATE `users` SET `gender`='%s' WHERE `userid`='%d'", $_POST['NewGender'], $ir['userid']));
echo sprintf("You Are Now A %s", $_POST['NewGender']);
$h->endpage();
exit;
} else {
echo '<h3 style="text-decoration: underline;">Sex Change</h3>
<form action="preferences.php?act=SexChange" method="post">';
echo sprintf("<input type='hidden' name='NewGender' value='%s' />", $NewGender);
echo sprintf("You Are Currently A Are %s, Are You Sure You Want To Become A %s?
", $ir['gender'], $NewGender);
echo '<input type="submit" value="Yes!" />
</form>';
}
}

// Password Change Function
function PassChange() {
global $ir, $db, $c; 
$Info = $db->fetch_row($db->query(sprintf("SELECT `userid`, `userpass`, `login_name` FROM `users` WHERE `userid`='%d'", $ir['userid'])));
if (isset($_POST['OldPass'], $_POST['NewPass1'])) {
if ($_POST['NewPass1'] == '') {
echo 'Error!
You Entered No Password 
';
} else if (md5($_POST['OldPass']) != $Info['userpass']) {
echo 'Error!
The Current Password Is Inncorrect! 
';
} else {
$db->query(sprintf("UPDATE `users` SET `userpass`='%s' WHERE `userid`='%d'", md5($_POST['NewPass1']), $ir['userid']));
echo 'Your Password Has Been Updated! 

Your New Password Is: [i]'.$_POST['NewPass1'].'[/i]

Keep This Password Safe And Don\'t Tell Anyone It.

> [url="index.php"]Home[/url]';
}
} else {
echo '<h3 style="text-decoration: underline;">Password Change</h3>
<form action="preferences.php?act=PassChange" method="post">
Current Password: <input type="password" name="OldPass" />

New Password: <input type="password" name="NewPass1" />

<input type="submit" value="Change Password!" />
</form>';
}
}

// Name Change Function
function NameChange() {
global $ir, $db;
if (isset($_POST['NewName'])) {
$CheckLog = $db->num_rows($db->query(sprintf("SELECT `userid`, `username` FROM `users` WHERE `login_name`='%s' AND `userid`!='%d'", $_POST['NewName'], $ir['userid'])));
$CheckGame = $db->num_rows($db->query(sprintf("SELECT `userid`, `username` FROM `users` WHERE `username`='%s' AND `userid`!='%d'", $_POST['NewName'], $ir['userid'])));
if (trim($_POST['NewName']) == '') {
echo 'Error! 
You Did Not Enter A New Name 
';
} else if ($CheckLog) {
echo 'Error! 
This Name Is In Use 
';
} else if ($CheckGame) {
echo 'Error! 
This Name Is In Use 
';
} else if (strlen($_POST['NewName']) < '4') {
echo 'Error! 
This Name Is Too Short';
} else if (strlen($_POST['NewName']) > '15') {
echo 'Error!
This Name Is Too Long';
} else {
$_POST['NewName'] = str_replace(array("<", ">", "'", ";"), array("", "", "", ""), $_POST['NewName']);
$db->query(sprintf("UPDATE `users` SET `username`='%s' WHERE `userid`='%d'", $_POST['NewName'], $ir['userid']));
echo 'You Have Changed Your Username';
}
} else {
echo '<h3>Name Change</h3>
Please note that you still use the same name to login, this procedure simply changes the name that is displayed.
<form action="preferences.php?act=NameChange" method="post"> 
New Name: <input type="text" name="NewName" />

<input type="submit" value="Change Name" />
</form>';
}
}

// Display Picture Change Function
function DPChange() {
global $ir, $db;
$Pic = $db->query(sprintf("SELECT `display_pic` FROM `users` WHERE `userid`='%d'", $ir['userid']));
if (isset($_POST['NewPic'])) {
if ($_POST['NewPic'] == '') { 
echo 'You Did Not Enter An Image';
} else {
$sizes = @getimagesize($_POST['NewPic']);
if ($sizes === true) {
Error('Uh.. this isn\'t an image.. o.o');
}
if(!preg_match('~(.?).(jpg|jpeg|gif|png)~i', $_POST['NewPic'])) {
Error('Invalid Extension!');
} else {
$_POST['NewPic'] = str_replace(array("<", ">", "'", ";", ".php", ".html", ".js"), array("", "", "", "", "", "", ""), $_POST['NewPic']);
$db->query(sprintf("UPDATE `users` SET `display_pic`='%s' WHERE `userid`='%d'", $_POST['NewPic'], $ir['userid']));
echo 'Picture Changed';
}
}
} else {
echo '<h3>Pic Change</h3>
Please note that this must be externally hosted, [url="http://imageshack.us"]ImageShack[/url] is our recommendation.

<form action="preferences.php?act=DPChange" method="post">';
echo sprintf("New Pic: <input type='text' name='NewPic' value='%s' />
", $Pic['display_pic']);
echo '
<input type="submit" value="Change Picture" />
</form>';
}
}

// Forum Info Change Function
function ForumSig() {
global $ir, $db; 
if (isset($_POST['NewFSig'])) {
$db->query(sprintf("UPDATE `users` SET `forums_avatar`='%s', `forums_signature`='%s' WHERE `userid`='%d'", NoXSS($_POST['FPic']), NoXSS($_POST['NewFSig']), $ir['userid']));
echo 'Forum Info Updated';
} else {
echo '<h3>Forum Info Change</h3>
Please note that the avatar must be externally hosted, [url="http://imageshack.us"]ImageShack[/url] is our recommendation.

<form action="preferences.php?act=ForumSig" method="post">';
echo sprintf("Avatar: <input type='text' name='NewFPic' value='%s' />
", $ir['forums_avatar']);
echo sprintf("Signature (you may use BBcode): <textarea rows='10' cols='50' name='NewFSig'>%s</textarea>
", $ir['forums_signature']);
echo '<input type="submit" value="Change Info" />
</form>';
}
}

// Profile Sig Change Function
function ProfileSig() {
global $ir, $db;
if (isset($_POST['NewPSig'])) {
$db->query(sprintf("UPDATE `users` SET `sig`='%s' WHERE `userid`='%d'", NoXSS($_POST['NewPSig']), $ir['userid']));
echo 'Profile Sig Updated';
} else {
echo '<h3>Profile Sig</h3>
<form action="preferences.php?act=ProfileSig" method="post">';
echo 'Signature (you may use BBcode):
';
echo sprintf("<textarea rows='10' cols='50' name='NewPSig'>%s</textarea>
", $ir['sig']);
echo '<input type="submit" value="Change Profile Sig" />
</form>';
}
}
// Style switchings
function style_switch()
{
global $userid, $ir, $db, $set;
echo "<h3>You are able to change the way you view the game with the preset styles!</h3>";
$select = $db->query("SELECT * FROM stylesheets ORDER BY number ASC");
$style = $db->fetch_row($select);

echo "<table class='table' width='100%'>";

echo "<tr>";
echo "<th width='20%'>Style</th>";
echo "<th width='5%'>Current</th>";
echo "<th>Description</th>";
echo "</tr>";
$selected1 = ($ir['header'] == 1)
? "[img=/imageicons/bullet_green.png]"
: "[img=/imageicons/bullet_red.png]";
echo "<tr>";
echo "<th>[url='preferences.php?action=styleswitch2&style=1']Style 1[/url]</th>";
echo sprintf("<td align='center'>%s</td>", $selected1);
echo sprintf("<td>The default style of %s</td>", $set['game_name']);
echo "</tr>";
while($css = $db->fetch_row($select))
{
$selected = ($ir['header'] == $css['number'])
? "[img=/imageicons/bullet_green.png]"
: "[img=/imageicons/bullet_red.png]";
echo "<tr>";
echo sprintf("<th>[url='preferences.php?action=styleswitch2&style=%u']%s[/url]</th>", $css['number'], stripslashes($css['name']));
echo sprintf("<td align='center'>%s</td>", $selected);
echo sprintf("<td>%s</td>", stripslashes($css['description']));
echo "</tr>";
}

echo "<tr>";
echo "<form action='preferences.php?action=stylerand' method='post'>";
echo sprintf("<td colspan='100%%' style='text-align:center;'>Randomise on every login: <input type='checkbox' name='rand' value='1' %s /> (leave unchecked if no) - <input type='submit' value='Submit' /></td>", ($ir['style_rand_checked']) ? "checked='checked'" : "");
echo "</form>";
echo "</tr>";

echo "</table>";
}
function style_switch_sub()
{
global $db, $ir, $userid, $h;
$_GET['style'] = abs(@intval($_GET['style']));
if(!$_GET['style'])
{
echo "What are you doing?";
$h->endpage();
exit;
}
$select = sprintf("SELECT name, number FROM stylesheets WHERE (number = %u)", $_GET['style']);
$get_ = $db->query($select);
if(!$db->num_rows($get_))
{
echo "What are you doing?";
$h->endpage();
exit;
}
if(isset($_POST['rand']))
{
$randomise = sprintf("UPDATE users SET style_rand_checked = 1 WHERE (userid = %u)", $userid);
$db->query($randomise);
}
$sql = sprintf("UPDATE users SET header = %u WHERE (userid = %u)", $_GET['style'], $userid);
$db->query($sql);
$css = $db->fetch_row($get_);
echo sprintf("Style switched to ā€œ%sā€
", stripslashes($css['name']));
echo "[url='preferences.php?action=styleswitch']Back[/url]";
}

function style_rand()
{
global $db, $userid;
$_POST['rand'] = abs(@intval($_POST['rand']));
$sql = sprintf("UPDATE users SET style_rand_checked = %u WHERE (userid = %u)", $_POST['rand'], $userid);
$db->query($sql);
echo sprintf("The styles will %sbe randomised on login from now on", ($_POST['rand'] == 1) ? "" : "no longer ");
}
$h->endpage( );
?>
Posted

Yeah, I hate alot od mods these days due to page reloading, likke it all to be on one page click and point, I was thinking abotu putting my whoel game into some type of java. So it wouldn't eed reloading That would be cool.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...