<?  
//
//  cP Account Creator Version 0.4 Beta Build 01
//  Copyright (C) 2004 Brian Freeman
//  All Rights Reserved.
//
//  This script set is distributed as is with absolutely no warranty.
//  Users of this script set agree to use at their own risk.
//  Questions or comments?  Contact webmaster@freemans-web.com
//
//



include("../config.php");

$cp_email="$email@$domain";

include("header.php");


?>
<center>
<?


//$conn  = mysql_connect($dbhost, $dbusername, $dbpass) or die(mysql_error( ));
//mysql_select_db($dbname,$conn) or die(mysql_error( ));
$display_block = "<table border=8><tr><td colspan=11><a href=admin.php?view=0>View users awaiting approval</a>&#160;&#160; &#160; <a href=admin.php?view=1>View approved users</a>&#160;&#160;&#160;<a href=view_settings.php>Settings</a>&#160;&#160;&#160;<a href=cust_cont.php>Contact Users</a>
</tr>
<tr><td colspan=11>
<table>
<tr>";
if($net2ftp==1){
  $display_block .="
<td valign=bottom>
<form method=post action=../net2ftp/index.php target=blank>
<input type=hidden name=username value=$ownername>
<input type=hidden name=password value=$reseller_pass>
<input type=hidden name=directory value=/public_html>
<input type=hidden name=ftpserver value=localhost/>
<input type=hidden name=ftpserverport value=21 />
<input type=hidden name=anonymous value=1 />
<input type=hidden name=language value=1 />
<input type=hidden name=skin value=1>
<input type=hidden name=ftpmode value=binary />
<input type=hidden name=state     value=browse />
<input type=hidden name=state2    value=main />
<input type=hidden name=cookieset value= />
<input type=image src=../images/gotodir.gif width=30 height=30 value=File_Manager>
Net2FTP File Manager
</form>
</td>";
}
if($webftp==1){
$display_block .="
               <td valign=bottom>
                   <form method=post action=../webftp/index.php target=_blank>
                   <input type=hidden name=user value=$ownername>
                   <input type=hidden name=password value=$reseller_pass>
                   <input type=image src=../images/gotodir.gif width=30 height=30 value=File_Manager>
                   File Manager
                   </form>
               </td>";
}


if($mpanel==1){
$display_block .="<td valign=bottom>
<form method=post action=../mpanel/login.php target=blank>
<input type=hidden name=username value=$ownername>
<input type=hidden name=password value=$reseller_pass>
<input type=hidden name=host value=localhost>
<input type=image src=../images/db.gif width=30 height=30 value=Database_Edit>
Database Editor
</form>
</td>";
}if($phpmyadmin==1){
  $display_block .="<td valign=bottom>
<form method=post action=../phpmyadmin target=_blank>
<input type=image src=../images/logo_right.png height=30 width=65 value=PHPMyAdmin>
PHPMyAdmin
</form>
</td>";
}
$display_block .="</tr>
</table>
</td>
</tr>
<tr>
<td colspan=11>
<center><font size=5><b>User Admin</b></font></center></td></tr>
<tr><td width=25>ID</td><td width=75>Approve</td><td width=55>User Name</td><td width=150>View Site</td><td width=100>Name</td><td width=200>Alternate Email</td><td width=75>Date</td><td width=60>FTP Stor.</td><td width=60>BW Used</td><td width=50>E-Stor</td></tr>";

