ecshop二次開發(fā)之常用函數(shù)匯總

字號:


    本文詳細匯總了ecshop二次開發(fā)中常用的函數(shù)。分享給大家供大家參考。具體如下:
    最近進行ecshop的二次開發(fā),整理了一部分的函數(shù),另外在ecshop論壇上面也發(fā)現(xiàn)了很多函數(shù)說明,整理匯總?cè)缦?,供大家參考?BR>    所有函數(shù)功能說明:
    lib_time.php
    gmtime()
    說明:獲得當前格林威治時間的時間戳
    server_timezone()
    說明:獲得服務(wù)器的時區(qū)
    local_mktime($hour = NULL , $minute= NULL, $second = NULL, $month = NULL, $day = NULL, $year = NULL)
    說明:生成一個用戶自定義時區(qū)日期的GMT時間戳
    local_date($format, $time = NULL)
    說明:將GMT時間戳格式化為用戶自定義時區(qū)日期
    gmstr2time($str)
    說明:轉(zhuǎn)換字符串形式的時間表達式為GMT時間戳
    local_strtotime($str)
    說明:將一個用戶自定義時區(qū)的日期轉(zhuǎn)為GMT時間戳
    local_gettime($timestamp = NULL)
    說明:獲得用戶所在時區(qū)指定的時間戳
    local_getdate($timestamp = NULL)
    說明:獲得用戶所在時區(qū)指定的日期和時間信息
    lib_base.php
    sub_str($str, $length = 0, $append = true)
    說明:截取UTF-8編碼下字符串的函數(shù)
    real_ip()
    說明:獲得用戶的真實IP地址
    str_len($str)
    說明:計算字符串的長度(漢字按照兩個字符計算)
    get_crlf()
    說明:獲得用戶操作系統(tǒng)的換行符
    send_mail($name, $email, $subject, $content, $type = 0, $notification=false)
    說明:郵件發(fā)送
    gd_version()
    說明:獲得服務(wù)器上的 GD 版本
    file_get_contents($file)
    說明:如果系統(tǒng)不存在file_get_contents函數(shù)則聲明該函數(shù)
    file_put_contents($file, $data, $flags = '')
    說明:如果系統(tǒng)不存在file_put_contents函數(shù)則聲明該函數(shù)
    floatval($n)
    說明:如果系統(tǒng)不存在 floatval 函數(shù)則聲明該函數(shù)
    file_mode_info($file_path)
    說明:文件或目錄權(quán)限檢查函數(shù)
    log_write($arg, $file = '', $line = '')
    說明:寫入日志內(nèi)容
    make_dir($folder)
    說明:檢查目標文件夾是否存在,如果不存在則自動創(chuàng)建該目錄
    gzip_enabled()
    說明:獲得系統(tǒng)是否啟用了 gzip
    addslashes_deep($value)
    說明:遞歸方式的對變量中的特殊字符進行轉(zhuǎn)義
    addslashes_deep_obj($obj)
    說明:將對象成員變量或者數(shù)組的特殊字符進行轉(zhuǎn)義
    stripslashes_deep($value)
    說明:遞歸方式的對變量中的特殊字符去除轉(zhuǎn)義
    make_semiangle($str)
    說明:將一個字串中含有全角的數(shù)字字符、字母、空格或'%+-()'字符轉(zhuǎn)換為相應(yīng)半角字符
    check_file_type($filename, $realname = '', $limit_ext_types = '')
    說明:檢查文件類型 /文件名/真實文件名/允許的文件類型
    mysql_like_quote($str)
    說明:對 MYSQL LIKE 的內(nèi)容進行轉(zhuǎn)義 過濾掉_ %等字符.
    real_server_ip()
    說明:獲取服務(wù)器的ip
    ecs_header($string, $replace = true, $http_response_code = 0)
    說明:自定義 header 函數(shù),用于過濾可能出現(xiàn)的安全隱患
    ecs_iconv($source_lang, $target_lang, $source_string = '')
    說明:自定義的編碼轉(zhuǎn)換
    ecs_geoip($ip)
    說明:取得IP的地址,采用IP庫
    trim_right($str)
    說明:去除字符串右側(cè)可能出現(xiàn)的亂碼
    move_upload_file($file_name, $target_name = '')
    說明:將上傳文件轉(zhuǎn)移到指定位置
    json_str_iconv($str)
    說明:將JSON傳遞的參數(shù)轉(zhuǎn)碼
    get_file_suffix($file_name, $allow_type = array())
    說明:獲取文件后綴名,并判斷是否合法
    read_static_cache($cache_name)
    說明:讀結(jié)果緩存文件
    write_static_cache($cache_name, $caches)
    說明:寫結(jié)果緩存文件
    lib_common.php (公用函數(shù)庫)
    db_create_in($item_list, $field_name = '')
    說明:創(chuàng)建像這樣的查詢: “IN('a','b')” $item_list為數(shù)組
    is_email($user_email)
    說明:驗證輸入的郵件地址是否合法
    is_time($time)
    說明:檢查是否為一個合法的時間格式
    assign_query_info()
    說明:獲得查詢時間和次數(shù),并賦值給smarty
    region_result($parent, $sel_name, $type)
    說明:創(chuàng)建地區(qū)的返回信息
    get_regions($type = 0, $parent = 0)
    說明:獲得指定國家的所有省份, 函數(shù)需要數(shù)據(jù)庫支持.
    get_shipping_config($area_id)
    說明:獲得配送區(qū)域中指定的配送方式的配送費用的計算參數(shù) 比如快捷公司不同.
    init_users()
    說明:初始化會員數(shù)據(jù)整合類
    cat_list($cat_id = 0, $selected = 0, $re_type = true, $level = 0, $is_show_all = true)
    說明:獲得指定分類下的子分類的數(shù)組, $re_type控制返回類型
    cat_options($spec_cat_id, $arr)
    說明:過濾和排序所有分類,返回一個帶有縮進級別的數(shù)組
    load_config()
    說明:載入配置信息
    get_brand_list()
    說明:取得品牌列表
    get_brands($cat = 0, $app = 'brand')
    說明:獲得某個分類下的品牌列表
    get_promotion_info($goods_id = '')
    說明:所有的促銷活動信息
    get_children($cat = 0)
    說明:獲得指定分類下所有底層分類的ID
    get_article_children ($cat = 0)
    說明:獲得指定文章分類下所有底層分類的ID
    get_mail_template($tpl_name)
    說明:獲取郵件模板
    order_action($order_sn, $order_status, $shipping_status, $pay_status, $note = '', $username = null)
    說明:記錄訂單操作記錄
    price_format($price, $change_price = true)
    說明:格式化商品價格
    get_virtual_goods($order_id, $shipping = false)
    說明:返回訂單中的虛擬商品 記錄是否發(fā)貨.
    virtual_goods_ship(&$virtual_goods, &$msg, $order_sn, $return_result = false, $process = 'other')
    說明:虛擬商品發(fā)貨
    virtual_card_shipping ($goods, $order_sn, &$msg, $process = 'other')
    說明:虛擬卡發(fā)貨
    virtual_card_result($order_sn, $goods)
    說明:返回虛擬卡信息
    get_snatch_result($id)
    說明:獲取指定 id snatch 活動的結(jié)果
    clear_tpl_files($is_cache = true, $ext = '')
    說明:清除指定后綴的模板緩存或編譯文件
    clear_compiled_files($ext = '')
    說明:清除模版編譯文件
    clear_cache_files($ext = '')
    說明:清除緩存文件
    clear_all_files($ext = '')
    說明:清除模版編譯和緩存文件
    smarty_insert_scripts($args)
    說明:頁面上調(diào)用的js文件,組合功能.
    smarty_create_pages($params)
    說明:創(chuàng)建分頁的列表
    build_uri($app, $params, $append = '', $page = 0, $size = 0)
    說明:重寫 URL 地址
    formated_weight($weight)
    說明:格式化重量
    log_account_change($user_id, $user_money = 0, $frozen_money = 0, $rank_points = 0, $pay_points = 0, $change_desc = '', $change_type = ACT_OTHER)
    說明:記錄帳戶變動
    article_cat_list($cat_id = 0, $selected = 0, $re_type = true, $level = 0)
    說明:獲得指定分類下的子分類的數(shù)組/ 向下取數(shù)組.
    article_cat_options($spec_cat_id, $arr)
    說明:過濾和排序所有文章分類,返回一個帶有縮進級別的數(shù)組
    uc_call($func, $params=null)
    說明:調(diào)用UCenter的函數(shù)
    exception_handler($errno, $errstr, $errfile, $errline)
    說明:error_handle回調(diào)函數(shù)未啟用.
    get_image_path($goods_id, $image='', $thumb=false, $call='goods', $del=false)
    說明:重新獲得商品圖片與商品相冊的地址
    user_uc_call($func, $params = null)
    說明:調(diào)用使用UCenter插件時的函數(shù)
    get_volume_price_list($goods_id, $price_type = '1')
    說明:取得商品優(yōu)惠價格列表
    get_final_price($goods_id, $goods_num = '1', $is_spec_price = false, $spec = array())
    說明:取得商品最終使用價格
    get_package_info($id)
    說明:獲取指定id package 的信息
    get_package_goods($package_id)
    說明:獲得指定禮包的商品lib_main.php (前臺公用函數(shù)庫)
    update_user_info()
    說明:更新用戶SESSION,COOKIE及登錄時間、登錄次數(shù)。
    get_user_info($id=0)
    說明:獲取用戶信息數(shù)組
    assign_ur_here($cat = 0, $str = '')
    說明:取得當前位置和頁面標題
    get_parent_cats($cat)
    說明:獲得指定分類的所有上級分類
    build_pagetitle($arr, $type = 'category')
    說明:根據(jù)提供的數(shù)組編譯成頁面標題
    build_urhere($arr, $type = 'category')
    說明:根據(jù)提供的數(shù)組編譯成當前位置
    assign_dynamic($tmp)
    說明:獲得指定頁面的動態(tài)內(nèi)容
    assign_articles($id, $num)
    說明:分配文章列表給smarty
    get_shop_help()
    說明:分配幫助信息
    assign_pager($app, $cat, $record_count, $size, $sort, $order, $page = 1,$keywords = '', $brand = 0, $price_min = 0, $price_max = 0, $display_type = 'list', $filter_attr='', $url_format='', $sch_array='')
    說明:創(chuàng)建分頁信息.分頁函數(shù).
    get_pager($url, $param, $record_count, $page = 1, $size = 10)
    說明:生成給pager.lbi賦值的數(shù)組
    get_vote($id = '')
    說明:調(diào)用調(diào)查內(nèi)容
    get_user_browser()
    說明:獲得瀏覽器名稱和版本
    is_spider($record = true)
    說明:判斷是否為搜索引擎蜘蛛
    get_os()
    說明:獲得客戶端的操作系統(tǒng)
    visit_stats()
    說明:統(tǒng)計訪問信息
    save_searchengine_keyword($domain, $path)
    說明:保存搜索引擎關(guān)鍵字
    get_tags($goods_id = 0, $user_id = 0)
    說明:獲得指定用戶、商品的所有標記
    get_dyna_libs($theme, $tmp)
    說明:獲取指定主題某個模板的主題的動態(tài)模塊
    dyna_libs_replace($matches)
    說明:換動態(tài)模塊
    upload_file($upload, $type)
    說明:處理上傳文件,并返回上傳圖片名(上傳失敗時返回圖片名為空)
    show_message($content, $links = '', $hrefs = '', $type = 'info', $auto_redirect = true)
    說明:顯示一個提示信息
    parse_rate_value($str, &$operate)
    說明:將一個形如+10, 10, -10, 10%的字串轉(zhuǎn)換為相應(yīng)數(shù)字,并返回操作符號
    recalculate_price()
    說明:重新計算購物車中的商品價格:目的是當用戶登錄時享受會員價格,當用戶退出登錄時不享受會員價格
    assign_comment($id, $type, $page = 1)
    說明:查詢評論內(nèi)容
    assign_template($ctype = '', $catlist = array())
    說明:默認的smarty賦值
    time2gmt($time)
    說明:將一個本地時間戳轉(zhuǎn)成GMT時間戳
    get_user_bonus($user_id = 0)
    說明:查詢會員的紅包金額
    set_affiliate()
    說明:保存推薦uid
    get_affiliate()
    說明:獲取推薦uid
    article_categories_tree($cat_id = 0)
    說明:獲得指定分類同級的所有分類以及該分類下的子分類
    get_article_parent_cats($cat)
    說明:獲得指定文章分類的所有上級分類
    get_library_number($library, $template = null)
    說明:取得某模板某庫設(shè)置的數(shù)量
    get_navigator($ctype = '', $catlist = array())
    說明:取得自定義導(dǎo)航欄列表
    license_info()
    說明:授權(quán)信息內(nèi)容
    lib_insert.php (動態(tài)內(nèi)容函數(shù)庫)
    insert_query_info()
    說明:獲得查詢次數(shù)以及查詢時間
    insert_history()
    說明:調(diào)用瀏覽歷史
    insert_cart_info()
    說明:調(diào)用購物車信息
    insert_ads($arr)
    說明:調(diào)用指定的廣告位的廣告
    insert_member_info()
    說明:調(diào)用會員信息
    insert_comments($arr)
    說明:調(diào)用評論信息
    insert_vote()
    說明:調(diào)用在線調(diào)查信息
    lib_goods.php (商品相關(guān)函數(shù)庫)
    goods_sort($goods_a, $goods_b)
    說明:商品推薦usort用自定義排序行數(shù)
    get_categories_tree($cat_id = 0)
    說明:獲得指定分類同級的所有分類以及該分類下的子分類
    get_child_tree($tree_id = 0)
    說明:取和指定分類ID下的分類樹
    get_top10($cats = '')
    說明:調(diào)用當前分類的銷售排行榜
    get_recommend_goods($type = '', $cats = '')
    說明:獲得推薦商品
    get_promote_goods($cats = '')
    說明:獲得促銷商品
    get_category_recommend_goods($type = '', $cats = '', $brand = 0, $min =0, $max = 0, $ext='')
    說明:獲得指定分類下的推薦商品
    get_goods_info($goods_id)
    說明:獲得商品的詳細信息
    get_goods_properties($goods_id)
    說明:獲得商品的屬性和規(guī)格
    get_same_attribute_goods($attr)
    說明:獲得屬性相同的商品
    get_goods_gallery($goods_id)
    說明:獲得指定商品的相冊
    assign_cat_goods($cat_id, $num = 0, $from = 'web')
    說明:獲得指定分類下的商品
    assign_brand_goods($brand_id, $num = 0, $cat_id = 0)
    說明:獲得指定的品牌下的商品
    get_extension_goods($cats)
    說明:獲得所有擴展分類屬于指定分類的所有商品ID
    bargain_price($price, $start, $end)
    說明:判斷某個商品是否正在特價促銷期
    spec_price($spec)
    說明:獲得指定的規(guī)格的價格
    group_buy_info($group_buy_id, $current_num = 0)
    說明:取得團購活動信息
    group_buy_stat($group_buy_id, $deposit)
    說明:取得某團購活動統(tǒng)計信息
    group_buy_status($group_buy)
    說明:獲得團購的狀態(tài)
    auction_info($act_id, $config = false)
    說明:取得拍賣活動信息
    auction_log($act_id)
    說明:取得拍賣活動出價記錄
    auction_status($auction)
    說明:計算拍賣活動狀態(tài)(注意參數(shù)一定是原始信息)
    goods_info($goods_id)
    說明:取得商品信息
    favourable_info($act_id)
    說明:取得優(yōu)惠活動信息
    wholesale_info($act_id)
    說明:批發(fā)信息
    add_style($goods_name, $style)
    說明:添加商品名樣式
    get_goods_attr($goods_id)
    說明:取得商品屬性
    get_goods_fittings($goods_list = array())
    說明:獲得購物車中商品的配件
    lib_article.php (文章及文章分類相關(guān)函數(shù)庫)
    get_cat_articles($cat_id, $page = 1, $size = 20 ,$requirement='')
    說明:獲得文章分類下的文章列表
    get_article_count($cat_id ,$requirement='')
    說明:獲得指定分類下的文章總數(shù)
    希望本文所述對大家的ecshop二次開發(fā)有所幫助。