]> jfr.im git - uguu.git/blobdiff - static/php/includes/Core.namespace.php
strip some tags
[uguu.git] / static / php / includes / Core.namespace.php
index bbb216b3c8101ec46b914b9529dc0e0c62c38c49..1626ff2e006b55d6ec42f16a6a6487a2b078be68 100644 (file)
@@ -87,7 +87,7 @@ namespace Core {
             } catch (Exception) {
                 throw new Exception('Cant populate settings.', 500);
             }
-            (new Database())->assemblePDO();
+            Database::assemblePDO();
         }
     }
 
@@ -283,7 +283,7 @@ namespace Core {
         /**
          * @throws Exception
          */
-        public function dbCheckNameExists()
+        public static function dbCheckNameExists()
         {
             try {
                 $q = Settings::$DB->prepare('SELECT COUNT(filename) FROM files WHERE filename = (:name)');
@@ -298,7 +298,7 @@ namespace Core {
         /**
          * @throws Exception
          */
-        public function checkFileBlacklist()
+        public static function checkFileBlacklist()
         {
             try {
                 $q = Settings::$DB->prepare('SELECT hash, COUNT(*) AS count FROM blacklist WHERE hash = (:hash)');
@@ -316,7 +316,7 @@ namespace Core {
         /**
          * @throws Exception
          */
-        public function antiDupe()
+        public static function antiDupe()
         {
             try {
                 $q = Settings::$DB->prepare(
@@ -327,7 +327,9 @@ namespace Core {
                 $q->execute();
                 $result = $q->fetch();
                 if ($result['count'] > 0) {
-                    return $result['filename'];
+                    Upload::$NEW_NAME_FULL = $result['filename'];
+                } else {
+                    Upload::generateName();
                 }
             } catch (Exception) {
                 throw new Exception('Cant check for dupes in DB.', 500);
@@ -337,7 +339,7 @@ namespace Core {
         /**
          * @throws Exception
          */
-        public function newIntoDB()
+        public static function newIntoDB()
         {
             try {
                 $q = Settings::$DB->prepare(
@@ -345,7 +347,7 @@ namespace Core {
                     'VALUES (:hash, :orig, :name, :size, :date, :ip)'
                 );
                 $q->bindValue(':hash', Upload::$SHA1, PDO::PARAM_STR);
-                $q->bindValue(':orig', strip_tags(Upload::$FILE_NAME), PDO::PARAM_STR);
+                $q->bindValue(':orig', Upload::$FILE_NAME, PDO::PARAM_STR);
                 $q->bindValue(':name', Upload::$NEW_NAME_FULL, PDO::PARAM_STR);
                 $q->bindValue(':size', Upload::$FILE_SIZE, PDO::PARAM_INT);
                 $q->bindValue(':date', time(), PDO::PARAM_STR);