【PHP】汉字转拼音通用版

Continue Read..
<?php 
class PY{
/**
*@param $_String 汉字
* @param $_Code 编码方式,默认gb2312,设置为其他任意字符则为utf8编码
* 试用方法   Pinyin('如果是UTF8第二个参数随便写',1);
*/
	static public function Pinyin($_String, $_Code='gb2312') {
	    $_DataKey =
				"a|ai|an|ang|ao|ba|bai|ban|bang|bao|bei|ben|beng|bi|bian|biao|bie|bin|bing|bo|bu|ca|cai|can|cang|cao|ce|ceng|cha".
	            "|chai|chan|chang|chao|che|chen|cheng|chi|chong|chou|chu|chuai|chuan|chuang|chui|chun|chuo|ci|cong|cou|cu|".
	            "cuan|cui|cun|cuo|da|dai|dan|dang|dao|de|deng|di|dian|diao|die|ding|diu|dong|dou|du|duan|dui|dun|duo|e|en|er".
	            "|fa|fan|fang|fei|fen|feng|fo|fou|fu|ga|gai|gan|gang|gao|ge|gei|gen|geng|gong|gou|gu|gua|guai|guan|guang|gui".
	            "|gun|guo|ha|hai|han|hang|hao|he|hei|hen|heng|hong|hou|hu|hua|huai|huan|huang|hui|hun|huo|ji|jia|jian|jiang".
	            "|jiao|jie|jin|jing|jiong|jiu|ju|juan|jue|jun|ka|kai|kan|kang|kao|ke|ken|keng|kong|kou|ku|kua|kuai|kuan|kuang".
	            "|kui|kun|kuo|la|lai|lan|lang|lao|le|lei|leng|li|lia|lian|liang|liao|lie|lin|ling|liu|long|lou|lu|lv|luan|lue|lun|luo|ma|mai".
	            "|man|mang|mao|me|mei|men|meng|mi|mian|miao|mie|min|ming|miu|mo|mou|mu|na|nai|nan|nang|nao|ne".
	            "|nei|nen|neng|ni|nian|niang|niao|nie|nin|ning|niu|nong|nu|nv|nuan|nue|nuo|o|ou|pa|pai|pan|pang|pao|pei|pen".
	            "|peng|pi|pian|piao|pie|pin|ping|po|pu|qi|qia|qian|qiang|qiao|qie|qin|qing|qiong|qiu|qu|quan|que|qun|ran|rang".
	            "|rao|re|ren|reng|ri|rong|rou|ru|ruan|rui|run|ruo|sa|sai|san|sang|sao|se|sen|seng|sha|shai|shan|shang|shao|".
	            "she|shen|sheng|shi|shou|shu|shua|shuai|shuan|shuang|shui|shun|shuo|si|song|sou|su|suan|sui|sun|suo|ta|tai|".
	            "tan|tang|tao|te|teng|ti|tian|tiao|tie|ting|tong|tou|tu|tuan|tui|tun|tuo|wa|wai|wan|wang|wei|wen|weng|wo|wu".
	            "|xi|xia|xian|xiang|xiao|xie|xin|xing|xiong|xiu|xu|xuan|xue|xun|ya|yan|yang|yao|ye|yi|yin|ying|yo|yong|you".
	            "|yu|yuan|yue|yun|za|zai|zan|zang|zao|ze|zei|zen|zeng|zha|zhai|zhan|zhang|zhao|zhe|zhen|zheng|zhi|zhong|".
	            "zhou|zhu|zhua|zhuai|zhuan|zhuang|zhui|zhun|zhuo|zi|zong|zou|zu|zuan|zui|zun|zuo";
	
	    $_DataValue =
				"-20319|-20317|-20304|-20295|-20292|-20283|-20265|-20257|-20242|-20230|-20051|-20036|-20032|-20026|-20002|-19990".
	            "|-19986|-19982|-19976|-19805|-19784|-19775|-19774|-19763|-19756|-19751|-19746|-19741|-19739|-19728|-19725".
	            "|-19715|-19540|-19531|-19525|-19515|-19500|-19484|-19479|-19467|-19289|-19288|-19281|-19275|-19270|-19263".
	            "|-19261|-19249|-19243|-19242|-19238|-19235|-19227|-19224|-19218|-19212|-19038|-19023|-19018|-19006|-19003".
	            "|-18996|-18977|-18961|-18952|-18783|-18774|-18773|-18763|-18756|-18741|-18735|-18731|-18722|-18710|-18697".
	            "|-18696|-18526|-18518|-18501|-18490|-18478|-18463|-18448|-18447|-18446|-18239|-18237|-18231|-18220|-18211".
	            "|-18201|-18184|-18183|-18181|-18012|-17997|-17988|-17970|-17964|-17961|-17950|-17947|-17931|-17928|-17922".
	            "|-17759|-17752|-17733|-17730|-17721|-17703|-17701|-17697|-17692|-17683|-17676|-17496|-17487|-17482|-17468".
	            "|-17454|-17433|-17427|-17417|-17202|-17185|-16983|-16970|-16942|-16915|-16733|-16708|-16706|-16689|-16664".
	            "|-16657|-16647|-16474|-16470|-16465|-16459|-16452|-16448|-16433|-16429|-16427|-16423|-16419|-16412|-16407".
	            "|-16403|-16401|-16393|-16220|-16216|-16212|-16205|-16202|-16187|-16180|-16171|-16169|-16158|-16155|-15959".
	            "|-15958|-15944|-15933|-15920|-15915|-15903|-15889|-15878|-15707|-15701|-15681|-15667|-15661|-15659|-15652".
	            "|-15640|-15631|-15625|-15454|-15448|-15436|-15435|-15419|-15416|-15408|-15394|-15385|-15377|-15375|-15369".
	            "|-15363|-15362|-15183|-15180|-15165|-15158|-15153|-15150|-15149|-15144|-15143|-15141|-15140|-15139|-15128".
	            "|-15121|-15119|-15117|-15110|-15109|-14941|-14937|-14933|-14930|-14929|-14928|-14926|-14922|-14921|-14914".
	            "|-14908|-14902|-14894|-14889|-14882|-14873|-14871|-14857|-14678|-14674|-14670|-14668|-14663|-14654|-14645".
	            "|-14630|-14594|-14429|-14407|-14399|-14384|-14379|-14368|-14355|-14353|-14345|-14170|-14159|-14151|-14149".
	            "|-14145|-14140|-14137|-14135|-14125|-14123|-14122|-14112|-14109|-14099|-14097|-14094|-14092|-14090|-14087".
	            "|-14083|-13917|-13914|-13910|-13907|-13906|-13905|-13896|-13894|-13878|-13870|-13859|-13847|-13831|-13658".
	            "|-13611|-13601|-13406|-13404|-13400|-13398|-13395|-13391|-13387|-13383|-13367|-13359|-13356|-13343|-13340".
	            "|-13329|-13326|-13318|-13147|-13138|-13120|-13107|-13096|-13095|-13091|-13076|-13068|-13063|-13060|-12888".
	            "|-12875|-12871|-12860|-12858|-12852|-12849|-12838|-12831|-12829|-12812|-12802|-12607|-12597|-12594|-12585".
	            "|-12556|-12359|-12346|-12320|-12300|-12120|-12099|-12089|-12074|-12067|-12058|-12039|-11867|-11861|-11847".
	            "|-11831|-11798|-11781|-11604|-11589|-11536|-11358|-11340|-11339|-11324|-11303|-11097|-11077|-11067|-11055".
	            "|-11052|-11045|-11041|-11038|-11024|-11020|-11019|-11018|-11014|-10838|-10832|-10815|-10800|-10790|-10780".
	            "|-10764|-10587|-10544|-10533|-10519|-10331|-10329|-10328|-10322|-10315|-10309|-10307|-10296|-10281|-10274".
	            "|-10270|-10262|-10260|-10256|-10254";
	    $_TDataKey = explode('|', $_DataKey);
	    $_TDataValue = explode('|', $_DataValue);
	    //array_combine:创建一个数组,用一个数组的值作为其键名,另一个数组的值作为其值
	    //PHP_VERSION:表示PHP的版本
	    $_Data = (PHP_VERSION>='5.0') ? array_combine($_TDataKey, $_TDataValue) : PY::_Array_Combine($_TDataKey, $_TDataValue);
	    //arsort:对数组进行逆向排序并保持索引关系
	    //reset:将数组的内部指针指向第一个单元
	    arsort($_Data);
	    reset($_Data);
	
	    /**
	     *    假如编码不是gb2312,则启用utf-8
	     */
	dump($_String);
	    if($_Code != 'gb2312') $_String = PY::_U2_Utf8_Gb($_String);
	    $_Res = '';
	    for($i=0; $i<strlen($_String); $i++) {
	        $_P = ord(substr($_String, $i, 1));
	        /**
	         *
	         */
	        if($_P>160) {
	            $_Q = ord(substr($_String, ++$i, 1));
	            $_P = $_P*256 + $_Q -65536;
	        }
	        $_Res .= PY::_Pinyin($_P, $_Data);
	    }
	    return preg_replace("/[^a-z0-9]*/", '', $_Res);
	}
	
