Пример #1
0
require 'includes/master.inc.php';
$Auth->requireAdmin('login.php');
$nav = 'applications';
$app = new Application($_GET['id']);
if (!$app->ok()) {
    redirect('index.php');
}
if (isset($_POST['btnSerial'])) {
    if (strlen($_POST['serial']) > 0) {
        $s = new Serial();
        $s->app_id = $app->id;
        $s->dt = dater();
        $s->guid = $_POST['guid'];
        $s->serial = $_POST['serial'];
        $s->insert();
        redirect('pirates.php?id=' . $app->id);
    }
}
$db = Database::getDatabase();
$pirates = $db->getRows("SELECT * FROM pirates WHERE app_id = '{$app->id}' ORDER BY dt DESC");
$serial_count = $db->getValue("SELECT COUNT(*) from pirated_serials WHERE app_id = '{$app->id}'");
$serial_date = $db->getValue("SELECT dt FROM pirated_serials WHERE app_id = '{$app->id}' ORDER BY dt DESC LIMIT 1");
$serial_date = $serial_date ? time2str($serial_date) : 'never';
if (isset($_GET['feed']) && $_GET['feed'] == 'json') {
    $serials = DBObject::glob('Serial', "SELECT * from pirated_serials WHERE app_id = '{$app->id}'");
    $arr = array();
    foreach ($serials as $s) {
        $arr[] = array('dt' => $s->dt, 'guid' => $s->guid, 'serial' => $s->serial);
    }
    die(json_encode($arr));