Revision: 1896
          http://mrbs.svn.sourceforge.net/mrbs/?rev=1896&view=rev
Author:   cimorrison
Date:     2011-08-27 17:16:01 +0000 (Sat, 27 Aug 2011)
Log Message:
-----------
Restructured code

Modified Paths:
--------------
    mrbs/branches/datatables/web/report.php

Modified: mrbs/branches/datatables/web/report.php
===================================================================
--- mrbs/branches/datatables/web/report.php     2011-08-27 16:55:56 UTC (rev 
1895)
+++ mrbs/branches/datatables/web/report.php     2011-08-27 17:16:01 UTC (rev 
1896)
@@ -53,29 +53,12 @@
   return $string;
 }
 
-// Add $value to a CSV row, escaping the value as well
-// Return the new row
-function csv_row_add_value($row, $value)
-{
-  global $csv_col_sep;
-  
-  // if it's not the first entry add a column separator
-  if (!empty($row))
-  {
-    $row .= $csv_col_sep;
-  }
-  $row .= '"';
-  $row .= escape($value);
-  $row .= '"';
-  return $row;
-}
 
-
 // Output the first row (header row) for CSV reports
 function report_header()
 {
   global $output_as_csv, $output_as_html, $ajax;
-  global $csv_row_sep;
+  global $csv_row_sep, $csv_col_sep;
   global $custom_fields, $tbl_entry;
   global $approval_somewhere, $confirmation_somewhere;
 
@@ -117,7 +100,7 @@
   
   if ($output_as_csv)
   {
-    // Remove any HTML entities from the values
+    // Remove any HTML entities from the values, and escape the strings
     $n_values = count($values);
     $charset = get_charset();
     // Find out what the non-breaking space is in this character set
@@ -129,15 +112,13 @@
       $values[$i] = trim($values[$i], $nbsp);
       // And do an ordinary trim
       $values[$i] = trim($values[$i]);
+      $values[$i] = escape($values[$i]);
     }
   
     // Now turn the array of values into a CSV row
-    $line = "";  // initialise the row
-    foreach ($values as $v)
-    {
-      $line = csv_row_add_value($line, $v);
-    }
-    $line .= $csv_row_sep;  // terminate the row
+    $line = '"';
+    $line .= implode("\"$csv_col_sep\"", $values);
+    $line .= '"' . $csv_row_sep;
   
     // Output the row
     echo $line;
@@ -338,7 +319,7 @@
   }
 
   // Last updated:
-  $values[] = time_date_string($row['last_updated']);
+  $values[] = escape(time_date_string($row['last_updated']));
 
   if ($ajax)
   {

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to