mirror of
https://github.com/Znote/ZnoteAAC.git
synced 2025-04-29 18:59:21 +02:00
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:
parent
deddeb462c
commit
43ae67f74e
@ -10,6 +10,14 @@ if (isset($_POST['delete'])) {
|
|||||||
updateImage($data[0], 3);
|
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
|
// Accept
|
||||||
if (isset($_POST['accept'])) {
|
if (isset($_POST['accept'])) {
|
||||||
$data = explode(":", $_POST['accept']);
|
$data = explode(":", $_POST['accept']);
|
||||||
@ -39,7 +47,6 @@ if (isset($_POST['accept']) || isset($_POST['delete'])) {
|
|||||||
$images = fetchImages(1);
|
$images = fetchImages(1);
|
||||||
if ($images != false) {
|
if ($images != false) {
|
||||||
foreach($images as $image) {
|
foreach($images as $image) {
|
||||||
$pw = explode("!", $image['image']);
|
|
||||||
?>
|
?>
|
||||||
<table>
|
<table>
|
||||||
<tr class="yellow">
|
<tr class="yellow">
|
||||||
@ -47,7 +54,7 @@ if ($images != false) {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -67,7 +74,6 @@ if ($images != false) {
|
|||||||
$images = fetchImages(2);
|
$images = fetchImages(2);
|
||||||
if ($images != false) {
|
if ($images != false) {
|
||||||
foreach($images as $image) {
|
foreach($images as $image) {
|
||||||
$pw = explode("!", $image['image']);
|
|
||||||
?>
|
?>
|
||||||
<table>
|
<table>
|
||||||
<tr class="yellow">
|
<tr class="yellow">
|
||||||
@ -75,7 +81,7 @@ if ($images != false) {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -95,15 +101,17 @@ if ($images != false) {
|
|||||||
$images = fetchImages(3);
|
$images = fetchImages(3);
|
||||||
if ($images != false) {
|
if ($images != false) {
|
||||||
foreach($images as $image) {
|
foreach($images as $image) {
|
||||||
$pw = explode("!", $image['image']);
|
|
||||||
?>
|
?>
|
||||||
<table>
|
<table>
|
||||||
<tr class="yellow">
|
<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>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -16,7 +16,14 @@ function insertImage($account_id, $title, $desc, $image) {
|
|||||||
$image = sanitize($image);
|
$image = sanitize($image);
|
||||||
$account_id = (int)$account_id;
|
$account_id = (int)$account_id;
|
||||||
$time = time();
|
$time = time();
|
||||||
mysql_insert("INSERT INTO `znote_images` (`title`, `desc`, `date`, `status`, `image`, `account_id`) VALUES ('$title', '$desc', '$time', '1', '$image', '$account_id');");
|
|
||||||
|
// 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) {
|
function updateImage($id, $status) {
|
||||||
|
106
gallery.php
106
gallery.php
@ -4,10 +4,9 @@ if ($logged_in === true) {
|
|||||||
if (!empty($_POST['new'])) {
|
if (!empty($_POST['new'])) {
|
||||||
?>
|
?>
|
||||||
<h1>Create image article</h1>
|
<h1>Create image article</h1>
|
||||||
<p>Only works with "Direct link" URLs from <a href="http://www.imgland.net/">imgland.net</a>
|
<p>Works with "Image Code" text from <a href="http://www.freeimagehosting.net/" target="_BLANK">www.freeimagehosting.net</a></p>
|
||||||
<br />Don't understand? Don't worry! Watch this <a href="http://youtu.be/r9pEc7T3cJg" target="_BLANK">video guide!</a></p>
|
|
||||||
<form action="" method="post">
|
<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 Title:<br /><input type="text" name="title" size="70"><br />
|
||||||
Image Description:<br /><textarea name="desc" cols="55" rows="15"></textarea><br />
|
Image Description:<br /><textarea name="desc" cols="55" rows="15"></textarea><br />
|
||||||
<input type="submit" name="Submit" value="Post Image Article">
|
<input type="submit" name="Submit" value="Post Image Article">
|
||||||
@ -15,40 +14,62 @@ if ($logged_in === true) {
|
|||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
if (!empty($_POST['image']) && !empty($_POST['title']) && !empty($_POST['desc'])) {
|
if (!empty($_POST['image']) && !empty($_POST['title']) && !empty($_POST['desc'])) {
|
||||||
$image = sanitize($_POST['image']);
|
$imageDom = $_POST['image'];
|
||||||
$image = str_replace("www", "", str_replace(":", "", str_replace("/", "", str_replace(".", "!", str_replace("1m.yt", "", str_replace("http", "", $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']);
|
$title = sanitize($_POST['title']);
|
||||||
$desc = sanitize($_POST['desc']);
|
$desc = sanitize($_POST['desc']);
|
||||||
|
|
||||||
// Insert to database
|
if ($imageSrc !== false) {
|
||||||
insertImage((int)$session_user_id, $title, $desc, $image);
|
|
||||||
|
// Insert to database
|
||||||
$pw = explode("!", $image);
|
$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">
|
|
||||||
<td><h3><?php echo $title; ?></h3></td>
|
|
||||||
</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>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<?php
|
|
||||||
$descr = str_replace("\\r", "", $desc);
|
|
||||||
$descr = str_replace("\\n", "<br />", $descr);
|
|
||||||
?>
|
?>
|
||||||
<p><?php echo $descr; ?></p>
|
<h1>Image Posted</h1>
|
||||||
</td>
|
<p>However, your image will not be listed until a GM have verified it.<br />
|
||||||
</tr>
|
Feel free to remind the GM in-game to login on website and approve the image post.</p>
|
||||||
</table>
|
|
||||||
<?php
|
<h2>Preview:</h2>
|
||||||
|
<table>
|
||||||
|
<tr class="yellow">
|
||||||
|
<td><h3><?php echo $title; ?></h3></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a href="<?php echo $imageSrc; ?>" target="_BLANK"><img class="galleryImage" src="<?php echo $imageSrc; ?>" alt="<?php echo $title; ?>"/></a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<?php
|
||||||
|
$descr = str_replace("\\r", "", $desc);
|
||||||
|
$descr = str_replace("\\n", "<br />", $descr);
|
||||||
|
?>
|
||||||
|
<p><?php echo $descr; ?></p>
|
||||||
|
</td>
|
||||||
|
</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)) {
|
if (empty($_POST)) {
|
||||||
@ -63,9 +84,8 @@ if (empty($_POST)) {
|
|||||||
|
|
||||||
$cache = new Cache('engine/cache/gallery');
|
$cache = new Cache('engine/cache/gallery');
|
||||||
$images = $cache->load();
|
$images = $cache->load();
|
||||||
if ($images != false) {
|
if (is_array($images) && !empty($images)) {
|
||||||
foreach($images as $image) {
|
foreach($images as $image) {
|
||||||
$pw = explode("!", $image['image']);
|
|
||||||
?>
|
?>
|
||||||
<table>
|
<table>
|
||||||
<tr class="yellow">
|
<tr class="yellow">
|
||||||
@ -73,7 +93,7 @@ if (empty($_POST)) {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -92,14 +112,4 @@ if (empty($_POST)) {
|
|||||||
if ($logged_in === false) echo 'You need to be logged in to add images.';
|
if ($logged_in === false) echo 'You need to be logged in to add images.';
|
||||||
}
|
}
|
||||||
include 'layout/overall/footer.php';
|
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");
|
|
||||||
*/?>
|
|
Loading…
x
Reference in New Issue
Block a user