本文整理汇总了PHP中idna_convert::encode方法的典型用法代码示例。如果您正苦于以下问题:PHP idna_convert::encode方法的具体用法?PHP idna_convert::encode怎么用?PHP idna_convert::encode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idna_convert
的用法示例。
在下文中一共展示了idna_convert::encode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
public function process(Vtiger_Request $request)
{
// SalesPlatform.ru begin
require_once 'includes/SalesPlatform/NetIDNA/idna_convert.class.php';
// SalesPlatform.ru end
$outgoingServerSettingsModel = Settings_Vtiger_Systems_Model::getInstanceFromServerType('email', 'OutgoingServer');
$loadDefaultSettings = $request->get('default');
if ($loadDefaultSettings == "true") {
$outgoingServerSettingsModel->loadDefaultValues();
} else {
$outgoingServerSettingsModel->setData($request->getAll());
}
$response = new Vtiger_Response();
// SalesPlatform.ru begin
$idn = new idna_convert();
$server_username = $idn->encode(vtlib_purify($request->get('server')));
$from_email_field = $idn->encode(vtlib_purify($request->get('from_email_field')));
$request->set('server_username', $server_username);
$request->set('from_email_field', $from_email_field);
// SalesPlatform.ru end
try {
$id = $outgoingServerSettingsModel->save($request);
$data = $outgoingServerSettingsModel->getData();
$response->setResult($data);
} catch (Exception $e) {
$response->setError($e->getCode(), $e->getMessage());
}
$response->emit();
}
示例2: punyencode
public function punyencode($inputtext, $inputenc)
{
require_once 'assets/php/vendors/idna_convert_060/idna_convert.class.php';
require_once 'assets/php/vendors/idna_convert_060/transcode_wrapper.php';
$IDN = new idna_convert();
return $IDN->encode(encode_utf8($inputtext, $inputenc));
}
示例3: domainWorker
/**
* @return array
*/
public function domainWorker()
{
$domainsFile = __DIR__ . "/domains.txt";
$handle = fopen($domainsFile, "r");
if (!$handle) {
throw new \RuntimeException('Error opening file ' . $domainsFile);
}
$lines = array();
while (($line = fgets($handle)) !== false) {
$line = trim(preg_replace('/\\s\\s+/', ' ', $line));
// convert russian domains
if (preg_match('/[А-Яа-яЁё]/u', $line)) {
$IDN = new idna_convert();
$line = $IDN->encode($line);
echo $line . "\n\n";
}
if (empty($line)) {
continue;
}
$lines[] = $line;
}
fclose($handle);
$uniqueLines = array_unique($lines, SORT_STRING);
sort($uniqueLines, SORT_STRING);
if (is_writable($domainsFile)) {
file_put_contents($domainsFile, implode("\n", $uniqueLines));
} else {
trigger_error("Permission denied");
}
return $lines;
}
示例4: convert_host_to_idna
function convert_host_to_idna($host)
{
$idna = new idna_convert();
if (viscacha_function_exists('mb_convert_encoding')) {
$host = mb_convert_encoding($host, 'UTF-8', ENCODING_LIST);
} else {
$host = utf8_encode($host);
}
$host = $idna->encode($host);
return $host;
}
示例5: IDNA
/**
*
*/
private function IDNA()
{
if (class_exists('idna_convert')) {
$IDNA = new \idna_convert();
$encoded_host = $IDNA->encode($this->host);
if ($encoded_host != $this->host) {
$this->properties['url'] = str_replace($this->host, $encoded_host, $this->url);
$this->properties['host'] = $encoded_host;
}
unset($IDNA);
}
}
示例6: files
function files()
{
$inDB = cmsDatabase::getInstance();
global $_LANG;
$do = cmsCore::getInstance()->do;
$model = new cms_model_files();
//============================================================================//
// Скачивание
if ($do == 'view') {
$fileurl = cmsCore::request('fileurl', 'html', '');
if (mb_strpos($fileurl, '-') === 0) {
$fileurl = htmlspecialchars_decode(base64_decode(ltrim($fileurl, '-')));
}
$fileurl = cmsCore::strClear($fileurl);
if (!$fileurl || mb_strstr($fileurl, '..') || strpos($fileurl, '.') === 0) {
cmsCore::error404();
}
if (strpos($fileurl, 'http') === 0) {
$model->increaseDownloadCount($fileurl);
cmsCore::redirect($fileurl);
} elseif (file_exists(PATH . $fileurl)) {
$model->increaseDownloadCount($fileurl);
header('Content-Disposition: attachment; filename=' . basename($fileurl) . "\n");
header('Content-Type: application/x-force-download; name="' . $fileurl . '"' . "\n");
header('Location:' . $fileurl);
cmsCore::halt();
} else {
cmsCore::halt($_LANG['FILE_NOT_FOUND']);
}
}
//============================================================================//
if ($do == 'redirect') {
$url = str_replace(array('--q--', ' '), array('?', '+'), cmsCore::request('url', 'str', ''));
if (mb_strpos($url, '-') === 0) {
$url = htmlspecialchars_decode(base64_decode(ltrim($url, '-')));
}
$url = cmsCore::strClear($url);
if (!$url || mb_strstr($url, '..') || strpos($url, '.') === 0) {
cmsCore::error404();
}
// кириллические домены
$url_host = parse_url($url, PHP_URL_HOST);
if (preg_match('/^[а-яё]+/iu', $url_host)) {
cmsCore::loadClass('idna_convert');
$IDN = new idna_convert();
$host = $IDN->encode($url_host);
$url = str_ireplace($url_host, $host, $url);
}
cmsCore::redirect($url);
}
//============================================================================//
}
示例7: idnaEncode
/**
* Returns an ASCII string (punicode) representation of $value
*
* @param string $value
* @return string An ASCII encoded (punicode) string
*/
public static function idnaEncode($value)
{
if (isset(self::$idnaStringCache[$value])) {
return self::$idnaStringCache[$value];
} else {
if (!self::$idnaConverter) {
require_once PATH_typo3 . 'contrib/idna/idna_convert.class.php';
self::$idnaConverter = new \idna_convert(array('idn_version' => 2008));
}
self::$idnaStringCache[$value] = self::$idnaConverter->encode($value);
return self::$idnaStringCache[$value];
}
}
示例8: sendEmail
/**
* Функция предотправки писем
*
* $from - адрес, с которого отправлено письмо
* $from_name - имя отправителя
* $sender - адрес, для ответа на письмо
* $message - сообщение
* $to_address - адрес получателя
* $to_name - имя получателя
* $file_pattern - имя файла шаблона
*
* @return bool
*/
public function sendEmail()
{
$arrSendMail = mailer::retSendMail();
if (!$arrSendMail['From'] || !$arrSendMail['Subject'] || !$arrSendMail['FilePattern']) {
$this->ErrorInfo = 'Wrong mail parameters. Not FROM or not SUBJECT or not MESSAGE!';
$this->mailErrorLog();
return false;
}
!empty($arrSendMail['Text']) ? $this->Body = $arrSendMail['FilePattern'] : $this->confMessage($arrSendMail['FilePattern']);
$idna = new idna_convert();
$this->From = $idna->encode($arrSendMail['From']);
$this->Subject = $arrSendMail['Subject'];
$this->FromName = !$arrSendMail['FromName'] ? $arrSendMail['From'] : $arrSendMail['FromName'];
$this->Sender = !$arrSendMail['Sender'] ? $this->From : $idna->encode($arrSendMail['Sender']);
!$arrSendMail['ToName'] ? $this->AddAddress($idna->encode($arrSendMail['ToAddress']), $arrSendMail['ToAddress']) : $this->AddAddress($idna->encode($arrSendMail['ToAddress']), $arrSendMail['ToName']);
// если включен формат HTML, заменяем перенос строки и вставляем дизайн в письмо
CONF_MAIL_FORMAT_HTML ? $this->MsgHTML($this->Body) : $this->MsgTXT($this->Body);
if (!$this->Send()) {
$this->mailErrorLog();
return false;
} else {
return true;
}
}
示例9: clm_function_is_email
function clm_function_is_email($email)
{
// Include the class
if (!class_exists('idna_convert')) {
$path = clm_core::$path . DS . "includes" . DS . "idna_convert.class" . '.php';
require_once $path;
}
$parts = explode('@', $email);
if (count($parts) != 2) {
return false;
}
// Instantiate it (depending on the version you are using) with
$IDN = new idna_convert();
// Encode it to its punycode presentation
$parts1 = $IDN->encode($parts[1]);
return filter_var($parts[0] . '@' . $parts1, FILTER_VALIDATE_EMAIL) !== false ? true : false;
}
示例10: __construct
public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false)
{
if (class_exists('idna_convert')) {
$idn = new idna_convert();
$parsed = SimplePie_Misc::parse_url($url);
$url = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']);
}
$this->url = $url;
$this->useragent = $useragent;
if (preg_match('/^http(s)?:\\/\\//i', $url)) {
if (!is_array($headers)) {
$headers = array();
}
$this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_CURL;
$headers2 = array();
foreach ($headers as $key => $value) {
$headers2[] = "{$key}: {$value}";
}
//TODO: allow for HTTP headers
// curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2);
$response = self::$agent->get($url);
if ($response === false || !isset($response['status_code'])) {
$this->error = 'failed to fetch URL';
$this->success = false;
} else {
// The extra lines at the end are there to satisfy SimplePie's HTTP parser.
// The class expects a full HTTP message, whereas we're giving it only
// headers - the new lines indicate the start of the body.
$parser = new SimplePie_HTTP_Parser($response['headers'] . "\r\n\r\n");
if ($parser->parse()) {
$this->headers = $parser->headers;
//$this->body = $parser->body;
$this->body = $response['body'];
$this->status_code = $parser->status_code;
}
}
} else {
$this->error = 'invalid URL';
$this->success = false;
}
}
示例11: checkmx_idna
function checkmx_idna($host)
{
if (empty($host)) {
return false;
}
$idna = new idna_convert();
$host_idna = $idna->encode($host);
if (viscacha_function_exists('checkdnsrr')) {
if (checkdnsrr($host_idna, 'MX') === false) {
return false;
} else {
return true;
}
} else {
@exec("nslookup -querytype=MX {$host_idna}", $output);
while (list($k, $line) = each($output)) {
# Valid records begin with host name
if (preg_match("~^(" . preg_quote($host, '~') . "|" . preg_quote($host_idna, '~') . ")~i", $line)) {
return true;
}
}
return false;
}
}
示例12: varValidate
/**
* Validate a Zikula variable.
*
* @param mixed $var The variable to validate.
* @param string $type The type of the validation to perform (email, url etc.).
* @param mixed $args Optional array with validation-specific settings (deprecated).
*
* @return boolean True if the validation was successful, false otherwise.
*/
public static function varValidate($var, $type, $args = 0)
{
if (!isset($var) || !isset($type)) {
return false;
}
// typecasting (might be useless in this function)
$var = (string) $var;
$type = (string) $type;
static $maxlength = array('modvar' => 64, 'func' => 512, 'api' => 187, 'theme' => 200, 'uname' => 25, 'config' => 64);
static $minlength = array('mod' => 1, 'modvar' => 1, 'uname' => 1, 'config' => 1);
// commented out some regexps until some useful and working ones are found
static $regexp = array('email' => '/^(?:[^\\s\\000-\\037\\177\\(\\)<>@,;:\\"\\[\\]]\\.?)+@(?:[^\\s\\000-\\037\\177\\(\\)<>@,;:\\\\"\\[\\]]\\.?)+\\.[a-z]{2,6}$/Ui', 'url' => '/^([!#\\$\\046-\\073=\\077-\\132_\\141-\\172~]|(?:%[a-f0-9]{2}))+$/i');
// special cases
if ($type == 'mod' && $var == ModUtil::CONFIG_MODULE) {
return true;
}
if ($type == 'config' && $var == 'dbtype' || $var == 'dbhost' || $var == 'dbuname' || $var == 'dbpass' || $var == 'dbname' || $var == 'system' || $var == 'prefix' || $var == 'encoded') {
// The database parameter are not allowed to change
return false;
}
if ($type == 'email' || $type == 'url') {
// CSRF protection for email and url
$var = str_replace(array('\\r', '\\n', '%0d', '%0a'), '', $var);
if (self::getVar('idnnames')) {
// transfer between the encoded (Punycode) notation and the decoded (8bit) notation.
require_once 'lib/vendor/idn/idna_convert.class.php';
$IDN = new idna_convert();
$var = $IDN->encode(DataUtil::convertToUTF8($var));
}
// all characters must be 7 bit ascii
$length = strlen($var);
$idx = 0;
while ($length--) {
$c = $var[$idx++];
if (ord($c) > 127) {
return false;
}
}
}
if ($type == 'url') {
// check for url
$url_array = @parse_url($var);
if (!empty($url_array) && empty($url_array['scheme'])) {
return false;
}
}
if ($type == 'uname') {
// check for invalid characters
if (!preg_match('/^[\\p{L}\\p{N}_\\.\\-]+$/uD', $var)) {
return false;
} else {
$lowerUname = mb_strtolower($var);
if ($lowerUname != $var) {
return false;
}
}
}
// variable passed special checks. We now to generic checkings.
// check for maximal length
if (isset($maxlength[$type]) && mb_strlen($var) > $maxlength[$type]) {
return false;
}
// check for minimal length
if (isset($minlength[$type]) && mb_strlen($var) < $minlength[$type]) {
return false;
}
// check for regular expression
if (isset($regexp[$type]) && !preg_match($regexp[$type], $var)) {
return false;
}
// all tests for illegal entries failed, so we assume the var is ok ;-)
return true;
}
示例13: substr
$itemid = JRequest::getVar('Itemid');
$url_sj = $url;
// delete backslashs if exist
if (substr($url, 0, 1) == chr(92)) {
$url = substr($url, 1, strlen($url) - 1);
}
if (substr($url, strlen($url) - 1, 1) == chr(92)) {
$url = substr($url, 0, strlen($url) - 1);
}
include_once 'idna_convert.class.php';
// Instantiate it (depending on the version you are using) with
$IDN = new idna_convert();
// The work string
$url1 = $url;
// Encode it to its punycode presentation
$url = $IDN->encode($url1);
$ext_url = "http://" . $url;
$ext_url1 = "http://" . $url1;
if ($ext_view == "" or $saison == "") {
?>
<h1>Die Anzeigeparameter sind falsch gesetzt !</h1><h2>Kontaktieren Sie umgehend den Administrator.</h2>
<?php
} else {
$document = JFactory::getDocument();
$cssDir = JURI::base() . 'components' . DS . 'com_clm_ext' . DS;
$document->addStyleSheet($cssDir . DS . 'clm_content.css', 'text/css', null, array());
$document->addStyleSheet($cssDir . DS . 'submenu.css', 'text/css', null, array());
$document->addScript($cssDir . DS . 'submenu.js');
/////////////////////
// Aufrufen mit z.B.:
// http://localhost/install/index.php?option=com_clm_ext&view=clm_ext&ext_view=rangliste&saison=1&liga=1
示例14: idnaEncode
/**
* Encode an internationalized domain name
* @param string
* @return string
*/
protected function idnaEncode($strDomain)
{
if (!class_exists('idna_convert', false)) {
require_once TL_ROOT . '/plugins/idna/idna_convert.class.php';
}
$objIdn = new idna_convert();
return $objIdn->encode($strDomain);
}
示例15: send
/**
* Function sends mail
*/
public function send()
{
$currentUserModel = Users_Record_Model::getCurrentUserModel();
$rootDirectory = vglobal('root_directory');
$mailer = Emails_Mailer_Model::getInstance();
$mailer->IsHTML(true);
$fromEmail = $this->getFromEmailAddress();
$replyTo = $currentUserModel->get('email1');
$userName = $currentUserModel->getName();
// To eliminate the empty value of an array
$toEmailInfo = array_filter($this->get('toemailinfo'));
$toMailNamesList = array_filter($this->get('toMailNamesList'));
foreach ($toMailNamesList as $id => $emailData) {
foreach ($emailData as $key => $email) {
if ($toEmailInfo[$id]) {
array_push($toEmailInfo[$id], $email['value']);
}
}
}
$emailsInfo = array();
foreach ($toEmailInfo as $id => $emails) {
foreach ($emails as $key => $value) {
array_push($emailsInfo, $value);
}
}
$toFieldData = array_diff(explode(',', $this->get('saved_toid')), $emailsInfo);
$toEmailsData = array();
$i = 1;
foreach ($toFieldData as $value) {
$toEmailInfo['to' . $i++] = array($value);
}
$attachments = $this->getAttachmentDetails();
$status = false;
// Merge Users module merge tags based on current user.
$mergedDescription = getMergedDescription($this->get('description'), $currentUserModel->getId(), 'Users');
$mergedSubject = getMergedDescription($this->get('subject'), $currentUserModel->getId(), 'Users');
foreach ($toEmailInfo as $id => $emails) {
$mailer->reinitialize();
$mailer->ConfigSenderInfo($fromEmail, $userName, $replyTo);
$old_mod_strings = vglobal('mod_strings');
$description = $this->get('description');
$subject = $this->get('subject');
$parentModule = $this->getEntityType($id);
if ($parentModule) {
$currentLanguage = Vtiger_Language_Handler::getLanguage();
$moduleLanguageStrings = Vtiger_Language_Handler::getModuleStringsFromFile($currentLanguage, $parentModule);
vglobal('mod_strings', $moduleLanguageStrings['languageStrings']);
if ($parentModule != 'Users') {
// Apply merge for non-Users module merge tags.
$description = getMergedDescription($mergedDescription, $id, $parentModule);
$subject = getMergedDescription($mergedSubject, $id, $parentModule);
} else {
// Re-merge the description for user tags based on actual user.
$description = getMergedDescription($description, $id, 'Users');
$subject = getMergedDescription($mergedSubject, $id, 'Users');
vglobal('mod_strings', $old_mod_strings);
}
}
if (strpos($description, '$logo$')) {
$description = str_replace('$logo$', "<img src='cid:logo' />", $description);
$logo = true;
}
foreach ($emails as $email) {
$mailer->Body = '';
if ($parentModule) {
$mailer->Body = $this->getTrackImageDetails($id, $this->isEmailTrackEnabled());
}
$mailer->Body .= $description;
$mailer->Signature = str_replace(array('\\r\\n', '\\n'), '<br>', $currentUserModel->get('signature'));
if ($mailer->Signature != '') {
$mailer->Body .= '<br><br>' . decode_html($mailer->Signature);
}
$mailer->Subject = $subject;
$mailer->AddAddress($email);
//Adding attachments to mail
if (is_array($attachments)) {
foreach ($attachments as $attachment) {
$fileNameWithPath = $rootDirectory . $attachment['path'] . $attachment['fileid'] . "_" . $attachment['attachment'];
if (is_file($fileNameWithPath)) {
$mailer->AddAttachment($fileNameWithPath, $attachment['attachment']);
}
}
}
if ($logo) {
//While sending email template and which has '$logo$' then it should replace with company logo
$mailer->AddEmbeddedImage(dirname(__FILE__) . '/../../../layouts/vlayout/skins/images/logo_mail.jpg', 'logo', 'logo.jpg', 'base64', 'image/jpg');
}
$ccs = array_filter(explode(',', $this->get('ccmail')));
$bccs = array_filter(explode(',', $this->get('bccmail')));
if (!empty($ccs)) {
// SalesPlatform.ru begin
foreach ($ccs as $cc) {
$mailer->AddCC($idn->encode($cc));
}
//$mailer->AddCC($cc);
// SalesPlatform.ru end
}
//.........这里部分代码省略.........