最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

專為新手寫的結(jié)合smarty的類第2/3頁(yè)

 更新時(shí)間:2006年12月02日 00:00:00   作者:  

復(fù)制代碼 代碼如下:


// 發(fā)送SQL語(yǔ)句函數(shù) 
    public function send_query( $sql ) 
    { 
        switch ( strtoupper( $this->config->database ) ) 
        { 
            case 'MYSQL' : 
                return $this->send_mysql_query( $sql ); 
                break; 
            case 'ACCESS' : 
                return $this->send_odbc_query( $sql ); 
                break; 
            default : 
                $this->sys_err( '數(shù)據(jù)庫(kù)類型錯(cuò)誤,該類目前只支持MYSQL與ACCESS兩種數(shù)據(jù)庫(kù)', 'die' ); 
                break; 
        } 
    } 

    // 發(fā)送SQL語(yǔ)句到MYSQL函數(shù) 
    private function send_mysql_query( $sql ) 
    { 
        @$rs = mysql_query( $sql, $this->conn ); 
        if ( $rs == false ) 
        { 
            $mysql_err = mysql_error(); 
            $this->sys_err( "SQL語(yǔ)句:{{$sql}}執(zhí)行失敗,原因是:{{$mysql_err}}", 'die' ); 
        } 
        return $rs; 
    } 

    // 發(fā)送SQL語(yǔ)句到ACCESS函數(shù) 
    private function send_odbc_query( $sql ) 
    { 
        @$rs = odbc_exec( $this->conn, $sql ); 
        if ( $rs == false ) 
        { 
            $odbc_err = odbc_errormsg( $this->conn ); 
            $this->sys_err( "SQL語(yǔ)句:{{$sql}}執(zhí)行失敗,原因是:{{$odbc_err}}", 'die' ); 
        } 
        return $rs; 
    } 

    // 獲取查詢返回函數(shù) 
    public function select_query( $sql, $retuen_res = false ) 
    { 
        $res = $this->send_query( $sql ); 
        if ( $retuen_res == true ) 
        { 
            return $res; 
        } 
        switch ( strtoupper( $this->config->database ) ) 
        { 
            case 'MYSQL' : 
                return $this->select_mysql_query( $res ); 
                break; 
            case 'ACCESS' : 
                return $this->select_access_query( $res ); 
                break; 
            default : 
                $this->sys_err( '數(shù)據(jù)庫(kù)類型錯(cuò)誤,該類目前只支持MYSQL與ACCESS兩種數(shù)據(jù)庫(kù)', 'die'); 
                break; 
        } 
    } 

    // 獲取MYSQL查詢返回函數(shù) 
    private function select_mysql_query( $res ) 
    { 
        $arr = array(); 
        while ( false != ( $rs = mysql_fetch_assoc( $res ) ) ) 
        { 
            $arr[] = $rs; 
        } 
        mysql_free_result( $res ); 
        return ( count( $arr ) > 0 ? $arr : false ); 
    } 

    // 獲取ACCCESS查詢返回函數(shù) 
    private function select_access_query( $res ) 
    { 
        $arr = array(); 
        while ( false != ( $rs = odbc_fetch_array( $res ) ) ) 
        { 
            $arr[] = $rs; 
        } 
        odbc_free_result( $res ); 
        return ( count( $arr ) > 0 ? $arr : false ); 
    } 

    // 獲取系統(tǒng)錯(cuò)誤函數(shù) 
    public function sys_err( $err_msg, $method, $err_notice = '很抱歉,本站發(fā)生系統(tǒng)錯(cuò)誤,請(qǐng)稍候再試。' ) 
    { 
        $this->err_record( 'sys', $err_msg ); 
        switch ( $method ) 
        { 
            case 'keep': 
                return; 
                break; 
            default: 
                $this->err_notice( $err_notice ); 
                break; 
        } 
    } 

    // 獲取用戶錯(cuò)誤函數(shù) 
    public function user_err( $err_notice, $method, $re_href = '', $err_msg = '' ) 
    { 
        if ( !empty( $err_msg ) ) 
        { 
            $this->err_record( 'user', $err_msg ); 
        } 
        switch ( $method ) 
        { 
            case 'keep': 
                return; 
                break; 
            default: 
                $this->err_notice( $err_notice, $re_href ); 
                break; 
        } 
    } 

    // 記錄錯(cuò)誤函數(shù) 
    private function err_record( $type, $err_msg ) 
    { 
        $err_url = $this->the_dir . 'lib/error/'; 
        $err_url .= ( $type == 'sys' ? 'system.err' : 'user.err' ); 
        $record_msg =  date( 'Y-m-d H:i:s' ) . '|' . $err_msg . "\n"; 
        $this->file_put( $err_url, $record_msg, 'ab' ); 
    } 

    // 文件寫入函數(shù) 
    public function file_put( $url, $content, $method ) 
    { 
        $dir = str_replace( basename( $url ), '', $url ); 
        if ( !file_exists( $dir ) ) 
        { 
            $this->sys_err( "{{$dir}}文件夾不存在", 'die' ); 
        } 
        @$f = fopen( $url, $method ); 
        @flock( $f, LOCK_NM ); 
        @fwrite( $f, $content, strlen( $content ) ); 
        @flock( $f, LOCK_UN ); 
        @fclose( $f ); 
    } 

    // 提示錯(cuò)誤函數(shù) 
    protected function err_notice( $err_notice, $re_href = '' ) 
    { 
        $err_page = $this->the_dir . $this->err_page; 
        if ( !file_exists( $err_page ) ) 
        { 
            $this->sys_err( '錯(cuò)誤提示頁(yè)面丟失', 'keep' ); 
            die( '很抱歉,本站發(fā)生系統(tǒng)錯(cuò)誤,請(qǐng)稍候再試。' ); 
        } 
        $err_html = file_get_contents( $err_page ); 
        $err_html = str_replace( '<%$err_notice%>', $err_notice, $err_html); 
        $err_html = str_replace( '<%$this_url%>', $this->the_dir, $err_html); 
        $err_html = str_replace( '<%$re_href%>', $re_href, $err_html); 
        echo $err_html; 
        exit; 
    } 

    // 用于設(shè)定模版文件路徑的函數(shù) 
    function set_dir( $file_dir = 'smarty_file' ) 
    { 
        if ( !preg_match( '{/$}', $file_dir ) ) 
        { 
            $file_dir .= '/'; 
        } 
        if ( !file_exists( $this->the_dir . $file_dir . $this->template_dir ) ) 
        { 
            $this->sys_err( 'smarty模版路徑丟失', 'die' ); 
        } 
        if ( !file_exists( $this->the_dir . $file_dir . $this->compile_dir ) ) 
        { 
            $this->sys_err( 'smarty編譯路徑丟失', 'die' ); 
        } 
        if ( !file_exists( $this->the_dir . $file_dir . $this->cache_dir ) ) 
        { 
            $this->sys_err( 'smarty緩存路徑丟失', 'die' ); 
        } 
        $this->template_dir = $this->the_dir . $file_dir . $this->template_dir; 
        $this->compile_dir = $this->the_dir . $file_dir . $this->compile_dir; 
        $this->cache_dir = $this->the_dir . $file_dir . $this->cache_dir; 
    } 

    // 生成靜態(tài)頁(yè)面函數(shù) 
    public function create_html( $tpl, $file_url = '', $html_name = '' ) 
    { 
        $html_tpl = $this->fetch( $tpl ); 
        //生成靜態(tài)文件的文件名 
        if ( empty( $html_name ) ) 
        { 
            $file_name = strtolower( basename( $_SERVER['PHP_SELF'] ) ); 
            $file_name = str_replace( '.php', ".{$this->html_cache}", $file_name ); 
        } 
        else 
        { 
            $file_name = $html_name; 
        } 
        if ( !empty( $file_url ) && !preg_match( '!\/$!', $file_url ) ) 
        { 
            $file_url .= '/'; 
        } 
        $file_url = !empty( $file_url ) ? $this->the_dir . $file_url : "./{$file_url}"; 
        $file_url .= $file_name; 
        $this->file_put( $file_url, $html_tpl, 'wb'); 
        header("location:{$file_url}"); 
        exit(); 
    } 

    // 轉(zhuǎn)到靜態(tài)頁(yè)面 
    public function goto_html( $left_time = null, $file_url = '', $html_name = '' ) 
    { 
        $left_time = ( $left_time == null ? $this->html_cache_lifetime : intval( $left_time ) ); 
        //獲取靜態(tài)文件的文件名 
        if ( empty( $html_name ) ) 
        { 
            $file_name = strtolower( basename( $_SERVER['PHP_SELF'] ) ); 
            $file_name = str_replace( '.php', ".{$this->html_cache}", $file_name ); 
        } 
        else 
        { 
            $file_name = $html_name; 
        } 
        if ( !empty( $file_url ) && !preg_match( '!\/$!', $file_url ) ) 
        { 
            $file_url .= '/'; 
        } 
        $file_url = !empty( $file_url ) ? $this->the_dir . $file_url : "./{$file_url}"; 
        $file_url .= $file_name; 
        if ( !file_exists( $file_url) ) 
        { 
            return; 
        } 
        if ( $left_time == -1 ) 
        { 
            header("location:{$file_url}"); 
            exit; 
        } 
        else 
        { 
            @$fmtime = filemtime( $file_url ); 
            $fmtime = intval( $fmtime ); 
            if ( time() - $fmtime <= $left_time ) 
            { 
                header("location:{$file_url}"); 
                exit; 
            } 
        } 
    } 