	static public function _Pinyin($_Num, $_Data) {
	    if($_Num>0 && $_Num<160 )
	        return chr($_Num);
	    elseif($_Num<-20319 || $_Num>-10247)
	        return '';
	    else {
	        foreach($_Data as $k=>$v) {
	            if($v<=$_Num)
	                break;
	        }
	        return $k;
	    }
	}
	
	static public function _U2_Utf8_Gb($_C){  
		$_String .= '';
		if($_C < 0x80){
			$_String .= $_C;
		}elseif($_C < 0x800){
			$_String .= chr(0xC0 | $_C>>6);
			$_String .= chr(0x80 | $_C & 0x3F);
		}elseif($_C < 0x10000){
			$_String .= chr(0xE0 | $_C>>12);
			$_String .= chr(0x80 | $_C>>6 & 0x3F);
			$_String .= chr(0x80 | $_C & 0x3F);
		} elseif($_C < 0x200000) {
			$_String .= chr(0xF0 | $_C>>18);
			$_String .= chr(0x80 | $_C>>12 & 0x3F);
			$_String .= chr(0x80 | $_C>>6 & 0x3F);
			$_String .= chr(0x80 | $_C & 0x3F);
		}
		return iconv('UTF-8', 'GB2312', $_String);
	}  
	 
	
	/**
	 * 等价PHP5版本的array_combine函数
	 */
	static public function _Array_Combine($_Arr1, $_Arr2) {
	    for($i=0; $i<count($_Arr1); $i++) $_Res[$_Arr1[$i]] = $_Arr2[$i];
	    return $_Res;
	}
}

