#!/usr/bin/env php
<?php
    /**
     * This file is part of TheWebMind 3rd generation.
     * 
     * @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
     * @license licenses/mind3rd.license
     * 
	 * this file will be only accessed trhough the console
	 * if you pass the parameter install to it, it will
	 * create the SQLite database, start it, and try to
	 * create shortcuts, allowing the use of the comand
	 * mind, in your console
	 */

	$_MIND= Array();
	$_MIND['env']= 'shell';

	// checks if it has received any argument
	if(sizeOf($_SERVER['argv'])>0 && isset($_SERVER['argv'][1]))
	{
		// installation should create the required SQLite database and a shortcut command
		if($_SERVER['argv'][1] == 'install')
		{
			// first, for linux and mac computers
			if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')
			{
				require('mind3rd/env/setup/UnixSetup.php');
                $_MIND['sys']= 'unix';
				UnixSetup::install();
			}else{
                    require('mind3rd/env/setup/WinSetup.php');
                    $_MIND['sys']= 'win';
                    WinSetup::install();
				 }
			exit;
		}
	}
	// if not installing, it should be redirected to mind3rd/API/shell.php
    $_REQ= Array();
    $_REQ["env"]= "shell";
    define("_MINDSRC_", dirname($_SERVER['PHP_SELF']));
    include(_MINDSRC_.'/mind3rd/API/utils.php');