当前位置: 首页>>代码示例>>PHP>>正文


PHP Chinese::Convert方法代码示例

本文整理汇总了PHP中Chinese::Convert方法的典型用法代码示例。如果您正苦于以下问题:PHP Chinese::Convert方法的具体用法?PHP Chinese::Convert怎么用?PHP Chinese::Convert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Chinese的用法示例。


在下文中一共展示了Chinese::Convert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_payment_code

 public function get_payment_code($payment_notice_id)
 {
     $payment_notice = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment_notice where id = " . $payment_notice_id);
     //$order = $GLOBALS['db']->getRow("select order_sn,bank_id from ".DB_PREFIX."deal_order where id = ".$payment_notice['order_id']);
     $order_sn = $payment_notice['notice_sn'];
     $money = round($payment_notice['money'], 2);
     $payment_info = $GLOBALS['db']->getRow("select id,config,logo from " . DB_PREFIX . "payment where id=" . intval($payment_notice['payment_id']));
     $payment_info['config'] = unserialize($payment_info['config']);
     /*$data_front_url =  SITE_DOMAIN.APP_ROOT.'/index.php?ctl=payment&act=notify&class_name=Guofubao';
       $data_front_url="";
       $data_return_url = SITE_DOMAIN.APP_ROOT.'/index.php?ctl=payment&act=response&class_name=Guofubao';
       */
     //新
     $data_front_url = SITE_DOMAIN . APP_ROOT . '/callback/pay/guofubao_callback.php?act=notify';
     //$data_front_url="";
     $data_return_url = SITE_DOMAIN . APP_ROOT . '/callback/pay/guofubao_callback.php?act=response';
     $tranCode = '8888';
     //$spbill_create_ip = $_SERVER['REMOTE_ADDR'];
     $spbill_create_ip = CLIENT_IP;
     /* 交易日期 */
     $today = to_date($payment_notice['create_time'], 'YmdHis');
     $bank_id = $payment_notice['bank_id'];
     if ($bank_id == '0') {
         $bank_id = '';
     }
     $desc = $order_sn;
     include_once APP_ROOT_PATH . "system/libs/iconv.php";
     $chinese = new Chinese();
     $desc = $chinese->Convert("UTF-8", "GBK", $desc);
     /* 货币类型 */
     $currencyType = '156';
     /* 数字签名 */
     $version = '2.1';
     $tranCode = $tranCode;
     $merchant_id = $payment_info['config']['merchant_id'];
     $merOrderNum = $order_sn;
     $tranAmt = $money;
     // 总金额
     $feeAmt = '';
     $tranDateTime = $today;
     $frontMerUrl = $data_front_url;
     $backgroundMerUrl = $data_return_url;
     //返回的路径
     $tranIP = $spbill_create_ip != "" ? $spbill_create_ip : '';
     //商户识别码
     $verficationCode = $payment_info['config']['VerficationCode'];
     $gopayServerTime = trim(file_get_contents("https://www.gopay.com.cn/PGServer/time"));
     $signValue = 'version=[' . $version . ']tranCode=[' . $tranCode . ']merchantID=[' . $merchant_id . ']merOrderNum=[' . $merOrderNum . ']tranAmt=[' . $tranAmt . ']feeAmt=[' . $feeAmt . ']tranDateTime=[' . $tranDateTime . ']frontMerUrl=[' . $frontMerUrl . ']backgroundMerUrl=[' . $backgroundMerUrl . ']orderId=[]gopayOutOrderId=[]tranIP=[' . $tranIP . ']respCode=[]gopayServerTime=[' . $gopayServerTime . ']VerficationCode=[' . $verficationCode . ']';
     $signValue = md5($signValue);
     /*交易参数*/
     $parameter = array('version' => '2.1', 'charset' => '2', 'language' => '1', 'signType' => '1', 'tranCode' => '8888', 'merchantID' => $merchant_id, 'virCardNoIn' => $payment_info['config']['virCardNoIn'], 'merOrderNum' => $merOrderNum, 'tranAmt' => $tranAmt, 'currencyType' => $currencyType, 'tranDateTime' => $tranDateTime, 'tranIP' => $spbill_create_ip, 'goodsName' => $desc, 'goodsDetail' => '', 'buyerName' => '', 'buyerContact' => '', 'frontMerUrl' => $frontMerUrl, 'backgroundMerUrl' => $backgroundMerUrl, 'signValue' => $signValue, 'gopayServerTime' => $gopayServerTime, 'bankCode' => $bank_id, 'userType' => 1, 'feeAmt' => '', 'isRepeatSubmit' => '', 'merRemark1' => $payment_notice_id, 'merRemark2' => '');
     $def_url = '<form style="text-align:center;" action="https://gateway.gopay.com.cn/Trans/WebClientAction.do" target="_blank" style="margin:0px;padding:0px" method="get" >';
     foreach ($parameter as $key => $val) {
         $def_url .= "<input type='hidden' name='{$key}' value='{$val}' />";
     }
     $def_url .= "<input type='submit' class='paybutton' value='前往国付宝在线支付' />";
     $def_url .= "</form>";
     $def_url .= "<br /><div style='text-align:center' class='red'>" . $GLOBALS['lang']['PAY_TOTAL_PRICE'] . ":" . format_price($money) . "</div>";
     return $def_url;
 }
