<?
include "header.php";
if(isset($_POST['user_task'])) { $user_task = $_POST['user_task']; } elseif(isset($_GET['user_task'])) { $user_task = $_GET['user_task']; } else { $user_task = "main"; }
if(isset($_POST['u_id'])) { $u_id = $_POST['u_id']; } elseif(isset($_GET['u_id'])) { $u_id = $_GET['u_id']; } else { exit; }
if(isset($_POST['task'])) { $task = $_POST['task']; } elseif(isset($_GET['task'])) { $task = $_GET['task']; } else { $task = "main"; }
if(isset($_POST['page'])) { $page = $_POST['page']; } elseif(isset($_GET['page'])) { $page = $_GET['page']; } else { $page = 1; }
if(isset($_POST['o'])) { $o = $_POST['o']; } elseif(isset($_GET['o'])) { $o = $_GET['o']; } else { $o = "u"; }
$user_info = mysql_fetch_assoc(mysql_query("SELECT * FROM ims WHERE u_id='$u_id'"));

$header = "
<html>
<head>
<title>Image Management System - Administration Panel</title>
<META HTTP-EQUIV='Pragma' CONTENT='no-cache'>
<link rel='STYLESHEET' type='text/css' href='../styles.css'>
<script language='javascript'>
<!--
function redirect() {
window.opener.location.href('users_pending.php?task=$task&page=$page&o=$o');
window.close();
}
// -->
</script>
</head>
<body>

<font style='font-size: 13pt;'><b>Confirm/Reject Pending User</b></font><br>

<table cellpadding='0' cellspacing='0' style='margin-top: 5px;'>
<tr>
<td width='420' style='border: 1px solid #AAAAAA; background: #F5F5F5; padding: 10px;'>

";

$footer = "

</body>
</html>
";




if($user_task == "ban_email") {
$ban_email = $admin_info[ban_email].",$user_info[email]";
mysql_query("UPDATE ims_admin SET ban_email='$ban_email'");
$admin_info = mysql_fetch_assoc(mysql_query("SELECT * FROM ims_admin"));
}



if($user_task == "ban_ip") {
$ban_ip = $admin_info[ban_ip].",$user_info[IP]";
mysql_query("UPDATE ims_admin SET ban_ip='$ban_ip'");
$admin_info = mysql_fetch_assoc(mysql_query("SELECT * FROM ims_admin"));
}


if($user_task == "unban_email") {
$ban_email = explode(",", $admin_info[ban_email]);
$new_ban_email = "";
$last_email = "yes";
for($i=0;$i<count($ban_email);$i++) {
if($ban_email[$i] != $user_info[email]) {
if($last_email == "no") { $new_ban_email .= ","; }
$new_ban_email .= "$ban_email[$i]";
}}
mysql_query("UPDATE ims_admin SET ban_email='$new_ban_email'");
$admin_info = mysql_fetch_assoc(mysql_query("SELECT * FROM ims_admin"));
}



if($user_task == "unban_ip") {
$ban_ip = explode(",", $admin_info[ban_ip]);
$new_ban_ip = "";
$last_ip = "yes";
for($i=0;$i<count($ban_ip);$i++) {
if($ban_ip[$i] != $user_info[IP]) {
if($last_ip == "no") { $new_ban_ip .= ","; }
$new_ban_ip .= "$ban_ip[$i]";
}}
mysql_query("UPDATE ims_admin SET ban_ip='$new_ban_ip'");
$admin_info = mysql_fetch_assoc(mysql_query("SELECT * FROM ims_admin"));
}



if($user_task == "reject") {
 if(str_replace(" ", "", $u_id) != "") { @deleteuse("../u/$u_id"); }
 mysql_query("DELETE FROM ims WHERE u_id='$u_id'");
 mysql_query("DELETE FROM ims_image WHERE u_id='$u_id'");
 mysql_query("DELETE FROM ims_folders WHERE u_id='$u_id'");
 if($admin_info[den_email] == "yes") {
 $den_sub = str_replace("&#39;", "'", stripslashes($admin_info[den_sub]));
 $den_message = str_replace("&#39;", "'", stripslashes($admin_info[den_message]));
 $den_message = str_replace("[email]", "$user_info[email]", $den_message);
 $den_sub = str_replace("[email]", "$user_info[email]", $den_sub);
 $den_message = str_replace("[password]", "$user_info[password]", $den_message);
 $den_sub = str_replace("[password]", "$user_info[password]", $den_sub);
 $fname = str_replace("&#39;", "'", $user_info[fname]);
 $lname = str_replace("&#39;", "'", $user_info[lname]);
 $den_message = str_replace("[name]", "$fname $lname", $den_message);
 $den_sub = str_replace("[name]", "$fname $lname", $den_sub);
 mail($user_info[email], $den_sub, $den_message, "From: $admin_info[email]");
 }
 echo $header;
 echo "
 <center>
 The user <b>\"$user_info[email]\"</b> has been rejected.<br><br>
 <input class='button' type='submit' value='Close Window' onClick=\"redirect()\">
 </center>
 ";
 echo $footer;
 exit;
}



