| [ 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: admindatasuppress.php 14 //---------------------------------------------------------------------- 15 16 if (!defined('IN_CRAWLT_ADMIN')) 17 { 18 echo"<h1>Hacking attempt !!!!</h1>"; 19 exit(); 20 } 21 22 if(isset($_POST['suppressdata'])) 23 { 24 $suppressdata = (int)$_POST['suppressdata']; 25 } 26 else 27 { 28 $suppressdata = 0; 29 } 30 31 if(isset($_POST['suppressdataok'])) 32 { 33 $suppressdataok = (int)$_POST['suppressdataok']; 34 } 35 else 36 { 37 $suppressdataok = 0; 38 } 39 40 if($suppressdata==1) 41 42 { 43 44 if(isset($_POST['datatosuppress'])) 45 { 46 $datatosuppress = (int)$_POST['datatosuppress']; 47 } 48 else 49 { 50 header("Location:../index.php"); 51 exit(); 52 } 53 54 55 56 if($suppressdataok==1) 57 { 58 //data suppression 59 60 //database connection 61 $connexion = mysql_connect($crawlthost,$crawltuser,$crawltpassword) or die("MySQL connection to database problem"); 62 $selection = mysql_select_db($crawltdb) or die("MySQL database selection problem"); 63 64 //period calculation 65 66 $today = date("Y-m-d"); 67 $today2 = explode('-', $today); 68 $yeartoday = $today2[0]; 69 $monthtoday = $today2[1]; 70 $daytoday = $today2[2]; 71 72 73 74 if ($datatosuppress==1) 75 { 76 $ts = mktime(0,0,0,$monthtoday, $daytoday, $yeartoday) - 31536000; 77 } 78 elseif ($datatosuppress==2) 79 { 80 $ts = mktime(0,0,0,$monthtoday, $daytoday, $yeartoday) - 15768000; 81 } 82 elseif ($datatosuppress==3) 83 { 84 $ts = mktime(0,0,0,$monthtoday, $daytoday, $yeartoday) - 2628000; 85 } 86 else 87 { 88 echo"<h1>Hacking attempt !!!!</h1>"; 89 exit(); 90 } 91 92 $datetosuppress = date("Y-m-d",$ts); 93 //treatment of $datetosuppress to have complete month 94 $suppress = explode('-', $datetosuppress); 95 $yearsuppress = $suppress[0]; 96 $monthsuppress = $suppress[1]; 97 98 $datetosuppress=$yearsuppress."-".$monthsuppress."-01"; 99 100 //archive creation 101 //query to get the number of visits and page view per month/year-site 102 103 $sqlstats = "SELECT CONCAT(FROM_UNIXTIME(UNIX_TIMESTAMP(date), '%m/%Y'),'-',crawlt_site_id_site) ,COUNT(DISTINCT id_visit),COUNT(DISTINCT crawlt_pages_id_page) FROM crawlt_visits 104 WHERE date < '".sql_quote($datetosuppress)."' 105 GROUP BY CONCAT(FROM_UNIXTIME(UNIX_TIMESTAMP(date), '%m/%Y'),'-',crawlt_site_id_site)"; 106 107 108 $requetestats = mysql_query($sqlstats, $connexion) or die("MySQL query error"); 109 $nbrresult=mysql_num_rows($requetestats); 110 111 if($nbrresult>=1) 112 { 113 while ($ligne = mysql_fetch_row($requetestats)) 114 { 115 $nbvisits[$ligne[0]]=$ligne[1]; 116 $nbrpagesview[$ligne[0]]=$ligne[2]; 117 $listmonth[$ligne[0]]=$ligne[0]; 118 } 119 120 121 122 123 //query to get the top 3 crawler (in number of visit) for each month/year-site 124 $sqlstats = "SELECT CONCAT(FROM_UNIXTIME(UNIX_TIMESTAMP(date), '%m/%Y'),'-',crawlt_site_id_site,'+',crawler_name) ,COUNT(DISTINCT id_visit) AS nbvisit FROM crawlt_visits, crawlt_crawler 125 WHERE crawlt_visits.crawlt_crawler_id_crawler=crawlt_crawler.id_crawler 126 AND date < '".sql_quote($datetosuppress)."' 127 GROUP BY CONCAT(FROM_UNIXTIME(UNIX_TIMESTAMP(date), '%m/%Y'),'-',crawlt_site_id_site,'+',crawler_name) 128 ORDER BY nbvisit DESC"; 129 130 $requetestats = mysql_query($sqlstats, $connexion) or die("MySQL query error"); 131 $nbrresult=mysql_num_rows($requetestats); 132 133 if($nbrresult>=1) 134 { 135 while ($ligne = mysql_fetch_row($requetestats)) 136 { 137 $monthsitecrawler = explode('+', $ligne[0]); 138 $monthsite = $monthsitecrawler[0]; 139 $crawler = $monthsitecrawler[1]; 140 ${'topcrawler'.$monthsite}[]=$crawler; 141 ${'nbvisits'.$monthsite}[$crawler]= $ligne[1]; 142 } 143 } 144 145 146 147 //query to get the top 3 crawlers (in number of page viewed) for each month/year-site 148 $sqlstats = "SELECT CONCAT(FROM_UNIXTIME(UNIX_TIMESTAMP(date), '%m/%Y'),'-',crawlt_site_id_site,'+',crawler_name) ,COUNT(DISTINCT crawlt_pages_id_page) AS nbpage FROM crawlt_visits, crawlt_crawler 149 WHERE crawlt_visits.crawlt_crawler_id_crawler=crawlt_crawler.id_crawler 150 AND date < '".sql_quote($datetosuppress)."' 151 GROUP BY CONCAT(FROM_UNIXTIME(UNIX_TIMESTAMP(date), '%m/%Y'),'-',crawlt_site_id_site,'+',crawler_name) 152 ORDER BY nbpage DESC"; 153 154 $requetestats = mysql_query($sqlstats, $connexion) or die("MySQL query error"); 155 $nbrresult=mysql_num_rows($requetestats); 156 157 if($nbrresult>=1) 158 { 159 while ($ligne = mysql_fetch_row($requetestats)) 160 { 161 $monthsitecrawler = explode('+', $ligne[0]); 162 $monthsite = $monthsitecrawler[0]; 163 $crawler = $monthsitecrawler[1]; 164 ${'topcrawlerpage'.$monthsite}[]=$crawler; 165 ${'nbpages'.$monthsite}[$crawler]= $ligne[1]; 166 } 167 } 168 169 170 //preparation of the request to add the datas in the archive table 171 foreach ($listmonth as $month) 172 { 173 //caculation of number of visits for the month 174 $nbrvisits=$nbvisits[$month]; 175 //caculation of number of pages view for the month 176 $nbrpages= $nbrpagesview[$month]; 177 //caculation of top visit for the month 178 179 180 if(isset(${'topcrawler'.$month}[0])) 181 { 182 $tv1 = "1)".${'topcrawler'.$month}[0]." (".${'nbvisits'.$month}[${'topcrawler'.$month}[0]]." ".$language['nbr_visits'].")"; 183 } 184 else 185 { 186 $tv1=""; 187 } 188 if(isset(${'topcrawler'.$month}[1])) 189 { 190 $tv2 = "2)".${'topcrawler'.$month}[1]." (".${'nbvisits'.$month}[${'topcrawler'.$month}[1]]." ".$language['nbr_visits'].")"; 191 } 192 else 193 { 194 $tv2=""; 195 } 196 if(isset(${'topcrawler'.$month}[2])) 197 { 198 $tv3 = "3)".${'topcrawler'.$month}[2]." (".${'nbvisits'.$month}[${'topcrawler'.$month}[2]]." ".$language['nbr_visits'].")"; 199 } 200 else 201 { 202 $tv3=""; 203 } 204 205 206 if(isset(${'topcrawlerpage'.$month}[0])) 207 { 208 $tpv1 = "1)".${'topcrawlerpage'.$month}[0]." (".${'nbpages'.$month}[${'topcrawlerpage'.$month}[0]]." ".$language['nbr_pages'].")"; 209 } 210 else 211 { 212 $tpv1=""; 213 } 214 if(isset(${'topcrawlerpage'.$month}[1])) 215 { 216 $tpv2 = "2)".${'topcrawlerpage'.$month}[1]." (".${'nbpages'.$month}[${'topcrawlerpage'.$month}[1]]." ".$language['nbr_pages'].")"; 217 } 218 else 219 { 220 $tpv2=""; 221 } 222 if(isset(${'topcrawlerpage'.$month}[2])) 223 { 224 $tpv3 = "3)".${'topcrawlerpage'.$month}[2]." (".${'nbpages'.$month}[${'topcrawlerpage'.$month}[2]]." ".$language['nbr_pages'].")"; 225 } 226 else 227 { 228 $tpv3=""; 229 } 230 231 232 233 //insertion request 234 $sqlarchive="INSERT INTO crawlt_archive (mois, nbr_visits, pages_view, top_visits_1,top_visits_2,top_visits_3,top_pages_view_1,top_pages_view_2,top_pages_view_3) VALUES ('".sql_quote($month)."', '".sql_quote($nbrvisits)."', '".sql_quote($nbrpages)."', '".sql_quote($tv1)."', '".sql_quote($tv2)."', '".sql_quote($tv3)."', '".sql_quote($tpv1)."', '".sql_quote($tpv2)."', '".sql_quote($tpv3)."')"; 235 $requetearchive = mysql_query($sqlarchive, $connexion) or die("MySQL query error"); 236 237 } 238 239 240 if($requetearchive) 241 { 242 243 //database query to suppress the data 244 $sqldelete="DELETE FROM crawlt_visits WHERE date < '".sql_quote($datetosuppress)."'"; 245 $requetedelete = mysql_query($sqldelete, $connexion) or die("MySQL query error"); 246 247 //database query to optimize the table 248 $sqloptimize = "OPTIMIZE TABLE crawlt_visits"; 249 $requeteoptimize = mysql_query($sqloptimize, $connexion) or die("MySQL query error"); 250 251 } 252 253 //emptied the cache table 254 $sqlcache = "TRUNCATE TABLE crawlt_cache"; 255 $requetecache = mysql_query($sqlcache, $connexion) or die("MySQL query error"); 256 257 if($requetedelete) 258 { 259 echo"<br><br><h1>".$language['data_suppress_ok']."</h1>\n"; 260 261 echo"<div class=\"form\">\n"; 262 echo"<form action=\"index.php\" method=\"POST\" >\n"; 263 echo "<input type=\"hidden\" name ='navig' value='6'>\n"; 264 echo"<input name='ok' type='submit' value='OK' size='20'>\n"; 265 echo"</form>\n"; 266 echo"</div>\n"; 267 } 268 else 269 { 270 echo"<br><br><h1>".$language['data_suppress_no_ok']."</h1>\n"; 271 272 echo"<div class=\"form\">\n"; 273 echo"<form action=\"index.php\" method=\"POST\" >\n"; 274 echo "<input type=\"hidden\" name ='navig' value='6'>\n"; 275 echo"<input name='ok' type='submit' value='OK' size='20'>\n"; 276 echo"</form>\n"; 277 echo"</div>\n"; 278 } 279 } 280 else 281 { 282 echo"<h1>".$language['no_data_to_suppress']."</h1>"; 283 } 284 285 } 286 else 287 { 288 //validation of suppression 289 290 //display 291 292 if ($datatosuppress==1) 293 { 294 $datatosuppressdisplay=$language['one_year_data']; 295 } 296 elseif ($datatosuppress==2) 297 { 298 $datatosuppressdisplay=$language['six_months_data']; 299 } 300 elseif ($datatosuppress==3) 301 { 302 $datatosuppressdisplay=$language['one_month_data']; 303 } 304 else 305 { 306 echo"<h1>Hacking attempt !!!!</h1>"; 307 exit(); 308 } 309 310 echo"<br><br><h1>".$language['data_suppress_validation']."$datatosuppressdisplay ?</h1>\n"; 311 312 echo"<div class=\"form\">\n"; 313 echo"<form action=\"index.php\" method=\"POST\" >\n"; 314 echo "<input type=\"hidden\" name ='navig' value='6'>\n"; 315 echo "<input type=\"hidden\" name ='validform' value=\"17\">"; 316 echo "<input type=\"hidden\" name ='suppressdata' value=\"1\">\n"; 317 echo "<input type=\"hidden\" name ='suppressdataok' value=\"1\">\n"; 318 echo "<input type=\"hidden\" name ='datatosuppress' value=\"$datatosuppress\">\n"; 319 echo"<table class=\"centrer\">\n"; 320 echo"<tr>\n"; 321 echo"<td colspan=\"2\">\n"; 322 echo"<input name='ok' type='submit' value=' ".$language['yes']." ' size='20'>\n"; 323 echo"</td>\n"; 324 echo"</tr>\n"; 325 echo"</table>\n"; 326 echo"</form>\n"; 327 echo"</div>"; 328 329 echo"<div class=\"form\">\n"; 330 echo"<form action=\"index.php\" method=\"POST\" >\n"; 331 echo "<input type=\"hidden\" name ='navig' value='6'>\n"; 332 echo "<input type=\"hidden\" name ='suppressdata' value=\"0\">\n"; 333 echo "<input type=\"hidden\" name ='suppressdataok' value=\"0\">\n"; 334 echo"<table class=\"centrer\">\n"; 335 echo"<tr>\n"; 336 echo"<td colspan=\"2\">\n"; 337 echo"<input name='ok' type='submit' value=' ".$language['no']." ' size='20'>\n"; 338 echo"</td>\n"; 339 echo"</tr>\n"; 340 echo"</table>\n"; 341 echo"</form>\n"; 342 echo"</div>"; 343 344 } 345 346 } 347 else 348 { 349 350 echo"<br><br><h1>".$language['data_suppress']."</h1>\n"; 351 352 $connexion = mysql_connect($crawlthost,$crawltuser,$crawltpassword) or die("MySQL connection to database problem"); 353 $selection = mysql_select_db($crawltdb) or die("MySQL database selection problem"); 354 355 356 $sql = "SELECT * FROM crawlt_visits ORDER BY date ASC"; 357 358 $requete = mysql_query($sql, $connexion) or die("MySQL query error"); 359 360 $nbrresult=mysql_num_rows($requete); 361 if($nbrresult>=1) 362 { 363 $ligne = mysql_fetch_object($requete); 364 365 $date=$ligne->date; 366 $date2 = explode('-', $date); 367 $yeardate = $date2[0]; 368 $monthdate = $date2[1]; 369 $daydate = $date2[2]; 370 $daydate2 = explode(' ',$daydate); 371 372 373 if ($crawltlang=='english') 374 { 375 echo"<h2>".$language['oldest_data']."$monthdate /".$daydate2[0]."/ $yeardate</h2>"; 376 } 377 else 378 { 379 echo"<h2>".$language['oldest_data']."".$daydate2[0]." / $monthdate / $yeardate</h2>"; 380 } 381 echo"<br><br><table>\n"; 382 echo"<tr><td valign='top'>\n"; 383 echo"".$language['data_suppress2']."\n"; 384 echo"</td><td>\n"; 385 echo"<div class=\"form3\">\n"; 386 echo"<form action=\"index.php\" method=\"POST\" >\n"; 387 echo"<input type=\"radio\" name=\"datatosuppress\" value=\"1\" checked>".$language['one_year_data']."<br><br>\n"; 388 echo"<input type=\"radio\" name=\"datatosuppress\" value=\"2\">".$language['six_months_data']."<br><br>\n"; 389 echo"<input type=\"radio\" name=\"datatosuppress\" value=\"3\">".$language['one_month_data']."<br><br>\n"; 390 echo "<input type=\"hidden\" name =\"suppressdata\" value=\"1\">\n"; 391 echo "<input type=\"hidden\" name =\"navig\" value=\"6\">\n"; 392 echo "<input type=\"hidden\" name =\"validform\" value=\"17\">\n"; 393 echo"<input name='ok' type='submit' value='OK' size='20'>\n"; 394 echo"</form>\n"; 395 echo"</div>"; 396 echo"</td></tr></table>\n"; 397 echo"<p>".$language['data_suppress3']."</p>\n"; 398 } 399 else 400 { 401 echo"<h1>".$language['no_data']."</h1>"; 402 } 403 404 } 405 ?>
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 |