<?php
session_start();
//ini_set("display_errors", 1);
include("../includes/site_config.php");
include("../deletes.php");
//include('../session_handler.inc');
include('../ps_pagination.php');
include('../ajax.js');

//include('date_picker.js');
include_once __INCLUDE_CLASS_PATH."/class.ItemManager.php";
include_once __INCLUDE_CLASS_PATH."/class.DB.php";

$db = new DB();


$mode=$_GET['mode'];
$option_manager = new OptionManager();
$sesstime=$option_manager->GetValue('session_exptime');

//echo "<pre>";
//print_r($_REQUEST);
$gra=form_get('gra');
$show=($gra=='sign')? 'Sign Ups' : 'Logins';

$area = 'member';
$Sess_UserType = $_SESSION['Sess_UserType'];
$Sess_UserId = $_SESSION['Sess_UserId'];
$chkRemove=$_REQUEST['chkRemove'];
$srchtxt=form_get('Srchtxt');

$count= count($chkRemove);

######
# Code For Deleting only Profile
######


if($_REQUEST['mode']=="Delete1" && $_REQUEST['delete_id']!=''){

$statusChange=form_get('delete_id');

$adchangevalue=form_get('adchangevalue');
$query="UPDATE adverts SET adv_paused='$adchangevalue' WHERE adv_userid = '$statusChange'";
$result=mysql_query($query,$link) or die(mysql_error());


}
if($_REQUEST['mode'] == "Standerd"){

$stand_id=form_get('stand_id');

$Expire_date='2007'.'-'.'10'.'-'.'10';

  $query="UPDATE members SET mem_expiredate='$Expire_date' WHERE mem_userid='$stand_id'";
    $result=mysql_query($query,$link) or die(mysql_error());           


}

if(isset($_REQUEST['DELETE_PROF'])){

for($i=0;$i<$count;$i++){

$del_id = $chkRemove[$i];

delete_advert($del_id);

}

}


######
# Code For Deleting Member as well as Profile
######

if(isset($_REQUEST['DELETE'])){
//restrict_demo();
for($i=0;$i<$count;$i++){

 $del_id = $chkRemove[$i]; 

	delete_advert($del_id);
	delete_match($del_id);
	delete_me($del_id);


}

}

######
# Code For HIDING Member Profile
######
if (isset($_POST['HIDE_PROF'])) {

for($i=0;$i<$count;$i++){

$hide_id = $chkRemove[$i];

	 $query="UPDATE adverts SET adv_paused='Y' WHERE adv_userid = '$hide_id'";



	$result=mysql_query($query,$link) or die(mysql_error());

}
}

######
# Code For Making member Standard
######

if (isset($_POST['STANDARD'])) {
$Expire_date='2007'.'-'.'10'.'-'.'10';

for($i=0;$i<$count;$i++){

$stand_id = $chkRemove[$i];
  $query="UPDATE members SET mem_expiredate='$Expire_date' WHERE mem_userid='$stand_id'";
    $result=mysql_query($query,$link) or die(mysql_error());           

}
}

######
# Code For Making member Standard
######

if (isset($_POST['Blacklist'])) {
for($i=0;$i<$count;$i++){
$block_ip = $chkRemove[$i];
$ip=mysql_fetch_object(mysql_query("SELECT mem_ip from members where mem_userid='$block_ip'"));
$ipAdd=trim($ip->mem_ip);
		 $query="INSERT ignore into blacklist set blacklist_ip='$ipAdd', black_date=CURDATE()"; 
		 if (! $result=mysql_query($query)) {error_page(mysql_error(),GENERAL_SYSTEM_ERROR);}
		 
	delete_advert($block_ip);
	delete_match($block_ip);
	delete_me($block_ip);     

	}
}



//$Sess_UserType="A";
if ($Sess_UserType != "A") {
?>
  <script language="javascript">
//window.location='<?=$CONST_LINK_ROOT?>/admin/index.php?msg1=inv';
 // header("Location: prgpicadmin.php");
 // exit;
</script>
<?php
}
$query="SELECT COUNT(mem_userid) FROM members";
$retval=mysql_query($query,$link) or die(mysql_error());
$totalreg=mysql_result($retval,0,0);
$query="SELECT COUNT(adv_userid) FROM adverts";
$retval=mysql_query($query,$link) or die(mysql_error());
$totaladv=mysql_result($retval,0,0);
$query = "  SELECT COUNT(blg_approved)
            FROM blogs
                WHERE blg_approved = 'N'";
$retvalblog=mysql_query($query,$link) or die(mysql_error());
$totalpenblog=mysql_result($retvalblog,0,0);

$query = "  SELECT COUNT(art_approved)
            FROM articles
                WHERE art_approved = 'N'";
$retvalart=mysql_query($query,$link) or die(mysql_error());
$totalpenart=mysql_result($retvalart,0,0);
######

$query = "  SELECT COUNT(approved)
            FROM youtube
                WHERE approved = '0'";
$retvalYou=mysql_query($query,$link) or die(mysql_error());
$totalpenyou=mysql_result($retvalYou,0,0);
#######


