Changeset 17758 for extensions/EStat
- Timestamp:
- Sep 5, 2012, 4:15:54 PM (12 years ago)
- Location:
- extensions/EStat
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/EStat/admin.php
r17737 r17758 27 27 $config=Array(); 28 28 GPCCore::loadConfig('estat', $config); 29 30 29 31 30 if($config['installed']!=ESTAT_VERSION2) -
extensions/EStat/admin/estat_admin.tpl
r17737 r17758 5 5 var translateString={ 6 6 {/literal} 7 dateTime:'{"estat_datetime"|@translate}', 8 ip_user:'{"estat_ip_user"|@translate}', 9 ipAdress:'{"estat_ipAdress"|@translate}', 10 country:'{"estat_country"|@translate}', 11 album:'{"estat_category"|@translate}', 12 image:'{"estat_image"|@translate}', 13 tags:'{"estat_tags"|@translate}', 14 section:'{"estat_section"|@translate}', 15 browser:'{"estat_browser"|@translate}', 16 os:'{"estat_os"|@translate}', 17 type:'{"estat_type"|@translate}', 18 engine:'{"estat_engine"|@translate}', 19 item_nb:'{"estat_item_nb"|@translate}', 20 items_nb:'{"estat_items_nb"|@translate}', 21 events:'{"estat_events"|@translate}', 22 ok:'{"estat_ok"|@translate}', 23 cancel:'{"estat_cancel"|@translate}', 24 eraseFilter:'{"estat_eraseFilter"|@translate}', 25 sortBy:'{"estat_sortBy"|@translate}', 26 ip_nb:'{"estat_ip_nb"|@translate}', 27 ips_nb:'{"estat_ips_nb"|@translate}', 28 category_nb:'{"estat_category_nb"|@translate}', 29 categories_nb:'{"estat_categories_nb"|@translate}', 30 image_nb:'{"estat_image_nb"|@translate}', 31 images_nb:'{"estat_images_nb"|@translate}', 32 dataExport:'{"estat_dataExport"|@translate}', 7 dateTime:"{'estat_datetime'|@translate}", 8 ip_user:"{'estat_ip_user'|@translate}", 9 ipAdress:"{'estat_ipAdress'|@translate}", 10 country:"{'estat_country'|@translate}", 11 album:"{'estat_category'|@translate}", 12 image:"{'estat_image'|@translate}", 13 tags:"{'estat_tags'|@translate}", 14 section:"{'estat_section'|@translate}", 15 browser:"{'estat_browser'|@translate}", 16 os:"{'estat_os'|@translate}", 17 type:"{'estat_type'|@translate}", 18 engine:"{'estat_engine'|@translate}", 19 item_nb:"{'estat_item_nb'|@translate}", 20 items_nb:"{'estat_items_nb'|@translate}", 21 events:"{'estat_events'|@translate}", 22 ok:"{'estat_ok'|@translate}", 23 cancel:"{'estat_cancel'|@translate}", 24 eraseFilter:"{'estat_eraseFilter'|@translate}", 25 sortBy:"{'estat_sortBy'|@translate}", 26 dataExport:"{'estat_dataExport'|@translate}", 33 27 34 allYear: '{"estat_allYear"|@translate}',35 year: '{"estat_year"|@translate}',36 viewedPages: '{"estat_viewedPages"|@translate}',37 viewedAlbums: '{"estat_viewedAlbums"|@translate}',38 viewedImages: '{"estat_viewedImages"|@translate}',39 uniqueIP: '{"estat_uniqueIP"|@translate}',40 visits: '{"estat_visits"|@translate}',41 period: '{"estat_period"|@translate}',28 allYear:"{'estat_allYear'|@translate}", 29 year:"{'estat_year'|@translate}", 30 viewedPages:"{'estat_viewedPages'|@translate}", 31 viewedAlbums:"{'estat_viewedAlbums'|@translate}", 32 viewedImages:"{'estat_viewedImages'|@translate}", 33 uniqueIP:"{'estat_uniqueIP'|@translate}", 34 visits:"{'estat_visits'|@translate}", 35 period:"{'estat_period'|@translate}", 42 36 43 fileFormatCSV: '{"estat_fileFormatCSV"|@translate}',44 fileFormatODS: '{"estat_fileFormatODS"|@translate}',45 fileFormatSQLite: '{"estat_fileFormatSQLite"|@translate}',37 fileFormatCSV:"{'estat_fileFormatCSV'|@translate}", 38 fileFormatODS:"{'estat_fileFormatODS'|@translate}", 39 fileFormatSQLite:"{'estat_fileFormatSQLite'|@translate}", 46 40 47 fileCompressionNone: '{"estat_fileCompressionNone"|@translate}',48 fileCompressionZIP: '{"estat_fileCompressionZIP"|@translate}',49 fileCompressionGZ: '{"estat_fileCompressionGZ"|@translate}',50 fileCompressionBZ2: '{"estat_fileCompressionBZ2"|@translate}',41 fileCompressionNone:"{'estat_fileCompressionNone'|@translate}", 42 fileCompressionZIP:"{'estat_fileCompressionZIP'|@translate}", 43 fileCompressionGZ:"{'estat_fileCompressionGZ'|@translate}", 44 fileCompressionBZ2:"{'estat_fileCompressionBZ2'|@translate}", 51 45 52 downloadError: '{"estat_downloadError"|@translate}',53 waitForDownload: '{"estat_waitForDownload"|@translate}',46 downloadError:"{'estat_downloadError'|@translate}", 47 waitForDownload:"{'estat_waitForDownload'|@translate}", 54 48 55 total: '{"estat_total"|@translate}',56 ua_Mobile: '{"ua_Mobile"|@translate}',57 ua_Computer: '{"ua_Computer"|@translate}',58 ua_Console: '{"ua_Console"|@translate}',59 ua_Unknown: '{"ua_Unknown"|@translate}',60 ua_Crawler: '{"ua_Crawler"|@translate}',61 ua_Other: '{"ua_Other"|@translate}',49 total:"{'estat_total'|@translate}", 50 ua_Mobile:"{'ua_Mobile'|@translate}", 51 ua_Computer:"{'ua_Computer'|@translate}", 52 ua_Console:"{'ua_Console'|@translate}", 53 ua_Unknown:"{'ua_Unknown'|@translate}", 54 ua_Crawler:"{'ua_Crawler'|@translate}", 55 ua_Other:"{'ua_Other'|@translate}", 62 56 {literal} 63 57 64 58 filter:{ 65 59 {/literal} 66 dateTime: '{"estat_datetime"|@translate}',67 ipAdress: '{"estat_ipAdress"|@translate}',68 country: '{"estat_country"|@translate}',69 section: '{"estat_section"|@translate}',70 browser: '{"estat_browser"|@translate}',71 os: '{"estat_os"|@translate}',72 type: '{"estat_type"|@translate}',73 engine: '{"estat_engine"|@translate}'60 dateTime:"{'estat_datetime'|@translate}", 61 ipAdress:"{'estat_ipAdress'|@translate}", 62 country:"{'estat_country'|@translate}", 63 section:"{'estat_section'|@translate}", 64 browser:"{'estat_browser'|@translate}", 65 os:"{'estat_os'|@translate}", 66 type:"{'estat_type'|@translate}", 67 engine:"{'estat_engine'|@translate}" 74 68 {literal} 75 69 } … … 78 72 inputFilterBoxLang={ 79 73 {/literal} 80 'Operator':'{"filter_operator"|@translate}', 81 'Value':'{"filter_value"|@translate}', 82 'MinValue':'{"filter_minValue"|@translate}', 83 'MaxValue':'{"filter_maxValue"|@translate}', 84 '>':'{"filter_gt"|@translate}', 85 '<':'{"filter_lt"|@translate}', 86 '>=':'{"filter_ge"|@translate}', 87 '<=':'{"filter_le"|@translate}', 88 '=':'{"filter_equal"|@translate}', 89 '!=':'{"filter_notEqual"|@translate}', 90 'between':'{"filter_between"|@translate}', 91 'and':'{"filter_and"|@translate}', 92 'like':'{"filter_like"|@translate}', 93 'not like':'{"filter_notLike"|@translate}', 74 'Operator':"{'filter_operator'|@translate}", 75 'Value':"{'filter_value'|@translate}", 76 'MinValue':"{'filter_minValue'|@translate}", 77 'MaxValue':"{'filter_maxValue'|@translate}", 78 '>':"{'filter_gt'|@translate}", 79 '<':"{'filter_lt'|@translate}", 80 '>=':"{'filter_ge'|@translate}", 81 '<=':"{'filter_le'|@translate}", 82 '=':"{'filter_equal'|@translate}", 83 '!=':"{'filter_notEqual'|@translate}", 84 'between':"{'filter_between'|@translate}", 85 'not between':"{'filter_notbetween'|@translate}", 86 'and':"{'filter_and'|@translate}", 87 'like':"{'filter_like'|@translate}", 88 'not like':"{'filter_notLike'|@translate}", 94 89 'invalidParam':"{'filter_invalid'|@translate}" 95 90 {literal} … … 97 92 inputExportBoxLang={ 98 93 {/literal} 99 'export': '{"export_dialogTitle"|@translate}',100 'name': '{"export_Name"|@translate}',101 'format': '{"export_Format"|@translate}',102 'compression': '{"export_Compression"|@translate}'94 'export':"{'export_dialogTitle'|@translate}", 95 'name':"{'export_Name'|@translate}", 96 'format':"{'export_Format'|@translate}", 97 'compression':"{'export_Compression'|@translate}" 103 98 {literal} 104 99 }; -
extensions/EStat/estat_ajax.php
r17737 r17758 475 475 476 476 $gStatFile=new StatDBGlobal($this->fileStatDir, self::FILE_GLOBAL); 477 $gStatFile->setIpCountryFile( ESTAT_PATH.'data/ipCountry.db');477 $gStatFile->setIpCountryFile($this->fileStatDir.'/'.self::FILE_COUNTRY.'.db', true); 478 478 $gStatFile->open(ASDF_OPEN_WRITE); 479 479 if($gStatFile->getInfoProperty('log', 'startImport')==null) … … 575 575 576 576 // prepare an EStat_IdList to buid a list of unique Id 577 $idList=new EStat_IdList(array('catId', 'imageId', 'tagsId', 'userId' , 'IPadress'));577 $idList=new EStat_IdList(array('catId', 'imageId', 'tagsId', 'userId')); 578 578 // $idAssoc will get the label associated to the id 579 579 $idAssoc=array( … … 581 581 'imageId'=>array(), 582 582 'tagsId'=>array(), 583 'userId'=>array(), 584 'IPadress'=>array() 583 'userId'=>array() 585 584 ); 586 585 … … 612 611 $this->prepareIdList($idAssoc, 'userId', "SELECT id, username AS name FROM ".USERS_TABLE." WHERE id IN (".implode(',', $idList->getItems('userId')).") ORDER BY id;"); 613 612 614 // for reverse DNS615 if($this->config['logs.ipCountry']=='y')616 $this->getIpInfos($idAssoc, $idList->getItems('IPadress'));617 618 613 // complete the data 619 614 foreach($returned['rows'] as $key=>$row) … … 636 631 'date' => date('Y-m-d H:i:s', $row['date']), 637 632 'IpUserId' => ($row['userId']==2)?$row['IPadress']:$this->getId($idAssoc, 'userId', $row['userId'], $row['IPadress'], 'name'), 638 //'country' => $row['country'],633 'country' => $row['country'], 639 634 'catId' => GPCCore::getUserLanguageDesc($this->getId($idAssoc, 'catId', $row['catId'], ($row['catId']==0)?'-':'?')), 640 635 'imageId' => $this->getId($idAssoc, 'imageId', $row['imageId'], ($row['imageId']==0)?'-':'?', 'name'), … … 702 697 if($row['userId']==2) 703 698 { 704 $ipInfo=$this->getId($idAssoc, 'IPadress', $tmp['IpUserId'], '?');705 699 if($this->config['logs.reverseDNS']=='y') 706 700 {/* … … 716 710 } 717 711 718 if($ ipInfo['country']!='--' and $ipInfo['country']!='XA')712 if($row['country']!='--' and $row['country']!='XA') 719 713 { 720 $tmp['IpUserId'].='<span class="geoip">[<a href="http://www.geoiptool.com/fr/?IP='.$tmp['IpUserId'].'">'.$ ipInfo['country'].'</a>]</span>';714 $tmp['IpUserId'].='<span class="geoip">[<a href="http://www.geoiptool.com/fr/?IP='.$tmp['IpUserId'].'">'.$row['country'].'</a>]</span>'; 721 715 } 722 716 else -
extensions/EStat/estat_ajax_export.php
r17737 r17758 238 238 239 239 // 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')); 241 241 // $idAssoc will get the label associated to the id 242 242 $idAssoc=array( … … 244 244 'imageId'=>array(), 245 245 'tagsId'=>array(), 246 'userId'=>array(), 247 'IPadress'=>array() 246 'userId'=>array() 248 247 ); 249 248 … … 256 255 'imageId' => $row['imageId'], 257 256 'tagsId' => $row['tagsId'], 258 'userId' => $row['userId'], 259 'IPadress' => $row['IPadress'] 257 'userId' => $row['userId'] 260 258 ) 261 259 ); … … 274 272 if(count($idList->getItems('userId')) > 0) 275 273 $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 DNS278 if($this->config['logs.ipCountry']=='y')279 $this->getIpInfos($idAssoc, $idList->getItems('IPadress'));280 274 281 275 $data=array(); … … 283 277 foreach($result as $row) 284 278 { 285 $ipInfo=$this->getId($idAssoc, 'IPadress', $row['IPadress'], '?');286 287 279 $userAgentNfo=GPCUserAgent::getProperties( 288 280 array( … … 298 290 if($userAgentNfo[UA_DATA_OS_NAME]=='Unknown') $userAgentNfo[UA_DATA_OS_NAME]='ua_Unknown'; 299 291 300 $country=l10n('estat_country_'.strtoupper($ ipInfo['country']));292 $country=l10n('estat_country_'.strtoupper($row['country'])); 301 293 if(isset($lang[$country])) 302 294 { … … 314 306 'UserId' => $row['userId'], 315 307 'UserName' => $this->getId($idAssoc, 'userId', $row['userId'], '?', 'name'), 316 'countryId' => $ ipInfo['country'],308 'countryId' => $row['country'], 317 309 'country' => $country, 318 310 'catId' => $row['catId'], … … 345 337 $export->setOptions( 346 338 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'], 351 343 ) 352 344 ); … … 386 378 array( 387 379 'sheetName' => l10n('estat_history'), 388 'fileTitle' => '',380 'fileTitle' => $this->config['export.ods.fileTitle'], 389 381 'fileSubject' => sprintf(l10n('estat_fileODSSubject'), l10n('estat_history')), 390 'keywords' => '',382 'keywords' => $this->config['export.ods.keywords'], 391 383 'comments' => sprintf(l10n('estat_fileODSComments_1'), date('Y-m-d@H:i:s'), ESTAT_VERSION, PHPWG_VERSION) 392 384 ) … … 460 452 } 461 453 $export->setFileName($name.$extension); 462 $export->setFileDir( GPCCore::getPiwigoSystemPath().'/'.PWG_LOCAL_DIR.self::EXPORT_DIRECTORY);454 $export->setFileDir($this->fileExportDir); 463 455 464 456 if($export->write($data)) 465 457 { 466 $file= GPCCore::getPiwigoSystemPath().'/'.PWG_LOCAL_DIR.self::EXPORT_DIRECTORY.$export->getFileName();458 $file=$this->fileExportDir.$export->getFileName(); 467 459 468 460 if($compression!='none') … … 623 615 $export->setOptions( 624 616 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'], 629 621 ) 630 622 ); … … 646 638 array( 647 639 'sheetName' => l10n('estat_ipAdress'), 648 'fileTitle' => '',640 'fileTitle' => $this->config['export.ods.fileTitle'], 649 641 'fileSubject' => sprintf(l10n('estat_fileODSSubject'), l10n('estat_by_ip')), 650 'keywords' => '',642 'keywords' => $this->config['export.ods.keywords'], 651 643 'comments' => sprintf(l10n('estat_fileODSComments_1'), date('Y-m-d@H:i:s'), ESTAT_VERSION, PHPWG_VERSION) 652 644 ) … … 668 660 $export->setOptions( 669 661 array( 670 'tableName' => ' history'662 'tableName' => 'ipAdress' 671 663 ) 672 664 ); … … 684 676 } 685 677 $export->setFileName($name.$extension); 686 $export->setFileDir( GPCCore::getPiwigoSystemPath().'/'.PWG_LOCAL_DIR.self::EXPORT_DIRECTORY);678 $export->setFileDir($this->fileExportDir); 687 679 688 680 if($export->write($data)) 689 681 { 690 $file= GPCCore::getPiwigoSystemPath().'/'.PWG_LOCAL_DIR.self::EXPORT_DIRECTORY.$export->getFileName();682 $file=$this->fileExportDir.$export->getFileName(); 691 683 692 684 if($compression!='none') … … 852 844 $export->setOptions( 853 845 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'], 858 850 ) 859 851 ); … … 873 865 $export->setOptions( 874 866 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'], 879 871 'comments' => sprintf(l10n('estat_fileODSComments_1'), date('Y-m-d@H:i:s'), ESTAT_VERSION, PHPWG_VERSION) 880 872 ) … … 895 887 $export->setOptions( 896 888 array( 897 'tableName' => ' history'889 'tableName' => 'album' 898 890 ) 899 891 ); … … 910 902 } 911 903 $export->setFileName($name.$extension); 912 $export->setFileDir( GPCCore::getPiwigoSystemPath().'/'.PWG_LOCAL_DIR.self::EXPORT_DIRECTORY);904 $export->setFileDir($this->fileExportDir); 913 905 914 906 if($export->write($data)) 915 907 { 916 $file= GPCCore::getPiwigoSystemPath().'/'.PWG_LOCAL_DIR.self::EXPORT_DIRECTORY.$export->getFileName();908 $file=$this->fileExportDir.$export->getFileName(); 917 909 918 910 if($compression!='none') … … 1090 1082 $export->setOptions( 1091 1083 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'], 1096 1088 ) 1097 1089 ); … … 1113 1105 $export->setOptions( 1114 1106 array( 1115 'sheetName' => l10n('estat_i pAdress'),1116 'fileTitle' => '',1117 'fileSubject' => sprintf(l10n('estat_fileODSSubject'), l10n('estat_by_i p')),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'], 1119 1111 'comments' => sprintf(l10n('estat_fileODSComments_1'), date('Y-m-d@H:i:s'), ESTAT_VERSION, PHPWG_VERSION) 1120 1112 ) … … 1137 1129 $export->setOptions( 1138 1130 array( 1139 'tableName' => ' history'1131 'tableName' => 'image' 1140 1132 ) 1141 1133 ); … … 1154 1146 } 1155 1147 $export->setFileName($name.$extension); 1156 $export->setFileDir( GPCCore::getPiwigoSystemPath().'/'.PWG_LOCAL_DIR.self::EXPORT_DIRECTORY);1148 $export->setFileDir($this->fileExportDir); 1157 1149 1158 1150 if($export->write($data)) 1159 1151 { 1160 $file= GPCCore::getPiwigoSystemPath().'/'.PWG_LOCAL_DIR.self::EXPORT_DIRECTORY.$export->getFileName();1152 $file=$this->fileExportDir.$export->getFileName(); 1161 1153 1162 1154 if($compression!='none') … … 1185 1177 private function ajax_estat_export_admin_loadFile($name, $deleteFile=true) 1186 1178 { 1187 $file= GPCCore::getPiwigoSystemPath().'/'.PWG_LOCAL_DIR.self::EXPORT_DIRECTORY.$name;1179 $file=$this->fileExportDir.$name; 1188 1180 if(!file_exists($file)) 1189 1181 do_error(404, "Requested file not readable - $name"); -
extensions/EStat/estat_install.class.inc.php
r17737 r17758 26 26 public function install() 27 27 { 28 if(!file_exists($this->fileStatDir)) 29 mkdir($this->fileStatDir, 0755, true); 30 28 $this->checkDirectories(); 31 29 $this->initConfig(); 32 30 $this->loadConfig(); … … 51 49 public function uninstall() 52 50 { 53 //GPCCore::rmDir(dirname( GPCCore::getPiwigoSystemPath().'/'.PWG_LOCAL_DIR.self::DATA_DIRECTORY));51 //GPCCore::rmDir(dirname($this->fileStatDir)); 54 52 $this->deleteConfig(); 55 53 GPCCore::unregister($this->getPluginName()); … … 59 57 public function activate() 60 58 { 59 $this->checkDirectories(); 61 60 $this->initConfig(); 62 61 $this->loadConfig(); … … 70 69 switch($this->config['installed']) 71 70 { 72 case '0 1.00.00':73 //$this->updateFrom_0 10000();71 case '00.01.00b': 72 //$this->updateFrom_000100b(); 74 73 default: 75 74 // nothing to do... … … 90 89 91 90 /** 92 * update from release 1.0.091 * update from release 0.1.0b 93 92 * 94 93 * -- dummy -- 95 94 * 96 95 */ 97 private function updateFrom_0 10000()96 private function updateFrom_000100b() 98 97 { 99 98 return(false); … … 123 122 } 124 123 124 /** 125 * create the local directories & copy index.php files 126 * 127 */ 128 private function checkDirectories() 129 { 130 if(!file_exists($this->fileStatDir)) 131 mkdir($this->fileStatDir, 0755, true); 132 133 if(!file_exists($this->fileExportDir)) 134 mkdir($this->fileExportDir, 0755, true); 135 136 137 if(!file_exists($this->fileStatDir.'/index.php')) 138 copy(ESTAT_PATH.'index.php', $this->fileStatDir.'/index.php'); 139 140 if(!file_exists(dirname($this->fileStatDir).'/index.php')) 141 copy(ESTAT_PATH.'index.php', dirname($this->fileStatDir).'/index.php'); 142 143 if(!file_exists($this->fileExportDir.'/index.php')) 144 copy(ESTAT_PATH.'index.php', $this->fileExportDir.'/index.php'); 145 146 if(!file_exists(dirname($this->fileExportDir).'/index.php')) 147 copy(ESTAT_PATH.'index.php', dirname($this->fileExportDir).'/index.php'); 148 } 149 125 150 } //class 126 151 -
extensions/EStat/estat_root.class.inc.php
r17737 r17758 57 57 58 58 protected $fileStatDir=''; 59 protected $fileExportDir=''; 59 60 60 61 public function __construct($prefixeTable, $filelocation) … … 63 64 $this->setPluginNameFiles("estat"); 64 65 parent::__construct($prefixeTable, $filelocation); 66 $this->loadConfig(); 65 67 $this->section_name=$this->getPluginNameFiles(); 66 $this-> fileStatDir=GPCCore::getPiwigoSystemPath().'/'.PWG_LOCAL_DIR.self::DATA_DIRECTORY;68 $this->setFileStatDir(); 67 69 } 68 70 … … 72 74 public function initConfig() 73 75 { 74 //global $user; 76 global $user; 77 78 $lang=''; 79 if(isset($user['language'])) $lang=$user['language']; 80 81 switch($lang) 82 { 83 case 'fr_FR': 84 $csvExport=array( 85 'export.csv.separator' => ';', 86 'export.csv.decimalDot' => ',' 87 ); 88 break; 89 default: 90 $csvExport=array( 91 'export.csv.separator' => ',', 92 'export.csv.decimalDot' => '.' 93 ); 94 break; 95 } 96 75 97 $this->config=array( 98 'installed' => '00.00.00', 76 99 'plugin.newInstall' => 'y', 77 100 'plugin.active' => 'n', 78 101 'plugin.historyImported' => 'n', 79 102 'plugin.ipCountryBuild' => 'n', 103 'plugin.pathKey' => '', // key to be used to know path where are stored the SQLite files 80 104 81 105 'build.delay' => '+24hours', // delay between 2 consolidation … … 86 110 87 111 'global.itemPerPage' => 250, 112 113 'export.csv.separator' => $csvExport['export.csv.separator'], 114 'export.csv.decimalDot' => $csvExport['export.csv.decimalDot'], 115 'export.csv.useQuotes' => 'y', 116 'export.csv.lineFeed' => 'unix', 117 'export.ods.fileTitle' => '', 118 'export.ods.keywords' => '', 88 119 89 120 'logs.reverseDNS' => 'n', … … 233 264 234 265 266 267 268 269 /** 270 * set the value for $fileStatDir & $fileExportDir 271 * $rootPath is the root path where are stored the SQLite data files 272 * example: (...)/local/plugins/EStat/Data/ 273 * 274 * This path is known is public and can be found by everyone. To forbid the 275 * download of files stored in this directory, a random key is added in the 276 * path 277 * example: (...)/local/plugins/EStat/Data-ABCDEF0123456789/ 278 * 279 * The random key is stored in config file: 280 * . if key is not set, try to find the directory 281 * . if key is set but directory doesn't exist, try to find the directory 282 * . if there's no key and no directory found, the key is created and saved 283 * 284 * the $fileStatDir provide the complete path with the key 285 * the $fileExportDir path gets the same key than $fileStatDir 286 * 287 * @return String: $fileStatDir value 288 */ 289 protected function setFileStatDir() 290 { 291 $rootPath=GPCCore::getPiwigoSystemPath().'/'.PWG_LOCAL_DIR.self::DATA_DIRECTORY; 292 293 $path=substr($rootPath,0,-1).'-'.$this->config['plugin.pathKey']; 294 if(file_exists($path) and $this->config['plugin.pathKey']!='') 295 { 296 $this->fileStatDir=$path; 297 $this->fileExportDir=GPCCore::getPiwigoSystemPath().'/'.PWG_LOCAL_DIR.substr(self::EXPORT_DIRECTORY,0,-1).'-'.$this->config['plugin.pathKey'].'/'; 298 return($this->fileStatDir); 299 } 300 301 // key is empty or directory doesn't exist, try to find the diretory 302 $path=$this->findDirectory(substr($rootPath,0,-1).'-'); 303 if(file_exists($path)) 304 { 305 $this->fileStatDir=$path; 306 $path=explode('-', basename($path)); // /xxx/xxx/xxx/data-abcdef012 => array('data', 'abcdef012') 307 $this->config['plugin.pathKey']=$path[1]; 308 $this->saveConfig(); 309 $this->fileExportDir=GPCCore::getPiwigoSystemPath().'/'.PWG_LOCAL_DIR.substr(self::EXPORT_DIRECTORY,0,-1).'-'.$this->config['plugin.pathKey'].'/'; 310 return($this->fileStatDir); 311 } 312 313 // no directory found, create the key 314 $this->config['plugin.pathKey']=strtoupper(md5(date('Ymd-His').rand(0,65536))); 315 $this->saveConfig(); 316 $this->fileStatDir=substr($rootPath,0,-1).'-'.$this->config['plugin.pathKey']; 317 $this->fileExportDir=GPCCore::getPiwigoSystemPath().'/'.PWG_LOCAL_DIR.substr(self::EXPORT_DIRECTORY,0,-1).'-'.$this->config['plugin.pathKey'].'/'; 318 return($this->fileStatDir); 319 } 320 321 /** 322 * try to find a directory in the $path 323 * exemple: 324 * $path = /local/plugins/EStat/Data- 325 * => try to find all directory macthing with /local/plugins/EStat/Data-* 326 * 327 * @param String $path: 328 * @return String: found path or empty string if nothing is found 329 */ 330 private function findDirectory($path) 331 { 332 $dirname=dirname($path); 333 if(!file_exists($dirname)) return(''); 334 $baseName=baseName($path); 335 $dirContent=scandir($dirname); 336 foreach($dirContent as $file) 337 { 338 if($file!='.' and $file!='..' and is_dir($dirname.'/'.$file) and strpos($file, $baseName)!==false) 339 { 340 return($dirname.'/'.$file); 341 } 342 } 343 return(''); 344 } 345 346 347 348 235 349 /* 236 350 * ------------------------------------------------------------------------- … … 357 471 } 358 472 359 360 361 362 473 } //class 474 363 475 364 476 -
extensions/EStat/js/estatPM.js
r17737 r17758 600 600 regexp:'\d{1,3}(?:\.\d{1,3}){0,3}' 601 601 }, 602 defaultOperator:' =',603 filterOperators:[' =', '!=', 'between']602 defaultOperator:'like', 603 filterOperators:['like', 'not like', 'between', 'not between'] 604 604 }, 605 605 group:true, … … 665 665 footerString: 666 666 { 667 singular:translateString.i p_nb,668 plural:translateString.i ps_nb,667 singular:translateString.item_nb, 668 plural:translateString.items_nb, 669 669 waitForDownload:translateString.waitForDownload 670 670 }, … … 939 939 footerString: 940 940 { 941 singular:translateString. category_nb,942 plural:translateString. categories_nb,941 singular:translateString.item_nb, 942 plural:translateString.items_nb, 943 943 waitForDownload:translateString.waitForDownload 944 944 }, … … 1110 1110 footerString: 1111 1111 { 1112 singular:translateString.i mage_nb,1113 plural:translateString.i mages_nb,1112 singular:translateString.item_nb, 1113 plural:translateString.items_nb, 1114 1114 waitForDownload:translateString.waitForDownload 1115 1115 }, … … 1252 1252 }, 1253 1253 defaultOperator:'between', 1254 filterOperators:['>', '<', '>=', '<=', '=', '!=', 'between' ]1254 filterOperators:['>', '<', '>=', '<=', '=', '!=', 'between', 'not between'] 1255 1255 }, 1256 1256 sortable:'asc', … … 1267 1267 regexp:'\d{1,3}(?:\.\d{1,3}){0,3}' 1268 1268 }, 1269 defaultOperator:' =',1270 filterOperators:[' =', '!=', 'between']1269 defaultOperator:'like', 1270 filterOperators:['like', 'not like', 'between', 'not between'] 1271 1271 }, 1272 1272 sortable:'asc', … … 1412 1412 saveButtonClick: function (event, data) 1413 1413 { 1414 $('#iHistoryTable').dynamicTable('waitForDownload', true);1415 1414 $.dialogExport( 1416 1415 { -
extensions/EStat/language/en_UK/plugin.lang.php
r17737 r17758 89 89 $lang['estat_allPeriods']='All periods'; 90 90 91 92 $lang['estat_item_nb']='% event'; 93 $lang['estat_items_nb']='% events'; 94 $lang['estat_ip_nb']='% IP adress'; 95 $lang['estat_ips_nb']='% IP adresses'; 96 $lang['estat_category_nb']='% album'; 97 $lang['estat_categories_nb']='% albums'; 98 $lang['estat_image_nb']='% photo'; 99 $lang['estat_images_nb']='% photos'; 91 $lang['estat_item_nb']='% item'; 92 $lang['estat_items_nb']='% items'; 93 100 94 $lang['estat_country_nb']='%s country'; 101 95 $lang['estat_countries_nb']='%s countries'; 102 $lang['estat_items']='Events'; 96 103 97 $lang['estat_ok']='Ok'; 104 98 $lang['estat_cancel']='Cancel'; -
extensions/EStat/language/fr_FR/plugin.lang.php
r17737 r17758 89 89 $lang['estat_allPeriods']='Toutes périodes'; 90 90 91 92 $lang['estat_item_nb']='% événement'; 93 $lang['estat_items_nb']='% événements'; 94 $lang['estat_ip_nb']='% adresse IP'; 95 $lang['estat_ips_nb']='% adresses IP'; 96 $lang['estat_category_nb']='% album'; 97 $lang['estat_categories_nb']='% albums'; 98 $lang['estat_image_nb']='% photo'; 99 $lang['estat_images_nb']='% photos'; 91 $lang['estat_item_nb']='% élément'; 92 $lang['estat_items_nb']='% éléments'; 93 100 94 $lang['estat_country_nb']='%s pays'; 101 95 $lang['estat_countries_nb']='%s pays'; 102 $lang['estat_items']='Evénements'; 96 97 103 98 $lang['estat_ok']='Ok'; 104 99 $lang['estat_cancel']='Annuler'; -
extensions/EStat/lib/statDB.class.inc.php
r17737 r17758 193 193 * 194 194 * @param String $file 195 * @param Boolean $force: if true, $force the filename affectation even if file doesn't exist 195 196 * @return String: file name set 196 197 */ 197 public function setIpCountryFile($file )198 { 199 if( file_exists($file))198 public function setIpCountryFile($file, $force=false) 199 { 200 if($force or file_exists($file)) 200 201 $this->ipCountryFile=$file; 201 202 return($this->ipCountryFile); … … 728 729 break; 729 730 case 'between': 731 case 'not between': 730 732 if($field=='IPadress') 731 733 { … … 737 739 $num++; 738 740 } 739 $where[]=' '.$field. " BETWEEN ".$param['minValue']." AND ".$param['maxValue']." ";741 $where[]=' '.$field.' '.strtoupper($param['operator']).' '.$param['minValue']." AND ".$param['maxValue']." "; 740 742 break; 741 743 } … … 824 826 } 825 827 828 829 /** 830 * to be used with IP filter: replace the given operator with 'between' or 'not between' 831 * 832 * @param Array $value 833 * @return Array 834 */ 835 protected function checkIPFilter($value) 836 { 837 if(is_array($value)) 838 { 839 if(isset($value['operator'])) 840 { 841 if($value['operator']=='=' or 842 $value['operator']=='>' or 843 $value['operator']=='>=' or 844 $value['operator']=='<' or 845 $value['operator']=='<=' or 846 $value['operator']=='like') 847 { 848 $value['operator']='between'; 849 $value['minValue']=$value['value']; 850 $value['maxValue']=$value['value']; 851 $value['value']=null; 852 } 853 elseif($value['operator']=='!=' or 854 $value['operator']=='not like') 855 { 856 $value['operator']='not between'; 857 $value['minValue']=$value['value']; 858 $value['maxValue']=$value['value']; 859 $value['value']=null; 860 } 861 } 862 } 863 return($value); 864 } // checkIPFilter 826 865 827 866 … … 856 895 case '<=': 857 896 case '!=': 897 case 'like': 898 case 'not like': 858 899 if(isset($value['value'])) 859 900 { … … 866 907 break; 867 908 case 'IP': 868 $value['value']=$this->checkValueIP($value['value']); 909 // for IP, replace internaly the operator with a 'between' 910 $value['value']=$this->checkValueIP($value['value'], 0); 869 911 if($value['value']==null) return(null); 870 912 break; … … 893 935 break; 894 936 case 'IP': 895 $val=$this->checkValueIP($val );937 $val=$this->checkValueIP($val, 0); 896 938 if($val!=null) $returned[]=$val; 897 939 break; … … 910 952 break; 911 953 case 'between': 954 case 'not between': 912 955 if(isset($value['minValue']) and isset($value['maxValue'])) 913 956 { … … 921 964 break; 922 965 case 'IP': 923 $value['minValue']=$this->checkValueIP($value['minValue'] );966 $value['minValue']=$this->checkValueIP($value['minValue'], 0); 924 967 if($value['minValue']==null) return(null); 925 $value['maxValue']=$this->checkValueIP($value['maxValue'] );968 $value['maxValue']=$this->checkValueIP($value['maxValue'], 255); 926 969 if($value['maxValue']==null) return(null); 927 970 break; … … 981 1024 * 982 1025 * @param String $value 1026 * @param Integer $completeCode 983 1027 * @return String 984 1028 */ 985 protected function checkValueIP($value )986 { 987 $returned=self::IPBinaryEncode($value );1029 protected function checkValueIP($value, $completeCode=0) 1030 { 1031 $returned=self::IPBinaryEncode($value, $completeCode); 988 1032 if($returned=="\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00") return(null); 989 1033 return($returned); … … 1000 1044 * 1001 1045 * @param String $IP: text IP string 1046 * @param Integer $completeCode 1002 1047 * @return String: a binary string 1003 1048 */ 1004 static public function IPBinaryEncode($IP )1049 static public function IPBinaryEncode($IP, $completeCode=0) 1005 1050 { 1006 1051 $value=trim($IP); 1007 if(preg_match('/\d{1,3} \.\d{1,3}\.\d{1,3}\.\d{1,3}/i',$value)>0)1052 if(preg_match('/\d{1,3}(\.\d{1,3}(\.\d{1,3}(\.\d{1,3})?)?)?/i',$value)>0) 1008 1053 { 1009 1054 //IPv4 1010 1055 $tmp=explode('.',$value); 1056 while(count($tmp)<4) $tmp[]=$completeCode; 1057 1011 1058 return("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00".chr($tmp[0]+0).chr($tmp[1]+0).chr($tmp[2]+0).chr($tmp[3]+0)); 1012 1059 } … … 1088 1135 1089 1136 1090 1091 1092 1137 /* 1138 used to display binary values when debug is necessary... 1139 1140 function toHexDump($data) 1141 { 1142 $returned=""; 1143 $maxItems=strlen($data); 1144 1145 $tmp=array(); 1146 for($i=0;$i<$maxItems;$i++) 1147 { 1148 $tmp[]=sprintf("%02x", ord($data{$i})); 1149 } 1150 $returned.=implode(" ", $tmp); 1151 return($returned); 1152 } 1153 */ 1093 1154 1094 1155 -
extensions/EStat/lib/statDBGlobal.class.inc.php
r17737 r17758 223 223 SELECT uaType, IPadress, catId, $year, $month, SUM(visits), country 224 224 FROM period.statIP 225 GROUP BY uaType, IPadress, catId ;225 GROUP BY uaType, IPadress, catId, country; 226 226 227 227 REPLACE INTO main.statUA (uaData, uaValue, uaVersion, year, month, visits) … … 486 486 if(!isset($filter['country'])) $filter['country']=null; 487 487 488 $filter['IPadress']=$this->checkIPFilter($filter['IPadress']); 488 489 // check filter values - getOperator check and 'clean' the filter 489 490 $filter['IPadress']=$this->getOperator($filter['IPadress'], 'IP'); … … 543 544 case ASDF_GET_ROWS: 544 545 $sql=$select." FROM statip ".$where.$groupBy.$orderBy.$limit; 545 546 546 $sqlStm=$this->dbHandle->prepare($sql); 547 547 foreach($IPList as $num=>$IP) … … 1245 1245 ); 1246 1246 $this->dbHandle->exec("CREATE UNIQUE INDEX iIP ON statIP ('uaType', 'IPadress', 'catId', 'year', 'month');"); 1247 $this->dbHandle->exec("CREATE UNIQUEINDEX iIPPeriod ON statIP ('year', 'month', 'IPadress', 'uaType');");1247 $this->dbHandle->exec("CREATE INDEX iIPPeriod ON statIP ('year', 'month', 'IPadress', 'uaType');"); 1248 1248 } 1249 1249 -
extensions/EStat/lib/statDBMonth.class.inc.php
r17737 r17758 78 78 * 79 79 * missing values are set to default value 80 * country is defined automatically after buildIPCountry call; set to '' while 81 * call is not made 80 82 * 81 83 * @param Array $log : a record … … 109 111 // insert log 110 112 $sql="INSERT INTO logs 111 (date, IPadress, userId, catId, imageId, tagsId, section,113 (date, IPadress, country, userId, catId, imageId, tagsId, section, 112 114 userAgent, uaBrowser, uaBrowserVersion, uaEngine, uaEngineVersion, 113 115 uaOS, uaOSVersion, uaType, screenSizeW, screenSizeH) … … 115 117 //"'".$this->dbHandle->escapeString($value['IPadress'])."', ". 116 118 ":IP, ". 119 "'', ". 117 120 $value['userId'].", ". 118 121 $value['catId'].", ". … … 254 257 if(!isset($filter['uaType'])) $filter['uaType']=null; 255 258 259 $filter['IPadress']=$this->checkIPFilter($filter['IPadress']); 256 260 // check filter values - getOperator check and 'clean' the filter 257 261 $filter['date']=$this->getOperator($filter['date'], 'date'); … … 296 300 array('id'=>'id', 'direction'=>'A') 297 301 ); 302 // to optimize query, if date is the first field selected for order by, 303 // all other fields are removed; exception: if IPadress is the second one this 304 // field is kept 305 $tmp=$orderBy; 306 if($tmp[0]['id']=='date') 307 { 308 $orderBy=array($tmp[0]); 309 if($tmp[1]['id']=='IPadress') 310 { 311 $orderBy[]=$tmp[1]; 312 } 313 } 314 298 315 //build ORDER BY clause 299 316 $orderBy=$this->buildOrderByClause($orderBy); … … 310 327 { 311 328 case ASDF_GET_ROWS: 312 $sql="SELECT id, date, IPadress, userId, catId, imageId, tagsId, section,329 $sql="SELECT id, date, IPadress, country, userId, catId, imageId, tagsId, section, 313 330 userAgent, uaBrowser, uaBrowserVersion, uaEngine, uaEngineVersion, 314 331 uaOS, uaOSVersion, uaType, screenSizeW, screenSizeH 315 332 FROM logs $where $orderBy $limit;"; 333 316 334 $sqlStm=$this->dbHandle->prepare($sql); 317 335 foreach($IPList as $num=>$IP) … … 576 594 if(!isset($filter['country'])) $filter['country']=null; 577 595 596 $filter['IPadress']=$this->checkIPFilter($filter['IPadress']); 578 597 // check filter values - getOperator check and 'clean' the filter 579 598 $filter['IPadress']=$this->getOperator($filter['IPadress'], 'IP'); … … 1248 1267 DROP TABLE IF EXISTS tmpIp; 1249 1268 1269 -- update the logs table for rows with unset country 1270 -- use a simple sub select here, assuming that it's quick enough for the update 1271 UPDATE logs 1272 SET country=(SELECT sip.country FROM statip sip WHERE logs.IPadress = sip.IPadress) 1273 WHERE country=''; 1274 1250 1275 -- commit changes 1251 1276 COMMIT TRANSACTION; … … 1285 1310 'date' INTEGER, 1286 1311 'IPadress' BLOB, 1312 'country' TEXT, 1287 1313 'userId' INTEGER, 1288 1314 'catId' INTEGER, … … 1302 1328 );" 1303 1329 ); 1304 $this->dbHandle->exec("CREATE INDEX iDate ON logs ('date');"); 1305 $this->dbHandle->exec("CREATE INDEX iByIP ON logs ('IPadress');"); 1330 $this->dbHandle->exec("CREATE INDEX iDateIP ON logs ('date', 'IPadress');"); 1331 $this->dbHandle->exec("CREATE INDEX iIPCountry ON logs ('IPadress', 'country');"); 1332 $this->dbHandle->exec("CREATE INDEX iUAB ON logs ('uaType', 'uaBrowser', 'uaEngine');"); 1333 $this->dbHandle->exec("CREATE INDEX iUAO ON logs ('uaOS');"); 1306 1334 } 1307 1335
Note: See TracChangeset
for help on using the changeset viewer.