diff --git a/admin.php b/admin.php index ba18351..b605af6 100644 --- a/admin.php +++ b/admin.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Admin main site // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-03-14 13:43:23 +0100 (Wed, 14 Mar 2012) $ -// Author : $LastChangedBy: rouven $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1296 $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ +// Author : $LastChangedBy: martin $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/administration.php b/admin/administration.php index 34521ce..30d4fbb 100644 --- a/admin/administration.php +++ b/admin/administration.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Administration overview // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-21 14:10:41 +0100 (Tue, 21 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1229 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/alarming.php b/admin/alarming.php index 391c14d..8897e9d 100644 --- a/admin/alarming.php +++ b/admin/alarming.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Alarming overview // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-08 15:13:31 +0100 (Wed, 08 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1189 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/cgicfg.php b/admin/cgicfg.php index 1490bab..55abf97 100644 --- a/admin/cgicfg.php +++ b/admin/cgicfg.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : File editor cgi.cfg // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-03-07 10:38:34 +0100 (Wed, 07 Mar 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1275 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // @@ -38,7 +38,7 @@ $intConfigId = $arrConfigSet[0]; $myConfigClass->getConfigData($intConfigId,"method",$intMethod); $myConfigClass->getConfigData($intConfigId,"nagiosbasedir",$strBaseDir); $strConfigfile = str_replace("//","/",$strBaseDir."/cgi.cfg"); -$strLocalBackup = str_replace("//","/",$strBaseDir."/cgi.cfg_old_").date("YmdHis",mktime()); +$strLocalBackup = str_replace("//","/",$strBaseDir."/cgi.cfg_old_").date("YmdHis",time()); // // Convert Windows to UNIX // ======================= diff --git a/admin/checkcommands.php b/admin/checkcommands.php index cb09ec1..25a1eef 100644 --- a/admin/checkcommands.php +++ b/admin/checkcommands.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Command definitions // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-03-09 07:43:00 +0100 (Fri, 09 Mar 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1282 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/commandline.php b/admin/commandline.php index c43621a..7bc4995 100644 --- a/admin/commandline.php +++ b/admin/commandline.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Command line visualization // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-21 14:10:41 +0100 (Tue, 21 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1229 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/commands.php b/admin/commands.php index 7bc8d0d..5c90b88 100644 --- a/admin/commands.php +++ b/admin/commands.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Commands overview // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-08 15:13:31 +0100 (Wed, 08 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1189 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/configtargets.php b/admin/configtargets.php old mode 100755 new mode 100644 index 9af9bbc..8f29968 --- a/admin/configtargets.php +++ b/admin/configtargets.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Admin configuration target administration // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2011-12-01 15:20:17 +0100 (Do, 01. Dez 2011) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1137 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/contactgroups.php b/admin/contactgroups.php index e73f304..b656e5e 100644 --- a/admin/contactgroups.php +++ b/admin/contactgroups.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Contactgroup definition // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-03-09 07:43:00 +0100 (Fri, 09 Mar 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1282 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/contacts.php b/admin/contacts.php index 5caeb0e..0dd9819 100644 --- a/admin/contacts.php +++ b/admin/contacts.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Contact definitions // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-04-20 12:39:53 +0200 (Fri, 20 Apr 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1323 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/contacttemplates.php b/admin/contacttemplates.php index d380c23..a54f100 100644 --- a/admin/contacttemplates.php +++ b/admin/contacttemplates.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Contact template definitions // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-03-09 07:43:00 +0100 (Fri, 09 Mar 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1282 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/datadomain.php b/admin/datadomain.php old mode 100755 new mode 100644 index 8e19db3..2e1f62b --- a/admin/datadomain.php +++ b/admin/datadomain.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Admin domain administration // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2011-12-01 15:20:17 +0100 (Do, 01. Dez 2011) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1137 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/delbackup.php b/admin/delbackup.php index 506c605..c087631 100644 --- a/admin/delbackup.php +++ b/admin/delbackup.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Admin file deletion // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-27 13:01:17 +0100 (Mon, 27 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1257 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/delconfig.php b/admin/delconfig.php index c745a52..73b6c07 100644 --- a/admin/delconfig.php +++ b/admin/delconfig.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Admin file deletion // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-27 13:01:17 +0100 (Mon, 27 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1257 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/download.php b/admin/download.php index 5122ab8..c78e611 100644 --- a/admin/download.php +++ b/admin/download.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Download config file // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-21 14:10:41 +0100 (Tue, 21 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1229 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/group.php b/admin/group.php index 1d434e1..ea8e043 100644 --- a/admin/group.php +++ b/admin/group.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Group administration // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-21 14:10:41 +0100 (Tue, 21 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1229 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/groupusers.php b/admin/groupusers.php index 1709fd3..b33b215 100644 --- a/admin/groupusers.php +++ b/admin/groupusers.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Admin time definition list // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-27 13:01:17 +0100 (Mon, 27 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1257 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/helpedit.php b/admin/helpedit.php index a1bed32..1046209 100644 --- a/admin/helpedit.php +++ b/admin/helpedit.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Help text editor // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-27 13:01:17 +0100 (Mon, 27 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1257 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/hostdependencies.php b/admin/hostdependencies.php index 151ca53..a15e91a 100644 --- a/admin/hostdependencies.php +++ b/admin/hostdependencies.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Host dependencies definition // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-03-09 07:43:00 +0100 (Fri, 09 Mar 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1282 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/hostescalations.php b/admin/hostescalations.php index 46e9acc..3b2daf8 100644 --- a/admin/hostescalations.php +++ b/admin/hostescalations.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Host escalation definition // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-03-09 07:43:00 +0100 (Fri, 09 Mar 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1282 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/hostextinfo.php b/admin/hostextinfo.php index 7c18c0a..15d47b8 100644 --- a/admin/hostextinfo.php +++ b/admin/hostextinfo.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Host extended information definition // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-03-09 07:43:00 +0100 (Fri, 09 Mar 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1282 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/hostgroups.php b/admin/hostgroups.php index f7bb1ca..0400047 100644 --- a/admin/hostgroups.php +++ b/admin/hostgroups.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Hostgroup definition // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-03-09 07:43:00 +0100 (Fri, 09 Mar 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1282 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/hosts.php b/admin/hosts.php index 78a79cf..3733be5 100644 --- a/admin/hosts.php +++ b/admin/hosts.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Host definition // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-04-17 12:09:50 +0200 (Tue, 17 Apr 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1321 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/hosttemplates.php b/admin/hosttemplates.php index b35ed16..ee1e30e 100644 --- a/admin/hosttemplates.php +++ b/admin/hosttemplates.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Hosttemplate definition // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-03-09 07:43:00 +0100 (Fri, 09 Mar 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1282 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/import.php b/admin/import.php index 770a88a..4564663 100644 --- a/admin/import.php +++ b/admin/import.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Admin configuration verification // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-03-07 10:38:34 +0100 (Wed, 07 Mar 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1275 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/info.php b/admin/info.php index 83bf631..d920e07 100644 --- a/admin/info.php +++ b/admin/info.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Admin information dialog // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-21 14:10:41 +0100 (Tue, 21 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1229 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/logbook.php b/admin/logbook.php index 96b0add..b68f65f 100644 --- a/admin/logbook.php +++ b/admin/logbook.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Admin logbook // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-01-13 07:40:23 +0100 (Fri, 13 Jan 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1158 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/menuaccess.php b/admin/menuaccess.php index 0887d02..c35aac8 100644 --- a/admin/menuaccess.php +++ b/admin/menuaccess.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Menu access administration // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-21 14:10:41 +0100 (Tue, 21 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1229 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/monitoring.php b/admin/monitoring.php index ca0b923..aacf13c 100644 --- a/admin/monitoring.php +++ b/admin/monitoring.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Admin specials overview // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-08 15:13:31 +0100 (Wed, 08 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1189 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/mutdialog.php b/admin/mutdialog.php index 443f45f..75d3e72 100644 --- a/admin/mutdialog.php +++ b/admin/mutdialog.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Admin timeperiod definitions // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-27 13:01:17 +0100 (Mon, 27 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1257 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/nagioscfg.php b/admin/nagioscfg.php index 7d5951e..3d12bb5 100644 --- a/admin/nagioscfg.php +++ b/admin/nagioscfg.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Admin timeperiod definitions // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-03-07 10:38:34 +0100 (Wed, 07 Mar 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1275 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // @@ -38,7 +38,7 @@ $intConfigId = $arrConfigSet[0]; $myConfigClass->getConfigData($intConfigId,"method",$intMethod); $myConfigClass->getConfigData($intConfigId,"nagiosbasedir",$strBaseDir); $myConfigClass->getConfigData($intConfigId,"conffile",$strConfigfile); -$strLocalBackup = $strConfigfile."_old_".date("YmdHis",mktime()); +$strLocalBackup = $strConfigfile."_old_".date("YmdHis",time()); // // Convert Windows to UNIX // ======================= diff --git a/admin/password.php b/admin/password.php index 903a56f..34b36bd 100644 --- a/admin/password.php +++ b/admin/password.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Password administration // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-27 13:01:17 +0100 (Mon, 27 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1257 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/servicedependencies.php b/admin/servicedependencies.php index 7c9c3f6..adef4a0 100644 --- a/admin/servicedependencies.php +++ b/admin/servicedependencies.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Service dependencies definition // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-03-09 07:43:00 +0100 (Fri, 09 Mar 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1282 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/serviceescalations.php b/admin/serviceescalations.php index bc1a9b2..d7e8382 100644 --- a/admin/serviceescalations.php +++ b/admin/serviceescalations.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Service escalation definition // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-03-09 07:43:00 +0100 (Fri, 09 Mar 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1282 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/serviceextinfo.php b/admin/serviceextinfo.php index b6ba2e2..ac3dac5 100644 --- a/admin/serviceextinfo.php +++ b/admin/serviceextinfo.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Service extended information definition // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-03-09 07:43:00 +0100 (Fri, 09 Mar 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1282 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/servicegroups.php b/admin/servicegroups.php index a094ef9..bd1e0bb 100644 --- a/admin/servicegroups.php +++ b/admin/servicegroups.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Admin servicegroup definition // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-03-09 07:43:00 +0100 (Fri, 09 Mar 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1282 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/services.php b/admin/services.php index 30b89db..13d4971 100644 --- a/admin/services.php +++ b/admin/services.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Service definition // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-04-17 12:09:50 +0200 (Tue, 17 Apr 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1321 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/servicetemplates.php b/admin/servicetemplates.php index 7de3200..0df5e81 100644 --- a/admin/servicetemplates.php +++ b/admin/servicetemplates.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Service template definition // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-03-09 07:43:00 +0100 (Fri, 09 Mar 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1282 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/settings.php b/admin/settings.php index c783d66..28f23f9 100644 --- a/admin/settings.php +++ b/admin/settings.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Settings configuration // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-21 14:10:41 +0100 (Tue, 21 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1229 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/specials.php b/admin/specials.php index 3759887..4f0e17f 100644 --- a/admin/specials.php +++ b/admin/specials.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Specials overview // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-08 15:13:31 +0100 (Wed, 08 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1189 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/support.php b/admin/support.php index 0bd3819..a27639c 100644 --- a/admin/support.php +++ b/admin/support.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Support page // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-01-27 09:59:02 +0100 (Fre, 27. Jan 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1182 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/templatedefinitions.php b/admin/templatedefinitions.php index 25641d8..9c2a9d9 100644 --- a/admin/templatedefinitions.php +++ b/admin/templatedefinitions.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Template definition list // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-04-05 08:11:59 +0200 (Thu, 05 Apr 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1315 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/timedefinitions.php b/admin/timedefinitions.php index 6b0f75d..221731a 100644 --- a/admin/timedefinitions.php +++ b/admin/timedefinitions.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Admin time definition list // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-27 13:01:17 +0100 (Mon, 27 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1257 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/timeperiods.php b/admin/timeperiods.php index 9488f35..927aa12 100644 --- a/admin/timeperiods.php +++ b/admin/timeperiods.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Timeperiod definitions // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-03-09 07:43:00 +0100 (Fri, 09 Mar 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1282 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/tools.php b/admin/tools.php index 6c00a06..da7fdc2 100644 --- a/admin/tools.php +++ b/admin/tools.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Tools overview // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-21 14:10:41 +0100 (Tue, 21 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1229 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/user.php b/admin/user.php index 639f4a0..2e104d4 100644 --- a/admin/user.php +++ b/admin/user.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : User administration // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-21 14:10:41 +0100 (Tue, 21 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1229 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/variabledefinitions.php b/admin/variabledefinitions.php index ad0f6d0..9679e33 100644 --- a/admin/variabledefinitions.php +++ b/admin/variabledefinitions.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Variable definition list // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-27 13:01:17 +0100 (Mon, 27 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1257 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/admin/verify.php b/admin/verify.php index 3dba235..d602364 100644 --- a/admin/verify.php +++ b/admin/verify.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Configuration verification // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-09-24 14:42:29 +0200 (Mon, 24 Sep 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1347 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // @@ -342,7 +342,7 @@ if ($chkButValue4 != "") { } if (file_exists($strPidfile) && isset($arrExec[0])) { if (file_exists($strCommandfile) && is_writable($strCommandfile)) { - $strCommandString = "[".mktime()."] RESTART_PROGRAM;".mktime(); + $strCommandString = "[".time()."] RESTART_PROGRAM;".time()."\n"; $timeout = 3; $old = ini_set('default_socket_timeout', $timeout); $resCmdFile = fopen($strCommandfile,"w"); @@ -379,7 +379,7 @@ if ($chkButValue4 != "") { $myVisClass->processMessage($myConfigClass->strErrorMessage,$strErrorMessage); } else { if (is_array($myConfigClass->sendSSHCommand('ls '.$strCommandfile))) { - $strCommandString = "[".mktime()."] RESTART_PROGRAM;".mktime(); + $strCommandString = "[".time()."] RESTART_PROGRAM;".time()."\n"; $arrInfo = ssh2_sftp_stat($myConfigClass->resSFTP, $strCommandfile); $intFileStamp1 = $arrInfo['mtime']; $arrResult = $myConfigClass->sendSSHCommand('echo "'.$strCommandString.'" >> '.$strCommandfile); diff --git a/admin/versioncheck.php b/admin/versioncheck.php index cfe0adb..297b797 100644 --- a/admin/versioncheck.php +++ b/admin/versioncheck.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Command line visualization // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2011-10-31 15:42:09 +0100 (Mo, 31. Okt 2011) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1118 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/config/content.css b/config/content.css index bf4a3bc..b0d1c8c 100644 --- a/config/content.css +++ b/config/content.css @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : CSS content definition // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2011-10-27 09:50:16 +0200 (Thu, 27 Oct 2011) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1111 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////*/ /* Content main div */ diff --git a/config/fieldvars.php b/config/fieldvars.php index 581179d..edb0a37 100644 --- a/config/fieldvars.php +++ b/config/fieldvars.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : field language variables (for replace in templates) // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-21 14:10:41 +0100 (Tue, 21 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1229 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/config/main.css b/config/main.css index af7dfab..7b6f1f1 100644 --- a/config/main.css +++ b/config/main.css @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : CSS Main definition // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-21 14:10:41 +0100 (Tue, 21 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1229 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////*/ body { diff --git a/doc/CHANGELOG b/doc/CHANGELOG old mode 100755 new mode 100644 index 881229f..ee89715 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -1,3 +1,8 @@ +CHANGELOG 3.3.0 +--------------- +- [OK] Support for PHP version 7.x +- [OK] Database interface changed from mysql to mysqli + CHANGELOG 3.2.0 --------------- diff --git a/doc/INSTALLATION_deDE.txt b/doc/INSTALLATION_deDE.txt index c586dd8..cd61956 100644 --- a/doc/INSTALLATION_deDE.txt +++ b/doc/INSTALLATION_deDE.txt @@ -4,16 +4,16 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2008-2012 by Martin Willisegger +// (c) 2008-2017 by Martin Willisegger // // Project : NagiosQL // Component: Installations HowTo // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-03-12 08:30:07 +0100 (Mon, 12 Mar 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1288 $ -// SVN-ID : $Id: INSTALLATION_deDE.txt 1288 2012-03-12 07:30:07Z martin $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ +// SVN-ID : $Id: INSTALLATION_deDE.txt 2 2017-06-22 07:29:35Z martin $ // /////////////////////////////////////////////////////////////////////////////// @@ -26,7 +26,7 @@ * Nagios 2.x/3.x oder Nagios kompatible Monitoringsoftware * PHP 5.2.0 oder groesser, inklusive: * PHP Module: Session - * PHP Module: MySQL + * PHP Module: MySQLi * PHP Module: gettext * PHP Module: filter * PHP Module: FTP (optional) @@ -38,7 +38,7 @@ = Neuinstallation = =================== - 1. Download und entpacken von NagiosQL 3.2 in einem Apache zugaenglichen Verzeichnis. + 1. Download und entpacken von NagiosQL 3.3 in einem Apache zugaenglichen Verzeichnis. 2. Der Installationsassistent wird automatisch durch Eingabe von install/index.php gestartet. 3. Die gewuenschte Sprache auswaehlen (siehe Appendix 2.) 4. Zum Installieren von NagiosQL den Anweisungen folgen. @@ -50,11 +50,11 @@ 1. Aktualisierungen von NagiosQL 1.x und 2.x sind leider nicht moeglich, bitte einfach eine neue Installation starten und dann die Nagios Konfiguration durch den Import einbinden. 2. Aktualisierungen von NagiosQL 3.x - a. Download und entpacken von NagiosQL 3.2 in ein NEUES Apache zugaenglichen Verzeichnis (DocumentRoot auf neues Verzeichnis + a. Download und entpacken von NagiosQL 3.3 in ein NEUES Apache zugaenglichen Verzeichnis (DocumentRoot auf neues Verzeichnis aendern) b. Wird dieselbe Apachekonfiguration verwendet (altes NagiosQL Verzeichnis wegkopiert, neues NagiosQL Verzeichnis bekommt denselben Namen), sollte der Apache Demon vor dem Upgrade neu gestartet werden. - c. Verschiebe die alte config/settings.php Datei in das neue NagiosQL 3.2 Verzeichnis config/ + c. Verschiebe die alte config/settings.php Datei in das neue NagiosQL 3.3 Verzeichnis config/ d. Die alte Datenbank manuell sichern (z.Bsp. mit mysqldump) e. Der Installationsassistent wird durch den Aufruf von install/index.php gestartet f. Die gewuenschte Sprache waehlen (siehe auch Appendix 1.) und den Anweisungen folgen diff --git a/doc/INSTALLATION_enGB.txt b/doc/INSTALLATION_enGB.txt index 44d5ce0..a2f0bac 100644 --- a/doc/INSTALLATION_enGB.txt +++ b/doc/INSTALLATION_enGB.txt @@ -4,16 +4,16 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2008-2012 by Martin Willisegger +// (c) 2008-2017 by Martin Willisegger // // Project : NagiosQL // Component: Installation HowTo // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-03-12 08:30:07 +0100 (Mon, 12 Mar 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1288 $ -// SVN-ID : $Id: INSTALLATION_enGB.txt 1288 2012-03-12 07:30:07Z martin $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ +// SVN-ID : $Id: INSTALLATION_enGB.txt 2 2017-06-22 07:29:35Z martin $ // /////////////////////////////////////////////////////////////////////////////// @@ -26,7 +26,7 @@ * Nagios 2.x/3.x or Nagios compatible monitoring software * PHP 5.2.0 or greater including: * PHP Module: Session - * PHP Module: MySQL + * PHP Module: MySQLi * PHP Module: gettext * PHP Module: filter * PHP Module: FTP (optional) @@ -38,7 +38,7 @@ NEW INSTALLATION ================ - 1. Download and extract NagiosQL 3.2 to a directory within your Apache Document Root + 1. Download and extract NagiosQL 3.3 to a directory within your Apache Document Root 2. Start the Installation Wizard by opening install/index.php 3. Switch to your preferred language (see Appendix 1.) 4. Follow the instructions to install NagiosQL @@ -50,10 +50,10 @@ NEW INSTALLATION 1. Upgrade from NagiosQL 1.x and 2.x are not possible, you should better start at "New Installation" and after the installation is done, import Nagios configuration files with NagiosQL 2. Upgrade from NagiosQL 3.x - a. Download and extract NagiosQL 3.2 to a NEW directory and change your Apache DocumentRoot to the new directory + a. Download and extract NagiosQL 3.3 to a NEW directory and change your Apache DocumentRoot to the new directory b. If the same Apache configuration is used (old NagiosQL directory moved away and new NagiosQL directory moved to the old DocumentRoot), you should restart the apache demon before upgrade - b. Move your old config/settings.php file to the new NagiosQL 3.2 config/ folder + b. Move your old config/settings.php file to the new NagiosQL 3.3 config/ folder c. Backup your old NagiosQL database (as example with mysqldump) d. Start the Installation Wizard by opening install/index.php e. Switch to your preferred language (see Appendix) and follow the instructions diff --git a/functions/config_class.php b/functions/config_class.php index ff4e2cd..727fe55 100644 --- a/functions/config_class.php +++ b/functions/config_class.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Configuration Class // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2013-01-10 09:46:11 +0100 (Thu, 10 Jan 2013) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1351 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////////////////////// // @@ -50,7 +50,7 @@ class nagconfig { // Activities during initialisation // /////////////////////////////////////////////////////////////////////////////////////////// - function nagconfig() { + function __construct() { if (isset($_SESSION) && isset($_SESSION['SETS'])) { // Read global settings $this->arrSettings = $_SESSION['SETS']; @@ -123,7 +123,7 @@ class nagconfig { if ($arrConfigId != 1) { // Define variables $strTimeFile = "unknown"; - $intFileStamp = mktime(); + $intFileStamp = time(); foreach($arrConfigId AS $intConfigId) { // Get configuration file data $this->getConfigData($intConfigId,"target",$strTarget); @@ -226,7 +226,7 @@ class nagconfig { if ($arrConfigId != 1) { // Define variables $strTimeFile = "unknown"; - $intFileStamp = mktime(); + $intFileStamp = time(); foreach($arrConfigId AS $intConfigId) { // Get configuration file data $this->getConfigData($intConfigId,"target",$strTarget); @@ -333,7 +333,7 @@ class nagconfig { if ($strMethod == 1) { // Save configuration file if (file_exists($strConfigDir."/".$strName) && is_writable($strBackupDir) && is_writable($strConfigDir)) { - $strOldDate = date("YmdHis",mktime()); + $strOldDate = date("YmdHis",time()); copy($strConfigDir."/".$strName,$strBackupDir."/".$strName."_old_".$strOldDate); unlink($strConfigDir."/".$strName); } else if (!is_writable($strBackupDir)) { @@ -350,7 +350,7 @@ class nagconfig { // Save configuration file $intFileStamp = ftp_mdtm($this->resConnectId, $strConfigDir."/".$strName); if ($intFileStamp > -1) { - $strOldDate = date("YmdHis",mktime()); + $strOldDate = date("YmdHis",time()); $intErrorReporting = error_reporting(); error_reporting(0); $intReturn = ftp_rename($this->resConnectId,$strConfigDir."/".$strName,$strBackupDir."/".$strName."_old_".$strOldDate); @@ -374,7 +374,7 @@ class nagconfig { $intFileStamp = $arrInfo['mtime']; if ($intFileStamp > -1) { - $strOldDate = date("YmdHis",mktime()); + $strOldDate = date("YmdHis",time()); $intReturn = ssh2_sftp_rename($this->resSFTP,$strConfigDir."/".$strName,$strBackupDir."/".$strName."_old_".$strOldDate); if (!$intReturn) { $this->processClassMessage(translate('Cannot backup the old configuration file because the permissions are wrong (remote SFTP)!')."::",$this->strErrorMessage); @@ -583,7 +583,7 @@ class nagconfig { $configtp = new HTML_Template_IT($this->arrSettings['path']['base_path']."/templates/files/"); $configtp->loadTemplatefile($setTemplate, true, true); $configtp->setOptions($arrTplOptions); - $configtp->setVariable("CREATE_DATE",date("Y-m-d H:i:s",mktime())); + $configtp->setVariable("CREATE_DATE",date("Y-m-d H:i:s",time())); $this->getConfigData($intConfigID,"version",$this->intNagVersion); $configtp->setVariable("NAGIOS_QL_VERSION",$this->arrSettings['db']['version']); if ($this->intNagVersion == 3) $strVersion = "Nagios 3.x config file"; @@ -812,7 +812,7 @@ class nagconfig { $configtp = new HTML_Template_IT($this->arrSettings['path']['base_path']."/templates/files/"); $configtp->loadTemplatefile($setTemplate, true, true); $configtp->setOptions($arrTplOptions); - $configtp->setVariable("CREATE_DATE",date("Y-m-d H:i:s",mktime())); + $configtp->setVariable("CREATE_DATE",date("Y-m-d H:i:s",time())); if ($this->intNagVersion == 0) { $this->getConfigData($intConfigID,"version",$this->intNagVersion); } diff --git a/functions/content_class.php b/functions/content_class.php old mode 100755 new mode 100644 index 3a65309..ee3e9cc --- a/functions/content_class.php +++ b/functions/content_class.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Content Class // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2011-12-08 07:35:31 +0100 (Do, 08. Dez 2011) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1141 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////////////////////// // @@ -55,7 +55,7 @@ class nagcontent { // Activities during class initialization // /////////////////////////////////////////////////////////////////////////////////////////// - function nagcontent() { + function __construct() { // Read global settings $this->arrSettings = $_SESSION['SETS']; if (isset($_SESSION['domain'])) $this->intDomainId = $_SESSION['domain']; diff --git a/functions/data_class.php b/functions/data_class.php index 1bc2608..f55a01d 100644 --- a/functions/data_class.php +++ b/functions/data_class.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : NagiosQL data processing class // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-03-05 07:55:49 +0100 (Mon, 05 Mar 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1271 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////////////////////// // @@ -44,7 +44,7 @@ class nagdata { // Activities during initialisation // /////////////////////////////////////////////////////////////////////////////////////////// - function nagdata() { + function __construct() { if (isset($_SESSION) && isset($_SESSION['SETS'])) { // Read global settings $this->arrSettings = $_SESSION['SETS']; @@ -113,7 +113,7 @@ class nagdata { $strSQL = "DELETE FROM `".$strTableName."` WHERE `id` = $intDataId $strNoDelete"; $booReturn = $this->myDBClass->insertData($strSQL); if ($booReturn == false) { - $this->processClassMessage(translate('Delete failed because a database error:')."::".mysql_error()."::",$this->strInfoMessage); + $this->processClassMessage(translate('Delete failed because a database error:')."::".$this->myDBClass->strErrorMessage."::",$this->strInfoMessage); return(1); } else if ($this->myDBClass->intAffectedRows == 0) { $this->processClassMessage(translate('No data deleted. Probably the dataset does not exist or it is protected from delete.')."::",$this->strErrorMessage); @@ -137,7 +137,7 @@ class nagdata { $strSQL = "DELETE FROM `".$strTableName."` WHERE `id` = ".$elem['id']; $booReturn = $this->myDBClass->insertData($strSQL); if ($booReturn == false) { - $this->processClassMessage(translate('Delete failed because a database error:')."::".mysql_error()."::",$this->strInfoMessage); + $this->processClassMessage(translate('Delete failed because a database error:')."::".$this->myDBClass->strErrorMessage."::",$this->strInfoMessage); return(1); } else { $intDeleteCount = $intDeleteCount + $this->myDBClass->intAffectedRows; diff --git a/functions/import_class.php b/functions/import_class.php index 89e6eb6..edfbe69 100644 --- a/functions/import_class.php +++ b/functions/import_class.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Import Class // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-09-18 10:44:22 +0200 (Tue, 18 Sep 2012) $ +// Date : $LastChangedDate: 2017-06-22 13:39:15 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1346 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 7 $ // /////////////////////////////////////////////////////////////////////////////////////////////// // @@ -45,7 +45,7 @@ class nagimport { // Activities during initialisation // /////////////////////////////////////////////////////////////////////////////////////////// - function nagimport() { + function __construct() { if (isset($_SESSION) && isset($_SESSION['SETS'])) { // Read global settings $this->arrSettings = $_SESSION['SETS']; @@ -632,8 +632,8 @@ class nagimport { if ($strKeyField == "") {$strKey = $strConfigName;} else {$strKey = $strKeyField;} if ($booResult != true) { $this->strErrorMessage .= $this->myDBClass->strErrorMessage; - if ($strKeyField != "") $this->strErrorMessage .= translate('Entry')." ".$strKey." -> ".$arrImportData[$strKeyField]['value']." ".translate('inside')." ".$strTable." ".translate('could not be inserted:')." ".mysql_error()."::"; - if ($strKeyField == "") $this->strErrorMessage .= translate('Entry')." ".$strTemp1." -> ".$strTemp2.translate('inside')." ".$strTable." ".$strTable." ".translate('could not be inserted:')." ".mysql_error()."::"; + if ($strKeyField != "") $this->strErrorMessage .= translate('Entry')." ".$strKey." -> ".$arrImportData[$strKeyField]['value']." ".translate('inside')." ".$strTable." ".translate('could not be inserted:')." ".$this->myDBClass->strErrorMessage."::"; + if ($strKeyField == "") $this->strErrorMessage .= translate('Entry')." ".$strTemp1." -> ".$strTemp2.translate('inside')." ".$strTable." ".$strTable." ".translate('could not be inserted:')." ".$this->myDBClass->strErrorMessage."::"; return(1); } else { if ($strKeyField != "") $this->strInfoMessage .= translate('Entry')." ".$strKey." -> ".$arrImportData[$strKeyField]['value']." ".translate('inside')." ".$strTable." ".translate('successfully inserted')."::"; @@ -1236,7 +1236,7 @@ class nagimport { // Update data in master table $arrCommand[0] = $intSlaveId; $strValue = implode("!",$arrCommand); - $strSQL = "UPDATE `".$strDataTable."` SET `".$arrRelData['fieldName']."` = '".mysql_real_escape_string($strValue)."' WHERE `id` = ".$intDataId; + $strSQL = "UPDATE `".$strDataTable."` SET `".$arrRelData['fieldName']."` = '".$this->myDBClass->real_escape($strValue)."' WHERE `id` = ".$intDataId; $booResult = $this->myDBClass->insertData($strSQL); if ($booResult == false) $this->strErrorMessage .= $this->myDBClass->strErrorMessage; } diff --git a/functions/mysql_class.php b/functions/mysql_class.php deleted file mode 100644 index 34ed989..0000000 --- a/functions/mysql_class.php +++ /dev/null @@ -1,331 +0,0 @@ -arrSettings = $_SESSION['SETS']; - // Connect to Database - if (isset($this->arrSettings['db'])) $this->getDatabase($this->arrSettings['db']); - } - } - - /////////////////////////////////////////////////////////////////////////////////////////// - // Function: Connect to a database - /////////////////////////////////////////////////////////////////////////////////////////// - // - // Opens a connection to the database server and select a database - // - // Parameters: $arrSettings Connection parameter - // -> Key server = Servername - // -> Key username = Benutzername - // -> Key password = Passwort - // -> Key database = Datenbank - // - // Return value: true = successful - // false = error - // Status message is stored in class variable $this->strErrorMessage - // - /////////////////////////////////////////////////////////////////////////////////////////// - function getdatabase($arrSettings) { - $this->dbconnect($arrSettings['server'],$arrSettings['port'],$arrSettings['username'],$arrSettings['password']); - if ($this->error == true) { - return false; - } - $this->dbselect($arrSettings['database']); - if ($this->error == true) { - return false; - } - return true; - } - - /////////////////////////////////////////////////////////////////////////////////////////// - // Function: Get a singe data field - /////////////////////////////////////////////////////////////////////////////////////////// - // - // Sends an SQL statement to the server and returns the result of the first data field - // - // Parameters: $strSQL SQL Statement - // - // Return value: = successful - // = error - // Status message is stored in class variable $this->strErrorMessage - // - /////////////////////////////////////////////////////////////////////////////////////////// - function getFieldData($strSQL) { - // Send an SQL Statement to the server - $resQuery = mysql_query($strSQL); - // Error processing - if ($resQuery && (mysql_num_rows($resQuery) != 0) && (mysql_error() == "")) { - // return the field value at postition 0/0 - return mysql_result($resQuery,0,0); - } else if (mysql_error() != "") { - $this->strErrorMessage .= mysql_error()."::"; - $this->error = true; - return(""); - } - return(""); - } - - /////////////////////////////////////////////////////////////////////////////////////////// - // Function: Get a single dataset - /////////////////////////////////////////////////////////////////////////////////////////// - // - // Sends an SQL statement to the server and returns the result of the first data set - // - // Parameters: $strSQL SQL Statement - // $arrDataset Return value including the data set - // - // Return value: true = successful - // false = error - // Status message is stored in class variable $this->strErrorMessage - // - /////////////////////////////////////////////////////////////////////////////////////////// - function getSingleDataset($strSQL,&$arrDataset) { - $arrDataset = ""; - // Send an SQL Statement to the server - $resQuery = mysql_query($strSQL); - // Error processing - if ($resQuery && (mysql_num_rows($resQuery) != 0) && (mysql_error() == "")) { - // Fill the data to the array - $arrDataset = mysql_fetch_array($resQuery,MYSQL_ASSOC); - return true; - } else if (mysql_error() != "") { - $this->strErrorMessage .= mysql_error()."::"; - $this->error = true; - return false; - } - return true; - } - - /////////////////////////////////////////////////////////////////////////////////////////// - // Function: Get a full data part - /////////////////////////////////////////////////////////////////////////////////////////// - // - // Sends an SQL statement to the server and returns the result inside a data array - // - // Parameters: $strSQL SQL Statement - // $arrDataset Return value including the data records - // $intDataCount Return value including the number of the records - // - // Return value: true = successful - // false = error - // Status message is stored in class variable $this->strErrorMessage - // - /////////////////////////////////////////////////////////////////////////////////////////// - function getDataArray($strSQL,&$arrDataset,&$intDataCount) { - $arrDataset = ""; - $intDataCount = 0; - // Send an SQL Statement to the server - $resQuery = mysql_query($strSQL); - // Error processing - if ($resQuery && (mysql_num_rows($resQuery) != 0) && (mysql_error() == "")) { - $intDataCount = mysql_num_rows($resQuery); - $i = 0; - // Fill array - while ($arrDataTemp = mysql_fetch_array($resQuery, MYSQL_ASSOC)) { - foreach ($arrDataTemp AS $key => $value) { - $arrDataset[$i][$key] = $value; - } - $i++; - } - return true; - } else if (mysql_error() != "") { - $this->strErrorMessage .= mysql_error()."::"; - $this->error = true; - return false; - } - return true; - } - - /////////////////////////////////////////////////////////////////////////////////////////// - // Function: Insert data - /////////////////////////////////////////////////////////////////////////////////////////// - // - // Inserts data to the database server - // - // Parameters: $strSQL SQL Statement - // - // $this->intLastId Dataset insert ID - // $this->intAffectedRows The number of the affected records - // - // Return value: true = successful - // false = error - // Status message is stored in class variable $this->strErrorMessage - // - /////////////////////////////////////////////////////////////////////////////////////////// - function insertData($strSQL) { - // Send an SQL Statement to the server - $resQuery = mysql_query($strSQL); - // Error processing - if (mysql_error() == "") { - $this->intLastId = mysql_insert_id(); - $this->intAffectedRows = mysql_affected_rows(); - return true; - } else { - $this->strErrorMessage .= mysql_error()."::"; - $this->error = true; - return false; - } - } - - /////////////////////////////////////////////////////////////////////////////////////////// - // Function: Count records - /////////////////////////////////////////////////////////////////////////////////////////// - // - // Counts the number of records - // - // Parameters: $strSQL SQL Statement - // - // Return value: = successful - // 0 = no datasets or error - // Status message is stored in class variable $this->strErrorMessage - // - /////////////////////////////////////////////////////////////////////////////////////////// - function countRows($strSQL) { - // Send an SQL Statement to the server - $resQuery = mysql_query($strSQL); - // Error processing - if ($resQuery && (mysql_error() == "")) { - return mysql_num_rows($resQuery); - } else { - $this->strErrorMessage .= mysql_error()."::"; - $this->error = true; - return 0; - } - } - - /////////////////////////////////////////////////////////////////////////////////////////// - // - // help functions - // - /////////////////////////////////////////////////////////////////////////////////////////// - // Function: Connet to the database server - /////////////////////////////////////////////////////////////////////////////////////////// - // - // Parameters: $dbserver Server name - // $dbport Server port - // $dbuser Database user - // $dbpasswd Database password - // - // Return value: true = successful - // false = error - // Status message is stored in class variable $this->strErrorMessage - // - /////////////////////////////////////////////////////////////////////////////////////////// - function dbconnect($dbserver,$dbport,$dbuser,$dbpasswd) { - // Not all parameters available - if (($dbserver == "") || ($dbuser == "")) { - $this->strErrorMessage .= translate("Missing server connection parameter!")."::"; - $this->error = true; - return false; - } - $this->strDBId = @mysql_connect($dbserver.":".$dbport,$dbuser,$dbpasswd); - // Session cannot be etablished - if(!$this->strDBId) { - $this->strErrorMessage .= "[".$this->arrSettings['db']['server']."] ".translate("Connection to the database server has failed by reason:")."::"; - $this->strErrorMessage .= mysql_error()."::"; - $this->error = true; - return false; - } - return true; - } - - /////////////////////////////////////////////////////////////////////////////////////////// - // Function: select database - /////////////////////////////////////////////////////////////////////////////////////////// - // - // Parameters: $database Database name - // - // Return value: true = successful - // false = error - // Status message is stored in class variable $this->strErrorMessage - // - /////////////////////////////////////////////////////////////////////////////////////////// - function dbselect($database) { - // Not all parameters available - if ($database == "") { - $this->strErrorMessage .= translate("Missing database connection parameter!")."::"; - $this->error = true; - return false; - } - $bolConnect = @mysql_select_db($database); - // Session cannot be etablished - if(!$bolConnect) { - $this->strErrorMessage .= "[".$this->arrSettings['db']['server']."] ".translate("Connection to the database server has failed by reason:")."::"; - $this->strErrorMessage .= mysql_error()."::"; - $this->error = true; - return false; - } - $resQuery = mysql_query("set names 'utf8'"); - if (mysql_error() != "") { - $this->strErrorMessage .= mysql_error()."::"; - $this->error = true; - return false; - } - return true; - } - - /////////////////////////////////////////////////////////////////////////////////////////// - // Function: Close database connection - /////////////////////////////////////////////////////////////////////////////////////////// - // - // Return value: true = successful - // - /////////////////////////////////////////////////////////////////////////////////////////// - function dbdisconnect() { - @mysql_close($this->strDBId); - return true; - } -} -?> \ No newline at end of file diff --git a/functions/mysqli_class.php b/functions/mysqli_class.php new file mode 100644 index 0000000..9e999ab --- /dev/null +++ b/functions/mysqli_class.php @@ -0,0 +1,440 @@ + DB server name +// ----------- $arrParams['port'] -> DB server port +// $arrParams['user'] -> DB server username +// $arrParams['password'] -> DB server password +// $arrParams['database'] -> DB server database name +// +/////////////////////////////////////////////////////////////////////////////////////////////// +class mysqlidb { + // Define class variables + var $error = false; // Will be filled in functions + var $strDBId = ""; // Will be filled in functions + var $intLastId = 0; // Will be filled in functions + var $intAffectedRows = 0; // Will be filled in functions + var $strErrorMessage = ""; // Will be filled in functions + var $booSSLuse = false; // Defines if SSL is used or not + var $arrParams = ""; // Must be filled in while initialization + var $arrSQLdef = ""; // Must be filled in while initialization + var $strSQLQuote1 = "`"; // Quote char for table or row names + var $strSQLQuote2 = "'"; // Quote char for table or row names + + /////////////////////////////////////////////////////////////////////////////////////////// + // Class constructor + /////////////////////////////////////////////////////////////////////////////////////////// + // + // Activities during initialisation + // + /////////////////////////////////////////////////////////////////////////////////////////// + function __construct() { + $this->arrParams['server'] = ""; + $this->arrParams['port'] = 0; + $this->arrParams['username'] = ""; + $this->arrParams['password'] = ""; + $this->arrParams['database'] = ""; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + // Function: Connect to database + /////////////////////////////////////////////////////////////////////////////////////////// + // + // Opens a connection to the database server and select a database + // + // + // Return value: true successful + // false error + // Status message is stored in class variable $this->strErrorMessage + // + /////////////////////////////////////////////////////////////////////////////////////////// + function getdatabase() { + $this->dbconnect(); + if ($this->error == true) { + return false; + } + $this->dbselect(); + if ($this->error == true) { + return false; + } + return true; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + // Function: Get a single dataset field value + /////////////////////////////////////////////////////////////////////////////////////////// + // + // Sends an SQL statement to the server and returns the result of the first data field + // + // Parameters: $strSQL SQL Statement + // + // Return value: = successful + // = error + // Status message is stored in class variable $this->strErrorMessage + // + /////////////////////////////////////////////////////////////////////////////////////////// + function getFieldData($strSQL) { + // Reset error variables + $this->strErrorMessage = ""; + $this->error = false; + // Send the SQL statement to the server + $resQuery = mysqli_query($this->strDBId,$strSQL); + // Error processing + if ($resQuery && (mysqli_num_rows($resQuery) != 0) && (mysqli_error($this->strDBId) == "")) { + // Return the field value from position 0/0 + $arrDataset = mysqli_fetch_array($resQuery,MYSQLI_NUM); + return $arrDataset[0]; + } else if (mysqli_error($this->strDBId) != "") { + $this->strErrorMessage .= mysqli_error($this->strDBId)."::"; + $this->error = true; + return(""); + } + return(""); + } + /////////////////////////////////////////////////////////////////////////////////////////// + // Function: Get a single dataset + /////////////////////////////////////////////////////////////////////////////////////////// + // + // Sends an SQL statement to the server and returns the result of the first data set + // + // Parameters: $strSQL SQL Statement + // $arrDataset Return value including the data set + // + // Return value: true = successful + // false = error + // Status message is stored in class variable $this->strErrorMessage + // + /////////////////////////////////////////////////////////////////////////////////////////// + function getSingleDataset($strSQL,&$arrDataset) { + $arrDataset = ""; + // Reset error variables + $this->strErrorMessage = ""; + $this->error = false; + // Send the SQL statement to the server + $resQuery = mysqli_query($this->strDBId,$strSQL); + // Error processing + if ($resQuery && (mysqli_num_rows($resQuery) != 0) && (mysqli_error($this->strDBId) == "")) { + // Put the values into the array + $arrDataset = mysqli_fetch_array($resQuery,MYSQLI_ASSOC); + return true; + } else if (mysqli_error($this->strDBId) != "") { + $this->strErrorMessage .= mysqli_error($this->strDBId)."::"; + $this->error = true; + return false; + } + return true; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + // Function: Get a full data part + /////////////////////////////////////////////////////////////////////////////////////////// + // + // Sends an SQL statement to the server and returns the result inside a data array + // + // Parameters: $strSQL SQL Statement + // $arrDataset Return value including the data records + // $intDataCount Return value including the number of the records + // + // Return value: true = successful + // false = error + // Status message is stored in class variable $this->strErrorMessage + // + /////////////////////////////////////////////////////////////////////////////////////////// + function getDataArray($strSQL,&$arrDataset,&$intDataCount) { + $arrDataset = ""; + $intDataCount = 0; + // Reset error variables + $this->strErrorMessage = ""; + $this->error = false; + // Send the SQL statement to the server + $resQuery = mysqli_query($this->strDBId,$strSQL); + // Error processing + if ($resQuery && (mysqli_num_rows($resQuery) != 0) && (mysqli_error($this->strDBId) == "")) { + $intDataCount = mysqli_num_rows($resQuery); + $i = 0; + // Put the values into the array + while ($arrDataTemp = mysqli_fetch_array($resQuery,MYSQLI_ASSOC)) { + foreach ($arrDataTemp AS $key => $value) { + $arrDataset[$i][$key] = $value; + } + $i++; + } + return true; + } else if (mysqli_error($this->strDBId) != "") { + $this->strErrorMessage .= mysqli_error($this->strDBId)."::"; + $this->error = true; + return false; + } + return true; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + // Function: Insert/update/delete data + /////////////////////////////////////////////////////////////////////////////////////////// + // + // Insert/update or delete data + // + // Parameters: $strSQL SQL Statement + // $this->intLastId Dataset insert ID + // $this->intAffectedRows The number of the affected records + // + // Return value: true = successful + // false = error + // Status message is stored in class variable $this->strErrorMessage + // + /////////////////////////////////////////////////////////////////////////////////////////// + function insertData($strSQL) { + // Reset error variables + $this->strErrorMessage = ""; + $this->error = false; + // Send the SQL statement to the server + $resQuery = mysqli_query($this->strDBId,$strSQL); + // Error processing + if (mysqli_error($this->strDBId) == "") { + $this->intLastId = mysqli_insert_id($this->strDBId); + $this->intAffectedRows = mysqli_affected_rows($this->strDBId); + return true; + } else { + $this->strErrorMessage .= mysqli_error($this->strDBId)."::"; + $this->error = true; + return false; + } + } + + /////////////////////////////////////////////////////////////////////////////////////////// + // Function: Counts data rows + /////////////////////////////////////////////////////////////////////////////////////////// + // + // Counts the number of records + // + // Parameters: $strSQL SQL Statement + // + // Return value: = successful + // 0 = no datasets or error + // Status message is stored in class variable $this->strErrorMessage + // + /////////////////////////////////////////////////////////////////////////////////////////// + function countRows($strSQL) { + // Reset error variables + $this->strErrorMessage = ""; + $this->error = false; + // Send the SQL statement to the server + $resQuery = mysqli_query($this->strDBId,$strSQL); + // Error processing + if ($resQuery && (mysqli_error($this->strDBId) == "")) { + return mysqli_num_rows($resQuery); + } else { + $this->strErrorMessage .= mysqli_error($this->strDBId); + $this->error = true; + return 0; + } + } + + /////////////////////////////////////////////////////////////////////////////////////////// + // Function: Use mysqli_real_escape_string + /////////////////////////////////////////////////////////////////////////////////////////// + // + // Returns a safe insert string for database manipulations + // + // Value: $strInput Input String + // + // Return value: $strOutput Output String + // + /////////////////////////////////////////////////////////////////////////////////////////// + function real_escape($strInput) { + return mysqli_real_escape_string($this->strDBId,$strInput); + } + + /////////////////////////////////////////////////////////////////////////////////////////// + // + // Assistant functions + // + /////////////////////////////////////////////////////////////////////////////////////////// + // Function: Initialize a mysql database connection + /////////////////////////////////////////////////////////////////////////////////////////// + // + // Return value: true + // + /////////////////////////////////////////////////////////////////////////////////////////// + function dbinit() { + $this->strDBId = mysqli_init(); + return true; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + // Function: Connect to database server + /////////////////////////////////////////////////////////////////////////////////////////// + // + // Parameters: $dbserver Server name + // $dbuser Database user + // $dbpasswd Database password + // $dbname Database name + // $dbport TCP port + // + // Return value: true successful + // false error + // Status message is stored in class variable $this->strErrorMessage + // + /////////////////////////////////////////////////////////////////////////////////////////// + function dbconnect($dbserver=NULL,$dbport=NULL,$dbuser=NULL,$dbpasswd=NULL) { + // Reset error variables + $this->strErrorMessage = ""; + $this->error = false; + // Get parameters + if ($dbserver == NULL) $dbserver = $this->arrParams['server']; + if ($dbport == NULL) $dbport = $this->arrParams['port']; + if ($dbuser == NULL) $dbuser = $this->arrParams['username']; + if ($dbpasswd == NULL) $dbpasswd = $this->arrParams['password']; + // Not all parameters available + if (($dbserver == "") || ($dbuser == "") || ($dbpasswd == "")) { + $this->strErrorMessage .= gettext("Missing server connection parameter!")."::"; + $this->error = true; + return false; + } + $this->dbinit(); + if ($this->booSSLuse == true) { + // TO BE DEFINED + } + $intErrorReporting = error_reporting(); + error_reporting(0); + if ($dbport == 0) { + $booReturn = mysqli_real_connect($this->strDBId,$dbserver,$dbuser,$dbpasswd); + } else { + $booReturn = mysqli_real_connect($this->strDBId,$dbserver,$dbuser,$dbpasswd,NULL,$dbport); + } + $arrError = error_get_last(); + error_reporting($intErrorReporting); + // Connection fails + if($booReturn == false) { + $this->strErrorMessage = "[".$dbserver."] ".gettext("Connection to the database server has failed by reason:")." ::"; + if (mysqli_connect_error($this->strDBId) != "") $this->strErrorMessage .= mysqli_connect_error($this->strDBId)."::"; + $this->error = true; + return false; + } + return true; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + // Function: select database + /////////////////////////////////////////////////////////////////////////////////////////// + // + // Parameters: $database Database name + // + // Return value: true = successful + // false = error + // Status message is stored in class variable $this->strErrorMessage + // + /////////////////////////////////////////////////////////////////////////////////////////// + function dbselect($database=NULL) { + // Reset error variables + $this->strErrorMessage = ""; + $this->error = false; + // Get parameters + if ($database == NULL) $database = $this->arrParams['database']; + // Not all parameters available + if ($database == "") { + $this->strErrorMessage .= gettext("Missing database connection parameter!")."::"; + $this->error = true; + return false; + } + $bolConnect = mysqli_select_db($this->strDBId,$database); + // Session cannot be etablished + if(!$bolConnect) { + $this->strErrorMessage .= "[".$database."] ".gettext("Connection to the database has failed by reason:")." ::"; + $this->strErrorMessage .= mysqli_error($this->strDBId)."::"; + $this->error = true; + return false; + } + $resQuery = mysqli_query($this->strDBId,"set names 'utf8'"); + if (mysqli_error($this->strDBId) != "") { + $this->strErrorMessage .= mysqli_error($this->strDBId)."::"; + $this->error = true; + return false; + } + $resQuery = mysqli_query($this->strDBId,"set session sql_mode = 'NO_ENGINE_SUBSTITUTION'"); + if (mysqli_error($this->strDBId) != "") { + $this->strErrorMessage .= mysqli_error($this->strDBId)."::"; + $this->error = true; + return false; + } + return true; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + // Function: Set SSL parameters + /////////////////////////////////////////////////////////////////////////////////////////// + // + // Parameters: $sslkey SSL key + // $sslcert SSL certificate + // $sslca SSL CA file (optional) + // $sslpath SSL certificate path (optional) + // $sslcypher SSL cypher (optional) + // + // Return value: true successful + // The mysqli_ssl_set function always returns TRUE! + // + /////////////////////////////////////////////////////////////////////////////////////////// + function dbsetssl($sslkey,$sslcert,$sslca=NULL,$sslpath=NULL,$sslcypher=NULL) { + // Reset error variables + $this->strErrorMessage = ""; + $this->error = false; + // Values are missing + if (($sslkey == "") || ($sslcert == "")) { + $this->strErrorMessage = gettext("Missing MySQL SSL parameter!")."::"; + $this->error = true; + return false; + } + mysqli_ssl_set($this->strDBId,$sslkey,$sslcert,$sslca,$sslpath,$sslcypher); + return true; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + // Function: Close database server connectuon + /////////////////////////////////////////////////////////////////////////////////////////// + // + // Value: none + // + // Return value: true if successful, false if failed + // + /////////////////////////////////////////////////////////////////////////////////////////// + function dbdisconnect() { + mysqli_close($this->strDBId); + return true; + } +} +?> \ No newline at end of file diff --git a/functions/nag_class.php b/functions/nag_class.php index 389f47f..e901bb8 100644 --- a/functions/nag_class.php +++ b/functions/nag_class.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Visualization Class // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-10-03 10:00:02 +0200 (Wed, 03 Oct 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1349 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////////////////////// // @@ -46,7 +46,7 @@ class nagvisual { // Activities during initialisation // /////////////////////////////////////////////////////////////////////////////////////////// - function nagvisual() { + function __construct() { // Read global settings $this->arrSettings = $_SESSION['SETS']; if (isset($_SESSION['domain'])) $this->intDomainId = $_SESSION['domain']; @@ -229,7 +229,7 @@ class nagvisual { /////////////////////////////////////////////////////////////////////////////////////////// function tfSecure($strKey) { $strKey = stripslashes($strKey); - $strKey = mysql_real_escape_string($strKey); + $strKey = $this->myDBClass->real_escape($strKey); return($strKey); } diff --git a/functions/prepend_adm.php b/functions/prepend_adm.php index fed7d6c..a9a2734 100644 --- a/functions/prepend_adm.php +++ b/functions/prepend_adm.php @@ -4,15 +4,15 @@ // NagiosQL /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Preprocessing script // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2013-01-10 09:46:11 +0100 (Thu, 10 Jan 2013) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1351 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// //error_reporting(E_ALL); @@ -46,7 +46,7 @@ $chkDomainId = 0; $chkGroupAdm = 0; $intError = 0; $setDBVersion = "unknown"; -$setFileVersion = "3.2.0"; +$setFileVersion = "3.3.0"; // // Start PHP session // ================= @@ -91,15 +91,17 @@ if (!isset($_SESSION['SETS']['db'])) $_SESSION['SETS']['db'] = $SETS['db']; // // Include external function/class files - part 1 // ============================================== -include("mysql_class.php"); +include("mysqli_class.php"); require("translator.php"); // // Initialize classes - part 1 // =========================== -$myDBClass = new mysqldb; +$myDBClass = new mysqlidb; +$myDBClass->arrParams = $SETS['db']; +$myDBClass->getDatabase(); if ($myDBClass->error == true) { - $strErrorMessage .= translate('Error while connecting to database:')."::".$myDBClass->strErrorMessage; - $intError = 1; + $strDBMessage = $myDBClass->strErrorMessage; + $booError = $myDBClass->error; } // // Get additional configuration from the table tbl_settings @@ -264,7 +266,7 @@ if (isset($_SERVER['REMOTE_USER']) && ($_SERVER['REMOTE_USER'] != "") && ($_SESS $SETS['data']['locale'] = $strUserLocale; } // Update last login time - $strSQLUpdate = "UPDATE `tbl_user` SET `last_login`=NOW() WHERE `username`='".mysql_real_escape_string($chkInsName)."'"; + $strSQLUpdate = "UPDATE `tbl_user` SET `last_login`=NOW() WHERE `username`='".$myDBClass->real_escape($chkInsName)."'"; $booReturn = $myDBClass->insertData($strSQLUpdate); $myDataClass->writeLog(translate('Webserver login successfull')); $_SESSION['strLoginMessage'] = ""; @@ -273,8 +275,8 @@ if (isset($_SERVER['REMOTE_USER']) && ($_SERVER['REMOTE_USER'] != "") && ($_SESS } } if (($_SESSION['logged_in'] == 0) && isset($chkInsName) && ($chkInsName != "") && ($intError == 0)) { - $chkInsName = mysql_real_escape_string($chkInsName); - $chkInsPasswd = mysql_real_escape_string($chkInsPasswd); + $chkInsName = $myDBClass->real_escape($chkInsName); + $chkInsPasswd = $myDBClass->real_escape($chkInsPasswd); $strSQL = "SELECT * FROM `tbl_user` WHERE `username`='".$chkInsName."' AND `password`=MD5('".$chkInsPasswd."') AND `active`='1'"; $booReturn = $myDBClass->getDataArray($strSQL,$arrDataUser,$intDataCount); @@ -299,7 +301,7 @@ if (($_SESSION['logged_in'] == 0) && isset($chkInsName) && ($chkInsName != "") & $SETS['data']['locale'] = $strUserLocale; } // Update last login time - $strSQLUpdate = "UPDATE `tbl_user` SET `last_login`=NOW() WHERE `username`='".mysql_real_escape_string($chkInsName)."'"; + $strSQLUpdate = "UPDATE `tbl_user` SET `last_login`=NOW() WHERE `username`='".$myDBClass->real_escape($chkInsName)."'"; $booReturn = $myDBClass->insertData($strSQLUpdate); $myDataClass->writeLog(translate('Login successfull')); $_SESSION['strLoginMessage'] = ""; @@ -322,7 +324,7 @@ if (!isset($_SESSION['userid']) && ($_SESSION['logged_in'] == 1)) { // Review and update login // ======================= if (($_SESSION['logged_in'] == 1) && ($intError == 0)) { - $strSQL = "SELECT * FROM `tbl_user` WHERE `username`='".mysql_real_escape_string($_SESSION['username'])."'"; + $strSQL = "SELECT * FROM `tbl_user` WHERE `username`='".$myDBClass->real_escape($_SESSION['username'])."'"; $booReturn = $myDBClass->getDataArray($strSQL,$arrDataUser,$intDataCount); if ($booReturn == false) { $myVisClass->processMessage(translate('Error while selecting data from database:'),$strErrorMessage); diff --git a/functions/prepend_content.php b/functions/prepend_content.php old mode 100755 new mode 100644 index 0ff6d55..24abfa2 --- a/functions/prepend_content.php +++ b/functions/prepend_content.php @@ -4,15 +4,15 @@ // NagiosQL /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Preprocessing script for content pages // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2011-12-08 07:35:31 +0100 (Do, 08. Dez 2011) $ +// Date : $LastChangedDate: 2017-06-22 09:53:38 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1141 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 5 $ // /////////////////////////////////////////////////////////////////////////////// // @@ -321,7 +321,7 @@ if (($chkModus == "make") && ($intGlobalWriteAccess == 0)) { if ($intSuccess != 0) $myVisClass->processMessage(translate('Configuration files successfully written!'),$strInfoMessage); if ($intError != 0) $myVisClass->processMessage(translate('Some configuration files were not written. Dataset not activated, not found or you do not have write permission!'),$strErrorMessage); } else if ($preTableName == 'tbl_service') { - $strSQL = "SELECT `id`, `$preKeyField` FROM `$preTableName` WHERE $strDomainWhere AND `access_group` IN ($strAccess) AND `active`='1' GROUP BY `$preKeyField`"; + $strSQL = "SELECT `id`, `$preKeyField` FROM `$preTableName` WHERE $strDomainWhere AND `access_group` IN ($strAccess) AND `active`='1' GROUP BY `$preKeyField`, `id`"; $myDBClass->getDataArray($strSQL,$arrData,$intDataCount); if ($booReturn == false) $myVisClass->processMessage($myDBClass->strErrorMessage,$strErrorMessage); if ($booReturn && ($intDataCount != 0)) { diff --git a/functions/prepend_scripting.php b/functions/prepend_scripting.php index 9cedb6b..011833d 100644 --- a/functions/prepend_scripting.php +++ b/functions/prepend_scripting.php @@ -2,17 +2,18 @@ /////////////////////////////////////////////////////////////////////////////// // // NagiosQL +// /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Preprocessing script for scripting files // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-29 09:54:45 +0100 (Wed, 29 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:48:25 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1262 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 4 $ // /////////////////////////////////////////////////////////////////////////////// error_reporting(E_ALL); @@ -41,7 +42,7 @@ define('BASE_PATH', str_replace("functions","",dirname(__FILE__))); // // Read settings file // ================== -$preBasePath = str_replace("scripts","",getcwd()); +$preBasePath = str_replace("functions","",dirname(__FILE__)); $preIniFile = $preBasePath.'config/settings.php'; // // Read file settings @@ -50,16 +51,16 @@ $SETS = parse_ini_file($preIniFile,true); // // Include external function/class files - part 1 // ============================================== -include("mysql_class.php"); +include("mysqli_class.php"); // // Initialize classes - part 1 // =========================== -$myDBClass = new mysqldb; -$myDBClass->arrSettings = $SETS; -$myDBClass->getDatabase($SETS['db']); +$myDBClass = new mysqlidb; +$myDBClass->arrParams = $SETS['db']; +$myDBClass->getDatabase(); if ($myDBClass->error == true) { - echo str_replace("::","\n","Error while connecting to database: ".$myDBClass->strErrorMessage); - $intError = 1; + $strDBMessage = $myDBClass->strErrorMessage; + $booError = $myDBClass->error; } // // Get additional configuration from the table tbl_settings diff --git a/functions/translator.php b/functions/translator.php index 6e9641f..d451293 100644 --- a/functions/translator.php +++ b/functions/translator.php @@ -5,13 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // +// (c) 2005-2017 by Martin Willisegger +// // Project : NagiosQL // Component : Translation Functions // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-23 08:02:21 +0100 (Thu, 23 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1238 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/images/sort_asc.png b/images/sort_asc.png old mode 100755 new mode 100644 diff --git a/images/sort_desc.png b/images/sort_desc.png old mode 100755 new mode 100644 diff --git a/index.php b/index.php index af155ac..b5e47ab 100644 --- a/index.php +++ b/index.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Start script // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-03-14 13:43:23 +0100 (Wed, 14 Mar 2012) $ -// Author : $LastChangedBy: rouven $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1296 $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ +// Author : $LastChangedBy: martin $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // diff --git a/install/css/install.css b/install/css/install.css index 73d8148..f98cc6c 100644 --- a/install/css/install.css +++ b/install/css/install.css @@ -11,10 +11,10 @@ /* Project : NagiosQL /* Component: Installer CSS /* Website : http://www.nagiosql.org -/* Date : $LastChangedDate: 2012-02-23 07:49:34 +0100 (Thu, 23 Feb 2012) $ +/* Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ /* Author : $LastChangedBy: martin $ -/* Version : 3.1.1 -/* Revision : $LastChangedRevision: 1237 $ +/* Version : 3.3.0 +/* Revision : $LastChangedRevision: 2 $ /* /**********************************************/ @@ -413,6 +413,16 @@ input[type=submit][disabled] { margin:0px; padding-bottom:2px; } +select.required { + width:202px; + border: 1px solid #053056; + background: #941616 url(../images/inputmust.png); + font-family:Verdana, Helvetica, sans-serif; + color: #FFFFFF; + font-weight: bold; + font-size:12px; + height:22px; +} .validation-advice { margin: 5px 0; padding: 5px; diff --git a/install/functions/initial_settings.php b/install/functions/initial_settings.php old mode 100755 new mode 100644 index 42f4e8d..12e6968 --- a/install/functions/initial_settings.php +++ b/install/functions/initial_settings.php @@ -11,14 +11,14 @@ exit; ; Component: Initial configuration settings ; Website : http://www.nagiosql.org ; Date : May 27, 2011, 2:35 pm -; Version : 3.2.0 -; $LastChangedRevision: 1058 $ +; Version : 3.3.0 +; $LastChangedRevision: 2 $ ; ; DO NOT USE THIS FILE AS NAGIOSQL SETTINGS FILE! ; ;/////////////////////////////////////////////////////////////////////////////// [db] -type = mysql +type = mysqli server = localhost port = 3306 database = db_nagiosql_v32 diff --git a/install/functions/install_class.php b/install/functions/install_class.php old mode 100755 new mode 100644 index ec860c5..a6b5252 --- a/install/functions/install_class.php +++ b/install/functions/install_class.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Installer Class // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2011-12-08 07:35:31 +0100 (Do, 08. Dez 2011) $ +// Date : $LastChangedDate: 2017-06-22 11:54:45 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1141 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 6 $ // /////////////////////////////////////////////////////////////////////////////////////////////// // @@ -31,7 +31,8 @@ class naginstall { // Define class variables var $filTemplate = ""; // template file - + var $myDBClass; // Database class + /////////////////////////////////////////////////////////////////////////////////////////// // Class constructor /////////////////////////////////////////////////////////////////////////////////////////// @@ -39,7 +40,7 @@ class naginstall { // Activities during class initialization // /////////////////////////////////////////////////////////////////////////////////////////// - function naginstall() { + function __construct() { } /////////////////////////////////////////////////////////////////////////////////////////// @@ -68,7 +69,248 @@ class naginstall { } return($strTemplate); } else { - echo "File not found"; + echo $this->translate("Template file not found").": ".$strTplFile; + } + } + /////////////////////////////////////////////////////////////////////////////////////////// + // Function: Translate text + /////////////////////////////////////////////////////////////////////////////////////////// + // + // Parameter: $strLangString String to translate + // + // Return values: Translated string + // + /////////////////////////////////////////////////////////////////////////////////////////// + function translate($strLangString) { + $strLangString = gettext($strLangString); + $strLangString = str_replace('"','"',$strLangString); + $strLangString = str_replace("'",''',$strLangString); + return $strLangString; + } + /////////////////////////////////////////////////////////////////////////////////////////// + // Function: Return supported languages + /////////////////////////////////////////////////////////////////////////////////////////// + // + // Parameter: none + // + // Return values: Array including supported languages + // + /////////////////////////////////////////////////////////////////////////////////////////// + function getLangData() { + unset($arrLangSupported); + // English + $arrLangSupported['en_GB']['description'] = $this->translate('English'); + $arrLangSupported['en_GB']['nativedescription'] = 'English'; + + // German + $arrLangSupported['de_DE']['description'] = $this->translate('German'); + $arrLangSupported['de_DE']['nativedescription'] = 'Deutsch'; + + // Chinese (Simplified) + $arrLangSupported['zh_CN']['description'] = $this->translate('Chinese (Simplified)'); + $arrLangSupported['zh_CN']['nativedescription'] = '简体中文'; + + // Italian + $arrLangSupported['it_IT']['description'] = $this->translate('Italian'); + $arrLangSupported['it_IT']['nativedescription'] = 'Italiano'; + + // French + $arrLangSupported['fr_FR']['description'] = $this->translate('French'); + $arrLangSupported['fr_FR']['nativedescription'] = 'Français'; + + // Russian + $arrLangSupported['ru_RU']['description'] = $this->translate('Russian'); + $arrLangSupported['ru_RU']['nativedescription'] = 'Русский'; + + // Spanish + $arrLangSupported['es_ES']['description'] = $this->translate('Spanish'); + $arrLangSupported['es_ES']['nativedescription'] = 'Español'; + + // Brazilian Portuguese + $arrLangSupported['pt_BR']['description'] = $this->translate('Portuguese (Brazilian)'); + $arrLangSupported['pt_BR']['nativedescription'] = 'Português do Brasil'; + + // Dutch + $arrLangSupported['nl_NL']['description'] = $this->translate('Dutch'); + $arrLangSupported['nl_NL']['nativedescription'] = 'Nederlands'; + + // Danish + $arrLangSupported['da_DK']['description'] = $this->translate('Danish'); + $arrLangSupported['da_DK']['nativedescription'] = 'Dansk'; + + // No longer supported language due to missing translators + // + // // Japanese + // $arrLangSupported['ja_JP']['description'] = $this->translate('Japanese'); + // $arrLangSupported['ja_JP']['nativedescription'] = '日本語'; + // + // // Polish + // $arrLangSupported['pl_PL']['description'] = $this->translate('Polish'); + // $arrLangSupported['pl_PL']['nativedescription'] = 'Polski'; + // + // // Spanish (Argentina) + // $arrLangSupported['es_AR']['description'] = $this->translate('Spanish (Argentina)'); + // $arrLangSupported['es_AR']['nativedescription'] = 'Español Argentina'; + /// + /// Currently not supported languages + // + // // Albanian + // $arrLangSupported['sq']['description'] = $clang->$this->translate('Albanian'); + // $arrLangSupported['sq']['nativedescription'] = 'Shqipe'; + // + // // Basque + // $arrLangSupported['eu']['description'] = $this->translate('Basque'); + // $arrLangSupported['eu']['nativedescription'] = 'Euskara'; + // + // // Bosnian + // $arrLangSupported['bs']['description'] = $this->translate('Bosnian'); + // $arrLangSupported['bs']['nativedescription'] = 'Български'; + // + // // Bulgarian + // $arrLangSupported['bg']['description'] = $this->translate('Bulgarian'); + // $arrLangSupported['bg']['nativedescription'] = 'Български'; + // + // // Catalan + // $arrLangSupported['ca']['description'] = $this->translate('Catalan'); + // $arrLangSupported['ca']['nativedescription'] = 'Catalά'; + // + // // Welsh + // $arrLangSupported['cy']['description'] = $this->translate('Welsh'); + // $arrLangSupported['cy']['nativedescription'] = 'Cymraeg'; + // + // // Chinese (Traditional - Hong Kong) + // $arrLangSupported['zh-Hant-HK']['description'] = $this->translate('Chinese (Traditional - Hong Kong)'); + // $arrLangSupported['zh-Hant-HK']['nativedescription'] = '繁體中文語系'; + // + // // Chinese (Traditional - Taiwan) + // $arrLangSupported['zh-Hant-TW']['description'] = $this->translate('Chinese (Traditional - Taiwan)'); + // $arrLangSupported['zh-Hant-TW']['nativedescription'] = 'Chinese (Traditional - Taiwan)'; + // + // // Croatian + // $arrLangSupported['hr']['description'] = $this->translate('Croatian'); + // $arrLangSupported['hr']['nativedescription'] = 'Hrvatski'; + // + // // Czech + // $arrLangSupported['cs']['description'] = $this->translate('Czech'); + // $arrLangSupported['cs']['nativedescription'] = 'Česky'; + // + // // Estonian + // $arrLangSupported['et']['description'] = $this->translate('Estonian'); + // $arrLangSupported['et']['nativedescription'] = 'Eesti'; + // + // // Finnish + // $arrLangSupported['fi']['description'] = $this->translate('Finnish'); + // $arrLangSupported['fi']['nativedescription'] = 'Suomi'; + // + // // Galician + // $arrLangSupported['gl']['description'] = $this->translate('Galician'); + // $arrLangSupported['gl']['nativedescription'] = 'Galego'; + // + // // German informal + // $arrLangSupported['de-informal']['description'] = $this->translate('German informal'); + // $arrLangSupported['de-informal']['nativedescription'] = 'Deutsch (Du)'; + // + // // Greek + // $arrLangSupported['el']['description'] = $this->translate('Greek'); + // $arrLangSupported['el']['nativedescription'] = 'ελληνικά'; + // + // // Hebrew + // $arrLangSupported['he']['description'] = $this->translate('Hebrew'); + // $arrLangSupported['he']['nativedescription'] = ' עברית'; + // + // // Hungarian + // $arrLangSupported['hu']['description'] = $this->translate('Hungarian'); + // $arrLangSupported['hu']['nativedescription'] = 'Magyar'; + // + // // Indonesian + // $arrLangSupported['id']['description'] = $this->translate('Indonesian'); + // $arrLangSupported['id']['nativedescription'] = 'Bahasa Indonesia'; + // + // // Lithuanian + // $arrLangSupported['lt']['description'] = $this->translate('Lithuanian'); + // $arrLangSupported['lt']['nativedescription'] = 'Lietuvių'; + // + // // Macedonian + // $arrLangSupported['mk']['description'] = $this->translate('Macedonian'); + // $arrLangSupported['mk']['nativedescription'] = 'Македонски'; + // + // // Norwegian Bokml + // $arrLangSupported['nb']['description'] = $this->translate('Norwegian (Bokmal)'); + // $arrLangSupported['nb']['nativedescription'] = 'Norsk Bokmål'; + // + // // Norwegian Nynorsk + // $arrLangSupported['nn']['description'] = $this->translate('Norwegian (Nynorsk)'); + // $arrLangSupported['nn']['nativedescription'] = 'Norsk Nynorsk'; + // + // // Portuguese + // $arrLangSupported['pt']['description'] = $this->translate('Portuguese'); + // $arrLangSupported['pt']['nativedescription'] = 'Português'; + // + // // Romanian + // $arrLangSupported['ro']['description'] = $this->translate('Romanian'); + // $arrLangSupported['ro']['nativedescription'] = 'Românesc'; + // + // // Slovak + // $arrLangSupported['sk']['description'] = $this->translate('Slovak'); + // $arrLangSupported['sk']['nativedescription'] = 'Slovák'; + // + // // Slovenian + // $arrLangSupported['sl']['description'] = $this->translate('Slovenian'); + // $arrLangSupported['sl']['nativedescription'] = 'Slovenščina'; + // + // // Serbian + // $arrLangSupported['sr']['description'] = $this->translate('Serbian'); + // $arrLangSupported['sr']['nativedescription'] = 'Srpski'; + // + // // Spanish (Mexico) + // $arrLangSupported['es-MX']['description'] = $this->translate('Spanish (Mexico)'); + // $arrLangSupported['es-MX']['nativedescription'] = 'Español Mejicano'; + // + // // Swedish + // $arrLangSupported['sv']['description'] = $this->translate('Swedish'); + // $arrLangSupported['sv']['nativedescription'] = 'Svenska'; + // + // // Turkish + // $arrLangSupported['tr']['description'] = $this->translate('Turkish'); + // $arrLangSupported['tr']['nativedescription'] = 'Türkçe'; + // + // // Thai + // $arrLangSupported['th']['description'] = $this->translate('Thai'); + // $arrLangSupported['th']['nativedescription'] = 'ภาษาไทย'; + // + // // Vietnamese + // $arrLangSupported['vi']['description'] = $this->translate('Vietnamese'); + // $arrLangSupported['vi']['nativedescription'] = 'Tiếng Việt'; + + + foreach ($arrLangSupported as $key => $row) { + $description[$key] = $row['description']; + $nativedescription[$key] = $row['nativedescription']; + } + array_multisort($description, SORT_ASC, $nativedescription, SORT_ASC, $arrLangSupported); + //uasort($arrLangSupported,"user_sort"); + return $arrLangSupported; + } + /////////////////////////////////////////////////////////////////////////////////////////// + // Function: Translate text + /////////////////////////////////////////////////////////////////////////////////////////// + // + // Parameter: $strCode Language code + // $booNative Native code true/false + // + // Return values: Language name if found / false if not exist + // + /////////////////////////////////////////////////////////////////////////////////////////// + function getLangNameFromCode($strCode, $booNative=true) { + $arrLanguages = $this->getLangData(); + if (isset($arrLanguages[$strCode]['description'])) { + if ($booNative) { + return $arrLanguages[$strCode]['description'].' - '.$arrLanguages[$strCode]['nativedescription']; + } else { + return $arrLanguages[$strCode]['description'];} + } else { + // else return false + return false; } } /////////////////////////////////////////////////////////////////////////////////////////// @@ -83,39 +325,17 @@ class naginstall { // /////////////////////////////////////////////////////////////////////////////////////////// function openAdmDBSrv(&$strStatusMessage,&$strErrorMessage,$intMode=0) { - if ($_SESSION['install']['dbtype'] == "mysql") { - $intStatus = 0; - // Connect to database server - if ($intMode == 1 ) { - $resDBSLink = @mysql_connect($_SESSION['install']['dbserver'].":".$_SESSION['install']['dbport'],$_SESSION['install']['dbuser'],$_SESSION['install']['dbpass']); - } else { - $resDBSLink = @mysql_connect($_SESSION['install']['dbserver'].":".$_SESSION['install']['dbport'],$_SESSION['install']['admuser'],$_SESSION['install']['admpass']); - } - if (!$resDBSLink) { - $strErrorMessage .= translate('Error while connecting to database:')."
".mysql_error()."
\n"; - $intStatus = 1; - } - } else if ($_SESSION['install']['dbtype'] == "pgsql") { - // Connect to database server - if ($intMode == 1 ) { - $resDBSLink = @pg_connect("host=".$_SESSION['install']['dbserver']." port=".$_SESSION['install']['dbport']." user=".$_SESSION['install']['dbuser']." password=".$_SESSION['install']['dbpass']); - } else { - $resDBSLink = @pg_connect("host=".$_SESSION['install']['dbserver']." port=".$_SESSION['install']['dbport']." user=".$_SESSION['install']['admuser']." password=".$_SESSION['install']['admpass']); - } - if (!$resDBSLink) { - $strErrorMessage .= translate('Error while connecting to database:')."
".pg_last_error()."
\n"; - $intStatus = 1; - } - } else { - $strErrorMessage .= translate("Database type not defined!")." (".$_SESSION['install']['dbtype'].")
\n"; - $strStatusMessage = "".translate("failed").""; - return(1); - } + $intStatus = 0; + $this->myDBClass->dbconnect(); + if ($this->myDBClass->error == true) { + $strErrorMessage .= str_replace("::","
",$this->myDBClass->strErrorMessage); + $intStatus = 1; + } if ($intStatus == 0) { - $strStatusMessage = "".translate("passed").""; + $strStatusMessage = "".$this->translate("passed").""; return(0); } else { - $strStatusMessage = "".translate("failed").""; + $strStatusMessage = "".$this->translate("failed").""; return(1); } } @@ -131,35 +351,19 @@ class naginstall { // /////////////////////////////////////////////////////////////////////////////////////////// function openDatabase(&$strStatusMessage,&$strErrorMessage,$intMode=0) { - if ($_SESSION['install']['dbtype'] == "mysql") { - $intStatus = 0; - // Connect to database - $resDBId = @mysql_select_db($_SESSION['install']['dbname']); - if (!$resDBId) { - $strErrorMessage .= translate('Error while connecting to database:')."
".mysql_error()."
\n"; - $intStatus = 1; - } - } else if ($_SESSION['install']['dbtype'] == "pgsql") { - // Connect to database - if ($intMode == 1 ) { - $resDBSLink = @pg_connect("host=".$_SESSION['install']['dbserver']." port=".$_SESSION['install']['dbport']." dbname=".$_SESSION['install']['dbname']." user=".$_SESSION['install']['dbuser']." password=".$_SESSION['install']['dbpass']); - } else { - $resDBSLink = @pg_connect("host=".$_SESSION['install']['dbserver']." port=".$_SESSION['install']['dbport']." dbname=".$_SESSION['install']['dbname']." user=".$_SESSION['install']['admuser']." password=".$_SESSION['install']['admpass']); - } - if (!$resDBSLink) { - $strErrorMessage .= translate('Error while connecting to database:')."
".pg_last_error()."
\n"; - $intStatus = 1; - } - } else { - $strErrorMessage .= translate("Database type not defined!")." (".$_SESSION['install']['dbtype'].")
\n"; - $strStatusMessage = "".translate("failed").""; - return(1); - } + $intStatus = 0; + // Connect to database + $booDB = $this->myDBClass->dbselect(); + if (!$booDB) { + $strErrorMessage .= $this->translate('Error while connecting to database:')."
"; + $strErrorMessage .= str_replace("::","
",$this->myDBClass->strErrorMessage)."\n"; + $intStatus = 1; + } if ($intStatus == 0) { - $strStatusMessage = "".translate("passed").""; + $strStatusMessage = "".$this->translate("passed").""; return(0); } else { - $strStatusMessage = "".translate("failed").""; + $strStatusMessage = "".$this->translate("failed").""; return(1); } } @@ -176,31 +380,24 @@ class naginstall { /////////////////////////////////////////////////////////////////////////////////////////// function checkDBVersion(&$strStatusMessage,&$strErrorMessage,&$setVersion) { // Read version string from DB - if ($_SESSION['install']['dbtype'] == "mysql") { - $setVersion = @mysql_result(@mysql_query("SHOW VARIABLES LIKE 'version'"),0,1); - $strDBError = mysql_error(); + if (($_SESSION['install']['dbtype'] == "mysql") || ($_SESSION['install']['dbtype'] == "mysqli")) { + $this->myDBClass->getSingleDataset("SHOW VARIABLES LIKE 'version'",$arrDataset); + $setVersion = $arrDataset['Value']; + $strDBError = str_replace("::","
",$this->myDBClass->strErrorMessage); $intVersion = version_compare($setVersion,"4.1.0"); - } else if ($_SESSION['install']['dbtype'] == "pgsql") { - $setVersion = @pg_fetch_result(@pg_query("SHOW VARIABLES LIKE 'version'"),0,1); - $strDBError = pg_last_error(); - $intVersion = version_compare($setVersion,"4.1.0"); - } else { - $strErrorMessage .= translate("Database type not defined!")." (".$_SESSION['install']['dbtype'].")
\n"; - $strStatusMessage = "".translate("failed").""; - return(1); } if ($strDBError == "") { // Is the currrent version supported? if ($intVersion >=0) { - $strStatusMessage = "".translate("supported").""; + $strStatusMessage = "".$this->translate("supported").""; return(0); } else { - $strStatusMessage = "".translate("not supported").""; + $strStatusMessage = "".$this->translate("not supported").""; return(1); } } else { $strErrorMessage .= $strDBError."
\n"; - $strStatusMessage = "".translate("failed").""; + $strStatusMessage = "".$this->translate("failed").""; $setVersion = "unknown"; return(1); } @@ -218,18 +415,9 @@ class naginstall { // /////////////////////////////////////////////////////////////////////////////////////////// function checkQLVersion(&$strStatusMessage,&$strErrorMessage,&$arrUpdate,&$setVersion) { - // Read version string from DB - if ($_SESSION['install']['dbtype'] == "mysql") { - $setVersion = @mysql_result(@mysql_query("SELECT `value` FROM `tbl_settings` WHERE `category`='db' AND `name`='version'"),0,0); - $strDBError = mysql_error(); - } else if ($_SESSION['install']['dbtype'] == "pgsql") { - $setVersion = @pg_fetch_result(@pg_query("SELECT `value` FROM `tbl_settings` WHERE `category`='db' AND `name`='version'"),0,0); - $strDBError = pg_last_error(); - } else { - $strErrorMessage .= translate("Database type not defined!")." (".$_SESSION['install']['dbtype'].")
\n"; - $strStatusMessage = "".translate("failed").""; - return(1); - } + $strSQL = "SELECT `value` FROM `tbl_settings` WHERE `category`='db' AND `name`='version'"; + $setVersion = $this->myDBClass->getFieldData($strSQL); + $strDBError = str_replace("::","
",$this->myDBClass->strErrorMessage); // Process result if (($strDBError == "") && ($setVersion != "")) { // NagiosQL version supported? @@ -256,28 +444,30 @@ class naginstall { break; case '3.1.1': $arrUpdate[] = "sql/update_311_320.sql"; break; - case '3.2.0': $intVersionError = 2; + case '3.2.0': $intVersionError = 2; + break; + case '3.3.0': $intVersionError = 2; break; default: $intVersionError = 1; break; } if ($intVersionError == 0) { - $strStatusMessage = "".translate("supported")." (".$setVersion.")"; + $strStatusMessage = "".$this->translate("supported")." (".$setVersion.")"; return(0); } else if ($intVersionError == 2) { - $strErrorMessage .= translate("Your NagiosQL installation is up to date - no further actions are needed!")."
\n"; - $strStatusMessage = "".translate("up-to-date")." (".$setVersion.")"; + $strErrorMessage .= $this->translate("Your NagiosQL installation is up to date - no further actions are needed!")."
\n"; + $strStatusMessage = "".$this->translate("up-to-date")." (".$setVersion.")"; return(1); } else { - $strErrorMessage .= translate("Updates to NagiosQL 3.2 and above are only supported from NagiosQL 3.0.0 and above!")."
\n"; - $strStatusMessage = "".translate("failed")." (".$setVersion.")"; + $strErrorMessage .= $this->translate("Updates to NagiosQL 3.2 and above are only supported from NagiosQL 3.0.0 and above!")."
\n"; + $strStatusMessage = "".$this->translate("failed")." (".$setVersion.")"; return(1); } } else { - $strErrorMessage .= translate("Error while selecting settings table.")."
\n"; + $strErrorMessage .= $this->translate("Error while selecting settings table.")."
\n"; $strErrorMessage .= $strDBError."
\n"; - $strErrorMessage .= translate("Updates to NagiosQL 3.2 and above are only supported from NagiosQL 3.0.0 and above!")."
\n"; - $strStatusMessage = "".translate("failed").""; + $strErrorMessage .= $this->translate("Updates to NagiosQL 3.2 and above are only supported from NagiosQL 3.0.0 and above!")."
\n"; + $strStatusMessage = "".$this->translate("failed").""; return(1); } } @@ -292,24 +482,14 @@ class naginstall { // /////////////////////////////////////////////////////////////////////////////////////////// function dropDB(&$strStatusMessage,&$strErrorMessage) { - // Drop database - if ($_SESSION['install']['dbtype'] == "mysql") { - $booReturn = @mysql_query("DROP DATABASE `".$_SESSION['install']['dbname']."`"); - $strDBError = mysql_error(); - } else if ($_SESSION['install']['dbtype'] == "pgsql") { - $setVersion = @pg_query("DROP DATABASE `".$_SESSION['install']['dbname']."`"); - $strDBError = pg_last_error(); - } else { - $strErrorMessage .= translate("Database type not defined!")." (".$_SESSION['install']['dbtype'].")
\n"; - $strStatusMessage = "".translate("failed").""; - return(1); - } + $booReturn = $this->myDBClass->insertData("DROP DATABASE ".$_SESSION['install']['dbname']); + $strDBError = str_replace("::","
",$this->myDBClass->strErrorMessage); if ($booReturn) { - $strStatusMessage = "".translate("done")." (".$_SESSION['install']['dbname'].")"; + $strStatusMessage = "".$this->translate("done")." (".$_SESSION['install']['dbname'].")"; return(0); } else { $strErrorMessage .= $strDBError."
\n"; - $strStatusMessage = "".translate("failed")." (".$_SESSION['install']['dbname'].")"; + $strStatusMessage = "".$this->translate("failed")." (".$_SESSION['install']['dbname'].")"; return(1); } } @@ -325,26 +505,24 @@ class naginstall { /////////////////////////////////////////////////////////////////////////////////////////// function createDB(&$strStatusMessage,&$strErrorMessage) { // Create database - if ($_SESSION['install']['dbtype'] == "mysql") { - $booReturn = @mysql_query("CREATE DATABASE `".$_SESSION['install']['dbname']."` DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci"); - $strDBError = mysql_error(); - } else if ($_SESSION['install']['dbtype'] == "pgsql") { - $setVersion = @pg_query("CREATE DATABASE `".$_SESSION['install']['dbname']."` DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci"); - $strDBError = pg_last_error(); + if (($_SESSION['install']['dbtype'] == "mysql") || ($_SESSION['install']['dbtype'] == "mysqli")) { + $strSQL = "CREATE DATABASE ".$_SESSION['install']['dbname']." DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci"; } else { - $strErrorMessage .= translate("Database type not defined!")." (".$_SESSION['install']['dbtype'].")
\n"; - $strStatusMessage = "".translate("failed").""; - return(1); + $strErrorMessage .= $this->translate("Unsupported database type.")."
\n"; + $strStatusMessage = "".$this->translate("failed")." (".$_SESSION['install']['dbname'].")"; + return(1); } + $booReturn = $this->myDBClass->insertData($strSQL); + $strDBError = str_replace("::","
",$this->myDBClass->strErrorMessage); if ($booReturn) { - $strStatusMessage = "".translate("done")." (".$_SESSION['install']['dbname'].")"; + $strStatusMessage = "".$this->translate("done")." (".$_SESSION['install']['dbname'].")"; return(0); } else { $strErrorMessage .= $strDBError."
\n"; - $strStatusMessage = "".translate("failed")." (".$_SESSION['install']['dbname'].")"; + $strStatusMessage = "".$this->translate("failed")." (".$_SESSION['install']['dbname'].")"; return(1); } - } + } /////////////////////////////////////////////////////////////////////////////////////////// // Function: Grant user to database /////////////////////////////////////////////////////////////////////////////////////////// @@ -357,76 +535,51 @@ class naginstall { /////////////////////////////////////////////////////////////////////////////////////////// function grantDBUser(&$strStatusMessage,&$strErrorMessage) { // Grant user - if ($_SESSION['install']['dbtype'] == "mysql") { + if (($_SESSION['install']['dbtype'] == "mysql") || ($_SESSION['install']['dbtype'] == "mysqli")) { // does the user exist? - $intUserError = 0; - $resQuery = @mysql_query("FLUSH PRIVILEGES"); - $resQuery1 = @mysql_query("SELECT * FROM `mysql`.`user` WHERE `Host`='".$_SESSION['install']['localsrv']."' AND `User`='".$_SESSION['install']['dbuser']."'"); - if ($resQuery1 && (mysql_num_rows($resQuery1) == 0)) { - $resQuery2 = @mysql_query("CREATE USER '".$_SESSION['install']['dbuser']."'@'".$_SESSION['install']['localsrv']."' IDENTIFIED BY '".$_SESSION['install']['dbpass']."'"); - if (!$resQuery2) { + $intUserError = 0; + $booReturn = $this->myDBClass->insertData("FLUSH PRIVILEGES"); + $strSQL = "SELECT * FROM `mysql`.`user` + WHERE `Host`='".$_SESSION['install']['localsrv']."' AND `User`='".$_SESSION['install']['dbuser']."'"; + $intCount = $this->myDBClass->countRows($strSQL); + if ($intCount == 0) { + $strSQL = "CREATE USER '".$_SESSION['install']['dbuser']."'@'".$_SESSION['install']['localsrv']."' IDENTIFIED BY '".$_SESSION['install']['dbpass']."'"; + $booReturn = $this->myDBClass->insertData($strSQL ); + if ($booReturn == false) { $intUserError = 1; - $strDBError = mysql_error(); + $strDBError = str_replace("::","
",$this->myDBClass->strErrorMessage); } - } else if (mysql_error() == ""){ - $intUserError = 2; + } else if ($this->myDBClass->strErrorMessage == "") { + $intUserError = 2; } else { $intUserError = 1; - $strDBError = mysql_error(); + $strDBError = str_replace("::","
",$this->myDBClass->strErrorMessage); } if ($intUserError != 1) { - $resQuery = @mysql_query("FLUSH PRIVILEGES"); - $resQuery = @mysql_query("GRANT SELECT, INSERT, UPDATE, DELETE, LOCK TABLES ON `".$_SESSION['install']['dbname']."`.* TO '".$_SESSION['install']['dbuser']."'@'".$_SESSION['install']['localsrv']."'"); - if (!$resQuery) { + $booReturn = $this->myDBClass->insertData("FLUSH PRIVILEGES"); + $strSQL = "GRANT SELECT, INSERT, UPDATE, DELETE, LOCK TABLES ON `".$_SESSION['install']['dbname']."`.* + TO '".$_SESSION['install']['dbuser']."'@'".$_SESSION['install']['localsrv']."'"; + $booReturn = $this->myDBClass->insertData($strSQL); + if ($booReturn == false) { $intUserError = 1; - $strDBError = mysql_error(); + $strDBError = str_replace("::","
",$this->myDBClass->strErrorMessage); } - $resQuery = @mysql_query("FLUSH PRIVILEGES"); + $booReturn = $this->myDBClass->insertData("FLUSH PRIVILEGES"); } - } else if ($_SESSION['install']['dbtype'] == "pgsql") { - // does the user exist? - $intUserError = 0; - $resQuery = @pg_query("FLUSH PRIVILEGES"); - $resQuery1 = @pg_query("SELECT * FROM `mysql`.`user WHERE `Host`='".$_SESSION['install']['localsrv']."' AND `User`='".$_SESSION['install']['dbuser']."'"); - if ($resQuery1 && (pg_num_rows($resQuery) != 0)) { - $resQuery2 = @pg_query("CREATE USER '".$_SESSION['install']['dbuser']."'@'".$_SESSION['install']['localsrv']."' IDENTIFIED BY '".$_SESSION['install']['dbpass']."'"); - if (!$resQuery2) { - $intUserError = 1; - $strDBError = pg_last_error(); - } - } else if (mysql_error() == ""){ - $intUserError = 2; - } else { - $intUserError = 1; - $strDBError = pg_last_error(); - } - if ($intUserError != 1) { - $resQuery = @pg_query("FLUSH PRIVILEGES"); - $resQuery = @pg_query("GRANT SELECT, INSERT, UPDATE, DELETE, LOCK TABLES ON `".$_SESSION['install']['dbname']."`.* TO '".$_SESSION['install']['dbuser']."'@'".$_SESSION['install']['localsrv']."'"); - if (!$resQuery) { - $intUserError = 1; - $strDBError = pg_last_error(); - } - $resQuery = @pg_query("FLUSH PRIVILEGES"); - } - } else { - $strErrorMessage .= translate("Database type not defined!")." (".$_SESSION['install']['dbtype'].")
\n"; - $strStatusMessage = "".translate("failed").""; - return(1); } if ($intUserError != 1) { if ($intUserError == 2) { - $strStatusMessage = "".translate("done")." (".translate("Only added rights to existing user").": ".$_SESSION['install']['dbuser'].")"; + $strStatusMessage = "".$this->translate("done")." (".$this->translate("Only added rights to existing user").": ".$_SESSION['install']['dbuser'].")"; } else { - $strStatusMessage = "".translate("done").""; + $strStatusMessage = "".$this->translate("done").""; } return(0); } else { $strErrorMessage .= $strDBError."
\n"; - $strStatusMessage = "".translate("failed").""; + $strStatusMessage = "".$this->translate("failed").""; return(1); } - } + } /////////////////////////////////////////////////////////////////////////////////////////// // Function: Update NagiosQL database /////////////////////////////////////////////////////////////////////////////////////////// @@ -450,23 +603,19 @@ class naginstall { $strSqlCommand = ""; $intSQLError = 0; $intLineCount = 0; - if ($_SESSION['install']['dbtype'] == "mysql") $booReturn = @mysql_query("SET NAMES `utf8`"); - if ($_SESSION['install']['dbtype'] == "pgsql") $booReturn = @pg_query("SET NAMES `utf8`"); while (!feof($filSqlNew)) { $strLine = fgets($filSqlNew); $strLine = trim($strLine); if ($intSQLError == 1) continue; // skip if an error was found $intLineCount++; - if ($strLine == "") continue; // skip empty lines + if ($strLine == "") continue; // skip empty lines if (substr($strLine,0,2) == "--") continue; // skip comment lines $strSqlCommand .= $strLine; if (substr($strSqlCommand,-1) == ";") { - if ($_SESSION['install']['dbtype'] == "mysql") $booReturn = @mysql_query($strSqlCommand); - if ($_SESSION['install']['dbtype'] == "pgsql") $booReturn = @pg_query($strSqlCommand); - if (!$booReturn) { + $booReturn = $this->myDBClass->insertData($strSqlCommand); + if ($booReturn == false) { $intSQLError = 1; - if ($_SESSION['install']['dbtype'] == "mysql") $strErrorMessage .= mysql_error()."
\n"; - if ($_SESSION['install']['dbtype'] == "pgsql") $strErrorMessage .= pg_last_error()."
\n"; + $strErrorMessage .= str_replace("::","
",$this->myDBClass->strErrorMessage); $intError = 1; } $strSqlCommand = ""; @@ -475,30 +624,30 @@ class naginstall { if ($intSQLError == 0) { $intUpdateOk++; } else { - $strStatusMessage = "".translate("failed")." (Line: ".$intLineCount." in file: ".$elem.")"; + $strStatusMessage = "".$this->translate("failed")." (Line: ".$intLineCount." in file: ".$elem.")"; $intUpdateError++; } } else { - $strStatusMessage = "".translate("failed").""; - $strErrorMessage .= translate("SQL file is not readable or empty")." (".$elem.")
\n"; + $strStatusMessage = "".$this->translate("failed").""; + $strErrorMessage .= $this->translate("SQL file is not readable or empty")." (".$elem.")
\n"; $intUpdateError++; } } else { - $strStatusMessage = "".translate("failed").""; - $strErrorMessage .= translate("SQL file is not readable or empty")." (".$elem.")
\n"; + $strStatusMessage = "".$this->translate("failed").""; + $strErrorMessage .= $this->translate("SQL file is not readable or empty")." (".$elem.")
\n"; $intUpdateError++; } } } if ($intUpdateError == 0) { - $strStatusMessage = "".translate("done").""; + $strStatusMessage = "".$this->translate("done").""; return(0); } else { return(1); } } else { - $strStatusMessage = "".translate("failed").""; - $strErrorMessage .= translate("No SQL update files available")."
\n"; + $strStatusMessage = "".$this->translate("failed").""; + $strErrorMessage .= $this->translate("No SQL update files available")."
\n"; return(1); } } @@ -514,28 +663,21 @@ class naginstall { /////////////////////////////////////////////////////////////////////////////////////////// function createNQLAdmin(&$strStatusMessage,&$strErrorMessage) { // Create admin user - $strSQL = "SELECT `id` FROM `tbl_language` WHERE `locale`='".$_SESSION['install']['locale']."'"; - $intLang = @mysql_result(@mysql_query($strSQL),0,0)+0; + $strSQL = "SELECT `id` FROM `tbl_language` WHERE `locale`='".$_SESSION['install']['locale']."'"; + $intLang = $this->myDBClass->getFieldData($strSQL)+0; if ($intLang == 0) $intLang = 1; - $strSQL = "INSERT INTO `tbl_user` (`id`, `username`, `alias`, `password`, `admin_enable`, `wsauth`, `active`, `nodelete`, `language`, `domain`, `last_login`, `last_modified`) - VALUES (1, '".$_SESSION['install']['qluser']."', 'Administrator', md5('".$_SESSION['install']['qlpass']."'), '1', '0', '1', '1', '".$intLang."', '1', '', NOW());"; - if ($_SESSION['install']['dbtype'] == "mysql") { - $booReturn = @mysql_query($strSQL); - $strDBError = mysql_error(); - } else if ($_SESSION['install']['dbtype'] == "pgsql") { - $setVersion = @pg_query($strSQL); - $strDBError = pg_last_error(); - } else { - $strErrorMessage .= translate("Database type not defined!")." (".$_SESSION['install']['dbtype'].")
\n"; - $strStatusMessage = "".translate("failed").""; - return(1); - } + $strSQL = "INSERT INTO `tbl_user` (`id`, `username`, `alias`, `password`, `admin_enable`, `wsauth`, `active`, + `nodelete`, `language`, `domain`, `last_login`, `last_modified`) + VALUES (1, '".$_SESSION['install']['qluser']."', 'Administrator', md5('".$_SESSION['install']['qlpass']."'), + '1', '0', '1', '1', '".$intLang."', '1', '', NOW());"; + $booReturn = $this->myDBClass->insertData($strSQL); + $strDBError = str_replace("::","
",$this->myDBClass->strErrorMessage); if ($booReturn) { - $strStatusMessage = "".translate("done").""; + $strStatusMessage = "".$this->translate("done").""; return(0); } else { $strErrorMessage .= $strDBError."
\n"; - $strStatusMessage = "".translate("failed").""; + $strStatusMessage = "".$this->translate("failed").""; return(1); } } @@ -553,43 +695,31 @@ class naginstall { // Checking initial settings $arrInitial[] = array('category'=>'db','name'=>'version','value'=>$_SESSION['install']['version']); $arrInitial[] = array('category'=>'db','name'=>'type','value'=>$_SESSION['install']['dbtype']); - foreach ($_SESSION['init_settings'] AS $key=>$elem) { + foreach ($_SESSION['init_settings'] AS $key => $elem) { if ($key == 'db') continue; // do not store db values to database foreach ($elem AS $key2=>$elem2) { $arrInitial[] = array('category'=>$key,'name'=>$key2,'value'=>$elem2); } } foreach ($arrInitial AS $elem) { - $strSQL1 = "SELECT `value` FROM `tbl_settings` WHERE `category`='".$elem['category']."' AND `name`='".$elem['name']."'"; - $strSQL2 = "INSERT INTO `tbl_settings` (`category`, `name`, `value`) VALUES ('".$elem['category']."', '".$elem['name']."', '".$elem['value']."')"; - if ($_SESSION['install']['dbtype'] == "mysql") { - $resQuery1 = @mysql_query($strSQL1); - if ($resQuery1 && (mysql_num_rows($resQuery1) == 0)) { - $resQuery2 = @mysql_query($strSQL2); - if (!$resQuery2) { - $strStatusMessage = "".translate("failed").""; - $strErrorMessage .= translate("Inserting initial data to settings database has failed:")."
".mysql_error()."
\n"; - return(1); - } - } else if (!$resQuery1) { - $strStatusMessage = "".translate("failed").""; - $strErrorMessage .= translate("Inserting initial data to settings database has failed:")." ".mysql_error()."
\n"; + $strSQL1 = "SELECT `value` FROM `tbl_settings` WHERE `category`='".$elem['category']."' + AND `name`='".$elem['name']."'"; + $strSQL2 = "INSERT INTO `tbl_settings` (`category`, `name`, `value`) + VALUES ('".$elem['category']."', '".$elem['name']."', '".$elem['value']."')"; + $intCount = $this->myDBClass->countRows($strSQL1); + if ($intCount == 0) { + $booReturn = $this->myDBClass->insertData($strSQL2); + if ($booReturn == false) { + $strStatusMessage = "".$this->translate("failed").""; + $strErrorMessage .= $this->translate("Inserting initial data to settings database has failed:")."1
"; + $strErrorMessage .= str_replace("::","
",$this->myDBClass->strErrorMessage); return(1); - } - } else if ($_SESSION['install']['dbtype'] == "pgsql") { - $resQuery1 = @pg_query($strSQL1); - if ($resQuery1 && (pg_num_rows($resQuery1) == 0)) { - $resQuery2 = @pg_query($strSQL2); - if (!$resQuery2) { - $strStatusMessage = "".translate("failed").""; - $strErrorMessage .= translate("Inserting initial data to settings database has failed:")."
".pg_last_error()."
\n"; - return(1); - } - } else if (!$resQuery1) { - $strStatusMessage = "".translate("failed").""; - $strErrorMessage .= translate("Inserting initial data to settings database has failed:")." ".pg_last_error()."
\n"; - return(1); - } + } + } else if ($this->myDBClass->strErrorMessage != "") { + $strStatusMessage = "".$this->translate("failed").""; + $strErrorMessage .= $this->translate("Inserting initial data to settings database has failed:")."2
"; + $strErrorMessage .= str_replace("::","
",$this->myDBClass->strErrorMessage); + return(1); } } // Update some values @@ -599,30 +729,23 @@ class naginstall { } else { $arrSettings[] = array('category'=>'path','name'=>'protocol','value'=>'http'); } - $strBaseURL = str_replace("install/install.php","",$_SERVER["PHP_SELF"]); - $arrSettings[] = array('category'=>'path','name'=>'base_url','value'=>$strBaseURL); - $strBasePath = substr(realpath('.'),0,-7); - $arrSettings[] = array('category'=>'path','name'=>'base_path','value'=>$strBasePath); + //$strBaseURL = str_replace("install/install.php","",$_SERVER["PHP_SELF"]); + //$arrSettings[] = array('category'=>'path','name'=>'base_url','value'=>$strBaseURL); + //$strBasePath = substr(realpath('.'),0,-7); + //$arrSettings[] = array('category'=>'path','name'=>'base_path','value'=>$strBasePath); $arrSettings[] = array('category'=>'data','name'=>'locale','value'=>$_SESSION['install']['locale']); foreach ($arrSettings AS $elem) { - $strSQL = "UPDATE `tbl_settings` SET `value`='".$elem['value']."' WHERE `category` = '".$elem['category']."' AND `name` = '".$elem['name']."'"; - if ($_SESSION['install']['dbtype'] == "mysql") { - $resQuery = @mysql_query($strSQL); - if (mysql_error() != '') { - $strStatusMessage = "".translate("failed").""; - $strErrorMessage .= translate("Inserting initial data to settings database has failed:")." ".mysql_error()."
\n"; - return(1); - } - } else if ($_SESSION['install']['dbtype'] == "pgsql") { - $resQuery = @pg_query($strSQL); - if (pg_last_error() != '') { - $strStatusMessage = "".translate("failed").""; - $strErrorMessage .= translate("Inserting initial data to settings database has failed:")." ".pg_last_error()."
\n"; - return(1); - } + $strSQL = "UPDATE `tbl_settings` SET `value`='".$elem['value']."' + WHERE `category` = '".$elem['category']."' AND `name` = '".$elem['name']."'"; + $booReturn = $this->myDBClass->insertData($strSQL); + if ($booReturn == false) { + $strStatusMessage = "".$this->translate("failed").""; + $strErrorMessage .= $this->translate("Inserting initial data to settings database has failed:"); + $strErrorMessage .= str_replace("::","
",$this->myDBClass->strErrorMessage); + return(1); } } - $strStatusMessage = "".translate("done").""; + $strStatusMessage = "".$this->translate("done").""; return(0); } /////////////////////////////////////////////////////////////////////////////////////////// @@ -672,11 +795,11 @@ class naginstall { fwrite($filSettings,"base_url = ".$strBaseURL."\n"); fwrite($filSettings,"base_path = ".$strBasePath."\n"); fclose($filSettings); - $strStatusMessage = "".translate("done").""; + $strStatusMessage = "".$this->translate("done").""; return(0); } else { - $strStatusMessage = "".translate("failed").""; - $strErrorMessage .= translate("Connot open/write to config/settings.php")."
\n"; + $strStatusMessage = "".$this->translate("failed").""; + $strErrorMessage .= $this->translate("Connot open/write to config/settings.php")."
\n"; return(1); } } @@ -694,32 +817,23 @@ class naginstall { // Update configuration target database $strNagiosQLpath = str_replace("//","/",$_SESSION['install']['qlpath']."/"); $strNagiosPath = str_replace("//","/",$_SESSION['install']['nagpath']."/"); - $strSQL = "UPDATE `tbl_configtarget` SET - `basedir`='".$strNagiosQLpath."', - `hostconfig`='".$strNagiosQLpath."hosts/', - `serviceconfig`='".$strNagiosQLpath."services/', - `backupdir`='".$strNagiosQLpath."backup/', - `hostbackup`='".$strNagiosQLpath."backup/hosts/', - `servicebackup`='".$strNagiosQLpath."backup/services/', - `nagiosbasedir`='".$strNagiosPath."', - `importdir`='".$strNagiosPath."objects/', - `conffile`='".$strNagiosPath."nagios.cfg', - `last_modified`=NOW() - WHERE `target`='localhost'"; - if ($_SESSION['install']['dbtype'] == "mysql") { - $resQuery1 = @mysql_query($strSQL); - if (!$resQuery1) { - $strStatusMessage = "".translate("failed").""; - $strErrorMessage .= translate("Inserting path data to database has failed:")." ".mysql_error()."
\n"; - return(1); - } - } else if ($_SESSION['install']['dbtype'] == "pgsql") { - $resQuery1 = @pg_query($strSQL); - if (!$resQuery1) { - $strStatusMessage = "".translate("failed").""; - $strErrorMessage .= translate("Inserting path data to database has failed:")." ".pg_last_error()."
\n"; - return(1); - } + $strSQL = "UPDATE `tbl_configtarget` SET + `basedir`='".$strNagiosQLpath."', + `hostconfig`='".$strNagiosQLpath."hosts/', + `serviceconfig`='".$strNagiosQLpath."services/', + `backupdir`='".$strNagiosQLpath."backup/', + `hostbackup`='".$strNagiosQLpath."backup/hosts/', + `servicebackup`='".$strNagiosQLpath."backup/services/', + `nagiosbasedir`='".$strNagiosPath."', + `importdir`='".$strNagiosPath."objects/', + `conffile`='".$strNagiosPath."nagios.cfg', + `last_modified`=NOW() + WHERE `target`='localhost'"; + $booReturn = $this->myDBClass->insertData($strSQL); + if ($booReturn == false) { + $strStatusMessage = "".$this->translate("failed").""; + $strErrorMessage .= $this->translate("Inserting path data to database has failed:")." ".str_replace("::","
",$this->myDBClass->strErrorMessage)."\n"; + return(1); } // Create real paths if ($_SESSION['install']['createpath'] == 1) { @@ -729,23 +843,17 @@ class naginstall { if (!file_exists($strNagiosQLpath."backup")) mkdir($strNagiosQLpath."backup",0755); if (!file_exists($strNagiosQLpath."backup/hosts")) mkdir($strNagiosQLpath."backup/hosts",0755); if (!file_exists($strNagiosQLpath."backup/services")) mkdir($strNagiosQLpath."backup/services",0755); - $strStatusMessage = "".translate("done")." (".translate("Check the permissions of the created paths!").")"; + $strStatusMessage = "".$this->translate("done")." (".$this->translate("Check the permissions of the created paths!").")"; return(0); } else { - $strStatusMessage = "".translate("failed").""; - $strErrorMessage .= translate("NagiosQL config path is not writeable - only database values updated")."
\n"; + $strStatusMessage = "".$this->translate("failed").""; + $strErrorMessage .= $this->translate("NagiosQL config path is not writeable - only database values updated")."
\n"; return(1); } } - $strStatusMessage = "".translate("done").""; + $strStatusMessage = "".$this->translate("done").""; return(0); } - - - - - - /////////////////////////////////////////////////////////////////////////////////////////// // Function: Converting NagiosQL database to utf-8 /////////////////////////////////////////////////////////////////////////////////////////// @@ -757,24 +865,18 @@ class naginstall { // /////////////////////////////////////////////////////////////////////////////////////////// function convQLDB(&$strStatusMessage,&$strErrorMessage) { - // Read version string from DB - if ($_SESSION['install']['dbtype'] == "mysql") { - $resQuery = @mysql_query("ALTER DATABASE `".$_SESSION['install']['dbname']."` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci"); - $strDBError = mysql_error(); - } else if ($_SESSION['install']['dbtype'] == "pgsql") { - $resQuery = @pg_query("ALTER DATABASE `".$_SESSION['install']['dbname']."` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci"); - $strDBError = pg_last_error(); - } else { - $strErrorMessage .= translate("Database type not defined!")." (".$_SESSION['install']['dbtype'].")
\n"; - $strStatusMessage = "".translate("failed").""; - return(1); + $strDBError = ""; + if ($_SESSION['install']['dbtype'] == "mysqli") { + $strSQL = "ALTER DATABASE `".$_SESSION['install']['dbname']."` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci"; + $booReturn = $this->myDBClass->insertData($strSQL); + $strDBError = str_replace("::","
",$this->myDBClass->strErrorMessage); } if ($strDBError == "") { - $strStatusMessage = "".translate("done").""; + $strStatusMessage = "".$this->translate("done").""; return(0); } else { - $strErrorMessage .= translate("Database errors while converting to utf-8:")."
".$strDBError."
\n"; - $strStatusMessage = "".translate("failed").""; + $strErrorMessage .= $this->translate("Database errors while converting to utf-8:")."
".$strDBError."
\n"; + $strStatusMessage = "".$this->translate("failed").""; return(1); } } @@ -790,24 +892,18 @@ class naginstall { /////////////////////////////////////////////////////////////////////////////////////////// function convQLDBTables(&$strStatusMessage,&$strErrorMessage) { // Read version string from DB - if ($_SESSION['install']['dbtype'] == "mysql") { - $resQuery = @mysql_query("SHOW TABLES FROM `".$_SESSION['install']['dbname']); - $strDBError = mysql_error(); - if ($resQuery && ($strDBError == "")) { - while ($elem = mysql_fetch_row($resQuery)) { - if ($strDBError != "") continue; - $resQueryTable = @mysql_query("ALTER TABLE `".$elem[0]."` DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"); - $strDBError .= mysql_error(); - } - } - } else if ($_SESSION['install']['dbtype'] == "pgsql") { - $resQuery = @pg_query("SHOW TABLES FROM `".$_SESSION['install']['dbname']); - $strDBError = pg_last_error(); - if ($resQuery && ($strDBError == "")) { - while ($elem = pg_fetch_row($resQuery)) { - if ($strDBError != "") continue; - $resQueryTable = @pg_query("ALTER TABLE `".$elem[0]."` DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"); - $strDBError .= pg_last_error(); + if ($_SESSION['install']['dbtype'] == "mysqli") { + $strSQL = "SHOW TABLES FROM `".$_SESSION['install']['dbname']."`"; + $booReturn = $this->myDBClass->getDataArray($strSQL,$arrDataset,$intDataCount); + if ($intDataCount != 0) { + foreach ($arrDataset AS $elem) { + if ($intError == 1) continue; + $strSQL = "ALTER TABLE `".$elem[0]."` DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; + $booReturn = $this->myDBClass->insertData($strSQL); + if ($booReturn == false) { + $intError = 1; + $strDBError = str_replace("::","
",$this->myDBClass->strErrorMessage); + } } } } else { @@ -836,67 +932,35 @@ class naginstall { /////////////////////////////////////////////////////////////////////////////////////////// function convQLDBFields(&$strStatusMessage,&$strErrorMessage) { // Read version string from DB - if ($_SESSION['install']['dbtype'] == "mysql") { - $resQuery = @mysql_query("SHOW TABLES FROM `".$_SESSION['install']['dbname']); - $strDBError = mysql_error(); - if ($resQuery && ($strDBError == "")) { - while ($elem = mysql_fetch_row($resQuery)) { - if ($strDBError != "") continue; - $resQueryTable = @mysql_query("SHOW FULL FIELDS FROM `".$elem[0]."` WHERE (`Type` LIKE '%varchar%' OR `Type` LIKE '%enum%' - OR `Type` LIKE '%text%') AND Collation <> 'utf8_unicode_ci'"); - $strDBError = mysql_error(); - if ($resQueryTable && ($strDBError == "")) { - while ($elem2 = mysql_fetch_row($resQueryTable)) { - if ($strDBError != "") continue; - if (($elem2[5] === NULL) && ($elem2[3] == 'YES')){ - $strDefault = "DEFAULT NULL"; - } else if ($elem2[5] != '') { - $strDefault = "DEFAULT '".$elem2[5]."'"; - } else { - $strDefault = ""; - } - if ($elem2[3] == 'YES') { $strNull = 'NULL'; } else { $strNull = 'NOT NULL'; } - $strSQL = "ALTER TABLE `".$elem[0]."` CHANGE `".$elem2[0]."` `".$elem2[0]."` ".$elem2[1]." CHARACTER SET 'utf8' - COLLATE 'utf8_unicode_ci' $strNull $strDefault"; - $resQueryField = @mysql_query($strSQL); - $strMySQLError = mysql_error(); - if ($strMySQLError != "") { - if (substr_count($strMySQLError,"Specified key was too long") == 0) { - $strDBError .= "Table:".$elem[0]." - Field: ".$elem2[0]." ".mysql_error(); - } - } + $strSQL1 = "SHOW TABLES FROM `".$_SESSION['install']['dbname']."`"; + $booReturn = $this->myDBClass->getDataArray($strSQL1,$arrDataset1,$intDataCount1); + if ($intDataCount1 != 0) { + foreach ($arrDataset1 AS $elem1) { + if ($intError == 1) continue; + $strSQL2 = "SHOW FULL FIELDS FROM `".$elem1[0]."` WHERE (`Type` LIKE '%varchar%' OR `Type` LIKE '%enum%' + OR `Type` LIKE '%text%') AND Collation <> 'utf8_unicode_ci'"; + $booReturn = $this->myDBClass->getDataArray($strSQL2,$arrDataset2,$intDataCount2); + if ($intDataCount2 != 0) { + foreach ($arrDataset2 AS $elem2) { + if ($intError2 == 1) continue; + if (($elem2[5] === NULL) && ($elem2[3] == 'YES')){ + $strDefault = "DEFAULT NULL"; + } else if ($elem2[5] != '') { + $strDefault = "DEFAULT '".$elem2[5]."'"; + } else { + $strDefault = ""; + } + if ($elem2[3] == 'YES') { $strNull = 'NULL'; } else { $strNull = 'NOT NULL'; } + $strSQL3 = "ALTER TABLE `".$elem[0]."` CHANGE `".$elem2[0]."` `".$elem2[0]."` ".$elem2[1]." + CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' $strNull $strDefault"; + $booReturn = $this->myDBClass->insertData($strSQL3); + if ($booReturn == false) { + $intError2 = 1; + $strDBError = "Table:".$elem[0]." - Field: ".$elem2[0]." ".$this->myDBClass->strErrorMessage; } } } } - } else if ($_SESSION['install']['dbtype'] == "pgsql") { - $resQuery = @pg_query("SHOW TABLES FROM `".$_SESSION['install']['dbname']); - $strDBError = pg_last_error(); - if ($resQuery && ($strDBError == "")) { - while ($elem = pg_fetch_row($resQuery)) { - if ($strDBError != "") continue; - $resQueryTable = @pg_query("SHOW FULL FIELDS FROM `".$elem[0]."` WHERE `Type` LIKE '%varchar%' AND Collation <> 'utf8_unicode_ci'"); - $strDBError = pg_last_error(); - if ($resQueryTable && ($strDBError == "")) { - while ($elem2 = pg_fetch_row($resQueryTable)) { - if (($elem2[5] === NULL) && ($elem2[3] == 'YES')){ - $strDefault = "DEFAULT NULL"; - } else if ($elem2[5] != '') { - $strDefault = "DEFAULT '".$elem2[5]."'"; - } else { - $strDefault = ""; - } - if ($elem2[3] == 'YES') { $strNull = 'NULL'; } else { $strNull = 'NOT NULL'; } - $strSQL = "ALTER TABLE `".$elem[0]."` CHANGE `".$elem2[0]."` `".$elem2[0]."` ".$elem2[1]." CHARACTER SET 'utf8' - COLLATE 'utf8_unicode_ci' $strNull $strDefault"; - if ($strDBError != "") continue; - $resQueryField = @pg_query($strSQL); - $strDBError .= pg_last_error(); - } - } - $strDBError .= pg_last_error(); - } - } } else { $strErrorMessage .= translate("Database type not defined!")." (".$_SESSION['install']['dbtype'].")
\n"; $strStatusMessage = "".translate("failed").""; diff --git a/install/functions/prepend_install.php b/install/functions/prepend_install.php old mode 100755 new mode 100644 index ab0d37e..21b4cca --- a/install/functions/prepend_install.php +++ b/install/functions/prepend_install.php @@ -4,15 +4,15 @@ // NagiosQL /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Installer preprocessing script // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-01-04 15:40:03 +0100 (Mi, 04. Jan 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1154 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// error_reporting(E_ALL); @@ -24,7 +24,7 @@ $strInfoMessage = ""; // All information messages (green) // // Start PHP session // ================= -session_start('nagiosql_install'); +session_start([ 'name' => 'nagiosql_install']); // // Include external function/class files // ===================================== diff --git a/install/images/input.png b/install/images/input.png old mode 100755 new mode 100644 diff --git a/install/index.php b/install/index.php index 87a2caa..b1a5df0 100644 --- a/install/index.php +++ b/install/index.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Installer main script // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-28 18:14:54 +0100 (Tue, 28 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1261 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // @@ -25,18 +25,18 @@ $preLocale = "../config/locale"; $filConfig = "../config/settings.php"; $preDBType = "mysql"; $strLangOpt = ""; -$intError = 0; +$strVersion = "3.3.0"; $intUpdate = 0; +$intError = 0; // // Include preprocessing file // ========================== require("functions/prepend_install.php"); -require("../functions/translator.php"); // // Restart session // =============== session_destroy(); -session_start('nagiosql_install'); +session_start([ 'name' => 'nagiosql_install']); // // POST parameters // =============== @@ -60,11 +60,11 @@ if (extension_loaded('gettext')) { bindtextdomain($chkLocale, $preLocale); bind_textdomain_codeset($chkLocale, $preEncode); textdomain($chkLocale); - $arrTemplate['NAGIOS_FAQ'] = translate("Online Documentation"); + $arrTemplate['NAGIOS_FAQ'] = $myInstClass->translate("Online Documentation"); // Language selection field - $arrTemplate['LANGUAGE'] = translate("Language"); - foreach(getLanguageData() AS $key => $elem) { - $strLangOpt .= "\n"; + $arrTemplate['LANGUAGE'] = $myInstClass->translate("Language"); + foreach($myInstClass->getLangData() AS $key => $elem) { + $strLangOpt .= "\n"; if ($key != $chkLocale) { $strLangOpt = str_replace(" {sel}","",$strLangOpt); } else { $strLangOpt = str_replace(" {sel}"," selected",$strLangOpt); } } $arrTemplate['LANG_OPTION'] = $strLangOpt; @@ -76,7 +76,6 @@ if (extension_loaded('gettext')) { // Checking current installation // ============================= // Does the settings file exist? -$_SESSION['install']['dbtype'] = $preDBType; if (file_exists($filConfig) && is_readable($filConfig)) { $preSettings = parse_ini_file($filConfig,true); // Are there any connection data? @@ -89,49 +88,70 @@ if (file_exists($filConfig) && is_readable($filConfig)) { $preDBType = "pgsql"; $_SESSION['install']['dbtype'] = $preDBType; } - if ($preDBType == "mysql") { - if (extension_loaded('mysql')) { + // Select database + $intDBFallback = 0; + if (isset($preSettings['db']['type'])) { + if ($preSettings['db']['type'] == "mysqli") { + if (extension_loaded('mysqli')) { + // Include mysqli class + include("../functions/mysqli_class.php"); + // Initialize mysqli class + $myDBClass = new mysqlidb; + } else { + $intDBFallback = 1; + } + $_SESSION['install']['dbtype'] = 'mysqli'; + } else { + $intDBFallback = 1; + } + } else { + if (extension_loaded('mysqli')) { // Include mysql class - include("../functions/mysql_class.php"); + include("../functions/mysqli_class.php"); // Initialize mysql class $myDBClass = new mysqldb; - if ($myDBClass->error == true) { - $strErrorMessage .= translate("Database connection failed. Upgrade not available!")."
"; - $strErrorMessage .= translate('Error while connecting to database:')."
".$myDBClass->strErrorMessage."
"; - } else { - $strSQL = "SELECT `category`,`name`,`value` FROM `tbl_settings`"; - $booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount); - if ($booReturn == false) { - $strErrorMessage .= translate("Settings table not available or wrong. Upgrade not available!")."
"; - $strErrorMessage .= translate('Error while selecting data from database:')."
".$myDBClass->strDBError."
"; - } else if ($intDataCount != 0) { - foreach ($arrDataLines AS $elem) { - $preSettings[$elem['category']][$elem['name']] = $elem['value']; - } - $intUpdate = 1; - } - } - $_SESSION['install']['dbtype'] = $preDBType; } else { - $strErrorMessage .= translate("Installation cannot continue, please make sure you have the mysql extension loaded!"); - $intError = 1; + $intDBFallback = 1; } - } else if ($preDBType == "pgsql") { - if (extension_loaded('pgsql')) { - $strErrorMessage .= translate("Installation cannot continue, postgres is not yet available in beta!"); - $intError = 1; - } else { - $strErrorMessage .= translate("Installation cannot continue, please make sure you have the pgsql extension loaded!"); - $intError = 1; - } + $_SESSION['install']['dbtype'] = 'mysqli'; + $preSettings['db']['type'] = 'mysqli'; + } + // Set DB parameters + $myDBClass->arrParams['server'] = $preSettings['db']['server']; + $myDBClass->arrParams['port'] = $preSettings['db']['port']; + $myDBClass->arrParams['username'] = $preSettings['db']['username']; + $myDBClass->arrParams['password'] = $preSettings['db']['password']; + $myDBClass->arrParams['database'] = $preSettings['db']['database']; + $myDBClass->getdatabase(); + // DB failure + if ($intDBFallback == 1) { + $_SESSION['install']['dbtype'] = 'mysqli'; + $preSettings['db']['type'] = 'mysqli'; + $intUpdate = 0; } else { - $strErrorMessage .= translate("Database type in settings file is wrong (config/settings.php). Upgrade not available!"); + if ($myDBClass->error == true) { + $strErrorMessage .= $myInstClass->translate("Database connection failed. Upgrade not available!")."
"; + $strErrorMessage .= str_replace("::","
",$myDBClass->strErrorMessage)."
"; + } else { + $strSQL = "SELECT category,name,value FROM tbl_settings"; + $booReturn = $myDBClass->getDataArray($strSQL,$arrDataLines,$intDataCount); + if ($booReturn == false) { + $strErrorMessage .= $myInstClass->translate("Settings table not available or wrong. Upgrade not available!")."
"; + $strErrorMessage .= str_replace("::","
",$myDBClass->strErrorMessage)."
"; + + } else if ($intDataCount != 0) { + foreach ($arrDataLines AS $elem) { + $preSettings[$elem['category']][$elem['name']] = $elem['value']; + } + $intUpdate = 1; + } + } } } else { - $strErrorMessage .= translate("Database values in settings file are missing (config/settings.php). Upgrade not available!"); + $strErrorMessage .= $myInstClass->translate("Database values in settings file are missing (config/settings.php). Upgrade not available!"); } } else { - $strErrorMessage .= translate("Settings file not found or not readable (config/settings.php). Upgrade not available!"); + $strErrorMessage .= $myInstClass->translate("Settings file not found or not readable (config/settings.php). Upgrade not available!"); } // // Initial settings (new installation) @@ -141,40 +161,38 @@ if (file_exists($filInit) && is_readable($filInit)) { $preInit = parse_ini_file($filInit,true); $_SESSION['init_settings'] = $preInit; } else { - $strErrorMessage .= translate("Default values file is not available or not readable (install/functions/initial_settings.php). Installation possible, but without predefined data!"); + $strErrorMessage .= $myInstClass->translate("Default values file is not available or not readable (install/functions/initial_settings.php). Installation possible, but without predefined data!"); } // // Build content // ============= -$arrTemplate['PAGETITLE'] = "[NagiosQL] Installation Wizard"; -$arrTemplate['MAIN_TITLE'] = translate("Welcome to the NagiosQL Installation Wizard"); -$arrTemplate['TEXT_PART_1'] = translate("This wizard will help you to install and configure NagiosQL."); -$arrTemplate['TEXT_PART_2'] = translate("For questions please visit"); -$arrTemplate['TEXT_PART_3'] = translate("First let's check your local environment and find out if everything NagiosQL needs is available."); -$arrTemplate['TEXT_PART_4'] = translate("The basic requirements are:"); -$arrTemplate['TEXT_PART_5'] = translate("PHP 5.2.0 or greater including:"); -$arrTemplate['TEXT_PHP_REQ_1'] = translate("PHP Module:")." Session"; -$arrTemplate['TEXT_PHP_REQ_2'] = translate("PHP Module:")." gettext"; -$arrTemplate['TEXT_PHP_REQ_3'] = translate("PHP Module:")." filter"; -//$arrTemplate['TEXT_PHP_REQ_4'] = translate("PHP Module:")." XML"; -//$arrTemplate['TEXT_PHP_REQ_5'] = translate("PHP Module:")." SimpleXML"; -$arrTemplate['TEXT_PHP_REQ_6'] = translate("PHP Module:")." MySQL"; -//$arrTemplate['TEXT_PHP_REQ_7'] = translate("PHP Module:")." PgSQL ".translate("(optional)"); -$arrTemplate['TEXT_PHP_REQ_8'] = translate("PHP Module:")." FTP ".translate("(optional)"); -$arrTemplate['TEXT_PHP_REQ_9'] = translate("PHP Module:")." curl ".translate("(optional)"); -$arrTemplate['TEXT_PHP_REQ_10'] = translate("PECL Extension:")." SSH ".translate("(optional)"); -$arrTemplate['TEXT_PART_6'] = translate("php.ini options").":"; -$arrTemplate['TEXT_INI_REQ_1'] = translate("file_uploads on (for upload features)"); -$arrTemplate['TEXT_INI_REQ_2'] = translate("session.auto_start needs to be off"); -$arrTemplate['TEXT_PART_7'] = translate("A MySQL database server"); -$arrTemplate['TEXT_PART_8'] = translate("Nagios 2.x/3.x"); +$arrTemplate['PAGETITLE'] = "[NagiosQL] ".$myInstClass->translate("Installation wizard"); +$arrTemplate['MAIN_TITLE'] = $myInstClass->translate("Welcome to the NagiosQL installation wizard"); +$arrTemplate['TEXT_PART_1'] = $myInstClass->translate("This wizard will help you to install and configure NagiosQL."); +$arrTemplate['TEXT_PART_2'] = $myInstClass->translate("For questions please visit").": "; +$arrTemplate['TEXT_PART_3'] = $myInstClass->translate("First let's check your local environment and find out if everything NagiosQL needs is available."); +$arrTemplate['TEXT_PART_4'] = $myInstClass->translate("The basic requirements are:"); +$arrTemplate['TEXT_PART_5'] = $myInstClass->translate("PHP 5.2.0 or greater including:"); +$arrTemplate['TEXT_PHP_REQ_1'] = $myInstClass->translate("PHP database module:")." ". + $myInstClass->translate("supported types are")." mysqli"; +$arrTemplate['TEXT_PHP_REQ_2'] = $myInstClass->translate("PHP module:")." session"; +$arrTemplate['TEXT_PHP_REQ_3'] = $myInstClass->translate("PHP module:")." gettext"; +$arrTemplate['TEXT_PHP_REQ_6'] = $myInstClass->translate("PHP module:")." filter"; +$arrTemplate['TEXT_PHP_REQ_8'] = $myInstClass->translate("PHP module:")." FTP ".$myInstClass->translate("(optional)"); +$arrTemplate['TEXT_PHP_REQ_10'] = $myInstClass->translate("PECL extension:")." SSH ".$myInstClass->translate("(optional)"); +$arrTemplate['TEXT_PART_6'] = $myInstClass->translate("php.ini options").":"; +$arrTemplate['TEXT_INI_REQ_1'] = $myInstClass->translate("file_uploads on (for upload features)"); +$arrTemplate['TEXT_INI_REQ_2'] = $myInstClass->translate("session.auto_start needs to be off"); +$arrTemplate['TEXT_PART_7'] = $myInstClass->translate("A database server"); +$arrTemplate['TEXT_PART_8'] = $myInstClass->translate("Nagios 2.x/3.x/4.x"); +$arrTemplate['TEXT_PART_9'] = $myInstClass->translate("NagiosQL version")." ".$strVersion; $arrTemplate['LOCALE'] = $chkLocale; -$arrTemplate['ONLINE_DOC'] = translate("Online Documentation"); +$arrTemplate['ONLINE_DOC'] = $myInstClass->translate("Online documentation"); // // New installation or upgrade // =========================== -$arrTemplate['NEW_INSTALLATION'] = translate("START INSTALLATION"); -$arrTemplate['UPDATE'] = translate("START UPDATE"); +$arrTemplate['NEW_INSTALLATION'] = $myInstClass->translate("START INSTALLATION"); +$arrTemplate['UPDATE'] = $myInstClass->translate("START UPDATE"); $arrTemplate['DISABLE_NEW'] = ""; $arrTemplate['UPDATE_ERROR'] = "".$strErrorMessage.""; if ($intUpdate == 1) { diff --git a/install/install.php b/install/install.php index 1826aa9..2ba93fe 100644 --- a/install/install.php +++ b/install/install.php @@ -5,39 +5,39 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Installer script - check page // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-21 14:10:41 +0100 (Tue, 21 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1229 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // -// Actual database files -// ===================== -$preSqlNewInstall = "sql/nagiosQL_v32_db_mysql.sql"; -$preSqlUpdateLast = "sql/update_31x_320.sql"; -$preNagiosQL_ver = "3.2.0"; -// // Define common variables // ======================= $preContent = "templates/install.tpl.htm"; $preEncode = 'utf-8'; $preLocale = "../config/locale"; -$intError = 0; $chkModus = "none"; // // Include preprocessing file // ========================== require("functions/prepend_install.php"); -require("../functions/translator.php"); +// +// Actual database files +// ===================== +$preSqlNewInstall = "sql/nagiosQL_v32_db_mysql.sql"; +$preSqlUpdateLast = "sql/update_31x_320.sql"; +$preNagiosQL_ver = "3.3.0"; // // Process initial value // ===================== +if (!isset($_SESSION['init_settings'])) header("Location: index.php"); +$strInitDBtype = isset($_SESSION['SETS']['db']['type']) ? $_SESSION['SETS']['db']['type'] : $_SESSION['init_settings']['db']['type']; $strInitDBserver = isset($_SESSION['SETS']['db']['server']) ? $_SESSION['SETS']['db']['server'] : $_SESSION['init_settings']['db']['server']; $strInitDBname = isset($_SESSION['SETS']['db']['database']) ? $_SESSION['SETS']['db']['database'] : $_SESSION['init_settings']['db']['database']; $strInitDBuser = isset($_SESSION['SETS']['db']['username']) ? $_SESSION['SETS']['db']['username'] : $_SESSION['init_settings']['db']['username']; @@ -48,6 +48,7 @@ $strInitDBport = isset($_SESSION['SETS']['db']['port']) ? $_SESSION['SETS']['d // ======================= if (!isset($_SESSION['install']['jscript'])) $_SESSION['install']['jscript'] = "no"; if (!isset($_SESSION['install']['locale'])) $_SESSION['install']['locale'] = "en_GB"; +if (!isset($_SESSION['install']['dbtype'])) $_SESSION['install']['dbtype'] = $strInitDBtype; if (!isset($_SESSION['install']['dbserver'])) $_SESSION['install']['dbserver'] = $strInitDBserver; if (!isset($_SESSION['install']['localsrv'])) $_SESSION['install']['localsrv'] = ""; if (!isset($_SESSION['install']['dbname'])) $_SESSION['install']['dbname'] = $strInitDBname; @@ -68,12 +69,13 @@ if (!isset($_SESSION['install']['nagpath'])) $_SESSION['install']['nagpath'] // POST parameters // =============== $arrStep = array(1,2,3); -$chkStep = isset($_POST['hidStep']) ? $_POST['hidStep'] : "1"; +$chkStep = (isset($_POST['hidStep']) && in_array($_POST['hidStep'],$arrStep)) ? $_POST['hidStep']+0 : "1"; if (isset($_GET['step']) && in_array($_GET['step'],$arrStep)) $chkStep = $_GET['step']+0; if (!in_array($chkStep,$arrStep)) $arrStep = 1; // Session values $_SESSION['install']['locale'] = isset($_POST['hidLocale']) ? $_POST['hidLocale'] : $_SESSION['install']['locale']; $_SESSION['install']['jscript'] = isset($_POST['hidJScript']) ? $_POST['hidJScript'] : $_SESSION['install']['jscript']; +$_SESSION['install']['dbtype'] = isset($_POST['selDBtype']) ? $_POST['selDBtype'] : $_SESSION['install']['dbtype']; $_SESSION['install']['dbserver'] = isset($_POST['tfDBserver']) ? $_POST['tfDBserver'] : $_SESSION['install']['dbserver']; $_SESSION['install']['localsrv'] = isset($_POST['tfLocalSrv']) ? $_POST['tfLocalSrv'] : $_SESSION['install']['localsrv']; $_SESSION['install']['dbname'] = isset($_POST['tfDBname']) ? $_POST['tfDBname'] : $_SESSION['install']['dbname']; @@ -84,20 +86,19 @@ $_SESSION['install']['admpass'] = isset($_POST['tfDBprivPass']) ? $_POST['tfDBp $_SESSION['install']['qluser'] = isset($_POST['tfQLuser']) ? $_POST['tfQLuser'] : $_SESSION['install']['qluser']; $_SESSION['install']['qlpass'] = isset($_POST['tfQLpass']) ? $_POST['tfQLpass'] : $_SESSION['install']['qlpass']; $_SESSION['install']['dbport'] = isset($_POST['tfDBport']) ? $_POST['tfDBport']+0 : $_SESSION['install']['dbport']; -$_SESSION['install']['dbdrop'] = isset($_POST['chbDrop']) ? $_POST['chbDrop']+0 : $_SESSION['install']['dbdrop']; -$_SESSION['install']['sample'] = isset($_POST['chbSample']) ? $_POST['chbSample']+0 : $_SESSION['install']['sample']; -$_SESSION['install']['createpath'] = isset($_POST['chbPath']) ? $_POST['chbPath']+0 : $_SESSION['install']['createpath']; +$_SESSION['install']['dbdrop'] = isset($_POST['chbDrop']) ? $_POST['chbDrop']+0 : 0; +$_SESSION['install']['sample'] = isset($_POST['chbSample']) ? $_POST['chbSample']+0 : 0; +$_SESSION['install']['createpath'] = isset($_POST['chbPath']) ? $_POST['chbPath']+0 : 0; $_SESSION['install']['qlpath'] = isset($_POST['tfQLpath']) ? $_POST['tfQLpath'] : $_SESSION['install']['qlpath']; $_SESSION['install']['nagpath'] = isset($_POST['tfNagiosPath']) ? $_POST['tfNagiosPath'] : $_SESSION['install']['nagpath']; +$preSqlNewInstall = str_replace("DBTYPE",$_SESSION['install']['dbtype'],$preSqlNewInstall); +$preSqlNewInstall = str_replace("mysqli","mysql",$preSqlNewInstall); + if (isset($_POST['butNewInstall'])) $chkModus = "Installation"; if (isset($_POST['butUpgrade'])) $chkModus = "Update"; if (!isset($_SESSION['install']['mode'])) $_SESSION['install']['mode'] = $chkModus; -// -// Store data to session parameters -// ================================ - // // Language settings // ================= @@ -121,7 +122,7 @@ ob_end_clean(); // Build content // ============= $arrTemplate['PAGETITLE'] = "[NagiosQL] Installation Wizard"; -$arrTemplate['MAIN_TITLE'] = translate("Welcome to the NagiosQL Installation Wizard"); +$arrTemplate['MAIN_TITLE'] = $myInstClass->translate("Welcome to the NagiosQL Installation Wizard"); $arrTemplate['CONTENT'] = $strContent; // // Write content diff --git a/install/sql/import_nagios_sample.sql b/install/sql/import_nagios_sample.sql index e5b8c8f..6a5a8ef 100644 --- a/install/sql/import_nagios_sample.sql +++ b/install/sql/import_nagios_sample.sql @@ -8,11 +8,11 @@ -- Project : NagiosQL -- Component : Import samples build from Nagios 3.0.5 configuration samples -- Website : www.nagiosql.org --- Date : $LastChangedDate: 2012-02-24 10:22:28 +0100 (Fri, 24 Feb 2012) $ +-- Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ -- Author : $LastChangedBy: martin $ --- Version : 3.2.0 --- Revision : $LastChangedRevision: 1248 $ --- SVN-ID : $Id: import_nagios_sample.sql 1248 2012-02-24 09:22:28Z martin $ +-- Version : 3.3.0 +-- Revision : $LastChangedRevision: 2 $ +-- SVN-ID : $Id: import_nagios_sample.sql 2 2017-06-22 07:29:35Z martin $ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- diff --git a/install/sql/nagiosQL_v32_db_mysql.sql b/install/sql/nagiosQL_v32_db_mysql.sql index 3c280d5..7bfa13d 100644 --- a/install/sql/nagiosQL_v32_db_mysql.sql +++ b/install/sql/nagiosQL_v32_db_mysql.sql @@ -8,11 +8,11 @@ -- Project : NagiosQL -- Component : Complete NagiosQL Database -- Website : www.nagiosql.org --- Date : $LastChangedDate: 2012-03-01 12:24:44 +0100 (Thu, 01 Mar 2012) $ +-- Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ -- Author : $LastChangedBy: martin $ --- Version : 3.2.0 --- Revision : $LastChangedRevision: 1268 $ --- SVN-ID : $Id: nagiosQL_v32_db_mysql.sql 1268 2012-03-01 11:24:44Z martin $ +-- Version : 3.3.0 +-- Revision : $LastChangedRevision: 2 $ +-- SVN-ID : $Id: nagiosQL_v32_db_mysql.sql 2 2017-06-22 07:29:35Z martin $ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- diff --git a/install/sql/update_300_301.sql b/install/sql/update_300_301.sql index 3d8f371..c54e39a 100644 --- a/install/sql/update_300_301.sql +++ b/install/sql/update_300_301.sql @@ -10,11 +10,11 @@ -- Project : NagiosQL -- Component : Update from NagiosQL 3.0.0 to NagiosQL 3.0.1 -- Website : www.nagiosql.org --- Date : $LastChangedDate: 2012-02-23 07:49:34 +0100 (Thu, 23 Feb 2012) $ +-- Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ -- Author : $LastChangedBy: martin $ -- Version : 3.0.2 --- Revision : $LastChangedRevision: 1237 $ --- SVN-ID : $Id: update_300_301.sql 1237 2012-02-23 06:49:34Z martin $ +-- Revision : $LastChangedRevision: 2 $ +-- SVN-ID : $Id: update_300_301.sql 2 2017-06-22 07:29:35Z martin $ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- diff --git a/install/sql/update_300_310.sql b/install/sql/update_300_310.sql index b840ce2..0dcefa8 100644 --- a/install/sql/update_300_310.sql +++ b/install/sql/update_300_310.sql @@ -8,10 +8,10 @@ -- Project : NagiosQL -- Component : Update from NagiosQL 3.0.4 to NagiosQL 3.1.0 -- Website : www.nagiosql.org --- Date : $LastChangedDate: 2012-02-27 07:58:18 +0100 (Mon, 27 Feb 2012) $ +-- Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ -- Author : $LastChangedBy: martin $ -- Version : 3.1.1 --- Revision : $LastChangedRevision: 1255 $ +-- Revision : $LastChangedRevision: 2 $ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- diff --git a/install/sql/update_301_302.sql b/install/sql/update_301_302.sql index fe0a639..8c66323 100644 --- a/install/sql/update_301_302.sql +++ b/install/sql/update_301_302.sql @@ -10,11 +10,11 @@ -- Project : NagiosQL -- Component : Update from NagiosQL 3.0.1 to NagiosQL 3.0.2 -- Website : www.nagiosql.org --- Date : $LastChangedDate: 2012-02-23 07:49:34 +0100 (Thu, 23 Feb 2012) $ +-- Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ -- Author : $LastChangedBy: martin $ -- Version : 3.0.2 --- Revision : $LastChangedRevision: 1237 $ --- SVN-ID : $Id: update_301_302.sql 1237 2012-02-23 06:49:34Z martin $ +-- Revision : $LastChangedRevision: 2 $ +-- SVN-ID : $Id: update_301_302.sql 2 2017-06-22 07:29:35Z martin $ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- diff --git a/install/sql/update_302_303.sql b/install/sql/update_302_303.sql index 3d28e9d..83a4800 100644 --- a/install/sql/update_302_303.sql +++ b/install/sql/update_302_303.sql @@ -10,11 +10,11 @@ -- Project : NagiosQL -- Component : Update from NagiosQL 3.0.2 to NagiosQL 3.0.3 -- Website : www.nagiosql.org --- Date : $LastChangedDate: 2012-02-23 07:49:34 +0100 (Thu, 23 Feb 2012) $ +-- Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ -- Author : $LastChangedBy: martin $ -- Version : 3.0.3 --- Revision : $LastChangedRevision: 1237 $ --- SVN-ID : $Id: update_302_303.sql 1237 2012-02-23 06:49:34Z martin $ +-- Revision : $LastChangedRevision: 2 $ +-- SVN-ID : $Id: update_302_303.sql 2 2017-06-22 07:29:35Z martin $ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- diff --git a/install/sql/update_303_304.sql b/install/sql/update_303_304.sql index f6e9a79..57a2444 100644 --- a/install/sql/update_303_304.sql +++ b/install/sql/update_303_304.sql @@ -8,11 +8,11 @@ -- Project : NagiosQL -- Component : Update from NagiosQL 3.0.3 to NagiosQL 3.0.4 -- Website : www.nagiosql.org --- Date : $LastChangedDate: 2011-03-13 14:00:26 +0100 (Sun, 13 Mar 2011) $ --- Author : $LastChangedBy: rouven $ +-- Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ +-- Author : $LastChangedBy: martin $ -- Version : 3.1.1 --- Revision : $LastChangedRevision: 1058 $ --- SVN-ID : $Id: update_303_304.sql 1058 2011-03-13 13:00:26Z rouven $ +-- Revision : $LastChangedRevision: 2 $ +-- SVN-ID : $Id: update_303_304.sql 2 2017-06-22 07:29:35Z martin $ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- diff --git a/install/sql/update_304_310.sql b/install/sql/update_304_310.sql index 72c3c35..e6c0995 100644 --- a/install/sql/update_304_310.sql +++ b/install/sql/update_304_310.sql @@ -8,10 +8,10 @@ -- Project : NagiosQL -- Component : Update from NagiosQL 3.0.4 to NagiosQL 3.1.0 -- Website : www.nagiosql.org --- Date : $LastChangedDate: 2012-02-27 07:58:18 +0100 (Mon, 27 Feb 2012) $ +-- Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ -- Author : $LastChangedBy: martin $ -- Version : 3.1.1 --- Revision : $LastChangedRevision: 1255 $ +-- Revision : $LastChangedRevision: 2 $ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- diff --git a/install/sql/update_310_311.sql b/install/sql/update_310_311.sql index 4410358..9971acd 100644 --- a/install/sql/update_310_311.sql +++ b/install/sql/update_310_311.sql @@ -8,10 +8,10 @@ -- Project : NagiosQL -- Component : Update from NagiosQL 3.1.0 to NagiosQL 3.1.1 -- Website : www.nagiosql.org --- Date : $LastChangedDate: 2012-02-23 07:49:34 +0100 (Thu, 23 Feb 2012) $ +-- Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ -- Author : $LastChangedBy: martin $ -- Version : 3.1.1 --- Revision : $LastChangedRevision: 1237 $ +-- Revision : $LastChangedRevision: 2 $ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- diff --git a/install/sql/update_310_320.sql b/install/sql/update_310_320.sql index 4837267..57116a3 100644 --- a/install/sql/update_310_320.sql +++ b/install/sql/update_310_320.sql @@ -8,10 +8,10 @@ -- Project : NagiosQL -- Component : Update from NagiosQL 3.1.x to NagiosQL 3.2.0 -- Website : www.nagiosql.org --- Date : $LastChangedDate: 2012-03-12 22:41:04 +0100 (Mon, 12 Mar 2012) $ +-- Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ -- Author : $LastChangedBy: martin $ -- Version : 3.2.0 --- Revision : $LastChangedRevision: 1291 $ +-- Revision : $LastChangedRevision: 2 $ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- diff --git a/install/sql/update_311_320.sql b/install/sql/update_311_320.sql index c57f38c..4881ead 100644 --- a/install/sql/update_311_320.sql +++ b/install/sql/update_311_320.sql @@ -8,10 +8,10 @@ -- Project : NagiosQL -- Component : Update from NagiosQL 3.1.x to NagiosQL 3.2.0 -- Website : www.nagiosql.org --- Date : $LastChangedDate: 2012-03-12 22:41:04 +0100 (Mon, 12 Mar 2012) $ +-- Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ -- Author : $LastChangedBy: martin $ -- Version : 3.2.0 --- Revision : $LastChangedRevision: 1291 $ +-- Revision : $LastChangedRevision: 2 $ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- diff --git a/install/step1.php b/install/step1.php index 73ed438..3ea77f8 100644 --- a/install/step1.php +++ b/install/step1.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Installer script - step 1 // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-25 17:48:16 +0100 (Sat, 25 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1252 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // @@ -38,15 +38,17 @@ $arrRequiredExt = array ( $arrOptionalExt = array ( 'FTP' => 'ftp', 'SSH2' => 'ssh2' -); -//$arrSupportedDBs = array ( -// 'MySQL' => 'mysql', -// 'Postgres' => 'pgsql' -//); -$arrSupportedDBs = array ( - 'MySQL' => 'mysql' ); - +/* +$arrSupportedDBs = array ( + 'MySQL' => 'mysql', + 'MySQLi' => 'mysqli', + 'Postgres' => 'pgsql' +); +*/ +$arrSupportedDBs = array ( + 'MySQLi' => 'mysqli' +); $arrIniCheck = array ( 'file_uploads' => 1, 'session.auto_start' => 0, @@ -69,7 +71,7 @@ $arrSourceURLs = array( 'XML' => 'http://www.php.net/manual/en/book.xml.php', 'SimpleXML' => 'http://www.php.net/manual/en/book.simplexml.php', 'FTP' => 'http://www.php.net/manual/en/book.ftp.php', - 'MySQL' => 'http://php.net/manual/de/book.mysql.php', + 'MySQL' => 'http://php.net/manual/de/book.mysqli.php', 'PEAR' => 'http://pear.php.net', 'date.timezone' => 'http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone', 'SSH2' => 'http://pecl.php.net/package/ssh2' @@ -77,20 +79,20 @@ $arrSourceURLs = array( // // Build content // ============= -$arrTemplate['STEP1_BOX'] = translate('Requirements'); -$arrTemplate['STEP2_BOX'] = translate($_SESSION['install']['mode']); -$arrTemplate['STEP3_BOX'] = translate('Finish'); -$arrTemplate['STEP1_TITLE'] = "NagiosQL ".translate($_SESSION['install']['mode']).": ".translate("Checking requirements"); -$arrTemplate['STEP1_SUBTITLE1'] = translate("Checking Client"); -$arrTemplate['STEP1_SUBTITLE2'] = translate("Checking PHP version"); -$arrTemplate['STEP1_SUBTITLE3'] = translate("Checking PHP extensions"); -$arrTemplate['STEP1_SUBTITLE4'] = translate("Checking available database interfaces"); -$arrTemplate['STEP1_SUBTITLE5'] = translate("Checking php.ini/.htaccess settings"); -$arrTemplate['STEP1_SUBTITLE6'] = translate("Checking System Permission"); -$arrTemplate['STEP1_TEXT3_1'] = translate("The following modules/extensions are required to run NagiosQL"); -$arrTemplate['STEP1_TEXT3_2'] = translate("The next couple of extensions are optional but recommended"); -$arrTemplate['STEP1_TEXT4_1'] = translate("Check which of the supported extensions are installed. At least one of them is required."); -$arrTemplate['STEP1_TEXT5_1'] = translate("The following settings are required to run NagiosQL"); +$arrTemplate['STEP1_BOX'] = $myInstClass->translate('Requirements'); +$arrTemplate['STEP2_BOX'] = $myInstClass->translate($_SESSION['install']['mode']); +$arrTemplate['STEP3_BOX'] = $myInstClass->translate('Finish'); +$arrTemplate['STEP1_TITLE'] = "NagiosQL ".$myInstClass->translate($_SESSION['install']['mode']).": ".$myInstClass->translate("Checking requirements"); +$arrTemplate['STEP1_SUBTITLE1'] = $myInstClass->translate("Checking Client"); +$arrTemplate['STEP1_SUBTITLE2'] = $myInstClass->translate("Checking PHP version"); +$arrTemplate['STEP1_SUBTITLE3'] = $myInstClass->translate("Checking PHP extensions"); +$arrTemplate['STEP1_SUBTITLE4'] = $myInstClass->translate("Checking available database interfaces"); +$arrTemplate['STEP1_SUBTITLE5'] = $myInstClass->translate("Checking php.ini/.htaccess settings"); +$arrTemplate['STEP1_SUBTITLE6'] = $myInstClass->translate("Checking System Permission"); +$arrTemplate['STEP1_TEXT3_1'] = $myInstClass->translate("The following modules/extensions are required to run NagiosQL"); +$arrTemplate['STEP1_TEXT3_2'] = $myInstClass->translate("The next couple of extensions are optional but recommended"); +$arrTemplate['STEP1_TEXT4_1'] = $myInstClass->translate("Check which of the supported extensions are installed. At least one of them is required."); +$arrTemplate['STEP1_TEXT5_1'] = $myInstClass->translate("The following settings are required to run NagiosQL"); // // Conditional checks // ======================= @@ -104,19 +106,21 @@ $strHTMLPart7 = "\"onlinetranslate("ENABLED"); + $arrTemplate['CHECK_1_INFO'] = ""; } else { - $arrTemplate['CHECK_1_PIC'] = "invalid"; $arrTemplate['CHECK_1_CLASS'] = "green"; $arrTemplate['CHECK_1_VALUE'] = translate("NOT ENABLED"); + $arrTemplate['CHECK_1_PIC'] = "invalid"; $arrTemplate['CHECK_1_CLASS'] = "green"; $arrTemplate['CHECK_1_VALUE'] = $myInstClass->translate("NOT ENABLED"); + $arrTemplate['CHECK_1_INFO'] = "(".$myInstClass->translate("After enabling Javascript, the page must be updated twice so that the status changes").")"; } // PHP version check define('MIN_PHP_VERSION', '5.2.0'); -$arrTemplate['CHECK_2_TEXT'] = translate("Version"); +$arrTemplate['CHECK_2_TEXT'] = $myInstClass->translate("Version"); if (version_compare(PHP_VERSION, MIN_PHP_VERSION, '>=')) { - $arrTemplate['CHECK_2_PIC'] = "valid"; $arrTemplate['CHECK_2_CLASS'] = "green"; $arrTemplate['CHECK_2_VALUE'] = translate("OK"); - $arrTemplate['CHECK_2_INFO'] = "(PHP ". PHP_VERSION ." ".translate("detected").")"; + $arrTemplate['CHECK_2_PIC'] = "valid"; $arrTemplate['CHECK_2_CLASS'] = "green"; $arrTemplate['CHECK_2_VALUE'] = $myInstClass->translate("OK"); + $arrTemplate['CHECK_2_INFO'] = "(PHP ". PHP_VERSION ." ".$myInstClass->translate("detected").")"; } else { - $arrTemplate['CHECK_2_PIC'] = "invalid"; $arrTemplate['CHECK_2_CLASS'] = "green"; $arrTemplate['CHECK_2_VALUE'] = "PHP ". PHP_VERSION ." ".translate("detected"); - $arrTemplate['CHECK_2_INFO'] = "(PHP ". MIN_PHP_VERSION ." ".translate("or greater is required").")"; + $arrTemplate['CHECK_2_PIC'] = "invalid"; $arrTemplate['CHECK_2_CLASS'] = "green"; $arrTemplate['CHECK_2_VALUE'] = "PHP ". PHP_VERSION ." ".$myInstClass->translate("detected"); + $arrTemplate['CHECK_2_INFO'] = "(PHP ". MIN_PHP_VERSION ." ".$myInstClass->translate("or greater is required").")"; $intError = 1; } // PHP modules / extensions @@ -125,11 +129,11 @@ $strPrefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : ''; $strHTML = ""; foreach ($arrRequiredExt as $key => $elem) { if (extension_loaded($elem)) { - $strHTML .= $strHTMLPart1.$key.$strHTMLPart4.translate("OK")."\n"; + $strHTML .= $strHTMLPart1.$key.$strHTMLPart4.$myInstClass->translate("OK")."\n"; } else { $strPath = $strExtPath."/".$strPrefix.$elem.".".PHP_SHLIB_SUFFIX; - $strMsg = @is_readable($strPath) ? translate("Could be loaded. Please add in php.ini") : "".$strHTMLPart7.""; - $strHTML .= $strHTMLPart2.$key.$strHTMLPart5.translate("NOT AVAILABLE")." (".$strMsg.")\n"; + $strMsg = @is_readable($strPath) ? $myInstClass->translate("Could be loaded. Please add in php.ini") : "".$strHTMLPart7.""; + $strHTML .= $strHTMLPart2.$key.$strHTMLPart5.$myInstClass->translate("NOT AVAILABLE")." (".$strMsg.")\n"; $intError = 1; } $strHTML .= "
\n"; @@ -138,11 +142,11 @@ $arrTemplate['CHECK_3_CONTENT_1'] = $strHTML; $strHTML = ""; foreach ($arrOptionalExt as $key => $elem) { if (extension_loaded($elem)) { - $strHTML .= $strHTMLPart1.$key.$strHTMLPart4.translate("OK")."\n"; + $strHTML .= $strHTMLPart1.$key.$strHTMLPart4.$myInstClass->translate("OK")."\n"; } else { $strPath = $strExtPath."/".$strPrefix.$elem.".".PHP_SHLIB_SUFFIX; - $strMsg = @is_readable($strPath) ? translate("Could be loaded. Please add in php.ini") : "".$strHTMLPart7.""; - $strHTML .= $strHTMLPart3.$key.$strHTMLPart6.translate("NOT AVAILABLE")." (".$strMsg.")\n"; + $strMsg = @is_readable($strPath) ? $myInstClass->translate("Could be loaded. Please add in php.ini") : "".$strHTMLPart7.""; + $strHTML .= $strHTMLPart3.$key.$strHTMLPart6.$myInstClass->translate("NOT AVAILABLE")." (".$strMsg.")\n"; //$intError = 1; } $strHTML .= "
\n"; @@ -151,16 +155,22 @@ $arrTemplate['CHECK_3_CONTENT_2'] = $strHTML; // PHP database interfaces $strHTML = ""; $intTemp = 0; +$_SESSION['install']['dbtype_available'] = array(); foreach ($arrSupportedDBs as $key => $elem) { if (extension_loaded($elem)) { $strNewInstallOnly = ""; - if (($_SESSION['install']['dbtype'] != $elem) && ($_SESSION['install']['mode'] == "Update")) $strNewInstallOnly = " (".translate("New installation only - updates are only supported using the same database interface!").")"; - $strHTML .= $strHTMLPart1.$key.$strHTMLPart4.translate("OK")." $strNewInstallOnly\n"; + if (isset($_SESSION['install']['dbtype']) && ($_SESSION['install']['mode'] == "Update")) { + if (($_SESSION['install']['dbtype'] != $elem) && (substr($_SESSION['install']['dbtype'],0,5) != substr($elem,0,5))) { + $strNewInstallOnly = " (".$myInstClass->translate("New installation only - updates are only supported using the same database interface!").")"; + } + } + $strHTML .= $strHTMLPart1.$key.$strHTMLPart4.$myInstClass->translate("OK")." $strNewInstallOnly\n"; + if ($strNewInstallOnly == "") $_SESSION['install']['dbtype_available'][] = $elem; $intTemp++; } else { $strPath = $strExtPath."/".$strPrefix.$elem.".".PHP_SHLIB_SUFFIX; - $strMsg = @is_readable($strPath) ? translate("Could be loaded. Please add in php.ini") : "".$strHTMLPart7.""; - $strHTML .= $strHTMLPart2.$key.$strHTMLPart5.translate("NOT AVAILABLE")." (".$strMsg.")\n"; + $strMsg = @is_readable($strPath) ? $myInstClass->translate("Could be loaded. Please add in php.ini") : "".$strHTMLPart7.""; + $strHTML .= $strHTMLPart2.$key.$strHTMLPart5.$myInstClass->translate("NOT AVAILABLE")." (".$strMsg.")\n"; } $strHTML .= "
\n"; } @@ -172,16 +182,16 @@ foreach ($arrIniCheck as $key => $elem) { $strStatus = ini_get($key); if ($elem === '-NOTEMPTY-') { if (empty($strStatus)) { - $strHTML .= $strHTMLPart2.$key.$strHTMLPart5.translate("NOT AVAILABLE")." (".translate("cannot be empty and needs to be set").")\n"; + $strHTML .= $strHTMLPart2.$key.$strHTMLPart5.$myInstClass->translate("NOT AVAILABLE")." (".$myInstClass->translate("cannot be empty and needs to be set").")\n"; $intError = 1; } else { - $strHTML .= $strHTMLPart1.$key.$strHTMLPart4.translate("OK")."\n"; + $strHTML .= $strHTMLPart1.$key.$strHTMLPart4.$myInstClass->translate("OK")."\n"; } } else { if ($strStatus == $elem) { - $strHTML .= $strHTMLPart1.$key.$strHTMLPart4.translate("OK")."\n"; + $strHTML .= $strHTMLPart1.$key.$strHTMLPart4.$myInstClass->translate("OK")."\n"; } else { - $strHTML .= $strHTMLPart2.$key.$strHTMLPart5.$status." (".translate("should be")." ".$elem.")\n"; + $strHTML .= $strHTMLPart2.$key.$strHTMLPart5.$status." (".$myInstClass->translate("should be")." ".$elem.")\n"; $intError = 1; } } @@ -191,77 +201,79 @@ $arrTemplate['CHECK_5_CONTENT_1'] = $strHTML; // File access checks $strConfigFile = "../config/settings.php"; if (file_exists($strConfigFile) && is_readable($strConfigFile)) { - $arrTemplate['CHECK_6_CONTENT_1'] = $strHTMLPart1.translate("Read test on settings file (config/settings.php)").$strHTMLPart4.translate("OK")."
\n"; + $arrTemplate['CHECK_6_CONTENT_1'] = $strHTMLPart1.$myInstClass->translate("Read test on settings file (config/settings.php)").$strHTMLPart4.$myInstClass->translate("OK")."
\n"; } else if (file_exists($strConfigFile)&& !is_readable($strConfigFile)) { - $arrTemplate['CHECK_6_CONTENT_1'] = $strHTMLPart2.translate("Read test on settings file (config/settings.php)").$strHTMLPart5.translate("failed")."
\n"; + $arrTemplate['CHECK_6_CONTENT_1'] = $strHTMLPart2.$myInstClass->translate("Read test on settings file (config/settings.php)").$strHTMLPart5.$myInstClass->translate("failed")."
\n"; } elseif (!file_exists($strConfigFile)) { - $arrTemplate['CHECK_6_CONTENT_1'] = $strHTMLPart3.translate("Settings file does not exists (config/settings.php)").$strHTMLPart6.translate("will be created")."
\n"; + $arrTemplate['CHECK_6_CONTENT_1'] = $strHTMLPart3.$myInstClass->translate("Settings file does not exists (config/settings.php)").$strHTMLPart6.$myInstClass->translate("will be created")."
\n"; } if(file_exists($strConfigFile) && is_writable($strConfigFile)) { - $arrTemplate['CHECK_6_CONTENT_2'] = $strHTMLPart1.translate("Write test on settings file (config/settings.php)").$strHTMLPart4.translate("OK")."
\n"; + $arrTemplate['CHECK_6_CONTENT_2'] = $strHTMLPart1.$myInstClass->translate("Write test on settings file (config/settings.php)").$strHTMLPart4.$myInstClass->translate("OK")."
\n"; } else if (is_writable("../config") && !file_exists($strConfigFile)) { - $arrTemplate['CHECK_6_CONTENT_2'] = $strHTMLPart1.translate("Write test on settings directory (config/)").$strHTMLPart4.translate("OK")."
\n"; + $arrTemplate['CHECK_6_CONTENT_2'] = $strHTMLPart1.$myInstClass->translate("Write test on settings directory (config/)").$strHTMLPart4.$myInstClass->translate("OK")."
\n"; } else if (file_exists($strConfigFile) && !is_writable($strConfigFile)) { - $arrTemplate['CHECK_6_CONTENT_2'] = $strHTMLPart2.translate("Write test on settings file (config/settings.php)").$strHTMLPart5.translate("failed")."
\n"; + $arrTemplate['CHECK_6_CONTENT_2'] = $strHTMLPart2.$myInstClass->translate("Write test on settings file (config/settings.php)").$strHTMLPart5.$myInstClass->translate("failed")."
\n"; $intError = 1; } else { - $arrTemplate['CHECK_6_CONTENT_2'] = $strHTMLPart2.translate("Write test on settings directory (config/)").$strHTMLPart5.translate("failed")."
\n"; + $arrTemplate['CHECK_6_CONTENT_2'] = $strHTMLPart2.$myInstClass->translate("Write test on settings directory (config/)").$strHTMLPart5.$myInstClass->translate("failed")."
\n"; $intError = 1; } $strClassFile = "../functions/nag_class.php"; if(file_exists($strClassFile) && is_readable($strClassFile)) { - $arrTemplate['CHECK_6_CONTENT_3'] = $strHTMLPart1.translate("Read test on a class file (functions/nag_class.php)").$strHTMLPart4.translate("OK")."
\n"; + $arrTemplate['CHECK_6_CONTENT_3'] = $strHTMLPart1.$myInstClass->translate("Read test on a class file (functions/nag_class.php)").$strHTMLPart4.$myInstClass->translate("OK")."
\n"; } else { - $arrTemplate['CHECK_6_CONTENT_3'] = $strHTMLPart2.translate("Read test on a class file (functions/nag_class.php)").$strHTMLPart5.translate("failed")."
\n"; + $arrTemplate['CHECK_6_CONTENT_3'] = $strHTMLPart2.$myInstClass->translate("Read test on a class file (functions/nag_class.php)").$strHTMLPart5.$myInstClass->translate("failed")."
\n"; $intError = 1; } $strFile = "../admin.php"; if(file_exists($strFile) && is_readable($strFile)) { - $arrTemplate['CHECK_6_CONTENT_4'] = $strHTMLPart1.translate("Read test on startsite file (admin.php)").$strHTMLPart4.translate("OK")."
\n"; + $arrTemplate['CHECK_6_CONTENT_4'] = $strHTMLPart1.$myInstClass->translate("Read test on startsite file (admin.php)").$strHTMLPart4.$myInstClass->translate("OK")."
\n"; } else { - $arrTemplate['CHECK_6_CONTENT_4'] = $strHTMLPart2.translate("Read test on startsite file (admin.php)").$strHTMLPart5.translate("failed")."
\n"; + $arrTemplate['CHECK_6_CONTENT_4'] = $strHTMLPart2.$myInstClass->translate("Read test on startsite file (admin.php)").$strHTMLPart5.$myInstClass->translate("failed")."
\n"; $intError = 1; } $strFile = "../templates/index.tpl.htm"; if(file_exists($strFile) && is_readable($strFile)) { - $arrTemplate['CHECK_6_CONTENT_5'] = $strHTMLPart1.translate("Read test on a template file (templates/index.tpl.htm)").$strHTMLPart4.translate("OK")."
\n"; + $arrTemplate['CHECK_6_CONTENT_5'] = $strHTMLPart1.$myInstClass->translate("Read test on a template file (templates/index.tpl.htm)").$strHTMLPart4.$myInstClass->translate("OK")."
\n"; } else { - $arrTemplate['CHECK_6_CONTENT_5'] = $strHTMLPart2.translate("Read test on a template file (templates/index.tpl.htm)").$strHTMLPart5.translate("failed")."
\n"; + $arrTemplate['CHECK_6_CONTENT_5'] = $strHTMLPart2.$myInstClass->translate("Read test on a template file (templates/index.tpl.htm)").$strHTMLPart5.$myInstClass->translate("failed")."
\n"; $intError = 1; } $strFile = "../templates/admin/admin_master.tpl.htm"; if(file_exists($strFile) && is_readable($strFile)) { - $arrTemplate['CHECK_6_CONTENT_6'] = $strHTMLPart1.translate("Read test on a admin template file (templates/admin/admin_master.tpl.htm)").$strHTMLPart4.translate("OK")."
\n"; + $arrTemplate['CHECK_6_CONTENT_6'] = $strHTMLPart1.$myInstClass->translate("Read test on a admin template file (templates/admin/admin_master.tpl.htm)").$strHTMLPart4.$myInstClass->translate("OK")."
\n"; } else { - $arrTemplate['CHECK_6_CONTENT_6'] = $strHTMLPart2.translate("Read test on a admin template file (templates/admin/admin_master.tpl.htm)").$strHTMLPart5.translate("failed")."
\n"; + $arrTemplate['CHECK_6_CONTENT_6'] = $strHTMLPart2.$myInstClass->translate("Read test on a admin template file (templates/admin/admin_master.tpl.htm)").$strHTMLPart5.$myInstClass->translate("failed")."
\n"; $intError = 1; } $strFile = "../templates/files/contacts.tpl.dat"; if(file_exists($strFile) && is_readable($strFile)) { - $arrTemplate['CHECK_6_CONTENT_7'] = $strHTMLPart1.translate("Read test on a file template (templates/files/contacts.tpl.dat)").$strHTMLPart4.translate("OK")."
\n"; + $arrTemplate['CHECK_6_CONTENT_7'] = $strHTMLPart1.$myInstClass->translate("Read test on a file template (templates/files/contacts.tpl.dat)").$strHTMLPart4.$myInstClass->translate("OK")."
\n"; } else { - $arrTemplate['CHECK_6_CONTENT_7'] = $strHTMLPart2.translate("Read test on a file template (templates/files/contacts.tpl.dat)").$strHTMLPart5.translate("failed")."
\n"; + $arrTemplate['CHECK_6_CONTENT_7'] = $strHTMLPart2.$myInstClass->translate("Read test on a file template (templates/files/contacts.tpl.dat)").$strHTMLPart5.$myInstClass->translate("failed")."
\n"; $intError = 1; } $strFile = "../images/pixel.gif"; if(file_exists($strFile) && is_readable($strFile)) { - $arrTemplate['CHECK_6_CONTENT_8'] = $strHTMLPart1.translate("Read test on a image file (images/pixel.gif)").$strHTMLPart4.translate("OK")."
\n"; + $arrTemplate['CHECK_6_CONTENT_8'] = $strHTMLPart1.$myInstClass->translate("Read test on a image file (images/pixel.gif)").$strHTMLPart4.$myInstClass->translate("OK")."
\n"; } else { - $arrTemplate['CHECK_6_CONTENT_9'] = $strHTMLPart2.translate("Read test on a image file (images/pixel.gif)").$strHTMLPart5.translate("failed")."
\n"; + $arrTemplate['CHECK_6_CONTENT_9'] = $strHTMLPart2.$myInstClass->translate("Read test on a image file (images/pixel.gif)").$strHTMLPart5.$myInstClass->translate("failed")."
\n"; $intError = 1; } if ($intError != 0) { - $arrTemplate['MESSAGE'] = "".translate("There are some errors - please check your system settings and read the requirements of NagiosQL!")."

