Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php ?><?php /* *********************************************************************..
Decoded Output download
<?php ?><?php
/*
*************************************************************************
* *
* Enet Online Solutions - KenPesa Addons Module *
* All Rights Reserved 2012, Illegal redistribution is prohibited *
* Last Modified: 20th November 2012 *
* Last Modified: 23th December 2014 *
* *
* Email: [email protected] *
* Website: http://www.enetonlinesolutions.net *
*************************************************************************
*/
if (!defined("WHMCS")) die("This file cannot be accessed directly");
function kenpesapb_config() {
$configarray = array("name" => "Ken-Pesa (PB) V.1.3", "version" => "1.3", "author" => "<a href='https://www.enetonlinesolutions.co.ke' target='_blank'>Enet Online Solutions</a>", "language" => "english", "description" => "This modules (Pay Bill Option) allows you configure the Ken-PESA Gateway and view all the MPESA payment Transactions. ", "fields" => array("mpesano" => array("FriendlyName" => "Pay Bill/Till No", "Type" => "text", "Size" => "25", "Description" => "Enter your MPESA Pay Bill Business No/Lipa Na MPESA Till No that clients will use to make MPESA payments"), "mpesatype" => array("FriendlyName" => "A/C Type", "Type" => "dropdown", "Options" => "Pay Bill No,Lipa Na MPESA", "Description" => "Choose the MPESA A/C Type", "Default" => "Pay Bill No",), "username" => array("FriendlyName" => "API Username", "Type" => "text", "Size" => "25", "Description" => "You must provide Safaricom with this username for them to set it in your IPN. <br><i>Leave blank to disable (Not Recommended)</i>"), "pass" => array("FriendlyName" => "API Password", "Type" => "password", "Size" => "25", "Description" => "You must provide Safaricom with this password for them to set it in your IPN. <br><i>Leave blank to disable (Not Recommended)</i>"), "licensekey" => array("FriendlyName" => "Licence Key", "Type" => "text", "Size" => "25", "Description" => "Enter your Licence from your clientarea. Any questions? Visit <a href='http://www.enetonlinesolutions.co.ke/portal/clients/clientarea.php' target='_blank'>www.enetonlinesolutions.co.ke</a>. Call (254) 726 872 512"), "autoapply" => array("FriendlyName" => "Auto-Apply payment to invoice", "Type" => "yesno", "Size" => "25", "Description" => "Tick this option to Auto Add Payment to invoice and send Invoice Payment Confirmation. You can purchase our SMS module to notify the client on Auto registrations/renewal."), "opentran" => array("FriendlyName" => "Re-Open Transaction", "Type" => "yesno", "Size" => "25", "Description" => "Tick this option to allow changing the status of closed or archived transaction to Open."), "archivetran" => array("FriendlyName" => "Archive Transaction", "Type" => "yesno", "Size" => "25", "Description" => "Tick this option to allow archiving of transactions before deleting."), "closetran" => array("FriendlyName" => "Close Transactions", "Type" => "yesno", "Size" => "25", "Description" => "Tick this option to allow closing Pay Bill Payment Transactions."), "deletetran" => array("FriendlyName" => "Payments", "Type" => "yesno", "Size" => "25", "Description" => "Tick this option to allow deleting Pay Bill Payment Transactions."), "archdays" => array("FriendlyName" => "Auto-archive", "Type" => "text", "Size" => "8", "Description" => "No of days after IPN Date to Auto-Archive your transactions. Leave blank to disable."), "deldays" => array("FriendlyName" => "Auto-Delete", "Type" => "text", "Size" => "8", "Description" => "No of days after Archive Date to Auto-delete your transactions. Leave blank to disable."), "debug" => array("FriendlyName" => "Debug On", "Type" => "yesno", "Size" => "25", "Description" => "Tick to Enable debug (Systems Module log)."),));
return $configarray;
}
function kenpesapb_activate() {
# Create Custom DB Table
$query = "CREATE TABLE IF NOT EXISTS tblpbtransactions (
id varchar(100) NOT NULL,
orig varchar(20) NOT NULL,
dest varchar(100) NOT NULL,
tstamp TIMESTAMP NOT NULL,
`text` varchar(255) NOT NULL,
mpesa_code varchar(50) NOT NULL,
mpesa_acc varchar(100) NOT NULL,
mpesa_msisdn varchar(100) NOT NULL,
mpesa_trx_date varchar(100) NOT NULL,
mpesa_trx_time varchar(100) NOT NULL,
mpesa_amt int(11) NOT NULL,
mpesa_sender varchar(100) NOT NULL,
`status` varchar(10) NOT NULL DEFAULT 'Open',
invoiceid int(11) NOT NULL DEFAULT '0',
`archivedate` DATETIME NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY mpesa_code (mpesa_code)
)";
$result1 = full_query($query);
$result2 = full_query("CREATE TABLE IF NOT EXISTS `mod_kenpesa` (
`localkey` text NOT NULL,
`status` varchar(100) NULL
)");
$localkey = '9tjIxIzNwgDMwIjI6gjOztjIlRXYkt2Ylh2YioTO6M3OicmbpNnblNWasx1cyVmdyV2ccNXZsVHZv1GX
zNWbodHXlNmc192czNWbodHXzN2bkRHacBFUNFEWcNHduVWb1N2bExFd0FWTcNnclNXVcpzQioDM4ozc
7ISey9GdjVmcpRGZpxWY2JiO0EjOztjIx4CMuAjL3ITMioTO6M3OiAXaklGbhZnI6cjOztjI0N3boxWY
j9Gbuc3d3xCdz9GasF2YvxmI6MjM6M3Oi4Wah12bkRWasFmdioTMxozc7ISeshGdu9WTiozN6M3OiUGb
jl3Yn5WasxWaiJiOyEjOztjI3ATL4ATL4ADMyIiOwEjOztjIlRXYkVWdkRHel5mI6ETM6M3OicDMtcDM
tgDMwIjI6ATM6M3OiUGdhR2ZlJnI6cjOztjIlNXYlxEI5xGa052bNByUD1ESXJiO5EjOztjIl1WYuR3Y
1R2byBnI6ETM6M3OicjI6EjOztjIklGdjVHZvJHcioTO6M3Oi02bj5ycj1Ga3BEd0FWbioDNxozc7ICb
pFWblJiO1ozc7IyUD1ESXBCd0FWTioDMxozc7ISZtFmbkVmclR3cpdWZyJiO0EjOztjIlZXa0NWQiojN
6M3OiMXd0FGdzJiO2ozc7pjMxoTY8baca0885830a33725148e94e693f3f073294c0558d38e31f844
c5e399e3c16a';
$encoded_status = base64_encode('Inactive');
$result3 = full_query("INSERT INTO `mod_kenpesa` (localkey,status) VALUES ('{$localkey}','{$encoded_status}')");
if ($result1 && $result2 && $result3) {
return array('status' => 'success', 'description' => 'Thank you for activating Ken-Pesa (PB) Module.');
} else {
return array('status' => 'error', 'description' => 'We apoligize that an error occurred while activating Ken-Pesa (PB) Module.');
}
}
function kenpesapb_deactivate() {
# Remove Custom DB Table
$query = "DROP TABLE IF EXISTS `tblpbtransactions`";
// $result1 = full_query($query);
$result2 = full_query("DROP TABLE IF EXISTS `mod_kenpesa`");
if ($result1 && $result2) {
return array('status' => 'success', 'description' => 'We regret to see that you have disabled Ken-Pesa (PB) Module.');
} else {
return array('status' => 'error', 'description' => 'We apoligize that an error occurred while de-activating Ken-Pesa (PB) Module.');
}
}
function kenpesapb_upgrade($vars) {
$version = $vars['version'];
# Run SQL Updates for V1.0 to V1.1
if ($version < 1.0) {
$query = "ALTER TABLE `tblpbtransactions` CHANGE `tstamp` `tstamp` TIMESTAMP NOT NULL";
$result = full_query($query);
$query = "ALTER TABLE `tblpbtransactions` ADD `archivedate` DATETIME NOT NULL AFTER `status`";
$result = full_query($query);
}
if ($version < 1.2) {
full_query("CREATE TABLE IF NOT EXISTS `mod_kenpesa` (
`localkey` text NOT NULL,
`status` varchar(100) NULL
)");
}
}
function kenpesapb_output($vars) {
$version = $vars['version'];
$opentran = $vars['opentran'];
$archivetran = $vars['archivetran'];
$closetran = $vars['closetran'];
$deletetran = $vars['deletetran'];
$IPN_URL = !empty($GLOBALS['CONFIG']['SystemSSLURL']) ? $GLOBALS['CONFIG']['SystemSSLURL'] : $GLOBALS['CONFIG']['SystemURL'];
$IPN_URL.= "/modules/gateways/callback/kenpesasyncpb.php";
if (!isset($_POST['Search'])) {
$sql = "SELECT * FROM tblpbtransactions";
} else {
$sql = "SELECT * FROM tblpbtransactions WHERE text LIKE '%'";
if (isset($_POST['tranID']) && $_POST['tranID'] != "") {
$sql.= " AND mpesa_code LIKE '" . $_POST['tranID'] . "'";
}
if (isset($_POST['sendername']) && $_POST['sendername'] != "") {
$sql.= " AND mpesa_sender LIKE '%" . $_POST['sendername'] . "%'";
}
if (isset($_POST['senderno']) && $_POST['senderno'] != "") {
$sql.= " AND mpesa_msisdn LIKE '%" . $_POST['senderno'] . "%'";
}
if (isset($_POST['invoiceno']) && $_POST['invoiceno'] != "") {
$sql.= " AND invoiceid = '" . $_POST['invoiceno'] . "'";
}
if (isset($_POST['status']) && $_POST['status'] != "") {
$sql.= " AND status = '" . $_POST['status'] . "'";
}
}
$result = full_query($sql);
$counttrx = mysql_num_rows($result);
$page = isset($_POST['page']) ? $_POST['page'] : 1;
$NumRecordstoDisplay = $GLOBALS['CONFIG']['NumRecordstoDisplay'];
$pages = ceil($counttrx / $NumRecordstoDisplay);
$pages = $pages ? $pages : 1;
$lower = (($page * $NumRecordstoDisplay) - $NumRecordstoDisplay);
$limits = "$lower,$NumRecordstoDisplay";
$sql.= " ORDER BY tstamp DESC LIMIT {$limits}";
$r = full_query($sql);
# Get Variables from storage (retrieve from wherever it's stored - DB, file, etc...)
$key_result = select_query("mod_kenpesa", "localkey", '', "", "", "0,1");
$key_data = mysql_fetch_array($key_result);
$licensekey = $vars['licensekey'];
$localkey = $key_data['localkey'];
# The call below actually performs the license check. You need to pass in the license key and the local key data
$results = kenpesapb_check_license($licensekey, $localkey);
# For Debugging, Echo Results
if ($vars['debug']) {
if (function_exists(logModuleCall)) {
logModuleCall('kenpesapbaddon', 'lc', '', $results, $results, '');
}
}
$encoded_status = base64_encode($results["status"]);
full_query("UPDATE `mod_kenpesa` SET status='{$encoded_status}' WHERE localkey = '{$localkey}'");
if ($results["status"] == "Active") {
# Allow Script to Run
if ($results["localkey"]) {
# Save Updated Local Key to DB or File
$localkeydata = $results["localkey"];
full_query("UPDATE `mod_kenpesa` SET localkey = '{$localkeydata}' WHERE localkey = '{$localkey}'");
}
?>
<style>
.licensinglinksbar {
padding:10px 25px 10px 25px;
background-color:#2162A3;
font-weight:bold;
font-size: 14px;
color: #1A4D80;
margin: 0 0 15px 0;
border-radius: 5px;
}
.licensinglinksbar a {
color: #fff;
font-weight: normal;
}
</style>
<div class="licensinglinksbar"><a href="addonmodules.php?module=kenpesapb">Home</a> | <a href="addonmodules.php?module=kenpesapb&action=ipn">View IPN Logs</a> | <a href="gatewaylog.php">View Gateway Log</a> | <a href="configaddonmods.php#kenpesapb">Configure Addon</a> | <a href="configgateways.php#kenpesapb">Configure Gateway</a> | <a href="addonmodules.php?module=kenpesapb&action=licence" >Licence Information</a> | <a href="#" target="_blank">Help</a></div>
<?php
if (isset($_GET['action'])) {
if ($_GET['action'] == "list") { #view Transactions
?>
<table width="100%" border="0">
<tr>
<td width="100%" align="center">
<div id="tabs"><ul><li class="tab tabselected" id="tab0"><a href="javascript:;">Search/Filter</a></li></ul></div>
<div class="tabbox" id="tab0box" style="">
<div id="tab_content">
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?module=kenpesapb&action=list">
<input type="hidden" name="token" value="547b83ed21769961442ded8d3fe327ea6a548420">
<table class="form" width="100%" border="0" cellspacing="2" cellpadding="3">
<tbody><tr>
<td width="16%" class="fieldlabel">Transaction ID </td><td width="34%" class="fieldarea"><input name="tranID" type="text" id="tranID" value="<?php if (isset($_POST['tranID'])) {
echo $_POST['tranID'];
} ?>" size="30" /></td>
<td width="16%" class="fieldlabel">Invoice No </td>
<td width="34%" class="fieldarea"><input name="invoiceno" type="text" id="invoiceno" value="<?php if (isset($_POST['invoiceno'])) {
echo $_POST['invoiceno'];
} ?>" size="30" /></td>
</tr>
<tr>
<td width="16%" class="fieldlabel">Sender Name </td>
<td class="fieldarea"><input name="sendername" type="text" id="sendername" value="<?php if (isset($_POST['sendername'])) {
echo $_POST['sendername'];
} ?>" size="30"></td>
<td class="fieldlabel">Status</td>
<td class="fieldarea"><select name="status" id="status">
<option value="" <?php if ($_POST['status'] == "") { ?> selected="selected" <?php
} ?>>- Any -</option>
<option <?php if ($_POST['status'] == "Open") { ?> selected="selected" <?php
} ?>>Open</option>
<option <?php if ($_POST['status'] == "Closed") { ?> selected="selected" <?php
} ?>>Closed</option>
<option <?php if ($_POST['status'] == "Archived") { ?> selected="selected" <?php
} ?>>Archived</option>
</select></td>
</tr>
<tr>
<td class="fieldlabel">Sender No </td>
<td class="fieldarea"><input name="senderno" type="text" id="senderno" value="<?php if (isset($_POST['senderno'])) {
echo $_POST['senderno'];
} ?>" size="30"></td>
<td class="fieldlabel"> </td>
<td class="fieldlabel"> </td>
</tr>
</tbody></table>
<div align="center"><input name="Search" type="submit" class="button" id="Search" value="Search"></div>
</form>
</div>
</div>
</div>
<?php
echo '<form action="' . $_SERVER['REQUEST_URI'] . '" method="post">
<input type="hidden" value="2e305c39c588677e110bbd161c6c7e9cab219ae3" name="token">
<table width="100%" cellspacing="0" cellpadding="3" border="0"><tbody><tr>
<td width="50%" align="left">' . $counttrx . ' Records Found, Page ' . $page . ' of ' . $pages . '</td>
<td width="50%" align="right">Jump to Page: <select onchange="submit()" name="page">
';
for ($p = 1;$p <= $pages;$p++) {
$selected = ($p == $page) ? " selected=selected " : '';
echo '<option value="' . $p . '" ' . $selected . '>' . $p . '</option>';
}
echo '
</select> <input type="submit" class="btn-small" value="Go"></td>
</tr></tbody></table>
</form>';
?>
</td>
</tr>
<tr>
<td align="center">
<?php
if (isset($_GET['ac'])) {
$title = "";
$message = "";
#Start Archive
if ($_GET['ac'] == 'archive') {
if (full_query("UPDATE tblpbtransactions SET status = 'Archived' WHERE id =" . $_GET['id'])) {
$title = "Success";
$message = "The Pay Bill transaction has been archived successfully.";
} else {
$title = "Failed";
$message = "An error occurred while archiving: " . mysql_error();
}
}
#End Archive
#Start Open
if ($_GET['ac'] == 'open') {
if (full_query("UPDATE tblpbtransactions SET status = 'Open' WHERE id =" . $_GET['id'])) {
$title = "Success";
$message = "The Pay Bill transaction has been re-opened successfully.";
} else {
$title = "Failed";
$message = "An error occurred during activation: " . mysql_error();
}
}
#End of Open
#Start Close
if ($_GET['ac'] == 'close') {
if (full_query("UPDATE tblpbtransactions SET status = 'Closed' WHERE id =" . $_GET['id'])) {
$title = "Success";
$message = "The Pay Bill transaction has been closed successfully.";
} else {
$title = "Failed";
$message = "An error occurred while closing: " . mysql_error();
}
}
#End of Close
#Start Delete
if ($_GET['ac'] == 'del') {
if (full_query("DELETE FROM tblpbtransactions WHERE id =" . $_GET['id'])) {
$title = "Success";
$message = "The Pay Bill transaction has been deleted successfully.";
} else {
$title = "Failed";
$message = "An error occurred while deleting: " . mysql_error();
}
}
#End of delete
?>
<?php if ($title == "Success") { ?>
<div class="successbox"><strong><span class="title"><?php echo $title; ?></span></strong><br><?php echo $message; ?></div>
<?php
} else if ($title == "Failed") {
?>
<div class="errorbox"><strong><span class="title"><?php echo $title; ?></span></strong><br><?php echo $message; ?></div>
<?php
}
}
?>
<table class="datatable" width="100%" border="0" cellspacing="1" bgcolor="#ECE9D8">
<tbody>
<tr>
<th>Date & Time <img src="images/desc.gif" class="absmiddle"></th>
<th>TRANSACTION ID </th>
<th>Sender</th>
<th>Sender No </th>
<th>Amount</th>
<th>Invoice No </th>
<th>Status</th>
<?php if ($opentran == "on") { ?><th width="16"> </th><?php
} ?>
<?php if ($archivetran == "on") { ?><th width="16"> </th><?php
} ?>
<?php if ($closetran == "on") { ?><th width="16"> </th><?php
} ?>
<?php if ($deletetran == "on") { ?><th width="16"> </th><?php
} ?>
</tr>
<?php
$n = mysql_num_rows($r);
if ($n <> 0) {
while ($row = mysql_fetch_array($r)) {
?>
<tr>
<td bgcolor="#FFFFFF"><?php echo fromMySQLDate($row['tstamp']) . ' ' . date('H:i:s', strtotime($row['tstamp'])); ?></td>
<td align="center" bgcolor="#FFFFFF"><a href="addonmodules.php?module=kenpesapb&action=details&id=<?php echo $row['id']; ?>"><?php echo $row['mpesa_code']; ?></a></td>
<td bgcolor="#FFFFFF"><?php echo strtoupper($row['mpesa_sender']); ?></td>
<td align="right" bgcolor="#FFFFFF"><?php echo $row['mpesa_msisdn']; ?></td>
<td align="right" bgcolor="#FFFFFF"><?php echo number_format($row['mpesa_amt'], 2); ?></td>
<td align="right" bgcolor="#FFFFFF">
<?php if (($row['invoiceid'] <> 0)) { ?> <a href="invoices.php?action=edit&id=<?php echo $row['invoiceid']; ?>"><?php echo $row['invoiceid']; ?></a> <?php
} ?></td>
<td bgcolor="#FFFFFF"><?php if ($row['status'] == "Open") { ?> <span class="label active"> <?php echo $row['status'];
} ?></span>
<?php if ($row['status'] == "Closed") { ?>
<span class="label closed">
<?php echo $row['status'];
} ?> </span>
<?php if ($row['status'] != "Open" && $row['status'] != "Closed") { ?>
<span class="label inactive">
<?php echo $row['status']; ?>
<?php
} ?> </span> </td>
<?php if ($opentran == "on") { ?><td bgcolor="#FFFFFF"><?php if ($row['status'] != "Open") { ?><a href="addonmodules.php?module=kenpesapb&action=list&ac=open&id=<?php echo $row['id']; ?>"><img src="../modules/addons/kenpesapb/images/open.gif" width="16" height="16" border="0" alt="Open" title="Open"></a><?php
} ?></td> <?php
} ?>
<?php if ($archivetran == "on") { ?><td bgcolor="#FFFFFF"><?php if ($row['status'] != "Archived") { ?><a href="addonmodules.php?module=kenpesapb&action=list&ac=archive&id=<?php echo $row['id']; ?>"><img src="../modules/addons/kenpesapb/images/archive.png" width="16" height="16" border="0" alt="Archive" title="Archive"></a><?php
} ?></td> <?php
} ?>
<?php if ($closetran == "on") { ?><td bgcolor="#FFFFFF"><?php if ($row['status'] != "Closed") { ?><a href="addonmodules.php?module=kenpesapb&action=list&ac=close&id=<?php echo $row['id']; ?>"><img src="../modules/addons/kenpesapb/images/close.png" width="16" height="16" border="0" alt="Close" title="Close"></a><?php
} ?></td><?php
} ?>
<?php if ($deletetran == "on") { ?><td bgcolor="#FFFFFF"><a href="addonmodules.php?module=kenpesapb&action=list&ac=del&id=<?php echo $row['id']; ?>"><img src="../modules/addons/kenpesapb/images/delete.png" width="16" height="16" border="0" alt="Delete" title="Delete"></a></td><?php
} ?>
</tr>
<?php
}
}
?>
</tbody>
</table></td>
</tr>
</table>
<p> </p>
<?php
} #list
else if ($_GET['action'] == "details") { #details
$tSQL = full_query("SELECT * FROM tblpbtransactions WHERE id = " . $_GET['id']);
while ($data = mysql_fetch_array($tSQL)) {
?>
<p><b>M-PESA Transaction details</b></p>
<table class="form" width="100%" border="0" cellspacing="2" cellpadding="3">
<tbody><tr><td width="20%" class="fieldlabel">Transaction ID</td><td class="fieldarea"><?php echo $transid = $data['mpesa_code']; ?></td></tr>
<tr>
<td class="fieldlabel">Transaction Date</td>
<td class="fieldarea"><?php echo ($data['mpesa_trx_date']); ?></td>
</tr>
<tr>
<td class="fieldlabel">Transaction Time </td>
<td class="fieldarea"><?php echo $data['mpesa_trx_time']; ?></td>
</tr>
<tr>
<td class="fieldlabel">M-PESA Notification Text </td>
<td class="fieldarea"><?php echo $data['text']; ?></td>
</tr>
<tr>
<td class="fieldlabel">Origin</td>
<td class="fieldarea"><?php echo $data['orig']; ?></td>
</tr>
<tr>
<td class="fieldlabel">Business Terminal MSISDN </td>
<td class="fieldarea"><?php echo $data['dest']; ?></td>
</tr>
<tr>
<td class="fieldlabel">Amount</td>
<td class="fieldarea"><?php echo number_format($data['mpesa_amt'], 2); ?></td>
</tr>
<tr>
<td class="fieldlabel">Account No </td>
<td class="fieldarea"><?php echo $data['mpesa_acc']; ?></td>
</tr>
<tr>
<td class="fieldlabel">Status</td><td class="fieldarea"><?php if ($data['status'] == "Open") { ?> <span class="label active"> <?php echo $data['status'];
} ?></span>
<?php if ($data['status'] == "Closed") { ?>
<span class="label closed">
<?php echo $data['status'];
} ?> </span>
<?php if ($data['status'] != "Open" && $data['status'] != "Closed") { ?>
<span class="label inactive">
<?php echo $data['status']; ?>
<?php
} ?> </span>
</td>
</tr>
<tr>
<td width="20%" class="fieldlabel">Sender Name </td><td class="fieldarea"><?php echo strtoupper($data['mpesa_sender']); ?></td>
</tr>
<tr>
<td class="fieldlabel">Sender Mobile Number </td>
<td class="fieldarea"><?php echo $data['mpesa_msisdn']; ?></td>
</tr>
<tr>
<td class="fieldlabel">IPN Notification Timestamp </td>
<td class="fieldarea"><?php echo fromMySQLDate($data['tstamp']) . ' ' . date('H:i:s', strtotime($data['tstamp'])); ?></td>
</tr>
</tbody></table>
<?php
}
if ($tRes = full_query("SELECT * FROM tblaccounts WHERE transid LIKE '" . $transid . "'")) {
while ($trow = mysql_fetch_array($tRes)) {
?>
<p><b>WHMCS Transaction Lookup</b></p>
<table class="form" width="100%" border="0" cellspacing="2" cellpadding="3">
<tbody><tr><td width="20%" class="fieldlabel">Date</td><td class="fieldarea"><?php echo fromMySQLDate($trow['date']) . ' ' . date('H:i:s', strtotime($trow['date'])); ?></td></tr>
<tr><td class="fieldlabel">Invoice ID</td><td class="fieldarea"><?php echo $invoiceid = $trow['invoiceid']; ?></td></tr>
<tr><td class="fieldlabel">Amount</td><td class="fieldarea"><?php echo number_format($trow['amountin'], 2); ?></td></tr>
<tr>
<td class="fieldlabel">Description</td>
<td class="fieldarea"><?php echo $trow['description']; ?></td>
</tr>
</tbody></table>
<?php
}
}
?>
<?php
if ($iRes = full_query("SELECT * FROM tblinvoices WHERE id = " . $invoiceid)) {
while ($irow = mysql_fetch_array($iRes)) {
?>
<p><b>
WHMCS Invoice Lookup</b></p>
<table class="form" width="100%" border="0" cellspacing="2" cellpadding="3">
<tbody><tr><td width="20%" class="fieldlabel">Invoice ID</td><td class="fieldarea"><a href="invoices.php?action=edit&id=<?php echo $irow['id']; ?>"><?php echo $irow['id']; ?></a></td></tr>
<tr><td class="fieldlabel">Client Name</td><td class="fieldarea"><?php
//get client name
$cres = full_query("SELECT * FROM tblclients WHERE id=" . $irow['userid']);
$cdata = mysql_fetch_array($cres);
$clientname = $cdata['firstname'] . " " . $cdata['lastname'];
?>
<a href="clientssummary.php?userid=<?php echo $irow['userid']; ?>"> <?php echo $clientname; ?></a></td>
</tr>
<tr>
<td class="fieldlabel">Invoice Date </td>
<td class="fieldarea"><?php echo fromMySQLDate($irow['date']); ?></td>
</tr>
<tr>
<td class="fieldlabel">Due Date </td>
<td class="fieldarea"><?php echo fromMySQLDate($irow['duedate']); ?></td>
</tr>
<tr>
<td class="fieldlabel">Date Paid </td>
<td class="fieldarea"><?php echo fromMySQLDate($irow['datepaid']); ?></td>
</tr>
<tr>
<td class="fieldlabel">Invoice Status</td>
<td class="fieldarea"><?php
if ($irow['status'] == "Paid") {
echo '<span class="textgreen">';
} else if ($irow['status'] == "Unpaid") {
echo '<span class="textred">';
} else if ($irow['status'] == "Cancelled") {
echo '<span class="textgrey">';
} else {
echo '<span class="textblack">';
}
echo $irow['status'];
echo "</span>"
?></td>
</tr>
<tr>
<td class="fieldlabel">Sub-Total</td>
<td class="fieldarea"><?php echo number_format($irow['subtotal'], 2); ?></td>
</tr>
<tr>
<td class="fieldlabel">Tax</td>
<td class="fieldarea"><?php echo number_format($irow['tax'], 2); ?></td>
</tr>
<tr>
<td class="fieldlabel">Credit</td>
<td class="fieldarea"><?php echo number_format($irow['credit'], 2); ?></td>
</tr>
<tr>
<td class="fieldlabel">Total</td>
<td class="fieldarea"><?php echo number_format($irow['total'], 2); ?></td></tr>
</tbody></table>
<?php
}
}
} else if ($_GET['action'] == "ipn") { #begin IPN log
?>
<table class="datatable" width="100%" border="0" cellspacing="1" bgcolor="#ECE9D8">
<tr>
<th>Date <img src="images/desc.gif" class="absmiddle"></th>
<th>Description</th>
<th>Username</th>
<th>IPN IP Address/URL </th>
</tr>
<?php
$sql = "SELECT * FROM tblactivitylog WHERE user='Safaricom IPN' ORDER BY id DESC";
$r = full_query($sql);
$n = mysql_num_rows($r);
if ($n <> 0) {
while ($row = mysql_fetch_array($r)) {
?>
<tr>
<td bgcolor="#FFFFFF"><?php echo $row['date']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $row['description']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $row['user']; ?></td>
<td align="right" bgcolor="#FFFFFF"><?php echo $row['ipaddr']; ?></td>
</tr>
<?php
}
}
?>
</table>
<?php
} #end IPN log
elseif ($_GET['action'] == "licence") { #begin licence
?>
<h1>License Information</h1>
<table class="form" width="100%" border="0" cellspacing="2" cellpadding="3">
<tbody><tr><td width="20%" class="fieldlabel">Product Name</td><td class="fieldarea"><?php echo $results['productname']; ?></td></tr>
<tbody><tr><td width="20%" class="fieldlabel">Registered To</td><td class="fieldarea"><?php echo $results['companyname']; ?></td></tr>
<tr><td class="fieldlabel">License Key</td><td class="fieldarea"><?php echo $licensekey; ?></td></tr>
<tr><td class="fieldlabel">Billing Cycle</td><td class="fieldarea"><?php echo $results['billingcycle']; ?></td>
</tr>
<tr><td class="fieldlabel">Status</td><td class="fieldarea"><?php if ($results["status"] == "Active") {
echo '<span class="label active">';
} else {
echo '<span class="label closed">';
}
echo $results["status"] . "</div>"; ?></td></tr>
<tr><td class="fieldlabel">Valid Domains</td><td class="fieldarea"><?php echo $results['validdomain']; ?></td></tr>
<tr><td class="fieldlabel">Valid IP</td><td class="fieldarea"><?php echo $results['validip']; ?></td></tr>
<tr><td class="fieldlabel">Valid Directory</td><td class="fieldarea"><?php echo $results['validdirectory']; ?></td></tr>
<tr><td class="fieldlabel">Registered</td><td class="fieldarea"><?php echo fromMySQLDate($results['regdate']); ?></td></tr>
<tr><td class="fieldlabel">Expires</td><td class="fieldarea"><?php echo $results['nextduedate'] == '0000-00-00' ? "Never" : fromMySQLDate($results['nextduedate']); ?></td></tr>
<tr><td class="fieldlabel">IPN URL</td><td class="fieldarea"><?php echo $IPN_URL; ?></td></tr>
</tbody></table>
<?php
} #end licence
} #isset action
else {
#Home
header("location:{$_SERVER['PHP_SELF']}?module=kenpesapb&action=list");
?>
<h2>Recent M-PESA Pay Bill Transactions </h2>
<table class="datatable" width="100%" border="0" cellspacing="1" bgcolor="#ECE9D8">
<tbody>
<tr>
<th>Date <img src="images/desc.gif" class="absmiddle"></th>
<th>TRANSACTION ID </th>
<th>Sender</th>
<th>Sender No </th>
<th>Amount</th>
<th>Invoice No </th>
<th>Status</th>
<?php if ($opentran == "on") { ?><th width="16"> </th><?php
} ?>
<?php if ($archivetran == "on") { ?><th width="16"> </th><?php
} ?>
<?php if ($closetran == "on") { ?><th width="16"> </th><?php
} ?>
<?php if ($deletetran == "on") { ?><th width="16"> </th><?php
} ?>
</tr>
<?php
$sql = "SELECT * FROM tblpbtransactions";
$sql.= " ORDER BY tstamp DESC LIMIT 0 , 15";
$r = full_query($sql);
$n = mysql_num_rows($r);
if ($n <> 0) {
while ($row = mysql_fetch_array($r)) {
?>
<tr>
<td bgcolor="#FFFFFF"><?php echo $row['tstamp']; ?></td>
<td align="center" bgcolor="#FFFFFF"><a href="addonmodules.php?module=kenpesapb&action=details&id=<?php echo $row['id']; ?>"><?php echo $row['mpesa_code']; ?></a></td>
<td bgcolor="#FFFFFF"><?php echo $row['mpesa_sender']; ?></td>
<td align="right" bgcolor="#FFFFFF"><?php echo $row['mpesa_msisdn']; ?></td>
<td align="right" bgcolor="#FFFFFF"><?php echo number_format($row['mpesa_amt'], 2); ?></td>
<td align="right" bgcolor="#FFFFFF">
<?php if (($row['invoiceid'] <> 0)) { ?> <a href="invoices.php?action=edit&id=<?php echo $row['invoiceid']; ?>"><?php echo $row['invoiceid']; ?></a> <?php
} ?></td>
<td bgcolor="#FFFFFF"><?php if ($row['status'] == "Open") { ?> <span class="label active"> <?php echo $row['status'];
} ?></span>
<?php if ($row['status'] == "Closed") { ?>
<span class="label closed">
<?php echo $row['status'];
} ?> </span>
<?php if ($row['status'] != "Open" && $row['status'] != "Closed") { ?>
<span class="label inactive">
<?php echo $row['status']; ?>
<?php
} ?> </span> </td>
<?php if ($opentran == "on") { ?><td bgcolor="#FFFFFF"><?php if ($row['status'] != "Open") { ?><a href="addonmodules.php?module=kenpesapb&action=list&ac=open&id=<?php echo $row['id']; ?>"><img src="../modules/addons/kenpesapb/images/open.gif" width="16" height="16" border="0" alt="Open" title="Open"></a><?php
} ?></td> <?php
} ?>
<?php if ($archivetran == "on") { ?><td bgcolor="#FFFFFF"><?php if ($row['status'] != "Archived") { ?><a href="addonmodules.php?module=kenpesapb&action=list&ac=archive&id=<?php echo $row['id']; ?>"><img src="../modules/addons/kenpesapb/images/archive.png" width="16" height="16" border="0" alt="Archive" title="Archive"></a><?php
} ?></td> <?php
} ?>
<?php if ($closetran == "on") { ?><td bgcolor="#FFFFFF"><?php if ($row['status'] != "Closed") { ?><a href="addonmodules.php?module=kenpesapb&action=list&ac=close&id=<?php echo $row['id']; ?>"><img src="../modules/addons/kenpesapb/images/close.png" width="16" height="16" border="0" alt="Close" title="Close"></a><?php
} ?></td><?php
} ?>
<?php if ($deletetran == "on") { ?><td bgcolor="#FFFFFF"><a href="addonmodules.php?module=kenpesapb&action=list&ac=del&id=<?php echo $row['id']; ?>"><img src="../modules/addons/kenpesapb/images/delete.png" width="16" height="16" border="0" alt="Delete" title="Delete"></a></td><?php
} ?>
</tr>
<?php
}
#end home
}
?>
</tbody>
</table>
<?php
}
} elseif ($results["status"] == "Invalid") {
# Show Invalid Message
?>
<div class="infobox" style="font-size:16px">Your license key is <span class="label closed" style="font-size:14px">Invalid.</span> Get a valid licence from <a href="https://www.enetonlinesolutions.co.ke/portal/clients/clientarea.php" target="_blank">https://www.enetonlinesolutions.co.ke/</a>. Have Questions? Call +254 726 872 512</div>
<?php
} elseif ($results["status"] == "Expired") {
# Show Expired Message
?>
<div class="infobox" style="font-size:16px">Your license key is <span class="label closed" style="font-size:14px">Expired.</span> Renew you licence from <a href="https://www.enetonlinesolutions.co.ke/portal/clients/clientarea.php" target="_blank">https://www.enetonlinesolutions.co.ke/</a> Have Questions? Call +254 726 872 512</div>
<?php
} elseif ($results["status"] == "Suspended") {
# Show Suspended Message
?>
<div class="infobox" style="font-size:16px">Your license key has been <span class="label closed" style="font-size:14px">Suspended.</span> Have Questions? <a href="https://www.enetonlinesolutions.co.ke/portal/clients/clientarea.php" target="_blank">https://www.enetonlinesolutions.co.ke/</a> or Call +254 726 872 512</div>
<?php
}
#end check licence
}
function kenpesapb_sidebar($vars) {
$sidebar = '';
return $sidebar;
}
//client output
function kenpesapb_clientarea($vars) {
$modulelink = $vars['modulelink'];
$version = $vars['version'];
$option1 = $vars['option1'];
$option2 = $vars['option2'];
$option3 = $vars['option3'];
$option4 = $vars['option4'];
$option5 = $vars['option5'];
$option6 = $vars['option6'];
$LANG = $vars['_lang'];
return array('pagetitle' => 'M-PESA Transactions', 'breadcrumb' => array('index.php?m=kenpesapb' => 'M-PESA Transactions'), 'templatefile' => 'kenpesapb', 'requirelogin' => true, # or false
'vars' => array('testvar' => 'demo', 'anothervar' => 'value', 'sample' => 'test',),);
}
?>
Did this file decode correctly?
Original Code
<?php ?><?php
/*
*************************************************************************
* *
* Enet Online Solutions - KenPesa Addons Module *
* All Rights Reserved 2012, Illegal redistribution is prohibited *
* Last Modified: 20th November 2012 *
* Last Modified: 23th December 2014 *
* *
* Email: [email protected] *
* Website: http://www.enetonlinesolutions.net *
*************************************************************************
*/
if (!defined("WHMCS")) die("This file cannot be accessed directly");
function kenpesapb_config() {
$configarray = array("name" => "Ken-Pesa (PB) V.1.3", "version" => "1.3", "author" => "<a href='https://www.enetonlinesolutions.co.ke' target='_blank'>Enet Online Solutions</a>", "language" => "english", "description" => "This modules (Pay Bill Option) allows you configure the Ken-PESA Gateway and view all the MPESA payment Transactions. ", "fields" => array("mpesano" => array("FriendlyName" => "Pay Bill/Till No", "Type" => "text", "Size" => "25", "Description" => "Enter your MPESA Pay Bill Business No/Lipa Na MPESA Till No that clients will use to make MPESA payments"), "mpesatype" => array("FriendlyName" => "A/C Type", "Type" => "dropdown", "Options" => "Pay Bill No,Lipa Na MPESA", "Description" => "Choose the MPESA A/C Type", "Default" => "Pay Bill No",), "username" => array("FriendlyName" => "API Username", "Type" => "text", "Size" => "25", "Description" => "You must provide Safaricom with this username for them to set it in your IPN. <br><i>Leave blank to disable (Not Recommended)</i>"), "pass" => array("FriendlyName" => "API Password", "Type" => "password", "Size" => "25", "Description" => "You must provide Safaricom with this password for them to set it in your IPN. <br><i>Leave blank to disable (Not Recommended)</i>"), "licensekey" => array("FriendlyName" => "Licence Key", "Type" => "text", "Size" => "25", "Description" => "Enter your Licence from your clientarea. Any questions? Visit <a href='http://www.enetonlinesolutions.co.ke/portal/clients/clientarea.php' target='_blank'>www.enetonlinesolutions.co.ke</a>. Call (254) 726 872 512"), "autoapply" => array("FriendlyName" => "Auto-Apply payment to invoice", "Type" => "yesno", "Size" => "25", "Description" => "Tick this option to Auto Add Payment to invoice and send Invoice Payment Confirmation. You can purchase our SMS module to notify the client on Auto registrations/renewal."), "opentran" => array("FriendlyName" => "Re-Open Transaction", "Type" => "yesno", "Size" => "25", "Description" => "Tick this option to allow changing the status of closed or archived transaction to Open."), "archivetran" => array("FriendlyName" => "Archive Transaction", "Type" => "yesno", "Size" => "25", "Description" => "Tick this option to allow archiving of transactions before deleting."), "closetran" => array("FriendlyName" => "Close Transactions", "Type" => "yesno", "Size" => "25", "Description" => "Tick this option to allow closing Pay Bill Payment Transactions."), "deletetran" => array("FriendlyName" => "Payments", "Type" => "yesno", "Size" => "25", "Description" => "Tick this option to allow deleting Pay Bill Payment Transactions."), "archdays" => array("FriendlyName" => "Auto-archive", "Type" => "text", "Size" => "8", "Description" => "No of days after IPN Date to Auto-Archive your transactions. Leave blank to disable."), "deldays" => array("FriendlyName" => "Auto-Delete", "Type" => "text", "Size" => "8", "Description" => "No of days after Archive Date to Auto-delete your transactions. Leave blank to disable."), "debug" => array("FriendlyName" => "Debug On", "Type" => "yesno", "Size" => "25", "Description" => "Tick to Enable debug (Systems Module log)."),));
return $configarray;
}
function kenpesapb_activate() {
# Create Custom DB Table
$query = "CREATE TABLE IF NOT EXISTS tblpbtransactions (
id varchar(100) NOT NULL,
orig varchar(20) NOT NULL,
dest varchar(100) NOT NULL,
tstamp TIMESTAMP NOT NULL,
`text` varchar(255) NOT NULL,
mpesa_code varchar(50) NOT NULL,
mpesa_acc varchar(100) NOT NULL,
mpesa_msisdn varchar(100) NOT NULL,
mpesa_trx_date varchar(100) NOT NULL,
mpesa_trx_time varchar(100) NOT NULL,
mpesa_amt int(11) NOT NULL,
mpesa_sender varchar(100) NOT NULL,
`status` varchar(10) NOT NULL DEFAULT 'Open',
invoiceid int(11) NOT NULL DEFAULT '0',
`archivedate` DATETIME NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY mpesa_code (mpesa_code)
)";
$result1 = full_query($query);
$result2 = full_query("CREATE TABLE IF NOT EXISTS `mod_kenpesa` (
`localkey` text NOT NULL,
`status` varchar(100) NULL
)");
$localkey = '9tjIxIzNwgDMwIjI6gjOztjIlRXYkt2Ylh2YioTO6M3OicmbpNnblNWasx1cyVmdyV2ccNXZsVHZv1GX
zNWbodHXlNmc192czNWbodHXzN2bkRHacBFUNFEWcNHduVWb1N2bExFd0FWTcNnclNXVcpzQioDM4ozc
7ISey9GdjVmcpRGZpxWY2JiO0EjOztjIx4CMuAjL3ITMioTO6M3OiAXaklGbhZnI6cjOztjI0N3boxWY
j9Gbuc3d3xCdz9GasF2YvxmI6MjM6M3Oi4Wah12bkRWasFmdioTMxozc7ISeshGdu9WTiozN6M3OiUGb
jl3Yn5WasxWaiJiOyEjOztjI3ATL4ATL4ADMyIiOwEjOztjIlRXYkVWdkRHel5mI6ETM6M3OicDMtcDM
tgDMwIjI6ATM6M3OiUGdhR2ZlJnI6cjOztjIlNXYlxEI5xGa052bNByUD1ESXJiO5EjOztjIl1WYuR3Y
1R2byBnI6ETM6M3OicjI6EjOztjIklGdjVHZvJHcioTO6M3Oi02bj5ycj1Ga3BEd0FWbioDNxozc7ICb
pFWblJiO1ozc7IyUD1ESXBCd0FWTioDMxozc7ISZtFmbkVmclR3cpdWZyJiO0EjOztjIlZXa0NWQiojN
6M3OiMXd0FGdzJiO2ozc7pjMxoTY8baca0885830a33725148e94e693f3f073294c0558d38e31f844
c5e399e3c16a';
$encoded_status = base64_encode('Inactive');
$result3 = full_query("INSERT INTO `mod_kenpesa` (localkey,status) VALUES ('{$localkey}','{$encoded_status}')");
if ($result1 && $result2 && $result3) {
return array('status' => 'success', 'description' => 'Thank you for activating Ken-Pesa (PB) Module.');
} else {
return array('status' => 'error', 'description' => 'We apoligize that an error occurred while activating Ken-Pesa (PB) Module.');
}
}
function kenpesapb_deactivate() {
# Remove Custom DB Table
$query = "DROP TABLE IF EXISTS `tblpbtransactions`";
// $result1 = full_query($query);
$result2 = full_query("DROP TABLE IF EXISTS `mod_kenpesa`");
if ($result1 && $result2) {
return array('status' => 'success', 'description' => 'We regret to see that you have disabled Ken-Pesa (PB) Module.');
} else {
return array('status' => 'error', 'description' => 'We apoligize that an error occurred while de-activating Ken-Pesa (PB) Module.');
}
}
function kenpesapb_upgrade($vars) {
$version = $vars['version'];
# Run SQL Updates for V1.0 to V1.1
if ($version < 1.0) {
$query = "ALTER TABLE `tblpbtransactions` CHANGE `tstamp` `tstamp` TIMESTAMP NOT NULL";
$result = full_query($query);
$query = "ALTER TABLE `tblpbtransactions` ADD `archivedate` DATETIME NOT NULL AFTER `status`";
$result = full_query($query);
}
if ($version < 1.2) {
full_query("CREATE TABLE IF NOT EXISTS `mod_kenpesa` (
`localkey` text NOT NULL,
`status` varchar(100) NULL
)");
}
}
function kenpesapb_output($vars) {
$version = $vars['version'];
$opentran = $vars['opentran'];
$archivetran = $vars['archivetran'];
$closetran = $vars['closetran'];
$deletetran = $vars['deletetran'];
$IPN_URL = !empty($GLOBALS['CONFIG']['SystemSSLURL']) ? $GLOBALS['CONFIG']['SystemSSLURL'] : $GLOBALS['CONFIG']['SystemURL'];
$IPN_URL.= "/modules/gateways/callback/kenpesasyncpb.php";
if (!isset($_POST['Search'])) {
$sql = "SELECT * FROM tblpbtransactions";
} else {
$sql = "SELECT * FROM tblpbtransactions WHERE text LIKE '%'";
if (isset($_POST['tranID']) && $_POST['tranID'] != "") {
$sql.= " AND mpesa_code LIKE '" . $_POST['tranID'] . "'";
}
if (isset($_POST['sendername']) && $_POST['sendername'] != "") {
$sql.= " AND mpesa_sender LIKE '%" . $_POST['sendername'] . "%'";
}
if (isset($_POST['senderno']) && $_POST['senderno'] != "") {
$sql.= " AND mpesa_msisdn LIKE '%" . $_POST['senderno'] . "%'";
}
if (isset($_POST['invoiceno']) && $_POST['invoiceno'] != "") {
$sql.= " AND invoiceid = '" . $_POST['invoiceno'] . "'";
}
if (isset($_POST['status']) && $_POST['status'] != "") {
$sql.= " AND status = '" . $_POST['status'] . "'";
}
}
$result = full_query($sql);
$counttrx = mysql_num_rows($result);
$page = isset($_POST['page']) ? $_POST['page'] : 1;
$NumRecordstoDisplay = $GLOBALS['CONFIG']['NumRecordstoDisplay'];
$pages = ceil($counttrx / $NumRecordstoDisplay);
$pages = $pages ? $pages : 1;
$lower = (($page * $NumRecordstoDisplay) - $NumRecordstoDisplay);
$limits = "$lower,$NumRecordstoDisplay";
$sql.= " ORDER BY tstamp DESC LIMIT {$limits}";
$r = full_query($sql);
# Get Variables from storage (retrieve from wherever it's stored - DB, file, etc...)
$key_result = select_query("mod_kenpesa", "localkey", '', "", "", "0,1");
$key_data = mysql_fetch_array($key_result);
$licensekey = $vars['licensekey'];
$localkey = $key_data['localkey'];
# The call below actually performs the license check. You need to pass in the license key and the local key data
$results = kenpesapb_check_license($licensekey, $localkey);
# For Debugging, Echo Results
if ($vars['debug']) {
if (function_exists(logModuleCall)) {
logModuleCall('kenpesapbaddon', 'lc', '', $results, $results, '');
}
}
$encoded_status = base64_encode($results["status"]);
full_query("UPDATE `mod_kenpesa` SET status='{$encoded_status}' WHERE localkey = '{$localkey}'");
if ($results["status"] == "Active") {
# Allow Script to Run
if ($results["localkey"]) {
# Save Updated Local Key to DB or File
$localkeydata = $results["localkey"];
full_query("UPDATE `mod_kenpesa` SET localkey = '{$localkeydata}' WHERE localkey = '{$localkey}'");
}
?>
<style>
.licensinglinksbar {
padding:10px 25px 10px 25px;
background-color:#2162A3;
font-weight:bold;
font-size: 14px;
color: #1A4D80;
margin: 0 0 15px 0;
border-radius: 5px;
}
.licensinglinksbar a {
color: #fff;
font-weight: normal;
}
</style>
<div class="licensinglinksbar"><a href="addonmodules.php?module=kenpesapb">Home</a> | <a href="addonmodules.php?module=kenpesapb&action=ipn">View IPN Logs</a> | <a href="gatewaylog.php">View Gateway Log</a> | <a href="configaddonmods.php#kenpesapb">Configure Addon</a> | <a href="configgateways.php#kenpesapb">Configure Gateway</a> | <a href="addonmodules.php?module=kenpesapb&action=licence" >Licence Information</a> | <a href="#" target="_blank">Help</a></div>
<?php
if (isset($_GET['action'])) {
if ($_GET['action'] == "list") { #view Transactions
?>
<table width="100%" border="0">
<tr>
<td width="100%" align="center">
<div id="tabs"><ul><li class="tab tabselected" id="tab0"><a href="javascript:;">Search/Filter</a></li></ul></div>
<div class="tabbox" id="tab0box" style="">
<div id="tab_content">
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?module=kenpesapb&action=list">
<input type="hidden" name="token" value="547b83ed21769961442ded8d3fe327ea6a548420">
<table class="form" width="100%" border="0" cellspacing="2" cellpadding="3">
<tbody><tr>
<td width="16%" class="fieldlabel">Transaction ID </td><td width="34%" class="fieldarea"><input name="tranID" type="text" id="tranID" value="<?php if (isset($_POST['tranID'])) {
echo $_POST['tranID'];
} ?>" size="30" /></td>
<td width="16%" class="fieldlabel">Invoice No </td>
<td width="34%" class="fieldarea"><input name="invoiceno" type="text" id="invoiceno" value="<?php if (isset($_POST['invoiceno'])) {
echo $_POST['invoiceno'];
} ?>" size="30" /></td>
</tr>
<tr>
<td width="16%" class="fieldlabel">Sender Name </td>
<td class="fieldarea"><input name="sendername" type="text" id="sendername" value="<?php if (isset($_POST['sendername'])) {
echo $_POST['sendername'];
} ?>" size="30"></td>
<td class="fieldlabel">Status</td>
<td class="fieldarea"><select name="status" id="status">
<option value="" <?php if ($_POST['status'] == "") { ?> selected="selected" <?php
} ?>>- Any -</option>
<option <?php if ($_POST['status'] == "Open") { ?> selected="selected" <?php
} ?>>Open</option>
<option <?php if ($_POST['status'] == "Closed") { ?> selected="selected" <?php
} ?>>Closed</option>
<option <?php if ($_POST['status'] == "Archived") { ?> selected="selected" <?php
} ?>>Archived</option>
</select></td>
</tr>
<tr>
<td class="fieldlabel">Sender No </td>
<td class="fieldarea"><input name="senderno" type="text" id="senderno" value="<?php if (isset($_POST['senderno'])) {
echo $_POST['senderno'];
} ?>" size="30"></td>
<td class="fieldlabel"> </td>
<td class="fieldlabel"> </td>
</tr>
</tbody></table>
<div align="center"><input name="Search" type="submit" class="button" id="Search" value="Search"></div>
</form>
</div>
</div>
</div>
<?php
echo '<form action="' . $_SERVER['REQUEST_URI'] . '" method="post">
<input type="hidden" value="2e305c39c588677e110bbd161c6c7e9cab219ae3" name="token">
<table width="100%" cellspacing="0" cellpadding="3" border="0"><tbody><tr>
<td width="50%" align="left">' . $counttrx . ' Records Found, Page ' . $page . ' of ' . $pages . '</td>
<td width="50%" align="right">Jump to Page: <select onchange="submit()" name="page">
';
for ($p = 1;$p <= $pages;$p++) {
$selected = ($p == $page) ? " selected=selected " : '';
echo '<option value="' . $p . '" ' . $selected . '>' . $p . '</option>';
}
echo '
</select> <input type="submit" class="btn-small" value="Go"></td>
</tr></tbody></table>
</form>';
?>
</td>
</tr>
<tr>
<td align="center">
<?php
if (isset($_GET['ac'])) {
$title = "";
$message = "";
#Start Archive
if ($_GET['ac'] == 'archive') {
if (full_query("UPDATE tblpbtransactions SET status = 'Archived' WHERE id =" . $_GET['id'])) {
$title = "Success";
$message = "The Pay Bill transaction has been archived successfully.";
} else {
$title = "Failed";
$message = "An error occurred while archiving: " . mysql_error();
}
}
#End Archive
#Start Open
if ($_GET['ac'] == 'open') {
if (full_query("UPDATE tblpbtransactions SET status = 'Open' WHERE id =" . $_GET['id'])) {
$title = "Success";
$message = "The Pay Bill transaction has been re-opened successfully.";
} else {
$title = "Failed";
$message = "An error occurred during activation: " . mysql_error();
}
}
#End of Open
#Start Close
if ($_GET['ac'] == 'close') {
if (full_query("UPDATE tblpbtransactions SET status = 'Closed' WHERE id =" . $_GET['id'])) {
$title = "Success";
$message = "The Pay Bill transaction has been closed successfully.";
} else {
$title = "Failed";
$message = "An error occurred while closing: " . mysql_error();
}
}
#End of Close
#Start Delete
if ($_GET['ac'] == 'del') {
if (full_query("DELETE FROM tblpbtransactions WHERE id =" . $_GET['id'])) {
$title = "Success";
$message = "The Pay Bill transaction has been deleted successfully.";
} else {
$title = "Failed";
$message = "An error occurred while deleting: " . mysql_error();
}
}
#End of delete
?>
<?php if ($title == "Success") { ?>
<div class="successbox"><strong><span class="title"><?php echo $title; ?></span></strong><br><?php echo $message; ?></div>
<?php
} else if ($title == "Failed") {
?>
<div class="errorbox"><strong><span class="title"><?php echo $title; ?></span></strong><br><?php echo $message; ?></div>
<?php
}
}
?>
<table class="datatable" width="100%" border="0" cellspacing="1" bgcolor="#ECE9D8">
<tbody>
<tr>
<th>Date & Time <img src="images/desc.gif" class="absmiddle"></th>
<th>TRANSACTION ID </th>
<th>Sender</th>
<th>Sender No </th>
<th>Amount</th>
<th>Invoice No </th>
<th>Status</th>
<?php if ($opentran == "on") { ?><th width="16"> </th><?php
} ?>
<?php if ($archivetran == "on") { ?><th width="16"> </th><?php
} ?>
<?php if ($closetran == "on") { ?><th width="16"> </th><?php
} ?>
<?php if ($deletetran == "on") { ?><th width="16"> </th><?php
} ?>
</tr>
<?php
$n = mysql_num_rows($r);
if ($n <> 0) {
while ($row = mysql_fetch_array($r)) {
?>
<tr>
<td bgcolor="#FFFFFF"><?php echo fromMySQLDate($row['tstamp']) . ' ' . date('H:i:s', strtotime($row['tstamp'])); ?></td>
<td align="center" bgcolor="#FFFFFF"><a href="addonmodules.php?module=kenpesapb&action=details&id=<?php echo $row['id']; ?>"><?php echo $row['mpesa_code']; ?></a></td>
<td bgcolor="#FFFFFF"><?php echo strtoupper($row['mpesa_sender']); ?></td>
<td align="right" bgcolor="#FFFFFF"><?php echo $row['mpesa_msisdn']; ?></td>
<td align="right" bgcolor="#FFFFFF"><?php echo number_format($row['mpesa_amt'], 2); ?></td>
<td align="right" bgcolor="#FFFFFF">
<?php if (($row['invoiceid'] <> 0)) { ?> <a href="invoices.php?action=edit&id=<?php echo $row['invoiceid']; ?>"><?php echo $row['invoiceid']; ?></a> <?php
} ?></td>
<td bgcolor="#FFFFFF"><?php if ($row['status'] == "Open") { ?> <span class="label active"> <?php echo $row['status'];
} ?></span>
<?php if ($row['status'] == "Closed") { ?>
<span class="label closed">
<?php echo $row['status'];
} ?> </span>
<?php if ($row['status'] != "Open" && $row['status'] != "Closed") { ?>
<span class="label inactive">
<?php echo $row['status']; ?>
<?php
} ?> </span> </td>
<?php if ($opentran == "on") { ?><td bgcolor="#FFFFFF"><?php if ($row['status'] != "Open") { ?><a href="addonmodules.php?module=kenpesapb&action=list&ac=open&id=<?php echo $row['id']; ?>"><img src="../modules/addons/kenpesapb/images/open.gif" width="16" height="16" border="0" alt="Open" title="Open"></a><?php
} ?></td> <?php
} ?>
<?php if ($archivetran == "on") { ?><td bgcolor="#FFFFFF"><?php if ($row['status'] != "Archived") { ?><a href="addonmodules.php?module=kenpesapb&action=list&ac=archive&id=<?php echo $row['id']; ?>"><img src="../modules/addons/kenpesapb/images/archive.png" width="16" height="16" border="0" alt="Archive" title="Archive"></a><?php
} ?></td> <?php
} ?>
<?php if ($closetran == "on") { ?><td bgcolor="#FFFFFF"><?php if ($row['status'] != "Closed") { ?><a href="addonmodules.php?module=kenpesapb&action=list&ac=close&id=<?php echo $row['id']; ?>"><img src="../modules/addons/kenpesapb/images/close.png" width="16" height="16" border="0" alt="Close" title="Close"></a><?php
} ?></td><?php
} ?>
<?php if ($deletetran == "on") { ?><td bgcolor="#FFFFFF"><a href="addonmodules.php?module=kenpesapb&action=list&ac=del&id=<?php echo $row['id']; ?>"><img src="../modules/addons/kenpesapb/images/delete.png" width="16" height="16" border="0" alt="Delete" title="Delete"></a></td><?php
} ?>
</tr>
<?php
}
}
?>
</tbody>
</table></td>
</tr>
</table>
<p> </p>
<?php
} #list
else if ($_GET['action'] == "details") { #details
$tSQL = full_query("SELECT * FROM tblpbtransactions WHERE id = " . $_GET['id']);
while ($data = mysql_fetch_array($tSQL)) {
?>
<p><b>M-PESA Transaction details</b></p>
<table class="form" width="100%" border="0" cellspacing="2" cellpadding="3">
<tbody><tr><td width="20%" class="fieldlabel">Transaction ID</td><td class="fieldarea"><?php echo $transid = $data['mpesa_code']; ?></td></tr>
<tr>
<td class="fieldlabel">Transaction Date</td>
<td class="fieldarea"><?php echo ($data['mpesa_trx_date']); ?></td>
</tr>
<tr>
<td class="fieldlabel">Transaction Time </td>
<td class="fieldarea"><?php echo $data['mpesa_trx_time']; ?></td>
</tr>
<tr>
<td class="fieldlabel">M-PESA Notification Text </td>
<td class="fieldarea"><?php echo $data['text']; ?></td>
</tr>
<tr>
<td class="fieldlabel">Origin</td>
<td class="fieldarea"><?php echo $data['orig']; ?></td>
</tr>
<tr>
<td class="fieldlabel">Business Terminal MSISDN </td>
<td class="fieldarea"><?php echo $data['dest']; ?></td>
</tr>
<tr>
<td class="fieldlabel">Amount</td>
<td class="fieldarea"><?php echo number_format($data['mpesa_amt'], 2); ?></td>
</tr>
<tr>
<td class="fieldlabel">Account No </td>
<td class="fieldarea"><?php echo $data['mpesa_acc']; ?></td>
</tr>
<tr>
<td class="fieldlabel">Status</td><td class="fieldarea"><?php if ($data['status'] == "Open") { ?> <span class="label active"> <?php echo $data['status'];
} ?></span>
<?php if ($data['status'] == "Closed") { ?>
<span class="label closed">
<?php echo $data['status'];
} ?> </span>
<?php if ($data['status'] != "Open" && $data['status'] != "Closed") { ?>
<span class="label inactive">
<?php echo $data['status']; ?>
<?php
} ?> </span>
</td>
</tr>
<tr>
<td width="20%" class="fieldlabel">Sender Name </td><td class="fieldarea"><?php echo strtoupper($data['mpesa_sender']); ?></td>
</tr>
<tr>
<td class="fieldlabel">Sender Mobile Number </td>
<td class="fieldarea"><?php echo $data['mpesa_msisdn']; ?></td>
</tr>
<tr>
<td class="fieldlabel">IPN Notification Timestamp </td>
<td class="fieldarea"><?php echo fromMySQLDate($data['tstamp']) . ' ' . date('H:i:s', strtotime($data['tstamp'])); ?></td>
</tr>
</tbody></table>
<?php
}
if ($tRes = full_query("SELECT * FROM tblaccounts WHERE transid LIKE '" . $transid . "'")) {
while ($trow = mysql_fetch_array($tRes)) {
?>
<p><b>WHMCS Transaction Lookup</b></p>
<table class="form" width="100%" border="0" cellspacing="2" cellpadding="3">
<tbody><tr><td width="20%" class="fieldlabel">Date</td><td class="fieldarea"><?php echo fromMySQLDate($trow['date']) . ' ' . date('H:i:s', strtotime($trow['date'])); ?></td></tr>
<tr><td class="fieldlabel">Invoice ID</td><td class="fieldarea"><?php echo $invoiceid = $trow['invoiceid']; ?></td></tr>
<tr><td class="fieldlabel">Amount</td><td class="fieldarea"><?php echo number_format($trow['amountin'], 2); ?></td></tr>
<tr>
<td class="fieldlabel">Description</td>
<td class="fieldarea"><?php echo $trow['description']; ?></td>
</tr>
</tbody></table>
<?php
}
}
?>
<?php
if ($iRes = full_query("SELECT * FROM tblinvoices WHERE id = " . $invoiceid)) {
while ($irow = mysql_fetch_array($iRes)) {
?>
<p><b>
WHMCS Invoice Lookup</b></p>
<table class="form" width="100%" border="0" cellspacing="2" cellpadding="3">
<tbody><tr><td width="20%" class="fieldlabel">Invoice ID</td><td class="fieldarea"><a href="invoices.php?action=edit&id=<?php echo $irow['id']; ?>"><?php echo $irow['id']; ?></a></td></tr>
<tr><td class="fieldlabel">Client Name</td><td class="fieldarea"><?php
//get client name
$cres = full_query("SELECT * FROM tblclients WHERE id=" . $irow['userid']);
$cdata = mysql_fetch_array($cres);
$clientname = $cdata['firstname'] . " " . $cdata['lastname'];
?>
<a href="clientssummary.php?userid=<?php echo $irow['userid']; ?>"> <?php echo $clientname; ?></a></td>
</tr>
<tr>
<td class="fieldlabel">Invoice Date </td>
<td class="fieldarea"><?php echo fromMySQLDate($irow['date']); ?></td>
</tr>
<tr>
<td class="fieldlabel">Due Date </td>
<td class="fieldarea"><?php echo fromMySQLDate($irow['duedate']); ?></td>
</tr>
<tr>
<td class="fieldlabel">Date Paid </td>
<td class="fieldarea"><?php echo fromMySQLDate($irow['datepaid']); ?></td>
</tr>
<tr>
<td class="fieldlabel">Invoice Status</td>
<td class="fieldarea"><?php
if ($irow['status'] == "Paid") {
echo '<span class="textgreen">';
} else if ($irow['status'] == "Unpaid") {
echo '<span class="textred">';
} else if ($irow['status'] == "Cancelled") {
echo '<span class="textgrey">';
} else {
echo '<span class="textblack">';
}
echo $irow['status'];
echo "</span>"
?></td>
</tr>
<tr>
<td class="fieldlabel">Sub-Total</td>
<td class="fieldarea"><?php echo number_format($irow['subtotal'], 2); ?></td>
</tr>
<tr>
<td class="fieldlabel">Tax</td>
<td class="fieldarea"><?php echo number_format($irow['tax'], 2); ?></td>
</tr>
<tr>
<td class="fieldlabel">Credit</td>
<td class="fieldarea"><?php echo number_format($irow['credit'], 2); ?></td>
</tr>
<tr>
<td class="fieldlabel">Total</td>
<td class="fieldarea"><?php echo number_format($irow['total'], 2); ?></td></tr>
</tbody></table>
<?php
}
}
} else if ($_GET['action'] == "ipn") { #begin IPN log
?>
<table class="datatable" width="100%" border="0" cellspacing="1" bgcolor="#ECE9D8">
<tr>
<th>Date <img src="images/desc.gif" class="absmiddle"></th>
<th>Description</th>
<th>Username</th>
<th>IPN IP Address/URL </th>
</tr>
<?php
$sql = "SELECT * FROM tblactivitylog WHERE user='Safaricom IPN' ORDER BY id DESC";
$r = full_query($sql);
$n = mysql_num_rows($r);
if ($n <> 0) {
while ($row = mysql_fetch_array($r)) {
?>
<tr>
<td bgcolor="#FFFFFF"><?php echo $row['date']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $row['description']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $row['user']; ?></td>
<td align="right" bgcolor="#FFFFFF"><?php echo $row['ipaddr']; ?></td>
</tr>
<?php
}
}
?>
</table>
<?php
} #end IPN log
elseif ($_GET['action'] == "licence") { #begin licence
?>
<h1>License Information</h1>
<table class="form" width="100%" border="0" cellspacing="2" cellpadding="3">
<tbody><tr><td width="20%" class="fieldlabel">Product Name</td><td class="fieldarea"><?php echo $results['productname']; ?></td></tr>
<tbody><tr><td width="20%" class="fieldlabel">Registered To</td><td class="fieldarea"><?php echo $results['companyname']; ?></td></tr>
<tr><td class="fieldlabel">License Key</td><td class="fieldarea"><?php echo $licensekey; ?></td></tr>
<tr><td class="fieldlabel">Billing Cycle</td><td class="fieldarea"><?php echo $results['billingcycle']; ?></td>
</tr>
<tr><td class="fieldlabel">Status</td><td class="fieldarea"><?php if ($results["status"] == "Active") {
echo '<span class="label active">';
} else {
echo '<span class="label closed">';
}
echo $results["status"] . "</div>"; ?></td></tr>
<tr><td class="fieldlabel">Valid Domains</td><td class="fieldarea"><?php echo $results['validdomain']; ?></td></tr>
<tr><td class="fieldlabel">Valid IP</td><td class="fieldarea"><?php echo $results['validip']; ?></td></tr>
<tr><td class="fieldlabel">Valid Directory</td><td class="fieldarea"><?php echo $results['validdirectory']; ?></td></tr>
<tr><td class="fieldlabel">Registered</td><td class="fieldarea"><?php echo fromMySQLDate($results['regdate']); ?></td></tr>
<tr><td class="fieldlabel">Expires</td><td class="fieldarea"><?php echo $results['nextduedate'] == '0000-00-00' ? "Never" : fromMySQLDate($results['nextduedate']); ?></td></tr>
<tr><td class="fieldlabel">IPN URL</td><td class="fieldarea"><?php echo $IPN_URL; ?></td></tr>
</tbody></table>
<?php
} #end licence
} #isset action
else {
#Home
header("location:{$_SERVER['PHP_SELF']}?module=kenpesapb&action=list");
?>
<h2>Recent M-PESA Pay Bill Transactions </h2>
<table class="datatable" width="100%" border="0" cellspacing="1" bgcolor="#ECE9D8">
<tbody>
<tr>
<th>Date <img src="images/desc.gif" class="absmiddle"></th>
<th>TRANSACTION ID </th>
<th>Sender</th>
<th>Sender No </th>
<th>Amount</th>
<th>Invoice No </th>
<th>Status</th>
<?php if ($opentran == "on") { ?><th width="16"> </th><?php
} ?>
<?php if ($archivetran == "on") { ?><th width="16"> </th><?php
} ?>
<?php if ($closetran == "on") { ?><th width="16"> </th><?php
} ?>
<?php if ($deletetran == "on") { ?><th width="16"> </th><?php
} ?>
</tr>
<?php
$sql = "SELECT * FROM tblpbtransactions";
$sql.= " ORDER BY tstamp DESC LIMIT 0 , 15";
$r = full_query($sql);
$n = mysql_num_rows($r);
if ($n <> 0) {
while ($row = mysql_fetch_array($r)) {
?>
<tr>
<td bgcolor="#FFFFFF"><?php echo $row['tstamp']; ?></td>
<td align="center" bgcolor="#FFFFFF"><a href="addonmodules.php?module=kenpesapb&action=details&id=<?php echo $row['id']; ?>"><?php echo $row['mpesa_code']; ?></a></td>
<td bgcolor="#FFFFFF"><?php echo $row['mpesa_sender']; ?></td>
<td align="right" bgcolor="#FFFFFF"><?php echo $row['mpesa_msisdn']; ?></td>
<td align="right" bgcolor="#FFFFFF"><?php echo number_format($row['mpesa_amt'], 2); ?></td>
<td align="right" bgcolor="#FFFFFF">
<?php if (($row['invoiceid'] <> 0)) { ?> <a href="invoices.php?action=edit&id=<?php echo $row['invoiceid']; ?>"><?php echo $row['invoiceid']; ?></a> <?php
} ?></td>
<td bgcolor="#FFFFFF"><?php if ($row['status'] == "Open") { ?> <span class="label active"> <?php echo $row['status'];
} ?></span>
<?php if ($row['status'] == "Closed") { ?>
<span class="label closed">
<?php echo $row['status'];
} ?> </span>
<?php if ($row['status'] != "Open" && $row['status'] != "Closed") { ?>
<span class="label inactive">
<?php echo $row['status']; ?>
<?php
} ?> </span> </td>
<?php if ($opentran == "on") { ?><td bgcolor="#FFFFFF"><?php if ($row['status'] != "Open") { ?><a href="addonmodules.php?module=kenpesapb&action=list&ac=open&id=<?php echo $row['id']; ?>"><img src="../modules/addons/kenpesapb/images/open.gif" width="16" height="16" border="0" alt="Open" title="Open"></a><?php
} ?></td> <?php
} ?>
<?php if ($archivetran == "on") { ?><td bgcolor="#FFFFFF"><?php if ($row['status'] != "Archived") { ?><a href="addonmodules.php?module=kenpesapb&action=list&ac=archive&id=<?php echo $row['id']; ?>"><img src="../modules/addons/kenpesapb/images/archive.png" width="16" height="16" border="0" alt="Archive" title="Archive"></a><?php
} ?></td> <?php
} ?>
<?php if ($closetran == "on") { ?><td bgcolor="#FFFFFF"><?php if ($row['status'] != "Closed") { ?><a href="addonmodules.php?module=kenpesapb&action=list&ac=close&id=<?php echo $row['id']; ?>"><img src="../modules/addons/kenpesapb/images/close.png" width="16" height="16" border="0" alt="Close" title="Close"></a><?php
} ?></td><?php
} ?>
<?php if ($deletetran == "on") { ?><td bgcolor="#FFFFFF"><a href="addonmodules.php?module=kenpesapb&action=list&ac=del&id=<?php echo $row['id']; ?>"><img src="../modules/addons/kenpesapb/images/delete.png" width="16" height="16" border="0" alt="Delete" title="Delete"></a></td><?php
} ?>
</tr>
<?php
}
#end home
}
?>
</tbody>
</table>
<?php
}
} elseif ($results["status"] == "Invalid") {
# Show Invalid Message
?>
<div class="infobox" style="font-size:16px">Your license key is <span class="label closed" style="font-size:14px">Invalid.</span> Get a valid licence from <a href="https://www.enetonlinesolutions.co.ke/portal/clients/clientarea.php" target="_blank">https://www.enetonlinesolutions.co.ke/</a>. Have Questions? Call +254 726 872 512</div>
<?php
} elseif ($results["status"] == "Expired") {
# Show Expired Message
?>
<div class="infobox" style="font-size:16px">Your license key is <span class="label closed" style="font-size:14px">Expired.</span> Renew you licence from <a href="https://www.enetonlinesolutions.co.ke/portal/clients/clientarea.php" target="_blank">https://www.enetonlinesolutions.co.ke/</a> Have Questions? Call +254 726 872 512</div>
<?php
} elseif ($results["status"] == "Suspended") {
# Show Suspended Message
?>
<div class="infobox" style="font-size:16px">Your license key has been <span class="label closed" style="font-size:14px">Suspended.</span> Have Questions? <a href="https://www.enetonlinesolutions.co.ke/portal/clients/clientarea.php" target="_blank">https://www.enetonlinesolutions.co.ke/</a> or Call +254 726 872 512</div>
<?php
}
#end check licence
}
function kenpesapb_sidebar($vars) {
$sidebar = '';
return $sidebar;
}
//client output
function kenpesapb_clientarea($vars) {
$modulelink = $vars['modulelink'];
$version = $vars['version'];
$option1 = $vars['option1'];
$option2 = $vars['option2'];
$option3 = $vars['option3'];
$option4 = $vars['option4'];
$option5 = $vars['option5'];
$option6 = $vars['option6'];
$LANG = $vars['_lang'];
return array('pagetitle' => 'M-PESA Transactions', 'breadcrumb' => array('index.php?m=kenpesapb' => 'M-PESA Transactions'), 'templatefile' => 'kenpesapb', 'requirelogin' => true, # or false
'vars' => array('testvar' => 'demo', 'anothervar' => 'value', 'sample' => 'test',),);
}
?>
Function Calls
| defined | 1 |
Stats
| MD5 | f30914d238e1a8abad49fd7ad8b98bfc |
| Eval Count | 0 |
| Decode Time | 172 ms |