2011-11-04 21:41:18 -04:00
|
|
|
<?php
|
|
|
|
$conf = json_decode(file_get_contents('database.conf'));
|
2011-11-05 01:56:18 -04:00
|
|
|
$db = mysqli_init();
|
|
|
|
$db->real_connect($conf->hostname, $conf->username, $conf->password, $conf->database);
|
2011-11-04 21:41:18 -04:00
|
|
|
|
2011-11-04 22:01:21 -04:00
|
|
|
$id = isset($_GET['id']) ? $_GET['id'] : '';
|
2011-11-04 21:41:18 -04:00
|
|
|
|
|
|
|
if($id == '' ) {
|
|
|
|
// redirect to gallery; do with .htaccess?
|
|
|
|
$message = 'id not set';
|
|
|
|
} else {
|
|
|
|
if(!is_numeric($id) || $id <= 0) {
|
|
|
|
$message = 'This image does not exist: bad id format (' . $id . ')';
|
|
|
|
} else {
|
2011-11-05 01:56:18 -04:00
|
|
|
$query = "SELECT extension, created, original, views FROM screens WHERE id = $id";
|
2011-11-04 21:41:18 -04:00
|
|
|
$result = $db->query($query);
|
|
|
|
|
|
|
|
if($result->num_rows == 0) {
|
|
|
|
$message = 'This image does not exist: not in database';
|
|
|
|
} else {
|
|
|
|
// load tags
|
|
|
|
|
|
|
|
$image = $result->fetch_object();
|
2011-11-05 01:56:18 -04:00
|
|
|
|
|
|
|
$ip = $_SERVER['remote_addr'];
|
|
|
|
$query = ""
|
|
|
|
$views = $image->views + 1;
|
|
|
|
$query = "UPDATE screens SET views = $views WHERE id = $id";
|
|
|
|
$db->query($query);
|
|
|
|
|
|
|
|
|
2011-11-04 22:01:21 -04:00
|
|
|
$imageOutput = '<img src="/uploads/' . $id . '.' . $image->extension . '" class="image" />';
|
2011-11-04 21:41:18 -04:00
|
|
|
$message = 'Uploaded on: ' . $image->created;
|
|
|
|
$message .= '<br/>Original name: ' . $image->original;
|
2011-11-04 22:01:21 -04:00
|
|
|
$message .= '<br/>View Raw: <a href="/uploads/' . $id . '.' . $image->extension . '">'. $id . '.' . $image->extension . '</a>';
|
2011-11-05 01:56:18 -04:00
|
|
|
$message .= '<br/>Views: ' . $views;
|
2011-11-04 21:41:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?><!DOCTYPE html>
|
|
|
|
<head>
|
|
|
|
<head>
|
|
|
|
<title>No Chicks Allowed: Image Repository</title>
|
|
|
|
<meta charset="utf-8" />
|
2011-11-04 22:01:21 -04:00
|
|
|
<link rel="stylesheet" type="text/css" media="all" href="/css/html5reset-1.6.1.css" />
|
|
|
|
<link rel="stylesheet" type="text/css" media="all" href="/css/style.css" />
|
2011-11-04 21:41:18 -04:00
|
|
|
|
|
|
|
<!--[if lt IE 9]>
|
|
|
|
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
|
|
<![endif]-->
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
<header>
|
|
|
|
<h1>title or navigation or something</h1>
|
|
|
|
</header>
|
2011-11-04 23:42:59 -04:00
|
|
|
|
|
|
|
<div id="left">
|
|
|
|
<a href="/<?php echo ($id - 1); ?>" class="navigation"></a>
|
|
|
|
</div>
|
|
|
|
<div id="right">
|
|
|
|
<a href="/<?php echo ($id + 1); ?>" class="navigation"></a>
|
|
|
|
</div>
|
2011-11-04 21:41:18 -04:00
|
|
|
<?if (isset($imageOutput)) { ?>
|
|
|
|
<div id="imageContainer">
|
|
|
|
<?php echo $imageOutput; ?>
|
|
|
|
</div>
|
|
|
|
<?php } ?>
|
|
|
|
<div id="message">
|
|
|
|
<?php echo $message; ?>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
|
|
|
|
</body>
|
|
|
|
</html>
|