[ Index ] |
|
Code source de phpMyVisites 2.3 |
1 <?php 2 /* 3 * phpMyVisites : website statistics and audience measurements 4 * Copyright (C) 2002 - 2006 5 * http://www.phpmyvisites.net/ 6 * phpMyVisites is free software (license GNU/GPL) 7 * Authors : phpMyVisites team 8 */ 9 10 // $Id: phpmyvisites.php 218 2007-06-02 07:15:48Z cmil $ 11 12 define('SAVE_STAT', true ); // default true 13 define('LOOK_FOR_COOKIE', true); // default true 14 define('DEBUG', false); // default false 15 define('TRACE_IN_FILES', false); // default false 16 define('INCLUDE_PATH', '.'); 17 define('PRINT_COOKIE_CONTENT', false); // debug only : display cookie content for the current domain 18 define('PRINT_ALL_COOKIES_CONTENT', false); // debug only : display all pmv cookies for the current domain 19 20 // TODO dans le test du referer appartient au site, testez également en plus 21 // des sitesUrls le host de l'url de la page current sur le host de l'url ref 22 23 @ignore_user_abort(true); 24 @set_time_limit(0); 25 @error_reporting(E_ALL); 26 27 require_once INCLUDE_PATH."/core/include/Lang.class.php"; 28 require_once INCLUDE_PATH.'/config.inc.php'; 29 require_once INCLUDE_PATH."/core/include/Logs.functions.php"; 30 require_once INCLUDE_PATH."/core/include/common.functions.php"; 31 require_once INCLUDE_PATH."/core/include/Cookie.class.php"; 32 require_once INCLUDE_PATH."/core/include/Site.class.php"; 33 require_once INCLUDE_PATH."/core/include/PmvConfig.class.php"; 34 35 if(!SAVE_STAT) 36 { 37 redirectToUrlIfNecessary(); 38 39 // else, display pixel 40 $img = INCLUDE_PATH . "/images/logos/pixel.gif"; 41 header("Content-type: image/gif"); 42 readfile($img); 43 exit; 44 } 45 46 // hack for not to show tables (because getCurrentCompleteUrl bugs 47 // with url containing another url in one parameter) 48 $GLOBALS['currentModuleIsLogModule'] = true; 49 50 $c =& PmvConfig::getInstance(); 51 52 $db =& Db::getInstance(); 53 $db->connect(); 54 55 // when no get specified, display a marketing page :) 56 if(sizeof($_GET) === 0) 57 { 58 require_once INCLUDE_PATH."/core/include/Lang.class.php"; 59 $l =& Lang::getInstance();; 60 displayPageWhenEmptyGet(); 61 exit; 62 } 63 64 if(DEBUG) 65 { 66 require_once INCLUDE_PATH."/core/include/functions.php"; 67 } 68 69 if(DEBUG) 70 ob_start(); 71 72 // - imprimer doc mysql "optimisation" 73 74 /* 75 * Get page & visitor information 76 */ 77 $idSite = getRequestVar('id', null, 'numeric'); 78 79 $GLOBALS['cookie'] = new Cookie( COOKIE_PMVLOG_NAME . $idSite); 80 81 if(LOOK_FOR_COOKIE && $GLOBALS['cookie']->isDefined()) 82 { 83 printDebug("<b>Cookie at the beginning (size : ".$GLOBALS['cookie']->getSize()." bytes)</b> :<br>"); 84 printDebug($GLOBALS['cookie']->get()); 85 $returningVisitor = 1; 86 } 87 else 88 { 89 $returningVisitor = 0; 90 printDebug("<b>Cookie not found !</b><br><br>"); 91 } 92 93 $flash = getRequestVar('flash', 0, 'numeric'); 94 $director = getRequestVar('director', 0, 'numeric'); 95 $quicktime = getRequestVar('quicktime', 0, 'numeric'); 96 $realPlayer = getRequestVar('realplayer', 0, 'numeric'); 97 $windowsMedia = getRequestVar('windowsmedia', 0, 'numeric'); 98 $cookieAccept = getRequestVar('cookie', 0, 'numeric'); // Don't name $cookie because conflict with $GLOBALS['cookie'] 99 $pdf = getRequestVar('pdf', 0, 'numeric'); 100 $java = getRequestVar('java', -1, 'numeric'); 101 if ($java == -1) { 102 $javascript = 0; 103 $java = 0; 104 } 105 else { 106 $javascript = 1; 107 } 108 109 $refererUrl = getRequestVar('ref', ''); 110 $typeTag = getRequestVar('type', "", 'string'); 111 112 113 $site = new Site($idSite); 114 115 // debug cookie 116 if(PRINT_ALL_COOKIES_CONTENT) 117 { 118 require_once INCLUDE_PATH . "/core/include/DataModel.class.php"; 119 $sitesId = $site->getSitesId(); 120 foreach($sitesId as $sid) 121 { 122 $c = new Cookie( COOKIE_PMVLOG_NAME . $sid); 123 print($c->toString()); 124 } 125 exit; 126 } 127 else if(PRINT_COOKIE_CONTENT) 128 { 129 print($GLOBALS['cookie']->toString()); 130 exit; 131 } 132 133 /* 134 * site urls 135 */ 136 // commented in 2.3b3 because its actually not used 137 //if(!$siteUrls = $GLOBALS['cookie']->getVar('site_urls')) 138 //{ 139 // $siteUrlsBefore = $site->getUrls(); 140 // $siteUrls = array(); 141 // if(is_array($siteUrlsBefore)) 142 // { 143 // foreach($siteUrlsBefore as $url) 144 // { 145 // $url = trim($url); 146 // if( array_search( $url, $siteUrls) === false 147 // && !empty($url) ) 148 // { 149 // $siteUrls[] = $url; 150 // } 151 // } 152 // } 153 // // save array of site urls in the cookie 154 // $GLOBALS['cookie']->setVar('site_urls', $siteUrls); 155 //} 156 157 /* 158 * site info 159 */ 160 //if(!$siteInfo = $GLOBALS['cookie']->getVar('site_info')) 161 //{ 162 // $siteInfo = $site->getInfo(); 163 // 164 // // save array of site urls in the cookie 165 // $GLOBALS['cookie']->setVar('site_info', $siteInfo); 166 //} 167 168 169 $logo = $site->getLogo(); 170 $siteParams = $site->getParams(); 171 172 $pageUrl = getRequestVar('url', '', 'string'); 173 if ($pageUrl == "") { 174 // May be it is a bot !! 175 printDebug("No url : may be it's a bot ! So we don't save this visit !"); 176 redirectToUrlIfNecessary(); 177 loadImage($logo, $idSite); 178 exit(); 179 } 180 // After modif js where we remove all before // in url 181 // We add http: to not have error in parse_url 182 if (substr($pageUrl, 0, 2) == "//") { 183 $pageUrl = "http:".$pageUrl; 184 } 185 /* 186 // Verify that url is in your site 187 $trouve = false; 188 foreach($siteUrls as $url) 189 { 190 $posInUrl = strpos($pageUrl, $url); 191 $trouve = ($posInUrl == 0); 192 } 193 if (! $trouve) { 194 printDebug("Url is not ok !"); 195 redirectToUrlIfNecessary(); 196 loadImage($logo, $idSite); 197 exit(); 198 } 199 */ 200 /** 201 * exit if visitor is cookie excluded from the stats 202 */ 203 204 if(isset($_COOKIE[COOKIE_NAME_NO_STAT.$site->getId()])) 205 { 206 printDebug("Excluded from stats with the cookie!"); 207 208 redirectToUrlIfNecessary(); 209 loadImage($logo, $idSite); 210 } 211 212 /* 213 * page variables 214 */ 215 $a_vars = getRequestVar('a_vars', array(), 'array'); 216 217 /* 218 * visitor config, as saved in the database 219 */ 220 $userAgent = secureVar(@$_SERVER['HTTP_USER_AGENT']); 221 $os = getOs($userAgent); 222 $a_browser = getBrowserInfo($userAgent); 223 $resolution = getRequestVar('res', 'unknown', 'string'); 224 $colorDepth = getRequestVar('col', 32, 'numeric'); 225 226 $browserLang = secureVar(@$_SERVER['HTTP_ACCEPT_LANGUAGE']); 227 228 $localTime = getRequestVar('h',date("H"),'numeric').':'. 229 getRequestVar('m',date("i"),'numeric').':'.getRequestVar('s',date("s"),'numeric'); 230 231 232 233 // assign pageCategory default value of the parse_url::path?query 234 $pageUrlParamsProcessed = processParams($pageUrl, $siteParams); 235 236 // fix add site.com because else parse_url bugs with ':' in query string 237 if(!ereg('^http://',$pageUrlParamsProcessed)) 238 { 239 $urlParse = parse_url('http://site.com'.$pageUrlParamsProcessed); 240 } 241 else 242 { 243 $urlParse = parse_url($pageUrlParamsProcessed); 244 } 245 246 if(isset($urlParse['path'])) 247 { 248 $pageNameDefault = substr($urlParse['path'], 1); 249 } 250 251 if(isset($urlParse['query'])) 252 { 253 $pageNameDefault .= '?'.$urlParse['query']; 254 } 255 256 if( (!isset($pageNameDefault) 257 || strcmp($pageNameDefault, '')===0) 258 && isset($urlParse['host']) 259 ) 260 { 261 $pageNameDefault = DEFAULT_PAGE_NAME; 262 } 263 else if(!isset($pageNameDefault)) 264 { 265 $pageNameDefault = null; 266 } 267 printDebug("PageNameDefault : " . $pageNameDefault); 268 269 // stripslashed because otherwise pageName if value is pageNameDefault is slashed twice 270 $pageCompleteName = utf8_encode(getRequestVar('pagename' , 271 stripslashes(html_entity_decode($pageNameDefault)) 272 ) 273 ); 274 $pageCompleteName = str_replace(array("\n", "\r"), '', $pageCompleteName); 275 $pageCompleteName = str_replace(array("?"), '', $pageCompleteName); 276 277 278 if ($typeTag != "") { 279 $pageCompleteName = $typeTag.":".$pageCompleteName; 280 } 281 // works only on 'path' of this url because the query may contain delimiter ! 282 $file = ''; 283 //if(substr($pageCompleteName, 0, 5) === PREFIX_FILES) 284 if(isPrefixTag ($pageCompleteName)) 285 { 286 // $file = PREFIX_FILES; 287 $file = getPrefixTag($pageCompleteName); 288 } 289 290 printDebug("<br>Page complete name:".$pageCompleteName); 291 $urlParse = parse_url('http://site.com/'.$pageCompleteName); 292 293 294 $pageCompleteNamePath = substr($urlParse['path'],1); 295 $lastDelimiter = strrpos($pageCompleteNamePath, CATEGORY_DELIMITER); 296 printDebug("<br>Page name complete path:".$pageCompleteNamePath); 297 298 printDebug("<br>Pos last delimiter : $lastDelimiter"); 299 if($lastDelimiter !== false) 300 { 301 // in the $pageCompleteName "g1>g2>page" select only "g1>g2" 302 $pageCategory = substr($pageCompleteNamePath, 0, $lastDelimiter); 303 // $pageCategory = str_replace( PREFIX_FILES, '', $pageCategory); 304 $tabTag = split(",", PREFIX_ALL_TAG); 305 foreach ($tabTag as $info) { 306 $pageCategory = str_replace($info, '', $pageCategory); 307 } 308 if($pageCategory == '/' 309 || $pageCategory == ' ' 310 || $pageCategory == '+' 311 || $pageCategory == '-' 312 || $pageCategory == '"' 313 || $pageCategory == '\'' 314 ) 315 { 316 $pageCategory = ''; 317 } 318 319 // in the $pageCompleteName "g1>g2>page" select only "page" 320 // if pageCompleteNamePath bug when all variables recorded, no pagename, only save index.php 321 $pageName = $file . substr($pageCompleteName, $lastDelimiter + 1); 322 } 323 else 324 { 325 $pageCategory = ''; 326 $pageName = $pageCompleteName; 327 } 328 //var_dump($pageCategory);exit; 329 330 // concerning names of pages in subgroups like /g1/g2/g3/ without page names 331 if(strcmp($pageName, '')===0) 332 { 333 $pageName = DEFAULT_PAGE_NAME; 334 } 335 336 337 printDebug('<br>URL : '.$pageUrl); 338 printDebug('<br>typeTag : '.$typeTag); 339 printDebug('<br>pageName : '.$pageName); 340 printDebug('<br>pageCategory : '.$pageCategory); 341 printDebug('<br>a_vars : '); printDebug($a_vars); 342 printDebug('<br>referer : '); printDebug($refererUrl); 343 printDebug('<br>flash : '.$flash); 344 printDebug('<br>director : '.$director); 345 printDebug('<br>quicktime : '.$quicktime); 346 printDebug('<br>real player : '.$realPlayer); 347 printDebug('<br>windows media : '.$windowsMedia); 348 printDebug('<br>cookie : '.$cookieAccept); 349 printDebug('<br>PDF : '.$pdf); 350 printDebug('<br>java : '.$java); 351 printDebug('<br>javascript : '.$javascript); 352 printDebug('<br>referer Url : '.$refererUrl); 353 printDebug('<br>id site : '.$idSite); 354 //printDebug('<br>site Urls : '); printDebug($siteUrls); 355 //printDebug('<br>site Info : '); printDebug($siteInfo); 356 printDebug('<br>user Agent : '.$userAgent); 357 printDebug('<br>os : '.$os); 358 printDebug('<br>browser : '.$a_browser['longName']); 359 printDebug('<br>resolution : '.$resolution); 360 printDebug('<br>color : '.$colorDepth); 361 362 /** 363 * other information 364 */ 365 $todayDate = date("Y-m-d"); 366 367 /** 368 * try to recognize the visitor, with or without cookie 369 * who said we are very strong ? 370 */ 371 372 // last_visit = last visit timestamp 373 // idcookie = id cookie 374 375 printDebug("<br><strong>Try to recognize the visitor...</strong><br>"); 376 377 function saveCountInFile( $fileName ) 378 { 379 $count = 0; 380 $fileName = './count/'.$fileName; 381 if(is_file($fileName)) 382 { 383 include($fileName); 384 if(isset($count) && is_integer($count) && $count != 0) 385 { 386 saveConfigFile( $fileName, $count+1, "count"); 387 } 388 } 389 390 } 391 if(TRACE_IN_FILES) saveCountInFile( 'p_total' ); 392 393 394 $timeDiffRef = DEFAULT_TIME_PAGE; 395 396 // does phpmyvisites cookie exist ? 397 if($GLOBALS['cookie']->isDefined()) 398 { 399 // yes, known visitor 400 $idVisit = $GLOBALS['cookie']->getVar('idvisit'); 401 $idCookie = $GLOBALS['cookie']->getVar('idcookie'); 402 $lastVisit = $GLOBALS['cookie']->getVar('last_visit_time'); 403 $serverTime = $GLOBALS['cookie']->getVar('server_time'); 404 $serverDate = $GLOBALS['cookie']->getVar('server_date'); 405 $idPageRef = $GLOBALS['cookie']->getVar('idpage_ref'); 406 407 if(TRACE_IN_FILES) saveCountInFile( 'p_cookie' ); 408 409 if(DEBUG) 410 printDebug("<br>We know the visitor (thanks to his cookie). 411 <br>He has idvisit = $idVisit and went last time on 412 ".getTimeForDisplay($lastVisit)."<br>"); 413 } 414 else 415 { 416 printDebug("=>We can't find the cookie...<br>"); 417 if(TRACE_IN_FILES) saveCountInFile( 'p_non_cookie' ); 418 // compute IP 419 $ip = getIp(); 420 $ip2long = ip2long($ip); 421 exitIfIpExcluded($ip2long, $logo, $site); 422 423 424 $serverDate = $todayDate; 425 426 $tryPutCookie = true; 427 428 //edit 2.2RC3 now we check all the time, because if someone refresh the home page 100 times 429 // and didn't accept cookies, it was counted 100 visitors!! 430 /* 431 if($site->isUrlIn($refererUrl)) 432 { 433 printDebug("=> Referer Is in the site ! try to catch the visitor...<br>"); 434 if(TRACE_IN_FILES) saveCountInFile( 'p_ref_url_in' ); 435 } 436 */ 437 438 $md5Config = md5( $os . serialize($a_browser) . $resolution . $colorDepth . $pdf 439 . $flash . $java . $javascript . $director . $quicktime . $realPlayer . $windowsMedia . $cookieAccept 440 . $ip2long . $browserLang); 441 442 // does the config (os+browser+resolution+color_depth) and the IP match any visitor ? 443 $r = query("SELECT idvisit, idcookie, TIME_TO_SEC(last_visit_time), 444 TIME_TO_SEC(server_time), exit_idpage 445 FROM ".T_VISIT." 446 WHERE server_date = '$todayDate' 447 AND idsite = '$idSite' 448 AND md5config = '$md5Config' 449 ORDER BY last_visit_time DESC 450 LIMIT 1"); 451 452 if(mysql_num_rows($r)>0) 453 { 454 // yes 455 $r = mysql_fetch_row($r); 456 $idVisit = $r[0]; 457 $idCookie = $r[1]; 458 $lastVisit = $r[2]; 459 $serverTime = $r[3]; 460 $idPageRef = $r[4]; 461 if(TRACE_IN_FILES) saveCountInFile( 'p_ref_url_in_found' ); 462 printDebug("=> We found the MD5CONFIG of visitor so he is known<br>"); 463 } 464 465 // case we didn't match any visitor 466 if(!isset($idVisit)) 467 { 468 // no, new visitor 469 $newVisitor = true; 470 if(TRACE_IN_FILES) saveCountInFile( 'p_ref_not_found' ); 471 printDebug("=> It's definitely a new visitor<br>"); 472 } 473 } 474 475 476 if(isset($lastVisit) 477 && $lastVisit !== false 478 && $lastVisit < todayTime() // case the lastVisit value has been spoiled 479 ) 480 { 481 $timeDiffRef = todayTime() - $lastVisit; 482 483 // case the lastVisit value has been spoiled (BIS) 484 $timeDiffRef = min($timeDiffRef, TIME_ONE_VISIT); 485 } 486 487 if(!isset($idPageRef) 488 || $idPageRef === false ) 489 { 490 $idPageRef = 0; 491 } 492 else 493 { 494 printDebug("We know its page ref id=$idPageRef and he stayed on it $timeDiffRef seconds <br>"); 495 } 496 497 /** 498 * Current visitor is a new visitor or an old one 499 * but without cookie, so we put a cookie 500 */ 501 if(isset($newVisitor) || isset($tryPutCookie)) 502 { 503 // record it and set the cookie 504 $idCookie = $GLOBALS['cookie']->put(isset($idCookie)?$idCookie:''); 505 506 // case : visitor known but cookie not set during his first page views... 507 if(isset($idVisit)) 508 { 509 $GLOBALS['cookie']->setVar('idvisit', $idVisit); 510 } 511 else 512 { 513 $lastVisit = todayTime(); 514 } 515 } 516 517 /** 518 * Visitor is known, we now look if it's a new visit or not 519 */ 520 // is the visit older than 30 minutes ? 521 if(!isset($newVisitor)) 522 { 523 if(DEBUG) 524 printDebug("(idvisit = $idVisit, ".getTimeForDisplay($serverTime)." | now : " . 525 todayTime()." :: first page last time : $serverTime)"); 526 527 if ($serverDate == date("Y-m-d") 528 && ($lastVisit > (todayTime() - TIME_ONE_VISIT)) 529 ) 530 { 531 // yes, new visit 532 $GLOBALS['cookie']->setVar('last_visit_time', todayTime()); 533 $knownVisit = true; 534 printDebug("<br><b>=>Visit is known on date : $serverDate</b><br>"); 535 } 536 else 537 { 538 printDebug("=>Last visit is too old <b>==> New visit</b><br>"); 539 $returningVisitor = 1; 540 } 541 } 542 else 543 { 544 printDebug("<br><b>=>New Visitor also means new visit</b><br>"); 545 } 546 547 548 /** 549 * Current visit is a known visit 550 */ 551 // save current page, etc. 552 if(isset($knownVisit) && $knownVisit) 553 { 554 // we know 555 // * $lastVisit 556 // * $idVisit 557 // * $idCookie 558 559 // update last_visit_time 560 printDebug("==> This is a visit known... we update the data <br>"); 561 562 // do it first because we need idpage for visit info insert 563 //print("$pageName <br> $pageUrl <br> $pageCategory ");exit; 564 $a_idPages = recordDbPage($pageName, $pageUrlParamsProcessed, $pageCategory, false); 565 566 $idPage = $a_idPages[0]; 567 568 // save current page & url & variables information 569 $idLink_vp = recordDbInfoPage($idVisit, $idPage, $idPageRef, $timeDiffRef, $a_vars); 570 571 $total_time = DEFAULT_TIME_PAGE + todayTime() - $serverTime; 572 // update last_visit_time & total_pages & c_total_time 573 $r = query("UPDATE ".T_VISIT." 574 SET last_visit_time = CURRENT_TIME(), 575 total_pages = total_pages + 1, 576 total_time = '$total_time', 577 exit_idpage = '$idPage' 578 WHERE idvisit = '$idVisit' 579 LIMIT 1"); 580 } 581 /* 582 * Current visit a new visit 583 */ 584 // now we know the visitor and its idcookie 585 // save new visit 586 else 587 { 588 printDebug("==> This is a new visit, we create datas in the database when necessary<br>"); 589 590 if(!isset($ip) || !isset($ip2long)) 591 { 592 $ip = getIp(); 593 $ip2long = ip2long($ip); 594 exitIfIpExcluded($ip2long, $logo, $site); 595 } 596 $hostExt = getHostnameExt(getHost($ip)); 597 printDebug('<br>ip : '.$ip); 598 printDebug('<br>hostname : '.$hostExt); 599 600 $serverDate = date("Y-m-d"); 601 $serverTime = date("H:i:s"); 602 603 $country = getCountry($hostExt, $browserLang); 604 605 if($country == 'gb') 606 { 607 $country = 'uk'; 608 } 609 610 $continent = getContinent($country); 611 612 if(strlen($refererUrl)===0) 613 { 614 $refererUrl = 'NULL'; 615 } 616 else 617 { 618 $refererUrl = "'".$refererUrl."'"; 619 } 620 621 // do it first because we need idpage for visit info insert 622 $a_idPages = recordDbPage($pageName, $pageUrlParamsProcessed, $pageCategory, true); 623 624 $idPageUrl = $a_idPages[1]; 625 $idPage = $a_idPages[0]; 626 627 $md5Config = md5( $os . serialize($a_browser) . $resolution . $colorDepth . $pdf 628 . $flash . $java . $javascript . $director . $quicktime . $realPlayer . $windowsMedia . $cookieAccept 629 . $ip2long . $browserLang); 630 631 // save visitor information 632 $r = query("INSERT INTO ".T_VISIT." 633 (idsite, idcookie, returning, last_visit_time, server_date, server_time, md5config, 634 referer, os, browser_name, browser_version, resolution, color_depth, 635 pdf, flash, java, javascript, director, quicktime, realplayer, windowsmedia, cookie, 636 local_time, ip, hostname_ext, browser_lang, country, continent, 637 total_pages, total_time, entry_idpage, entry_idpageurl, exit_idpage) 638 VALUES ('$idSite', '$idCookie', '$returningVisitor', CURRENT_TIME(), 639 '$serverDate', '$serverTime', '$md5Config', 640 $refererUrl, '$os', '".$a_browser['shortName']."', 641 '".$a_browser['version']."', '$resolution', '$colorDepth', 642 '$pdf', '$flash','$java', '$javascript', '$director', '$quicktime', '$realPlayer', '$windowsMedia', '$cookieAccept', 643 '$localTime','$ip2long', '$hostExt', '$browserLang', '$country', '$continent', 644 1, '".DEFAULT_TIME_PAGE ."', '$idPage', '$idPageUrl', '$idPage') 645 "); 646 $idVisit = mysql_insert_id(); 647 648 // save page view and URL and variables 649 recordDbInfoPage($idVisit, $idPage, $idPageRef, $timeDiffRef, $a_vars); 650 651 // save idvisit 652 $GLOBALS['cookie']->setVar('idvisit', $idVisit); 653 $GLOBALS['cookie']->setVar('last_visit_time', todayTime()); 654 $GLOBALS['cookie']->setVar('server_time', todayTime()); 655 $GLOBALS['cookie']->setVar('server_date', $serverDate); 656 } 657 658 $GLOBALS['cookie']->setVar('idpage_ref', $idPage); 659 660 $GLOBALS['cookie']->save(); 661 printDebug("<br><b>Next cookie should be :</b>"); 662 printDebug($GLOBALS['cookie']->getContent()); 663 664 // footer 665 if(PRINT_QUERY_COUNT) 666 printQueryCount(); 667 if(PRINT_TIME) 668 printTime(); 669 670 if(SAVE_DB_LOG) 671 { 672 recordDbQueryCount($idSite); 673 } 674 675 require_once INCLUDE_PATH . "/core/include/common.functions.php"; 676 $crontabFile = INCLUDE_PATH . "/config/crontab.php"; 677 if(is_file($crontabFile)) 678 { 679 include($crontabFile); 680 } 681 if( WEB_CRONTAB 682 && is_writable( $crontabFile) 683 && 684 ( 685 // if crontab doesn't exist in the file or the file doesn't exist 686 // or if the last try was before today 687 ( !isset($crontab) 688 || $crontab['date_last_success'] != getDateFromTimestamp(time()) 689 ) 690 && 691 ( 692 !is_file($crontabFile) 693 || ( isset($crontab) 694 && $crontab['time_last_try'] < time() - TIME_TO_WAIT_FOR_PARALLEL_ARCHIVE // every 5min 695 ) 696 ) 697 ) 698 ) 699 { 700 $crontab['time_last_try'] = time(); 701 $crontab['date_last_success'] = '2000-12-31'; 702 saveConfigFile( $crontabFile, $crontab, "crontab"); 703 704 printDebug('==========================<br> 705 CRONTAB BEGIN/ <br> 706 ==========================<br> 707 '); 708 require_once INCLUDE_PATH . '/core/include/PmvConfig.class.php'; 709 require_once INCLUDE_PATH . '/core/include/ApplicationController.php'; 710 711 $r =& Request::getInstance(); 712 $r->setModuleName('send_mail'); 713 $r->setCrontabAllowed(); 714 ApplicationController::init(); 715 printDebug('==========================<br> 716 CRONTAB END/ <br> 717 ==========================<br> 718 '); 719 $crontab['date_last_success'] = getDateFromTimestamp(time()); 720 saveConfigFile( $crontabFile, $crontab, "crontab"); 721 } 722 723 $db->close(); 724 725 726 redirectToUrlIfNecessary(); 727 loadImage($logo, $idSite); 728 729 // flush content for display 730 if(DEBUG) 731 ob_end_flush(); 732 733 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 14:10:01 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |