Changeset 17760 for extensions/EStat
- Timestamp:
- Sep 5, 2012, 5:15:35 PM (12 years ago)
- Location:
- extensions/EStat
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/EStat/estat_ajax.php
r17758 r17760 1151 1151 1152 1152 $tmp=$statFile->getStatPeriod(0, 0, $fields['total'], $filter, $sort); 1153 $returned['total']=array('', $tmp[0]['T'], $tmp[0]['C'], $tmp[0]['I'], $tmp[0]['A']); 1153 if(isset($tmp[0])) 1154 { 1155 $returned['total']=array('', $tmp[0]['T'], $tmp[0]['C'], $tmp[0]['I'], $tmp[0]['A']); 1156 } 1157 else 1158 { 1159 $returned['total']=array('', '0', '0', '0', '0'); 1160 } 1154 1161 break; 1155 1162 case 'y': … … 1170 1177 1171 1178 $tmp=$statFile->getStatPeriod(0, 0, $fields['total'], $filter, $sort); 1172 $returned['total']=array('', $tmp[0][0]['T'], $tmp[0][0]['C'], $tmp[0][0]['I'], $tmp[0][0]['A']); 1179 if(isset($tmp[0])) 1180 { 1181 $returned['total']=array('', $tmp[0][0]['T'], $tmp[0][0]['C'], $tmp[0][0]['I'], $tmp[0][0]['A']); 1182 } 1183 else 1184 { 1185 $returned['total']=array('', '0', '0', '0', '0'); 1186 } 1173 1187 break; 1174 1188 default: … … 1189 1203 } 1190 1204 $tmp=$statFile->getStatPeriod(0, 0, $fields['total'], $filter, $sort); 1191 $returned['total']=array('', $tmp[0][0]['T'], $tmp[0][0]['C'], $tmp[0][0]['I'], $tmp[0][0]['A']); 1205 if(isset($tmp[0])) 1206 { 1207 $returned['total']=array('', $tmp[0][0]['T'], $tmp[0][0]['C'], $tmp[0][0]['I'], $tmp[0][0]['A']); 1208 } 1209 else 1210 { 1211 $returned['total']=array('', '0', '0', '0', '0'); 1212 } 1192 1213 break; 1193 1214 } -
extensions/EStat/lib/statDB.class.inc.php
r17758 r17760 865 865 866 866 867 868 /** 869 * to be used with Date filter: replace the given operator with 'between' or 'not between' 870 * 871 * @param Array $value 872 * @return Array 873 */ 874 protected function checkDateFilter($value) 875 { 876 if(is_array($value)) 877 { 878 if(isset($value['operator'])) 879 { 880 if($value['operator']=='=' or 881 $value['operator']=='like') 882 { 883 $value['operator']='between'; 884 $value['minValue']=$value['value']; 885 $value['maxValue']=$value['value']; 886 $value['value']=null; 887 } 888 elseif($value['operator']=='!=' or 889 $value['operator']=='not like') 890 { 891 $value['operator']='not between'; 892 $value['minValue']=$value['value']; 893 $value['maxValue']=$value['value']; 894 $value['value']=null; 895 } 896 } 897 } 898 return($value); 899 } // checkDateFilter 900 901 902 903 867 904 /** 868 905 * check if value is a valid operator array … … 902 939 { 903 940 case 'date': 904 $value['value']=$this->checkValueDate($value['value']); 941 switch($value['operator']) 942 { 943 case '>': 944 case '<=': 945 $value['value']=$this->checkValueDate($value['value'], 'E'); 946 break; 947 case '<': 948 case '>=': 949 default: 950 $value['value']=$this->checkValueDate($value['value'], 'B'); 951 break; 952 } 905 953 if($value['value']==null) return(null); 906 954 $value['value']=$value['value']; … … 958 1006 { 959 1007 case 'date': 960 $value['minValue']=$this->checkValueDate($value['minValue'] );1008 $value['minValue']=$this->checkValueDate($value['minValue'], 'B'); 961 1009 if($value['minValue']==null) return(null); 962 $value['maxValue']=$this->checkValueDate($value['maxValue'] );1010 $value['maxValue']=$this->checkValueDate($value['maxValue'], 'E'); 963 1011 if($value['maxValue']==null) return(null); 964 1012 break; … … 993 1041 /** 994 1042 * check if date is Ok 995 * return the date completed (YYYY-MM-DD => YYYY-MM-DD 00:00:00) or null if not valid 1043 * return the date completed 1044 * (YYYY-MM-DD => YYYY-MM-DD 00:00:00) if $mode='B' 1045 * or (YYYY-MM-DD => YYYY-MM-DD 23:59:59) if $mode='E' 1046 * or null if not valid 996 1047 * 997 1048 * @param String $value 1049 * @param String $mode: 'B' for begin or 'E' for end 998 1050 * @return String 999 1051 */ 1000 protected function checkValueDate($value )1052 protected function checkValueDate($value, $mode='B') 1001 1053 { 1002 1054 $returned=null; 1003 1055 $result=array(); 1004 if(preg_match('/^(\d{4}-\d{2}-\d{2})(?:(\s{1}\d{2}:\d{2})(:\d{2})?)?$/', $value, $result)>0)1056 if(preg_match('/^(\d{4}-\d{2}-\d{2})(?:(\s{1}\d{2}:\d{2})(:\d{2})?)?$/', trim($value), $result)>0) 1005 1057 { 1006 1058 $returned=$result[1]; … … 1012 1064 $returned.=$result[3]; 1013 1065 } 1014 else $returned.=':00'; 1015 } 1016 else $returned.=' 00:00:00'; 1066 else 1067 { 1068 $returned.=($mode=='B')?':00':':59'; 1069 } 1070 } 1071 else 1072 { 1073 $returned.=($mode=='B')?' 00:00:00':' 23:59:59'; 1074 } 1017 1075 } 1018 1076 return(strtotime($returned)); -
extensions/EStat/lib/statDBMonth.class.inc.php
r17758 r17760 257 257 if(!isset($filter['uaType'])) $filter['uaType']=null; 258 258 259 $filter['date']=$this->checkDateFilter($filter['date']); 259 260 $filter['IPadress']=$this->checkIPFilter($filter['IPadress']); 260 261 // check filter values - getOperator check and 'clean' the filter
Note: See TracChangeset
for help on using the changeset viewer.