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


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



/**

 * 红包独立页 红包独立页 会员直接领取红包红包插件

 */



define('IN_ECTOUCH', true);



require(dirname(__FILE__) . '/include/init.php');



if ((DEBUG_MODE & 2) != 2)

{

    $smarty->caching = true;

}



/* 获得当前页码 */

$page = isset($_REQUEST['page']) && intval($_REQUEST['page']) > 0 ? intval($_REQUEST['page']) : 1;

$size = 20;

$action = isset($_REQUEST['act']) ? trim($_REQUEST['act']) : 'default';

if ($action == 'getBonus')

{

	

    $type_id  = isset($_REQUEST['type_id']) ? trim($_REQUEST['type_id']) : 0;

    if (empty($_SESSION['user_id']))

    {

        show_message($GLOBALS['_LANG']['bonus_no_login'], array($GLOBALS['_LANG']['bonus_login'], $_LANG['back_up_page']), array('user.php', 'javascript:history.back(-1)'), 'error');

    }

	$suppId  = $_REQUEST['suppId'];

    $user_id = $_SESSION['user_id'];

    //检查是否领取过

	$user_bonus_max = $db->getOne("SELECT user_bonus_max FROM " . $ecs->table('bonus_type') . " WHERE type_id = $type_id");

	

    $sql = "select count(*) from " . $ecs->table('user_bonus'). " where bonus_type_id='$type_id' and user_id=$user_id";

    $count = $db->getOne($sql);

    if ($count>$user_bonus_max || $count==$user_bonus_max)

    {

        show_message($GLOBALS['_LANG']['bonus_isbonus'], $GLOBALS['_LANG']['bonus_other'], 'bonus.php', 'error');

    }

    $sql = 'SELECT user_id, email, user_name FROM ' . $ecs->table('users')." where user_id='$user_id'";

    $user_info = $db->getRow($sql);

    $bonus_type = bonus_type_info($type_id);

    $tpl = get_mail_template('send_bonus');

    $today = local_date($_CFG['date_format']);

    $smarty->assign('user_name', $user_info['user_name']);

    $smarty->assign('shop_name', $GLOBALS['_CFG']['shop_name']);

    $smarty->assign('send_date', $today);

    $smarty->assign('count', 1);

    $smarty->assign('money', price_format($bonus_type['type_money']));

    $content = $smarty->fetch('str:' . $tpl['template_content']);

    if (add_to_maillist($user_info['user_name'], $user_info['email'], $tpl['template_subject'], $content, $tpl['is_html']))

    {

        /* 向会员红包表录入数据 */

        $sql = "INSERT INTO " . $ecs->table('user_bonus') .

                "(bonus_type_id, bonus_sn, user_id, used_time, order_id, emailed) " .

                "VALUES ('$type_id', 0, '$user_info[user_id]', 0, 0, " .BONUS_MAIL_SUCCEED. ")";

        $db->query($sql);

    }

    else

    {

        /* 邮件发送失败,更新数据库 */

        $sql = "INSERT INTO " . $ecs->table('user_bonus') .

                "(bonus_type_id, bonus_sn, user_id, used_time, order_id, emailed) " .

                "VALUES ('$type_id', 0, '$user_info[user_id]', 0, 0, " .BONUS_MAIL_FAIL. ")";

        $db->query($sql);

    }

    show_message($GLOBALS['_LANG']['bonus_success'],array($GLOBALS['_LANG']['bonus_continue'], $GLOBALS['_LANG']['bonus_mybonus']), array('bonus.php', 'user.php?act=bonus'), 'info');

}

elseif($action=='default')

{

    /* 获得页面的缓存ID */

    $cache_id = sprintf('%X', crc32($page . '-' . $_CFG['lang']));

    if (!$smarty->is_cached('comment-list.dwt', $cache_id))

    {

        /* 如果页面没有被缓存则重新获得页面的内容 */

        assign_template('a');

        $position = assign_ur_here(0, $GLOBALS['_LANG']['bonus_pagetitle']);

        $smarty->assign('page_title', $position['title']); // 页面标题

        $smarty->assign('ur_here', $position['ur_here']); // 当前位置

        $smarty->assign('helps', get_shop_help()); // 网店帮助

        $smarty->assign('keywords', $GLOBALS['_LANG']['bonus_pagetitle'] . htmlspecialchars($_CFG['shop_keywords']));

        $smarty->assign('description', $GLOBALS['_LANG']['bonus_pagetitle'] . htmlspecialchars($_CFG['shop_desc']));

        $count = get_bonus_count();

        $max_page = ($count> 0) ? ceil($count / $size) : 1;

        if ($page > $max_page)

        {

            $page = $max_page;

        }

        $bonus_list = get_bonus_list($size, $page);

        $smarty->assign('bonus_list', $bonus_list);

        $pager = get_pager('user.php', array('act' => $action), $record_count, $page, 8);

        $smarty->assign('pager', $pager);

        $smarty->assign('categories', get_categories_tree(0)); // 分类树

    }

    $smarty->display('bonus_list.dwt', $cache_id);

}



function get_bonus_list($size, $page)

{

    $cur_date = gmtime();

    $where = " where send_start_date <= $cur_date and send_end_date >= $cur_date and send_type=4";

    $sql = 'SELECT * FROM ' . $GLOBALS['ecs']->table('bonus_type') . " as bt $where ORDER BY type_money asc";

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

    $arr = array();

    $ids = '';

    while ($row = $GLOBALS['db']->fetchRow($res))
    {
        $row['use_start_date'] = local_date('Y.m.d', $row['use_start_date']);
        $row['use_end_date'] = local_date('Y.m.d', $row['use_end_date']);
		$row['type_money'] = intval($row['type_money']);
		$row['min_goods_amount'] = intval($row['min_goods_amount']);
		if ($_SESSION['user_id']) {
			$r = $GLOBALS['db']->getOne('SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('user_bonus') . ' WHERE bonus_type_id=\'' . $row['type_id'] . '\' AND user_id =\'' . $_SESSION['user_id'] . '\'');

			if ($r> $row['user_bonus_max'] || $r==$row['user_bonus_max']) {
				$row['is_receive'] = 1;
			}
			else {
				$row['is_receive'] = 0;
			}
		}
        $arr[] = $row;
    }
    return $arr;

}



function get_bonus_count($children, $comment_rank = 0)

{

    $cur_date = gmtime();

    $where = " where 1 and send_start_date <= $cur_date and send_end_date >= $cur_date and send_type=0";

    $count = $GLOBALS['db']->getOne("SELECT COUNT(*) FROM " .$GLOBALS['ecs']->table('bonus_type')." as b $where ");

    return $count;

	

}



function bonus_type_info($bonus_type_id)

{

    $sql = "SELECT * FROM " . $GLOBALS['ecs']->table('bonus_type') . " WHERE type_id = '$bonus_type_id'";

    return $GLOBALS['db']->getRow($sql);

}



function add_to_maillist($username, $email, $subject, $content, $is_html)

{

    $time = time();

    $content = addslashes($content);

    $template_id = $GLOBALS['db']->getOne("SELECT template_id FROM " . $GLOBALS['ecs']->table('mail_templates') . " WHERE template_code = 'send_bonus'");

    $sql = "INSERT INTO " . $GLOBALS['ecs']->table('email_sendlist') . " (email, template_id, email_content, pri, last_send) VALUES ('$email', $template_id, '$content', 1, '$time')";

    $GLOBALS['db']->query($sql);

    return true;

}



?>