dolibarr/htdocs/admin/tools/update.php

177 lines
5.7 KiB
PHP
Raw Normal View History

<?php
2012-04-16 11:07:09 +02:00
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
2012-12-30 15:13:49 +01:00
* Copyright (C) 2009-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2011-08-03 02:45:22 +02:00
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
2009-05-18 01:54:07 +02:00
* \file htdocs/admin/tools/update.php
* \brief Page to make a Dolibarr online upgrade
*/
2007-04-27 11:19:42 +02:00
require '../../main.inc.php';
include_once $dolibarr_main_document_root.'/core/lib/files.lib.php';
$langs->load("admin");
2007-04-27 11:19:42 +02:00
$langs->load("other");
2011-12-28 12:53:46 +01:00
if (! $user->admin) accessforbidden();
2007-04-27 11:19:42 +02:00
if (GETPOST('msg','alpha')) $message='<div class="error">'.GETPOST('msg','alpha').'</div>';
2007-04-27 11:19:42 +02:00
2011-10-14 00:09:22 +02:00
$urldolibarr='http://www.dolibarr.org/downloads/';
2010-06-05 01:00:57 +02:00
$urldolibarrmodules='http://www.dolistore.com/';
$urldolibarrthemes='http://www.dolistore.com/';
$dolibarrroot=preg_replace('/([\\/]+)$/i','',DOL_DOCUMENT_ROOT);
$dolibarrroot=preg_replace('/([^\\/]+)$/i','',$dolibarrroot);
2012-04-16 11:07:09 +02:00
$dolibarrdataroot=preg_replace('/([\\/]+)$/i','',DOL_DATA_ROOT);
2007-04-27 11:19:42 +02:00
/*
* Actions
*/
2007-04-27 11:19:42 +02:00
if (GETPOST('action','alpha')=='install')
{
$error=0;
$original_file=basename($_FILES["fileinstall"]["name"]);
$newfile=$conf->admin->dir_temp.'/'.$original_file.'/'.$original_file;
if (! $original_file)
{
$langs->load("Error");
$mesg = '<div class="warning">'.$langs->trans("ErrorFileRequired").'</div>';
$error++;
}
else
{
if (! preg_match('/\.zip/i',$original_file))
{
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFileMustBeADolibarrPackage",$original_file).'</div>';
$error++;
}
}
if (! $error)
{
@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']);
if ($result > 0)
{
$documentrootalt=DOL_DOCUMENT_ROOT.'/extensions';
$result=dol_uncompress($newfile,$documentrootalt);
2012-04-26 15:02:29 +02:00
if (! empty($result['error']))
{
2012-07-02 19:30:37 +02:00
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans($result['error'],$original_file).'</div>';
2012-04-30 16:08:34 +02:00
}
2012-04-26 15:02:29 +02:00
else
{
$mesg = '<div class="ok">'.$langs->trans("SetupIsReadyForUse").'</div>';
}
}
}
2007-04-27 11:19:42 +02:00
}
/*
* View
*/
$dirins=DOL_DOCUMENT_ROOT.'/extensions';
2012-07-02 19:30:37 +02:00
$dirins_ok=(is_dir($dirins));
$wikihelp='EN:Installation_-_Upgrade|FR:Installation_-_Mise_à_jour|ES:Instalación_-_Actualización';
2010-05-26 13:42:29 +02:00
llxHeader('',$langs->trans("Upgrade"),$wikihelp);
print_fiche_titre($langs->trans("Upgrade"),'','setup');
2008-02-11 17:34:55 +01:00
print $langs->trans("CurrentVersion").' : <b>'.DOL_VERSION.'</b><br>';
print $langs->trans("LastStableVersion").' : <b>'.$langs->trans("FeatureNotYetAvailable").'</b><br>';
print '<br>';
//dol_htmloutput_errors($mesg);
dol_htmloutput_mesg($mesg);
print $langs->trans("Upgrade").'<br>';
2008-02-11 17:34:55 +01:00
print '<hr>';
print $langs->trans("ThisIsProcessToFollow").'<br>';
print '<b>'.$langs->trans("StepNb",1).'</b>: ';
$fullurl='<a href="'.$urldolibarr.'" target="_blank">'.$urldolibarr.'</a>';
print $langs->trans("DownloadPackageFromWebSite",$fullurl).'<br>';
print '<b>'.$langs->trans("StepNb",2).'</b>: ';
print $langs->trans("UnpackPackageInDolibarrRoot",$dolibarrroot).'<br>';
print '<b>'.$langs->trans("StepNb",3).'</b>: ';
2012-04-16 11:07:09 +02:00
print $langs->trans("RemoveLock",$dolibarrdataroot.'/install.lock').'<br>';
2009-03-13 01:57:36 +01:00
print '<b>'.$langs->trans("StepNb",4).'</b>: ';
$fullurl='<a href="'.DOL_URL_ROOT.'/install/" target="_blank">'.DOL_URL_ROOT.'/install/</a>';
2008-02-11 17:34:55 +01:00
print $langs->trans("CallUpdatePage",$fullurl).'<br>';
2009-03-13 01:57:36 +01:00
print '<b>'.$langs->trans("StepNb",5).'</b>: ';
2012-04-16 11:07:09 +02:00
print $langs->trans("RestoreLock",$dolibarrdataroot.'/install.lock').'<br>';
print '<br>';
print '<br>';
2010-06-05 01:00:57 +02:00
$fullurl='<a href="'.$urldolibarrmodules.'" target="_blank">'.$urldolibarrmodules.'</a>';
print $langs->trans("AddExtensionThemeModuleOrOther").'<br>';
2008-02-11 17:34:55 +01:00
print '<hr>';
print $langs->trans("ThisIsProcessToFollow").'<br>';
print '<b>'.$langs->trans("StepNb",1).'</b>: ';
2010-06-05 01:00:57 +02:00
print $langs->trans("FindPackageFromWebSite",$fullurl).'<br>';
2008-02-11 17:34:55 +01:00
print '<b>'.$langs->trans("StepNb",2).'</b>: ';
2010-06-05 01:00:57 +02:00
print $langs->trans("DownloadPackageFromWebSite",$fullurl).'<br>';
2008-02-11 17:34:55 +01:00
print '<b>'.$langs->trans("StepNb",3).'</b>: ';
2010-06-05 01:00:57 +02:00
print $langs->trans("UnpackPackageInDolibarrRoot",$dolibarrroot).'<br>';
if (! empty($conf->global->MAIN_ONLINE_INSTALL_MODULE))
{
if ($dirins_ok)
{
print '<form enctype="multipart/form-data" method="POST" class="noborder" action="'.$_SERVER["PHP_SELF"].'" name="forminstall">';
print '<input type="hidden" name="action" value="install">';
print $langs->trans("YouCanSubmitFile").' <input type="file" name="fileinstall"> ';
print '<input type="submit" name="'.dol_escape_htmltag($langs->trans("Send")).'" class="button">';
print '</form>';
}
else
2012-07-02 19:30:37 +02:00
{
$message=info_admin($langs->trans("NotExistsDirect",$dirins).$langs->trans("InfDirAlt").$langs->trans("InfDirExample"));
print '<div class="warning">'.$message.'</div>';
}
}
else
{
2012-07-02 19:30:37 +02:00
print '<b>'.$langs->trans("StepNb",4).'</b>: ';
print $langs->trans("SetupIsReadyForUse").'<br>';
}
2007-04-27 11:19:42 +02:00
print '</form>';
2012-04-26 15:02:29 +02:00
if (! empty($result['return']))
{
print '<br>';
2012-04-26 15:02:29 +02:00
foreach($result['return'] as $value)
{
echo $value.'<br>';
}
}
llxFooter();
2012-04-16 11:07:09 +02:00
$db->close();
?>