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/wordfenc.../lib
File: wfImportExportController.php
<?php
[0] Fix | Delete
[1] Fix | Delete
class wfImportExportController {
[2] Fix | Delete
/**
[3] Fix | Delete
* Returns the singleton wfImportExportController.
[4] Fix | Delete
*
[5] Fix | Delete
* @return wfImportExportController
[6] Fix | Delete
*/
[7] Fix | Delete
public static function shared() {
[8] Fix | Delete
static $_shared = null;
[9] Fix | Delete
if ($_shared === null) {
[10] Fix | Delete
$_shared = new wfImportExportController();
[11] Fix | Delete
}
[12] Fix | Delete
return $_shared;
[13] Fix | Delete
}
[14] Fix | Delete
[15] Fix | Delete
public function export() {
[16] Fix | Delete
$export = array();
[17] Fix | Delete
[18] Fix | Delete
//Basic Options
[19] Fix | Delete
$keys = wfConfig::getExportableOptionsKeys();
[20] Fix | Delete
foreach ($keys as $key) {
[21] Fix | Delete
$export[$key] = wfConfig::get($key, '');
[22] Fix | Delete
}
[23] Fix | Delete
[24] Fix | Delete
//Serialized Options
[25] Fix | Delete
$export['scanSched'] = wfConfig::get_ser('scanSched', array());
[26] Fix | Delete
[27] Fix | Delete
//Table-based Options
[28] Fix | Delete
$export['blocks'] = wfBlock::exportBlocks();
[29] Fix | Delete
[30] Fix | Delete
//Make the API call
[31] Fix | Delete
try {
[32] Fix | Delete
$api = new wfAPI(wfConfig::get('apiKey'), wfUtils::getWPVersion());
[33] Fix | Delete
$res = $api->call('export_options', array(), array('export' => json_encode($export)));
[34] Fix | Delete
if ($res['ok'] && $res['token']) {
[35] Fix | Delete
return array(
[36] Fix | Delete
'ok' => 1,
[37] Fix | Delete
'token' => $res['token'],
[38] Fix | Delete
);
[39] Fix | Delete
}
[40] Fix | Delete
else if ($res['err']) {
[41] Fix | Delete
return array('err' => __("An error occurred: ", 'wordfence') . $res['err']);
[42] Fix | Delete
}
[43] Fix | Delete
else {
[44] Fix | Delete
throw new Exception(__("Invalid response: ", 'wordfence') . var_export($res, true));
[45] Fix | Delete
}
[46] Fix | Delete
}
[47] Fix | Delete
catch (Exception $e) {
[48] Fix | Delete
return array('err' => __("An error occurred: ", 'wordfence') . $e->getMessage());
[49] Fix | Delete
}
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
public function import($token) {
[53] Fix | Delete
try {
[54] Fix | Delete
$api = new wfAPI(wfConfig::get('apiKey'), wfUtils::getWPVersion());
[55] Fix | Delete
$res = $api->call('import_options', array(), array('token' => $token));
[56] Fix | Delete
if ($res['ok'] && $res['export']) {
[57] Fix | Delete
$totalSet = 0;
[58] Fix | Delete
$import = @json_decode($res['export'], true);
[59] Fix | Delete
if (!is_array($import)) {
[60] Fix | Delete
return array('err' => __("An error occurred: Invalid options format received.", 'wordfence'));
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
//Basic Options
[64] Fix | Delete
$keys = wfConfig::getExportableOptionsKeys();
[65] Fix | Delete
$toSet = array();
[66] Fix | Delete
foreach ($keys as $key) {
[67] Fix | Delete
if (isset($import[$key])) {
[68] Fix | Delete
$toSet[$key] = $import[$key];
[69] Fix | Delete
}
[70] Fix | Delete
}
[71] Fix | Delete
[72] Fix | Delete
if (count($toSet)) {
[73] Fix | Delete
$validation = wfConfig::validate($toSet);
[74] Fix | Delete
$skipped = array();
[75] Fix | Delete
if ($validation !== true) {
[76] Fix | Delete
foreach ($validation as $error) {
[77] Fix | Delete
$skipped[$error['option']] = $error['error'];
[78] Fix | Delete
unset($toSet[$error['option']]);
[79] Fix | Delete
}
[80] Fix | Delete
}
[81] Fix | Delete
[82] Fix | Delete
$totalSet += count($toSet);
[83] Fix | Delete
wfConfig::save(wfConfig::clean($toSet));
[84] Fix | Delete
}
[85] Fix | Delete
[86] Fix | Delete
//Serialized Options
[87] Fix | Delete
if (isset($import['scanSched']) && is_array($import['scanSched'])) {
[88] Fix | Delete
wfConfig::set_ser('scanSched', $import['scanSched']);
[89] Fix | Delete
wfScanner::shared()->scheduleScans();
[90] Fix | Delete
$totalSet++;
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
//Table-based Options
[94] Fix | Delete
if (isset($import['blocks']) && is_array($import['blocks'])) {
[95] Fix | Delete
wfBlock::importBlocks($import['blocks']);
[96] Fix | Delete
$totalSet += count($import['blocks']);
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
return array(
[100] Fix | Delete
'ok' => 1,
[101] Fix | Delete
'totalSet' => $totalSet,
[102] Fix | Delete
);
[103] Fix | Delete
}
[104] Fix | Delete
else if ($res['err']) {
[105] Fix | Delete
return array('err' => sprintf(/* translators: Error message. */ __("An error occurred: %s", 'wordfence'), $res['err']));
[106] Fix | Delete
}
[107] Fix | Delete
else {
[108] Fix | Delete
throw new Exception(sprintf(/* translators: Error message. */ __("Invalid response: %s", 'wordfence'), var_export($res, true)));
[109] Fix | Delete
}
[110] Fix | Delete
}
[111] Fix | Delete
catch (Exception $e) {
[112] Fix | Delete
return array('err' => sprintf(/* translators: Error message. */ __("An error occurred: %s", 'wordfence'), $e->getMessage()));
[113] Fix | Delete
}
[114] Fix | Delete
}
[115] Fix | Delete
}
[116] Fix | Delete
[117] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function