?>
 
 
 
 
//按拼音排序
function array_sort($arr,$keys,$type='asc'){ 
    $keysvalue = $new_array = array();
    foreach ($arr as $k=>$v){
        $keysvalue[$k] = $v[$keys];
    }
    if($type == 'asc'){
        asort($keysvalue);
    }else{
        arsort($keysvalue);
    }
    reset($keysvalue);
    foreach ($keysvalue as $k=>$v){
        $new_array[$k] = $arr[$k];
    }
    return $new_array; 
}

【CSS】文本框默认文字

Continue Read..
<span >姓名:</span><input type="text" name="name" id="name" placeholder="请填写姓名"  class="input-medium search-query" />

声明:此文系舞林cuznwww.wulinlw.org)原创稿件,转载请保留版权

多条数据的IList<OperationScheme>存储,提示框方法

Continue Read..
IList<OperationSchemeDetail> oss = new List<OperationSchemeDetail>();
        string[] ConsumerGoodsName = Request.Params.GetValues("ConsumerGoodsName");
        string[] ConsumerGoodsNo = Request.Params.GetValues("ConsumerGoodsNo");
        string[] spec = Request.Params.GetValues("spec");
        string[] quantity = Request.Params.GetValues("quantity");
        string[] unit = Request.Params.GetValues("unit");
        if (quantity != null)
        {
            for (int i = 0; i < quantity.Length; i++)
            {
                if (quantity[i] == "")
                    continue;
                OperationSchemeDetail osDetail = new OperationSchemeDetail();
                osDetail.ConsumerGoodsNo = ConsumerGoodsNo[i];
                osDetail.spec = spec[i];
                osDetail.unit = unit[i];
                osDetail.quantity = Convert.ToInt32(quantity[i]);
                osDetail.SchemeID = schemeID;
                osDetail.item = Convert.ToInt32(i + 1);
                oss.Add(osDetail);
            }
        }

        if (oss.Count == 0) 
        {
            SupplyWebApp.Common.MessageBox.Show(this.Page, "至少需要填写一条记录!");
            return;
        }
        
        //更新手术方案
        if (osMgr.EditSave(os, oss, Convert.ToInt32(ViewState["rows"])))
        {
            SupplyWebApp.Common.MessageBox.ShowAndRedirect(this.Page, "保存成功!", "OperationSchemeMgr.aspx");
        }

声明:此文系舞林cuznwww.wulinlw.org)原创稿件,转载请保留版权

页面里嵌套iframe时带参数的url写法

Continue Read..

重点把 & 改为 %26

 

http://192.168.1.207:20060/Reports/Print.aspx?url=printpages/SectionPrint.aspx?supplyid=0&purchaseNo=PU000000005&timestr=1

 

http://192.168.1.207:20060/Reports/Print.aspx?url=printpages/SectionPrint.aspx?supplyid=0%26purchaseNo=PU000000005%26timestr=1

声明:此文系舞林cuznwww.wulinlw.org)原创稿件,转载请保留版权

