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.

log.php 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?PHP
  2. require_once('lib/database.php');
  3. class logger {
  4. const unknown = "'unknown'";
  5. const critical = "'critical'";
  6. const important = "'important'";
  7. const normal = "'normal'";
  8. const information = "'info'";
  9. const info = "'info'";
  10. static function log ($message, $uid = false, $level = logger::unknown) {
  11. if ($uid !== false && !ctype_digit((string)$uid)) {
  12. $temp = $level;
  13. $level = $uid;
  14. $uid = $temp;
  15. }
  16. if ($uid === false || !ctype_digit((string)$uid)) {
  17. if (defined('UID')) { $uid = UID; } else { $uid = 5; }
  18. }
  19. if (DEVELOPMENT) {
  20. $message = 'DEV: '.$message;
  21. }
  22. $sql = 'INSERT INTO log (user_id, log_level, log_time, log_message) ';
  23. $sql .= 'VALUES('.$uid.', '.$level.', '.time().', \''.m($message).'\')';
  24. mysql_query($sql);
  25. $botmsg = '';
  26. switch ($level) {
  27. case self::critical:
  28. $botmsg = chr(2).chr(3).'4CRITICAL:'.chr(3).chr(2); break;
  29. case self::important:
  30. $botmsg = chr(2).'IMPORTANT:'.chr(2); break;
  31. case self::normal:
  32. $botmsg = 'NORMAL:'; break;
  33. case self::unknown:
  34. $botmsg = 'UNKNOWN:'; break;
  35. case self::information:
  36. $botmsg = chr(3).'14INFORMATION:'.chr(3); break;
  37. }
  38. if ($uid != 5) {
  39. $sql = 'SELECT user_name FROM users WHERE user_id = '.$uid;
  40. $res = mysql_query($sql);
  41. $row = mysql_fetch_array($res);
  42. $botmsg .= ' User '.$row['user_name'].':';
  43. }
  44. $botmsg .= ' '.$message;
  45. if ($fh = @fsockopen('utd-hosting.com',3302,$errno,$errstr,0.1)) {
  46. fputs($fh, '... #utd.staff '.$botmsg."\r\n");
  47. fclose($fh);
  48. }
  49. }
  50. }
  51. ?>