@@ -55,10 +55,10 @@ public static function add($type, $title, $message): void
55
55
*/
56
56
public static function getAll ($ start , $ limit ): mixed
57
57
{
58
- $ where = '' ;
58
+ $ where = null ;
59
59
$ valueOther = null ;
60
- $ value = $ _GET ['advSearch ' ];
61
- $ type = $ _GET ['advType ' ];
60
+ $ value = $ _GET ['advSearch ' ] ?? null ;
61
+ $ type = $ _GET ['advType ' ] ?? null ;
62
62
63
63
switch ($ type ) {
64
64
case "admin " :
@@ -82,15 +82,16 @@ public static function getAll($start, $limit): mixed
82
82
break ;
83
83
}
84
84
85
- $ query = " SELECT ad.user, l.* FROM `:prefix_log` AS l
85
+ $ query = ' SELECT ad.user, l.* FROM `:prefix_log` AS l
86
86
LEFT JOIN `:prefix_admins` AS ad ON l.aid = ad.aid
87
- WHERE $ where
87
+ ' . ( $ where ? " WHERE $ where" : '' ) . '
88
88
ORDER BY l.created DESC
89
- LIMIT :start, :lim " ;
89
+ LIMIT :start, :lim ' ;
90
90
91
- self ::$ dbs ->query ($ query )
92
- ->bind ('value ' , $ value );
91
+ self ::$ dbs ->query ($ query );
93
92
93
+ if ($ value !== null )
94
+ self ::$ dbs ->bind ('value ' , $ value );
94
95
if ($ valueOther !== null )
95
96
self ::$ dbs ->bind ('valueOther ' , $ valueOther );
96
97
@@ -105,17 +106,17 @@ public static function getAll($start, $limit): mixed
105
106
*/
106
107
public static function getCount ($ search ): mixed
107
108
{
108
- $ value = $ _GET ['advSearch ' ];
109
+ $ value = $ _GET ['advSearch ' ] ?? null ;
109
110
$ valueOther = null ;
110
- $ type = $ _GET ['advType ' ];
111
- $ query = "SELECT COUNT(l.lid) AS count FROM `:prefix_log` AS l WHERE " ;
111
+ $ type = $ _GET ['advType ' ] ?? null ;
112
+ $ query = "SELECT COUNT(l.lid) AS count FROM `:prefix_log` AS l " ;
112
113
switch ($ type ) {
113
114
case "admin " :
114
- $ query .= " l.aid = :value " ;
115
+ $ query .= "WHERE l.aid = :value " ;
115
116
break ;
116
117
case "message " :
117
118
$ value = "% $ value% " ;
118
- $ query .= " l.message LIKE :value OR l.title LIKE :value " ;
119
+ $ query .= "WHERE l.message LIKE :value OR l.title LIKE :value " ;
119
120
break ;
120
121
case "date " :
121
122
$ date = explode (", " , $ value );
@@ -124,16 +125,17 @@ public static function getCount($search): mixed
124
125
$ date [2 ] = (is_numeric ($ date [2 ])) ? $ date [2 ] : date ('Y ' );
125
126
$ value = mktime ($ date [3 ], $ date [4 ], 0 , (int )$ date [1 ], (int )$ date [0 ], (int )$ date [2 ]);
126
127
$ valueOther = mktime ($ date [5 ], $ date [6 ], 59 , (int )$ date [1 ], (int )$ date [0 ], (int )$ date [2 ]);
127
- $ query .= " l.created > :value AND l.created :valueOther " ;
128
+ $ query .= "WHERE l.created > :value AND l.created :valueOther " ;
128
129
break ;
129
130
case "type " :
130
- $ query .= " l.type = :value " ;
131
+ $ query .= "WHERE l.type = :value " ;
131
132
break ;
132
133
}
133
134
134
- self ::$ dbs ->query ($ query )
135
- ->bind ('value ' , $ value );
135
+ self ::$ dbs ->query ($ query );
136
136
137
+ if ($ value !== null )
138
+ self ::$ dbs ->bind ('value ' , $ value );
137
139
if ($ valueOther !== null )
138
140
self ::$ dbs ->bind ('valueOther ' , $ valueOther );
139
141
0 commit comments