Show
Ignore:
Timestamp:
07/21/07 02:40:43 (5 years ago)
Author:
benoitg
Message:
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/wifidog/classes/StatisticReport/AnonymisedDataExport.php

    r1249 r1262  
    9999        else 
    100100        { 
     101            header('Content-Type: application/octet-stream'); 
     102            header('Content-Disposition: inline; filename="anonymised_data.sql"'); 
     103            header("Content-Transfer-Encoding: binary"); 
     104 
    101105            $html  .= <<<EOT 
    102106            CREATE TABLE connections_anonymised 
     
    113117EOT; 
    114118$html .= "\n"; 
     119            echo $html; 
    115120            $distinguish_users_by = $this->stats->getDistinguishUsersBy(); 
    116121 
     
    118123 
    119124            $sql = "$candidate_connections_sql ORDER BY timestamp_in DESC"; 
    120             $db->execSql($sql, $rows, false); 
    121             foreach ($rows as $row) 
    122             { 
    123                 $keys = null; 
    124                 $values = null; 
    125                 $first = true; 
    126                 foreach ($row as $key=>$value) 
     125            $db->execSqlRaw($sql, $resultHandle, false); 
     126            if($resultHandle) { 
     127                while($row=pg_fetch_array($resultHandle,null,PGSQL_ASSOC)) 
    127128                { 
    128                     if($key == 'user_id' || $key == 'node_id' || $key == 'conn_id' || $key == 'user_mac' ) { 
    129                         $value = "'".$this->getNonRepeatableHash($value)."'"; 
     129 
     130                    $keys = null; 
     131                    $values = null; 
     132                    $first = true; 
     133                    foreach ($row as $key=>$value) 
     134                    { 
     135                        if($key == 'user_id' || $key == 'node_id' || $key == 'conn_id' || $key == 'user_mac' ) { 
     136                            $value = "'".$this->getNonRepeatableHash($value)."'"; 
     137                        } 
     138                        else if ($key == 'timestamp_out' && empty ($value)) { 
     139                            $value = 'NULL'; 
     140                        } 
     141                        else { 
     142                            $value = "'$value'"; 
     143                        } 
     144                        if(!$first) { 
     145                            $keys .= ', '; 
     146                            $values .= ', '; 
     147                        } 
     148                        else { 
     149                            $first = false; 
     150                        } 
     151                        $keys .= $key; 
     152                        $values .= $value; 
    130153                    } 
    131                     else if ($key == 'timestamp_out' && empty ($value)) { 
    132                         $value = 'NULL'; 
    133                     } 
    134                     else { 
    135                         $value = "'$value'"; 
    136                     } 
    137                     if(!$first) { 
    138                         $keys .= ', '; 
    139                         $values .= ', '; 
    140                     } 
    141                     else { 
    142                         $first = false; 
    143                     } 
    144                     $keys .= $key; 
    145                     $values .= $value; 
     154                    //fwrite($temp, "INSERT INTO connections_anonymised ($keys) VALUES ($values);\n"); 
     155                    echo "INSERT INTO connections_anonymised ($keys) VALUES ($values);\n"; 
    146156                } 
    147                 $html .= "INSERT INTO connections_anonymised ($keys) VALUES ($values);\n"; 
    148                 //$html .= "<br/>\n"; 
    149157            } 
     158            exit; 
    150159        } 
    151         header('Content-Type: text/plain'); 
    152         header('Content-Disposition: inline; filename="anonymised_data.sql"'); 
    153         header("Content-Transfer-Encoding: binary"); 
    154         echo $html; 
    155         exit; 
     160        return $html; 
    156161    } 
    157162