开发者ID:eliu03,项目名称:fanweP2P,代码行数:60,代码来源:Guofubao_payment.php

示例2: webim_from_utf8

function webim_from_utf8($charset, $str)
{
    if (strtoupper($charset) == 'UTF-8') {
        return $str;
    }
    if (function_exists('iconv')) {
        return iconv('utf-8', $charset, $str);
    }
    require_once dirname(__FILE__) . '/class_chinese.php';
    $chs = new Chinese('utf-8', $charset);
    return $chs->Convert($str);
}
开发者ID:nextalk,项目名称:webim-for-php4,代码行数:12,代码来源:webim_common.func.php

示例3: jsprocdata

function jsprocdata($data, $requestcharset)
{
    global $boardurl, $_DCACHE, $charset;
    if ($requestcharset) {
        include DISCUZ_ROOT . 'include/chinese.class.php';
        if (strtoupper($charset) != 'UTF-8') {
            $c = new Chinese($charset, 'utf8');
        } else {
            $c = new Chinese('utf8', $requestcharset == 1 ? 'gbk' : 'big5');
        }
        $data = $c->Convert($data);
    }
    return 'document.write(\'' . preg_replace("/\r\n|\n|\r/", '\\n', addcslashes($data, "'\\")) . '\');';
}
开发者ID:BGCX067,项目名称:f2cont-svn-to-git,代码行数:14,代码来源:javascript.php

示例4: wap_footer

function wap_footer()
{
    global $wind_version, $db_obstart, $windid, $db_charset, $db_wapcharset, $prog, $chs;
    require_once PrintEot('wap_footer');
    $output = ob_get_contents();
    ob_end_clean();
    $db_obstart && function_exists('ob_gzhandler') ? ob_start('ob_gzhandler') : ob_start();
    if ($db_charset != 'utf8') {
        $chs = new Chinese();
        $output = $chs->Convert($output, $db_charset, $db_wapcharset ? 'UTF8' : 'UNICODE');
    }
    $output = str_replace(array('<!--<!---->', '<!---->'), '', $output);
    echo $output;
    flush();
    exit;
}
开发者ID:adi00,项目名称:wumaproject,代码行数:16,代码来源:wap_mod.php

示例5: get_seo_info