?>  

復(fù)制代碼 代碼如下:


<?php 
// 添斜線 
function m_addslashes( $gpc ) 

    if ( !get_magic_quotes_gpc() ) 
    { 
        if( is_array( $gpc ) ) 
        { 
            while( list( $k, $v ) = each( $gpc ) ) 
            { 
                if( is_array( $gpc[$k] ) ) 
                { 
                    while( list( $k2, $v2 ) = each( $gpc[$k] ) ) 
                    { 
                        $gpc[$k][$k2] = addslashes( $v2 ); 
                    } 
                    @reset( $gpc[$k] ); 
                } 
                else 
                { 
                    $gpc[$k] = addslashes( $v ); 
                } 
            } 
            @reset( $gpc ); 
        } 
        else 
        { 
            $gpc = addslashes( $gpc ); 
        } 
    } 
    return $gpc; 


?>  



復(fù)制代碼 代碼如下:


<?php 
function m_check_fill( $check_arr = array() ) 

    $pattern['idname'] = array('!^[a-z0-9]{3,8}$!i' , '您輸入的用戶名格式不正確'); 

    $pattern['username'] = array('!^.{4,12}$!' , '您輸入的用戶昵稱格式不正確'); 

    $pattern['email'] = array('!^([a-z0-9]+(\.[a-z0-9]+)?@[a-z0-9]+\.[a-z0-9]+(\.[a-z0-9]+)?)?$!i' , '您輸入的電子郵箱格式不正確'); 

    $pattern['oicq'] = array('!^([0-9]{4,12})?$!' , '您輸入的OICQ格式不正確'); 

    $pattern['password'] = array('!^[a-z0-9]{6,14}$!i' , '您輸入的密碼格式不正確'); 

    $pattern['real_name'] = array('!^.{4,20}$!' , '您輸入的真實(shí)姓名格式不正確'); 

    $pattern['id_card'] = array('!^[0-9]{15}([0-9]{2}[a-z0-9])?$!i' , '您輸入的身份證號(hào)碼格式不正確'); 

    $pattern['title'] = array('!^.{1,255}$!' , '您輸入的帖子標(biāo)題格式不正確'); 

    $pattern['block_name'] = array('!^.{3,12}$!' , '您輸入的板塊名稱格式不正確'); 

    $err_msg = ''; 

    if ( !is_array( $check_arr ) ) 
    { 
        return '很抱歉,系統(tǒng)出現(xiàn)參數(shù)傳遞錯(cuò)誤,請(qǐng)通知管理員,謝謝合作'; 
    } 

    foreach ( $check_arr as $key => $value ) 
    { 
        if ( !empty( $pattern[$key] ) ) 
        { 
            if( !preg_match( $pattern[$key][0], $value ) ) 
            { 
                $err_msg .= $pattern[$key][1] . '<br>'; 
            } 
        } 
    } 

    return $err_msg; 

