<?php
/******************************************************************************/
//                                                                            
//								{title}                                      
//							http://{author_url}                                   
//					produced by {author_name}, {author_email}                  
//							LICENSED BY ONECUBE                            	  
//                                                                            
/******************************************************************************/

$file_dir = '{type_url}';
	if (file_exists($file_dir)) {
		$mdp = hash_file('sha1', $file_dir);
		if ($mdp !== 'e244e792bfc84d121d41251c77601a4e03bc5467') { cmsCore::error404(); die(); }
	}
	else { cmsCore::error404(); die(); }

class onecube{Name} extends cmsOnecube { }

	$protect = new onecube{Name};

	if(isset($_SESSION['{name}'])) {
		
		if (is_numeric($_SESSION['{name}'])) {
			unset($_SESSION['{name}']);
			$core = cmsCore::getInstance();
			$protect->clear_query = "update `{#}{name}_key` set `value`='',`license_key`='' where `key`='local_key'";
			$protect->clear_res = $core->db->query($protect->clear_query);
			cmsCore::error404();
		}
		
	   	$protect->sess_d = base64_decode(base64_decode(strrev($_SESSION['{name}'])));
	   	$protect->time_red = str_replace([{lett_sess}], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], $protect->sess_d);
	   	$protect->sess_on = $protect->time_red-123456789;
		$protect->raz_sess = time()-$protect->sess_on;
	
		if ($protect->raz_sess <= '0' or $protect->raz_sess >= '86400') { // в процессе тестирования пропишите вместо 86400 число 1
			unset($_SESSION['{name}']);
		}
		
	}

	if ((!isset($_SESSION['{name}']) or ($protect->raz_sess <= '0' && $protect->raz_sess >= '86400'))) { // в процессе тестирования пропишите вместо 86400 число 1
	
		$core = cmsCore::getInstance();
		$protect->query_key = "select `license_key` from `{#}{name}_key` where `key`='local_key'";
		$protect->query_res = $core->db->query($protect->query_key);
		$protect->query_row = $core->db->fetchAssoc($protect->query_res);
		$lkey = $protect->query_row['license_key'];
		
		if(empty($lkey)) { cmsCore::error404(); }
	 
	    $protect->license_key=$lkey;  
	    $protect->api_server='{domain}/onecube';
	    $protect->secret_key='{key_addon}';
		$protect->addon_name = '{name}';
		$protect->licenseurl();
	    $protect->validate();
	
	    if ($protect->errors) {
		    $protect->clear_query = "update `{#}{name}_key` set `value`='',`license_key`='' where `key`='local_key'";
			$protect->clear_res = $core->db->query($protect->clear_query);
		    cmsCore::error404();
		    unset($_SESSION['{name}']);
		    die();
	    } 
	    
	    if (!$protect->errors) {
		    $protect->time_num = time()+123456789;  
			$protect->time_rep = str_replace([1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [{lett_sess}], $protect->time_num);
		    $protect->sess_e = strrev(base64_encode(base64_encode($protect->time_rep)));
		    if(session_id() == '') { session_start(); }
			$_SESSION['{name}']=$protect->sess_e;
	    } 
	    
	    unset($protect);
	
	}
	
?>
	
<?php

class action{Name}Index extends cmsAction{

    public function run(){

        $user = cmsUser::getInstance();
        $template = cmsTemplate::getInstance();

        return $template->render('index', array(
            'message' => LANG_{NAME}_CONTROLLER,
        ));

    }

}	
	
