| [ Index ] |
|
Code source de Cr@wltr@ck 2.2.1 |
1 <?php 2 //---------------------------------------------------------------------- 3 // CrawlTrack 2.2.1 4 //---------------------------------------------------------------------- 5 // Crawler Tracker for website 6 //---------------------------------------------------------------------- 7 // Author: Jean-Denis Brun 8 //---------------------------------------------------------------------- 9 // Website: www.crawltrack.fr 10 //---------------------------------------------------------------------- 11 // That script is distributed under GNU GPL license 12 //---------------------------------------------------------------------- 13 // file: mapgraph.php 14 //---------------------------------------------------------------------- 15 //initialize array 16 $axexlabel=array(); 17 $axex=array(); 18 $nbvisitsgraph=array(); 19 $nbpagesgraph=array(); 20 $nbcrawlergraph=array(); 21 $datatransfert=array(); 22 23 //number of days (or months) for the period 24 $nbday2=0; 25 if($period == 0 OR $period >= 1000) 26 { 27 $nbday=24; 28 } 29 elseif($period==1 OR ($period>=300 && $period<400)) 30 { 31 $nbday=7; 32 } 33 elseif($period==2 OR ($period>=100 && $period<200)) 34 { 35 $nbday=date("t",mktime(0,0,0,$monthrequest,$dayrequest,$yearrequest)); 36 } 37 elseif($period==3 OR ($period >= 200 && $period<300)) 38 { 39 $nbday=12; 40 } 41 elseif($period==4) 42 { 43 $nbday=8; 44 } 45 46 47 48 //prepare X axis label 49 50 if($period == 0 OR $period >= 1000) 51 { 52 $axex = array( 53 "0" => "0", 54 "1" => "1", 55 "2" => "2", 56 "3" => "3", 57 "4" => "4", 58 "5" => "5", 59 "6" => "6", 60 "7" => "7", 61 "8" => "8", 62 "9" => "9", 63 "10" => "10", 64 "11" => "11", 65 "12" => "12", 66 "13" => "13", 67 "14" => "14", 68 "15" => "15", 69 "16" => "16", 70 "17" => "17", 71 "18" => "18", 72 "19" => "19", 73 "20" => "20", 74 "21" => "21", 75 "22" => "22", 76 "23" => "23" 77 ); 78 79 $nbvisitsgraph = array( 80 "0" => "0", 81 "1" => "0", 82 "2" => "0", 83 "3" => "0", 84 "4" => "0", 85 "5" => "0", 86 "6" => "0", 87 "7" => "0", 88 "8" => "0", 89 "9" => "0", 90 "10" => "0", 91 "11" => "0", 92 "12" => "0", 93 "13" => "0", 94 "14" => "0", 95 "15" => "0", 96 "16" => "0", 97 "17" => "0", 98 "18" => "0", 99 "19" => "0", 100 "20" => "0", 101 "21" => "0", 102 "22" => "0", 103 "23" => "0" 104 ); 105 106 $nbpagesgraph = array( 107 "0" => "0", 108 "1" => "0", 109 "2" => "0", 110 "3" => "0", 111 "4" => "0", 112 "5" => "0", 113 "6" => "0", 114 "7" => "0", 115 "8" => "0", 116 "9" => "0", 117 "10" => "0", 118 "11" => "0", 119 "12" => "0", 120 "13" => "0", 121 "14" => "0", 122 "15" => "0", 123 "16" => "0", 124 "17" => "0", 125 "18" => "0", 126 "19" => "0", 127 "20" => "0", 128 "21" => "0", 129 "22" => "0", 130 "23" => "0" 131 ); 132 133 $nbcrawlergraph = array( 134 "0" => "0", 135 "1" => "0", 136 "2" => "0", 137 "3" => "0", 138 "4" => "0", 139 "5" => "0", 140 "6" => "0", 141 "7" => "0", 142 "8" => "0", 143 "9" => "0", 144 "10" => "0", 145 "11" => "0", 146 "12" => "0", 147 "13" => "0", 148 "14" => "0", 149 "15" => "0", 150 "16" => "0", 151 "17" => "0", 152 "18" => "0", 153 "19" => "0", 154 "20" => "0", 155 "21" => "0", 156 "22" => "0", 157 "23" => "0" 158 ); 159 160 $datatransfert = array( 161 "0" => "0-0-0", 162 "1" => "0-0-0", 163 "2" => "0-0-0", 164 "3" => "0-0-0", 165 "4" => "0-0-0", 166 "5" => "0-0-0", 167 "6" => "0-0-0", 168 "7" => "0-0-0", 169 "8" => "0-0-0", 170 "9" => "0-0-0", 171 "10" => "0-0-0", 172 "11" => "0-0-0", 173 "12" => "0-0-0", 174 "13" => "0-0-0", 175 "14" => "0-0-0", 176 "15" => "0-0-0", 177 "16" => "0-0-0", 178 "17" => "0-0-0", 179 "18" => "0-0-0", 180 "19" => "0-0-0", 181 "20" => "0-0-0", 182 "21" => "0-0-0", 183 "22" => "0-0-0", 184 "23" => "0-0-0" 185 ); 186 } 187 elseif($period==3 OR ($period >= 200 && $period<300)) 188 { 189 $date=$datebeginlocalcut[0]; 190 $date20 = explode('-', $date); 191 $yeardate = $date20[0]; 192 $actualmonth=date("m"); 193 $actualyear=date("Y"); 194 195 $axex = array( 196 "0" => "01/".$yeardate, 197 "1" => "02/".$yeardate, 198 "2" => "03/".$yeardate, 199 "3" => "04/".$yeardate, 200 "4" => "05/".$yeardate, 201 "5" => "06/".$yeardate, 202 "6" => "07/".$yeardate, 203 "7" => "08/".$yeardate, 204 "8" => "09/".$yeardate, 205 "9" => "10/".$yeardate, 206 "10" => "11/".$yeardate, 207 "11" => "12/".$yeardate 208 ); 209 210 $nbvisitsgraph = array( 211 "01/".$yeardate => "0", 212 "02/".$yeardate => "0", 213 "03/".$yeardate => "0", 214 "04/".$yeardate => "0", 215 "05/".$yeardate => "0", 216 "06/".$yeardate => "0", 217 "07/".$yeardate => "0", 218 "08/".$yeardate => "0", 219 "09/".$yeardate => "0", 220 "10/".$yeardate => "0", 221 "11/".$yeardate => "0", 222 "12/".$yeardate => "0" 223 ); 224 225 226 227 $nbpagesgraph = array( 228 "01/".$yeardate => "0", 229 "02/".$yeardate => "0", 230 "03/".$yeardate => "0", 231 "04/".$yeardate => "0", 232 "05/".$yeardate => "0", 233 "06/".$yeardate => "0", 234 "07/".$yeardate => "0", 235 "08/".$yeardate => "0", 236 "09/".$yeardate => "0", 237 "10/".$yeardate => "0", 238 "11/".$yeardate => "0", 239 "12/".$yeardate => "0" 240 ); 241 242 $nbcrawlergraph = array( 243 "01/".$yeardate => "0", 244 "02/".$yeardate => "0", 245 "03/".$yeardate => "0", 246 "04/".$yeardate => "0", 247 "05/".$yeardate => "0", 248 "06/".$yeardate => "0", 249 "07/".$yeardate => "0", 250 "08/".$yeardate => "0", 251 "09/".$yeardate => "0", 252 "10/".$yeardate => "0", 253 "11/".$yeardate => "0", 254 "12/".$yeardate => "0" 255 ); 256 257 $datatransfert = array( 258 "01/".$yeardate => "0-0-0", 259 "02/".$yeardate => "0-0-0", 260 "03/".$yeardate => "0-0-0", 261 "04/".$yeardate => "0-0-0", 262 "05/".$yeardate => "0-0-0", 263 "06/".$yeardate => "0-0-0", 264 "07/".$yeardate => "0-0-0", 265 "08/".$yeardate => "0-0-0", 266 "09/".$yeardate => "0-0-0", 267 "10/".$yeardate => "0-0-0", 268 "11/".$yeardate => "0-0-0", 269 "12/".$yeardate => "0-0-0" 270 ); 271 272 $totperiod = array( 273 "01/".$yeardate => linkmapgraph('1',$actualmonth,$yeardate,$actualyear), 274 "02/".$yeardate => linkmapgraph('2',$actualmonth,$yeardate,$actualyear), 275 "03/".$yeardate => linkmapgraph('3',$actualmonth,$yeardate,$actualyear), 276 "04/".$yeardate => linkmapgraph('4',$actualmonth,$yeardate,$actualyear), 277 "05/".$yeardate => linkmapgraph('5',$actualmonth,$yeardate,$actualyear), 278 "06/".$yeardate => linkmapgraph('6',$actualmonth,$yeardate,$actualyear), 279 "07/".$yeardate => linkmapgraph('7',$actualmonth,$yeardate,$actualyear), 280 "08/".$yeardate => linkmapgraph('8',$actualmonth,$yeardate,$actualyear), 281 "09/".$yeardate => linkmapgraph('9',$actualmonth,$yeardate,$actualyear), 282 "10/".$yeardate => linkmapgraph('10',$actualmonth,$yeardate,$actualyear), 283 "11/".$yeardate => linkmapgraph('11',$actualmonth,$yeardate,$actualyear), 284 "12/".$yeardate => linkmapgraph('12',$actualmonth,$yeardate,$actualyear), 285 ); 286 } 287 else 288 { 289 $date=$datebeginlocalcut[0]; 290 $nbday2=0; 291 292 do { 293 294 $date2=$date; 295 $date20 = explode('-', $date); 296 $yeardate = $date20[0]; 297 $monthdate = $date20[1]; 298 $daydate = $date20[2]; 299 300 $yeardate2=substr($yeardate,2,2); 301 if($nbday==7) 302 { 303 if($firstdayweek =='Monday') 304 { 305 $day="day".$nbday2; 306 } 307 else 308 { 309 //case first week day is sunday 310 $nbday3=$nbday2+6; 311 if($nbday3>6) 312 { 313 $nbday3=$nbday3-7; 314 } 315 $day="day".$nbday3; 316 } 317 $axexlabel[$daydate."/".$monthdate."/".$yeardate]=$language[$day]." ".$daydate; 318 $axex[]=$language[$day]." ".$daydate; 319 $nbvisitsgraph[$language[$day]." ".$daydate]=0; 320 $nbpagesgraph[$language[$day]." ".$daydate]=0; 321 $nbcrawlergraph[$language[$day]." ".$daydate]=0; 322 $datatransfert[$language[$day]." ".$daydate]='0-0-0'; 323 if(nbdayfromtoday($date)==0) 324 { 325 $totperiod[$language[$day]." ".$daydate]=0; 326 } 327 else 328 { 329 $totperiod[$language[$day]." ".$daydate]=999+nbdayfromtoday($date); 330 } 331 } 332 else 333 { 334 $axex[]=$daydate."/".$monthdate."/".$yeardate; 335 $nbvisitsgraph[$daydate."/".$monthdate."/".$yeardate]=0; 336 $nbpagesgraph[$daydate."/".$monthdate."/".$yeardate]=0; 337 $nbcrawlergraph[$daydate."/".$monthdate."/".$yeardate]=0; 338 $datatransfert[$daydate."/".$monthdate."/".$yeardate]='0-0-0'; 339 if(nbdayfromtoday($date)==0) 340 { 341 $totperiod[$daydate."/".$monthdate."/".$yeardate]=0; 342 } 343 else 344 { 345 $totperiod[$daydate."/".$monthdate."/".$yeardate]=999+nbdayfromtoday($date); 346 } 347 } 348 349 $ts = mktime(0,0,0,$monthdate, $daydate, $yeardate) + 86400; 350 $date = date("Y-m-d",$ts); 351 //case change summer time to winter time 352 if($date==$date2) 353 { 354 $date = date("Y-m-d",($ts+7200)); 355 } 356 $nbday2++; 357 } 358 while($nbday2<$nbday); 359 360 } 361 362 //mysql requete 363 364 if($navig==2) //case one specific crawler 365 { 366 $testcrawler= "AND crawlt_crawler.crawler_name='".sql_quote($crawler)."'"; 367 $tables="crawlt_crawler"; 368 $union="AND crawlt_visits.crawlt_crawler_id_crawler=crawlt_crawler.id_crawler"; 369 } 370 elseif($navig==4) //case one specific page 371 { 372 $testcrawler= "AND crawlt_pages.url_page='".sql_quote($crawler)."'"; 373 $tables="crawlt_pages, crawlt_crawler"; 374 $union="AND crawlt_visits.crawlt_crawler_id_crawler=crawlt_crawler.id_crawler 375 AND crawlt_visits.crawlt_pages_id_page=crawlt_pages.id_page"; 376 } 377 else //case all crawler or all pages 378 { 379 $testcrawler= ""; 380 $tables="crawlt_crawler"; 381 $union="AND crawlt_visits.crawlt_crawler_id_crawler=crawlt_crawler.id_crawler"; 382 } 383 384 385 if($period==0 OR $period >= 1000) 386 { 387 $datequery= "HOUR(date)"; 388 } 389 elseif($period==3 OR ($period >= 200 && $period<300)) 390 { 391 $datequery= "FROM_UNIXTIME(UNIX_TIMESTAMP(date)-($times*3600), '%Y%m')"; 392 } 393 else 394 { 395 $datequery= "FROM_UNIXTIME(UNIX_TIMESTAMP(date)-($times*3600), '%d/%m/%Y')"; 396 } 397 398 //requete to count the number of page viewed, visits and crawler 399 $sqlstats = "SELECT $datequery, COUNT(DISTINCT crawlt_pages_id_page), COUNT(DISTINCT id_visit),COUNT(DISTINCT crawler_name) FROM crawlt_visits, $tables 400 WHERE $datetolookfor 401 $union 402 AND crawlt_visits.crawlt_site_id_site='".sql_quote($site)."' 403 $testcrawler 404 GROUP BY $datequery"; 405 406 $requetestats = mysql_query($sqlstats, $connexion) or die("MySQL query error"); 407 408 if($period==0 OR $period >= 1000) 409 { 410 while ($ligne = mysql_fetch_row($requetestats)) 411 { 412 $hour= $ligne[0] - $times; 413 if($hour<0) 414 { 415 $hour = 24 + $hour; 416 } 417 if($hour>=24) 418 { 419 $hour= $hour - 24; 420 } 421 $nbpagesgraph[$hour]=$ligne[1]; 422 $nbvisitsgraph[$hour]=$ligne[2]; 423 $nbcrawlergraph[$hour]=$ligne[3]; 424 $datatransfert[$hour]=$ligne[1]."-".$ligne[2]."-".$ligne[3]; 425 } 426 } 427 elseif($period==3 OR ($period >= 200 && $period<300)) 428 { 429 while ($ligne = mysql_fetch_row($requetestats)) 430 { 431 $year=substr($ligne[0],0,4); 432 $month=substr($ligne[0],4,2); 433 $yearmonth=$month."/".$year; 434 $nbpagesgraph[$yearmonth]=$ligne[1]; 435 $nbvisitsgraph[$yearmonth]=$ligne[2]; 436 $nbcrawlergraph[$yearmonth]=$ligne[3]; 437 $datatransfert[$yearmonth]=$ligne[1]."-".$ligne[2]."-".$ligne[3]; 438 } 439 } 440 elseif($period==1 OR ($period >= 300 && $period<400)) //case 1 week back and forward 441 { 442 while ($ligne = mysql_fetch_row($requetestats)) 443 { 444 $nbpagesgraph[$axexlabel[$ligne[0]]]=$ligne[1]; 445 $nbvisitsgraph[$axexlabel[$ligne[0]]]=$ligne[2]; 446 $nbcrawlergraph[$axexlabel[$ligne[0]]]=$ligne[3]; 447 $datatransfert[$axexlabel[$ligne[0]]]=$ligne[1]."-".$ligne[2]."-".$ligne[3]; 448 } 449 } 450 else 451 { 452 while ($ligne = mysql_fetch_row($requetestats)) 453 { 454 $nbpagesgraph[$ligne[0]]=$ligne[1]; 455 $nbvisitsgraph[$ligne[0]]=$ligne[2]; 456 $nbcrawlergraph[$ligne[0]]=$ligne[3]; 457 $datatransfert[$ligne[0]]=$ligne[1]."-".$ligne[2]."-".$ligne[3]; 458 } 459 } 460 461 462 if(($navig==1 OR $navig==3) && ($period==3 OR ($period>=200 && $period<300))) 463 { 464 //use data in archive to complete the graph 465 466 //data request 467 $sqlarchive="SELECT mois, nbr_visits, pages_view FROM crawlt_archive"; 468 469 $requetearchive = mysql_query($sqlarchive, $connexion) or die("MySQL query error"); 470 471 $nbrresult=mysql_num_rows($requetearchive); 472 if($nbrresult>=1) 473 { 474 while ($ligne = mysql_fetch_row($requetearchive)) 475 { 476 $sitetodisplay = explode('-',$ligne[0]); 477 if($sitetodisplay[1]==$site && in_array($sitetodisplay[0],$axex)) 478 { 479 $data=$sitetodisplay[0]; 480 $nbvisitsgraph[$data]=$ligne[1]; 481 $nbpagesgraph[$data]=$ligne[2]; 482 $datatransfert[$data]=$ligne[2]."-".$ligne[1]."-0"; 483 } 484 } 485 } 486 } 487 488 489 //map graph 490 if($period == 0 OR $period >= 1000) 491 { 492 $widthzone=22; 493 $x2=88; 494 $y=30; 495 $y2=280; 496 } 497 elseif($period==1 OR ($period>=300 && $period<400)) 498 { 499 $widthzone=75.4; 500 $x2=141.4; 501 $y=30; 502 $y2=280; 503 } 504 elseif($period==2 OR ($period>=100 && $period<200)) 505 { 506 if($nbday==28) 507 { 508 $widthzone=18.9; 509 $x2=84.9; 510 $y=30; 511 $y2=240; 512 } 513 elseif($nbday==29) 514 { 515 $widthzone=18.2; 516 $x2=84.2; 517 $y=30; 518 $y2=240; 519 } 520 elseif($nbday==30) 521 { 522 $widthzone=17.6; 523 $x2=83; 524 $y=30; 525 $y2=240; 526 } 527 else 528 { 529 $widthzone=17; 530 $x2=83; 531 $y=30; 532 $y2=240; 533 } 534 535 } 536 elseif($period==3 OR ($period >= 200 && $period<300)) 537 { 538 $widthzone=44; 539 $x2=110; 540 $y=30; 541 $y2=280; 542 } 543 elseif($period==4) 544 { 545 $widthzone=66; 546 $x2=132; 547 $y=30; 548 $y2=280; 549 } 550 551 echo"<MAP ID=\"visit\" NAME=\"visit\">\n"; 552 $iday=0; 553 $x=66; 554 555 do { 556 557 echo"<AREA SHAPE=\"RECT\" COORDS=\"".$x.",".$y.",".$x2.",".$y2."\" onmouseover=\"javascript:montre('smenu".($iday+9)."');\" onmouseout=\"javascript:montre();\""; 558 if($period != 0 && $period < 1000 && $onlyarchive==0) 559 { 560 $dateday=$axex[$iday]; 561 $periodtogo = $totperiod[$dateday]; 562 echo"href=\"index.php?navig=$navig&period=$periodtogo&site=$site&crawler=$crawlencode&graphpos=$graphpos\">\n"; 563 } 564 else 565 { 566 echo">\n"; 567 } 568 $x=$x+$widthzone; 569 $x2=$x2+$widthzone; 570 $iday++; 571 } 572 while($iday<$nbday); 573 574 echo"</MAP>\n"; 575 576 577 $iday=0; 578 do { 579 echo"<div id=\"smenu".($iday+9)."\" style=\"display:none; font-size:13px; color:#003399; font-family:Verdana,Geneva, Arial, Helvetica, Sans-Serif; text-align:left; border:2px solid navy; position:absolute; top:8px; left:300px; background:#eee;\">\n"; 580 if($period == 0 OR $period >= 1000) 581 { 582 echo" ".$axex[$iday]."h-->".($axex[$iday]+1)."h \n"; 583 } 584 else 585 { 586 echo" ".$axex[$iday]." \n"; 587 } 588 echo" ". $nbvisitsgraph[$axex[$iday]]." ".$language['nbr_visits']." \n"; 589 if($navig != 4) 590 { 591 echo" ".$nbpagesgraph[$axex[$iday]]." ".$language['nbr_pages']." \n"; 592 } 593 if($navig != 2) 594 { 595 echo" ". $nbcrawlergraph[$axex[$iday]]." ".$language['crawler_name']." \n"; 596 } 597 echo"</div>\n"; 598 $iday++; 599 } 600 while($iday<$nbday); 601 602 //prepare datas to be transfert to graph file 603 $datatransferttograph=addslashes(urlencode(serialize($datatransfert))); 604 //insert the values in the graph table 605 $graphname="visits-".$cachename; 606 607 //check if this graph exit already in the table 608 $sql = "SELECT name FROM crawlt_graph 609 WHERE name= '".sql_quote($graphname)."'"; 610 611 612 $requete = mysql_query($sql, $connexion) or die("MySQL query error"); 613 $nbrresult=mysql_num_rows($requete); 614 if($nbrresult >=1) 615 { 616 $sql2 ="UPDATE crawlt_graph SET graph_values='".sql_quote($datatransferttograph)."' 617 WHERE name= '".sql_quote($graphname)."'"; 618 } 619 else 620 { 621 $sql2 ="INSERT INTO crawlt_graph (name,graph_values) VALUES ( '".sql_quote($graphname)."','".sql_quote($datatransferttograph)."')"; 622 } 623 $requete2 = mysql_query($sql2, $connexion) or die("MySQL query error"); 624 625 626 //mysql connexion close 627 mysql_close($connexion); 628 629 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Thu Sep 6 14:14:11 2007 | par Balluche grâce à PHPXref 0.7 |