| 1 |
<?php |
| 2 |
|
| 3 |
if (!defined('ABSPATH')) exit; |
| 4 |
if (!class_exists('BVActLogCallback')) : |
| 5 |
|
| 6 |
require_once dirname( __FILE__ ) . '/../../wp_actlog.php'; |
| 7 |
|
| 8 |
class BVActLogCallback extends BVCallbackBase { |
| 9 |
public $db; |
| 10 |
public $settings; |
| 11 |
|
| 12 |
const ACTLOG_WING_VERSION = 1.0; |
| 13 |
|
| 14 |
public function __construct($callback_handler) { |
| 15 |
$this->db = $callback_handler->db; |
| 16 |
$this->settings = $callback_handler->settings; |
| 17 |
} |
| 18 |
|
| 19 |
public function dropActLogTable() { |
| 20 |
return $this->db->dropBVTable(BVWPActLog::$actlog_table); |
| 21 |
} |
| 22 |
|
| 23 |
public function createActLogTable($usedbdelta = false) { |
| 24 |
$db = $this->db; |
| 25 |
$charset_collate = $db->getCharsetCollate(); |
| 26 |
$table = $this->db->getBVTable(BVWPActLog::$actlog_table); |
| 27 |
$query = "CREATE TABLE $table ( |
| 28 |
id bigint(20) NOT NULL AUTO_INCREMENT, |
| 29 |
site_id int NOT NULL, |
| 30 |
user_id int DEFAULT 0, |
| 31 |
username text DEFAULT '', |
| 32 |
request_id text DEFAULT '', |
| 33 |
ip varchar(20) DEFAULT '', |
| 34 |
event_type varchar(40) NOT NULL DEFAULT '', |
| 35 |
event_data mediumtext NOT NULL, |
| 36 |
time int, |
| 37 |
PRIMARY KEY (id) |
| 38 |
) $charset_collate;"; |
| 39 |
return $db->createTable($query, BVWPActLog::$actlog_table, $usedbdelta); |
| 40 |
} |
| 41 |
|
| 42 |
public function process($request) { |
| 43 |
$settings = $this->settings; |
| 44 |
$params = $request->params; |
| 45 |
switch ($request->method) { |
| 46 |
case "truncactlogtable": |
| 47 |
$resp = array("status" => $this->db->truncateBVTable(BVWPActLog::$actlog_table)); |
| 48 |
break; |
| 49 |
case "dropactlogtable": |
| 50 |
$resp = array("status" => $this->dropActLogTable()); |
| 51 |
break; |
| 52 |
case "createactlogtable": |
| 53 |
$usedbdelta = array_key_exists('usedbdelta', $params); |
| 54 |
$resp = array("status" => $this->createActLogTable($usedbdelta)); |
| 55 |
break; |
| 56 |
default: |
| 57 |
$resp = false; |
| 58 |
} |
| 59 |
return $resp; |
| 60 |
} |
| 61 |
} |
| 62 |
endif; |