示例#1
0
function update_ssl_data()
{
    // Get a reference to the Config object
    $cfg = EasySCP_Registry::get('Config');
    // Gets a reference to the EasySCP_ConfigHandler_Db instance
    $db_cfg = EasySCP_Registry::get('Db_Config');
    $db_cfg->resetQueriesCounter('update');
    $sslkey = clean_input(filter_input(INPUT_POST, 'ssl_key'));
    $sslcert = clean_input(filter_input(INPUT_POST, 'ssl_cert'));
    $sslcacert = clean_input(filter_input(INPUT_POST, 'ssl_cacert'));
    $sslstatus = clean_input(filter_input(INPUT_POST, 'ssl_status'));
    if (openssl_x509_check_private_key($sslcert, $sslkey)) {
        // update the ssl related values
        $db_cfg->SSL_KEY = $sslkey;
        $db_cfg->SSL_CERT = $sslcert;
        $db_cfg->SSL_CACERT = $sslcacert;
        $db_cfg->SSL_STATUS = $sslstatus;
        $cfg->replaceWith($db_cfg);
        /*
        $data = array (
        	'SSL_KEY'	=> $sslkey,
        	'SSL_CERT'	=> $sslcert,
        	'SSL_STATUS'=> $sslstatus
        );
        */
        $data = array('SSL_STATUS' => $sslstatus);
        EasyConfig::Save($data);
        write_log(get_session('user_logged') . ": Updated SSL configuration!");
        // get number of updates
        $update_count = $db_cfg->countQueries('update');
        if ($update_count == 0) {
            set_page_message(tr("SSL configuration unchanged"), 'info');
        } elseif ($update_count > 0) {
            set_page_message(tr('SSL configuration updated!'), 'success');
        }
    } else {
        set_page_message(tr("SSL key/cert don't match"), 'Warning');
        write_log(get_session('user_logged') . ": Update of SSL configuration failed!");
    }
    send_request('110 DOMAIN master');
    user_goto('tools_config_ssl.php');
}
示例#2
0
 public static function Reload()
 {
     self::$cfg = simplexml_load_file(EasyConfig_PATH . '/EasySCP_Config.xml');
 }