Removed unneeded echos

This commit is contained in:
alopexc0de 2013-02-21 02:24:14 -05:00
parent 5b5b92d293
commit d139d74445

View File

@ -1,225 +1,222 @@
<?php <?php
/*------------------------------------------ /*------------------------------------------
* Helper.Get.php - Holds the functions for get - uname, tag, search, and upload * Helper.Get.php - Holds the functions for get - uname, tag, search, and upload
* *
* Copyright (c) 2013 David Todd (c0de) of http://www.unps-gama.info and http://unps.us * Copyright (c) 2013 David Todd (c0de) of http://www.unps-gama.info and http://unps.us
* for use with the image host (http://img.unps-gama.info) * for use with the image host (http://img.unps-gama.info)
*------------------------------------------ *------------------------------------------
*/ */
function uname(){ function uname(){
if(!empty($_GET['uname'])){ // Show list of pictures uploaded by certain username if(!empty($_GET['uname'])){ // Show list of pictures uploaded by certain username
echo "<center><h4>Pictures uploaded from Username: ".$_GET['uname'].":</h4></center><br />"; echo "<center><h4>Pictures uploaded from Username: ".$_GET['uname'].":</h4></center><br />";
require('dbsettings.php'); require('dbsettings.php');
$uname = sanitize($_GET['uname']); $uname = sanitize($_GET['uname']);
$sql = 'SELECT * FROM `share` WHERE `username` = "'.$uname.'"'; $sql = 'SELECT * FROM `share` WHERE `username` = "'.$uname.'"';
if(!$result = $db->query($sql)){ if(!$result = $db->query($sql)){
die('There was an error running the query [' . $db->error . ']'); die('There was an error running the query [' . $db->error . ']');
} }
while($row = $result->fetch_assoc()){ while($row = $result->fetch_assoc()){
$_SESSION['noimg'] = 'uname'; $_SESSION['noimg'] = 'uname';
$id = $row['id']; $id = $row['id'];
$img = $row['name']; $img = $row['name'];
$location = $row['location']; $location = $row['location'];
$type = $row['type']; $type = $row['type'];
$size = $row['size']; $size = $row['size'];
$time = $row['time']; $time = $row['time'];
$comment = $row['comment']; $comment = $row['comment'];
$username = $row['username']; $username = $row['username'];
$tags = $row['tags']; $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: "; 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); $tags = explode(" ", $tags);
foreach($tags as $tag){ foreach($tags as $tag){
echo "<a href=\"?tag=$tag\">$tag</a> "; // For future use - catagorize by tag echo "<a href=\"?tag=$tag\">$tag</a> "; // For future use - catagorize by tag
} }
echo "</center><br />"; echo "</center><br />";
} }
$result->free(); $result->free();
//echo "<br /><hr /><br />"; }
} }
}
function tag(){
function tag(){ if(!empty($_GET['tag'])){ // Show list of pictures according to one tag - maybe multiple tags in the future
if(!empty($_GET['tag'])){ // Show list of pictures according to one tag - maybe multiple tags in the future echo "<center><h4>Pictures uploaded with the tag: ".$_GET['tag'].":</h4></center><br />";
echo "<center><h4>Pictures uploaded with the tag: ".$_GET['tag'].":</h4></center><br />"; require('dbsettings.php');
require('dbsettings.php'); $tag = sanitize($_GET['tag']);
$tag = sanitize($_GET['tag']); $sql = 'SELECT * FROM `share` WHERE `tags` LIKE "%'.$tag.'%"';
$sql = 'SELECT * FROM `share` WHERE `tags` LIKE "%'.$tag.'%"';
if(!$result = $db->query($sql)){
if(!$result = $db->query($sql)){ die('There was an error running the query [' . $db->error . ']');
die('There was an error running the query [' . $db->error . ']'); }
}
while($row = $result->fetch_assoc()){
while($row = $result->fetch_assoc()){ $_SESSION['noimg'] = 'tag';
$_SESSION['noimg'] = 'tag'; $id = $row['id'];
$id = $row['id']; $img = $row['name'];
$img = $row['name']; $location = $row['location'];
$location = $row['location']; $type = $row['type'];
$type = $row['type']; $size = $row['size'];
$size = $row['size']; $time = $row['time'];
$time = $row['time']; $comment = $row['comment'];
$comment = $row['comment']; $username = $row['username'];
$username = $row['username']; $tags = $row['tags'];
$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 />";
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();
$result->free(); }
//echo "<br /><hr /><br />"; }
}
} function search(){
if(!empty($_GET['search'])){ // Show list of pictures according to search term
function search(){ $search = sanitize($_GET['search']);
if(!empty($_GET['search'])){ // Show list of pictures according to search term $search = explode(" ", $search);
$search = sanitize($_GET['search']); echo "<center><h4>Pictures found using search terms: ";
$search = explode(" ", $search); foreach ($search as $searches){
echo "<center><h4>Pictures found using search terms: "; echo $searches." ";
foreach ($search as $searches){ }
echo $searches." "; echo ":</h4></center><br />";
} require('dbsettings.php');
echo ":</h4></center><br />"; $sql = "SELECT * FROM `share` WHERE `tags` LIKE '%".$search[0]."%'";
require('dbsettings.php'); for($i=1; $i<count($search); $i++){
$sql = "SELECT * FROM `share` WHERE `tags` LIKE '%".$search[0]."%'"; $sql = $sql." AND `tags` LIKE '%".$search[$i]."%'";
for($i=1; $i<count($search); $i++){ }
$sql = $sql." AND `tags` LIKE '%".$search[$i]."%'"; if(!$result = $db->query($sql)){
} die('There was an error running the query [' . $db->error . ']');
if(!$result = $db->query($sql)){ }
die('There was an error running the query [' . $db->error . ']');
} while($row = $result->fetch_assoc()){
$_SESSION['noimg'] = 'search';
while($row = $result->fetch_assoc()){ $id = $row['id'];
$_SESSION['noimg'] = 'search'; $img = $row['name'];
$id = $row['id']; $location = $row['location'];
$img = $row['name']; $type = $row['type'];
$location = $row['location']; $size = $row['size'];
$type = $row['type']; $time = $row['time'];
$size = $row['size']; $comment = $row['comment'];
$time = $row['time']; $username = $row['username'];
$comment = $row['comment']; $tags = $row['tags'];
$username = $row['username']; 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>";
$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>"; $result->free();
} }
$result->free(); }
//echo "<br /><hr /><br />";
} function upload(){
} if(isset($_GET['upload'])){
$max_file_size="4096";
function upload(){ $file_uploads="1";
if(isset($_GET['upload'])){ $websitename="UnPS-GAMA Image Host Uploader";
$max_file_size="4096"; $allow_types=array("jpg","gif","png","JPEG","JPG","GIF","PNG");
$file_uploads="1"; echo "
$websitename="UnPS-GAMA Image Host Uploader"; <center>
$allow_types=array("jpg","gif","png","JPEG","JPG","GIF","PNG"); <form name=\"uploadform\" action=\"\" method=\"post\" enctype=\"multipart/form-data\">
echo " <table>
<center> <tr>
<form name=\"uploadform\" action=\"\" method=\"post\" enctype=\"multipart/form-data\"> <td colspan=\"2\">
<table> <h3>Upload Pictures Here</h3>
<tr> <pre>All fields required</pre>
<td colspan=\"2\"> </td>
<h3>Upload Pictures Here</h3> </tr>
<pre>All fields required</pre> <tr>
</td> <td colspan=\"2\" class=\"upload_info\">
</tr> <b>Allowed Types:</b> jpg, gif, png<br />
<tr> <b>Max size per file:</b> 4 MB.
<td colspan=\"2\" class=\"upload_info\"> </td>
<b>Allowed Types:</b> jpg, gif, png<br /> </tr>
<b>Max size per file:</b> 4 MB. <tr>
</td> <td class=\"table_body\" width=\"30%\"><b>Select File:</b> </td>
</tr> <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>Select File:</b> </td> <tr>
<td class=\"table_body\" width=\"70%\"><input type=\"file\" name=\"file\" id=\"file\" size=\"70\" /></td> <td class=\"table_body\" width=\"30%\"><b>Your Name: </b></td>
</tr> <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>Your Name: </b></td> <tr>
<td class=\"table_body\" width=\"70%\"><input type=\"text\" name=\"username\" id=\"username\" size=\"70\" /></td> <td class=\"table_body\" width=\"30%\"><b>Comment: </b></td>
</tr> <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>Comment: </b></td> <tr>
<td class=\"table_body\" width=\"70%\"><input type=\"text\" name=\"comment\" id=\"comment\" size=\"70\" /></td> <td class=\"table_body\" width=\"30%\"><b>Tags</b> (spaces only):</td>
</tr> <td class=\"table_body\" width=\"70%\"><input type=\"text\" name=\"tags\" id=\"tags\" size=\"70\" /></td>
<tr> </tr>
<td class=\"table_body\" width=\"30%\"><b>Tags</b> (spaces only):</td> <tr>
<td class=\"table_body\" width=\"70%\"><input type=\"text\" name=\"tags\" id=\"tags\" size=\"70\" /></td> <td colspan=\"2\">
</tr> <input type=\"hidden\" name=\"submit\" value=\"true\" />
<tr> <input type=\"reset\" name=\"reset\" value=\" Reset Form \" onclick=\"window.location.reload(true);\" /> &nbsp;
<td colspan=\"2\"> <input type=\"submit\" value=\" Upload \" />
<input type=\"hidden\" name=\"submit\" value=\"true\" /> </td>
<input type=\"reset\" name=\"reset\" value=\" Reset Form \" onclick=\"window.location.reload(true);\" /> &nbsp; </tr>
<input type=\"submit\" value=\" Upload \" /> </table>
</td> </form>
</tr> </center>
</table> <hr /><br />
</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');
if(isset($_POST['submit'])){
if(!isset($_POST['username']) || !isset($_POST['comment']) || !isset($_POST['tags'])) die("Please fill in the form completly"); $location = 'Pictures';
require('dbsettings.php'); $extensions = array('png', 'gif', 'jpg', 'jpeg');
$short = substr(number_format(time() * mt_rand(),0,'',''),0,10);
$location = 'Pictures'; $short = base_convert($short, 10, 36);
$extensions = array('png', 'gif', 'jpg', 'jpeg');
$short = substr(number_format(time() * mt_rand(),0,'',''),0,10); $upusername = $_POST['username'];
$short = base_convert($short, 10, 36); $upcomment = $_POST['comment'];
$tags = $_POST['tags'];
$upusername = $_POST['username']; $name = $_FILES["file"]["name"];
$upcomment = $_POST['comment']; $type = $_FILES["file"]["type"];
$tags = $_POST['tags']; $size = ($_FILES["file"]["size"] / 1024); // get size of file in Kb
$name = $_FILES["file"]["name"];
$type = $_FILES["file"]["type"]; $name = cln_file_name($name);
$size = ($_FILES["file"]["size"] / 1024); // get size of file in Kb $type = sanitize($type);
$size = sanitize($size);
$name = cln_file_name($name); $upcomment = comment($upcomment);
$type = sanitize($type); $tags = sanitize($tags);
$size = sanitize($size); $upusername = sanitize($upusername);
$upcomment = comment($upcomment);
$tags = sanitize($tags); //$notspace = array("\,", ".", "/", "\\", ":", "-", "_", "+", "=", "~", "#", "&", "");
$upusername = sanitize($upusername); //$tags = preg_replace($notspace, " ", $tags);
//$notspace = array("\,", ".", "/", "\\", ":", "-", "_", "+", "=", "~", "#", "&", ""); $size = round($size, 2)." Kb";
//$tags = preg_replace($notspace, " ", $tags); $time = date("d/j/y - g:i:s a");
$size = round($size, 2)." Kb"; $file_ext = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
$time = date("d/j/y - g:i:s a"); if(!in_array($file_ext, $extensions))die("Wrong or no file extension"); // stop the upload if it's wrong
$name = $short.".".$file_ext;
$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 if (($_FILES["file"]["size"] < 4000000000)){
$name = $short.".".$file_ext; if ($_FILES["file"]["error"] > 0){
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
if (($_FILES["file"]["size"] < 4000000000)){ }else{
if ($_FILES["file"]["error"] > 0){ if (file_exists("Pictures/" . $name)){
echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; echo $name." already exists. ";
}else{ }else{
if (file_exists("Pictures/" . $name)){ if(preg_match('/php/i', $name) || preg_match('/phtml/i', $name) || preg_match('/htaccess/i', $name)){
echo $name." already exists. "; echo $name." is not allowed, sorry about that...";
}else{ }else{
if(preg_match('/php/i', $name) || preg_match('/phtml/i', $name) || preg_match('/htaccess/i', $name)){ // Somehow bump one of the images from the recently upload table and add new image in its place
echo $name." is not allowed, sorry about that..."; $sql="INSERT INTO `share` (name, location, type, size, time, comment, username, tags) VALUES ('$name', '$location', '$type', '$size', '$time', '$upcomment', '$upusername', '$tags')";
}else{ if($result = $db->query($sql)){
// Somehow bump one of the images from the recently upload table and add new image in its place move_uploaded_file($_FILES["file"]["tmp_name"], "Pictures/" . $name);
$sql="INSERT INTO `share` (name, location, type, size, time, comment, username, tags) VALUES ('$name', '$location', '$type', '$size', '$time', '$upcomment', '$upusername', '$tags')"; $donefile = 'Pictures/'.$name;
if($result = $db->query($sql)){ genthumb($name);
move_uploaded_file($_FILES["file"]["tmp_name"], "Pictures/" . $name); echo "Stored at: <a href='?img=$name'>". $name."</a>";
$donefile = 'Pictures/'.$name; }elseif(!$result = $db->query($sql)){
genthumb($name); die('There was a problem trying to upload your file - [' . $db->error . ']');
echo "Stored at: <a href='?img=$name'>". $name."</a>"; }else{
}elseif(!$result = $db->query($sql)){ echo "There was a problem trying to upload your file - Could be a server error";
die('There was a problem trying to upload your file - [' . $db->error . ']'); }
}else{ }
echo "There was a problem trying to upload your file - Could be a server error"; }
} }
} }else{
} die("File too big!");
} }
}else{ }
die("File too big!"); }
}
}
}
?> ?>