$get_items="SELECT * FROM email_users WHERE id>1 && approved='$view'";
$get_items_res=mysql_query($get_items)  or die(mysql_error( ));
if (mysql_num_rows($get_items_res)<1) {
	$display_block .= "<h1>No Records</h1>";

} else {

	while ($items = mysql_fetch_array ($get_items_res)) {
		$cp_id=$items[id];
		$cp_username=$items[username];
		$cp_email=$items[cp_email];
		$cp_sub_dom=$items[sub_domain];
                $act_sub=$items[act_sub];
		$cp_password = $items[password];
		$cp_first_name = $items[first_name];
		$cp_last_name = $items[last_name];
		$alt_email = $items[email];
		$approved=$items[approved];
		$password=$items[raw_pwd];
		$quota=$items[quota];
                $user_ip=$items[user_ip];
                $user_host=$items[user_hostname];
                $date=$items[date];
                


$ck_domain_type=explode(".",$cp_sub_dom);
$domain_type=explode(".",$domain);

if($ck_domain_type[0]==$domain_type[0]){
$dom_type=1;

}else{
$dom_type=0;
}
if($dom_type==1){
  $dir_st=explode($domain,$cp_sub_dom);
  $dir_struct=$dir_st[1];
}

if($dom_type==0){
$dir_struct=$cp_username;

}




if($add_sub==1){
$usr_subdom=explode("$cp_username.",$cp_sub_dom);
$usr_subdomain=$usr_subdom[1];
}
if($add_sub==0){
$usr_subdom=explode("$domain",$cp_sub_dom);
$usr_sub1=explode("$cp_username",$usr_subdom[1]);
$usr_subdomain=$usr_sub1[0];
}




$lnk_first_name=str_replace(" ", "%20", $cp_first_name);
$lnk_last_name=str_replace(" ", "%20", $cp_last_name);

$request="/frontend/$cpmod/diskusage/index.html?showtree=public_html/$dir_struct";
$result=cprq($host,$port,$ownername,$reseller_pass,$request);
$usage_raw_st= strip_tags($result);
$usage_form_st=explode('public_html',$usage_raw_st);
$usage_out_st= str_replace("/$dir_struct", "", $usage_form_st[1]);
$usage_form1_st=explode("Meg",$usage_out_st);

$request="/frontend/$cpmod/stats/bandwidth.html";
$result=cprq($host,$port,$ownername,$reseller_pass,$request);
$usage_raw_bw= strip_tags($result);
$usage_form_bw=explode("$cp_sub_dom",$usage_raw_bw);
$usage_form1_bw=explode("Meg",$usage_form_bw[1]);

$request="/frontend/x/mail/pops.html?extras=disk";
$result=cprq($host,$port,$ownername,$reseller_pass,$request);
$usage_raw_e= strip_tags($result);
$usage_form_e=explode("$cp_username+$domain",$usage_raw_e);
$usage_form1_e=explode("Meg",$usage_form_e[1]);

if($approved==1) {

  if($act_sub==1){
$approve="<a href=functions.php?acct_suspend=1&cp_username=$cp_username&cp_id=$cp_id&cp_sub_dom=$cp_sub_dom>Suspend</a><a href=functions.php?del_pop=1&id=$cp_id&email=$cp_username&domain=$domain><img border=0 src=../images/delete.gif alt=\"Delete User Name\"></a>";
$sub_dom="<a href=http://$cp_sub_dom target=blank>$cp_sub_dom</a>";
$disapprove="";
               }else{
$approve="<a href=functions.php?acct_unsuspend=1&cp_username=$cp_username&password=$password&cp_id=$cp_id&cp_sub_dom=$cp_sub_dom>Unsuspend</a> <a href=functions.php?del_pop=1&id=$cp_id&email=$cp_username&domain=$domain><img border=0 src=../images/delete.gif height=24 width=24 alt=\"Delete User Name\"></a>";
$sub_dom="<a href=http://$cp_sub_dom target=blank>$cp_sub_dom</a>";
$disapprove="";
               }
}else{
$approve="<a href=approve.php?first_name=$lnk_first_name&last_name=$lnk_last_name&alt_email=$alt_email&email=$cp_username&password=$password&quota=$quota&usr_subdomain=$usr_subdomain><img src=../images/yes.gif height=24 width=24 alt=\"Click to Approve\" border=0></a>";
$sub_dom="Not Created Yet";
$disapprove="<a href=functions.php?del_pop=1&id=$cp_id&email=$cp_username&domain=$domain><img src=../images/no.gif alt=\"Click to Disapprove and Delete User\" border=0></a>";
}

$sub_dom="<a href=http://$cp_sub_dom target=blank>$cp_sub_dom</a>";


	$display_block .= "<tr><td><a href=update.php?cp_id=$cp_id>$cp_id</a></td><td><center>$approve$disapprove</center></td><td><a href=http://$domain$script_directory$client_acc?user=$cp_username&pass=$password target=_blank>$cp_username</a></td><td>$sub_dom</td><td>$cp_first_name $cp_last_name</td><td> $alt_email</td><td>$date</td><td>$usage_form1_st[0] M.</td><td>$usage_form1_bw[0] M.</td><td>$usage_form1_e[0] M.</td></tr>";
							}
	}
echo $display_block;
echo "</table>";

?>
<p><table border=8>
  <tr>
  <td colspan=4>
<center><font size=5><b>Banned Admin</b></font></center>
  </td>
  </tr>

  <tr>
  <td colspan=4>
<center>   <a href="view_ban.php" target="blank">View Banned List</a></center>
  </td>
  </tr>


  <tr>
    <td>
        <table>
        <form method="POST" action="functions.php">
              <tr>
                  <td>Ban IP Address</td>
             </tr>
             <tr>
                 <td><input type="text" name="b_entry" > </td>
             </tr>
                  <input type=hidden name=b_field value=banned_ip>
                  <input type=hidden name=banned value=1>
             <tr>
                 <td><input type="submit" value="Add Record"></td>
             </tr>
        </form>
        </table>
    </td>
    <td>
        <table>
        <form method="POST" action="functions.php">
              <tr>
                  <td>Ban Host Name</td>
              </tr>
              <tr>
                   <td><input type="text" name="b_entry" > </td>
                   <input type=hidden name=b_field value=banned_host>
                   <input type=hidden name=banned value=1>
              </tr>
              <tr>
                  <td><input type="submit" value="Add Record"></td>
              </tr>
        </form>
        </table>
    </td>
    <td>
        <table>
        <form method="POST" action="functions.php">
              <tr>
                  <td>Ban Free Email Service</td>
              </tr>
              <tr>
                   <td><input type="text" name="b_entry" > </td>
                   <input type=hidden name=b_field value=free_email>
                   <input type=hidden name=banned value=1>
              </tr>
              <tr>
                  <td><input type="submit" value="Add Record"></td>
              </tr>
        </form>
        </table>
    </td>
    <td>
        <table>
        <form method="POST" action="functions.php">
              <tr>
                   <td>Ban Email Address</td>
              </tr>
              <tr>
                  <td><input type="text" name="b_entry" > </td>
              </tr>
                   <input type=hidden name=b_field value=banned_email>
                   <input type=hidden name=banned value=1>
              <tr>
                   <td><input type="submit" value="Add Record"></td>
              </tr>
        </form>
        </table>
    </td>
  </tr>
</table>
</center>
<?
include("footer.php");
function cprq($host,$port,$ownername,$reseller_pass,$request)  {
global $email,$cpmod;



$sock = fsockopen($host,$port);

if(!$sock)

{

print('Socket error');

exit();

}

$authstr = "$ownername:$reseller_pass";

$pass = base64_encode($authstr);
//$in  = "GET $request\r\n";
$in  = "GET $request\n";

$in .= "HTTP/1.0\r\n";

$in .= "Host:$domain\r\n";

$in .= "Authorization: Basic $pass\r\n";

$in .= "\r\n";





   fputs($sock, $in);

   while (!feof($sock))  {

// fgets ($sock,128);

$result .= fgets ($sock,128);

}

fclose( $sock );

return $result;


}




?>