\n"; - $arrTemplate['MESSAGE'] .= translate("Read the INSTALLATION file from NagiosQL to find out, how to fix them.") ."
\n"; - $arrTemplate['MESSAGE'] .= translate("After that - refresh this page to proceed") ."...
\n"; + $arrTemplate['MESSAGE'] = "".$myInstClass->translate("There are some errors - please check your system settings and read the requirements of NagiosQL!")."

\n"; + $arrTemplate['MESSAGE'] .= $myInstClass->translate("Read the INSTALLATION file in the NagiosQL doc directory or the installation PDF file on our"); + $arrTemplate['MESSAGE'] .= " "; + $arrTemplate['MESSAGE'] .= $myInstClass->translate("online documentation")."
".$myInstClass->translate("site to find out, how to fix them.") ."
\n"; + $arrTemplate['MESSAGE'] .= $myInstClass->translate("After that - refresh this page to proceed") ."...
\n"; $arrTemplate['DIV_ID'] = "install-center"; $arrTemplate['FORM_CONTENT'] = "
"; - $arrTemplate['FORM_CONTENT'] .= translate("Refresh")."\n"; + $arrTemplate['FORM_CONTENT'] .= $myInstClass->translate("Refresh")."\n"; } else { - $arrTemplate['MESSAGE'] = "".translate("Environment test sucessfully passed")."

