Setup for windows

Esse commit está contido em:
unknown
2011-04-14 12:36:57 -03:00
commit a3f381ad34
7 arquivos alterados com 89 adições e 39 exclusões
+4 -1
Ver Arquivo
@@ -21,9 +21,12 @@
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')
{
require('mind3rd/env/setup/UnixSetup.php');
$_MIND['sys']= 'unix';
UnixSetup::install();
}else{
WinSetup::install();
require('mind3rd/env/setup/WinSetup.php');
$_MIND['sys']= 'win';
WinSetup::install();
}
exit;
}
+5 -5
Ver Arquivo
@@ -20,9 +20,9 @@ class MindDB {
*/
public function query($qr)
{
$ret= sqlite_query($this->db, $qr);
$ret= $this->db->query($qr);
$ar_ret= Array();
while($tuple= sqlite_fetch_array($ret, SQLITE_ASSOC))
while($tuple= $ret->fetchArray(SQLITE3_ASSOC))
{
$ar_ret[]= $tuple;
}
@@ -36,14 +36,14 @@ class MindDB {
*/
public function execute($command)
{
$ret= sqlite_exec($this->db, $command);
$this->lastInsertedId= sqlite_last_insert_rowid($this->db);
$ret= $this->db->exec($command);
$this->lastInsertedId= $this->db->lastInsertRowId();
return $this->lastInsertedId;
}
public function __construct()
{
if(!$db = sqlite_open(_MINDSRC_.SQLITE))
if(!$db = new SQLite3(_MINDSRC_.SQLITE))
{
Mind::message('Database', '[Fail]');
return false;
+6 -6
Ver Arquivo
@@ -67,20 +67,20 @@ EOT
private function action()
{
if($db = new SQLiteDatabase(_MINDSRC_.'/mind3rd/SQLite/mind'))
if($db = new SQLite3(_MINDSRC_.'/mind3rd/SQLite/mind'))
{
$result= $db->query("SELECT * FROM user where login='".$this->login.
"' AND pwd='".sha1($this->pwd)."' AND status= 'A'");
$row= false;
while ($result->valid())
$row= $result->fetchArray();
/*while()
{
$row = $result->current();
$row = $result->current();*/
$_SESSION['auth']= JSON_encode($row);
$_SESSION['pk_user']= $row['pk_user'];
$_SESSION['status']= $row['status'];
$_SESSION['login']= $row['login'];
break;
}
/*break;
}*/
if(!$row)
{
Mind::write('auth_fail', true);
+1 -1
Ver Arquivo
@@ -106,7 +106,7 @@ EOT
}
private function runStep2()
{
if(!$db = new SQLiteDatabase(_MINDSRC_.'/mind3rd/SQLite/mind'))
if(!$db = new SQLite3(_MINDSRC_.SQLITE))
{
Mind::message('Database', '[Fail]');
return false;
+17 -3
Ver Arquivo
@@ -3,7 +3,7 @@
// setting the general helperSet
$helperSet= false;
$helperSet= ($helperSet) ?: new Symfony\Component\Console\Helper\HelperSet();
$app->setHelperSet($helperSet);
$app->setHelperSet($helperSet);
if(isset($_SERVER['argv']))
{
@@ -15,5 +15,19 @@
/* let's load the plugins, if they are allowed */
Mind::$triggers= array_keys($app->getCommands());
$sh= new Symfony\Component\Console\Shell($app);
$sh->run();
try {
$sh= new Symfony\Component\Console\Shell($app);
$sh->run();
}catch(Exception $exc) {
echo " <[ERROR] It looks like you are not using the readline extension enabled!\n";
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')
{
echo " Sorry! The readline extension is not available for windows(!)\n";
echo " So, you will not be able to use the application through command line\n\n";
}
else
echo " Please, follow these instructions to install it: http://goo.gl/UDrEY\n\n";
echo " NOTE: Even without the readline extension, you already can use the\n";
echo " system via HTTP once it does not need the shell towork\n\n";
}
+23 -6
Ver Arquivo
@@ -6,16 +6,29 @@
*/
abstract class Setup {
public function createDatabase(){
GLOBAL $_MIND;
echo " creating database...\n";
if($db = new SQLiteDatabase('mind3rd/SQLite/mind'))
$sqlite= class_exists('SQLite3')? 'SQLite3': 'SQLiteDatabase';
$sqliteDDLFile= 'mind3rd/SQLite/ddl.sql';
$sqliteBaseFile= 'mind3rd/SQLite/mind';
if(file_exists($sqliteBaseFile))
{
echo " <[warning] Database already exists! It till NOT be touched>\n";
echo " If you want to re-install the system, remove the followinf file:\n";
echo " ".str_replace('\\', '/', getcwd()).
"/".$sqliteBaseFile."\n";
return true;
}
if(class_exists($sqlite) && $db = new SQLite3($sqliteBaseFile))
{
$DDL= file_get_contents('mind3rd/SQLite/ddl.sql');
if(!$db->queryExec($DDL))
$DDL= file_get_contents($sqliteDDLFile);
if(!$db->exec($DDL))
{
echo " <[INFO] Database already exists...it wont be touched>\n";
echo " <[ERROR] Failed creating the SQLite database!>\n";
return false;
}
echo " adding the main user...\n";
$db->queryExec("INSERT into user(
$db->exec("INSERT into user(
name,
login,
pwd,
@@ -29,10 +42,14 @@ abstract class Setup {
'A'
);");
echo " setting database permissions...\n";
echo shell_exec('sudo chmod 777 '.getcwd().'/mind3rd/SQLite/mind');
if($_MIND['sys']== 'unix')
echo shell_exec('sudo chmod 777 '.getcwd().'/mind3rd/SQLite/mind');
}else{
echo " <[ERROR] SQLite Database could not be created. ".
" Is your server working properly with SQLite?>\n";
echo " TIP: Remember that, the php.ini for phpcli may be
different from the php.ini for your http server\n";
exit;
}
echo "Finished\n";
+33 -17
Ver Arquivo
@@ -16,19 +16,35 @@ abstract class WinSetup extends Setup{
*/
public function createExecFile()
{
// inspired on Doctrine bat for windows
self::$content= <<<BAT
@echo off
if "%PHPBIN%" == "" set PHPBIN=@php_bin@
if not exist "%PHPBIN%" if "%PHP_PEAR_PHP_BIN%" neq "" goto USE_PEAR_PATH
GOTO RUN
:USE_PEAR_PATH
set PHPBIN=%PHP_PEAR_PHP_BIN%
:RUN
"%PHPBIN%" "@bin_dir@\mind" %*
BAT;
// TODO: any good soul to help with it?
$runDir= str_replace('cmd.exe', '', getenv('COMSPEC'));
$phpBin= '';
while(!file_exists($phpBin) || basename($phpBin)!='php.exe')
{
$command= " [PROMPT] Please type the PHP bin file";
if(file_exists('c:/wamp'))
$command.="
eg: \"c:/wamp/bin/php/php5.3.4/php.exe\":\n ";
else
echo $command.= "
eg: \"c:/php/php.exe\":\n ";
echo $command;
$fp = fopen('php://stdin', 'r');
$phpBin = trim(fgets($fp, 1024));
}
@shell_exec("copy /y NUL ".$runDir."mind.bat >NUL");
@shell_exec("copy /y NUL ".$runDir."mind3rd.php >NUL");
$content= $phpBin.' '.$runDir.'mind3rd.php';
@shell_exec('echo '.$content.' > '.$runDir.'mind.bat');
$cwd= str_replace('\\', '/', getcwd());
$phpContent= '$_REQ= Array(); $_REQ["env"]= "shell"; define("_MINDSRC_", "'.$cwd.'"); require("'.$cwd.'/mind3rd/API/utils.php"); ';
@shell_exec('echo ^<?php '.$phpContent.' > '.$runDir.'mind3rd.php');
return true;
}
/**
@@ -37,8 +53,8 @@ BAT;
* It uses an inherited method, createDatabase
*/
public function install(){
self::createExecFile();
self::createDatabase();
if(self::createExecFile())
return self::createDatabase();
return false;
}
}
?>
}