コード例 #1
2
ファイル: Html2Text.php プロジェクト: soundasleep/html2text
 /**
  * Tries to convert the given HTML into a plain text format - best suited for
  * e-mail display, etc.
  *
  * <p>In particular, it tries to maintain the following features:
  * <ul>
  *   <li>Links are maintained, with the 'href' copied over
  *   <li>Information in the &lt;head&gt; is lost
  * </ul>
  *
  * @param string $html the input HTML
  * @return string the HTML converted, as best as possible, to text
  * @throws Html2TextException if the HTML could not be loaded as a {@link DOMDocument}
  */
 static function convert($html)
 {
     // replace &nbsp; with spaces
     $html = str_replace("&nbsp;", " ", $html);
     $html = str_replace(" ", " ", $html);
     if (static::isOfficeDocument($html)) {
         // remove office namespace
         $html = str_replace(array("<o:p>", "</o:p>"), "", $html);
     }
     $html = static::fixNewlines($html);
     if (mb_detect_encoding($html, "UTF-8", true)) {
         $html = mb_convert_encoding($html, "HTML-ENTITIES", "UTF-8");
     }
     $doc = new \DOMDocument();
     if (!$doc->loadHTML($html)) {
         throw new Html2TextException("Could not load HTML - badly formed?", $html);
     }
     if (static::isOfficeDocument($html)) {
         // remove office namespace
         $doc = static::fixMSEncoding($doc);
     }
     $output = static::iterateOverNode($doc);
     // remove leading and trailing spaces on each line
     $output = preg_replace("/[ \t]*\n[ \t]*/im", "\n", $output);
     $output = preg_replace("/ *\t */im", "\t", $output);
     // remove unnecessary empty lines
     $output = preg_replace("/\n\n\n*/im", "\n\n", $output);
     // remove leading and trailing whitespace
     $output = trim($output);
     return $output;
 }
コード例 #2
2
ファイル: MarketController.php プロジェクト: Quiss/Evrika
 /**
  * @todo перенести в комманды
  * Контроллер для записи Категорий
  * @Secure(roles = "ROLE_ADMIN")
  * @Route("/testxmlcat", name = "testcategories")
  */
 public function reParceCategoriesAction()
 {
     $html = file_get_contents("http://www.medknigaservis.ru/ervr/medknigaservis.xml");
     $html = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8");
     $html = iconv("windows-1251", "utf-8", $html);
     $saw = new \nokogiri($html);
     $xml = $saw->get('category')->toArray();
     #echo '<pre>';
     #print_r($xml);
     #echo '</pre>';
     #echo '<hr />';
     for ($i = 0; true; $i++) {
         if (isset($xml[$i]['#text'][0])) {
             echo '<b>' . $xml[$i]['#text'][0] . '</b><br />';
             $cat = new MarketCategory();
             $cat->setName($xml[$i]['#text'][0]);
             $cat->setOfferId($xml[$i]['id']);
             $em = $this->getDoctrine()->getManager();
             $em->persist($cat);
             $em->flush();
         } else {
             break;
         }
     }
     return $this->render('EvrikaMainBundle:Shop:main.html.twig');
 }
コード例 #3
1
ファイル: FdfFile.php プロジェクト: aviddv1/php-pdftk
 /**
  * Constructor
  *
  * @param array $data the form data as name => value
  * @param string|null $suffix the optional suffix for the tmp file
  * @param string|null $suffix the optional prefix for the tmp file. If null 'php_tmpfile_' is used.
  * @param string|null $directory directory where the file should be created. Autodetected if not provided.
  * @param string|null $encoding of the data. Default is 'UTF-8'.
  */
 public function __construct($data, $suffix = null, $prefix = null, $directory = null, $encoding = 'UTF-8')
 {
     if ($directory === null) {
         $directory = self::getTempDir();
     }
     $suffix = '.fdf';
     $prefix = 'php_pdftk_fdf_';
     $this->_fileName = tempnam($directory, $prefix);
     $newName = $this->_fileName . $suffix;
     rename($this->_fileName, $newName);
     $this->_fileName = $newName;
     $fields = '';
     foreach ($data as $key => $value) {
         // Create UTF-16BE string encode as ASCII hex
         // See http://blog.tremily.us/posts/PDF_forms/
         $utf16Value = mb_convert_encoding($value, 'UTF-16BE', $encoding);
         /* Also create UTF-16BE encoded key, this allows field names containing
          * german umlauts and most likely many other "special" characters.
          * See issue #17 (https://github.com/mikehaertl/php-pdftk/issues/17)
          */
         $utf16Key = mb_convert_encoding($key, 'UTF-16BE', $encoding);
         // Escape parenthesis
         $utf16Value = strtr($utf16Value, array('(' => '\\(', ')' => '\\)'));
         $fields .= "<</T(" . chr(0xfe) . chr(0xff) . $utf16Key . ")/V(" . chr(0xfe) . chr(0xff) . $utf16Value . ")>>\n";
     }
     // Use fwrite, since file_put_contents() messes around with character encoding
     $fp = fopen($this->_fileName, 'w');
     fwrite($fp, self::FDF_HEADER);
     fwrite($fp, $fields);
     fwrite($fp, self::FDF_FOOTER);
     fclose($fp);
 }
