[ 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: display-one-crawler.php 14 //---------------------------------------------------------------------- 15 if (!defined('IN_CRAWLT')) 16 { 17 echo"<h1>Hacking attempt !!!!</h1>"; 18 exit(); 19 } 20 21 //initialize array 22 $listpage=array(); 23 $nbvisits=array(); 24 $lastdate1=array(); 25 $address=array(); 26 $info=array(); 27 $agent=array(); 28 $ip=array(); 29 $uagent=array(); 30 $table=array(); 31 32 $crawlencode=urlencode($crawler); 33 $cachename=$navig.$period.$site.$order.$crawlencode.$displayall.$firstdayweek.$localday.$graphpos.$crawltlang; 34 35 //start the caching if fopen exist 36 if(function_exists('fopen')) 37 { 38 $ch = new cache($cachename); 39 } 40 41 //database connection 42 $connexion = mysql_connect($crawlthost,$crawltuser,$crawltpassword) or die("MySQL connection to database problem"); 43 $selection = mysql_select_db($crawltdb) or die("MySQL database selection problem"); 44 45 //include menu 46 include "include/menumain.php"; 47 include "include/menusite.php"; 48 include "include/timecache.php"; 49 //order case 50 if($order==0) 51 { 52 //case date 53 $orderby="maxdate DESC"; 54 } 55 elseif($order==2 OR $order==1 OR $order==4) 56 { 57 //case visits 58 $orderby="maxvisites DESC"; 59 } 60 elseif($order==3) 61 { 62 //case crawlers 63 $orderby="url_page ASC"; 64 } 65 //date format 66 if($period == 0 OR $period >= 1000) 67 { 68 $datequery= "DATE_FORMAT(MAX(FROM_UNIXTIME(UNIX_TIMESTAMP(date)-($times*3600))), '%H hr %i mn')"; 69 } 70 else 71 { 72 $datequery= "DATE_FORMAT(MAX(FROM_UNIXTIME(UNIX_TIMESTAMP(date)-($times*3600))), '%d/%m/%Y<br>%H hr %i mn')"; 73 } 74 //limite to 75 if($displayall=='no') 76 { 77 $limitquery='LIMIT '.$rowdisplay; 78 } 79 else 80 { 81 $limitquery=''; 82 } 83 //date for the mysql query 84 if($period>=10) 85 { 86 $datetolookfor=" date >'".sql_quote($daterequest)."' 87 AND date <'".sql_quote($daterequest2)."'"; 88 } 89 else 90 { 91 $datetolookfor=" date >'".sql_quote($daterequest)."'"; 92 } 93 94 95 //mysql requete 96 97 //requete to count the number of crawler per page and to list the page viewed and to count the number of visits per page and to have the date of last visit for each pages 98 $sqlstats = "SELECT url_page, COUNT(DISTINCT id_visit) as maxvisites, 99 MAX(FROM_UNIXTIME(UNIX_TIMESTAMP(date)-($times*3600), '%Y-%m-%d %H:%i:%s')) as maxdate, 100 $datequery 101 FROM crawlt_visits, crawlt_crawler, crawlt_pages 102 WHERE crawlt_visits.crawlt_crawler_id_crawler=crawlt_crawler.id_crawler 103 AND crawlt_visits.crawlt_pages_id_page=crawlt_pages.id_page 104 AND $datetolookfor 105 AND crawlt_visits.crawlt_site_id_site='".sql_quote($site)."' 106 AND crawlt_crawler.crawler_name='".sql_quote($crawler)."' 107 GROUP BY crawlt_pages_id_page 108 ORDER BY $orderby 109 $limitquery"; 110 111 $requetestats = mysql_query($sqlstats, $connexion) or die("MySQL query error1"); 112 113 114 $nbrresult=mysql_num_rows($requetestats); 115 if($nbrresult>=1) 116 { 117 $onlyarchive=0; 118 119 while ($ligne = mysql_fetch_row($requetestats)) 120 { 121 $nbvisits[$ligne[0]]=$ligne[1]; 122 $lastdatedisplay[$ligne[0]]=$ligne[3]; 123 } 124 125 126 127 //requete to have the crawler data 128 129 $sqlstats2 = "SELECT DISTINCT crawlt_crawler_id_crawler as robot, crawler_url, crawler_info, crawler_user_agent, crawler_ip, COUNT(DISTINCT id_visit), COUNT(DISTINCT crawlt_pages_id_page) FROM crawlt_visits,crawlt_crawler 130 WHERE crawlt_visits.crawlt_crawler_id_crawler=crawlt_crawler.id_crawler 131 AND $datetolookfor 132 AND crawlt_visits.crawlt_site_id_site='".sql_quote($site)."' 133 AND crawlt_crawler.crawler_name='".sql_quote($crawler)."' 134 GROUP BY robot"; 135 136 137 $requetestats2 = mysql_query($sqlstats2, $connexion) or die("MySQL query error2"); 138 $nbrtotvisits=0; 139 $nbrtotpages=0; 140 141 while ($ligne = mysql_fetch_row($requetestats2)) 142 { 143 $nbrtotvisits = $nbrtotvisits + $ligne[5]; 144 $nbrtotpages = $nbrtotpages + $ligne[6]; 145 $address=$ligne[1]; 146 $info=$ligne[2]; 147 $agent=$ligne[3]; 148 $ip=$ligne[4]; 149 150 if($agent!='') 151 { 152 $uagent[]=$agent; 153 } 154 if($ip!='') 155 { 156 $uagent[]=$ip; 157 } 158 159 160 } 161 162 //check if there is datas in archive 163 $usearchive=0; 164 if($period==3 OR ($period>=200 && $period<300)) 165 { 166 $beginperiod = mktime(0,0,0,$monthbeginserver, 1, $yearbeginserver); 167 168 //data request 169 $sqlarchive="SELECT mois, nbr_visits, pages_view FROM crawlt_archive"; 170 171 $requetearchive = mysql_query($sqlarchive, $connexion) or die("MySQL query error"); 172 173 $nbrresult=mysql_num_rows($requetearchive); 174 if($nbrresult>=1) 175 { 176 while ($ligne = mysql_fetch_row($requetearchive)) 177 { 178 $sitetodisplay = explode('-',$ligne[0]); 179 if($sitetodisplay[1]==$site) 180 { 181 $data=$sitetodisplay[0]; 182 $archivdate=explode('/',$data); 183 $archivperiod =mktime(0,0,0,$archivdate[0], 1, $archivdate[1]); 184 if($archivperiod >=$beginperiod) 185 { 186 $usearchive=1; 187 } 188 189 } 190 } 191 } 192 193 } 194 195 196 //display-------------------------------------------------------------------------------------------------- 197 198 $crawlerdisplay=htmlentities($crawler); 199 $addressdisplay=htmlentities($address); 200 $infodisplay=htmlentities($info); 201 echo"<br><br><div class=\"content\">\n"; 202 echo crawltbackforward($crawlerdisplay,$period,$daytodaylocal,$monthtodaylocal,$yeartodaylocal,$daybeginlocal,$monthbeginlocal,$yearbeginlocal,$dayendweek,$monthendweek,$yearendweek,$crawler,$navig,$site,$graphpos); 203 204 //ua table 205 echo"<div class='tableau' align='center' onmouseover=\"javascript:montre();\">\n"; 206 echo"<table cellpadding='0px' cellspacing='0' width='100%'>\n"; 207 echo"<tr><th class='tableau1'>\n"; 208 echo"".$language['user_agent_or_ip']."\n"; 209 echo"</th>\n"; 210 echo"<th class='tableau2'>\n"; 211 echo"".$language['Origin']."\n"; 212 echo"</th></tr>\n"; 213 214 $nbline=sizeof($uagent); 215 $nb=0; 216 foreach ($uagent as $ua) 217 { 218 $uadisplay=htmlentities($ua); 219 echo"<tr><td class='tableau3'>".$uadisplay."</td>\n"; 220 if($nb==0) 221 { 222 echo"<td class='tableau5' rowspan=".$nbline."><a href=\"$addressdisplay\">".$infodisplay."</a></td></tr>\n"; 223 } 224 else 225 { 226 echo"</tr>\n"; 227 } 228 $nb=2; 229 } 230 echo"</table></div><br>\n"; 231 232 233 echo"</div>\n"; 234 235 236 //graph 237 echo"<div align='center'>\n"; 238 echo"<img src=\"./graphs/page-graph.php?nbrpageview=$nbrtotpages&nbrpagestotal=$nbrpagestotal[$site]&crawltlang=$crawltlang\" alt=\"graph\" width=\"500\" heigth=\"175\"/>\n"; 239 echo"</div>\n"; 240 241 242 243 244 echo"<div class='tableau' align='center'>\n"; 245 echo"<table cellpadding='0px' cellspacing='0' width='550px'>\n"; 246 echo"<tr><th class='tableau1'>\n"; 247 echo"".$language['nbr_tot_visits']."\n"; 248 echo"</th>\n"; 249 echo"<th class='tableau1'>\n"; 250 echo"".$language['nbr_tot_pages']."\n"; 251 echo"</th>\n"; 252 echo"<th class='tableau2'>\n"; 253 echo"".$language['pc-page-view']."\n"; 254 echo"</th></tr>\n"; 255 if($usearchive==0) 256 { 257 echo"<tr><td class='tableau3'>".numbdisp($nbrtotvisits)."</td>\n"; 258 echo"<td class='tableau3'>".numbdisp($nbrtotpages)."</td>\n"; 259 $pcvis = round(($nbrtotpages / $nbrpagestotal[$site])*100,1); 260 echo"<td class='tableau5'>".$pcvis."%</td></tr> \n"; 261 echo"</table></div><br>\n"; 262 } 263 else 264 { 265 echo"<tr><td class='tableau3'>".numbdisp($nbrtotvisits)."*</td>\n"; 266 echo"<td class='tableau3'>".numbdisp($nbrtotpages)."*</td>\n"; 267 $pcvis = round(($nbrtotpages / $nbrpagestotal[$site])*100,1); 268 echo"<td class='tableau5'>".$pcvis."%*</td></tr> \n"; 269 echo"</table>\n"; 270 echo"<p>*".$language['use-archive']."</p></div><br>\n"; 271 } 272 273 274 275 if($period != 5) 276 { 277 //graph 278 echo"<div class='graphvisits'>\n"; 279 //mapgraph 280 include "include/mapgraph.php"; 281 echo"<img src=\"./graphs/visit-graph.php?crawltlang=$crawltlang&period=$period&navig=$navig&graphname=$graphname\" USEMAP=\"#visit\" alt=\"graph\" width=\"700\" heigth=\"300\" border=\"0\"/>\n"; 282 echo"</div>\n"; 283 echo"<div class='imprimgraph'>\n"; 284 echo" <br><br><br><br><br><br></div>\n"; 285 } 286 287 //change text if more than x crawlers and display limited (value of x can be change in function.php,,it's displaynumber) 288 if($nbrtotpages>=$rowdisplay && $displayall=='no' && $period !=5) 289 { 290 echo"<br><h2>"; 291 printf($language['100_visit_per-crawler'],$rowdisplay); 292 echo"<br>\n"; 293 $crawlencode = urlencode($crawler); 294 echo"<span class=\"smalltext\"><a href=\"index.php?navig=$navig&period=$period&site=$site&crawler=$crawlencode&order=$order&displayall=yes&graphpos=$graphpos\">".$language['show_all']."</a></span></h2>"; 295 } 296 else 297 { 298 echo"<h2>".$language['visit_per-crawler']."</h2>\n"; 299 } 300 301 302 echo"<div class='tableau' align='center'>\n"; 303 echo"<table cellpadding='0px'; cellspacing='0' width='100%'>\n"; 304 if($order==3) 305 { 306 echo"<tr><th class='tableau1' colspan=\"2\">\n"; 307 echo"<form action=\"index.php\" method=\"POST\" >\n"; 308 echo "<input type=\"hidden\" name ='order' value=\"3\">\n"; 309 echo "<input type=\"hidden\" name ='period' value=\"$period\">\n"; 310 echo "<input type=\"hidden\" name ='graphpos' value=\"$graphpos\">\n"; 311 echo "<input type=\"hidden\" name ='navig' value=\"$navig\">\n"; 312 echo "<input type=\"hidden\" name ='crawler' value=\"$crawler\">\n"; 313 echo "<input type=\"hidden\" name ='site' value=\"$site\">\n"; 314 echo"<input type='submit' class='orderselect' value='".$language['page']."'>\n"; 315 echo"</form>\n"; 316 echo"</th>\n"; 317 } 318 else 319 { 320 echo"<tr><th class='tableau1' colspan=\"2\">\n"; 321 echo"<form action=\"index.php\" method=\"POST\" >\n"; 322 echo "<input type=\"hidden\" name ='order' value=\"3\">\n"; 323 echo "<input type=\"hidden\" name ='period' value=\"$period\">\n"; 324 echo "<input type=\"hidden\" name ='graphpos' value=\"$graphpos\">\n"; 325 echo "<input type=\"hidden\" name ='navig' value=\"$navig\">\n"; 326 echo "<input type=\"hidden\" name ='crawler' value=\"$crawler\">\n"; 327 echo "<input type=\"hidden\" name ='site' value=\"$site\">\n"; 328 echo"<input type='submit' class='order' value='".$language['page']."'>\n"; 329 echo"</form>\n"; 330 echo"</th>\n"; 331 } 332 if($order==2) 333 { 334 if($period !=5) 335 { 336 echo"<th class='tableau1' >\n"; 337 } 338 else 339 { 340 echo"<th class='tableau2' >\n"; 341 } 342 echo"<form action=\"index.php\" method=\"POST\" >\n"; 343 echo "<input type=\"hidden\" name ='order' value=\"2\">\n"; 344 echo "<input type=\"hidden\" name ='period' value=\"$period\">\n"; 345 echo "<input type=\"hidden\" name ='graphpos' value=\"$graphpos\">\n"; 346 echo "<input type=\"hidden\" name ='navig' value=\"$navig\">\n"; 347 echo "<input type=\"hidden\" name ='crawler' value=\"$crawler\">\n"; 348 echo "<input type=\"hidden\" name ='site' value=\"$site\">\n"; 349 echo"<input type='submit' class='orderselect' value='".$language['nbr_visits']."'>\n"; 350 echo"</form>\n"; 351 echo"</th>\n"; 352 } 353 else 354 { 355 if($period !=5) 356 { 357 echo"<th class='tableau1' >\n"; 358 } 359 else 360 { 361 echo"<th class='tableau2' >\n"; 362 } 363 echo"<form action=\"index.php\" method=\"POST\" >\n"; 364 echo "<input type=\"hidden\" name ='order' value=\"2\">\n"; 365 echo "<input type=\"hidden\" name ='period' value=\"$period\">\n"; 366 echo "<input type=\"hidden\" name ='graphpos' value=\"$graphpos\">\n"; 367 echo "<input type=\"hidden\" name ='navig' value=\"$navig\">\n"; 368 echo "<input type=\"hidden\" name ='crawler' value=\"$crawler\">\n"; 369 echo "<input type=\"hidden\" name ='site' value=\"$site\">\n"; 370 echo"<input type='submit' class='order' value='".$language['nbr_visits']."'>\n"; 371 echo"</form>\n"; 372 echo"</th>\n"; 373 } 374 if($period !=5) 375 { 376 if($order==0) 377 { 378 echo"<th class='tableau2'>\n"; 379 echo"<form action=\"index.php\" method=\"POST\" >\n"; 380 echo "<input type=\"hidden\" name ='order' value=\"0\">\n"; 381 echo "<input type=\"hidden\" name ='period' value=\"$period\">\n"; 382 echo "<input type=\"hidden\" name ='graphpos' value=\"$graphpos\">\n"; 383 echo "<input type=\"hidden\" name ='navig' value=\"$navig\">\n"; 384 echo "<input type=\"hidden\" name ='crawler' value=\"$crawler\">\n"; 385 echo "<input type=\"hidden\" name ='site' value=\"$site\">\n"; 386 echo"<input type='submit' class='orderselect' value='".$language['date_visits']."'>\n"; 387 echo"</form>\n"; 388 echo"</th></tr>\n"; 389 } 390 else 391 { 392 echo"<th class='tableau2'>\n"; 393 echo"<form action=\"index.php\" method=\"POST\" >\n"; 394 echo "<input type=\"hidden\" name ='order' value=\"0\">\n"; 395 echo "<input type=\"hidden\" name ='period' value=\"$period\">\n"; 396 echo "<input type=\"hidden\" name ='graphpos' value=\"$graphpos\">\n"; 397 echo "<input type=\"hidden\" name ='navig' value=\"$navig\">\n"; 398 echo "<input type=\"hidden\" name ='crawler' value=\"$crawler\">\n"; 399 echo "<input type=\"hidden\" name ='site' value=\"$site\">\n"; 400 echo"<input type='submit' class='order' value='".$language['date_visits']."'>\n"; 401 echo"</form>\n"; 402 echo"</th></tr>\n"; 403 } 404 } 405 //counter for alternate color lane 406 $comptligne=2; 407 408 409 foreach ($nbvisits as $key => $value) 410 { 411 $page1display = crawltcutkeyword($key,'60'); 412 $page1encode=urlencode($key); 413 414 //to avoid problem if the url is enter in the database with http:// 415 if (!eregi("^http://", $urlsite[$site])) 416 { 417 $urlpage="http://".$urlsite[$site].$key; 418 } 419 else 420 { 421 $urlpage= $urlsite[$site].$key; 422 } 423 424 425 if ($comptligne%2 ==0) 426 { 427 echo"<tr><td class='tableau3g'"; 428 if($keywordcut==1) 429 { 430 echo"onmouseover=\"javascript:montre('smenu".($comptligne+40)."');\" onmouseout=\"javascript:montre();\""; 431 } 432 echo"> <a href='index.php?navig=4&period=".$period."&site=".$site."&crawler=".$page1encode."&graphpos=".$graphpos."' rel='nofollow'>".$page1display."</a></td>\n"; 433 echo"<td class='tableau6' width=\"8%\">\n"; 434 echo"<a href='".$urlpage."' rel='nofollow'><img src=\"./images/page.png\" width=\"16\" height=\"16\" border=\"0\" ></a>\n"; 435 echo"</td> \n"; 436 if($period !=5) 437 { 438 echo"<td class='tableau3'>".numbdisp($nbvisits[$key])."</td>\n"; 439 echo"<td class='tableau5'>".$lastdatedisplay[$key]."</td></tr>\n"; 440 } 441 else 442 { 443 echo"<td class='tableau5'>".numbdisp($nbvisits[$key])."</td></tr>\n"; 444 } 445 } 446 else 447 { 448 echo"<tr><td class='tableau30g'"; 449 if($keywordcut==1) 450 { 451 echo"onmouseover=\"javascript:montre('smenu".($comptligne+40)."');\" onmouseout=\"javascript:montre();\""; 452 } 453 echo"> <a href='index.php?navig=4&period=".$period."&site=".$site."&crawler=".$page1encode."&graphpos=".$graphpos."' rel='nofollow'>".$page1display."</a></td>\n"; 454 echo"<td class='tableau60' width=\"8%\">\n"; 455 echo"<a href='".$urlpage."' rel='nofollow'><img src=\"./images/page.png\" width=\"16\" height=\"16\" border=\"0\" ></a>\n"; 456 echo"</td> \n"; 457 if($period !=5) 458 { 459 echo"<td class='tableau30'>".numbdisp($nbvisits[$key])."</td>\n"; 460 echo"<td class='tableau50'>".$lastdatedisplay[$key]."</td></tr>\n"; 461 } 462 else 463 { 464 echo"<td class='tableau50'>".numbdisp($nbvisits[$key])."</td></tr>\n"; 465 } 466 } 467 if($keywordcut==1) 468 { 469 if($period==0 OR $period>=1000) 470 { 471 $step=25; 472 } 473 else 474 { 475 $step=30; 476 } 477 echo"<div id=\"smenu".($comptligne+40)."\" style=\"display:none; font-size:14px; font-weight:bold; color:#ff0000; font-family:Verdana,Geneva, Arial, Helvetica, Sans-Serif; text-align:left; border:2px solid navy; position:absolute; top:".(900+(($comptligne-3)*$step))."px; left:5px; background:#fff;\">\n"; 478 echo" ".crawltcuturl($key,'92')." \n"; 479 echo"</div>\n"; 480 } 481 $comptligne++; 482 483 } 484 485 echo"</table>\n"; 486 echo"<br>\n"; 487 488 489 } 490 else 491 { 492 $sqlstats2 = "SELECT * FROM crawlt_crawler 493 WHERE crawlt_crawler.crawler_name='".sql_quote($crawler)."' 494 ORDER BY crawler_name ASC"; 495 496 $requetestats2 = mysql_query($sqlstats2, $connexion) or die("MySQL query error"); 497 498 //mysql connexion close 499 mysql_close($connexion); 500 501 $nbrresult2=mysql_num_rows($requetestats2); 502 if ($nbrresult2==0) 503 { 504 echo"<h1>Hacking attempt !!!!</h1>"; 505 exit(); 506 } 507 508 509 while ($ligne = mysql_fetch_object($requetestats2)) 510 { 511 $address=$ligne->crawler_url; 512 $info=$ligne->crawler_info; 513 $agent=$ligne->crawler_user_agent; 514 $uagent[]=$agent; 515 } 516 517 $crawlerdisplay=htmlentities($crawler); 518 $addressdisplay=htmlentities($address); 519 $infodisplay=htmlentities($info); 520 521 522 echo"<div align='center'>\n"; 523 echo crawltbackforward($crawlerdisplay,$period,$daytodaylocal,$monthtodaylocal,$yeartodaylocal,$daybeginlocal,$monthbeginlocal,$yearbeginlocal,$dayendweek,$monthendweek,$yearendweek,$crawler,$navig,$site,$graphpos); 524 525 //ua table 526 echo"<div class='tableau' align='center'>\n"; 527 echo"<table cellpadding='0px' cellspacing='0' width='100%'>\n"; 528 echo"<tr><th class='tableau1'>\n"; 529 echo"".$language['user_agent']."\n"; 530 echo"</th>\n"; 531 echo"<th class='tableau2'>\n"; 532 echo"".$language['Origin']."\n"; 533 echo"</th></tr>\n"; 534 $uagent=array_unique($uagent); 535 $nbline=sizeof($uagent); 536 $nb=0; 537 foreach ($uagent as $ua) 538 { 539 $uadisplay=htmlentities($ua); 540 echo"<tr><td class='tableau3'>".$uadisplay."</td>\n"; 541 if($nb==0) 542 { 543 echo"<td class='tableau5' rowspan=".$nbline."><a href=\"$addressdisplay\">".$infodisplay."</a></td></tr>\n"; 544 } 545 else 546 { 547 echo"</tr>\n"; 548 } 549 $nb=2; 550 } 551 echo"</table></div><br>\n"; 552 553 554 555 echo"<h1>".$language['no_visit']."</h1>\n"; 556 echo"<br>\n"; 557 558 } 559 560 ?>
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 |