/**
  * @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
0
파일: Request.php 프로젝트: Roewe/encoder
 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']);
 }
 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
0
 /** 
  * Decode IDN Punycode to UTF-8 domain name 
  * 
  * @param string $value Punycode 
  * @return string Domain name in UTF-8 charset 
  * 
  * @author Igor V Belousov <*****@*****.**> 
  * @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;
 }
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
0
파일: Url.php 프로젝트: redpic/net
 /**
  *
  */
 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
0
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
0
파일: Systems.php 프로젝트: Wasage/werpa
 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
0
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
0
 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;
 }
 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;
     }
 }
 /**
  * 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
0
 /**
  * Функция предотправки писем
  * 
  * $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;
     }
 }
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
0
파일: Enclosure.php 프로젝트: vazahat/dudex
 /**
  * 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
 }
예제 #16
0
파일: Idna.php 프로젝트: iCodr8/core
 /**
  * Decode an internationalized domain name
  *
  * @param string $strDomain The domain name
  *
  * @return string The decoded domain name
  */
 public static function decode($strDomain)
 {
     $objIdn = new \idna_convert();
     return $objIdn->decode($strDomain);
 }
예제 #17
0
파일: File.php 프로젝트: kosir/wp-pipes
 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 ($useragent === null) {
             $useragent = ini_get('user_agent');
             $this->useragent = $useragent;
         }
         if (!is_array($headers)) {
             $headers = array();
         }
         if (!$force_fsockopen && function_exists('curl_exec')) {
             $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_CURL;
             $fp = curl_init();
             $headers2 = array();
             foreach ($headers as $key => $value) {
                 $headers2[] = "{$key}: {$value}";
             }
             if (version_compare(SimplePie_Misc::get_curl_version(), '7.10.5', '>=')) {
                 curl_setopt($fp, CURLOPT_ENCODING, '');
             }
             curl_setopt($fp, CURLOPT_URL, $url);
             curl_setopt($fp, CURLOPT_HEADER, 1);
             curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1);
             curl_setopt($fp, CURLOPT_TIMEOUT, $timeout);
             curl_setopt($fp, CURLOPT_CONNECTTIMEOUT, $timeout);
             curl_setopt($fp, CURLOPT_REFERER, $url);
             curl_setopt($fp, CURLOPT_USERAGENT, $useragent);
             curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2);
             if (!ini_get('open_basedir') && !ini_get('safe_mode') && version_compare(SimplePie_Misc::get_curl_version(), '7.15.2', '>=')) {
                 curl_setopt($fp, CURLOPT_FOLLOWLOCATION, 1);
                 curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects);
             }
             $this->headers = curl_exec($fp);
             if (curl_errno($fp) === 23 || curl_errno($fp) === 61) {
                 curl_setopt($fp, CURLOPT_ENCODING, 'none');
                 $this->headers = curl_exec($fp);
             }
             if (curl_errno($fp)) {
                 $this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp);
                 $this->success = false;
             } else {
                 $info = curl_getinfo($fp);
                 curl_close($fp);
                 $this->headers = explode("\r\n\r\n", $this->headers, $info['redirect_count'] + 1);
                 $this->headers = array_pop($this->headers);
                 $parser = new SimplePie_HTTP_Parser($this->headers);
                 if ($parser->parse()) {
                     $this->headers = $parser->headers;
                     $this->body = $parser->body;
                     $this->status_code = $parser->status_code;
                     if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects) {
                         $this->redirects++;
                         $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);
                         return $this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen);
                     }
                 }
             }
         } else {
             $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN;
             $url_parts = parse_url($url);
             $socket_host = $url_parts['host'];
             if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https') {
                 $socket_host = "ssl://{$url_parts['host']}";
                 $url_parts['port'] = 443;
             }
             if (!isset($url_parts['port'])) {
                 $url_parts['port'] = 80;
             }
             $fp = @fsockopen($socket_host, $url_parts['port'], $errno, $errstr, $timeout);
             if (!$fp) {
                 $this->error = 'fsockopen error: ' . $errstr;
                 $this->success = false;
             } else {
                 stream_set_timeout($fp, $timeout);
                 if (isset($url_parts['path'])) {
                     if (isset($url_parts['query'])) {
                         $get = "{$url_parts['path']}?{$url_parts['query']}";
                     } else {
                         $get = $url_parts['path'];
                     }
                 } else {
                     $get = '/';
                 }
                 $out = "GET {$get} HTTP/1.1\r\n";
                 $out .= "Host: {$url_parts['host']}\r\n";
                 $out .= "User-Agent: {$useragent}\r\n";
                 if (extension_loaded('zlib')) {
                     $out .= "Accept-Encoding: x-gzip,gzip,deflate\r\n";
                 }
                 if (isset($url_parts['user']) && isset($url_parts['pass'])) {
                     $out .= "Authorization: Basic " . base64_encode("{$url_parts['user']}:{$url_parts['pass']}") . "\r\n";
                 }
                 foreach ($headers as $key => $value) {
                     $out .= "{$key}: {$value}\r\n";
                 }
                 $out .= "Connection: Close\r\n\r\n";
                 fwrite($fp, $out);
                 $info = stream_get_meta_data($fp);
                 $this->headers = '';
                 while (!$info['eof'] && !$info['timed_out']) {
                     $this->headers .= fread($fp, 1160);
                     $info = stream_get_meta_data($fp);
                 }
                 if (!$info['timed_out']) {
                     $parser = new SimplePie_HTTP_Parser($this->headers);
                     if ($parser->parse()) {
                         $this->headers = $parser->headers;
                         $this->body = $parser->body;
                         $this->status_code = $parser->status_code;
                         if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects) {
                             $this->redirects++;
                             $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);
                             return $this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen);
                         }
                         if (isset($this->headers['content-encoding'])) {
                             // Hey, we act dumb elsewhere, so let's do that here too
                             switch (strtolower(trim($this->headers['content-encoding'], "\t\n\r "))) {
                                 case 'gzip':
                                 case 'x-gzip':
                                     $decoder = new SimplePie_gzdecode($this->body);
                                     if (!$decoder->parse()) {
                                         $this->error = 'Unable to decode HTTP "gzip" stream';
                                         $this->success = false;
                                     } else {
                                         $this->body = $decoder->data;
                                     }
                                     break;
                                 case 'deflate':
                                     if (($decompressed = gzinflate($this->body)) !== false) {
                                         $this->body = $decompressed;
                                     } else {
                                         if (($decompressed = gzuncompress($this->body)) !== false) {
                                             $this->body = $decompressed;
                                         } else {
                                             if (function_exists('gzdecode') && ($decompressed = gzdecode($this->body)) !== false) {
                                                 $this->body = $decompressed;
                                             } else {
                                                 $this->error = 'Unable to decode HTTP "deflate" stream';
                                                 $this->success = false;
                                             }
                                         }
                                     }
                                     break;
                                 default:
                                     $this->error = 'Unknown content coding';
                                     $this->success = false;
                             }
                         }
                     }
                 } else {
                     $this->error = 'fsocket timed out';
                     $this->success = false;
                 }
                 fclose($fp);
             }
         }
     } else {
         $this->method = SIMPLEPIE_FILE_SOURCE_LOCAL | SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS;
         if (!($this->body = file_get_contents($url))) {
             $this->error = 'file_get_contents could not read the file';
             $this->success = false;
         }
     }
 }
