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.

common.php 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?PHP
  2. if (defined('LIB_COMMON')) { return; }
  3. require_once('lib/database.php');
  4. define('CP_PATH', '/mon/');
  5. function NiceSize($bytes) {
  6. $sizes = array();
  7. $sizes[1024] = ' <abbr title="Kibibytes">KiB</abbr>';
  8. $sizes[(1024*1024)] = ' <abbr title="Mebibytes">MiB</abbr>';
  9. $sizes[(1024*1024*1024)] = ' <abbr title="Gibibytes">GiB</abbr>';
  10. krsort($sizes);
  11. foreach ($sizes as $val => $name) {
  12. if ($bytes > ($val * 1.2)) {
  13. return round($bytes/$val, 2).$name;
  14. }
  15. }
  16. return $bytes.' <abbr title="Bytes">B</abbr>';
  17. }
  18. function h ($text) { return htmlspecialchars($text); }
  19. function m ($a) { return mysql_real_escape_string($a); }
  20. function l ($message, $uid = false) {
  21. if ($uid === false ){ $uid = UID; }; mysql_query('INSERT INTO log (log_time, user_id, log_message) VALUES ('.time().', '.$uid.', \''.m($message).'\')') or print(mysql_error());
  22. $sql = 'SELECT user_name FROM users WHERE user_id = '.$uid;
  23. $res = mysql_query($sql);
  24. $row = mysql_fetch_array($res);
  25. botlog('User '.chr(2).$row[0].chr(2).': '.$message);
  26. }
  27. function botlog ($message) {
  28. if ($fh = @fsockopen('soren.dataforce.org.uk',7530,$errno,$errstr,0.2)) {
  29. fputs($fh, 'ZOMGutdSTAFF '.$message."\r\n");
  30. fclose($fh);
  31. }
  32. }
  33. define('LIB_COMMON', true);
  34. ?>