本文整理汇总了PHP中idna_convert类的典型用法代码示例。如果您正苦于以下问题:PHP idna_convert类的具体用法?PHP idna_convert怎么用?PHP idna_convert使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了idna_convert类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: punydecode
public function punydecode($inputtext)
{
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->decode($this->response['inputtext']);
}
示例3: 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();
}
示例4: DecodePunycodeIDN
/**
* Decode IDN Punycode to UTF-8 domain name
*
* @param string $value Punycode
* @return string Domain name in UTF-8 charset
*
* @author Igor V Belousov <igor@belousovv.ru>
* @copyright 2013 Igor V Belousov
* @license http://opensource.org/licenses/LGPL-2.1 LGPL v2.1
* @link http://belousovv.ru/myscript/phpIDN
*/
public static function DecodePunycodeIDN($value)
{
Yii::import('application.vendors.punicode.*');
require_once Yii::getPathOfAlias('application.vendors.punicode') . '/idna_convert.class.php';
$IDN = new idna_convert();
// Encode it to its punycode presentation
$output = $IDN->decode($value);
return $output;
}
示例5: 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;
}
示例6: 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);
}
}
示例7: 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);
}
//============================================================================//
}
示例8: getInstanceFromServerType
public static function getInstanceFromServerType($type,$componentName) {
// SalesPlatform.ru begin
require_once 'includes/SalesPlatform/NetIDNA/idna_convert.class.php';
// SalesPlatform.ru end
$db = PearDatabase::getInstance();
$query = 'SELECT * FROM '.self::tableName.' WHERE server_type=?';
$params = array($type);
$result = $db->pquery($query,$params);
try{
$modelClassName = Vtiger_Loader::getComponentClassName('Model', $componentName, 'Settings:Vtiger');
}catch(Exception $e) {
$modelClassName = self;
}
$instance = new $modelClassName();
if($db->num_rows($result) > 0 ){
$rowData = $db->query_result_rowdata($result,0);
$instance->setData($rowData);
}
// SalesPlatform.ru begin
$idn = new idna_convert();
$mail_server_username = $idn->decode($instance->get('server_username'));
$from_email_field = $idn->decode($instance->get('from_email_field'));
$instance->set('server_username', $mail_server_username);
$instance->set('from_email_field', $from_email_field);
// SalesPlatform.ru end
return $instance;
}
示例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: checkIdna
public static function checkIdna($ref)
{
$content = '';
if ($ref == "") {
$content .= "<font color=grey>неизвестно</font>";
} else {
$content .= "<a target=_blank href=\"" . $ref . "\">";
if (stristr(urldecode($ref), "xn--")) {
$IDN = new idna_convert(array('idn_version' => 2008));
$content .= $IDN->decode(urldecode($ref));
} else {
$content .= urldecode($ref);
}
$content .= "</a>";
}
return $content;
}
示例11: __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;
}
}
示例12: 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];
}
}
示例13: 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;
}
}
示例14: 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;
}
}
示例15: __construct
/**
* Constructor, used to input the data
*
* For documentation on all the parameters, see the corresponding
* properties and their accessors
*
* @uses idna_convert If available, this will convert an IDN
*/
public function __construct($link = null, $type = null, $length = null, $javascript = null, $bitrate = null, $captions = null, $categories = null, $channels = null, $copyright = null, $credits = null, $description = null, $duration = null, $expression = null, $framerate = null, $hashes = null, $height = null, $keywords = null, $lang = null, $medium = null, $player = null, $ratings = null, $restrictions = null, $samplingrate = null, $thumbnails = null, $title = null, $width = null)
{
$this->bitrate = $bitrate;
$this->captions = $captions;
$this->categories = $categories;
$this->channels = $channels;
$this->copyright = $copyright;
$this->credits = $credits;
$this->description = $description;
$this->duration = $duration;
$this->expression = $expression;
$this->framerate = $framerate;
$this->hashes = $hashes;
$this->height = $height;
$this->keywords = $keywords;
$this->lang = $lang;
$this->length = $length;
$this->link = $link;
$this->medium = $medium;
$this->player = $player;
$this->ratings = $ratings;
$this->restrictions = $restrictions;
$this->samplingrate = $samplingrate;
$this->thumbnails = $thumbnails;
$this->title = $title;
$this->type = $type;
$this->width = $width;
if (class_exists('idna_convert')) {
$idn = new idna_convert();
$parsed = SimplePie_Misc::parse_url($link);
$this->link = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']);
}
$this->handler = $this->get_handler();
// Needs to load last
}