qc.ifish7.com/Application/Home/Common/function.php

94 lines
2.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
//获取地区中文
function get_region_name($arr,$str="-"){
if($arr){
$return_str="";
foreach($arr as $id){
$name=M("region")->where(array("id"=>$id))->getField("name");
if($name){
$return_str.="-".$name;
}
}
}
return trim($return_str,"-");
}
//USD TO RMB
function USD_RMB($usd){
$rmb=$usd*C("display.USD_RMB");
return $rmb;
}
//RMB TO USD 10000
function RMB_USD($rmb){
$rmb=intval($rmb);
$usd=$rmb*10000/C("display.USD_RMB");
return $usd;
}
function add_on($value,$common){
if($value==$common){return 'on';}
}
//转换标签
function tran_tag($tag){
$tag=trim($tag,"|");
$tag=explode("|",$tag);
if($tag){
$return_str="";
foreach($tag as $val){
$return_str.="<a>".$val."</a>";
}
}
return $return_str;
}
//修改url参数用于筛选中的
function update_url($arr){
C("URL_MODEL", 0); //强制使用默认url模板因为筛选中有中文url中文不支持
$get=$_GET;
$get["p"]="";//删除分页参数
foreach($arr as $key=>$val){
$get[$key]=$val;
}
$url=U("",$get);
C("URL_MODEL",1); //强制使用默认url模板因为筛选中有中文url中文不支持
echo $url;
}
//adid函数用于反回单张广告中的某一个字段
function adid($adid,$field='thumb'){
$data=M("ad_cat")->find($adid);
return $data[$field];
}
//替换url参数一般用于筛选里
function reurl($field,$value="",$url=''){
if(!$url){
//如果是生成静态页面的话url是当前栏目的url
if(I("get.isSystemMakeHtml")){
$url=U("List/index",array("catid"=>I("catid")));
}else{
$url=$_SERVER["REQUEST_URI"];
}
}
//获取url query参数部
$urlarr=parse_url($url);
//将类似于:?a=1&b=2&c=3 参数转出成数组
parse_str($urlarr['query'],$arr);
//参数替换(如果$value为假则消除这个参数
if($value===""){//注意这里一定要是恒等于防止0和''混淆
unset($arr[$field]);
}else{
$arr[$field]=$value;
}
$reurl=$urlarr['path']."?".http_build_query($arr);
$reurl=trim($reurl,"?");
return $reurl;
}
//查看指定栏目是否为当前栏目的父栏目id里
function isParent($parent_id,$self_id=0){
$catid=$self_id?$self_id:$_GET[catid];
//如果是当前栏目的话也返回true
if($parent_id==$catid){
return true;
}
return strstr($GLOBALS[cat][$catid][parent_catids],"|".$parent_id."|");
}
function abc(){
return "diy fun";
}