Gallery image system now works again. Fix #263

Changed the gallery image host from imgland.net to http://www.freeimagehosting.net/ (which uses imgur.com)
This commit is contained in:
Znote 2017-01-01 04:14:35 +01:00
parent deddeb462c
commit 43ae67f74e
3 changed files with 81 additions and 56 deletions

View File

@ -10,6 +10,14 @@ if (isset($_POST['delete'])) {
updateImage($data[0], 3);
}
// Remove
if (isset($_POST['remove'])) {
$data = explode(":", $_POST['remove']);
$did = (int)$data[0];
echo 'Image '. $did .' removed.';
mysql_delete("DELETE FROM `znote_images` WHERE `id`='$did' LIMIT 1;");
}
// Accept
if (isset($_POST['accept'])) {
$data = explode(":", $_POST['accept']);
@ -39,7 +47,6 @@ if (isset($_POST['accept']) || isset($_POST['delete'])) {
$images = fetchImages(1);
if ($images != false) {
foreach($images as $image) {
$pw = explode("!", $image['image']);
?>
<table>
<tr class="yellow">
@ -47,7 +54,7 @@ if ($images != false) {
</tr>
<tr>
<td>
<a href="<?php echo 'http://'. $pw[0] .'.1m.yt/'. $pw[1] .'.'. $pw[2]; ?>"><img src="<?php echo 'http://'. $pw[0] .'.1m.yt/'. $pw[1] .'.'. $pw[2]; ?>" width="650"/></a>
<a href="<?php echo $image['image']; ?>"><img src="<?php echo $image['image']; ?>" alt="<?php echo $image['title']; ?>" style="max-width: 100%;"/></a>
</td>
</tr>
<tr>
@ -67,7 +74,6 @@ if ($images != false) {
$images = fetchImages(2);
if ($images != false) {
foreach($images as $image) {
$pw = explode("!", $image['image']);
?>
<table>
<tr class="yellow">
@ -75,7 +81,7 @@ if ($images != false) {
</tr>
<tr>
<td>
<a href="<?php echo 'http://'. $pw[0] .'.1m.yt/'. $pw[1] .'.'. $pw[2]; ?>"><img src="<?php echo 'http://'. $pw[0] .'.1m.yt/'. $pw[1] .'.'. $pw[2]; ?>" width="650"/></a>
<a href="<?php echo $image['image']; ?>"><img src="<?php echo $image['image']; ?>" alt="<?php echo $image['title']; ?>" style="max-width: 100%;"/></a>
</td>
</tr>
<tr>
@ -95,15 +101,17 @@ if ($images != false) {
$images = fetchImages(3);
if ($images != false) {
foreach($images as $image) {
$pw = explode("!", $image['image']);
?>
<table>
<tr class="yellow">
<td><h2><?php echo $image['title']; ?><form action="" method="post"><input type="submit" name="accept" value="<?php echo $image['id']; ?>:Recover Image"/></form></h2></td>
<td><h2><?php echo $image['title']; ?><form action="" method="post">
<input type="submit" name="accept" value="<?php echo $image['id']; ?>:Recover Image"/>
<input type="submit" name="remove" value="<?php echo $image['id']; ?>:Remove Image"/>
</form></h2></td>
</tr>
<tr>
<td>
<a href="<?php echo 'http://'. $pw[0] .'.1m.yt/'. $pw[1] .'.'. $pw[2]; ?>"><img src="<?php echo 'http://'. $pw[0] .'.1m.yt/'. $pw[1] .'.'. $pw[2]; ?>" width="650"/></a>
<a href="<?php echo $image['image']; ?>"><img src="<?php echo $image['image']; ?>" alt="<?php echo $image['title']; ?>" style="max-width: 100%;"/></a>
</td>
</tr>
<tr>

View File

@ -16,7 +16,14 @@ function insertImage($account_id, $title, $desc, $image) {
$image = sanitize($image);
$account_id = (int)$account_id;
$time = time();
// Insert only if image dosn't already exist there
$exist = mysql_select_single("SELECT `id` FROM `znote_images` WHERE `image`='$image' LIMIT 1;");
if ($exist === false) {
mysql_insert("INSERT INTO `znote_images` (`title`, `desc`, `date`, `status`, `image`, `account_id`) VALUES ('$title', '$desc', '$time', '1', '$image', '$account_id');");
return true;
}
return false;
}
function updateImage($id, $status) {

View File

@ -4,10 +4,9 @@ if ($logged_in === true) {
if (!empty($_POST['new'])) {
?>
<h1>Create image article</h1>
<p>Only works with "Direct link" URLs from <a href="http://www.imgland.net/">imgland.net</a>
<br />Don't understand? Don't worry! Watch this <a href="http://youtu.be/r9pEc7T3cJg" target="_BLANK">video guide!</a></p>
<p>Works with "Image Code" text from <a href="http://www.freeimagehosting.net/" target="_BLANK">www.freeimagehosting.net</a></p>
<form action="" method="post">
Image URL:<br /><input type="text" name="image" size="70"><br />
Image Code:<br /><input type="text" name="image" size="70"><br />
Image Title:<br /><input type="text" name="title" size="70"><br />
Image Description:<br /><textarea name="desc" cols="55" rows="15"></textarea><br />
<input type="submit" name="Submit" value="Post Image Article">
@ -15,19 +14,28 @@ if ($logged_in === true) {
<?php
}
if (!empty($_POST['image']) && !empty($_POST['title']) && !empty($_POST['desc'])) {
$image = sanitize($_POST['image']);
$image = str_replace("www", "", str_replace(":", "", str_replace("/", "", str_replace(".", "!", str_replace("1m.yt", "", str_replace("http", "", $image))))));
$imageDom = $_POST['image'];
$imageSrc = false;
$doc=new DOMDocument();
$doc->loadHTML($imageDom);
$xml=simplexml_import_dom($doc); // just to make xpath more simple
$images=$xml->xpath('//img');
foreach ($images as $img) {
$imageSrc = (string)$img['src'];
}
$title = sanitize($_POST['title']);
$desc = sanitize($_POST['desc']);
// Insert to database
insertImage((int)$session_user_id, $title, $desc, $image);
if ($imageSrc !== false) {
$pw = explode("!", $image);
// Insert to database
$inserted = insertImage((int)$session_user_id, $title, $desc, $imageSrc);
if ($inserted === true) {
?>
<h1>Image Posted</h1>
<p>However, your image will not be listed until a GM have verified it.<br />
Feel free to remind the GM in-game to login on website and approve the image post.</p>
<h2>Preview:</h2>
<table>
<tr class="yellow">
@ -35,7 +43,7 @@ if ($logged_in === true) {
</tr>
<tr>
<td>
<a href="<?php echo 'http://'. $pw[0] .'.1m.yt/'. $pw[1] .'.'. $pw[2]; ?>" target="_BLANK"><img class="galleryImage" src="<?php echo 'http://'. $pw[0] .'.1m.yt/'. $pw[1] .'.'. $pw[2]; ?>"/></a>
<a href="<?php echo $imageSrc; ?>" target="_BLANK"><img class="galleryImage" src="<?php echo $imageSrc; ?>" alt="<?php echo $title; ?>"/></a>
</td>
</tr>
<tr>
@ -49,6 +57,19 @@ if ($logged_in === true) {
</tr>
</table>
<?php
} else { // Image not inserted because it already exist
?>
<h1>Image already exist</h1>
<p>The image has already been posted. However, images will not be listed until a GM have verified it.</p>
<?php
}
} else { // Failed to locate imageSrc
?>
<h1>Failed to find the image</h1>
<p>We failed to find the image, did you give us the Image code from <a href="http://www.freeimagehosting.net/">www.freeimagehosting.net</a>?</p>
<?php
}
}
}
if (empty($_POST)) {
@ -63,9 +84,8 @@ if (empty($_POST)) {
$cache = new Cache('engine/cache/gallery');
$images = $cache->load();
if ($images != false) {
if (is_array($images) && !empty($images)) {
foreach($images as $image) {
$pw = explode("!", $image['image']);
?>
<table>
<tr class="yellow">
@ -73,7 +93,7 @@ if (empty($_POST)) {
</tr>
<tr>
<td>
<a href="<?php echo 'http://'. $pw[0] .'.1m.yt/'. $pw[1] .'.'. $pw[2]; ?>" target="_BLANK"><img class="galleryImage" src="<?php echo 'http://'. $pw[0] .'.1m.yt/'. $pw[1] .'.'. $pw[2]; ?>"/></a>
<a href="<?php echo $image['image']; ?>" target="_BLANK"><img class="galleryImage" src="<?php echo $image['image']; ?>" alt="<?php echo $image['title']; ?>"/></a>
</td>
</tr>
<tr>
@ -92,14 +112,4 @@ if (empty($_POST)) {
if ($logged_in === false) echo 'You need to be logged in to add images.';
}
include 'layout/overall/footer.php';
/*
$url = strtolower("HTTP://1.imgland.net/pxPmUL.jpg");
echo $url .'<br />';
$url = str_replace("www", "", str_replace(":", "", str_replace("/", "", str_replace(".", "!", str_replace("imgland.net", "", str_replace("http", "", $url))))));
$url = sanitize($url);
echo $url;
$url = explode("!", $url);
<a href="<?php echo 'http://'. $url[0] .'.imgland.net/'. $url[1] .'.'. $url[2]; ?>"><img src="<?php echo 'http://'. $url[0] .'.imgland.net/'. $url[1] .'.'. $url[2]; ?>" width="650"/></a>
echo time();
//insertImage(2, "Yaay!", "Super description!", "1!pxpmul!jpg");
*/?>
?>