コード例 #4
1
ファイル: shocky.php プロジェクト: Cazzar/Shocky
function mb_ord($char)
{
    $k = mb_convert_encoding($char, 'UCS-2LE', 'UTF-8');
    $k1 = ord(substr($k, 0, 1));
    $k2 = ord(substr($k, 1, 1));
    return $k2 * 256 + $k1;
}
    function content_56fb07db48ec49_11926809($_smarty_tpl)
    {
        ?>

<!-- Block search module -->
<div id="search_block_left" class="block exclusive">
	<p class="title_block"><?php 
        echo smartyTranslate(array('s' => 'Search', 'mod' => 'blocksearch'), $_smarty_tpl);
        ?>
</p>
	<form method="get" action="<?php 
        echo htmlspecialchars($_smarty_tpl->tpl_vars['link']->value->getPageLink('search', true, null, null, false, null, true), ENT_QUOTES, 'UTF-8', true);
        ?>
" id="searchbox">
    	<label for="search_query_block"><?php 
        echo smartyTranslate(array('s' => 'Search products:', 'mod' => 'blocksearch'), $_smarty_tpl);
        ?>
</label>
		<p class="block_content clearfix">
			<input type="hidden" name="orderby" value="position" />
			<input type="hidden" name="controller" value="search" />
			<input type="hidden" name="orderway" value="desc" />
			<input class="search_query form-control grey" type="text" id="search_query_block" name="search_query" value="<?php 
        echo stripslashes(mb_convert_encoding(htmlspecialchars($_smarty_tpl->tpl_vars['search_query']->value, ENT_QUOTES, 'UTF-8', true), "HTML-ENTITIES", 'UTF-8'));
        ?>
" />
			<button type="submit" id="search_button" class="btn btn-default button button-small"><span><i class="icon-search"></i></span></button>
		</p>
	</form>
</div>
<!-- /Block search module --><?php 
    }
コード例 #6
0
ファイル: snsref.inc.php プロジェクト: nao-pon/xpWiki
 private function apiRequest($apiurl, $target = 'html')
 {
     $html = null;
     $this->fetcherr = false;
     $res = $this->func->http_request($apiurl);
     if ($res['rc'] === 200) {
         if ($res['data'] && ($decd = json_decode($res['data'], true))) {
             if (is_array($decd) && isset($decd[$target])) {
                 $html = mb_convert_encoding($decd[$target], $this->cont['SOURCE_ENCODING'], 'UTF-8');
                 $ttl = 2592000;
                 // 30days
             }
         }
     }
     if (is_null($html)) {
         $this->fetcherr = true;
         if ($res['rc'] === 404) {
             // Not found
             $html = 'Target post was not found: ';
             $ttl = 3600;
         } else {
             // Network error
             $html = 'Network error, Try after 10 minute: ';
             $ttl = 60;
             $this->root->rtf['disable_render_cache'] = true;
         }
     }
     return array($html, $ttl);
 }
コード例 #7
0
/**
 * Formats a given decimal value to a local aware currency value
 *
 *
 * @link http://framework.zend.com/manual/de/zend.currency.options.html
 * @param float  $value Value can have a coma as a decimal separator
 * @param array  $config
 * @param string $position where the currency symbol should be displayed
 * @return float|string
 */
