File: /home/httpd/html/xdudes.com/admin/apis.php
<?php
require "db.php";
$enabledMap[0] = 'No';
$enabledMap[1] = 'Yes';
if ($_POST['list']) {
foreach ($_POST['list'] as $i) {
if (is_numeric($i)) {
if($_POST['action'] == 'enable') {
dbQuery("UPDATE paysites SET enabled = 1 WHERE `record_num` = '$i'");
dbQuery("UPDATE performers SET enabled = 1 WHERE `site` = '$i'");
} elseif($_POST['action'] == 'disable') {
dbQuery("UPDATE paysites SET enabled = 0 WHERE `record_num` = '$i'");
dbQuery("UPDATE performers SET enabled = 0 WHERE `site` = '$i'");
}
}
}
setMessage('Success!');
header("Location: ".$_SERVER['REQUEST_URI']);
exit();
}
?>
<? require "header.php"; ?>
<div class="content-page">
<div class="header-area">
<div class="breadcrumbs">
<a href="index.php">Admin Home</a>
<span><a href="apis.php">Manage APIs</a></span>
</div>
</div>
<div class="content-outer">
<h2>Manage<strong>APIs</strong></h2>
<div class="content-inner">
<? echo getMessages(); ?>
<form method="POST" action="" class="form" novalidate autocomplete="off">
<table class="pagetable">
<thead>
<tr>
<th>Name</th>
<th>Function Name</th>
<th>Affiliate ID/API Key</th>
<th>Enabled</th>
<th>Performers</th>
<th class="options"></th>
<th style="width:50px">
<label for="check-select-all-1" class="checkbox">
<input type="checkbox" name="select_all" value="1" data-items="list[]" id="check-select-all-1">
<i></i>
</label>
</th>
</tr>
</thead>
<tbody>
<?php $result = dbQuery("SELECT *, (SELECT COUNT(*) FROM `performers` WHERE `site` = `paysites`.`record_num` AND `deleted` = 0) AS `content__amount` FROM `paysites` ORDER BY `name`", false); ?>
<?php if (count($result) == 0) { ?>
<tr><td colspan="7"><div class="notification alert">No APIs found</div></td></tr>
<?php } else { ?>
<?php foreach ($result as $row) { ?>
<tr>
<td>
<?php echo $row['name'] ;?>
</td>
<td><?php echo $row['functionName']; ?></td>
<td><?php if($row['apiData']) { echo truncate($row['apiData'],30); } else { if($row['wmReferral']) { echo "<a target='_blank' href='".$row['wmReferral']."'>Webmaster Program</a>"; } else { echo '-'; } } ?></td>
<td><?php echo $enabledMap[$row['enabled']]; ?></td>
<td><?php echo $row['content__amount']; ?></td>
<td class="options">
<a href='api_log.php?id=<?php echo $row['record_num']; ?>' title="API Last Result" class="btn btn-xs btn-seablue"><i class="ion ion-calendar"></i></a>
<a href="edit_api.php?id=<?php echo $row['record_num']; ?>" class="btn btn-xs btn-orange" title="Edit paysite"><i class="ion ion-edit icon-edit"></i></a>
</td>
<td>
<label class="checkbox">
<input type="checkbox" name="list[]" value="<?php echo $row['record_num']; ?>" id="ids-<?php echo $row['record_num']; ?>"><i></i>
</label>
</td>
</tr>
<?php } ?>
<? } ?>
<?php if(count($result) > 0) { ?>
<tr class="item submit">
<td colspan="7">
<span>
<select name="action" id="changeAction">
<option value="enable">Enable API and Performers</option>
<option value="disable">Disable API and Performers</option>
</select>
</span>
<button type="submit" class="btn action-delete">Process Selected</button>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</form>
</div>
</div>
</div>
<?php require "footer.php"; ?>