예제 #18
0
function gen_user_als_list(&$tpl, &$sql, $user_id)
{
    $domain_id = get_user_domain_id($sql, $user_id);
    $query = <<<SQL_QUERY
        select
            alias_id, alias_name, alias_status, alias_mount, alias_ip_id, url_forward
        from
            domain_aliasses
        where
            domain_id = ?
        order by
            alias_name
SQL_QUERY;
    $rs = exec_query($sql, $query, array($domain_id));
    if ($rs->RecordCount() == 0) {
        $tpl->assign(array('ALS_MSG' => tr('Alias list is empty!'), 'ALS_LIST' => ''));
        $tpl->parse('ALS_MESSAGE', 'als_message');
    } else {
        $counter = 0;
        while (!$rs->EOF) {
            if ($counter % 2 == 0) {
                $tpl->assign('ITEM_CLASS', 'content');
            } else {
                $tpl->assign('ITEM_CLASS', 'content2');
            }
            list($als_action, $als_action_script) = gen_user_als_action($rs->fields['alias_id'], $rs->fields['alias_status']);
            list($als_forward, $als_forward_script) = gen_user_als_forward($rs->fields['alias_id'], $rs->fields['alias_status'], $rs->fields['url_forward']);
            $IDN = new idna_convert();
            $alias_name = $IDN->decode($rs->fields['alias_name']);
            $alias_name = utf8_decode($alias_name);
            $tpl->assign(array('ALS_NAME' => $alias_name, 'ALS_MOUNT' => $rs->fields['alias_mount'], 'ALS_STATUS' => translate_dmn_status($rs->fields['alias_status']), 'ALS_FORWARD' => $als_forward, 'ALS_FWD_SCRIPT' => $als_forward_script, 'ALS_ACTION' => $als_action, 'ALS_ACTION_SCRIPT' => $als_action_script));
            $tpl->parse('ALS_ITEM', '.als_item');
            $rs->MoveNext();
            $counter++;
        }
        $tpl->parse('ALS_LIST', 'als_list');
        $tpl->assign('ALS_MESSAGE', '');
    }
}
예제 #19
0
 /**
  * Attempts to return a concrete IDNA instance for either php4 or php5,
  * only creating a new instance if no IDNA instance with the same
  * parameters currently exists.
  *
  * @param array $params Set of paramaters
  *
  * @return object idna_convert
  * @access public
  */
 public function singleton($params = array())
 {
     static $instances;
     if (!isset($instances)) {
         $instances = array();
     }
     $signature = serialize($params);
     if (!isset($instances[$signature])) {
         $instances[$signature] = idna_convert::getInstance($params);
     }
     return $instances[$signature];
 }
