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/ecshopjcw/
Upload File :
Current Directory [ Writeable ] Root Directory [ Writeable ]


Current File : /www/wwwroot/saimikebio.com/ecshopjcw/shaidan.php
<?php

/**
 * ECSHOP 管理中心信息管理
 * ============================================================================
 * * 版权所有 2005-2012 上海商派网络科技有限公司,并保留所有权利。
 * 网站地址: http://www.ecshop.com;
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用;不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: liubo $
 * $Id: brand.php 17217 2011-01-19 06:29:08Z liubo $
*/

define('IN_ECS', true);

require(dirname(__FILE__) . '/includes/init.php');
$exc = new exchange($ecs->table("shaidan"), $db, 'shaidan_id', 'title');

/*------------------------------------------------------ */
//-- 信息列表
/*------------------------------------------------------ */
if ($_REQUEST['act'] == 'list')
{	
    /* 检查权限 */
    admin_priv('comment_priv');
    $smarty->assign('ur_here',      '用户晒单');
    $smarty->assign('full_page',    1);

	
    $member_list = get_shaidanlist();
    $smarty->assign('member_list',     $member_list['arr']);
    $smarty->assign('filter',          $member_list['filter']);
    $smarty->assign('record_count',    $member_list['record_count']);
    $smarty->assign('page_count',      $member_list['page_count']);

    assign_query_info();
    $smarty->display('shaidan_list.htm');
}


/*------------------------------------------------------ */
//-- 编辑信息
/*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'edit')
{
    /* 检查权限 */
    admin_priv('comment_priv');
	$shaidan_id = intval($_REQUEST['id']);
    $info = $db->GetRow("SELECT * FROM " .$ecs->table('shaidan'). " WHERE shaidan_id='$shaidan_id'");
	$info['add_time'] = date("Y-m-d",$info['add_time']);
	$goods = $db->GetRow("SELECT * FROM " .$ecs->table('order_goods'). " WHERE rec_id='$info[rec_id]'");
	$shaidan_imgs = $GLOBALS['db']->getAll("SELECT * FROM ".$GLOBALS['ecs']->table('shaidan_img')." WHERE shaidan_id = '$shaidan_id'");	
	
	
	//该商品第几位晒单者
	$res = $db->getAll("SELECT shaidan_id FROM ".$ecs->table("shaidan")." WHERE goods_id = '$info[goods_id]' ORDER BY add_time ASC");
	foreach ($res as $key => $value)
	{
		if ($shaidan_id == $value['shaidan_id'])
		{
			$weizhi = $key + 1;	
		}
	}
	//图片数量
	$imgnum = count($shaidan_imgs);
	
	
	//是否赠送积分
	if ($info['is_points'] == 0 && $weizhi <= $_CFG['shaidan_pre_num'] && $imgnum >= $_CFG['shaidan_img_num'])
	{
		$get_points = 1;	
	}
	else
	{
		$get_points = 0;
	}
	
	
	
	$smarty->assign('ur_here',     '晒单详情');
	$smarty->assign('weizhi',      $weizhi);
    $smarty->assign('imgnum',      $imgnum);
	$smarty->assign('get_points',      $get_points);
	$smarty->assign('shop_config', $_CFG);
    $smarty->assign('action_link', array('text' => '返回', 'href' => 'shaidan.php?act=list&' . list_link_postfix()));
    $smarty->assign('info',       $info);
	$smarty->assign('goods',       $goods);
	$smarty->assign('shaidan_imgs',          $shaidan_imgs);
    $smarty->assign('form_action', 'updata');

    assign_query_info();
    $smarty->display('shaidan_info.htm');
}
elseif ($_REQUEST['act'] == 'updata')
{
    /* 检查权限 */
    admin_priv('comment_priv');
	$shaidan_id = intval($_POST['shaidan_id']);
	$get_points = intval($_POST['get_points']);
	$pay_points = $_CFG['shaidan_pay_points'];
	$status = intval($_POST['status']);
	
	
	if ($get_points == 1 && $pay_points > 0)
	{
		$info = $db->GetRow("SELECT * FROM " .$ecs->table('shaidan'). " WHERE shaidan_id='$shaidan_id'");		
		$db->query("UPDATE ".$ecs->table('shaidan')." SET pay_points = '$pay_points', is_points = 1 WHERE shaidan_id = '$shaidan_id'");	
		$db->query("INSERT INTO ".$ecs->table('account_log')."(user_id, rank_points, pay_points, change_time, change_desc, change_type) ".
				"VALUES ('$info[user_id]', 0, '".$pay_points."', ".gmtime().", '晒单获得积分', '99')");
		$log = $db->getRow("SELECT SUM(rank_points) AS rank_points, SUM(pay_points) AS pay_points FROM ".$ecs->table("account_log")." WHERE user_id = '$info[user_id]'");
		$db->query("UPDATE " . $ecs->table('users') . " SET rank_points = '".$log['rank_points']."', pay_points = '".$log['pay_points']."' WHERE user_id = '$info[user_id]'");
	}
	
	$db->query("UPDATE ".$ecs->table('shaidan')." SET status = '$status' WHERE shaidan_id = '$shaidan_id'");
	
    $link[0]['text'] = '返回列表';
    $link[0]['href'] = 'shaidan.php?act=list';
    sys_msg('操作成功',0, $link);
}


