Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/blogvaul.../callback/wings
File: db.php
<?php
[0] Fix | Delete
[1] Fix | Delete
if (!defined('ABSPATH')) exit;
[2] Fix | Delete
if (!class_exists('BVDBCallback')) :
[3] Fix | Delete
require_once dirname( __FILE__ ) . '/../streams.php';
[4] Fix | Delete
[5] Fix | Delete
class BVDBCallback extends BVCallbackBase {
[6] Fix | Delete
public $db;
[7] Fix | Delete
public $stream;
[8] Fix | Delete
public $account;
[9] Fix | Delete
public $siteinfo;
[10] Fix | Delete
[11] Fix | Delete
public static $bvTables = array("fw_requests", "lp_requests", "ip_store");
[12] Fix | Delete
[13] Fix | Delete
const DB_WING_VERSION = 1.3;
[14] Fix | Delete
[15] Fix | Delete
public function __construct($callback_handler) {
[16] Fix | Delete
$this->db = $callback_handler->db;
[17] Fix | Delete
$this->account = $callback_handler->account;
[18] Fix | Delete
$this->siteinfo = $callback_handler->siteinfo;
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
public function getLastID($pkeys, $end_row) {
[22] Fix | Delete
$last_ids = array();
[23] Fix | Delete
foreach($pkeys as $pk) {
[24] Fix | Delete
$last_ids[$pk] = $end_row[$pk];
[25] Fix | Delete
}
[26] Fix | Delete
return $last_ids;
[27] Fix | Delete
}
[28] Fix | Delete
[29] Fix | Delete
public function getTableData($table, $tname, $offset, $limit, $bsize, $filter, $pkeys, $include_rows = false) {
[30] Fix | Delete
$tinfo = array();
[31] Fix | Delete
[32] Fix | Delete
$rows_count = $this->db->rowsCount($table);
[33] Fix | Delete
$result = array('count' => $rows_count);
[34] Fix | Delete
if ($limit == 0) {
[35] Fix | Delete
$limit = $rows_count;
[36] Fix | Delete
}
[37] Fix | Delete
$srows = 1;
[38] Fix | Delete
while (($limit > 0) && ($srows > 0)) {
[39] Fix | Delete
if ($bsize > $limit)
[40] Fix | Delete
$bsize = $limit;
[41] Fix | Delete
$rows = $this->db->getTableContent($table, '*', $filter, $bsize, $offset);
[42] Fix | Delete
$srows = sizeof($rows);
[43] Fix | Delete
$data = array();
[44] Fix | Delete
$data["table_name"] = $tname;
[45] Fix | Delete
$data["offset"] = $offset;
[46] Fix | Delete
$data["size"] = $srows;
[47] Fix | Delete
$serialized_rows = serialize($rows);
[48] Fix | Delete
$data['md5'] = md5($serialized_rows);
[49] Fix | Delete
$data['length'] = strlen($serialized_rows);
[50] Fix | Delete
array_push($tinfo, $data);
[51] Fix | Delete
if (!empty($pkeys) && $srows > 0) {
[52] Fix | Delete
$end_row = end($rows);
[53] Fix | Delete
$last_ids = $this->getLastID($pkeys, $end_row);
[54] Fix | Delete
$data['last_ids'] = $last_ids;
[55] Fix | Delete
$result['last_ids'] = $last_ids;
[56] Fix | Delete
}
[57] Fix | Delete
if ($include_rows) {
[58] Fix | Delete
$data["rows"] = $rows;
[59] Fix | Delete
$str = serialize($data);
[60] Fix | Delete
$this->stream->writeStream($str);
[61] Fix | Delete
}
[62] Fix | Delete
$offset += $srows;
[63] Fix | Delete
$limit -= $srows;
[64] Fix | Delete
}
[65] Fix | Delete
$result['size'] = $offset;
[66] Fix | Delete
$result['tinfo'] = $tinfo;
[67] Fix | Delete
return $result;
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
public function streamQueryResult($identifier, $query, $pkeys) {
[71] Fix | Delete
$data = array();
[72] Fix | Delete
$data["identifier"] = $identifier;
[73] Fix | Delete
$data["query"] = $query;
[74] Fix | Delete
[75] Fix | Delete
$data["query_start_time"] = time();
[76] Fix | Delete
$rows = $this->db->getResult($query);
[77] Fix | Delete
$srows = sizeof($rows);
[78] Fix | Delete
$data["size"] = $srows;
[79] Fix | Delete
$data["query_end_time"] = time();
[80] Fix | Delete
if (!empty($pkeys) && $srows > 0) {
[81] Fix | Delete
$end_row = end($rows);
[82] Fix | Delete
$last_ids = $this->getLastID($pkeys, $end_row);
[83] Fix | Delete
$data['last_ids'] = $last_ids;
[84] Fix | Delete
}
[85] Fix | Delete
$result = array_merge($data);
[86] Fix | Delete
$data["rows"] = $rows;
[87] Fix | Delete
$serialized_rows = serialize($data);
[88] Fix | Delete
$this->stream->writeStream($serialized_rows);
[89] Fix | Delete
$result['length'] = strlen($serialized_rows);
[90] Fix | Delete
return $result;
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
function getRandomData($totalSize, $bsize) {
[94] Fix | Delete
if ($bsize == 0) {
[95] Fix | Delete
$bsize = $totalSize;
[96] Fix | Delete
}
[97] Fix | Delete
[98] Fix | Delete
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
[99] Fix | Delete
$charactersLength = strlen($characters);
[100] Fix | Delete
[101] Fix | Delete
while ($totalSize > 0) {
[102] Fix | Delete
if ($bsize > $totalSize) {
[103] Fix | Delete
$bsize = $totalSize;
[104] Fix | Delete
}
[105] Fix | Delete
[106] Fix | Delete
$randomString = '';
[107] Fix | Delete
for ($i = 0; $i < $bsize; $i++) {
[108] Fix | Delete
$randomString .= $characters[rand(0, $charactersLength - 1)];
[109] Fix | Delete
}
[110] Fix | Delete
[111] Fix | Delete
$this->stream->writeStream($randomString);
[112] Fix | Delete
$totalSize -= $bsize;
[113] Fix | Delete
}
[114] Fix | Delete
return array("status" => "true");
[115] Fix | Delete
}
[116] Fix | Delete
[117] Fix | Delete
public function getCreateTableQueries($tables) {
[118] Fix | Delete
$resp = array();
[119] Fix | Delete
foreach($tables as $table) {
[120] Fix | Delete
$tname = $table;
[121] Fix | Delete
$resp[$tname] = array("create" => $this->db->showTableCreate($table));
[122] Fix | Delete
}
[123] Fix | Delete
return $resp;
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
public function checkTables($tables, $type) {
[127] Fix | Delete
$resp = array();
[128] Fix | Delete
foreach($tables as $table) {
[129] Fix | Delete
$tname = $table;
[130] Fix | Delete
$resp[$tname] = array("status" => $this->db->checkTable($table, $type));
[131] Fix | Delete
}
[132] Fix | Delete
return $resp;
[133] Fix | Delete
}
[134] Fix | Delete
[135] Fix | Delete
public function describeTables($tables) {
[136] Fix | Delete
$resp = array();
[137] Fix | Delete
foreach($tables as $table) {
[138] Fix | Delete
$tname = $table;
[139] Fix | Delete
$resp[$tname] = array("description" => $this->db->describeTable($table));
[140] Fix | Delete
$resp[$tname]["primary_keys_index"] = $this->db->showTableIndex($table);
[141] Fix | Delete
}
[142] Fix | Delete
return $resp;
[143] Fix | Delete
}
[144] Fix | Delete
[145] Fix | Delete
public function checkTablesExist($tables) {
[146] Fix | Delete
$resp = array();
[147] Fix | Delete
foreach($tables as $table) {
[148] Fix | Delete
$tname = $table;
[149] Fix | Delete
$resp[$tname] = array("tblexists" => $this->db->isTablePresent($table));
[150] Fix | Delete
}
[151] Fix | Delete
return $resp;
[152] Fix | Delete
}
[153] Fix | Delete
[154] Fix | Delete
public function getTablesRowCount($tables) {
[155] Fix | Delete
$resp = array();
[156] Fix | Delete
foreach($tables as $table) {
[157] Fix | Delete
$tname = $table;
[158] Fix | Delete
$resp[$tname] = array("count" => $this->db->rowsCount($table));
[159] Fix | Delete
}
[160] Fix | Delete
return $resp;
[161] Fix | Delete
}
[162] Fix | Delete
[163] Fix | Delete
public function getTablesKeys($tables) {
[164] Fix | Delete
$resp = array();
[165] Fix | Delete
foreach($tables as $table) {
[166] Fix | Delete
$tname = $table;
[167] Fix | Delete
$resp[$tname] = array("keys" => $this->db->tableKeys($table));
[168] Fix | Delete
}
[169] Fix | Delete
return $resp;
[170] Fix | Delete
}
[171] Fix | Delete
[172] Fix | Delete
public function multiGetResult($queries) {
[173] Fix | Delete
$resp = array();
[174] Fix | Delete
foreach($queries as $query) {
[175] Fix | Delete
array_push($resp, $this->db->getResult($query));
[176] Fix | Delete
}
[177] Fix | Delete
return $resp;
[178] Fix | Delete
}
[179] Fix | Delete
[180] Fix | Delete
public function process($request) {
[181] Fix | Delete
$db = $this->db;
[182] Fix | Delete
$params = $request->params;
[183] Fix | Delete
$stream_init_info = BVStream::startStream($this->account, $request);
[184] Fix | Delete
[185] Fix | Delete
if (array_key_exists('stream', $stream_init_info)) {
[186] Fix | Delete
$this->stream = $stream_init_info['stream'];
[187] Fix | Delete
switch ($request->method) {
[188] Fix | Delete
case "gettbls":
[189] Fix | Delete
$resp = array("tables" => $db->showTables());
[190] Fix | Delete
break;
[191] Fix | Delete
case "tblstatus":
[192] Fix | Delete
$resp = array("statuses" => $db->showTableStatus());
[193] Fix | Delete
break;
[194] Fix | Delete
case "tablekeys":
[195] Fix | Delete
$table = $params['table'];
[196] Fix | Delete
$resp = array("table_keys" => $db->tableKeys($table));
[197] Fix | Delete
break;
[198] Fix | Delete
case "describetable":
[199] Fix | Delete
$table = $params['table'];
[200] Fix | Delete
$resp = array("table_description" => $db->describeTable($table));
[201] Fix | Delete
$resp["primary_keys_index"] = $db->showTableIndex($table);
[202] Fix | Delete
break;
[203] Fix | Delete
case "checktable":
[204] Fix | Delete
$table = $params['table'];
[205] Fix | Delete
$type = $params['type'];
[206] Fix | Delete
$resp = array("status" => $db->checkTable($table, $type));
[207] Fix | Delete
break;
[208] Fix | Delete
case "repairtable":
[209] Fix | Delete
$table = $params['table'];
[210] Fix | Delete
$resp = array("status" => $db->repairTable($table));
[211] Fix | Delete
break;
[212] Fix | Delete
case "gettcrt":
[213] Fix | Delete
$table = $params['table'];
[214] Fix | Delete
$resp = array("create" => $db->showTableCreate($table));
[215] Fix | Delete
break;
[216] Fix | Delete
case "tblskys":
[217] Fix | Delete
$tables = $params['tables'];
[218] Fix | Delete
$resp = $this->getTablesKeys($tables);
[219] Fix | Delete
break;
[220] Fix | Delete
case "getmlticrt":
[221] Fix | Delete
$tables = $params['tables'];
[222] Fix | Delete
$resp = $this->getCreateTableQueries($tables);
[223] Fix | Delete
break;
[224] Fix | Delete
case "desctbls":
[225] Fix | Delete
$tables = $params['tables'];
[226] Fix | Delete
$resp = $this->describeTables($tables);
[227] Fix | Delete
break;
[228] Fix | Delete
case "mltirwscount":
[229] Fix | Delete
$tables = $params['tables'];
[230] Fix | Delete
$resp = $this->getTablesRowCount($tables);
[231] Fix | Delete
break;
[232] Fix | Delete
case "chktabls":
[233] Fix | Delete
$tables = $params['tables'];
[234] Fix | Delete
$type = $params['type'];
[235] Fix | Delete
$resp = $this->checkTables($tables, $type);
[236] Fix | Delete
break;
[237] Fix | Delete
case "chktablsxist":
[238] Fix | Delete
$tables = $params['tables'];
[239] Fix | Delete
$resp = $this->checkTablesExist($tables);
[240] Fix | Delete
break;
[241] Fix | Delete
case "getrowscount":
[242] Fix | Delete
$table = $params['table'];
[243] Fix | Delete
$resp = array("count" => $db->rowsCount($table));
[244] Fix | Delete
break;
[245] Fix | Delete
case "gettablecontent":
[246] Fix | Delete
$result = array();
[247] Fix | Delete
$table = $params['table'];
[248] Fix | Delete
$fields = $params['fields'];
[249] Fix | Delete
$filter = (array_key_exists('filter', $params)) ? $params['filter'] : "";
[250] Fix | Delete
$limit = intval($params['limit']);
[251] Fix | Delete
$offset = intval($params['offset']);
[252] Fix | Delete
$pkeys = (array_key_exists('pkeys', $params)) ? $params['pkeys'] : array();
[253] Fix | Delete
$result['timestamp'] = time();
[254] Fix | Delete
$result['tablename'] = $table;
[255] Fix | Delete
$rows = $db->getTableContent($table, $fields, $filter, $limit, $offset);
[256] Fix | Delete
$srows = sizeof($rows);
[257] Fix | Delete
if (!empty($pkeys) && $srows > 0) {
[258] Fix | Delete
$end_row = end($rows);
[259] Fix | Delete
$result['last_ids'] = $this->getLastID($pkeys, $end_row);
[260] Fix | Delete
}
[261] Fix | Delete
$result["rows"] = $rows;
[262] Fix | Delete
$resp = $result;
[263] Fix | Delete
break;
[264] Fix | Delete
case "multitablecontent":
[265] Fix | Delete
$tableParams = $params['table_params'];
[266] Fix | Delete
$resp = array();
[267] Fix | Delete
foreach($tableParams as $tableParam) {
[268] Fix | Delete
$result = array();
[269] Fix | Delete
$identifier = $tableParam['identifier'];
[270] Fix | Delete
$table = $tableParam['table'];
[271] Fix | Delete
$tname = $tableParam['tname'];
[272] Fix | Delete
$fields = $tableParam['fields'];
[273] Fix | Delete
$filter = (array_key_exists('filter', $tableParam)) ? $tableParam['filter'] : "";
[274] Fix | Delete
$limit = $tableParam['limit'];
[275] Fix | Delete
$offset = $tableParam['offset'];
[276] Fix | Delete
$pkeys = (array_key_exists('pkeys', $tableParam)) ? $tableParam['pkeys'] : array();
[277] Fix | Delete
$result['timestamp'] = time();
[278] Fix | Delete
$result['table_name'] = $tname;
[279] Fix | Delete
$rows = $db->getTableContent($table, $fields, $filter, $limit, $offset);
[280] Fix | Delete
$srows = sizeof($rows);
[281] Fix | Delete
if (!empty($pkeys) && $srows > 0) {
[282] Fix | Delete
$end_row = end($rows);
[283] Fix | Delete
$result['last_ids'] = $this->getLastID($pkeys, $end_row);
[284] Fix | Delete
}
[285] Fix | Delete
$result["rows"] = $rows;
[286] Fix | Delete
$result["size"] = $srows;
[287] Fix | Delete
$resp[$identifier] = $result;
[288] Fix | Delete
}
[289] Fix | Delete
break;
[290] Fix | Delete
case "tableinfo":
[291] Fix | Delete
$table = $params['table'];
[292] Fix | Delete
$offset = intval($params['offset']);
[293] Fix | Delete
$limit = intval($params['limit']);
[294] Fix | Delete
$bsize = intval($params['bsize']);
[295] Fix | Delete
$filter = (array_key_exists('filter', $params)) ? $params['filter'] : "";
[296] Fix | Delete
$tname = $params['tname'];
[297] Fix | Delete
$pkeys = (array_key_exists('pkeys', $params)) ? $params['pkeys'] : array();
[298] Fix | Delete
$resp = $this->getTableData($table, $tname, $offset, $limit, $bsize, $filter, $pkeys, false);
[299] Fix | Delete
break;
[300] Fix | Delete
case "getmulttables":
[301] Fix | Delete
$result = array();
[302] Fix | Delete
$tableParams = $params['table_params'];
[303] Fix | Delete
$resp = array();
[304] Fix | Delete
foreach($tableParams as $tableParam) {
[305] Fix | Delete
$table = $tableParam['table'];
[306] Fix | Delete
$tname = $tableParam['tname'];
[307] Fix | Delete
$filter = (array_key_exists('filter', $tableParam)) ? $tableParam['filter'] : "";
[308] Fix | Delete
$limit = intval($tableParam['limit']);
[309] Fix | Delete
$offset = intval($tableParam['offset']);
[310] Fix | Delete
$bsize = intval($tableParam['bsize']);
[311] Fix | Delete
$pkeys = (array_key_exists('pkeys', $tableParam)) ? $tableParam['pkeys'] : array();
[312] Fix | Delete
$resp[$tname] = $this->getTableData($table, $tname, $offset, $limit, $bsize, $filter, $pkeys, true);
[313] Fix | Delete
}
[314] Fix | Delete
break;
[315] Fix | Delete
case "uploadrows":
[316] Fix | Delete
$table = $params['table'];
[317] Fix | Delete
$offset = intval($params['offset']);
[318] Fix | Delete
$limit = intval($params['limit']);
[319] Fix | Delete
$bsize = intval($params['bsize']);
[320] Fix | Delete
$filter = (array_key_exists('filter', $params)) ? $params['filter'] : "";
[321] Fix | Delete
$tname = $params['tname'];
[322] Fix | Delete
$pkeys = (array_key_exists('pkeys', $params)) ? $params['pkeys'] : array();
[323] Fix | Delete
$resp = $this->getTableData($table, $tname, $offset, $limit, $bsize, $filter, $pkeys, true);
[324] Fix | Delete
break;
[325] Fix | Delete
case "tblexists":
[326] Fix | Delete
$resp = array("tblexists" => $db->isTablePresent($params['table']));
[327] Fix | Delete
break;
[328] Fix | Delete
case "crttbl":
[329] Fix | Delete
$usedbdelta = array_key_exists('usedbdelta', $params);
[330] Fix | Delete
$resp = array("crttbl" => $db->createTable($params['query'], $params['table'], $usedbdelta));
[331] Fix | Delete
break;
[332] Fix | Delete
case "drptbl":
[333] Fix | Delete
$resp = array("drptbl" => $db->dropBVTable($params['table']));
[334] Fix | Delete
break;
[335] Fix | Delete
case "trttbl":
[336] Fix | Delete
$resp = array("trttbl" => $db->truncateBVTable($params['table']));
[337] Fix | Delete
break;
[338] Fix | Delete
case "altrtbl":
[339] Fix | Delete
$resp = array("altrtbl" => $db->alterBVTable($params['query'], $params['query']));
[340] Fix | Delete
break;
[341] Fix | Delete
case "mltigtrslt":
[342] Fix | Delete
$resp = array("mltigtrslt" => $this->multiGetResult($params['queries']));
[343] Fix | Delete
break;
[344] Fix | Delete
case "mltiqrsstrm":
[345] Fix | Delete
$queries = $params['queries'];
[346] Fix | Delete
$result = array();
[347] Fix | Delete
foreach ($queries as $qparams) {
[348] Fix | Delete
$identifier = $qparams['identifier'];
[349] Fix | Delete
$query = $qparams['query'];
[350] Fix | Delete
$pkeys = (array_key_exists('pkeys', $qparams)) ? $qparams['pkeys'] : array();
[351] Fix | Delete
array_push($result, $this->streamQueryResult($identifier, $query, $pkeys));
[352] Fix | Delete
}
[353] Fix | Delete
$resp = array('mltqrsstrm' => $result);
[354] Fix | Delete
break;
[355] Fix | Delete
case "getrndmdata":
[356] Fix | Delete
$resp = array("getrndmdata" => $this->getRandomData($params['size'], $params['batch_size']));
[357] Fix | Delete
break;
[358] Fix | Delete
case "tbls":
[359] Fix | Delete
$resp = array();
[360] Fix | Delete
[361] Fix | Delete
if (array_key_exists('truncate', $params))
[362] Fix | Delete
$resp['truncate'] = $db->truncateTables($params['truncate']);
[363] Fix | Delete
[364] Fix | Delete
if (array_key_exists('drop', $params))
[365] Fix | Delete
$resp['drop'] = $db->dropTables($params['drop']);
[366] Fix | Delete
[367] Fix | Delete
if (array_key_exists('create', $params))
[368] Fix | Delete
$resp['create'] = $db->createTables($params['create']);
[369] Fix | Delete
[370] Fix | Delete
if (array_key_exists('alter', $params))
[371] Fix | Delete
$resp['alter'] = $db->alterTables($params['alter']);
[372] Fix | Delete
[373] Fix | Delete
break;
[374] Fix | Delete
default:
[375] Fix | Delete
$resp = false;
[376] Fix | Delete
}
[377] Fix | Delete
$end_stream_info = $this->stream->endStream();
[378] Fix | Delete
if (!empty($end_stream_info) && is_array($resp)) {
[379] Fix | Delete
$resp = array_merge($resp, $end_stream_info);
[380] Fix | Delete
}
[381] Fix | Delete
} else {
[382] Fix | Delete
$resp = $stream_init_info;
[383] Fix | Delete
}
[384] Fix | Delete
return $resp;
[385] Fix | Delete
}
[386] Fix | Delete
}
[387] Fix | Delete
endif;
[388] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function