Prechádzať zdrojové kódy

DB connection is now globally available.

Iñigo Valentin 6 rokov pred
rodič
commit
644931593c
53 zmenil súbory, kde vykonal 424 pridanie a 356 odobranie
  1. 32 24
      application/Controller.php
  2. 4 2
      application/action/edit_profile.php
  3. 5 2
      application/action/login.php
  4. 1 2
      application/action/logout.php
  5. 4 8
      application/action/new_team.php
  6. 3 2
      application/action/save_run_team.php
  7. 7 5
      application/entity/Building.php
  8. 6 4
      application/entity/Custom_Filter.php
  9. 7 5
      application/entity/Decoration.php
  10. 3 10
      application/entity/Entity.php
  11. 19 16
      application/entity/Fusion.php
  12. 9 8
      application/entity/Guild.php
  13. 6 5
      application/entity/Guild_Member.php
  14. 7 5
      application/entity/Inventory.php
  15. 6 4
      application/entity/K_Area.php
  16. 6 4
      application/entity/K_Building.php
  17. 7 5
      application/entity/K_Decoration.php
  18. 6 4
      application/entity/K_Effect.php
  19. 6 4
      application/entity/K_Guild_Skill.php
  20. 8 6
      application/entity/K_Guild_Skill_Group.php
  21. 4 4
      application/entity/K_Inventory.php
  22. 6 7
      application/entity/K_Leader_Skill.php
  23. 6 4
      application/entity/K_Rune_Set.php
  24. 10 8
      application/entity/K_Skill.php
  25. 6 4
      application/entity/K_Skill_Level.php
  26. 6 6
      application/entity/K_Source.php
  27. 25 13
      application/entity/K_Unit.php
  28. 10 7
      application/entity/K_Unit_Transformation.php
  29. 22 20
      application/entity/Run.php
  30. 7 5
      application/entity/Rune.php
  31. 7 5
      application/entity/Rune_Craft.php
  32. 9 7
      application/entity/Team.php
  33. 21 14
      application/entity/Unit.php
  34. 5 5
      application/page/Catalog_Page.php
  35. 7 7
      application/page/Fusion_Page.php
  36. 7 7
      application/page/Guild_Page.php
  37. 19 20
      application/page/Home_Page.php
  38. 3 3
      application/page/Landing_Page.php
  39. 7 7
      application/page/Monster_Info_Page.php
  40. 7 5
      application/page/Monster_Page.php
  41. 12 6
      application/page/Monsters_Page.php
  42. 1 9
      application/page/Page.php
  43. 4 4
      application/page/Profile_Page.php
  44. 5 5
      application/page/Report_Page.php
  45. 8 8
      application/page/Report_Runecraft_Page.php
  46. 14 12
      application/page/Report_Runeupgrade_Page.php
  47. 5 5
      application/page/Report_Skillup_Page.php
  48. 11 9
      application/page/Runes_Page.php
  49. 5 5
      application/page/Runs_Page.php
  50. 7 7
      application/page/Teams_Page.php
  51. 2 2
      application/view/guild.php
  52. 3 0
      application/view/monster.php
  53. 1 1
      public/css/monster.css

+ 32 - 24
application/Controller.php

@@ -23,6 +23,11 @@
      * @global int $UID.
      */
     $UID = 0;
+    
+    /**
+     * @global resource $DB.
+     */
+    $db = null;
 
     /**
      * Application controller.
@@ -43,10 +48,13 @@
          * @param mixed[] $params POST parameters of the request.
          * @return int HTTP status codes 200 or 404;
          * @global int User ID.
+         * @global resource Databse connection.
          */
         public function __construct($params){
 
             global $UID;
+            global $db;
+
             $page = null;
 
             session_start();
@@ -66,27 +74,27 @@
                 switch (strtoupper($pars[1])){
                     case "LOGIN":
                         require_once(PATH::ACTION . "login.php");
-                        action($db);
+                        action();
                         return;
                         break;
                     case "LOGOUT":
                         require_once(PATH::ACTION . "logout.php");
-                        action($db);
+                        action();
                         return;
                         break;
                     case "NEW_TEAM":
                         require_once(PATH::ACTION . "new_team.php");
-                        error_log("NEW_TEAM: " . action($db));
+                        action();
                         return;
                         break;
                     case "SAVE_RUN_TEAM":
                         require_once(PATH::ACTION . "save_run_team.php");
-                        action($db);
+                        action();
                         return;
                         break;
                     case "EDIT_PROFILE":
                         require_once(PATH::ACTION . "edit_profile.php");
-                        $response = action($db);
+                        $response = action();
                         if (strlen($response) > 1){
                             echo($response);
                             return;
@@ -97,7 +105,7 @@
                         break;
                     default:
                         require_once(PATH::PAGE . "Error_Page.php");
-                        $page = new Error_Page($db, 404);
+                        $page = new Error_Page(404);
                         http_response_code(404);
                 }
             }
@@ -108,7 +116,7 @@
                 $_SESSION["session"] = false;
                 $_SESSION["uid"] = "";
                 require_once(PATH::PAGE . "Landing_Page.php");
-                $page = new Landing_Page($db);
+                $page = new Landing_Page();
                 require_once($page->view);
                 return;
             }
@@ -126,7 +134,7 @@
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r["c"] == 0){
                 require_once(PATH::PAGE . "Landing_Page.php");
-                $page = new Landing_Page($db);
+                $page = new Landing_Page();
                 require_once($page->view);
                 return;
             }
@@ -153,69 +161,69 @@
             array_shift($pars); // Remove first one, should be UID
             if (sizeof($pars) == 0){
                 require_once(PATH::PAGE . "Home_Page.php");
-                $page = new Home_Page($db);
+                $page = new Home_Page();
             }
             else{
                 if (strtoupper($pars[0]) == "FUSION"){
                     require_once(PATH::PAGE . "Fusion_Page.php");
-                    $page = new Fusion_Page($db);
+                    $page = new Fusion_Page();
                 }
                 elseif (strtoupper($pars[0]) == "RUNES"){
                     require_once(PATH::PAGE . "Runes_Page.php");
-                    $page = new Runes_Page($db);
+                    $page = new Runes_Page();
                 }
                 elseif (strtoupper($pars[0]) == "GUILD"){
                     require_once(PATH::PAGE . "Guild_Page.php");
-                    $page = new Guild_Page($db);
+                    $page = new Guild_Page();
                 }
                 elseif (strtoupper($pars[0]) == "RUNS"){
                     require_once(PATH::PAGE . "Runs_Page.php");
-                    $page = new Runs_Page($db);
+                    $page = new Runs_Page();
                 }
                 elseif (strtoupper($pars[0]) == "TEAMS"){
                     require_once(PATH::PAGE . "Teams_Page.php");
-                    $page = new Teams_Page($db);
+                    $page = new Teams_Page();
                 }
                 elseif (strtoupper($pars[0]) == "PROFILE"){
                     require_once(PATH::PAGE . "Profile_Page.php");
-                    $page = new Profile_Page($db);
+                    $page = new Profile_Page();
                 }
                 elseif (strtoupper($pars[0]) == "MONSTERS"){
                     if (count($pars) == 1){
                         require_once(PATH::PAGE . "Monsters_Page.php");
-                        $page = new Monsters_Page($db);
+                        $page = new Monsters_Page();
                     }
                     else{
                         require_once(PATH::PAGE . "Monster_Page.php");
-                        $page = new Monster_Page($db, $pars[1]);
+                        $page = new Monster_Page($pars[1]);
                     }
                 }
                 elseif (strtoupper($pars[0]) == "CATALOG"){
                     if (count($pars) == 1){
                         require_once(PATH::PAGE . "Catalog_Page.php");
-                        $page = new Catalog_Page($db);
+                        $page = new Catalog_Page();
                     }
                     else{
                         require_once(PATH::PAGE . "Monster_Info_Page.php");
-                        $page = new Monster_Info_Page($db, $pars[1]);
+                        $page = new Monster_Info_Page($pars[1]);
                     }
                 }
                 elseif (strtoupper($pars[0]) == "REPORT"){
                     if (count($pars) == 1){
                         require_once(PATH::PAGE . "Report_Page.php");
-                        $page = new Report_Page($db);
+                        $page = new Report_Page();
                     }
                     elseif (strtoupper($pars[1]) == "SKILLUP"){
                         require_once(PATH::PAGE . "Report_Skillup_Page.php");
-                        $page = new Report_Skillup_Page($db, $pars[1]);
+                        $page = new Report_Skillup_Page($pars[1]);
                     }
                     elseif (strtoupper($pars[1]) == "RUNEUPGRADE"){
                         require_once(PATH::PAGE . "Report_Runeupgrade_Page.php");
-                        $page = new Report_Runeupgrade_Page($db, $pars[1]);
+                        $page = new Report_Runeupgrade_Page($pars[1]);
                     }
                     elseif (strtoupper($pars[1]) == "RUNECRAFT"){
                         require_once(PATH::PAGE . "Report_Runecraft_Page.php");
-                        $page = new Report_Runecraft_Page($db, $pars[1]);
+                        $page = new Report_Runecraft_Page($pars[1]);
                     }
 
                 }
@@ -227,7 +235,7 @@
             }
             else{
                 require_once(PATH::PAGE . "Error_Page.php");
-                $page = new Error_Page($db, 404);
+                $page = new Error_Page(404);
                 http_response_code(404);
                 return 404;
             }