# Find the gender breakdown
$query="SELECT COUNT(mem_sex) as gender_total, mem_sex FROM members GROUP BY mem_sex";
$retval=mysql_query($query,$link) or die(mysql_error());
while($reg_stats=mysql_fetch_object($retval)) {
        switch ($reg_stats->mem_sex) {
                case 'F':
                        if ($reg_stats->gender_total != 0 && $totalreg != 0) {
                            $width_f=(($reg_stats->gender_total/$totalreg)*100)*2;
                            $f_perc=sprintf("%01.2f", $width_f/2);
                        } else {
						                           $width_f=0;
                            $f_perc=0;
                        }
                        break;
                case 'M':
                        if ($reg_stats->gender_total != 0 && $totalreg != 0) {
                            $width_m=(($reg_stats->gender_total/$totalreg)*100)*2;
                            $m_perc=sprintf("%01.2f", $width_m/2);
                        } else {
                           $width_m=0;
                           $m_perc=0;
                        }
                        break;
                case 'C':
                        if ($reg_stats->gender_total != 0 && $totalreg != 0) {
                           $width_c=(($reg_stats->gender_total/$totalreg)*100)*2;
						     $c_perc=sprintf("%01.2f", $width_c/2);
                        } else {
          $width_c=0;
          $c_perc=0;
       }
       break;
        }
}
# Find the user level status breakdown
$query="SELECT COUNT(mem_expiredate) FROM members WHERE mem_expiredate >= NOW()";
$retval=mysql_query($query,$link) or die(mysql_error());
$totalprem=mysql_result($retval,0,0);
if ($totalprem != 0 && $totalreg != 0) {
    $width_p=(($totalprem/$totalreg)*100)*2;
    $p_perc=sprintf("%01.2f", $width_p/2);
} else {
    $width_p=0;
    $p_perc=0;
}
$query="SELECT COUNT(mem_expiredate) FROM members WHERE mem_expiredate < NOW()";
$retval=mysql_query($query,$link) or die(mysql_error());
$totalstand=mysql_result($retval,0,0);
if ($totalstand != 0 && $totalreg != 0) {
    $width_s=(($totalstand/$totalreg)*100)*2;
    $s_perc=sprintf("%01.2f", $width_s/2);
} else {
    $width_s=0;
    $s_perc=0;
}
# Find the profile status breakdown
$query="SELECT COUNT(adv_approved) FROM adverts WHERE adv_approved = 1";
$retval=mysql_query($query,$link) or die(mysql_error());
$totalapp=mysql_result($retval,0,0);
if ($totalapp != 0 && $totaladv != 0) {
    $width_app=(($totalapp/$totaladv)*100)*2;
    $app_perc=sprintf("%01.2f", $width_app/2);
} else {
    $width_app=0;
    $app_perc=0;
}

//Time operations
$curr_time = time();
$mod_time = $curr_time - BLOCK_PERIOD_AVAILABLE;
$modified_time = date("Y-m-d H:i:s", $mod_time);
//EOF Time operations
#################
$query = "  SELECT COUNT(com_approved)
            FROM profile_comment
                WHERE com_approved = '0'";
$retval=mysql_query($query,$link) or die(mysql_error());
$totalpencomment=mysql_result($retval,0,0);

#################


include_once __INCLUDE_CLASS_PATH."/class.Gallery.php";
$gallery= new Gallery();
$totalpengallery = $gallery->CountPendingItem();
//$query = "  SELECT COUNT(adv_approved)

//            FROM adverts

//                LEFT JOIN members ON (adv_userid=mem_userid)


//            WHERE adv_approved = 0 AND mem_confirm = 1 AND block_time <= '$modified_time'";


$query = "  SELECT COUNT(adv_approved)

            FROM adverts

                LEFT JOIN members ON (adv_userid=mem_userid)

            WHERE adv_approved = 0 AND mem_confirm = 1";

$retval=mysql_query($query,$link) or die(mysql_error());

$totalpen=mysql_result($retval,0,0);

if ($totalpen != 0 && $totaladv != 0) {

    $width_pen=(($totalpen/$totaladv)*100)*2;

    $pen_perc=sprintf("%01.2f", $width_pen/2);


} else {

    $width_pen=0;

    $pen_perc=0;

}


$query="SELECT COUNT(adv_approved) FROM adverts WHERE adv_approved = 2";

$retval=mysql_query($query,$link) or die(mysql_error());


$totalrej=mysql_result($retval,0,0);

if ($totalrej != 0 && $totaladv != 0) {

    $width_rej=(($totalrej/$totaladv)*100)*2;

    $rej_perc=sprintf("%01.2f", $width_rej/2);


} else {

    $width_rej=0;

    $rej_perc=0;

}


# Find the mail confirmation breakdown

$query="SELECT COUNT(mem_confirm) FROM members WHERE mem_confirm = 1";

$retval=mysql_query($query,$link) or die(mysql_error());

$totalcon=mysql_result($retval,0,0);

if ($totalcon != 0 && $totalreg != 0) {

    $width_con=(($totalcon/$totalreg)*100)*2;

    $con_perc=sprintf("%01.2f", $width_con/2);

} else {


    $width_con=0;

    $con_perc=0;

}


$query="SELECT COUNT(mem_confirm) FROM members WHERE mem_confirm = 0";







$retval=mysql_query($query,$link) or die(mysql_error());



$totaluncon=mysql_result($retval,0,0);



if ($totalcon != 0 && $totalreg != 0) {



    $width_uncon=(($totaluncon/$totalreg)*100)*2;

    $uncon_perc=sprintf("%01.2f", $width_uncon/2);



} else {

    $width_uncon=0;


    $uncon_perc=0;


}

$query="SELECT COUNT(ev_approved) FROM events WHERE ev_approved=0";


$retval=mysql_query($query,$link) or die(mysql_error());

$totalevapproved=mysql_result($retval,0,0);

$query="SELECT COUNT(review_approved) FROM reviews WHERE review_approved=0";
$retval=mysql_query($query,$link) or die(mysql_error());
$totalreviewapproved=mysql_result($retval,0,0);