?>  



復(fù)制代碼 代碼如下:


<?php 
//防止跨站攻擊函數(shù) 
function m_check_key( $no_reload = true ) 

        if ( empty( $_COOKIE['check'] ) || $_COOKIE['check'] != $_POST['check'] ) 
        { 
                setcookie( 'check', '', time()-86400 ); 
                return '發(fā)生錯(cuò)誤,這也許是由于您重復(fù)提交數(shù)據(jù)造成的,請(qǐng)重新提交。<br>'; 
        } 
        if ( $no_reload == true ) 
        { 
                setcookie( 'check', '', time()-86400 ); 
        } 

?>  

復(fù)制代碼 代碼如下:


<?php 
//防止跨站攻擊函數(shù) 
function m_md5( $password = '' ) 

    if ( empty( $password ) ) 
    { 
        $password = md5( uniqid ( rand(), true ) ); 
        setcookie( 'check', $password ); 
    } 
    else 
    { 
        $key = 'machine'; 
        $password = md5( $password . $key ); 
    } 
    return $password; 

?>

復(fù)制代碼 代碼如下:


<?php 
//中文截取函數(shù) 
function m_cnsubstr( $string, $sublen ) 

    if( $sublen >= strlen( $string ) ) 
    { 
        return $string; 
    } 
    $s = ""; 

    for ( $i = 0; $i < $sublen; $i++ ) 
    { 
        if( ord( $string{$i} ) > 127 ) 
        { 
            $s .= $string{$i} . $string{++$i}; 
            continue; 
        } 
        else 
        { 
            $s .= $string{$i}; 
            continue; 
        } 
    } 
    return $s . '…'; 

