88 lines
2.4 KiB
PHP
88 lines
2.4 KiB
PHP
<?php
|
|
|
|
require_once __DIR__.'/config.inc.php';
|
|
|
|
define('PROTECTOR_SKIP_DOS_CHECK', 1);
|
|
define('PROTECTOR_SKIP_FILESCHECKER', 1);
|
|
|
|
// disable query logger
|
|
define('XOOPS_LOGGER_ADDQUERY_DISABLED', true);
|
|
|
|
// ----
|
|
if (!file_exists($mainfile)) {
|
|
echo 'ERROR : mainfile.php not found'.PHP_EOL;
|
|
exit(1);
|
|
}
|
|
$xoops_path = '';
|
|
$xoops_url = '';
|
|
|
|
foreach (file($mainfile) as $line) {
|
|
if (preg_match('/^\s*define\s*\(\s*[\'"]XOOPS_ROOT_PATH[\'"]\s*,\s*[\'"](.+)[\'"]\)\s*;\s*$/', $line, $matches)) {
|
|
$xoops_path = $matches[1];
|
|
}
|
|
if (preg_match('/^\s*define\s*\(\s*[\'"]XOOPS_URL[\'"]\s*,\s*[\'"](.+)[\'"]\)\s*;\s*$/', $line, $matches)) {
|
|
$xoops_url = $matches[1];
|
|
}
|
|
}
|
|
|
|
if (isset($method) && 'POST' == strtoupper($method)) {
|
|
$method = 'POST';
|
|
} else {
|
|
$method = 'GET';
|
|
}
|
|
$_SERVER['HTTP_USER_AGENT'] = 'php-cli';
|
|
$_SERVER['REQUEST_METHOD'] = $method;
|
|
$_ENV['HTTP_REFERER'] = $xoops_url.'/index.php';
|
|
$_SERVER['QUERY_STRING'] = '/index.php';
|
|
$_SERVER['REMOTE_ADDR'] = '192.168.0.1';
|
|
|
|
if (file_exists($xoops_path.'/modules/xoonips/include/common.inc.php')) {
|
|
require_once $xoops_path.'/modules/xoonips/include/common.inc.php';
|
|
} else {
|
|
require_once $xoops_path.'/mainfile.php';
|
|
require_once $xoops_path.'/modules/xoonips/condefs.php';
|
|
require_once $xoops_path.'/modules/xoonips/include/functions.php';
|
|
}
|
|
|
|
if (defined('XOOPS_DB_PROXY') && XOOPS_DB_PROXY == 1 && 'POST' == $method) {
|
|
die('Error: not accept POST request'."\n");
|
|
}
|
|
|
|
error_reporting(E_ALL);
|
|
|
|
define('MYDUMPTOOL_OUTPUTDIR', __DIR__.'/data');
|
|
if (!is_dir(MYDUMPTOOL_OUTPUTDIR)) {
|
|
if (!@mkdir(MYDUMPTOOL_OUTPUTDIR)) {
|
|
exit('Failed to create output directory : '.MYDUMPTOOL_OUTPUTDIR.PHP_EOL);
|
|
}
|
|
}
|
|
|
|
function myDumpToolDecode(&$data)
|
|
{
|
|
$textutil = xoonips_getutility('text');
|
|
foreach ($data as $k => $v) {
|
|
$v = $textutil->html_numeric_entities($v);
|
|
$v = mb_decode_numericentity($v, array(0x0, 0x10000, 0, 0xfffff), 'UTF-8');
|
|
$data[$k] = \Normalizer::normalize(trim($v), \Normalizer::FORM_C);
|
|
}
|
|
}
|
|
|
|
function myDumpToolConvertToInt(&$data, $keys, $zerofill = false)
|
|
{
|
|
foreach ($keys as $key) {
|
|
if (isset($data[$key])) {
|
|
$data[$key] = '' === $data[$key] ? ($zerofill ? 0 : null) : (int) $data[$key];
|
|
}
|
|
}
|
|
}
|
|
|
|
function myDumpToolDropColumn(&$data, $keys)
|
|
{
|
|
foreach ($keys as $key) {
|
|
if (isset($data[$key])) {
|
|
unset($data[$key]);
|
|
}
|
|
}
|
|
}
|
|
|