本文整理汇总了PHP中Email::obfuscate方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::obfuscate方法的具体用法?PHP Email::obfuscate怎么用?PHP Email::obfuscate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Email
的用法示例。
在下文中一共展示了Email::obfuscate方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: output
public function output()
{
// TODO: Refactor into a content-type option
if (\Director::is_ajax()) {
return $this->friendlyErrorMessage;
} else {
// TODO: Refactor this into CMS
if (class_exists('ErrorPage')) {
$errorFilePath = \ErrorPage::get_filepath_for_errorcode($this->statusCode, class_exists('Translatable') ? \Translatable::get_current_locale() : null);
if (file_exists($errorFilePath)) {
$content = file_get_contents($errorFilePath);
if (!headers_sent()) {
header('Content-Type: text/html');
}
// $BaseURL is left dynamic in error-###.html, so that multi-domain sites don't get broken
return str_replace('$BaseURL', \Director::absoluteBaseURL(), $content);
}
}
$renderer = \Debug::create_debug_view();
$output = $renderer->renderHeader();
$output .= $renderer->renderInfo("Website Error", $this->friendlyErrorMessage, $this->friendlyErrorDetail);
if (\Email::config()->admin_email) {
$mailto = \Email::obfuscate(\Email::config()->admin_email);
$output .= $renderer->renderParagraph('Contact an administrator: ' . $mailto . '');
}
$output .= $renderer->renderFooter();
return $output;
}
}
示例2: testObfuscate
public function testObfuscate()
{
$emailAddress = 'test-1@example.com';
$direction = Email::obfuscate($emailAddress, 'direction');
$visible = Email::obfuscate($emailAddress, 'visible');
$hex = Email::obfuscate($emailAddress, 'hex');
$this->assertEquals('<span class="codedirection">moc.elpmaxe@1-tset</span>', $direction, 'obfuscate() correctly reverses the email direction');
$this->assertEquals('test [dash] 1 [at] example [dot] com', $visible, 'obfuscate() correctly obfuscates email characters');
$this->assertEquals('test-1@examp' . 'le.com', $hex, 'obfuscate() correctly returns hex representation of email');
}
示例3: ObfuscatedEmail
/**
* Return the obfuscated email
*/
public function ObfuscatedEmail()
{
return $this->Email ? Email::obfuscate($this->Email, 'hex') : null;
}
示例4: friendlyError
/**
* Render a user-facing error page, using the default HTML error template
* rendered by {@link ErrorPage} if it exists. Doesn't use the standard {@link SS_HTTPResponse} class
* the keep dependencies minimal.
*
* @uses ErrorPage
*
* @param int $statusCode HTTP Status Code (Default: 500)
* @param string $friendlyErrorMessage User-focused error message. Should not contain code pointers
* or "tech-speak". Used in the HTTP Header and ajax responses.
* @param string $friendlyErrorDetail Detailed user-focused message. Is just used if no {@link ErrorPage} is found
* for this specific status code.
* @return string HTML error message for non-ajax requests, plaintext for ajax-request.
*/
public static function friendlyError($statusCode = 500, $friendlyErrorMessage = null, $friendlyErrorDetail = null)
{
if (!$friendlyErrorMessage) {
$friendlyErrorMessage = Config::inst()->get('Debug', 'friendly_error_header');
}
if (!$friendlyErrorDetail) {
$friendlyErrorDetail = Config::inst()->get('Debug', 'friendly_error_detail');
}
if (!headers_sent()) {
$currController = Controller::has_curr() ? Controller::curr() : null;
// Ensure the error message complies with the HTTP 1.1 spec
$msg = strip_tags(str_replace(array("\n", "\r"), '', $friendlyErrorMessage));
if ($currController) {
$response = $currController->getResponse();
$response->setStatusCode($statusCode, $msg);
} else {
header($_SERVER['SERVER_PROTOCOL'] . " {$statusCode} {$msg}");
}
}
if (Director::is_ajax()) {
echo $friendlyErrorMessage;
} else {
if (class_exists('ErrorPage')) {
$errorFilePath = ErrorPage::get_filepath_for_errorcode($statusCode, class_exists('Translatable') ? Translatable::get_current_locale() : null);
if (file_exists($errorFilePath)) {
$content = file_get_contents(ASSETS_PATH . "/error-{$statusCode}.html");
// $BaseURL is left dynamic in error-###.html, so that multi-domain sites don't get broken
echo str_replace('$BaseURL', Director::absoluteBaseURL(), $content);
}
} else {
$renderer = new DebugView();
$renderer->writeHeader();
$renderer->writeInfo("Website Error", $friendlyErrorMessage, $friendlyErrorDetail);
if (Email::config()->admin_email) {
$mailto = Email::obfuscate(Email::config()->admin_email);
$renderer->writeParagraph('Contact an administrator: ' . $mailto . '');
}
$renderer->writeFooter();
}
}
return false;
}
示例5: EncodedEmail
/**
* Email encoded in html character entities.
*
* @return string
*/
public function EncodedEmail()
{
// return CleanUtils::html_obfuscate($this->owner->Email);
return Email::obfuscate($this->owner->Email, 'hex');
}
开发者ID:helpfulrobot,项目名称:arillo-silverstripe-cleanutilities,代码行数:10,代码来源:SiteConfigAddressExtension.php
示例6: friendlyError
/**
* Render a user-facing error page, using the default HTML error template
* rendered by {@link ErrorPage} if it exists. Doesn't use the standard {@link SS_HTTPResponse} class
* the keep dependencies minimal.
*
* @uses ErrorPage
*
* @param int $statusCode HTTP Status Code (Default: 500)
* @param string $friendlyErrorMessage User-focused error message. Should not contain code pointers or "tech-speak".
* Used in the HTTP Header and ajax responses.
* @param string $friendlyErrorDetail Detailed user-focused message. Is just used if no {@link ErrorPage} is found
* for this specific status code.
* @return string HTML error message for non-ajax requests, plaintext for ajax-request.
*/
static function friendlyError($statusCode = 500, $friendlyErrorMessage = null, $friendlyErrorDetail = null)
{
if (!$friendlyErrorMessage) {
$friendlyErrorMessage = self::$friendly_error_header;
}
if (!$friendlyErrorDetail) {
$friendlyErrorDetail = self::$friendly_error_detail;
}
if (!headers_sent()) {
header(sprintf('%s %d %s', $_SERVER['SERVER_PROTOCOL'], $statusCode, strip_tags(str_replace(array("\n", "\r"), '', $friendlyErrorMessage))));
}
if (Director::is_ajax()) {
echo $friendlyErrorMessage;
} else {
$errorFilePath = ErrorPage::get_filepath_for_errorcode($statusCode, Translatable::get_current_locale());
if (file_exists($errorFilePath)) {
$content = file_get_contents(ASSETS_PATH . "/error-{$statusCode}.html");
// $BaseURL is left dynamic in error-###.html, so that multi-domain sites don't get broken
echo str_replace('$BaseURL', Director::absoluteBaseURL(), $content);
} else {
$renderer = new DebugView();
$renderer->writeHeader();
$renderer->writeInfo("Website Error", $friendlyErrorMessage, $friendlyErrorDetail);
if (Email::getAdminEmail()) {
$mailto = Email::obfuscate(Email::getAdminEmail());
$renderer->writeParagraph('Contact an administrator: ' . $mailto . '');
}
$renderer->writeFooter();
}
}
}
示例7: output
/**
* Return the appropriate error content for the given status code
*
* @param int $statusCode
* @return string Content in an appropriate format for the current request
*/
public function output($statusCode)
{
// TODO: Refactor into a content-type option
if (\Director::is_ajax()) {
return $this->getTitle();
}
$renderer = \Debug::create_debug_view();
$output = $renderer->renderHeader();
$output .= $renderer->renderInfo("Website Error", $this->getTitle(), $this->getBody());
if (\Email::config()->admin_email) {
$mailto = \Email::obfuscate(\Email::config()->admin_email);
$output .= $renderer->renderParagraph('Contact an administrator: ' . $mailto . '');
}
$output .= $renderer->renderFooter();
return $output;
}
示例8: friendlyError
/**
* Render a user-facing error page, using the default HTML error template
* rendered by {@link ErrorPage} if it exists. Doesn't use the standard {@link HTTPResponse} class
* the keep dependencies minimal.
*
* @uses ErrorPage
*
* @param int $statusCode HTTP Status Code (Default: 500)
* @param string $friendlyErrorMessage User-focused error message. Should not contain code pointers or "tech-speak".
* Used in the HTTP Header and ajax responses.
* @param string $friendlyErrorDetail Detailed user-focused message. Is just used if no {@link ErrorPage} is found
* for this specific status code.
* @return string HTML error message for non-ajax requests, plaintext for ajax-request.
*/
static function friendlyError($statusCode = 500, $friendlyErrorMessage = null, $friendlyErrorDetail = null)
{
if (!$friendlyErrorMessage) {
$friendlyErrorMessage = 'There has been an error';
}
if (!$friendlyErrorDetail) {
$friendlyErrorDetail = 'The website server has not been able to respond to your request.';
}
if (!headers_sent()) {
header($_SERVER['SERVER_PROTOCOL'] . " {$statusCode} {$friendlyErrorMessage}");
}
if (Director::is_ajax()) {
echo $friendlyErrorMessage;
} else {
$errorFilePath = ErrorPage::get_filepath_for_errorcode($statusCode, Translatable::get_current_locale());
if (file_exists($errorFilePath)) {
echo file_get_contents($errorFilePath);
} else {
$renderer = new DebugView();
$renderer->writeHeader();
$renderer->writeInfo("Website Error", $friendlyErrorMessage, $friendlyErrorDetail);
if (Email::getAdminEmail()) {
$mailto = Email::obfuscate(Email::getAdminEmail());
$renderer->writeParagraph('Contact an administrator: ' . $mailto . '');
}
$renderer->writeFooter();
}
}
}
示例9: friendlyError
/**
* Render a user-facing error page, using the default HTML error template
* rendered by {@link ErrorPage} if it exists. Doesn't use the standard {@link HTTPResponse} class
* the keep dependencies minimal.
*
* @uses ErrorPage
*
* @param int $statusCode HTTP Status Code (Default: 500)
* @param string $friendlyErrorMessage User-focused error message. Should not contain code pointers or "tech-speak".
* Used in the HTTP Header and ajax responses.
* @param string $friendlyErrorDetail Detailed user-focused message. Is just used if no {@link ErrorPage} is found
* for this specific status code.
* @return string HTML error message for non-ajax requests, plaintext for ajax-request.
*/
static function friendlyError($statusCode = 500, $friendlyErrorMessage = null, $friendlyErrorDetail = null) {
if(!$friendlyErrorMessage) $friendlyErrorMessage = 'There has been an error';
if(!$friendlyErrorDetail) $friendlyErrorDetail = 'The website server has not been able to respond to your request.';
if(!headers_sent()) header($_SERVER['SERVER_PROTOCOL'] . " $statusCode $friendlyErrorMessage");
if(Director::is_ajax()) {
echo $friendlyErrorMessage;
} else {
if(file_exists(ASSETS_PATH . "/error-$statusCode.html")) {
echo file_get_contents(ASSETS_PATH . "/error-$statusCode.html");
} else {
$renderer = new DebugView();
$renderer->writeHeader();
$renderer->writeInfo("Website Error", $friendlyErrorMessage, $friendlyErrorDetail);
if(Email::getAdminEmail()) {
$mailto = Email::obfuscate(Email::getAdminEmail());
$renderer->writeParagraph('Contact an administrator: ' . $mailto . '');
}
$renderer->writeFooter();
}
}
}
示例10: friendlyError
/**
* Render a user-facing error page, using the default HTML error template
* rendered by {@link ErrorPage} if it exists. Doesn't use the standard {@link SS_HTTPResponse} class
* the keep dependencies minimal.
*
* @uses ErrorPage
*
* @param int $statusCode HTTP Status Code (Default: 500)
* @param string $friendlyErrorMessage User-focused error message. Should not contain code pointers
* or "tech-speak". Used in the HTTP Header and ajax responses.
* @param string $friendlyErrorDetail Detailed user-focused message. Is just used if no {@link ErrorPage} is found
* for this specific status code.
* @return string HTML error message for non-ajax requests, plaintext for ajax-request.
*/
public static function friendlyError($statusCode = 500, $friendlyErrorMessage = null, $friendlyErrorDetail = null)
{
// Ensure the error message complies with the HTTP 1.1 spec
if (!$friendlyErrorMessage) {
$friendlyErrorMessage = Config::inst()->get('Debug', 'friendly_error_header');
}
$friendlyErrorMessage = strip_tags(str_replace(array("\n", "\r"), '', $friendlyErrorMessage));
if (!$friendlyErrorDetail) {
$friendlyErrorDetail = Config::inst()->get('Debug', 'friendly_error_detail');
}
if (!headers_sent()) {
// Allow toggle between legacy behaviour and correctly setting HTTP response code
// In 4.0 this should be fixed to always set this response code.
if (Config::inst()->get('Debug', 'friendly_error_httpcode') || !Controller::has_curr()) {
header($_SERVER['SERVER_PROTOCOL'] . " {$statusCode} {$friendlyErrorMessage}");
}
}
if (Director::is_ajax()) {
echo $friendlyErrorMessage;
} else {
if (!headers_sent()) {
header('Content-Type: text/html');
}
if (class_exists('ErrorPage')) {
$errorFilePath = ErrorPage::get_filepath_for_errorcode($statusCode, class_exists('Translatable') ? Translatable::get_current_locale() : null);
if (file_exists($errorFilePath)) {
$content = file_get_contents($errorFilePath);
// $BaseURL is left dynamic in error-###.html, so that multi-domain sites don't get broken
echo str_replace('$BaseURL', Director::absoluteBaseURL(), $content);
}
} else {
$renderer = new DebugView();
$renderer->writeHeader();
$renderer->writeInfo("Website Error", $friendlyErrorMessage, $friendlyErrorDetail);
if (Email::config()->admin_email) {
$mailto = Email::obfuscate(Email::config()->admin_email);
$renderer->writeParagraph('Contact an administrator: ' . $mailto . '');
}
$renderer->writeFooter();
}
}
return false;
}
示例11: EmailObfuscated
/**
* Returns a representation of this text
* with all email addresses converted into html character entities.
*
* @return string
*/
public function EmailObfuscated()
{
$content = $this->owner->forTemplate();
$emailPattern = "/[A-Za-z0-9_-]+@[A-Za-z0-9_-]+\\.([A-Za-z0-9_-][A-Za-z0-9_]+)/";
if (preg_match_all($emailPattern, $content, $matches)) {
$searches = array();
$replaces = array();
for ($i = 0; $i < count($matches[0]); $i++) {
$link = $matches[0][$i];
$obfuscatedLink = Email::obfuscate($link, 'hex');
array_push($searches, $link);
array_push($replaces, $obfuscatedLink);
}
$content = str_replace($searches, $replaces, $content);
}
return $content;
}