home *** CD-ROM | disk | FTP | other *** search
/ Practical Internet Web Designer 90 / PIWD90.iso / pc / contents / ecommerce / software / osCommerce.exe / oscommerce-2.2ms2 / catalog / admin / configuration.php < prev    next >
PHP Script  |  2003-06-29  |  9KB  |  172 lines

  1. <?php
  2. /*
  3.   $Id: configuration.php,v 1.43 2003/06/29 22:50:51 hpdl Exp $
  4.  
  5.   osCommerce, Open Source E-Commerce Solutions
  6.   http://www.oscommerce.com
  7.  
  8.   Copyright (c) 2003 osCommerce
  9.  
  10.   Released under the GNU General Public License
  11. */
  12.  
  13.   require('includes/application_top.php');
  14.  
  15.   $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
  16.  
  17.   if (tep_not_null($action)) {
  18.     switch ($action) {
  19.       case 'save':
  20.         $configuration_value = tep_db_prepare_input($HTTP_POST_VARS['configuration_value']);
  21.         $cID = tep_db_prepare_input($HTTP_GET_VARS['cID']);
  22.  
  23.         tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . tep_db_input($configuration_value) . "', last_modified = now() where configuration_id = '" . (int)$cID . "'");
  24.  
  25.         tep_redirect(tep_href_link(FILENAME_CONFIGURATION, 'gID=' . $HTTP_GET_VARS['gID'] . '&cID=' . $cID));
  26.         break;
  27.     }
  28.   }
  29.  
  30.   $gID = (isset($HTTP_GET_VARS['gID'])) ? $HTTP_GET_VARS['gID'] : 1;
  31.  
  32.   $cfg_group_query = tep_db_query("select configuration_group_title from " . TABLE_CONFIGURATION_GROUP . " where configuration_group_id = '" . (int)$gID . "'");
  33.   $cfg_group = tep_db_fetch_array($cfg_group_query);
  34. ?>
  35. <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  36. <html <?php echo HTML_PARAMS; ?>>
  37. <head>
  38. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
  39. <title><?php echo TITLE; ?></title>
  40. <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
  41. <script language="javascript" src="includes/general.js"></script>
  42. </head>
  43. <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
  44. <!-- header //-->
  45. <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
  46. <!-- header_eof //-->
  47.  
  48. <!-- body //-->
  49. <table border="0" width="100%" cellspacing="2" cellpadding="2">
  50.   <tr>
  51.     <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
  52. <!-- left_navigation //-->
  53. <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
  54. <!-- left_navigation_eof //-->
  55.     </table></td>
  56. <!-- body_text //-->
  57.     <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  58.       <tr>
  59.         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  60.           <tr>
  61.             <td class="pageHeading"><?php echo $cfg_group['configuration_group_title']; ?></td>
  62.             <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
  63.           </tr>
  64.         </table></td>
  65.       </tr>
  66.       <tr>
  67.         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  68.           <tr>
  69.             <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  70.               <tr class="dataTableHeadingRow">
  71.                 <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_CONFIGURATION_TITLE; ?></td>
  72.                 <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_CONFIGURATION_VALUE; ?></td>
  73.                 <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td>
  74.               </tr>
  75. <?php
  76.   $configuration_query = tep_db_query("select configuration_id, configuration_title, configuration_value, use_function from " . TABLE_CONFIGURATION . " where configuration_group_id = '" . (int)$gID . "' order by sort_order");
  77.   while ($configuration = tep_db_fetch_array($configuration_query)) {
  78.     if (tep_not_null($configuration['use_function'])) {
  79.       $use_function = $configuration['use_function'];
  80.       if (ereg('->', $use_function)) {
  81.         $class_method = explode('->', $use_function);
  82.         if (!is_object(${$class_method[0]})) {
  83.           include(DIR_WS_CLASSES . $class_method[0] . '.php');
  84.           ${$class_method[0]} = new $class_method[0]();
  85.         }
  86.         $cfgValue = tep_call_function($class_method[1], $configuration['configuration_value'], ${$class_method[0]});
  87.       } else {
  88.         $cfgValue = tep_call_function($use_function, $configuration['configuration_value']);
  89.       }
  90.     } else {
  91.       $cfgValue = $configuration['configuration_value'];
  92.     }
  93.  
  94.     if ((!isset($HTTP_GET_VARS['cID']) || (isset($HTTP_GET_VARS['cID']) && ($HTTP_GET_VARS['cID'] == $configuration['configuration_id']))) && !isset($cInfo) && (substr($action, 0, 3) != 'new')) {
  95.       $cfg_extra_query = tep_db_query("select configuration_key, configuration_description, date_added, last_modified, use_function, set_function from " . TABLE_CONFIGURATION . " where configuration_id = '" . (int)$configuration['configuration_id'] . "'");
  96.       $cfg_extra = tep_db_fetch_array($cfg_extra_query);
  97.  
  98.       $cInfo_array = array_merge($configuration, $cfg_extra);
  99.       $cInfo = new objectInfo($cInfo_array);
  100.     }
  101.  
  102.     if ( (isset($cInfo) && is_object($cInfo)) && ($configuration['configuration_id'] == $cInfo->configuration_id) ) {
  103.       echo '                  <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CONFIGURATION, 'gID=' . $HTTP_GET_VARS['gID'] . '&cID=' . $cInfo->configuration_id . '&action=edit') . '\'">' . "\n";
  104.     } else {
  105.       echo '                  <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CONFIGURATION, 'gID=' . $HTTP_GET_VARS['gID'] . '&cID=' . $configuration['configuration_id']) . '\'">' . "\n";
  106.     }
  107. ?>
  108.                 <td class="dataTableContent"><?php echo $configuration['configuration_title']; ?></td>
  109.                 <td class="dataTableContent"><?php echo htmlspecialchars($cfgValue); ?></td>
  110.                 <td class="dataTableContent" align="right"><?php if ( (isset($cInfo) && is_object($cInfo)) && ($configuration['configuration_id'] == $cInfo->configuration_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_CONFIGURATION, 'gID=' . $HTTP_GET_VARS['gID'] . '&cID=' . $configuration['configuration_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td>
  111.               </tr>
  112. <?php
  113.   }
  114. ?>
  115.             </table></td>
  116. <?php
  117.   $heading = array();
  118.   $contents = array();
  119.  
  120.   switch ($action) {
  121.     case 'edit':
  122.       $heading[] = array('text' => '<b>' . $cInfo->configuration_title . '</b>');
  123.  
  124.       if ($cInfo->set_function) {
  125.         eval('$value_field = ' . $cInfo->set_function . '"' . htmlspecialchars($cInfo->configuration_value) . '");');
  126.       } else {
  127.         $value_field = tep_draw_input_field('configuration_value', $cInfo->configuration_value);
  128.       }
  129.  
  130.       $contents = array('form' => tep_draw_form('configuration', FILENAME_CONFIGURATION, 'gID=' . $HTTP_GET_VARS['gID'] . '&cID=' . $cInfo->configuration_id . '&action=save'));
  131.       $contents[] = array('text' => TEXT_INFO_EDIT_INTRO);
  132.       $contents[] = array('text' => '<br><b>' . $cInfo->configuration_title . '</b><br>' . $cInfo->configuration_description . '<br>' . $value_field);
  133.       $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_update.gif', IMAGE_UPDATE) . ' <a href="' . tep_href_link(FILENAME_CONFIGURATION, 'gID=' . $HTTP_GET_VARS['gID'] . '&cID=' . $cInfo->configuration_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
  134.       break;
  135.     default:
  136.       if (isset($cInfo) && is_object($cInfo)) {
  137.         $heading[] = array('text' => '<b>' . $cInfo->configuration_title . '</b>');
  138.  
  139.         $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_CONFIGURATION, 'gID=' . $HTTP_GET_VARS['gID'] . '&cID=' . $cInfo->configuration_id . '&action=edit') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a>');
  140.         $contents[] = array('text' => '<br>' . $cInfo->configuration_description);
  141.         $contents[] = array('text' => '<br>' . TEXT_INFO_DATE_ADDED . ' ' . tep_date_short($cInfo->date_added));
  142.         if (tep_not_null($cInfo->last_modified)) $contents[] = array('text' => TEXT_INFO_LAST_MODIFIED . ' ' . tep_date_short($cInfo->last_modified));
  143.       }
  144.       break;
  145.   }
  146.  
  147.   if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
  148.     echo '            <td width="25%" valign="top">' . "\n";
  149.  
  150.     $box = new box;
  151.     echo $box->infoBox($heading, $contents);
  152.  
  153.     echo '            </td>' . "\n";
  154.   }
  155. ?>
  156.           </tr>
  157.         </table></td>
  158.       </tr>
  159.     </table></td>
  160. <!-- body_text_eof //-->
  161.   </tr>
  162. </table>
  163. <!-- body_eof //-->
  164.  
  165. <!-- footer //-->
  166. <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
  167. <!-- footer_eof //-->
  168. <br>
  169. </body>
  170. </html>
  171. <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
  172.