<?php

$dont_close_session = true; 
$accessControl = array(
    "Admin" => true
);
require_once "../../AccessControl.php";

/**
* @desc This function will enable or disable the ipencoding setting 
*/
function toggleIPencoding() {
    global $ipencoding;
    unset($_SESSION['ipencoding']);

    if ($ipencoding === true) { # Check if the var is a boolean and set true
        setGlobalSetting('ipencoding', 'false');
        $msg = _IP_ENDCODING_DISABLED;
        $ipencoding = false;
    } else {
        setGlobalSetting('ipencoding', 'true');
        $msg = _IP_ENDCODING_ENABLED . "!";
        $ipencoding = true;
    }
    return '{ "Status": "Success", "Message": "'.$msg.'" }';
}


if (isset($_REQUEST["toggle_ipencode"])==1) {
    $res = toggleIPencoding();    
    echo $res;   
} else {
    # we are not setting the value, just requesting it
    if (isset($ipencoding) == true) {
        echo '{ "Status": "' . _ENABLED . '" }';
    } else {
        echo '{ "Status": "' . _DISABLED . '" }';
    }
}
?>