Ignore:
Timestamp:
Sep 5, 2012, 4:15:54 PM (12 years ago)
Author:
grum
Message:

version 0.1.0b

. Fix install bugs
. Manage anonymous directories
. Manage CSV export options settings
. Fix IPadress<=>country association bug & improve join performances
. Fix bug on IP filter
. Improve performances for history consult

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/EStat/estat_ajax_export.php

    r17737 r17758  
    238238
    239239      // prepare an EStat_IdList to buid a list of unique Id
    240       $idList=new EStat_IdList(array('catId', 'imageId', 'tagsId', 'userId', 'IPadress'));
     240      $idList=new EStat_IdList(array('catId', 'imageId', 'tagsId', 'userId'));
    241241      // $idAssoc will get the label associated to the id
    242242      $idAssoc=array(
     
    244244        'imageId'=>array(),
    245245        'tagsId'=>array(),
    246         'userId'=>array(),
    247         'IPadress'=>array()
     246        'userId'=>array()
    248247      );
    249248
     
    256255            'imageId' => $row['imageId'],
    257256            'tagsId' => $row['tagsId'],
    258             'userId' => $row['userId'],
    259             'IPadress' => $row['IPadress']
     257            'userId' => $row['userId']
    260258          )
    261259        );
     
    274272      if(count($idList->getItems('userId')) > 0)
    275273        $this->prepareIdList($idAssoc, 'userId', "SELECT id, username AS name FROM ".USERS_TABLE." WHERE id IN (".implode(',', $idList->getItems('userId')).") ORDER BY id;");
    276 
    277       // for reverse DNS
    278       if($this->config['logs.ipCountry']=='y')
    279         $this->getIpInfos($idAssoc, $idList->getItems('IPadress'));
    280274
    281275      $data=array();
     
    283277      foreach($result as $row)
    284278      {
    285         $ipInfo=$this->getId($idAssoc, 'IPadress', $row['IPadress'], '?');
    286 
    287279        $userAgentNfo=GPCUserAgent::getProperties(
    288280            array(
     
    298290        if($userAgentNfo[UA_DATA_OS_NAME]=='Unknown') $userAgentNfo[UA_DATA_OS_NAME]='ua_Unknown';
    299291
    300         $country=l10n('estat_country_'.strtoupper($ipInfo['country']));
     292        $country=l10n('estat_country_'.strtoupper($row['country']));
    301293        if(isset($lang[$country]))
    302294        {
     
    314306          'UserId' => $row['userId'],
    315307          'UserName' => $this->getId($idAssoc, 'userId', $row['userId'], '?', 'name'),
    316           'countryId' => $ipInfo['country'],
     308          'countryId' => $row['country'],
    317309          'country' => $country,
    318310          'catId' => $row['catId'],
     
    345337          $export->setOptions(
    346338              array(
    347                 'separator' => ';',
    348                 'decimalDot' => ',',
    349                 'useQuotes' => true,
    350                 'lineFeed' => 'unix'
     339                'separator' => $this->config['export.csv.separator'],
     340                'decimalDot' => $this->config['export.csv.decimalDot'],
     341                'useQuotes' => ($this->config['export.csv.useQuotes']=='y')?true:false,
     342                'lineFeed' => $this->config['export.csv.lineFeed'],
    351343              )
    352344            );
     
    386378              array(
    387379                'sheetName' => l10n('estat_history'),
    388                 'fileTitle' => '',
     380                'fileTitle' => $this->config['export.ods.fileTitle'],
    389381                'fileSubject' => sprintf(l10n('estat_fileODSSubject'), l10n('estat_history')),
    390                 'keywords' => '',
     382                'keywords' => $this->config['export.ods.keywords'],
    391383                'comments' => sprintf(l10n('estat_fileODSComments_1'), date('Y-m-d@H:i:s'), ESTAT_VERSION, PHPWG_VERSION)
    392384              )
     
    460452      }
    461453      $export->setFileName($name.$extension);
    462       $export->setFileDir(GPCCore::getPiwigoSystemPath().'/'.PWG_LOCAL_DIR.self::EXPORT_DIRECTORY);
     454      $export->setFileDir($this->fileExportDir);
    463455
    464456      if($export->write($data))
    465457      {
    466         $file=GPCCore::getPiwigoSystemPath().'/'.PWG_LOCAL_DIR.self::EXPORT_DIRECTORY.$export->getFileName();
     458        $file=$this->fileExportDir.$export->getFileName();
    467459
    468460        if($compression!='none')
     
    623615          $export->setOptions(
    624616              array(
    625                 'separator' => ';',
    626                 'decimalDot' => ',',
    627                 'useQuotes' => true,
    628                 'lineFeed' => 'unix'
     617                'separator' => $this->config['export.csv.separator'],
     618                'decimalDot' => $this->config['export.csv.decimalDot'],
     619                'useQuotes' => ($this->config['export.csv.useQuotes']=='y')?true:false,
     620                'lineFeed' => $this->config['export.csv.lineFeed'],
    629621              )
    630622            );
     
    646638              array(
    647639                'sheetName' => l10n('estat_ipAdress'),
    648                 'fileTitle' => '',
     640                'fileTitle' => $this->config['export.ods.fileTitle'],
    649641                'fileSubject' => sprintf(l10n('estat_fileODSSubject'), l10n('estat_by_ip')),
    650                 'keywords' => '',
     642                'keywords' => $this->config['export.ods.keywords'],
    651643                'comments' => sprintf(l10n('estat_fileODSComments_1'), date('Y-m-d@H:i:s'), ESTAT_VERSION, PHPWG_VERSION)
    652644              )
     
    668660          $export->setOptions(
    669661              array(
    670                 'tableName' => 'history'
     662                'tableName' => 'ipAdress'
    671663              )
    672664            );
     
    684676      }
    685677      $export->setFileName($name.$extension);
    686       $export->setFileDir(GPCCore::getPiwigoSystemPath().'/'.PWG_LOCAL_DIR.self::EXPORT_DIRECTORY);
     678      $export->setFileDir($this->fileExportDir);
    687679
    688680      if($export->write($data))
    689681      {
    690         $file=GPCCore::getPiwigoSystemPath().'/'.PWG_LOCAL_DIR.self::EXPORT_DIRECTORY.$export->getFileName();
     682        $file=$this->fileExportDir.$export->getFileName();
    691683
    692684        if($compression!='none')
     
    852844          $export->setOptions(
    853845              array(
    854                 'separator' => ';',
    855                 'decimalDot' => ',',
    856                 'useQuotes' => true,
    857                 'lineFeed' => 'unix'
     846                'separator' => $this->config['export.csv.separator'],
     847                'decimalDot' => $this->config['export.csv.decimalDot'],
     848                'useQuotes' => ($this->config['export.csv.useQuotes']=='y')?true:false,
     849                'lineFeed' => $this->config['export.csv.lineFeed'],
    858850              )
    859851            );
     
    873865          $export->setOptions(
    874866              array(
    875                 'sheetName' => l10n('estat_ipAdress'),
    876                 'fileTitle' => '',
    877                 'fileSubject' => sprintf(l10n('estat_fileODSSubject'), l10n('estat_by_ip')),
    878                 'keywords' => '',
     867                'sheetName' => l10n('estat_category'),
     868                'fileTitle' => $this->config['export.ods.fileTitle'],
     869                'fileSubject' => sprintf(l10n('estat_fileODSSubject'), l10n('estat_by_category')),
     870                'keywords' => $this->config['export.ods.keywords'],
    879871                'comments' => sprintf(l10n('estat_fileODSComments_1'), date('Y-m-d@H:i:s'), ESTAT_VERSION, PHPWG_VERSION)
    880872              )
     
    895887          $export->setOptions(
    896888              array(
    897                 'tableName' => 'history'
     889                'tableName' => 'album'
    898890              )
    899891            );
     
    910902      }
    911903      $export->setFileName($name.$extension);
    912       $export->setFileDir(GPCCore::getPiwigoSystemPath().'/'.PWG_LOCAL_DIR.self::EXPORT_DIRECTORY);
     904      $export->setFileDir($this->fileExportDir);
    913905
    914906      if($export->write($data))
    915907      {
    916         $file=GPCCore::getPiwigoSystemPath().'/'.PWG_LOCAL_DIR.self::EXPORT_DIRECTORY.$export->getFileName();
     908        $file=$this->fileExportDir.$export->getFileName();
    917909
    918910        if($compression!='none')
     
    10901082          $export->setOptions(
    10911083              array(
    1092                 'separator' => ';',
    1093                 'decimalDot' => ',',
    1094                 'useQuotes' => true,
    1095                 'lineFeed' => 'unix'
     1084                'separator' => $this->config['export.csv.separator'],
     1085                'decimalDot' => $this->config['export.csv.decimalDot'],
     1086                'useQuotes' => ($this->config['export.csv.useQuotes']=='y')?true:false,
     1087                'lineFeed' => $this->config['export.csv.lineFeed'],
    10961088              )
    10971089            );
     
    11131105          $export->setOptions(
    11141106              array(
    1115                 'sheetName' => l10n('estat_ipAdress'),
    1116                 'fileTitle' => '',
    1117                 'fileSubject' => sprintf(l10n('estat_fileODSSubject'), l10n('estat_by_ip')),
    1118                 'keywords' => '',
     1107                'sheetName' => l10n('estat_image'),
     1108                'fileTitle' => $this->config['export.ods.fileTitle'],
     1109                'fileSubject' => sprintf(l10n('estat_fileODSSubject'), l10n('estat_by_image')),
     1110                'keywords' => $this->config['export.ods.keywords'],
    11191111                'comments' => sprintf(l10n('estat_fileODSComments_1'), date('Y-m-d@H:i:s'), ESTAT_VERSION, PHPWG_VERSION)
    11201112              )
     
    11371129          $export->setOptions(
    11381130              array(
    1139                 'tableName' => 'history'
     1131                'tableName' => 'image'
    11401132              )
    11411133            );
     
    11541146      }
    11551147      $export->setFileName($name.$extension);
    1156       $export->setFileDir(GPCCore::getPiwigoSystemPath().'/'.PWG_LOCAL_DIR.self::EXPORT_DIRECTORY);
     1148      $export->setFileDir($this->fileExportDir);
    11571149
    11581150      if($export->write($data))
    11591151      {
    1160         $file=GPCCore::getPiwigoSystemPath().'/'.PWG_LOCAL_DIR.self::EXPORT_DIRECTORY.$export->getFileName();
     1152        $file=$this->fileExportDir.$export->getFileName();
    11611153
    11621154        if($compression!='none')
     
    11851177    private function ajax_estat_export_admin_loadFile($name, $deleteFile=true)
    11861178    {
    1187       $file=GPCCore::getPiwigoSystemPath().'/'.PWG_LOCAL_DIR.self::EXPORT_DIRECTORY.$name;
     1179      $file=$this->fileExportDir.$name;
    11881180      if(!file_exists($file))
    11891181        do_error(404, "Requested file not readable - $name");
Note: See TracChangeset for help on using the changeset viewer.