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.  
  21. define ("MOVING_AVERAGE_DAYS", 8); // number of days to use in the moving average calculation
  22.  
  23. $db = new phpusertrack_db();
  24.  
  25. if ($_GET['mode'] == 'delete') {
  26.     $sql = 'delete from phpusertrack_sites where id=' . $_GET['id'];
  27.     $del = $db->_query($sql);
  28.     $notify[] = array('title' => _('Site Deleted'), 
  29.         'desc' => 'The site has been deleted from your list of installed and tracked sites.',
  30.         'type' => 'success'
  31.     );
  32. }
  33.  
  34. try {
  35.     $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';
  36.     $sites = $db->_query($sql);
  37.     
  38.     $smarty->assign('sitesold', $_SESSION['sitesold']);
  39.     $_SESSION['sitesold'] = $sites;
  40.     
  41.     $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';
  42.     $avgs = $db->_query($sql);
  43.     
  44.     $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";
  45.     $paths = $db->_query($sql);
  46.     
  47.     $sql = "select count(id) as count, ip from phpusertrack_ip group by ip order by count desc limit 10";
  48.     $sessions = $db->_query($sql);
  49. } catch (Exception $e) {
  50.     $notify[] = array('title' => 'Database Error', 
  51.         'desc' => $e->getMessage(),
  52.         'type' => 'error'
  53.     );
  54. }    
  55.  
  56. $smarty->assign('mysqlQueryTime', (getmicrotime() - $time));
  57.  
  58. $smarty->assign('sites', $sites);
  59. $smarty->assign('browseravgs', $avgs);
  60. $smarty->assign('paths', $paths);
  61. $smarty->assign('sessions', $sessions);
  62.  
  63. $smarty->assign('mysqlHost', $conf['mysqlHost']);
  64. $smarty->assign('mysqlPort', $conf['mysqlPort']);
  65. $smarty->assign('mysqlDb', $conf['mysqlDbName']);
  66.  
  67. $smarty->assign('movAvgDays', MOVING_AVERAGE_DAYS);
  68.  
  69. $smarty->assign('notifMsg', $notify);
  70.  
  71. $smarty->display('header.tpl');
  72. $smarty->display('index.tpl');
  73.  
  74. $smarty->assign('pageRenderTime', (getmicrotime() - $time));
  75.  
  76. $smarty->display('footer.tpl');
  77.  
  78. ?>

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