[Alba-desarrollo] SVN Alba r4007 - prosistem/alba/trunk
commits en pressenter.com.ar
commits en pressenter.com.ar
Vie Ene 12 20:07:45 CET 2007
Author: josx
Date: 2007-01-12 16:07:43 -0300 (Fri, 12 Jan 2007)
New Revision: 4007
Modified:
prosistem/alba/trunk/index.php
Log:
Modificaciones la instalador para soportar windows ( ticket #60 )
Modified: prosistem/alba/trunk/index.php
===================================================================
--- prosistem/alba/trunk/index.php 2007-01-12 14:18:25 UTC (rev 4006)
+++ prosistem/alba/trunk/index.php 2007-01-12 19:07:43 UTC (rev 4007)
@@ -30,23 +30,24 @@
* @license GPL
*/
+ define("OS_WINDOWS",((strtoupper(substr(PHP_OS,0,3))=='WIN'))?true:false);
define("APACHE_REQUIRED_VERSION","2.0.0");
define("PHP_REQUIRED_VERSION","5.0.0");
define("MEMORY_LIMIT_REQUIRED", "16");
define("MYSQL_REQUIRED_VERSION","4.1.0");
- define("INSTALL_DIR", getcwd()."/");
+ define("INSTALL_DIR", getcwd().DIRECTORY_SEPARATOR);
- chdir("alba/");
- define("ALBA_PATH", getcwd()."/");
+ chdir("alba".DIRECTORY_SEPARATOR);
+ define("ALBA_PATH", getcwd().DIRECTORY_SEPARATOR);
define("INSTALL_COMPLETE_DIR",ALBA_PATH."log");
- define("INSTALL_COMPLETE_FILE",INSTALL_COMPLETE_DIR."/"."instalacion_completa");
+ define("INSTALL_COMPLETE_FILE",INSTALL_COMPLETE_DIR.DIRECTORY_SEPARATOR."instalacion_completa");
- define("ALBA_WEB",ALBA_PATH."web/");
- define("CONFIG_PATH", ALBA_PATH."config/");
+ define("ALBA_WEB",ALBA_PATH."web".DIRECTORY_SEPARATOR);
+ define("CONFIG_PATH", ALBA_PATH."config".DIRECTORY_SEPARATOR);
define("APACHE_CONFIG_DIST", CONFIG_PATH."apache.conf.dist");
define("DATABASE_CONFIG_DIST", CONFIG_PATH."databases.yml.dist");
@@ -65,18 +66,24 @@
define("IMG_OK", "<img src='dist/".SYMFONY_DIR."/data/web/sf/images/sf_admin/save.png'>");
define("IMG_NOT_OK", "<img src='dist/".SYMFONY_DIR."/data/web/sf/images/sf_admin/delete.png'>");
- define("SQL_CREATE", ALBA_PATH."data/sql/alba_tablas.sql");
- define("SQL_INSERT", ALBA_PATH."data/sql/datos_desde_cero.sql");
+ define("SQL_CREATE", ALBA_PATH."data".DIRECTORY_SEPARATOR."sql".DIRECTORY_SEPARATOR."alba_tablas.sql");
+ define("SQL_INSERT", ALBA_PATH."data".DIRECTORY_SEPARATOR."sql".DIRECTORY_SEPARATOR."datos_desde_cero.sql");
define("CURRENT_WEB_DIR",dirname($_SERVER["PHP_SELF"])."/");
define("SYMFONY_WEB_DIR", "public_html");
- define("REDIRECT_URL","http://" . $_SERVER['SERVER_NAME'] . CURRENT_WEB_DIR.SYMFONY_WEB_DIR."/");
+ define("SERVER","http://" . $_SERVER['SERVER_NAME'].CURRENT_WEB_DIR);
+ define("SYMFONY_WINDOWS_WEB_DIR","alba/web"); // directorio directo del web en alba
+ define("REDIRECT_URL",(OS_WINDOWS)?SERVER.SYMFONY_WINDOWS_WEB_DIR."/index.php":SERVER.SYMFONY_WEB_DIR."/");
-
if(!file_exists(INSTALL_COMPLETE_FILE)) {
+ if(OS_WINDOWS) {
+ @unlink(ALBA_PATH.".htaccess");
+ @unlink(INSTALL_DIR."dist/.htaccess");
+ }
+
$f_phpversion = function_exists ("phpversion");
$f_apache_get_version = function_exists ("apache_get_version");
// $f_get_magic_quotes_gpc = function_exists ("get_magic_quotes_gpc");
@@ -470,21 +477,23 @@
$contenido_archivo = reemplzarArchivo(PROPEL_CONFIG_DIST,$aReemplazo);
file_put_contents(PROPEL_CONFIG, $contenido_archivo);
- //if ($_SERVER['WINDIR'] || $_SERVER['windir']
- // ver http://ar.php.net/manual/en/function.symlink.php para emulacion de symlinks en windows
- @symlink(ALBA_WEB, INSTALL_DIR.SYMFONY_WEB_DIR);
- $aReemplazo = Array('REWRITE_PATH' => CURRENT_WEB_DIR.SYMFONY_WEB_DIR);
+ _symlink(INSTALL_DIR."dist/".SYMFONY_DIR."/data/", ALBA_PATH."data/symfony");
+ _symlink(INSTALL_DIR."dist/pake/", ALBA_PATH."lib/pake");
+ _symlink(INSTALL_DIR."dist/phing.sandbox/", ALBA_PATH."lib/phing");
+ _symlink(INSTALL_DIR."dist/".SYMFONY_DIR."/lib/", ALBA_PATH."lib/symfony");
+ _symlink(INSTALL_DIR."alba/data/symfony/web/sf/", ALBA_WEB."sf");
+
+
+ $rewrite_path = (OS_WINDOWS)?CURRENT_WEB_DIR.SYMFONY_WINDOWS_WEB_DIR:CURRENT_WEB_DIR.SYMFONY_WEB_DIR;
+
+ if(!OS_WINDOWS)
+ _symlink(ALBA_WEB, INSTALL_DIR.SYMFONY_WEB_DIR); // crea nuevo link afuera de la estructura de alba
+
+ $aReemplazo = Array('REWRITE_PATH' => $rewrite_path);
$contenido_archivo = reemplzarArchivo(HTACCESS_DIST,$aReemplazo);
file_put_contents(HTACCESS, $contenido_archivo);
-
-
- @symlink(INSTALL_DIR."dist/".SYMFONY_DIR."/data/", ALBA_PATH."data/symfony");
- @symlink(INSTALL_DIR."dist/pake/", ALBA_PATH."lib/pake");
- @symlink(INSTALL_DIR."dist/phing.sandbox/", ALBA_PATH."lib/phing");
- @symlink(INSTALL_DIR."dist/".SYMFONY_DIR."/lib/", ALBA_PATH."lib/symfony");
- @symlink(INSTALL_DIR."alba/data/symfony/web/sf/", ALBA_WEB."sf");
-
+
touch(INSTALL_COMPLETE_FILE);
return true;
@@ -501,4 +510,42 @@
}
+function _symlink( $target, $link ) {
+ if (OS_WINDOWS) {
+ @dircopy($target, $link);
+ } else {
+ @symlink($target,$link);
+ }
+}
+
+
+function dircopy($srcdir, $dstdir, $verbose = false) {
+ $num = 0;
+ if(!is_dir($dstdir)) mkdir($dstdir);
+ if($curdir = opendir($srcdir)) {
+ while($file = readdir($curdir)) {
+ if($file != '.' && $file != '..') {
+ $srcfile = $srcdir . DIRECTORY_SEPARATOR . $file;
+ $dstfile = $dstdir . DIRECTORY_SEPARATOR . $file;
+ if(is_file($srcfile)) {
+ if(is_file($dstfile)) $ow = filemtime($srcfile) - filemtime($dstfile); else $ow = 1;
+ if($ow > 0) {
+ if($verbose) echo "Copying '$srcfile' to '$dstfile'...";
+ if(copy($srcfile, $dstfile)) {
+ touch($dstfile, filemtime($srcfile)); $num++;
+ if($verbose) echo "OK\n";
+ }
+ else echo "Error: File '$srcfile' could not be copied!\n";
+ }
+ }
+ else if(is_dir($srcfile)) {
+ $num += dircopy($srcfile, $dstfile, $verbose);
+ }
+ }
+ }
+ closedir($curdir);
+ }
+ return $num;
+}
+
?>
\ No newline at end of file
Más información sobre la lista de distribución Alba-desarrollo