<?php
include("../includes/site_config.php");
include('../session_handler.inc');
include('../error.php');
include('../imagesizer.php');
include('../message.php');
include('../includes/functions.php');
include('paginate.php');
$pathh = $skin->Path; 
include('../ajax.js');
include('../lib/lib.Functions.php');
$area='member';
$option_manager = new OptionManager();
$CONST_MAIL = $option_manager->GetValue('mail'); 

//$vidcount=$option_manager->GetValue('video_count');
$youcount=$option_manager->GetValue('youtube_count'); 
 

include_once __INCLUDE_CLASS_PATH."/class.DB.php";

$db = new DB();


include("../includes/tab_functions.js");
$mode=$_GET['mode'];

$chkPrivateyou='N';

if($_REQUEST['chkPrivateyou']=='Y'){

 $chkPrivateyou='Y' ;
}
if($_REQUEST['chkPrivateyou']=='N'){

 $chkPrivateyou='N' ;
}
##############
# Deleting Youtube Video
###########

if(isset($_REQUEST['chkRemoveyou'])){
$chkRemoveyou=form_get('chkRemoveyou');
$quePic=mysql_fetch_object(mysql_query("
										 SELECT * from youtube
										 LEFT JOIN members on(you_userid=mem_userid) 
										 where you_id='$chkRemoveyou'
									"));
										 
	mysql_query("DELETE from youtube WHERE you_id = '".form_get('chkRemoveyou')."'") or die(mysql_error());
	
	send_mail ("$quePic->mem_email", "$CONST_MAIL", "$CONST_COMPANY ".YOU_REJ, MAIL_UNAPPROVEDYOU,$type,"ON");

}

#####

if(isset($_REQUEST['youApp'])){
$youApp=form_get('youApp');
mysql_query("Update youtube set approved='1' WHERE you_id = '$youApp'");
$quePic=mysql_fetch_object(mysql_query("
										 SELECT * from youtube
										 LEFT JOIN members on(you_userid=mem_userid) 
										 where you_id='$youApp'
									"));
		send_mail ("$quePic->mem_email", "$CONST_MAIL", "$CONST_COMPANY ".YOU_APP, MAIL_APPROVEDYOU,$type,"ON");
								
}


$ret=mysql_query("select * from youtube where approved='0'");
$noyou=mysql_num_rows($ret);
//$ret_you=mysql_fetch_object($ret);

//$you_count =$db->get_var("SELECT count(*) FROM youtube WHERE you_userid=$Sess_UserId");

###############@@@@@@@
# End of Youtube Code
######################

$Sess_UserId = $_SESSION['Sess_UserId'];
$Sess_UserName = $_SESSION['Sess_UserName'];

# select advert data

$result = mysql_query("SELECT * FROM adverts WHERE adv_userid=$Sess_UserId",$link);

$TOTAL = mysql_num_rows($result);

# if nothing is returned then show error otherwise get data

if ($TOTAL < 1) {

    $error_message=PRGPICADMIN_ERROR1;

    error_page($error_message,GENERAL_USER_ERROR);

}


$area = 'member';
?>

<?php include("include/header.php"); ?>

<script type="text/javascript" src="wmvplayer/silverlight.js"></script>
<script type="text/javascript" src="wmvplayer/player.js"></script>

<?php include('approve_menu.php'); ?>

<div class="mainwidth">
<div class="admin-page-header"><div class="admin-page-heading">&nbsp;&nbsp;Approve Youtube</div></div>
<div class="clear"></div>
<div class="admin-page">
<table width="680" align="<?php print("$CONST_TABLE_ALIGN"); ?>" border="0" cellspacing="0" cellpadding="0">
<!-- 
<div class="admin-head"><?=AWAITING_APP?>:</div>-->
  <tr>

    <td>
	

       <? if($noyou<1){?>
	   <table width="100%"  border="0" cellpadding="<?php print("$CONST_SUBTABLE_CELLPADDING"); ?>" cellspacing="<?php print("$CONST_SUBTABLE_CELLSPACING"); ?>"><tr><td>&nbsp;</td>
 <td  align="left"> <font color="#CC0000" size="+2">Nothing To Approve!</font></td>

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

          </tr></table>

<? }?>

        
<br style="clear:both" />
<input type='hidden' name='type' value='v'>

   
<?
	$i=0;
	echo "<br style=clear:both>";	
while($ret_you=mysql_fetch_object($ret)){ 
if(($i%5)==0)
	{
	print "<br style=clear:both>";
}?>
<table border="0" cellpadding="5" cellspacing="5" align="left"><tr>
<td  align="left"><input type="image" src="<?=$SKIN_IMAGE_PATH?>/you.png" border="0"  align="absmiddle" value='<?=$ret_you->you_id?>' onClick='toggle_youApp(this.value);' name='My Youtube' width='100'/><br><a onClick="javascript:return confirm('Are you sure you want to DELETE')" href="<?=$_SERVER['PHP_SELF']?>?chkRemoveyou=<?=$ret_you->you_id ?>&mode=amend&type=av">Delete</a>|<a href='<?=$_SERVER['PHP_SELF']?>?youApp=<?=$ret_you->you_id?>&mode=amend&type=av'>Approve</a></td></tr>   </table>


<?  $i++;}
?>

<br style="clear:both" />
<table border="0"><tr><td>
<div id='you_div'  align='center' style='font-size: 10px;font-weight: bold;color:#0066FF'> </div>
</td></tr></table>
</td></tr>

<tr><td align="right"><? //echo $pager->renderNext(); ?></td></tr>
<!--Code ends here-->
 </table></div><div class="admin-page-bottom"></div></div>

<!--Approved Youtube codes starts here-->
<!---->
<!---->
<br />
<br />
<div class="mainwidth">
<div class="admin-page-header"><div class="admin-page-heading">&nbsp;&nbsp;<?=APPR_YOU?></div></div>
<div class="clear"></div>
<div class="admin-page">
<table width="680" align="<?php print("$CONST_TABLE_ALIGN"); ?>" border="0" cellspacing="0" cellpadding="0">



  <tr>

    <td>
	

       
 <? 
 $uCount =$db->get_var("SELECT count(*) FROM youtube WHERE approved='1'");

 
 if($uCount<1){?>
 <table width="100%"  border="0" cellpadding="<?php print("$CONST_SUBTABLE_CELLPADDING"); ?>" cellspacing="<?php print("$CONST_SUBTABLE_CELLSPACING"); ?>"><tr><td>&nbsp;</td>
 <td  align="left"> <font color="#CC0000" size="+2">Nothing has been Approved yet!</font></td>
 <td align="center"></td>

          </tr></table>
<? }?>

        
<br style="clear:both" />
<input type='hidden' name='type' value='v'>

   
<?
$rsQuery="select * from youtube where approved='1'";

$record_per_page='20';

$pager = new PS_Pagination($link,$rsQuery,$record_per_page,5);

$rs = $pager->paginate();


	$i=0;
	echo "<br style=clear:both>";	
while($youTube=mysql_fetch_object($rs)){ 
if(($i%5)==0)
	{
	print "<br style=clear:both>";
}?>
<table border="0" cellpadding="5" cellspacing="5" align="left"><tr>
<td  align="left"><a href="#playYou"><input type="image" src="<?=$SKIN_IMAGE_PATH?>/you.png" border="0"  align="absmiddle" value='<?=$youTube->you_id?>' onClick='toggle_youApproved(this.value);' name='My Youtube' width='100'/></a><br><? if($DEMO==false){?><a onClick="javascript:return confirm('Are you sure you want to DELETE')" href="<?=$_SERVER['PHP_SELF']?>?chkRemoveyou=<?=$youTube->you_id ?>&mode=amend&type=av">Delete</a><? }?><!--|<a href='<?=$_SERVER['PHP_SELF']?>?youApp=<?=$youTube->you_id?>&mode=amend&type=av'>Approve</a>--></td></tr>	</table>


<?  $i++;}
?>

<br style="clear:both" />
<a name="playYou"><table border="0"><tr><td>
<div id='you_approved'  align='center' style='font-size: 10px;font-weight: bold;color:#0066FF'> </div>
</td></tr></table></a>
</td></tr>

<tr><td align="right"><? echo $pager->renderNext(); ?></td></tr>
<!--Code ends here-->
 </table></div><div class="admin-page-bottom"></div></div>



<!--Code ends here-->
<?php include("include/footer.php"); ?>