]> git.sur5r.net Git - bacula/bacula/commitdiff
- Add templates_c to cvs repository.
authorJuan Luis Francis <indpnday@users.sourceforge.net>
Mon, 18 Jul 2005 15:33:46 +0000 (15:33 +0000)
committerJuan Luis Francis <indpnday@users.sourceforge.net>
Mon, 18 Jul 2005 15:33:46 +0000 (15:33 +0000)
- Apply pgsql patch. Thanks to Dan Langille.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2214 91ce42f0-d328-0410-95d8-f526ca767f89

gui/bacula-web/ChangeLog
gui/bacula-web/classes.inc
gui/bacula-web/index.php

index 6e34e7c9fd458dae30e33c65665cc1f16a0b50fa..c9ed5a23a7e86cbcee68957c8b7cc2fd953ef116 100644 (file)
@@ -1,8 +1,9 @@
 - - - -  Bacula web 1.2
        - Human redable Y-axis of graphs
        - Updated French translation
-       - Initial support for PostgreSQL
+       - Initial support for PostgreSQL (thanks to Dan Langille)
        - Upgrade Phplot to 5.0rc2 version.
+       - Add templates_c to cvs repository.
        
 25-10-2004 Bacula web 1.1
     - Add array_fill function (as Mikael suggested)