设置IE浏览器中iframe边框方法

Continue Read..

在做页面嵌套iframe的时候,在ie下发现总有黑边(只在上,左两侧)

注意:border:none;不管用          给iframe添加一个 frameborder="0" 属性就好了  ie下的缓存很烦人,记得清除一下缓存再看结果哦

 

把:<iframe src="<%=url %>" class="iframecon" allowTransparency="true" id="ifr" name="ifr" onload="javascript:showprintbtn();" style="border:none;width:842px;height:595px;overflow:hidden;"></iframe>

 改为以下:

<iframe src="<%=url %>" class="iframecon" allowTransparency="true" id="ifr" name="ifr" frameborder="0" onload="javascript:showprintbtn();" style="width:842px;height:595px;overflow:hidden;"></iframe>

声明:此文系舞林cuznwww.wulinlw.org)原创稿件,转载请保留版权

文本的样式设置

Continue Read..
系统颜色:
 zhufuRelText.ForeColor = Color.Red;
 zhufuRelText.Text="此柜已经是辅柜,不能再设置其下的辅柜";

自定义颜色:
 Lsavemsg.ForeColor = ColorTranslator.FromHtml("#3979c7");
 Lsavemsg.Text = "修改成功!!";

声明:此文系舞林cuznwww.wulinlw.org)原创稿件,转载请保留版权

Repeater绑定数据以及Item转换数据类型

Continue Read..

Repeater的OnItemDataBound

点击查看原图点击查看原图

 

<asp:Repeater ID="RepeaterChests" runat="server" OnItemDataBound="RepeaterChests_ItemDataBound">

                                <ItemTemplate>

                                    <tr class=" " id="d993667818fc065459b16d8008566676">

                                        <td>

                                        <%#Eval("ChestUID")%>

                                        </td>

                                        <td>

                                            <%#Eval("NameText")%>

                                        </td>

                                        <td>

                                            <%#Eval("SectionName")%>

                                        </td>

                                        <td>

                                            <%--<%#Eval("ChestType")%>--%>

                                            <asp:Label Text='<%#Eval("ChestType") %>' ID="lblChestType" runat="server"></asp:Label>

                                        </td>

                                        <td>

                                            <%#Eval("IP")%>

                                        </td>

                                        <td>

                                            <%#Eval("DescText")%>

                                        </td>

                                        <td>

                                        <a title="编辑" href='ChestSetAdd.aspx?ChestKey=<%#Eval("ChestKey") %>' ><img src="../images/edit.png" style="vertical-align:middle"></img>&nbsp;编辑</a>  

                                        </td>

                                    </tr>

                                    </ItemTemplate>

                                    </asp:Repeater>

 

后台代码:

 public static string GetEnumDesc(Type enumType, object val)

    {

        string enumvalue = System.Enum.GetName(enumType, val);

        if (string.IsNullOrEmpty(enumvalue))

        {

            return "";

        }

        System.Reflection.FieldInfo finfo = enumType.GetField(enumvalue);

        object[] enumAttr = finfo.GetCustomAttributes(typeof(System.ComponentModel.DescriptionAttribute), true);

        if (enumAttr.Length > 0)

        {

            System.ComponentModel.DescriptionAttribute desc = enumAttr[0] as System.ComponentModel.DescriptionAttribute;

            if (desc != null)

            {

                return desc.Description;

            }

        }

        return enumvalue;

    }

 

protected void RepeaterChests_ItemDataBound(object sender, RepeaterItemEventArgs e)

{

        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)

        {

            ((Label)e.Item.FindControl("lblChestType")).Text = GetEnumDesc(typeof(DrawerType), Enum.Parse(typeof(DrawerType), ((Label)e.Item.FindControl("lblChestType")).Text));

        }

}

 

//获取药车列表

    private void SelectAllChests(string sectionkey)

    {

        string strwhere = " ";

 

        if (!string.IsNullOrEmpty(sectionkey)&&sectionkey!="0")

        {

            strwhere = "and A.SectionKey = '" + sectionkey + "'";

        }

 

        else

        {

            if (DDLSection.Text != "0")

            {

                strwhere += " and A.SectionKey = " + DDLSection.Text;

            }

 

            if (DDLState.Text != "3")

                strwhere += " and A.State = " + DDLState.Text;

 

            if (txtChestsName.Value != "")

                strwhere += " and A.NameText like '%" + txtChestsName.Value + "%'";

 

            if (tbStart.Text != "")

                strwhere += " and CONVERT(varchar(100),A.CreatedLocalDtm, 23) >= '" + tbStart.Text + "'";

 

            if (tbEnd.Text != "")

                strwhere += " and CONVERT(varchar(100), A.CreatedLocalDtm, 23) <= '" + tbEnd.Text + "'";

        }

 

        ds = ChestC.SelectAllChests(strwhere);

        DataTable dt = ds.Tables[0];

 

        //分页控件初始参数

        this.AspNetPager1.RecordCount = ds.Tables[0].Rows.Count;

        this.AspNetPager1.PageSize = 13;

        PagedDataSource pds = new PagedDataSource();

 

        pds.AllowPaging = true;

        pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;

        pds.PageSize = AspNetPager1.PageSize;

 

        if (dt != null && dt.Rows.Count > 0)

        {

            pds.DataSource = dt.DefaultView;

            RepeaterChests.DataSource = pds;

        }

        RepeaterChests.DataBind();

    }