function smarty_modifier_currency($value, $config = null, $position = null)
{
    if (!Enlight_Application::Instance()->Bootstrap()->hasResource('Currency')) {
        return $value;
    }
    if (!empty($config) && is_string($config)) {
        $config = strtoupper($config);
        if (defined('Zend_Currency::' . $config)) {
            $config = array('display' => constant('Zend_Currency::' . $config));
        } else {
            $config = array();
        }
    } else {
        $config = array();
    }
    if (!empty($position) && is_string($position)) {
        $position = strtoupper($position);
        if (defined('Zend_Currency::' . $position)) {
            $config['position'] = constant('Zend_Currency::' . $position);
        }
    }
    $currency = Enlight_Application::Instance()->Currency();
    $value = floatval(str_replace(',', '.', $value));
    $value = $currency->toCurrency($value, $config);
    if (function_exists('mb_convert_encoding')) {
        $value = mb_convert_encoding($value, 'HTML-ENTITIES', 'UTF-8');
    }
    $value = htmlentities($value, ENT_COMPAT, 'UTF-8', false);
    return $value;
}
コード例 #8
0
 public function __construct($url)
 {
     if (!preg_match('!^https?://!i', $url)) {
         $url = 'http://' . $url;
     }
     $data = Http::Request($url);
     //$enc = mb_detect_encoding($str, "UTF-8,ISO-8859-1,ASCII");
     $html = mb_convert_encoding($data, "UTF-8", "UTF-8,ISO-8859-1,ASCII");
     //$html = utf8_encode($html);
     $r = new Readability($html, $url);
     $r->init();
     if (!isset($this->metadata["title"])) {
         $this->metadata["title"] = CharacterEntities::convert(strip_tags($r->getTitle()->innerHTML));
     }
     if (!isset($this->metadata["author"])) {
         $parts = parse_url($url);
         $this->metadata["author"] = $parts["host"];
     }
     $article = $r->getContent()->innerHTML;
     if (substr($article, 0, 5) == "<body") {
         $article = "<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'/></head>" . $article . "</html>";
     } else {
         $article = "<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'/></head><body>" . $article . "</body></html>";
     }
     $doc = new DOMDocument();
     @$doc->loadHTML($article) or die($article);
     $doc->normalizeDocument();
     $this->images = $this->handleImages($doc, $url);
     $this->text = $doc->saveHTML();
 }
コード例 #9
0
ファイル: file_list.php プロジェクト: tejdeeps/tejcs.com
function cleanExcelData(&$str)
{
    if (strstr($str, '"')) {
        $str = '"' . str_replace('"', '""', $str) . '"';
    }
    $str = mb_convert_encoding($str, 'UTF-16LE', 'UTF-8');
}
コード例 #10
0
ファイル: tag.app.php プロジェクト: sunhk25/iCMS
 public function do_iCMS($a = null)
 {
     if ($_GET['name']) {
         $name = $_GET['name'];
         $encode = mb_detect_encoding($name, array("ASCII", "UTF-8", "GB2312", "GBK", "BIG5"));
         if (strtoupper($encode) != 'UTF-8') {
             if (function_exists('iconv')) {
                 $name = iconv($encode, 'UTF-8//IGNORE', $name);
             } elseif (function_exists('mb_convert_encoding')) {
                 $name = mb_convert_encoding($name, 'UTF-8//IGNORE', $encode);
             }
         }
         $val = iS::escapeStr($name);
         $field = 'name';
     } elseif ($_GET['tkey']) {
         $field = 'tkey';
         $val = iS::escapeStr($_GET['tkey']);
     } elseif ($_GET['id']) {
         $field = 'id';
         $val = (int) $_GET['id'];
     } else {
         iPHP::throw404('标签请求出错', 30001);
     }
     return $this->tag($val, $field);
 }
コード例 #11
0
 public function command_calc($user, $channel, $args)
 {
     $calc = implode(" ", $args);
     $data = file_get_contents("http://www.google.com/ig/calculator?hl=en&q=" . urlencode($calc));
     $this->bot->privmsg($channel, "0|" . $data);
     $data = mb_convert_encoding($data, 'UTF-8', mb_detect_encoding($data, 'UTF-8, ISO-8859-1', true));
     //print("1|".$data . "\n");
     $this->bot->privmsg($channel, "1|" . $data);
     $data = preg_replace("/([,{])(.*?):/", '$1"$2":', $data);
     //hack, convert js to json.
     //print("2|".$data . "\n");
     $this->bot->privmsg($channel, "2|" . $data);
     $data = stripcslashes($data);
     //print("3|".$data . "\n");
     $this->bot->privmsg($channel, "3|" . $data);
     $data = preg_replace("/<sup>(.*?)<\\/sup>/", '^$1', $data);
     //print("4|".$data . "\n");
     $this->bot->privmsg($channel, "4|" . $data);
     $data = preg_replace("/&#215;/", '\\u00d7', $data);
     //print("5|".$data . "\n");
     $this->bot->privmsg($channel, "5|" . $data);
     $data = json_decode($data, 1);
     //foreach ($data as &$node) { $node = html_entity_decode($node); }
     //print_r($data);
     $this->bot->privmsg($channel, "6|" . json_encode($data));
     $this->bot->privmsg($channel, $data["lhs"] . " = " . $data["rhs"]);
     //$this->bot->privmsg($channel, json_encode(array($data[error], $data[icc], $calc))); //DEBUG
 }
