[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
Zen Cart 源代码 users.php

Zen Cart 源代码 users.php




下载文件

文件名: users.php
文件类型: PHP文件
文件大小: 11.43 KiB
MD5: 72019193a9d48491834668aa18240519

users.php - 关闭高亮
  1. <?php
  2. /**
  3.  * @package admin
  4.  * @copyright Copyright 2003-2012 Zen Cart Development Team
  5.  * @copyright Portions Copyright 2003 osCommerce<br />
  6.  * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  7.  * @version GIT: $Id: Author: DrByte  Mon Jul 16 15:05:32 2012 -0400 Modified in v1.5.1 $
  8.  */
  9.  
  10. require('includes/application_top.php');
  11.  
  12. // Check if session has timed out
  13. if (!isset($_SESSION['admin_id'])) zen_redirect(zen_href_link(FILENAME_LOGIN));
  14.  
  15. // make a note of the current user - they can't delete themselves (by accident) or change their own status
  16. $currentUser = $_SESSION['admin_id'];
  17.  
  18. // determine whether an action has been requested
  19. if (isset($_POST['action']) && in_array($_POST['action'], array('insert','update','reset'))) {
  20.   $action = $_POST['action'];
  21. } elseif (isset($_GET['action']) && in_array($_GET['action'], array('add','edit','password','delete', 'delete_confirm'))) {
  22.   $action = $_GET['action'];
  23. } else {
  24.   $action = '';
  25. }
  26.  
  27. // if needed, check that a valid user id has been passed
  28. if (($action == 'update' || $action == 'reset') && isset($_POST['user']))
  29. {
  30.   $user = $_POST['user'];
  31. }
  32. elseif (($action == 'edit' || $action == 'password' || $action == 'delete' || $action == 'delete_confirm') && $_GET['user'])
  33. {
  34.   $user = $_GET['user'];
  35. }
  36. elseif(($action=='delete' || $action=='delete_confirm') && isset($_POST['user']))
  37. {
  38.   $user = $_POST['user'];
  39. }
  40. elseif (in_array($action, array('edit','password','delete','delete_confirm','update','reset')))
  41. {
  42.   $messageStack->add_session(ERROR_NO_USER_DEFINED, 'error');
  43.   zen_redirect(zen_href_link(FILENAME_USERS));
  44. }
  45.  
  46. // act upon any specific action specified
  47. switch ($action) {
  48.   case 'add': // display unpopulated form for adding a new user
  49.     $formAction = 'insert';
  50.     $profilesList = array_merge(array(array('id'=>0,'text'=>'Choose Profile')), zen_get_profiles());
  51.     break;
  52.   case 'edit': // display populated form for editing existing user
  53.     $formAction = 'update';
  54.     $profilesList = array_merge(array(array('id'=>0,'text'=>'Choose Profile')), zen_get_profiles());
  55.     break;
  56.   case 'password': // display unpopulated form for resetting existing user's password
  57.     $formAction = 'reset';
  58.     break;
  59.   case 'delete_confirm': // remove existing user from database
  60.     if (isset($_POST['user']))
  61.     {
  62.        zen_delete_user($_POST['user']);
  63.     }
  64.     break;
  65.   case 'insert': // insert new user into database. Post data is prep'd for db in the first function call
  66.     $errors = zen_insert_user($_POST['name'],$_POST['email'], $_POST['password'], $_POST['confirm'], $_POST['profile']);
  67.     if (sizeof($errors) > 0)
  68.     {
  69.       foreach ($errors as $error)
  70.       {
  71.         $messageStack->add($error, 'error');
  72.       }
  73.       $action = 'add';
  74.       $formAction = 'insert';
  75.       $profilesList = array_merge(array(array('id'=>0,'text'=>'Choose Profile')), zen_get_profiles());
  76.     } else
  77.     {
  78.       $action = '';
  79.       $messageStack->add(SUCCESS_NEW_USER_ADDED, 'success');
  80.     }
  81.     break;
  82.   case 'update': // update existing user's details in database. Post data is prep'd for db in the first function call
  83.     $errors = zen_update_user($_POST['name'],$_POST['email'], $_POST['id'], $_POST['profile']);
  84.     if (sizeof($errors) > 0)
  85.     {
  86.       foreach ($errors as $error)
  87.       {
  88.         $messageStack->add($error, 'error');
  89.       }
  90.       $action = 'edit';
  91.       $formAction = 'update';
  92.       $profilesList = array_merge(array(array('id'=>0,'text'=>'Choose Profile')), zen_get_profiles());
  93.     } else
  94.     {
  95.       $action = '';
  96.       $messageStack->add(SUCCESS_USER_DETAILS_UPDATED, 'success');
  97.     }
  98.     break;
  99.   case 'reset': // reset existing user's password in database. Post data is prep'd for db in the first function call
  100.     $errors = zen_reset_password($_POST['user'], $_POST['password'], $_POST['confirm']);
  101.     if (sizeof($errors) > 0)
  102.     {
  103.       foreach ($errors as $error)
  104.     {
  105.       $messageStack->add($error, 'error');
  106.     }
  107.     $action = 'password';
  108.     $formAction = 'reset';
  109.     } else
  110.     {
  111.       $action = '';
  112.       $messageStack->add(SUCCESS_PASSWORD_UPDATED, 'success');
  113.     }
  114.     break;
  115.   default: // no action, simply drop through and display existing users
  116. }
  117.  
  118. // we'll always display a list of the available users
  119. $userList = zen_get_users();
  120. ?>
  121. <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  122. <html <?php echo HTML_PARAMS; ?>>
  123. <head>
  124. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
  125. <title><?php echo TITLE; ?></title>
  126. <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
  127. <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
  128. <link rel="stylesheet" type="text/css" href="includes/admin_access.css">
  129. <script type="text/javascript" src="includes/menu.js"></script>
  130. <script type="text/javascript" src="includes/general.js"></script>
  131. <script type="text/javascript">
  132.   <!--
  133.   function init()
  134.   {
  135.     cssjsmenu('navbar');
  136.     if (document.getElementById)
  137.     {
  138.       var kill = document.getElementById('hoverJS');
  139.       kill.disabled = true;
  140.     }
  141.   }
  142.   // -->
  143. </script>
  144. </head>
  145. <body onload="init()">
  146. <!-- header //-->
  147. <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
  148. <!-- header_eof //-->
  149.  
  150. <!-- body //-->
  151. <div id="pageWrapper">
  152.  
  153. <h1><?php echo HEADING_TITLE ?></h1>
  154. <?php if ($action == 'edit' || $action == 'add' || $action == 'password') { ?>
  155. <?php echo zen_draw_form('users', FILENAME_USERS); ?>
  156. <?php if (isset($formAction)) echo zen_draw_hidden_field('action',$formAction) ?>
  157. <?php } ?>
  158. <?php if ($action == 'edit' || $action == 'password') echo zen_draw_hidden_field('user',$user) ?>
  159.   <table cellspacing="0">
  160.     <thead>
  161.       <tr class="headingRow">
  162.         <th class="id"><?php echo TEXT_ID ?></th>
  163.         <th class="name"><?php echo TEXT_NAME ?></th>
  164.         <th class="email"><?php echo TEXT_EMAIL ?></th>
  165.         <th class="profile"><?php echo TEXT_PROFILE ?></th>
  166. <?php if ($action == 'add' || $action == 'password') { ?>
  167.         <th class="password"><?php echo TEXT_PASSWORD ?></th>
  168.         <th class="password"><?php echo TEXT_CONFIRM_PASSWORD ?></th>
  169. <?php } ?>
  170.         <th class="actions">&nbsp;</th>
  171.       </tr>
  172.     </thead>
  173.     <tfoot>
  174. <?php if ($action != 'add' && $action != 'edit' && $action != 'password') { ?>
  175.       <tr>
  176.         <td colspan="5"><a href="<?php echo zen_href_link(FILENAME_USERS, 'action=add') ?>"><?php echo zen_image_button('button_add_user.gif', IMAGE_ADD_USER) ?></a></td>
  177.       </tr>
  178. <?php } ?>
  179.     </tfoot>
  180.  
  181.     <tbody>
  182. <?php if ($action == 'add') { ?>
  183.       <tr>
  184.         <td class="id">&nbsp;</td>
  185.         <td class="name"><?php echo zen_draw_input_field('name', isset($_POST['name']) ? $_POST['name'] : '', 'class="field"', false, 'text', true) ?></td>
  186.         <td class="email"><?php echo zen_draw_input_field('email', isset($_POST['email']) ? $_POST['email'] : '', 'class="field"', false, 'text', true) ?></td>
  187.         <td class="profile"><?php echo zen_draw_pull_down_menu('profile', $profilesList, isset($_POST['profile']) ? $_POST['profile'] : 0) ?></td>
  188.         <td class="password"><?php echo zen_draw_input_field('password', isset($_POST['password']) ? $_POST['password'] : '', ' class="field"', false, 'password'); ?></td>
  189.         <td class="confirm"><?php echo zen_draw_input_field('confirm', isset($_POST['confirm']) ? $_POST['confirm'] : '', ' class="field"', false, 'password'); ?></td>
  190.         <td class="actions"><?php echo zen_image_submit('button_insert.gif', IMAGE_INSERT) ?> <a href="<?php echo zen_href_link(FILENAME_USERS) ?>"> <?php echo zen_image_button('button_cancel.gif', IMAGE_CANCEL) ?></a></td>
  191.       </tr>
  192. <?php } ?>
  193. <?php if (sizeof($userList) > 0) { ?>
  194. <?php foreach ($userList as $userDetails) { ?>
  195.       <tr>
  196. <?php if (($action == 'edit' || $action == 'password') && $user == $userDetails['id']) { ?>
  197.         <td class="id"><?php echo $userDetails['id'] ?><?php echo zen_draw_hidden_field('id', $userDetails['id']) ?></td>
  198. <?php } else { ?>
  199.         <td class="id"><?php echo $userDetails['id'] ?></td>
  200. <?php } ?>
  201. <?php if ($action == 'edit' && $user == $userDetails['id']) { ?>
  202.         <td class="name"><?php echo zen_draw_input_field('name', $userDetails['name'], 'class="field"') ?></td>
  203.         <td class="email"><?php echo zen_draw_input_field('email', $userDetails['email'], 'class="field"') ?></td>
  204. <?php } else { ?>
  205.         <td class="name"><?php echo $userDetails['name'] ?></td>
  206.         <td class="email"><?php echo $userDetails['email'] ?></td>
  207. <?php } ?>
  208. <?php if ($action == 'edit' && $user == $userDetails['id'] && $user != $currentUser) { ?>
  209.         <td class="profile"><?php echo zen_draw_pull_down_menu('profile', $profilesList, $userDetails['profile']) ?></td>
  210. <?php } else { ?>
  211.         <td class="profile"><?php echo $userDetails['profileName'] ?></td>
  212. <?php } ?>
  213. <?php if ($action == 'password' && $user == $userDetails['id']) { ?>
  214.         <td class="password"><?php echo zen_draw_input_field('password', '', 'class="field"', false, 'password', true) ?></td>
  215.         <td class="confirm"><?php echo zen_draw_input_field('confirm', '', 'class="field"', false, 'password', true) ?></td>
  216. <?php } elseif($action == 'add' || $action == 'password') { ?>
  217.         <td class="password">&nbsp;</td>
  218.         <td class="confirm">&nbsp;</td>
  219. <?php } ?>
  220. <?php if ($action == 'edit' || $action == 'password') { ?>
  221. <?php if ($user == $userDetails['id']) { ?>
  222.         <td class="actions">
  223.           <?php echo zen_image_submit('button_update.gif', IMAGE_UPDATE) ?>
  224.           <a href="<?php echo zen_href_link(FILENAME_USERS) ?>"><?php echo zen_image_button('button_cancel.gif', IMAGE_CANCEL) ?></a>
  225.         </td>
  226. <?php } else { ?>
  227.         <td class="actions">&nbsp;</td>
  228. <?php } ?>
  229. <?php } elseif ($action != 'add') { ?>
  230.         <td class="actions">
  231. <?php if ($action != 'delete') { ?>
  232.           <a href="<?php echo zen_href_link(FILENAME_USERS, 'action=edit&amp;user=' . $userDetails['id']) ?>"><?php echo zen_image_button('button_edit.gif', IMAGE_EDIT) ?></a>
  233.           <a href="<?php echo zen_href_link(FILENAME_USERS, 'action=password&amp;user=' . $userDetails['id']) ?>"><?php echo zen_image_button('button_reset_pwd.gif', IMAGE_RESET_PWD) ?></a>
  234. <?php } ?>
  235. <?php if ($userDetails['id'] != $currentUser) {
  236.  
  237.   $btn_img = '';
  238.   if ($action == 'delete' && $userDetails['id'] == $user) {
  239.     $btn_img = 'button_confirm_red.gif';
  240.   } else if ($action != 'delete') {
  241.     $btn_img = 'button_delete.gif';
  242.   }
  243. ?>
  244.           <?php echo zen_draw_form('delete_user', FILENAME_USERS, 'action=' . ($action == 'delete' ? 'delete_confirm' : 'delete')); ?>
  245.           <?php echo zen_draw_hidden_field('user', $userDetails['id']); ?>
  246.           <?php echo ($action == 'delete' && $userDetails['id'] == $user ? TEXT_CONFIRM_DELETE : '') . ($btn_img == '' ? '' : zen_image_submit($btn_img, IMAGE_DELETE)) ?>
  247. <?php if ($action == 'delete' && $userDetails['id'] == $user) { ?>
  248.             <a href="<?php echo zen_href_link(FILENAME_USERS) ?>"><?php echo zen_image_button('button_cancel.gif', IMAGE_CANCEL) ?></a>
  249. <?php } ?>
  250.           </form>
  251. <?php } ?>
  252.         </td>
  253.       </tr>
  254. <?php } } } else { ?>
  255.       <tr>
  256.         <td rowspan="4"><?php echo TEXT_NO_USERS_FOUND ?></td>
  257.       </tr>
  258. <?php } ?>
  259.     </tbody>
  260.   </table>
  261.  
  262. </div>
  263. <!-- body_eof //-->
  264.  
  265. <!-- footer //-->
  266. <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
  267. <!-- footer_eof //-->
  268. <br>
  269. </body>
  270. </html>
  271. <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
  272.  


cron