예제 #20
0
/**
* Validate an email address - also supports IDN email addresses
* @returns True/false for valid/invalid
*
* @param mixed $sEmailAddress  Email address to check
*/
function validateEmailAddress($sEmailAddress)
{
    require_once APPPATH . 'third_party/idna-convert/idna_convert.class.php';
    $oIdnConverter = new idna_convert();
    $sEmailAddress = $oIdnConverter->encode($sEmailAddress);
    $bResult = filter_var($sEmailAddress, FILTER_VALIDATE_EMAIL);
    if ($bResult !== false) {
        return true;
    }
    return false;
}
예제 #21
0
function checkCSRF()
{
    if ($_SERVER['REQUEST_METHOD'] != 'POST') {
        return FALSE;
    }
    $default_url = Context::getDefaultUrl();
    $referer = $_SERVER["HTTP_REFERER"];
    if (strpos($default_url, 'xn--') !== FALSE && strpos($referer, 'xn--') === FALSE) {
        require_once _XE_PATH_ . 'libs/idna_convert/idna_convert.class.php';
        $IDN = new idna_convert(array('idn_version' => 2008));
        $referer = $IDN->encode($referer);
    }
    $default_url = parse_url($default_url);
    $referer = parse_url($referer);
    $oModuleModel = getModel('module');
    $siteModuleInfo = $oModuleModel->getDefaultMid();
    if ($siteModuleInfo->site_srl == 0) {
        if ($default_url['host'] !== $referer['host']) {
            return FALSE;
        }
    } else {
        $virtualSiteInfo = $oModuleModel->getSiteInfo($siteModuleInfo->site_srl);
        if (strtolower($virtualSiteInfo->domain) != strtolower(Context::get('vid')) && !strstr(strtolower($virtualSiteInfo->domain), strtolower($referer['host']))) {
            return FALSE;
        }
    }
    return TRUE;
}
예제 #22
0
 /**
  * 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;
 }
예제 #23
0
$mcolor3 = JRequest::getVar('mcolor3');
$mcolor4 = JRequest::getVar('mcolor4');
$mcolor5 = JRequest::getVar('mcolor5');
$mcolor6 = JRequest::getVar('mcolor6');
$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());
예제 #24
0
 /**
  * Decode an internationalized domain name
  * @param string
  * @return string
  */
 protected function idnaDecode($strDomain)
 {
     if (!class_exists('idna_convert', false)) {
         require_once TL_ROOT . '/plugins/idna/idna_convert.class.php';
     }
     $objIdn = new idna_convert();
     return $objIdn->decode($strDomain);
 }
