<?php
require_once ("../config.inc.php");
require_once ("../includes/adminlogincheck.inc.php");
require_once ("../includes/mysql.inc.php");
require_once ("../includes/arrays.inc.php");
require_once "../classes/users.class.php";
require_once ("../classes/miscellaneous.class.php");
require_once ("../includes/Pager/Pager.php");
$message	= "";
$pages		= "";
$data		= array();
$array		= array();
$page		= isset($_REQUEST['page'])	?	trim($_REQUEST['page'])	:	"1";
$flag		= isset($_REQUEST['act'])	?	trim($_REQUEST['act'])	:	"0";

if (!isset($_REQUEST['page'])) {
	$_SESSION['api_search']	= "";
}

if (!$objDB) {
	$message	= "Unable to Locate Database Server.";
} else {
	$objU		= new users($objDB);
	if ($flag == "1") {
		$message	= "<font color='green'>You have successfully saved the details.</font><br>";
	} 
	$array	= $objU->freecode_list();
//	$array		= $objU->get_users();
	$params 	= array(
		'mode'      => 'Sliding',
		'perPage'   => PAGESIZE,
		'urlVar'    => 'page',
		'extraVars' => array(),
		'itemData'  => $array
	);
	$objP 		= & Pager::factory($params);
	$data  		= $objP->getPageData();
	
	if (empty($data))
		$message	.= "No record(s) exists.<br>";
}

include_once('title.inc.php');
?>
<?php include_once('tophtml.php');?>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top" class="white"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="72%" valign="top">
			<table width="100%"  border="0" cellspacing="0" cellpadding="5">
          <tr>
            <td><table width="100%"  border="0" cellspacing="0" cellpadding="5">
              <tr>
                <td width="41%" class="headings1" colspan="2">Free Code Report</td>
              </tr>
            </table>
			<div class="bordernew padding2">
			<table width="100%"  border="0" cellspacing="0" cellpadding="5">
            <tr>
              <td><table width="100%"  border="0" cellspacing="1" cellpadding="0" class="listing_tbl_admin">
				<?php if ($objDB) 
					  { 
                 			if (!empty($data)) 
							{ 
				?>
                <tr align="left">
                  <th align="center" class="maintext2">#</th>
                  <th class="maintext2">Free Code</th>
                  <th class="maintext2">Count</th>
                  </tr>
					<?php 	if(isset($message) && $message!='')
							{
					?>
                <tr align="left">
                  <td align="center" class="maintext2">&nbsp;</td>
                  <td colspan="2" class="maintext2 warning"><?php echo $message;?></td>
                  </tr>
					<?php  	}//end if
							foreach ($data as $key => $value) 
							{ 
				?>
                <tr align="left">
                  <td width="3%" align="center" class="maintext2"><?php echo $key+1;?></td>
                  <td width="65%" class="maintext2"><?php echo htmlspecialchars(stripslashes($value['vCode']))?></td>
                  <td width="32%" class="maintext2"><?php echo $value['vCount']?></td>
                  </tr>
				<?php 			}//end foreach
					 		}//end if
						}//end first if
				?>
              </table>
				<?php if(!empty($data))
					  {
				?>
                <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="82%">&nbsp;</td>
                    <td width="18%"><table width="100%"  border="0" cellspacing="2" cellpadding="0">
                        <tr align="center" class="textbox">
                          <td><?php echo $objP->links;?></td>
                          </tr>
                    </table></td>
                  </tr>
                </table><?php }//end if?>
                <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td align="right">
                      </td>
                  </tr>
                </table></td>
            </tr>
          </table>
			</div>
			</td>
          </tr>
        </table>
          </td>
        </tr>
    </table>      
    </td>
  </tr>
</table>
<?php include_once('bottomhtml.php');?>