function webim_mail($toaddr, $reply_to, $subject, $body, $link) { global $webim_encoding, $webim_mailbox, $mail_encoding, $current_locale; $headers = "From: {$webim_mailbox}\r\n" . "Reply-To: " . myiconv($webim_encoding, $mail_encoding, $reply_to) . "\r\n" . "Content-Type: text/plain; charset={$mail_encoding}\r\n" . 'X-Mailer: PHP/' . phpversion(); $real_subject = "=?" . $mail_encoding . "?B?" . base64_encode(myiconv($webim_encoding, $mail_encoding, $subject)) . "?="; $body = preg_replace("/\n/", "\r\n", $body); @mail($toaddr, $real_subject, wordwrap(myiconv($webim_encoding, $mail_encoding, $body), 70), $headers); }
function demo_print_message($msg, $format) { global $webim_encoding; if ($format == "xml") { print "<message>" . myiconv($webim_encoding, "utf-8", escape_with_cdata(message_to_html($msg))) . "</message>\n"; } else { print topage(message_to_html($msg)); } }
function mibew_mail($toaddr, $reply_to, $subject, $body, $link) { global $mibew_encoding, $mibew_mailbox, $mail_encoding, $current_locale; $headers = "From: {$mibew_mailbox}\r\n" . "Reply-To: " . myiconv($mibew_encoding, $mail_encoding, $reply_to) . "\r\n" . "Content-Type: text/plain; charset={$mail_encoding}\r\n" . 'X-Mailer: PHP/' . phpversion(); $real_subject = "=?" . $mail_encoding . "?B?" . base64_encode(myiconv($mibew_encoding, $mail_encoding, $subject)) . "?="; $body = preg_replace("/\n/", "\r\n", $body); log_notification($current_locale, "mail", $toaddr, $subject, $body, null, $link); $old_from = ini_get('sendmail_from'); ini_set('sendmail_from', $mibew_mailbox); @mail($toaddr, $real_subject, wordwrap(myiconv($mibew_encoding, $mail_encoding, $body), 70), $headers); if (isset($old_from)) { ini_set('sendmail_from', $old_from); } }
function getgetparam($name, $default = '') { global $webim_encoding; if (!isset($_GET[$name]) || !$_GET[$name]) { return $default; } $value = myiconv("utf-8", $webim_encoding, unicode_urldecode($_GET[$name])); if (get_magic_quotes_gpc()) { $value = stripslashes($value); } return $value; }
function visitor_from_request() { global $namecookie, $webim_encoding, $usercookie; $defaultName = getstring("chat.default.username"); $userName = $defaultName; if (isset($_COOKIE[$namecookie])) { $data = base64_decode(strtr($_COOKIE[$namecookie], '-_,', '+/=')); if (strlen($data) > 0) { $userName = myiconv("utf-8", $webim_encoding, $data); } } if ($userName == $defaultName) { $userName = getgetparam('name', $userName); } if (isset($_COOKIE[$usercookie])) { $userId = $_COOKIE[$usercookie]; } else { $userId = get_user_id(); setcookie($usercookie, $userId, time() + 60 * 60 * 24 * 365); } return array('id' => $userId, 'name' => $userName); }
function save_message($locale, $key, $value) { global $webim_encoding; $result = ""; $added = false; $current_encoding = $webim_encoding; $fp = fopen(dirname(__FILE__) . "/../locales/{$locale}/properties", "r"); while (!feof($fp)) { $line = fgets($fp, 4096); $keyval = preg_split("/=/", $line, 2); if (isset($keyval[1])) { if ($keyval[0] == 'encoding') { $current_encoding = trim($keyval[1]); } else { if (!$added && $keyval[0] == $key) { $line = "{$key}=" . myiconv($webim_encoding, $current_encoding, str_replace("\r", "", str_replace("\n", "\\n", trim($value)))) . "\n"; $added = true; } } } $result .= $line; } fclose($fp); if (!$added) { $result .= "{$key}=" . myiconv($webim_encoding, $current_encoding, str_replace("\r", "", str_replace("\n", "\\n", trim($value)))) . "\n"; } $fp = @fopen(dirname(__FILE__) . "/../locales/{$locale}/properties", "w"); if ($fp !== FALSE) { fwrite($fp, $result); fclose($fp); } else { die("cannot write /locales/{$locale}/properties, please check file permissions on your server"); } $fp = @fopen(dirname(__FILE__) . "/../locales/{$locale}/properties.log", "a"); if ($fp !== FALSE) { $extAddr = $_SERVER['REMOTE_ADDR']; if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] != $_SERVER['REMOTE_ADDR']) { $extAddr = $_SERVER['REMOTE_ADDR'] . ' (' . $_SERVER['HTTP_X_FORWARDED_FOR'] . ')'; } $userbrowser = $_SERVER['HTTP_USER_AGENT']; $remoteHost = isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : $extAddr; fwrite($fp, "# " . date(DATE_RFC822) . " by {$remoteHost} using {$userbrowser}\n"); fwrite($fp, "{$key}=" . myiconv($webim_encoding, $current_encoding, str_replace("\r", "", str_replace("\n", "\\n", trim($value)))) . "\n"); fclose($fp); } }
$visitor = visitor_from_request(); if (isset($_POST['survey']) && $_POST['survey'] == 'on') { $firstmessage = getparam("message"); $info = getparam("info"); $email = getparam("email"); $referrer = urldecode(getparam("referrer")); if ($settings["surveyaskcaptcha"] == "1") { $captcha = getparam('captcha'); $original = isset($_SESSION["mibew_captcha"]) ? $_SESSION["mibew_captcha"] : ""; $survey_captcha_failed = empty($original) || empty($captcha) || $captcha != $original; unset($_SESSION['mibew_captcha']); } if ($settings['usercanchangename'] == "1" && isset($_POST['name'])) { $newname = getparam("name"); if ($newname != $visitor['name']) { $data = strtr(base64_encode(myiconv($mibew_encoding, "utf-8", $newname)), '+/=', '-_,'); setcookie($namecookie, $data, time() + 60 * 60 * 24 * 365); $visitor['name'] = $newname; } } } else { $firstmessage = NULL; $info = getgetparam('info'); $email = getgetparam('email'); $referrer = isset($_GET['url']) ? $_GET['url'] : (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ""); if (isset($_GET['referrer']) && $_GET['referrer']) { $referrer .= "\n" . $_GET['referrer']; } } if (!has_online_operators($groupid)) { $page = array();
* EPL, indicate your decision by deleting the provisions above and replace them * with the notice and other provisions required by the GPL. * * Contributors: * Pavel Petroshenko - initial API and implementation */ require_once '../libs/common.php'; require_once '../libs/operator.php'; require_once '../libs/chat.php'; require_once '../libs/userinfo.php'; require_once '../libs/pagination.php'; $operator = check_login(); loadsettings(); setlocale(LC_TIME, getstring("time.locale")); $page = array(); $query = isset($_GET['q']) ? myiconv(getoutputenc(), $webim_encoding, $_GET['q']) : false; if ($query !== false) { $link = connect(); $result = mysql_query("select {$mysqlprefix}chatgroup.groupid as groupid, vclocalname " . "from {$mysqlprefix}chatgroup order by vclocalname", $link); $groupName = array(); while ($group = mysql_fetch_array($result, MYSQL_ASSOC)) { $groupName[$group['groupid']] = $group['vclocalname']; } mysql_free_result($result); $page['groupName'] = $groupName; $escapedQuery = mysql_real_escape_string($query, $link); select_with_pagintation("DISTINCT unix_timestamp({$mysqlprefix}chatthread.dtmcreated) as created, " . "unix_timestamp({$mysqlprefix}chatthread.dtmmodified) as modified, {$mysqlprefix}chatthread.threadid, " . "{$mysqlprefix}chatthread.remote, {$mysqlprefix}chatthread.agentName, {$mysqlprefix}chatthread.userName, groupid, " . "messageCount as size", "{$mysqlprefix}chatthread, {$mysqlprefix}chatmessage", array("{$mysqlprefix}chatmessage.threadid = {$mysqlprefix}chatthread.threadid", "(({$mysqlprefix}chatthread.userName LIKE '%%{$escapedQuery}%%') or ({$mysqlprefix}chatmessage.tmessage LIKE '%%{$escapedQuery}%%'))"), "order by created DESC", "DISTINCT {$mysqlprefix}chatthread.dtmcreated", $link); mysql_close($link); $page['formq'] = topage($query); } else { setup_empty_pagination();
function print_operators() { global $mibew_encoding; echo "<operators>"; $operators = operator_get_all(); foreach ($operators as $operator) { if (!operator_is_online($operator)) { continue; } $name = myiconv($mibew_encoding, "utf-8", safe_htmlspecialchars(safe_htmlspecialchars($operator['vclocalename']))); $away = operator_is_away($operator) ? " away=\"1\"" : ""; echo "<operator name=\"{$name}\"{$away}/>"; } echo "</operators>"; }
function print_pending_threads($groupids, $since) { global $webim_encoding, $settings, $state_closed, $state_left, $mysqlprefix; $link = connect(); $revision = $since; $output = array(); $query = "select threadid, userName, agentName, unix_timestamp(dtmcreated), userTyping, " . "unix_timestamp(dtmmodified), lrevision, istate, remote, nextagent, agentId, userid, shownmessageid, userAgent, (select vclocalname from {$mysqlprefix}chatgroup where {$mysqlprefix}chatgroup.groupid = {$mysqlprefix}chatthread.groupid) as groupname " . "from {$mysqlprefix}chatthread where lrevision > {$since} " . ($since <= 0 ? "AND istate <> {$state_closed} AND istate <> {$state_left} " : "") . ($settings['enablegroups'] == '1' ? "AND (groupid is NULL" . ($groupids ? " OR groupid IN ({$groupids})" : "") . ") " : "") . "ORDER BY threadid"; $rows = select_multi_assoc($query, $link); foreach ($rows as $row) { $thread = thread_to_xml($row, $link); $output[] = $thread; if ($row['lrevision'] > $revision) { $revision = $row['lrevision']; } } mysql_close($link); echo "<threads revision=\"{$revision}\" time=\"" . time() . "000\">"; foreach ($output as $thr) { print myiconv($webim_encoding, "utf-8", $thr); } echo "</threads>"; }