コード例 #12
0
ファイル: Cep.php プロジェクト: samukt/ConsultarCEPCorreios
function ConsultarCEP($cep)
{
    $url = 'http://www.buscacep.correios.com.br/sistemas/buscacep/resultadoBuscaCepEndereco.cfm';
    $fields = array('relaxation' => urlencode(intval($cep)), 'tipoCEP' => urlencode('ALL'), 'semelhante' => urlencode('N'));
    $fields_string = '';
    foreach ($fields as $key => $value) {
        $fields_string .= $key . '=' . $value . '&';
    }
    rtrim($fields_string, '&');
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, count($fields));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    $result = utf8_decode(curl_exec($ch));
    curl_close($ch);
    $doc = new DOMDocument();
    $doc->preserveWhiteSpace = false;
    $doc->strictErrorChecking = false;
    $doc->recover = true;
    $doc->loadHTML(mb_convert_encoding($result, 'HTML-ENTITIES', 'UTF-8'));
    $xpath = new DOMXPath($doc);
    $query = "//table[@class='tmptabela']//td";
    $entries = $xpath->query($query);
    $uf = explode('/', $entries->item(2)->nodeValue)[1];
    $cidade = explode('/', $entries->item(2)->nodeValue)[0];
    $bairro = substr($entries->item(1)->nodeValue, 0, -2);
    $logradouro = substr($entries->item(0)->nodeValue, 0, -2);
    $return = array('uf' => trim($uf), 'cidade' => trim($cidade), 'bairro' => trim($bairro), 'logradouro' => trim($logradouro));
    if (!empty($return)) {
        return $return;
    } else {
        return false;
    }
}
コード例 #13
0
ファイル: webmapplus.php プロジェクト: notWood/webmapplus
 static function GeoCode($address, $returnBox = false)
 {
     $params =& JComponentHelper::getParams('com_webmapplus');
     $key = $params->get('gmaps_api_key', '');
     $request = "http://maps.google.com/maps/geo?q=" . urlencode($address) . "&key={$key}";
     if (function_exists("curl_version")) {
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $request);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
         $page = curl_exec($ch);
         curl_close($ch);
     } elseif (ini_get('allow_url_fopen') == 1) {
         $page = file_get_contents($request);
     } else {
         echo "cURL is not installed and allow_url_fopen is false. Can not continue.";
         die;
         return false;
     }
     //Silly Google doesn't use UTF-8 Encoding
     $page = mb_convert_encoding($page, 'UTF-8', mb_detect_encoding($page, 'UTF-8, ISO-8859-1', true));
     $data = json_decode($page);
     if ($data->Status->code == "200") {
         if (!$returnBox) {
             return $data->Placemark[0]->Point->coordinates;
         } else {
             return $data->Placemark[0]->ExtendedData->LatLonBox;
         }
     } else {
         return $data->Status->code;
     }
 }
コード例 #14
0
ファイル: RenderEngine.php プロジェクト: angelog4/sdk-php
 /**
  * Transform asset paths based on the report
  *
  * @param $content
  * @return string
  * @throws ExtensionNotLoadedException
  */
 public function transformAssetPaths($content)
 {
     if (null === $content) {
         throw new ContentNotFoundException('No content was found to be rendered');
     }
     libxml_use_internal_errors(true);
     $doc = new \DOMDocument();
     $doc->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES'));
     $reportRouting = $this->extensionManager->findExtension('report_routing');
     if (null === $reportRouting) {
         throw new ExtensionNotLoadedException('report_routing');
     }
     /* Transform images */
     $images = $doc->getElementsByTagName('img');
     foreach ($images as $image) {
         $this->prepareAsset($image, 'src', $reportRouting);
     }
     /* Transform styles */
     $styles = $doc->getElementsByTagName('link');
     foreach ($styles as $style) {
         $this->prepareAsset($style, 'href', $reportRouting);
     }
     /* Transform scripts */
     $scripts = $doc->getElementsByTagName('script');
     foreach ($scripts as $script) {
         $this->prepareAsset($script, 'src', $reportRouting);
     }
     return $doc->saveHTML();
 }
