mibew/src/messenger/webim/libs/common/request.php
2013-03-13 15:32:40 +00:00

88 lines
2.2 KiB
PHP

<?php
/*
* Copyright 2005-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require_once(dirname(__FILE__) . '/locale.php');
/* ajax server actions use utf-8 */
function getrawparam($name)
{
global $webim_encoding;
if (isset($_POST[$name])) {
$value = myiconv("utf-8", $webim_encoding, $_POST[$name]);
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
}
return $value;
}
die("no " . $name . " parameter");
}
/* form processors use current Output encoding */
function getparam($name)
{
global $webim_encoding;
if (isset($_POST[$name])) {
$value = myiconv(getoutputenc(), $webim_encoding, $_POST[$name]);
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
}
return $value;
}
die("no " . $name . " parameter");
}
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 get_app_location($showhost, $issecure)
{
global $webimroot;
if ($showhost) {
return ($issecure ? "https://" : "http://") . $_SERVER['HTTP_HOST'] . $webimroot;
} else {
return $webimroot;
}
}
function is_secure_request()
{
return
isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443'
|| isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on"
|| isset($_SERVER["HTTP_HTTPS"]) && $_SERVER["HTTP_HTTPS"] == "on";
}
function getchatstyle()
{
$chatstyle = verifyparam("style", "/^\w+$/", "");
if ($chatstyle) {
return $chatstyle;
}
return Settings::get('chatstyle');
}
?>