File: modify.php

package info (click to toggle)
mediamate 0.9.3.6-5
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,256 kB
  • ctags: 1,071
  • sloc: php: 5,023; sh: 647; sql: 97; makefile: 70
file content (302 lines) | stat: -rw-r--r-- 9,616 bytes parent folder | download | duplicates (3)
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
<?php
/*
 * Copyright 2003-2004 Jamin W. Collins <jcollins@asgardsrealm.net>
 * Copyright 2001-2003 Tony Collins
 *
 * This file is part of Media Mate
 * 
 * Media Mate is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * Media Mate is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Media Mate; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 * USA
 *
 */

// This script modifies locations of movies, among other things.
require_once('header.php');

?>

<!-- Some necessary crap to set the page up. -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
   <head>
      <link rel="stylesheet" type="text/css"
         href="themes/<?php echo $global_prefs['theme'];?>.css" >
      <title>

<?php 
echo $global_text['detailsupdated'];
?>

      </title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   </head>
   <body>
      <!-- Center the background canvas on the page -->
      <div align="center">
         <div id="pageborder">

            <a href="index.php">
               <div id="title">
               </div>
            </a>

            <br/>

<?php
// This checks to see if the person has enough permissions to use 
// this section. (level 3)
if ($_SESSION['level'] == '3') {
   // If we're editing a user's details
   if ($_POST['action'] == "edituser") {
                  
      $admin_level = $_POST['admin_level'];
      $real_name = $_POST['real_name'];
      $address_1 = $_POST['address_1'];
      $address_2 = $_POST['address_2'];
      $email_address = $_POST['email_address'];
      $user_phone = $_POST['user_phone'];
      $jabber_id = $_POST['jabber_id'];
      $id = $_POST['id'];
      $password_1 = $_POST['password_1'];
      $password_2 = $_POST['password_2'];
      
      $sql = "UPDATE global_users SET admin_level='$admin_level', 
         real_name='$real_name', address_1='$address_1', 
         address_2='$address_2', email_address='$email_address', 
         user_phone='$user_phone', jabber_id='$jabber_id' 
         WHERE user_id = '$id'";
      $update = $mm->dbExec($sql);
      $message = "{$global_text['userdetailsfor']}";
      $message = $message . " $real_name {$global_text['updated']}";
                  
      if (($password_1 AND $password_2) AND ($password_1 == $password_2)) {
         $enc_password = crypt("$password_1", "4t6dcHiefIkeYcn48B");

         $sql = "UPDATE global_users SET user_password='$enc_password' 
            WHERE user_id = '$id'";
         $update2 = $mm->dbExec($sql);
         $pwd_status = $global_text['chpwdyes'];
      } else {
         $pwd_status = $global_text['chpwdno'];
      };
?>

            <table class="admin">
               <tr>
                  <td align="center">

<?php
      echo "$message<br/><br/>";
      echo "$pwd_status";
?>

                  </td>
               </tr>
            </table>
            <br>

<?php
      echo "<a class=\"returnlink\" href=\"details.php?id=$id\">";
      echo "{$global_text['returntouser']}</a>";

      // The global options are set here
   } elseif ($_POST['action'] == "options") {
                  
      $lang_name = $_POST['lang_name'];
      $theme_name = $_POST['theme_name'];
      $server_online = $_POST['server_online'];
      $theme_credits = $_POST['theme_credits'];
      $notify_new = $_POST['notify_new'];
      $mail_server = $_POST['mail_server'];
      $j_server = $_POST['j_server'];
      $j_port = $_POST['j_port'];
      $j_username = $_POST['j_username'];
      $j_password = $_POST['j_password'];

      $sqlbase = "UPDATE global_prefs SET value = ";
      $sql = $sqlbase . "'$lang_name' WHERE name = 'lang'";
      $update = $mm->dbExec($sql);
      $sql = $sqlbase . "'$theme_name' WHERE name = 'theme'";
      $update = $mm->dbExec($sql);
      $sql = $sqlbase . "'$theme_credits' WHERE name = 'theme_credits'";
      $update = $mm->dbExec($sql);
      $sql = $sqlbase . "'$notify_new' WHERE name = 'notify_new'";
      $update = $mm->dbExec($sql);
      $sql = $sqlbase . "'$server_online' WHERE name = 'online'";
      $update = $mm->dbExec($sql);
      $sql = $sqlbase . "'$mail_server' WHERE name = 'mta'";
      $update = $mm->dbExec($sql);
      $sql = $sqlbase . "'$j_server' WHERE name = 'j_server'";
      $update = $mm->dbExec($sql);
      $sql = $sqlbase . "'$j_port' WHERE name = 'j_port'";
      $update = $mm->dbExec($sql);
      $sql = $sqlbase . "'$j_username' WHERE name = 'j_username'";
      $update = $mm->dbExec($sql);
      $sql = $sqlbase . "'$j_password' WHERE name = 'j_password'";
      $update = $mm->dbExec($sql);
      
?>

            <table class="admin" cellpadding="5">
               <tr>
                  <td align="center">

<?php 
      echo $global_text['prefssaved'];
?>

                  </td>
               </tr>
            </table>

<?php

   //  If we're adding a new user
   } elseif ($_POST['action'] == "adduser") {

      $user_name = $_POST['user_name'];
      $admin_level = $_POST['admin_level'];
      $real_name = $_POST['real_name'];
      $address_1 = $_POST['address_1'];
      $address_2 = $_POST['address_1'];
      $email_address = $_POST['email_address'];
      $user_phone = $_POST['user_phone'];
      $jabber_id = $_POST['jabber_id'];
      $password_1 = $_POST['password_1'];
      $password_2 = $_POST['password_2'];
                     
      // Check to see if the username has already been taken
      $sql = "SELECT * FROM global_users WHERE user_name = '$user_name'";
      $result = $mm->dbExec($sql);
      if (!$mm->dbCountRows($result)) {
         $sql = "INSERT INTO global_users (admin_level, user_name, 
            user_password, real_name, address_1, address_2, email_address, 
            user_phone, jabber_id ) VALUES ( '$admin_level', '$user_name', 
            '', '$real_name', '$address_1', '$address_2', '$email_address', 
            '$user_phone', '$jabber_id')";
         $insert = $mm->dbExec($sql);
                        
         // See if two passwords were typed in
         if ($password_1 AND $password_2) {
            // See if the passwords match
            if ($password_1 == $password_2) {
               // Query for the new user's user_id
               $sql = "SELECT user_id FROM global_users 
                  WHERE user_name = '$user_name' 
                  AND real_name = '$real_name' 
                  AND address_1 = '$address_1'";
               $result = $mm->dbQuery($sql);
               
               list($user_id) = $mm->dbFetchRow($result);
               $enc_password = crypt("$password_1", "4t6dcHiefIkeYcn48B");

               $sql = "UPDATE global_users SET user_password = '$enc_password' 
                  WHERE user_id = '$user_id'";
               $result = $mm->dbExec($sql);
            // If the passwords didn't match, show an error
            } else {
               $pwd_msg = $global_text['passnotmatch'];
            };
         // If both password boxes weren't filled in, show half an error
         } else {
            $pwd_msg = $global_text['passnotenteredtwice'];
         };
                        
         // Specify the message to report back to the user
         $add_msg = $global_text['newuseradded'];
      } else {
         $add_msg = $global_text['usernametaken'];
      };
?>

            <table class="admin" cellpadding="5">
               <tr>
                  <td align="center">

<?php
      echo "$add_msg";
      if ($pwd_msg) {
         echo "<br><br>$pwd_msg";
      };
?>

                  </td>
               </tr>
            </table>

<?php

   // If the user wants to change their password
   } elseif ($_POST['action'] == "chpwd") {

      $password_1 = $_POST['password_1'];
      $password_2 = $_POST['password_2'];
      $userid = $_SESSION['userid'];

      // See if two passwords were typed in
      if ($password_1 AND $password_2) {

         // See if the passwords match
         if ($password_1 == $password_2) {

            // Query for the new user's user_id
            $enc_password = crypt("$password_1", "4t6dcHiefIkeYcn48B");

            $sql = "UPDATE global_users SET user_password = '$enc_password' 
               WHERE user_id = '$userid'";
            $result = $mm->dbExec($sql);
            $pwd_msg = $global_text['chpwdyes'];
         // If the passwords didn't match, show an error
         } else {
            $pwd_msg = $global_text['passnotmatch'];
         };
      // If both password boxes weren't filled in, show half an error
      } else {
         $pwd_msg = $global_text['passnotenteredtwice2'];
      };
?>

            <table class="admin" cellpadding="5">
               <tr>
                  <td align="center">

<?php
   echo "$pwd_msg";
?>

                  </td>
               </tr>
            </table>

<?php
   }; // End of all functions

}; // End of permission check for level 3.

?>
            <br/>
            <a class="returnlink" href="index.php">

<?php 
echo $global_text['returntofront'];
?>

            </a>

      <!-- End of centering the canvas on the page -->
         </div>
      </div>
   </body>
</html>