if($user_task == "confirm") {
 $newurl = "http".($_SERVER['HTTPS']=="on"?"s":"")."://".$_SERVER['SERVER_NAME'].strrev(substr(strstr(strrev("$_SERVER[PHP_SELF]"),"/"), 6));
 $login_url = $newurl."index.php";
 mysql_query("UPDATE ims SET is_approved='yes' WHERE u_id='$u_id'");
 if($admin_info[appr_email] == "yes") {
 $appr_sub = str_replace("&#39;", "'", stripslashes($admin_info[appr_sub]));
 $appr_message = str_replace("&#39;", "'", stripslashes($admin_info[appr_message]));
 $appr_message = str_replace("[email]", "$user_info[email]", $appr_message);
 $appr_sub = str_replace("[email]", "$user_info[email]", $appr_sub);
 $appr_message = str_replace("[password]", "$user_info[password]", $appr_message);
 $appr_sub = str_replace("[password]", "$user_info[password]", $appr_sub);
 $fname = str_replace("&#39;", "'", $user_info[fname]);
 $lname = str_replace("&#39;", "'", $user_info[lname]);
 $appr_message = str_replace("[name]", "$fname $lname", $appr_message);
 $appr_sub = str_replace("[name]", "$fname $lname", $appr_sub);
 $appr_message = str_replace("[url]", "$login_url", $appr_message);
 $appr_sub = str_replace("[url]", "$login_url", $appr_sub);
 mail($user_info[email], $appr_sub, $appr_message, "From: $admin_info[email]");
 }
 echo $header;
 echo "
 <center>
 The user <b>\"$user_info[email]\"</b> has been approved.<br><br>
 <input class='button' type='submit' value='Close Window' onClick=\"redirect()\">
 </center>
 ";
 echo $footer;
 exit;
}




$plan_info = mysql_fetch_assoc(mysql_query("SELECT * FROM ims_plans WHERE p_id='$user_info[plan]'"));
$extensions = explode(",", $user_info[ext_list]);
$day_difference = time() - $user_info[last_login];
$banned_users_email = explode(",", $admin_info[ban_email]);
$banned_users_ip = explode(",", $admin_info[ban_ip]);
if(in_array($user_info[email], $banned_users_email) | (in_array($user_info[IP], $banned_users_ip) & $user_info[IP] != "")) {
$status = "Banned";
} elseif($user_info[account_active] != "yes") {
$status = "Disabled";
} elseif($day_difference >= ($admin_info[inactivity] * 86400)) {
$status = "Inactive";
} else {
$status = "Active";
}

echo $header;
echo "

<b>User ID:</b>&nbsp; $user_info[u_id]<br>
<b>Email (username):</b>&nbsp; $user_info[email] "; if(in_array($user_info[email], $banned_users_email)) { echo "<a href='user_info_pending.php?user_task=unban_email&u_id=$u_id&task=$task&page=$page&o=$o'>(Un-Ban Email)</a>"; } else { echo "<a href='user_info_pending.php?user_task=ban_email&u_id=$u_id&$user_task&task=$task&page=$page&o=$o'>(Ban Email)</a>"; } echo "<br>
<b>Signup Date:</b>&nbsp; ".date("F d, Y h:ia", timezone($user_info[signup_date]))."<br>
<b>Status:</b>&nbsp; Pending<br>
<b>Plan:</b>&nbsp; $plan_info[plan]<br>
<b>IP Address (at signup date):</b>&nbsp; $user_info[IP] "; if(in_array($user_info[IP], $banned_users_ip) & $user_info[IP] != "") { echo "<a href='user_info_pending.php?user_task=unban_ip&u_id=$u_id&task=$task&page=$page&o=$o'>(Un-Ban IP)</a>"; } else { echo "<a href='user_info_pending.php?user_task=ban_ip&u_id=$u_id&$user_task&task=$task&page=$page&o=$o'>(Ban IP)</a>"; } echo "<br>
<b>Password:</b>&nbsp; $user_info[password]<br>
<b>First Name:</b>&nbsp; $user_info[fname]<br>
<b>Last Name:</b>&nbsp; $user_info[lname]<br>
<b>Extentions:</b>&nbsp;";
if(in_array("jpg", $extensions)) { echo " jpg"; }
if(in_array("jpeg", $extensions)) { echo " jpeg"; }
if(in_array("gif", $extensions)) { echo " gif"; }
if(in_array("bmp", $extensions)) { echo " bmp"; }
if(in_array("png", $extensions)) { echo " png"; }
if(in_array("pdf", $extensions)) { echo " pdf"; }
echo "
<br>
<b>Space Available:</b>&nbsp; $user_info[space_avail]MB<br>
<b>Max. Folders:</b>&nbsp; $user_info[folders_avail]<br>
<b>Bandwidth Allotted:</b>&nbsp; $user_info[bandwidth_allotted]MB<br>
<b>Max. Size of Uploaded File:</b>&nbsp; $user_info[max_filesize]KB<br>

</td></tr></table>

<br>

<table cellpadding='0' cellspacing='0'>
<form action='user_info_pending.php' method='POST'>
<tr>
<td>
<input type='hidden' name='u_id' value='$u_id'>
<input type='hidden' name='user_task' value='confirm'>
<input type='hidden' name='task' value='$task'>
<input type='hidden' name='page' value='$page'>
<input type='hidden' name='o' value='$o'>
<input class='button' type='submit' value='Confirm User'>&nbsp;
</td>
</form>
<form action='user_info_pending.php' method='POST'>
<td>
<input type='hidden' name='u_id' value='$u_id'>
<input type='hidden' name='user_task' value='reject'>
<input type='hidden' name='task' value='$task'>
<input type='hidden' name='page' value='$page'>
<input type='hidden' name='o' value='$o'>
<input class='button' type='submit' value='Reject User'>&nbsp;
</td>
<td>
<input class='button' type='submit' value='Cancel' onClick=\"redirect()\">
</td>
</tr>
</form>
</table>
";
echo $footer;




?>