phpUserTrack
[ class tree: phpUserTrack ] [ index: phpUserTrack ] [ all elements ]

Source for file index.php

Documentation is available at index.php

  1. <?php
  2. require_once dirname(__FILE__'/include/version.php';
  3. require_once dirname(__FILE__'/smarty/libs/Smarty.class.php';
  4. require_once dirname(__FILE__'/lib/core.php';
  5.  
  6. try {
  7.     $smarty new Smarty();
  8. catch (Exception $e{
  9.     die('Smarty must be installed for phpUserTrack to work. Try reinstalling if you have accidentally deleted it.');
  10. }
  11. $smarty->plugins_dir['include';
  12. require_once $smarty->_get_plugin_filepath('function''html_doctype');
  13.  
  14. try {
  15.     $login new login(true);
  16.     $smarty->assign('login'$login);
  17. catch (LoginException $e{
  18.     header'Location: login.php' ;
  19.  
  20. define ("MOVING_AVERAGE_DAYS"8)// number of days to use in the moving average calculation
  21.  
  22. $db new phpusertrack_db();
  23.  
  24. if ($_GET['mode'== 'delete'{
  25.     $sql 'delete from phpusertrack_sites where id=' $_GET['id'];
  26.     $del $db->_query($sql);
  27.     $notify[array('title' => _('Site Deleted')
  28.         'desc' => 'The site has been deleted from your list of installed and tracked sites.',
  29.         'type' => 'success'
  30.     );
  31. }
  32.  
  33. try {
  34.     $sql 'select (select count(*) from phpusertrack_data as tmpdata where tmpdata.site_id=phpusertrack_sites.id) as count, phpusertrack_sites.* from phpusertrack_sites group by id';
  35.     $sites $db->_query($sql);
  36.     
  37.     $smarty->assign('sitesold'$_SESSION['sitesold']);
  38.     $_SESSION['sitesold'$sites;
  39.     
  40.     $sql 'select browser, count(id)*100/(select count(*) from phpusertrack_ip) as percent from phpusertrack_ip group by browser order by percent desc limit 10';
  41.     $avgs $db->_query($sql);
  42.     
  43.     $sql "Select Count(phpusertrack_data.path) AS `count`, phpusertrack_data.path, phpusertrack_sites.url, phpusertrack_data.site_id From phpusertrack_data Inner Join phpusertrack_sites ON phpusertrack_data.site_id = phpusertrack_sites.id Group By phpusertrack_data.path, phpusertrack_sites.id Order By `count` Desc Limit 10";
  44.     $paths $db->_query($sql);
  45.     
  46.     $sql "select count(id) as count, ip from phpusertrack_ip group by ip order by count desc limit 10";
  47.     $sessions $db->_query($sql);
  48. catch (Exception $e{
  49.     $notify[array('title' => 'Database Error'
  50.         'desc' => $e->getMessage(),
  51.         'type' => 'error'
  52.     );
  53. }    
  54.  
  55. $smarty->assign('mysqlQueryTime'(getmicrotime($time));
  56.  
  57. $smarty->assign('sites'$sites);
  58. $smarty->assign('browseravgs'$avgs);
  59. $smarty->assign('paths'$paths);
  60. $smarty->assign('sessions'$sessions);
  61.  
  62. $smarty->assign('mysqlHost'$conf['mysqlHost']);
  63. $smarty->assign('mysqlPort'$conf['mysqlPort']);
  64. $smarty->assign('mysqlDb'$conf['mysqlDbName']);
  65.  
  66. $smarty->assign('movAvgDays'MOVING_AVERAGE_DAYS);
  67.  
  68. $smarty->assign('notifMsg'$notify);
  69.  
  70. $smarty->display('header.tpl');
  71. $smarty->display('index.tpl');
  72.  
  73. $smarty->assign('pageRenderTime'(getmicrotime($time));
  74.  
  75. $smarty->display('footer.tpl');
  76.  
  77. ?>

Documentation generated on Tue, 06 Nov 2007 09:21:54 -0800 by phpDocumentor 1.4.0a2