\n"; + $arrTemplate['MESSAGE'] = "".$myInstClass->translate("Environment test sucessfully passed")."

\n"; $arrTemplate['DIV_ID'] = "install-next"; $arrTemplate['FORM_CONTENT'] = "\n"; - $arrTemplate['FORM_CONTENT'] .= "
".translate("Next")."\n"; + $arrTemplate['FORM_CONTENT'] .= "
".$myInstClass->translate("Next")."\n"; } // // Write content diff --git a/install/step2.php b/install/step2.php index 8fe576c..5a6a120 100644 --- a/install/step2.php +++ b/install/step2.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Installer script - step 2 // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-23 11:44:55 +0100 (Thu, 23 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1239 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // @@ -30,56 +30,66 @@ $intError = 0; // // Build content // ============= -$arrTemplate['PASSWD_MESSAGE'] = translate('The NagiosQL first passwords are not equal!'); -$arrTemplate['FIELDS_MESSAGE'] = translate('Please fill in all fields marked with an *'); -$arrTemplate['STEP1_BOX'] = translate('Requirements'); -$arrTemplate['STEP2_BOX'] = translate($_SESSION['install']['mode']); -$arrTemplate['STEP3_BOX'] = translate('Finish'); -$arrTemplate['STEP2_TITLE'] = "NagiosQL ".translate($_SESSION['install']['mode']).": ".translate("Setup"); -$arrTemplate['STEP2_TEXT1_1'] = translate("Please complete the form below. Mandatory fields marked *"); -$arrTemplate['STEP2_TEXT2_1'] = translate("Database Configuration"); -$arrTemplate['STEP2_TEXT2_2'] = translate("Database Type"); -$arrTemplate['STEP2_VALUE2_2'] = htmlspecialchars($_SESSION['install']['dbtype'], ENT_QUOTES, 'utf-8'); -$arrTemplate['STEP2_TEXT2_3'] = translate("Database Server"); +$arrTemplate['PASSWD_MESSAGE'] = $myInstClass->translate('The NagiosQL first passwords are not equal!'); +$arrTemplate['FIELDS_MESSAGE'] = $myInstClass->translate('Please fill in all fields marked with an *'); +$arrTemplate['STEP1_BOX'] = $myInstClass->translate('Requirements'); +$arrTemplate['STEP2_BOX'] = $myInstClass->translate($_SESSION['install']['mode']); +$arrTemplate['STEP3_BOX'] = $myInstClass->translate('Finish'); +$arrTemplate['STEP2_TITLE'] = "NagiosQL ".$myInstClass->translate($_SESSION['install']['mode']).": ".$myInstClass->translate("Setup"); +$arrTemplate['STEP2_TEXT1_1'] = $myInstClass->translate("Please complete the form below. Mandatory fields marked *"); +$arrTemplate['STEP2_TEXT2_1'] = $myInstClass->translate("Database Configuration"); +$arrTemplate['STEP2_TEXT2_2'] = $myInstClass->translate("Database Type"); +if (is_array($_SESSION['install']['dbtype_available']) && (count($_SESSION['install']['dbtype_available']) != 0)) { + $strDBType = ""; + foreach ($_SESSION['install']['dbtype_available'] AS $elem) { + $strSelected = ""; + if (isset($_SESSION['install']['dbtype']) && ($_SESSION['install']['dbtype'] == $elem)) $strSelected = "selected=\"selected\""; + $strDBType .= "\n"; + } +} else { + $strDBType .= "\n"; +} +$arrTemplate['STEP2_VALUE2_2'] = $strDBType; +$arrTemplate['STEP2_TEXT2_3'] = $myInstClass->translate("Database Server"); $arrTemplate['STEP2_VALUE2_3'] = htmlspecialchars($_SESSION['install']['dbserver'], ENT_QUOTES, 'utf-8'); -$arrTemplate['STEP2_TEXT2_4'] = translate("Local hostname or IP address"); +$arrTemplate['STEP2_TEXT2_4'] = $myInstClass->translate("Local hostname or IP address"); if (htmlspecialchars($_SESSION['install']['dbserver'], ENT_QUOTES, 'utf-8') == "localhost") { $arrTemplate['STEP2_VALUE2_4'] = htmlspecialchars($_SESSION['install']['dbserver'], ENT_QUOTES, 'utf-8'); }else { $arrTemplate['STEP2_VALUE2_4'] = $_SERVER['SERVER_ADDR']; } -$arrTemplate['STEP2_TEXT2_5'] = translate("Database Server Port"); +$arrTemplate['STEP2_TEXT2_5'] = $myInstClass->translate("Database Server Port"); $arrTemplate['STEP2_VALUE2_5'] = htmlspecialchars($_SESSION['install']['dbport'], ENT_QUOTES, 'utf-8'); -$arrTemplate['STEP2_TEXT2_6'] = translate("Database name"); +$arrTemplate['STEP2_TEXT2_6'] = $myInstClass->translate("Database name"); $arrTemplate['STEP2_VALUE2_6'] = htmlspecialchars($_SESSION['install']['dbname'], ENT_QUOTES, 'utf-8'); -$arrTemplate['STEP2_TEXT2_7'] = translate("NagiosQL DB User"); +$arrTemplate['STEP2_TEXT2_7'] = $myInstClass->translate("NagiosQL DB User"); $arrTemplate['STEP2_VALUE2_7'] = htmlspecialchars($_SESSION['install']['dbuser'], ENT_QUOTES, 'utf-8'); -$arrTemplate['STEP2_TEXT2_8'] = translate("NagiosQL DB Password"); +$arrTemplate['STEP2_TEXT2_8'] = $myInstClass->translate("NagiosQL DB Password"); $arrTemplate['STEP2_VALUE2_8'] = htmlspecialchars($_SESSION['install']['dbpass'], ENT_QUOTES, 'utf-8'); -$arrTemplate['STEP2_TEXT2_9'] = translate("Administrative Database User"); +$arrTemplate['STEP2_TEXT2_9'] = $myInstClass->translate("Administrative Database User"); $arrTemplate['STEP2_VALUE2_9'] = htmlspecialchars($_SESSION['install']['admuser'], ENT_QUOTES, 'utf-8'); -$arrTemplate['STEP2_TEXT2_10'] = translate("Administrative Database Password"); -$arrTemplate['STEP2_TEXT2_11'] = translate("Drop database if already exists?"); +$arrTemplate['STEP2_TEXT2_10'] = $myInstClass->translate("Administrative Database Password"); +$arrTemplate['STEP2_TEXT2_11'] = $myInstClass->translate("Drop database if already exists?"); if ($_SESSION['install']['dbdrop'] == 1) {$arrTemplate['STEP2_VALUE2_11'] = "checked";} else {$arrTemplate['STEP2_VALUE2_11'] = "";} -$arrTemplate['STEP2_TEXT3_1'] = translate("NagiosQL User Setup"); -$arrTemplate['STEP2_TEXT3_2'] = translate("Initial NagiosQL User"); +$arrTemplate['STEP2_TEXT3_1'] = $myInstClass->translate("NagiosQL User Setup"); +$arrTemplate['STEP2_TEXT3_2'] = $myInstClass->translate("Initial NagiosQL User"); $arrTemplate['STEP2_VALUE3_2'] = htmlspecialchars($_SESSION['install']['qluser'], ENT_QUOTES, 'utf-8'); -$arrTemplate['STEP2_TEXT3_3'] = translate("Initial NagiosQL Password"); +$arrTemplate['STEP2_TEXT3_3'] = $myInstClass->translate("Initial NagiosQL Password"); $arrTemplate['STEP2_VALUE3_3'] = htmlspecialchars($_SESSION['install']['qlpass'], ENT_QUOTES, 'utf-8'); -$arrTemplate['STEP2_TEXT3_4'] = translate("Please repeat the password"); -$arrTemplate['STEP2_TEXT4_1'] = translate("Nagios Configuration"); -$arrTemplate['STEP2_TEXT4_2'] = translate("Import Nagios sample config?"); +$arrTemplate['STEP2_TEXT3_4'] = $myInstClass->translate("Please repeat the password"); +$arrTemplate['STEP2_TEXT4_1'] = $myInstClass->translate("Nagios Configuration"); +$arrTemplate['STEP2_TEXT4_2'] = $myInstClass->translate("Import Nagios sample config?"); if ($_SESSION['install']['sample'] == 1) {$arrTemplate['STEP2_VALUE4_2'] = "checked";} else {$arrTemplate['STEP2_VALUE4_2'] = "";} -$arrTemplate['STEP2_FORM_1'] = translate("Next"); -$arrTemplate['STEP2_TEXT5_1'] = translate("NagiosQL path values"); -$arrTemplate['STEP2_TEXT5_2'] = translate("Create NagiosQL config paths?"); +$arrTemplate['STEP2_FORM_1'] = $myInstClass->translate("Next"); +$arrTemplate['STEP2_TEXT5_1'] = $myInstClass->translate("NagiosQL path values"); +$arrTemplate['STEP2_TEXT5_2'] = $myInstClass->translate("Create NagiosQL config paths?"); if ($_SESSION['install']['createpath'] == 1) {$arrTemplate['STEP2_VALUE5_2'] = "checked";} else {$arrTemplate['STEP2_VALUE5_2'] = "";} -$arrTemplate['STEP2_TEXT5_3'] = translate("NagiosQL config path"); +$arrTemplate['STEP2_TEXT5_3'] = $myInstClass->translate("NagiosQL config path"); $arrTemplate['STEP2_VALUE5_3'] = htmlspecialchars($_SESSION['install']['qlpath'], ENT_QUOTES, 'utf-8'); -$arrTemplate['STEP2_TEXT5_4'] = translate("Nagios config path"); +$arrTemplate['STEP2_TEXT5_4'] = $myInstClass->translate("Nagios config path"); $arrTemplate['STEP2_VALUE5_4'] = htmlspecialchars($_SESSION['install']['nagpath'], ENT_QUOTES, 'utf-8'); -$arrTemplate['STEP2_TEXT5_5'] = translate("Both path values were stored in your configuration target settings for localhost."); -$arrTemplate['STEP2_TEXT5_6'] = translate("If you select the create path option, be sure that the NagiosQL base path exist and the webserver demon has write access to it. So the installer will create the required subdirectories in your localhost's filesystem (hosts, services, backup etc.)"); +$arrTemplate['STEP2_TEXT5_5'] = $myInstClass->translate("Both path values were stored in your configuration target settings for localhost."); +$arrTemplate['STEP2_TEXT5_6'] = $myInstClass->translate("If you select the create path option, be sure that the NagiosQL base path exist and the webserver demon has write access to it. So the installer will create the required subdirectories in your localhost's filesystem (hosts, services, backup etc.)"); $arrTemplate['INSTALL_FIELDS'] = ""; // @@ -91,7 +101,7 @@ $arrTemplate['STEP2_TEXT1_2'] = ""; // Conditional checks // ======================= if ($_SESSION['install']['mode'] == "Update") { - $arrTemplate['STEP2_TEXT1_2'] = "

