/var/www/(Del)gepgroup.hk/webadmin/cms_user_form.php


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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
require_once( realpath(dirname(__FILE__)) . '/../common/config.php');
require_once( 
realpath(dirname(__FILE__)) . '/function_is_login.php');
if (!
is_login())
{
    
header("Location: index.php");
    exit;
}

//----------------------------------------------------
// Submit information
//----------------------------------------------------
if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST')
{
    
$id $_POST['id'];
    
$action strlen($id) ? 'Modify' 'Add';
    
    if (
strlen($id))
    {
        
$model SysCmsUser::first($id);
    }
    else
    {
        
$model = new SysCmsUser(array(
            
'role' => 'user',
            
'actived' => 1,
        ));
    }
    
    
$post $_POST;
    unset(
$post['password']);
    if (!empty(
$_POST['password'])) {
        
$post['password'] = md5($_POST['password']);
    }
    
$model->safe_set_attributes($post);
    
    if (
$model->save())
    {
        
header("Location: cms_user_index.php?msg=" $action "%20Success");
        exit;
    }
}

//----------------------------------------------------
// Initialize
//----------------------------------------------------
$id $_GET['id'];
$action strlen($id) ? 'Modify' 'Add';

if (isset(
$model))
{
    if (
$model->is_new_record())
        
$model->id NULL;
}
else
{
    
$model strlen($id) ? SysCmsUser::first($id) : new SysCmsUser;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <title>Content Management System (CMS) - Powered by One Solution Limited</title>
    <link rel="stylesheet" type="text/css" href="css/style.css" />
    <script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="js/jquery.blockUI.js"></script>
    <script type="text/javascript" src="js/webadmin_common.js"></script>
</head>

<body>
<form action="<?=basename(__FILE__)?>?<?=htmlentities(http_build_query($_GET))?>" method="post" id="data_form" name="data_form" enctype="multipart/form-data">
    <?php $attribute 'id'?>
    <input type="hidden" name="<?=$attribute?>" value="<?=$model->$attribute?>" />
    <table width="1000" border="0" cellpadding="0" cellspacing="0">
        <tr>
            <td height="70" align="right" valign="middle" class="icontxt"><table border="0" cellpadding="0" cellspacing="0">
                    <tr>
                        <td width="50" align="center"><a href="#" onclick="return submitFormOnClick('data_form');"><img src="images/iconSave.png" alt="Save" width="32" height="32" border="0" /><br />
                            &nbsp;Save&nbsp;</a></td>
                        <td width="50" align="center"><a href="cms_user_index.php"><img src="images/iconCancel.png" alt="Cancel" width="32" height="32" border="0" /><br />
                            &nbsp;Cancel&nbsp;</a></td>
                        <td>&nbsp;</td>
                    </tr>
                </table></td>
        </tr>
        <tr>
            <td class="pagetitletxt">&nbsp;<strong><img alt="" src="images/iconList.jpg" width="48" height="48" style="vertical-align:middle" /> CMS Use Management </strong></td>
        </tr>
        <tr>
            <td align="left" valign="middle"><!-- Content -->
                
                <table border="0" cellpadding="0" cellspacing="0">
                    <tr>
                        <td width="120" align="right" valign="top" class="content">User Name</td>
                        <td width="10" class="content" valign="top">:</td>
                        <?php $attribute 'user_name'?>
                        <td class="content"><input type="text" class="content" name="<?=$attribute?>" value="<?=$model->$attribute?>" size="80" maxlength="80" />
                            Max length: 80</td>
                    </tr>
                    <?php
                    
/*
                    <tr>
                        <td width="120" align="right" valign="top" class="content">Role</td>
                        <td width="10" class="content" valign="top">:</td>
                        <td class="content">
                            <?php $attribute = 'role'; ?>
                            <select name="<?=$attribute?>" class="content">
                                <option value="1" <?php if($model->$attribute == '1') { echo 'selected'; } ?>>Admin</option>
                                <option value="2" <?php if($model->$attribute == '2') { echo 'selected'; } ?>>User</option>
                            </select>
                        </td>
                    </tr>
                    */
                    
?>
                    <tr>
                        <td width="120" align="right" valign="top" class="content">Login Name</td>
                        <td width="10" class="content" valign="top">:</td>
                        <?php $attribute 'login_name'?>
                        <td class="content"><input type="text" class="content" name="<?=$attribute?>" value="<?=$model->$attribute?>" size="50" maxlength="20" />
                            Max length: 20</td>
                    </tr>
                    <tr>
                        <td width="120" align="right" valign="top" class="content">Password</td>
                        <td width="10" class="content" valign="top">:</td>
                        <?php $attribute 'password'?>
                        <td class="content"><input type="password" class="content" name="<?=$attribute?>" size="50" maxlength="20" />
                            Max length: 20</td>
                    </tr>
                </table>
                
                <!-- End Content --></td>
        </tr>
        <tr>
            <td align="left" valign="middle">&nbsp;</td>
        </tr>
    </table>
</form>
</body>
</html>