声明:此文系舞林cuznwww.wulinlw.org)原创稿件,转载请保留版权

webdiyer:AspNetPager分页设置

Continue Read..

点击查看原图

<webdiyer:aspnetpager ID="AspNetPager1" runat="server" CssClass="paginator" CurrentPageButtonClass="cpb"

                        EnableTheming="true" FirstPageText="首页" HorizontalAlign="right" LastPageText="尾页"

                        NextPageText="下一页"  PageIndexBoxType="DropDownList"

                        PageSize="12" PrevPageText="上一页" ShowPageIndexBox="Always" TextBeforePageIndexBox="Go To Page: "

                        UrlPaging="false" Width="100%" onpagechanging="AspNetPager1_PageChanging"  >

                        </webdiyer:aspnetpager>

 

后台代码:

protected void Page_Load(object sender, EventArgs e)

    {

        if (!IsPostBack)

        {

            if (Request.QueryString["sectionkey"] != null)

                sectionkey = Request.QueryString["sectionkey"].ToString();

             

            SelectAllChests(sectionkey);

        }

    }

 

private void SelectAllChests(string sectionkey)

    {

        string strwhere = " ";

 

        if (!string.IsNullOrEmpty(sectionkey)&&sectionkey!="0")

        {

            strwhere = "and A.SectionKey = '" + sectionkey + "'";

        }

 

        else

        {

            if (DDLSection.Text != "0")

            {

                strwhere += " and A.SectionKey = " + DDLSection.Text;

            }

 

            if (DDLState.Text != "3")

                strwhere += " and A.State = " + DDLState.Text;

 

            if (txtChestsName.Value != "")

                strwhere += " and A.NameText like '%" + txtChestsName.Value + "%'";

 

            if (tbStart.Text != "")

                strwhere += " and CONVERT(varchar(100),A.CreatedLocalDtm, 23) >= '" + tbStart.Text + "'";

 

            if (tbEnd.Text != "")

                strwhere += " and CONVERT(varchar(100), A.CreatedLocalDtm, 23) <= '" + tbEnd.Text + "'";

        }

 

        ds = ChestC.SelectAllChests(strwhere);

        DataTable dt = ds.Tables[0];

 

        //分页控件初始参数

        this.AspNetPager1.RecordCount = ds.Tables[0].Rows.Count;

        this.AspNetPager1.PageSize = 13;

        PagedDataSource pds = new PagedDataSource();

 

        pds.AllowPaging = true;

        pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;

        pds.PageSize = AspNetPager1.PageSize;

 

        if (dt != null && dt.Rows.Count > 0)

        {

            pds.DataSource = dt.DefaultView;

            RepeaterChests.DataSource = pds;

        }

        RepeaterChests.DataBind();

    }

 

protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)

    {

        AspNetPager1.CurrentPageIndex = e.NewPageIndex;

        SelectAllChests(sectionkey);

    }

声明:此文系舞林cuznwww.wulinlw.org)原创稿件,转载请保留版权

底部报名代码

Continue Read..

【html】

<link rel="stylesheet" rev="stylesheet" href="/gonggong/2011/kft/login19.css" type="text/css" />

<script type='text/javascript' src='/gonggong/2011/kft/jquery-1.7.2.min.js'></script>

 

<div id="J_loginGuide" class="login-wrap" style=""><div class="login-box"><div class="login-user clearallx"><div class="login-title flflfl clearallx"><h3 class="flflfl">春节看房团火热报名中...</h3><span class="login-arrow flflfl"><img src="view_bg.png" class="vm" /></span></div>

<div class="login-cont flflfl"><ul>

