/**
 * clean
 *
 * @since 2.2.0
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Migrate
 * @author Henry Ruhs
 *
 * @param string $input
 * @param integer $mode
 * @return string
 */
function clean($input = null, $mode = null)
{
    $output = $input;
    $registry = Redaxscript\Registry::getInstance();
    /* if untrusted user */
    if ($registry->get('filter') == 1) {
        if ($mode == 0) {
            $specialFilter = new Redaxscript\Filter\Special();
            $output = $specialFilter->sanitize($output);
        }
        if ($mode == 1) {
            $htmlFilter = new Redaxscript\Filter\Html();
            $output = $htmlFilter->sanitize($output);
        }
        if ($mode == 5) {
            $output = strip_tags($output);
        }
    }
    /* type related clean */
    if ($mode == 2) {
        $aliasFilter = new Redaxscript\Filter\Alias();
        $output = $aliasFilter->sanitize($output);
    }
    if ($mode == 3) {
        $emailFilter = new Redaxscript\Filter\Email();
        $output = $emailFilter->sanitize($output);
    }
    if ($mode == 4) {
        $urlFilter = new Redaxscript\Filter\Url();
        $output = $urlFilter->sanitize($output);
    }
    $output = stripslashes($output);
    return $output;
}
/**
 * admin update
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Admin
 * @author Henry Ruhs
 */
function admin_update()
{
    $tableParameter = Redaxscript\Registry::get('tableParameter');
    if ($tableParameter == 'settings') {
        $specialFilter = new Redaxscript\Filter\Special();
        $emailFilter = new Redaxscript\Filter\Email();
        /* clean post */
        $r['language'] = $specialFilter->sanitize($_POST['language']);
        $r['template'] = $specialFilter->sanitize($_POST['template']);
        $r['title'] = $_POST['title'];
        $r['author'] = $_POST['author'];
        $r['copyright'] = $_POST['copyright'];
        $r['description'] = $_POST['description'];
        $r['keywords'] = $_POST['keywords'];
        $r['robots'] = $specialFilter->sanitize($_POST['robots']);
        $r['email'] = $emailFilter->sanitize($_POST['email']);
        $r['subject'] = $_POST['subject'];
        $r['notification'] = $specialFilter->sanitize($_POST['notification']);
        $r['charset'] = !$r['charset'] ? 'utf-8' : $r['charset'];
        $r['divider'] = $_POST['divider'];
        $r['time'] = $_POST['time'];
        $r['date'] = $_POST['date'];
        $r['homepage'] = $specialFilter->sanitize($_POST['homepage']);
        $r['limit'] = !$specialFilter->sanitize($_POST['limit']) ? 10 : $specialFilter->sanitize($_POST['limit']);
        $r['order'] = $specialFilter->sanitize($_POST['order']);
        $r['pagination'] = $specialFilter->sanitize($_POST['pagination']);
        $r['moderation'] = $specialFilter->sanitize($_POST['moderation']);
        $r['registration'] = $specialFilter->sanitize($_POST['registration']);
        $r['verification'] = $specialFilter->sanitize($_POST['verification']);
        $r['recovery'] = $specialFilter->sanitize($_POST['recovery']);
        $r['captcha'] = $specialFilter->sanitize($_POST['captcha']);
        /* update settings */
        foreach ($r as $key => $value) {
            if ($value == 'select') {
                $value = null;
            }
            Redaxscript\Db::forTablePrefix($tableParameter)->where('name', $key)->findOne()->set('value', $value)->save();
        }
        /* show success */
        $messenger = new Redaxscript\Admin\Messenger(Redaxscript\Registry::getInstance());
        echo $messenger->setRoute(Redaxscript\Language::get('continue'), 'admin/edit/settings')->doRedirect()->success(Redaxscript\Language::get('operation_completed'));
    }
}