Changeset 3706 for extensions/AStat/astat_aip.class.inc.php
- Timestamp:
- Jul 30, 2009, 7:36:50 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/AStat/astat_aip.class.inc.php
r3543 r3706 17 17 include_once('astat_aim.class.inc.php'); 18 18 include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); 19 include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/ajax.class.inc.php'); 19 20 20 21 class AStat_AIP extends AStat_AIM 21 { 22 protected $tabsheet; 22 { 23 protected $tabsheet; 23 24 protected $list_periods = array('global', 'all', 'year', 'month', 'day'); 24 25 protected $list_sortcat = array('page', 'picture', 'nbpicture'); 25 26 protected $list_sortimg = array('picture', 'catname'); 26 27 protected $list_sortip = array('page', 'picture', 'ip'); 28 protected $ajax; 27 29 28 30 protected $catfilter; //filter on categories … … 56 58 l10n('AStat_tools'), 57 59 $this->page_link.'&fAStat_tabsheet=tools'); 60 61 $this->ajax = new Ajax(); 58 62 } 59 63 … … 78 82 { 79 83 global $template; 84 85 $this->return_ajax_content(); 80 86 81 87 $template->set_filename('plugin_admin_content', dirname(__FILE__)."/admin/astat_admin.tpl"); … … 102 108 elseif($_REQUEST['fAStat_tabsheet']=='stats_by_ip') 103 109 { 110 if(isset($_REQUEST['fAStat_IP_BL'])) 111 { 112 $this->add_ip_to_filter($_REQUEST['fAStat_IP_BL']); 113 } 114 104 115 $this->display_stats_by_ip( 105 116 $_REQUEST['fAStat_year'], … … 167 178 --------------------------------------------------------------------------- */ 168 179 180 /* 181 return ajax content 182 */ 183 protected function return_ajax_content() 184 { 185 global $ajax, $template; 186 187 if(isset($_REQUEST['ajaxfct'])) 188 { 189 //$this->debug("AJAXFCT:".$_REQUEST['ajaxfct']); 190 $result="<p class='errors'>An error has occured</p>"; 191 switch($_REQUEST['ajaxfct']) 192 { 193 case 'astat_listip': 194 if(!isset($_REQUEST['ipfilter'])) $_REQUEST['ipfilter']=""; 195 if(!isset($_REQUEST['exclude'])) $_REQUEST['exclude']=""; 196 $result=$this->ajax_listip($_REQUEST['ipfilter'], $_REQUEST['exclude']); 197 break; 198 } 199 //$template-> 200 $this->ajax->return_result($result); 201 } 202 } 203 204 205 206 207 208 209 169 210 private function init_request() 170 211 { … … 292 333 293 334 if($day!="") 294 { 335 { 295 336 $sql_groupdef="HOUR(time) as GId,"; 296 337 $sql_select="select HOUR(time) as GId, "; … … 299 340 $sql_order=" order by GId asc"; 300 341 301 for($i=0;$i<24;$i++) 342 for($i=0;$i<24;$i++) 302 343 { 303 344 $returned[$i] = array( … … 313 354 } 314 355 } 315 elseif($month!="") 316 { 356 elseif($month!="") 357 { 317 358 $sql_groupdef="DAY(date) as GId,"; 318 359 $sql_select="select DAY(date) as GId, "; … … 323 364 $delta = 1; 324 365 $NbDays = strftime('%d', mktime(0,0,0,$month+1,0,$year)); 325 for($i=0;$i<$NbDays;$i++) 366 for($i=0;$i<$NbDays;$i++) 326 367 { 327 368 $returned[$i] = array( … … 337 378 } 338 379 } 339 elseif($year!="") 340 { 380 elseif($year!="") 381 { 341 382 $sql_groupdef="MONTH(date) as GId,"; 342 383 $sql_select="select MONTH(date) as GId, "; … … 346 387 347 388 $delta = 1; 348 for($i=0;$i<12;$i++) 389 for($i=0;$i<12;$i++) 349 390 { 350 391 $returned[$i] = array( … … 360 401 } 361 402 } 362 elseif($total!="Y") 403 elseif($total!="Y") 363 404 { 364 405 $sql_groupdef="YEAR(date) as GId,"; … … 379 420 } 380 421 422 if($this->my_config['AStat_BlackListedIP']!="") 423 { 424 ($sql_where=="")?$sql_where=" where ":$sql_where.=" AND "; 425 $sql_where .= " NOT ".$this->make_IP_where_clause($this->my_config['AStat_BlackListedIP']); 426 } 427 381 428 $sql_max=", (select max(n.MaxPages) as MaxPages, max(n.MaxIP) as MaxIP, max(n.MaxImg) as MaxImg 382 429 from (select ".$sql_groupdef." count(id) as MaxPages, count(distinct IP) as MaxIP, count(image_id) as MaxImg 383 from ".HISTORY_TABLE.$sql_where.$sql_group.") as n) as n "; 430 from ".HISTORY_TABLE.$sql_where.$sql_group.") as n) as n "; 384 431 $sql=$sql_select.$sql.$sql_nfomax.$sql_from.$sql_max.$sql_where.$sql_group.$sql_order; 385 432 … … 394 441 { $returned[$row["GId"]-$delta] = $row; } 395 442 } 396 443 397 444 return($returned); 398 445 } //stat by period … … 423 470 $sql_where = ""; 424 471 $sql_group=" group by IP_USER "; 425 $sql_order=" order by ".$sortlist[$sortip]." "; 472 $sql_order=" order by ".$sortlist[$sortip]." "; 426 473 $sql_limit=" limit ".(($pagenumber-1)* $nbipperpage).", ".$nbipperpage; 427 474 428 475 429 if($day!="") 430 { 476 if($day!="") 477 { 431 478 $sql_where=" where YEAR(date) = $year and MONTH(date) = $month and DAY(date) = $day "; 432 479 } 433 elseif($month!="") 434 { 480 elseif($month!="") 481 { 435 482 $sql_where=" where YEAR(date) = $year and MONTH(date) = $month "; 436 483 } 437 elseif($year!="") 438 { 484 elseif($year!="") 485 { 439 486 $sql_where=" where YEAR(date) = $year "; 440 487 } … … 451 498 } 452 499 500 if($this->my_config['AStat_BlackListedIP']!="") 501 { 502 ($sql_where=="")?$sql_where=" where ":$sql_where.=" AND "; 503 $sql_where .= " NOT ".$this->make_IP_where_clause($this->my_config['AStat_BlackListedIP']); 504 } 505 453 506 $sql_max=", (select max(n.MaxPages) as MaxPages, max(n.MaxImg) as MaxImg 454 from (select if(".HISTORY_TABLE.".user_id = 2, IP, if(".USERS_TABLE.".username is null, '[".l10n("AStat_deleted_user")."]', ".USERS_TABLE.".username)) as IP_USER, count(".HISTORY_TABLE.".id) as MaxPages, count(image_id) as MaxImg 455 from ".HISTORY_TABLE." LEFT JOIN ".USERS_TABLE." ON ".HISTORY_TABLE.".user_id = ".USERS_TABLE.".id ".$sql_where.$sql_group.") as n) as n "; 507 from (select if(".HISTORY_TABLE.".user_id = 2, IP, if(".USERS_TABLE.".username is null, '[".l10n("AStat_deleted_user")."]', ".USERS_TABLE.".username)) as IP_USER, count(".HISTORY_TABLE.".id) as MaxPages, count(image_id) as MaxImg 508 from ".HISTORY_TABLE." LEFT JOIN ".USERS_TABLE." ON ".HISTORY_TABLE.".user_id = ".USERS_TABLE.".id ".$sql_where.$sql_group.") as n) as n "; 456 509 $sql=$sql_select.$sql.$sql_nfomax.$sql_from.$sql_max.$sql_where.$sql_group.$sql_order.$sql_limit; 457 510 … … 475 528 $returned[1] = -1; 476 529 } 477 530 478 531 return($returned); 479 532 } //stat by ip … … 483 536 %Pages 484 537 %Images 485 by : 538 by : 486 539 Categories 487 540 Categories/years … … 505 558 506 559 if($show_thumb=='true') 507 { 560 { 508 561 $sql_thumb = ', '.IMAGES_TABLE.'.path as ThumbPath, '.IMAGES_TABLE.'.file as ThumbFile, '.IMAGES_TABLE.'.tn_ext as Extension'; 509 562 $sql_fromthumb = "LEFT JOIN ".IMAGES_TABLE." ON ic2.representative_picture_id = ".IMAGES_TABLE.".id "; … … 514 567 $sql_fromthumb = ""; 515 568 } 516 569 517 570 $sql_from = " from (".HISTORY_TABLE." LEFT JOIN ".CATEGORIES_TABLE." ON ".CATEGORIES_TABLE.".id = ".HISTORY_TABLE.".category_id), 518 (select category_id as catid, count(image_id) as nb_images, representative_picture_id 571 (select category_id as catid, count(image_id) as nb_images, representative_picture_id 519 572 from ".IMAGE_CATEGORY_TABLE.", ".CATEGORIES_TABLE." 520 573 where ".CATEGORIES_TABLE.".id = ".IMAGE_CATEGORY_TABLE.".category_id group by category_id) as ic2 "; … … 522 575 $sql_group=" group by category_id, section "; 523 576 $sql_group2=""; 524 $sql_order=" order by ".$sortlist[$sortcat]; 577 $sql_order=" order by ".$sortlist[$sortcat]; 525 578 $sql_limit=" limit ".(($pagenumber-1)* $nbipperpage).", ".$nbipperpage; 526 579 527 if($day!="") 528 { 580 if($day!="") 581 { 529 582 $sql_where=" where YEAR(date) = $year and MONTH(date) = $month and DAY(date)= $day "; 530 583 } 531 elseif($month!="") 532 { 584 elseif($month!="") 585 { 533 586 $sql_where=" where YEAR(date) = $year and MONTH(date) = $month "; 534 587 } 535 elseif($year!="") 536 { 588 elseif($year!="") 589 { 537 590 $sql_where=" where YEAR(date) = $year "; 538 591 } … … 552 605 $sql_where .= " ic2.catid = ".HISTORY_TABLE.".category_id "; 553 606 607 if($this->my_config['AStat_BlackListedIP']!="") 608 { 609 $sql_where .= " AND NOT ".$this->make_IP_where_clause($this->my_config['AStat_BlackListedIP']); 610 } 554 611 555 612 $sql=$sql_select.$sql.$sql_thumb.$sql_from.$sql_fromthumb.$sql_max.$sql_where.$sql_group.$sql_order.$sql_limit; … … 574 631 $returned[1] = -1; 575 632 } 576 633 577 634 return($returned); 578 635 } // stats per categories … … 582 639 Num of view per image 583 640 %view on period 584 by : 641 by : 585 642 Images 586 643 Images/years … … 605 662 ".IMAGES_TABLE.".path as ThumbPath, ".IMAGES_TABLE.".file as ThumbFile, 606 663 MaxImg2.somme as NbVuesMax, ".IMAGES_TABLE.".tn_ext as Extension "; 607 664 608 665 $sql_from = " from ((".HISTORY_TABLE." LEFT JOIN ".IMAGES_TABLE." ON 609 666 ".IMAGES_TABLE.".id = ".HISTORY_TABLE.".image_id) LEFT JOIN ".CATEGORIES_TABLE." … … 613 670 $sql_where = " where ".HISTORY_TABLE.".image_id is not null "; 614 671 $sql_group=" group by image_id, category_id "; 615 $sql_order=" order by ".$sortlist[$sortimg]; 672 $sql_order=" order by ".$sortlist[$sortimg]; 616 673 $sql_limit=" limit ".(($pagenumber-1)* $nbipperpage).", ".$nbipperpage; 617 674 618 if($day!="") 619 { 675 if($day!="") 676 { 620 677 $sql_where.=" and YEAR(date) = $year and MONTH(date) = $month and DAY(date)= $day "; 621 678 } 622 elseif($month!="") 623 { 679 elseif($month!="") 680 { 624 681 $sql_where.=" and YEAR(date) = $year and MONTH(date) = $month "; 625 682 } 626 elseif($year!="") 627 { 683 elseif($year!="") 684 { 628 685 $sql_where.=" and YEAR(date) = $year "; 629 686 } … … 631 688 632 689 if($ip!="") 633 { 690 { 634 691 $sql_where.=" and ( ((IP = '$ip') and ( user_id = 2 )) or (".USERS_TABLE.".username = '$ip') )"; 635 $sql_from_ip=" LEFT JOIN ".USERS_TABLE." ON ".USERS_TABLE.".id = ".HISTORY_TABLE.".user_id "; 636 } 637 692 $sql_from_ip=" LEFT JOIN ".USERS_TABLE." ON ".USERS_TABLE.".id = ".HISTORY_TABLE.".user_id "; 693 } 694 638 695 if($this->catfilter!="") 639 696 { … … 643 700 } 644 701 702 if($this->my_config['AStat_BlackListedIP']!="") 703 { 704 ($sql_where=="")?$sql_where=" where ":$sql_where.=" AND "; 705 $sql_where .= " NOT ".$this->make_IP_where_clause($this->my_config['AStat_BlackListedIP']); 706 } 707 708 645 709 $sql_max=", (select count(image_id) as somme from ".HISTORY_TABLE.$sql_from_ip.$sql_where.") as MaxImg, (select count(image_id) as somme from ".HISTORY_TABLE.$sql_from_ip.$sql_where." and ".HISTORY_TABLE.".image_id is not null group by image_id order by somme desc limit 0,1) as MaxImg2 "; 646 710 … … 666 730 $returned[1] = -1; 667 731 } 668 732 669 733 return($returned); 670 734 } //stat by images … … 719 783 720 784 /* period label + navigation links */ 721 if($day!="") 722 { 785 if($day!="") 786 { 723 787 $template_datas["PERIOD_LABEL"] = l10n("AStat_period_label_hours"); 724 788 $template_datas["L_STAT_TITLE"] = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".$this->format_link(l10n("AStat_period_label_all"), $a_links["all"])." / ".$this->format_link($year, $a_links["year"])." / ".$this->format_link(l10n("AStat_month_of_year_".$month), $a_links["month"])." / ".l10n("AStat_day_of_week_".date("w",mktime(0, 0, 0, $month, $day, $year)))." $day"; 725 789 } 726 elseif($month!="") 727 { 790 elseif($month!="") 791 { 728 792 $template_datas["PERIOD_LABEL"] = l10n("AStat_period_label_days"); 729 793 $template_datas["L_STAT_TITLE"] = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".$this->format_link(l10n("AStat_period_label_all"), $a_links["all"])." / ".$this->format_link($year, $a_links["year"])." / ".l10n("AStat_month_of_year_".$month); 730 794 } 731 elseif($year!="") 732 { 795 elseif($year!="") 796 { 733 797 $template_datas["PERIOD_LABEL"] = l10n("AStat_period_label_months"); 734 798 $template_datas["L_STAT_TITLE"] = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".$this->format_link(l10n("AStat_period_label_all"), $a_links["all"])." / ".$year; 735 799 } 736 elseif($total!="Y") 737 { 800 elseif($total!="Y") 801 { 738 802 $template_datas["PERIOD_LABEL"] = l10n("AStat_period_label_years"); 739 803 $template_datas["L_STAT_TITLE"] = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".l10n("AStat_period_label_all"); 740 804 } 741 else 742 { 805 else 806 { 743 807 $template_datas["PERIOD_LABEL"] = l10n("AStat_period_label_all"); 744 808 $template_datas["L_STAT_TITLE"] = l10n("AStat_period_label_global"); 745 } 809 } 746 810 $template_datas["MAX_WIDTH"] = $max_width+10; 747 811 $template_datas["ASTAT_NFO_STAT"] = l10n("AStat_Nfo_Period"); … … 763 827 } 764 828 else 765 { 766 $width_pages = 0; 829 { 830 $width_pages = 0; 767 831 $width_img = 0; 768 832 $width_ip = 0; … … 770 834 } 771 835 772 836 773 837 if($day!="") 774 838 { // si jours sélectionné, heures affichées … … 787 851 $value_img=$img_links["day"].$stats[$i]["GId"]; 788 852 } 789 elseif($year!="") 853 elseif($year!="") 790 854 { // si année sélectionnée, mois affichés 791 855 $value = l10n("AStat_month_of_year_".$stats[$i]["GId"]); … … 803 867 $value_img=$img_links["year"].$stats[$i]["GId"]; 804 868 } 805 else 806 { 807 $value=l10n("AStat_period_label_all"); 869 else 870 { 871 $value=l10n("AStat_period_label_all"); 808 872 $link=$this->page_link."&fAStat_defper=N&fAStat_all=N"; 809 873 $value_ip=$ip_links["all"]; … … 897 961 898 962 /* periode label + navigation links */ 899 if($day!="") 900 { 963 if($day!="") 964 { 901 965 $dir_links = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".$this->format_link(l10n("AStat_period_label_all"), $a_links["all"])." / ".$this->format_link($year, $a_links["year"])." / ".$this->format_link(l10n("AStat_month_of_year_".$month), $a_links["month"])." / ".l10n("AStat_day_of_week_".date("w",mktime(0, 0, 0, $month, $day, $year)))." $day"; 902 966 $page_link=$ip_links["day"]; 903 967 $img_link=$img_links["day"]; 904 968 } 905 elseif($month!="") 906 { 969 elseif($month!="") 970 { 907 971 $dir_links = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".$this->format_link(l10n("AStat_period_label_all"), $a_links["all"])." / ".$this->format_link($year, $a_links["year"])." / ".l10n("AStat_month_of_year_".$month); 908 972 $page_link=$ip_links["month"]; 909 973 $img_link=$img_links["month"]; 910 974 } 911 elseif($year!="") 912 { 975 elseif($year!="") 976 { 913 977 $dir_links = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".$this->format_link(l10n("AStat_period_label_all"), $a_links["all"])." / ".$year; 914 978 $page_link=$ip_links["year"]; 915 979 $img_link=$img_links["year"]; 916 980 } 917 else 918 { 981 else 982 { 919 983 $dir_links = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".l10n("AStat_period_label_all"); 920 984 $page_link=$ip_links["all"]; 921 985 $img_link=$img_links["all"]; 922 986 } 923 987 924 988 925 989 if($nbpages>1) { $plural="s"; } else { $plural=""; } … … 927 991 for($i=1;$i<=$nbpages;$i++) 928 992 { 929 if($i==$pagenumber) 930 { $pages_links.=" $i "; } 993 if($i==$pagenumber) 994 { $pages_links.=" $i "; } 931 995 else 932 996 { … … 934 998 } 935 999 } 936 1000 937 1001 $template_datas["L_STAT_TITLE"] = $dir_links; 938 1002 $template_datas["MAX_WIDTH"]=$max_width+10; … … 955 1019 { 956 1020 if($stats[$i]["MaxPages"] > 0) 957 { 958 $width_pages = ceil(($stats[$i]["NbPages"] * $max_width) / $stats[$i]["MaxPages"] ); 1021 { 1022 $width_pages = ceil(($stats[$i]["NbPages"] * $max_width) / $stats[$i]["MaxPages"] ); 959 1023 $width_img = ceil(($stats[$i]["NbImg"] * $max_width) / $stats[$i]["MaxPages"] ); 960 1024 } 961 1025 else 962 { 963 $width_pages = 0; 1026 { 1027 $width_pages = 0; 964 1028 $width_img = 0; 965 1029 } … … 970 1034 $ip_geolocalisation='<a href="http://www.geoiptool.com/fr/?IP='.$stats[$i]["IP_USER"].'" title="Geo IP localisation" target="_blank">['.l10n('AStat_IP_geolocalisation').'] </a>'; 971 1035 $ip_adress='<a href="http://www.ripe.net/whois?form_type=simple&full_query_string=&searchtext='.$stats[$i]["IP_USER"].'+&do_search=Search" title="Ripe Whois" target="_blank">'.$stats[$i]["IP_USER"].'</a>'; 972 } 973 else 1036 $ip_blacklist=$page_link."&fAStat_IP_BL=".$stats[$i]["IP_USER"]; 1037 1038 if($pagenumber>1) 1039 { 1040 $ip_blacklist.="&fAStat_page_number=$pagenumber"; 1041 } 1042 1043 if($sortip!="page") 1044 { 1045 $ip_blacklist.="&fAStat_SortIP=$sortip"; 1046 } 1047 1048 $ip_blacklist=$this->format_link("[".l10n('AStat_IP_blacklist')."]", $ip_blacklist); 1049 } 1050 else 974 1051 { 975 1052 $ip_geolocalisation=''; 976 1053 $ip_adress=$stats[$i]["IP_USER"]; 977 } 1054 $ip_blacklist=''; 1055 } 1056 978 1057 979 1058 980 1059 $template_datarows[]=array( 1060 'ASTAT_IP_BLACKLIST' => $ip_blacklist, 981 1061 'ASTAT_IP_GEOLOCALISATION' => $ip_geolocalisation, 982 1062 'ASTAT_IP_ADRESS' => $ip_adress, … … 1030 1110 1031 1111 /* make navigation links */ 1032 if($day!="") 1033 { 1112 if($day!="") 1113 { 1034 1114 $dir_links = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".$this->format_link(l10n("AStat_period_label_all"), $a_links["all"])." / ".$this->format_link($year, $a_links["year"])." / ".$this->format_link(l10n("AStat_month_of_year_".$month), $a_links["month"])." / ".l10n("AStat_day_of_week_".date("w",mktime(0, 0, 0, $month, $day, $year)))." $day"; 1035 1115 $page_link=$cat_links["day"]; 1036 1116 } 1037 elseif($month!="") 1038 { 1117 elseif($month!="") 1118 { 1039 1119 $dir_links = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".$this->format_link(l10n("AStat_period_label_all"), $a_links["all"])." / ".$this->format_link($year, $a_links["year"])." / ".l10n("AStat_month_of_year_".$month); 1040 1120 $page_link=$cat_links["month"]; 1041 1121 } 1042 elseif($year!="") 1043 { 1122 elseif($year!="") 1123 { 1044 1124 $dir_links = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".$this->format_link(l10n("AStat_period_label_all"), $a_links["all"])." / ".$year; 1045 1125 $page_link=$cat_links["year"]; 1046 1126 } 1047 else 1048 { 1127 else 1128 { 1049 1129 $dir_links = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".l10n("AStat_period_label_all"); 1050 1130 $page_link=$cat_links["all"]; 1051 1131 } 1052 1132 1053 1133 1054 1134 if($nbpages>1) … … 1064 1144 for($i=1;$i<=$nbpages;$i++) 1065 1145 { 1066 if($i==$pagenumber) 1146 if($i==$pagenumber) 1067 1147 { 1068 1148 $pages_links.=" $i "; … … 1096 1176 $width_pages = ceil(($stats[$i]["PctPages"] * $max_width)/100); 1097 1177 $width_img = ceil(($stats[$i]["PctImg"] * $max_width)/100 ); 1098 1178 1099 1179 if($showthumb=='true') 1100 { 1180 { 1101 1181 $filethumb=$this->change_file_ext($stats[$i]["ThumbFile"], $stats[$i]["Extension"]); 1102 1182 $filethumb=str_replace($stats[$i]["ThumbFile"],"thumbnail/".$conf['prefix_thumbnail'].$filethumb,$stats[$i]["ThumbPath"]); } … … 1109 1189 { $category = $this->format_link($stats[$i]["IdCat"], PHPWG_ROOT_PATH."index.php?/category/".$stats[$i]["category_id"]); } 1110 1190 else 1111 { 1191 { 1112 1192 $category = "<i>".l10n('AStat_section_label').' : '; 1113 1193 if(l10n('AStat_section_'.$stats[$i]["IdCat"])!='AStat_section_'.$stats[$i]["IdCat"]) … … 1142 1222 1143 1223 /* ------------------------------------------------------------------------------------------ 1144 display stats for images 1224 display stats for images 1145 1225 ------------------------------------------------------------------------------------------ */ 1146 1226 function display_stats_by_image($year, $month, $day, $max_width, $nbipperpage, $pagenumber,$showthumb, $sortimg, $ip, $seetimerequest) … … 1176 1256 1177 1257 /* navigation links */ 1178 if($day!="") 1179 { 1258 if($day!="") 1259 { 1180 1260 $dir_links = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".$this->format_link(l10n("AStat_period_label_all"), $a_links["all"])." / ".$this->format_link($year, $a_links["year"])." / ".$this->format_link(l10n("AStat_month_of_year_".$month), $a_links["month"])." / ".l10n("AStat_day_of_week_".date("w",mktime(0, 0, 0, $month, $day, $year)))." $day"; 1181 1261 $page_link=$img_links["day"]; 1182 1262 } 1183 elseif($month!="") 1184 { 1263 elseif($month!="") 1264 { 1185 1265 $dir_links = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".$this->format_link(l10n("AStat_period_label_all"), $a_links["all"])." / ".$this->format_link($year, $a_links["year"])." / ".l10n("AStat_month_of_year_".$month); 1186 1266 $page_link=$img_links["month"]; 1187 1267 } 1188 elseif($year!="") 1189 { 1268 elseif($year!="") 1269 { 1190 1270 $dir_links = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".$this->format_link(l10n("AStat_period_label_all"), $a_links["all"])." / ".$year; 1191 1271 $page_link=$img_links["year"]; 1192 1272 } 1193 else 1194 { 1273 else 1274 { 1195 1275 $dir_links = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".l10n("AStat_period_label_all"); 1196 1276 $page_link=$img_links["all"]; … … 1201 1281 $dir_links.= " [IP : $ip]"; 1202 1282 } 1203 1283 1204 1284 1205 1285 if($nbpages>1) { $plural="s"; } else { $plural=""; } … … 1207 1287 for($i=1;$i<=$nbpages;$i++) 1208 1288 { 1209 if($i==$pagenumber) 1210 { $pages_links.=" $i "; } 1289 if($i==$pagenumber) 1290 { $pages_links.=" $i "; } 1211 1291 else 1212 1292 { … … 1236 1316 for($i=0;$i<count($stats);$i++) 1237 1317 { 1238 $width_pages = ceil(($stats[$i]["NbVues"] * $max_width)/$stats[$i]["NbVuesMax"] ); 1318 $width_pages = ceil(($stats[$i]["NbVues"] * $max_width)/$stats[$i]["NbVuesMax"] ); 1239 1319 $width_img = ceil(($stats[$i]["PctImg"] * $max_width)/100 ); 1240 1320 1241 1321 if($showthumb=='true') 1242 1322 { 1243 1323 $filethumb=$this->change_file_ext($stats[$i]["ThumbFile"], $stats[$i]["Extension"]); 1244 $filethumb=str_replace($stats[$i]["ThumbFile"],"thumbnail/".$conf['prefix_thumbnail'].$filethumb,$stats[$i]["ThumbPath"]); 1324 $filethumb=str_replace($stats[$i]["ThumbFile"],"thumbnail/".$conf['prefix_thumbnail'].$filethumb,$stats[$i]["ThumbPath"]); 1245 1325 } 1246 1326 else … … 1258 1338 } 1259 1339 else 1260 { 1340 { 1261 1341 if($stats[$i]["ThumbFile"]!="") 1262 1342 { … … 1270 1350 } 1271 1351 else 1272 { 1352 { 1273 1353 $image_links = "<i>".l10n('AStat_section_label').' : '; 1274 1354 if(l10n('AStat_section_'.$stats[$i]["CatName"])!='AStat_section_'.$stats[$i]["CatName"]) … … 1281 1361 } 1282 1362 1283 $image_links.="</i> / "; 1363 $image_links.="</i> / "; 1284 1364 1285 1365 if($stats[$i]["ImgName"]!="") … … 1288 1368 } 1289 1369 else 1290 { 1370 { 1291 1371 if($stats[$i]["ThumbFile"]!="") 1292 1372 { … … 1320 1400 1321 1401 1402 private function add_ip_to_filter($ip) 1403 { 1404 if(strpos($this->my_config['AStat_BlackListedIP'].",", $ip.",")===false) 1405 { 1406 ($this->my_config['AStat_BlackListedIP']!='')?$this->my_config['AStat_BlackListedIP'].=",":""; 1407 $this->my_config['AStat_BlackListedIP'].=$ip; 1408 $this->save_config(); 1409 } 1410 } 1411 1322 1412 1323 1413 /* … … 1330 1420 $save_status=false; 1331 1421 1332 if(isset($_POST['submit'])) 1422 if(isset($_POST['submit'])) 1333 1423 { 1334 1424 if(!is_adviser()) 1335 1425 { 1336 reset($this->my_config); 1337 while (list($key, $val) = each($this->my_config)) 1426 reset($this->my_config); 1427 while (list($key, $val) = each($this->my_config)) 1338 1428 { 1339 1429 if(isset($_POST['f_'.$key])) … … 1364 1454 1365 1455 //standards inputs zones 1366 reset($this->my_config); 1367 while (list($key, $val) = each($this->my_config)) 1456 reset($this->my_config); 1457 while (list($key, $val) = each($this->my_config)) 1368 1458 { 1369 1459 $template_datas["f_".$key]=$val; 1370 1460 } 1461 1462 // 1463 $template_datas['ajaxurl']=$this->page_link; 1371 1464 1372 1465 // define selected item for lists zones … … 1395 1488 } 1396 1489 // default ip order 1397 reset($this->list_sortip); 1398 while (list($key, $val) = each($this->list_sortip)) 1490 reset($this->list_sortip); 1491 while (list($key, $val) = each($this->list_sortip)) 1399 1492 { 1400 1493 $template_list_values['sortip'][]=$val; … … 1434 1527 1435 1528 1436 /* 1529 /* 1437 1530 display tools page 1438 1531 */ … … 1448 1541 1449 1542 // >> PURGE HISTORY -------------------------------------------------------- 1450 if(isset($_POST['apply_tool_purge_history'])) 1543 if(isset($_POST['apply_tool_purge_history'])) 1451 1544 { 1452 1545 if(!is_adviser()) 1453 1546 { 1454 $action_result['action']='AStat_tools_purge_history'; 1455 $action_result['result']='false'; 1547 $action_result['action']='AStat_tools_purge_history'; 1548 $action_result['result']='false'; 1456 1549 $action_result['msg']='AStat_tools_result_ko'; 1457 1550 1458 1551 $ok_to_purge=true; 1459 1552 if($_REQUEST['fAStat_purge_history_type']=='bydate') … … 1466 1559 1467 1560 $purge_date=mktime(0,0,0,$date[1],$date[0],$date[2]); 1468 $f date=date("Y-m-d", mktime(0,0,0,$date[1],$date[0],$date[2]));1561 $fparam=date("Y-m-d", mktime(0,0,0,$date[1],$date[0],$date[2])); 1469 1562 1470 1563 if(date("d/m/Y", $purge_date)!=$_REQUEST['fAStat_purge_history_date']) 1471 { 1472 $action_result['nfo']='AStat_tools_invalid_date'; 1564 { 1565 $action_result['nfo']='AStat_tools_invalid_date'; 1473 1566 $ok_to_purge=false; 1474 1567 } 1475 1568 elseif(date("Ymd", $purge_date)>=date("Ymd")) 1476 1569 { 1477 $action_result['nfo']='AStat_tools_invalid_date2'; 1570 $action_result['nfo']='AStat_tools_invalid_date2'; 1478 1571 $ok_to_purge=false; 1479 1572 } 1480 1573 } 1574 elseif($_REQUEST['fAStat_purge_history_type']=='byipid0') 1575 { 1576 $fparam=$this->my_config['AStat_BlackListedIP']; 1577 } 1481 1578 else 1482 1579 { 1483 $f date="";1580 $fparam=""; 1484 1581 } 1485 1582 1486 1583 if($ok_to_purge) 1487 1584 { 1488 $result=$this->do_purge_history( $f date, $_REQUEST['fAStat_purge_history_type']);1585 $result=$this->do_purge_history( $fparam, $_REQUEST['fAStat_purge_history_type']); 1489 1586 if($result) 1490 1587 { … … 1542 1639 } 1543 1640 } 1544 // 1641 // 1545 1642 elseif(isset($_POST['apply_tool_deleted_picture'])) 1546 1643 { … … 1566 1663 1567 1664 // >> DELETED_CATEGORY ----------------------------------------------------- 1568 elseif(isset($_POST['apply_tool_deleted_category'])) 1665 elseif(isset($_POST['apply_tool_deleted_category'])) 1569 1666 { 1570 1667 if(!is_adviser()) … … 1587 1684 } 1588 1685 // << DELETED_CATEGORY ----------------------------------------------------- 1589 1686 1590 1687 // >> DELETED USER --------------------------------------------------------- 1591 elseif(isset($_POST['apply_tool_deleted_user'])) 1688 elseif(isset($_POST['apply_tool_deleted_user'])) 1592 1689 { 1593 1690 if(!is_adviser()) … … 1615 1712 $table_exists=$this->verify_AStat_picture_table_status(); 1616 1713 if($table_exists==true) 1617 { 1714 { 1618 1715 $template_datas["ASTAT_DELETED_PICTURE_DO_ACTION"] = "checked"; 1619 1716 $template_datas["ASTAT_DELETED_PICTURE_PREPARE"] = "disabled"; 1620 1717 } 1621 1718 else 1622 { 1719 { 1623 1720 $template_datas["ASTAT_DELETED_PICTURE_PREPARE"]="checked"; 1624 1721 $template_datas["ASTAT_DELETED_PICTURE_DO_ACTION"]="disabled"; … … 1632 1729 { 1633 1730 $list=''; 1634 for($i=0;$i<count($nfo[2]);$i++) 1635 { 1731 for($i=0;$i<count($nfo[2]);$i++) 1732 { 1636 1733 if($nfo[2][$i][0]>1) { $s='s'; } else { $s=''; } 1637 $list.="<li>image_id #".$nfo[2][$i][1]." : ".$nfo[2][$i][0]." ".l10n("AStat_event$s")."</li>"; 1734 $list.="<li>image_id #".$nfo[2][$i][1]." : ".$nfo[2][$i][0]." ".l10n("AStat_event$s")."</li>"; 1638 1735 } 1639 1736 $template_datas["ASTAT_DELETED_PICTURE_NFO"] = sprintf(l10n('AStat_tools_deleted_picture_nfo1'), $nfo[0], $nfo[1], $list); … … 1644 1741 { 1645 1742 $template_datas["ASTAT_DELETED_PICTURE_NFO"] = l10n('AStat_tools_deleted_picture_nfo2'); 1646 } 1743 } 1647 1744 // << DISPLAY DELETED_PICTURE NFO ------------------------------------------ 1648 1745 … … 1672 1769 { 1673 1770 $list=''; 1674 for($i=0;$i<count($nfo[2]);$i++) 1675 { 1771 for($i=0;$i<count($nfo[2]);$i++) 1772 { 1676 1773 if($nfo[2][$i][0]>1) { $s='s'; } else { $s=''; } 1677 $list.="<li>user_id #".$nfo[2][$i][1]." : ".$nfo[2][$i][0]." ".l10n("AStat_event$s")."</li>"; 1774 $list.="<li>user_id #".$nfo[2][$i][1]." : ".$nfo[2][$i][0]." ".l10n("AStat_event$s")."</li>"; 1678 1775 } 1679 1776 $template_datas["ASTAT_DELETED_USER_NFO"] = sprintf(l10n('AStat_tools_deleted_user_nfo1'), $nfo[0], $nfo[1], $list); … … 1683 1780 { 1684 1781 $template_datas["ASTAT_DELETED_USER_NFO"] = l10n('AStat_tools_deleted_user_nfo2'); 1685 } 1782 } 1686 1783 // << DISPLAY DELETED USER NFO --------------------------------------------- 1687 1784 … … 1692 1789 { 1693 1790 $template_datas["ASTAT_GENERAL_NFO"] = sprintf(l10n('AStat_tools_general_nfo_nfo'), 1694 $nfo[0], 1791 $nfo[0], 1695 1792 $this->formatoctet($nfo[3]+$nfo[4], "A", " ", 2, true), 1696 1793 $this->formatoctet($nfo[3], "A", " ", 2, true), 1697 1794 $this->formatoctet($nfo[4], "A", " ", 2, true), 1698 date(l10n('AStat_date_time_format'), strtotime($nfo[2])), 1795 date(l10n('AStat_date_time_format'), strtotime($nfo[2])), 1699 1796 date(l10n('AStat_date_time_format'), strtotime($nfo[1])) ); 1797 $template_datas["ASTAT_MINDATE"]=date("m/d/Y",strtotime($nfo[2])); 1700 1798 } 1701 1799 1702 1800 $nfo=$this->purge_history_count_imageid0(); 1703 1801 $template_datas["ASTAT_PURGE_HISTORY_IMAGE_NFO"] = sprintf(l10n('AStat_tools_purge_history_imageid0'), $nfo); 1704 if($nfo==0) 1705 { 1802 if($nfo==0) 1803 { 1706 1804 $template_datas["ASTAT_PURGE_HISTORY_IMAGE_DISABLED"] = " disabled "; 1707 1805 } 1708 1806 $nfo=$this->purge_history_count_categoryid0(); 1709 1807 $template_datas["ASTAT_PURGE_HISTORY_CATEGORY_NFO"] = sprintf(l10n('AStat_tools_purge_history_categoryid0'), $nfo); 1710 if($nfo==0) 1711 { 1808 if($nfo==0) 1809 { 1712 1810 $template_datas["ASTAT_PURGE_HISTORY_CATEGORY_DISABLED"] = " disabled "; 1811 } 1812 $nfo=$this->purge_history_count_ipid0(); 1813 $template_datas["ASTAT_PURGE_HISTORY_IP_NFO"] = sprintf(l10n('AStat_tools_purge_history_ipid0'), $nfo[1], $nfo[0]); 1814 if($nfo[0]==0) 1815 { 1816 $template_datas["ASTAT_PURGE_HISTORY_IP_DISABLED"] = " disabled "; 1713 1817 } 1714 1818 // << GENERAL NFO ---------------------------------------------------------- … … 1752 1856 allow to force HISTORY_TABLE.user_id at 2 (guest) for records with user ident 1753 1857 doesn't exist anymore in the USERS_TABLE 1754 1858 1755 1859 Two usages : 1756 - analyse : return infos about records wich need to be updated 1860 - analyse : return infos about records wich need to be updated 1757 1861 * number of users 1758 1862 * number of records in HISTORY_TABLE … … 1763 1867 { 1764 1868 $returned = array(-1,0,''); 1765 1869 1766 1870 if($mode=='analyse') 1767 1871 { … … 1781 1885 $returned[1]+=$row[0]; 1782 1886 } 1783 1887 1784 1888 } 1785 1889 } … … 1797 1901 1798 1902 /* 1799 tools : deleted_picture 1903 tools : deleted_picture 1800 1904 analyse history to find deleted pictures 1801 1905 Two functions : … … 1809 1913 { 1810 1914 $returned = array(-1,0,''); 1811 1915 1812 1916 if($mode=='analyse') 1813 1917 { … … 1828 1932 $returned[1]+=$row[0]; 1829 1933 } 1830 1934 1831 1935 } 1832 1936 } … … 1834 1938 { 1835 1939 $sql="UPDATE ".HISTORY_TABLE." 1836 SET image_id = 0 1837 WHERE ".HISTORY_TABLE.".image_id > 0 1940 SET image_id = 0 1941 WHERE ".HISTORY_TABLE.".image_id > 0 1838 1942 AND ".HISTORY_TABLE.".image_id NOT IN (SELECT id FROM ".IMAGES_TABLE.")"; 1839 1943 $result=pwg_query($sql); … … 1861 1965 { 1862 1966 $returned = array(-1,0,''); 1863 1967 1864 1968 if($mode=='analyse') 1865 1969 { … … 1880 1984 $returned[1]+=$row[0]; 1881 1985 } 1882 1986 1883 1987 } 1884 1988 } … … 1886 1990 { 1887 1991 $sql="UPDATE ".HISTORY_TABLE." 1888 SET category_id = NULL, section = 'deleted_cat' 1889 WHERE ".HISTORY_TABLE.".category_id > 0 1992 SET category_id = NULL, section = 'deleted_cat' 1993 WHERE ".HISTORY_TABLE.".category_id > 0 1890 1994 AND ".HISTORY_TABLE.".category_id NOT IN (SELECT id FROM ".CATEGORIES_TABLE.")"; 1891 1995 $result=pwg_query($sql); … … 1901 2005 1902 2006 /* 1903 tools : general_nfo 2007 tools : general_nfo 1904 2008 return infos about historic 1905 2009 0 : nulber of records … … 1912 2016 { 1913 2017 $returned = array(-1,'','',0,0); 1914 2018 1915 2019 $sql="SELECT count(id) AS NbRecord, MAX(concat(date,' ', time)) AS LastDate, MIN(concat(date,' ', time)) AS FirstDate "; 1916 2020 $sql.=" FROM ".HISTORY_TABLE; … … 1919 2023 { 1920 2024 $row = mysql_fetch_array($result); 1921 if(is_array($row)) 1922 { 1923 $returned = $row; 2025 if(is_array($row)) 2026 { 2027 $returned = $row; 1924 2028 $sql="SHOW TABLE STATUS LIKE '".HISTORY_TABLE."';"; 1925 2029 $result=pwg_query($sql); … … 1936 2040 1937 2041 /* 1938 tools : do_purge_history 2042 tools : do_purge_history 1939 2043 do a purge of history table : 1940 2044 - $purgetype='bydate' : purge all record wich date is less than given date 1941 2045 - $purgetype='byimageid0' : with and image_id = 0 1942 2046 ------------------------------------------------------------------------------------ */ 1943 private function do_purge_history($ date, $purgetype)2047 private function do_purge_history($param, $purgetype) 1944 2048 { 1945 2049 if($purgetype=='bydate') 1946 2050 { 1947 $sql="DELETE FROM ".HISTORY_TABLE." WHERE date < '$ date'";2051 $sql="DELETE FROM ".HISTORY_TABLE." WHERE date < '$param'"; 1948 2052 } 1949 2053 elseif($purgetype=='byimageid0') … … 1955 2059 $sql="DELETE FROM ".HISTORY_TABLE." WHERE category_id is null and section='deleted_cat'"; 1956 2060 } 1957 else 1958 { 2061 elseif($purgetype=='byipid0') 2062 { 2063 $sql="DELETE FROM ".HISTORY_TABLE." WHERE ".$this->make_IP_where_clause($param); 2064 } 2065 else 2066 { 1959 2067 return(false); 1960 2068 } … … 1965 2073 $sql="OPTIMIZE TABLE ".HISTORY_TABLE; 1966 2074 $result=pwg_query($sql); 1967 return($result); 2075 return($result); 1968 2076 } 1969 2077 return(false); … … 1994 2102 } 1995 2103 1996 1997 /* 1998 tools : deleted_picture 1999 > verify_AStat_picture_table_status : 2000 > prepare_AStat_picture_table : 2104 private function purge_history_count_ipid0() 2105 { 2106 if($this->my_config['AStat_BlackListedIP']!="") 2107 { 2108 $list=explode(',', $this->my_config['AStat_BlackListedIP']); 2109 } 2110 else 2111 { 2112 $list=array(); 2113 } 2114 2115 $returned=array(0,count($list)); 2116 2117 if($this->my_config['AStat_BlackListedIP']!='') 2118 { 2119 $sql="SELECT COUNT(id) 2120 FROM ".HISTORY_TABLE." 2121 WHERE ".$this->make_IP_where_clause($this->my_config['AStat_BlackListedIP']); 2122 $result=pwg_query($sql); 2123 if($result) 2124 { 2125 $row=mysql_fetch_array($result); 2126 $returned[0]=$row[0]; 2127 } 2128 } 2129 return($returned); 2130 } 2131 2132 2133 /* 2134 tools : deleted_picture 2135 > verify_AStat_picture_table_status : 2136 > prepare_AStat_picture_table : 2001 2137 */ 2002 2138 private function verify_AStat_picture_table_status() … … 2020 2156 global $prefixeTable; 2021 2157 2022 $sql="CREATE TABLE ".$prefixeTable."AStat_picture (PRIMARY KEY (id), KEY ifile(file)) 2023 SELECT id, file 2158 $sql="CREATE TABLE ".$prefixeTable."AStat_picture (PRIMARY KEY (id), KEY ifile(file)) 2159 SELECT id, file 2024 2160 FROM ".IMAGES_TABLE; 2025 2161 $result=pwg_query($sql); … … 2027 2163 { 2028 2164 return(true); 2029 } 2165 } 2030 2166 return(false); 2031 2167 } … … 2035 2171 global $prefixeTable; 2036 2172 $returned=array(false,0,0); 2037 2173 2038 2174 if($this->verify_AStat_picture_table_status()) 2039 2175 { 2040 2176 $sql="SELECT count(DISTINCT ".$prefixeTable."AStat_picture.id), count(".HISTORY_TABLE.".id) 2041 FROM ".HISTORY_TABLE.", ".$prefixeTable."AStat_picture 2042 WHERE ".HISTORY_TABLE.".image_id = ".$prefixeTable."AStat_picture.id 2177 FROM ".HISTORY_TABLE.", ".$prefixeTable."AStat_picture 2178 WHERE ".HISTORY_TABLE.".image_id = ".$prefixeTable."AStat_picture.id 2043 2179 AND ".HISTORY_TABLE.".image_id NOT IN (SELECT id FROM ".IMAGES_TABLE.") 2044 2180 ORDER BY ".$prefixeTable."AStat_picture.id"; … … 2064 2200 2065 2201 $sql="CREATE TABLE ".$prefixeTable."AStat_picture2 (PRIMARY KEY (OldId)) 2066 SELECT AStat_tmp.id as OldId , ".IMAGES_TABLE.".id as NewId, ".IMAGES_TABLE.".storage_category_id as NewCatId 2202 SELECT AStat_tmp.id as OldId , ".IMAGES_TABLE.".id as NewId, ".IMAGES_TABLE.".storage_category_id as NewCatId 2067 2203 FROM (SELECT DISTINCT ".$prefixeTable."AStat_picture.* 2068 FROM ".HISTORY_TABLE.", ".$prefixeTable."AStat_picture 2069 WHERE ".HISTORY_TABLE.".image_id = ".$prefixeTable."AStat_picture.id 2204 FROM ".HISTORY_TABLE.", ".$prefixeTable."AStat_picture 2205 WHERE ".HISTORY_TABLE.".image_id = ".$prefixeTable."AStat_picture.id 2070 2206 AND ".HISTORY_TABLE.".image_id NOT IN (SELECT id FROM ".IMAGES_TABLE.") 2071 2207 ORDER BY ".$prefixeTable."AStat_picture.id … … 2077 2213 $sql="UPDATE ".HISTORY_TABLE.", ".$prefixeTable."AStat_picture2, ".IMAGES_TABLE." 2078 2214 SET ".HISTORY_TABLE.".image_id = ".$prefixeTable."AStat_picture2.NewId, 2079 ".HISTORY_TABLE.".category_id = ".$prefixeTable."AStat_picture2.NewCatId 2215 ".HISTORY_TABLE.".category_id = ".$prefixeTable."AStat_picture2.NewCatId 2080 2216 WHERE ".$prefixeTable."AStat_picture2.OldId = ".HISTORY_TABLE.".image_id"; 2081 2217 $result=pwg_query($sql); … … 2088 2224 $sql="DROP TABLE IF EXISTS ".$prefixeTable."AStat_picture"; 2089 2225 $result=pwg_query($sql); 2090 } 2226 } 2091 2227 return($returned); 2092 2228 } … … 2146 2282 2147 2283 2148 /* 2284 /* 2149 2285 this function make SELECT "WHERE" clause for filter list 2150 2286 … … 2173 2309 2174 2310 2175 /* 2311 /* 2176 2312 format text : <a href="$link">$value</a> 2177 2313 */ … … 2187 2323 { //basic test, maybe a pcre will be more appropriate... 2188 2324 $tmp=explode('.', $ip); 2189 if(count($tmp)!=4) 2325 if(count($tmp)!=4) 2190 2326 { return (false); } 2191 2327 2192 for($i=0;$i<4;$i++) 2193 { 2194 if(!is_numeric($tmp[$i])) { return (false); } 2328 for($i=0;$i<4;$i++) 2329 { 2330 if(!is_numeric($tmp[$i])) { return (false); } 2195 2331 } 2196 2332 return (true); … … 2203 2339 { //filename can be <filename.truc.jpeg> for example 2204 2340 $tmp = explode('.', $file); 2205 if(count($tmp)>1) { $tmp[count($tmp)-1] = $newext; } 2206 return implode('.', $tmp); 2341 if(count($tmp)>1) { $tmp[count($tmp)-1] = $newext; } 2342 return implode('.', $tmp); 2207 2343 } 2208 2344 2209 /* 2345 /* 2210 2346 format number $octets with unit 2211 2347 $format = "A" : auto … … 2229 2365 { $format="M"; } 2230 2366 else 2231 { $format="G"; } 2367 { $format="G"; } 2232 2368 } 2233 2369 switch($format) … … 2244 2380 case "G": 2245 2381 $unite="Go"; $div=1024000000; 2246 break; 2247 } 2248 2382 break; 2383 } 2384 2249 2385 $retour=number_format($octets/$div, $prec, '.', $thsep); 2250 2386 if($unitevis) … … 2253 2389 } 2254 2390 2391 private function make_IP_where_clause($list) 2392 { 2393 $returned=""; 2394 2395 $tmp=explode(",", $list); 2396 foreach($tmp as $key=>$val) 2397 { 2398 if($returned!="") { $returned.=" OR "; } 2399 $returned.=" IP LIKE '".$val."' "; 2400 } 2401 if($returned!="") 2402 { 2403 $returned ="(".$returned.")"; 2404 } 2405 return($returned); 2406 } 2407 2408 /* --------------------------------------------------------------------------- 2409 * AJAX functions 2410 * ------------------------------------------------------------------------- */ 2411 protected function ajax_listip($filter, $exclude) 2412 { 2413 $sql="SELECT IP, COUNT(id) as NbEvents FROM ".HISTORY_TABLE; 2414 2415 $where=array(); 2416 if($filter!="") 2417 { 2418 $where[]=" IP LIKE '".$filter."' "; 2419 } 2420 if($exclude!="") 2421 { 2422 $where[]=" NOT ".$this->make_IP_where_clause($exclude); 2423 } 2424 if(count($where)>0) 2425 { 2426 $sql.=" WHERE ".implode(" AND ", $where); 2427 } 2428 $sql.=" GROUP BY IP ORDER BY NbEvents desc, IP asc LIMIT 0,100"; 2429 2430 $list="<select multiple id='iipsellist'>"; 2431 $result=pwg_query($sql); 2432 if($result) 2433 { 2434 while($row=mysql_fetch_array($result)) 2435 { 2436 $list.="<option value='".$row['IP']."'>".$row['IP'].str_repeat(" ", 15-strlen($row['IP']))." (".$row['NbEvents'].")</option>"; 2437 } 2438 } 2439 $list.="</select>"; 2440 2441 return($list); 2442 } 2443 2444 2255 2445 } // AStat_AI class 2256 2446
Note: See TracChangeset
for help on using the changeset viewer.