".translate("Please backup your database before proceeding!")."

\n"; + $arrTemplate['STEP2_TEXT1_2'] = "

".$myInstClass->translate("Please backup your database before proceeding!")."

\n"; $arrTemplate['INST_VISIBLE'] = "hidefield"; } else { $arrTemplate['INSTALL_FIELDS'] = ",tfDBprivUser,tfDBprivPass,tfQLuser,tfQLpass"; diff --git a/install/step3.php b/install/step3.php index b331381..cf8ecdc 100644 --- a/install/step3.php +++ b/install/step3.php @@ -5,15 +5,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Installer script - step 2 // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-02-23 11:44:55 +0100 (Thu, 23 Feb 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1239 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // @@ -34,27 +34,28 @@ if(function_exists("date_default_timezone_set") and function_exists("date_defaul // // Build content // ============= -$arrTemplate['STEP1_BOX'] = translate('Requirements'); -$arrTemplate['STEP2_BOX'] = translate($_SESSION['install']['mode']); -$arrTemplate['STEP3_BOX'] = translate('Finish'); -$arrTemplate['STEP3_TITLE'] = "NagiosQL ".translate($_SESSION['install']['mode']).": ".translate("Finishing Setup"); +$arrTemplate['STEP1_BOX'] = $myInstClass->translate('Requirements'); +$arrTemplate['STEP2_BOX'] = $myInstClass->translate($_SESSION['install']['mode']); +$arrTemplate['STEP3_BOX'] = $myInstClass->translate('Finish'); +$arrTemplate['STEP3_TITLE'] = "NagiosQL ".$myInstClass->translate($_SESSION['install']['mode']).": ".$myInstClass->translate("Finishing Setup"); $arrTemplate['INST_VISIBLE'] = "showfield"; -$arrTemplate['STEP4_SUB_TITLE'] = translate("Deploy NagiosQL settings"); -$arrTemplate['STEP3_TEXT_01'] = translate("Database server connection (privileged user)"); -$arrTemplate['STEP3_TEXT_03'] = translate("Database server version"); -$arrTemplate['STEP3_TEXT_05'] = translate("Database server support"); -$arrTemplate['STEP3_TEXT_07'] = translate("Delete existing NagiosQL database"); -$arrTemplate['STEP3_TEXT_09'] = translate("Creating new database"); -$arrTemplate['STEP3_TEXT_11'] = translate("Create NagiosQL database user"); -$arrTemplate['STEP3_TEXT_13'] = translate("Installing NagiosQL database tables"); -$arrTemplate['STEP3_TEXT_15'] = translate("Set initial NagiosQL Administrator"); -$arrTemplate['STEP3_TEXT_17'] = translate("Database server connection (NagiosQL user)"); -$arrTemplate['STEP4_TEXT_01'] = translate("Writing global settings to database"); -$arrTemplate['STEP4_TEXT_03'] = translate("Writing database configuration to settings.php"); -$arrTemplate['STEP4_TEXT_05'] = translate("Import Nagios sample data"); -$arrTemplate['STEP4_TEXT_07'] = translate("Create and/or store NagiosQL path settings"); +$arrTemplate['STEP4_SUB_TITLE'] = $myInstClass->translate("Deploy NagiosQL settings"); +$arrTemplate['STEP3_TEXT_01'] = $myInstClass->translate("Database server connection (privileged user)"); +$arrTemplate['STEP3_TEXT_03'] = $myInstClass->translate("Database server version"); +$arrTemplate['STEP3_TEXT_05'] = $myInstClass->translate("Database server support"); +$arrTemplate['STEP3_TEXT_07'] = $myInstClass->translate("Delete existing NagiosQL database"); +$arrTemplate['STEP3_TEXT_09'] = $myInstClass->translate("Creating new database"); +$arrTemplate['STEP3_TEXT_11'] = $myInstClass->translate("Installing NagiosQL database tables"); +$arrTemplate['STEP3_TEXT_13'] = $myInstClass->translate("Create NagiosQL database user"); +$arrTemplate['STEP3_TEXT_15'] = $myInstClass->translate("Set initial NagiosQL Administrator"); +$arrTemplate['STEP3_TEXT_17'] = $myInstClass->translate("Database server connection (NagiosQL user)"); +$arrTemplate['STEP4_TEXT_01'] = $myInstClass->translate("Writing global settings to database"); +$arrTemplate['STEP4_TEXT_03'] = $myInstClass->translate("Writing database configuration to settings.php"); +$arrTemplate['STEP4_TEXT_05'] = $myInstClass->translate("Import Nagios sample data"); +$arrTemplate['STEP4_TEXT_07'] = $myInstClass->translate("Create and/or store NagiosQL path settings"); $arrTemplate['STEP4_VISIBLE'] = "hidefield"; +$arrTemplate['STEP3_TEXT_02_SHOW'] = "hidefield"; $arrTemplate['STEP3_TEXT_03_SHOW'] = "hidefield"; $arrTemplate['STEP3_TEXT_05_SHOW'] = "hidefield"; $arrTemplate['STEP3_TEXT_07_SHOW'] = "hidefield"; @@ -67,83 +68,144 @@ $arrTemplate['STEP4_TEXT_03_SHOW'] = "hidefield"; $arrTemplate['STEP4_TEXT_05_SHOW'] = "hidefield"; $arrTemplate['STEP4_TEXT_07_SHOW'] = "hidefield"; // +// Check any data before installation +// ================================== +$intInstError = 0; +// // Doing installation/upgrade // ========================== if ($_SESSION['install']['mode'] == "Update") { - $arrTemplate['STEP3_SUB_TITLE'] = translate("Updating existing NagiosQL database"); - if ($_SESSION['install']['dbtype'] == "mysql") { - // Check database connection - if ($intError == 0) $intError = $myInstClass->openAdmDBSrv($arrTemplate['STEP3_TEXT_02'],$strErrorMessage); - if ($intError == 0) $intError = $myInstClass->openDatabase($arrTemplate['STEP3_TEXT_02'],$strErrorMessage); - // Check NagiosQL version - if ($intError == 0) { - $arrTemplate['STEP3_TEXT_03'] = translate("Installed NagiosQL version"); - $arrTemplate['STEP3_TEXT_03_SHOW'] = "showfield"; - $intError = $myInstClass->checkQLVersion($arrTemplate['STEP3_TEXT_04'],$strErrorMessage,$arrUpdate,$setQLVersion); - } - // Upgrade NagiosQL DB - if ($intError == 0) { - $arrTemplate['STEP3_TEXT_05'] = translate("Upgrading from version")." ".$setQLVersion." ".translate("to")." ".$preNagiosQL_ver; - $arrTemplate['STEP3_TEXT_05_SHOW'] = "showfield"; - $intError = $myInstClass->updateQLDB($arrTemplate['STEP3_TEXT_06'],$strErrorMessage,$arrUpdate); - } + $arrTemplate['STEP3_SUB_TITLE'] = $myInstClass->translate("Updating existing NagiosQL database"); + // + // Include database class + // ====================== + if ($_SESSION['install']['dbtype'] == "mysqli") { + // Include and initialize mysqli class + include("../functions/mysqli_class.php"); + $myDBClass = new mysqlidb; + } else if ($_SESSION['install']['dbtype'] == "pgsql") { + // Include and initialize pgsql class + include("../functions/pgsql_class.php"); + $myDBClass = new pgsqldb; + } else { + $strErrorMessage .= $myInstClass->translate("Database type not defined!")." (".$_SESSION['install']['dbtype'].")
\n"; + $strStatusMessage = "".$myInstClass->translate("failed").""; + $intError = 1; + } + // Set DB parameters + $myDBClass->arrParams['server'] = $_SESSION['install']['dbserver']; + $myDBClass->arrParams['port'] = $_SESSION['install']['dbport']; + $myDBClass->arrParams['username'] = $_SESSION['install']['admuser']; + $myDBClass->arrParams['password'] = $_SESSION['install']['admpass']; + $myDBClass->arrParams['database'] = $_SESSION['install']['dbname']; + // Include classes + if ($intError == 0) $myInstClass->myDBClass =& $myDBClass; + // Check database connection + if ($intError == 0) $intError = $myInstClass->openAdmDBSrv($arrTemplate['STEP3_TEXT_02'],$strErrorMessage); + if ($intError == 0) $intError = $myInstClass->openDatabase($arrTemplate['STEP3_TEXT_02'],$strErrorMessage); + $arrTemplate['STEP3_TEXT_02_SHOW'] = "showfield"; + // Check NagiosQL version + if ($intError == 0) { + $arrTemplate['STEP3_TEXT_03'] = $myInstClass->translate("Installed NagiosQL version"); + $arrTemplate['STEP3_TEXT_03_SHOW'] = "showfield"; + $intError = $myInstClass->checkQLVersion($arrTemplate['STEP3_TEXT_04'],$strErrorMessage,$arrUpdate,$setQLVersion); + } + // Upgrade NagiosQL DB + if ($intError == 0) { + $arrTemplate['STEP3_TEXT_05'] = $myInstClass->translate("Upgrading from version")." ".$setQLVersion." ".$myInstClass->translate("to")." ".$preNagiosQL_ver; + $arrTemplate['STEP3_TEXT_05_SHOW'] = "showfield"; + $intError = $myInstClass->updateQLDB($arrTemplate['STEP3_TEXT_06'],$strErrorMessage,$arrUpdate); + } + if (($_SESSION['install']['dbtype'] == "mysql") && (version_compare($setQLVersion,"3.2.0") == -1)) { // Converting database to UTF8 if ($intError == 0) { - $arrTemplate['STEP3_TEXT_07'] = translate("Converting database to utf8 character set"); + $arrTemplate['STEP3_TEXT_07'] = $myInstClass->translate("Converting database to utf8 character set"); $arrTemplate['STEP3_TEXT_07_SHOW'] = "showfield"; $intError = $myInstClass->convQLDB($arrTemplate['STEP3_TEXT_08'],$strErrorMessage); } // Converting database tables to UTF8 if ($intError == 0) { - $arrTemplate['STEP3_TEXT_09'] = translate("Converting database tables to utf8 character set"); + $arrTemplate['STEP3_TEXT_09'] = $myInstClass->translate("Converting database tables to utf8 character set"); $arrTemplate['STEP3_TEXT_09_SHOW'] = "showfield"; $intError = $myInstClass->convQLDBTables($arrTemplate['STEP3_TEXT_10'],$strErrorMessage); } // Converting database fields to UTF8 if ($intError == 0) { - $arrTemplate['STEP3_TEXT_11'] = translate("Converting database fields to utf8 character set"); + $arrTemplate['STEP3_TEXT_11'] = $myInstClass->translate("Converting database fields to utf8 character set"); $arrTemplate['STEP3_TEXT_11_SHOW'] = "showfield"; $intError = $myInstClass->convQLDBFields($arrTemplate['STEP3_TEXT_12'],$strErrorMessage); } - // Reconnect Database with new user - if ($intError == 0) { - $arrTemplate['STEP3_TEXT_17_SHOW'] = "showfield"; - $intError = $myInstClass->openAdmDBSrv($arrTemplate['STEP3_TEXT_18'],$strErrorMessage,1); - $intError = $myInstClass->openDatabase($arrTemplate['STEP3_TEXT_18'],$strErrorMessage,1); - } - // Deploy NagiosQL database settings - if ($intError == 0) { - $arrTemplate['STEP4_VISIBLE'] = "showfield"; - $intError = $myInstClass->updateSettingsDB($arrTemplate['STEP4_TEXT_02'],$strErrorMessage); - } - // Write database settings to file - if ($intError == 0) { - $arrTemplate['STEP4_TEXT_03_SHOW'] = "showfield"; - $intError = $myInstClass->updateSettingsFile($arrTemplate['STEP4_TEXT_04'],$strErrorMessage); - } + } + // Reconnect Database with new user + if ($intError == 0) { + $arrTemplate['STEP3_TEXT_17_SHOW'] = "showfield"; + $intError = $myInstClass->openAdmDBSrv($arrTemplate['STEP3_TEXT_18'],$strErrorMessage,1); + $intError = $myInstClass->openDatabase($arrTemplate['STEP3_TEXT_18'],$strErrorMessage,1); + } + // Deploy NagiosQL database settings + if ($intError == 0) { + $arrTemplate['STEP4_VISIBLE'] = "showfield"; + $intError = $myInstClass->updateSettingsDB($arrTemplate['STEP4_TEXT_02'],$strErrorMessage); + } + // Write database settings to file + if ($intError == 0) { + $arrTemplate['STEP4_TEXT_03_SHOW'] = "showfield"; + $intError = $myInstClass->updateSettingsFile($arrTemplate['STEP4_TEXT_04'],$strErrorMessage); } } else { - $arrTemplate['STEP3_SUB_TITLE'] = translate("Create new NagiosQL database"); + $arrTemplate['STEP3_SUB_TITLE'] = $myInstClass->translate("Create new NagiosQL database"); + // + // Include database class + // ====================== + if ($_SESSION['install']['dbtype'] == "mysqli") { + // Include and initialize mysqli class + include("../functions/mysqli_class.php"); + $myDBClass = new mysqlidb; + } else if ($_SESSION['install']['dbtype'] == "pgsql") { + // Include and initialize pgsql class + include("../functions/pgsql_class.php"); + $myDBClass = new pgsqldb; + //} else if ($_SESSION['install']['dbtype'] == "sqlite3") { + // // Include sqlite3 and initialize class + // include("../functions/sqlite3_class.php"); + // $myDBClass = new sqlite3db; + } else { + $strErrorMessage .= $myInstClass->translate("Database type not defined!")." (".$_SESSION['install']['dbtype'].")
\n"; + $strStatusMessage = "".$myInstClass->translate("failed").""; + $intError = 1; + } + // Set DB parameters + $myDBClass->arrParams['server'] = $_SESSION['install']['dbserver']; + $myDBClass->arrParams['port'] = $_SESSION['install']['dbport']; + $myDBClass->arrParams['username'] = $_SESSION['install']['admuser']; + $myDBClass->arrParams['password'] = $_SESSION['install']['admpass']; + $myDBClass->arrParams['database'] = $_SESSION['install']['dbname']; + // Include classes + if ($intError == 0) $myInstClass->myDBClass =& $myDBClass; // Check database connection $intOldDBStatus = 0; if ($intError == 0) $intError = $myInstClass->openAdmDBSrv($arrTemplate['STEP3_TEXT_02'],$strErrorMessage); + // Does the database already exist? if ($intError == 0) { - $intOldDBStatus = $myInstClass->openDatabase($arrTemplate['STEP3_TEXT_02'],$strErrorMessage); + $intOldDBStatus = $myInstClass->openDatabase($strTmpMessage,$strTmpError); + $myDBClass->strErrorMessage = ""; if (($intOldDBStatus == 0) && ($_SESSION['install']['dbdrop'] == 0)) { - $strErrorMessage .= translate("Database already exists and drop database was not selected, please correct or manage manually")."
"; - $arrTemplate['STEP3_TEXT_02'] = "".translate("failed").""; - $intError = 1; + $strErrorMessage .= $myInstClass->translate("Database already exists and drop database was not selected, please correct or manage manually")."
"; + $arrTemplate['STEP3_TEXT_02'] = "".$myInstClass->translate("failed").""; + $intError = 1; } else { - $arrTemplate['STEP3_TEXT_02'] = "".translate("passed").""; + $myInstClass->openAdmDBSrv($arrTemplate['STEP3_TEXT_02'],$strErrorMessage); } } + $arrTemplate['STEP3_TEXT_02_SHOW'] = "showfield"; + $arrTemplate['STEP3_TEXT_02'] .= " (".$_SESSION['install']['dbtype'].")"; // Check database version if ($intError == 0) { $arrTemplate['STEP3_TEXT_03_SHOW'] = "showfield"; $arrTemplate['STEP3_TEXT_05_SHOW'] = "showfield"; $intError = $myInstClass->checkDBVersion($arrTemplate['STEP3_TEXT_06'],$strErrorMessage,$strVersion); if ($strVersion == "unknown") { - $arrTemplate['STEP3_TEXT_04'] = "".translate("unknown").""; + $arrTemplate['STEP3_TEXT_04'] = "".$myInstClass->translate("unknown").""; } else { $arrTemplate['STEP3_TEXT_04'] = "".$strVersion.""; } @@ -157,18 +219,19 @@ if ($_SESSION['install']['mode'] == "Update") { if ($intError == 0) { $arrTemplate['STEP3_TEXT_09_SHOW'] = "showfield"; $intError = $myInstClass->createDB($arrTemplate['STEP3_TEXT_10'],$strErrorMessage); + echo $strErrorMessage; + } + // Write initial SQL data to database + if ($intError == 0) $intError = $myInstClass->openDatabase($strTmp,$strErrorMessage); + if ($intError == 0) { + $arrTemplate['STEP3_TEXT_11_SHOW'] = "showfield"; + $arrInsert[] = $preSqlNewInstall; + $intError = $myInstClass->updateQLDB($arrTemplate['STEP3_TEXT_12'],$strErrorMessage,$arrInsert); } // Grant NagiosQL database user - if ($intError == 0) { - $arrTemplate['STEP3_TEXT_11_SHOW'] = "showfield"; - $intError = $myInstClass->grantDBUser($arrTemplate['STEP3_TEXT_12'],$strErrorMessage); - } - // Write initial SQL data to database - if ($intError == 0) $intError = $myInstClass->openDatabase($arrTemplate['STEP3_TEXT_02'],$strErrorMessage); if ($intError == 0) { $arrTemplate['STEP3_TEXT_13_SHOW'] = "showfield"; - $arrInsert[] = $preSqlNewInstall; - $intError = $myInstClass->updateQLDB($arrTemplate['STEP3_TEXT_14'],$strErrorMessage,$arrInsert); + $intError = $myInstClass->grantDBUser($arrTemplate['STEP3_TEXT_14'],$strErrorMessage); } // Create NagiosQL admin user if ($intError == 0) { @@ -177,6 +240,8 @@ if ($_SESSION['install']['mode'] == "Update") { } // Reconnect Database with new user if ($intError == 0) { + $myDBClass->arrParams['username'] = $_SESSION['install']['dbuser']; + $myDBClass->arrParams['password'] = $_SESSION['install']['dbpass']; $arrTemplate['STEP3_TEXT_17_SHOW'] = "showfield"; if ($intError == 0) $intError = $myInstClass->openAdmDBSrv($arrTemplate['STEP3_TEXT_18'],$strErrorMessage,1); if ($intError == 0) $intError = $myInstClass->openDatabase($arrTemplate['STEP3_TEXT_18'],$strErrorMessage,1); @@ -185,7 +250,7 @@ if ($_SESSION['install']['mode'] == "Update") { if ($intError == 0) { $arrTemplate['STEP4_VISIBLE'] = "showfield"; $intError = $myInstClass->updateSettingsDB($arrTemplate['STEP4_TEXT_02'],$strErrorMessage); - } + } // Write database settings to file if ($intError == 0) { $arrTemplate['STEP4_TEXT_03_SHOW'] = "showfield"; @@ -208,14 +273,14 @@ if ($intError != 0) { $arrTemplate['INFO_TEXT'] = ""; $arrTemplate['BUTTON'] = "
\n"; $arrTemplate['BUTTON'] .= "\n"; - $arrTemplate['BUTTON'] .= "
".translate("Back")."\n"; + $arrTemplate['BUTTON'] .= "
".$myInstClass->translate("Back")."\n"; $arrTemplate['BUTTON'] .= "
\n"; } else { $arrTemplate['ERRORMESSAGE'] = ""; $arrTemplate['INST_VISIBLE'] = "showfield"; - $arrTemplate['INFO_TEXT'] = translate("Please delete the install directory to continue!"); + $arrTemplate['INFO_TEXT'] = $myInstClass->translate("Please delete the install directory to continue!"); $arrTemplate['BUTTON'] = "
\n"; - $arrTemplate['BUTTON'] .= "finish
".translate("Finish")."\n"; + $arrTemplate['BUTTON'] .= "finish
".$myInstClass->translate("Finish")."\n"; $arrTemplate['BUTTON'] .= "
\n"; } // diff --git a/install/templates/index.tpl.htm b/install/templates/index.tpl.htm old mode 100755 new mode 100644 index 874bf28..0816bbf --- a/install/templates/index.tpl.htm +++ b/install/templates/index.tpl.htm @@ -1,12 +1,12 @@ - + - + - - + + @@ -22,7 +22,7 @@ NagiosQL
@@ -38,6 +38,7 @@

