summary refs log tree commit diff stats
path: root/includes/update.php
blob: 3f2fae1a8868e28086402b907071689756aa0995 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php

$getlast = $mysql_conn->query("SELECT * FROM config WHERE name = \"lastUpdated\"");
$getlast3 = $getlast->fetch_assoc();

$last = $getlast3['value'];
if ($last != date('md'))
{
	$getpending = $mysql_conn->query("SELECT * FROM comics WHERE status = \"pending\" ORDER BY id ASC LIMIT 0,1");
  $getpending3 = $getpending->fetch_assoc();
	if (!empty($getpending3))
	{
		$id = next_comic_id();

    $setcomic = $mysql_conn->prepare("UPDATE comics SET status = \"publish\", comic_id = ? WHERE id = ?");
    $setcomic->bind_param("ii", $id, $getpending3['id']);
    $setcomic->execute() or die($setcomic);

    $insmeta = $mysql_conn->prepare("INSERT INTO meta (comic_id,name,value) VALUES (?,\"pubDate\",\"" . date('Y-m-d H:i:s') . "\")");
    $insmeta->bind_param("i", $getpending3['id']);
		$insmeta->execute() or die($insmeta);

    $setconfig = $mysql_conn->prepare("UPDATE config SET value = ? WHERE name = \"lastUpdated\"");
    $newdate = date('md');
    $setconfig->bind_param("s", $newdate);
    $setconfig->execute();
	}
}

?>