예제 #25
0
파일: Record.php 프로젝트: Wasage/werpa
 /**
  * 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
             }
             if (!empty($bccs)) {
                 // SalesPlatform.ru begin
                 foreach ($bccs as $bcc) {
                     $mailer->AddBCC($idn->encode($bcc));
                 }
                 //$mailer->AddBCC($bcc);
                 // SalesPlatform.ru end
             }
         }
         // SalesPlatform.ru begin
         $idn = new idna_convert();
         $query = "select * from vtiger_systems where server_type=?";
         $params = array('email');
         //SalesPlatform begin fix bug
         $adb = PearDatabase::getInstance();
         //SalesPaltform.ru end
         $result = $adb->pquery($query, $params);
         $server_username = $adb->query_result($result, 0, 'server_username');
         $from_name_db = $adb->query_result($result, 0, 'from_name');
         $server_port = $adb->query_result($result, 0, 'server_port');
         $server_tls = $adb->query_result($result, 0, 'server_tls');
         if ($server_username != '') {
             $server_username = $idn->encode($server_username);
             $mailer->Username = $server_username;
         }
         if (isset($from_name_db) && $from_name_db != '') {
             $mailer->FromName = decode_html($from_name_db);
         }
         $from_email = $adb->query_result($result, 0, 'from_email_field');
         if ($from_email != '') {
             $mailer->From = $idn->encode($from_email);
         }
         if (!empty($server_port) && $server_port != 0) {
             $mailer->Port = $server_port;
         }
         if (!empty($server_tls) && $server_tls != 'no') {
             $mailer->SMTPSecure = $server_tls;
         }
         $use_sendmail = $adb->query_result($result, 0, 'use_sendmail');
         if ($use_sendmail == "on") {
             $mailer->IsSendmail();
         } else {
             $mailer->IsSMTP();
         }
         // SalesPlatform.ru end
         $status = $mailer->Send(true);
         if (!$status) {
             $status = $mailer->getError();
         } else {
             $mailString = $mailer->getMailString();
             $mailBoxModel = MailManager_Mailbox_Model::activeInstance();
             $folderName = $mailBoxModel->folder();
             if (!empty($folderName) && !empty($mailString)) {
                 $connector = MailManager_Connector_Connector::connectorWithModel($mailBoxModel, '');
                 imap_append($connector->mBox, $connector->mBoxUrl . $folderName, $mailString, "\\Seen");
             }
         }
     }
     return $status;
 }
예제 #26
0
 /**
  * Transforms a Punycode string to a UTF-8 string
  *
  * @param   string  $punycodeString  The Punycode string to transform
  *
  * @return  string  The UF-8 URL
  *
  * @since   3.1.2
  */
 public static function fromPunycode($punycodeString)
 {
     $idn = new idna_convert();
     return $idn->decode($punycodeString);
 }
예제 #27
0
<?php

