<?php // Platform's core initialization. require dirname(__FILE__) . '/../config.php'; require $PLATFORMCREATE; ci()->load->helper('url')->library('template'); header('Content-Type: text/html; charset=UTF-8'); //require 'Net/IDNA2.php'; $idn = Net_IDNA2::getInstance(); if (isset($_REQUEST['encode'])) { $decoded = isset($_REQUEST['decoded']) ? $_REQUEST['decoded'] : ''; try { $encoded = $idn->encode($decoded); } catch (Exception $e) { /* just swallow */ } } if (isset($_REQUEST['decode'])) { $encoded = isset($_REQUEST['encoded']) ? $_REQUEST['encoded'] : ''; try { $decoded = $idn->decode($encoded); } catch (Exception $e) { /* just swallow */ } } if (!isset($encoded)) { $encoded = ''; } if (!isset($decoded)) { $decoded = ''; }
/** * 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 Net_IDNA2 * @access public */ function singleton($params = array()) { static $instances; if (!isset($instances)) { $instances = array(); } $signature = serialize($params); if (!isset($instances[$signature])) { $instances[$signature] = Net_IDNA2::getInstance($params); } return $instances[$signature]; }