PluginProbe ʕ •ᴥ•ʔ
Event Tickets with Ticket Scanner / 3.1.2
Event Tickets with Ticket Scanner v3.1.2
3.1.2 3.1.1 3.1.0 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.4 trunk 2.6.0 2.7.0 2.7.1 2.7.10 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.10 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.0 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8 2.9.9 3.0.0 3.0.1 3.0.2 3.0.3
event-tickets-with-ticket-scanner / db.php
event-tickets-with-ticket-scanner Last commit date
3rd 1 week ago css 1 week ago img 1 week ago includes 1 week ago js 1 week ago languages 1 week ago ticket 1 week ago vendors 1 week ago SASO_EVENTTICKETS.php 1 week ago backend.js 1 week ago changelog-features.json 1 week ago changelog.txt 1 week ago db.php 1 week ago index.php 1 week ago init_file.php 1 week ago order_details.js 1 week ago pwa-sw.js 1 week ago readme.txt 1 week ago saso-eventtickets-validator.js 1 week ago sasoEventtickets_AdminSettings.php 1 week ago sasoEventtickets_Authtoken.php 1 week ago sasoEventtickets_Base.php 1 week ago sasoEventtickets_Core.php 1 week ago sasoEventtickets_Frontend.php 1 week ago sasoEventtickets_Messenger.php 1 week ago sasoEventtickets_Options.php 1 week ago sasoEventtickets_PDF.php 1 week ago sasoEventtickets_Seating.php 1 week ago sasoEventtickets_Ticket.php 1 week ago sasoEventtickets_TicketBadge.php 1 week ago sasoEventtickets_TicketDesigner.php 1 week ago sasoEventtickets_TicketQR.php 1 week ago ticket_events.js 1 week ago ticket_scanner.js 1 week ago validator.js 1 week ago version-notices.json 1 week ago vollstart-cross-promo.php 1 week ago wc_backend.js 1 week ago wc_frontend.js 1 week ago woocommerce-hooks.php 1 week ago
db.php
516 lines
1 <?php
2 include_once(plugin_dir_path(__FILE__)."init_file.php");
3 class sasoEventticketsDB extends sasoEventtickets_DB {
4 public $dbversion = '1.19';
5 public function __construct($MAIN) {
6 $this->MAIN = $MAIN;
7 parent::$dbprefix = "saso_eventtickets_";
8 $this->_tabellen = ['lists', 'codes', 'ips', 'authtokens', 'errorlogs', 'seatingplans', 'seats', 'seat_blocks', 'options', 'options_history', 'congresses', 'congress_pages', 'congress_sections', 'congress_products'];
9 $this->init();
10 }
11
12 protected function _system_installiereTabellen() {
13 $tabellen = [];
14 $tabellen[] = [
15 "sql"=>
16 "CREATE TABLE ".$this->getTabelle('lists')." (
17 id int(32) unsigned NOT NULL auto_increment,
18 time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
19 timezone varchar(255) NOT NULL DEFAULT '',
20 name varchar(255) NOT NULL DEFAULT '',
21 aktiv int(1) unsigned NOT NULL DEFAULT 0,
22 meta longtext NOT NULL DEFAULT '',
23 PRIMARY KEY (id)) ".$this->getCharsetCollate().";",
24 "additional"=>[
25 "CREATE UNIQUE INDEX idx1 ON ".$this->getTabelle('lists')." (name)"
26 ]
27 ];
28 $tabellen[] = [
29 "sql"=>
30 "CREATE TABLE ".$this->getTabelle('codes')." (
31 id int(32) unsigned NOT NULL auto_increment,
32 time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
33 timezone varchar(255) NOT NULL DEFAULT '',
34 code varchar(150) NOT NULL DEFAULT '',
35 code_display varchar(250) NOT NULL DEFAULT '',
36 cvv varchar(50) NOT NULL DEFAULT '',
37 meta longtext NOT NULL DEFAULT '',
38 aktiv int(1) unsigned NOT NULL DEFAULT 0,
39 redeemed int(1) unsigned NOT NULL DEFAULT 0,
40 list_id int(32) unsigned NOT NULL DEFAULT 0,
41 user_id int(32) unsigned NOT NULL DEFAULT 0,
42 order_id int(32) unsigned NOT NULL DEFAULT 0,
43 semaphorecode varchar(50) NOT NULL DEFAULT '',
44 PRIMARY KEY (id)) ".$this->getCharsetCollate().";",
45 "additional"=>[
46 "CREATE UNIQUE INDEX idx1 ON ".$this->getTabelle('codes')." (code)",
47 "CREATE INDEX idx2 ON ".$this->getTabelle('codes')." (time)",
48 "CREATE INDEX idx3 ON ".$this->getTabelle('codes')." (order_id)",
49 "CREATE INDEX idx4 ON ".$this->getTabelle('codes')." (user_id)",
50 "CREATE INDEX idx5 ON ".$this->getTabelle('codes')." (redeemed)"
51 ]
52 ];
53 $tabellen[] = [
54 "sql"=>
55 "CREATE TABLE ".$this->getTabelle('ips')." (
56 id int(32) unsigned NOT NULL auto_increment,
57 time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
58 timezone varchar(255) NOT NULL DEFAULT '',
59 code varchar(150) NOT NULL DEFAULT '',
60 valid int(1) NOT NULL DEFAULT 0,
61 ip varchar(40) NOT NULL DEFAULT '',
62 action varchar(150) NOT NULL DEFAULT 'Validation',
63 PRIMARY KEY (id)) ".$this->getCharsetCollate().";",
64 "additional"=>[
65 "CREATE INDEX idx1 ON ".$this->getTabelle('ips')." (code,time)",
66 "CREATE INDEX idx2 ON ".$this->getTabelle('ips')." (ip,time)"
67 ]
68 ];
69 $tabellen[] = [
70 "sql"=>
71 "CREATE TABLE ".$this->getTabelle('authtokens')." (
72 id int(32) unsigned NOT NULL auto_increment,
73 time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
74 timezone varchar(255) NOT NULL DEFAULT '',
75 changed datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
76 changed_timezone varchar(255) NOT NULL DEFAULT '',
77 name varchar(255) NOT NULL DEFAULT '',
78 aktiv int(1) unsigned NOT NULL DEFAULT 0,
79 code varchar(200) NOT NULL DEFAULT '',
80 areacode varchar(25) NOT NULL DEFAULT '',
81 user_id int(32) unsigned NOT NULL DEFAULT 0,
82 meta longtext NOT NULL DEFAULT '',
83 PRIMARY KEY (id)) ".$this->getCharsetCollate().";",
84 "additional"=>[
85 "CREATE UNIQUE INDEX idx1 ON ".$this->getTabelle('authtokens')." (code, areacode)"
86 ]
87 ];
88 $tabellen[] = [
89 "sql"=>
90 "CREATE TABLE ".$this->getTabelle('errorlogs')." (
91 id int(32) unsigned NOT NULL auto_increment,
92 time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
93 timezone varchar(255) NOT NULL DEFAULT '',
94 exception_msg varchar(250) NOT NULL DEFAULT '',
95 msg longtext NOT NULL DEFAULT '',
96 caller_name varchar(250) NOT NULL DEFAULT '',
97 PRIMARY KEY (id)) ".$this->getCharsetCollate().";",
98 "additional"=>[
99 "CREATE INDEX idx1 ON ".$this->getTabelle('errorlogs')." (time)",
100 "CREATE INDEX idx2 ON ".$this->getTabelle('errorlogs')." (caller_name)"
101 ]
102 ];
103 // Seating Plans - v1.8, extended v1.9 for Visual Designer
104 $tabellen[] = [
105 "sql"=>
106 "CREATE TABLE ".$this->getTabelle('seatingplans')." (
107 id int(32) unsigned NOT NULL auto_increment,
108 time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
109 timezone varchar(255) NOT NULL DEFAULT '',
110 name varchar(255) NOT NULL DEFAULT '',
111 aktiv int(1) unsigned NOT NULL DEFAULT 0,
112 meta longtext NOT NULL DEFAULT '',
113 layout_type varchar(20) NOT NULL DEFAULT 'simple',
114 meta_draft longtext NOT NULL DEFAULT '',
115 meta_published longtext NOT NULL DEFAULT '',
116 published_at datetime DEFAULT NULL,
117 published_by int(32) unsigned DEFAULT NULL,
118 created_by int(32) unsigned DEFAULT NULL,
119 updated_by int(32) unsigned DEFAULT NULL,
120 created_at datetime DEFAULT NULL,
121 updated_at datetime DEFAULT NULL,
122 PRIMARY KEY (id)) ".$this->getCharsetCollate().";",
123 "additional"=>[
124 "CREATE UNIQUE INDEX idx1 ON ".$this->getTabelle('seatingplans')." (name)"
125 ]
126 ];
127 // Seats - v1.8, extended v1.9 for Visual Designer
128 $tabellen[] = [
129 "sql"=>
130 "CREATE TABLE ".$this->getTabelle('seats')." (
131 id int(32) unsigned NOT NULL auto_increment,
132 time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
133 timezone varchar(255) NOT NULL DEFAULT '',
134 seatingplan_id int(32) unsigned NOT NULL DEFAULT 0,
135 seat_identifier varchar(100) NOT NULL DEFAULT '',
136 aktiv int(1) unsigned NOT NULL DEFAULT 1,
137 sort_order int(32) unsigned NOT NULL DEFAULT 0,
138 meta longtext NOT NULL DEFAULT '',
139 is_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
140 deleted_at datetime DEFAULT NULL,
141 deleted_by int(32) unsigned DEFAULT NULL,
142 created_by int(32) unsigned DEFAULT NULL,
143 updated_by int(32) unsigned DEFAULT NULL,
144 created_at datetime DEFAULT NULL,
145 updated_at datetime DEFAULT NULL,
146 PRIMARY KEY (id)) ".$this->getCharsetCollate().";",
147 "additional"=>[
148 "CREATE INDEX idx1 ON ".$this->getTabelle('seats')." (seatingplan_id, aktiv, sort_order)",
149 "CREATE UNIQUE INDEX idx2 ON ".$this->getTabelle('seats')." (seatingplan_id, seat_identifier)",
150 "CREATE INDEX idx3 ON ".$this->getTabelle('seats')." (seatingplan_id, is_deleted)"
151 ]
152 ];
153 // Seat Blocks (Semaphore) - v1.8
154 $tabellen[] = [
155 "sql"=>
156 "CREATE TABLE ".$this->getTabelle('seat_blocks')." (
157 id int(32) unsigned NOT NULL auto_increment,
158 time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
159 timezone varchar(255) NOT NULL DEFAULT '',
160 seat_id int(32) unsigned NOT NULL DEFAULT 0,
161 seatingplan_id int(32) unsigned NOT NULL DEFAULT 0,
162 product_id int(32) unsigned NOT NULL DEFAULT 0,
163 event_date date DEFAULT NULL,
164 session_id varchar(100) NOT NULL DEFAULT '',
165 order_id int(32) unsigned DEFAULT NULL,
166 code_id int(32) unsigned DEFAULT NULL,
167 expires_at datetime DEFAULT NULL,
168 last_seen datetime DEFAULT NULL,
169 status varchar(20) NOT NULL DEFAULT 'blocked',
170 meta longtext NOT NULL DEFAULT '',
171 PRIMARY KEY (id)) ".$this->getCharsetCollate().";",
172 "additional"=>[
173 "CREATE INDEX idx1 ON ".$this->getTabelle('seat_blocks')." (seatingplan_id, event_date, status)",
174 "CREATE INDEX idx2 ON ".$this->getTabelle('seat_blocks')." (seat_id, product_id, event_date, status)",
175 "CREATE INDEX idx3 ON ".$this->getTabelle('seat_blocks')." (status, expires_at)",
176 "CREATE INDEX idx4 ON ".$this->getTabelle('seat_blocks')." (session_id)",
177 "CREATE INDEX idx5 ON ".$this->getTabelle('seat_blocks')." (order_id)",
178 "CREATE INDEX idx6 ON ".$this->getTabelle('seat_blocks')." (code_id)"
179 ]
180 ];
181 // Options table - v1.11: replaces individual wp_options rows with single table
182 $tabellen[] = [
183 "sql"=>
184 "CREATE TABLE ".$this->getTabelle('options')." (
185 option_key varchar(191) NOT NULL DEFAULT '',
186 option_value longtext NOT NULL DEFAULT '',
187 updated_at datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
188 updated_by int(32) unsigned NOT NULL DEFAULT 0,
189 PRIMARY KEY (option_key)) ".$this->getCharsetCollate().";",
190 "additional"=>[]
191 ];
192 // Options history table - v1.12: tracks changes to plugin options
193 $tabellen[] = [
194 "sql"=>
195 "CREATE TABLE ".$this->getTabelle('options_history')." (
196 id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
197 option_key varchar(191) NOT NULL DEFAULT '',
198 old_value text NOT NULL,
199 new_value text NOT NULL,
200 changed_by int(32) unsigned NOT NULL DEFAULT 0,
201 changed_at datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
202 PRIMARY KEY (id),
203 KEY option_key_changed_at (option_key, changed_at),
204 KEY changed_at (changed_at)) ".$this->getCharsetCollate().";",
205 "additional"=>[]
206 ];
207 // Congress tables - v1.14
208 $tabellen[] = [
209 "sql" =>
210 "CREATE TABLE ".$this->getTabelle('congresses')." (
211 id int(32) unsigned NOT NULL AUTO_INCREMENT,
212 slug varchar(200) NOT NULL DEFAULT '',
213 title varchar(500) NOT NULL DEFAULT '',
214 updated_at datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
215 access_expires_at datetime DEFAULT NULL,
216 event_start_at datetime DEFAULT NULL,
217 event_end_at datetime DEFAULT NULL,
218 is_active tinyint(1) NOT NULL DEFAULT 1,
219 label varchar(191) NOT NULL DEFAULT '',
220 meta longtext NOT NULL DEFAULT '',
221 PRIMARY KEY (id)) ".$this->getCharsetCollate().";",
222 "additional" => [
223 "CREATE UNIQUE INDEX idx1 ON ".$this->getTabelle('congresses')." (slug)"
224 ]
225 ];
226 $tabellen[] = [
227 "sql" =>
228 "CREATE TABLE ".$this->getTabelle('congress_pages')." (
229 id int(32) unsigned NOT NULL AUTO_INCREMENT,
230 congress_id int(32) unsigned NOT NULL DEFAULT 0,
231 title varchar(500) NOT NULL DEFAULT '',
232 sort_order int(11) unsigned NOT NULL DEFAULT 0,
233 created_at datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
234 updated_at datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
235 created_by_user_id int(11) unsigned NOT NULL DEFAULT 0,
236 updated_by_user_id int(11) unsigned NOT NULL DEFAULT 0,
237 meta longtext NOT NULL DEFAULT '',
238 PRIMARY KEY (id)) ".$this->getCharsetCollate().";",
239 "additional" => [
240 "CREATE INDEX idx1 ON ".$this->getTabelle('congress_pages')." (congress_id, sort_order)"
241 ]
242 ];
243 $tabellen[] = [
244 "sql" =>
245 "CREATE TABLE ".$this->getTabelle('congress_sections')." (
246 id int(32) unsigned NOT NULL AUTO_INCREMENT,
247 congress_id int(32) unsigned NOT NULL DEFAULT 0,
248 page_id int(32) unsigned NOT NULL DEFAULT 0,
249 type varchar(20) NOT NULL DEFAULT 'info',
250 title varchar(500) NOT NULL DEFAULT '',
251 password_hash varchar(255) DEFAULT NULL,
252 sort_order int(11) unsigned NOT NULL DEFAULT 0,
253 content longtext NOT NULL DEFAULT '',
254 created_at datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
255 updated_at datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
256 created_by_user_id int(11) unsigned NOT NULL DEFAULT 0,
257 updated_by_user_id int(11) unsigned NOT NULL DEFAULT 0,
258 PRIMARY KEY (id)) ".$this->getCharsetCollate().";",
259 "additional" => [
260 "CREATE INDEX idx1 ON ".$this->getTabelle('congress_sections')." (congress_id, sort_order)",
261 "CREATE INDEX idx2 ON ".$this->getTabelle('congress_sections')." (page_id, sort_order)"
262 ]
263 ];
264 $tabellen[] = [
265 "sql" =>
266 "CREATE TABLE ".$this->getTabelle('congress_products')." (
267 congress_id int(32) unsigned NOT NULL DEFAULT 0,
268 product_id int(32) unsigned NOT NULL DEFAULT 0,
269 PRIMARY KEY (congress_id, product_id)) ".$this->getCharsetCollate().";",
270 "additional" => [
271 "CREATE INDEX idx1 ON ".$this->getTabelle('congress_products')." (product_id)"
272 ]
273 ];
274 $tabellen = apply_filters( $this->MAIN->_add_filter_prefix.'db_system_installiereTabellen', $tabellen );
275 do_action( $this->MAIN->_do_action_prefix.'db_system_installiereTabellen', $tabellen );
276 return $tabellen;
277 }
278 }
279
280 class sasoEventtickets_DB {
281 // irgendwann nach dem https://codex.wordpress.org/Creating_Tables_with_Plugins
282 //https://tobier.de/wordpress-plugin-erstellen-datenbank/
283 public $dbversion;
284 protected static $dbprefix;
285 protected $_tabellen = [];
286 private $tabellen;
287 protected $callerValue = "basic";
288
289 protected $MAIN;
290
291 public function __construct($MAIN) {
292 $this->MAIN = $MAIN;
293 $this->init();
294 }
295 protected function init() {
296 $this->tabellen = [];
297 foreach($this->_tabellen as $t) {
298 $this->tabellen[$t] = $this->getPrefix().$t;
299 }
300 }
301
302 public function getTabelle($tabelle) {
303 return $this->tabellen[$tabelle];
304 }
305
306 public function getTables() {
307 return $this->_tabellen;
308 }
309
310 public function reinigen_in($text, $len=0, $addsl=1, $utf=0, $html=0) {
311 $text = trim($text);
312 if ($len > 0)
313 $text = substr($text, 0, $len);
314 if ($utf == 1)
315 $text = mb_convert_encoding($text, 'ISO-8859-1', 'UTF-8');
316 //$text = utf8_decode($text); // die zeichen sind utf kodiert
317 if ($html == 1)
318 $text = htmlentities($text); // zerstört HTML zeug im text
319 if ($addsl == 1)
320 $text = addslashes($text);
321 return $text;
322 }
323
324 private function getPrefix() {
325 global $wpdb;
326 return $wpdb->prefix . self::$dbprefix;
327 }
328
329 protected function getCharsetCollate() {
330 global $wpdb;
331 return $wpdb->get_charset_collate();
332 }
333
334 public function _db_datenholen_prepared($sql, $felder) {
335 global $wpdb;
336 for ($a=0;$a<count($felder);$a++) {
337 //$felder[$a] = $wpdb->esc_like( $felder[$a] );
338 $felder[$a] = $this->reinigen_in( $felder[$a] );
339 }
340 $sql = $wpdb->prepare( $sql, $felder );
341 return $this->_db_datenholen($sql);
342 }
343
344 public function _db_datenholen($sql, $again=true) {
345 global $wpdb;
346 //update_option( self::$dbprefix."db_version", "1.4" );
347 //$installed_ver = get_option( self::$dbprefix."db_version" );
348 //if ($installed_ver != $this->dbversion) $this->installiereTabellen();
349 //echo $installed_ver;
350 try {
351 $ret = $wpdb->get_results($sql, ARRAY_A);
352 } catch(Exception $e) {
353 if ($again == true) {
354 $this->installiereTabellen(true);
355 return $this->_db_datenholen($sql, false);
356 } else {
357 throw $e;
358 }
359 }
360 if ( $wpdb->last_error ) {
361 $this->MAIN->getAdmin()->logErrorToDB(new Exception("Database error - Again: ".$again), null, $wpdb->last_error);
362 if ($again == true) {
363 $this->installiereTabellen(true);
364 $ret = $this->_db_datenholen($sql, false);
365 }
366 }
367 return $ret;
368 }
369
370 public function _db_getRecordCountOfTable($tabelle, $where="") {
371 $sql = "select count(*) as anzahl from ".$this->getTabelle($tabelle);
372 if ($where != "") $sql .= " where ".$where;
373 list($d) = $this->_db_datenholen($sql);
374 return $d['anzahl'];
375 }
376
377 public function getCodesSize() {
378 return $this->_db_getRecordCountOfTable('codes');
379 }
380
381 private function addMissingFelder($felder) {
382 if (($this->callerValue == "basic" && version_compare( $this->dbversion, '1.6', '>' )) ||
383 ($this->callerValue == "prem" && version_compare( $this->dbversion, '1.3', '>' ))) {
384 if (array_key_exists("time", $felder)) {
385 if (!array_key_exists("timezone", $felder)) {
386 $felder["timezone"] = wp_timezone_string();
387 }
388 }
389 if (array_key_exists("changed", $felder)) {
390 if (!array_key_exists("changed_timezone", $felder)) {
391 $felder["changed_timezone"] = wp_timezone_string();
392 }
393 }
394 }
395 $felder = apply_filters( $this->MAIN->_add_filter_prefix.'db_addMissingFelder', $felder );
396 return $felder;
397 }
398
399 public function insert($tabelle, $felder=[]) {
400 global $wpdb;
401 if (count($felder) == 0) throw new Exception("no fields provided");
402 $felder = $this->addMissingFelder($felder);
403 $wpdb->insert( $this->getTabelle($tabelle), $felder );
404 return $wpdb->insert_id;
405 }
406
407 public function update($tabelle, $felder, $where) {
408 global $wpdb;
409 if (count($felder) == 0) throw new Exception("no fields provided");
410 $felder = $this->addMissingFelder($felder);
411 if (count($where) == 0) throw new Exception("no where fields provided");
412 return $wpdb->update( $this->getTabelle($tabelle), $felder, $where);
413 }
414
415 public function _db_query($sql) {
416 global $wpdb;
417 $erg = $wpdb->query($sql);
418 if ($erg):
419 if (strtolower(substr($sql, 0, 6)) == "insert") {
420 return $wpdb->insert_id;
421 }
422 return $erg;
423 else:
424 if (!empty($wpdb->last_error)) {
425 $this->installiereTabellen(true);
426 $this->MAIN->getAdmin()->logErrorToDB(new Exception("Database error"), null, $wpdb->last_error);
427 echo $wpdb->last_error;
428 wp_die($wpdb->last_error);
429 }
430 endif;
431 return $erg;
432 }
433
434 public function installiereTabellen($force=false) {
435 global $wpdb;
436 if (empty($this->dbversion)) throw new Exception("dbversion is not set");
437 if (empty(self::$dbprefix)) throw new Exception("dbprefix is not set");
438
439 $installed_ver = get_option( self::$dbprefix."db_version" );
440
441 if ($force || $installed_ver != $this->dbversion ) {
442 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
443
444 $tabellen = $this->_system_installiereTabellen(); // array
445 foreach($tabellen as $tabelle) {
446 dbDelta( $tabelle['sql'] ); // tabelle erstellen
447 if (isset($tabelle['additional'])) {
448 $wpdb->suppress_errors = true;
449 foreach($tabelle['additional'] as $sql) {
450 //echo $sql;
451 $wpdb->query($sql); // zusätzlich sql wie index
452 }
453 $wpdb->suppress_errors = false;
454 }
455 }
456
457 // Run upgrade jobs BEFORE saving the new db_version.
458 // This ensures that if any job (e.g. options migration) crashes,
459 // the next request re-runs the entire upgrade — all jobs are idempotent.
460 // Note: premium/hook calls inside performJobsAfterDBUpgraded are wrapped
461 // in try/catch to prevent an infinite crash loop if they throw.
462 if ($this->callerValue == "basic") {
463 $this->MAIN->getAdmin()->performJobsAfterDBUpgraded($this->dbversion, $installed_ver);
464 } else { // wenn für die prem DB dann direkt aufruf
465 try {
466 if ($this->MAIN->isPremium() && method_exists($this->MAIN->getPremiumFunctions(), 'performJobsAfterPremDBUpgraded')) {
467 $this->MAIN->getPremiumFunctions()->performJobsAfterPremDBUpgraded($this->dbversion, $installed_ver);
468 }
469 } catch (\Throwable $e) {
470 $this->MAIN->getAdmin()->logErrorToDB($e, null, 'Premium DB upgrade job failed: ' . $e->getMessage());
471 }
472 }
473 update_option( self::$dbprefix."db_version", $this->dbversion );
474 }
475 }
476 public static function plugin_deactivated() {
477 //delete_option(self::$dbprefix."db_version");
478 }
479 public static function plugin_uninstall(){
480 self::plugin_deactivated();
481 //delete tabellen
482 /*
483 global $wpdb;
484 foreach($this->tabellen as $key => $value) {
485 $wpdb->query("DROP TABLE IF EXISTS ".$value);
486 }
487 */
488 }
489 /**
490 * Log an error message to the errorlogs table.
491 *
492 * Convenience method used by seating subsystem and other components
493 * that need simple string-based error logging without an Exception object.
494 *
495 * @param string $message Error message
496 * @param string $callerName Optional caller identification
497 */
498 public function logError(string $message, string $callerName = ''): void {
499 try {
500 $this->insert('errorlogs', [
501 'time' => wp_date('Y-m-d H:i:s'),
502 'exception_msg' => mb_substr($message, 0, 250),
503 'msg' => $message,
504 'caller_name' => mb_substr($callerName, 0, 250),
505 ]);
506 } catch (\Exception $e) {
507 // Silently fail — logging should never break the application
508 }
509 }
510
511 protected function _system_installiereTabellen()
512 {
513 throw new Exception("overwrite this function");
514 }
515 }
516 ?>