sibtracker/system/inc/repa/repa_save.php

74 lines
2.0 KiB
PHP
Raw Permalink Normal View History

2019-05-18 13:46:03 +08:00
<?php
if(!defined('DATALIFEENGINE'))
{
die("Hacking attempt!");
}
if ($_REQUEST['savecfg'] != "savecfg")
require_once SYSTEM_DIR.'/data/repa.php';
if($_REQUEST['savecfg'] == "savecfg")
{
$find[] = "'\r'";
$replace[] = "";
$find[] = "'\n'";
$replace[] = "";
$save_con['version'] = "6.5";
$save_config = $save_config + $save_con;
$handler = fopen(SYSTEM_DIR.'/data/repa.php', "w");
fwrite($handler, "<?PHP\r\n\$repa_cf = array (\r\n");
foreach($save_config as $name => $value)
{
if ($name == "repa_rules_tpl_tsu" OR $name == "repa_ban_desc")
{
include_once SYSTEM_DIR.'/classes/parse.class.php';
$parse = new ParseFilter();
$value = $db->safesql( $parse->BB_Parse( $parse->process( $value ), false ));
$value = preg_split( '((>)|(<))', $value, - 1, PREG_SPLIT_DELIM_CAPTURE );
$n = count( $value );
for($i = 0; $i < $n; $i ++)
{
if( $value[$i] == "<" )
{
$i ++;
continue;
}
$value[$i] = preg_replace( "#([^\s\n\r]{" . intval( 50 ) . "})#i", "\\1<br />", $value[$i] );
}
$value = join( "", $value );
}
elseif ($name == "bl_period" OR $name == "res_site" OR $name == "res_cp" OR $name == "sp_num")
{
$value = intval($value);
}
elseif ($name == "adm_minus" OR $name == "repa_stop_change_min")
{
$value = intval($value);
if ($value > 0 AND $value != 0)
$value = 0 - $value;
}
elseif ($name == "adm_plus")
{
$value = intval($value);
if ($value < 0 AND $value != 0)
$value = 0 - $value;
}
else
{
$value = stripslashes ($value);
$value = addslashes($value);
$value = preg_replace($find, $replace, $value);
}
fwrite($handler, "'{$name}' => \"{$value}\",\r\n");
}
fwrite($handler, ");\r\n?>");
fclose($handler);
$cache->clear();
msg("info", $langms['sea_info'], "{$lang_repa['opt_saved']}<br><br><input type='button' value=\" {$lang_repa['repa_go_back']} \" class='bbcodes' onclick=\"window.location='$PHP_SELF?mod=repa&action=opt'\">", "");
}
?>