本文整理汇总了PHP中unslashify函数的典型用法代码示例。如果您正苦于以下问题:PHP unslashify函数的具体用法?PHP unslashify怎么用?PHP unslashify使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了unslashify函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: replace
/**
* Replace emoticon icons <img> 'src' attribute, so it can
* be replaced with real file by Mail_Mime.
*
* @param string &$html HTML content
*
* @return array List of image files
*/
public static function replace(&$html)
{
// Replace this:
// <img src="http[s]://.../tinymce/plugins/emoticons/img/smiley-cool.gif" ... />
// with this:
// <img src="/path/on/server/.../tinymce/plugins/emoticons/img/smiley-cool.gif" ... />
$rcube = rcube::get_instance();
$assets_dir = $rcube->config->get('assets_dir');
$path = unslashify($assets_dir ?: INSTALL_PATH) . '/' . self::IMG_PATH;
$offset = 0;
$images = array();
// remove any null-byte characters before parsing
$html = preg_replace('/\\x00/', '', $html);
if (preg_match_all('# src=[\'"]([^\'"]+)#', $html, $matches, PREG_OFFSET_CAPTURE)) {
foreach ($matches[1] as $m) {
// find emoticon image tags
if (preg_match('#' . self::IMG_PATH . '(.*)$#', $m[0], $imatches)) {
$image_name = $imatches[1];
// sanitize image name so resulting attachment doesn't leave images dir
$image_name = preg_replace('/[^a-zA-Z0-9_\\.\\-]/i', '', $image_name);
$image_file = $path . $image_name;
// Add the same image only once
$images[$image_name] = $image_file;
$html = substr_replace($html, $image_file, $m[1] + $offset, strlen($m[0]));
$offset += strlen($image_file) - strlen($m[0]);
}
}
}
return $images;
}
示例2: load
/**
* Load config from local config file
*
* @todo Remove global $CONFIG
*/
private function load()
{
// load main config file
if (!$this->load_from_file(RCMAIL_CONFIG_DIR . '/main.inc.php')) {
$this->errors[] = 'main.inc.php was not found.';
}
// load database config
if (!$this->load_from_file(RCMAIL_CONFIG_DIR . '/db.inc.php')) {
$this->errors[] = 'db.inc.php was not found.';
}
// load host-specific configuration
$this->load_host_config();
// set skin (with fallback to old 'skin_path' property)
if (empty($this->prop['skin'])) {
if (!empty($this->prop['skin_path'])) {
$this->prop['skin'] = str_replace('skins/', '', unslashify($this->prop['skin_path']));
} else {
$this->prop['skin'] = self::DEFAULT_SKIN;
}
}
// larry is the new default skin :-)
if ($this->prop['skin'] == 'default') {
$this->prop['skin'] = self::DEFAULT_SKIN;
}
// fix paths
$this->prop['log_dir'] = $this->prop['log_dir'] ? realpath(unslashify($this->prop['log_dir'])) : INSTALL_PATH . 'logs';
$this->prop['temp_dir'] = $this->prop['temp_dir'] ? realpath(unslashify($this->prop['temp_dir'])) : INSTALL_PATH . 'temp';
// fix default imap folders encoding
foreach (array('drafts_mbox', 'junk_mbox', 'sent_mbox', 'trash_mbox') as $folder) {
$this->prop[$folder] = rcube_charset::convert($this->prop[$folder], RCMAIL_CHARSET, 'UTF7-IMAP');
}
if (!empty($this->prop['default_folders'])) {
foreach ($this->prop['default_folders'] as $n => $folder) {
$this->prop['default_folders'][$n] = rcube_charset::convert($folder, RCMAIL_CHARSET, 'UTF7-IMAP');
}
}
// set PHP error logging according to config
if ($this->prop['debug_level'] & 1) {
ini_set('log_errors', 1);
if ($this->prop['log_driver'] == 'syslog') {
ini_set('error_log', 'syslog');
} else {
ini_set('error_log', $this->prop['log_dir'] . '/errors');
}
}
// enable display_errors in 'show' level, but not for ajax requests
ini_set('display_errors', intval(empty($_REQUEST['_remote']) && $this->prop['debug_level'] & 4));
// set timezone auto settings values
if ($this->prop['timezone'] == 'auto') {
$this->prop['_timezone_value'] = $this->client_timezone();
} else {
if (is_numeric($this->prop['timezone'])) {
$this->prop['timezone'] = timezone_name_from_abbr("", $this->prop['timezone'] * 3600, 0);
}
}
// remove deprecated properties
unset($this->prop['dst_active']);
// export config data
$GLOBALS['CONFIG'] =& $this->prop;
}
示例3: do_messagemove
function do_messagemove($uids, $spam)
{
$rcmail = rcmail::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);
if (strpos($_SESSION['username'], '@') !== false) {
$parts = explode("@", $_SESSION['username'], 2);
$filename = str_replace(array('%l', '%d'), array($parts[0], $parts[1]), $filename);
}
foreach (explode(",", $uids) as $uid) {
$tmpfname = tempnam($dest_dir, $filename);
file_put_contents($tmpfname, $rcmail->imap->get_raw_body($uid));
if ($rcmail->config->get('markasjunk2_debug')) {
write_log('markasjunk2', $tmpfname);
}
}
}
示例4: test_unslashify
/**
* rcube_shared.inc: unslashify()
*/
function test_unslashify()
{
$data = array('test' => 'test', 'test/' => 'test', '/' => '', "\\/" => "\\", 'test/test' => 'test/test', 'test//' => 'test');
foreach ($data as $value => $expected) {
$result = unslashify($value);
$this->assertEquals($expected, $result, "Invalid unslashify() result for {$value}");
}
}
示例5: load
/**
* Load config from local config file
*
* @todo Remove global $CONFIG
*/
private function load()
{
// start output buffering, we don't need any output yet,
// it'll be cleared after reading of config files, etc.
ob_start();
// load main config file
if (include RCMAIL_CONFIG_DIR . '/main.inc.php') {
$this->prop = (array) $rcmail_config;
} else {
$this->errors[] = 'main.inc.php was not found.';
}
// load database config
if (include RCMAIL_CONFIG_DIR . '/db.inc.php') {
$this->prop += (array) $rcmail_config;
} else {
$this->errors[] = 'db.inc.php was not found.';
}
// load host-specific configuration
$this->load_host_config();
// set skin (with fallback to old 'skin_path' property)
if (empty($this->prop['skin']) && !empty($this->prop['skin_path'])) {
$this->prop['skin'] = str_replace('skins/', '', unslashify($this->prop['skin_path']));
} else {
if (empty($this->prop['skin'])) {
$this->prop['skin'] = 'default';
}
}
// fix paths
$this->prop['log_dir'] = $this->prop['log_dir'] ? unslashify($this->prop['log_dir']) : INSTALL_PATH . 'logs';
$this->prop['temp_dir'] = $this->prop['temp_dir'] ? unslashify($this->prop['temp_dir']) : INSTALL_PATH . 'temp';
// fix default imap folders encoding
foreach (array('drafts_mbox', 'junk_mbox', 'sent_mbox', 'trash_mbox') as $folder) {
$this->prop[$folder] = rcube_charset_convert($this->prop[$folder], RCMAIL_CHARSET, 'UTF-7');
}
if (!empty($this->prop['default_imap_folders'])) {
foreach ($this->prop['default_imap_folders'] as $n => $folder) {
$this->prop['default_imap_folders'][$n] = rcube_charset_convert($folder, RCMAIL_CHARSET, 'UTF-7');
}
}
// set PHP error logging according to config
if ($this->prop['debug_level'] & 1) {
ini_set('log_errors', 1);
if ($this->prop['log_driver'] == 'syslog') {
ini_set('error_log', 'syslog');
} else {
ini_set('error_log', $this->prop['log_dir'] . '/errors');
}
}
if ($this->prop['debug_level'] & 4) {
ini_set('display_errors', 1);
} else {
ini_set('display_errors', 0);
}
// clear output buffer
ob_end_clean();
// export config data
$GLOBALS['CONFIG'] =& $this->prop;
}
示例6: bSaveStat
function bSaveStat()
{
$ip = ip2int($_SERVER['REMOTE_ADDR']);
$to = unslashify($_SERVER['REQUEST_URI']);
$from = @unslashify($_SERVER['HTTP_REFERER']);
$agent = $_SERVER['HTTP_USER_AGENT'];
$sessid = session_id();
$sql = "INSERT INTO `" . DB_PREFIX . DB_TBL_STAT . "` ( `id` , `t` , `ip` , `to` , `from` , `agent` , `sessid` ) VALUES ( '', NOW( ) , '{$ip}', '{$to}', '{$from}', '{$agent}', '{$sessid}');";
$sql = mysql_query($sql);
if ($sql === false) {
return false;
}
return true;
}
示例7: load
/**
* Load config from local config file
*
* @todo Remove global $CONFIG
*/
private function load()
{
// load main config file
if (!$this->load_from_file(RCMAIL_CONFIG_DIR . '/main.inc.php')) {
$this->errors[] = 'main.inc.php was not found.';
}
// load database config
if (!$this->load_from_file(RCMAIL_CONFIG_DIR . '/db.inc.php')) {
$this->errors[] = 'db.inc.php was not found.';
}
// load host-specific configuration
$this->load_host_config();
// set skin (with fallback to old 'skin_path' property)
if (empty($this->prop['skin']) && !empty($this->prop['skin_path'])) {
$this->prop['skin'] = str_replace('skins/', '', unslashify($this->prop['skin_path']));
} else {
if (empty($this->prop['skin'])) {
$this->prop['skin'] = 'default';
}
}
// fix paths
$this->prop['log_dir'] = $this->prop['log_dir'] ? realpath(unslashify($this->prop['log_dir'])) : INSTALL_PATH . 'logs';
$this->prop['temp_dir'] = $this->prop['temp_dir'] ? realpath(unslashify($this->prop['temp_dir'])) : INSTALL_PATH . 'temp';
// fix default imap folders encoding
foreach (array('drafts_mbox', 'junk_mbox', 'sent_mbox', 'trash_mbox') as $folder) {
$this->prop[$folder] = rcube_charset_convert($this->prop[$folder], RCMAIL_CHARSET, 'UTF7-IMAP');
}
if (!empty($this->prop['default_imap_folders'])) {
foreach ($this->prop['default_imap_folders'] as $n => $folder) {
$this->prop['default_imap_folders'][$n] = rcube_charset_convert($folder, RCMAIL_CHARSET, 'UTF7-IMAP');
}
}
// set PHP error logging according to config
if ($this->prop['debug_level'] & 1) {
ini_set('log_errors', 1);
if ($this->prop['log_driver'] == 'syslog') {
ini_set('error_log', 'syslog');
} else {
ini_set('error_log', $this->prop['log_dir'] . '/errors');
}
}
if ($this->prop['debug_level'] & 4) {
ini_set('display_errors', 1);
} else {
ini_set('display_errors', 0);
}
// export config data
$GLOBALS['CONFIG'] =& $this->prop;
}
示例8: save
/**
* Save an attachment from a non-upload source (draft or forward)
*/
function save($args)
{
$args['status'] = false;
if (!$args['path']) {
$rcmail = rcmail::get_instance();
$temp_dir = unslashify($rcmail->config->get('temp_dir'));
$tmp_path = tempnam($temp_dir, 'rcmAttmnt');
if ($fp = fopen($tmp_path, 'w')) {
fwrite($fp, $args['data']);
fclose($fp);
$args['path'] = $tmp_path;
} else {
return $args;
}
}
$args['id'] = $this->file_id();
$args['status'] = true;
// Note the file for later cleanup
$_SESSION['plugins']['filesystem_attachments']['tmp_files'][] = $args['path'];
return $args;
}
示例9: _do_messagemove
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);
}
}
}
示例10: load
/**
* Load config from local config file
*
* @todo Remove global $CONFIG
*/
private function load()
{
// Load default settings
if (!$this->load_from_file('defaults.inc.php')) {
$this->errors[] = 'defaults.inc.php was not found.';
}
// load main config file
if (!$this->load_from_file('config.inc.php')) {
// Old configuration files
if (!$this->load_from_file('main.inc.php') || !$this->load_from_file('db.inc.php')) {
$this->errors[] = 'config.inc.php was not found.';
} else {
if (rand(1, 100) == 10) {
// log warning on every 100th request (average)
trigger_error("config.inc.php was not found. Please migrate your config by running bin/update.sh", E_USER_WARNING);
}
}
}
// load host-specific configuration
$this->load_host_config();
// set skin (with fallback to old 'skin_path' property)
if (empty($this->prop['skin'])) {
if (!empty($this->prop['skin_path'])) {
$this->prop['skin'] = str_replace('skins/', '', unslashify($this->prop['skin_path']));
} else {
$this->prop['skin'] = self::DEFAULT_SKIN;
}
}
// larry is the new default skin :-)
if ($this->prop['skin'] == 'default') {
$this->prop['skin'] = self::DEFAULT_SKIN;
}
// fix paths
foreach (array('log_dir' => 'logs', 'temp_dir' => 'temp') as $key => $dir) {
foreach (array($this->prop[$key], '../' . $this->prop[$key], RCUBE_INSTALL_PATH . $dir) as $path) {
if ($path && ($realpath = realpath(unslashify($path)))) {
$this->prop[$key] = $realpath;
break;
}
}
}
// fix default imap folders encoding
foreach (array('drafts_mbox', 'junk_mbox', 'sent_mbox', 'trash_mbox') as $folder) {
$this->prop[$folder] = rcube_charset::convert($this->prop[$folder], RCUBE_CHARSET, 'UTF7-IMAP');
}
// set PHP error logging according to config
if ($this->prop['debug_level'] & 1) {
ini_set('log_errors', 1);
if ($this->prop['log_driver'] == 'syslog') {
ini_set('error_log', 'syslog');
} else {
ini_set('error_log', $this->prop['log_dir'] . '/errors');
}
}
// enable display_errors in 'show' level, but not for ajax requests
ini_set('display_errors', intval(empty($_REQUEST['_remote']) && $this->prop['debug_level'] & 4));
// remove deprecated properties
unset($this->prop['dst_active']);
// export config data
$GLOBALS['CONFIG'] =& $this->prop;
}
示例11: parse_url
}
}
// $aGetQuery - массив содержащий все get-параметры
// $sRequest - строка запроса, $nRequest - ee длина
// $aRequest - массив элементов запроса
$url = parse_url($_SERVER['REQUEST_URI']);
if (isset($url['query'])) {
parse_str($url['query'], $url['query']);
if (get_magic_quotes_gpc()) {
strips($url['query']);
}
$aGetQuery = $url['query'];
} else {
$aGetQuery = array();
}
$sRequest = unslashify($url['path']);
$nRequest = strlen($sRequest);
$aRequest = explode('/', $sRequest);
// libs, нужные в том числе и ядру
// Components // ***TODO***: Кэшировать в файле алиасы таблиц, чтобы не дергать каждый раз базу
$Components = new Components();
foreach ($Components->getAllTablesAndAliases() as $v) {
$v['alias'] = 'DB_TBL_' . strtoupper($v['alias']);
if (!defined($v['alias'])) {
define($v['alias'], $v['name']);
//dbg($v['alias']);
}
}
// Стартуем сессии - до вывода чего-либо в броузер
session_start();
// Stat - мало ли какие ошибки произойдут дальше, а статитистику мы сохраним
示例12: temp_gc
/**
* Garbage collector function for temp files.
* Remove temp files older than two days
*/
public function temp_gc()
{
$tmp = unslashify($this->config->get('temp_dir'));
$expire = time() - 172800;
// expire in 48 hours
if ($tmp && ($dir = opendir($tmp))) {
while (($fname = readdir($dir)) !== false) {
if ($fname[0] == '.') {
continue;
}
if (filemtime($tmp . '/' . $fname) < $expire) {
@unlink($tmp . '/' . $fname);
}
}
closedir($dir);
}
}
示例13: autodiscover_calendars
/**
* Auto discover calenders available to the user on the caldav server
* @param array $props
* url: Absolute URL to calendar server
* user: Username
* pass: Password
* @return array
* name: Calendar display name
* href: Absolute calendar URL
*/
public function autodiscover_calendars($props)
{
$calendars = array();
$current_user_principal = array('{DAV:}current-user-principal');
$calendar_home_set = array('{urn:ietf:params:xml:ns:caldav}calendar-home-set');
$cal_attribs = array('{DAV:}resourcetype', '{DAV:}displayname');
require_once INSTALL_PATH . 'plugins/libgpl/caldav/caldav-client.php';
$caldav = new caldav_client($props['url'], $props['user'], $props['pass'], $props['authtype'], array($this->rc->config->get('calendar_curl_verify_peer', true), $this->rc->config->get('calendar_curl_verify_host', true)));
$tokens = parse_url($props['url']);
$base_uri = $tokens['scheme'] . '://' . $tokens['host'] . ($tokens['port'] ? ':' . $tokens['port'] : null);
$caldav_url = $props['url'];
$response = $caldav->prop_find($caldav_url, $current_user_principal, 0);
if (!$response) {
self::debug_log("Resource \"{$caldav_url}\" has no collections.");
return $calendars;
}
$caldav_url = $base_uri . $response[$current_user_principal[0]];
$response = $caldav->prop_find($caldav_url, $calendar_home_set, 0);
if (!$response) {
self::debug_log("Resource \"{$caldav_url}\" contains no calendars.");
return $calendars;
}
if (strtolower(substr($response[$calendar_home_set[0]], 0, 4)) == 'http') {
$caldav_url = $response[$calendar_home_set[0]];
} else {
$caldav_url = $base_uri . $response[$calendar_home_set[0]];
}
$response = $caldav->prop_find($caldav_url, $cal_attribs, 1);
$categories = $this->rc->config->get('calendar_categories', array());
foreach ($response as $collection => $attribs) {
$found = false;
$name = '';
foreach ($attribs as $key => $value) {
if ($key == '{DAV:}resourcetype' && is_object($value)) {
if ($value instanceof Sabre\DAV\Property\ResourceType) {
$values = $value->getValue();
if (in_array('{urn:ietf:params:xml:ns:caldav}calendar', $values)) {
$found = true;
}
}
} else {
if ($key == '{DAV:}displayname') {
$name = $value;
}
}
}
if ($found) {
array_push($calendars, array('name' => $name ? $name : ucwords(end(explode('/', unslashify($base_uri . $collection)))), 'href' => $base_uri . $collection, 'color' => $categories[$name] ? $categories[$name] : $props['color']));
}
}
return $calendars;
}
示例14: create_pubkey_dummy
/**
* Creates a dummy public key file
*/
function create_pubkey_dummy()
{
$rcmail = rcmail::get_instance();
$temp_dir = unslashify($rcmail->config->get('temp_dir'));
if (!empty($temp_dir)) {
$file = $temp_dir . "/" . md5($_SESSION['username']) . ".asc";
if (file_exists($file)) {
@unlink($file);
}
if (file_put_contents($file, " ")) {
return $file;
}
}
return false;
}
示例15: gc_temp
/**
* Garbage collector function for temp files.
* Remove temp files older than two days
*/
public function gc_temp()
{
$tmp = unslashify($this->config->get('temp_dir'));
// expire in 48 hours by default
$temp_dir_ttl = $this->config->get('temp_dir_ttl', '48h');
$temp_dir_ttl = get_offset_sec($temp_dir_ttl);
if ($temp_dir_ttl < 6 * 3600) {
$temp_dir_ttl = 6 * 3600;
}
// 6 hours sensible lower bound.
$expire = time() - $temp_dir_ttl;
if ($tmp && ($dir = opendir($tmp))) {
while (($fname = readdir($dir)) !== false) {
if ($fname[0] == '.') {
continue;
}
if (@filemtime($tmp . '/' . $fname) < $expire) {
@unlink($tmp . '/' . $fname);
}
}
closedir($dir);
}
}