本文整理汇总了PHP中slashify函数的典型用法代码示例。如果您正苦于以下问题:PHP slashify函数的具体用法?PHP slashify怎么用?PHP slashify使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了slashify函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($username, $password, $host, $port, $usetls, $ruleset, $dir, $elsif = true)
{
$this->sieve = new Net_Sieve();
if (PEAR::isError($this->sieve->connect($host, $port, NULL, $usetls))) {
return $this->_set_error(SIEVE_ERROR_CONNECTION);
}
if (PEAR::isError($this->sieve->login($username, $password))) {
return $this->_set_error(SIEVE_ERROR_LOGIN);
}
$this->ruleset = $ruleset;
$this->elsif = $elsif;
if ($this->ruleset !== false) {
$this->get_script();
} else {
$this->ruleset = $this->get_active();
$this->get_script();
}
// init importers
$dir = slashify(realpath(slashify($dir) . 'importFilters/'));
$handle = opendir($dir);
while ($importer = readdir($handle)) {
if ($importer == '.' || $importer == '..') {
continue;
}
include $dir . $importer;
$importer = substr($importer, 0, -4);
$importer = 'srimport_' . $importer;
if (class_exists($importer, false)) {
$importerClass = new $importer();
$this->importers[$importer] = $importerClass;
}
}
closedir($handle);
}
示例2: read_squirrel_prefs
private function read_squirrel_prefs($uname)
{
$this->load_config();
$rcmail = rcmail::get_instance();
if ($srcdir = $rcmail->config->get('squirrelmail_data_dir')) {
$prefsfile = slashify($srcdir) . $uname . '.pref';
$abookfile = slashify($srcdir) . $uname . '.abook';
$sigfile = slashify($srcdir) . $uname . '.sig';
if (is_readable($prefsfile)) {
$this->prefs = array();
foreach (file($prefsfile) as $line) {
list($key, $value) = explode('=', $line);
$this->prefs[$key] = utf8_encode(rtrim($value));
}
// also read signature file if exists
if (is_readable($sigfile)) {
$this->prefs['signature'] = utf8_encode(file_get_contents($sigfile));
}
// parse addres book file
if (filesize($abookfile)) {
foreach (file($abookfile) as $line) {
list($rec['name'], $rec['firstname'], $rec['surname'], $rec['email']) = explode('|', utf8_encode(rtrim($line)));
if ($rec['name'] && $rec['email']) {
$this->abook[] = $rec;
}
}
}
}
}
}
示例3: test_slashify
/**
* rcube_shared.inc: slashify()
*/
function test_slashify()
{
$data = array('test' => 'test/', 'test/' => 'test/', '' => '/', "\\" => "\\/");
foreach ($data as $value => $expected) {
$result = slashify($value);
$this->assertEquals($expected, $result, "Invalid slashify() result for {$value}");
}
}
示例4: __construct
public function __construct($username, $password, $host, $port, $auth_type = NULL, $usetls, $ruleset, $dir, $elsif = true, $auth_cid = NULL, $auth_pw = NULL, $socket_options = array())
{
$this->sieve = new Net_Sieve();
$data = rcube::get_instance()->plugins->exec_hook('sieverules_connect', array('username' => $username, 'password' => $password, 'host' => $host, 'port' => $port, 'auth_type' => $auth_type, 'usetls' => $usetls, 'ruleset' => $ruleset, 'dir' => $dir, 'elsif' => $elsif, 'auth_cid' => $auth_cid, 'auth_pw' => $auth_pw, 'socket_options' => $options));
$username = $data['username'];
$password = $data['password'];
$host = $data['host'];
$port = $data['port'];
$auth_type = $data['auth_type'];
$usetls = $data['usetls'];
$ruleset = $data['ruleset'];
$dir = $data['dir'];
$elsif = $data['elsif'];
$auth_cid = $data['auth_cid'];
$auth_pw = $data['auth_pw'];
$socket_options = $data['socket_options'];
if (PEAR::isError($this->sieve->connect($host, $port, $socket_options, $usetls))) {
return $this->_set_error(SIEVE_ERROR_CONNECTION);
}
if (!empty($auth_cid)) {
$authz = $username;
$username = $auth_cid;
$password = $auth_pw;
}
if (PEAR::isError($this->sieve->login($username, $password, $auth_type ? strtoupper($auth_type) : NULL, $authz))) {
return $this->_set_error(SIEVE_ERROR_LOGIN);
}
$this->ruleset = $ruleset;
$this->elsif = $elsif;
if ($this->ruleset !== false) {
$this->get_script();
} else {
$this->ruleset = $this->get_active();
$this->get_script();
}
// init importers
if ($dir = realpath(slashify($dir) . 'importFilters/')) {
$dir = slashify($dir);
$handle = opendir($dir);
while ($importer = readdir($handle)) {
if (preg_match('/\\.php$/', $importer) && is_file($dir . $importer) && is_readable($dir . $importer)) {
include $dir . $importer;
$importer = substr($importer, 0, -4);
$importer = 'srimport_' . $importer;
if (class_exists($importer, false)) {
$importerClass = new $importer();
$this->importers[$importer] = $importerClass;
}
}
}
closedir($handle);
}
}
示例5: mysql_query
$sql = mysql_query($sql);
if (false == $sql) {
my_die();
}
$aPhotos = array();
while ($row = mysql_fetch_assoc($sql)) {
$aPhotos[] = $row;
}
//dbg($aPhotos);
if (empty($aPhotos)) {
$tplAlbum->assign('ThumbNail', 'В этом альбоме нет изображений');
}
foreach ($aPhotos as $v) {
$tplThumbNail = $tplAlbum->fetchBlock('ThumbNail');
$tplThumbNail->assign('link', slashify($sRequest) . $v['file']);
$tplThumbNail->assign('img', slashify(ADDR_PHOTOS_THUMBNAILS) . $v['file']);
$tplAlbum->assign('ThumbNail', $tplThumbNail);
$tplThumbNail->reset();
}
$tpl->assign('content', $tplAlbum);
$tplAlbum->reset();
$_t->assign('ContentBlock', $tpl);
$tpl->reset();
} else {
$sql = "SELECT * FROM `" . DB_PREFIX . DB_TBL_IMAGES . "` \n\t\t\tWHERE `file` = '" . $aRequest[count($aRequest) - 1] . "'";
$sql = mysql_query($sql);
if (false == $sql) {
my_die();
}
$aP = array();
while ($row = mysql_fetch_assoc($sql)) {
示例6: mysql_query
}
$sql = "SELECT * FROM `" . DB_PREFIX . DB_TBL_COMMENTS . "` ORDER BY `t` DESC LIMIT " . $nStart . "," . POST_PER_PAGE;
$sql = mysql_query($sql);
if (false == $sql) {
my_die();
}
$aList = array();
while ($row = mysql_fetch_assoc($sql)) {
$aList[] = $row;
}
//dbg($aList);
if (empty($aList)) {
$tpl->assign('Comment', 'Нет комментариев');
}
foreach ($aList as $v) {
$v['url'] = slashify($v['url']);
$sql = "SELECT * FROM. `" . DB_PREFIX . DB_TBL_USERS . "` WHERE `id`=" . $v['user_id'];
$sql = mysql_query($sql);
if (false == $sql) {
my_die();
}
$aUser = array();
while ($row = mysql_fetch_assoc($sql)) {
$aUser = $row;
}
// dbg($aUser);
$v = array_merge($aUser, $v);
// dbg($v);
$tplComment = $tpl->fetchBlock('Comment');
$tplComment->assign($v);
$tpl->assign('Comment', $tplComment);
示例7: read_squirrel_prefs
private function read_squirrel_prefs($uname)
{
$rcmail = rcmail::get_instance();
/**** File based backend ****/
if ($rcmail->config->get('squirrelmail_driver') == 'file' && ($srcdir = $rcmail->config->get('squirrelmail_data_dir'))) {
if (($hash_level = $rcmail->config->get('squirrelmail_data_dir_hash_level')) > 0) {
$srcdir = slashify($srcdir) . chunk_split(substr(base_convert(crc32($uname), 10, 16), 0, $hash_level), 1, '/');
}
$prefsfile = slashify($srcdir) . $uname . '.pref';
$abookfile = slashify($srcdir) . $uname . '.abook';
$sigfile = slashify($srcdir) . $uname . '.sig';
$sigbase = slashify($srcdir) . $uname . '.si';
if (is_readable($prefsfile)) {
$this->prefs = array();
foreach (file($prefsfile) as $line) {
list($key, $value) = explode('=', $line);
$this->prefs[$key] = utf8_encode(rtrim($value));
}
// also read signature file if exists
if (is_readable($sigfile)) {
$this->prefs['___signature___'] = utf8_encode(file_get_contents($sigfile));
}
if (isset($this->prefs['identities']) && $this->prefs['identities'] > 1) {
for ($i = 1; $i < $this->prefs['identities']; $i++) {
// read signature file if exists
if (is_readable($sigbase . $i)) {
$this->prefs['___sig' . $i . '___'] = utf8_encode(file_get_contents($sigbase . $i));
}
}
}
// parse addres book file
if (filesize($abookfile)) {
foreach (file($abookfile) as $line) {
list($rec['name'], $rec['firstname'], $rec['surname'], $rec['email']) = explode('|', utf8_encode(rtrim($line)));
if ($rec['name'] && $rec['email']) {
$this->abook[] = $rec;
}
}
}
}
} else {
if ($rcmail->config->get('squirrelmail_driver') == 'sql') {
$this->prefs = array();
/* connect to squirrelmail database */
$db = rcube_db::factory($rcmail->config->get('squirrelmail_dsn'));
$db->set_debug($rcmail->config->get('sql_debug'));
$db->db_connect('r');
// connect in read mode
/* retrieve prefs */
$userprefs_table = $rcmail->config->get('squirrelmail_userprefs_table');
$address_table = $rcmail->config->get('squirrelmail_address_table');
$db_charset = $rcmail->config->get('squirrelmail_db_charset');
if ($db_charset) {
$db->query('SET NAMES ' . $db_charset);
}
$sql_result = $db->query('SELECT * FROM ' . $userprefs_table . ' WHERE user=?', $uname);
// ? is replaced with emailaddress
while ($sql_array = $db->fetch_assoc($sql_result)) {
// fetch one row from result
$this->prefs[$sql_array['prefkey']] = rcube_charset::convert(rtrim($sql_array['prefval']), $db_charset);
}
/* retrieve address table data */
$sql_result = $db->query('SELECT * FROM ' . $address_table . ' WHERE owner=?', $uname);
// ? is replaced with emailaddress
// parse addres book
while ($sql_array = $db->fetch_assoc($sql_result)) {
// fetch one row from result
$rec['name'] = rcube_charset::convert(rtrim($sql_array['nickname']), $db_charset);
$rec['firstname'] = rcube_charset::convert(rtrim($sql_array['firstname']), $db_charset);
$rec['surname'] = rcube_charset::convert(rtrim($sql_array['lastname']), $db_charset);
$rec['email'] = rcube_charset::convert(rtrim($sql_array['email']), $db_charset);
$rec['notes'] = rcube_charset::convert(rtrim($sql_array['label']), $db_charset);
if ($rec['name'] && $rec['email']) {
$this->abook[] = $rec;
}
}
}
}
// end if 'sql'-driver
}
示例8: __construct
/**
* Private constructor
*/
private function __construct()
{
$this->dir = slashify(RCMAIL_PLUGINS_DIR);
}
示例9: slashify
$tplSelectNews->assign('Paginator', '');
$tplSelectNews->assign('BottomPaginator', '');
}
$page--;
if ($page + NEWS_PER_PAGE > $row - 1) {
$lastnews = $row - 1;
} else {
$lastnews = $page + NEWS_PER_PAGE;
}
for ($i = $page; $i < $lastnews; $i++) {
$tplNews = $tplSelectNews->fetchBlock('News');
$tplNews->assign('way', $sWays);
$tplNews->assign('Img', '');
if (!empty($aNews[$i]['image'])) {
$tplImg = $tplNews->fetchBlock('Img');
$tplImg->assign('image', slashify(ADDR_USERFILES_NEWSPREV));
$tplImg->assign($aNews[$i]);
$tplNews->assign('Img', $tplImg);
$tplImg->reset();
}
$tplNews->assign($aNews[$i]);
$tplSelectNews->assign('News', $tplNews);
$tplNews->reset();
}
$tpl->assign('SelectNews', $tplSelectNews);
} else {
$tplSelectNews->assign('Paginator', '');
$tplSelectNews->assign('BottomPaginator', '');
$tplSelectNews->assign('News', '');
$tpl->assign('SelectNews', $tplSelectNews);
$tpl->assign('SelectNews', 'Ќовостей в данной категории нет.');
示例10: get_resource_content
/**
* Get resource file content (with assets_dir support)
*
* @param string $name File name
*/
public function get_resource_content($name)
{
if (!strpos($name, '/')) {
$name = "program/resources/{$name}";
}
$assets_dir = $this->config->get('assets_dir');
if ($assets_dir) {
$path = slashify($assets_dir) . $name;
if (@file_exists($path)) {
$name = $path;
}
}
return file_get_contents($name, false);
}
示例11: remove_calendar
/**
* Deletes ical properties and the appropriate calendar.
*
* @see database_driver::remove_calendar()
*/
public function remove_calendar($prop)
{
$removed = $this->_get_ical_props($prop['id'], self::OBJ_TYPE_ICAL);
$protected = array();
$preinstalled_calendars = $this->rc->config->get('calendar_preinstalled_calendars', array());
foreach ($preinstalled_calendars as $idx => $properties) {
if ($properties['driver'] == 'ical') {
$url = str_replace('@', urlencode('@'), str_replace('%u', $this->rc->get_user_name(), $properties['ical_url']));
if (stripos($removed['url'], $url) === 0) {
if (isset($properties['deleteable']) && !$properties['deleteable']) {
$this->last_error = $this->rc->gettext('calendar.protected');
return false;
}
}
}
}
if (is_array($removed)) {
$removed = slashify($removed['url']);
$removed = array_merge($this->rc->config->get('calendar_icals_removed', array()), array($removed => time()));
$this->rc->user->save_prefs(array('calendar_icals_removed' => $removed));
}
if (parent::remove_calendar($prop, $ical)) {
$this->_remove_ical_props($prop['id'], self::OBJ_TYPE_ICAL);
return true;
}
return false;
}
示例12: local_skin_path
/**
* Provide path to the currently selected skin folder within the plugin directory
* with a fallback to the default skin folder.
*
* @return string Skin path relative to plugins directory
*/
public function local_skin_path()
{
$rcmail = rcube::get_instance();
$skin_path = 'skins/' . $rcmail->config->get('skin');
if (!is_dir(realpath(slashify($this->home) . $skin_path))) {
$skin_path = 'skins/default';
}
return $skin_path;
}
示例13: prop_report
/**
* Does a REPORT request
*
* @param string $url
* @param array $properties List of requested properties must be specified as an array, in clark
* notation.
* @param array $event_urls If specified, a multiget report request will be initiated with the
* specified event urls.
* @param int $depth = 1 Depth should be either 0 or 1. A depth of 1 will cause a request to be
* made to the server to also return all child resources.
* @return array Hash with ics event path as key and a hash array with properties and appropriate values.
*/
public function prop_report($url, array $properties, array $event_urls = array(), $depth = 1)
{
$url = slashify($url);
// iCloud
$parent_tag = sizeof($event_urls) > 0 ? "c:calendar-multiget" : "d:propfind";
$method = sizeof($event_urls) > 0 ? 'REPORT' : 'PROPFIND';
$body = '<?xml version="1.0"?>' . "\n" . '<' . $parent_tag . ' xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">' . "\n";
$body .= ' <d:prop>' . "\n";
foreach ($properties as $property) {
list($namespace, $elementName) = Sabre\DAV\XMLUtil::parseClarkNotation($property);
if ($namespace === 'DAV:') {
$body .= ' <d:' . $elementName . ' />' . "\n";
} else {
$body .= ' <x:' . $elementName . ' xmlns:x="' . $namespace . '"/>' . "\n";
}
}
$body .= ' </d:prop>' . "\n";
// http://tools.ietf.org/html/rfc4791#page-90
// http://www.bedework.org/trac/bedework/wiki/Bedework/DevDocs/Filters
/*
if($start && $end)
{
$body.= ' <c:filter>'."\n".
' <c:comp-filter name="VCALENDAR">'."\n".
' <c:comp-filter name="VEVENT">'."\n".
' <c:time-range start="'.$start.'" end="'.$end.'" />'."\n".
' </c:comp-filter>'."\n".
' </c:comp-filter>'."\n".
' </c:filter>' . "\n";
}
*/
foreach ($event_urls as $event_url) {
$body .= '<d:href>' . $event_url . '</d:href>' . "\n";
}
$body .= '</' . $parent_tag . '>';
$response = $this->request($method, $url, $body, array('Depth' => $depth, 'Content-Type' => 'application/xml', 'User-Agent' => $this->user_agent));
$result = $this->parseMultiStatus($response['body']);
// If depth was 0, we only return the top item
if ($depth === 0) {
reset($result);
$result = current($result);
return isset($result[200]) ? $result[200] : array();
}
$new_result = array();
foreach ($result as $href => $status_list) {
$new_result[$href] = isset($status_list[200]) ? $status_list[200] : array();
}
return $new_result;
}
示例14: local_skin_path
/**
* Provide path to the currently selected skin folder within the plugin directory
* with a fallback to the default skin folder.
*
* @return string Skin path relative to plugins directory
*/
protected function local_skin_path()
{
$skin_path = 'skins/' . $this->api->config->get('skin');
if (!is_dir(realpath(slashify($this->home) . $skin_path))) {
$skin_path = 'skins/default';
}
return $skin_path;
}
示例15: simplify
/**
* Simplify CardDAV XML response
*
* @param string $response CardDAV XML response
* @param boolean $include_vcards Include vCards or not
* @return string Simplified CardDAV XML response
*/
private function simplify($response, $include_vcards = true)
{
$response = $this->clean_response($response);
set_error_handler(function () {
/* ignore errors */
});
try {
$xml = new SimpleXMLElement($response);
} catch (Exception $e) {
return false;
}
restore_error_handler();
$simplified_xml = new XMLWriter();
$simplified_xml->openMemory();
$simplified_xml->setIndent(4);
$simplified_xml->startDocument('1.0', 'utf-8');
$simplified_xml->startElement('response');
foreach ($xml->response as $response) {
if (preg_match('/vcard/', $response->propstat->prop->getcontenttype) || preg_match('/vcf/', $response->href) || preg_match('/carddav/', $response->href) && slashify($response->href) != $response->href) {
$id = basename($response->href);
$id = str_replace($this->ext, null, $id);
if (!empty($id)) {
$simplified_xml->startElement('element');
$simplified_xml->writeElement('id', $id);
$simplified_xml->writeElement('etag', str_replace('"', null, $response->propstat->prop->getetag));
$simplified_xml->writeElement('last_modified', $response->propstat->prop->getlastmodified);
if ($include_vcards === true) {
$simplified_xml->writeElement('vcard', $this->get_vcard($id));
}
$simplified_xml->endElement();
}
} else {
if (preg_match('/unix-directory/', $response->propstat->prop->getcontenttype)) {
if (isset($response->propstat->prop->href)) {
$href = $response->propstat->prop->href;
} else {
if (isset($response->href)) {
$href = $response->href;
} else {
$href = null;
}
}
$url = str_replace($this->url_parts['path'], null, $this->url) . $href;
$simplified_xml->startElement('addressbook_element');
$simplified_xml->writeElement('display_name', $response->propstat->prop->displayname);
$simplified_xml->writeElement('url', $url);
$simplified_xml->writeElement('last_modified', $response->propstat->prop->getlastmodified);
$simplified_xml->endElement();
}
}
}
$simplified_xml->endElement();
$simplified_xml->endDocument();
return $simplified_xml->outputMemory();
}