function get_seo_info($domain, $che)
{
    global $ROBOT;
    $che = explode(',', $che);
    $ch = array_combine($che, $che);
    $content = '';
    $site_info = '';
    $link_info = '';
    $jobs = array();
    $jobs[1] = "baidu";
    $jobs[2] = "google";
    $jobs[3] = "yahoo";
    $jobs[4] = "soso";
    $jobs[5] = "vnet";
    $jobs[6] = "so163";
    $jobs[7] = "sogou";
    $a = '<table border=1 width=100% bordercolordark=#FFFFFF cellspacing=0 cellpadding=0 bordercolorlight=#BBD7E6>	<tr bgcolor=#D8F0FC><td colspan=9>网址<a href=http://' . $domain . ' target=_blank>http://' . $domain . '</a>在各大搜索引擎的收录查询结果</td></tr><tr><td>搜索引擎</td>';
    for ($i = 1; $i <= sizeof($jobs); $i++) {
        if ($ch[$i]) {
            $a .= "<td>" . $ROBOT[$jobs[$i]]['name'] . "</td>";
        }
    }
    $a .= "</tr><tr><td>收录数量</td>";
    for ($i = 1; $i <= sizeof($jobs); $i++) {
        if ($ch[$i]) {
            eval('$__file__=__FILE__;');
            define('ROOT_PATH', $__file__ ? dirname($__file__) . '/' : './');
            $content[$i] = get_content($ROBOT[$jobs[$i]]['site_url'] . $domain);
            if ($i == 3 || $i == 5 || $i == 6) {
                require_once 'require/chinese.php';
                $chs = new Chinese('utf-8', 'GB2312');
                $content[$i] = $chs->Convert($content[$i]);
            }
            if (empty($content[$i])) {
                return 'Unkown Error...';
            }
            if (preg_match($ROBOT[$jobs[$i]]['site_pattern'], $content[$i], $matches[$i])) {
                $site_info[$i] = $matches[$i][1];
            }
            $site_info[$i] = $site_info[$i] ? $site_info[$i] : '--';
            $a .= '<td><a href="' . $ROBOT[$jobs[$i]]['site_url'] . $domain . '" target="_blank">' . $site_info[$i] . '</a></td>';
        }
    }
    $a .= "</tr><tr><td>相关查询</td><td colspan=7 align=left><a href=../ip/index.php?domain=" . $domain . " target=_blank>IP地址查询</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href=../pr/pr.php?domain=" . $domain . " target=_blank>PR查询</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href=../whois/index.php?domain=" . $domain . " target=_blank>域名Whois查询</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href=/alexa target=_blank>Alexa排名查询</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href=../friends/friends.php?domain=" . $domain . " target=_blank>友情链接查询</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href=../friendlink/friendlink.php?domain=" . $domain . " target=_blank>友情链接IP查询</a></td></tr></table>";
    return $a;
}
开发者ID:repodevs,项目名称:web_admin_tools,代码行数:46,代码来源:function.php

示例6: Chinese

 function _buildResult($result, $index)
 {
     require_once R_P . 'm/chinese.php';
     $chs = new Chinese('utf8', 'gbk');
     foreach ($result["words"] as $word => $info) {
         $words[] = $chs->Convert($word);
     }
     $totals = $result['total'];
     if (is_array($result["matches"])) {
         $tids = '';
         foreach ($result["matches"] as $docinfo) {
             $tids && ($tids .= ',');
             if (strpos($index, 'tmsgs') !== false || strpos($index, 'threads') !== false) {
                 $tids .= $docinfo['id'];
             } else {
                 $tids .= $docinfo['attrs']['tid'];
             }
         }
         return array($totals, $tids, $words);
     } else {
         return false;
     }
 }
开发者ID:adi00,项目名称:wumaproject,代码行数:23,代码来源:search.class.php

示例7: stringtopic

