Final commit before rewrite.
This commit is contained in:
parent
7e947fcf94
commit
aaccb5b2fc
16
view.php
16
view.php
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
$conf = json_decode(file_get_contents('database.conf'));
|
||||
$db = mysqli_init();
|
||||
$db->real_connect($conf->hostname, $conf->username, $conf->password, $conf->database);
|
||||
|
||||
$id = isset($_GET['id']) ? $_GET['id'] : '';
|
||||
|
||||
|
@ -10,10 +12,7 @@ if($id == '' ) {
|
|||
if(!is_numeric($id) || $id <= 0) {
|
||||
$message = 'This image does not exist: bad id format (' . $id . ')';
|
||||
} else {
|
||||
$db = mysqli_init();
|
||||
$db->real_connect($conf->hostname, $conf->username, $conf->password, $conf->database);
|
||||
|
||||
$query = "SELECT extension, created, original FROM screens WHERE id = $id";
|
||||
$query = "SELECT extension, created, original, views FROM screens WHERE id = $id";
|
||||
$result = $db->query($query);
|
||||
|
||||
if($result->num_rows == 0) {
|
||||
|
@ -22,10 +21,19 @@ if($id == '' ) {
|
|||
// load tags
|
||||
|
||||
$image = $result->fetch_object();
|
||||
|
||||
$ip = $_SERVER['remote_addr'];
|
||||
$query = ""
|
||||
$views = $image->views + 1;
|
||||
$query = "UPDATE screens SET views = $views WHERE id = $id";
|
||||
$db->query($query);
|
||||
|
||||
|
||||
$imageOutput = '<img src="/uploads/' . $id . '.' . $image->extension . '" class="image" />';
|
||||
$message = 'Uploaded on: ' . $image->created;
|
||||
$message .= '<br/>Original name: ' . $image->original;
|
||||
$message .= '<br/>View Raw: <a href="/uploads/' . $id . '.' . $image->extension . '">'. $id . '.' . $image->extension . '</a>';
|
||||
$message .= '<br/>Views: ' . $views;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue