bhq@iemsoft.cn
2018-11-27 e2b48dac099e43f4b3243cdf19a7522e4b5eccbe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
 
 
define('IN_ECS', true);
 
require(dirname(__FILE__) . '/includes/init.php');
require(dirname(__FILE__) . '/includes/lib_v_user.php');
 
if ((DEBUG_MODE & 2) != 2)
{
    $smarty->caching = true;
}
 
if($_CFG['is_distrib'] == 0)
{
    show_message('没有开启微信分销服务!','返回首页','index.php'); 
}
 
if($_SESSION['user_id'] == 0)
{
    ecs_header("Location: ./\n");
    exit;     
}
 
$is_distribor = is_distribor($_SESSION['user_id']);
if($is_distribor != 1)
{
    show_message('您还不是分销商!','去首页','index.php');
    exit;
}
 
if(isset($_REQUEST['act']) && $_REQUEST['act'] == 'insert_dianpu')
{
    $dianpu = array(
           'dianpu_name' => $_POST['dianpu_name'] ? $_POST['dianpu_name'] : '',
           'dianpu_desc' => $_POST['dianpu_desc'] ? $_POST['dianpu_desc'] : '',
           'phone'          => $_POST['phone'] ? $_POST['phone'] : '',
           'wechat'      => $_POST['wechat'] ? $_POST['wechat'] : '',
           'qq'          => $_POST['qq'] ? $_POST['qq'] : '',
           'address'      => $_POST['address'] ? $_POST['address'] : '',
           'user_id'      => $_SESSION['user_id']
    );
    if($dianpu['dianpu_name'] == '' || $dianpu['dianpu_desc'] == '' || $dianpu['phone'] == '' || $dianpu['wechat'] == '' || $dianpu['address'] == '')
    {
        show_message('店铺信息请填写完整!','返回上一页','v_user_dianpu_detail.php'); 
    }
    $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('dianpu') . " WHERE user_id = '" . $_SESSION['user_id'] . "'";
    $count = $GLOBALS['db']->getOne($sql);
    if($count == 0)
    {
        $GLOBALS['db']->autoExecute($GLOBALS['ecs']->table('dianpu'), $dianpu, 'INSERT');
        $error_no = $GLOBALS['db']->errno();
        if ($error_no > 0)
        {
            show_message($GLOBALS['db']->errorMsg());
        }
        else
        {
            ecs_header("Location: v_user_dianpu.php\n"); 
        }
    }
    else
    {
        $GLOBALS['db']->autoExecute($GLOBALS['ecs']->table('dianpu'), $dianpu, 'UPDATE' , "user_id = '" . $_SESSION['user_id'] . "'");
        $error_no = $GLOBALS['db']->errno();
        if ($error_no > 0)
        {
            show_message($GLOBALS['db']->errorMsg());
        }
        else
        {
            ecs_header("Location: v_user_dianpu.php\n"); 
        }
    }
}
 
 
if (!$smarty->is_cached('v_user_dianpu_detail.dwt', $cache_id))
{
    assign_template();
 
    $position = assign_ur_here();
    $smarty->assign('page_title',      $position['title']);    // 页面标题
    $smarty->assign('ur_here',         $position['ur_here']);  // 当前位置
 
    /* meta information */
    $smarty->assign('keywords',        htmlspecialchars($_CFG['shop_keywords']));
    $smarty->assign('description',     htmlspecialchars($_CFG['shop_desc']));
    $smarty->assign('user_info',get_user_info_by_user_id($_SESSION['user_id'])); 
    
    $smarty->assign('dianpu',get_dianpu_by_user_id($_SESSION['user_id']));
    $smarty->assign('user_id',$_SESSION['user_id']);
    
    /* 页面中的动态内容 */
    assign_dynamic('v_user_dianpu_detail');
}
 
$smarty->display('v_user_dianpu_detail.dwt', $cache_id);
 
 
?>