beber pushed a commit to branch master.

http://git.enlightenment.org/website/www.git/commit/?id=af7a8a8305fedfe6a26a939cbf935dd028aadbed

commit af7a8a8305fedfe6a26a939cbf935dd028aadbed
Author: Bertrand Jacquin <bertr...@jacquin.bzh>
Date:   Mon Apr 13 21:38:16 2015 +0100

    MAJOR: Revert ss/ as pre-dokuwki
    (1ee870ba3d75ad1eb3ef0e837597fb7ef022a147)
---
 public_html/ss/_dummy     |  0
 public_html/ss/ban.php    | 74 +++++++++++++++++++++++++++++++++++++++++++++++
 public_html/ss/remove.php | 56 +++++++++++++++++++++++++++++++++++
 3 files changed, 130 insertions(+)

diff --git a/public_html/ss/_dummy b/public_html/ss/_dummy
deleted file mode 100644
index e69de29..0000000
diff --git a/public_html/ss/ban.php b/public_html/ss/ban.php
new file mode 100644
index 0000000..dfb3e56
--- /dev/null
+++ b/public_html/ss/ban.php
@@ -0,0 +1,74 @@
+<?php
+function get_ip()
+{
+  if (getenv("REMOTE_ADDR")) $ip = getenv("REMOTE_ADDR");
+  else $ip = "UNKNOWN";
+  return $ip;
+}
+
+$img = "";
+if (isset($_GET['image']))
+  $img = $_GET['image'];
+
+$file = $_SERVER["DOCUMENT_ROOT"] . "/ss/" . $img;
+$ignore_file = $_SERVER["DOCUMENT_ROOT"] . "/ss/ignore-" . $img;
+$abuse_file = $_SERVER["DOCUMENT_ROOT"] . "/ss/abuse-" . $img;
+
+if (isset($img) && $img[0] == "e" && file_exists($file) && 
!file_exists($ignore_file))
+  {
+    $already = 0;
+    $auth = md5($img . get_ip());
+
+    $count = 0;
+    if (file_exists($abuse_file) && ($fh = fopen($abuse_file, "r")))
+      {
+       $auth_eol = $auth . "\n";
+       while (!feof($fh))
+         {
+           $tmp = fgets($fh);
+           if ($auth_eol == $tmp)
+             {
+               // Don't let people vote multiple time somehow
+               $already = 1;
+             }
+           else
+             {
+               $count++;
+             }
+         }
+       fclose($fh);
+      }
+
+    if ($count > 10)
+      {
+       if (file_exists($_SERVER["DOCUMENT_ROOT"] . "/ss/ip-" . $img)) {
+               rename($_SERVER["DOCUMENT_ROOT"] . "/ss/ip-" . $img,
+                      $_SERVER["DOCUMENT_ROOT"] . "/ss/ban/ip-" . $img);
+       }
+       if (file_exists($_SERVER["DOCUMENT_ROOT"] . "/ss/abuse-" . $img)) {
+               rename($_SERVER["DOCUMENT_ROOT"] . "/ss/abuse-" . $img,
+                      $_SERVER["DOCUMENT_ROOT"] . "/ss/ban/abuse-" . $img);
+       }
+       if (file_exists($_SERVER["DOCUMENT_ROOT"] . "/ss/th-" . $img)) {
+               rename($_SERVER["DOCUMENT_ROOT"] . "/ss/th-" . $img,
+                      $_SERVER["DOCUMENT_ROOT"] . "/ss/ban/th-" . $img);
+       }
+       if (file_exists($_SERVER["DOCUMENT_ROOT"] . "/ss/" . $img)) {
+               rename($_SERVER["DOCUMENT_ROOT"] . "/ss/" . $img,
+                      $_SERVER["DOCUMENT_ROOT"] . "/ss/ban/" . $img);
+       }
+      }
+    else
+      {
+       if ($already == 0)
+         {
+           $fh = fopen($abuse_file, "a");
+           fwrite($fh, $auth . "\n");
+           fclose($fh);
+         }
+      }
+  }
+
+header("Location: http://www.enlightenment.org/ss/";);
+die();
+?>
diff --git a/public_html/ss/remove.php b/public_html/ss/remove.php
new file mode 100644
index 0000000..c10aa34
--- /dev/null
+++ b/public_html/ss/remove.php
@@ -0,0 +1,56 @@
+<?php
+function get_ip()
+{
+  if (getenv("REMOTE_ADDR")) $ip = getenv("REMOTE_ADDR");
+  else $ip = "UNKNOWN";
+  return $ip;
+}
+
+$img = "";
+if (isset($_GET['image']))
+  $img = $_GET['image'];
+
+$file = $_SERVER["DOCUMENT_ROOT"] . "/ss/" . $img;
+$auth_file = $_SERVER["DOCUMENT_ROOT"] . "/ss/ip-" . $img;
+$ignore_file = $_SERVER["DOCUMENT_ROOT"] . "/ss/ignore-" . $img;
+$abuse_file = $_SERVER["DOCUMENT_ROOT"] . "/ss/abuse-" . $img;
+$auth_expire = 60 * 60;
+$ip = get_ip();
+
+if ($img[0] == "e" && file_exists($file))
+  {
+    $remove = 0;
+    if ($ip = "140.211.167.168")
+      {
+       $remove = 1;
+      }
+    else if (time() - filemtime($auth_file) < $auth_expire)
+      {
+       $auth = md5($img . get_ip());
+
+       $fh = fopen($auth_file, "r");
+       $head = fgets($fh);
+       fclose($fh);
+
+       if ($auth == $head)
+         {
+           $remove = 1;
+         }
+      }
+
+    if ($remove == 1)
+      {
+       rename($_SERVER["DOCUMENT_ROOT"] . "/ss/ip-" . $img,
+              $_SERVER["DOCUMENT_ROOT"] . "/ss/kill/ip-" . $img);
+       rename($_SERVER["DOCUMENT_ROOT"] . "/ss/abuse-" . $img,
+              $_SERVER["DOCUMENT_ROOT"] . "/ss/kill/abuse-" . $img);
+       rename($_SERVER["DOCUMENT_ROOT"] . "/ss/th-" . $img,
+              $_SERVER["DOCUMENT_ROOT"] . "/ss/kill/th-" . $img);
+       rename($_SERVER["DOCUMENT_ROOT"] . "/ss/" . $img,
+              $_SERVER["DOCUMENT_ROOT"] . "/ss/kill/" . $img);
+      }
+  }
+
+header("Location: http://www.enlightenment.org/ss/";);
+die();
+?>

-- 


Reply via email to