<?php

error_reporting(E_ALL ^ E_NOTICE);

require "classes/DB.class.php";
require "classes/SevenBase.class.php";
require "classes/Seven.class.php";
require "classes/SevenRegistrar.class.php";

if(get_magic_quotes_gpc()){
	
	// If magic quotes is enabled, strip the extra slashes
	array_walk_recursive($_GET,create_function('&$v,$k','$v = stripslashes($v);'));
	array_walk_recursive($_POST,create_function('&$v,$k','$v = stripslashes($v);'));
}

/* Database Configuration. Add your details below */

$dbOptions = array(
	'db_host' => 'localhost',
	'db_name' => 'appsiete_consultacpe',
	'db_user' => 'appsiete_seven',
	'db_pass' => '3owTCLTvNLw'
);

/* Database Config End */

try{
	DB::init($dbOptions);
	$response = array();
	// Handling the supported actions:
	switch($_GET['action']){
		 
        case 'getRegistrar':
			$response = Seven::getRegistrar($_POST['ruc'], $_POST['subdominio'], $_POST['nombre_bd']);
        	break;     
        case 'getEmpresas':
			$response = Seven::getEmpresas();
        	break;  
        /************************************/
		default:
			throw new Exception('Wrong action');
	}
	echo json_encode($response);
}
catch(Exception $e){
	die(json_encode(array('error' => $e->getMessage())));
}

?>