?> 

相關(guān)文章

  • php內(nèi)核解析:PHP中的哈希表

    php內(nèi)核解析:PHP中的哈希表

    PHP中使用最為頻繁的數(shù)據(jù)類型非字符串和數(shù)組莫屬,PHP比較容易上手也得益于非常靈活的數(shù)組類型。 在開始詳細(xì)介紹這些數(shù)據(jù)類型之前有必要介紹一下哈希表(HashTable)。 哈希表是PHP實(shí)現(xiàn)中尤為關(guān)鍵的數(shù)據(jù)結(jié)構(gòu)
    2014-01-01
  • 火車頭采集器3.0采集圖文教程

    火車頭采集器3.0采集圖文教程

    今天要給大家做示例的網(wǎng)站是163的 娛樂(lè)頻道 這個(gè)應(yīng)該是個(gè)比較通用和實(shí)用的規(guī)則,下面開始。
    2007-03-03
  • php寫入、刪除與復(fù)制文件的方法

    php寫入、刪除與復(fù)制文件的方法

    這篇文章主要介紹了php寫入、刪除與復(fù)制文件的方法,涉及php針對(duì)文件常見的操作技巧,需要的朋友可以參考下
    2015-06-06
  • PHP cookie,session的使用與用戶自動(dòng)登錄功能實(shí)現(xiàn)方法分析

    PHP cookie,session的使用與用戶自動(dòng)登錄功能實(shí)現(xiàn)方法分析

    這篇文章主要介紹了PHP cookie,session的使用與用戶自動(dòng)登錄功能實(shí)現(xiàn)方法,結(jié)合實(shí)例形式分析了php使用cookie與session進(jìn)行數(shù)據(jù)存取以及實(shí)現(xiàn)自動(dòng)登陸功能的相關(guān)操作技巧,需要的朋友可以參考下
    2019-06-06
  • php 各種應(yīng)用亂碼問(wèn)題的解決方法

    php 各種應(yīng)用亂碼問(wèn)題的解決方法

    php開發(fā)中經(jīng)常碰到一些亂碼問(wèn)題,這里腳本之家給簡(jiǎn)單的整理下。
    2010-05-05
  • 淺談PHP設(shè)計(jì)模式之對(duì)象池模式Pool

    淺談PHP設(shè)計(jì)模式之對(duì)象池模式Pool

    對(duì)象池模式是一種提前準(zhǔn)備了一組已經(jīng)初始化了的對(duì)象『池』而不是按需創(chuàng)建或者銷毀的創(chuàng)建型設(shè)計(jì)模式。對(duì)象池客戶端會(huì)向?qū)ο蟪刂姓?qǐng)求一個(gè)對(duì)象,然后使用這個(gè)返回的對(duì)象執(zhí)行相關(guān)操作。當(dāng)客戶端使用完畢,它將把這個(gè)特定類型的工廠對(duì)象返回給對(duì)象池,而不是銷毀掉這個(gè)對(duì)象。
    2021-05-05
  • php實(shí)現(xiàn)圖片文件與下載文件防盜鏈的方法

    php實(shí)現(xiàn)圖片文件與下載文件防盜鏈的方法

    這篇文章主要介紹了php實(shí)現(xiàn)圖片文件與下載文件防盜鏈的方法,包括了常用的操作方法與服務(wù)器端配置方法等,非常具有實(shí)用價(jià)值,需要的朋友可以參考下
    2014-11-11
  • PHP版微信小店接口開發(fā)實(shí)例

    PHP版微信小店接口開發(fā)實(shí)例

    這篇文章主要介紹了PHP版微信小店接口開發(fā)方法,結(jié)合實(shí)例形式分析了php實(shí)現(xiàn)微信小店接口調(diào)用的相關(guān)操作技巧,需要的朋友可以參考下
    2016-11-11
  • 基于php+redis實(shí)現(xiàn)布隆過(guò)濾器

    基于php+redis實(shí)現(xiàn)布隆過(guò)濾器

    布隆過(guò)濾器(Bloom filter)是一種用于快速判斷一個(gè)元素是否存在于集合中的數(shù)據(jù)結(jié)構(gòu),它可以有效地檢索數(shù)據(jù),而不需要存儲(chǔ)實(shí)際的元素本身,本文給大家介紹了如何基于php+redis實(shí)現(xiàn)布隆過(guò)濾器,感興趣的朋友可以參考下
    2023-12-12
  • php獲取英文姓名首字母的方法

    php獲取英文姓名首字母的方法

    這篇文章主要介紹了php獲取英文姓名首字母的方法,涉及php中explode及strtoupper函數(shù)操作php字符串分割及大小寫轉(zhuǎn)換的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-07-07

最新評(píng)論

桃园县| 新疆| 石景山区| 碌曲县| 浮梁县| 台江县| 关岭| 平山县| 澳门| 长白| 青田县| 正安县| 武宁县| 邵东县| 石门县| 龙井市| 乐都县| 五河县| 自治县| 廊坊市| 颍上县| 宜章县| 平顶山市| 房产| 浠水县| 日土县| 白银市| 涿州市| 苗栗县| 溆浦县| 游戏| 南皮县| 江陵县| 新闻| 平南县| 潢川县| 桓台县| 富宁县| 察雅县| 永川市| 乌拉特后旗|