if (strlen($sign_up_date) != 8 || strlen($expiration_date) != 8) { die("<h3> Please check your dates, you must use the DD/MM/YY format</h3>". "<br /><a href='javascript:history.go(-1);'>Click here to go back</a></h3>"); }
// Get User Profile Data $xml = @simplexml_load_file($steam_link . "/?xml=1") or die("<h3>Sorry we were unable to get your Steam ID.". "<br />Either you entered an invalid Steam ID, or the Steam community is down.". "<br />Please check and make sure you entered a valid Steam ID and try again." . "<br /><a href='javascript:history.go(-1);'>Click here to go back</a></h3>"); if(!empty($xml)) { $username = $xml->steamID; }
if (isset($user_id)) { die("<p>This user is already in the database</p><br /><p><a href='javascript:history.go(-1);'>Click here to go back</a></p>"); exit(); } else { $insert_sql = "INSERT INTO donors (username,steam_id,sign_up_date,renewal_date,current_amount,total_amount,expiration_date,steam_link,email,notes,activated) VALUES ('{$username}', '{$steam_id}', '{$sign_up_date}', '{$renewal_date}','{$current_amount}','{$total_amount}','{$expiration_date}','{$steam_link}','{$email}','{$notes}','{$activated}');"; } mysql_query($insert_sql) or die("<h1>FAILED TO UPDATE USER</h1><br /><a href='javascript:history.go(-1);'>Click here to go back</a></h3>". mysql_error()); //insert/remove user from sourcebans database
if(SOURCEBANS){ mysql_select_db($SB_DB_NAME) or die("<p>Unable to select the database". $SB_DB_NAME . ": ". mysql_error() . "</p>"); $sb_pw = "1fcc1a43dfb4a474abb925f54e65f426e932b59e";
switch ($activated) { case 1: mysql_select_db($SB_DB_NAME) or die("<p>Unable to select the database". $SB_DB_NAME . ": ". mysql_error() . "</p>"); //check sourcebans database to see if user is already in there $check_sql = "SELECT * FROM sb_admins WHERE authid='".$steam_id."'"; $result=mysql_query($check_sql) or die(mysql_error());
if (isset($sb_aid)) { die("{$username} is already in the Sourcebans database.<br /> Aborting. <br /> <a href='../show_donations.php'>Click here to go back</a>"); } else { //if not, PUT EM IN!
$sb_sql = "INSERT INTO `{$SB_DB_NAME}` . `sb_admins` (user,authid,password,gid,extraflags,immunity,srv_group) VALUES ('{$username}', '{$steam_id}', '{$sb_pw}' , '-1' , '0' , '0', '{$srv_group}');"; mysql_query($sb_sql) or die(mysql_error()); $admin_id = mysql_insert_id(); $sb_sql2 = "INSERT INTO `{$SB_DB_NAME}` . `sb_admins_servers_groups` (admin_id,group_id,srv_group_id,server_id) VALUES('{$admin_id}', '{$group_id}', '{$srv_group_id}', '{$server_id}');"; mysql_query($sb_sql2) or die(mysql_error());
if(!$debug){queryServers('sm_reloadadmins');} }
mysql_select_db(DB_NAME) or die("<p>Unable to select the database". DB_NAME . ": ". mysql_error() . "</p>");
$insert_sql="UPDATE `donors` SET `username` = '{$username}', `steam_id` = '{$steam_id}', `sign_up_date` = '{$sign_up_date}', `email` = '{$email}', `renewal_date` = '{$renewal_date}', `current_amount` = '{$current_amount}', `total_amount` = '{$total_amount}', `expiration_date` = '{$expiration_date}', `steam_link` = '{$steam_link}', `notes` = '{$notes}', `activated` = '{$activated}' WHERE `user_id` = '{$user_id}';"; mysql_query($insert_sql) or die("<h1>FAILED TO UPDATE USER</h1><br /><a href='../show_donations.php'>Click here to go back</a></h3>". mysql_error()); break;
case 2:
if(SOURCEBANS){
mysql_select_db($SB_DB_NAME) or die("<p>Unable to select the database". $SB_DB_NAME . ": ". mysql_error() . "</p>"); $check_sql = "SELECT * FROM sb_admins WHERE authid='".$steam_id."'"; $result=mysql_query($check_sql) or die(mysql_error());
if($result){ $row=mysql_fetch_array($result); $admin_id = $row['aid']; $admin_group = $row['srv_group']; }else{die();} if ($admin_group == $srv_group){ $sb_sql = "DELETE FROM `{$SB_DB_NAME}`.`sb_admins` WHERE `sb_admins`.`authid` ='" . $steam_id ."'"; mysql_query($sb_sql) or die(mysql_error()); $sb_sql2 = "DELETE FROM `{$SB_DB_NAME}`.`sb_admins_servers_groups` WHERE `admin_id` ='" . $admin_id ."'"; mysql_query($sb_sql2) or die(mysql_error());
if(!$debug){queryServers('sm_reloadadmins');} }else{ die("<h1> {$username} is not in the {$srv_group} group, {$username} is in the {$admin_group} group.<br />Aborting.<hr /><h3><a href='../show_donations.php'>Click here to go back</a></h3></h1>"); } } mysql_select_db(DB_NAME) or die("<p>Unable to select the database". DB_NAME . ": ". mysql_error() . "</p>"); $insert_sql="UPDATE `donors` SET `username` = '{$username}', `steam_id` = '{$steam_id}', `sign_up_date` = '{$sign_up_date}', `email` = '{$email}', `renewal_date` = '{$renewal_date}', `current_amount` = '{$current_amount}', `total_amount` = '{$total_amount}', `expiration_date` = '{$expiration_date}', `steam_link` = '{$steam_link}', `notes` = '{$notes}', `activated` = '{$activated}' WHERE `user_id` = '{$user_id}';"; mysql_query($insert_sql) or die("<h1>FAILED TO UPDATE USER</h1><br /><a href='../show_donations.php'>Click here to go back</a></h3>". mysql_error());
break;
default: //if user was never initially activated, yell at admin. print("<script type='text/javascript'>"); print("alert('Y NO PERKS!??!?!?! \\n Going back to edit page');"); print("history.go(-1);"); print("</script>"); $goBack = false; break; }
also sorts users by expiration date now
next update will have a login system so you no longer need htaccess, and ill do the prefix support.
Nice update, just need to point out nineteeneleven that when it gets to 2014 it puts it up the top with expiration date, not at the bottom. Thanks again
if (strlen($sign_up_date) != 8 || strlen($expiration_date) != 8) { die("<h3> Please check your dates, you must use the DD/MM/YY format</h3>". "<br /><a href='javascript:history.go(-1);'>Click here to go back</a></h3>"); }
// Get User Profile Data $xml = @simplexml_load_file($steam_link . "/?xml=1") or die("<h3>Sorry we were unable to get your Steam ID.". "<br />Either you entered an invalid Steam ID, or the Steam community is down.". "<br />Please check and make sure you entered a valid Steam ID and try again." . "<br /><a href='javascript:history.go(-1);'>Click here to go back</a></h3>"); if(!empty($xml)) { $username = $xml->steamID; }
if (isset($user_id)) { die("<p>This user is already in the database</p><br /><p><a href='javascript:history.go(-1);'>Click here to go back</a></p>"); exit(); } else { $insert_sql = "INSERT INTO donors (username,steam_id,sign_up_date,renewal_date,current_amount,total_amount,expiration_date,steam_link,email,notes,activated) VALUES ('{$username}', '{$steam_id}', '{$sign_up_date}', '{$renewal_date}','{$current_amount}','{$total_amount}','{$expiration_date}','{$steam_link}','{$email}','{$notes}','{$activated}');"; } mysql_query($insert_sql) or die("<h1>FAILED TO UPDATE USER</h1><br /><a href='javascript:history.go(-1);'>Click here to go back</a></h3>". mysql_error()); //insert/remove user from sourcebans database
if(SOURCEBANS){ mysql_select_db($SB_DB_NAME) or die("<p>Unable to select the database". $SB_DB_NAME . ": ". mysql_error() . "</p>"); $sb_pw = "1fcc1a43dfb4a474abb925f54e65f426e932b59e"; } switch ($activated) { case 1: mysql_select_db($SB_DB_NAME) or die("<p>Unable to select the database". $SB_DB_NAME . ": ". mysql_error() . "</p>"); //check sourcebans database to see if user is already in there $check_sql = "SELECT * FROM sb_admins WHERE authid='".$steam_id."'"; $result=mysql_query($check_sql) or die(mysql_error());
if (isset($sb_aid)) { die("{$username} is already in the Sourcebans database.<br /> Aborting. <br /> <a href='../show_donations.php'>Click here to go back</a>"); } else { //if not, PUT EM IN!
$sb_sql = "INSERT INTO `{$SB_DB_NAME}` . `sb_admins` (user,authid,password,gid,extraflags,immunity,srv_group) VALUES ('{$username}', '{$steam_id}', '{$sb_pw}' , '-1' , '0' , '0', '{$srv_group}');"; mysql_query($sb_sql) or die(mysql_error()); $admin_id = mysql_insert_id(); $sb_sql2 = "INSERT INTO `{$SB_DB_NAME}` . `sb_admins_servers_groups` (admin_id,group_id,srv_group_id,server_id) VALUES('{$admin_id}', '{$group_id}', '{$srv_group_id}', '{$server_id}');"; mysql_query($sb_sql2) or die(mysql_error());
if(!$debug){queryServers('sm_reloadadmins');} }
mysql_select_db(DB_NAME) or die("<p>Unable to select the database". DB_NAME . ": ". mysql_error() . "</p>");
$insert_sql="UPDATE `donors` SET `username` = '{$username}', `steam_id` = '{$steam_id}', `sign_up_date` = '{$sign_up_date}', `email` = '{$email}', `renewal_date` = '{$renewal_date}', `current_amount` = '{$current_amount}', `total_amount` = '{$total_amount}', `expiration_date` = '{$expiration_date}', `steam_link` = '{$steam_link}', `notes` = '{$notes}', `activated` = '{$activated}' WHERE `user_id` = '{$user_id}';"; mysql_query($insert_sql) or die("<h1>FAILED TO UPDATE USER</h1><br /><a href='../show_donations.php'>Click here to go back</a></h3>". mysql_error()); break;
case 2:
if(SOURCEBANS){
mysql_select_db($SB_DB_NAME) or die("<p>Unable to select the database". $SB_DB_NAME . ": ". mysql_error() . "</p>"); $check_sql = "SELECT * FROM sb_admins WHERE authid='".$steam_id."'"; $result=mysql_query($check_sql) or die(mysql_error());
if($result){ $row=mysql_fetch_array($result); $admin_id = $row['aid']; $admin_group = $row['srv_group']; }else{die();} if ($admin_group == $srv_group){ $sb_sql = "DELETE FROM `{$SB_DB_NAME}`.`sb_admins` WHERE `sb_admins`.`authid` ='" . $steam_id ."'"; mysql_query($sb_sql) or die(mysql_error()); $sb_sql2 = "DELETE FROM `{$SB_DB_NAME}`.`sb_admins_servers_groups` WHERE `admin_id` ='" . $admin_id ."'"; mysql_query($sb_sql2) or die(mysql_error());
if(!$debug){queryServers('sm_reloadadmins');} }else{ die("<h1> {$username} is not in the {$srv_group} group, {$username} is in the {$admin_group} group.<br />Aborting.<hr /><h3><a href='../show_donations.php'>Click here to go back</a></h3></h1>"); } } mysql_select_db(DB_NAME) or die("<p>Unable to select the database". DB_NAME . ": ". mysql_error() . "</p>"); $insert_sql="UPDATE `donors` SET `username` = '{$username}', `steam_id` = '{$steam_id}', `sign_up_date` = '{$sign_up_date}', `email` = '{$email}', `renewal_date` = '{$renewal_date}', `current_amount` = '{$current_amount}', `total_amount` = '{$total_amount}', `expiration_date` = '{$expiration_date}', `steam_link` = '{$steam_link}', `notes` = '{$notes}', `activated` = '{$activated}' WHERE `user_id` = '{$user_id}';"; mysql_query($insert_sql) or die("<h1>FAILED TO UPDATE USER</h1><br /><a href='../show_donations.php'>Click here to go back</a></h3>". mysql_error());
break;
default: //if user was never initially activated, yell at admin. print("<script type='text/javascript'>"); print("alert('Y NO PERKS!??!?!?! \\n Going back to edit page');"); print("history.go(-1);"); print("</script>"); $goBack = false; break; }
as far as the ordering goes, I used SQL to do the ordering. it gonna be a pain in the balls to change because I will need to change the way that the dates are stored in the database to fix it.
Well you should convert them to DATE/DATETIME fields or UNIX timestamps anyway if you want to properly deal with dates. STR_TO_DATE() will convert your existing dates easily.