private function _do_list($uids, $spam) { $rcmail = rcube::get_instance(); $this->sa_user = $rcmail->config->get('sauserprefs_userid', "%u"); $this->sa_table = $rcmail->config->get('sauserprefs_sql_table_name'); $this->sa_username_field = $rcmail->config->get('sauserprefs_sql_username_field'); $this->sa_preference_field = $rcmail->config->get('sauserprefs_sql_preference_field'); $this->sa_value_field = $rcmail->config->get('sauserprefs_sql_value_field'); $identity_arr = $rcmail->user->get_identity(); $identity = $identity_arr['email']; $this->sa_user = str_replace('%u', $_SESSION['username'], $this->sa_user); $this->sa_user = str_replace('%l', $rcmail->user->get_username('local'), $this->sa_user); $this->sa_user = str_replace('%d', $rcmail->user->get_username('domain'), $this->sa_user); $this->sa_user = str_replace('%i', $identity, $this->sa_user); if (is_file($rcmail->config->get('markasjunk2_sauserprefs_config')) && !$rcmail->config->load_from_file($rcmail->config->get('markasjunk2_sauserprefs_config'))) { rcube::raise_error(array('code' => 527, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Failed to load config from " . $rcmail->config->get('markasjunk2_sauserprefs_config')), true, false); return false; } $db = rcube_db::factory($rcmail->config->get('sauserprefs_db_dsnw'), $rcmail->config->get('sauserprefs_db_dsnr'), $rcmail->config->get('sauserprefs_db_persistent')); $db->set_debug((bool) $rcmail->config->get('sql_debug')); $db->db_connect('w'); // check DB connections and exit on failure if ($err_str = $db->is_error()) { rcube::raise_error(array('code' => 603, 'type' => 'db', 'message' => $err_str), FALSE, TRUE); } foreach ($uids as $uid) { $message = new rcube_message($uid); $email = $message->sender['mailto']; if ($spam) { // delete any whitelisting for this address $db->query("DELETE FROM `{$this->sa_table}` WHERE `{$this->sa_username_field}` = ? AND `{$this->sa_preference_field}` = ? AND `{$this->sa_value_field}` = ?;", $this->sa_user, 'whitelist_from', $email); // check address is not already blacklisted $sql_result = $db->query("SELECT `value` FROM `{$this->sa_table}` WHERE `{$this->sa_username_field}` = ? AND `{$this->sa_preference_field}` = ? AND `{$this->sa_value_field}` = ?;", $this->sa_user, 'blacklist_from', $email); if (!$db->fetch_array($sql_result)) { $db->query("INSERT INTO `{$this->sa_table}` (`{$this->sa_username_field}`, `{$this->sa_preference_field}`, `{$this->sa_value_field}`) VALUES (?, ?, ?);", $this->sa_user, 'blacklist_from', $email); if ($rcmail->config->get('markasjunk2_debug')) { rcube::write_log('markasjunk2', $this->sa_user . ' blacklist ' . $email); } } } else { // delete any blacklisting for this address $db->query("DELETE FROM `{$this->sa_table}` WHERE `{$this->sa_username_field}` = ? AND `{$this->sa_preference_field}` = ? AND `{$this->sa_value_field}` = ?;", $this->sa_user, 'blacklist_from', $email); // check address is not already whitelisted $sql_result = $db->query("SELECT `value` FROM `{$this->sa_table}` WHERE `{$this->sa_username_field}` = ? AND `{$this->sa_preference_field}` = ? AND `{$this->sa_value_field}` = ?;", $this->sa_user, 'whitelist_from', $email); if (!$db->fetch_array($sql_result)) { $db->query("INSERT INTO `{$this->sa_table}` (`{$this->sa_username_field}`, `{$this->sa_preference_field}`, `{$this->sa_value_field}`) VALUES (?, ?, ?);", $this->sa_user, 'whitelist_from', $email); if ($rcmail->config->get('markasjunk2_debug')) { rcube::write_log('markasjunk2', $this->sa_user . ' whitelist ' . $email); } } } } }
private function _do_salearn($uids, $spam) { $rcmail = rcube::get_instance(); $temp_dir = realpath($rcmail->config->get('temp_dir')); if ($spam) { $command = $rcmail->config->get('markasjunk2_spam_cmd'); } else { $command = $rcmail->config->get('markasjunk2_ham_cmd'); } if (!$command) { return; } $command = str_replace('%u', $_SESSION['username'], $command); $command = str_replace('%l', $rcmail->user->get_username('local'), $command); $command = str_replace('%d', $rcmail->user->get_username('domain'), $command); if (preg_match('/%i/', $command)) { $identity_arr = $rcmail->user->get_identity(); $command = str_replace('%i', $identity_arr['email'], $command); } foreach ($uids as $uid) { // reset command for next message $tmp_command = $command; // get DSPAM signature from header (if %xds macro is used) if (preg_match('/%xds/', $command)) { if (preg_match('/^X\\-DSPAM\\-Signature:\\s+((\\d+,)?([a-f\\d]+))\\s*$/im', $rcmail->storage->get_raw_headers($uid), $dspam_signature)) { $tmp_command = str_replace('%xds', $dspam_signature[1], $tmp_command); } else { continue; } // no DSPAM signature found in headers -> continue with next uid/message } if (preg_match('/%f/', $command)) { $tmpfname = tempnam($temp_dir, 'rcmSALearn'); file_put_contents($tmpfname, $rcmail->storage->get_raw_body($uid)); $tmp_command = str_replace('%f', $tmpfname, $tmp_command); } exec($tmp_command, $output); if ($rcmail->config->get('markasjunk2_debug')) { rcube::write_log('markasjunk2', $tmp_command); rcube::write_log('markasjunk2', $output); } if (preg_match('/%f/', $command)) { unlink($tmpfname); } $output = ''; } }
public function save($curpass, $passwd) { $rcmail = rcmail::get_instance(); if ($curpass == '' || $passwd == '') { return PASSWORD_ERROR; } try { $remote = $rcmail->config->get('hmailserver_remote_dcom', false); if ($remote) { $obApp = new COM("hMailServer.Application", $rcmail->config->get('hmailserver_server')); } else { $obApp = new COM("hMailServer.Application"); } } catch (Exception $e) { rcube::write_log('errors', "Plugin password (hmail driver): " . trim(strip_tags($e->getMessage()))); rcube::write_log('errors', "Plugin password (hmail driver): This problem is often caused by DCOM permissions not being set."); return PASSWORD_ERROR; } $username = $rcmail->user->data['username']; if (strstr($username, '@')) { $temparr = explode('@', $username); $domain = $temparr[1]; } else { $domain = $rcmail->config->get('username_domain', false); if (!$domain) { rcube::write_log('errors', 'Plugin password (hmail driver): $config[\'username_domain\'] is not defined.'); return PASSWORD_ERROR; } $username = $username . "@" . $domain; } $obApp->Authenticate($username, $curpass); try { $obDomain = $obApp->Domains->ItemByName($domain); $obAccount = $obDomain->Accounts->ItemByAddress($username); $obAccount->Password = $passwd; $obAccount->Save(); return PASSWORD_SUCCESS; } catch (Exception $e) { rcube::write_log('errors', "Plugin password (hmail driver): " . trim(strip_tags($e->getMessage()))); rcube::write_log('errors', "Plugin password (hmail driver): This problem is often caused by DCOM permissions not being set."); return PASSWORD_ERROR; } }
private function _do_list($uids, $spam) { $rcmail = rcube::get_instance(); if (is_file($rcmail->config->get('markasjunk2_sauserprefs_config')) && !$rcmail->config->load_from_file($rcmail->config->get('markasjunk2_sauserprefs_config'))) { rcube::raise_error(array('code' => 527, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Failed to load config from " . $rcmail->config->get('markasjunk2_sauserprefs_config')), true, false); return false; } $db = rcube_db::factory($rcmail->config->get('sauserprefs_db_dsnw'), $rcmail->config->get('sauserprefs_db_dsnr'), $rcmail->config->get('sauserprefs_db_persistent')); $db->db_connect('w'); // check DB connections and exit on failure if ($err_str = $db->is_error()) { rcube::raise_error(array('code' => 603, 'type' => 'db', 'message' => $err_str), FALSE, TRUE); } foreach (explode(",", $uids) as $uid) { $message = new rcube_message($uid); $email = $message->sender['mailto']; if ($spam) { // delete any whitelisting for this address $db->query("DELETE FROM " . $rcmail->config->get('sauserprefs_sql_table_name') . " WHERE " . $rcmail->config->get('sauserprefs_sql_username_field') . " = ? AND " . $rcmail->config->get('sauserprefs_sql_preference_field') . " = ? AND " . $rcmail->config->get('sauserprefs_sql_value_field') . " = ?;", $_SESSION['username'], 'whitelist_from', $email); // check address is not already blacklisted $sql_result = $db->query("SELECT value FROM " . $rcmail->config->get('sauserprefs_sql_table_name') . " WHERE " . $rcmail->config->get('sauserprefs_sql_username_field') . " = ? AND " . $rcmail->config->get('sauserprefs_sql_preference_field') . " = ? AND " . $rcmail->config->get('sauserprefs_sql_value_field') . " = ?;", $_SESSION['username'], 'blacklist_from', $email); if (!$db->fetch_array($sql_result)) { $db->query("INSERT INTO " . $rcmail->config->get('sauserprefs_sql_table_name') . " (" . $rcmail->config->get('sauserprefs_sql_username_field') . ", " . $rcmail->config->get('sauserprefs_sql_preference_field') . ", " . $rcmail->config->get('sauserprefs_sql_value_field') . ") VALUES (?, ?, ?);", $_SESSION['username'], 'blacklist_from', $email); if ($rcmail->config->get('markasjunk2_debug')) { rcube::write_log('markasjunk2', $_SESSION['username'] . ' blacklist ' . $email); } } } else { // delete any blacklisting for this address $db->query("DELETE FROM " . $rcmail->config->get('sauserprefs_sql_table_name') . " WHERE " . $rcmail->config->get('sauserprefs_sql_username_field') . " = ? AND " . $rcmail->config->get('sauserprefs_sql_preference_field') . " = ? AND " . $rcmail->config->get('sauserprefs_sql_value_field') . " = ?;", $_SESSION['username'], 'blacklist_from', $email); // check address is not already whitelisted $sql_result = $db->query("SELECT value FROM " . $rcmail->config->get('sauserprefs_sql_table_name') . " WHERE " . $rcmail->config->get('sauserprefs_sql_username_field') . " = ? AND " . $rcmail->config->get('sauserprefs_sql_preference_field') . " = ? AND " . $rcmail->config->get('sauserprefs_sql_value_field') . " = ?;", $_SESSION['username'], 'whitelist_from', $email); if (!$db->fetch_array($sql_result)) { $db->query("INSERT INTO " . $rcmail->config->get('sauserprefs_sql_table_name') . " (" . $rcmail->config->get('sauserprefs_sql_username_field') . ", " . $rcmail->config->get('sauserprefs_sql_preference_field') . ", " . $rcmail->config->get('sauserprefs_sql_value_field') . ") VALUES (?, ?, ?);", $_SESSION['username'], 'whitelist_from', $email); if ($rcmail->config->get('markasjunk2_debug')) { rcube::write_log('markasjunk2', $_SESSION['username'] . ' whitelist ' . $email); } } } } }
/** * Prints debug/error info to the log */ public function log($level, $msg) { $msg = implode("\n", $msg); switch ($level) { case LOG_DEBUG: case LOG_INFO: case LOG_NOTICE: if ($this->config['debug']) { rcube::write_log('ldap', $msg); } break; case LOG_EMERGE: case LOG_ALERT: case LOG_CRIT: rcube::raise_error($msg, true, true); break; case LOG_ERR: case LOG_WARNING: $this->error = $msg; rcube::raise_error($msg, true, false); break; } }
private function _do_messagemove($uids, $spam) { $rcmail = rcube::get_instance(); if ($spam) { $dest_dir = unslashify($rcmail->config->get('markasjunk2_spam_dir')); } else { $dest_dir = unslashify($rcmail->config->get('markasjunk2_ham_dir')); } if (!$dest_dir) { return; } $filename = $rcmail->config->get('markasjunk2_filename'); $filename = str_replace('%u', $_SESSION['username'], $filename); $filename = str_replace('%t', $spam ? 'spam' : 'ham', $filename); $filename = str_replace('%l', $rcmail->user->get_username('local'), $filename); $filename = str_replace('%d', $rcmail->user->get_username('domain'), $filename); foreach ($uids as $uid) { $tmpfname = tempnam($dest_dir, $filename); file_put_contents($tmpfname, $rcmail->storage->get_raw_body($uid)); if ($rcmail->config->get('markasjunk2_debug')) { rcube::write_log('markasjunk2', $tmpfname); } } }
/** * Writes debug information/query to 'sql' log file * * @param string $query SQL query */ protected function debug($query) { if ($this->options['debug_mode']) { if (($len = strlen($query)) > self::DEBUG_LINE_LENGTH) { $diff = $len - self::DEBUG_LINE_LENGTH; $query = substr($query, 0, self::DEBUG_LINE_LENGTH) . "... [truncated {$diff} bytes]"; } rcube::write_log('sql', '[' . ++$this->db_index . '] ' . $query . ';'); } }
/** * This is our own debug handler for connection */ public function debug_handler(&$sieve, $message) { rcube::write_log('sieve', preg_replace('/\\r\\n$/', '', $message)); }
private function _do_emaillearn($uids, $spam) { $rcmail = rcube::get_instance(); $identity_arr = $rcmail->user->get_identity(); $from = $identity_arr['email']; if ($spam) { $mailto = $rcmail->config->get('markasjunk2_email_spam'); } else { $mailto = $rcmail->config->get('markasjunk2_email_ham'); } $mailto = str_replace('%u', $_SESSION['username'], $mailto); $mailto = str_replace('%l', $rcmail->user->get_username('local'), $mailto); $mailto = str_replace('%d', $rcmail->user->get_username('domain'), $mailto); $mailto = str_replace('%i', $from, $mailto); if (!$mailto) { return; } $message_charset = $rcmail->output->get_charset(); // chose transfer encoding $charset_7bit = array('ASCII', 'ISO-2022-JP', 'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-15'); $transfer_encoding = in_array(strtoupper($message_charset), $charset_7bit) ? '7bit' : '8bit'; $temp_dir = realpath($rcmail->config->get('temp_dir')); $subject = $rcmail->config->get('markasjunk2_email_subject'); $subject = str_replace('%u', $_SESSION['username'], $subject); $subject = str_replace('%t', $spam ? 'spam' : 'ham', $subject); $subject = str_replace('%l', $rcmail->user->get_username('local'), $subject); $subject = str_replace('%d', $rcmail->user->get_username('domain'), $subject); // compose headers array $headers = array(); $headers['Date'] = date('r'); $headers['From'] = format_email_recipient($identity_arr['email'], $identity_arr['name']); $headers['To'] = $mailto; $headers['Subject'] = $subject; foreach ($uids as $uid) { $MESSAGE = new rcube_message($uid); // set message charset as default if (!empty($MESSAGE->headers->charset)) { $rcmail->storage->set_charset($MESSAGE->headers->charset); } $MAIL_MIME = new Mail_mime($rcmail->config->header_delimiter()); if ($rcmail->config->get('markasjunk2_email_attach', false)) { $tmpPath = tempnam($temp_dir, 'rcmMarkASJunk2'); // send mail as attachment $MAIL_MIME->setTXTBody(($spam ? 'Spam' : 'Ham') . ' report from ' . $rcmail->config->get('product_name'), false, true); $raw_message = $rcmail->storage->get_raw_body($uid); $subject = $MESSAGE->get_header('subject'); if (isset($subject) && $subject != "") { $disp_name = $subject . ".eml"; } else { $disp_name = "message_rfc822.eml"; } if (file_put_contents($tmpPath, $raw_message)) { $MAIL_MIME->addAttachment($tmpPath, "message/rfc822", $disp_name, true, $transfer_encoding, 'attachment', '', '', '', $rcmail->config->get('mime_param_folding') ? 'quoted-printable' : NULL, $rcmail->config->get('mime_param_folding') == 2 ? 'quoted-printable' : NULL, '', RCUBE_CHARSET); } // encoding settings for mail composing $MAIL_MIME->setParam('text_encoding', $transfer_encoding); $MAIL_MIME->setParam('html_encoding', 'quoted-printable'); $MAIL_MIME->setParam('head_encoding', 'quoted-printable'); $MAIL_MIME->setParam('head_charset', $message_charset); $MAIL_MIME->setParam('html_charset', $message_charset); $MAIL_MIME->setParam('text_charset', $message_charset); // pass headers to message object $MAIL_MIME->headers($headers); } else { $headers['Resent-From'] = $headers['From']; $headers['Resent-Date'] = $headers['Date']; $headers['Date'] = $MESSAGE->headers->date; $headers['From'] = $MESSAGE->headers->from; $headers['Subject'] = $MESSAGE->headers->subject; $MAIL_MIME->headers($headers); if ($MESSAGE->has_html_part()) { $body = $MESSAGE->first_html_part(); $MAIL_MIME->setHTMLBody($body); } $body = $MESSAGE->first_text_part(); $MAIL_MIME->setTXTBody($body, false, true); foreach ($MESSAGE->attachments as $attachment) { $MAIL_MIME->addAttachment($MESSAGE->get_part_body($attachment->mime_id, true), $attachment->mimetype, $attachment->filename, false, $attachment->encoding, $attachment->disposition, '', $attachment->charset); } foreach ($MESSAGE->mime_parts as $attachment) { if (!empty($attachment->content_id)) { // covert CID to Mail_MIME format $attachment->content_id = str_replace('<', '', $attachment->content_id); $attachment->content_id = str_replace('>', '', $attachment->content_id); if (empty($attachment->filename)) { $attachment->filename = $attachment->content_id; } $message_body = $MAIL_MIME->getHTMLBody(); $dispurl = 'cid:' . $attachment->content_id; $message_body = str_replace($dispurl, $attachment->filename, $message_body); $MAIL_MIME->setHTMLBody($message_body); $MAIL_MIME->addHTMLImage($MESSAGE->get_part_body($attachment->mime_id, true), $attachment->mimetype, $attachment->filename, false); } } // encoding settings for mail composing $MAIL_MIME->setParam('head_encoding', $MESSAGE->headers->encoding); $MAIL_MIME->setParam('head_charset', $MESSAGE->headers->charset); foreach ($MESSAGE->mime_parts as $mime_id => $part) { $mimetype = strtolower($part->ctype_primary . '/' . $part->ctype_secondary); if ($mimetype == 'text/html') { $MAIL_MIME->setParam('text_encoding', $part->encoding); $MAIL_MIME->setParam('html_charset', $part->charset); } else { if ($mimetype == 'text/plain') { $MAIL_MIME->setParam('html_encoding', $part->encoding); $MAIL_MIME->setParam('text_charset', $part->charset); } } } } $rcmail->deliver_message($MAIL_MIME, $from, $mailto, $smtp_error, $body_file); // clean up if (file_exists($tmpPath)) { unlink($tmpPath); } if ($rcmail->config->get('markasjunk2_debug')) { if ($spam) { rcube::write_log('markasjunk2', $uid . ' SPAM ' . $mailto . ' (' . $subject . ')'); } else { rcube::write_log('markasjunk2', $uid . ' HAM ' . $mailto . ' (' . $subject . ')'); } if ($smtp_error['vars']) { rcube::write_log('markasjunk2', $smtp_error['vars']); } } } }
function password_save() { $this->register_handler('plugin.body', array($this, 'password_form')); $rcmail = rcmail::get_instance(); $rcmail->output->set_pagetitle($this->gettext('changepasswd')); $confirm = $rcmail->config->get('password_confirm_current'); $required_length = intval($rcmail->config->get('password_minimum_length')); $check_strength = $rcmail->config->get('password_require_nonalpha'); if ($confirm && !isset($_POST['_curpasswd']) || !isset($_POST['_newpasswd'])) { $rcmail->output->command('display_message', $this->gettext('nopassword'), 'error'); } else { $charset = strtoupper($rcmail->config->get('password_charset', 'ISO-8859-1')); $rc_charset = strtoupper($rcmail->output->get_charset()); $sespwd = $rcmail->decrypt($_SESSION['password']); $curpwd = $confirm ? rcube_utils::get_input_value('_curpasswd', rcube_utils::INPUT_POST, true, $charset) : $sespwd; $newpwd = rcube_utils::get_input_value('_newpasswd', rcube_utils::INPUT_POST, true); $conpwd = rcube_utils::get_input_value('_confpasswd', rcube_utils::INPUT_POST, true); // check allowed characters according to the configured 'password_charset' option // by converting the password entered by the user to this charset and back to UTF-8 $orig_pwd = $newpwd; $chk_pwd = rcube_charset::convert($orig_pwd, $rc_charset, $charset); $chk_pwd = rcube_charset::convert($chk_pwd, $charset, $rc_charset); // WARNING: Default password_charset is ISO-8859-1, so conversion will // change national characters. This may disable possibility of using // the same password in other MUA's. // We're doing this for consistence with Roundcube core $newpwd = rcube_charset::convert($newpwd, $rc_charset, $charset); $conpwd = rcube_charset::convert($conpwd, $rc_charset, $charset); if ($chk_pwd != $orig_pwd) { $rcmail->output->command('display_message', $this->gettext('passwordforbidden'), 'error'); } else { if ($conpwd != $newpwd) { $rcmail->output->command('display_message', $this->gettext('passwordinconsistency'), 'error'); } else { if ($confirm && $sespwd != $curpwd) { $rcmail->output->command('display_message', $this->gettext('passwordincorrect'), 'error'); } else { if ($required_length && strlen($newpwd) < $required_length) { $rcmail->output->command('display_message', $this->gettext(array('name' => 'passwordshort', 'vars' => array('length' => $required_length))), 'error'); } else { if ($check_strength && (!preg_match("/[0-9]/", $newpwd) || !preg_match("/[^A-Za-z0-9]/", $newpwd))) { $rcmail->output->command('display_message', $this->gettext('passwordweak'), 'error'); } else { if ($sespwd == $newpwd && !$rcmail->config->get('password_force_save')) { $rcmail->output->command('display_message', $this->gettext('successfullysaved'), 'confirmation'); } else { if (!($res = $this->_save($curpwd, $newpwd))) { $rcmail->output->command('display_message', $this->gettext('successfullysaved'), 'confirmation'); // allow additional actions after password change (e.g. reset some backends) $plugin = $rcmail->plugins->exec_hook('password_change', array('old_pass' => $curpwd, 'new_pass' => $newpwd)); // Reset session password $_SESSION['password'] = $rcmail->encrypt($plugin['new_pass']); // Log password change if ($rcmail->config->get('password_log')) { rcube::write_log('password', sprintf('Password changed for user %s (ID: %d) from %s', $rcmail->get_user_name(), $rcmail->user->ID, rcube_utils::remote_ip())); } } else { $rcmail->output->command('display_message', $res, 'error'); } } } } } } } } $rcmail->overwrite_action('plugin.password'); $rcmail->output->send('plugin'); }
/** * This is our own debug handler for the IMAP connection * @access public */ public function debug_handler(&$imap, $message) { rcube::write_log('imap', $message); }
/** * This is our own debug handler for the SMTP connection */ public function debug_handler(&$smtp, $message) { // catch AUTH commands and set anonymization flag for subsequent sends if (preg_match('/^Send: AUTH ([A-Z]+)/', $message, $m)) { $this->anonymize_log = $m[1] == 'LOGIN' ? 2 : 1; } else { if ($this->anonymize_log > 0 && strpos($message, 'Send:') === 0 && --$this->anonymize_log == 0) { $message = sprintf('Send: ****** [%d]', strlen($message) - 8); } } if (($len = strlen($message)) > self::DEBUG_LINE_LENGTH) { $diff = $len - self::DEBUG_LINE_LENGTH; $message = substr($message, 0, self::DEBUG_LINE_LENGTH) . "... [truncated {$diff} bytes]"; } rcube::write_log('smtp', preg_replace('/\\r\\n$/', '', $message)); }
/** * This is our own debug handler for the SMTP connection */ public function debug_handler(&$smtp, $message) { if (($len = strlen($message)) > self::DEBUG_LINE_LENGTH) { $diff = $len - self::DEBUG_LINE_LENGTH; $message = substr($message, 0, self::DEBUG_LINE_LENGTH) . "... [truncated {$diff} bytes]"; } rcube::write_log('smtp', preg_replace('/\\r\\n$/', '', $message)); }
function send_request($body) { $bosh_xml = $this->request_body($body); if ($this->debug) { rcube::write_log('xmpp', "C: " . $bosh_xml); } if ($ch = curl_init()) { curl_setopt_array($ch, array(CURLOPT_URL => $this->bosh_url, CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $bosh_xml, CURLOPT_FRESH_CONNECT => true, CURLOPT_HTTPHEADER => array('Content-Type: application/xml'))); $out = curl_exec($ch); if ($this->debug) { rcube::write_log('xmpp', "S: " . ($out ?: '<no-response>')); } if ($err = curl_error($ch)) { rcube::raise_error("Converse-XMPP: HTTP connection error: " . $err); } return strlen($out) ? simplexml_load_string($out) : null; } }
/** * Write debug info from Crypt_GPG to logs/enigma */ public function debug($line) { rcube::write_log('enigma', 'GPG: ' . $line); }
/** * Prints debug info to the log */ private function _debug($str) { if ($this->debug && class_exists('rcube')) { rcube::write_log('ldap', $str); } }
private function log_recaptcha($log_type, $username) { $rcmail = rcmail::get_instance(); $client_ip = $this->get_client_ip(); $username = empty($username) ? 'empty username' : $username; if (!$rcmail->config->get('recaptcha_log')) { return; } switch ($log_type) { case RCGUARD_RECAPTCHA_SUCCESS: $log_entry = $rcmail->config->get('recaptcha_log_success'); break; case RCGUARD_RECAPTCHA_FAILURE: $log_entry = $rcmail->config->get('recaptcha_log_failure'); break; default: $log_entry = $rcmail->config->get('recaptcha_log_unknown'); } if (!empty($log_entry)) { $log_entry = str_replace(array('%r', '%u'), array($client_ip, $username), $log_entry); rcube::write_log('rcguard', $log_entry); } }
private function _do_list($uids, $spam) { $rcmail = rcmail::get_instance(); $this->user_email = $rcmail->user->data['username']; if (is_file($rcmail->config->get('markasjunk2_amacube_config')) && !$rcmail->config->load_from_file($rcmail->config->get('markasjunk2_amacube_config'))) { rcube::raise_error(array('code' => 527, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Failed to load config from " . $rcmail->config->get('markasjunk2_amacube_config')), true, false); return false; } $db = rcube_db::factory($rcmail->config->get('amacube_db_dsn'), '', TRUE); $db->set_debug((bool) $rcmail->config->get('sql_debug')); $db->db_connect('w'); // check DB connections and exit on failure if ($err_str = $db->is_error()) { rcube::raise_error(array('code' => 603, 'type' => 'db', 'message' => $err_str), FALSE, TRUE); } $sql_result = $db->query("SELECT `id` FROM `users` WHERE `email` = ?", $this->user_email); if ($sql_result && ($res_array = $db->fetch_assoc($sql_result))) { $rid = $res_array['id']; } else { if ($rcmail->config->get('markasjunk2_debug')) { rcube::write_log('markasjunk2', $this->user_email . ' not found in users table'); } return false; } foreach ($uids as $uid) { $message = new rcube_message($uid); $email = $message->sender['mailto']; $sql_result = $db->query("SELECT `id` FROM `mailaddr` WHERE `email` = ? ORDER BY `priority` DESC", $email); if ($sql_result && ($res_array = $db->fetch_assoc($sql_result))) { $sid = $res_array['id']; } else { if ($rcmail->config->get('markasjunk2_debug')) { rcube::write_log('markasjunk2', $email . ' not found in mailaddr table - add it'); } $sql_result = $db->query("INSERT INTO `mailaddr` ( `priority`, `email` ) VALUES ( 20, ? )", $email); if ($sql_result) { $sid = $db->insert_id(); } else { if ($rcmail->config->get('markasjunk2_debug')) { rcube::write_log('markasjunk2', 'Cannot add ' . $email . ' to mailaddr table: ' . $db->is_error($sql_result)); } return false; } } $wb = ''; $sql_result = $db->query("SELECT `wb` FROM `wblist` WHERE `sid` = ? AND `rid` =?", $sid, $rid); if ($sql_result && ($res_array = $db->fetch_assoc($sql_result))) { $wb = $res_array['wb']; } if (!$wb || !$spam && preg_match('/^([BbNnFf])[ ]*\\z/', $wb) || $spam && preg_match('/^([WwYyTt])[ ]*\\z/', $wb)) { $newwb = 'w'; if ($spam) { $newwb = 'b'; } if ($wb) { $sql_result = $db->query('UPDATE `wblist` SET `wb` = ? WHERE `sid` = ? AND `rid` = ?', $newwb, $sid, $rid); } else { $sql_result = $db->query('INSERT INTO `wblist` (`sid`, `rid`, `wb`) VALUES (?,?,?)', $sid, $rid, $newwb); } if (!$sql_result) { if ($rcmail->config->get('markasjunk2_debug')) { rcube::write_log('markasjunk2', 'Cannot update wblist for user ' . $this->user_email . ' with ' . $email); } return false; } } } }
private function _debug($str) { if ($this->debug) { rcube::write_log('password_ldap_ppolicy', $str); } }
function save_prefs($new_prefs, $cur_prefs, $global_prefs) { $this->_db_connect('w'); $result = true; // save prefs foreach ($new_prefs as $preference => $value) { if ($preference == 'addresses') { foreach ($value as $address) { if ($address['action'] == "DELETE") { $result = false; $this->db->query("DELETE FROM " . $this->table_name . " WHERE " . $this->username_field . " = ?" . " AND " . $this->preference_field . " = ?" . " AND " . $this->value_field . " = ?;", $this->sa_user, sauserprefs::map_pref_name($address['field']), $address['value']); $result = $this->db->affected_rows(); if (!$result) { rcube::write_log('errors', 'sauserprefs error: cannot delete "' . sauserprefs::map_pref_name($prefs[$idx]) . '" = "' . $vals[$idx] . '" for ' . $this->sa_user); break; } } elseif ($address['action'] == "INSERT") { $result = false; $this->db->query("INSERT INTO " . $this->table_name . " (" . $this->username_field . ", " . $this->preference_field . ", " . $this->value_field . ") VALUES (?, ?, ?);", $this->sa_user, sauserprefs::map_pref_name($address['field']), $address['value']); $result = $this->db->affected_rows(); if (!$result) { rcube::write_log('errors', 'sauserprefs error: cannot insert "' . sauserprefs::map_pref_name($prefs[$idx]) . '" = "' . $vals[$idx] . '" for ' . $this->sa_user); break; } } } } elseif (array_key_exists($preference, $cur_prefs) && ($value == "" || $value == $global_prefs[$preference])) { $result = false; $this->db->query("DELETE FROM " . $this->table_name . " WHERE " . $this->username_field . " = ?" . " AND " . $this->preference_field . " = ?;", $this->sa_user, sauserprefs::map_pref_name($preference)); $result = $this->db->affected_rows(); if (!$result) { rcube::write_log('errors', 'sauserprefs error: cannot delete "' . sauserprefs::map_pref_name($preference) . '" for "' . $this->sa_user); break; } } elseif (array_key_exists($preference, $cur_prefs) && $value != $cur_prefs[$preference]) { $result = false; $this->db->query("UPDATE " . $this->table_name . " SET " . $this->value_field . " = ?" . " WHERE " . $this->username_field . " = ?" . " AND " . $this->preference_field . " = ?;", $value, $this->sa_user, sauserprefs::map_pref_name($preference)); $result = $this->db->affected_rows(); if (!$result) { rcube::write_log('errors', 'sauserprefs error: cannot update "' . sauserprefs::map_pref_name($preference) . '" = "' . $value . '" for ' . $this->sa_user); break; } } elseif (!array_key_exists($preference, $cur_prefs) && $value != $global_prefs[$preference]) { $result = false; $this->db->query("INSERT INTO " . $this->table_name . " (" . $this->username_field . ", " . $this->preference_field . ", " . $this->value_field . ") VALUES (?, ?, ?);", $this->sa_user, sauserprefs::map_pref_name($preference), $value); $result = $this->db->affected_rows(); if (!$result) { rcube::write_log('errors', 'sauserprefs error: cannot insert "' . sauserprefs::map_pref_name($preference) . '" = "' . $value . '" for ' . $this->sa_user); break; } } } return $result; }
/** * Debug handler for the MDB2 */ function debug_handler(&$db, $scope, $message, $context = array()) { if ($scope != 'prepare') { $debug_output = sprintf('%s(%d): %s;', $scope, $db->db_index, rtrim($message, ';')); rcube::write_log('sql', $debug_output); } }
/** * Writes debug information to the log */ function log($line) { if ($this->logging) { rcube::write_log('session', $line); } }
/** * Writes debug information/query to 'sql' log file * * @param string $query SQL query */ protected function debug($query) { if ($this->options['debug_mode']) { rcube::write_log('sql', '[' . ++$this->db_index . '] ' . $query . ';'); } }
/** * Prints debug info to the log */ private function _debug($str) { if ($this->debug) { rcube::write_log('ldap', $str); } }
private function log_msg($str) { if ($this->debug) { rcube::write_log('ldap', "virtuser_ldap: {$str}"); } }
function save_data() { $COMPOSE_ID = rcube_utils::get_input_value('_id', rcube_utils::INPUT_GPC); $COMPOSE = null; if ($COMPOSE_ID && $_SESSION['compose_data_' . $COMPOSE_ID]) { $SESSION_KEY = 'compose_data_' . $COMPOSE_ID; $COMPOSE =& $_SESSION[$SESSION_KEY]; } if (!$COMPOSE) { die("Invalid session var!"); } $uploadid = rcube_utils::get_input_value('_uploadid', rcube_utils::INPUT_POST); $files = rcube_utils::get_input_value('files', rcube_utils::INPUT_POST); $RCMAIL = rcmail::get_instance(); $RCMAIL->output->reset(); //rcube::write_log('dropbox_attachments', $files); if (is_array($files)) { $multiple = count($files) > 1; foreach ($files as $i => $file) { /*File checks*/ $err = false; if ($file['is_dir'] == 'true') { $err = "UPLOAD_ERR_DIRECTORY"; } // Fetch file $filepath = $this->download_fopen($file['link']); //rcube::write_log('dropbox_attachments', link); //rcube::write_log('dropbox_attachments', $filepath); rcube::write_log('dropbox_attachments', $file['link']); if (!$filepath) { $err = "UPLOAD_ERR_FETCH"; } if (!$err) { $attachment = $this->move_file(array('path' => $filepath, 'size' => $file['bytes'], 'name' => $file['name'], 'mimetype' => rcube_mime::file_content_type($filepath, $file['name']), 'group' => $COMPOSE_ID)); } //rcube::write_log('dropbox_attachments', $attachment); if (!$err && $attachment['status'] && !$attachment['abort']) { $id = $attachment['id']; // store new attachment in session unset($attachment['status'], $attachment['abort']); $RCMAIL->session->append($SESSION_KEY . '.attachments', $id, $attachment); if (($icon = $COMPOSE['deleteicon']) && is_file($icon)) { $button = html::img(array('src' => $icon, 'alt' => $RCMAIL->gettext('delete'))); } else { if ($COMPOSE['textbuttons']) { $button = rcube::Q($RCMAIL->gettext('delete')); } else { $button = ''; } } $content = html::a(array('href' => "#delete", 'onclick' => sprintf("return %s.command('remove-attachment','rcmfile%s', this)", rcmail_output::JS_OBJECT_NAME, $id), 'title' => $RCMAIL->gettext('delete'), 'class' => 'delete'), $button); $content .= rcube::Q($attachment['name']); $RCMAIL->output->command('add2attachment_list', "rcmfile{$id}", array('html' => $content, 'name' => $attachment['name'], 'mimetype' => $attachment['mimetype'], 'classname' => rcube_utils::file2class($attachment['mimetype'], $attachment['name']), 'complete' => true), $uploadid); } else { // upload failed if ($err == "UPLOAD_ERR_DIRECTORY") { $msg = "Directory upload not allowed."; } else { if ($err == "UPLOAD_ERR_FETCH") { $msg = "Failed to download file from Dropbox"; } else { if ($err == UPLOAD_ERR_INI_SIZE || $err == UPLOAD_ERR_FORM_SIZE) { $size = $RCMAIL->show_bytes(parse_bytes(ini_get('upload_max_filesize'))); $msg = $RCMAIL->gettext(array('name' => 'filesizeerror', 'vars' => array('size' => $size))); } else { if ($attachment['error']) { $msg = $attachment['error']; } else { $msg = $RCMAIL->gettext('fileuploaderror'); } } } } if ($attachment['error'] || $err != UPLOAD_ERR_NO_FILE) { $RCMAIL->output->command('display_message', $msg, 'error'); $RCMAIL->output->command('remove_from_attachment_list', $uploadid); } } } } $RCMAIL->output->command('auto_save_start', 'false'); $RCMAIL->output->send(); }
function save_prefs($user_id, $new_prefs, $cur_prefs, $global_prefs) { $this->_db_connect('w'); $result = true; // save prefs foreach ($new_prefs as $preference => $value) { if ($preference == 'addresses') { foreach ($value as $address) { if ($address['action'] == "DELETE") { $result = false; $this->db->query("DELETE FROM `{$this->table_name}` WHERE `{$this->username_field}` = ? AND `{$this->preference_field}` = ? AND `{$this->value_field}` = ?;", $user_id, $address['field'], $address['value']); $result = $this->db->affected_rows(); if (!$result) { rcube::write_log('errors', 'sauserprefs error: cannot delete "' . $prefs[$idx] . '" = "' . $vals[$idx] . '" for ' . $user_id); break; } } elseif ($address['action'] == "INSERT") { $result = false; $this->db->query("INSERT INTO `{$this->table_name}` (`{$this->username_field}`, `{$this->preference_field}`, `{$this->value_field}`) VALUES (?, ?, ?);", $user_id, $address['field'], $address['value']); $result = $this->db->affected_rows(); if (!$result) { rcube::write_log('errors', 'sauserprefs error: cannot insert "' . $prefs[$idx] . '" = "' . $vals[$idx] . '" for ' . $user_id); break; } } } } elseif (array_key_exists($preference, $cur_prefs) && ($value == "" || $value == $global_prefs[$preference])) { $result = false; $this->db->query("DELETE FROM `{$this->table_name}` WHERE `{$this->username_field}` = ? AND `{$this->preference_field}` = ?;", $user_id, $preference); $result = $this->db->affected_rows(); if (!$result) { rcube::write_log('errors', 'sauserprefs error: cannot delete "' . $preference . '" for "' . $user_id); break; } } elseif (array_key_exists($preference, $cur_prefs) && $value != $cur_prefs[$preference]) { $result = false; $this->db->query("UPDATE `{$this->table_name}` SET `{$this->value_field}` = ? WHERE `{$this->username_field}` = ? AND `{$this->preference_field}` = ?;", $value, $user_id, $preference); $result = $this->db->affected_rows(); if (!$result) { rcube::write_log('errors', 'sauserprefs error: cannot update "' . $preference . '" = "' . $value . '" for ' . $user_id); break; } } elseif (!array_key_exists($preference, $cur_prefs) && $value != $global_prefs[$preference]) { $result = false; $this->db->query("INSERT INTO `{$this->table_name}` (`{$this->username_field}`, `{$this->preference_field}`, `{$this->value_field}`) VALUES (?, ?, ?);", $user_id, $preference, $value); $result = $this->db->affected_rows(); if (!$result) { rcube::write_log('errors', 'sauserprefs error: cannot insert "' . $preference . '" = "' . $value . '" for ' . $user_id); break; } } } return $result; }