function stringtopic($value, $key = '', $force = false, $rlength = 0)
{
    if ($key === '') {
        $key = $value;
    }
    $basedir = !getglobal('setting/attachdir') ? './data/attachment' : getglobal('setting/attachdir');
    $url = !getglobal('setting/attachurl') ? './data/attachment/' : getglobal('setting/attachurl');
    $subdir1 = substr(md5($key), 0, 2);
    $subdir2 = substr(md5($key), 2, 2);
    $target = 'temp/' . $subdir1 . '/' . $subdir2 . '/';
    $targetname = substr(md5($key), 8, 16) . '.png';
    discuz_upload::check_dir_exists('temp', $subdir1, $subdir2);
    if (!$force && file_exists($basedir . '/' . $target . $targetname)) {
        return $url . $target . $targetname;
    }
    $value = str_replace("\n", '', $value);
    $fontfile = $fontname = '';
    $ttfenabled = false;
    $size = 10;
    $w = 130;
    $rowh = 25;
    $value = explode("\r", $value);
    if ($rlength) {
        $temp = array();
        foreach ($value as $str) {
            $strlen = dstrlen($str);
            if ($strlen > $rlength) {
                for ($i = 0; $i < $strlen; $i++) {
                    $sub = cutstr($str, $rlength, '');
                    $temp[] = $sub;
                    $str = substr($str, strlen($sub));
                    $strlen = $strlen - $rlength;
                }
            } else {
                $temp[] = $str;
            }
        }
        $value = $temp;
        unset($temp);
    }
    if (function_exists('imagettftext')) {
        $fontroot = DISCUZ_ROOT . './static/image/seccode/font/ch/';
        $dirs = opendir($fontroot);
        while ($entry = readdir($dirs)) {
            if ($entry != '.' && $entry != '..' && in_array(strtolower(fileext($entry)), array('ttf', 'ttc'))) {
                $fontname = $entry;
                break;
            }
        }
        if (!empty($fontname)) {
            $fontfile = DISCUZ_ROOT . './static/image/seccode/font/ch/' . $fontname;
        }
        if ($fontfile) {
            if (strtoupper(CHARSET) != 'UTF-8') {
                include DISCUZ_ROOT . './source/class/class_chinese.php';
                $cvt = new Chinese(CHARSET, 'utf8');
                $value = $cvt->Convert(implode("\r", $value));
                $value = explode("\r", $value);
            }
            $ttfenabled = true;
        }
    }
    foreach ($value as $str) {
        if ($ttfenabled) {
            $box = imagettfbbox($size, 0, $fontfile, $str);
            $height = max($box[1], $box[3]) - min($box[5], $box[7]);
            $len = max($box[2], $box[4]) - min($box[0], $box[6]);
            $rowh = max(array($height, $rowh));
        } else {
            $len = strlen($str) * 12;
        }
        $w = max(array($len, $w));
    }
    $h = $rowh * count($value) + count($value) * 2;
    $im = @imagecreate($w, $h);
    $background_color = imagecolorallocate($im, 255, 255, 255);
    $text_color = imagecolorallocate($im, 60, 60, 60);
    $h = $ttfenabled ? $rowh : 4;
    foreach ($value as $str) {
        if ($ttfenabled) {
            imagettftext($im, $size, 0, 0, $h, $text_color, $fontfile, $str);
            $h += 2;
        } else {
            imagestring($im, $size, 0, $h, $str, $text_color);
        }
        $h += $rowh;
    }
    imagepng($im, $basedir . '/' . $target . $targetname);
    imagedestroy($im);
    return $url . $target . $targetname;
}
开发者ID:samyex6,项目名称:discuz3.2-lite,代码行数:91,代码来源:function_forum.php

示例8: ecs_iconv

function ecs_iconv($source_lang, $target_lang, $source_string = '')
{
    static $chs = NULL;

    /* 如果字符串为空或者字符串不需要转换,直接返回 */
    if ($source_lang == $target_lang || $source_string == '' || preg_match("/[\x80-\xFF]+/", $source_string) == 0)
    {
        return $source_string;
    }

    if ($chs === NULL)
    {
        require_once(ROOT_PATH . 'includes/cls_iconv.php');
        $chs = new Chinese(ROOT_PATH);
    }

    return $chs->Convert($source_lang, $target_lang, $source_string);
}
开发者ID:Richerjx,项目名称:ecshop,代码行数:18,代码来源:lib_base.php

示例9: diconv

function diconv($str, $in_charset, $out_charset = CHARSET, $ForceTable = FALSE)
{
    global $_G;
    $in_charset = strtoupper($in_charset);
    $out_charset = strtoupper($out_charset);
    if (empty($str) || $in_charset == $out_charset) {
        return $str;
    }
    $out = '';
    if (!$ForceTable) {
        if (function_exists('iconv')) {
            $out = iconv($in_charset, $out_charset . '//IGNORE', $str);
        } elseif (function_exists('mb_convert_encoding')) {
            $out = mb_convert_encoding($str, $out_charset, $in_charset);
        }
    }
    if ($out == '') {
        $chinese = new Chinese($in_charset, $out_charset, true);
        $out = $chinese->Convert($str);
    }
    return $out;
}
开发者ID:dalinhuang,项目名称:healthshop,代码行数:22,代码来源:function_core.php

示例10: invite_payurl

