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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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($uid)) {
  12. $temp = $level;
  13. $level = $uid;
  14. $uid = $temp;
  15. }
  16. if ($uid === false || !ctype_digit($uid)) {
  17. if (defined('UID')) { $uid = UID; } else { $uid = 5; }
  18. }
  19. $sql = 'INSERT INTO log (user_id, log_level, log_time, log_message) ';
  20. $sql .= 'VALUES('.$uid.', '.$level.', '.time().', \''.m($message).'\')';
  21. mysql_query($sql);
  22. $botmsg = '';
  23. switch ($level) {
  24. case self::critical:
  25. $botmsg = chr(2).chr(3).'4CRITICAL:'.chr(3).chr(2); break;
  26. case self::important:
  27. $botmsg = chr(2).'IMPORTANT:'.chr(2); break;
  28. case self::normal:
  29. $botmsg = 'NORMAL:'; break;
  30. case self::unknown:
  31. $botmsg = 'UNKNOWN:'; break;
  32. case self::information:
  33. $botmsg = chr(3).'14INFORMATION:'.chr(3); break;
  34. }
  35. if ($uid != 5) {
  36. $sql = 'SELECT user_name FROM users WHERE user_id = '.$uid;
  37. $res = mysql_query($sql);
  38. $row = mysql_fetch_array($res);
  39. $botmsg .= ' User '.$row['user_name'].':';
  40. }
  41. $botmsg .= ' '.$message;
  42. if ($fh = @fsockopen('207.150.170.50',7530,$errno,$errstr,0.1)) {
  43. fputs($fh, '...'.$botmsg."\r\n");
  44. fclose($fh);
  45. }
  46. }
  47. }
  48. ?>