/*------------------------------------------------------ */
//-- 排序、分页、查询
/*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'query')
{
    $member_list = get_shaidanlist();
    $smarty->assign('member_list',     $member_list['arr']);
    $smarty->assign('filter',          $member_list['filter']);
    $smarty->assign('record_count',    $member_list['record_count']);
    $smarty->assign('page_count',      $member_list['page_count']);

    make_json_result($smarty->fetch('shaidan_list.htm'), '',
        array('filter' => $member_list['filter'], 'page_count' => $member_list['page_count']));
}

/**
 * 获取信息列表
 *
 * @access  public
 * @return  array
 */
function get_shaidanlist()
{
    $result = get_filter();
    if ($result === false)
    {
        $filter = array();
        $filter['title']    = empty($_REQUEST['title']) ? '' : trim($_REQUEST['title']);
		$filter['goods_name'] = empty($_REQUEST['goods_name']) ? '' : trim($_REQUEST['goods_name']);
		$filter['user_name'] = empty($_REQUEST['user_name']) ? '' : trim($_REQUEST['user_name']);
        if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1)
        {
            $filter['title'] = json_str_iconv($filter['title']);
			$filter['goods_name'] = json_str_iconv($filter['goods_name']);
			$filter['user_name'] = json_str_iconv($filter['user_name']);
        }
        $filter['sort_by']    = empty($_REQUEST['sort_by']) ? 'a.shaidan_id' : trim($_REQUEST['sort_by']);
        $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);

        $where = '';
        if (!empty($filter['title']))
        {
            $where .= " AND a.title LIKE '%" . mysql_like_quote($filter['title']) . "%'";
        }
		if (!empty($filter['goods_name']))
        {
            $where .= " AND og.goods_name LIKE '%" . mysql_like_quote($filter['goods_name']) . "%'";
        }
		if (!empty($filter['user_name']))
        {
            $where .= " AND u.user_name LIKE '%" . mysql_like_quote($filter['user_name']) . "%'";
        }

        /* 总数 */
        $sql = 'SELECT COUNT(*) FROM ' .$GLOBALS['ecs']->table('shaidan'). ' AS a '.
               'LEFT JOIN ' .$GLOBALS['ecs']->table('users'). ' AS u ON u.user_id = a.user_id '.
			   'LEFT JOIN ' .$GLOBALS['ecs']->table('order_goods'). ' AS og ON og.rec_id = a.rec_id '.
               'WHERE 1 ' .$where;
        $filter['record_count'] = $GLOBALS['db']->getOne($sql);

        $filter = page_and_size($filter);

        /* 数据 */
        $sql = 'SELECT a.* , u.user_name, og.goods_name '.
               'FROM ' .$GLOBALS['ecs']->table('shaidan'). ' AS a '.
               'LEFT JOIN ' .$GLOBALS['ecs']->table('users'). ' AS u ON u.user_id = a.user_id '.
			   'LEFT JOIN ' .$GLOBALS['ecs']->table('order_goods'). ' AS og ON og.rec_id = a.rec_id '.
               'WHERE 1 ' .$where. ' ORDER by '.$filter['sort_by'].' '.$filter['sort_order'];

        $filter['title'] = stripslashes($filter['title']);
        set_filter($filter, $sql);
    }
    else
    {
        $sql    = $result['sql'];
        $filter = $result['filter'];
    }
    $arr = array();
    $res = $GLOBALS['db']->selectLimit($sql, $filter['page_size'], $filter['start']);

    while ($member = $GLOBALS['db']->fetchRow($res))
    {
		$member['add_time'] = date("Y-m-d",$member['add_time']);
        $arr[] = $member;
    }
    return array('arr' => $arr, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
}

?>