function invite_payurl($amount, $price, &$orderid, $bank = 'DEFAULT')
{
    include_once DISCUZ_ROOT . './source/class/class_chinese.php';
    global $_G;
    $date = dgmdate(TIMESTAMP, 'YmdHis');
    $suffix = dgmdate(TIMESTAMP, 'His') . rand(1000, 9999);
    $transaction_id = DISCUZ_PARTNER . $date . $suffix;
    $orderid = dgmdate(TIMESTAMP, 'YmdHis') . random(14);
    $chinese = new Chinese(strtoupper(CHARSET), 'GBK');
    $subject = $chinese->Convert(lang('forum/misc', 'invite_forum_payment') . '_' . intval($amount) . '_' . lang('forum/misc', 'invite_forum_payment_unit') . '_(' . $_G['clientip'] . ')');
    $reqHandler = new RequestHandler();
    $reqHandler->setGateURL("https://gw.tenpay.com/gateway/pay.htm");
    $reqHandler->init();
    $reqHandler->setKey(DISCUZ_SECURITYCODE);
    $reqHandler->setParameter("partner", DISCUZ_PARTNER);
    $reqHandler->setParameter("out_trade_no", $orderid);
    $reqHandler->setParameter("total_fee", $price * 100);
    $reqHandler->setParameter("return_url", $_G['siteurl'] . 'api/trade/notify_invite.php');
    $reqHandler->setParameter("notify_url", $_G['siteurl'] . 'api/trade/notify_invite.php');
    $reqHandler->setParameter("body", $subject);
    $reqHandler->setParameter("bank_type", $bank);
    $reqHandler->setParameter("spbill_create_ip", $_G['clientip']);
    $reqHandler->setParameter("fee_type", "1");
    $reqHandler->setParameter("subject", $subject);
    $reqHandler->setParameter("sign_type", "MD5");
    $reqHandler->setParameter("service_version", "1.0");
    $reqHandler->setParameter("input_charset", "GBK");
    $reqHandler->setParameter("sign_key_index", "1");
    $reqHandler->setParameter("attach", "tenpay");
    $reqHandler->setParameter("time_start", $date);
    $reqHandler->setParameter("trade_mode", "1");
    $reqHandler->setParameter("trans_type", "1");
    $reqHandler->setParameter("agentid", DISCUZ_AGENTID);
    $reqHandler->setParameter("agent_type", "2");
    $reqUrl = $reqHandler->getRequestURL();
    return $reqUrl;
}
开发者ID:softhui,项目名称:discuz,代码行数:37,代码来源:api_tenpay.php

示例11: printerror

    printerror('此充值类型需要 ' . $level_r[$buyr[buygroupid]][groupname] . ' 会员级别以上', '', 1, 0, 1);
}
include 'payfun.php';
$money = $buyr['gmoney'];
if (!$money) {
    printerror('此充值类型金额有误', '', 1, 0, 1);
}
$ddno = '';
$productname = "充值类型:" . $buyr['gname'] . ",UID:" . $user['userid'] . ",UName:" . $user['username'];
$productsay = "用户ID:" . $user['userid'] . ",用户名:" . $user['username'];
esetcookie("payphome", "BuyGroupPay", 0);
esetcookie("paymoneybgid", $id, 0);
//返回地址前缀
$PayReturnUrlQz = $public_r['newsurl'];
if (!stristr($public_r['newsurl'], '://')) {
    $PayReturnUrlQz = eReturnDomain() . $public_r['newsurl'];
}
//编码
if ($ecms_config['sets']['pagechar'] != 'gb2312') {
    @(include_once "../class/doiconv.php");
    $iconv = new Chinese('');
    $char = $ecms_config['sets']['pagechar'] == 'big5' ? 'BIG5' : 'UTF8';
    $targetchar = 'GB2312';
    $productname = $iconv->Convert($char, $targetchar, $productname);
    $productsay = $iconv->Convert($char, $targetchar, $productsay);
    @header('Content-Type: text/html; charset=gb2312');
}
$file = $payr['paytype'] . '/to_pay.php';
@(include $file);
db_close();
$empire = null;
开发者ID:novnan,项目名称:meiju,代码行数:31,代码来源:BuyGroupPay.php

示例12: dirname

