本文整理汇总了PHP中auto_charset函数的典型用法代码示例。如果您正苦于以下问题:PHP auto_charset函数的具体用法?PHP auto_charset怎么用?PHP auto_charset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了auto_charset函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: proxy
public function proxy()
{
$city = t($_REQUEST['city']);
$data = file_get_contents('http://php.weather.sina.com.cn/iframe/index/w_cl.php?day=2&code=js&cbf=show&city=' . $city);
$data = auto_charset($data, 'gb2312', 'utf8');
echo $data;
}
示例2: auto_charset
function auto_charset(&$fContents, $from = 'gbk', $to = 'utf-8')
{
$from = strtoupper($from) == 'UTF8' ? 'utf-8' : $from;
$to = strtoupper($to) == 'UTF8' ? 'utf-8' : $to;
if (strtoupper($from) === strtoupper($to) || empty($fContents) || is_scalar($fContents) && !is_string($fContents)) {
//如果编码相同或者非字符串标量则不转换
return $fContents;
}
if (is_string($fContents)) {
if (function_exists('mb_convert_encoding')) {
return mb_convert_encoding($fContents, $to, $from);
} elseif (function_exists('iconv')) {
return iconv($from, $to, $fContents);
} else {
return $fContents;
}
} elseif (is_array($fContents)) {
foreach ($fContents as $key => $val) {
$_key = auto_charset($key, $from, $to);
$fContents[$_key] = auto_charset($val, $from, $to);
if ($key != $_key) {
unset($fContents[$key]);
}
}
return $fContents;
} else {
return $fContents;
}
}
示例3: validateUser
public function validateUser()
{
$retcode = "200";
$arr_message = array("result" => "fail", "message" => "操作出现异常,请稍后再试!");
$db = new DB_test();
$phonenumber = trim($this->arr_body['phonenumber']);
$query = "SELECT fd_author_id FROM tb_author WHERE fd_author_username = '" . $phonenumber . "'";
$authorid = $db->get_all($query);
if ($authorid != 0 && count($authorid) > 0) {
$authorid = $authorid[0]["fd_author_id"];
$query = "SELECT Q.fd_question_contect AS que, A.fd_answer AS answer \n\t\t\t\t\tFROM tb_safeguard_secque_useranswer AS A \n\t\t\t\t\tINNER JOIN tb_safeguard_secque AS Q ON A.fd_question_id = Q.fd_question_id \n\t\t\t\t\tWHERE A.fd_author_id = " . $authorid;
$db->query($query);
$retcode = "0";
if ($db->nf() > 0) {
$arr_msg = auto_charset($db->getData('', 'msgbody'), 'gbk', 'utf-8');
$arr_msg['msgbody']['authorid'] = $authorid;
$arr_message = array("result" => "success", "message" => "成功获取密保问题");
} else {
$retcode = "200";
$arr_message = array("result" => "failure", "message" => "您还未设置过密保问题");
}
} else {
$retcode = "200";
$arr_message = array("result" => "failure", "message" => "该手机号还未注册过通付宝账号");
}
$arr_msg['msgbody']['result'] = $arr_message['result'];
$arr_msg['msgbody']['message'] = $arr_message['message'];
$returnvalue = array("msgbody" => $arr_msg['msgbody']);
$returnval = TfbxmlResponse::ResponsetoApp($retcode, $returnvalue);
return $returnval;
}
示例4: readKuaiDicmpList
public function readKuaiDicmpList()
{
$db = new DB_test();
$arr_header = $this->arr_header;
$arr_body = $this->arr_body;
$arr_channelinfo = $this->arr_channelinfo;
$apptype = trim($arr_body['apptype']);
$appversion = trim($arr_body['appversion']);
$query = "select fd_kdcompany_id as comid,fd_kdcompany_no as com,fd_kdcompany_name as comname\n\t\t ,fd_kdcompany_api as apitype,fd_kdcompany_pic as comlogo ,fd_kdcompany_phone as comphone from \n\t tb_kdcompany where fd_kdcompany_active = '1' order by fd_kdcompany_api desc";
//只显示激活的列表
$db->query($query);
$arr_msg = auto_charset($db->getData('', 'msgbody'), 'gbk', 'utf-8');
if (!$arr_msg) {
$arr_message = array("result" => "failure", "message" => "列表为空!");
$retcode = "200";
//反馈状态 0 成功 200 自定义错误
} else {
$arr_message = array("result" => "success", "message" => "读取成功!");
$retcode = "0";
//反馈状态 0 成功 200 自定义错误
}
$arr_msg['msgbody']['result'] = $arr_message['result'];
$arr_msg['msgbody']['message'] = $arr_message['message'];
$returnvalue = array("msgbody" => $arr_msg['msgbody']);
$returnval = TfbxmlResponse::ResponsetoApp($retcode, $returnvalue);
return $returnval;
}
示例5: getAllExpression
public function getAllExpression($flush = false)
{
$cache_id = '_model_expression';
if (($res = F($cache_id)) === false || $flush === true) {
global $ts;
$pkg = $ts['site']['expression'];
$filepath = SITE_PATH . '/public/themes/' . $ts['site']['site_theme'] . '/images/expression/' . $pkg;
require_once ADDON_PATH . '/libs/Io/Dir.class.php';
$expression = new Dir($filepath);
$expression_pkg = $expression->toArray();
$res = array();
foreach ($expression_pkg as $value) {
if (!is_utf8($value['filename'])) {
$value['filename'] = auto_charset($value['filename'], 'GBK', 'UTF8');
}
list($file) = explode(".", $value['filename']);
$temp['title'] = $file;
$temp['emotion'] = '[' . $file . ']';
$temp['filename'] = $value['filename'];
$temp['type'] = $pkg;
$res[$temp['emotion']] = $temp;
}
F($cache_id, $res);
}
return $res;
}
示例6: lists
private function lists($order = '')
{
if (empty($order)) {
$order = 'id desc';
}
$status = $this->input->get('status') === false ? '1' : $this->input->get('status');
$count = $this->db->order_by($order)->where('status', $status)->get($this->table);
$count = $count->result_array();
if (count($count) > 0) {
//分页 1.load 分页类,2.加载分页配置,
$this->load->library('pagination');
$this->config->load('pagination');
$pageconfig = $this->config->item('pagination');
$pageconfig['total_rows'] = count($count);
$pageconfig['base_url'] = site_url('user/index');
if (count($count) < $pageconfig['per_page']) {
auto_charset($count);
return array('lists' => $count);
}
$offset = $pageconfig['per_page'] * ($this->uri->segment(3, 1) - 1);
//return resource object
$query = $this->db->_execute("select * from as_" . $this->table . "order by " . $order);
$lists = $this->db->limit_access($query, $offset, $pageconfig['per_page']);
$pages = $this->paged($pageconfig);
$lists = auto_charset($lists);
$r = array('lists' => $lists, 'pages' => $pages);
return $r;
} else {
return null;
}
}
示例7: readHelpList
public function readHelpList()
{
$db = new DB_test();
$arr_header = $this->arr_header;
$arr_body = $this->arr_body;
$arr_channelinfo = $this->arr_channelinfo;
$msgstart = $arr_body['msgstart'] + 0;
$msgdisplay = $arr_body['msgdisplay'] + 0;
if ($msgstart < 0) {
$msgstart = 0;
}
$query = "select 1 from web_help order by fd_help_no ";
$db->query($query);
$msgallcount = $db->nf();
$query = "select fd_help_id as helpid ,fd_help_name as helpname,fd_help_contect as helpcontent,\n\t fd_help_date as helpdate from web_help order by fd_help_no limit {$msgstart}, {$msgdisplay} ";
$db->query($query);
$msgdiscount = $db->nf();
$arr_msg = auto_charset($db->getData('', 'msgbody'), 'gbk', 'utf-8');
$arr_message = array("result" => "success", "message" => "读取成功!");
$retcode = "0";
//反馈状态 0 成功 200 自定义错误
$arr_msg['msgbody']['msgallcount'] = $msgallcount;
$arr_msg['msgbody']['msgdiscount'] = $msgdiscount + $msgstart;
$arr_msg['msgbody']['result'] = $arr_message['result'];
$arr_msg['msgbody']['message'] = $arr_message['message'];
$returnvalue = array("msgbody" => $arr_msg['msgbody']);
$returnval = TfbxmlResponse::ResponsetoApp($retcode, $returnvalue);
return $returnval;
}
示例8: analyseContent
public function analyseContent($file_contents, $key = '', &$errMsg, &$retCode)
{
$logger = Logger::getLogger('Ofpay');
$logger->debug("开始解析欧飞返回的数据(" . $file_contents . ")");
$file_contents = auto_charset($file_contents, 'gbk', 'utf-8');
$file_contents = str_replace("gb2312", "utf-8", $file_contents);
$file_contents = str_replace("GB2312", "utf-8", $file_contents);
$file_contents = simplexml_load_string($file_contents);
$logger->debug("开始把数据解析成xml格式:" . $key);
foreach ($file_contents->children() as $item) {
switch ($item->getName()) {
case "err_msg":
$errMsg = (string) $item;
break;
case "retcode":
$retCode = (int) $item;
break;
case $key:
return $item;
default:
$msgBody = $item;
}
}
return $msgBody;
}
示例9: toDate
function toDate($time, $format = 'Y年m月d日 H:i:s')
{
if (empty($time)) {
return '';
}
$format = str_replace('#', ':', $format);
return date(auto_charset($format), $time);
}
示例10: edit
function edit($id)
{
$this->db->where('id', intval($id));
$result = $this->db->get('comments')->result_array();
$result = array_shift($result);
auto_charset($result);
$this->data['form'] = $result;
Displayview::display('comment/edit.html', $this->data);
}
示例11: view
function view($type, $id)
{
//内容类型
$this->type = $this->types[$type];
$query = $this->db->where('id', intval($id))->get('contents');
$data = auto_charset($query->row_array());
//views
$this->data['head'] = $this->parser->parse('home/head-page', $this->pagedata, true);
$this->data['header'] = $this->parser->parse('home/header.html', $this->pagedata, true);
$this->data['footer'] = $this->parser->parse('home/footer.html', $this->pagedata, true);
$this->data['content'] = $data;
$this->parser->parse($this->type['tpl'], $this->data);
}
示例12: Delete
function Delete()
{
$id = $_REQUEST['id'];
$map['id'] = array('in', $id);
if ($list = $this->dao->where($map)->findall()) {
$img = auto_charset($list['imgurl'], 'utf-8', 'gbk');
if (file_exists($img)) {
unlink($img);
}
$this->dao->where($map)->delete();
}
$this->success("删除成功!");
}
示例13: getStatus
function getStatus($status, $imageShow = true)
{
switch ($status) {
case 0:
$showText = '未处理';
$showImg = '<IMG SRC="' . APP_PUBLIC_URL . '/Images/state0.bmp" BORDER="0" ALT="未处理">';
break;
case 1:
default:
$showText = '已处理';
$showImg = '<IMG SRC="' . APP_PUBLIC_URL . '/Images/state1.bmp" BORDER="0" ALT="已处理">';
}
return $imageShow === true ? auto_charset($showImg) : $showText;
}
示例14: CreateOrder
public function CreateOrder($msgBody, $authorId, $payType)
{
$now = time();
$logger = Logger::getLogger('mobilerecharge');
$logger->debug("开始创建手机充值订单({$now})");
$arrPayCard = GetPayCalcuInfo::readpaycardid($msgBody['paycardid'], $authorId);
// ******
$logger->debug("正在创建手机充值订单({$now}) : paycardid(" . $msgBody['paycardid'] . "),authorId({$authorId} ),arrPayCard(" . print_r($arrPayCard, true) . ")");
$payCardId = $arrPayCard['paycardid'];
// 刷卡器ID
$cusId = $arrPayCard['cusid'];
// 代理商ID
$payfee = 0;
// 利润 = 用户支付给通付宝的钱 - 通付宝从向上的进货价- 支付通道的费率
$query = "SELECT (fd_recham_paymoney - fd_recham_costmoney) AS payfee \n\t\t\t\tFROM tb_mobilerechamoney WHERE fd_recham_money = '" . $msgBody['rechargeMoney'] . "'";
$db = new DB_test();
$dataInDB = $db->get_all($query);
if (is_array($dataInDB) && count($dataInDB) == 1) {
$payfee = $dataInDB[0]['payfee'];
$logger->debug("正在创建手机充值订单({$now}) : 用户支付给通付宝的钱 - 通付宝从向上的进货价 = ({$payfee})");
} else {
$logger->error("正在创建手机充值订单({$now}) : 无法获取面额" . $msgBody['rechargeMoney'] . "元所对应的利润值");
}
$payTypeFee = 0;
// 转账费率
switch ($payType) {
case "YiBao":
$payTypeFee = YiBaoPay::GetPayFee($msgBody['payMoney']);
break;
case "upmp":
$payTypeFee = BankPayInfoV3::GetPayFee($msgBody['payMoney']);
break;
}
// ********
$cusfeeResult = getcusfenrun::get_cusfenrun($cusId, "mobilerecharge", $msgBody['payMoney'], 0, $payfee, 0, date("Y-m-d"), null, null);
//$cusfeeResult = getcusfenrun :: get_cusfenrun($cusId, "mobilerecharge", $msgBody['payMoney'], $payTypeFee, $payfee, 0, date("Y-m-d"), null, null);
$logger->debug("正在创建手机充值订单({$now}) : cusId({$cusId} ),cusfeeResult(" . print_r($cusfeeResult, true) . ")");
$cusfee = $cusfeeResult["cusfee"];
$cusfee = $cusfee > 0 ? $cusfee : 0;
$logger->debug("正在创建手机充值订单({$now}) : 通付宝的利润({$payfee}), 代理商的利润({$cusfee})");
$orderNumber = "tfbmrc" . date("YmdHiss") . mt_rand(1000, 9999);
// 创建通付宝订单号
$listno = makeorderno("mobilerechargelist", "mrclist", "mrc");
// ******
$sql = "INSERT INTO tb_mobilerechargelist(fd_mrclist_no, fd_mrclist_paycardid, fd_mrclist_cusid, \n\t\t\t\tfd_mrclist_cusfee, fd_mrclist_authorid, fd_mrclist_paydate, \n\t\t\t\tfd_mrclist_bkordernumber, fd_mrclist_sdcrid, fd_mrclist_payrq, fd_mrclist_paytypeid, \n\t\t\t\tfd_mrclist_paytype, fd_mrclist_rechamoney, fd_mrclist_bkmoney, fd_mrclist_rechaphone, \n\t\t\t\tfd_mrclist_paymoney, fd_mrclist_payfee, fd_mrclist_mobileprov, fd_mrclist_bankcardno, \n\t\t\t\tfd_mrclist_state, fd_mrclist_date, fd_mrclist_datetime) VALUES \n\t\t\t\t('{$listno}', '{$payCardId}', '{$cusId}', \n\t\t\t\t'{$cusfee}', '{$authorId}', NOW(), \n\t\t\t\t'{$orderNumber}', 3, '01', '1', \n\t\t\t\t'mobilerecharge', '" . $msgBody['rechargeMoney'] . "', '" . $msgBody['payMoney'] . "', '" . $msgBody['rechargePhone'] . "', \n\t\t\t\t'" . $msgBody['payMoney'] . "', '{$payfee}', '" . $msgBody['mobileProvince'] . "', '" . $msgBody['bankCardId'] . "', \n\t\t\t\t'0', NOW(), NOW());";
$logger->debug("正在创建手机充值订单({$now}) : ({$sql})");
$sql = auto_charset($sql, 'utf-8', 'gbk');
$db->query($sql);
return $orderNumber;
}
示例15: getStatus
function getStatus($status, $imageShow = true)
{
switch ($status) {
case 0:
$showText = '禁用';
$showImg = '<IMG SRC="../Public/images/locked.gif" WIDTH="20" HEIGHT="20" BORDER="0" ALT="禁用">';
break;
case 1:
default:
$showText = '正常';
$showImg = '<IMG SRC="../Public/images/ok.gif" WIDTH="20" HEIGHT="20" BORDER="0" ALT="正常">';
}
return $imageShow === true ? auto_charset($showImg) : $showText;
}