Server : Apache
System : Linux iZ2vcgyutqttsd1p850kl8Z 3.10.0-1160.92.1.el7.x86_64 #1 SMP Tue Jun 20 11:48:01 UTC 2023 x86_64
User : www ( 1000)
PHP Version : 5.6.40
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Directory :  /www/wwwroot/saimikebio.com/mobile/include/
Upload File :
Current Directory [ Writeable ] Root Directory [ Writeable ]


Current File : /www/wwwroot/saimikebio.com/mobile/include/lib_article.php
<?php



/**

 * ECSHOP 文章及文章分类相关函数库

 * ============================================================================

 * * 版权所有 2005-2012 上海商派网络科技有限公司,并保留所有权利。

 * 网站地址: http://www.ecshop.com;

 * ----------------------------------------------------------------------------

 * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和

 * 使用;不允许对程序代码以任何形式任何目的的再发布。

 * ============================================================================

 * $Author: liubo $

 * $Id: lib_article.php 17217 2011-01-19 06:29:08Z liubo $

*/



if (!defined('IN_ECTOUCH'))

{

    die('Hacking attempt');

}



/**

 * 获得文章分类下的文章列表

 *

 * @access  public

 * @param   integer     $cat_id

 * @param   integer     $page

 * @param   integer     $size

 *

 * @return  array

 */

function get_cat_articles($cat_id, $page = 1, $size = 20 ,$requirement='')

{

    //取出所有非0的文章

    if ($cat_id == '-1')

    {

        $cat_str = 'cat_id > 0';

    }

    else

    {

        $cat_str = get_article_children($cat_id);

    }

    //增加搜索条件,如果有搜索内容就进行搜索    

    if ($requirement != '')

    {

        $sql = 'SELECT article_id, title, author, add_time, file_url, open_type' .

               ' FROM ' .$GLOBALS['ecs']->table('article') .

               ' WHERE is_open = 1 AND title like \'%' . $requirement . '%\' ' .

               ' ORDER BY article_type DESC, article_id DESC';

    }

    else 

    {

        

        $sql = 'SELECT article_id, title, author, add_time, file_url, open_type' .

               ' FROM ' .$GLOBALS['ecs']->table('article') .

               ' WHERE is_open = 1 AND ' . $cat_str .

               ' ORDER BY article_type DESC, article_id DESC';

    }



    $res = $GLOBALS['db']->selectLimit($sql, $size, ($page-1) * $size);



    $arr = array();

    if ($res)

    {

        while ($row = $GLOBALS['db']->fetchRow($res))

        {

            $article_id = $row['article_id'];



            $arr[$article_id]['id']          = $article_id;

            $arr[$article_id]['title']       = $row['title'];

            $arr[$article_id]['short_title'] = $GLOBALS['_CFG']['article_title_length'] > 0 ? sub_str($row['title'], $GLOBALS['_CFG']['article_title_length']) : $row['title'];

            $arr[$article_id]['author']      = empty($row['author']) || $row['author'] == '_SHOPHELP' ? $GLOBALS['_CFG']['shop_name'] : $row['author'];

            $arr[$article_id]['url']         = $row['open_type'] != 1 ? build_uri('article', array('aid'=>$article_id), $row['title']) : trim($row['file_url']);

            $arr[$article_id]['add_time']    = date($GLOBALS['_CFG']['date_format'], $row['add_time']);

        }

    }



    return $arr;

}



/**

 * 获得指定分类下的文章总数

 *

 * @param   integer     $cat_id

 *

 * @return  integer

 */

function get_article_count($cat_id ,$requirement='')

{

    global $db, $ecs;

    if ($requirement != '')

    {

        $count = $db->getOne('SELECT COUNT(*) FROM ' . $ecs->table('article') . ' WHERE ' . get_article_children($cat_id) . ' AND  title like \'%' . $requirement . '%\'  AND is_open = 1');

    }

    else

    {

        $count = $db->getOne("SELECT COUNT(*) FROM " . $ecs->table('article') . " WHERE " . get_article_children($cat_id) . " AND is_open = 1");

    }

    return $count;

}

function child_article_categories_tree($cat_id)
{
        $sql = 'SELECT * ' .
               ' FROM ' .$GLOBALS['ecs']->table('article_cat') .
               ' WHERE parent_id = ' . $cat_id . ' ORDER BY cat_id DESC, sort_order DESC';
    $res = $GLOBALS['db']->query($sql);
    $arr = array();
    if ($res)
    {
        while ($row = $GLOBALS['db']->fetchRow($res))
        {
            $article_cat = $row['cat_id'];

            $arr[$article_cat]['cat_id']          = $article_cat;
            $arr[$article_cat]['cat_name']       = $row['cat_name'];			
			$arr[$article_cat]['cat_url']  = build_uri('article_cat', array('acid' => $row['cat_id']), $row['cat_name']);
        }
    }
    return $arr;
}

?>