コード例 #15
0
 /**
  * Check for invalid UTF8 encoding and invalid byte .
  *
  * @param string $string Your string.
  *
  * @return boolean
  */
 public static function checkUtf8Encoding($string)
 {
     if (!mb_check_encoding($string, 'UTF-8') || !$string == mb_convert_encoding(mb_convert_encoding($string, 'UTF-32', 'UTF-8'), 'UTF-8', 'UTF-32')) {
         return false;
     }
     return true;
 }
コード例 #16
0
ファイル: ajaxGetTitle.php プロジェクト: kidwellj/scuttle
function getTitle($url)
{
    $fd = @fopen($url, 'r');
    if ($fd) {
        $html = fread($fd, 1750);
        fclose($fd);
        // Get title from title tag
        preg_match_all('/<title>(.*)<\\/title>/si', $html, $matches);
        $title = $matches[1][0];
        // Get encoding from charset attribute
        preg_match_all('/<meta.*charset=([^;"]*)">/i', $html, $matches);
        $encoding = strtoupper($matches[1][0]);
        // Convert to UTF-8 from the original encoding
        if (function_exists('mb_convert_encoding')) {
            $title = @mb_convert_encoding($title, 'UTF-8', $encoding);
        }
        if (utf8_strlen($title) > 0) {
            return $title;
        } else {
            // No title, so return filename
            $uriparts = explode('/', $url);
            $filename = end($uriparts);
            unset($uriparts);
            return $filename;
        }
    } else {
        return false;
    }
}
コード例 #17
0
 public static function serializeValue($value)
 {
     if ($value === null) {
         return 'null';
     } elseif ($value === false) {
         return 'false';
     } elseif ($value === true) {
         return 'true';
     } elseif (is_float($value) && (int) $value == $value) {
         return $value . '.0';
     } elseif (is_object($value) || gettype($value) == 'object') {
         return 'Object ' . get_class($value);
     } elseif (is_resource($value)) {
         return 'Resource ' . get_resource_type($value);
     } elseif (is_array($value)) {
         return 'Array of length ' . count($value);
     } elseif (is_integer($value)) {
         return (int) $value;
     } else {
         $value = (string) $value;
         if (function_exists('mb_convert_encoding')) {
             $value = mb_convert_encoding($value, 'UTF-8', 'UTF-8');
         }
         return $value;
     }
 }
コード例 #18
0
ファイル: getcookies.php プロジェクト: bajian/js-web-skills
function getAuthResult($postData, $cookie_file)
{
    $url = 'http://rkk.cdpf.org.cn/queryDistrictrecordCDPF.action';
    $header = array("Host: rkk.cdpf.org.cn", 'Cache-Control: max-age=0', 'Connection: keep-alive', "Content-Length: " . strlen($postData), 'Origin: http://rkk.cdpf.org.cn', 'User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36', 'Content-Type: application/x-www-form-urlencoded', 'Referer: http://rkk.cdpf.org.cn/content2.html', 'Accept-Encoding: gzip,deflate', 'Accept-Language: zh-CN,zh;q=0.8');
    $ch = curl_init();
    $res = curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
    $result = curl_exec($ch);
    //需要转码
    echo '<br>';
    echo mb_detect_encoding($result, array('ASCII', 'UTF-8', 'GB2312', 'GBK', 'BIG5'));
    $result = mb_convert_encoding($result, 'UTF-8', 'EUC-CN');
    echo $result;
    $pos = strpos($result, '号码一致');
    if ($pos) {
        echo '号码一致';
    } else {
        echo '不一致';
    }
    curl_close($ch);
}
コード例 #19
0
ファイル: Gettext.php プロジェクト: reoring/sabel
 public function testCodeSet()
 {
     $gettext = Sabel_I18n_Gettext::getInstance();
     $gettext->setCodeSet("EUC-JP");
     $this->assertEquals(mb_convert_encoding("なまえ", "EUC-JP", "UTF-8"), __("name"));
     $this->assertEquals(mb_convert_encoding("じゅうしょ", "EUC-JP", "UTF-8"), __("address"));
 }