$query="SELECT COUNT(mem_userid) FROM members where mem_sex='M'";
$retsex=mysql_query($query,$link) or die(mysql_error());
$totalsexm=mysql_result($retsex,0,0);

$query="SELECT COUNT(mem_userid) FROM members where mem_sex='F'";
$retsex=mysql_query($query,$link) or die(mysql_error());
$totalsexf=mysql_result($retsex,0,0);

$time=time();
$timeout = time()-$sesstime*60;
$query="SELECT COUNT(mem_userid) FROM members where timestamp > $timeout";
$reton=mysql_query($query,$link) or die(mysql_error());
$totalon=mysql_result($reton,0,0);

$query="SELECT COUNT(pic_id) FROM pictures";
$retpic=mysql_query($query,$link) or die(mysql_error());
$totalpic=mysql_result($retpic,0,0);

$count_app=$db->get_var("select count(*) from adverts where adv_picture!='templates/default/images/genericm.gif' AND adv_picture!='templates/default/images/genericf.gif' AND adv_imageappr='0'");


$query="SELECT COUNT(pic_id) FROM pictures LEFT JOIN members ON(pic_userid=mem_userid) where approved='0' and mem_confirm!='0'";
$retpicapp=mysql_query($query,$link) or die(mysql_error());
$totalpicapp=mysql_result($retpicapp,0,0);


$query="SELECT COUNT(msg_id) FROM messages";
$retmes=mysql_query($query,$link) or die(mysql_error());
$totalmes=mysql_result($retmes,0,0);

$query="SELECT COUNT(vid_id) FROM videos";
$retvid=mysql_query($query,$link) or die(mysql_error());
$totalvid=mysql_result($retvid,0,0);

$count_vid=$db->get_var("select count(*) from videos where approved='0'");

$count_you=$db->get_var("select count(*) from youtube where approved='0'");
$count_you=$count_vid;

$query="SELECT COUNT(msg_id) FROM messages where msg_title='Someone is flirting with you.'";
$retflrt=mysql_query($query,$link) or die(mysql_error());
$totalflrt=mysql_result($retflrt,0,0);

$query="SELECT COUNT(ev_eventid) FROM events";
$retevent=mysql_query($query,$link) or die(mysql_error());
$totalevent=mysql_result($retevent,0,0);

$query="SELECT COUNT(news_id) FROM news";
$retnews=mysql_query($query,$link) or die(mysql_error());
$totalnews=mysql_result($retnews,0,0);

$query="SELECT COUNT(story_id) FROM stories";
$retstory=mysql_query($query,$link) or die(mysql_error());
$totalstory=mysql_result($retstory,0,0);

$query="SELECT COUNT(aud_id) FROM audios where approved='0'";
$retaudio=mysql_query($query,$link) or die(mysql_error());
$totalaudio=mysql_result($retaudio,0,0);

$query="SELECT * from adverts where adv_bio!='' AND bio_approved=0";
$rettbio=mysql_query($query,$link) or die(mysql_error());
$totalbio=mysql_num_rows($rettbio);

$query="SELECT * from essay_answers where approved='0'";
$retess=mysql_query($query,$link) or die(mysql_error());
$totaless=mysql_num_rows($retess);

?>
<head>
<script language="JavaScript" type="text/JavaScript">
function F_check_picker(var_obj)
{
show_calendar(var_obj);

}
function searchByAddedCost(k)
{

document.member.action='index.php?searchby='+k;
document.member.submit();


}


<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0

  window.open(theURL,winName,features);
  return false;
}
//-->





</script>


<script src="<?=$CONST_LINK_ROOT?>/admin/date_picker.js" type="text/javascript"></script>



<style type="text/css">
<!--
#apDiv1 {
	position:absolute;
	left:599px;
	top:169px;
	width:509px;
	height:126px;
	z-index:1;
}
.style2 {
	font-size: 24px;
	font-family: Verdana, Arial, Helvetica, sans-serif;
}
-->
</style>
</head>
<!--<body onLoad="toggle_graph('sign');">-->
<body>


<div align="center">
  <?php
