diff --git a/admin_gallery.php b/admin_gallery.php index cd47b36..4c2f369 100644 --- a/admin_gallery.php +++ b/admin_gallery.php @@ -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']); ?> @@ -47,7 +54,7 @@ if ($images != false) { @@ -67,7 +74,6 @@ if ($images != false) { $images = fetchImages(2); if ($images != false) { foreach($images as $image) { - $pw = explode("!", $image['image']); ?>
- + <?php echo $image['title']; ?>
@@ -75,7 +81,7 @@ if ($images != false) { @@ -95,15 +101,17 @@ if ($images != false) { $images = fetchImages(3); if ($images != false) { foreach($images as $image) { - $pw = explode("!", $image['image']); ?>
- + <?php echo $image['title']; ?>
- + diff --git a/engine/function/users.php b/engine/function/users.php index 2bc9302..7eda00f 100644 --- a/engine/function/users.php +++ b/engine/function/users.php @@ -16,7 +16,14 @@ function insertImage($account_id, $title, $desc, $image) { $image = sanitize($image); $account_id = (int)$account_id; $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) { diff --git a/gallery.php b/gallery.php index 30b4dec..ea5f043 100644 --- a/gallery.php +++ b/gallery.php @@ -4,10 +4,9 @@ if ($logged_in === true) { if (!empty($_POST['new'])) { ?>

Create image article

-

Only works with "Direct link" URLs from imgland.net -
Don't understand? Don't worry! Watch this video guide!

+

Works with "Image Code" text from www.freeimagehosting.net

- Image URL:

+ Image Code:

Image Title:

Image Description:

@@ -15,40 +14,62 @@ if ($logged_in === true) { 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); - - $pw = explode("!", $image); - ?> -

Image Posted

-

However, your image will not be listed until a GM have verified it.
- Feel free to remind the GM in-game to login on website and approve the image post.

-

Preview:

-

+ + +

- + <?php echo $image['title']; ?>
- - - - - - - - - -

- -
- ", $descr); + + if ($imageSrc !== false) { + + // Insert to database + $inserted = insertImage((int)$session_user_id, $title, $desc, $imageSrc); + if ($inserted === true) { ?> -

-
- Image Posted +

However, your image will not be listed until a GM have verified it.
+ Feel free to remind the GM in-game to login on website and approve the image post.

+ +

Preview:

+ + + + + + + + + + +

+ <?php echo $title; ?> +
+ ", $descr); + ?> +

+
+ +

Image already exist

+

The image has already been posted. However, images will not be listed until a GM have verified it.

+ +

Failed to find the image

+

We failed to find the image, did you give us the Image code from www.freeimagehosting.net?

+ load(); - if ($images != false) { + if (is_array($images) && !empty($images)) { foreach($images as $image) { - $pw = explode("!", $image['image']); ?> @@ -73,7 +93,7 @@ if (empty($_POST)) { @@ -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 .'
'; -$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); - -echo time(); -//insertImage(2, "Yaay!", "Super description!", "1!pxpmul!jpg"); -*/?> \ No newline at end of file +?> \ No newline at end of file
- + <?php echo $image['title']; ?>