本文整理汇总了PHP中obfuscate函数的典型用法代码示例。如果您正苦于以下问题:PHP obfuscate函数的具体用法?PHP obfuscate怎么用?PHP obfuscate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了obfuscate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mailto_link
function mailto_link($email, $title = null)
{
$email = str_replace('@', '@', obfuscate($email));
$email = obfuscate('mailto:') . $email;
$title = $title ?: $email;
return $this->toHtmlString('<a href="' . $email . '">' . htmlentities($title, ENT_QUOTES, 'UTF-8', false) . '</a>');
}
示例2: qx_mailtoencode
function qx_mailtoencode($emailAddy, $text = '', $buildLink = true, $class = '', $style = '')
{
if ($buildLink) {
// mailto: portion
$obfuscatedMailTo = '';
$mailto = "mailto:";
$length = strlen($mailto);
for ($i = 0; $i < $length; $i++) {
$obfuscatedMailTo .= "&#" . ord($mailto[$i]);
}
// END - mailto: portion
$emailLink = '<a href="';
$emailLink .= $obfuscatedMailTo;
}
$emailLink .= obfuscate($emailAddy);
if ($buildLink) {
$emailLink .= '"';
if (trim($class) != '') {
$emailLink .= ' class="' . $class . '"';
}
if (trim($style) != '') {
$emailLink .= ' style="' . $style . '"';
}
$emailLink .= '>';
if (trim($text) != '') {
$newText = trim($text);
$newText = str_replace('@', '@', $newText);
$newText = str_replace('.', '.', $newText);
$emailLink .= $newText;
} else {
$newText = trim($emailAddy);
$newText = str_replace('@', '@', $newText);
$newText = str_replace('.', '.', $newText);
$emailLink .= $newText;
}
$emailLink .= "</a>";
}
return $emailLink;
}
示例3: obfuscateEmail
/**
* obfuscates eMail addresses (links with 'href="mailto:..."') by using
* Base64 Encoding and ROT13 in combination; this will need JavaScript for
* de-obfuscation on the client side!
*
* @access public
* @param string &$content - page content to parse
* @return void edits $content
**/
function obfuscateEmail(&$content)
{
$dom = new DOMDocument();
libxml_use_internal_errors(true);
@$dom->loadHTML($content);
$x = new DOMXPath($dom);
foreach ($x->query("//a") as $node) {
if (preg_match('~^mailto:(.*)~i', $node->getAttribute("href"), $match)) {
$obfuscated = obfuscate($match[1]);
$content = str_replace($match[0], 'javascript:' . $obfuscated, $content);
// replace any other occurance
$content = str_replace($match[1], '<script type="text/javascript">document.write(' . $obfuscated . ');</script>', $content);
}
}
// match any other occurances of email addresses
preg_match_all('/\\b([A-Za-z0-9._%-]+@(?:[A-Za-z0-9-]+\\.)+[A-Za-z]{2,4})\\b/D', $content, $matches, PREG_SET_ORDER);
if (count($matches)) {
foreach ($matches as $match) {
$content = str_replace($match[1], '<script type="text/javascript">document.write(' . obfuscate($match[1]) . ');</script>', $content);
}
}
// add JS to the header
register_filter_js(CAT_URL . '/modules/blackcatFilter/js/obfuscateEmail.js');
}
示例4: editorinfo
/**
* Return the users realname or e-mail address for use
* in page footer and recent changes pages
*
* @author Andy Webber <dokuwiki AT andywebber DOT com>
*/
function editorinfo($username)
{
global $conf;
global $auth;
switch ($conf['showuseras']) {
case 'username':
case 'email':
case 'email_link':
if ($auth) {
$info = $auth->getUserData($username);
}
break;
default:
return hsc($username);
}
if (isset($info) && $info) {
switch ($conf['showuseras']) {
case 'username':
return hsc($info['name']);
case 'email':
return obfuscate($info['mail']);
case 'email_link':
$mail = obfuscate($info['mail']);
return '<a href="mailto:' . $mail . '">' . $mail . '</a>';
default:
return hsc($username);
}
} else {
return hsc($username);
}
}
示例5: myPrettyprinter
$parser = new PhpParser\Parser(new PhpParser\Lexer\Emulative());
// $parser = new PhpParser\Parser(new PhpParser\Lexer);
$traverser = new PhpParser\NodeTraverser();
if ($conf->obfuscate_string_literal) {
$prettyPrinter = new myPrettyprinter();
} else {
$prettyPrinter = new PhpParser\PrettyPrinter\Standard();
}
$t_scrambler = array();
foreach (array('variable', 'function', 'method', 'property', 'class', 'class_constant', 'constant', 'namespace', 'label') as $dummy => $scramble_what) {
$t_scrambler[$scramble_what] = new Scrambler($scramble_what, $conf, $process_mode == 'directory' ? $target_directory : null);
}
$traverser->addVisitor(new MyNodeVisitor());
switch ($process_mode) {
case 'file':
$obfuscated_str = obfuscate($source_file);
if ($obfuscated_str === null) {
exit;
}
if ($target_file === '') {
echo $obfuscated_str . PHP_EOL;
exit;
}
file_put_contents($target_file, $obfuscated_str . PHP_EOL);
exit;
case 'directory':
if (isset($conf->t_skip) && is_array($conf->t_skip)) {
foreach ($conf->t_skip as $key => $val) {
$conf->t_skip[$key] = "{$source_directory}/{$val}";
}
}
示例6: userlink
/**
* Returns users realname w/o link
*
* @param string|null $username or null when currently logged-in user should be used
* @param bool $textonly true returns only plain text, true allows returning html
* @return string html or plain text(not escaped) of formatted user name
*
* @triggers COMMON_USER_LINK
*/
function userlink($username = null, $textonly = false)
{
global $conf, $INFO;
/** @var DokuWiki_Auth_Plugin $auth */
global $auth;
/** @var Input $INPUT */
global $INPUT;
// prepare initial event data
$data = array('username' => $username, 'name' => '', 'link' => array('target' => '', 'pre' => '', 'suf' => '', 'style' => '', 'more' => '', 'url' => '', 'title' => '', 'class' => ''), 'userlink' => '', 'textonly' => $textonly);
if ($username === null) {
$data['username'] = $username = $INPUT->server->str('REMOTE_USER');
if ($textonly) {
$data['name'] = $INFO['userinfo']['name'] . ' (' . $INPUT->server->str('REMOTE_USER') . ')';
} else {
$data['name'] = '<bdi>' . hsc($INFO['userinfo']['name']) . '</bdi> (<bdi>' . hsc($INPUT->server->str('REMOTE_USER')) . '</bdi>)';
}
}
$evt = new Doku_Event('COMMON_USER_LINK', $data);
if ($evt->advise_before(true)) {
if (empty($data['name'])) {
if ($auth) {
$info = $auth->getUserData($username);
}
if ($conf['showuseras'] != 'loginname' && isset($info) && $info) {
switch ($conf['showuseras']) {
case 'username':
case 'username_link':
$data['name'] = $textonly ? $info['name'] : hsc($info['name']);
break;
case 'email':
case 'email_link':
$data['name'] = obfuscate($info['mail']);
break;
}
} else {
$data['name'] = $textonly ? $data['username'] : hsc($data['username']);
}
}
/** @var Doku_Renderer_xhtml $xhtml_renderer */
static $xhtml_renderer = null;
if (!$data['textonly'] && empty($data['link']['url'])) {
if (in_array($conf['showuseras'], array('email_link', 'username_link'))) {
if (!isset($info)) {
if ($auth) {
$info = $auth->getUserData($username);
}
}
if (isset($info) && $info) {
if ($conf['showuseras'] == 'email_link') {
$data['link']['url'] = 'mailto:' . obfuscate($info['mail']);
} else {
if (is_null($xhtml_renderer)) {
$xhtml_renderer = p_get_renderer('xhtml');
}
if (empty($xhtml_renderer->interwiki)) {
$xhtml_renderer->interwiki = getInterwiki();
}
$shortcut = 'user';
$exists = null;
$data['link']['url'] = $xhtml_renderer->_resolveInterWiki($shortcut, $username, $exists);
$data['link']['class'] .= ' interwiki iw_user';
if ($exists !== null) {
if ($exists) {
$data['link']['class'] .= ' wikilink1';
} else {
$data['link']['class'] .= ' wikilink2';
$data['link']['rel'] = 'nofollow';
}
}
}
} else {
$data['textonly'] = true;
}
} else {
$data['textonly'] = true;
}
}
if ($data['textonly']) {
$data['userlink'] = $data['name'];
} else {
$data['link']['name'] = $data['name'];
if (is_null($xhtml_renderer)) {
$xhtml_renderer = p_get_renderer('xhtml');
}
$data['userlink'] = $xhtml_renderer->_formatLink($data['link']);
}
}
$evt->advise_after();
unset($evt);
return $data['userlink'];
}
示例7: emaillink
function emaillink($address, $name = NULL)
{
global $conf;
//simple setup
$link = array();
$link['target'] = '';
$link['pre'] = '';
$link['suf'] = '';
$link['style'] = '';
$link['more'] = '';
//we just test for image here - we need to encode the title our self
$this->_getLinkTitle($name, $address, $isImage);
if (!$isImage) {
$link['class'] = 'mail JSnocheck';
} else {
$link['class'] = 'media JSnocheck';
}
$address = $this->_xmlEntities($address);
$address = obfuscate($address);
$title = $address;
if (empty($name)) {
$name = $address;
} else {
$name = $this->_xmlEntities($name);
}
if ($conf['mailguard'] == 'visible') {
$address = rawurlencode($address);
}
$link['url'] = 'mailto:' . $address;
$link['name'] = $name;
$link['title'] = $title;
//output formatted
$this->doc .= $this->_formatLink($link);
}
示例8: test_visible
function test_visible()
{
global $conf;
$conf['mailguard'] = 'visible';
$this->assertEqual(obfuscate('jon-doe@example.com'), 'jon [dash] doe [at] example [dot] com');
}
示例9: email
function email($email)
{
// Make sure the at sign is always obfuscated
return str_replace('@', '@', obfuscate($email));
}
示例10: _getAvatarURL
/**
* Main function to determine the avatar to use
*/
function _getAvatarURL($user, &$title, &$size)
{
global $auth;
if (!$size || !is_int($size)) {
$size = $this->getConf('size');
}
if (is_array($user)) {
$mail = $user['mail'];
$name = $user['name'];
$user = $user['user'];
} else {
$mail = $user;
}
// check first if a local image for the given user exists
$userinfo = $auth->getUserData($user);
if (is_array($userinfo)) {
if ($userinfo['name'] && !$title) {
$title = hsc($userinfo['name']);
}
$ns = $this->getConf('namespace');
$formats = array('.png', '.jpg', '.gif');
foreach ($formats as $format) {
$user_img = mediaFN($ns . ':' . $user . $format);
$name_img = mediaFN($ns . ':' . $name . $format);
if (@file_exists($user_img)) {
$src = ml($ns . ':' . $user . $format, array('w' => $size, 'h' => $size));
break;
} elseif (@file_exists($name_img)) {
$src = ml($ns . ':' . $name . $format, array('w' => $size, 'h' => $size));
}
}
if (!$src) {
$mail = $userinfo['mail'];
}
}
if (!$src) {
$seed = md5(utf8_strtolower($mail));
if (function_exists('imagecreatetruecolor')) {
// we take the monster ID as default
$file = 'monsterid.php?seed=' . $seed . '&size=' . $size . '&.png';
} else {
// GDlib is not availble - resort to default images
switch ($size) {
case 20:
case 40:
case 80:
$file = 'images/default_' . $size . '.png';
break;
default:
$file = 'images/default_120.png';
}
}
$default = ml(DOKU_URL . '/lib/plugins/avatar/' . $file, 'cache=recache', true, '&', true);
// do not pass invalid or empty emails to gravatar site...
if (mail_isvalid($mail) && $size <= 80) {
$src = ml('http://www.gravatar.com/avatar.php?' . 'gravatar_id=' . $seed . '&default=' . urlencode($default) . '&size=' . $size . '&rating=' . $this->getConf('rating') . '&.jpg', 'cache=recache');
// show only default image if invalid or empty email given
} else {
$src = $default;
}
}
if (!$title) {
$title = obfuscate($mail);
}
return $src;
}
示例11: deobfuscate_deep
/**
* Deobfuscate the values even if on an array
*
* @param $value could be an array or a string which need to be deobfuscated
* @return the element passed as parameter with deobfuscated
*/
function deobfuscate_deep($value)
{
if (is_array($value)) {
return array_map('deobfuscate_deep', $value);
} else {
return obfuscate($value);
}
}
示例12: obfuscate
<?php
require 'js_obfuscator.php';
?>
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
<?php
obfuscate("script.js");
?>
</script>
</head>
<body>
</body>
</html>
示例13: obfuscate_directory
function obfuscate_directory($source_dir, $target_dir, $keep_mode = false)
{
global $conf;
if (!($dp = opendir($source_dir))) {
fprintf(STDERR, "Error:\t [%s] directory does not exists!%s", $source_dir, PHP_EOL);
exit(-1);
}
$t_dir = array();
$t_file = array();
while (($entry = readdir($dp)) !== false) {
if ($entry == "." || $entry == "..") {
continue;
}
$new_keep_mode = $keep_mode;
$source_path = "{$source_dir}/{$entry}";
$source_stat = @lstat($source_path);
$target_path = "{$target_dir}/{$entry}";
$target_stat = @lstat($target_path);
if ($source_stat === false) {
fprintf(STDERR, "Error:\t cannot stat [%s] !%s", $source_path, PHP_EOL);
exit(-1);
}
if (isset($conf->t_skip) && is_array($conf->t_skip) && in_array($source_path, $conf->t_skip)) {
continue;
}
if (is_link($source_path)) {
if ($target_stat !== false && is_link($target_path) && $source_stat['mtime'] <= $target_stat['mtime']) {
continue;
}
if ($target_stat !== false) {
if (is_dir($target_path)) {
directory_remove($target_path);
} else {
if (unlink($target_path) === false) {
fprintf(STDERR, "Error:\t cannot unlink [%s] !%s", $target_path, PHP_EOL);
exit(-1);
}
}
}
@symlink(readlink($source_path), $target_path);
// Do not warn on non existing symbolinc link target!
if (strtolower(PHP_OS) == 'linux') {
$x = `touch '{$target_path}' --no-dereference --reference='{$source_path}' `;
}
continue;
}
if (is_dir($source_path)) {
if ($target_stat !== false) {
if (!is_dir($target_path)) {
if (unlink($target_path) === false) {
fprintf(STDERR, "Error:\t cannot unlink [%s] !%s", $target_path, PHP_EOL);
exit(-1);
}
}
}
if (!file_exists($target_path)) {
mkdir($target_path, 0777, true);
}
if (isset($conf->t_keep) && is_array($conf->t_keep) && in_array($source_path, $conf->t_keep)) {
$new_keep_mode = true;
}
obfuscate_directory($source_path, $target_path, $new_keep_mode);
continue;
}
if (is_file($source_path)) {
if ($target_stat !== false && is_dir($target_path)) {
directory_remove($target_path);
}
if ($target_stat !== false && $source_stat['mtime'] <= $target_stat['mtime']) {
continue;
}
// do not process if source timestamp is not greater than target
$extension = pathinfo($source_path, PATHINFO_EXTENSION);
$keep = $keep_mode;
if (isset($conf->t_keep) && is_array($conf->t_keep) && in_array($source_path, $conf->t_keep)) {
$keep = true;
}
if (!in_array($extension, $conf->t_obfuscate_php_extension)) {
$keep = true;
}
if ($keep) {
file_put_contents($target_path, file_get_contents($source_path));
} else {
$obfuscated_str = obfuscate($source_path);
if ($obfuscated_str === null) {
if (isset($conf->abort_on_error)) {
fprintf(STDERR, "Aborting...%s", PHP_EOL);
exit;
}
}
file_put_contents($target_path, $obfuscated_str . PHP_EOL);
}
if ($keep) {
file_put_contents($target_path, file_get_contents($source_path));
}
touch($target_path, $source_stat['mtime']);
continue;
}
}
closedir($dp);
//.........这里部分代码省略.........
示例14: _formatData
/**
* Return XHTML formated data, depending on column type
*
* @param $column
* @param $value
* @param $R Doku_Renderer_xhtml
* @return string
*/
function _formatData($column, $value, &$R)
{
global $conf;
$vals = explode("\n", $value);
$outs = array();
foreach ($vals as $val) {
$val = trim($val);
if ($val == '') {
continue;
}
$type = $column['type'];
if (is_array($type)) {
$type = $type['type'];
}
switch ($type) {
case 'page':
$val = $this->_addPrePostFixes($column['type'], $val);
$outs[] = $R->internallink($val, null, null, true);
break;
case 'title':
case 'pageid':
list($id, $title) = explode('|', $val, 2);
$id = $this->_addPrePostFixes($column['type'], $id);
$outs[] = $R->internallink($id, $title, null, true);
break;
case 'nspage':
// no prefix/postfix here
$val = ':' . $column['key'] . ":{$val}";
$outs[] = $R->internallink($val, null, null, true);
break;
case 'mail':
list($id, $title) = explode(' ', $val, 2);
$id = $this->_addPrePostFixes($column['type'], $id);
$id = obfuscate(hsc($id));
if (!$title) {
$title = $id;
} else {
$title = hsc($title);
}
if ($conf['mailguard'] == 'visible') {
$id = rawurlencode($id);
}
$outs[] = '<a href="mailto:' . $id . '" class="mail" title="' . $id . '">' . $title . '</a>';
break;
case 'url':
$val = $this->_addPrePostFixes($column['type'], $val);
$outs[] = $this->external_link($val, false, 'urlextern');
break;
case 'tag':
// per default use keyname as target page, but prefix on aliases
if (!is_array($column['type'])) {
$target = $column['key'] . ':';
} else {
$target = $this->_addPrePostFixes($column['type'], '');
}
$outs[] = '<a href="' . wl(str_replace('/', ':', cleanID($target)), $this->_getTagUrlparam($column, $val)) . '" title="' . sprintf($this->getLang('tagfilter'), hsc($val)) . '" class="wikilink1">' . hsc($val) . '</a>';
break;
case 'timestamp':
$outs[] = dformat($val);
break;
case 'wiki':
global $ID;
$oldid = $ID;
list($ID, $data) = explode('|', $val, 2);
$data = $this->_addPrePostFixes($column['type'], $data);
// Trim document_{start,end}, p_{open,close}
$ins = array_slice(p_get_instructions($data), 2, -2);
$outs[] = p_render('xhtml', $ins, $byref_ignore);
$ID = $oldid;
break;
default:
$val = $this->_addPrePostFixes($column['type'], $val);
if (substr($type, 0, 3) == 'img') {
$sz = (int) substr($type, 3);
if (!$sz) {
$sz = 40;
}
$title = $column['key'] . ': ' . basename(str_replace(':', '/', $val));
$outs[] = '<a href="' . ml($val) . '" class="media" rel="lightbox"><img src="' . ml($val, "w={$sz}") . '" alt="' . hsc($title) . '" title="' . hsc($title) . '" width="' . $sz . '" /></a>';
} else {
$outs[] = hsc($val);
}
}
}
return join(', ', $outs);
}
示例15: _formatData
/**
* Return XHTML formated data, depending on column type
*/
function _formatData($column, $value, &$R)
{
global $conf;
$vals = explode("\n", $value);
$outs = array();
foreach ($vals as $val) {
$val = trim($val);
if ($val == '') {
continue;
}
switch ($column['type']) {
case 'page':
if ($column['prefix']) {
$val = $column['prefix'] . $val;
} else {
$val = ':' . $val;
}
$val .= $column['postfix'];
$outs[] = $R->internallink(":{$val}", NULL, NULL, true);
break;
case 'title':
list($id, $title) = explode('|', $val, 2);
$id = $column['prefix'] . $id . $column['postfix'];
$outs[] = $R->internallink(":{$id}", $title, NULL, true);
break;
case 'nspage':
// no prefix/postfix here
$val = ':' . $column['key'] . ":{$val}";
$outs[] = $R->internallink($val, NULL, NULL, true);
break;
case 'mail':
list($id, $title) = explode(' ', $val, 2);
$val = $column['prefix'] . $val . $column['postfix'];
$id = obfuscate(hsc($id));
if (!$title) {
$title = $id;
} else {
$title = hsc($title);
}
if ($conf['mailguard'] == 'visible') {
$id = rawurlencode($id);
}
$outs[] = '<a href="mailto:' . $id . '" class="mail" title="' . $id . '">' . $title . '</a>';
break;
case 'url':
$val = $column['prefix'] . $val . $column['postfix'];
$outs[] = '<a href="' . hsc($val) . '" class="urlextern" title="' . hsc($val) . '">' . hsc($val) . '</a>';
break;
case 'tag':
#FIXME handle pre/postfix
$outs[] = '<a href="' . wl(str_replace('/', ':', cleanID($column['key'])), array('dataflt' => $column['key'] . ':' . $val)) . '" title="' . sprintf($this->getLang('tagfilter'), hsc($val)) . '" class="wikilink1">' . hsc($val) . '</a>';
break;
case 'wiki':
global $ID;
$oldid = $ID;
list($ID, $data) = explode('|', $val, 2);
$outs[] = p_render('xhtml', p_get_instructions($data), $ignore);
$ID = $oldid;
break;
default:
$val = $column['prefix'] . $val . $column['postfix'];
if (substr($column['type'], 0, 3) == 'img') {
$sz = (int) substr($type, 3);
if (!$sz) {
$sz = 40;
}
$title = $column['key'] . ': ' . basename(str_replace(':', '/', $val));
$outs[] = '<a href="' . ml($val) . '" class="media" rel="lightbox"><img src="' . ml($val, "w={$sz}") . '" alt="' . hsc($title) . '" title="' . hsc($title) . '" width="' . $sz . '" /></a>';
} else {
$outs[] = hsc($val);
}
}
}
return join(', ', $outs);
}