Browse Source

Remove is_empty()

master
Skylar Ittner 8 months ago
parent
commit
59ace4fa05
4 changed files with 25 additions and 25 deletions
  1. 16
    16
      action.php
  2. 3
    3
      pages/analytics.php
  3. 5
    5
      pages/editor.php
  4. 1
    1
      pages/sitesettings.php

+ 16
- 16
action.php View File

@@ -43,13 +43,13 @@ switch ($VARS['action']) {
43 43
         if (!$user->hasPermission("SITEWRITER") && !$user->hasPermission("SITEWRITER_EDIT")) {
44 44
             returnToSender("no_permission");
45 45
         }
46
-        if (is_empty($VARS['siteid']) || !$database->has("sites", ["siteid" => $VARS['siteid']])) {
46
+        if (empty($VARS['siteid']) || !$database->has("sites", ["siteid" => $VARS['siteid']])) {
47 47
             returnToSender("invalid_parameters");
48 48
         }
49
-        if (is_empty($VARS['title'])) {
49
+        if (empty($VARS['title'])) {
50 50
             returnToSender("invalid_parameters", $VARS['siteid']);
51 51
         }
52
-        if (!is_empty($VARS['slug'])) {
52
+        if (!empty($VARS['slug'])) {
53 53
             $slug = strtolower($VARS['slug']);
54 54
             $slug = preg_replace("/[^[:alnum:][:space:]]/u", '', $slug);
55 55
             $slug = preg_replace("/[[:space:]]/u", '-', $slug);
@@ -70,7 +70,7 @@ switch ($VARS['action']) {
70 70
             }
71 71
         }
72 72
         $template = "default";
73
-        if (!is_empty($VARS['template'])) {
73
+        if (!empty($VARS['template'])) {
74 74
             $template = preg_replace("/[^A-Za-z0-9]/", '', $VARS['template']);
75 75
         }
76 76
         $theme = $database->get("sites", "theme", ["siteid" => $VARS['siteid']]);
@@ -84,21 +84,21 @@ switch ($VARS['action']) {
84 84
         if (!$user->hasPermission("SITEWRITER")) {
85 85
             returnToSender("no_permission");
86 86
         }
87
-        if (is_empty($VARS['siteid']) || !$database->has("sites", ["siteid" => $VARS['siteid']])) {
87
+        if (empty($VARS['siteid']) || !$database->has("sites", ["siteid" => $VARS['siteid']])) {
88 88
             returnToSender("invalid_parameters");
89 89
         }
90
-        if (is_empty($VARS['pageid']) || !$database->has("pages", ["AND" => ["pageid" => $VARS['pageid'], "siteid" => $VARS['siteid']]])) {
90
+        if (empty($VARS['pageid']) || !$database->has("pages", ["AND" => ["pageid" => $VARS['pageid'], "siteid" => $VARS['siteid']]])) {
91 91
             returnToSender("invalid_parameters");
92 92
         }
93
-        if (is_empty($VARS['title'])) {
93
+        if (empty($VARS['title'])) {
94 94
             returnToSender("invalid_parameters", $VARS['siteid']);
95 95
         }
96
-        if (is_empty($VARS['template'])) {
96
+        if (empty($VARS['template'])) {
97 97
             returnToSender("invalid_parameters", $VARS['siteid']);
98 98
         }
99 99
         $nav = null;
100 100
         if ($VARS['innavbar'] == 1) {
101
-            if (is_empty($VARS['navbartitle'])) {
101
+            if (empty($VARS['navbartitle'])) {
102 102
                 returnToSender("invalid_parameters", $VARS['siteid']);
103 103
             }
104 104
             $nav = $VARS['navbartitle'];
@@ -123,7 +123,7 @@ switch ($VARS['action']) {
123 123
                 "pageid" => $VARS['pageid']
124 124
             ]
125 125
         ]);
126
-        if (!is_empty($VARS['navorder']) && preg_match("/^[0-9]+([0-9|]*([0-9])|[0-9])$/", $VARS['navorder'])) {
126
+        if (!empty($VARS['navorder']) && preg_match("/^[0-9]+([0-9|]*([0-9])|[0-9])$/", $VARS['navorder'])) {
127 127
             $pages = explode("|", preg_replace("/[|]{2,}/", "", $VARS['navorder']));
128 128
             for ($i = 0; $i < count($pages); $i++) {
129 129
                 $database->update("pages", [
@@ -142,21 +142,21 @@ switch ($VARS['action']) {
142 142
         if (!$user->hasPermission("SITEWRITER")) {
143 143
             returnToSender("no_permission");
144 144
         }
145
-        if (!is_empty($VARS['siteid'])) {
145
+        if (!empty($VARS['siteid'])) {
146 146
             if (!$database->has("sites", ["siteid" => $VARS['siteid']])) {
147 147
                 returnToSender("invalid_parameters");
148 148
             }
149 149
         }
150
-        if (is_empty($VARS['name'])) {
150
+        if (empty($VARS['name'])) {
151 151
             returnToSender("invalid_parameters");
152 152
         }
153
-        if (is_empty($VARS['url'])) {
153
+        if (empty($VARS['url'])) {
154 154
             returnToSender("invalid_parameters");
155 155
         }
156
-        if (is_empty($VARS['theme'])) {
156
+        if (empty($VARS['theme'])) {
157 157
             returnToSender("invalid_parameters");
158 158
         }
159
-        if (is_empty($VARS['color'])) {
159
+        if (empty($VARS['color'])) {
160 160
             returnToSender("invalid_parameters");
161 161
         }
162 162
         $url = formatsiteurl($VARS['url']);
@@ -168,7 +168,7 @@ switch ($VARS['action']) {
168 168
         if ($color != "default" && !file_exists(__DIR__ . "/public/themes/$theme/colors/$color")) {
169 169
             returnToSender("invalid_parameters");
170 170
         }
171
-        if (is_empty($VARS['siteid'])) {
171
+        if (empty($VARS['siteid'])) {
172 172
             $database->insert('sites', ["sitename" => $VARS['name'], "url" => $url, "theme" => $theme, "color" => $color]);
173 173
             $siteid = $database->id();
174 174
             $template = (file_exists(__DIR__ . "/public/themes/$theme/home.php") ? "home" : "default");

+ 3
- 3
pages/analytics.php View File

@@ -18,18 +18,18 @@ if (!$user->hasPermission("SITEWRITER") && !$user->hasPermission("SITEWRITER_ANA
18 18
 
19 19
 $select_filter = [];
20 20
 
21
-if (isset($VARS['siteid']) && !is_empty($VARS['siteid'])) {
21
+if (!empty($VARS['siteid'])) {
22 22
     if ($database->has('sites', ['siteid' => $VARS['siteid']])) {
23 23
         $select_filter["analytics.siteid"] = $VARS['siteid'];
24 24
     }
25 25
 }
26 26
 
27
-if (isset($VARS['after']) && !is_empty($VARS['after'])) {
27
+if (!empty($VARS['after'])) {
28 28
     if (strtotime($VARS['after']) !== FALSE) {
29 29
         $select_filter["time[>]"] = date("Y-m-d H:i:s", strtotime($VARS['after']));
30 30
     }
31 31
 }
32
-if (isset($VARS['before']) && !is_empty($VARS['before'])) {
32
+if (!empty($VARS['before'])) {
33 33
     if (strtotime($VARS['before']) !== FALSE) {
34 34
         $select_filter["time[<]"] = date("Y-m-d H:i:s", strtotime($VARS['before']));
35 35
     }

+ 5
- 5
pages/editor.php View File

@@ -16,7 +16,7 @@ if (!$user->hasPermission("SITEWRITER") && !$user->hasPermission("SITEWRITER_EDI
16 16
     die();
17 17
 }
18 18
 
19
-if (isset($VARS['arg']) && !is_empty($VARS['arg'])) {
19
+if (!empty($VARS['arg'])) {
20 20
     // Allow action.php to do a better redirect
21 21
     $VARS['siteid'] = $VARS['arg'];
22 22
     if (strpos($VARS['arg'], "|") !== FALSE) {
@@ -28,7 +28,7 @@ if (isset($VARS['arg']) && !is_empty($VARS['arg'])) {
28 28
     }
29 29
 }
30 30
 
31
-if (!is_empty($VARS['siteid'])) {
31
+if (!empty($VARS['siteid'])) {
32 32
     if ($database->has('sites', ['siteid' => $VARS['siteid']])) {
33 33
         $sitedata = $database->get(
34 34
                 'sites', [
@@ -138,7 +138,7 @@ if (!is_empty($VARS['siteid'])) {
138 138
                     <div class="form-group">
139 139
                         <label><i class="fas fa-bars"></i> <?php $Strings->get("navbar options"); ?></label>
140 140
                         <div class="form-check">
141
-                            <input class="form-check-input" type="checkbox" name="innavbar" id="innavbarCheckbox" value="1" <?php echo (is_empty($thispage['nav']) ? "" : "checked") ?> />
141
+                            <input class="form-check-input" type="checkbox" name="innavbar" id="innavbarCheckbox" value="1" <?php echo (empty($thispage['nav']) ? "" : "checked") ?> />
142 142
                             <label class="form-check-label" for="innavbarCheckbox">
143 143
                                 <?php $Strings->get("in navbar"); ?>
144 144
                             </label>
@@ -152,14 +152,14 @@ if (!is_empty($VARS['siteid'])) {
152 152
                                 <div class="input-group-prepend">
153 153
                                     <label class="input-group-text" for="navbarTitle"><?php $Strings->get("navbar title"); ?></label>
154 154
                                 </div>
155
-                                <input type="text" id="navbarTitle" name="navbartitle" class="form-control" required="required" minlength="1" maxlength="200" value="<?php echo (is_empty($thispage['nav']) ? $thispage['title'] : $thispage['nav']); ?>" />
155
+                                <input type="text" id="navbarTitle" name="navbartitle" class="form-control" required="required" minlength="1" maxlength="200" value="<?php echo (empty($thispage['nav']) ? $thispage['title'] : $thispage['nav']); ?>" />
156 156
                             </div>
157 157
 
158 158
                             <label class="mb-0 pb-0"><?php $Strings->get("navbar position"); ?></label>
159 159
                             <div class="list-group py-3" id="navbar-order-list">
160 160
                                 <?php
161 161
                                 foreach ($pagedata as $page) {
162
-                                    if (is_empty($page['nav'])) {
162
+                                    if (empty($page['nav'])) {
163 163
                                         continue;
164 164
                                     }
165 165
                                     ?>

+ 1
- 1
pages/sitesettings.php View File

@@ -28,7 +28,7 @@ $sitedata = [
28 28
 ];
29 29
 $settings = [];
30 30
 
31
-if (isset($VARS['siteid']) && !is_empty($VARS['siteid'])) {
31
+if (!empty($VARS['siteid'])) {
32 32
     if ($database->has('sites', ['siteid' => $VARS['siteid']])) {
33 33
         $siteid = $VARS['siteid'];
34 34
         $sitedata = $database->select(

Loading…
Cancel
Save