diff --git a/htdocs/admin/tools/update.php b/htdocs/admin/tools/update.php index f041907f974..df127c155e6 100644 --- a/htdocs/admin/tools/update.php +++ b/htdocs/admin/tools/update.php @@ -1,6 +1,7 @@ * Copyright (C) 2009 Regis Houssin + * Copyright (C) 2012 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,7 +30,7 @@ $langs->load("other"); if (! $user->admin) accessforbidden(); -if ($_GET["msg"]) $message='
'.$_GET["msg"].'
'; +if (GETPOST('msg','alpha')) $message='
'.GETPOST('msg','alpha').'
'; $urldolibarr='http://www.dolibarr.org/downloads/'; @@ -45,7 +46,7 @@ $dolibarrdataroot=preg_replace('/([\\/]+)$/i','',DOL_DATA_ROOT); * Actions */ -if ($_POST["action"]=='install') +if (GETPOST('action','alpha')=='install') { $error=0; @@ -59,7 +60,7 @@ if ($_POST["action"]=='install') } else { - if (! preg_match('/\.tgz/i',$original_file)) + if (! preg_match('/\.tgz/i',$original_file) && ! preg_match('/\.zip/i',$original_file)) { $mesg=$langs->trans("ErrorFileMustBeADolibarrPackage"); $error++; @@ -71,19 +72,32 @@ if ($_POST["action"]=='install') @dol_delete_dir_recursive($conf->admin->dir_temp.'/'.$original_file); dol_mkdir($conf->admin->dir_temp.'/'.$original_file); - $result=dol_move_uploaded_file($_FILES["fileinstall"]["tmp_name"],$newfile,1,0,$_FILES['fileinstall']['error']); + $result=dol_move_uploaded_file($_FILES['fileinstall']['tmp_name'],$newfile,1,0,$_FILES['fileinstall']['error']); if ($result > 0) { - //dol_uncompress($newfile); + $rutax=DOL_DOCUMENT_ROOT_ALT; + $result=dol_uncompress($newfile,$_FILES['fileinstall']['type'],$rutax); + if ($result==2) + { + $langs->load("errors"); + $mesg = "".$langs->trans("ErrorOSSystem").""; + } + else + { + $mesg = "".$langs->trans("SetupIsReadyForUse").""; + } } } } - /* * View */ +$dirins=DOL_DOCUMENT_ROOT_ALT; +$vale=(is_dir($dirins)); +$system=PHP_OS; + $wikihelp='EN:Installation_-_Upgrade|FR:Installation_-_Mise_à_jour|ES:Instalaci&omodulon_-_Actualizaci&omodulon'; llxHeader('',$langs->trans("Upgrade"),$wikihelp); @@ -93,7 +107,8 @@ print $langs->trans("CurrentVersion").' : '.DOL_VERSION.'
'; print $langs->trans("LastStableVersion").' : '.$langs->trans("FeatureNotYetAvailable").'
'; print '
'; -dol_htmloutput_errors($mesg); +//dol_htmloutput_errors($mesg); +dol_htmloutput_mesg($mesg); print $langs->trans("Upgrade").'
'; print '
'; @@ -126,18 +141,33 @@ print ''.$langs->trans("StepNb",3).': '; print $langs->trans("UnpackPackageInDolibarrRoot",$dolibarrroot).'
'; if (! empty($conf->global->MAIN_ONLINE_INSTALL_MODULE)) { - print '
'; - print ''; - print $langs->trans("YouCanSubmitFile").' '; - print ''; - print '
'; + if ($vale == 1 && $dirins != 'DOL_DOCUMENT_ROOT_ALT' && ($system=="Linux")) + { + print '
'; + print ''; + print $langs->trans("YouCanSubmitFile").' '; + print ''; + print '
'; + } + elseif ($system!='Linux') + { + $langs->load('errors'); + $message=info_admin($langs->transnoentities("ErrorOSSystem")); + print $message; + } + else + { + $message=info_admin($langs->trans("NotExistsDirect").$langs->trans("InfDirAlt").$langs->trans("InfDirExample")); + print $message; + } +} +else +{ + print ''.$langs->trans("StepNb",4).': '; + print $langs->trans("SetupIsReadyForUse").'
'; } -print ''.$langs->trans("StepNb",4).': '; -print $langs->trans("SetupIsReadyForUse").'
'; - print ''; llxFooter(); - $db->close(); ?> \ No newline at end of file diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 8a26d9f7deb..c713b6cba12 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1,5 +1,6 @@ + * Copyright (C) 2012 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -617,6 +618,51 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable } } +/** + * Uncompress a file + * + * @param string $newfile file to uncompress + * @param stirng $typefile type of file + * @param string $dstdir destination dir + * @return int 0 if ok, >0 if ko + */ +function dol_uncompress($newfile,$typefile,$dstdir) +{ + global $conf; + $error=0; + $system=PHP_OS; + + //TODO: See best method for this + + if ($system=="Linux") + { + if ($typefile == 'application/x-gzip') + { + $prog= "tar -xzvf "; + } + elseif ($typefile == 'application/zip') + { + $prog= "unzip "; + } + else + { + $error=1; + } + } + else + { + $error=2; + } + $original_file=basename($_FILES["fileinstall"]["name"]); + $diruncom=$conf->admin->dir_temp.'/'.$original_file; + $ruta=$diruncom.'/'.$original_file; + chdir ($dstdir); + $command= $prog.$ruta; + exec($command); + + return $error; +} + /** * Remove a file or several files with a mask * diff --git a/htdocs/langs/ca_ES/admin.lang b/htdocs/langs/ca_ES/admin.lang index 7eb4bb0a57a..65f5d9bb2c9 100644 --- a/htdocs/langs/ca_ES/admin.lang +++ b/htdocs/langs/ca_ES/admin.lang @@ -266,6 +266,10 @@ FindPackageFromWebSite=Cercar el paquet que respon a la seva necessitat (per exe DownloadPackageFromWebSite=Descarregar el paquet des del lloc %s. UnpackPackageInDolibarrRoot=Descomprimir el paquet a la carpeta arrel de Dolibarr %s sobre els arxius existents (sense desplaçar o esborrar els existents, sota pena de perdre la seva configuració o els mòduls no oficials instal·lats) SetupIsReadyForUse=La instal·lació ha finalitzat i Dolibarr està disponible amb el nou component. +NotExistsDirect=No existeix el directori alternatiu.
+InfDirAlt=Des de la versió 3 és possible definir un directori root alternatiu, això li permet emmagatzemar en el mateix lloc mòduls i temes personalitzades.
Només cal crear un directori en l'arrel de Dolibarr (per exemple: custom).
+InfDirExample=
Seguidament es declara a l'arxiu conf.php:
$dolibarr_main_url_root_alt='http://miservidor/custom'
$dolibarr_main_document_root_alt='/directorio/de/dolibarr/htdocs/custom'
*Aquestes línies venen comentades amb un "#", per descomentar-les només cal retirar el caràcter. +YouCanSubmitFile=Seleccioneu mòdul: CurrentVersion=Versió actual de Dolibarr CallUpdatePage=Trucar a la pàgina d'actualització de l'estructura i dades de la base de dades %s. LastStableVersion=Última versió estable disponible diff --git a/htdocs/langs/ca_ES/errors.lang b/htdocs/langs/ca_ES/errors.lang index c11165ff8da..11d63394dda 100644 --- a/htdocs/langs/ca_ES/errors.lang +++ b/htdocs/langs/ca_ES/errors.lang @@ -105,6 +105,7 @@ ErrorBothFieldCantBeNegative=Els camps %s i %s no poden ser negatius ErrorNoActivatedBarcode=Cap tipus de codi de barres activat ErrorWebServerUserHasNotPermission=El compte d'execució del servidor web %s no disposa dels permisos per això ErrorNoActivatedBarcode=No hi ha activat cap tipus de codi de barres +ErrorOSSystem=La instal·lació en línia no suporta el seu sistema operatiu.
Instal·leu l'extensió manualment. # Warnings WarningSafeModeOnCheckExecDir=Atenció, està activada l'opció PHP safe_mode, la comanda ha d'estar dins d'un directori declarat dins del paràmetre php safe_mode_exec_dir. diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 03f3d7c4483..48b1c14a998 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -265,6 +265,10 @@ FindPackageFromWebSite=Find a package that provides feature you want (for exampl DownloadPackageFromWebSite=Download package. UnpackPackageInDolibarrRoot=Unpack package file into Dolibarr's root directory %s SetupIsReadyForUse=Install is finished and Dolibarr is ready to use with this new component. +NotExistsDirect=The alternative root directory is not defined.
+InfDirAlt=Since version 3 it is possible to define an alternative root directory.This allows you to store, same place, plug-ins and custom templates.
Just create a directory at the root of Dolibarr (eg: custom).
+InfDirExample=
Then declare it in the file conf.php
$dolibarr_main_url_root_alt='http://myserver/custom'
$dolibarr_main_document_root_alt='/path/of/dolibarr/htdocs/custom'
*These lines are commented with "#", to uncomment only remove the character. +YouCanSubmitFile=Select module: CurrentVersion=Dolibarr current version CallUpdatePage=Go to the page that updates the database structure and datas: %s. LastStableVersion=Last stable version diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index c5ddcf6a9c2..be3383cfb88 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -104,6 +104,7 @@ ErrorBadValueForCode=Bad value for security code. Try again with new value... ErrorBothFieldCantBeNegative=Fields %s and %s can't be both negative ErrorWebServerUserHasNotPermission=User account %s used to execute web server has no permission for that ErrorNoActivatedBarcode=No barcode type activated +ErrorOSSystem=The online installation does not support your operating system.
Install the component manually. # Warnings WarningSafeModeOnCheckExecDir=Warning, PHP option safe_mode is on so command must be stored inside a directory declared by php parameter safe_mode_exec_dir. diff --git a/htdocs/langs/es_ES/admin.lang b/htdocs/langs/es_ES/admin.lang index e9188192dd2..e9a2e4775cc 100644 --- a/htdocs/langs/es_ES/admin.lang +++ b/htdocs/langs/es_ES/admin.lang @@ -266,6 +266,12 @@ FindPackageFromWebSite=Buscar el paquete que responde a su necesidad (por ejempl DownloadPackageFromWebSite=Descargar el paquete desde el sitio %s. UnpackPackageInDolibarrRoot=Descomprimir el paquete en el directorio raíz de Dolibarr %s sobre los archivos existentes (sin desplazar o borrar los existentes, so pena de perder su configuración o los módulos no oficiales instalados) SetupIsReadyForUse=La instalación ha finalizado y Dolibarr está disponible con el nuevo componente. + +NotExistsDirect=No existe el directorio alternativo.
+InfDirAlt=Desde la versión 3 es posible definir un directorio root alternativo, esto le permite almacenar en el mismo lugar módulos y temas personalizados.
Basta con crear un directorio en el raíz de Dolibarr (por ejemplo: custom).
+InfDirExample=
Seguidamente se declara en el archivo conf.php:
$dolibarr_main_url_root_alt='http://miservidor/custom'
$dolibarr_main_document_root_alt='/directorio/de/dolibarr/htdocs/custom'
*Estas lineas vienen comentadas con un "#", para descomentarlas solo hay que retirar el caracter. +YouCanSubmitFile=Seleccione módulo: + CurrentVersion=Versión actual de Dolibarr CallUpdatePage=Llamar a la página de actualización de la estructura y datos de la base de datos %s. LastStableVersion=Última versión estable disponible diff --git a/htdocs/langs/es_ES/errors.lang b/htdocs/langs/es_ES/errors.lang index 0ec14146485..7abc87ae98d 100644 --- a/htdocs/langs/es_ES/errors.lang +++ b/htdocs/langs/es_ES/errors.lang @@ -105,6 +105,7 @@ ErrorBothFieldCantBeNegative=Los campos %s y %s no pueden ser negativos ErrorNoActivatedBarcode=Ningún tipo de código de barra activado ErrorWebServerUserHasNotPermission=La cuenta de ejecución del servidor web %s no dispone de los permisos para esto ErrorNoActivatedBarcode=No hay activado ningún tipo de código de barras +ErrorOSSystem=La instalación online no soporta su sistema operativo.
Instale la extensión manualmente. # Warnings WarningSafeModeOnCheckExecDir=Atención, está activada la opción PHP safe_mode, el comando deberá estar dentro de un directorio declarado dentro del parámetro php safe_mode_exec_dir. diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 9778fcc49a7..19199ccbf9f 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -266,6 +266,10 @@ FindPackageFromWebSite=Recherche le package qui répond à votre besoin (par exe DownloadPackageFromWebSite= Télécharger le package. UnpackPackageInDolibarrRoot= Décompresser le package dans le répertoire racine de Dolibarr %s par dessus les fichiers existants (sans déplacer ou effacer cet existant sous peine de perdre sa configuration ou les modules non officiels installés) SetupIsReadyForUse= L'installation est terminée et Dolibarr est prêt à être utilisé avec le nouveau composant. +NotExistsDirect=Il n'y a pas répertoire alternative.
+InfDirAlt=Depuis la version 3 est possible de définir un répertoire alternatif qui vous permet de stocker dans le même endroit les modules et thèmes personnalisés.
Il suffit de créer un répertoire à la racine de Dolibarr (par exemple: custom).
+InfDirExample=
Ensuite, declarons dans le fichier conf.php:
$dolibarr_main_url_root_alt='http://monserveur/custom'
$dolibarr_main_document_root_alt='/repertoire/de/dolibarr/htdocs/custom'
*Ces lignes sont commentées par "#" de décommenter suffit de supprimer le caractère. +YouCanSubmitFile=Sélectionner le module: CurrentVersion= Version en cours de Dolibarr CallUpdatePage= Appeler la page de l'outil de mise à jour de la structure et données de la base: %s. LastStableVersion= Dernière version stable disponible diff --git a/htdocs/langs/fr_FR/errors.lang b/htdocs/langs/fr_FR/errors.lang index ce85bd48f60..8a90d1d0e55 100644 --- a/htdocs/langs/fr_FR/errors.lang +++ b/htdocs/langs/fr_FR/errors.lang @@ -105,6 +105,7 @@ ErrorBadValueForCode=Mauvaise valeur saisie pour le code. Réessayez avec une no ErrorBothFieldCantBeNegative=Les champs %s et %s ne peuvent être tous deux négatifs ErrorWebServerUserHasNotPermission=Le compte d'execution du serveur web %s n'a pas les permissions pour cela ErrorNoActivatedBarcode=Aucun type de code bar activé +ErrorOSSystem=L'installation en ligne ne prend pas en charge votre OS.
Installez le composant manuellement. # Warnings WarningSafeModeOnCheckExecDir=Attention, l'option PHP safe_mode est active, la commande doit dont être dans un répertoire déclaré dans le paramètre php safe_mode_exec_dir.