--- /tmp/dsg/dolibarr/htdocs/admin/tools/github_19.0.3_dolibarr_export.php +++ /tmp/dsg/dolibarr/htdocs/admin/tools/client_dolibarr_export.php @@ -3 +3 @@ - * Copyright (C) 2006-2021 Regis Houssin + * Copyright (C) 2006-2018 Regis Houssin @@ -25 +24,0 @@ -// Load Dolibarr environment @@ -33,4 +32,4 @@ -$action = GETPOST('action', 'aZ09'); - -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$action = GETPOST('action', 'alpha'); + +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); @@ -38,10 +37,4 @@ -if (!$sortorder) { - $sortorder = "DESC"; -} -if (!$sortfield) { - $sortfield = "date"; -} -if (empty($page) || $page == -1) { - $page = 0; -} -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "date"; +if (empty($page) || $page == -1) { $page = 0; } +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -50 +43 @@ -if (!$user->admin) { +if (!$user->admin) @@ -52 +44,0 @@ -} @@ -59,2 +51,4 @@ -if ($action == 'deletefile') { - if (preg_match('/^backup\//', GETPOST('urlfile', 'alpha'))) { +if ($action == 'delete') +{ + if (preg_match('/^backup\//', GETPOST('urlfile', 'alpha'))) + { @@ -63,6 +57,5 @@ - if ($ret) { - setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); - } else { - setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); - } - } else { + if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); + else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); + } + else + { @@ -71,5 +64,2 @@ - if ($ret) { - setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); - } else { - setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); - } + if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); + else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); @@ -79 +68,0 @@ - @@ -135,3 +124 @@ -$title = $langs->trans("Backup"); - -print load_fiche_titre($title, '', 'title_setup'); +print load_fiche_titre($langs->trans("Backup"), '', 'title_setup'); @@ -140 +127 @@ -print '
'; +print '
'; @@ -149,2 +135,0 @@ -print ''; - @@ -153 +137,0 @@ -print ''; @@ -156,2 +139,0 @@ -print ''; - @@ -162,14 +144,10 @@ -$title = $langs->trans("BackupDumpWizard"); - -print load_fiche_titre($title); - -//print ''; -//print ''; -//print ''; -//print ''; -//print ''; - } - - // ID - print ''; - - // Date - print ''; - - print ''; + + print ''; - - print ''; - - print ''; + + print ''; + + print ''; - - if (!empty($arrayfields['e.prefix_session']['checked'])) { + if (!empty($arrayfields['e.user_agent']['checked'])) + { @@ -397,11 +268,15 @@ - print ''; - print ''; - } - - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } + print ''; + print ''; + } + + if (!empty($arrayfields['e.prefix_session']['checked'])) + { + print ''; + } + + print ''; @@ -413,5 +287,0 @@ - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre(''); - } - print_liste_field_titre("ID", $_SERVER["PHP_SELF"], "e.rowid", "", $param, '', $sortfield, $sortorder); @@ -423,8 +293,9 @@ - print_liste_field_titre("UserAgent", $_SERVER["PHP_SELF"], "e.user_agent", "", $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['e.prefix_session']['checked'])) { - print_liste_field_titre("SuffixSessionName", $_SERVER["PHP_SELF"], "e.prefix_session", "", $param, '', $sortfield, $sortorder); - } - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre(''); - } + if (!empty($arrayfields['e.user_agent']['checked'])) + { + print_liste_field_titre("UserAgent", $_SERVER["PHP_SELF"], "e.user_agent", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['e.prefix_session']['checked'])) + { + print_liste_field_titre("PrefixSession", $_SERVER["PHP_SELF"], "e.prefix_session", "", $param, '', $sortfield, $sortorder); + } + print_liste_field_titre(''); @@ -433 +304,2 @@ - while ($i < min($num, $limit)) { + while ($i < min($num, $limit)) + { @@ -438,6 +310,40 @@ - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; + + // Code + print ''; + + // IP + print ''; + + // Login + print ''; + + // Description + print ''; + + if (!empty($arrayfields['e.user_agent']['checked'])) + { + // User agent + print ''; - - // Date - print ''; - - // Code - print ''; - - // IP - print ''; - - // Login - print ''; - - // Description - $text = $langs->trans($obj->description); - $reg = array(); - if (InterfaceLogevents::isEventActionTextKey($obj->description)) { - $val = explode(' : ', $obj->description); - $text = $langs->trans($val[0], isset($val[1]) ? $val[1] : '', isset($val[2]) ? $val[2] : '', isset($val[3]) ? $val[3] : '', isset($val[4]) ? $val[4] : ''); - } - if (preg_match('/\((.*)\)(.*)/i', $obj->description, $reg)) { - $val = explode(',', $reg[1]); - $text = $langs->trans($val[0], isset($val[1]) ? $val[1] : '', isset($val[2]) ? $val[2] : '', isset($val[3]) ? $val[3] : '', isset($val[4]) ? $val[4] : ''); - if (!empty($reg[2])) { - $text .= $reg[2]; - } - } - print ''; - - // User agent - print ''; - - // Prefix - if (!empty($arrayfields['e.prefix_session']['checked'])) { - print ''; - } + // More informations + print ''; @@ -524,7 +372,4 @@ - if ($num == 0) { - $colspan = 8; - if ($usefilter) { - print ''; - } else { - print ''; - } + if ($num == 0) + { + if ($usefilter) print ''; + else print ''; @@ -537 +382,3 @@ -} else { +} +else +{ --- /tmp/dsg/dolibarr/htdocs/admin/tools/github_19.0.3_listsessions.php +++ /tmp/dsg/dolibarr/htdocs/admin/tools/client_listsessions.php @@ -25,5 +24,0 @@ -if (! defined('CSRFCHECK_WITH_TOKEN')) { - define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -} - -// Load Dolibarr environment @@ -33 +27,0 @@ - @@ -37 +31 @@ -if (!$user->admin) { +if (!$user->admin) @@ -39,3 +33,2 @@ -} - -$action = GETPOST('action', 'aZ09'); + +$action = GETPOST('action', 'alpha'); @@ -45,3 +38,4 @@ -if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; +if ($user->socid > 0) +{ + $action = ''; + $socid = $user->socid; @@ -51,2 +45,2 @@ -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -54,3 +48 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -60,6 +52,2 @@ -if (!$sortorder) { - $sortorder = "DESC"; -} -if (!$sortfield) { - $sortfield = "dateevent"; -} +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "dateevent"; @@ -73 +61,2 @@ -if ($action == 'confirm_purge' && $confirm == 'yes' && $user->admin) { +if ($action == 'confirm_purge' && $confirm == 'yes' && $user->admin) +{ @@ -78,2 +67,4 @@ -if ($action == 'confirm_lock' && $confirm == 'yes' && $user->admin) { - if (dolibarr_set_const($db, 'MAIN_ONLY_LOGIN_ALLOWED', $user->login, 'text', 1, 'Logon is restricted to a particular user', 0) < 0) { +if ($action == 'confirm_lock' && $confirm == 'yes' && $user->admin) +{ + if (dolibarr_set_const($db, 'MAIN_ONLY_LOGIN_ALLOWED', $user->login, 'text', 1, 'Logon is restricted to a particular user', 0) < 0) + { @@ -85,2 +76,4 @@ -if ($action == 'confirm_unlock' && $user->admin) { - if (dolibarr_del_const($db, 'MAIN_ONLY_LOGIN_ALLOWED', -1) < 0) { +if ($action == 'confirm_unlock' && $user->admin) +{ + if (dolibarr_del_const($db, 'MAIN_ONLY_LOGIN_ALLOWED', -1) < 0) + { @@ -117,6 +110,2 @@ -if ($openbasedir) { - print ''.$langs->trans("OpenBaseDir").': '.$openbasedir.'
'; -} -if ($suhosin) { - print ''.$langs->trans("SuhosinSessionEncrypt").': '.$suhosin.'
'; -} +if ($openbasedir) print ''.$langs->trans("OpenBaseDir").': '.$openbasedir.'
'; +if ($suhosin) print ''.$langs->trans("SuhosinSessionEncrypt").': '.$suhosin.'
'; @@ -125 +114,2 @@ -if ($action == 'purge') { +if ($action == 'purge') +{ @@ -128 +118,3 @@ -} elseif ($action == 'lock') { +} +elseif ($action == 'lock') +{ @@ -133 +125,2 @@ -if ($savehandler == 'files') { +if ($savehandler == 'files') +{ @@ -145 +138,2 @@ - foreach ($listofsessions as $key => $sessionentry) { + foreach ($listofsessions as $key => $sessionentry) + { @@ -153,5 +147,2 @@ - if ("$key" == session_id()) { - print $form->textwithpicto($key, $langs->trans("YourSession")); - } else { - print $key; - } + if ("$key" == session_id()) print $form->textwithpicto($key, $langs->trans("YourSession")); + else print $key; @@ -178 +169,2 @@ - if (count($listofsessions) == 0) { + if (count($listofsessions) == 0) + { @@ -182 +174,3 @@ -} else { +} +else +{ @@ -193,9 +187,14 @@ -if (!getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED')) { - print ''.$langs->trans("LockNewSessions").''; -} else { - print ''.$langs->trans("UnlockNewSessions").''; -} - -if ($savehandler == 'files') { - if (count($listofsessions)) { - print ''.$langs->trans("PurgeSessions").''; +if (empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) +{ + print ''.$langs->trans("LockNewSessions").''; +} +else +{ + print ''.$langs->trans("UnlockNewSessions").''; +} + +if ($savehandler == 'files') +{ + if (count($listofsessions)) + { + print ''.$langs->trans("PurgeSessions").''; --- /tmp/dsg/dolibarr/htdocs/admin/tools/github_19.0.3_purge.php +++ /tmp/dsg/dolibarr/htdocs/admin/tools/client_purge.php @@ -24,5 +23,0 @@ -if (! defined('CSRFCHECK_WITH_TOKEN')) { - define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -} - -// Load Dolibarr environment @@ -34 +29,4 @@ -$action = GETPOST('action', 'aZ09'); +if (!$user->admin) + accessforbidden(); + +$action = GETPOST('action', 'alpha'); @@ -37 +35 @@ -$nbsecondsold = GETPOSTINT('nbsecondsold'); + @@ -41,2 +39,3 @@ -if (isModEnabled('syslog')) { - $filelog = getDolGlobalString('SYSLOG_FILE'); +if (!empty($conf->syslog->enabled)) +{ + $filelog = $conf->global->SYSLOG_FILE; @@ -44,5 +42,0 @@ -} - -// Security -if (!$user->admin) { - accessforbidden(); @@ -55,11 +49,12 @@ - -if ($action == 'purge' && !preg_match('/^confirm/i', $choice) && ($choice != 'allfiles' || $confirm == 'yes')) { - // Increase limit of time. Works only if we are not in safe mode - $ExecTimeLimit = 600; - if (!empty($ExecTimeLimit)) { - $err = error_reporting(); - error_reporting(0); // Disable all errors - //error_reporting(E_ALL); - @set_time_limit($ExecTimeLimit); // Need more than 240 on Windows 7/64 - error_reporting($err); - } +if ($action == 'purge' && !preg_match('/^confirm/i', $choice) && ($choice != 'allfiles' || $confirm == 'yes')) +{ + // Increase limit of time. Works only if we are not in safe mode + $ExecTimeLimit = 600; + if (!empty($ExecTimeLimit)) + { + $err = error_reporting(); + error_reporting(0); // Disable all errors + //error_reporting(E_ALL); + @set_time_limit($ExecTimeLimit); // Need more than 240 on Windows 7/64 + error_reporting($err); + } @@ -69,2 +64 @@ - - $result = $utils->purgeFiles($choice, $nbsecondsold); + $result = $utils->purgeFiles($choice); @@ -99,2 +93,3 @@ -if (isModEnabled('syslog')) { - print 'syslog->enabled)) +{ + print 'admin && preg_match('/^dolibarr.*\.log$/', basename($filelog))) { - $filelogparam = ''.$filelog.''; + if ($user->admin && preg_match('/^dolibarr.*\.log$/', basename($filelog))) + { + $filelogparam = ''.$filelog.''; @@ -108,3 +104 @@ - $desc = $langs->trans("PurgeDeleteLogFile", '{filelogparam}'); - $desc = str_replace('{filelogparam}', $filelogparam, $desc); - print '> '; + print '> '.$langs->trans("PurgeDeleteLogFile", $filelogparam); @@ -114 +108 @@ -print '

'; +print '> '.$langs->trans("PurgeDeleteTemporaryFiles").'

'; @@ -118 +112 @@ -print ''; -print '
'; -if (getDolGlobalInt('MAIN_PURGE_ACCEPT_NBSECONDSOLD')) { - print 'NbSecondsOld = '; -} +print '> '.$langs->trans("PurgeDeleteAllFilesInDocumentsDir", $dolibarr_main_data_root).'
'; + @@ -130 +121 @@ - print '
'; + print '
'; @@ -135 +126,2 @@ -if (preg_match('/^confirm/i', $choice)) { +if (preg_match('/^confirm/i', $choice)) +{ @@ -138 +130 @@ - print $form->formconfirm($_SERVER["PHP_SELF"].'?choice=allfiles&nbsecondsold='.$nbsecondsold, $langs->trans('Purge'), $langs->trans('ConfirmPurge').img_warning().' ', 'purge', $formquestion, 'no', 2); + print $form->formconfirm($_SERVER["PHP_SELF"].'?choice=allfiles', $langs->trans('Purge'), $langs->trans('ConfirmPurge').img_warning().' ', 'purge', $formquestion, 'no', 2); --- /tmp/dsg/dolibarr/htdocs/admin/tools/github_19.0.3_update.php +++ /tmp/dsg/dolibarr/htdocs/admin/tools/client_update.php @@ -25,5 +24,0 @@ -if (! defined('CSRFCHECK_WITH_TOKEN')) { - define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -} - -// Load Dolibarr environment @@ -38 +33 @@ -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); @@ -40,3 +35 @@ -if (!$user->admin) { - accessforbidden(); -} +if (!$user->admin) accessforbidden(); @@ -62,2 +55,3 @@ -if ($action == 'getlastversion') { - $result = getURLContent('https://sourceforge.net/projects/dolibarr/rss'); +if ($action == 'getlastversion') +{ + $result = getURLContent('http://sourceforge.net/projects/dolibarr/rss'); @@ -65,11 +59 @@ - if (function_exists('simplexml_load_string')) { - if (LIBXML_VERSION < 20900) { - // Avoid load of external entities (security problem). - // Required only if LIBXML_VERSION < 20900 - libxml_disable_entity_loader(true); - } - - $sfurl = simplexml_load_string($result['content'], 'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET); - } else { - $sfurl = 'xml_not_available'; - } + $sfurl = simplexml_load_string($result['content']); @@ -92 +76,2 @@ -if (function_exists('curl_init')) { +if (function_exists('curl_init')) +{ @@ -95,5 +80,4 @@ - if ($action == 'getlastversion') { - if ($sfurl == 'xml_not_available') { - $langs->load("errors"); - print $langs->trans("LastStableVersion").' : '.$langs->trans("ErrorFunctionNotAvailableInPHP", 'simplexml_load_string').'
'; - } elseif ($sfurl) { + if ($action == 'getlastversion') + { + if ($sfurl) + { @@ -101 +85,2 @@ - while (!empty($sfurl->channel[0]->item[$i]->title) && $i < 10000) { + while (!empty($sfurl->channel[0]->item[$i]->title) && $i < 10000) + { @@ -103 +88,2 @@ - if (preg_match('/([0-9]+\.([0-9\.]+))/', $title, $reg)) { + if (preg_match('/([0-9]+\.([0-9\.]+))/', $title, $reg)) + { @@ -108,3 +94 @@ - if (versioncompare($newversionarray, $versionarray) > 0) { - $version = $newversion; - } + if (versioncompare($newversionarray, $versionarray) > 0) $version = $newversion; @@ -117 +101,3 @@ - } else { + } + else + { @@ -120,2 +106,4 @@ - } else { - print $langs->trans("LastStableVersion").' : '.$langs->trans("Check").'
'; + } + else + { + print $langs->trans("LastStableVersion").' : '.$langs->trans("Check").'
'; @@ -133,2 +121,2 @@ -$fullurl = ''.$urldolibarr.''; -print str_replace('{s}', $fullurl, $langs->trans("DownloadPackageFromWebSite", '{s}')).'
'; +$fullurl = ''.$urldolibarr.''; +print $langs->trans("DownloadPackageFromWebSite", $fullurl).'
'; @@ -136 +124 @@ -print str_replace('{s}', $dolibarrroot, $langs->trans("UnpackPackageInDolibarrRoot", '{s}')).'
'; +print $langs->trans("UnpackPackageInDolibarrRoot", $dolibarrroot).'
'; @@ -140,2 +128,2 @@ -$fullurl = ''.DOL_URL_ROOT.'/install/'; -print str_replace('{s}', $fullurl, $langs->trans("CallUpdatePage", '{s}')).'
'; +$fullurl = ''.DOL_URL_ROOT.'/install/'; +print $langs->trans("CallUpdatePage", $fullurl).'
'; @@ -154,3 +142,2 @@ -$texttoshow = $langs->trans("GoModuleSetupArea", DOL_URL_ROOT.'/admin/modules.php?mode=deploy', '{s2}'); -$texttoshow = str_replace('{s2}', img_picto('', 'tools', 'class="pictofixedwidth"').$langs->transnoentities("Home").' - '.$langs->transnoentities("Setup").' - '.$langs->transnoentities("Modules"), $texttoshow); -print $texttoshow; + +print $langs->trans("GoModuleSetupArea", DOL_URL_ROOT.'/admin/modules.php?mode=deploy', $langs->transnoentities("Home").' - '.$langs->transnoentities("Setup").' - '.$langs->transnoentities("Modules"));
'; -print ''.$langs->trans("DatabaseName").' : '.$dolibarr_main_db_name.'

'; -//print '
'; - -print ''; - +print load_fiche_titre($title ? $title : $langs->trans("BackupDumpWizard")); + +print '
'; +print ''; +print ''; +print ''; +print ''; +print '
'; +print $langs->trans("DatabaseName").' : '.$dolibarr_main_db_name.'
'; +print '
'; +print ''; @@ -177 +155 @@ -print ''; - -print ''; -print ''; -//print '
'; +print ''; @@ -182,7 +160,7 @@ - print '
'; - print ''; - print '
'; - print '
'; - print '
'; - print ''; - print '
'; + print '
'; + print ''; + print '
'; + print '
'; + print '
'; + print ''; + print '
'; @@ -190,3 +168,3 @@ - print '
'; - print ''; - print '
'; + print '
'; + print ''; + print '
'; @@ -194 +172 @@ - print 'No method available with database '.$label; + print 'No method available with database '.$label; @@ -200,33 +178,4 @@ -print '
'; - -print '
'; -print img_picto('', 'setup', 'class="pictofixedwidth"').''.$langs->trans("ShowAdvancedOptions").'...'; -print '
'; - -print ''; - - -print '
'; + + +print '
'; @@ -234,45 +183,47 @@ - print "\n"; - print '
'; - - print '
'.$langs->trans("FullPathToMysqldumpCommand").''; - if (!getDolGlobalString('SYSTEMTOOLS_MYSQLDUMP')) { - $fullpathofmysqldump = $db->getPathOfDump(); - } else { - $fullpathofmysqldump = $conf->global->SYSTEMTOOLS_MYSQLDUMP; - } - print ''; - print '
'; - - print '
'; - print '
'.$langs->trans("ExportOptions").''; - - if (getDolGlobalString('MYSQL_OLD_OPTION_DISABLE_FK')) { - print '
'; - print ''; - print ''; - print '
'; - } - - print ''; - - print ''; - print '

'; - - print '
'; - print ''; - print ''; - print '
'; - - print ''; - print '
'; + + print '
'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print '
'; + + print '
'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + + print ''; + print ''; + print '
'; + + print ''; + print ''; + print '
'; + + print ''; + print ''; + print '
'; + + print ''; + print ''; + print '
'; + + print ''; + print ''; + print '
'; + + print ''; + print ''; + print '
'; + + print '
'; + print '
'; + print "\n"; + print '
'; + print ''.$langs->trans("MySqlExportParameters").''; + print '
'; + print ''.$langs->trans("ExportOptions").''; + print '
'; + print ''; + print ''; + + print '
'; + if (!empty($conf->global->MYSQL_OLD_OPTION_DISABLE_FK)) { + print '
'; + print ''; + print ''; + print '
'; + } + print '
'; + + print '
'; + print '
'.$langs->trans('ExportStructure').''; + print ''; + print ''; + print '
'; + print '
'; + + print '
'; + print '
'; + print ''.$langs->trans("Datas").''; + + print ''; + print ''; + print '
'; + + print ''; + print ''; + print '
'; + + print ''; + print ''; + print '
'; + + print ''; + print ''; + print '
'; + + print '
'; + print '
'; @@ -410,45 +335,45 @@ - print "\n"; - print '
'; - - - print '
'.$langs->trans("FullPathToPostgreSQLdumpCommand").''; - if (!getDolGlobalString('SYSTEMTOOLS_POSTGRESQLDUMP')) { - $fullpathofpgdump = $db->getPathOfDump(); - } else { - $fullpathofpgdump = $conf->global->SYSTEMTOOLS_POSTGRESQLDUMP; - } - print '
'; - print ''; - print '
'; - - print '
'; - print '
'; - print ''.$langs->trans("ExportOptions").''; - print ''; - print ''; - print '
'; - print ''; - print '
'; - print '
'; - print '
'; - print ''; - print ''; - print ''; - print ''; - print '
'; - print '
'; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - print '
'; - print '
'; + print "\n"; + print '
'.$langs->trans("PostgreSqlExportParameters").''; + + print '
'.$langs->trans("FullPathToPostgreSQLdumpCommand"); + if (empty($conf->global->SYSTEMTOOLS_POSTGRESQLDUMP)) { + $fullpathofpgdump = $db->getPathOfDump(); + } + else + { + $fullpathofpgdump = $conf->global->SYSTEMTOOLS_POSTGRESQLDUMP; + } + print '
'; + print '
'; + + print '
'; + print '
'; + print ''.$langs->trans("ExportOptions").''; + print ''; + print ''; + print '
'; + print ''; + print '
'; + print '
'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print '
'; + print '
'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print '
'; + print '
'; @@ -463,2 +387,0 @@ - - @@ -468 +391 @@ -print ''; +print ''; @@ -484 +407 @@ -$file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.dol_print_date(dol_now('gmt'), "dayhourlogsmall", 'tzuser').'.'.$ext; +$file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.strftime("%Y%m%d%H%M").'.'.$ext; @@ -503,4 +426,4 @@ - $compression['bz'] = array( - 'function' => 'bzopen', - 'id' => 'radio_compression_bzip', - 'label' => $langs->trans("Bzip2") + $compression['bz'] = array( + 'function' => 'bzopen', + 'id' => 'radio_compression_bzip', + 'label' => $langs->trans("Bzip2") @@ -508,11 +431,8 @@ - $compression['zstd'] = array( - 'function' => 'zstd_compress', - 'id' => 'radio_compression_zstd', - 'label' => $langs->trans("Zstd") - ); - $compression['none'] = array( - 'function' => '', - 'id' => 'radio_compression_none', - 'label' => $langs->trans("None") - ); -} else { + $compression['none'] = array( + 'function' => '', + 'id' => 'radio_compression_none', + 'label' => $langs->trans("None") + ); +} +else +{ @@ -538 +458,2 @@ -foreach ($compression as $key => $val) { +foreach ($compression as $key => $val) +{ @@ -542,3 +463 @@ - if ($key == 'gz') { - $checked = ' checked'; - } + if ($key == 'gz') $checked = ' checked'; @@ -547 +466,3 @@ - } else { + } + else + { @@ -565,12 +486,14 @@ -print '
'; -print '
'; - -if (!empty($_SESSION["commandbackuplastdone"])) { - print '
'.$langs->trans("RunCommandSummary").':
'."\n"; - print '
'."\n"; - print '
'; - - //print $paramclear; - - // Now show result - print ''.$langs->trans("BackupResult").': '; +print ''; +print '
'; +print '
'; + +if (!empty($_SESSION["commandbackuplastdone"])) +{ + print '
'.$langs->trans("RunCommandSummary").':
'."\n"; + print '
'."\n"; + print '
'; + + //print $paramclear; + + // Now show result + print ''.$langs->trans("BackupResult").': '; @@ -583,2 +506,3 @@ -if (!empty($_SESSION["commandbackuptorun"])) { - print '
'.$langs->trans("YouMustRunCommandFromCommandLineAfterLoginToUser", $dolibarr_main_db_user, $dolibarr_main_db_user).':
'."\n"; +if (!empty($_SESSION["commandbackuptorun"])) +{ + print '
'.$langs->trans("YouMustRunCommandFromCommandLineAfterLoginToUser", $dolibarr_main_db_user, $dolibarr_main_db_user).':
'."\n"; @@ -598,2 +522,2 @@ -//print '
'; +print '
'; @@ -604,6 +528,8 @@ -print '
'; - -$filearray = dol_dir_list($conf->admin->dir_output.'/backup', 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ? SORT_ASC : SORT_DESC), 1); -$result = $formfile->list_of_documents($filearray, null, 'systemtools', '', 1, 'backup/', 1, 0, $langs->trans("NoBackupFileAvailable"), 0, $langs->trans("PreviousDumpFiles"), '', 0, -1, '', '', 'ASC', 1, 0, -1, 'style="height:250px; overflow: auto;"'); -print '
'; - +print '
'; +print '
'; + +$filearray = dol_dir_list($conf->admin->dir_output.'/backup', 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ?SORT_ASC:SORT_DESC), 1); +$result = $formfile->list_of_documents($filearray, null, 'systemtools', '', 1, 'backup/', 1, 0, $langs->trans("NoBackupFileAvailable"), 0, $langs->trans("PreviousDumpFiles")); +print '
'; + +print '
'; @@ -615 +540,0 @@ -$title = $langs->trans("BackupZipWizard"); @@ -627 +551,0 @@ -print ''; @@ -630 +553,0 @@ -print ''; @@ -634,3 +557,3 @@ -print load_fiche_titre($title); - -print '
'; +print load_fiche_titre($title ? $title : $langs->trans("BackupZipWizard")); + +print '
'; @@ -639 +562 @@ -$file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.dol_print_date(dol_now('gmt'), "dayhourlogsmall", 'tzuser'); +$file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.strftime("%Y%m%d%H%M"); @@ -655,15 +578,17 @@ -foreach ($filecompression as $key => $val) { - if (!$val['function'] || function_exists($val['function'])) { // Enabled export format - $checked = ''; - if ($key == 'gz') { - $checked = ' checked'; - } - print ''; - print ' '; - } else { // Disabled export format - print ''; - print ' '; - print ' ('.$langs->trans("NotAvailable").')'; - } - print '     '; - $i++; +foreach ($filecompression as $key => $val) +{ + if (!$val['function'] || function_exists($val['function'])) // Enabled export format + { + $checked = ''; + if ($key == 'gz') $checked = ' checked'; + print ''; + print ' '; + } + else // Disabled export format + { + print ''; + print ' '; + print ' ('.$langs->trans("NotAvailable").')'; + } + print '     '; + $i++; @@ -683,6 +608,8 @@ -print '
'; - -$filearray = dol_dir_list($conf->admin->dir_output.'/documents', 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ? SORT_ASC : SORT_DESC), 1); -$result = $formfile->list_of_documents($filearray, null, 'systemtools', '', 1, 'documents/', 1, 0, $langs->trans("NoBackupFileAvailable"), 0, $langs->trans("PreviousArchiveFiles"), '', 0, -1, '', '', 'ASC', 1, 0, -1, 'style="height:250px; overflow: auto;"'); -print '
'; - +print '
'; +print '
'; + +$filearray = dol_dir_list($conf->admin->dir_output.'/documents', 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ?SORT_ASC:SORT_DESC), 1); +$result = $formfile->list_of_documents($filearray, null, 'systemtools', '', 1, 'documents/', 1, 0, $langs->trans("NoBackupFileAvailable"), 0, $langs->trans("PreviousArchiveFiles")); +print '
'; + +print '
'; @@ -693,2 +619,0 @@ - -print '
'; --- /tmp/dsg/dolibarr/htdocs/admin/tools/github_19.0.3_dolibarr_import.php +++ /tmp/dsg/dolibarr/htdocs/admin/tools/client_dolibarr_import.php @@ -2 +2 @@ -/* Copyright (C) 2006-2021 Laurent Destailleur +/* Copyright (C) 2006-2012 Laurent Destailleur @@ -25,5 +24,0 @@ -if (! defined('CSRFCHECK_WITH_TOKEN')) { - define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -} - -// Load Dolibarr environment @@ -35 +30 @@ -if (!$user->admin) { +if (!$user->admin) @@ -37 +31,0 @@ -} @@ -67,6 +61,2 @@ - if ($label == 'MySQL') { - print 'jQuery("#radio_dump_mysql").click();'; - } - if ($label == 'PostgreSQL') { - print 'jQuery("#radio_dump_postgresql").click();'; - } + if ($label == 'MySQL') print 'jQuery("#radio_dump_mysql").click();'; + if ($label == 'PostgreSQL') print 'jQuery("#radio_dump_postgresql").click();'; @@ -80 +70 @@ -print '
'; +print '
'; @@ -89 +78,0 @@ -print ''; @@ -91 +79,0 @@ -print ''; @@ -100 +87,0 @@ -print ''; @@ -102 +88,0 @@ -print ''; @@ -113,19 +99,24 @@ - -
- /> - -
- -
- /> - -
- + +
+ /> + +
+ +
+ /> + +
+ @@ -141,19 +132,17 @@ -if (in_array($type, array('mysql', 'mysqli'))) { - print '
'; - print ''.$langs->trans('RestoreMySQL').''; - print '
'; - // Parameteres execution - $command = $db->getPathOfRestore(); - if (preg_match("/\s/", $command)) { - $command = $command = escapeshellarg($command); // Use quotes on command - } - - $param = $dolibarr_main_db_name; - $param .= " -h ".$dolibarr_main_db_host; - if (!empty($dolibarr_main_db_port)) { - $param .= " -P ".$dolibarr_main_db_port; - } - $param .= " -u ".$dolibarr_main_db_user; - $paramcrypted = $param; - $paramclear = $param; - if (!empty($dolibarr_main_db_pass)) { +if (in_array($type, array('mysql', 'mysqli'))) +{ + print '
'; + print ''.$langs->trans('RestoreMySQL').''; + print '
'; + // Parameteres execution + $command = $db->getPathOfRestore(); + if (preg_match("/\s/", $command)) $command = $command = escapeshellarg($command); // Use quotes on command + + $param = $dolibarr_main_db_name; + $param .= " -h ".$dolibarr_main_db_host; + if (!empty($dolibarr_main_db_port)) $param .= " -P ".$dolibarr_main_db_port; + $param .= " -u ".$dolibarr_main_db_user; + $paramcrypted = $param; + $paramclear = $param; + if (!empty($dolibarr_main_db_pass)) + { @@ -164,41 +153 @@ - echo $langs->trans("ImportMySqlDesc"); - print '
'; - print '
'; - print ajax_autoselect('restorecommand'); - - if (empty($_GET["showpass"]) && $dolibarr_main_db_pass) { - print '
'.$langs->trans("UnHidePassword").''; - } - //else print '
'.$langs->trans("HidePassword").''; - print '
'; - print '
'; -} elseif (in_array($type, array('pgsql'))) { - print '
'; - print 'Restore PostgreSQL'; - print '
'; - // Parameteres execution - $command = $db->getPathOfRestore(); - if (preg_match("/\s/", $command)) { - $command = $command = escapeshellarg($command); // Use quotes on command - } - - $param = " -d ".$dolibarr_main_db_name; - $param .= " -h ".$dolibarr_main_db_host; - if (!empty($dolibarr_main_db_port)) { - $param .= " -p ".$dolibarr_main_db_port; - } - $param .= " -U ".$dolibarr_main_db_user; - $paramcrypted = $param; - $paramclear = $param; - /*if (!empty($dolibarr_main_db_pass)) - { - $paramcrypted.=" -p".preg_replace('/./i','*',$dolibarr_main_db_pass); - $paramclear.=" -p".$dolibarr_main_db_pass; - }*/ - $paramcrypted .= " -W"; - $paramclear .= " -W"; - // With psql: - $paramcrypted .= " -f"; - $paramclear .= " -f"; - - echo $langs->trans("ImportPostgreSqlDesc"); + echo $langs->trans("ImportMySqlDesc"); @@ -206 +155 @@ - print '
'; + print '
'; @@ -208,7 +157,42 @@ - //if (empty($_GET["showpass"]) && $dolibarr_main_db_pass) print '
'.$langs->trans("UnHidePassword").''; - //else print '
'.$langs->trans("HidePassword").''; - print '
'; - - print '
'; - - print '
'; + + if (empty($_GET["showpass"]) && $dolibarr_main_db_pass) { + print '
'.$langs->trans("UnHidePassword").''; + } + //else print '
'.$langs->trans("HidePassword").''; + print '
'; + print '
'; +} +elseif (in_array($type, array('pgsql'))) +{ + print '
'; + print 'Restore PostgreSQL'; + print '
'; + // Parameteres execution + $command = $db->getPathOfRestore(); + if (preg_match("/\s/", $command)) $command = $command = escapeshellarg($command); // Use quotes on command + + $param = " -d ".$dolibarr_main_db_name; + $param .= " -h ".$dolibarr_main_db_host; + if (!empty($dolibarr_main_db_port)) $param .= " -p ".$dolibarr_main_db_port; + $param .= " -U ".$dolibarr_main_db_user; + $paramcrypted = $param; + $paramclear = $param; + /*if (! empty($dolibarr_main_db_pass)) + { + $paramcrypted.=" -p".preg_replace('/./i','*',$dolibarr_main_db_pass); + $paramclear.=" -p".$dolibarr_main_db_pass; + }*/ + $paramcrypted .= " -W"; + $paramclear .= " -W"; + // With psql: + $paramcrypted .= " -f"; + $paramclear .= " -f"; + + echo $langs->trans("ImportPostgreSqlDesc"); + print '
'; + print '
'; + print ajax_autoselect('restorecommand'); + //if (empty($_GET["showpass"]) && $dolibarr_main_db_pass) print '
'.$langs->trans("UnHidePassword").''; + //else print '
'.$langs->trans("HidePassword").''; + print '
'; + print '
'; --- /tmp/dsg/dolibarr/htdocs/admin/tools/github_19.0.3_export.php +++ /tmp/dsg/dolibarr/htdocs/admin/tools/client_export.php @@ -5 +4,0 @@ - * Copyright (C) 2021 Regis Houssin @@ -7,13 +6,13 @@ - * 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 - * along with this program. If not, see . - */ +* 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 +* along with this program. If not, see . +*/ @@ -26 +24,0 @@ -// Load Dolibarr environment @@ -35 +33 @@ -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); @@ -38 +36 @@ -$file = dol_sanitizeFileName(GETPOST('filename_template', 'alpha')); +$file = GETPOST('filename_template', 'alpha'); @@ -41,3 +39,3 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); @@ -45,3 +43 @@ -if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { - $page = 0; -} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action @@ -49,9 +45,10 @@ -if (!$sortorder) { - $sortorder = "DESC"; -} -if (!$sortfield) { - $sortfield = "date"; -} - -if (!$user->admin) { - accessforbidden(); +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "date"; + +if (!$user->admin) accessforbidden(); + +if ($file && !$what) +{ + //print DOL_URL_ROOT.'/dolibarr_export.php'; + header("Location: ".DOL_URL_ROOT.'/admin/tools/dolibarr_export.php?msg='.urlencode($langs->trans("ErrorFieldRequired", $langs->transnoentities("ExportMethod"))).(GETPOST('page_y', 'int') ? '&page_y='.GETPOST('page_y', 'int') : '')); + exit; @@ -61,2 +57,0 @@ - -$utils = new Utils($db); @@ -69,8 +64,3 @@ -if ($file && !$what) { - //print DOL_URL_ROOT.'/dolibarr_export.php'; - header("Location: ".DOL_URL_ROOT.'/admin/tools/dolibarr_export.php?msg='.urlencode($langs->trans("ErrorFieldRequired", $langs->transnoentities("ExportMethod"))).(GETPOST('page_y', 'int') ? '&page_y='.GETPOST('page_y', 'int') : '')); - exit; -} - -if ($action == 'delete') { - $file = $conf->admin->dir_output.'/'.dol_sanitizeFileName(GETPOST('urlfile')); +if ($action == 'delete') +{ + $file = $conf->admin->dir_output.'/'.GETPOST('urlfile'); @@ -78,5 +68,2 @@ - if ($ret) { - setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); - } else { - setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); - } + if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); + else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); @@ -84,0 +72,5 @@ + + +/* + * View + */ @@ -91,7 +83,8 @@ -$ExecTimeLimit = 600; // Set it to 0 to not use a forced time limit -if (!empty($ExecTimeLimit)) { - $err = error_reporting(); - error_reporting(0); // Disable all errors - //error_reporting(E_ALL); - @set_time_limit($ExecTimeLimit); // Need more than 240 on Windows 7/64 - error_reporting($err); +$ExecTimeLimit = 600; +if (!empty($ExecTimeLimit)) +{ + $err = error_reporting(); + error_reporting(0); // Disable all errors + //error_reporting(E_ALL); + @set_time_limit($ExecTimeLimit); // Need more than 240 on Windows 7/64 + error_reporting($err); @@ -100,3 +93,13 @@ -if (!empty($MemoryLimit)) { - @ini_set('memory_limit', $MemoryLimit); -} +if (!empty($MemoryLimit)) +{ + @ini_set('memory_limit', $MemoryLimit); +} + +$form = new Form($db); +$formfile = new FormFile($db); + +//$help_url='EN:Backups|FR:Sauvegardes|ES:Copias_de_seguridad'; +//llxHeader('','',$help_url); + +//print load_fiche_titre($langs->trans("Backup"),'','title_setup'); + @@ -116 +119 @@ -$lowmemorydump = GETPOSTISSET("lowmemorydump") ? GETPOST("lowmemorydump") : getDolGlobalString('MAIN_LOW_MEMORY_DUMP'); +$utils = new Utils($db); @@ -120,26 +123,28 @@ -if ($what == 'mysql') { - $cmddump = GETPOST("mysqldump", 'none'); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg - $cmddump = dol_sanitizePathName($cmddump); - - if (!empty($dolibarr_main_restrict_os_commands)) { - $arrayofallowedcommand = explode(',', $dolibarr_main_restrict_os_commands); - $arrayofallowedcommand = array_map('trim', $arrayofallowedcommand); - dol_syslog("Command are restricted to ".$dolibarr_main_restrict_os_commands.". We check that one of this command is inside ".$cmddump); - $basenamecmddump = basename(str_replace('\\', '/', $cmddump)); - if (!in_array($basenamecmddump, $arrayofallowedcommand)) { // the provided command $cmddump must be an allowed command - $langs->load("errors"); - $errormsg = $langs->trans('CommandIsNotInsideAllowedCommands'); - $errormsg .= '
'.$langs->trans('ErrorCheckTheCommandInsideTheAdvancedOptions'); - } - } - - if (!$errormsg && $cmddump) { - dolibarr_set_const($db, 'SYSTEMTOOLS_MYSQLDUMP', $cmddump, 'chaine', 0, '', $conf->entity); - } - - if (!$errormsg) { - $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file, 0, 0, $lowmemorydump); - $errormsg = $utils->error; - $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; - $_SESSION["commandbackuptorun"] = $utils->result['commandbackuptorun']; - } +if ($what == 'mysql') +{ + $cmddump = GETPOST("mysqldump"); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg + $cmddump = dol_sanitizePathName($cmddump); + + if (!empty($dolibarr_main_restrict_os_commands)) + { + $arrayofallowedcommand = explode(',', $dolibarr_main_restrict_os_commands); + dol_syslog("Command are restricted to ".$dolibarr_main_restrict_os_commands.". We check that one of this command is inside ".$cmddump); + $basenamecmddump = basename($cmddump); + if (!in_array($basenamecmddump, $arrayofallowedcommand)) // the provided command $cmddump must be an allowed command + { + $errormsg = $langs->trans('CommandIsNotInsideAllowedCommands'); + } + } + + if (!$errormsg && $cmddump) + { + dolibarr_set_const($db, 'SYSTEMTOOLS_MYSQLDUMP', $cmddump, 'chaine', 0, '', $conf->entity); + } + + if (!$errormsg) + { + $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file); + $errormsg = $utils->error; + $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; + $_SESSION["commandbackuptorun"] = $utils->result['commandbackuptorun']; + } @@ -149,6 +154,7 @@ -if ($what == 'mysqlnobin') { - $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file, 0, 0, $lowmemorydump); - - $errormsg = $utils->error; - $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; - $_SESSION["commandbackuptorun"] = $utils->result['commandbackuptorun']; +if ($what == 'mysqlnobin') +{ + $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file); + + $errormsg = $utils->error; + $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; + $_SESSION["commandbackuptorun"] = $utils->result['commandbackuptorun']; @@ -158,6 +164,46 @@ -if ($what == 'postgresql') { - $cmddump = GETPOST("postgresqldump", 'none'); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg - $cmddump = dol_sanitizePathName($cmddump); - - /* Not required, the command is output on screen but not ran for pgsql - if (!empty($dolibarr_main_restrict_os_commands)) +if ($what == 'postgresql') +{ + $cmddump = GETPOST("postgresqldump"); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg + $cmddump = dol_sanitizePathName($cmddump); + + /* Not required, the command is output on screen but not ran for pgsql + if (! empty($dolibarr_main_restrict_os_commands)) + { + $arrayofallowedcommand=explode(',', $dolibarr_main_restrict_os_commands); + dol_syslog("Command are restricted to ".$dolibarr_main_restrict_os_commands.". We check that one of this command is inside ".$cmddump); + $basenamecmddump=basename($cmddump); + if (! in_array($basenamecmddump, $arrayofallowedcommand)) // the provided command $cmddump must be an allowed command + { + $errormsg=$langs->trans('CommandIsNotInsideAllowedCommands'); + } + } */ + + if (!$errormsg && $cmddump) + { + dolibarr_set_const($db, 'SYSTEMTOOLS_POSTGRESQLDUMP', $cmddump, 'chaine', 0, '', $conf->entity); + } + + if (!$errormsg) + { + $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file); + $errormsg = $utils->error; + $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; + $_SESSION["commandbackuptorun"] = $utils->result['commandbackuptorun']; + } + + $what = ''; // Clear to show message to run command +} + + +if ($errormsg) +{ + setEventMessages($langs->trans("Error")." : ".$errormsg, null, 'errors'); + + $resultstring = ''; + $resultstring .= '
'.$langs->trans("Error")." : ".$errormsg.'
'; + + $_SESSION["commandbackupresult"] = $resultstring; +} +else +{ + if ($what) @@ -165,42 +211,8 @@ - $arrayofallowedcommand=explode(',', $dolibarr_main_restrict_os_commands); - $arrayofallowedcommand = array_map('trim', $arrayofallowedcommand); - dol_syslog("Command are restricted to ".$dolibarr_main_restrict_os_commands.". We check that one of this command is inside ".$cmddump); - $basenamecmddump = basename(str_replace('\\', '/', $cmddump)); - if (! in_array($basenamecmddump, $arrayofallowedcommand)) // the provided command $cmddump must be an allowed command - { - $errormsg=$langs->trans('CommandIsNotInsideAllowedCommands'); - } - } */ - - if (!$errormsg && $cmddump) { - dolibarr_set_const($db, 'SYSTEMTOOLS_POSTGRESQLDUMP', $cmddump, 'chaine', 0, '', $conf->entity); - } - - if (!$errormsg) { - $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file, 0, 0, $lowmemorydump); - $errormsg = $utils->error; - $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; - $_SESSION["commandbackuptorun"] = $utils->result['commandbackuptorun']; - } - - $what = ''; // Clear to show message to run command -} - - -if ($errormsg) { - setEventMessages($langs->trans("Error")." : ".$errormsg, null, 'errors'); - - $resultstring = ''; - $resultstring .= '
'.$langs->trans("Error")." : ".$errormsg.'
'; - - $_SESSION["commandbackupresult"] = $resultstring; -} else { - if ($what) { - setEventMessages($langs->trans("BackupFileSuccessfullyCreated").'.
'.$langs->trans("YouCanDownloadBackupFile"), null, 'mesgs'); - - $resultstring = '
'; - $resultstring .= $langs->trans("BackupFileSuccessfullyCreated").'.
'; - $resultstring .= $langs->trans("YouCanDownloadBackupFile"); - $resultstring .= '
'; - - $_SESSION["commandbackupresult"] = $resultstring; + setEventMessages($langs->trans("BackupFileSuccessfullyCreated").'.
'.$langs->trans("YouCanDownloadBackupFile"), null, 'mesgs'); + + $resultstring = '
'; + $resultstring .= $langs->trans("BackupFileSuccessfullyCreated").'.
'; + $resultstring .= $langs->trans("YouCanDownloadBackupFile"); + $resultstring .= '
'; + + $_SESSION["commandbackupresult"] = $resultstring; @@ -215 +226,0 @@ - @@ -217,6 +228,5 @@ - * View - */ - -top_httphead(); - -$db->close(); +$filearray=dol_dir_list($conf->admin->dir_output.'/backup','files',0,'','',$sortfield,(strtolower($sortorder)=='asc'?SORT_ASC:SORT_DESC),1); +$result=$formfile->list_of_documents($filearray,null,'systemtools','',1,'backup/',1,0,($langs->trans("NoBackupFileAvailable").'
'.$langs->trans("ToBuildBackupFileClickHere",DOL_URL_ROOT.'/admin/tools/dolibarr_export.php')),0,$langs->trans("PreviousDumpFiles")); + +print '
'; +*/ @@ -226 +236,4 @@ -exit(); + +$time_end = time(); + +$db->close(); --- /tmp/dsg/dolibarr/htdocs/admin/tools/github_19.0.3_export_files.php +++ /tmp/dsg/dolibarr/htdocs/admin/tools/client_export_files.php @@ -5 +4,0 @@ - * Copyright (C) 2021 Regis Houssin @@ -7,13 +6,13 @@ - * 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 - * along with this program. If not, see . - */ +* 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 +* along with this program. If not, see . +*/ @@ -26,5 +24,0 @@ -if (! defined('CSRFCHECK_WITH_TOKEN')) { - define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -} - -// Load Dolibarr environment @@ -39 +33 @@ -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); @@ -43 +37 @@ -$compression = GETPOST('compression', 'aZ09'); +$compression = GETPOST('compression'); @@ -46 +40 @@ -$file = preg_replace('/(\.zip|\.tar|\.tgz|\.gz|\.tar\.gz|\.bz2|\.zst)$/i', '', $file); +$file = preg_replace('/(\.zip|\.tar|\.tgz|\.gz|\.tar\.gz|\.bz2)$/i', '', $file); @@ -48,2 +42,2 @@ -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); @@ -51,12 +45,5 @@ -if (!$sortorder) { - $sortorder = "DESC"; -} -if (!$sortfield) { - $sortfield = "date"; -} -if ($page < 0) { - $page = 0; -} elseif (empty($page)) { - $page = 0; -} -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "date"; +if ($page < 0) { $page = 0; } +elseif (empty($page)) $page = 0; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -65,3 +52 @@ -if (!$user->admin) { - accessforbidden(); -} +if (!$user->admin) accessforbidden(); @@ -76,3 +61,4 @@ -if ($action == 'delete') { - $filerelative = dol_sanitizeFileName(GETPOST('urlfile', 'alpha')); - $filepath = $conf->admin->dir_output.'/'.$filerelative; +if ($action == 'delete') +{ + $filerelative = dol_sanitizeFileName(GETPOST('urlfile', 'alpha')); + $filepath = $conf->admin->dir_output.'/'.$filerelative; @@ -80,5 +66,2 @@ - if ($ret) { - setEventMessages($langs->trans("FileWasRemoved", $filerelative), null, 'mesgs'); - } else { - setEventMessages($langs->trans("ErrorFailToDeleteFile", $filerelative), null, 'errors'); - } + if ($ret) setEventMessages($langs->trans("FileWasRemoved", $filerelative), null, 'mesgs'); + else setEventMessages($langs->trans("ErrorFailToDeleteFile", $filerelative), null, 'errors'); @@ -95,6 +78,7 @@ -if (!empty($ExecTimeLimit)) { - $err = error_reporting(); - error_reporting(0); // Disable all errors - //error_reporting(E_ALL); - @set_time_limit($ExecTimeLimit); // Need more than 240 on Windows 7/64 - error_reporting($err); +if (!empty($ExecTimeLimit)) +{ + $err = error_reporting(); + error_reporting(0); // Disable all errors + //error_reporting(E_ALL); + @set_time_limit($ExecTimeLimit); // Need more than 240 on Windows 7/64 + error_reporting($err); @@ -102,5 +86,4 @@ - -/* If value has been forced with a php_admin_value, this has no effect. Example of value: '512M' */ -$MemoryLimit = getDolGlobalString('MAIN_MEMORY_LIMIT_ARCHIVE_DATAROOT'); -if (!empty($MemoryLimit)) { - @ini_set('memory_limit', $MemoryLimit); +$MemoryLimit = 0; +if (!empty($MemoryLimit)) +{ + @ini_set('memory_limit', $MemoryLimit); @@ -131,4 +114,15 @@ -if ($export_type == 'externalmodule' && !empty($what)) { - $fulldirtocompress = DOL_DOCUMENT_ROOT.'/custom/'.dol_sanitizeFileName($what); -} else { - $fulldirtocompress = DOL_DATA_ROOT; +if ($compression == 'zip') +{ + $file .= '.zip'; + $ret = dol_compress_dir(DOL_DATA_ROOT, $outputdir."/".$file, $compression, '/(\.log|\/temp\/|documents\/admin\/documents\/)/'); + if ($ret < 0) + { + if ($ret == -2) { + $langs->load("errors"); + $errormsg = $langs->trans("ErrNoZipEngine"); + } + else { + $langs->load("errors"); + $errormsg = $langs->trans("ErrorFailedToWriteInDir", $outputdir); + } + } @@ -136,34 +130,2 @@ -$dirtoswitch = dirname($fulldirtocompress); -$dirtocompress = basename($fulldirtocompress); - -if ($compression == 'zip') { - $file .= '.zip'; - - $excludefiles = '/(\.back|\.old|\.log|\.pdf_preview-.*\.png|[\/\\\]temp[\/\\\]|[\/\\\]admin[\/\\\]documents[\/\\\])/i'; - - //var_dump($fulldirtocompress); - //var_dump($outputdir."/".$file);exit; - - $rootdirinzip = ''; - if ($export_type == 'externalmodule' && !empty($what)) { - $rootdirinzip = $what; - - global $dolibarr_allow_download_external_modules; - if (empty($dolibarr_allow_download_external_modules)) { - print 'Download of external modules is not allowed by $dolibarr_allow_download_external_modules in conf.php file'; - $db->close(); - exit(); - } - } - - $ret = dol_compress_dir($fulldirtocompress, $outputdir."/".$file, $compression, $excludefiles, $rootdirinzip); - if ($ret < 0) { - if ($ret == -2) { - $langs->load("errors"); - $errormsg = $langs->trans("ErrNoZipEngine"); - } else { - $langs->load("errors"); - $errormsg = $langs->trans("ErrorFailedToWriteInDir", $outputdir); - } - } -} elseif (in_array($compression, array('gz', 'bz', 'zstd'))) { +elseif (in_array($compression, array('gz', 'bz'))) +{ @@ -174 +136,3 @@ - $file .= '.tar'; + $file .= '.tar'; + // We also exclude '/temp/' dir and 'documents/admin/documents' + $cmd = "tar -cf ".$outputdir."/".$file." --exclude-vcs --exclude 'temp' --exclude 'dolibarr.log' --exclude 'dolibarr_*.log' --exclude 'documents/admin/documents' -C ".dirname(DOL_DATA_ROOT)." ".basename(DOL_DATA_ROOT); @@ -176,3 +140 @@ - // We also exclude '/temp/' dir and 'documents/admin/documents' - // We make escapement here and call executeCLI without escapement because we don't want to have the '*.log' escaped. - $cmd = "tar -cf '".escapeshellcmd($outputdir."/".$file)."' --exclude-vcs --exclude-caches-all --exclude='temp' --exclude='*.log' --exclude='*.pdf_preview-*.png' --exclude='documents/admin/documents' -C '".escapeshellcmd(dol_sanitizePathName($dirtoswitch))."' '".escapeshellcmd(dol_sanitizeFileName($dirtocompress))."'"; + $result = $utils->executeCLI($cmd, $outputfile); @@ -180 +142,17 @@ - $result = $utils->executeCLI($cmd, $outputfile, 0, null, 1); + $retval = $result['error']; + if ($result['result'] || !empty($retval)) + { + $langs->load("errors"); + dol_syslog("Documents tar retval after exec=".$retval, LOG_ERR); + $errormsg = 'Error tar generation return '.$retval; + } + else + { + if ($compression == 'gz') + { + $cmd = "gzip -f ".$outputdir."/".$file; + } + if ($compression == 'bz') + { + $cmd = "bzip2 -f ".$outputdir."/".$file; + } @@ -182,13 +160 @@ - $retval = $result['error']; - if ($result['result'] || !empty($retval)) { - $langs->load("errors"); - dol_syslog("Documents tar retval after exec=".$retval, LOG_ERR); - $errormsg = 'Error tar generation return '.$retval; - } else { - if ($compression == 'gz') { - $cmd = "gzip -f ".$outputdir."/".$file; - } elseif ($compression == 'bz') { - $cmd = "bzip2 -f ".$outputdir."/".$file; - } elseif ($compression == 'zstd') { - $cmd = "zstd -z -9 -q --rm ".$outputdir."/".$file; - } + $result = $utils->executeCLI($cmd, $outputfile); @@ -196,11 +162,7 @@ - $result = $utils->executeCLI($cmd, $outputfile); - - $retval = $result['error']; - if ($result['result'] || !empty($retval)) { - $errormsg = 'Error '.$compression.' generation return '.$retval; - unlink($outputdir."/".$file); - } - } -} else { - $errormsg = 'Bad value for compression method'; - print $errormsg; + $retval = $result['error']; + if ($result['result'] || !empty($retval)) + { + $errormsg = 'Error '.$compression.' generation return '.$retval; + unlink($outputdir."/".$file); + } + } @@ -208,0 +171,4 @@ +if ($errormsg) +{ + setEventMessages($langs->trans("Error")." : ".$errormsg, null, 'errors'); +} @@ -210 +176,2 @@ -// Output export +// Redirect t backup page +header("Location: dolibarr_export.php"); @@ -212,2 +179 @@ -if ($export_type != 'externalmodule' || empty($what)) { - top_httphead(); +$time_end = time(); @@ -215,31 +181 @@ - if ($errormsg) { - setEventMessages($langs->trans("Error")." : ".$errormsg, null, 'errors'); - } else { - setEventMessages($langs->trans("BackupFileSuccessfullyCreated").'.
'.$langs->trans("YouCanDownloadBackupFile"), null, 'mesgs'); - } - - $db->close(); - - // Redirect to calling page - $returnto = 'dolibarr_export.php'; - - header("Location: ".$returnto); - - exit(); -} else { - top_httphead('application/zip'); - - $zipname = $outputdir."/".$file; - - // Then download the zipped file. - - header('Content-disposition: attachment; filename='.basename($zipname)); - header('Content-Length: '.filesize($zipname)); - readfile($zipname); - - dol_delete_file($zipname); - - $db->close(); - - exit(); -} +$db->close(); --- /tmp/dsg/dolibarr/htdocs/admin/tools/github_19.0.3_listevents.php +++ /tmp/dsg/dolibarr/htdocs/admin/tools/client_listevents.php @@ -2 +2 @@ -/* Copyright (C) 2004-2023 Laurent Destailleur +/* Copyright (C) 2004-2017 Laurent Destailleur @@ -5 +5 @@ - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018 Frédéric France @@ -27 +26,0 @@ -// Load Dolibarr environment @@ -31,3 +30,2 @@ -require_once DOL_DOCUMENT_ROOT.'/core/triggers/interface_20_all_Logevents.class.php'; - -if (!$user->admin) { + +if (!$user->admin) @@ -35,3 +33,2 @@ -} - -$action = GETPOST('action', 'aZ09'); + +$action = GETPOST('action', 'alpha'); @@ -41 +38,2 @@ -if ($user->socid > 0) { +if ($user->socid > 0) +{ @@ -47 +45 @@ -$langs->loadLangs(array("companies", "admin", "users", "other","withdrawals")); +$langs->loadLangs(array("companies", "admin", "users", "other")); @@ -50,3 +48,3 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); @@ -54,3 +52 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -60,8 +56,3 @@ -if (!$sortfield) { - $sortfield = "e.rowid"; -} -if (!$sortorder) { - $sortorder = "DESC"; -} - -$search_rowid = GETPOST("search_rowid", "int"); +if (!$sortfield) $sortfield = "dateevent"; +if (!$sortorder) $sortorder = "DESC"; + @@ -72,3 +63,10 @@ -$search_ua = GETPOST("search_ua", "restricthtml"); -$search_prefix_session = GETPOST("search_prefix_session", "restricthtml"); -$optioncss = GETPOST("optioncss", "aZ"); // Option for the css output (always '' except when 'print') +$search_ua = GETPOST("search_ua", "none"); +$search_prefix_session = GETPOST("search_prefix_session", "none"); + +if (GETPOST("date_startmonth") == '' || GETPOST("date_startmonth") > 0) $date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); +else $date_start = -1; +if (GETPOST("date_endmonth") == '' || GETPOST("date_endmonth") > 0) $date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); +else $date_end = -1; + +// checks:if date_start>date_end then date_end=date_start + 24 hours +if ($date_start > 0 && $date_end > 0 && $date_start > $date_end) $date_end = $date_start + 86400; @@ -79,24 +77,8 @@ -if (GETPOST("date_startmonth", 'int') > 0) { - $date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth", 'int'), GETPOST("date_startday", 'int'), GETPOST("date_startyear", 'int'), 'tzuserrel'); -} else { - $date_start = ''; -} -if (GETPOST("date_endmonth", 'int') > 0) { - $date_end = dol_get_last_hour(dol_mktime(23, 59, 59, GETPOST("date_endmonth", 'int'), GETPOST("date_endday", 'int'), GETPOST("date_endyear", 'int'), 'tzuserrel'), 'tzuserrel'); -} else { - $date_end = ''; -} - -// checks:if date_start>date_end then date_end=date_start + 24 hours -if ($date_start !== '' && $date_end !== '' && $date_start > $date_end) { - $date_end = $date_start + 86400; -} - - -if (!GETPOSTISSET('pageplusoneold') && !GETPOSTISSET('page') && $date_start === '') { // We define date_start and date_end - $date_start = dol_get_first_day($nowarray['year'], $nowarray['mon'], 'tzuserrel'); -} -if (!GETPOSTISSET('pageplusoneold') && !GETPOSTISSET('page') && $date_end === '') { - $date_end = dol_get_last_day($nowarray['year'], $nowarray['mon'], 'tzuserrel'); -} - +if (empty($date_start)) // We define date_start and date_end +{ + $date_start = dol_get_first_day($nowarray['year'], $nowarray['mon'], false); +} +if (empty($date_end)) +{ + $date_end = dol_mktime(23, 59, 59, $nowarray['mon'], $nowarray['mday'], $nowarray['year']); +} @@ -104,28 +86,10 @@ -$date_startday = ''; -$date_startmonth = ''; -$date_startyear = ''; -$date_endday = ''; -$date_endmonth = ''; -$date_endyear = ''; -if ($date_start !== '') { - $tmp = dol_getdate($date_start); - $date_startday = $tmp['mday']; - $date_startmonth = $tmp['mon']; - $date_startyear = $tmp['year']; -} -if ($date_end !== '') { - $tmp = dol_getdate($date_end); - $date_endday = $tmp['mday']; - $date_endmonth = $tmp['mon']; - $date_endyear = $tmp['year']; -} - -// Add prefix session -$arrayfields = array( - 'e.prefix_session' => array( - 'label'=>'UserAgent', - 'checked'=>(!getDolGlobalString('AUDIT_ENABLE_PREFIX_SESSION') ? 0 : 1), - 'enabled'=>(!getDolGlobalString('AUDIT_ENABLE_PREFIX_SESSION') ? 0 : 1), - 'position'=>110 - ) -); +$tmp = dol_getdate($date_start); +$date_startday = $tmp['mday']; +$date_startmonth = $tmp['mon']; +$date_startyear = $tmp['year']; +$tmp = dol_getdate($date_end); +$date_endday = $tmp['mday']; +$date_endmonth = $tmp['mon']; +$date_endyear = $tmp['year']; + +$arrayfields = array(); @@ -141,16 +105,10 @@ -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers - $date_start = ''; - $date_end = ''; - $date_startday = ''; - $date_endday = ''; - $date_startmonth = ''; - $date_endmonth = ''; - $date_startyear = ''; - $date_endyear = ''; - $search_rowid = ''; - $search_code = ''; - $search_ip = ''; - $search_user = ''; - $search_desc = ''; - $search_ua = ''; - $search_prefix_session = ''; +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers +{ + $date_start = -1; + $date_end = -1; + $search_code = ''; + $search_ip = ''; + $search_user = ''; + $search_desc = ''; + $search_ua = ''; + $search_prefix_session = ''; @@ -160 +118,2 @@ -if ($action == 'confirm_purge' && $confirm == 'yes' && $user->admin) { +if ($action == 'confirm_purge' && $confirm == 'yes' && $user->admin) +{ @@ -172 +131,2 @@ - if (!$resql) { + if (!$resql) + { @@ -185,2 +145,3 @@ - if ($result > 0) { - $db->commit(); + if ($result > 0) + { + $db->commit(); @@ -188 +149,3 @@ - } else { + } + else + { @@ -200,2 +163 @@ -$title = $langs->trans("Audit"); -llxHeader('', $title); +llxHeader('', $langs->trans("Audit")); @@ -210 +172 @@ -$sql .= " u.login, u.admin, u.entity, u.firstname, u.lastname, u.statut as status"; +$sql .= " u.login"; @@ -214,34 +176,8 @@ -if ($date_start !== '') { - $sql .= " AND e.dateevent >= '".$db->idate($date_start)."'"; -} -if ($date_end !== '') { - $sql .= " AND e.dateevent <= '".$db->idate($date_end)."'"; -} -if ($search_rowid) { - $usefilter++; - $sql .= natural_search("e.rowid", $search_rowid, 1); -} -if ($search_code) { - $usefilter++; - $sql .= natural_search("e.type", $search_code, 0); -} -if ($search_ip) { - $usefilter++; - $sql .= natural_search("e.ip", $search_ip, 0); -} -if ($search_user) { - $usefilter++; - $sql .= natural_search("u.login", $search_user, 0); -} -if ($search_desc) { - $usefilter++; - $sql .= natural_search("e.description", $search_desc, 0); -} -if ($search_ua) { - $usefilter++; - $sql .= natural_search("e.user_agent", $search_ua, 0); -} -if ($search_prefix_session) { - $usefilter++; - $sql .= natural_search("e.prefix_session", $search_prefix_session, 0); -} +if ($date_start > 0) $sql .= " AND e.dateevent >= '".$db->idate($date_start)."'"; +if ($date_end > 0) $sql .= " AND e.dateevent <= '".$db->idate($date_end)."'"; +if ($search_code) { $usefilter++; $sql .= natural_search("e.type", $search_code, 0); } +if ($search_ip) { $usefilter++; $sql .= natural_search("e.ip", $search_ip, 0); } +if ($search_user) { $usefilter++; $sql .= natural_search("u.login", $search_user, 0); } +if ($search_desc) { $usefilter++; $sql .= natural_search("e.description", $search_desc, 0); } +if ($search_ua) { $usefilter++; $sql .= natural_search("e.user_agent", $search_ua, 0); } +if ($search_prefix_session) { $usefilter++; $sql .= natural_search("e.prefix_session", $search_prefix_session, 0); } @@ -254,7 +190,7 @@ - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { - $page = 0; - $offset = 0; - } + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } @@ -263,2 +199,2 @@ -$sql .= $db->plimit($limit + 1, $offset); - +$sql .= $db->plimit($conf->liste_limit + 1, $offset); +//print $sql; @@ -266 +202,2 @@ -if ($result) { +if ($result) +{ @@ -271,53 +208,21 @@ - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); - } - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); - } - if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); - } - if ($search_rowid) { - $param .= '&search_rowid='.urlencode($search_rowid); - } - if ($search_code) { - $param .= '&search_code='.urlencode($search_code); - } - if ($search_ip) { - $param .= '&search_ip='.urlencode($search_ip); - } - if ($search_user) { - $param .= '&search_user='.urlencode($search_user); - } - if ($search_desc) { - $param .= '&search_desc='.urlencode($search_desc); - } - if ($search_ua) { - $param .= '&search_ua='.urlencode($search_ua); - } - if ($search_prefix_session) { - $param .= '&search_prefix_session='.urlencode($search_prefix_session); - } - if ($date_startmonth) { - $param .= "&date_startmonth=".urlencode($date_startmonth); - } - if ($date_startday) { - $param .= "&date_startday=".urlencode($date_startday); - } - if ($date_startyear) { - $param .= "&date_startyear=".urlencode($date_startyear); - } - if ($date_endmonth) { - $param .= "&date_endmonth=".urlencode($date_endmonth); - } - if ($date_endday) { - $param .= "&date_endday=".urlencode($date_endday); - } - if ($date_endyear) { - $param .= "&date_endyear=".urlencode($date_endyear); - } - - $center = ''; - if ($num) { - $center = ''.$langs->trans("Purge").''; - } + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + if ($search_code) $param .= '&search_code='.urlencode($search_code); + if ($search_ip) $param .= '&search_ip='.urlencode($search_ip); + if ($search_user) $param .= '&search_user='.urlencode($search_user); + if ($search_desc) $param .= '&search_desc='.urlencode($search_desc); + if ($search_ua) $param .= '&search_ua='.urlencode($search_ua); + if ($search_prefix_sessiona) $param .= '&search_prefix_session='.urlencode($search_prefix_session); + if ($date_startmonth) $param .= "&date_startmonth=".urlencode($date_startmonth); + if ($date_startday) $param .= "&date_startday=".urlencode($date_startday); + if ($date_startyear) $param .= "&date_startyear=".urlencode($date_startyear); + if ($date_endmonth) $param .= "&date_endmonth=".urlencode($date_endmonth); + if ($date_endday) $param .= "&date_endday=".urlencode($date_endday); + if ($date_endyear) $param .= "&date_endyear=".urlencode($date_endyear); + + $langs->load('withdrawals'); + if ($num) + { + $center = ''.$langs->trans("Purge").''; + } @@ -326,5 +231,5 @@ - print ''; - - print_barre_liste($langs->trans("ListOfSecurityEvents"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $nbtotalofrecords, 'setup', 0, '', '', $limit); - - if ($action == 'purge') { + + print_barre_liste($langs->trans("ListOfSecurityEvents"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $nbtotalofrecords, 'setup', 0, '', '', $limit); + + if ($action == 'purge') + { @@ -335,14 +239,0 @@ - // Check some parameters - // TODO Add a tab with this and other information - /* - global $dolibarr_main_prod, $dolibarr_nocsrfcheck; - if (empty($dolibarr_main_prod)) { - print $langs->trans("Warning").' dolibarr_main_prod = '.$dolibarr_main_prod; - print ' '.img_warning($langs->trans('SwitchThisForABetterSecurity', 1)).'
'; - } - if (!empty($dolibarr_nocsrfcheck)) { - print $langs->trans("Warning").' dolibarr_nocsrfcheck = '.$dolibarr_nocsrfcheck; - print ' '.img_warning($langs->trans('SwitchThisForABetterSecurity', 0)).'
'; - } - */ - @@ -355,21 +246,4 @@ - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print '
'; - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print ''; - print ''; - print ''; - print $form->selectDate($date_start === '' ? -1 : $date_start, 'date_start', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel'); - print $form->selectDate($date_end === '' ? -1 : $date_end, 'date_end', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel'); - print ''; - print ''; + print ''.$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0).''; + print ''; @@ -379,9 +253,9 @@ - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; @@ -391,5 +265,2 @@ - print ''; - print ''; - print ''; - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print ''; + print ''; + print ''; + $searchpicto = $form->showFilterAndCheckAddButtons(0); + print $searchpicto; + print ''; - $htmltext = ''.$langs->trans("UserAgent").': '.($obj->user_agent ? dol_string_nohtmltag($obj->user_agent) : $langs->trans("Unknown")); - $htmltext .= '
'.$langs->trans("SuffixSessionName").' (DOLSESSID_...): '.($obj->prefix_session ? dol_string_nohtmltag($obj->prefix_session) : $langs->trans("Unknown")); - print $form->textwithpicto('', $htmltext); + // Date + print '
'.dol_print_date($db->jdate($obj->dateevent), '%Y-%m-%d %H:%M:%S').''.$obj->type.''; + print dol_print_ip($obj->ip); + print ''; + if ($obj->fk_user) + { + $userstatic->id = $obj->fk_user; + $userstatic->login = $obj->login; + print $userstatic->getLoginUrl(1); + } + else print ' '; + print ''; + $text = $langs->trans($obj->description); + $reg = array(); + if (preg_match('/\((.*)\)(.*)/i', $obj->description, $reg)) + { + $val = explode(',', $reg[1]); + $text = $langs->trans($val[0], isset($val[1]) ? $val[1] : '', isset($val[2]) ? $val[2] : '', isset($val[3]) ? $val[3] : '', isset($val[4]) ? $val[4] : ''); + if (!empty($reg[2])) $text .= $reg[2]; + } + print dol_escape_htmltag($text); + print ''; + print $obj->user_agent; @@ -447,61 +353,5 @@ - // ID - print ''.dol_escape_htmltag($obj->rowid).''.dol_print_date($db->jdate($obj->dateevent), '%Y-%m-%d %H:%M:%S', 'tzuserrel').''.dol_escape_htmltag($obj->type).''; - print dol_print_ip($obj->ip); - print ''; - if ($obj->fk_user > 0) { - $userstatic->id = $obj->fk_user; - $userstatic->login = $obj->login; - $userstatic->admin = $obj->admin; - $userstatic->entity = $obj->entity; - $userstatic->status = $obj->status; - - print $userstatic->getLoginUrl(1); - if (isModEnabled('multicompany') && $userstatic->admin && !$userstatic->entity) { - print img_picto($langs->trans("SuperAdministratorDesc"), 'redstar', 'class="valignmiddle paddingleft"'); - } elseif ($userstatic->admin) { - print img_picto($langs->trans("AdministratorDesc"), 'star', 'class="valignmiddle paddingleft"'); - } - } else { - print ' '; - } - print ''; - print dol_escape_htmltag($text); - print ''; - print dol_escape_htmltag($obj->user_agent); - print ''; - print dol_escape_htmltag($obj->prefix_session); + if (!empty($arrayfields['e.prefix_session']['checked'])) + { + // User agent + print ''; + print $obj->prefix_session; @@ -511,8 +361,6 @@ - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - $htmltext = ''.$langs->trans("UserAgent").': '.($obj->user_agent ? dol_string_nohtmltag($obj->user_agent) : $langs->trans("Unknown")); - $htmltext .= '
'.$langs->trans("SuffixSessionName").' (DOLSESSID_...): '.($obj->prefix_session ? dol_string_nohtmltag($obj->prefix_session) : $langs->trans("Unknown")); - print $form->textwithpicto('', $htmltext); - print '
'; + $htmltext = ''.$langs->trans("UserAgent").': '.($obj->user_agent ? dol_string_nohtmltag($obj->user_agent) : $langs->trans("Unknown")); + $htmltext .= '
'.$langs->trans("PrefixSession").': '.($obj->prefix_session ? dol_string_nohtmltag($obj->prefix_session) : $langs->trans("Unknown")); + print $form->textwithpicto('', $htmltext); + print '
'.$langs->trans("NoEventFoundWithCriteria").'
'.$langs->trans("NoEventOrNoAuditSetup").'
'.$langs->trans("NoEventFoundWithCriteria").'
'.$langs->trans("NoEventOrNoAuditSetup").'