コード例 #20
0
ファイル: SearchControl.php プロジェクト: svobodni/web
 public function handleSearch($query, $limit)
 {
     $results = array();
     foreach (array('name', 'title', 'notation', 'text') as $column) {
         $qb = $routes = $this->routeRepository->createQueryBuilder('r')->andWhere('r.published = :true')->setParameter('true', TRUE)->andWhere('r.released < :now')->setParameter('now', new \DateTime())->setParameter('query', "%{$query}%")->setMaxResults($limit);
         if ($this->websiteManager->defaultLanguage !== $this->presenter->lang) {
             $qb->leftJoin('r.translations', 'a')->andWhere('a.language = :langId')->andWhere('(a.' . $column . ' LIKE :query)')->setParameter('langId', $this->presenter->language->id);
         } else {
             $qb->andWhere('r.' . $column . ' LIKE :query');
         }
         foreach ($qb->getQuery()->getResult() as $route) {
             $text = strip_tags(html_entity_decode($route->{$column}));
             if (($len = strlen($text)) > 40) {
                 $pos = stripos($text, $query);
                 $start = $pos - 20;
                 if ($start > 0) {
                     $text = '...' . substr($text, $start);
                 }
                 if ($start + 40 < $len) {
                     $text = substr($text, 0, 40) . '...';
                 }
             }
             $results[$route->id] = array('url' => $this->presenter->link('Route', array('route' => $route)), 'name' => mb_convert_encoding($this->highlightText($route->name, $query), 'UTF-8', 'UTF-8'), 'value' => mb_convert_encoding($route->name, 'UTF-8', 'UTF-8'), 'description' => mb_convert_encoding($this->highlightText($text, $query), 'UTF-8', 'UTF-8'), 'photo' => $route->photo ? $this->template->basePath . \CmsModule\Content\Macros\MediaMacro::proccessImage($route->photo->getFileUrl(true), array('size' => 'x48')) : NULL);
         }
     }
     $this->presenter->sendResponse(new JsonResponse(array_merge($results)));
 }
コード例 #21
0
ファイル: encoding.php プロジェクト: ForAEdesWeb/AEW4
 function change($data, $input, $output)
 {
     $input = strtoupper(trim($input));
     $output = strtoupper(trim($output));
     if ($input == $output) {
         return $data;
     }
     if ($input == 'UTF-8' && $output == 'ISO-8859-1') {
         $data = str_replace(array('€', '„', '“'), array('EUR', '"', '"'), $data);
     }
     if (function_exists('iconv')) {
         set_error_handler('acymailing_error_handler_encoding');
         $encodedData = iconv($input, $output . "//IGNORE", $data);
         restore_error_handler();
         if (!empty($encodedData) && !acymailing_error_handler_encoding('result')) {
             return $encodedData;
         }
     }
     if (function_exists('mb_convert_encoding')) {
         return mb_convert_encoding($data, $output, $input);
     }
     if ($input == 'UTF-8' && $output == 'ISO-8859-1') {
         return utf8_decode($data);
     }
     if ($input == 'ISO-8859-1' && $output == 'UTF-8') {
         return utf8_encode($data);
     }
     return $data;
 }
コード例 #22
0
 /**
  * {@inheritdoc}
  */
 public function encodeCharacter($immune, $c)
 {
     //detect encoding, special-handling for chr(172) and chr(128) to chr(159)
     //which fail to be detected by mb_detect_encoding()
     $initialEncoding = $this->detectEncoding($c);
     // Normalize encoding to UTF-32
     $_4ByteUnencodedOutput = $this->normalizeEncoding($c);
     // Start with nothing; format it to match the encoding of the string passed
     //as an argument.
     $encodedOutput = mb_convert_encoding("", $initialEncoding);
     // Grab the 4 byte character.
     $_4ByteCharacter = $this->forceToSingleCharacter($_4ByteUnencodedOutput);
     // Get the ordinal value of the character.
     list(, $ordinalValue) = unpack("N", $_4ByteCharacter);
     // check for immune characters
     if ($this->containsCharacter($_4ByteCharacter, $immune)) {
         return $encodedOutput . chr($ordinalValue);
     }
     // Check for alphanumeric characters
     $hex = $this->getHexForNonAlphanumeric($_4ByteCharacter);
     if ($hex === null) {
         return $encodedOutput . chr($ordinalValue);
     }
     return $encodedOutput . "\\" . $c;
 }
