欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

專為新手寫的結合smarty的類

 更新時間:2006年12月02日 00:00:00   作者:  

復制代碼 代碼如下:


<?php 
// 分頁類,使用時調用類下面的函數即可 
class Page_class 

 //帖子總數 
 private $count = 0; 
 //每頁顯示多少行 
 private $rows; 
 //每頁顯示多少個跳轉頁號 
 private $link_num; 
 //共有多少頁 
 private $pages = 0; 
 //當前頁 
 private $current_page; 
 //開始記錄 
 private $start = 0; 
 //上一大頁 
 private $prve = 0; 
 //下一大頁 
 private $next = 0; 
 //數字鏈接 
 private $links = array(); 
 //返回值 
 public $return_rs = array(); 
 public function __construct( $count, $current_page = 1, $rows = 10, $link_num = 7 ) 
 { 
  //獲取傳入的帖子總數 
  $this->count = intval( $count ); 
  //獲取當前頁 
  $this->current_page = intval( $current_page ); 
  //顯示多少行 
  $this->rows = intval( $rows ); 
  //每頁顯示多少個跳轉頁號 
  $this->link_num = $link_num; 
  //調用計算頁數的方法 
  $this->count_page(); 
  //調用返回跳轉頁號的方法 
  $this->return_links(); 
  //返回值 
  $this->return_rs = array( 
  'rows' => $this->rows, 
  'prve' => $this->prve, 
  'next' => $this->next, 
  'pages' => $this->pages, 
  'start' => $this->start, 
  'count' => $this->count, 
  'links' => $this->links, 
  'current_page' => $this->current_page 
  ); 
 } 

 public function __destruct() 
 { 

 } 
 //計算頁數 
 private function count_page() 
 { 
  //計算共有多少頁 
  @$this->pages = ceil( $this->count / $this->rows ); 
  //如果當前頁大于最大頁數,則使其等于最大頁數;如果當前頁小于1,則使其等于1 
  $this->current_page > $this->pages ? $this->current_page = $this->pages : true ; 
  $this->current_page < 1 ? $this->current_page = 1 : true; 
  //計算查詢的開始記錄數 
  $this->start = ( $this->current_page - 1 ) * $this->rows; 
 } 
 //返回頁面跳轉頁號的函數 
 private function return_links() 
 { 
  //用當前頁除以顯示頁數得到當前是第幾“大頁” 
  $start_s = floor( $this->current_page / $this->link_num ); 
  //如果當前頁號正好整除顯示頁數,則應該對$start_s減一,因為設想一下,如果當前是第7頁 
  //顯示頁數也是7,則$start_s=1,也就是說已經到了第二“大頁”了,而實際上它應該還是在 
  //第一“大頁” 
  ( $this->current_page % $this->link_num ) == 0 ? $start_s-- : true; 
  //計算當前“大頁”開始頁號,算法是(當前“大頁”*顯示頁數)+1;例如0*7+1=1,1*7+1=8,2*7+1=15 
  $start_page = ( $start_s * $this->link_num ) + 1; 
  //上一大頁 
  $this->prve = $start_page - 1; 
  //下一大頁 
  $this->next = $start_page + $this->link_num; 
  //開始循環(huán)計算當前大頁中的小頁號 
  for ( $i=0; $i < $this->link_num; $i++ ) 
  { 
   //如果下一個頁號已經超出了總頁數,則說明應該停止了 
   if ( $start_page + $i > $this->pages ) 
   { 
    break; 
   } 
   //將頁號記錄在$this->links_arr數組中 
   $this->links[] = $start_page + $i; 
  } 
 } 

function m_page( $count, $current_page = 1, $rows = 10, $link_num = 7 ) 

 $page = new Page_class( $count, $current_page, $rows, $link_num ); 
 return $page->return_rs; 

?>  



復制代碼 代碼如下:


<?php 
// 文本操作函數 
// 修改 
function m_txt_replace( $pattern, $text, $content ) 

    $pattern_start =  "<!--$pattern-->"; 
    $pattern_end =  "<!--/$pattern-->"; 
    @$ok = preg_match( "{{$pattern_start}.*{$pattern_end}}Ssi", $content, $match ); 
    if ( $ok != true ) 
    { 
        return false; 
    } 
    $replace = "{$pattern_start}{$text}{$pattern_end}"; 
    $new_content = str_replace( $match[0], $replace, $content ); 
    return $new_content; 


