2013-02-09 06:29:47 +00:00
|
|
|
<?php
|
|
|
|
session_start();
|
2013-02-09 07:48:52 +00:00
|
|
|
|
2013-02-09 10:09:07 +00:00
|
|
|
/* -----------------------------------------------------------
|
|
|
|
*
|
|
|
|
* UnPS-GAMA Image Host
|
|
|
|
* Copyright (c) 2013 UnPS-GAMATechnologies
|
2013-02-12 09:38:50 +00:00
|
|
|
* Author: David Todd (c0de) of http://www.unps-gama.info and http://unps.us
|
2013-02-09 10:09:07 +00:00
|
|
|
*
|
|
|
|
* -----------------------------------------------------------
|
|
|
|
* TODO:
|
|
|
|
*
|
|
|
|
* JavaScript fo show bigger image if clicked
|
2013-02-15 21:39:34 +00:00
|
|
|
* Recently Uploaded Pictures on sidebar
|
2013-02-15 22:29:23 +00:00
|
|
|
* Automatic thumbnail generation - genthumb() (100px x 100px)
|
2013-02-15 22:47:30 +00:00
|
|
|
* Force Spaces in tags
|
2013-02-12 09:38:50 +00:00
|
|
|
* Fix headstuff() and title()
|
2013-02-10 00:39:59 +00:00
|
|
|
* Multiple tags without search?
|
|
|
|
* Classes?
|
2013-02-09 10:09:07 +00:00
|
|
|
*
|
|
|
|
* -----------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2013-02-09 06:29:47 +00:00
|
|
|
$thelist = '';
|
2013-02-09 10:09:07 +00:00
|
|
|
$img = '';
|
2013-02-09 06:29:47 +00:00
|
|
|
$id = '';
|
|
|
|
$location = '';
|
|
|
|
$type = '';
|
|
|
|
$size = '';
|
|
|
|
$time = '';
|
|
|
|
$comment = '';
|
|
|
|
$username = '';
|
|
|
|
$tags = '';
|
2013-02-15 22:29:23 +00:00
|
|
|
$_SESSION['noimg'] = '';
|
2013-02-09 07:48:52 +00:00
|
|
|
|
2013-02-10 00:39:59 +00:00
|
|
|
// GET functions
|
|
|
|
|
2013-02-09 07:48:52 +00:00
|
|
|
function uname(){
|
|
|
|
if(!empty($_GET['uname'])){ // Show list of pictures uploaded by certain username
|
2013-02-10 00:39:59 +00:00
|
|
|
echo "<center><h4>Pictures uploaded from Username: ".$_GET['uname'].":</h4></center><br />";
|
2013-02-09 07:48:52 +00:00
|
|
|
require('dbsettings.php');
|
|
|
|
$uname = sanitize($_GET['uname']);
|
2013-02-15 21:39:34 +00:00
|
|
|
$sql = 'SELECT * FROM `share` WHERE `username` = "'.$uname.'"';
|
|
|
|
|
|
|
|
if(!$result = $db->query($sql)){
|
|
|
|
die('There was an error running the query [' . $db->error . ']');
|
|
|
|
}
|
|
|
|
|
|
|
|
while($row = $result->fetch_assoc()){
|
|
|
|
$_SESSION['noimg'] = 'uname';
|
|
|
|
$id = $row['id'];
|
|
|
|
$img = $row['name'];
|
|
|
|
$location = $row['location'];
|
|
|
|
$type = $row['type'];
|
|
|
|
$size = $row['size'];
|
|
|
|
$time = $row['time'];
|
|
|
|
$comment = $row['comment'];
|
|
|
|
$username = $row['username'];
|
|
|
|
$tags = $row['tags'];
|
|
|
|
echo "<center><a href=\"?img=$img\"><img src=\"thumbs/$img\" alt=\"Thumbnail of $img\" align=\"middle\"></a><br /><a href=\"?img=$img\">$img</a> - $time - $size <br /> Tags: ";
|
|
|
|
$tags = explode(" ", $tags);
|
|
|
|
foreach($tags as $tag){
|
|
|
|
echo "<a href=\"?tag=$tag\">$tag</a> "; // For future use - catagorize by tag
|
2013-02-09 07:48:52 +00:00
|
|
|
}
|
2013-02-15 21:39:34 +00:00
|
|
|
echo "</center><br />";
|
2013-02-09 07:48:52 +00:00
|
|
|
}
|
2013-02-15 21:39:34 +00:00
|
|
|
$result->free();
|
|
|
|
//echo "<br /><hr /><br />";
|
2013-02-09 07:48:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function tag(){
|
|
|
|
if(!empty($_GET['tag'])){ // Show list of pictures according to one tag - maybe multiple tags in the future
|
2013-02-10 00:39:59 +00:00
|
|
|
echo "<center><h4>Pictures uploaded with the tag: ".$_GET['tag'].":</h4></center><br />";
|
2013-02-09 07:48:52 +00:00
|
|
|
require('dbsettings.php');
|
|
|
|
$tag = sanitize($_GET['tag']);
|
2013-02-15 21:39:34 +00:00
|
|
|
$sql = 'SELECT * FROM `share` WHERE `tags` LIKE "%'.$tag.'%"';
|
|
|
|
|
|
|
|
if(!$result = $db->query($sql)){
|
|
|
|
die('There was an error running the query [' . $db->error . ']');
|
2013-02-09 07:48:52 +00:00
|
|
|
}
|
2013-02-15 21:39:34 +00:00
|
|
|
|
|
|
|
while($row = $result->fetch_assoc()){
|
|
|
|
$_SESSION['noimg'] = 'tag';
|
|
|
|
$id = $row['id'];
|
|
|
|
$img = $row['name'];
|
|
|
|
$location = $row['location'];
|
|
|
|
$type = $row['type'];
|
|
|
|
$size = $row['size'];
|
|
|
|
$time = $row['time'];
|
|
|
|
$comment = $row['comment'];
|
|
|
|
$username = $row['username'];
|
|
|
|
$tags = $row['tags'];
|
|
|
|
echo "<center><a href=\"?img=$img\"><img src=\"thumbs/$img\" alt=\"Thumbnail of $img\" align=\"middle\"></a> <br /> <a href=\"?img=$img\">$img</a> - $time - $size - Uploader: <a href=\"?uname=$username\">$username</a><br /></center><br />";
|
|
|
|
}
|
|
|
|
$result->free();
|
|
|
|
//echo "<br /><hr /><br />";
|
2013-02-09 07:48:52 +00:00
|
|
|
}
|
|
|
|
}
|
2013-02-09 06:29:47 +00:00
|
|
|
|
2013-02-09 11:27:02 +00:00
|
|
|
function search(){
|
2013-02-12 09:38:50 +00:00
|
|
|
if(!empty($_GET['search'])){ // Show list of pictures according to search term
|
2013-02-09 11:27:02 +00:00
|
|
|
$search = sanitize($_GET['search']);
|
|
|
|
$search = explode(" ", $search);
|
|
|
|
echo "<center><h4>Pictures found using search terms: ";
|
|
|
|
foreach ($search as $searches){
|
|
|
|
echo $searches." ";
|
|
|
|
}
|
2013-02-10 00:39:59 +00:00
|
|
|
echo ":</h4></center><br />";
|
2013-02-09 11:27:02 +00:00
|
|
|
require('dbsettings.php');
|
2013-02-15 21:39:34 +00:00
|
|
|
$sql = "SELECT * FROM `share` WHERE `tags` LIKE '%".$search[0]."%'";
|
2013-02-09 11:27:02 +00:00
|
|
|
for($i=1; $i<count($search); $i++){
|
2013-02-15 21:39:34 +00:00
|
|
|
$sql = $sql." AND `tags` LIKE '%".$search[$i]."%'";
|
2013-02-09 11:27:02 +00:00
|
|
|
}
|
2013-02-15 21:39:34 +00:00
|
|
|
if(!$result = $db->query($sql)){
|
|
|
|
die('There was an error running the query [' . $db->error . ']');
|
|
|
|
}
|
|
|
|
|
|
|
|
while($row = $result->fetch_assoc()){
|
|
|
|
$_SESSION['noimg'] = 'search';
|
|
|
|
$id = $row['id'];
|
|
|
|
$img = $row['name'];
|
|
|
|
$location = $row['location'];
|
|
|
|
$type = $row['type'];
|
|
|
|
$size = $row['size'];
|
|
|
|
$time = $row['time'];
|
|
|
|
$comment = $row['comment'];
|
|
|
|
$username = $row['username'];
|
|
|
|
$tags = $row['tags'];
|
|
|
|
echo "<center><a href=\"?img=$img\"><img src=\"thumbs/$img\" alt=\"Thumbnail of $img\" align=\"middle\"></a><br /> <a href=\"?img=$img\">$img</a> - $time - $size - Uploader: <a href=\"?uname=$username\">$username</a><br /></center>";
|
2013-02-10 00:39:59 +00:00
|
|
|
}
|
2013-02-15 21:39:34 +00:00
|
|
|
$result->free();
|
|
|
|
//echo "<br /><hr /><br />";
|
2013-02-10 00:39:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function upload(){
|
|
|
|
if(isset($_GET['upload'])){
|
|
|
|
$max_file_size="4096";
|
|
|
|
$file_uploads="1";
|
|
|
|
$websitename="UnPS-GAMA Image Host Uploader";
|
|
|
|
$allow_types=array("jpg","gif","png","bmp","JPEG","JPG","GIF","PNG");
|
|
|
|
echo "
|
|
|
|
<center>
|
2013-02-15 21:39:34 +00:00
|
|
|
<form name=\"uploadform\" action=\"\" method=\"post\" enctype=\"multipart/form-data\">
|
2013-02-10 00:39:59 +00:00
|
|
|
<table>
|
|
|
|
<tr>
|
|
|
|
<td colspan=\"2\">
|
|
|
|
<h3>Upload Pictures Here</h3>
|
|
|
|
<pre>All fields required</pre>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td colspan=\"2\" class=\"upload_info\">
|
|
|
|
<b>Allowed Types:</b> jpg, gif, png, bmp<br />
|
|
|
|
<b>Max size per file:</b> 4 MB.
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td class=\"table_body\" width=\"30%\"><b>Select File:</b> </td>
|
|
|
|
<td class=\"table_body\" width=\"70%\"><input type=\"file\" name=\"file\" id=\"file\" size=\"70\" /></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td class=\"table_body\" width=\"30%\"><b>Your Name: </b></td>
|
|
|
|
<td class=\"table_body\" width=\"70%\"><input type=\"text\" name=\"username\" id=\"username\" size=\"70\" /></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td class=\"table_body\" width=\"30%\"><b>Comment: </b></td>
|
|
|
|
<td class=\"table_body\" width=\"70%\"><input type=\"text\" name=\"comment\" id=\"comment\" size=\"70\" /></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td class=\"table_body\" width=\"30%\"><b>Tags</b> (spaces only):</td>
|
|
|
|
<td class=\"table_body\" width=\"70%\"><input type=\"text\" name=\"tags\" id=\"tags\" size=\"70\" /></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td colspan=\"2\">
|
|
|
|
<input type=\"hidden\" name=\"submit\" value=\"true\" />
|
|
|
|
<input type=\"reset\" name=\"reset\" value=\" Reset Form \" onclick=\"window.location.reload(true);\" />
|
|
|
|
<input type=\"submit\" value=\" Upload \" />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</form>
|
|
|
|
</center>
|
|
|
|
<hr /><br />
|
|
|
|
";
|
|
|
|
}
|
|
|
|
if(isset($_POST['submit'])){
|
|
|
|
if(!isset($_POST['username']) || !isset($_POST['comment']) || !isset($_POST['tags'])) die("Please fill in the form completly");
|
|
|
|
require('dbsettings.php');
|
|
|
|
|
|
|
|
$location = 'Pictures';
|
|
|
|
$extensions = array('png', 'gif', 'jpg', 'jpeg', 'bmp');
|
|
|
|
$short = substr(number_format(time() * mt_rand(),0,'',''),0,10);
|
|
|
|
$short = base_convert($short, 10, 36);
|
|
|
|
|
|
|
|
$upusername = $_POST['username'];
|
|
|
|
$upcomment = $_POST['comment'];
|
|
|
|
$tags = $_POST['tags'];
|
|
|
|
$name = $_FILES["file"]["name"];
|
|
|
|
$type = $_FILES["file"]["type"];
|
|
|
|
$size = ($_FILES["file"]["size"] / 1024); // get size of file in Kb
|
|
|
|
|
|
|
|
$name = cln_file_name($name);
|
|
|
|
$type = sanitize($type);
|
|
|
|
$size = sanitize($size);
|
|
|
|
$upcomment = comment($upcomment);
|
|
|
|
$tags = sanitize($tags);
|
|
|
|
$upusername = sanitize($upusername);
|
|
|
|
|
2013-02-12 09:38:50 +00:00
|
|
|
//$notspace = array("\,", ".", "/", "\\", ":", "-", "_", "+", "=", "~", "#", "&", "");
|
|
|
|
//$tags = preg_replace($notspace, " ", $tags);
|
|
|
|
|
2013-02-10 00:39:59 +00:00
|
|
|
$size = round($size, 2)." Kb";
|
2013-02-12 09:38:50 +00:00
|
|
|
$time = date("d/j/y - g:i:s a");
|
2013-02-10 00:39:59 +00:00
|
|
|
|
|
|
|
$file_ext = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
|
|
|
|
if(!in_array($file_ext, $extensions))die("Wrong or no file extension"); // stop the upload if it's wrong
|
|
|
|
$name = $short.".".$file_ext;
|
|
|
|
|
2013-02-12 09:38:50 +00:00
|
|
|
if (($_FILES["file"]["size"] < 4000000000)){
|
2013-02-10 00:39:59 +00:00
|
|
|
if ($_FILES["file"]["error"] > 0){
|
|
|
|
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
|
|
|
|
}else{
|
|
|
|
if (file_exists("Pictures/" . $name)){
|
|
|
|
echo $name." already exists. ";
|
|
|
|
}else{
|
|
|
|
if(preg_match('/php/i', $name) || preg_match('/phtml/i', $name) || preg_match('/htaccess/i', $name)){
|
|
|
|
echo $name." is not allowed, sorry about that...";
|
|
|
|
}else{
|
2013-02-15 21:39:34 +00:00
|
|
|
$sql="INSERT INTO `share` (name, location, type, size, time, comment, username, tags) VALUES ('$name', '$location', '$type', '$size', '$time', '$upcomment', '$upusername', '$tags')";
|
|
|
|
if($result = $db->query($sql)){
|
|
|
|
//$sql = "UPDATE `recentpics` SET name = '-$name' WHERE id = 1"; // Not currently working
|
|
|
|
//$result=mysql_query($sql);
|
|
|
|
//if($result){
|
|
|
|
move_uploaded_file($_FILES["file"]["tmp_name"], "Pictures/" . $name);
|
2013-02-15 22:29:23 +00:00
|
|
|
$donefile = 'Pictures/'.$name;
|
|
|
|
genthumb($donefile);
|
2013-02-15 21:39:34 +00:00
|
|
|
echo "Stored at: <a href='?img=$name'>". $name."</a>";
|
|
|
|
//}else{
|
|
|
|
// echo "There was a problem uploading this file.";
|
|
|
|
//}
|
|
|
|
}elseif(!$result = $db->query($sql)){
|
|
|
|
die('There was a problem trying to upload your file - [' . $db->error . ']');
|
|
|
|
}else{
|
2013-02-10 00:39:59 +00:00
|
|
|
echo "There was a problem trying to upload your file - Could be a database error";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-02-09 11:27:02 +00:00
|
|
|
}
|
2013-02-10 00:39:59 +00:00
|
|
|
}else{
|
|
|
|
die("File too big!");
|
2013-02-09 11:27:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-10 00:39:59 +00:00
|
|
|
// END OF GET FUNCTIONS
|
|
|
|
|
2013-02-15 22:29:23 +00:00
|
|
|
function genthumb($input){
|
|
|
|
echo "Placeholder for automatic 100x100px thumbnail generation of new pictures<br />\n";
|
|
|
|
}
|
|
|
|
|
2013-02-09 06:29:47 +00:00
|
|
|
function sanitize($input){
|
|
|
|
if ($input == null) die("Sanatize() - No Input Provided, Aborting\r\n<br>");
|
2013-02-15 21:39:34 +00:00
|
|
|
include('dbsettings.php');
|
2013-02-09 06:29:47 +00:00
|
|
|
$output = strip_tags($input);
|
|
|
|
$output = stripslashes($output);
|
2013-02-15 21:39:34 +00:00
|
|
|
$output = $db->real_escape_string($output);
|
2013-02-09 06:29:47 +00:00
|
|
|
$output = strtolower($output);
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
2013-02-10 00:39:59 +00:00
|
|
|
function comment($input){
|
|
|
|
if ($input == null) die("Sanatize() - No Input Provided, Aborting\r\n<br>");
|
2013-02-15 21:39:34 +00:00
|
|
|
include('dbsettings.php');
|
2013-02-10 00:39:59 +00:00
|
|
|
$output = strip_tags($input);
|
|
|
|
$output = stripslashes($output);
|
2013-02-15 21:39:34 +00:00
|
|
|
$output = $db->real_escape_string($output);
|
2013-02-10 00:39:59 +00:00
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
|
|
|
function cln_file_name($string) {
|
|
|
|
$cln_filename_find=array("/\.[^\.]+$/", "/[^\d\w\s-]/", "/\s\s+/", "/[-]+/", "/[_]+/");
|
2013-02-12 09:38:50 +00:00
|
|
|
$cln_filename_repl=array("", "", " ", "-", "_");
|
2013-02-10 00:39:59 +00:00
|
|
|
$string=preg_replace($cln_filename_find, $cln_filename_repl, $string);
|
|
|
|
return trim($string);
|
|
|
|
}
|
|
|
|
|
|
|
|
// MAIN PROGRAM
|
|
|
|
|
2013-02-09 06:29:47 +00:00
|
|
|
function imgstuff(){
|
2013-02-12 09:38:50 +00:00
|
|
|
// My little cheat to be able to display all the different items in the same area
|
2013-02-09 07:48:52 +00:00
|
|
|
uname();
|
|
|
|
tag();
|
2013-02-09 11:27:02 +00:00
|
|
|
search();
|
2013-02-10 00:39:59 +00:00
|
|
|
upload();
|
2013-02-12 09:38:50 +00:00
|
|
|
// Basically all my functions are used as part of one big one, but more organized into smaller sections
|
2013-02-09 06:29:47 +00:00
|
|
|
if (empty($_GET['img']) || $_GET['img'] == null || $_GET['img'] == ''){
|
|
|
|
$img = '';
|
|
|
|
}else{
|
|
|
|
$img = $_GET["img"]; // get the image
|
|
|
|
}
|
|
|
|
if(!empty($img) || $img != null || $img != ''){
|
|
|
|
require('dbsettings.php');
|
|
|
|
$img = sanitize($img); // clean image string
|
2013-02-15 21:39:34 +00:00
|
|
|
$sql = "SELECT * FROM `share` WHERE `name` = '$img' LIMIT 1";
|
|
|
|
if(!$result = $db->query($sql)){
|
|
|
|
die('There was an error running the query [' . $db->error . ']');
|
|
|
|
};
|
|
|
|
$row = $result->fetch_assoc();
|
2013-02-09 06:29:47 +00:00
|
|
|
if ($row){
|
|
|
|
$_SESSION['noimg'] = false;
|
|
|
|
$_SESSION['id'] = $row['id'];
|
|
|
|
$_SESSION['img'] = $row['name'];
|
|
|
|
$_SESSION['location'] = $row['location'];
|
|
|
|
$_SESSION['type'] = $row['type'];
|
|
|
|
$_SESSION['size'] = $row['size'];
|
|
|
|
$_SESSION['time'] = $row['time'];
|
|
|
|
$_SESSION['comment'] = $row['comment'];
|
|
|
|
$_SESSION['username'] = $row['username'];
|
|
|
|
$_SESSION['tags'] = $row['tags'];
|
2013-02-12 09:38:50 +00:00
|
|
|
echo "<center><img id='the_pic' class='fit' src=\"".$_SESSION['location']."/$img\" /><br /></center>";
|
2013-02-09 06:29:47 +00:00
|
|
|
//echo "$id<br>$img<br>$location<br>$type<br>$size<br>$time<br>$comment<br>$username<br>$tags\n";
|
|
|
|
}else{
|
|
|
|
$_SESSION['noimg'] = true;
|
|
|
|
echo "<center><h3>That image was not found in our database D:</h3></center>";
|
|
|
|
}
|
2013-02-15 21:39:34 +00:00
|
|
|
$result->free();
|
2013-02-09 06:29:47 +00:00
|
|
|
}else{
|
2013-02-15 21:39:34 +00:00
|
|
|
if($_SESSION['noimg'] == 'search' || $_SESSION['noimg'] == 'tag' || $_SESSION['noimg'] == 'uname'){
|
|
|
|
}else{
|
|
|
|
noimg();
|
|
|
|
$_SESSION['noimg'] = true;
|
|
|
|
}
|
2013-02-09 06:29:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-10 00:39:59 +00:00
|
|
|
// END OF MAIN PROGRAM
|
|
|
|
|
|
|
|
function headstuff(){ // Sets the meta tags - WIP/iffy
|
|
|
|
if(isset($_SESSION['img'])){
|
|
|
|
echo "<meta property=\"og:title\" content=\"".$_SESSION['img']."\" />\n";
|
|
|
|
echo " <meta property=\"og:url\" content=\"http://img.unps-gama.info/index.php?img=".$_SESSION['img']."\" />\n";
|
|
|
|
echo " <meta property=\"og:image\" content=\"http://img.unps-gama.info/".$_SESSION['location']."/".$_SESSION['img']."\" />\n";
|
|
|
|
echo " <meta property=\"og:description\" content=\"".$_SESSION['comment']."\" />\n";
|
|
|
|
}
|
2013-02-09 06:29:47 +00:00
|
|
|
}
|
|
|
|
|
2013-02-10 00:39:59 +00:00
|
|
|
function textstuff(){ // Sets up right side box of info under the other sidebars
|
2013-02-09 06:29:47 +00:00
|
|
|
if($_SESSION['noimg'] == false){
|
|
|
|
echo "<div align=\"left\">\n";
|
|
|
|
echo "<h3>Image Name:</h3><code> - ".$_SESSION['img']."</code>\n";
|
|
|
|
echo "<h3>Image Type:</h3><code> - ".$_SESSION['type']."</code>\n";
|
|
|
|
echo "<h3>Image Size:</h3><code> - ".$_SESSION['size']."</code>\n";
|
|
|
|
echo "<h3>Time Uploaded:</h3><code> - ".$_SESSION['time']."</code>\n";
|
2013-02-09 07:48:52 +00:00
|
|
|
echo "<h3>Username:</h3><code> - ";
|
|
|
|
$username = $_SESSION['username'];
|
|
|
|
echo "<a href=\"?uname=$username\">$username</a>"; // For future use - catagorize by username
|
|
|
|
echo "</code>\n";
|
2013-02-09 06:29:47 +00:00
|
|
|
echo "<h3>Comment:</h3><code> - ".$_SESSION['comment']."</code>\n";
|
2013-02-09 07:48:52 +00:00
|
|
|
echo "<h3>Tags:</h3><code> - ";
|
|
|
|
$tags = $_SESSION['tags'];
|
|
|
|
$tags = explode(" ", $tags);
|
|
|
|
foreach($tags as $tag){
|
|
|
|
echo "<a href=\"?tag=$tag\">$tag</a> "; // For future use - catagorize by tag
|
|
|
|
}
|
|
|
|
echo "</code>\n";
|
2013-02-09 06:29:47 +00:00
|
|
|
echo "</div>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-10 00:39:59 +00:00
|
|
|
function noimg(){ // Shown in place of the image if one isn't available
|
|
|
|
$thelist = '';
|
|
|
|
// Last Modified not working, so removed for the time being
|
2013-02-09 07:48:52 +00:00
|
|
|
if($handle = opendir('Pictures')){
|
|
|
|
while(false != ($file = readdir($handle))){
|
|
|
|
if($file != "." && $file != ".." && $file != ".htaccess"){
|
2013-02-15 22:29:23 +00:00
|
|
|
//$thelist .= '<a href="?img='.$file.'"><img src="thumbs/'.$file.'" alt="Thumbnail for '.$file.'" /><br /> └ '.$file.'</a></font><br /><p></p>'."\n";
|
|
|
|
$thelist .= "-".$file;
|
2013-02-09 07:48:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir($handle);
|
|
|
|
}
|
2013-02-09 06:29:47 +00:00
|
|
|
echo "
|
|
|
|
<p>
|
|
|
|
Please specify an image with the url:
|
|
|
|
<code>
|
|
|
|
img.unps-gama.info/?img=(IMGAGE STUFF HERE)
|
|
|
|
</code>
|
|
|
|
</p>
|
|
|
|
<center>
|
2013-02-15 22:29:23 +00:00
|
|
|
<h4>Uploaded Pictures:</h4>
|
|
|
|
";
|
|
|
|
$thelist = explode("-", $thelist);
|
|
|
|
foreach($thelist as $pics){
|
|
|
|
if($pics == '' || $pics == null){
|
|
|
|
echo '';
|
|
|
|
}else{
|
|
|
|
echo '<a href="?img='.$pics.'"><img src="thumbs/'.$pics.'" alt="'.$pics.'" title="'.$pics.'"/></a>'."\n ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo"
|
2013-02-09 06:29:47 +00:00
|
|
|
</center>
|
|
|
|
";
|
|
|
|
}
|
|
|
|
|
2013-02-12 09:38:50 +00:00
|
|
|
function title(){ // Suffers same problem as headstuff()
|
2013-02-10 00:39:59 +00:00
|
|
|
if(!isset($_SESSION['img'])){
|
2013-02-09 07:48:52 +00:00
|
|
|
echo "";
|
2013-02-09 06:29:47 +00:00
|
|
|
}else{
|
2013-02-10 00:39:59 +00:00
|
|
|
echo " - Now Showing: ".$_SESSION['img'];
|
2013-02-09 06:29:47 +00:00
|
|
|
}
|
|
|
|
}
|
2013-02-09 07:48:52 +00:00
|
|
|
?>
|
2013-02-09 06:29:47 +00:00
|
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml" prefix="og: http://ogp.me/ns#">
|
2013-02-12 09:38:50 +00:00
|
|
|
<!--
|
|
|
|
* -----------------------------------------------------------
|
|
|
|
*
|
|
|
|
* UnPS-GAMA Image Host
|
|
|
|
* Copyright (c) 2013 UnPS-GAMATechnologies
|
|
|
|
* Author: David Todd (c0de) of http://www.unps-gama.info and http://unps.us
|
|
|
|
*
|
|
|
|
* -----------------------------------------------------------
|
|
|
|
* TODO:
|
|
|
|
*
|
|
|
|
* JavaScript fo show bigger image if clicked
|
2013-02-15 21:39:34 +00:00
|
|
|
* Recently Uploaded Pictures on sidebar
|
2013-02-15 22:47:30 +00:00
|
|
|
* Automatic thumbnail generation - genthumb() (100px x 100px)
|
|
|
|
* Force spaces on tags
|
2013-02-12 09:38:50 +00:00
|
|
|
* Fix headstuff() and title()
|
|
|
|
* Multiple tags without search?
|
|
|
|
* Classes?
|
|
|
|
*
|
|
|
|
* -----------------------------------------------------------
|
|
|
|
*
|
|
|
|
-->
|
2012-11-16 09:15:24 +00:00
|
|
|
<head>
|
2013-02-09 06:29:47 +00:00
|
|
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
|
|
|
<meta name="description" content="Image Host for UnProfessional Standards" />
|
2012-11-16 09:15:24 +00:00
|
|
|
<meta name="keywords" content="GAMA,UnPS,upstandards,unps-gama,gama-unps,unps,gama,davitech,davitodd" />
|
|
|
|
<meta name="author" content="David Todd" />
|
2013-02-12 09:38:50 +00:00
|
|
|
<?php //headstuff(); ?>
|
|
|
|
<title>UnPS-GAMA Image Host<?php //title(); ?></title>
|
2013-02-09 06:29:47 +00:00
|
|
|
<link rel="shortcut icon" type="image/ico" href="favicon.ico" />
|
|
|
|
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
|
|
|
|
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
|
|
|
|
<script src="jquery.js"></script>
|
2012-11-16 09:15:24 +00:00
|
|
|
<script type="text/javascript" language="JavaScript">
|
|
|
|
function set_body_height(){
|
|
|
|
var wh = $(window).height();
|
|
|
|
$('body').attr('style', 'height:' + wh + 'px;');
|
|
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
|
|
set_body_height();
|
|
|
|
$(window).bind('resize', function() { set_body_height(); });
|
|
|
|
});
|
|
|
|
</script>
|
2013-02-09 06:29:47 +00:00
|
|
|
<style type="text/css">
|
2012-11-16 09:15:24 +00:00
|
|
|
.fit {
|
|
|
|
max-width: 100%;
|
|
|
|
max-height: 100%;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</head>
|
2013-02-09 06:29:47 +00:00
|
|
|
<body>
|
|
|
|
<div id="page_wrap">
|
|
|
|
<div id="header">
|
|
|
|
<img src="header.png" alt="Header image"/>
|
|
|
|
</div>
|
2013-02-09 07:48:52 +00:00
|
|
|
|
2013-02-09 06:29:47 +00:00
|
|
|
<div id="main_navi">
|
|
|
|
<ul class="left">
|
|
|
|
<li><a href="http://www.unps-gama.info">Home</a></li>
|
2013-02-15 22:47:30 +00:00
|
|
|
<li><a href="../img">Images</a></li>
|
2013-02-09 06:29:47 +00:00
|
|
|
<li><a href="http://unps.us" target="_unps">Shortener</a></li>
|
|
|
|
<li><a href="http://p.unps.us" target="_pro">Projects</a></li>
|
|
|
|
<li><a href="https://github.com/alopexc0de/GAMA-Site" target="_git">GitHub</a></li>
|
|
|
|
<li><a href="http://www.unps-gama.info/ToS.html">Terms of Service</a></li>
|
2013-02-09 07:48:52 +00:00
|
|
|
<li><a href="http://www.unps-gama.info/privacy.html">Privacy Policy</a></li>
|
2013-02-09 06:29:47 +00:00
|
|
|
</ul>
|
|
|
|
|
|
|
|
<ul class="right">
|
|
|
|
<li class="twitter"><a href="http://twitter.com/upstandards" title="Follow UnPS on twitter">TWITTER</a></li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
2013-02-09 07:48:52 +00:00
|
|
|
|
2013-02-09 06:29:47 +00:00
|
|
|
<div class="clear"></div>
|
2013-02-09 07:48:52 +00:00
|
|
|
|
2013-02-09 06:29:47 +00:00
|
|
|
<div id="container">
|
|
|
|
<div id="main">
|
|
|
|
<div class="sticky">
|
2013-02-15 21:39:34 +00:00
|
|
|
Thumbnails need work
|
2013-02-09 06:29:47 +00:00
|
|
|
</div>
|
|
|
|
<div class="post">
|
2013-02-15 21:39:34 +00:00
|
|
|
<div class="entry"><!-- Begin image stuff php -->
|
2013-02-09 06:29:47 +00:00
|
|
|
<?php
|
|
|
|
imgstuff();
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2013-02-09 07:48:52 +00:00
|
|
|
|
2013-02-09 06:29:47 +00:00
|
|
|
<div id="sidebar">
|
2013-02-09 11:27:02 +00:00
|
|
|
<ul>
|
|
|
|
<li class="widget widget_search">
|
|
|
|
<div id="search">
|
2013-02-10 00:39:59 +00:00
|
|
|
<form action="" method="get" name="search" id="search">
|
2013-02-09 11:27:02 +00:00
|
|
|
<input name="search" id="search" type="text" placeholder="Search" />
|
2013-02-12 09:38:50 +00:00
|
|
|
<input id="submit" name="submit" type="submit" value=" Search " />
|
2013-02-09 11:27:02 +00:00
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
2013-02-15 22:47:30 +00:00
|
|
|
<!--<br /> Might not keep this
|
2013-02-09 06:29:47 +00:00
|
|
|
<ul>
|
|
|
|
<li class="widget widget_text">
|
|
|
|
<div class="textwidget">
|
|
|
|
<span>
|
|
|
|
ADS GO HERE
|
|
|
|
<script type="text/javascript">
|
|
|
|
//<!--
|
|
|
|
google_ad_client = "ca-pub-6762927271223365";
|
|
|
|
/* sidebar ads */
|
|
|
|
google_ad_slot = "1523932882";
|
|
|
|
google_ad_width = 120;
|
|
|
|
google_ad_height = 240;
|
2013-02-15 22:47:30 +00:00
|
|
|
//- ->
|
2013-02-09 06:29:47 +00:00
|
|
|
</script>
|
|
|
|
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</li>
|
2013-02-15 22:47:30 +00:00
|
|
|
</ul>-->
|
|
|
|
<!--<br /> Might not keep this
|
2013-02-09 06:29:47 +00:00
|
|
|
<ul>
|
|
|
|
<li class="widget widget_text">
|
|
|
|
<div class="textwidget">
|
|
|
|
<span>
|
|
|
|
Social Media Buttons Here
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</li>
|
2013-02-15 22:47:30 +00:00
|
|
|
</ul>-->
|
|
|
|
<!-- This is what I want the end result of the recently uploaded pictures to look like- ->
|
2013-02-15 22:29:23 +00:00
|
|
|
<br />
|
|
|
|
<ul>
|
|
|
|
<li class="widget widget_text">
|
|
|
|
<div class="textwidget">
|
|
|
|
<h3>Recently Uploaded Pictures</h3><br />
|
2013-02-15 22:47:30 +00:00
|
|
|
<a href="?img=1607vhu.png"><img src="thumbs/1607vhu.png" alt="1607vhu.png" title="1607vhu.png"/></a>
|
2013-02-15 22:29:23 +00:00
|
|
|
<a href="?img=icbqp9.jpg"><img src="thumbs/icbqp9.jpg" alt="icbqp9.jpg" title="icbqp9.jpg"/></a>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
2013-02-15 22:47:30 +00:00
|
|
|
<!-------- Make what's commented below resemble (in output) what happens above-->
|
2013-02-15 21:39:34 +00:00
|
|
|
<br />
|
|
|
|
<ul>
|
|
|
|
<li class="widget widget_text">
|
|
|
|
<div class="textwidget">
|
2013-02-15 22:47:30 +00:00
|
|
|
<h3>Recently Uploaded Pictures</h3><br />
|
2013-02-15 21:39:34 +00:00
|
|
|
<?php // Not currently working
|
2013-02-15 22:47:30 +00:00
|
|
|
require('dbsettings.php');
|
|
|
|
$sql = "SELECT * FROM `recentpics` WHERE `id` = 1";
|
|
|
|
if(!$result = $db->query($sql)){
|
|
|
|
die('There was an error running the query [' . $db->error . ']');
|
|
|
|
}
|
|
|
|
$row = $result->fetch_assoc();
|
2013-02-15 21:39:34 +00:00
|
|
|
if ($row){
|
|
|
|
$name = $row['name'];
|
|
|
|
$name = explode("-", $name);
|
|
|
|
foreach($name as $names){
|
2013-02-15 22:47:30 +00:00
|
|
|
//echo '<a href="?img='.$names.'"><img src="thumbs/'.$names.'"></a>';
|
|
|
|
echo '<a href="?img='.$names.'"><img src="thumbs/'.$names.'" alt="'.$names.'" title="'.$names.'"/></a>'."\n ";
|
2013-02-15 21:39:34 +00:00
|
|
|
}
|
|
|
|
}else{
|
|
|
|
echo "Error getting images from database";
|
2013-02-15 22:47:30 +00:00
|
|
|
}
|
2013-02-15 21:39:34 +00:00
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<!-- textstuff is right under here (not shown unless picture is viewed though) -->
|
2013-02-09 06:29:47 +00:00
|
|
|
<?php
|
|
|
|
if($_SESSION['noimg'] == false){
|
|
|
|
echo "
|
|
|
|
<br />
|
|
|
|
<ul>
|
|
|
|
<li class=\"widget widget_text\">
|
|
|
|
<div class=\"textwidget\">
|
|
|
|
";
|
|
|
|
textstuff();
|
|
|
|
echo "
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
2012-11-16 09:15:24 +00:00
|
|
|
";
|
2013-02-10 00:39:59 +00:00
|
|
|
}
|
|
|
|
?>
|
|
|
|
<br />
|
2013-02-09 06:29:47 +00:00
|
|
|
<ul>
|
2013-02-10 00:39:59 +00:00
|
|
|
<li class="widget widget_text">
|
|
|
|
<div class="textwidget">
|
2013-02-09 06:29:47 +00:00
|
|
|
<h4>Want to upload pictures?</h4>
|
2013-02-10 00:39:59 +00:00
|
|
|
<a href='?upload'>Image Uploader Here</a>
|
2013-02-09 06:29:47 +00:00
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id="footer">
|
|
|
|
<div class="footer_wrapper">
|
|
|
|
<div class="footer_left">
|
|
|
|
<p>
|
|
|
|
<a href="http://www.unps-gama.info/privacy.html">Privacy Policy</a> - <a href="http://www.unps-gama.info/ToS.html">Terms of Service</a> - Modified <a href="http://imotta.cn/wordpress/pyrmont-theme-v2-for-wordpress.html">Pyrmont V2</a> - <strong>Copyright © 2012-2013 UnPS-GAMA</strong>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
2013-02-09 07:48:52 +00:00
|
|
|
</div>
|
2013-02-09 06:29:47 +00:00
|
|
|
</body>
|
2013-02-12 09:38:50 +00:00
|
|
|
</html>
|
|
|
|
<?php session_unset(); session_destroy(); ?>
|