{MAIN_TITLE}

{TEXT_PART_1}
{TEXT_PART_2}www.nagiosql.org
+

{TEXT_PART_9}


{TEXT_PART_3}

{TEXT_PART_4}

@@ -47,12 +48,8 @@
  • {TEXT_PHP_REQ_1}
  • {TEXT_PHP_REQ_2}
  • {TEXT_PHP_REQ_3}
  • - -
  • {TEXT_PHP_REQ_6}
  • -
  • {TEXT_PHP_REQ_8}
  • -
  • {TEXT_PHP_REQ_9}
  • {TEXT_PHP_REQ_10}
  • @@ -74,7 +71,7 @@

    -

    {ONLINE_DOC}

    +

    {ONLINE_DOC}

    diff --git a/install/templates/install.tpl.htm b/install/templates/install.tpl.htm old mode 100755 new mode 100644 index adeb67c..bdad9be --- a/install/templates/install.tpl.htm +++ b/install/templates/install.tpl.htm @@ -1,12 +1,12 @@ - + - + - - + + diff --git a/install/templates/step1.tpl.htm b/install/templates/step1.tpl.htm old mode 100755 new mode 100644 index f081d84..b249304 --- a/install/templates/step1.tpl.htm +++ b/install/templates/step1.tpl.htm @@ -1,12 +1,12 @@ - + - + - - + +



    {STEP1_BOX}

    @@ -18,7 +18,7 @@

    {STEP1_TITLE}

    {STEP1_SUBTITLE1}

    - {CHECK_1_PIC} Javascript: {CHECK_1_VALUE} + {CHECK_1_PIC} Javascript: {CHECK_1_VALUE}{CHECK_1_INFO}

    {STEP1_SUBTITLE2}

    {CHECK_2_PIC} {CHECK_2_TEXT}: {CHECK_2_VALUE} {CHECK_2_INFO}

    {STEP1_SUBTITLE3}

    @@ -46,9 +46,15 @@
    + {FORM_CONTENT}
    -
    \ No newline at end of file + +
    \ No newline at end of file diff --git a/install/templates/step2.tpl.htm b/install/templates/step2.tpl.htm old mode 100755 new mode 100644 index 42b7896..d9a21dc --- a/install/templates/step2.tpl.htm +++ b/install/templates/step2.tpl.htm @@ -1,12 +1,12 @@ - + - + - - + +
    @@ -59,8 +72,12 @@ {STEP2_TEXT2_1} - - + + diff --git a/install/templates/step3.tpl.htm b/install/templates/step3.tpl.htm old mode 100755 new mode 100644 index 3c2bf50..474022e --- a/install/templates/step3.tpl.htm +++ b/install/templates/step3.tpl.htm @@ -1,12 +1,12 @@ - + - + - - + +



    {STEP1_BOX}

    @@ -22,7 +22,7 @@ {STEP3_SUB_TITLE} {ERRORMESSAGE}
    {STEP2_TEXT2_2}{STEP2_TEXT2_2} * + +
    {STEP2_TEXT2_3} *
    - + diff --git a/libraries/pear/HTML/Template/IT.php b/libraries/pear/HTML/Template/IT.php index 462a7ab..a48faeb 100644 --- a/libraries/pear/HTML/Template/IT.php +++ b/libraries/pear/HTML/Template/IT.php @@ -1,1186 +1,1197 @@ - - * Pierre-Alain Joye - * David Soria Parra - * - * @category HTML - * @package HTML_Template_IT - * @author Ulf Wendel - * @license BSD http://www.opensource.org/licenses/bsd-license.php - * @version CVS: $Id: IT.php 295605 2010-02-28 22:48:07Z gregorycu $ - * @link http://pear.php.net/packages/HTML_Template_IT - * @access public - */ - -require_once (dirname(__FILE__) .'/../../PEAR.php' ); - -define('IT_OK', 1); -define('IT_ERROR', -1); -define('IT_TPL_NOT_FOUND', -2); -define('IT_BLOCK_NOT_FOUND', -3); -define('IT_BLOCK_DUPLICATE', -4); -define('IT_UNKNOWN_OPTION', -6); - -/** - * Integrated Template - IT - * - * Well there's not much to say about it. I needed a template class that - * supports a single template file with multiple (nested) blocks inside and - * a simple block API. - * - * The Isotemplate API is somewhat tricky for a beginner although it is the best - * one you can build. template::parse() [phplib template = Isotemplate] requests - * you to name a source and a target where the current block gets parsed into. - * Source and target can be block names or even handler names. This API gives you - * a maximum of fexibility but you always have to know what you do which is - * quite unusual for php skripter like me. - * - * I noticed that I do not any control on which block gets parsed into which one. - * If all blocks are within one file, the script knows how they are nested and in - * which way you have to parse them. IT knows that inner1 is a child of block2, - * there's no need to tell him about this. - * - *
    {STEP3_TEXT_02}
    - * - * - * - * - * - * - * - *
    - * __global__ - *

    - * (hidden and automatically added) - *

    block1 - * - * - * - * - * - * - * - * - *
    block2
    inner1inner2
    - *
    - * - * To add content to block1 you simply type: - * $tpl->setCurrentBlock("block1"); - * and repeat this as often as needed: - * - * $tpl->setVariable(...); - * $tpl->parseCurrentBlock(); - * - * - * To add content to block2 you would type something like: - * - * $tpl->setCurrentBlock("inner1"); - * $tpl->setVariable(...); - * $tpl->parseCurrentBlock(); - * - * $tpl->setVariable(...); - * $tpl->parseCurrentBlock(); - * - * $tpl->parse("block1"); - * - * - * This will result in one repition of block1 which contains two repitions - * of inner1. inner2 will be removed if $removeEmptyBlock is set to true - * which is the default. - * - * Usage: - * - * $tpl = new HTML_Template_IT( [string filerootdir] ); - * - * // load a template or set it with setTemplate() - * $tpl->loadTemplatefile( string filename [, boolean removeUnknownVariables, boolean removeEmptyBlocks] ) - * - * // set "global" Variables meaning variables not beeing within a (inner) block - * $tpl->setVariable( string variablename, mixed value ); - * - * // like with the Isotemplates there's a second way to use setVariable() - * $tpl->setVariable( array ( string varname => mixed value ) ); - * - * // Let's use any block, even a deeply nested one - * $tpl->setCurrentBlock( string blockname ); - * - * // repeat this as often as you need it. - * $tpl->setVariable( array ( string varname => mixed value ) ); - * $tpl->parseCurrentBlock(); - * - * // get the parsed template or print it: $tpl->show() - * $tpl->get(); - * - * - * @category HTML - * @package HTML_Template_IT - * @author Ulf Wendel - * @license BSD http://www.opensource.org/licenses/bsd-license.php - * @link http://pear.php.net/packages/HTML_Template_IT - * @access public - */ -class HTML_Template_IT -{ - /** - * Contains the error objects - * @var array - * @access public - * @see halt(), $printError, $haltOnError - */ - var $err = array(); - - /** - * Clear cache on get()? - - * @var boolean - * @acces public - */ - var $clearCache = false; - - /** - * First character of a variable placeholder ( _{_VARIABLE} ). - * @var string - * @access public - * @see $closingDelimiter, $blocknameRegExp, $variablenameRegExp - */ - var $openingDelimiter = '{'; - - /** - * Last character of a variable placeholder ( {VARIABLE_}_ ). - * @var string - * @access public - * @see $openingDelimiter, $blocknameRegExp, $variablenameRegExp - */ - var $closingDelimiter = '}'; - - /** - * RegExp matching a block in the template. - * Per default "sm" is used as the regexp modifier, "i" is missing. - * That means a case sensitive search is done. - * @var string - * @access public - * @see $variablenameRegExp, $openingDelimiter, $closingDelimiter - */ - var $blocknameRegExp = '[\.0-9A-Za-z_-]+'; - - /** - * RegExp matching a variable placeholder in the template. - * Per default "sm" is used as the regexp modifier, "i" is missing. - * That means a case sensitive search is done. - * @var string - * @access public - * @see $blocknameRegExp, $openingDelimiter, $closingDelimiter - */ - var $variablenameRegExp = '[\.0-9A-Za-z_-]+'; - - /** - * RegExp used to find variable placeholder, filled by the constructor. - * @var string Looks somewhat like @(delimiter varname delimiter)@ - * @access private - * @see IntegratedTemplate() - */ - var $variablesRegExp = ''; - - /** - * RegExp used to strip unused variable placeholder. - * @access private - * @brother $variablesRegExp - */ - var $removeVariablesRegExp = ''; - - /** - * Controls the handling of unknown variables, default is remove. - * @var boolean - * @access public - */ - var $removeUnknownVariables = true; - - /** - * Controls the handling of empty blocks, default is remove. - * @var boolean - * @access public - */ - var $removeEmptyBlocks = true; - - /** - * RegExp used to find blocks an their content, filled by the constructor. - * @var string - * @see IntegratedTemplate() - * @access private - */ - var $blockRegExp = ''; - - /** - * Name of the current block. - * @var string - * @access private - */ - var $currentBlock = '__global__'; - - /** - * Content of the template. - * @var string - * @access private - */ - var $template = ''; - - /** - * Array of all blocks and their content. - * - * @var array - * @see findBlocks() - * @access private - */ - var $blocklist = array(); - - /** - * Array with the parsed content of a block. - * - * @var array - * @access private - */ - var $blockdata = array(); - - /** - * Array of variables in a block. - * @var array - * @access private - */ - var $blockvariables = array(); - - /** - * Array of inner blocks of a block. - * @var array - * @access private - */ - var $blockinner = array(); - - /** - * List of blocks to preverse even if they are "empty". - * - * This is something special. Sometimes you have blocks that - * should be preserved although they are empty (no placeholder replaced). - * Think of a shopping basket. If it's empty you have to drop a message to - * the user. If it's filled you have to show the contents of - * the shopping baseket. Now where do you place the message that the basket - * is empty? It's no good idea to place it in you applications as customers - * tend to like unecessary minor text changes. Having another template file - * for an empty basket means that it's very likely that one fine day - * the filled and empty basket templates have different layout. I decided - * to introduce blocks that to not contain any placeholder but only - * text such as the message "Your shopping basked is empty". - * - * Now if there is no replacement done in such a block the block will - * be recognized as "empty" and by default ($removeEmptyBlocks = true) be - * stripped off. To avoid thisyou can now call touchBlock() to avoid this. - * - * The array $touchedBlocks stores a list of touched block which must not - * be removed even if they are empty. - * - * @var array $touchedBlocks - * @see touchBlock(), $removeEmptyBlocks - * @access private - */ - var $touchedBlocks = array(); - - /** - * List of blocks which should not be shown even if not "empty" - * @var array $_hiddenBlocks - * @see hideBlock(), $removeEmptyBlocks - * @access private - */ - var $_hiddenBlocks = array(); - - /** - * Variable cache. - * - * Variables get cached before any replacement is done. - * Advantage: empty blocks can be removed automatically. - * Disadvantage: might take some more memory - * - * @var array - * @see setVariable(), $clearCacheOnParse - * @access private - */ - var $variableCache = array(); - - /** - * Clear the variable cache on parse? - * - * If you're not an expert just leave the default false. - * True reduces memory consumption somewhat if you tend to - * add lots of values for unknown placeholder. - * - * @var boolean - * @access public - */ - var $clearCacheOnParse = false; - - /** - * Root directory for all file operations. - * The string gets prefixed to all filenames given. - * @var string - * @see HTML_Template_IT(), setRoot() - * @access private - */ - var $fileRoot = ''; - - /** - * Internal flag indicating that a blockname was used multiple times. - * @var boolean - * @access private - */ - var $flagBlocktrouble = false; - - /** - * Flag indicating that the global block was parsed. - * @var boolean - * @access private - */ - var $flagGlobalParsed = false; - - /** - * EXPERIMENTAL! FIXME! - * Flag indication that a template gets cached. - * - * Complex templates require some times to be preparsed - * before the replacement can take place. Often I use - * one template file over and over again but I don't know - * before that I will use the same template file again. - * Now IT could notice this and skip the preparse. - * - * @var boolean - * @access private - */ - var $flagCacheTemplatefile = true; - - /** - * EXPERIMENTAL! FIXME! - * @access private - */ - var $lastTemplatefile = ''; - - /** - * $_options['preserve_data'] Whether to substitute variables and remove - * empty placeholders in data passed through setVariable - * (see also bugs #20199, #21951). - * $_options['use_preg'] Whether to use preg_replace instead of - * str_replace in parse() - * (this is a backwards compatibility feature, see also bugs #21951, #20392) - * - * @var array - * @access private - */ - var $_options = array( - 'preserve_data' => false, - 'use_preg' => true, - 'preserve_input'=> true - ); - - /** - * Builds some complex regular expressions and optinally sets the - * file root directory. - * - * Make sure that you call this constructor if you derive your template - * class from this one. - * - * @param string $root File root directory, prefix for all filenames - * given to the object. - * @param mixed $options Unknown - * - * @see setRoot() - * @access public - */ - function HTML_Template_IT($root = '', $options = null) - { - if (!is_null($options)) { - $this->setOptions($options); - } - - $this->variablesRegExp = '@' . $this->openingDelimiter . - '(' . $this->variablenameRegExp . ')' . - $this->closingDelimiter . '@sm'; - - $this->removeVariablesRegExp = '@' . $this->openingDelimiter . - "\s*(" . $this->variablenameRegExp . - ")\s*" . $this->closingDelimiter .'@sm'; - - $this->blockRegExp = '@(.*)@sm'; - - $this->setRoot($root); - } // end constructor - - - /** - * Sets the option for the template class - * - * @param string $option option name - * @param mixed $value option value - * - * @access public - * @return mixed IT_OK on success, error object on failure - */ - function setOption($option, $value) - { - switch ($option) { - case 'removeEmptyBlocks': - $this->removeEmptyBlocks = $value; - return IT_OK; - } - - if (array_key_exists($option, $this->_options)) { - $this->_options[$option] = $value; - return IT_OK; - } - - return PEAR::raiseError( - $this->errorMessage(IT_UNKNOWN_OPTION) . ": '{$option}'", - IT_UNKNOWN_OPTION - ); - } - - /** - * Sets the options for the template class - * - * @param string[] $options options array of options - * default value: - * 'preserve_data' => false, - * 'use_preg' => true - * - * @access public - * @return mixed IT_OK on success, error object on failure - * @see $options - */ - function setOptions($options) - { - if (is_array($options)) { - foreach ($options as $option => $value) { - $error = $this->setOption($option, $value); - if (PEAR::isError($error)) { - return $error; - } - } - } - - return IT_OK; - } - - /** - * Print a certain block with all replacements done. - * - * @param string $block block - * - * @brother get() - * @access public - * @return null - */ - function show($block = '__global__') - { - print $this->get($block); - } // end func show - - /** - * Returns a block with all replacements done. - * - * @param string $block name of the block - * - * @return string - * @throws PEAR_Error - * @access public - * @see show() - */ - function get($block = '__global__') - { - if ($block == '__global__' && !$this->flagGlobalParsed) { - $this->parse('__global__'); - } - - if (!isset($this->blocklist[$block])) { - $this->err[] = PEAR::raiseError( - $this->errorMessage(IT_BLOCK_NOT_FOUND) . '"' . $block . "'", - IT_BLOCK_NOT_FOUND - ); - return ''; - } - - if (isset($this->blockdata[$block])) { - $ret = $this->blockdata[$block]; - - if ($this->clearCache) { - unset($this->blockdata[$block]); - if ($block == '__global__') { - $this->flagGlobalParsed = false; - } - } - - if ($this->_options['preserve_data']) { - $ret = str_replace( - $this->openingDelimiter . - '%preserved%' . $this->closingDelimiter, - $this->openingDelimiter, - $ret - ); - } - return $ret; - } - - return ''; - } // end func get() - - /** - * Parses the given block. - * - * @param string $block name of the block to be parsed - * @param bool $flag_recursion unknown - * - * @access public - * @see parseCurrentBlock() - * @throws PEAR_Error - * @return null - */ - function parse($block = '__global__', $flag_recursion = false) - { - static $regs, $values; - - if (!isset($this->blocklist[$block])) { - return PEAR::raiseError( - $this->errorMessage(IT_BLOCK_NOT_FOUND) . '"' . $block . "'", - IT_BLOCK_NOT_FOUND - ); - } - - if ($block == '__global__') { - $this->flagGlobalParsed = true; - } - - if (!$flag_recursion) { - $regs = array(); - $values = array(); - } - $outer = $this->blocklist[$block]; - $empty = true; - - $variablelist = array(); - if ($this->clearCacheOnParse) { - foreach ($this->variableCache as $name => $value) { - $regs[] = $this->openingDelimiter . - $name . $this->closingDelimiter; - - $values[] = $value; - - $empty = false; - - $variablelist[] = $name; - } - $this->variableCache = array(); - } else { - foreach ($this->blockvariables[$block] as $allowedvar => $v) { - - if (isset($this->variableCache[$allowedvar])) { - $regs[] = $this->openingDelimiter . - $allowedvar . $this->closingDelimiter; - $values[] = $this->variableCache[$allowedvar]; - - unset($this->variableCache[$allowedvar]); - - $empty = false; - - $variablelist[] = $allowedvar; - } - } - } - - if (isset($this->blockinner[$block])) { - foreach ($this->blockinner[$block] as $k => $innerblock) { - - $this->parse($innerblock, true); - if ($this->blockdata[$innerblock] != '') { - $empty = false; - } - - $placeholder = $this->openingDelimiter . "__" . - $innerblock . "__" . $this->closingDelimiter; - - $outer = str_replace( - $placeholder, - $this->blockdata[$innerblock], $outer - ); - - $this->blockdata[$innerblock] = ""; - } - - } - - if (!$flag_recursion && 0 != count($values)) { - if ($this->_options['use_preg']) { - $regs = array_map(array(&$this, '_addPregDelimiters'), $regs); - $values = array_map(array(&$this, '_escapeBackreferences'), $values); - - $funcReplace = 'preg_replace'; - } else { - $funcReplace = 'str_replace'; - } - - if ($this->_options['preserve_data']) { - $values = array_map( - array(&$this, '_preserveOpeningDelimiter'), - $values - ); - } - - $outer = $funcReplace($regs, $values, $outer); - } - - if ($this->removeUnknownVariables) { - $outer = $this->removeUnknownVariablesFromBlock( - $block, - $outer, - $variablelist - ); - } - - if ($empty) { - if (!$this->removeEmptyBlocks) { - $this->blockdata[$block ] .= $outer; - } else { - if (isset($this->touchedBlocks[$block])) { - $this->blockdata[$block] .= $outer; - unset($this->touchedBlocks[$block]); - } - } - } else { - if (empty($this->blockdata[$block])) { - $this->blockdata[$block] = $outer; - } else { - $this->blockdata[$block] .= $outer; - } - } - - return $empty; - } // end func parse - - /** - * Removes unknown variables from block. If preserve_input is set to true - * only unknown variables that were present during setTemplate or - * loadTemplatefile are removed. Thus you can set a variable to - * "{SOMEINPUTDATA}" which is preserved. - * - * @param string $blockname block - * @param string $blockinner unknown - * @param string $variableList unknown - * - * @see parse() - * @access private - * @return null - */ - function removeUnknownVariablesFromBlock ($blockname, $blockinner, $variableList) - { - if ($this->_options['preserve_input']) { - foreach ($this->blockvariables[$blockname] as $var => $setted) { - if (!in_array($var, $variableList)) { - $blockinner = str_replace( - $this->openingDelimiter . $var . $this->closingDelimiter, - '', - $blockinner - ); - } - } - } else { - $blockinner = preg_replace( - $this->removeVariablesRegExp, - '', - $blockinner - ); - } - - return $blockinner; - } - - /** - * Parses the current block - * - * @see parse(), setCurrentBlock(), $currentBlock - * @access public - * @return null - */ - function parseCurrentBlock() - { - return $this->parse($this->currentBlock); - } // end func parseCurrentBlock - - /** - * Checks to see if a placeholder exists within a block (and its children) - * - * @access public - * @return bool - */ - function checkPlaceholderExists($blockname, $placeholder) { - if (isset($this->blockvariables[$blockname][$placeholder])) { - return true; - } - if (isset($this->blockinner[$blockname])) { - foreach ($this->blockinner[$blockname] as $block) { - if ($this->checkPlaceholderExists($block, $placeholder)) { - return true; - } - } - } - return false; - } // end func checkPlaceholderExists - - /** - * Sets a variable value. - * - * The function can be used eighter like setVariable( "varname", "value") - * or with one array $variables["varname"] = "value" - * given setVariable($variables) quite like phplib templates set_var(). - * - * @param mixed $variable string with the variable name or an array - * %variables["varname"] = "value" - * @param string $value value of the variable or empty if $variable - * is an array. - * - * @access public - * @return null - */ - function setVariable($variable, $value = '') - { - if (is_array($variable)) { - foreach ($variable as $key => $value) { - $this->setVariable($key, $value); - } - } else { - if ($this->checkPlaceholderExists($this->currentBlock, $variable)) { - $this->variableCache[$variable] = $value; - } - } - } // end func setVariable - - /** - * Sets the name of the current block that is the block where variables - * are added. - * - * @param string $block name of the block - * - * @return boolean false on failure, otherwise true - * @throws PEAR_Error - * @access public - */ - function setCurrentBlock($block = '__global__') - { - - if (!isset($this->blocklist[$block])) { - return PEAR::raiseError( - $this->errorMessage(IT_BLOCK_NOT_FOUND) - . '"' . $block . "'", - IT_BLOCK_NOT_FOUND - ); - } - - $this->currentBlock = $block; - - return true; - } // end func setCurrentBlock - - /** - * Preserves an empty block even if removeEmptyBlocks is true. - * - * @param string $block name of the block - * - * @return boolean false on false, otherwise true - * @throws PEAR_Error - * @access public - * @see $removeEmptyBlocks - */ - function touchBlock($block) - { - if (!isset($this->blocklist[$block])) { - return PEAR::raiseError( - $this->errorMessage(IT_BLOCK_NOT_FOUND) . '"' . $block . "'", - IT_BLOCK_NOT_FOUND - ); - } - - $this->touchedBlocks[$block] = true; - - return true; - } // end func touchBlock - - /** - * Clears all datafields of the object and rebuild the internal blocklist - * - * LoadTemplatefile() and setTemplate() automatically call this function - * when a new template is given. Don't use this function - * unless you know what you're doing. - * - * @access private - * @see free() - * @return null - */ - function init() - { - $this->free(); - $this->findBlocks($this->template); - // we don't need it any more - $this->template = ''; - $this->buildBlockvariablelist(); - } // end func init - - /** - * Clears all datafields of the object. - * - * Don't use this function unless you know what you're doing. - * - * @access private - * @see init() - * @return null - */ - function free() - { - $this->err = array(); - - $this->currentBlock = '__global__'; - - $this->variableCache = array(); - $this->blocklist = array(); - $this->touchedBlocks = array(); - - $this->flagBlocktrouble = false; - $this->flagGlobalParsed = false; - } // end func free - - /** - * Sets the template. - * - * You can eighter load a template file from disk with - * LoadTemplatefile() or set the template manually using this function. - * - * @param string $template template content - * @param bool $removeUnknownVariables how to handle unknown variables. - * @param bool $removeEmptyBlocks how to handle empty blocks. - * - * @see LoadTemplatefile(), $template - * @access public - * @return boolean - */ - function setTemplate( $template, - $removeUnknownVariables = true, - $removeEmptyBlocks = true) { - $this->removeUnknownVariables = $removeUnknownVariables; - - $this->removeEmptyBlocks = $removeEmptyBlocks; - - if ($template == '' && $this->flagCacheTemplatefile) { - $this->variableCache = array(); - $this->blockdata = array(); - $this->touchedBlocks = array(); - $this->currentBlock = '__global__'; - } else { - $this->template = '' . $template . - ''; - $this->init(); - } - - if ($this->flagBlocktrouble) { - return false; - } - - return true; - } // end func setTemplate - - /** - * Reads a template file from the disk. - * - * @param string $filename name of the template file - * @param bool $removeUnknownVariables how to handle unknown variables. - * @param bool $removeEmptyBlocks how to handle empty blocks. - * - * @access public - * @return boolean false on failure, otherwise true - * @see $template, setTemplate(), $removeUnknownVariables, - * $removeEmptyBlocks - */ - function loadTemplatefile( $filename, - $removeUnknownVariables = true, - $removeEmptyBlocks = true ) {; - $template = ''; - if (!$this->flagCacheTemplatefile - || $this->lastTemplatefile != $filename - ) { - $template = $this->getFile($filename); - } - $this->lastTemplatefile = $filename; - - return $template != '' ? - $this->setTemplate( - $template, - $removeUnknownVariables, - $removeEmptyBlocks) : false; - } // end func LoadTemplatefile - - /** - * Sets the file root. The file root gets prefixed to all filenames passed - * to the object. - * - * Make sure that you override this function when using the class - * on windows. - * - * @param string $root File root - * - * @see HTML_Template_IT() - * @access public - * @return null - */ - function setRoot($root) - { - if ($root != '' && substr($root, -1) != '/') { - $root .= '/'; - } - - $this->fileRoot = $root; - } // end func setRoot - - /** - * Build a list of all variables within of a block - * - * @access private - * @return null - */ - function buildBlockvariablelist() - { - foreach ($this->blocklist as $name => $content) { - preg_match_all($this->variablesRegExp, $content, $regs); - - if (count($regs[1]) != 0) { - foreach ($regs[1] as $k => $var) { - $this->blockvariables[$name][$var] = true; - } - } else { - $this->blockvariables[$name] = array(); - } - } - } // end func buildBlockvariablelist - - /** - * Returns a list of all global variables - * - * @access public - * @return array - */ - function getGlobalvariables() - { - $regs = array(); - $values = array(); - - foreach ($this->blockvariables['__global__'] as $allowedvar => $v) { - if (isset($this->variableCache[$allowedvar])) { - $regs[] = '@' . $this->openingDelimiter . - $allowedvar . $this->closingDelimiter . '@'; - $values[] = $this->variableCache[$allowedvar]; - unset($this->variableCache[$allowedvar]); - } - } - - return array($regs, $values); - } // end func getGlobalvariables - - /** - * Recusively builds a list of all blocks within the template. - * - * @param string $string string that gets scanned - * - * @access private - * @see $blocklist - * @return array - */ - function findBlocks($string) - { - $blocklist = array(); - - if (preg_match_all($this->blockRegExp, $string, $regs, PREG_SET_ORDER)) { - foreach ($regs as $k => $match) { - $blockname = $match[1]; - $blockcontent = $match[2]; - - if (isset($this->blocklist[$blockname])) { - $msg = $this->errorMessage(IT_BLOCK_DUPLICATE, $blockname); - - $this->err[] = PEAR::raiseError($msg, IT_BLOCK_DUPLICATE); - - $this->flagBlocktrouble = true; - } - - $this->blocklist[$blockname] = $blockcontent; - $this->blockdata[$blockname] = ""; - - $blocklist[] = $blockname; - - $inner = $this->findBlocks($blockcontent); - $regex = '@(.*)@sm'; - foreach ($inner as $k => $name) { - $pattern = sprintf($regex, preg_quote($name), preg_quote($name)); - - $this->blocklist[$blockname] = preg_replace( - $pattern, - $this->openingDelimiter . - '__' . $name . '__' . - $this->closingDelimiter, - $this->blocklist[$blockname] - ); - - $this->blockinner[$blockname][] = $name; - - $this->blockparents[$name] = $blockname; - } - } - } - - return $blocklist; - } // end func findBlocks - - /** - * Reads a file from disk and returns its content. - * - * @param string $filename Filename - * - * @return string Filecontent - * @access private - */ - function getFile($filename) - { - if ($filename{0} == '/' && substr($this->fileRoot, -1) == '/') { - $filename = substr($filename, 1); - } - - $filename = $this->fileRoot . $filename; - - if (!($fh = @fopen($filename, 'r'))) { - $this->err[] = PEAR::raiseError( - $this->errorMessage(IT_TPL_NOT_FOUND) . ': "' .$filename .'"', - IT_TPL_NOT_FOUND - ); - return ""; - } - - $fsize = filesize($filename); - if ($fsize < 1) { - fclose($fh); - return ''; - } - - $content = fread($fh, $fsize); - fclose($fh); - - return preg_replace( - "##ime", - "\$this->getFile('\\1')", - $content - ); - } // end func getFile - - /** - * Adds delimiters to a string, so it can be used as a pattern - * in preg_* functions - * - * @param string $str input - * - * @return string - * @access private - */ - function _addPregDelimiters($str) - { - return '@' . preg_quote($str) . '@'; - } - - /** - * Escapes $ and \ as preg_replace will treat - * them as a backreference and not literal. - * See bug #9501 - * - * @param string $str String to escape - * - * @since 1.2.2 - * @return string - * @access private - */ - function _escapeBackreferences($str) - { - $str = str_replace('\\', '\\\\', $str); - $str = preg_replace('@\$([0-9]{1,2})@', '\\\$${1}', $str); - return $str; - } - - /** - * Replaces an opening delimiter by a special string - * - * @param string $str special string - * - * @return string - * @access private - */ - function _preserveOpeningDelimiter($str) - { - return (false === strpos($str, $this->openingDelimiter))? - $str: - str_replace( - $this->openingDelimiter, - $this->openingDelimiter . - '%preserved%' . $this->closingDelimiter, - $str - ); - } - - /** - * Return a textual error message for a IT error code - * - * @param integer $value error code - * @param string $blockname unknown - * - * @access private - * @return string error message, or false if the error code was - * not recognized - */ - function errorMessage($value, $blockname = '') - { - static $errorMessages; - if (!isset($errorMessages)) { - $errorMessages = array( - IT_OK => '', - IT_ERROR => 'unknown error', - IT_TPL_NOT_FOUND => 'Cannot read the template file', - IT_BLOCK_NOT_FOUND => 'Cannot find this block', - IT_BLOCK_DUPLICATE => 'The name of a block must be'. - ' uniquewithin a template.'. - ' Found "' . $blockname . '" twice.'. - 'Unpredictable results '. - 'may appear.', - IT_UNKNOWN_OPTION => 'Unknown option' - ); - } - - if (PEAR::isError($value)) { - $value = $value->getCode(); - } - - return isset($errorMessages[$value]) ? - $errorMessages[$value] : $errorMessages[IT_ERROR]; - } -} // end class IntegratedTemplate -?> + + * Pierre-Alain Joye + * David Soria Parra + * + * @category HTML + * @package HTML_Template_IT + * @author Ulf Wendel + * @license BSD http://www.opensource.org/licenses/bsd-license.php + * @version CVS: $Id: IT.php 3 2017-06-22 07:32:17Z martin $ + * @link http://pear.php.net/packages/HTML_Template_IT + * @access public + */ + +require_once 'PEAR.php'; +$myPEAR = new PEAR(); + +define('IT_OK', 1); +define('IT_ERROR', -1); +define('IT_TPL_NOT_FOUND', -2); +define('IT_BLOCK_NOT_FOUND', -3); +define('IT_BLOCK_DUPLICATE', -4); +define('IT_UNKNOWN_OPTION', -6); + +/** + * Integrated Template - IT + * + * Well there's not much to say about it. I needed a template class that + * supports a single template file with multiple (nested) blocks inside and + * a simple block API. + * + * The Isotemplate API is somewhat tricky for a beginner although it is the best + * one you can build. template::parse() [phplib template = Isotemplate] requests + * you to name a source and a target where the current block gets parsed into. + * Source and target can be block names or even handler names. This API gives you + * a maximum of fexibility but you always have to know what you do which is + * quite unusual for php skripter like me. + * + * I noticed that I do not any control on which block gets parsed into which one. + * If all blocks are within one file, the script knows how they are nested and in + * which way you have to parse them. IT knows that inner1 is a child of block2, + * there's no need to tell him about this. + * + * + * + * + * + * + * + * + * + *
    + * __global__ + *

    + * (hidden and automatically added) + *

    block1 + * + * + * + * + * + * + * + * + *
    block2
    inner1inner2
    + *
    + * + * To add content to block1 you simply type: + * $tpl->setCurrentBlock("block1"); + * and repeat this as often as needed: + * + * $tpl->setVariable(...); + * $tpl->parseCurrentBlock(); + * + * + * To add content to block2 you would type something like: + * + * $tpl->setCurrentBlock("inner1"); + * $tpl->setVariable(...); + * $tpl->parseCurrentBlock(); + * + * $tpl->setVariable(...); + * $tpl->parseCurrentBlock(); + * + * $tpl->parse("block1"); + * + * + * This will result in one repition of block1 which contains two repitions + * of inner1. inner2 will be removed if $removeEmptyBlock is set to true + * which is the default. + * + * Usage: + * + * $tpl = new HTML_Template_IT( [string filerootdir] ); + * + * // load a template or set it with setTemplate() + * $tpl->loadTemplatefile( string filename [, boolean removeUnknownVariables, boolean removeEmptyBlocks] ) + * + * // set "global" Variables meaning variables not beeing within a (inner) block + * $tpl->setVariable( string variablename, mixed value ); + * + * // like with the Isotemplates there's a second way to use setVariable() + * $tpl->setVariable( array ( string varname => mixed value ) ); + * + * // Let's use any block, even a deeply nested one + * $tpl->setCurrentBlock( string blockname ); + * + * // repeat this as often as you need it. + * $tpl->setVariable( array ( string varname => mixed value ) ); + * $tpl->parseCurrentBlock(); + * + * // get the parsed template or print it: $tpl->show() + * $tpl->get(); + * + * + * @category HTML + * @package HTML_Template_IT + * @author Ulf Wendel + * @license BSD http://www.opensource.org/licenses/bsd-license.php + * @link http://pear.php.net/packages/HTML_Template_IT + * @access public + */ +class HTML_Template_IT +{ + /** + * Contains the error objects + * @var array + * @access public + * @see halt(), $printError, $haltOnError + */ + var $err = array(); + + /** + * Clear cache on get()? + + * @var boolean + * @acces public + */ + var $clearCache = false; + + /** + * First character of a variable placeholder ( _{_VARIABLE} ). + * @var string + * @access public + * @see $closingDelimiter, $blocknameRegExp, $variablenameRegExp + */ + var $openingDelimiter = '{'; + + /** + * Last character of a variable placeholder ( {VARIABLE_}_ ). + * @var string + * @access public + * @see $openingDelimiter, $blocknameRegExp, $variablenameRegExp + */ + var $closingDelimiter = '}'; + + /** + * RegExp matching a block in the template. + * Per default "sm" is used as the regexp modifier, "i" is missing. + * That means a case sensitive search is done. + * @var string + * @access public + * @see $variablenameRegExp, $openingDelimiter, $closingDelimiter + */ + var $blocknameRegExp = '[\.0-9A-Za-z_-]+'; + + /** + * RegExp matching a variable placeholder in the template. + * Per default "sm" is used as the regexp modifier, "i" is missing. + * That means a case sensitive search is done. + * @var string + * @access public + * @see $blocknameRegExp, $openingDelimiter, $closingDelimiter + */ + var $variablenameRegExp = '[\.0-9A-Za-z_-]+'; + + /** + * RegExp used to find variable placeholder, filled by the constructor. + * @var string Looks somewhat like @(delimiter varname delimiter)@ + * @access private + * @see IntegratedTemplate() + */ + var $variablesRegExp = ''; + + /** + * RegExp used to strip unused variable placeholder. + * @access private + * @brother $variablesRegExp + */ + var $removeVariablesRegExp = ''; + + /** + * Controls the handling of unknown variables, default is remove. + * @var boolean + * @access public + */ + var $removeUnknownVariables = true; + + /** + * Controls the handling of empty blocks, default is remove. + * @var boolean + * @access public + */ + var $removeEmptyBlocks = true; + + /** + * RegExp used to find blocks an their content, filled by the constructor. + * @var string + * @see IntegratedTemplate() + * @access private + */ + var $blockRegExp = ''; + + /** + * Name of the current block. + * @var string + * @access private + */ + var $currentBlock = '__global__'; + + /** + * Content of the template. + * @var string + * @access private + */ + var $template = ''; + + /** + * Array of all blocks and their content. + * + * @var array + * @see findBlocks() + * @access private + */ + var $blocklist = array(); + + /** + * Array with the parsed content of a block. + * + * @var array + * @access private + */ + var $blockdata = array(); + + /** + * Array of variables in a block. + * @var array + * @access private + */ + var $blockvariables = array(); + + /** + * Array of inner blocks of a block. + * @var array + * @access private + */ + var $blockinner = array(); + + /** + * List of blocks to preverse even if they are "empty". + * + * This is something special. Sometimes you have blocks that + * should be preserved although they are empty (no placeholder replaced). + * Think of a shopping basket. If it's empty you have to drop a message to + * the user. If it's filled you have to show the contents of + * the shopping baseket. Now where do you place the message that the basket + * is empty? It's no good idea to place it in you applications as customers + * tend to like unecessary minor text changes. Having another template file + * for an empty basket means that it's very likely that one fine day + * the filled and empty basket templates have different layout. I decided + * to introduce blocks that to not contain any placeholder but only + * text such as the message "Your shopping basked is empty". + * + * Now if there is no replacement done in such a block the block will + * be recognized as "empty" and by default ($removeEmptyBlocks = true) be + * stripped off. To avoid thisyou can now call touchBlock() to avoid this. + * + * The array $touchedBlocks stores a list of touched block which must not + * be removed even if they are empty. + * + * @var array $touchedBlocks + * @see touchBlock(), $removeEmptyBlocks + * @access private + */ + var $touchedBlocks = array(); + + /** + * List of blocks which should not be shown even if not "empty" + * @var array $_hiddenBlocks + * @see hideBlock(), $removeEmptyBlocks + * @access private + */ + var $_hiddenBlocks = array(); + + /** + * Variable cache. + * + * Variables get cached before any replacement is done. + * Advantage: empty blocks can be removed automatically. + * Disadvantage: might take some more memory + * + * @var array + * @see setVariable(), $clearCacheOnParse + * @access private + */ + var $variableCache = array(); + + /** + * Clear the variable cache on parse? + * + * If you're not an expert just leave the default false. + * True reduces memory consumption somewhat if you tend to + * add lots of values for unknown placeholder. + * + * @var boolean + * @access public + */ + var $clearCacheOnParse = false; + + /** + * Root directory for all file operations. + * The string gets prefixed to all filenames given. + * @var string + * @see HTML_Template_IT(), setRoot() + * @access private + */ + var $fileRoot = ''; + + /** + * Internal flag indicating that a blockname was used multiple times. + * @var boolean + * @access private + */ + var $flagBlocktrouble = false; + + /** + * Flag indicating that the global block was parsed. + * @var boolean + * @access private + */ + var $flagGlobalParsed = false; + + /** + * EXPERIMENTAL! FIXME! + * Flag indication that a template gets cached. + * + * Complex templates require some times to be preparsed + * before the replacement can take place. Often I use + * one template file over and over again but I don't know + * before that I will use the same template file again. + * Now IT could notice this and skip the preparse. + * + * @var boolean + * @access private + */ + var $flagCacheTemplatefile = true; + + /** + * EXPERIMENTAL! FIXME! + * @access private + */ + var $lastTemplatefile = ''; + + /** + * $_options['preserve_data'] Whether to substitute variables and remove + * empty placeholders in data passed through setVariable + * (see also bugs #20199, #21951). + * $_options['use_preg'] Whether to use preg_replace instead of + * str_replace in parse() + * (this is a backwards compatibility feature, see also bugs #21951, #20392) + * + * @var array + * @access private + */ + var $_options = array( + 'preserve_data' => false, + 'use_preg' => true, + 'preserve_input'=> true + ); + + /** + * Builds some complex regular expressions and optinally sets the + * file root directory. + * + * Make sure that you call this constructor if you derive your template + * class from this one. + * + * @param string $root File root directory, prefix for all filenames + * given to the object. + * @param mixed $options Unknown + * + * @see setRoot() + * @access public + */ + function __construct($root = '', $options = null) + { + if (!is_null($options)) { + $this->setOptions($options); + } + + $this->variablesRegExp = '@' . $this->openingDelimiter . + '(' . $this->variablenameRegExp . ')' . + $this->closingDelimiter . '@sm'; + + $this->removeVariablesRegExp = '@' . $this->openingDelimiter . + "\s*(" . $this->variablenameRegExp . + ")\s*" . $this->closingDelimiter .'@sm'; + + $this->blockRegExp = '@(.*)@sm'; + + $this->setRoot($root); + } // end constructor + + + /** + * Sets the option for the template class + * + * @param string $option option name + * @param mixed $value option value + * + * @access public + * @return mixed IT_OK on success, error object on failure + */ + function setOption($option, $value) + { + global $myPEAR; + switch ($option) { + case 'removeEmptyBlocks': + $this->removeEmptyBlocks = $value; + return IT_OK; + } + + if (array_key_exists($option, $this->_options)) { + $this->_options[$option] = $value; + return IT_OK; + } + + return $myPEAR->raiseError( + $this->errorMessage(IT_UNKNOWN_OPTION) . ": '{$option}'", + IT_UNKNOWN_OPTION + ); + } + + /** + * Sets the options for the template class + * + * @param string[] $options options array of options + * default value: + * 'preserve_data' => false, + * 'use_preg' => true + * + * @access public + * @return mixed IT_OK on success, error object on failure + * @see $options + */ + function setOptions($options) + { + global $myPEAR; + if (is_array($options)) { + foreach ($options as $option => $value) { + $error = $this->setOption($option, $value); + if ($myPEAR->isError($error)) { + + return $error; + } + } + } + + return IT_OK; + } + + /** + * Print a certain block with all replacements done. + * + * @param string $block block + * + * @brother get() + * @access public + * @return null + */ + function show($block = '__global__') + { + print $this->get($block); + } // end func show + + /** + * Returns a block with all replacements done. + * + * @param string $block name of the block + * + * @return string + * @throws PEAR_Error + * @access public + * @see show() + */ + function get($block = '__global__') + { + global $myPEAR; + if ($block == '__global__' && !$this->flagGlobalParsed) { + $this->parse('__global__'); + } + + if (!isset($this->blocklist[$block])) { + $this->err[] = $myPEAR->raiseError( + $this->errorMessage(IT_BLOCK_NOT_FOUND) . '"' . $block . "'", + IT_BLOCK_NOT_FOUND + ); + return ''; + } + + if (isset($this->blockdata[$block])) { + $ret = $this->blockdata[$block]; + + if ($this->clearCache) { + unset($this->blockdata[$block]); + if ($block == '__global__') { + $this->flagGlobalParsed = false; + } + } + + if ($this->_options['preserve_data']) { + $ret = str_replace( + $this->openingDelimiter . + '%preserved%' . $this->closingDelimiter, + $this->openingDelimiter, + $ret + ); + } + return $ret; + } + + return ''; + } // end func get() + + /** + * Parses the given block. + * + * @param string $block name of the block to be parsed + * @param bool $flag_recursion unknown + * + * @access public + * @see parseCurrentBlock() + * @throws PEAR_Error + * @return null + */ + function parse($block = '__global__', $flag_recursion = false) + { + global $myPEAR; + static $regs, $values; + + if (!isset($this->blocklist[$block])) { + return $myPEAR->raiseError( + $this->errorMessage(IT_BLOCK_NOT_FOUND) . '"' . $block . "'", + IT_BLOCK_NOT_FOUND + ); + } + + if ($block == '__global__') { + $this->flagGlobalParsed = true; + } + + if (!$flag_recursion) { + $regs = array(); + $values = array(); + } + $outer = $this->blocklist[$block]; + $empty = true; + + $variablelist = array(); + if ($this->clearCacheOnParse) { + foreach ($this->variableCache as $name => $value) { + $regs[] = $this->openingDelimiter . + $name . $this->closingDelimiter; + + $values[] = $value; + + $empty = false; + + $variablelist[] = $name; + } + $this->variableCache = array(); + } else { + foreach ($this->blockvariables[$block] as $allowedvar => $v) { + + if (isset($this->variableCache[$allowedvar])) { + $regs[] = $this->openingDelimiter . + $allowedvar . $this->closingDelimiter; + $values[] = $this->variableCache[$allowedvar]; + + unset($this->variableCache[$allowedvar]); + + $empty = false; + + $variablelist[] = $allowedvar; + } + } + } + + if (isset($this->blockinner[$block])) { + foreach ($this->blockinner[$block] as $k => $innerblock) { + + $this->parse($innerblock, true); + if ($this->blockdata[$innerblock] != '') { + $empty = false; + } + + $placeholder = $this->openingDelimiter . "__" . + $innerblock . "__" . $this->closingDelimiter; + + $outer = str_replace( + $placeholder, + $this->blockdata[$innerblock], $outer + ); + + $this->blockdata[$innerblock] = ""; + } + + } + + if (!$flag_recursion && 0 != count($values)) { + if ($this->_options['use_preg']) { + $regs = array_map(array(&$this, '_addPregDelimiters'), $regs); + $values = array_map(array(&$this, '_escapeBackreferences'), $values); + + $funcReplace = 'preg_replace'; + } else { + $funcReplace = 'str_replace'; + } + + if ($this->_options['preserve_data']) { + $values = array_map( + array(&$this, '_preserveOpeningDelimiter'), + $values + ); + } + + $outer = $funcReplace($regs, $values, $outer); + } + + if ($this->removeUnknownVariables) { + $outer = $this->removeUnknownVariablesFromBlock( + $block, + $outer, + $variablelist + ); + } + + if ($empty) { + if (!$this->removeEmptyBlocks) { + $this->blockdata[$block ] .= $outer; + } else { + if (isset($this->touchedBlocks[$block])) { + $this->blockdata[$block] .= $outer; + unset($this->touchedBlocks[$block]); + } + } + } else { + if (empty($this->blockdata[$block])) { + $this->blockdata[$block] = $outer; + } else { + $this->blockdata[$block] .= $outer; + } + } + + return $empty; + } // end func parse + + /** + * Removes unknown variables from block. If preserve_input is set to true + * only unknown variables that were present during setTemplate or + * loadTemplatefile are removed. Thus you can set a variable to + * "{SOMEINPUTDATA}" which is preserved. + * + * @param string $blockname block + * @param string $blockinner unknown + * @param string $variableList unknown + * + * @see parse() + * @access private + * @return null + */ + function removeUnknownVariablesFromBlock ($blockname, $blockinner, $variableList) + { + if ($this->_options['preserve_input']) { + foreach ($this->blockvariables[$blockname] as $var => $setted) { + if (!in_array($var, $variableList)) { + $blockinner = str_replace( + $this->openingDelimiter . $var . $this->closingDelimiter, + '', + $blockinner + ); + } + } + } else { + $blockinner = preg_replace( + $this->removeVariablesRegExp, + '', + $blockinner + ); + } + + return $blockinner; + } + + /** + * Parses the current block + * + * @see parse(), setCurrentBlock(), $currentBlock + * @access public + * @return null + */ + function parseCurrentBlock() + { + return $this->parse($this->currentBlock); + } // end func parseCurrentBlock + + /** + * Checks to see if a placeholder exists within a block (and its children) + * + * @access public + * @return bool + */ + function checkPlaceholderExists($blockname, $placeholder) { + if (isset($this->blockvariables[$blockname][$placeholder])) { + return true; + } + if (isset($this->blockinner[$blockname])) { + foreach ($this->blockinner[$blockname] as $block) { + if ($this->checkPlaceholderExists($block, $placeholder)) { + return true; + } + } + } + return false; + } // end func checkPlaceholderExists + + /** + * Sets a variable value. + * + * The function can be used eighter like setVariable( "varname", "value") + * or with one array $variables["varname"] = "value" + * given setVariable($variables) quite like phplib templates set_var(). + * + * @param mixed $variable string with the variable name or an array + * %variables["varname"] = "value" + * @param string $value value of the variable or empty if $variable + * is an array. + * + * @access public + * @return null + */ + function setVariable($variable, $value = '') + { + if (is_array($variable)) { + foreach ($variable as $key => $value) { + $this->setVariable($key, $value); + } + } else { + if ($this->checkPlaceholderExists($this->currentBlock, $variable)) { + $this->variableCache[$variable] = $value; + } + } + } // end func setVariable + + /** + * Sets the name of the current block that is the block where variables + * are added. + * + * @param string $block name of the block + * + * @return boolean false on failure, otherwise true + * @throws PEAR_Error + * @access public + */ + function setCurrentBlock($block = '__global__') + { + global $myPEAR; + if (!isset($this->blocklist[$block])) { + return $myPEAR->raiseError( + $this->errorMessage(IT_BLOCK_NOT_FOUND) + . '"' . $block . "'", + IT_BLOCK_NOT_FOUND + ); + } + + $this->currentBlock = $block; + + return true; + } // end func setCurrentBlock + + /** + * Preserves an empty block even if removeEmptyBlocks is true. + * + * @param string $block name of the block + * + * @return boolean false on false, otherwise true + * @throws PEAR_Error + * @access public + * @see $removeEmptyBlocks + */ + function touchBlock($block) + { + global $myPEAR; + if (!isset($this->blocklist[$block])) { + return $myPEAR->raiseError( + $this->errorMessage(IT_BLOCK_NOT_FOUND) . '"' . $block . "'", + IT_BLOCK_NOT_FOUND + ); + } + + $this->touchedBlocks[$block] = true; + + return true; + } // end func touchBlock + + /** + * Clears all datafields of the object and rebuild the internal blocklist + * + * LoadTemplatefile() and setTemplate() automatically call this function + * when a new template is given. Don't use this function + * unless you know what you're doing. + * + * @access private + * @see free() + * @return null + */ + function init() + { + $this->free(); + $this->findBlocks($this->template); + // we don't need it any more + $this->template = ''; + $this->buildBlockvariablelist(); + } // end func init + + /** + * Clears all datafields of the object. + * + * Don't use this function unless you know what you're doing. + * + * @access private + * @see init() + * @return null + */ + function free() + { + $this->err = array(); + + $this->currentBlock = '__global__'; + + $this->variableCache = array(); + $this->blocklist = array(); + $this->touchedBlocks = array(); + + $this->flagBlocktrouble = false; + $this->flagGlobalParsed = false; + } // end func free + + /** + * Sets the template. + * + * You can eighter load a template file from disk with + * LoadTemplatefile() or set the template manually using this function. + * + * @param string $template template content + * @param bool $removeUnknownVariables how to handle unknown variables. + * @param bool $removeEmptyBlocks how to handle empty blocks. + * + * @see LoadTemplatefile(), $template + * @access public + * @return boolean + */ + function setTemplate( $template, + $removeUnknownVariables = true, + $removeEmptyBlocks = true) { + $this->removeUnknownVariables = $removeUnknownVariables; + + $this->removeEmptyBlocks = $removeEmptyBlocks; + + if ($template == '' && $this->flagCacheTemplatefile) { + $this->variableCache = array(); + $this->blockdata = array(); + $this->touchedBlocks = array(); + $this->currentBlock = '__global__'; + } else { + $this->template = '' . $template . + ''; + $this->init(); + } + + if ($this->flagBlocktrouble) { + return false; + } + + return true; + } // end func setTemplate + + /** + * Reads a template file from the disk. + * + * @param string $filename name of the template file + * @param bool $removeUnknownVariables how to handle unknown variables. + * @param bool $removeEmptyBlocks how to handle empty blocks. + * + * @access public + * @return boolean false on failure, otherwise true + * @see $template, setTemplate(), $removeUnknownVariables, + * $removeEmptyBlocks + */ + function loadTemplatefile( $filename, + $removeUnknownVariables = true, + $removeEmptyBlocks = true ) {; + $template = ''; + if (!$this->flagCacheTemplatefile + || $this->lastTemplatefile != $filename + ) { + $template = $this->getFile($filename); + } + $this->lastTemplatefile = $filename; + + return $template != '' ? + $this->setTemplate( + $template, + $removeUnknownVariables, + $removeEmptyBlocks) : false; + } // end func LoadTemplatefile + + /** + * Sets the file root. The file root gets prefixed to all filenames passed + * to the object. + * + * Make sure that you override this function when using the class + * on windows. + * + * @param string $root File root + * + * @see HTML_Template_IT() + * @access public + * @return null + */ + function setRoot($root) + { + if ($root != '' && substr($root, -1) != '/') { + $root .= '/'; + } + + $this->fileRoot = $root; + } // end func setRoot + + /** + * Build a list of all variables within of a block + * + * @access private + * @return null + */ + function buildBlockvariablelist() + { + foreach ($this->blocklist as $name => $content) { + preg_match_all($this->variablesRegExp, $content, $regs); + + if (count($regs[1]) != 0) { + foreach ($regs[1] as $k => $var) { + $this->blockvariables[$name][$var] = true; + } + } else { + $this->blockvariables[$name] = array(); + } + } + } // end func buildBlockvariablelist + + /** + * Returns a list of all global variables + * + * @access public + * @return array + */ + function getGlobalvariables() + { + $regs = array(); + $values = array(); + + foreach ($this->blockvariables['__global__'] as $allowedvar => $v) { + if (isset($this->variableCache[$allowedvar])) { + $regs[] = '@' . $this->openingDelimiter . + $allowedvar . $this->closingDelimiter . '@'; + $values[] = $this->variableCache[$allowedvar]; + unset($this->variableCache[$allowedvar]); + } + } + + return array($regs, $values); + } // end func getGlobalvariables + + /** + * Recusively builds a list of all blocks within the template. + * + * @param string $string string that gets scanned + * + * @access private + * @see $blocklist + * @return array + */ + function findBlocks($string) + { + global $myPEAR; + $blocklist = array(); + + if (preg_match_all($this->blockRegExp, $string, $regs, PREG_SET_ORDER)) { + foreach ($regs as $k => $match) { + $blockname = $match[1]; + $blockcontent = $match[2]; + + if (isset($this->blocklist[$blockname])) { + $msg = $this->errorMessage(IT_BLOCK_DUPLICATE, $blockname); + + $this->err[] = $myPEAR->raiseError($msg, IT_BLOCK_DUPLICATE); + + $this->flagBlocktrouble = true; + } + + $this->blocklist[$blockname] = $blockcontent; + $this->blockdata[$blockname] = ""; + + $blocklist[] = $blockname; + + $inner = $this->findBlocks($blockcontent); + $regex = '@(.*)@sm'; + foreach ($inner as $k => $name) { + $pattern = sprintf($regex, preg_quote($name), preg_quote($name)); + + $this->blocklist[$blockname] = preg_replace( + $pattern, + $this->openingDelimiter . + '__' . $name . '__' . + $this->closingDelimiter, + $this->blocklist[$blockname] + ); + + $this->blockinner[$blockname][] = $name; + + $this->blockparents[$name] = $blockname; + } + } + } + + return $blocklist; + } // end func findBlocks + + /** + * Reads a file from disk and returns its content. + * + * @param string $filename Filename + * + * @return string Filecontent + * @access private + */ + function getFile($filename) + { + global $myPEAR; + if ($filename{0} == '/' && substr($this->fileRoot, -1) == '/') { + $filename = substr($filename, 1); + } + + $filename = $this->fileRoot . $filename; + + if (!($fh = @fopen($filename, 'r'))) { + $this->err[] = $myPEAR->raiseError( + $this->errorMessage(IT_TPL_NOT_FOUND) . ': "' .$filename .'"', + IT_TPL_NOT_FOUND + ); + return ""; + } + + $fsize = filesize($filename); + if ($fsize < 1) { + fclose($fh); + return ''; + } + + $content = fread($fh, $fsize); + fclose($fh); + + // "##ime", wma/PEAR error + return preg_replace( + "##im", + "\$this->getFile('\\1')", + $content + ); + } // end func getFile + + /** + * Adds delimiters to a string, so it can be used as a pattern + * in preg_* functions + * + * @param string $str input + * + * @return string + * @access private + */ + function _addPregDelimiters($str) + { + return '@' . preg_quote($str) . '@'; + } + + /** + * Escapes $ and \ as preg_replace will treat + * them as a backreference and not literal. + * See bug #9501 + * + * @param string $str String to escape + * + * @since 1.2.2 + * @return string + * @access private + */ + function _escapeBackreferences($str) + { + $str = str_replace('\\', '\\\\', $str); + $str = preg_replace('@\$([0-9]{1,2})@', '\\\$${1}', $str); + return $str; + } + + /** + * Replaces an opening delimiter by a special string + * + * @param string $str special string + * + * @return string + * @access private + */ + function _preserveOpeningDelimiter($str) + { + return (false === strpos($str, $this->openingDelimiter))? + $str: + str_replace( + $this->openingDelimiter, + $this->openingDelimiter . + '%preserved%' . $this->closingDelimiter, + $str + ); + } + + /** + * Return a textual error message for a IT error code + * + * @param integer $value error code + * @param string $blockname unknown + * + * @access private + * @return string error message, or false if the error code was + * not recognized + */ + function errorMessage($value, $blockname = '') + { + global $myPEAR; + static $errorMessages; + if (!isset($errorMessages)) { + $errorMessages = array( + IT_OK => '', + IT_ERROR => 'unknown error', + IT_TPL_NOT_FOUND => 'Cannot read the template file', + IT_BLOCK_NOT_FOUND => 'Cannot find this block', + IT_BLOCK_DUPLICATE => 'The name of a block must be'. + ' uniquewithin a template.'. + ' Found "' . $blockname . '" twice.'. + 'Unpredictable results '. + 'may appear.', + IT_UNKNOWN_OPTION => 'Unknown option' + ); + } + + if ($myPEAR->isError($value)) { + $value = $value->getCode(); + } + + return isset($errorMessages[$value]) ? + $errorMessages[$value] : $errorMessages[IT_ERROR]; + } +} // end class IntegratedTemplate +?> diff --git a/libraries/pear/HTML/Template/ITX.php b/libraries/pear/HTML/Template/ITX.php index b8ec37c..4753b78 100644 --- a/libraries/pear/HTML/Template/ITX.php +++ b/libraries/pear/HTML/Template/ITX.php @@ -1,889 +1,889 @@ - - * Pierre-Alain Joye - * David Soria Parra - * - * @category HTML - * @package HTML_Template_IT - * @author Ulf Wendel - * @license BSD http://www.opensource.org/licenses/bsd-license.php - * @version CVS: $Id: ITX.php 295086 2010-02-15 06:31:36Z clockwerx $ - * @link http://pear.php.net/packages/HTML_Template_IT - * @access public - */ - -require_once 'HTML/Template/IT.php'; -require_once 'HTML/Template/IT_Error.php'; - -/** -* Integrated Template Extension - ITX -* -* With this class you get the full power of the phplib template class. -* You may have one file with blocks in it but you have as well one main file -* and multiple files one for each block. This is quite usefull when you have -* user configurable websites. Using blocks not in the main template allows -* you to modify some parts of your layout easily. -* -* Note that you can replace an existing block and add new blocks at runtime. -* Adding new blocks means changing a variable placeholder to a block. -* - * @category HTML - * @package HTML_Template_IT - * @author Ulf Wendel - * @license BSD http://www.opensource.org/licenses/bsd-license.php - * @link http://pear.php.net/packages/HTML_Template_IT - * @access public -*/ -class HTML_Template_ITX extends HTML_Template_IT -{ - /** - * Array with all warnings. - * @var array - * @access public - * @see $printWarning, $haltOnWarning, warning() - */ - var $warn = array(); - - /** - * Print warnings? - * @var array - * @access public - * @see $haltOnWarning, $warn, warning() - */ - var $printWarning = false; - - /** - * Call die() on warning? - * @var boolean - * @access public - * @see $warn, $printWarning, warning() - */ - var $haltOnWarning = false; - - /** - * RegExp used to test for a valid blockname. - * @var string - * @access private - */ - var $checkblocknameRegExp = ''; - - /** - * Functionnameprefix used when searching function calls in the template. - * @var string - * @access public - */ - var $functionPrefix = 'func_'; - - /** - * Functionname RegExp. - * @var string - * @access public - */ - var $functionnameRegExp = '[_a-zA-Z]+[A-Za-z_0-9]*'; - - /** - * RegExp used to grep function calls in the template. - * - * The variable gets set by the constructor. - * - * @access private - * @var string - * @see HTML_Template_IT() - */ - var $functionRegExp = ''; - - /** - * List of functions found in the template. - * - * @access private - * @var array - */ - var $functions = array(); - - /** - * List of callback functions specified by the user. - * - * @access private - * @var array - */ - var $callback = array(); - - /** - * Builds some complex regexps and calls the constructor - * of the parent class. - * - * Make sure that you call this constructor if you derive your own - * template class from this one. - * - * @param string $root Root node? - * - * @access public - * @see HTML_Template_IT() - */ - function HTML_Template_ITX($root = '') - { - - $this->checkblocknameRegExp = '@' . $this->blocknameRegExp . '@'; - - $this->functionRegExp = '@' . $this->functionPrefix . '(' . - $this->functionnameRegExp . ')\s*\(@sm'; - - $this->HTML_Template_IT($root); - } // end func constructor - - /** - * Clears all datafields of the object and rebuild the internal blocklist - * - * LoadTemplatefile() and setTemplate() automatically call this function - * when a new template is given. Don't use this function - * unless you know what you're doing. - * - * @access private - * @return null - */ - function init() - { - $this->free(); - $this->buildFunctionlist(); - $this->findBlocks($this->template); - - // we don't need it any more - $this->template = ''; - $this->buildBlockvariablelist(); - - } // end func init - - /** - * Replaces an existing block with new content. - * - * This function will replace a block of the template and all blocks - * contained in the replaced block and add a new block insted, means - * you can dynamically change your template. - * - * Note that changing the template structure violates one of the IT[X] - * development goals. I've tried to write a simple to use template engine - * supporting blocks. In contrast to other systems IT[X] analyses the way - * you've nested blocks and knows which block belongs into another block. - * The nesting information helps to make the API short and simple. Replacing - * blocks does not only mean that IT[X] has to update the nesting - * information (relatively time consumpting task) but you have to make sure - * that you do not get confused due to the template change itself. - * - * @param string $block Blockname - * @param string $template Blockcontent - * @param boolean $keep_content true if the new block inherits the content - * of the old block - * - * @return boolean - * @throws IT_Error - * @see replaceBlockfile(), addBlock(), addBlockfile() - * @access public - */ - function replaceBlock($block, $template, $keep_content = false) - { - if (!isset($this->blocklist[$block])) { - return new IT_Error("The block "."'$block'". - " does not exist in the template and thus it can't be replaced.", - __FILE__, __LINE__); - } - - if ($template == '') { - return new IT_Error('No block content given.', __FILE__, __LINE__); - } - - if ($keep_content) { - $blockdata = $this->blockdata[$block]; - } - - // remove all kinds of links to the block / data of the block - $this->removeBlockData($block); - - $template = "" . $template . ""; - $parents = $this->blockparents[$block]; - - $this->findBlocks($template); - $this->blockparents[$block] = $parents; - - // KLUDGE: rebuild the list for all block - could be done faster - $this->buildBlockvariablelist(); - - if ($keep_content) { - $this->blockdata[$block] = $blockdata; - } - - // old TODO - I'm not sure if we need this - // update caches - - return true; - } // end func replaceBlock - - /** - * Replaces an existing block with new content from a file. - * - * @param string $block Blockname - * @param string $filename Name of the file that contains the blockcontent - * @param boolean $keep_content true if the new block inherits the content of - * the old block - * - * @brother replaceBlock() - * @access public - * @return null - */ - function replaceBlockfile($block, $filename, $keep_content = false) - { - return $this->replaceBlock($block, $this->getFile($filename), $keep_content); - } // end func replaceBlockfile - - /** - * Adds a block to the template changing a variable placeholder - * to a block placeholder. - * - * Add means "replace a variable placeholder by a new block". - * This is different to PHPLibs templates. The function loads a - * block, creates a handle for it and assigns it to a certain - * variable placeholder. To to the same with PHPLibs templates you would - * call set_file() to create the handle and parse() to assign the - * parsed block to a variable. By this PHPLibs templates assume - * that you tend to assign a block to more than one one placeholder. - * To assign a parsed block to more than only the placeholder you specify - * in this function you have to use a combination of getBlock() - * and setVariable(). - * - * As no updates to cached data is necessary addBlock() and addBlockfile() - * are rather "cheap" meaning quick operations. - * - * The block content must not start with - * and end with this would cause overhead and - * produce an error. - * - * @param string $placeholder Name of the variable placeholder, the name - * must be unique within the template. - * @param string $blockname Name of the block to be added - * @param string $template Content of the block - * - * @return boolean - * @throws IT_Error - * @see addBlockfile() - * @access public - */ - function addBlock($placeholder, $blockname, $template) - { - // Don't trust any user even if it's a programmer or yourself... - if ($placeholder == '') { - return new IT_Error('No variable placeholder given.', - __FILE__, __LINE__); - } elseif ($blockname == '' || - !preg_match($this->checkblocknameRegExp, $blockname) - ) { - return new IT_Error("No or invalid blockname '$blockname' given.", - __FILE__, __LINE__); - } elseif ($template == '') { - return new IT_Error('No block content given.', __FILE__, __LINE__); - } elseif (isset($this->blocklist[$blockname])) { - return new IT_Error('The block already exists.', - __FILE__, __LINE__); - } - - // find out where to insert the new block - $parents = $this->findPlaceholderBlocks($placeholder); - if (count($parents) == 0) { - - return new IT_Error("The variable placeholder". - " '$placeholder' was not found in the template.", - __FILE__, __LINE__); - - } elseif (count($parents) > 1) { - - reset($parents); - while (list($k, $parent) = each($parents)) { - $msg .= "$parent, "; - } - $msg = substr($parent, -2); - - return new IT_Error("The variable placeholder "."'$placeholder'". - " must be unique, found in multiple blocks '$msg'.", - __FILE__, __LINE__); - } - - $template = "" - . $template - . ""; - $this->findBlocks($template); - if ($this->flagBlocktrouble) { - return false; // findBlocks() already throws an exception - } - - $this->blockinner[$parents[0]][] = $blockname; - - $escblockname = '__' . $blockname . '__'; - - $this->blocklist[$parents[0]] = preg_replace( - '@' . $this->openingDelimiter . $placeholder . - $this->closingDelimiter . '@', - $this->openingDelimiter . $escblockname . $this->closingDelimiter, - $this->blocklist[$parents[0]] - ); - - $this->deleteFromBlockvariablelist($parents[0], $placeholder); - $this->updateBlockvariablelist($blockname); - - return true; - } // end func addBlock - - /** - * Adds a block taken from a file to the template changing a variable - * placeholder to a block placeholder. - * - * @param string $placeholder Name of the variable placeholder to be converted - * @param string $blockname Name of the block to be added - * @param string $filename File that contains the block - * - * @brother addBlock() - * @access public - * @return null - */ - function addBlockfile($placeholder, $blockname, $filename) - { - return $this->addBlock($placeholder, $blockname, $this->getFile($filename)); - } // end func addBlockfile - - /** - * Returns the name of the (first) block that contains - * the specified placeholder. - * - * @param string $placeholder Name of the placeholder you're searching - * @param string $block Name of the block to scan. If left out (default) - * all blocks are scanned. - * - * @return string Name of the (first) block that contains - * the specified placeholder. - * If the placeholder was not found or an error occured - * an empty string is returned. - * @throws IT_Error - * @access public - */ - function placeholderExists($placeholder, $block = '') - { - if ($placeholder == '') { - new IT_Error('No placeholder name given.', __FILE__, __LINE__); - return ''; - } - - if ($block != '' && !isset($this->blocklist[$block])) { - new IT_Error("Unknown block '$block'.", __FILE__, __LINE__); - return ''; - } - - // name of the block where the given placeholder was found - $found = ''; - - if ($block != '') { - if (is_array($variables = $this->blockvariables[$block])) { - // search the value in the list of blockvariables - reset($variables); - while (list($k, $variable) = each($variables)) { - if ($k == $placeholder) { - $found = $block; - break; - } - } - } - } else { - - // search all blocks and return the name of the first block that - // contains the placeholder - reset($this->blockvariables); - while (list($blockname, $variables) = each($this->blockvariables)) { - if (is_array($variables) && isset($variables[$placeholder])) { - $found = $blockname; - break; - } - } - } - - return $found; - } // end func placeholderExists - - /** - * Checks the list of function calls in the template and - * calls their callback function. - * - * @access public - * @return null - */ - function performCallback() - { - reset($this->functions); - while (list($func_id, $function) = each($this->functions)) { - if (isset($this->callback[$function['name']])) { - if ($this->callback[$function['name']]['expandParameters']) { - $callFunction = 'call_user_func_array'; - } else { - $callFunction = 'call_user_func'; - } - - if ($this->callback[$function['name']]['object'] != '') { - $call = $callFunction( - array( - &$GLOBALS[$this->callback[$function['name']]['object']], - $this->callback[$function['name']]['function']), - $function['args']); - - } else { - $call = $callFunction( - $this->callback[$function['name']]['function'], - $function['args']); - } - $this->variableCache['__function' . $func_id . '__'] = $call; - } - } - - } // end func performCallback - - /** - * Returns a list of all function calls in the current template. - * - * @return array - * @access public - */ - function getFunctioncalls() - { - return $this->functions; - } // end func getFunctioncalls - - /** - * Replaces a function call with the given replacement. - * - * @param int $functionID Function ID - * @param string $replacement Replacement - * - * @access public - * @deprecated - * @return null - */ - function setFunctioncontent($functionID, $replacement) - { - $this->variableCache['__function' . $functionID . '__'] = $replacement; - } // end func setFunctioncontent - - /** - * Sets a callback function. - * - * IT[X] templates (note the X) can contain simple function calls. - * "function call" means that the editor of the template can add - * special placeholder to the template like 'func_h1("embedded in h1")'. - * IT[X] will grab this function calls and allow you to define a callback - * function for them. - * - * This is an absolutely evil feature. If your application makes heavy - * use of such callbacks and you're even implementing if-then etc. on - * the level of a template engine you're reiventing the wheel... - that's - * actually how PHP came into life. Anyway, sometimes it's handy. - * - * Consider also using XML/XSLT or native PHP. And please do not push - * IT[X] any further into this direction of adding logics to the template - * engine. - * - * For those of you ready for the X in IT[X]: - * - * %s', $args[0]); - * } - * - * ... - * $itx = new HTML_Template_ITX(...); - * ... - * $itx->setCallbackFunction('h1', 'h_one'); - * $itx->performCallback(); - * ?> - * - * template: - * func_h1('H1 Headline'); - * - * @param string $tplfunction Function name in the template - * @param string $callbackfunction Name of the callback function - * @param string $callbackobject Name of the callback object - * @param boolean $expandCallbackParameters If the callback is called with - * a list of parameters or with an - * array holding the parameters - * - * @return boolean False on failure. - * @throws IT_Error - * @access public - * @deprecated The $callbackobject parameter is depricated since - * version 1.2 and might be dropped in further versions. - */ - function setCallbackFunction($tplfunction, $callbackfunction, - $callbackobject = '', - $expandCallbackParameters = false) { - if ($tplfunction == '' || $callbackfunction == '') { - return new IT_Error("No template function "."('$tplfunction')". - " and/or no callback function ('$callback') given.", - __FILE__, __LINE__); - } - $this->callback[$tplfunction] = array( - 'function' => $callbackfunction, - 'object' => $callbackobject, - 'expandParameters' => (boolean) - $expandCallbackParameters); - - return true; - } // end func setCallbackFunction - - /** - * Sets the Callback function lookup table - * - * @param array $functions function table - * array[templatefunction] = - * array( - * "function" => userfunction, - * "object" => userobject - * ) - * - * @access public - * @return null - */ - function setCallbackFuntiontable($functions) - { - $this->callback = $functions; - } // end func setCallbackFunctiontable - - /** - * Recursively removes all data assiciated with a block, including - * all inner blocks - * - * @param string $block block to be removed - * - * @return null - * @access private - */ - function removeBlockData($block) - { - if (isset($this->blockinner[$block])) { - foreach ($this->blockinner[$block] as $k => $inner) { - $this->removeBlockData($inner); - } - - unset($this->blockinner[$block]); - } - - unset($this->blocklist[$block]); - unset($this->blockdata[$block]); - unset($this->blockvariables[$block]); - unset($this->touchedBlocks[$block]); - - } // end func removeBlockinner - - /** - * Returns a list of blocknames in the template. - * - * @return array [blockname => blockname] - * @access public - * @see blockExists() - */ - function getBlocklist() - { - $blocklist = array(); - foreach ($this->blocklist as $block => $content) { - $blocklist[$block] = $block; - } - - return $blocklist; - } // end func getBlocklist - - /** - * Checks wheter a block exists. - * - * @param string $blockname Blockname - * - * @return boolean - * @access public - * @see getBlocklist() - */ - function blockExists($blockname) - { - return isset($this->blocklist[$blockname]); - } // end func blockExists - - /** - * Returns a list of variables of a block. - * - * @param string $block Blockname - * - * @return array [varname => varname] - * @access public - * @see BlockvariableExists() - */ - function getBlockvariables($block) - { - if (!isset($this->blockvariables[$block])) { - return array(); - } - - $variables = array(); - foreach ($this->blockvariables[$block] as $variable => $v) { - $variables[$variable] = $variable; - } - - return $variables; - } // end func getBlockvariables - - /** - * Checks wheter a block variable exists. - * - * @param string $block Blockname - * @param string $variable Variablename - * - * @return boolean - * @access public - * @see getBlockvariables() - */ - function BlockvariableExists($block, $variable) - { - return isset($this->blockvariables[$block][$variable]); - } // end func BlockvariableExists - - /** - * Builds a functionlist from the template. - * - * @access private - * @return null - */ - function buildFunctionlist() - { - $this->functions = array(); - - $template = $this->template; - - $num = 0; - - while (preg_match($this->functionRegExp, $template, $regs)) { - - $pos = strpos($template, $regs[0]); - - $template = substr($template, $pos + strlen($regs[0])); - - $head = $this->getValue($template, ')'); - $args = array(); - - $search = $regs[0] . $head . ')'; - - $replace = $this->openingDelimiter . - '__function' . $num . '__' . - $this->closingDelimiter; - - $this->template = str_replace($search, $replace, $this->template); - $template = str_replace($search, $replace, $template); - - while ($head != '' && $args2 = $this->getValue($head, ',')) { - $arg2 = trim($args2); - - $args[] = ('"' == $arg2{0} || "'" == $arg2{0}) ? - substr($arg2, 1, -1) : $arg2; - - if ($arg2 == $head) { - break; - } - $head = substr($head, strlen($arg2) + 1); - } - - $this->functions[$num++] = array('name' => $regs[1], - 'args' => $args); - } - - } // end func buildFunctionlist - - /** - * Truncates the given code from the first occurence of - * $delimiter but ignores $delimiter enclosed by " or '. - * - * @param string $code The code which should be parsed - * @param string $delimiter The delimiter char - * - * @access private - * @return string - * @see buildFunctionList() - */ - function getValue($code, $delimiter) - { - if ($code == '') { - return ''; - } - - if (!is_array($delimiter)) { - $delimiter = array($delimiter => true); - } - - $len = strlen($code); - $enclosed = false; - $enclosed_by = ''; - - if (isset($delimiter[$code[0]])) { - $i = 1; - } else { - for ($i = 0; $i < $len; ++$i) { - $char = $code[$i]; - - if (($char == '"' || $char == "'") - && ($char == $enclosed_by || '' == $enclosed_by) - && (0 == $i || ($i > 0 && '\\' != $code[$i - 1])) - ) { - - if (!$enclosed) { - $enclosed_by = $char; - } else { - $enclosed_by = ""; - } - $enclosed = !$enclosed; - - } - - if (!$enclosed && isset($delimiter[$char])) { - break; - } - } - } - - return substr($code, 0, $i); - } // end func getValue - - /** - * Deletes one or many variables from the block variable list. - * - * @param string $block Blockname - * @param mixed $variables Name of one variable or array of variables - * (array (name => true ) ) to be stripped. - * - * @access private - * @return null - */ - function deleteFromBlockvariablelist($block, $variables) - { - if (!is_array($variables)) { - $variables = array($variables => true); - } - - reset($this->blockvariables[$block]); - while (list($varname, $val) = each($this->blockvariables[$block])) { - if (isset($variables[$varname])) { - unset($this->blockvariables[$block][$varname]); - } - } - } // end deleteFromBlockvariablelist - - /** - * Updates the variable list of a block. - * - * @param string $block Blockname - * - * @access private - * @return null - */ - function updateBlockvariablelist($block) - { - preg_match_all( - $this->variablesRegExp, - $this->blocklist[$block], $regs - ); - - if (count($regs[1]) != 0) { - foreach ($regs[1] as $k => $var) { - $this->blockvariables[$block][$var] = true; - } - } else { - $this->blockvariables[$block] = array(); - } - - // check if any inner blocks were found - if (isset($this->blockinner[$block]) - && is_array($this->blockinner[$block]) - && count($this->blockinner[$block]) > 0 - ) { - /* - * loop through inner blocks, registering the variable - * placeholders in each - */ - foreach ($this->blockinner[$block] as $childBlock) { - $this->updateBlockvariablelist($childBlock); - } - } - } // end func updateBlockvariablelist - - /** - * Returns an array of blocknames where the given variable - * placeholder is used. - * - * @param string $variable Variable placeholder - * - * @return array $parents parents[0..n] = blockname - * @access public - */ - function findPlaceholderBlocks($variable) - { - $parents = array(); - reset($this->blocklist); - while (list($blockname, $content) = each($this->blocklist)) { - reset($this->blockvariables[$blockname]); - - while (list($varname, $val) = each($this->blockvariables[$blockname])) { - if ($variable == $varname) { - $parents[] = $blockname; - } - } - } - - return $parents; - } // end func findPlaceholderBlocks - - /** - * Handles warnings, saves them to $warn and prints them or - * calls die() depending on the flags - * - * @param string $message Warning - * @param string $file File where the warning occured - * @param int $line Linenumber where the warning occured - * - * @see $warn, $printWarning, $haltOnWarning - * @access private - * @return null - */ - function warning($message, $file = '', $line = 0) - { - $message = sprintf( - 'HTML_Template_ITX Warning: %s [File: %s, Line: %d]', - $message, - $file, - $line - ); - - $this->warn[] = $message; - - if ($this->printWarning) { - print $message; - } - - if ($this->haltOnWarning) { - die($message); - } - } // end func warning - -} // end class HTML_Template_ITX -?> + + * Pierre-Alain Joye + * David Soria Parra + * + * @category HTML + * @package HTML_Template_IT + * @author Ulf Wendel + * @license BSD http://www.opensource.org/licenses/bsd-license.php + * @version CVS: $Id: ITX.php 3 2017-06-22 07:32:17Z martin $ + * @link http://pear.php.net/packages/HTML_Template_IT + * @access public + */ + +require_once 'HTML/Template/IT.php'; +require_once 'HTML/Template/IT_Error.php'; + +/** +* Integrated Template Extension - ITX +* +* With this class you get the full power of the phplib template class. +* You may have one file with blocks in it but you have as well one main file +* and multiple files one for each block. This is quite usefull when you have +* user configurable websites. Using blocks not in the main template allows +* you to modify some parts of your layout easily. +* +* Note that you can replace an existing block and add new blocks at runtime. +* Adding new blocks means changing a variable placeholder to a block. +* + * @category HTML + * @package HTML_Template_IT + * @author Ulf Wendel + * @license BSD http://www.opensource.org/licenses/bsd-license.php + * @link http://pear.php.net/packages/HTML_Template_IT + * @access public +*/ +class HTML_Template_ITX extends HTML_Template_IT +{ + /** + * Array with all warnings. + * @var array + * @access public + * @see $printWarning, $haltOnWarning, warning() + */ + var $warn = array(); + + /** + * Print warnings? + * @var array + * @access public + * @see $haltOnWarning, $warn, warning() + */ + var $printWarning = false; + + /** + * Call die() on warning? + * @var boolean + * @access public + * @see $warn, $printWarning, warning() + */ + var $haltOnWarning = false; + + /** + * RegExp used to test for a valid blockname. + * @var string + * @access private + */ + var $checkblocknameRegExp = ''; + + /** + * Functionnameprefix used when searching function calls in the template. + * @var string + * @access public + */ + var $functionPrefix = 'func_'; + + /** + * Functionname RegExp. + * @var string + * @access public + */ + var $functionnameRegExp = '[_a-zA-Z]+[A-Za-z_0-9]*'; + + /** + * RegExp used to grep function calls in the template. + * + * The variable gets set by the constructor. + * + * @access private + * @var string + * @see HTML_Template_IT() + */ + var $functionRegExp = ''; + + /** + * List of functions found in the template. + * + * @access private + * @var array + */ + var $functions = array(); + + /** + * List of callback functions specified by the user. + * + * @access private + * @var array + */ + var $callback = array(); + + /** + * Builds some complex regexps and calls the constructor + * of the parent class. + * + * Make sure that you call this constructor if you derive your own + * template class from this one. + * + * @param string $root Root node? + * + * @access public + * @see HTML_Template_IT() + */ + function HTML_Template_ITX($root = '') + { + + $this->checkblocknameRegExp = '@' . $this->blocknameRegExp . '@'; + + $this->functionRegExp = '@' . $this->functionPrefix . '(' . + $this->functionnameRegExp . ')\s*\(@sm'; + + $this->HTML_Template_IT($root); + } // end func constructor + + /** + * Clears all datafields of the object and rebuild the internal blocklist + * + * LoadTemplatefile() and setTemplate() automatically call this function + * when a new template is given. Don't use this function + * unless you know what you're doing. + * + * @access private + * @return null + */ + function init() + { + $this->free(); + $this->buildFunctionlist(); + $this->findBlocks($this->template); + + // we don't need it any more + $this->template = ''; + $this->buildBlockvariablelist(); + + } // end func init + + /** + * Replaces an existing block with new content. + * + * This function will replace a block of the template and all blocks + * contained in the replaced block and add a new block insted, means + * you can dynamically change your template. + * + * Note that changing the template structure violates one of the IT[X] + * development goals. I've tried to write a simple to use template engine + * supporting blocks. In contrast to other systems IT[X] analyses the way + * you've nested blocks and knows which block belongs into another block. + * The nesting information helps to make the API short and simple. Replacing + * blocks does not only mean that IT[X] has to update the nesting + * information (relatively time consumpting task) but you have to make sure + * that you do not get confused due to the template change itself. + * + * @param string $block Blockname + * @param string $template Blockcontent + * @param boolean $keep_content true if the new block inherits the content + * of the old block + * + * @return boolean + * @throws IT_Error + * @see replaceBlockfile(), addBlock(), addBlockfile() + * @access public + */ + function replaceBlock($block, $template, $keep_content = false) + { + if (!isset($this->blocklist[$block])) { + return new IT_Error("The block "."'$block'". + " does not exist in the template and thus it can't be replaced.", + __FILE__, __LINE__); + } + + if ($template == '') { + return new IT_Error('No block content given.', __FILE__, __LINE__); + } + + if ($keep_content) { + $blockdata = $this->blockdata[$block]; + } + + // remove all kinds of links to the block / data of the block + $this->removeBlockData($block); + + $template = "" . $template . ""; + $parents = $this->blockparents[$block]; + + $this->findBlocks($template); + $this->blockparents[$block] = $parents; + + // KLUDGE: rebuild the list for all block - could be done faster + $this->buildBlockvariablelist(); + + if ($keep_content) { + $this->blockdata[$block] = $blockdata; + } + + // old TODO - I'm not sure if we need this + // update caches + + return true; + } // end func replaceBlock + + /** + * Replaces an existing block with new content from a file. + * + * @param string $block Blockname + * @param string $filename Name of the file that contains the blockcontent + * @param boolean $keep_content true if the new block inherits the content of + * the old block + * + * @brother replaceBlock() + * @access public + * @return null + */ + function replaceBlockfile($block, $filename, $keep_content = false) + { + return $this->replaceBlock($block, $this->getFile($filename), $keep_content); + } // end func replaceBlockfile + + /** + * Adds a block to the template changing a variable placeholder + * to a block placeholder. + * + * Add means "replace a variable placeholder by a new block". + * This is different to PHPLibs templates. The function loads a + * block, creates a handle for it and assigns it to a certain + * variable placeholder. To to the same with PHPLibs templates you would + * call set_file() to create the handle and parse() to assign the + * parsed block to a variable. By this PHPLibs templates assume + * that you tend to assign a block to more than one one placeholder. + * To assign a parsed block to more than only the placeholder you specify + * in this function you have to use a combination of getBlock() + * and setVariable(). + * + * As no updates to cached data is necessary addBlock() and addBlockfile() + * are rather "cheap" meaning quick operations. + * + * The block content must not start with + * and end with this would cause overhead and + * produce an error. + * + * @param string $placeholder Name of the variable placeholder, the name + * must be unique within the template. + * @param string $blockname Name of the block to be added + * @param string $template Content of the block + * + * @return boolean + * @throws IT_Error + * @see addBlockfile() + * @access public + */ + function addBlock($placeholder, $blockname, $template) + { + // Don't trust any user even if it's a programmer or yourself... + if ($placeholder == '') { + return new IT_Error('No variable placeholder given.', + __FILE__, __LINE__); + } elseif ($blockname == '' || + !preg_match($this->checkblocknameRegExp, $blockname) + ) { + return new IT_Error("No or invalid blockname '$blockname' given.", + __FILE__, __LINE__); + } elseif ($template == '') { + return new IT_Error('No block content given.', __FILE__, __LINE__); + } elseif (isset($this->blocklist[$blockname])) { + return new IT_Error('The block already exists.', + __FILE__, __LINE__); + } + + // find out where to insert the new block + $parents = $this->findPlaceholderBlocks($placeholder); + if (count($parents) == 0) { + + return new IT_Error("The variable placeholder". + " '$placeholder' was not found in the template.", + __FILE__, __LINE__); + + } elseif (count($parents) > 1) { + + reset($parents); + while (list($k, $parent) = each($parents)) { + $msg .= "$parent, "; + } + $msg = substr($parent, -2); + + return new IT_Error("The variable placeholder "."'$placeholder'". + " must be unique, found in multiple blocks '$msg'.", + __FILE__, __LINE__); + } + + $template = "" + . $template + . ""; + $this->findBlocks($template); + if ($this->flagBlocktrouble) { + return false; // findBlocks() already throws an exception + } + + $this->blockinner[$parents[0]][] = $blockname; + + $escblockname = '__' . $blockname . '__'; + + $this->blocklist[$parents[0]] = preg_replace( + '@' . $this->openingDelimiter . $placeholder . + $this->closingDelimiter . '@', + $this->openingDelimiter . $escblockname . $this->closingDelimiter, + $this->blocklist[$parents[0]] + ); + + $this->deleteFromBlockvariablelist($parents[0], $placeholder); + $this->updateBlockvariablelist($blockname); + + return true; + } // end func addBlock + + /** + * Adds a block taken from a file to the template changing a variable + * placeholder to a block placeholder. + * + * @param string $placeholder Name of the variable placeholder to be converted + * @param string $blockname Name of the block to be added + * @param string $filename File that contains the block + * + * @brother addBlock() + * @access public + * @return null + */ + function addBlockfile($placeholder, $blockname, $filename) + { + return $this->addBlock($placeholder, $blockname, $this->getFile($filename)); + } // end func addBlockfile + + /** + * Returns the name of the (first) block that contains + * the specified placeholder. + * + * @param string $placeholder Name of the placeholder you're searching + * @param string $block Name of the block to scan. If left out (default) + * all blocks are scanned. + * + * @return string Name of the (first) block that contains + * the specified placeholder. + * If the placeholder was not found or an error occured + * an empty string is returned. + * @throws IT_Error + * @access public + */ + function placeholderExists($placeholder, $block = '') + { + if ($placeholder == '') { + new IT_Error('No placeholder name given.', __FILE__, __LINE__); + return ''; + } + + if ($block != '' && !isset($this->blocklist[$block])) { + new IT_Error("Unknown block '$block'.", __FILE__, __LINE__); + return ''; + } + + // name of the block where the given placeholder was found + $found = ''; + + if ($block != '') { + if (is_array($variables = $this->blockvariables[$block])) { + // search the value in the list of blockvariables + reset($variables); + while (list($k, $variable) = each($variables)) { + if ($k == $placeholder) { + $found = $block; + break; + } + } + } + } else { + + // search all blocks and return the name of the first block that + // contains the placeholder + reset($this->blockvariables); + while (list($blockname, $variables) = each($this->blockvariables)) { + if (is_array($variables) && isset($variables[$placeholder])) { + $found = $blockname; + break; + } + } + } + + return $found; + } // end func placeholderExists + + /** + * Checks the list of function calls in the template and + * calls their callback function. + * + * @access public + * @return null + */ + function performCallback() + { + reset($this->functions); + while (list($func_id, $function) = each($this->functions)) { + if (isset($this->callback[$function['name']])) { + if ($this->callback[$function['name']]['expandParameters']) { + $callFunction = 'call_user_func_array'; + } else { + $callFunction = 'call_user_func'; + } + + if ($this->callback[$function['name']]['object'] != '') { + $call = $callFunction( + array( + &$GLOBALS[$this->callback[$function['name']]['object']], + $this->callback[$function['name']]['function']), + $function['args']); + + } else { + $call = $callFunction( + $this->callback[$function['name']]['function'], + $function['args']); + } + $this->variableCache['__function' . $func_id . '__'] = $call; + } + } + + } // end func performCallback + + /** + * Returns a list of all function calls in the current template. + * + * @return array + * @access public + */ + function getFunctioncalls() + { + return $this->functions; + } // end func getFunctioncalls + + /** + * Replaces a function call with the given replacement. + * + * @param int $functionID Function ID + * @param string $replacement Replacement + * + * @access public + * @deprecated + * @return null + */ + function setFunctioncontent($functionID, $replacement) + { + $this->variableCache['__function' . $functionID . '__'] = $replacement; + } // end func setFunctioncontent + + /** + * Sets a callback function. + * + * IT[X] templates (note the X) can contain simple function calls. + * "function call" means that the editor of the template can add + * special placeholder to the template like 'func_h1("embedded in h1")'. + * IT[X] will grab this function calls and allow you to define a callback + * function for them. + * + * This is an absolutely evil feature. If your application makes heavy + * use of such callbacks and you're even implementing if-then etc. on + * the level of a template engine you're reiventing the wheel... - that's + * actually how PHP came into life. Anyway, sometimes it's handy. + * + * Consider also using XML/XSLT or native PHP. And please do not push + * IT[X] any further into this direction of adding logics to the template + * engine. + * + * For those of you ready for the X in IT[X]: + * + * %s', $args[0]); + * } + * + * ... + * $itx = new HTML_Template_ITX(...); + * ... + * $itx->setCallbackFunction('h1', 'h_one'); + * $itx->performCallback(); + * ?> + * + * template: + * func_h1('H1 Headline'); + * + * @param string $tplfunction Function name in the template + * @param string $callbackfunction Name of the callback function + * @param string $callbackobject Name of the callback object + * @param boolean $expandCallbackParameters If the callback is called with + * a list of parameters or with an + * array holding the parameters + * + * @return boolean False on failure. + * @throws IT_Error + * @access public + * @deprecated The $callbackobject parameter is depricated since + * version 1.2 and might be dropped in further versions. + */ + function setCallbackFunction($tplfunction, $callbackfunction, + $callbackobject = '', + $expandCallbackParameters = false) { + if ($tplfunction == '' || $callbackfunction == '') { + return new IT_Error("No template function "."('$tplfunction')". + " and/or no callback function ('$callback') given.", + __FILE__, __LINE__); + } + $this->callback[$tplfunction] = array( + 'function' => $callbackfunction, + 'object' => $callbackobject, + 'expandParameters' => (boolean) + $expandCallbackParameters); + + return true; + } // end func setCallbackFunction + + /** + * Sets the Callback function lookup table + * + * @param array $functions function table + * array[templatefunction] = + * array( + * "function" => userfunction, + * "object" => userobject + * ) + * + * @access public + * @return null + */ + function setCallbackFuntiontable($functions) + { + $this->callback = $functions; + } // end func setCallbackFunctiontable + + /** + * Recursively removes all data assiciated with a block, including + * all inner blocks + * + * @param string $block block to be removed + * + * @return null + * @access private + */ + function removeBlockData($block) + { + if (isset($this->blockinner[$block])) { + foreach ($this->blockinner[$block] as $k => $inner) { + $this->removeBlockData($inner); + } + + unset($this->blockinner[$block]); + } + + unset($this->blocklist[$block]); + unset($this->blockdata[$block]); + unset($this->blockvariables[$block]); + unset($this->touchedBlocks[$block]); + + } // end func removeBlockinner + + /** + * Returns a list of blocknames in the template. + * + * @return array [blockname => blockname] + * @access public + * @see blockExists() + */ + function getBlocklist() + { + $blocklist = array(); + foreach ($this->blocklist as $block => $content) { + $blocklist[$block] = $block; + } + + return $blocklist; + } // end func getBlocklist + + /** + * Checks wheter a block exists. + * + * @param string $blockname Blockname + * + * @return boolean + * @access public + * @see getBlocklist() + */ + function blockExists($blockname) + { + return isset($this->blocklist[$blockname]); + } // end func blockExists + + /** + * Returns a list of variables of a block. + * + * @param string $block Blockname + * + * @return array [varname => varname] + * @access public + * @see BlockvariableExists() + */ + function getBlockvariables($block) + { + if (!isset($this->blockvariables[$block])) { + return array(); + } + + $variables = array(); + foreach ($this->blockvariables[$block] as $variable => $v) { + $variables[$variable] = $variable; + } + + return $variables; + } // end func getBlockvariables + + /** + * Checks wheter a block variable exists. + * + * @param string $block Blockname + * @param string $variable Variablename + * + * @return boolean + * @access public + * @see getBlockvariables() + */ + function BlockvariableExists($block, $variable) + { + return isset($this->blockvariables[$block][$variable]); + } // end func BlockvariableExists + + /** + * Builds a functionlist from the template. + * + * @access private + * @return null + */ + function buildFunctionlist() + { + $this->functions = array(); + + $template = $this->template; + + $num = 0; + + while (preg_match($this->functionRegExp, $template, $regs)) { + + $pos = strpos($template, $regs[0]); + + $template = substr($template, $pos + strlen($regs[0])); + + $head = $this->getValue($template, ')'); + $args = array(); + + $search = $regs[0] . $head . ')'; + + $replace = $this->openingDelimiter . + '__function' . $num . '__' . + $this->closingDelimiter; + + $this->template = str_replace($search, $replace, $this->template); + $template = str_replace($search, $replace, $template); + + while ($head != '' && $args2 = $this->getValue($head, ',')) { + $arg2 = trim($args2); + + $args[] = ('"' == $arg2{0} || "'" == $arg2{0}) ? + substr($arg2, 1, -1) : $arg2; + + if ($arg2 == $head) { + break; + } + $head = substr($head, strlen($arg2) + 1); + } + + $this->functions[$num++] = array('name' => $regs[1], + 'args' => $args); + } + + } // end func buildFunctionlist + + /** + * Truncates the given code from the first occurence of + * $delimiter but ignores $delimiter enclosed by " or '. + * + * @param string $code The code which should be parsed + * @param string $delimiter The delimiter char + * + * @access private + * @return string + * @see buildFunctionList() + */ + function getValue($code, $delimiter) + { + if ($code == '') { + return ''; + } + + if (!is_array($delimiter)) { + $delimiter = array($delimiter => true); + } + + $len = strlen($code); + $enclosed = false; + $enclosed_by = ''; + + if (isset($delimiter[$code[0]])) { + $i = 1; + } else { + for ($i = 0; $i < $len; ++$i) { + $char = $code[$i]; + + if (($char == '"' || $char == "'") + && ($char == $enclosed_by || '' == $enclosed_by) + && (0 == $i || ($i > 0 && '\\' != $code[$i - 1])) + ) { + + if (!$enclosed) { + $enclosed_by = $char; + } else { + $enclosed_by = ""; + } + $enclosed = !$enclosed; + + } + + if (!$enclosed && isset($delimiter[$char])) { + break; + } + } + } + + return substr($code, 0, $i); + } // end func getValue + + /** + * Deletes one or many variables from the block variable list. + * + * @param string $block Blockname + * @param mixed $variables Name of one variable or array of variables + * (array (name => true ) ) to be stripped. + * + * @access private + * @return null + */ + function deleteFromBlockvariablelist($block, $variables) + { + if (!is_array($variables)) { + $variables = array($variables => true); + } + + reset($this->blockvariables[$block]); + while (list($varname, $val) = each($this->blockvariables[$block])) { + if (isset($variables[$varname])) { + unset($this->blockvariables[$block][$varname]); + } + } + } // end deleteFromBlockvariablelist + + /** + * Updates the variable list of a block. + * + * @param string $block Blockname + * + * @access private + * @return null + */ + function updateBlockvariablelist($block) + { + preg_match_all( + $this->variablesRegExp, + $this->blocklist[$block], $regs + ); + + if (count($regs[1]) != 0) { + foreach ($regs[1] as $k => $var) { + $this->blockvariables[$block][$var] = true; + } + } else { + $this->blockvariables[$block] = array(); + } + + // check if any inner blocks were found + if (isset($this->blockinner[$block]) + && is_array($this->blockinner[$block]) + && count($this->blockinner[$block]) > 0 + ) { + /* + * loop through inner blocks, registering the variable + * placeholders in each + */ + foreach ($this->blockinner[$block] as $childBlock) { + $this->updateBlockvariablelist($childBlock); + } + } + } // end func updateBlockvariablelist + + /** + * Returns an array of blocknames where the given variable + * placeholder is used. + * + * @param string $variable Variable placeholder + * + * @return array $parents parents[0..n] = blockname + * @access public + */ + function findPlaceholderBlocks($variable) + { + $parents = array(); + reset($this->blocklist); + while (list($blockname, $content) = each($this->blocklist)) { + reset($this->blockvariables[$blockname]); + + while (list($varname, $val) = each($this->blockvariables[$blockname])) { + if ($variable == $varname) { + $parents[] = $blockname; + } + } + } + + return $parents; + } // end func findPlaceholderBlocks + + /** + * Handles warnings, saves them to $warn and prints them or + * calls die() depending on the flags + * + * @param string $message Warning + * @param string $file File where the warning occured + * @param int $line Linenumber where the warning occured + * + * @see $warn, $printWarning, $haltOnWarning + * @access private + * @return null + */ + function warning($message, $file = '', $line = 0) + { + $message = sprintf( + 'HTML_Template_ITX Warning: %s [File: %s, Line: %d]', + $message, + $file, + $line + ); + + $this->warn[] = $message; + + if ($this->printWarning) { + print $message; + } + + if ($this->haltOnWarning) { + die($message); + } + } // end func warning + +} // end class HTML_Template_ITX +?> diff --git a/libraries/pear/HTML/Template/IT_Error.php b/libraries/pear/HTML/Template/IT_Error.php index 20e250c..b9a08e1 100644 --- a/libraries/pear/HTML/Template/IT_Error.php +++ b/libraries/pear/HTML/Template/IT_Error.php @@ -1,65 +1,65 @@ - - * Pierre-Alain Joye - * David Soria Parra - * - * @category HTML - * @package HTML_Template_IT - * @author Ulf Wendel - * @license BSD http://www.opensource.org/licenses/bsd-license.php - * @version CVS: $Id: IT_Error.php 295117 2010-02-15 23:25:21Z clockwerx $ - * @link http://pear.php.net/packages/HTML_Template_IT - * @access public - */ - -require_once "PEAR.php"; - -/** -* IT[X] Error class -* - * @category HTML - * @package HTML_Template_IT - * @author Ulf Wendel - * @license BSD http://www.opensource.org/licenses/bsd-license.php - * @link http://pear.php.net/packages/HTML_Template_IT - * @access public -*/ -class IT_Error extends PEAR_Error -{ - /** - * Prefix of all error messages. - * - * @var string - */ - var $error_message_prefix = "IntegratedTemplate Error: "; - - /** - * Creates an cache error object. - * - * @param string $msg error message - * @param string $file file where the error occured - * @param string $line linenumber where the error occured - */ - function IT_Error($msg, $file = __FILE__, $line = __LINE__) - { - $this->PEAR_Error(sprintf("%s [%s on line %d].", $msg, $file, $line)); - } // end func IT_Error - -} // end class IT_Error -?> + + * Pierre-Alain Joye + * David Soria Parra + * + * @category HTML + * @package HTML_Template_IT + * @author Ulf Wendel + * @license BSD http://www.opensource.org/licenses/bsd-license.php + * @version CVS: $Id: IT_Error.php 3 2017-06-22 07:32:17Z martin $ + * @link http://pear.php.net/packages/HTML_Template_IT + * @access public + */ + +require_once "PEAR.php"; + +/** +* IT[X] Error class +* + * @category HTML + * @package HTML_Template_IT + * @author Ulf Wendel + * @license BSD http://www.opensource.org/licenses/bsd-license.php + * @link http://pear.php.net/packages/HTML_Template_IT + * @access public +*/ +class IT_Error extends PEAR_Error +{ + /** + * Prefix of all error messages. + * + * @var string + */ + var $error_message_prefix = "IntegratedTemplate Error: "; + + /** + * Creates an cache error object. + * + * @param string $msg error message + * @param string $file file where the error occured + * @param string $line linenumber where the error occured + */ + function IT_Error($msg, $file = __FILE__, $line = __LINE__) + { + $this->PEAR_Error(sprintf("%s [%s on line %d].", $msg, $file, $line)); + } // end func IT_Error + +} // end class IT_Error +?> diff --git a/scripts/do_config.php b/scripts/do_config.php index a0b7cc0..3e8912f 100644 --- a/scripts/do_config.php +++ b/scripts/do_config.php @@ -6,15 +6,15 @@ // /////////////////////////////////////////////////////////////////////////////// // -// (c) 2005-2012 by Martin Willisegger +// (c) 2005-2017 by Martin Willisegger // // Project : NagiosQL // Component : Configuration scripting interface // Website : http://www.nagiosql.org -// Date : $LastChangedDate: 2012-03-08 08:40:12 +0100 (Thu, 08 Mar 2012) $ +// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $ // Author : $LastChangedBy: martin $ -// Version : 3.2.0 -// Revision : $LastChangedRevision: 1280 $ +// Version : 3.3.0 +// Revision : $LastChangedRevision: 2 $ // /////////////////////////////////////////////////////////////////////////////// // @@ -129,7 +129,7 @@ if ($argFunction == "restart") { if ($intMethod == 1) { if (file_exists($strPidfile)) { if (file_exists($strCommandfile) && is_writable($strCommandfile)) { - $strCommandString = "[".mktime()."] RESTART_PROGRAM;".mktime(); + $strCommandString = "[".time()."] RESTART_PROGRAM;".time()."\n"; $timeout = 3; $old = ini_set('default_socket_timeout', $timeout); $resCmdFile = fopen($strCommandfile,"w"); @@ -161,7 +161,7 @@ if ($argFunction == "restart") { $myVisClass->processMessage($myDataClass->strErrorMessage,$strErrorMessage); } else { if (is_array($myConfigClass->sendSSHCommand('ls '.$strCommandfile))) { - $strCommandString = "[".mktime()."] RESTART_PROGRAM;".mktime(); + $strCommandString = "[".time()."] RESTART_PROGRAM;".time()."\n";; $arrResult = $myConfigClass->sendSSHCommand('echo "'.$strCommandString.'" >> '.$strCommandfile); if ($arrResult == false) { echo "Restart failed - Nagios command file not found or no rights to execute (remote SSH)!\n"; diff --git a/templates/admin/admin_master.tpl.htm b/templates/admin/admin_master.tpl.htm index e698b11..1f3cfdf 100644 --- a/templates/admin/admin_master.tpl.htm +++ b/templates/admin/admin_master.tpl.htm @@ -1,12 +1,12 @@ - + - + - - + +