<li><input name="kfname" id="kfname" class="txt" tabindex="1"   value="请输入姓名" onclick="this.value = ''" placeholder="姓名"></li><li><input name="kftel" id="kftel" class="txt" tabindex="2" onclick="this.value = ''" placeholder="请输入手机号码"></li><li class="login-qt"><button id="tijiao" type="submit"  class="login-button" tabindex="904"><em>报名</em></button>

 

</li><li class="login-shortcut color6"><a href="http://loupan.xnfw.com/kanfangtuan/index/ydindex" target="_blank"><span style="color:#F00">免费专车接送、独家优惠、奖品大放送....</span></a>

 </li>

 </ul><div id="J_loginGuidePopo" class="popo-id" style="display:none"><div class="popo-bd popo-mod"><p id="J_loginGuideTip"></p><a href="javascript:void(0);" class="close" title="关闭">关闭</a><p class="popo-aw"></p></div></div></div></div><a href="javascript:void(0);" id="J_loginGuideClose" class="close" title="关闭" onclick="close19login()"></a></div></div>

 <script language="javascript" type="text/javascript">

function isCHName(astr){

var lst = /[^u4e00-u9fa5]/g;

return lst.test(astr);

}

 

function isPhone(tophone){

var pr = /^1[3|5|8]([0-9]{1})([0-9]{8})$/;

return pr.test(tophone);

}

 

$("#tijiao").click(function(){

 var name=$("#kfname").val();

 var phone=$("#kftel").val();

 if(lenofstr(name)>20 || lenofstr(name)<3 || !isCHName(name)){

alert("请认真填写真实姓名!");

$("#name").focus();

  return false;

 

 } else if(isNaN(phone) || lenofstr(phone)>11 || !isPhone(phone)){

alert("手机号码填写有误!");

$("#phone").focus();

     return false;

 } else {

hrefValue="http://loupan.xnfw.com"; 

$.getJSON(

   hrefValue+"/kanfangtuan/index/jsondata?callback=?",

  { name: encodeURIComponent(name), phone:phone, area:encodeURIComponent('咸宁'), sjname:encodeURIComponent('2012元旦看房团')},

   function(data){

alert(data);

  if(data.status==1)

  {   

      $("#kfname").val("");

      $("#kftel").val("");

      alert('提交成功!');

  }

  } 

); 

 

}

 

})

 

 

function lenofstr(str)

{

   var len;

  

   var i;

   len = 0; 

   for (i=0;i<str.length;i++) 

   {

        if (str.charCodeAt(i)>255) len+=2; else len++; 

   } 

    return len;

}

function close19login(){

$('#J_loginGuide').css('display','none');

}

</script>

 

【php】

function jsondata(){

$tel = iconv('UTF-8', 'GB2312', urldecode($_GET['phone']));

$sjname = iconv('UTF-8', 'GB2312', urldecode($_GET['sjname']));

$name = iconv('UTF-8', 'GB2312', urldecode($_GET['name']));

$area = iconv('UTF-8', 'GB2312', urldecode($_GET['area']));

 

$row = $this->mfun->get_select_fun('fw_member','tel',array('tel'=>$tel,'sjname'=>$sjname,'area'=>$area))->row_array();

if(!empty($row['tel'])){

$this->mfun->update_table_fun('fw_member',array('addtime'=>time()),array('tel'=>$tel,'sjname'=>$sjname,'area'=>$area));

}else{

$dataArr['name'] = $name;

$dataArr['tel'] = $tel;

$dataArr['sjname'] = $sjname ;

$dataArr['area'] = $area;

$dataArr['addtime']=time();

$dataArr['edittime']=time();

 

$this->mfun->get_insert_fun('fw_member',$dataArr);

}

 

$arr = array("message"=>"ok","status"=>"1");

 

echo $_GET['callback'].'('.json_encode($arr).')'; 

 

}

 

点击查看原图

 

 

 

 

 

 

 

 

<!--看房团报名-->

<style>

#kanfang{z-index:998; position:fixed;bottom:0;left:50%;width:0px;height:0px;_position:absolute;_top: expression(documentElement.scrollTop + (documentElement.clientHeight-this.offsetHeight));}

#kanfang .padface{position:absolute;left:-475px;width:950px;height:92px;top:-92px;*+left:-475px;_left:-475px;z-index:999;}

