Unsupported scripts and control panel web app for a hosting company
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sitestats.php 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?PHP
  2. require_once('lib/dashboard.php');
  3. require_once('lib/account.php');
  4. checkAccess(HAS_HOSTING);
  5. if (!isset($_GET['n']) || !preg_match('/^[0-9]+$/',$_GET['n']) && !isset($error)) {
  6. $error = 'Invalid site ID!';
  7. die($error);
  8. define('TITLE', 'Error');
  9. } elseif (!defined('UID')) {
  10. $error = 'You must be logged in to view site statistics.';
  11. die($error);
  12. define('TITLE', 'Error');
  13. } else {
  14. $site = $_GET['n'];
  15. $sql = 'SELECT site_id, user_id, site_name, site_docroot FROM sites WHERE site_id = '.$site;
  16. $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
  17. if (mysql_num_rows($res) == 0) {
  18. $error = 'There is no such site with that ID.';
  19. die($error);
  20. define('TITLE', 'Error');
  21. } else {
  22. $row = mysql_fetch_array($res);
  23. if ($row['user_id'] != UID && !defined('ADMIN')) {
  24. $error = 'You do not own this site.';
  25. die($error);
  26. define('TITLE', 'Error');
  27. } else {
  28. define('SITE_ID', $row['site_id']);
  29. define('SITE_NAME', $row['site_name']);
  30. define('SITE_DOCROOT', $row['site_docroot']);
  31. define('TITLE', 'Edit site: '.$row['site_name']);
  32. }
  33. }
  34. }
  35. if (!isset($_GET['f'])) { header('Location: /control/sitestats/'.SITE_ID.'/'); }
  36. if (empty($_GET['f'])) { $_GET['f'] = 'index.html'; }
  37. $file = '/home/utd/stats/'.str_pad(SITE_ID,3,'0',STR_PAD_LEFT).'/'.$_GET['f'];
  38. if (dirname(realpath($file)) != '/home/utd/stats/'.str_pad(SITE_ID,3,'0',STR_PAD_LEFT)) {
  39. die('Invalid path');
  40. }
  41. if (!file_exists($file)) { die('Invalid path'); }
  42. if (substr($file, -3) == 'png') { header('Content-type: image/png'); }
  43. readfile($file);
  44. ?>