// 追加 
function m_txt_add( $pattern, $text, $content ) 

    $pattern = "<!--{$pattern}-->"; 
    @$ok = preg_match( "{{$pattern}}Ssi", $content ); 
    if ( $ok != true ) 
    { 
        return false; 
    } 
    $add = "{$pattern}\n{$text}"; 
    $new_content = str_replace( $pattern, $add, $content ); 
    return $new_content; 


// 刪除 
function m_txt_delete( $pattern, $content ) 

    $pattern_start =  "<!--$pattern-->"; 
    $pattern_end =  "<!--/$pattern-->"; 
    @$ok = preg_match( "{{$pattern_start}.*{$pattern_end}}Ssi", $content, $match ); 
    if ( $ok != true ) 
    { 
        return false; 
    } 
    $new_content = str_replace( $match[0], '', $content ); 
    return $new_content; 


//獲取 
function m_txt_get( $pattern, $content ) 

    $pattern_start =  "<!--$pattern-->"; 
    $pattern_end =  "<!--/$pattern-->"; 
    @$ok = preg_match( "{{$pattern_start}.*{$pattern_end}}Ssi", $content, $match ); 
    if ( $ok != true ) 
    { 
        return false; 
    } 
    return $match[0]; 

?>  



復制代碼 代碼如下:


<?php 
// 上傳函數 
function m_up_file( $files, $up_url, $type, $max_size = 2097152 ) 

    $i = 0; 
    if ( !is_array( $files ) ) 
    { 
        die( '參數傳遞錯誤' ); 
    } 
    $type_pattern = is_array( $type ) ? '\.(' . implode( ')|(', $type ) . ')' : "\.({$type})"; 
    foreach ( $files as $key => $arr ) 
    { 
        $ok = false; 
        if( $arr['error'] == 0 ) 
        { 
            if ( !is_uploaded_file( $arr['tmp_name'] ) ) 
            { 
                $err_msg .= "文件:<b>{$arr['name']}</b>不可上傳<br>"; 
                continue; 
            } 
            elseif ( $_FILES['up_file']['size'] > $max_size ) 
            { 
                $err_msg .= "文件:<b>{$arr['name']}</b>上傳失敗,原因是:文件超過限定大小<br>"; 
                continue; 
            } 
            elseif ( !preg_match( "!{$type_pattern}!Si", $arr['name'] ) ) 
            { 
                $err_msg .= "文件<b>{$arr['name']}</b>上傳失敗,原因是:格式不正確<br>"; 
                continue; 
            } 
            else 
            { 
                $txt = substr( str_shuffle( 'abcdefghijklmnopqrstuvwxyz' ), -4 ); 
                $hz = strtolower( strstr( $arr['name'], '.' ) ); 
                $new_name = date( 'YmdHis' ) . $txt . $hz; 
                if ( !is_array( $up_url ) ) 
                { 
                    !preg_match( '!\/$!', $up_url ) ? $up_url .= '/' : true; 
                    $new_url = $up_url . $new_name; 
                } 
                else 
                { 
                    $key = str_replace( '.', '', $hz ); 
                    $up_url = array_change_key_case( $up_url, CASE_LOWER ); 
                    !preg_match( '!\/$!', $up_url[$key] ) ? $up_url[$key] .= '/' : true; 
                    $new_url = $up_url[$key] . $new_name; 
                } 
                @$ok = move_uploaded_file( $arr['tmp_name'], THIS_DIR . $new_url ); 
            } 
        } 
        if ( $ok == true ) 
        { 
            $rs[$i]['url'] = $new_url; 
            $rs[$i]['name'] = $arr['name']; 
            $rs[$i]['type'] = strtoupper( str_replace( '.', '', $hz ) ); 
            $i++; 
        } 
        elseif( !empty($arr['name']) ) 
        { 
            $err_msg .= "文件<b>{$arr['name']}</b>上傳出錯<br>"; 
            continue; 
        } 
    } 
    return array( 'arr' => $rs, 'err_msg' => $err_msg, 'num' => $i ); 

?>  


相關文章

最新評論