@@ -53,14 +53,47 @@ public static function add($type, $title, $message): void
53
53
* @param string $search Entire "WHERE" statement including the word WHERE
54
54
* @return mixed
55
55
*/
56
- public static function getAll ($ start , $ limit, $ search ): mixed
56
+ public static function getAll ($ start , $ limit ): mixed
57
57
{
58
+ $ where = '' ;
59
+ $ valueOther = null ;
60
+ $ value = $ _GET ['advSearch ' ];
61
+ $ type = $ _GET ['advType ' ];
62
+
63
+ switch ($ type ) {
64
+ case "admin " :
65
+ $ where = " l.aid = :value " ;
66
+ break ;
67
+ case "message " :
68
+ $ value = "% $ value% " ;
69
+ $ where = " l.message LIKE :value OR l.title LIKE :value " ;
70
+ break ;
71
+ case "date " :
72
+ $ date = explode (", " , $ value );
73
+ $ date [0 ] = (is_numeric ($ date [0 ])) ? $ date [0 ] : date ('d ' );
74
+ $ date [1 ] = (is_numeric ($ date [1 ])) ? $ date [1 ] : date ('m ' );
75
+ $ date [2 ] = (is_numeric ($ date [2 ])) ? $ date [2 ] : date ('Y ' );
76
+ $ value = mktime ($ date [3 ], $ date [4 ], 0 , (int )$ date [1 ], (int )$ date [0 ], (int )$ date [2 ]);
77
+ $ valueOther = mktime ($ date [5 ], $ date [6 ], 59 , (int )$ date [1 ], (int )$ date [0 ], (int )$ date [2 ]);
78
+ $ where = " l.created > :value AND l.created :valueOther " ;
79
+ break ;
80
+ case "type " :
81
+ $ where = " l.type = :value " ;
82
+ break ;
83
+ }
84
+
58
85
$ query = "SELECT ad.user, l.* FROM `:prefix_log` AS l
59
86
LEFT JOIN `:prefix_admins` AS ad ON l.aid = ad.aid
60
- :search ORDER BY l.created DESC
87
+ WHERE $ where
88
+ ORDER BY l.created DESC
61
89
LIMIT :start, :lim " ;
62
- $ query = str_replace (':search ' , filter_var ($ search , FILTER_SANITIZE_SPECIAL_CHARS , FILTER_FLAG_NO_ENCODE_QUOTES ), $ query );
63
- self ::$ dbs ->query ($ query );
90
+
91
+ self ::$ dbs ->query ($ query )
92
+ ->bind ('value ' , $ value );
93
+
94
+ if ($ valueOther !== null )
95
+ self ::$ dbs ->bind ('valueOther ' , $ valueOther );
96
+
64
97
self ::$ dbs ->bind (':start ' , (int )$ start , PDO ::PARAM_INT );
65
98
self ::$ dbs ->bind (':lim ' , (int )$ limit , PDO ::PARAM_INT );
66
99
return self ::$ dbs ->resultset ();
@@ -72,9 +105,38 @@ public static function getAll($start, $limit, $search): mixed
72
105
*/
73
106
public static function getCount ($ search ): mixed
74
107
{
75
- $ query = "SELECT COUNT(l.lid) AS count FROM `:prefix_log` AS l :search " ;
76
- $ query = str_replace (':search ' , filter_var ($ search , FILTER_SANITIZE_SPECIAL_CHARS , FILTER_FLAG_NO_ENCODE_QUOTES ), $ query );
77
- self ::$ dbs ->query ($ query );
108
+ $ value = $ _GET ['advSearch ' ];
109
+ $ valueOther = null ;
110
+ $ type = $ _GET ['advType ' ];
111
+ $ query = "SELECT COUNT(l.lid) AS count FROM `:prefix_log` AS l WHERE " ;
112
+ switch ($ type ) {
113
+ case "admin " :
114
+ $ query .= " l.aid = :value " ;
115
+ break ;
116
+ case "message " :
117
+ $ value = "% $ value% " ;
118
+ $ query .= " l.message LIKE :value OR l.title LIKE :value " ;
119
+ break ;
120
+ case "date " :
121
+ $ date = explode (", " , $ value );
122
+ $ date [0 ] = (is_numeric ($ date [0 ])) ? $ date [0 ] : date ('d ' );
123
+ $ date [1 ] = (is_numeric ($ date [1 ])) ? $ date [1 ] : date ('m ' );
124
+ $ date [2 ] = (is_numeric ($ date [2 ])) ? $ date [2 ] : date ('Y ' );
125
+ $ value = mktime ($ date [3 ], $ date [4 ], 0 , (int )$ date [1 ], (int )$ date [0 ], (int )$ date [2 ]);
126
+ $ 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
+ break ;
129
+ case "type " :
130
+ $ query .= " l.type = :value " ;
131
+ break ;
132
+ }
133
+
134
+ self ::$ dbs ->query ($ query )
135
+ ->bind ('value ' , $ value );
136
+
137
+ if ($ valueOther !== null )
138
+ self ::$ dbs ->bind ('valueOther ' , $ valueOther );
139
+
78
140
$ log = self ::$ dbs ->single ();
79
141
return $ log ['count ' ];
80
142
}
0 commit comments