Source for file rebuild_sd_stats.php

Documentation is available at rebuild_sd_stats.php

  1. #!/usr/local/php/bin/php
  2. <?php
  3. /**
  4. * Rebuild Stats Pages
  5. *
  6. * This is a command-line script for generating the cached stats pages.
  7. * It expectes one commandline arguments
  8. * - a CompUnix name
  9. *
  10. * This file is normally run every minute by cron. It checks for
  11. * recent registrations and ensures that another instance of it
  12. * isn't already running.
  13. *
  14. * This file is part of CompInaBox.
  15. * @package CommandLine-Scripts
  16. * @author Eric D. Nielsen <nielsene@alum.mit.edu>
  17. * @copyright CompInaBox Copyright 2005, Eric D. Nielsen. All Rights Reserved.
  18. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  19. * @todo Compare with current version running on production
  20. */
  21.  
  22. /**
  23. * Inlucde the basic path information
  24. */
  25. ini_alter("include_path",".");
  26. include("../include/paths.inc");
  27.  
  28. if ($argv[1]=="") die("No Comp Name provided\n");
  29. $unixname = $argv[1];
  30. ini_alter("include_path","$CIB_CLASS_PATH:$CIB_PREFIX/include:$CIB_PREFIX/www/register/$unixname/PrepStep_Generated_Files");
  31.  
  32. $CIB_TOOL_ROLE="register";
  33.  
  34. $updateTimeFileName = "$CIB_VAR_PATH/$unixname.updated";
  35. $updateLockFileName = "$CIB_VAR_PATH/$unixname.lock";
  36. $testFileName = "$CIB_WEB_PATH/stats/$unixname/affils.html";
  37. if (!file_exists($updateLockFileName))
  38. {
  39. touch($updateLockFileName);
  40. }
  41. if (filemtime($updateTimeFileName) > filemtime($testFileName))
  42. {
  43. include "$CIB_CONFIG_PATH/comps/{$unixname}_config.inc";
  44. ini_alter("include_path", "$CIB_CLASS_PATH:$CIB_PREFIX/include:$CIB_WEB_PATH/$CIB_TOOL_ROLE/$unixname/PREPARSED");
  45.  
  46. include "$CIB_INCLUDE_PATH/tools/SlidingDoors_header.inc";
  47. echo "rebuilding stats";
  48. $fp = fopen($updateLockFileName,"r");
  49.  
  50. $lock = flock($fp,LOCK_EX+LOCK_NB);
  51. if ($lock)
  52. {
  53. $db = new StatsDB($db->getDBName(),$db->getDBUser(), $db->getDBpass());
  54. $display = new StatsDisplay($db);
  55. $affilLut = $db->buildAffilLut();
  56.  
  57. $affilList = $db->buildAffilList();
  58. $eventLut = $db->buildEventLut();
  59. $eventList = $db->buildEventList();
  60. $peopleList = $db->buildPeopleLut($affilLut);
  61. $details = $db->getStatsSummary();
  62.  
  63. $display->generateStats($peopleList,$affilLut,$eventLut,
  64. $affilList, $eventList, $details);
  65.  
  66. }
  67. flock($fp,LOCK_UN);
  68. fclose($fp);
  69. passthru("$CIB_PREFIX/bin/latex_invoices.php $unixname");
  70. }
  71. ?>

Documentation generated on Tue, 25 Apr 2006 13:08:47 -0400 by phpDocumentor 1.3.0RC3