index 14a0b2104f521038d752872eed0a0ffefec90c30..9b4211b6443509a411cf0b3eab583c5d97b2304f 100644 (file)
@@ -42,11 +42,11 @@ class Bweb extends DB {
                 $conf = new Config_File (CONFIG_DIR);
                 
                 
-                $this->dsn[hostspec] = $conf->get(CONFIG_FILE,"DATABASE","host");
-                $this->dsn[username] = $conf->get(CONFIG_FILE,"DATABASE","login");
-                $this->dsn[password] = $conf->get(CONFIG_FILE,"DATABASE","pass");
-                $this->dsn[database] = $conf->get(CONFIG_FILE,"DATABASE","db_name");
-                $this->dsn[phptype] = $conf->get(CONFIG_FILE,"DATABASE","db_type");   // mysql, (sqlite, pgsql) -->> Yet not checked
+                $this->dsn['hostspec'] = $conf->get(CONFIG_FILE,"DATABASE","host");
+                $this->dsn['username'] = $conf->get(CONFIG_FILE,"DATABASE","login");
+                $this->dsn['password'] = $conf->get(CONFIG_FILE,"DATABASE","pass");
+                $this->dsn['database'] = $conf->get(CONFIG_FILE,"DATABASE","db_name");
+                $this->dsn['phptype'] = $conf->get(CONFIG_FILE,"DATABASE","db_type");   // mysql, (sqlite, pgsql) -->> Yet not checked
                 if (  $conf->get(CONFIG_FILE,"DATABASE","db_port") )
                         $this->dsn[port] = $conf->get(CONFIG_FILE,"DATABASE","db_port");
                         
@@ -104,7 +104,7 @@ class Bweb extends DB {
                         if ($this->driver == "mysql" )
                                 $result = $this->link->query("select Media.VolumeName, Media.VolBytes,Media.VolStatus,Pool.Name,Media.MediaType,Media.LastWritten,FROM_UNIXTIME(UNIX_TIMESTAMP(Media.LastWritten)+Media.VolRetention ) as expire from Pool LEFT JOIN Media ON Media.PoolId=Pool.PoolId where Name='$tmp[0]' order by Media.VolumeName");
                         else if ($this->driver == "pgsql")
-                                $result = $this->link->query("select Media.VolumeName, Media.VolBytes,Media.VolStatus,Pool.Name,Media.MediaType,Media.LastWritten,FROM_UNIXTIME(Media.LastWritten::Timestamp without time zone + Media.VolRetention) as expire from Pool LEFT JOIN Media ON Media.PoolId=Pool.PoolId where Name='$tmp[0]' order by Media.VolumeName");                                                          
+                               $result = $this->link->query("select Media.VolumeName, Media.VolBytes,Media.VolStatus,Pool.Name,Media.MediaType,Media.LastWritten, Media.LastWritten + Media.VolRetention * interval '1 second' as expire from Pool LEFT JOIN Media ON Media.PoolId=Pool.PoolId where Name='$tmp[0]' order by Media.VolumeName");
                         while ( $tmp1 = $result->fetchRow() ) {
                                 $pos = array_key_exists($tmp[0],$volume);
                                 if ($pos != FALSE)
@@ -354,14 +354,18 @@ class BCreateGraph extends BGraph {
                                         $i = -1;                         // Counter of number of jobs of one cliente. SP: Contador del nmero de jobs totales de un cliente.
                                         $i2 = 0;                         // Counter of number of keys of array. SP: Contador del nmero de valores del array.
                                         
+                                        if ($DB_bacula->driver == "mysql") {
                                         $res = $DB_bacula->link->query("select Name from Job where UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-$this->elapsed  group by Name order by Name desc")
                                                 or die ("classes.inc: Error at query: 7");
-                                        if ($DB_bacula->driver == "mysql")
                                                 $resdata = $DB_bacula->link->query("select date_format(EndTime,\"%Y-%m-%d\") from Job where UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-$this->elapsed  group by date_format(EndTime, \"%Y-%m-%d\") order by EndTime")
                                                         or die ("classes.inc: Error at query: 8");
-                                        else if ($DB_bacula->driver == "pgsql")
-                                                $resdata = $DB_bacula->link->query("select date_format(EndTime,'%Y-%m-%d') from Job where UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-$this->elapsed  group by EndTime order by EndTime")                                                   
+                                       }
+                                        else if ($DB_bacula->driver == "pgsql") {
+                                               $res = $DB_bacula->link->query("select Name from Job where EndTime > now()) - $this->elapsed  group by Name order by Name desc")
+                                                       or die ("classes.inc: Error at query: 8");
+                                                $resdata = $DB_bacula->link->query("select date_format(EndTime,\"%Y-%m-%d\") from Job where EndTime > NOW() - $this->elapsed  group by date_format(EndTime,\"%Y-%m-%d\") order by EndTime")
                                                         or die ("classes.inc: Error at query: 9");
+                                       }
                                         
                                         while ( $tmpdata = $res->fetchRow() )
                                                 array_push($this->clientes,$tmpdata[0]);
index e6bce4b619d642cae486b49dec04db881636d8ac..78c527309aebfacff064f0ec2c7ed063f0f9c492 100644 (file)
@@ -38,7 +38,11 @@ $client = $dbSql->link->query("select count(*) from Client")
         or die ("Error query: 1");
 $totalfiles = $dbSql->link->query("select count(FilenameId) from Filename")
         or die ("Error query: 2");
-$last24bytes = $dbSql->link->query("select sum(JobBytes),count(*) from Job where Endtime <= NOW() and UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-86400")
+if ( $dbSql->driver == "mysql")
+  $last24bytes = $dbSql->link->query("select sum(JobBytes),count(*) from Job where Endtime <= NOW() and UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-86400")
+        or die ("Error query: 3");
+if ( $dbSql->driver == "pgsql")
+  $last24bytes = $dbSql->link->query("select sum(JobBytes),count(*) from Job where Endtime <= NOW() and EndTime > NOW() - 86400 * interval '1 second'")
         or die ("Error query: 3");
 $bytes_stored =& $dbSql->link->getOne("select SUM(VolBytes) from Media")
         or die ("Error query: 4");
@@ -51,7 +55,10 @@ $smarty->assign('clientes_totales',$tmp[0]);
 
 $tmp = $last24bytes->fetchRow();
 if ( empty($tmp[0]) ) {                                                                                                                 // No data for last 24, search last 48
-        $last24bytes = $dbSql->link->query("select sum(JobBytes) from Job where Endtime <= NOW() and UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-172800" );
+        if ( $dbSql->driver == "mysql" )
+          $last24bytes = $dbSql->link->query("select sum(JobBytes) from Job where Endtime <= NOW() and UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-172800" );
+        if ( $dbSql->driver == "pgsql")
+          $last24bytes = $dbSql->link->query("select sum(JobBytes) from Job where Endtime <= NOW() and EndTime > NOW()-172800" );
         $smarty->assign('when',"yesterday");
 }
 $smarty->assign('bytes_totales',$tmp[0]);
@@ -83,8 +90,12 @@ $smarty->assign('volumes',$volumes);
 // last_run_report.tpl
 if ($mode == "Lite" && $_GET['Full_popup'] != "yes") {
         $tmp = array();
-        $status = $dbSql->link->query("select JobId,Name,EndTime,JobStatus from Job where EndTime <= NOW() and UNIX_TIMESTAMP(EndTime) >UNIX_TIMESTAMP(NOW())-86400 and JobStatus!='T'" )               
-                or die ("Error: query at row 85");
+        if ( $dbSql->driver == "mysql" )
+          $status = $dbSql->link->query("select JobId,Name,EndTime,JobStatus from Job where EndTime <= NOW() and UNIX_TIMESTAMP(EndTime) >UNIX_TIMESTAMP(NOW())-86400 and JobStatus!='T'" )               
+                or die ("Error: query at row 95");
+        if ( $dbSql->driver == "pgsql" )
+          $status = $dbSql->link->query("select JobId,Name,EndTime,JobStatus from Job where EndTime <= NOW() and EndTime >NOW() - 86400 * interval '1 second' and JobStatus!= 'T'")
+                or die ( "Error: query at row 98" );
         $smarty->assign('status', $status->numRows());
         if ( $status->numRows() ) {
                 while ( $res = $status->fetchRow() )
@@ -94,8 +105,12 @@ if ($mode == "Lite" && $_GET['Full_popup'] != "yes") {
         $status->free();
         
         // Total Elapsed Time. Only for single Job.
-        $ret = $dbSql->link->query("select UNIX_TIMESTAMP(EndTime)-UNIX_TIMESTAMP(StartTime) as elapsed from Job where EndTime <= NOW() and UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-84600")
-                or die ("Error at row 96");
+        if ( $dbSql->driver == "mysql" )
+          $ret = $dbSql->link->query("select UNIX_TIMESTAMP(EndTime)-UNIX_TIMESTAMP(StartTime) as elapsed from Job where EndTime <= NOW() and UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-84600")
+                or die ("Error at row 110");
+        if ( $dbSql->driver == "pgsql" )
+          $ret = $dbSql->link->query("select EndTime - StartTime as elapsed from Job where EndTime <= NOW() and EndTime > NOW() - 84600 * interval '1 second'")
+                or die ("Error at row 113");
         while ( $res = $ret->fetchRow() ) {
                 if ( $TotalElapsed < 1000000000 )                                                                               // Temporal "workaround" ;) Fix later
                         $TotalElapsed += $res[0];
@@ -115,9 +130,12 @@ else if ($mode == "Full" || $_GET['Full_popup'] == "yes" ){
                                 LEFT JOIN Pool ON Job.PoolId=Pool.PoolId where EndTime <= NOW() and UNIX_TIMESTAMP(EndTime) >UNIX_TIMESTAMP(NOW())-86400 
                                 order by elapsed ";                                                                                                     // Full report array
         if ( $dbSql->driver == "pgsql")
-                $query = "select Job.EndTime::timestamp-Job.StartTime::timestamp as elapsed,Job.Name,Job.StartTime,Job.EndTime,Job.Level,Pool.Name,Job.JobStatus from Job LEFT JOIN Pool ON Job.PoolId=Pool.PoolId where EndTime <= NOW() and UNIX_TIMESTAMP(EndTime) >UNIX_TIMESTAMP(NOW())-86400 order by elapsed ";
+                $query = "select Job.EndTime - Job.StartTime )
+                                as elapsed,Job.Name,Job.StartTime,Job.EndTime,Job.Level,Pool.Name,Job.JobStatus from Job
+                                LEFT JOIN Pool ON Job.PoolId=Pool.PoolId where EndTime <= NOW() and EndTime > NOW() - 86400 * interval '1 second'
+                                order by elapsed ";
         $status = $dbSql->link->query($query)
-                or die ("Error: query at row 118");
+                or die ("Error: query at row 138");
         while ( $tmp = $status->fetchRow() ) {
                 $tdate = explode (":",$tmp[0]);
                 if ( $tdate[0] > 300000 )                                                                                               // Temporal "workaround" ;) Fix later