if($Sess_UserType!='A'){  ?>
  
  <? include("include/login_header.php");?>
  
  
</div>
<form name="form1" method="post" action="<?=$CONST_LINK_ROOT?>/complete_login.php?area=adm" onSubmit="return validate();">

<div align="center"><br>
    <br>
</div>
<div align="center"><br>
    
  <br>
  <span class="logo style2"><b><?php echo $CONST_COMPANY?></b> Admin Area</span><br>
</div><br><br>
<?  


											if($_GET['msg1']=='inv')
											{?>
											<DIV align=center>
						<!--<HR align="left" color=#c0c0c0 SIZE=0>-->
						<font color="#FF0000">Invalid login information</font><BR>
						<!--<HR align="left" color=#c0c0c0 SIZE=0>-->
					</DIV><?
											}?>
<table background="images/wazzum_admin_login_background.jpg" border="0" cellspacing="6" cellpadding="4" align="center" style="background-repeat:no-repeat"><tr><td colspan="2">

	
        <!--DWLayoutTable-->
       <!-- <tr> 
          <td width="14" height="1"></td>
          <td width="88"></td>
          <td width="91"></td>
          <td width="79"></td>
          <td width="19"></td>
        </tr>-->
</td></tr>
        <tr> 
          <td colspan="2" valign="top"><strong><font color="#000000" size="3">Administrator 
            Login</font></strong></td>
    </tr>
        
        <tr> 
		<td valign="top"><strong>Username:</strong></td>
          <td valign="top"><input type="text" id="txtname" name="WUsername"></td>
        </tr>
        <tr> <td valign="top"><strong>Password:</strong></td>
          <td valign="top"><input type="password" id="txtpwd" name="WPassword" /></td>
        </tr>
        <tr> 
          <td  align="left" valign="middle">
          <input type=checkbox name="save"<?php if(isset($HTTP_COOKIE_VARS[WUsername_c])) echo ' checked' ?> />
          Remember me</td>
          <td valign="top"><input type="submit" name="Submit" value="Login"></td>
        </tr><tr> 
          <td></td>
          <td></td>
        </tr>
    </table></div><p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>

</form>


<p style="margin:0">
  <?php include("include/login_footer.php"); ?>
</p>

<p>
  
  
  <? } else {?>
  
  
  <?php include("include/header.php"); ?>
  <!--<table width="100%" align="<?php //print("$CONST_TABLE_ALIGN"); ?>" border="0" cellspacing="<?php //print("$CONST_TABLE_CELLSPACING"); ?>" cellpadding="<?php //print("$CONST_TABLE_CELLPADDING"); ?>">-->
</p>




<table width="102%"  align="right" border="0" cellspacing="0" cellpadding="0">
<script type="text/javascript" src="../jquery.js"></script>

<script>


	//function DeleteMembers()
//{
//  
//   var hasSelected = false;
//
//  
//   var members = document.member.elements['chkRemove[]'];
//
//  
//   for( var n = 0; n < members.length; n++ )
//   {
//       if( members[n].checked )
//           hasSelected = true;
//   }
//   
//   if( hasSelected )
//   {  
//       var r=confirm( "Are you sure you want to delete selected Member(s)?" );
//	   if(r==true )
//       {  
//	   
//	   return true; 
//           /*for( var n = 0; n < members.length; n++ )
//           {
//               if( members[n].checked )
//                   confirm( members[n].value );
//           }*/
//       }
//	   else{
//	   return false;
//}
//	   }
//   else
//   {  
//       alert( "Please select at least one Member to delete." );
//	   return false;
//   }
//}



$(document).ready(function()
{
$("#delete").click(function()
{
if (!isCheckedById("selector"))
{
alert ("Please select at least one Member to Delete");
return false;
}

else
{
var r=confirm( "Are you sure you want to delete selected Member(s)?" );
	   if(r==true )
       {  
	   return true; 
       }
else{
	   return false;
}//submit the form
}
});

$("#profile").click(function()
{
if (!isCheckedById("selector"))
{
alert ("Please select at least one selector");
return false;
}

else
{
return true; //submit the form
}
});


$("#standard").click(function()
{
if (!isCheckedById("selector"))
{
alert ("Please select at least one selector");
return false;
}

else
{
return true; //submit the form
}
});


$("#blacklist").click(function()
{

if (!isCheckedById("selector"))
{
alert ("Please select at least one Member to Block!");
return false;
}

else if($("input[@id="+blacklist+"]:checked").length>1)
{
alert ("Please select only one Member to Block!");
return false;
}
else
{

var r=confirm( "Are you sure you want to Block selected Member(s)?" );
	   if(r==true )
       {  
	   return true; 
       }
else{
	   return false;
}//submit the form
}
});

function isCheckedById(id)
{
var checked = $("input[@id="+id+"]:checked").length;
if (checked == 0)
{
return false;
}
else
{
return true;
}
}
});



</script>



<!--DWLayoutTable
<tr>
 <td width="100%" align="right">DWLayoutEmptyCell&nbsp; </td>
 </tr>
 <tr><td class="pageheader">Administration Area</td>
  </tr>-->
  
<tr><td align="center"> <div class="mainwidth">
<div class="admin-page-header"><div class="admin-page-heading">&nbsp;&nbsp;Admin Dashboard</div></div>
<div class="clear"></div>
<div class="admin-page">
<table width="680px"  border="0" cellspacing="0" cellpadding="0">
<tr> <td>
       <!--DWLayoutTable

       <tr> 

          <td height="0" align="center" ></td>

        </tr>

        <tr valign="top"> 

 
         <td align="left" ><table width="100%"  border="0" cellspacing="<?php //print("$CONST_SUBTABLE_CELLSPACING"); ?>" cellpadding="<?php //print("$CONST_SUBTABLE_CELLPADDING"); ?>">-->
		 
<form enctype='multipart/form-data' method="post" name="member" action="<?php $_SERVER[PHP_SELF] ?>">
<table width="600" border="0" cellspacing="2" cellpadding="0" style="padding-top:20x" align="center">
  <tr>
    <td class="pageheader" width="200px"><strong>Awaiting Approval</strong></td>
    <td class="pageheader" width="200px"><b>Quick Stats</b></td>
    <td class="pageheader" width="200px" class="pageheader"><b>Demographics</b></td>
  </tr>
<tr>
  </tr>
  <tr>
    <td><img src="<?=$CONST_LINK_ROOT?>/admin/images/user_48.png" width="20" height="20">&nbsp;<font color="#0066FF"><a href="<?php echo $CONST_LINK_ROOT?>/admin/approve_profiles.php<?php print("?PHPSESSID=".session_id()); ?>&mode=start"><?php  print("$totalpen"); ?></a></font>&nbsp;Members</td>
    <td><font color="#0066FF"><img src="<?=$CONST_LINK_ROOT?>/admin/images/heart_48.png" alt="" width="20" height="20">&nbsp;
        <?php  print("$totalflrt"); ?>
    </font>&nbsp;Flirts Sent</td>
    <td><font color="#0066FF"><img src="<?=$CONST_LINK_ROOT?>/admin/images/members_content_48.png" alt="" width="20" height="20">&nbsp;
        <?php  print("$totalreg"); ?>
    </a></b></font>&nbsp;Members</td>
  </tr>
  <tr>
    <td><img src="<?=$CONST_LINK_ROOT?>/admin/images/image_add_48.png">&nbsp;<font color="#0066FF"><b><a href="<?php echo $CONST_LINK_ROOT?>/admin/approve_media.php<?php print("?PHPSESSID=".session_id()); ?>"><?php  print("$totalpengallery"); ?></a></b></font>&nbsp;Galleries</td>
    <td><font color="#0066FF"><img src="<?=$CONST_LINK_ROOT?>/admin/images/online_48.png" alt="" width="20" height="20">&nbsp;
    <?php  print("$totalon"); ?></font>&nbsp;Online</td>
    <td><font color="#0066FF"><img src="<?=$CONST_LINK_ROOT?>/admin/images/male_content_48.png" alt="" width="20" height="20">&nbsp;
        <?php  print("$totalsexm"); ?>
    </font>&nbsp;Males</td>
  </tr>
  <tr>
    <td><img src="<?=$CONST_LINK_ROOT?>/admin/images/comment_48.png" width="20" height="20">&nbsp;<font color="#0066FF"><b><a href="<?php echo $CONST_LINK_ROOT?>/admin/approve_comments.php<?php print("?PHPSESSID=".session_id()); ?>"><?php  print("$totalpencomment"); ?></a></b></font>&nbsp;Comments</td>
    <td><font color="#0066FF"><img src="<?=$CONST_LINK_ROOT?>/admin/images/photos_content_48.png" alt="" width="20" height="20">&nbsp;
    <?php  print("$totalpic"); ?></font>&nbsp;Photos</td>
    <td><font color="#0066FF"><img src="<?=$CONST_LINK_ROOT?>/admin/images/female_content_48.png" alt="" width="20" height="20">&nbsp;
        <?php  print("$totalsexf"); ?>
    </font>&nbsp;Females</td>
  </tr>
  <tr>
  <td><img src="<?=$CONST_LINK_ROOT?>/admin/images/camera_48.png" width="20" height="20">&nbsp;<font color="#0066FF"><b><a href="<?php echo $CONST_LINK_ROOT?>/admin/approve_pictures.php<?php print("?PHPSESSID=".session_id()); ?>&type=ap"><?php  print("$totalpicapp"); ?></a></b></font>&nbsp;Photos</td>
   <!--  <td><font color="#0066FF"><b><a href="<?php echo $CONST_LINK_ROOT?>/admin/events.php"><?php  print("$totalevapproved"); ?></a></b></font>&nbsp;Events -->
    <td><font color="#0066FF"><img src="<?=$CONST_LINK_ROOT?>/admin/images/video_48.png" alt="">&nbsp;
    <?php  print("$totalvid"); ?></font>&nbsp;Videos</td>
    <td><font color="#0066FF"><img src="<?=$CONST_LINK_ROOT?>/admin/images/couples_content_48.png" alt="" width="20" height="20">&nbsp;&nbsp;&nbsp;0</font>&nbsp;Couples</td>
  </tr>
  <tr>
     <td><img src="<?=$CONST_LINK_ROOT?>/admin/images/audio_content_48.png" alt="" width="20" height="20"><font color="#0066FF"><b><a href="<?php echo $CONST_LINK_ROOT?>/admin/approve_audio.php<?php print("?PHPSESSID=".session_id()); ?>&type=ap">
       <?php  print("$totalaudio"); ?>
     </a></b></font>Audio</td> 
     <td><font color="#0066FF"><img src="<?=$CONST_LINK_ROOT?>/admin/images/newspaper_48.png" alt="" width="20" height="20">&nbsp;
    <?php  print("$totalnews"); ?></font>&nbsp;News</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><img src="<?=$CONST_LINK_ROOT?>/admin/images/bio_content_48.png" alt="" width="20" height="20">&nbsp;<font color="#0066FF"><b><a href="<?php echo $CONST_LINK_ROOT?>/admin/approve_bio.php<?php print("?PHPSESSID=".session_id()); ?>&type=ap"><?php  print("$totalbio"); ?>
    </a></b></font>Bio</td>
    <td><font color="#0066FF"><img src="<?=$CONST_LINK_ROOT?>/admin/images/stories_content.png" alt="" width="20" height="20">&nbsp;
    <?php  print("$totalstory"); ?></font>&nbsp;Stories</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><font color="#0066FF">
      <img src="<?=$CONST_LINK_ROOT?>/admin/images/video_48.png" alt="" width="20" height="20">
      <a href="<?=$CONST_LINK_ROOT?>/admin/approve_videos.php<?php print("?PHPSESSID=".session_id()); ?>&type=vid"><?php  print("$count_you"); ?></a>
    </font>Videos</td>
	
    <td><font color="#0066FF">
      <img src="<?=$CONST_LINK_ROOT?>/admin/images/emails_sent_48.png" alt="" width="20" height="20">&nbsp;
      <?php  print("$totalmes"); ?>
    </font>&nbsp;Emails Sent</td>
    <td>&nbsp;</td>
  </tr>
   <tr>
    <td><font color="#0066FF">
      <img src="<?=$CONST_LINK_ROOT?>/admin/images/approve_blogs.png" alt="" width="20" height="20">
      <a href="<?php echo $CONST_LINK_ROOT?>/admin/approve_blogs.php<?php print("?PHPSESSID=".session_id()); ?>&mode=start"><?php  print("$totalpenblog"); ?></a>
    </font>Blogs</td>
	
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><font color="#0066FF">
      <img src="<?=$CONST_LINK_ROOT?>/admin/images/generic_articles.png" alt="" width="20" height="20">
      <a href="<?php echo $CONST_LINK_ROOT?>/admin/approve_articles.php<?php print("?PHPSESSID=".session_id()); ?>&mode=start"><?php  print("$totalpenart"); ?></a>
    </font>Articles</td>
	
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><font color="#0066FF">
      <img src="<?=$CONST_LINK_ROOT?>/admin/images/admin_youtube.png" alt="" width="20" height="20">
      <a href="<?php echo $CONST_LINK_ROOT?>/admin/approve_youtube.php<?php print("?PHPSESSID=".session_id()); ?>&mode=start"><?php  print("$totalpenyou"); ?></a>
    </font>Youtube</td>
	
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><font color="#0066FF"> 
      <img src="<?=$CONST_LINK_ROOT?>/admin/images/admin_essay.png" alt="" width="20" height="20">
      <a href="<?php echo $CONST_LINK_ROOT?>/admin/approve_essays.php<?php print("?PHPSESSID=".session_id()); ?>"><?php  print("$totaless"); ?></a>
    </font>Essay</td>
	
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>


</table><br><br><br>
<table>

<?php 

$tendayz = time() - (14 * 24 * 60 * 60);
        
$tendayz= date('Y-m-d', $tendayz);

function OutputImage($img1) 
{
	
	imagejpeg($img1, 'simplegraph.jpg', 100);
}
 $curDate=date('Y-m-d');

$query=mysql_query("select * from member_stats where statDate >= '$tendayz' ORDER BY statDate");
/*$query = mysql_query(
					"SELECT * 
					FROM member_stats
					WHERE DATE_SUB(CURDATE() , INTERVAL 13 
					DAY ) 
					ORDER BY statDate"
					); */



function associative_push($arr, $tmp) {
  if (is_array($tmp)) {
    foreach ($tmp as $key => $value) { 
      $arr[$key] = $value;
    }
    return $arr;
  }
  return false;
}


function change2dmy($date)
{
$dtmp = explode("-",$date);
$dadate = mktime(0,0,0,$dtmp[1],$dtmp[2],$dtmp[0]);
return date("m-d",$dadate);
}

	while($statGraph=mysql_fetch_object($query))
    {
	  $StDat=change2dmy($statGraph->statDate);
	  if($gra=='sign'){
	  $StCount=$statGraph->counter_sign;	
	  }else{
	  $StCount=$statGraph->counter;	
	  }
        $myArr = array("$StDat" => "$StCount"); 
		$values = associative_push($values, $myArr);
       
    } 
# Graph code starts 	

	$img_width=600;
	$img_height=200; 
	$margins=20;

 
	
	$graph_width=$img_width - $margins * 2;
	$graph_height=$img_height - $margins * 2; 
	$img=imagecreate($img_width,$img_height);

 
	$bar_width=20;
	$total_bars=count($values);
	$gap= ($graph_width- $total_bars * $bar_width ) / ($total_bars +1);

 
	
	$bar_color=imagecolorallocate($img,0,64,128);
	$background_color=imagecolorallocate($img,240,240,255);
	$border_color=imagecolorallocate($img,200,200,200);
	$line_color=imagecolorallocate($img,220,220,220);
 	
	
	imagefilledrectangle($img,1,1,$img_width-2,$img_height-2,$border_color);
	imagefilledrectangle($img,$margins,$margins,$img_width-1-$margins,$img_height-1-$margins,$background_color);

 
	
	$max_value=max($values);
	$ratio= $graph_height/$max_value;

 
	
	$horizontal_lines=20;
	$horizontal_gap=$graph_height/$horizontal_lines;

	for($i=1;$i<=$horizontal_lines;$i++){
		$y=$img_height - $margins - $horizontal_gap * $i ;
		imageline($img,$margins,$y,$img_width-$margins,$y,$line_color);
		$v=intval($horizontal_gap * $i /$ratio);
		imagestring($img,0,5,$y-5,$v,$bar_color);

	}
 
 
	
	for($i=0;$i< $total_bars; $i++){ 
		
		list($key,$value)=each($values); 
		$x1= $margins + $gap + $i * ($gap+$bar_width) ;
		$x2= $x1 + $bar_width; 
		$y1=$margins +$graph_height- intval($value * $ratio) ;
		$y2=$img_height-$margins;
		imagestring($img,0,$x1+3,$y1-10,$value,$bar_color);imagestring($img,0,$x1+3,$img_height-15,$key,$bar_color);		
		imagefilledrectangle($img,$x1,$y1,$x2,$y2,$bar_color);
	}
	OutputImage($img);
	
	//header("Content-type:image/png");
	//imagepng($img);
	
# graph code ends	
	
?>
<div class="pageheader">&nbsp;&nbsp;<?=$show?></div>
<tr><td><div align="right"><a href="<?=$_SERVER['PHP_SELF']?>?gra=sign">Sign Up</a> - <a href="<?=$_SERVER['PHP_SELF']?>">Login</a></div><img src="simplegraph.jpg"></td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td></tr>
</table>
<table width="300" border="0" cellspacing="2" cellpadding="0">
<font color="#094e89" size="3"><b>Member Search:</b></font><br>
  <tr>
    <input name="Srchtxt" type="text" size="70" value="<? echo $srchtxt;?>">
<!--	<input type="hidden" name="Srchtxt" value="<? echo $srchtxt;?>"> -->
  </tr>
  <tr>
    <td align="left"><input type="submit" class="normal" name="Username" value="Username Search" ></td>

    <td align="left"><input type="submit" class="normal" name="Email" value="Email Search" ></td>
    <td align='left'><input type="submit" class="normal" name="Userid" value="UserID Search" ></td>
  </tr>
</table>


<table width="100%"  border="0" cellspacing="0" cellpadding="0">
              <!--DWLayoutTable-->

             <?php /*?> <tr> 

                <td width="161" height="19" valign="top" class="normal"><a href="<?=$CONST_LINK_ROOT?>/admin/admin_tools.php">Tools</a></td>

                <td width="1024">&nbsp;</td>
              </tr>

              <tr> 

                <td height="19" valign="top" class="normal"><a href="<?=$CONST_LINK_ROOT?>/admin/admin_settings.php">Settings</a></td>

                <td>&nbsp;</td>
              </tr>

              <tr> 

                <td height="19" valign="top" class="normal"><a href="<?=$CONST_LINK_ROOT?>/admin/admin_reports.php">Reports</a></td>

                <td>&nbsp;</td>
              </tr>

              <tr> 

                <td height="19" valign="top" class="normal"><!--<a href="<?=$CONST_LINK_ROOT?>/admin/index.php">Admin 

                  Home</a>--></td>

                <td>&nbsp;</td>
              </tr>--><?php */?>

              <tr>
                <td colspan="2">&nbsp;</td>
              </tr>
              <tr>
                <td colspan="2">
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td>&nbsp;</td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                  </tr>
                  <tr>
                    <td align="right"><div style="border:0px solid #cccccc; padding:5px; width:680px">
					  <div align="center">				      </div>
						
						
					  <table width="100%" cellspacing="0" cellpadding="5" border="1" bordercolor="#cccccc" style="border-collapse:collapse; border-color:#CCCCCC">
  <tr>
    <td bgcolor="#F1F1F1" width="25px">&nbsp;</td>
  <!--  <td bgcolor="#CCCCCC" width="35px"><div align="center"><font color="#0066FF"><b>ID</b></font></div></td>-->
    <td bgcolor="#F1F1F1" width="112px"><div align="center"><font color="#094E89"><b>Username </b></font></div></td>
    <td bgcolor="#F1F1F1" width="112px"><div align="center"><font color="#094E89"><b>Email </b></font></div></td>
   <!-- <td bgcolor="#CCCCCC" width="73px"><div align="center"><font color="#0066FF"><b>Registered </b></font></div></td>-->
    <td bgcolor="#F1F1F1"><div align="center"><font color="#094E89"><b>Last Visited </b></font></div></td>
	<td bgcolor="#F1F1F1"><div align="center"></div></td>
	<td bgcolor="#F1F1F1"><div align="center"><font color="#094E89"></font></div></td>
	<td bgcolor="#F1F1F1"><div align="center"></div></td>
	<td bgcolor="#F1F1F1"><div align="center"></div></td>
	<td bgcolor="#F1F1F1"><div align="center"></div></td>
  </tr>
  <?php  


 $Sess_Userlevel =$_SESSION['Sess_Userlevel'];
$link=mysql_connect($CONST_DB_HOST,$CONST_DB_USER,$CONST_DB_PASS);

$db=mysql_select_db($CONST_DB_NAME,$link);
if(isset($_REQUEST['Username']))
{
$mem = "select mem_userid, mem_username, mem_email, mem_lastvisit, mem_ip from members where mem_username LIKE '$srchtxt%' ";
}
elseif(isset($_REQUEST['Email']))
{
$mem = "select mem_userid, mem_username, mem_email, mem_lastvisit, mem_ip from members where mem_email='$srchtxt' ";
}
elseif(isset($_REQUEST['Userid']))
{
$mem = "select mem_userid, mem_username, mem_email, mem_lastvisit, mem_ip from members where mem_userid='$srchtxt' ";
}
else
{
  $mem = "select mem_userid, mem_username, mem_email, mem_lastvisit, mem_ip from members order by mem_userid ";
  }
  
  
$pager = new PS_Pagination($link,$mem,10,5);
$rs = $pager->paginate();
if(mysql_num_rows($rs)==0)
  {?>
  <br><DIV align=center>
				
					<font color="#0066FF" size="+1">No Records Found!</font><BR>
<HR width="70%" class="line">
					</DIV>
  
 <? }
$x=1;
while($mem_list=mysql_fetch_array($rs)){
$query="SELECT adv_userid,adv_picture, adv_paused, adv_approved FROM adverts WHERE adv_userid='$mem_list[mem_userid]'";

$retval=mysql_query($query,$link) or die(mysql_error());

$got_photo = mysql_fetch_object($retval);

if ($got_photo->adv_paused == 'Y') {

	$adstatus=MY_AD_STATUS_PAUSED;

	$adpausedval='N'; // opposite value for updating

} else{//if  ($got_photo->adv_paused == 'N') {

	$adstatus=MY_AD_STATUS_VISIBLE;

	$adpausedval='Y'; // opposite value for updating

} 
/*else {

	$adstatus=MY_AD_STATUS_NONE;

	$adpausedval=''; // opposite value for updating

}*/
  ?>
  
  <tr>
    <td><div align="center">
    
      <input type="checkbox" name="chkRemove[]"  id="selector" value="<? echo $mem_list[mem_userid]; ?>" />
      
    </div></td>
    <!--<td><div align="center"><? //echo $mem_list[mem_userid]; ?></div></td>-->
    <td style="cursor:pointer"><span title="<? echo $mem_list['mem_ip']; ?>"><? echo $mem_list[mem_username]; ?></span></td>
    <td><? echo $mem_list[mem_email]; ?></td>
    <!--<td>Y<? //echo $mem_list[mem_userid]; ?></td>-->
	<? $change_to_timestamp = strtotime($mem_list[mem_lastvisit]);
	$new_date = date("M j, Y",$change_to_timestamp); ?>
    <td><? echo $new_date;?></td>
	<td align="center"> 
	<!--href="javascript:F_check_picker('member.cal<?=$x?>','1')"-->
<? if($DEMO==false){?><a href="javascript:;" 
onclick="MM_openBrWindow('change_password.php?mem_id=<?=md5($mem_list[mem_userid])?>','','width=350,height=300'); border=0"><? } else{?><a href="javascript:;" 
onclick="alert('Not allowed in demo mode')"><? }?>
<img title="Change Password" src="<?=$CONST_LINK_ROOT?>/templates/default/images/pass_key.gif" border="0" width="15" height="15">
</a></td>
	
	<td align="center"> 
	<!--href="javascript:F_check_picker('member.cal<?=$x?>','1')"-->
<a href="javascript:;" 
onclick="MM_openBrWindow('UpdMemExp_date.php?mem_id=<?=$mem_list[mem_userid]?>','','width=200,height=200'); border=0">
<img onMouseOver="window.status='Date Picker';return true;" title="Select Date From Calendar" onMouseOut="window.status='';return true;" src="<?=$CONST_LINK_ROOT?>/templates/default/images/b_calendar.png" border="0">
</a></td>
	
	<td align="center"><a href="javascript:;" 
onclick="MM_openBrWindow('email_member.php?mail_mem=<?=$mem_list[mem_userid]?>','','width=500,height=350');"><img src="<?=$CONST_LINK_ROOT?>/templates/default/images/newmail.gif" width="15" height="15" alt="Email the Member" border="0" /></a></td>
	<td align="center">
	<!--<a href="javascript:;" 
onclick="MM_openBrWindow('approve_profiles.php?mode=EDIT&edit_mem=<?=$mem_list[mem_userid]?>','','width=500,height=400,scrollbars=yes');"><img src="<?=$CONST_LINK_ROOT?>/templates/default/images/edit.png" width="15" height="15" alt="Edit Member" border="0" /></a>-->
	
	<a href="approve_profiles.php?mode=EDIT&edit_mem=<?=$mem_list[mem_userid]?>"><img src="<?=$CONST_LINK_ROOT?>/templates/default/images/edit.png" width="15" height="15" alt="Edit Member" border="0" /></a>
	</td>
	<td align="center"><? if($DEMO==false){?><a href="index.php?mode=Delete1&delete_id=<?=$mem_list[mem_userid]?>&adchangevalue=<?=$adpausedval?> "><?=$adstatus?></a><? }else{?>Demo<? }?></td>

	
	
  </tr>
  <? $x++; } echo "<b>Total Result:</b>"." ".$pager->total_rows." ". "<b>Pages:</b>"." ".$pager->max_pages;?>&nbsp;
<? echo $pager->renderFullNav(); ?>
</table>
<? echo $pager->renderFullNav(); ?>
					</div></td>
                  </tr>
				  <tr><td colspan="7">
				  <table cellpadding="0" cellspacing="0" border="0" width="100%">
				  <? if($DEMO==false){?><tr><br>
<td align='center'  class="normal"><input type="submit" name="DELETE" value="Delete" class="normal" id="delete" ></td>
<td  align='center'><input type="submit" name="DELETE_PROF" value="Remove Profile" class="normal"  id="profile" onClick="javascript:return confirm('Are you sure you want to DELETE this profile?')" ></td>
<!--<td  align='center'><input type="submit" name="HIDE_PROF" value="Hide Profile" class="normal" onClick="javascript:return confirm('Are you sure you want to HIDE this profile?')" ></td>-->
<td  align='center'><input type="submit" name="STANDARD" value="Make Standard" class="normal" id="standard" onClick="javascript:return confirm('Are you sure you want to make these member Standard Member?')"></td><td align="center"><input type="submit" name="Blacklist" id="blacklist" class="normal" value="Blacklist" ></td> 
</tr><? } else {?>
<tr><br>
<td align='center'  class="normal"><input type="button" name="DELETE" value="Delete" class="normal"title="Won't work in demo mode!" ></td>
<td  align='center'><input type="button" name="DELETE_PROF" value="Remove Profile" class="normal"  onClick="javascript:return confirm('Are you sure you want to DELETE this profile?')" title="Won't work in demo mode!"></td>
<!--<td  align='center'><input type="submit" name="HIDE_PROF" value="Hide Profile" class="normal" onClick="javascript:return confirm('Are you sure you want to HIDE this profile?')" ></td>-->
<td  align='center'><input type="button" name="STANDARD" value="Make Standard" class="normal"  onClick="javascript:return confirm('Are you sure you want to make these member Standard Member?')" title="Won't work in demo mode!"></td><td align="center"><input type="button" name="Blacklist"  class="normal" value="Blacklist" title="Won't work in demo mode!" ></td> 
</tr>
<? }?>

</form>

</table></td></tr></table></td></tr>
</table></td>
  </tr>
</table></div><div class="admin-page-bottom"></div></div>
<br>
<div class="mainwidth">
<div class="admin-page-header"><div class="admin-page-heading">&nbsp;&nbsp;Wazzum Blog Feed</div></div>
<div class="clear"></div>
<div class="admin-page">
 <table width="680px" border="0" cellspacing="0" cellpadding="0">

<tr><td>&nbsp;</td> <td>&nbsp;</td></tr>
<tr><td>&nbsp;</td> <td>&nbsp;</td></tr>
<tr>
    <td class="normal" align="left">
  <?php
include("../rss/wazzum_rss.php");
?></td> 
     <td>&nbsp;</td>
   </tr>
</table></div><div class="admin-page-bottom"></div></div>
</body>
<?php include("include/footer.php"); } ?>