コード例 #23
0
ファイル: Statement.php プロジェクト: reoring/sabel
 public function escape(array $values)
 {
     if (extension_loaded("mbstring")) {
         $toEnc = defined("SDB_MSSQL_ENCODING") ? SDB_MSSQL_ENCODING : "SJIS";
         $fromEnc = mb_internal_encoding();
         $currentRegexEnc = mb_regex_encoding();
         mb_regex_encoding($fromEnc);
         foreach ($values as $k => &$val) {
             if (is_bool($val)) {
                 $val = $val ? "1" : "0";
             } elseif (is_string($val)) {
                 $val = "'" . mb_convert_encoding(mb_ereg_replace("'", "''", $val), $toEnc, $fromEnc) . "'";
             }
         }
         mb_regex_encoding($currentRegexEnc);
     } else {
         foreach ($values as &$val) {
             if (is_bool($val)) {
                 $val = $val ? "1" : "0";
             } elseif (is_string($val)) {
                 $val = "'" . str_replace("'", "''", $val) . "'";
             }
         }
     }
     return $values;
 }
コード例 #24
0
 public function execute()
 {
     if (empty($this->command)) {
         $this->phpci->logFailure('Configuration command not found.');
         return false;
     }
     if (empty($this->directory)) {
         $this->phpci->logFailure('Configuration directory not found.');
         return false;
     }
     $this->phpci->logExecOutput(false);
     $cmd = 'cd ' . $this->directory . '; ' . $this->command;
     $this->phpci->executeCommand($cmd);
     $tapString = $this->phpci->getLastOutput();
     if ($this->data_offset) {
         $tapString = implode("\n", array_slice(explode("\n", $tapString), $this->data_offset));
     }
     $tapString = mb_convert_encoding($tapString, "UTF-8", "ISO-8859-1");
     $tapString = 'TAP version 13' . "\n" . $tapString;
     try {
         $tapParser = new TapParser($tapString);
         $output = $tapParser->parse();
     } catch (\Exception $ex) {
         $this->phpci->logFailure($tapString);
         throw $ex;
     }
     $failures = $tapParser->getTotalFailures();
     $success = $failures === 0;
     $this->build->storeMeta('mocha-errors', $failures);
     $this->build->storeMeta('mocha-data', $output);
     $this->phpci->logExecOutput(true);
     return $success;
 }
コード例 #25
0
ファイル: SignupCheck.php プロジェクト: Reciplan/Web
function Name_2_ID($Name)
{
    $link = mysql_connect("localhost", "Reciplan", "reciplan");
    if (!$link) {
        die("Connection Failed." . mysql_error());
    }
    $dbselect = mysql_select_db('Neighbor', $link);
    if (!$dbselect) {
        die("DB Select Failed." . mysql_error());
    }
    $chartype = mysql_query("SET NAMES utf8", $link);
    if (!$chartype) {
        die("Query Failed." . mysql_error());
    }
    $Name = mb_convert_encoding($Name, "UTF8", "auto");
    $query = sprintf("SELECT City_ID.City_ID  FROM City_ID WHERE City_Name = '%s' ", $Name);
    //print($query);
    $result = mysql_query($query);
    // MySQL に送られたクエリと返ってきたエラーをそのまま表示します。デバッグに便利です。
    if (!$result) {
        $message = 'Invalid query: ' . mysql_error() . "\n";
        $message .= 'Whole query: ' . $query;
        die($message);
    }
    $data = mysql_fetch_array($result);
    //		print_r($data);
    mysql_close($link);
    return $data['City_ID'];
}
コード例 #26
0
ファイル: image.logic.php プロジェクト: pf5512/phpstudy
	public function water($image_source, $image_dest, $config)
	{
		if ($config['type'] == 'image')
		{
						handler('image')->setSrcImg($image_source);
			handler('image')->setDstImg($image_dest);
			handler('image')->setMaskImg($config['image']);
			handler('image')->setMaskPosition($config['position']);
			handler('image')->createImg(100);
		}
		elseif ($config['type'] == 'text')
		{
			if (ENC_IS_GBK)
			{
								$config['text'] = ENC_G2U($config['text']);
			}
						$config['text'] = mb_convert_encoding($config['text'], 'html-entities', 'UTF-8');
 			$r = array();
						$r[] = handler('image')->setSrcImg($image_source);
			$r[] = handler('image')->setDstImg($image_dest);
			$r[] = handler('image')->setMaskFont(ROOT_PATH.'static/images/watermark/'.$config['font']);
			$r[] = handler('image')->setMaskFontColor('#ffffff');
			$r[] = handler('image')->setMaskFontSize($config['fontsize'] ? $config['fontsize'] : 13);
			$r[] = handler('image')->setMaskWord($config['text']);
			$r[] = handler('image')->setMaskPosition($config['position']);
			$r[] = handler('image')->createImg(100);
		}
	}
    function content_569a53138b5903_87780724($_smarty_tpl)
    {
        ?>
<!-- Block search module TOP -->
<div id="search_block_top" class="col-sm-4 clearfix">
	<form id="searchbox" method="get" action="<?php 
        echo htmlspecialchars($_smarty_tpl->tpl_vars['link']->value->getPageLink('search', null, null, null, false, null, true), ENT_QUOTES, 'UTF-8', true);
        ?>
" >
		<input type="hidden" name="controller" value="search" />
		<input type="hidden" name="orderby" value="position" />
		<input type="hidden" name="orderway" value="desc" />
		<input class="search_query form-control" type="text" id="search_query_top" name="search_query" placeholder="<?php 
        echo smartyTranslate(array('s' => 'Search', 'mod' => 'blocksearch'), $_smarty_tpl);
        ?>
" value="<?php 
        echo stripslashes(mb_convert_encoding(htmlspecialchars($_smarty_tpl->tpl_vars['search_query']->value, ENT_QUOTES, 'UTF-8', true), "HTML-ENTITIES", 'UTF-8'));
        ?>
" />
		<button type="submit" name="submit_search" class="btn btn-default button-search">
			<span><?php 
        echo smartyTranslate(array('s' => 'Search', 'mod' => 'blocksearch'), $_smarty_tpl);
        ?>
</span>
		</button>
	</form>
</div>
<!-- /Block search module TOP --><?php 
    }