.kanfang{width:950px; height:92px; background:url(http://loupan.xtfw.cn/images/kft101/xiantao/kanfang.gif) no-repeat;overflow: hidden;position:relative;}

.kanfang .iclose{position: absolute;display:block;right:2px;right:2px; width:20px; height:20px;}

.kanfang .kflink1,.kanfang .kflink2{position: absolute;display:block;}

.kanfang .kflink1{left:0px;top:0px;width:320px;height:92px;}

.kanfang .kflink2{right:0px;bottom:0px;width:279px;height:69px;}

.kanfang .kfname,.kanfang .kftel{font-size:12px;height:27px;line-height:27px; color:#000;position: absolute;left:374px;background:none; text-indent:3px; border:0px;} 

.kanfang .kfname{top:23px;width:158px;}

.kanfang .kftel{top:57px;width:158px;}

.kanfang .kfbtn{background: none;border: medium none;top:35px;left:544px;cursor: pointer;width:98px;height:49px;position: absolute;text-indent: -9999px;margin:0px;padding:0px;}

</style>

<div id="kanfang" style="display:block;">

 <div class="padface">

  <div class="kanfang">

      <a onclick="$('#kanfang').hide();" class="iclose" target="_self" href="javascript:void(0)"></a>

<a href="http://loupan.xtfw.cn/kft101/index/" target="_blank" title="仙桃10.1看房团" class="kflink1"></a>

              <input name="kfname" id="kfname" class="kfname" tabindex="1"    onclick="this.value = ''" placeholder="请输入姓名">

              <input name="kftel" id="kftel" class="kftel" tabindex="2" onclick="this.value = ''" placeholder="请输入手机号码">

              <input class="kfbtn" id="tijiao" type="submit" name="tijiao"  />

<a href="http://loupan.xtfw.cn/kft101/index/" target="_blank" title="仙桃10.1看房团" class="kflink2"></a>

  </div>

 </div>

</div>

 <script language="javascript" type="text/javascript">

function isCHName(astr){

var lst = /[^u4e00-u9fa5]/g;

return lst.test(astr);

}

 

function isPhone(tophone){

var pr = /^1[3|5|8]([0-9]{1})([0-9]{8})$/;

return pr.test(tophone);

}

$("#tijiao").click(function(){

 var name=$("#kfname").val();

 var phone=$("#kftel").val();

 if(lenofstr(name)>20 || lenofstr(name)<3 || !isCHName(name)){

alert("请认真填写真实姓名!");

$("#name").focus();

  return false;

 

 } else if(isNaN(phone) || lenofstr(phone)>11 || !isPhone(phone)){

alert("手机号码填写有误!");

$("#phone").focus();

     return false;

 } else {

hrefValue="http://loupan.xtfw.cn"; 

$.getJSON(

   hrefValue+"/kanfangtuan/index/jsondata?callback=?",

  { name: encodeURIComponent(name), phone:phone, area:encodeURIComponent('仙桃'), sjname:encodeURIComponent('2013-10-1看房团')},

   function(data){

  if(data.status==1)

  {   

      $("#kfname").val("");

      $("#kftel").val("");

      alert('提交成功!');

  }

  } 

); 

})

function lenofstr(str)

{

   var len;

   var i;

   len = 0; 

   for (i=0;i<str.length;i++) 

   {

        if (str.charCodeAt(i)>255) len+=2; else len++; 

   } 

    return len;

}

</script>

 

 

 

 

 

 

 

 

 

<!--看房团报名-->

<style>

.kftuan{width:950px;margin-left:auto;margin-right:auto;text-align:center;overflow:hidden}

#kanfang{z-index:998; position:fixed;bottom:0;left:50%;width:0px;height:0px;_position:absolute;_top: expression(documentElement.scrollTop + (documentElement.clientHeight-this.offsetHeight));}

#kanfang .padface{position:absolute;left:-475px;width:950px;height:92px;top:-92px;*+left:-475px;_left:-475px;z-index:999;}

.kanfang{width:950px; height:92px; background:url(http://loupan.xtfw.cn/images/kft101/xiantao/kanfang.gif) no-repeat;overflow: hidden;position:relative;}

.kanfang .iclose{position: absolute;display:block;right:2px;right:2px; width:20px; height:20px;}

.kanfang .kflink1,.kanfang .kflink2{position: absolute;display:block;}

.kanfang .kflink1{left:0px;top:0px;width:320px;height:92px;}

.kanfang .kflink2{right:0px;bottom:0px;width:279px;height:69px;}

.kanfang .kfname,.kanfang .kftel{font-size:12px;height:27px;line-height:27px; color:#000;position: absolute;left:374px;background:none; text-indent:3px; border:0px;} 

.kanfang .kfname{top:23px;width:158px;}

.kanfang .kftel{top:57px;width:158px;}

.kanfang .kfbtn{background: none;border: medium none;top:35px;left:544px;cursor: pointer;width:98px;height:49px;position: absolute;text-indent: -9999px;margin:0px;padding:0px;}

</style>

<div class="kftuan">

<div id="kanfang" style="display:block;">

 <div class="padface">

  <div class="kanfang">

      <a onclick="$('#kanfang').hide();" class="iclose" target="_self" href="javascript:void(0)"></a>

<a href="http://loupan.xtfw.cn/kft101/index/" target="_blank" title="仙桃10.1看房团" class="kflink1"></a>

              <input name="kfname" id="kfname" class="kfname" tabindex="1"    onclick="this.value = ''" placeholder="请输入姓名">

              <input name="kftel" id="kftel" class="kftel" tabindex="2" onclick="this.value = ''" placeholder="请输入手机号码">

              <input class="kfbtn" id="tijiao" type="submit" name="tijiao"  />

<a href="http://loupan.xtfw.cn/kft101/index/" target="_blank" title="仙桃10.1看房团" class="kflink2"></a>

  </div>

 </div>

</div>

</div>

 <script language="javascript" type="text/javascript">

function isCHName(astr){

var lst = /[^u4e00-u9fa5]/g;

return lst.test(astr);

}

 

function isPhone(tophone){

var pr = /^1[3|5|8]([0-9]{1})([0-9]{8})$/;

return pr.test(tophone);

}

$("#tijiao").click(function(){

 var name=$("#kfname").val();

 var phone=$("#kftel").val();

 if(lenofstr(name)>20 || lenofstr(name)<3 || !isCHName(name)){

alert("请认真填写真实姓名!");

$("#name").focus();

  return false;

 

 } else if(isNaN(phone) || lenofstr(phone)>11 || !isPhone(phone)){

alert("手机号码填写有误!");

$("#phone").focus();

     return false;

 } else {

hrefValue="http://loupan.xtfw.cn"; 

$.getJSON(

   hrefValue+"/kanfangtuan/index/jsondata?callback=?",

  { name: encodeURIComponent(name), phone:phone, area:encodeURIComponent('仙桃'), sjname:encodeURIComponent('2013-10-1看房团')},

   function(data){

  if(data.status==1)

  {   

      $("#kfname").val("");

      $("#kftel").val("");

      alert('提交成功!');

  }

  } 

); 

})

function lenofstr(str)

{

   var len;

   var i;

   len = 0; 

   for (i=0;i<str.length;i++) 

   {

        if (str.charCodeAt(i)>255) len+=2; else len++; 

   } 

    return len;

}

</script>

<!--看房团报名end-->

声明:此文系舞林cuznwww.wulinlw.org)原创稿件,转载请保留版权

【DEDE】过滤函数

Continue Read..
/*
 * $rptype = 0 表示仅替换 html标记
 * $rptype = 1 表示替换 html标记同时去除连续空白字符
 * $rptype = 2 表示替换 html标记同时去除所有空白字符
 * $rptype = -1 表示仅替换 html危险的标记
 */
function HtmlReplace($str,$rptype=0){
	$str = stripslashes($str);
	if($rptype==0)
	{
		$str = htmlspecialchars($str);
	}
	else if($rptype==1)
	{
		$str = htmlspecialchars($str);
		$str = str_replace(" ",' ',$str);
		$str = ereg_replace("[\r\n\t ]{1,}",' ',$str);
	}
	else if($rptype==2)
	{
		$str = htmlspecialchars($str);
		$str = str_replace(" ",'',$str);
		$str = ereg_replace("[\r\n\t ]",'',$str);
	}
	else if($rptype==3){
		$str = $this->SpHtml2Text($str);
	}
	else
	{
		$str = ereg_replace("[\r\n\t ]{1,}",' ',$str);
		$str = eregi_replace('script','script',$str);
		$str = eregi_replace("<[/]{0,1}(link|meta|ifr|fra)[^>]*>",'',$str);
	}
	return addslashes($str);
}

function SpHtml2Text($str)
{
	$str = preg_replace("/<sty(.*)\\/style>|<scr(.*)\\/script>|<!--(.*)-->/isU","",$str);
	$alltext = "";
	$start = 1;
	for($i=0;$i<strlen($str);$i++)
	{
		if($start==0 && $str[$i]==">")
		{
			$start = 1;
		}
		else if($start==1)
		{
			if($str[$i]=="<")
			{
				$start = 0;
				$alltext .= " ";
			}
			else if(ord($str[$i])>31)
			{
				$alltext .= $str[$i];
			}
		}
	}
	$alltext = str_replace(" "," ",$alltext);
	$alltext = preg_replace("/&([^;&]*)(;|&)/","",$alltext);
	$alltext = preg_replace("/[ ]+/s"," ",$alltext);
	return $alltext;
}

声明:此文系舞林cuznwww.wulinlw.org)原创稿件,转载请保留版权