<?php
/**
* NOTICE OF LICENSE
*
* This file is licenced under the Software License Agreement.
* With the purchase or the installation of the software in your application
* you accept the licence agreement.
*
* You must not modify, adapt or create derivative works of this source code.
*
*  @author    Active Design <office@activedesign.ro>
*  @copyright 2017 Active Design
*  @license   LICENSE.txt
*/

class OneclicksslHelperModuleFrontController extends ModuleFrontController
{
    public function init()
    {
        header("Access-Control-Allow-Origin: *");
        if(Tools::getValue('method') == 'checkhttps')
        {
            die($this->context->smarty->fetch(_PS_MODULE_DIR_.'oneclickssl/views/templates/admin/checkhttps.tpl'));
        }
        elseif(Tools::getValue('method') == 'activatehttps')
        {
            $array = array();
            if(Configuration::updateValue('PS_SSL_ENABLED', true) && Configuration::updateValue('PS_SSL_ENABLED_EVERYWHERE', true))
            {
                $array['success'] = true;
            }
            else
            {
                $array['success'] = false;
            }
            die(Tools::jsonEncode($array));
        }
    }
}