コード例 #28
0
ファイル: uname.inc.php プロジェクト: big2men/qhm
function plugin_uname_inline()
{
    $qt = get_qt();
    //---- キャッシュのための処理を登録 -----
    if ($qt->create_cache) {
        $args = func_get_args();
        return $qt->get_dynamic_plugin_mark(__FUNCTION__, $args);
    }
    //------------------------------------
    global $vars;
    $name = isset($vars['uname']) ? $vars['uname'] : '';
    //unameパラメータがセットされていない場合
    if ($name == '') {
        return 'あなた';
    } else {
        $name = htmlspecialchars(mb_convert_encoding($name, SOURCE_ENCODING, 'UTF8,EUC-JP,Shift_JIS'));
    }
    $args = func_get_args();
    $num = count($args);
    $ntitle = "さん";
    if ($num > 1) {
        strip_htmltag(array_pop($args), FALSE);
        $tmpstr = strip_htmltag(array_pop($args), FALSE);
        if ($tmpstr == "none") {
            $ntitle = '';
        } else {
            $ntitle = $tmpstr;
        }
    }
    return $name . $ntitle;
}
コード例 #29
0
ファイル: lib.php プロジェクト: bunkeraa/laravel
 public function big52utf8($string)
 {
     $string = mb_convert_encoding($string, "UTF-8", "BIG5");
     $string = Chinese::decimal_notation_converting($string);
     $string = $this->stringRevise($string);
     return $string;
 }
コード例 #30
0
ファイル: Strmaxcompat.php プロジェクト: t-f-m/ethna
 /**
  *  最大値のチェックを行う
  *
  *  @access public
  *  @param  string  $name       フォームの名前
  *  @param  mixed   $var        フォームの値
  *  @param  array   $params     プラグインのパラメータ
  *  @return true: 成功  Ethna_Error: エラー
  */
 public function validate($name, $var, $params)
 {
     $true = true;
     $type = $this->getFormType($name);
     if (isset($params['strmaxcompat']) == false || $this->isEmpty($var, $type)) {
         return $true;
     }
     $ctl = $this->backend->getController();
     $client_enc = $ctl->getClientEncoding();
     if (mb_enabled() && (strcasecmp('EUC-JP', $client_enc) != 0 && strcasecmp('eucJP-win', $client_enc) != 0)) {
         $var = mb_convert_encoding($var, 'EUC-JP', $client_enc);
     }
     if ($type == VAR_TYPE_STRING) {
         $max_param = $params['strmaxcompat'];
         if (strlen($var) > $max_param) {
             if (isset($params['error'])) {
                 $msg = $params['error'];
             } else {
                 $msg = _et('Please input less than %d full-size (%d half-size) characters to {form}.');
             }
             return Ethna::raiseNotice($msg, E_FORM_MAX_STRING, array(intval($max_param / 2), $max_param));
         }
     }
     return $true;
 }