function xmppdaemon_error_handler($errno, $errstr, $errfile, $errline, $errcontext) {
switch ($errno) {
case E_USER_ERROR:
- echo "ERROR: [$errno] $errstr\n";
+ echo "ERROR: [$errno] $errstr ($errfile:$errline)\n";
echo " Fatal error on line $errline in file $errfile";
echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")\n";
echo "Aborting...\n";
exit(1);
break;
- case E_USER_WARNING:
- echo "WARNING [$errno] $errstr\n";
+ case E_USER_WARNING:
+ echo "WARNING [$errno] $errstr ($errfile:$errline)\n";
break;
case E_USER_NOTICE:
- echo "My NOTICE [$errno] $errstr\n";
+ echo "My NOTICE [$errno] $errstr ($errfile:$errline)\n";
break;
default:
- echo "Unknown error type: [$errno] $errstr\n";
+ echo "Unknown error type: [$errno] $errstr ($errfile:$errline)\n";
break;
}
} else if ($this->is_autoreply($pl['body'])) {
$this->log(LOG_INFO, 'Ignoring auto reply from ' . $from);
return;
+ } else if ($this->is_otr($pl['body'])) {
+ $this->log(LOG_INFO, 'Ignoring OTR from ' . $from);
+ return;
} else {
$this->add_notice($user, $pl);
}
}
}
+ function is_otr($txt) {
+ if (preg_match('/^\?OTR/', $txt)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
function from_site($address, $msg) {
$text = '['.common_config('site', 'name') . '] ' . $msg;
jabber_send_message($address, $text);
}
function add_notice(&$user, &$pl) {
- $notice = new Notice();
- $notice->is_local = 1;
- $notice->profile_id = $user->id;
- $notice->content = trim(substr($pl['body'], 0, 140));
- $notice->rendered = common_render_content($notice->content, $notice);
- $notice->created = DB_DataObject_Cast::dateTime();
- $notice->query('BEGIN');
- $id = $notice->insert();
- if (!$id) {
- $last_error = &PEAR::getStaticProperty('DB_DataObject','lastError');
- $this->log(LOG_ERR,
- 'Could not insert ' . common_log_objstring($notice) .
- ' for user ' . common_log_objstring($user) .
- ': ' . $last_error->message);
- return;
- }
- $orig = clone($notice);
- $notice->uri = common_notice_uri($notice);
- $result = $notice->update($orig);
- if (!$result) {
- $last_error = &PEAR::getStaticProperty('DB_DataObject','lastError');
- $this->log(LOG_ERR,
- 'Could not add URI to ' . common_log_objstring($notice) .
- ' for user ' . common_log_objstring($user) .
- ': ' . $last_error->message);
+ $notice = Notice::saveNew($user->id, trim(substr($pl['body'], 0, 140)), 'xmpp');
+ if (is_string($notice)) {
+ $this->log(LOG_ERR, $notice);
return;
}
- $notice->query('COMMIT');
- common_save_replies($notice);
- $notice->saveTags();
common_real_broadcast($notice);
$this->log(LOG_INFO,
'Added notice ' . $notice->id . ' from user ' . $user->nickname);