$encoded = $decoded = $add = '';
header('Content-Type: text/html; charset=utf-8');
require_once 'idna_convert.class.php';
$idn_version = isset($_REQUEST['idn_version']) && $_REQUEST['idn_version'] == 2003 ? 2003 : 2008;
$IDN = new idna_convert(array('idn_version' => $idn_version));
$version_select = '<select size="1" name="idn_version"><option value="2003">IDNA 2003</option><option value="2008"';
if ($idn_version == 2008) {
    $version_select .= ' selected="selected"';
}
$version_select .= '>IDNA 2008</option></select>';
if (isset($_REQUEST['encode'])) {
    $decoded = isset($_REQUEST['decoded']) ? stripslashes($_REQUEST['decoded']) : '';
    $encoded = $IDN->encode($decoded);
}
if (isset($_REQUEST['decode'])) {
    $encoded = isset($_REQUEST['encoded']) ? stripslashes($_REQUEST['encoded']) : '';
    $decoded = $IDN->decode($encoded);
}
$lang = 'en';
if (isset($_REQUEST['lang'])) {
    if ('de' == $_REQUEST['lang'] || 'en' == $_REQUEST['lang']) {
        $lang = $_REQUEST['lang'];
        $add .= '<input type="hidden" name="lang" value="' . $lang . '" />' . "\n";
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
예제 #28
0
 /**
  * Converts given punycode to the IDN.
  * @param $value punycode to be converted.
  * @return string resulting IDN.
  * @since 1.1.13
  */
 private function decodeIDN($value)
 {
     require_once Yii::getPathOfAlias('system.vendors.idna_convert') . DIRECTORY_SEPARATOR . 'idna_convert.class.php';
     $idnaConvert = new idna_convert();
     return $idnaConvert->decode($value);
 }
예제 #29
0
파일: frontend.php 프로젝트: 4uva4ek/svato
function files()
{
    $inDB = cmsDatabase::getInstance();
    global $_LANG;
    $do = cmsCore::getInstance()->do;
    //============================================================================//
    // Скачивание
    if ($do == 'view') {
        $fileurl = cmsCore::request('fileurl', 'str', '');
        if (!$fileurl) {
            cmsCore::error404();
        }
        $fileurl = mb_strpos($fileurl, '-') === 0 ? htmlspecialchars_decode(base64_decode(ltrim($fileurl, '-'))) : $fileurl;
        if (mb_strstr($fileurl, '..')) {
            cmsCore::error404();
        }
        if (mb_strstr($fileurl, 'http:/')) {
            if (!mb_strstr($fileurl, 'http://')) {
                $fileurl = str_replace('http:/', 'http://', $fileurl);
            }
        }
        $downloads = cmsCore::fileDownloadCount($fileurl);
        if ($downloads == 0) {
            $sql = "INSERT INTO cms_downloads (fileurl, hits) VALUES ('{$fileurl}', '1')";
            $inDB->query($sql);
        } else {
            $sql = "UPDATE cms_downloads SET hits = hits + 1 WHERE fileurl = '{$fileurl}'";
            $inDB->query($sql);
        }
        if (mb_strstr($fileurl, 'http:/')) {
            cmsCore::redirect($fileurl);
        }
        if (file_exists(PATH . $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 (!$url) {
            cmsCore::error404();
        }
        $url = mb_strpos($url, '-') === 0 ? htmlspecialchars_decode(base64_decode(ltrim($url, '-'))) : $url;
        if (mb_strstr($url, '..')) {
            cmsCore::error404();
        }
        if (mb_strstr($url, 'http:/')) {
            if (!mb_strstr($url, 'http://')) {
                $url = str_replace('http:/', 'http://', $url);
            }
        }
        if (mb_strstr($url, 'https:/')) {
            if (!mb_strstr($url, 'https://')) {
                $url = str_replace('https:/', 'https://', $url);
            }
        }
        // кириллические домены
        $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);
    }
    //============================================================================//
}
예제 #30
0
 /**
  * Checks if a given string is a Uniform Resource Locator (URL).
  *
  * @param string $url The URL to be validated
  * @return boolean Whether the given URL is valid
  */
 public static function isValidUrl($url)
 {
     require_once PATH_typo3 . 'contrib/idna/idna_convert.class.php';
     $IDN = new \idna_convert(array('idn_version' => 2008));
     return filter_var($IDN->encode($url), FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED) !== FALSE;
 }