$hu = 'eseach';
eval('$__file__=__FILE__;');
define('ROOT_PATH', $__file__ ? dirname($__file__) . '/' : './');
require_once "global.php";
$domain = $_POST['domain'] ? $_POST['domain'] : $_GET['domain'];
if ($domain) {
    is_domain($domain) or exit("<script language=javascript>alert('请输入正确的域名!');location.href='esearch.php';</script>");
    $url = 'http://' . trim($domain);
    $content = @file_get_contents($url);
    $charset = "/charset=(.*)/";
    preg_match($charset, $content, $charsetarr);
    $charset2 = strtolower(substr($charsetarr[1], 0, 2));
    if ($charset2 != 'gb') {
        require_once 'require/chinese.php';
        $chs = new Chinese('utf-8', 'GB2312');
        $content = $chs->Convert($content);
    }
    $pat1 = "/<title>(.*)<\\/title>/si";
    preg_match_all($pat1, $content, $array);
    $pat2 = "/meta content=\"(.+)\" name=\"keywords\"/Ui";
    $pat9 = "/meta name=\"keywords\" content=\"(.+)\"/Ui";
    preg_match_all($pat2, $content, $array2);
    preg_match_all($pat9, $content, $array9);
    $pat3 = "/<meta content=\"(.+)\" name=\"description\"/Usi";
    $pat8 = "/<meta name=\"description\" content=\"(.+)\"/Usi";
    preg_match_all($pat3, $content, $array3);
    preg_match_all($pat8, $content, $array8);
    $bods = "/<body>(.*)<\\/body>/is";
    preg_match_all($bods, $content, $array4);
    $pat4 = "/>(.*)</U";
    preg_match_all($pat4, $array4[0][0], $array5);
开发者ID:repodevs,项目名称:web_admin_tools,代码行数:31,代码来源:esearch.php

示例13: showtype

<?php 
        showtype('video_config', 'top');
        showsetting('video_open', 'settingsnew[open]', $settings['open'], 'radio');
        showtype('video_basic');
        showsetting('video_site_name', 'settingsnew[bbname]', $settings['bbname'], 'text');
        showsetting('video_site_url', 'settingsnew[url]', $settings['url'], 'text');
        showsetting('video_site_email', 'settingsnew[email]', $settings['email'], 'text');
        showsetting('video_site_logo', 'settingsnew[logo]', $settings['logo'], 'text');
        showsetting('video_site_type', '', '', $sitetypeselect);
        showtype('', 'bottom');
        echo '<br /><center><input class="button" type="submit" name="configsubmit" value="' . $lang['submit'] . '"></form>';
    } else {
        if ($charset != 'utf-8') {
            require_once DISCUZ_ROOT . './include/chinese.class.php';
            $chs = new Chinese($charset, 'UTF-8');
            $settingsnew['bbnameu8'] = $chs->Convert($settingsnew['bbname']);
        } else {
            $settingsnew['bbnameu8'] = $settingsnew['bbname'];
        }
        $settingsnew['vtype'] = str_replace("\r\n", "\n", $settingsnew['vtype']);
        $settingsnew['vtype'] = str_replace("\n", "\t", $settingsnew['vtype']);
        if ($settingsnew['vtype']) {
            $sitetypexml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<channels>\n";
            foreach (explode("\t", $settingsnew['vtype']) as $key => $typename) {
                $sitetypexml .= $typename ? "\t<channel id='" . intval($key + 32) . "' name='" . ($charset != 'utf-8' ? $chs->Convert(htmlspecialchars($typename)) : $typename) . "' />\n" : '';
            }
            $sitetypexml .= "</channels>";
            if ($fp = @fopen(DISCUZ_ROOT . './forumdata/video_category.xml', 'wb')) {
                fwrite($fp, $sitetypexml);
                fclose($fp);
            }
开发者ID:BGCX262,项目名称:zyyhong-svn-to-git,代码行数:31,代码来源:video.inc.php

示例14: ttffont

 function ttffont()
 {
     $seccode = $this->code;
     $charset = isset($GLOBALS['charset']) ? $GLOBALS['charset'] : '';
     $seccoderoot = $this->type ? $this->fontpath . 'ch/' : $this->fontpath . 'en/';
     $dirs = opendir($seccoderoot);
     $seccodettf = array();
     while ($entry = readdir($dirs)) {
         if ($entry != '.' && $entry != '..' && in_array(strtolower($this->fileext($entry)), array('ttf', 'ttc'))) {
             $seccodettf[] = $entry;
         }
     }
     if (empty($seccodettf)) {
         $this->giffont();
         return;
     }
     $seccodelength = 4;
     if ($this->type && !empty($seccodettf)) {
         if (strtoupper($charset) != 'UTF-8') {
             include $this->includepath . 'chinese.class.php';
             $cvt = new Chinese($charset, 'utf8');
             $seccode = $cvt->Convert($seccode);
         }
         $seccode = array(substr($seccode, 0, 3), substr($seccode, 3, 3));
         $seccodelength = 2;
     }
     $widthtotal = 0;
     for ($i = 0; $i < $seccodelength; $i++) {
         $font[$i]['font'] = $seccoderoot . $seccodettf[array_rand($seccodettf)];
         $font[$i]['angle'] = $this->angle ? mt_rand(-30, 30) : 0;
         $font[$i]['size'] = $this->type ? $this->width / 7 : $this->width / 6;
         $this->size && ($font[$i]['size'] = mt_rand($font[$i]['size'] - $this->width / 40, $font[$i]['size'] + $this->width / 20));
         $box = imagettfbbox($font[$i]['size'], 0, $font[$i]['font'], $seccode[$i]);
         $font[$i]['zheight'] = max($box[1], $box[3]) - min($box[5], $box[7]);
         $box = imagettfbbox($font[$i]['size'], $font[$i]['angle'], $font[$i]['font'], $seccode[$i]);
         $font[$i]['height'] = max($box[1], $box[3]) - min($box[5], $box[7]);
         $font[$i]['hd'] = $font[$i]['height'] - $font[$i]['zheight'];
         $font[$i]['width'] = max($box[2], $box[4]) - min($box[0], $box[6]) + mt_rand(0, $this->width / 8);
         $font[$i]['width'] = $font[$i]['width'] > $this->width / $seccodelength ? $this->width / $seccodelength : $font[$i]['width'];
         $widthtotal += $font[$i]['width'];
     }
     $x = mt_rand($font[0]['angle'] > 0 ? cos(deg2rad(90 - $font[0]['angle'])) * $font[0]['zheight'] : 1, $this->width - $widthtotal);
     !$this->color && ($text_color = imagecolorallocate($this->im, $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]));
     for ($i = 0; $i < $seccodelength; $i++) {
         if ($this->color) {
             $this->fontcolor = array(mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
             $this->shadow && ($text_shadowcolor = imagecolorallocate($this->im, 255 - $this->fontcolor[0], 255 - $this->fontcolor[1], 255 - $this->fontcolor[2]));
             $text_color = imagecolorallocate($this->im, $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]);
         } elseif ($this->shadow) {
             $text_shadowcolor = imagecolorallocate($this->im, 255 - $this->fontcolor[0], 255 - $this->fontcolor[1], 255 - $this->fontcolor[2]);
         }
         $y = $font[0]['angle'] > 0 ? mt_rand($font[$i]['height'], $this->height) : mt_rand($font[$i]['height'] - $font[$i]['hd'], $this->height - $font[$i]['hd']);
         $this->shadow && imagettftext($this->im, $font[$i]['size'], $font[$i]['angle'], $x + 1, $y + 1, $text_shadowcolor, $font[$i]['font'], $seccode[$i]);
         imagettftext($this->im, $font[$i]['size'], $font[$i]['angle'], $x, $y, $text_color, $font[$i]['font'], $seccode[$i]);
         $x += $font[$i]['width'];
     }
 }
开发者ID:samyex6,项目名称:discuz3.2-lite,代码行数:57,代码来源:seccode.class.php

示例15: convertCode

 /**
  * 进行编码转换,这里主要用于繁体转简体
  * @param $fcode 即from code ,原来的编码,比如"BIG5"
  * @param $tcode 即to code,目标编码,比如"GB2312"
  * @param $content 对已经处理过的文本进行转换
  * @param $dict_dir 转换字符对照表存放位置
  * @return $ret string 返回转换后的文本
  */
 function convertCode($content, $fcode = 'CHST', $tcode = 'CHSS', $dict_dir = null)
 {
     if (is_null($dict_dir)) {
         $dict_dir = $this->dict_dir;
     }
     L::loadClass('Chinese', 'utility/lang', false);
     $ch = new Chinese($fcode, $tcode, true);
     $ret = $ch->Convert($content);
     return $ret;
 }
开发者ID:sherlockhouse,项目名称:aliyun,代码行数:18,代码来源:filterutil.class.php


注:本文中的Chinese::Convert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。