+ 4 - 2
application/action/edit_profile.php

@@ -18,12 +18,14 @@
      * Then it updates the selected info with the prameter vlue. Multiple
      * itemas can be updated at the same time.
      * 
-     * @param resource $db Database connection. 
      * @return int|string 0 on success, negative values on error. If the API
      * key has been updated, the new key.
      * @category Action
+     * @global resource Database connection.
      */
-    function action($db = null){
+    function action(){
+
+        global $db;
 
         $response = null;
 

+ 5 - 2
application/action/login.php

@@ -17,11 +17,14 @@
      * If there is a match, it sets cookies and session variables, and
      * redirects to the user homepage.
      * 
-     * @param resource $db Database connection. 
      * @return int 0 on success, negative values on error.
      * @category Action
+     * @global resource Database connection.
      */
-    function action($db = null){
+    function action(){
+
+        global $db;
+
         if (!isset($_POST['uname'], $_POST['password'])){
             return -1;
         }

+ 1 - 2
application/action/logout.php

@@ -13,12 +13,11 @@
      *
      * Invalidates cookies and session variables.
      * 
-     * @param resource $db Database connection. 
      * @return int 0.
      * @category Action
      * @global int The user id.
      */
-    function action($db = null){
+    function action(){
         global $UID;
         $UID = null;
         setcookie("uid", null, time() - 3600);

+ 4 - 8
application/action/new_team.php

@@ -22,17 +22,13 @@
      *  description
      * Validates the data and creates the team in the database.
      * 
-     * @param resource $db Database connection. 
      * @return int 0 on success, negative values on error.
      * @category Action
-     * @global int[] Area types.
-     * @global int[] Difficulty levels.
-     * @global int[] Scenario areas.
-     * @global int[] Dungeon sections.
-     * @global int[] Elemental rift dungeons.
-     * @global int[] Labyrinth stage types.
+     * @global resource Database connection.
      */
-    function action($db = null){
+    function action(){
+
+        global $db;
 
         $player = filter_input(INPUT_POST, 'uid');
         $area_type = filter_input(INPUT_POST, 'area_type');

+ 3 - 2
application/action/save_run_team.php

@@ -17,11 +17,12 @@
      *  description
      * Validates the data and creates the team in the database.
      * 
-     * @param resource $db Database connection. 
      * @return int 0 on success, negative values on error.
      * @category Action
+     * @global resource Database connection.
      */
-    function action($db = null){
+    function action(){
+        global $db;
         $player = filter_input(INPUT_POST, 'uid');
         $run = filter_input(INPUT_POST, 'run');
         $name = filter_input(INPUT_POST, 'name');

+ 7 - 5
application/entity/Building.php

@@ -44,11 +44,13 @@
          * Searches the database and retrieves the information about the
          * building, populating it and it's items.
          *
-         * @param resource $db Connection to the database.
          * @param int $id Building identifier.
+         * @global resource Database connection.
          */
-        public function __construct($db, $id){
-            parent::__construct($db);
+        public function __construct($id){
+
+            global $db;
+
             $s = "
                 SELECT
                   uid,
@@ -57,10 +59,10 @@
                 FROM building
                 WHERE id = $id;
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             $this->uid = $r["uid"];
-            $this->building = new K_Building($this->db, $r["building"]);
+            $this->building = new K_Building($r["building"]);
             $this->gain = $r["gain"];
         }
     }

+ 6 - 4
application/entity/Custom_Filter.php

@@ -57,11 +57,13 @@
          * Searches the database and retrieves the information about the
          * run, populating it and it's items.
          *
-         * @param resource $db Connection to the database.
          * @param int $id Filter identifier.
+         * @global resource Database connection.
          */
-        public function __construct($db, $id){
-            parent::__construct($db);
+        public function __construct($id){
+
+            global $db;
+
             $s = "
                 SELECT
                   uid,
@@ -73,7 +75,7 @@
                 FROM filter
                 WHERE id = $id;
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             $this->id = $r["id"];
             $this->uid = $r["uid"];

+ 7 - 5
application/entity/Decoration.php

@@ -43,11 +43,13 @@
          * Searches the database and retrieves the information about the
          * decoration, populating it and it's items.
          *
-         * @param resource $db Connection to the database.
          * @param int $id Building identifier.
+         * @global resource Database connection.
          */
-        public function __construct($db, $id){
-            parent::__construct($db);
+        public function __construct($id){
+
+            global $db;
+
             $s = "
                 SELECT
                   uid,
@@ -56,10 +58,10 @@
                 FROM decoration
                 WHERE id = $id;
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             $this->uid = $r["uid"];
-            $this->decoration = new K_Decoration($this->db, $r["decoration"]);
+            $this->decoration = new K_Decoration($r["decoration"]);
             $this->level = $r["level"];
         }
     }

+ 3 - 10
application/entity/Entity.php

@@ -18,20 +18,13 @@
      */
     abstract class Entity{
 
-        /**
-         * @var resource Database connection.
-         */
-        public $db;
-
         /**
          * Constructor.
          *
-         * Sets the database conection and the language.
-         *
-         * @param resource $db Connection to the database.
+         * Empty.
          */
-        public function __construct($db){
-            $this->db = $db;
+        public function __construct(){
+
         }
     }
 ?>

+ 19 - 16
application/entity/Fusion.php

@@ -33,12 +33,13 @@
          * Searches the database and retrieves the information about the
          * fusion, populating it and it's items.
          *
-         * @param resource $db Connection to the database.
          * @param int $id Unit id.
          * @param int $uid Player id.
+         * @global resource Database connection.
          */
-        public function __construct($db, $id, $uid){
-            parent::__construct($db, $id, false);
+        public function __construct($id, $uid){
+            global $db;
+            parent::__construct($id, false);
             $s = "
               SELECT unit.id AS id
               FROM
@@ -53,9 +54,9 @@
                   k_unit.awakens_to = $id
                 );
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->owned, new Unit($this->db, $r["id"], false));
+                array_push($this->owned, new Unit($r["id"], false));
             }
         }
     }
@@ -116,12 +117,14 @@
          * Searches the database and retrieves the information about the
          * fusion, populating it and it's items.
          *
-         * @param resource $db Connection to the database.
          * @param int $id Product monster id.
          * @param int $uid User id.
+         * @global resource Database connection.
          */
-        public function __construct($db, $id, $uid = null){
-            parent::__construct($db);
+        public function __construct($id, $uid = null){
+
+            global $db;
+
             $s = "
               SELECT DISTINCT
                 product,
@@ -133,10 +136,10 @@
                 product = (SELECT awakens_to FROM k_unit WHERE id = $id) OR
                 product = (SELECT awakens_from FROM k_unit WHERE id = $id);
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
-            $this->product = new Monster_Fusion($this->db, $r["product"], $uid);
-            $this->product_awaken = new Monster_Fusion($this->db, $this->product->awakens_to, $uid);
+            $this->product = new Monster_Fusion($r["product"], $uid);
+            $this->product_awaken = new Monster_Fusion($this->product->awakens_to, $uid);
             $this->stars = $r["stars"];
             $this->cost = $r["cost"];
             $s_f = "
@@ -155,9 +158,9 @@
                     k_fusion.product = k_unit.id
                 );
             ";
-            $q_f = $this->db->query($s_f);
+            $q_f = $db->query($s_f);
             while ($r_f = $q_f->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->fusion, new Fusion($this->db, $r_f["ingredient"], $uid));
+                array_push($this->fusion, new Fusion($r_f["ingredient"], $uid));
             }
             $s_m =
               "SELECT  " .
@@ -181,11 +184,11 @@
               "        k_fusion.product = k_unit.id " .
               "    ) " .
               "  ); ";
-            $q_m = $this->db->query($s_m);
+            $q_m = $db->query($s_m);
             while ($r_m = $q_m->fetchArray(SQLITE3_ASSOC)){
-                $m = new Monster_Fusion($this->db, $r_m["id"], $uid);
+                $m = new Monster_Fusion($r_m["id"], $uid);
                 array_push($this->ingredient, $m);
-                $m = new Monster_Fusion($this->db, $r_m["awakens_from"], $uid);
+                $m = new Monster_Fusion($r_m["awakens_from"], $uid);
                 $m->load_essences();
                 array_push($this->ingredient_unawaken, $m);
             }

+ 9 - 8
application/entity/Guild.php

@@ -78,19 +78,20 @@
          * Searches the database and retrieves the information about the
          * guild, populating it and it's items.
          *
-         * @param resource $db Connection to the database.
          * @param int $id Guild identifier.
+         * @global resource Database connection.
          */
-        public function __construct($db, $id){
-            global $path;
-            parent::__construct($db);
+        public function __construct($id){
+
+            global $db;
+
             $s =
               "SELECT " .
               "  id, " .
               "  name, " .
               "  name, " .
               "  level, " .
-              "  experience, " .
+              "              experience, " .
               "  recruiting, " .
               "  members, " .
               "  leader, " .
@@ -98,7 +99,7 @@
               "  notice " .
               "FROM guild " .
               "WHERE id = $id; ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r){
                 $this->id = $r["id"];
@@ -120,9 +121,9 @@
               "  grade = 3 DESC, " .
               "  grade = 2 DESC, " .
               "  arena_score DESC; ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->members, new Guild_Member($db, $r["id"]));
+                array_push($this->members, new Guild_Member($r["id"]));
             }
         }
 

+ 6 - 5
application/entity/Guild_Member.php

@@ -83,12 +83,13 @@
          * Searches the database and retrieves the information about the
          * guild, populating it and it's items.
          *
-         * @param resource $db Connection to the database.
          * @param int $id Guild identifier.
+         * @global resource Database connection.
          */
-        public function __construct($db, $id){
-            global $path;
-            parent::__construct($db);
+        public function __construct($id){
+
+            global $db;
+
             $s =
               "SELECT " .
               "  id, " .
@@ -104,7 +105,7 @@
               "  has_defense " .
               "FROM guild_member " .
               "WHERE id = $id; ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r){
                 $this->id = $r["id"];

+ 7 - 5
application/entity/Inventory.php

@@ -58,12 +58,14 @@
          * Searches the database and retrieves the information about the
          * building, populating it and it's items.
          *
-         * @param resource $db Connection to the database.
          * @param int $id Item identifier.
          * @param int $type Item type identifier. Optional, will try to guess if null.
+         * @global resource Database connection.
          */
-        public function __construct($db, $id, $type = null){
-            parent::__construct($db);
+        public function __construct($id, $type = null){
+
+            global $db;
+
             $s = "
                 SELECT
                   inventory.id AS id,
@@ -85,13 +87,13 @@
             if ($type != null){
                 $s .= "AND inventory.type = $type";
             }
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             $this->type = $r["type"];
             $this->amount = $r["amount"];
             if ($r["type"] == INVENTORY_TYPE_ID::GUILD_MONSTER_PIECE || $r["type"] == INVENTORY_TYPE_ID::MONSTER_PIECE){
                 $this->is_monster_pices = true;
-                $this->id = new K_Unit($this->db, $r["id"]);
+                $this->id = new K_Unit($r["id"]);
                 $this->name = HTML::e($this->id->title) . " Pieces";
                 $this->description = HTML::e($this->id->title) . " Pieces";
             }

+ 6 - 4
application/entity/K_Area.php

@@ -43,12 +43,14 @@
          * Searches the database and retrieves the information about the
          * run, populating it and it's items.
          *
-         * @param resource $db Connection to the database.
          * @param int $id Area identifier.
          * @param int $type Area type (required).
+         * @global resource Database connection.
          */
-        public function __construct($db, $id, $type){
-            parent::__construct($db);
+        public function __construct($id, $type){
+
+            global $db;
+
             $this->id = $id;
             $this->type = $type;
             $s = "
@@ -62,7 +64,7 @@
                   type = '$type' 
                 ORDER BY type = '$type' DESC;
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r){
                 $this->name = HTML::e($r["name"]);

+ 6 - 4
application/entity/K_Building.php

@@ -43,11 +43,13 @@
          * Searches the database and retrieves the information about the
          * building, populating it and it's items.
          *
-         * @param resource $db Connection to the database.
          * @param int $id Building identifier.
+         * @global resource Database connection.
          */
-        public function __construct($db, $id){
-            parent::__construct($db);
+        public function __construct($id){
+
+            global $db;
+
             $s =
               "SELECT " .
               "  id, " .
@@ -55,7 +57,7 @@
               "  description " .
               "FROM k_building " .
               "WHERE id = '$id'; ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r){
                 $this->id = $r["id"];

+ 7 - 5
application/entity/K_Decoration.php

@@ -73,11 +73,13 @@
          * Searches the database and retrieves the information about the
          * decoration, populating it and it's items.
          *
-         * @param resource $db Connection to the database.
          * @param int $id Decoration identifier.
+         * @global resource Database connection.
          */
-        public function __construct($db, $id){
-            parent::__construct($db);
+        public function __construct($id){
+
+            global $db;
+
             $s = "
                 SELECT
                   id,
@@ -90,7 +92,7 @@
                 FROM k_decoration
                 WHERE id = $id;
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r){
                 $this->id = $r["id"];
@@ -108,7 +110,7 @@
                     FROM k_decoration_level
                     WHERE decoration = $id
                 ";
-                $q = $this->db->query($s);
+                $q = $db->query($s);
                 while ($r = $q->fetchArray(SQLITE3_ASSOC)){
                     $this->level_bonus[$r["level"]] = $r["bonus"];
                     $this->level_cost[$r["level"]] = $r["cost"];

+ 6 - 4
application/entity/K_Effect.php

@@ -47,11 +47,13 @@
          * Searches the database and retrieves the information about the
          * skill level, populating it and it's items.
          *
-         * @param reocurce $db Connection to the database.
          * @param int $id Effect identifier.
+         * @global resource Database connection.
          */
-        public function __construct($db, $id){
-            parent::__construct($db);
+        public function __construct($id){
+
+            global $db;
+
             $s =
               "SELECT " .
               "  id, " .
@@ -60,7 +62,7 @@
               "  description " .
               "FROM k_effect " .
               "WHERE id = $id;";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r){
                 $this->id = $r["id"];

+ 6 - 4
application/entity/K_Guild_Skill.php

@@ -47,11 +47,13 @@
          * Searches the database and retrieves the information about the
          * skill, populating it and it's items.
          *
-         * @param resource $db Connection to the database.
          * @param int $id Skill identifier.
+         * @global resource Database connection.
          */
-        public function __construct($db, $id){
-            parent::__construct($db);
+        public function __construct($id){
+
+            global $db;
+
             $s =
               "SELECT " .
               "  id, " .
@@ -60,7 +62,7 @@
               "  effect " .
               "FROM k_guild_skill " .
               "WHERE id = $id; ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r){
                 $this->id = $r["id"];

+ 8 - 6
application/entity/K_Guild_Skill_Group.php

@@ -48,11 +48,13 @@
          * Searches the database and retrieves the information about the
          * skill group, populating it and it's items.
          *
-         * @param resource $db Connection to the database.
          * @param int $id Skill group identifier.
+         * @global resource Database connection.
          */
-        public function __construct($db, $id){
-            parent::__construct($db);
+        public function __construct($id){
+
+            global $db;
+
             $s =
               "SELECT " .
               "  id, " .
@@ -60,7 +62,7 @@
               "  description " .
               "FROM k_guild_skill_group " .
               "WHERE id = $id; ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r){
                 $this->id = $r["id"];
@@ -71,9 +73,9 @@
               "SELECT id " .
               "FROM k_guild_skill " .
               "WHERE skill_group = $this->id; ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->skills, new K_Guild_Skill($db, $r["id"]));
+                array_push($this->skills, new K_Guild_Skill($r["id"]));
             }
         }
 

+ 4 - 4
application/entity/K_Inventory.php

@@ -47,12 +47,12 @@
          * Searches the database and retrieves the information about the
          * building, populating it and it's items.
          *
-         * @param resource $db Connection to the database.
          * @param int $id Item identifier.
          * @param int $type Item type identifier. Optional, will try to guess if null.
+         * @global resource Database connection.
          */
-        public function __construct($db, $id, $type = null){
-            parent::__construct($db);
+        public function __construct($id, $type = null){
+            global $db;
             $s = "
                 SELECT
                   k_inventory.id AS id,
@@ -69,7 +69,7 @@
             if ($type != null){
                 $s .= "AND k_inventory.type = $type";
             }
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             $this->type = $r["type"];
             $this->amount = $r["amount"];

+ 6 - 7
application/entity/K_Leader_Skill.php

@@ -52,11 +52,13 @@
          * Searches the database and retrieves the information about the
          * skill, populating it and it's items.
          *
-         * @param resource $db Connection to the database.
          * @param int $id Skill identifier.
+         * @global resource Database connection.
          */
-        public function __construct($db, $id){
-            parent::__construct($db);
+        public function __construct($id){
+
+            global $db;
+
             $s =
               "SELECT " .
               "  id, " .
@@ -66,7 +68,7 @@
               "  element " .
               "FROM k_leader_skill " .
               "WHERE id = $id; ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             $this->id = $r["id"];
             $this->attribute = $r["stat"];
@@ -92,9 +94,6 @@
          * @return string The description.
          */
         public function create_description(){
-            global $STAT;
-            global $ELEMENT;
-            global $EFFECT_AREA;
             $s = "Increases the ";
             switch ($this->attribute){
                 case STAT_ID::ATK:

+ 6 - 4
application/entity/K_Rune_Set.php

@@ -47,11 +47,13 @@
          * Searches the database and retrieves the information about the
          * set, populating it and it's items.
          *
-         * @param resource $db Connection to the database.
          * @param int $id Set identifier.
+         * @global resource Database connection.
          */
-        public function __construct($db, $id){
-            parent::__construct($db);
+        public function __construct($id){
+
+            global $db;
+
             $s =
               "SELECT " .
               "  id, " .
@@ -60,7 +62,7 @@
               "  description " .
               "FROM k_rune_set " .
               "WHERE id = $id;";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r){
                 $this->id = $r["id"];

+ 10 - 8
application/entity/K_Skill.php

@@ -95,11 +95,13 @@
          * Searches the database and retrieves the information about the
          * skill, populating it and it's items.
          *
-         * @param resource $db Connection to the database.
          * @param int $id Skill identifier.
+         * @global resource Database connection.
          */
-        public function __construct($db, $id){
-            parent::__construct($db);
+        public function __construct($id){
+
+            global $db;
+
             $s =
               "SELECT " .
               "  id, " .
@@ -114,7 +116,7 @@
               "  multiplier_formula " .
               "FROM k_skill " .
               "WHERE id = $id; ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             $this->id = $r["id"];
             $this->name = HTML::e($r["name"]);
@@ -133,17 +135,17 @@
               "FROM k_skill_level " .
               "WHERE skill = " . $this->id . " " .
               "ORDER BY level; ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->level, new K_Skill_Level($this->db, $r["skill"], $r["level"]));
+                array_push($this->level, new K_Skill_Level($r["skill"], $r["level"]));
             }
             $s =
               "SELECT effect " .
               "FROM k_skill_effect " .
               "WHERE skill = " . $this->id . "; ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->effect, new K_Effect($this->db, $r["effect"]));
+                array_push($this->effect, new K_Effect($r["effect"]));
             }
         }
 

+ 6 - 4
application/entity/K_Skill_Level.php

@@ -42,12 +42,14 @@
          * Searches the database and retrieves the information about the
          * skill level, populating it and it's items.
          *
-         * @param resource $db Connection to the database.
          * @param int $skill Skill identifier.
          * @param int $level Skill level.
+         * @global resource Database connection.
          */
-        public function __construct($db, $skill, $level){
-            parent::__construct($db);
+        public function __construct($skill, $level){
+
+            global $db;
+
             $s =
               "SELECT " .
               "  skill, " .
@@ -57,7 +59,7 @@
               "WHERE " .
               "  skill = $skill AND " .
               "  level = $level;";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r){
                 $this->skill = $r["skill"];

+ 6 - 6
application/entity/K_Source.php

@@ -46,13 +46,13 @@
          * Constructor.
          *
          * Searches the database and retrieves the information about the
-         * monster, populating it and it's items.
+         * source, populating it and it's items.
          *
-         * @param resource $db Connection to the database.
-         * @param int $id Monster identifier.
+         * @param int $id Surce identifier.
+         * @global resource Database connection.
          */
-        public function __construct($db, $id){
-            parent::__construct($db);
+        public function __construct($id){
+            global $db;
             $s =
               "SELECT " .
               "  id, " .
@@ -61,7 +61,7 @@
               "  farmable " .
               "FROM k_source " .
               "WHERE id = $id; ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r){
                 $this->id = $r["id"];

+ 25 - 13
application/entity/K_Unit.php

@@ -230,12 +230,12 @@
          * Searches the database and retrieves the information about the
          * unit, populating it and it's items.
          *
-         * @param resouce $db Connection to the database.
          * @param int $id Unit identifier.
          * @param bool $complete If false, query only k_unit.
+         * @global resource Database connection.
          */
-        public function __construct($db, $id, $complete = true){
-            parent::__construct($db);
+        public function __construct($id, $complete = true){
+            global $db;
             $s =
               "SELECT " .
               "  id, " .
@@ -271,7 +271,7 @@
               "  craft_cost " .
               "FROM k_unit " .
               "WHERE id = $id; ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r){
                 $this->id = $r["id"];
@@ -320,7 +320,7 @@
                 $this->awaken_bonus = HTML::e($r["awaken_bonus"]);
                 $this->skill_ups_to_max = $r["skill_ups_to_max"];
                 if (strlen($r["leader_skill"]) > 0){
-                    $this->leader_skill = new K_Leader_Skill($this->db, $r["leader_skill"]);
+                    $this->leader_skill = new K_Leader_Skill($r["leader_skill"]);
                 }
                 $this->hp = $r["hp"];
                 $this->attack = $r["attack"];
@@ -368,8 +368,11 @@
          * It is autoatically called at construction time if the
          * $complete parameter is true (by default). No point in calling it
          * twice.
+         *
+         * @global resource Database connection.
          */
         public function load_essences(){
+            global $db;
             $this->essences = [];
             $s =
               "SELECT " .
@@ -379,10 +382,10 @@
               "WHERE " .
               "  unit = " . $this->id . " " .
               "ORDER BY item; ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
                 $e = [
-                    "item" => new K_Inventory($this->db, $r["item"], INVENTORY_TYPE_ID::ESSENCES),
+                    "item" => new K_Inventory($r["item"], INVENTORY_TYPE_ID::ESSENCES),
                     "amount" => $r["amount"]
                 ];
                 array_push($this->essences, $e);
@@ -395,17 +398,20 @@
          * It is automatically called at construction time if the
          * $complete parameter is true (by default). No point in calling it
          * twice.
+         *
+         * @global resource Database connection.
          */
         public function load_transformation(){
+            global $db;
             $this->transformation = null;
             $s = "
               SELECT id
               FROM k_unit_transformation
               WHERE  unit = " . $this->id . ";";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r){
-                $this->transformation = new K_Unit_Transformation($this->db, $r["id"]);
+                $this->transformation = new K_Unit_Transformation($r["id"]);
             }
         }
 
@@ -415,8 +421,11 @@
          * It is autoatically called at construction time if the
          * $complete parameter is true (by default). No point in calling it
          * twice.
+         *
+         * @global resource Database connection.
          */
         public function load_skills(){
+            global $db;
             $this->skill = [];
             $s = "
               SELECT skill
@@ -428,9 +437,9 @@
                 unit = " . $this->id . "
               ORDER BY slot;
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->skill, new K_Skill($this->db, $r["skill"]));
+                array_push($this->skill, new K_Skill($r["skill"]));
             }
         }
 
@@ -440,16 +449,19 @@
          * It is autoatically called at construction time if the
          * $complete parameter is true (by default). No point in calling it
          * twice.
+         *
+         * @global resource Database connection.
          */
         public function load_sources(){
+            global $db;
             $this->sources = [];
             $s =
               "SELECT source " .
               "FROM k_unit_source " .
               "WHERE unit = " . $this->id . ";";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->sources, new K_Source($this->db, $r["source"]));
+                array_push($this->sources, new K_Source($r["source"]));
             }
         }
 

+ 10 - 7
application/entity/K_Unit_Transformation.php

@@ -51,11 +51,11 @@
          * Searches the database and retrieves the information about the
          * trnsformed unit, populating it and it's items.
          *
-         * @param resource $db Connection to the database.
-         * @param int $id TRansformed unit identifier.
+         * @param int $id Transformed unit identifier.
+         * @global resource Database connection.
          */
-        public function __construct($db, $id){
-            parent::__construct($db);
+        public function __construct($id){
+            global $db;
             $s = "
               SELECT
                 id,
@@ -64,7 +64,7 @@
               FROM k_unit_transformation
               WHERE id = $id;
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r){
                 $this->id = $r["id"];
@@ -76,8 +76,11 @@
 
         /**
          * Loads the information about the unit skills in the transformed form.
+         *
+         * @global resource Database connection.
          */
         private function load_skills(){
+            global $db;
             $this->skill = [];
             $s = "
               SELECT skill
@@ -89,9 +92,9 @@
                 unit = " . $this->id . "
               ORDER BY slot;
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->skill, new K_Skill($this->db, $r["skill"]));
+                array_push($this->skill, new K_Skill($r["skill"]));
             }
         }
 

+ 22 - 20
application/entity/Run.php

@@ -134,11 +134,13 @@
          * Searches the database and retrieves the information about the
          * run, populating it and it's items.
          *
-         * @param resource $db Connection to the database.
          * @param int $id Run identifier.
+         * @global resource Database connection.
          */
-        public function __construct($db, $id){
-            parent::__construct($db);
+        public function __construct($id){
+
+            global $db;
+
             $s = "
                 SELECT
                   id,
@@ -156,7 +158,7 @@
                 FROM run
                 WHERE id = $id;
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             $this->id = $r["id"];
             $this->uid = $r["uid"];
@@ -174,7 +176,7 @@
             elseif (APPLICATION::valid_id("DUNGEON_ID", $r["area"])){
                 $type = AREA_TYPE_ID::CAIROS_DUNGEON;
             }
-            $this->area = new K_Area($this->db, $r["area"], $type);
+            $this->area = new K_Area($r["area"], $type);
             $this->stage = $r["stage"];
             $this->difficulty = $r["difficulty"];
             $this->win = $r["win"];
@@ -191,13 +193,13 @@
                 FROM run_party
                 WHERE run = $id;
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
                 if ($r["owned"] > 0){
-                    array_push($this->party, new Unit($this->db, $r["unit"], false));
+                    array_push($this->party, new Unit($r["unit"], false));
                 }
                 else{
-                    array_push($this->party, new K_Unit($this->db, $r["k_unit"], false));
+                    array_push($this->party, new K_Unit($r["k_unit"], false));
                 }
             }
             $s = "
@@ -207,9 +209,9 @@
                 FROM run_drop_item
                 WHERE run = $this->id;
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                $i = new Inventory($this->db, $r["item"]);
+                $i = new Inventory($r["item"]);
                 $i->amount =  $r["amount"];
                 array_push($this->item, $i);
             }
@@ -218,18 +220,18 @@
                 FROM run_drop_unit
                 WHERE run = $this->id;
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->unit, new K_Unit($this->db, $r["unit"]));
+                array_push($this->unit, new K_Unit($r["unit"]));
             }
             $s = "
                 SELECT unit
                 FROM run_drop_sd
                 WHERE run = $this->id;
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->sd, new K_Unit($this->db, $r["unit"]));
+                array_push($this->sd, new K_Unit($r["unit"]));
             }
             $s = "
                 SELECT
@@ -238,10 +240,10 @@
                 FROM run_drop_unit_pieces
                 WHERE run = $this->id;
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
                 $i = [
-                    "unit" => new K_Unit($this->db, $r["unit"]),
+                    "unit" => new K_Unit($r["unit"]),
                     "amount" => $r["amount"]
                 ];
                 array_push($this->unit_piece, $i);
@@ -251,7 +253,7 @@
                 FROM run_drop_shapeshifting
                 WHERE run = $this->id;
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r){
                 $this->shapeshifting = $r["amount"];
@@ -281,14 +283,14 @@
                 FROM run_drop_rune
                 WHERE run = $this->id;
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                $rune = new Rune($this->db, $r["id"]);
+                $rune = new Rune($r["id"]);
                 if (!isset($rune->id)){
                     $rune->id = $r["id"];
                     $rune->level = 0;
                     $rune->assigned_to = null;
-                    $rune->type = new K_Rune_Set($this->db, $r["type"]);
+                    $rune->type = new K_Rune_Set($r["type"]);
                     $rune->slot = $r["slot"];
                     $rune->stars = $r["stars"];
                     $rune->ancient = $r["ancient"];

+ 7 - 5
application/entity/Rune.php

@@ -234,11 +234,13 @@
          * Searches the database and retrieves the information about the
          * rune, populating it and it's items.
          *
-         * @param resource $db Connection to the database.
          * @param int $id Rune id.
+         * @global resource Database connection.
          */
-        public function __construct($db, $id){
-            parent::__construct($db);
+        public function __construct($id){
+
+            global $db;
+
             $s =
               "SELECT " .
               "  id, " .
@@ -275,12 +277,12 @@
               "  substat_4_grind " .
               "FROM rune " .
               "WHERE id = '$id'; ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r){
                 $this->id = $r["id"];
                 $this->assigned_to = $r["assigned_to"];
-                $this->type = new K_Rune_Set($this->db, $r["type"]);
+                $this->type = new K_Rune_Set($r["type"]);
                 $this->slot = $r["slot"];
                 $this->stars = $r["stars"];
                 $this->level = $r["level"];

+ 7 - 5
application/entity/Rune_Craft.php

@@ -102,11 +102,13 @@
          * Searches the database and retrieves the information about the
          * rune, populating it and it's items.
          *
-         * @param resource $db Connection to the database.
          * @param int $id Rune id.
+         * @global resource Database connection.
          */
-        public function __construct($db, $id){
-            parent::__construct($db);
+        public function __construct($id){
+
+            global $db;
+
             $s =
               "SELECT " .
               "  rune_craft.id AS id, " .
@@ -132,7 +134,7 @@
               "  k_rune_craft_type.ancient = k_rune_craft_range.ancient AND " .
               "  rune_craft.quality = k_rune_craft_range.quality AND " .
               "  rune_craft.stat = k_rune_craft_range.stat;";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r){
                 $this->id = $r["id"];
@@ -144,7 +146,7 @@
                 $this->ancient = $r["ancient"];
                 $this->inmemorial = $r["inmemorial"];
                 if ($this->inmemorial == 0){
-                    $this->rune = new K_Rune_Set($this->db, $r["rune"]);
+                    $this->rune = new K_Rune_Set($r["rune"]);
                     $this->name = $this->rune->name . " " . $r["stat"];
                 }
                 else{

+ 9 - 7
application/entity/Team.php

@@ -80,12 +80,14 @@
          * Searches the database and retrieves the information about the
          * monster, populating it and it's items.
          *
-         * @param resource $db Connection to the database.
          * @param int $id Monster identifier.
          * @param bool $complete If false, it won't load the units.
+         * @global resource Database connection.
          */
-        public function __construct($db, $id, $complete = true){
-            parent::__construct($db);
+        public function __construct($id, $complete = true){
+
+            global $db;
+
             $s = "
               SELECT
                 uid,
@@ -99,13 +101,13 @@
               FROM team
               WHERE id = '$id';
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             $this->uid = $r["uid"];
             $this->id = $r["id"];
             $this->name = HTML::e($r["name"]);
             $this->description = HTML::e($r["description"]);
-            $this->area = new K_Area($this->db, $r["area"], $r["area_type"]);
+            $this->area = new K_Area($r["area"], $r["area_type"]);
             $this->stage = $r["stage"];
             if ($complete){
                 $s = "
@@ -119,9 +121,9 @@
                     front DESC,
                     leader DESC;
                 ";
-                $q = $this->db->query($s);
+                $q = $db->query($s);
                 while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                    array_push($this->unit, new Unit($this->db, $r["unit"], false));
+                    array_push($this->unit, new Unit($r["unit"], false));
                     if ($r["leader"] == 1){
                         $this->leader = $r["unit"];
                     }

+ 21 - 14
application/entity/Unit.php

@@ -225,14 +225,14 @@
          * Searches the database and retrieves the information about the
          * monster, populating it and it's items.
          *
-         * @param resource $db Connection to the database.
          * @param int $id Monster identifier.
          * @param bool $complete If false, query only monster and k_monster.
          * @global int Player ID.
+         * @global resource Database connection.
          */
-        public function __construct($db, $id, $complete = true){
+        public function __construct($id, $complete = true){
             global $UID;
-            parent::__construct($db);
+            global $db;
             $s =
               "SELECT " .
               "  uid, " .
@@ -261,15 +261,15 @@
               "WHERE " .
               "  uid = '$UID' AND " .
               "  id = '$id'; ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             $this->uid = $r["uid"];
             $this->id = $r["id"];
             if ($r["building"] != null && $r["building"] > 0){
-                $this->building = new Building($this->db, $r["building"]);
+                $this->building = new Building($r["building"]);
             }
             if (strlen($r["unit"]) > 0){
-                $this->unit = new K_Unit($this->db, $r["unit"], $complete);
+                $this->unit = new K_Unit($r["unit"], $complete);
             }
             $this->stars = $r["stars"];
             $this->level = $r["level"];
@@ -285,7 +285,7 @@
             $this->exp_gained = $r["exp_gained"];
             $this->exp_gain_rate = $r["exp_gain_rate"];
             $this->costume = $r["costume"];
-            $this->source = new K_Source($this->db, $r["source"]);
+            $this->source = new K_Source($r["source"]);
             $this->create_time = date_create($r["create_time"]);
             $this->homunculus_name = $r["homunculus_name"];
             if ($complete){
@@ -302,7 +302,7 @@
                   "  k_skill.id = unit_skill.skill AND " .
                   "  unit = '$this->id' " .
                   "ORDER BY slot;";
-                $q = $this->db->query($s);
+                $q = $db->query($s);
                 while ($r = $q->fetchArray(SQLITE3_ASSOC)){
                     array_push($this->skill_levels, $r["level"]);
                 }
@@ -312,7 +312,7 @@
                   "WHERE " .
                   "  stars = $this->stars AND " .
                   "  level = $this->level;";
-                $q = $this->db->query($s);
+                $q = $db->query($s);
                 $r = $q->fetchArray(SQLITE3_ASSOC);
                 $this->experience_level = $r["exp"];
                 $this->experience_level_up = $r["exp"] - $this->exp_gained;
@@ -330,9 +330,11 @@
          * true or false.
          *
          * @global int Player ID.
+         * @global resource Database connection.
          */
         public function check_storage(){
             global $UID;
+            global $db;
             $s = "
               SELECT 1
               FROM
@@ -345,7 +347,7 @@
                 unit.building = building.id AND
                 building.building = '" . BUILDING_ID::MONSTER_STORAGE . "';
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             if ($q->fetchArray(SQLITE3_ASSOC) == false){
                 $this->in_storage = false;
             }
@@ -358,9 +360,11 @@
          * Loads the {@see teams} array, with the teams the unit is on.
          *
          * @global int Player ID.
+         * @global resource Database connection.
          */
         public function load_teams(){
             global $UID;
+            global $db;
             $this->teams = [];
             $s = "
               SELECT DISTINCT team.id AS id
@@ -372,9 +376,9 @@
                 team.id = team_unit.team AND
                 team_unit.unit = '" . $this->id . "';
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->teams, new Team($this->db, $r["id"], false));
+                array_push($this->teams, new Team($r["id"], false));
             }
         }
 
@@ -383,16 +387,19 @@
          * It is autoatically called at construction time if the
          * $complete parameter is true (by default). No point in calling it
          * twice.
+         *
+         * @global resource Database connection.
          */
         public function load_runes(){
+            global $db;
             $this->rune = [];
             $s =
               "SELECT id " .
               "FROM rune " .
               "WHERE assigned_to = '$this->id'; ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->rune, new Rune($this->db, $r["id"]));
+                array_push($this->rune, new Rune($r["id"]));
             }
             foreach ($this->rune as $rune){
                 $this->sum_rune_stat($rune->main_stat, $rune->main_stat_value);

+ 5 - 5
application/page/Catalog_Page.php

@@ -31,16 +31,16 @@
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param resource $db Connection to the database.
+         * @global resource Connection to the database.
          */
-        public function __construct($db){
-            parent::__construct($db);
+        public function __construct(){
+            global $db;
             $this->view = PATH::VIEW . "catalog.php";
             $this->parse_filters();
             $s_mon = $this->build_query();
-            $q_mon = $this->db->query($s_mon);
+            $q_mon = $db->query($s_mon);
             while ($r_mon = $q_mon->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->units, new K_Unit($db, $r_mon["id"], false));
+                array_push($this->units, new K_Unit($r_mon["id"], false));
             }
             $this->title = "Catalog - SWDB";
             $this->description = "Catalog of all monsters";

+ 7 - 7
application/page/Fusion_Page.php

@@ -36,12 +36,12 @@
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param resource $db Connection to the database.
          * @global int User ID.
+         * @global resource Connection to the database.
          */
-        public function __construct($db){
+        public function __construct(){
             global $UID;
-            parent::__construct($db);
+            global $db;
             $this->view = PATH::VIEW . "fusion.php";
             $this->parse_filters();
             $s =
@@ -49,14 +49,14 @@
               "FROM k_fusion " .
               "WHERE stars = 5 " .
               "ORDER BY stars DESC; ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->products, new K_Unit($this->db, $r["product"], false));
+                array_push($this->products, new K_Unit($r["product"], false));
             }
             $s = $this->build_query();
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->fusion, new Fusion($this->db, $r["product"], $UID));
+                array_push($this->fusion, new Fusion($r["product"], $UID));
             }
             $this->title = "Fusion - SWDB";
             $this->description = "Fusion chart";

+ 7 - 7
application/page/Guild_Page.php

@@ -36,23 +36,23 @@
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param resource $db Connection to the database.
          * @global int Player id.
+         * @global resource Connection to the database.
          */
-        public function __construct($db){
+        public function __construct(){
             global $UID;
-            parent::__construct($db);
+            global $db;
             $this->view = PATH::VIEW . "guild.php";
             $s = "
               SELECT id
               FROM guild
               WHERE id = (SELECT guild FROM guild_member WHERE id = '$UID');
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r){
                 $guild_id =  $r["id"];
-                $this->guild = new Guild($db, $guild_id);
+                $this->guild = new Guild($guild_id);
                 $this->title = $this->guild->name . " - SWDB";
                 $this->description = $this->guild->name . " Guild details";
                 $s = "
@@ -60,9 +60,9 @@
                   FROM k_guild_skill_group
                   ORDER BY id;
                 ";
-                $q = $this->db->query($s);
+                $q = $db->query($s);
                 while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                    array_push($this->skill_groups, new K_Guild_Skill_Group($db, $r["id"]));
+                    array_push($this->skill_groups, new K_Guild_Skill_Group($r["id"]));
                 }
             }
             else{

+ 19 - 20
application/page/Home_Page.php

@@ -118,13 +118,12 @@
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param resource $db Connection to the database.
          * @global int Player ID.
+         * @global resource Connection to the database.
          */
-        public function __construct($db){
-            global $INVENTORY_TYPE;
+        public function __construct(){
             global $UID;
-            parent::__construct($db);
+            global $db;
             $this->view = PATH::VIEW . "home.php";
             $s = "
               SELECT
@@ -154,7 +153,7 @@
               FROM player
               WHERE uid = '$UID';
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r){
                 $this->uid = $r["uid"];
@@ -163,7 +162,7 @@
                 $this->country = $r["country"];
                 $this->experience = $r["experience"];
                 if (strlen($r["rep"]) > 0){
-                    $this->rep = new Unit($this->db, $r["rep"]);
+                    $this->rep = new Unit($r["rep"]);
                 }
                 $this->currency["mana"] = $r["mana"];
                 $this->currency["crystal"] = $r["crystal"];
@@ -189,27 +188,27 @@
                 WHERE uid = '$UID'
                 ORDER BY position;
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->defense, new Unit($db, $r["unit"], false));
+                array_push($this->defense, new Unit($r["unit"], false));
             }
             $s = "
                 SELECT DISTINCT id
                 FROM building
                 WHERE uid = '$UID';
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->building, new Building($db, $r["id"]));
+                array_push($this->building, new Building($r["id"]));
             }
             $s = "
                 SELECT id
                 FROM decoration
                 WHERE uid = '$UID';
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->decoration, new Decoration($db, $r["id"]));
+                array_push($this->decoration, new Decoration($r["id"]));
             }
             $s = "
                 SELECT
@@ -222,9 +221,9 @@
                   amount > 0
                 ORDER BY inventory.type;
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->inventory_scroll, new Inventory($db, $r["id"], $r["type"]));
+                array_push($this->inventory_scroll, new Inventory($r["id"], $r["type"]));
             }
             // Rune crafting items are marked as generic crafting.
             $s = "
@@ -239,9 +238,9 @@
                   amount > 0
                 ORDER BY inventory.id;
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->inventory_craft_rune, new Inventory($db, $r["id"], $r["type"]));
+                array_push($this->inventory_craft_rune, new Inventory($r["id"], $r["type"]));
             }
             $s = "
                 SELECT
@@ -255,9 +254,9 @@
                   amount > 0
                 ORDER BY inventory.id;
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->inventory_craft, new Inventory($db, $r["id"], $r["type"]));
+                array_push($this->inventory_craft, new Inventory($r["id"], $r["type"]));
             }
             $s = "
                 SELECT
@@ -284,9 +283,9 @@
                   upper(name) NOT LIKE '%HIGH%'
                 ;
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->inventory_essence, new Inventory($db, $r["id"], $r["type"]));
+                array_push($this->inventory_essence, new Inventory($r["id"], $r["type"]));
             }
             $this->title = "SWDB";
             $this->description = "Summoners War DataBase";

+ 3 - 3
application/page/Landing_Page.php

@@ -24,10 +24,10 @@
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param resource $db Connection to the database. Can be null.
+         ** @global resource Database connection.
          */
-        public function __construct($db){
-            parent::__construct($db);
+        public function __construct(){
+            global $db;
             $this->view = PATH::VIEW . "landing.php";
             $this->title = "Login - SWDB";
             $this->description = "Login to SWDB";

+ 7 - 7
application/page/Monster_Info_Page.php

@@ -40,14 +40,14 @@
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param resource $db Connection to the database.
          * @param int $id Monster id. Can be any of the awakening stages
+         * @global resource Database connection.
          */
-        public function __construct($db, $id){
-            parent::__construct($db);
+        public function __construct($id){
+            global $db;
             $this->view = PATH::VIEW . "monster_info.php";
             $title = "";
-            $monster = new K_Unit($db, $id);
+            $monster = new K_Unit($id);
             if ($monster->can_awaken == 0){
                 // Silver star monster.
                 $this->monster[0] = $monster;
@@ -64,7 +64,7 @@
             }
             elseif ($monster->can_awaken == 1 && $monster->awakens_to == "" && strlen($monster->awakens_from) > 0){
                 // Normal monster, already awakened, no 2a.
-                $this->monster[0] = new K_Unit($db, $monster->awakens_from);
+                $this->monster[0] = new K_Unit($monster->awakens_from);
                 $this->monster[1] = $monster;
                 $this->monster[2] = null;
                 $title = $this->monster[1]->name . " - " .$this->monster[0]->element_name . " " . $this->monster[0]->name;
@@ -73,12 +73,12 @@
             elseif ($monster->can_awaken == 1 && strlen($monster->awakens_to) > 0 && $monster->awakens_from == ""){
                 // Normal monster, not awakened, may have 2a.
                 $this->monster[0] = $monster;
-                $this->monster[1] = new K_Unit($db, $this->monster[0]->awakens_to);
+                $this->monster[1] = new K_Unit($this->monster[0]->awakens_to);
                 if ($this->monster[1]->awakens_to == ""){
                     $this->monster[2] = null;
                 }
                 else{
-                    $this->monster[2] = new K_Unit($db, $this->monster[1]->awakens_to);
+                    $this->monster[2] = new K_Unit($this->monster[1]->awakens_to);
                 }
                 $title = $this->monster[1]->name . " - " .$this->monster[0]->element_name . " " . $this->monster[0]->name;
             }

+ 7 - 5
application/page/Monster_Page.php

@@ -48,14 +48,14 @@
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param resource $db Connection to the database.
          * @param string $id Selected unit id
+         * @global resource Database connection.
          */
-        public function __construct($db, $id){
-            parent::__construct($db);
+        public function __construct($id){
+            global $db;
             $this->view = PATH::VIEW . "monster.php";
             $this->calculate_buildings();
-            $this->unit = new Unit($db, $id);
+            $this->unit = new Unit($id);
             $this->title = $this->unit->unit->name ." - SWDB";
             $this->description = "Owned " . $this->unit->unit->name;
             $this->canonical = URL::BASE . "monster/" . $id;
@@ -66,9 +66,11 @@
          * $building_stats array.
          *
          * @gobal int User ID.
+         * @global resource Database connection.
          */
         private function calculate_buildings(){
             global $UID;
+            global $db;
             $s = "
               SELECT
                 affected_stat,
@@ -86,7 +88,7 @@
                 area = " . EFFECT_AREA_ID::GENERAL . " AND
                 affected_stat IN (" . STAT_ID::ATK . ", " . STAT_ID::DEF . ", " . STAT_ID::HP . ", " . STAT_ID::SPD . ", " . STAT_ID::CRIT_DMG . ");
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
                 switch($r["affected_stat"]){
                     case STAT_ID::DEF:

+ 12 - 6
application/page/Monsters_Page.php

@@ -48,17 +48,17 @@
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param resource $db Connection to the database.
+         * @global resource Database connection.
          */
-        public function __construct($db){
-            parent::__construct($db);
+        public function __construct(){
+            global $db;
             $this->view = PATH::VIEW . "monsters.php";
             $this->parse_filters();
             $this->calculate_buildings();
             $s_mon = $this->build_query();
-            $q_mon = $this->db->query($s_mon);
+            $q_mon = $db->query($s_mon);
             while ($r_mon = $q_mon->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->monsters, new Unit($db, $r_mon["id"]));
+                array_push($this->monsters, new Unit($r_mon["id"]));
             }
             $this->title = "Monsters - SWDB";
             $this->description = "Owned monsters";
@@ -98,9 +98,11 @@
          *
          * @return string The query to be executed.
          * @global int Player ID.
+         * @global resource Database connection.
          */
         private function build_query(){
             global $UID;
+            global $db;
             $s = "
                 SELECT unit.id AS id
                 FROM
@@ -139,9 +141,13 @@
         /**
          * Calculates the stats gained from bulding upgrades and populates the
          * $building_stats array.
+         *
+         * @global int Player ID.
+         * @global resource Database connection.
          */
         private function calculate_buildings(){
             global $UID;
+            global $db;
             $s = "
               SELECT
                 affected_stat,
@@ -159,7 +165,7 @@
                 area = " . EFFECT_AREA_ID::GENERAL . " AND
                 affected_stat IN (" . STAT_ID::ATK . ", " . STAT_ID::DEF . ", " . STAT_ID::HP . ", " . STAT_ID::SPD . ", " . STAT_ID::CRIT_DMG . ");
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
                 switch($r["affected_stat"]){
                     case STAT_ID::DEF:

+ 1 - 9
application/page/Page.php

@@ -16,11 +16,6 @@
      */
     abstract class Page{
 
-        /**
-         * @var resource Database connection.
-         */
-        public $db;
-
         /**
          * @var string Path to the view associated with the page.
          */
@@ -70,11 +65,8 @@
 
         /**
          * Constructor.
-         *
-         * @param resource $db Connection to the database.
          */
-        public function __construct($db){
-            $this->db = $db;
+        public function __construct(){
             $this->favicon = URL::IMG["LOGO"] . "sw.png";
             $this->icon = URL::IMG["LOGO"] . "sw.png";
             $this->name = "SWDB";

+ 4 - 4
application/page/Profile_Page.php

@@ -40,12 +40,12 @@
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param resource $db Connection to the database.
          * @global int Player ID.
+         * @global resource Database connection.
          */
-        public function __construct($db){
+        public function __construct(){
             global $UID;
-            parent::__construct($db);
+            global $db;
             $this->view = PATH::VIEW . "profile.php";
             $s = "
               SELECT
@@ -55,7 +55,7 @@
               FROM player
               WHERE uid = '$UID';
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             if ($r = $q->fetchArray(SQLITE3_ASSOC)){
                 $this->name = $r["name"];
                 $this->mail = $r["mail"];

+ 5 - 5
application/page/Report_Page.php

@@ -31,12 +31,12 @@
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param resource $db Connection to the database.
          * @global int Player ID.
+         * @global resource Database connection.
          */
-        public function __construct($db){
+        public function __construct(){
             global $UID;
-            parent::__construct($db);
+            global $db;
             $this->view = PATH::VIEW . "report.php";
 
             // Get custom filters
@@ -47,9 +47,9 @@
                 uid = '$UID' AND
                 page = 'REPORT_RUNEUPGRADE';
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->custom_filters_runeupgrade, new Custom_Filter($this->db, $r["id"]));
+                array_push($this->custom_filters_runeupgrade, new Custom_Filter($r["id"]));
             }
 
             $this->title = "Reports - SWDB";

+ 8 - 8
application/page/Report_Runecraft_Page.php

@@ -45,14 +45,14 @@
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param resource $db Connection to the database.
+         * @global resource Database connection.
          */
-        public function __construct($db){
-            parent::__construct($db);
+        public function __construct(){
+            global $db;
             $this->view = PATH::VIEW . "report_runecraft.php";
             $this->parse_filters();
             $s = $this->build_query();
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $prev_monster = "";
             $prev_rune = "";
             $upgrade = null;
@@ -68,11 +68,11 @@
                     $prev_monster = $r["unit"];
                     $prev_rune = "";
                     $upgrade = [
-                        "unit" => new Unit($this->db, $r["unit"]),
+                        "unit" => new Unit($r["unit"]),
                         "upgrade" => [],
                     ];
                     $rupgrade = [
-                        "rune" => new Rune($this->db, $r["rune"]),
+                        "rune" => new Rune($r["rune"]),
                         "craft" => [],
                     ];
                 }
@@ -82,11 +82,11 @@
                     }
                     $prev_rune = $r["rune"];
                     $rupgrade = [
-                        "rune" => new Rune($this->db, $r["rune"]),
+                        "rune" => new Rune($r["rune"]),
                         "craft" => [],
                     ];
                 }
-                $rune_craft = new Rune_craft($this->db, $r["craft"]);
+                $rune_craft = new Rune_craft($r["craft"]);
                 array_push($rupgrade["craft"], $rune_craft);
             }
             // Last entries

+ 14 - 12
application/page/Report_Runeupgrade_Page.php

@@ -50,12 +50,12 @@
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param resource $db Connection to the database.
          * @global int Player ID.
+         * @global resource Database connection.
          */
-        public function __construct($db){
+        public function __construct(){
             global $UID;
-            parent::__construct($db);
+            global $db;
             $this->view = PATH::VIEW . "report_runeupgrade.php";
             $this->parse_filters();
             if (!isset($_GET["custom_filter"])){
@@ -64,7 +64,7 @@
             else{
                 $s = $this->build_custom_query($_GET["custom_filter"]);
             }
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $prev_monster = "";
             $prev_rune = "";
             $upgrade = null;
@@ -80,11 +80,11 @@
                     $prev_monster = $r["unit"];
                     $prev_rune = "";
                     $upgrade = [
-                        "unit" => new Unit($this->db, $r["unit"]),
+                        "unit" => new Unit($r["unit"]),
                         "upgrade" => [],
                     ];
                     $rupgrade = [
-                        "rune" => new Rune($this->db, $r["id"]),
+                        "rune" => new Rune($r["id"]),
                         "alternative" => [],
                     ];
                 }
@@ -94,14 +94,14 @@
                     }
                     $prev_rune = $r["id"];
                     $rupgrade = [
-                        "rune" => new Rune($this->db, $r["id"]),
+                        "rune" => new Rune($r["id"]),
                         "alternative" => [],
                     ];
                 }
-                $rune_alt = new Rune($this->db, $r["alternative"]);
+                $rune_alt = new Rune($r["alternative"]);
                 // If the alternative rune isassigned
                 if (strlen($rune_alt->assigned_to) > 0){
-                    $rune_alt->assigned_to = new Unit($this->db, $rune_alt->assigned_to);
+                    $rune_alt->assigned_to = new Unit($rune_alt->assigned_to);
                 }
                 array_push($rupgrade["alternative"], $rune_alt);
             }
@@ -117,9 +117,9 @@
                 uid = '$UID' AND
                 page = 'REPORT_RUNEUPGRADE';
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->custom_filters, new Custom_Filter($this->db, $r["id"]));
+                array_push($this->custom_filters, new Custom_Filter($r["id"]));
             }
             $this->title = "Replaceable runes - SWDB";
             $this->description = "Find equiped runes that can be substituted for better ones.";
@@ -225,9 +225,11 @@
          * @param int $filter Custom filter ID.
          * @return string The query to be executed.
          * @global int Player ID.
+         * @global resource Database connection.
          */
         private function build_custom_query($filter){
             global $UID;
+            global $db;
             $s = "
               SELECT condition
               FROM filter
@@ -235,7 +237,7 @@
                 uid = '$UID' AND
                 id = $filter;
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             $cond = $r["condition"];
             $s = "

+ 5 - 5
application/page/Report_Skillup_Page.php

@@ -30,16 +30,16 @@
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param resource $db Connection to the database.
+         * @global resource Database connection.
          */
-        public function __construct($db){
-            parent::__construct($db);
+        public function __construct(){
+            global $db;
             $this->view = PATH::VIEW . "report_skillup.php";
             $this->parse_filters();
             $s = $this->build_query();
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->units, new Unit($db, $r["id"]));
+                array_push($this->units, new Unit($r["id"]));
             }
             $this->title = "Urgent skill-ups - SWDB";
             $this->description = "Monster in need of skilling up";

+ 11 - 9
application/page/Runes_Page.php

@@ -41,12 +41,12 @@
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param resource $db Connection to the database.
          * @global int Player ID.
+         * @global resource Database connection.
          */
-        public function __construct($db){
+        public function __construct(){
             global $UID;
-            parent::__construct($db);
+            global $db;
             $this->view = PATH::VIEW . "runes.php";
             $this->parse_filters();
             if (!isset($_GET["custom_filter"])){
@@ -57,11 +57,11 @@
                 $s = $this->build_custom_query($_GET["custom_filter"]);
             }
             error_log($s);
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                $rune = new Rune($db, $r["id"]);
+                $rune = new Rune($r["id"]);
                 if (strlen($rune->assigned_to) > 0){
-                    $rune->assigned_to = new Unit($this->db, $rune->assigned_to, false);
+                    $rune->assigned_to = new Unit($rune->assigned_to, false);
                 }
                 array_push($this->runes, $rune);
             }
@@ -72,9 +72,9 @@
                 uid = '$UID' AND
                 page = 'RUNES';
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->custom_filters, new Custom_Filter($this->db, $r["id"]));
+                array_push($this->custom_filters, new Custom_Filter($r["id"]));
             }
             $this->title = "Runes - SWDB";
             $this->description = "Rune inventory";
@@ -163,9 +163,11 @@
          * @param int $filter Custom filter ID.
          * @return string The query to be executed.
          * @global int Player ID.
+         * @global resource Database connection.
          */
         private function build_custom_query($filter){
             global $UID;
+            global $db;
             $s = "
               SELECT condition
               FROM filter
@@ -173,7 +175,7 @@
                 uid = '$UID' AND
                 id = $filter;
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             $cond = $r["condition"];
             $s = "

+ 5 - 5
application/page/Runs_Page.php

@@ -30,16 +30,16 @@
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param resource $db Connection to the database.
+         * @global resource Database connection.
          */
-        public function __construct($db){
-            parent::__construct($db);
+        public function __construct(){
+            global $db;
             $this->view = PATH::VIEW . "runs.php";
             $this->parse_filters();
             $s = $this->build_query();
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->runs, new Run($db, $r["id"]));
+                array_push($this->runs, new Run($r["id"]));
             }
             $this->title = "Runs - SWDB";
             $this->description = "Run logs";

+ 7 - 7
application/page/Teams_Page.php

@@ -36,27 +36,27 @@
          *
          * Retrieves the data and initializes the variables.
          *
-         * @param resource $db Connection to the database.
          * @global int Player ID.
+         * @global resource Database connection.
          */
-        public function __construct($db){
+        public function __construct(){
             global $UID;
-            parent::__construct($db);
+            global $db;
             $this->view = PATH::VIEW . "teams.php";
             $this->parse_filters();
             $s = $this->build_query();
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->teams, new Team($db, $r["id"]));
+                array_push($this->teams, new Team($r["id"]));
             }
             $s = "
               SELECT id
               FROM unit
               WHERE unit.uid = '$UID';
             ";
-            $q = $this->db->query($s);
+            $q = $db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->units, new Unit($this->db, $r["id"], false));
+                array_push($this->units, new Unit($r["id"], false));
             }
             $this->title = "Teams - SWDB";
             $this->description = "Teams";

+ 2 - 2
application/view/guild.php

@@ -137,12 +137,12 @@
                         <tr>
                             <td class='grade <?=$odd?>'>
 <?php
-                                if ($member->grade == GUILD_MEMBER_GRADE::LEADER){
+                                if ($member->grade == GUILD_MEMBER_GRADE_ID::LEADER){
 ?>
                                     <img alt='yes' src='<?=URL::IMG["ICON"] . "leader.png"?>'/>
 <?php
                                 }
-                                elseif ($member->grade == GUILD_MEMBER_GRADE::VICELEADER){
+                                elseif ($member->grade == GUILD_MEMBER_GRADE_ID::VICELEADER){
 ?>
                                     <img alt='yes' src='<?=URL::IMG["ICON"] . "viceleader.png"?>'/>
 <?php

+ 3 - 0
application/view/monster.php

@@ -402,7 +402,9 @@
                             <td></td>
 <?php
                         }
+                        $skill_num = 0;
                         foreach ($page->unit->unit->skill as $skill){
+                            $cur_lvl = $page->unit->skill_levels[$skill_num];
 ?>
                             <td class='skill_up'>
 <?php
@@ -425,6 +427,7 @@
 ?>
                             </td>
 <?php
+                            $skill_num ++;
                         }
 ?>
                     </tr>

+ 1 - 1
public/css/monster.css

@@ -191,7 +191,7 @@ section#monster article#profile table#skills td.skill_up span.description{
 }
 
 section#monster article#profile table#skills td.skill_up span.aquired{
-    font-weight: bold;
+    color: #efefef;
 }
 
 section#monster article#profile td#skill_averages{