[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 源代码 modules.php

Zen Cart 源代码 modules.php




下载文件

文件名: modules.php
文件类型: PHP文件
文件大小: 17.96 KiB
MD5: 3119f59e1eacdc67038c7059c976337c

modules.php - 关闭高亮
  1. <?php
  2. /**
  3.  * @package admin
  4.  * @copyright Copyright 2003-2010 Zen Cart Development Team
  5.  * @copyright Portions Copyright 2003 osCommerce
  6.  * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  7.  * @version $Id: modules.php 15416 2010-02-04 05:56:43Z drbyte $
  8.  */
  9.  
  10.   require('includes/application_top.php');
  11.  
  12.   $set = (isset($_GET['set']) ? $_GET['set'] : '');
  13.  
  14.   if (zen_not_null($set)) {
  15.     switch ($set) {
  16.       case 'shipping':
  17.         $module_type = 'shipping';
  18.         $module_directory = DIR_FS_CATALOG_MODULES . 'shipping/';
  19.         $module_key = 'MODULE_SHIPPING_INSTALLED';
  20.         define('HEADING_TITLE', HEADING_TITLE_MODULES_SHIPPING);
  21.         $shipping_errors = '';
  22.         if (zen_get_configuration_key_value('SHIPPING_ORIGIN_ZIP') == 'NONE' or zen_get_configuration_key_value('SHIPPING_ORIGIN_ZIP') == '') {
  23.           $shipping_errors .= '<br />' . ERROR_SHIPPING_ORIGIN_ZIP;
  24.         }
  25.         if (zen_get_configuration_key_value('ORDER_WEIGHT_ZERO_STATUS') == '1' and !defined('MODULE_SHIPPING_FREESHIPPER_STATUS')) {
  26.           $shipping_errors .= '<br />' . ERROR_ORDER_WEIGHT_ZERO_STATUS;
  27.         }
  28.         if (defined('MODULE_SHIPPING_USPS_STATUS') and (MODULE_SHIPPING_USPS_USERID=='NONE' or MODULE_SHIPPING_USPS_SERVER == 'test')) {
  29.           $shipping_errors .= '<br />' . ERROR_USPS_STATUS;
  30.         }
  31.         if ($shipping_errors != '') {
  32.           $messageStack->add(ERROR_SHIPPING_CONFIGURATION . $shipping_errors, 'caution');
  33.         }
  34.         break;
  35.       case 'ordertotal':
  36.         $module_type = 'order_total';
  37.         $module_directory = DIR_FS_CATALOG_MODULES . 'order_total/';
  38.         $module_key = 'MODULE_ORDER_TOTAL_INSTALLED';
  39.         define('HEADING_TITLE', HEADING_TITLE_MODULES_ORDER_TOTAL);
  40.         break;
  41.       case 'payment':
  42.       default:
  43.         $module_type = 'payment';
  44.         $module_directory = DIR_FS_CATALOG_MODULES . 'payment/';
  45.         $module_key = 'MODULE_PAYMENT_INSTALLED';
  46.         define('HEADING_TITLE', HEADING_TITLE_MODULES_PAYMENT);
  47.         break;
  48.     }
  49.   }
  50.  
  51.   $action = (isset($_GET['action']) ? $_GET['action'] : '');
  52.  
  53.   if (zen_not_null($action)) {
  54.     switch ($action) {
  55.       case 'save':
  56.         while (list($key, $value) = each($_POST['configuration'])) {
  57. // BOF: UPS USPS
  58.           if( is_array( $value ) ){
  59.             $value = implode( ", ", $value);
  60.             $value = preg_replace ("/, --none--/", "", $value);
  61.           }
  62. // EOF: UPS USPS
  63.           $db->Execute("update " . TABLE_CONFIGURATION . "
  64.                        set configuration_value = '" . $value . "'
  65.                        where configuration_key = '" . $key . "'");
  66.         }
  67.         $configuration_query = 'select configuration_key as cfgkey, configuration_value as cfgvalue
  68.                                from ' . TABLE_CONFIGURATION;
  69.         $configuration = $db->Execute($configuration_query);
  70.  
  71.         zen_redirect(zen_href_link(FILENAME_MODULES, 'set=' . $set . ($_GET['module'] != '' ? '&module=' . $_GET['module'] : ''), 'NONSSL'));
  72.         break;
  73.       case 'install':
  74.       case 'remove':
  75.         $file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.'));
  76.         $class = basename($_GET['module']);
  77.         if (file_exists($module_directory . $class . $file_extension)) {
  78.           $configuration_query = 'select configuration_key as cfgkey, configuration_value as cfgvalue
  79.                                  from ' . TABLE_CONFIGURATION;
  80.           $configuration = $db->Execute($configuration_query);
  81.           include($module_directory . $class . $file_extension);
  82.           $module = new $class;
  83.           if ($action == 'install') {
  84.             $result = $module->install();
  85.           } elseif ($action == 'remove') {
  86.             $result = $module->remove();
  87.           }
  88.         }
  89.  
  90.         if ($action == 'install' && $result != 'failed') {
  91.           zen_redirect(zen_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $class . '&action=edit', 'NONSSL'));
  92.         } else {
  93.           zen_redirect(zen_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $class, 'NONSSL'));
  94.         }
  95.         break;
  96.     }
  97.   }
  98. ?>
  99. <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  100. <html <?php echo HTML_PARAMS; ?>>
  101. <head>
  102. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
  103. <title><?php echo TITLE; ?></title>
  104. <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
  105. <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
  106. <script language="javascript" src="includes/menu.js"></script>
  107. <script language="javascript" src="includes/general.js"></script>
  108. <script type="text/javascript">
  109.   <!--
  110.   function init()
  111.   {
  112.     cssjsmenu('navbar');
  113.     if (document.getElementById)
  114.     {
  115.       var kill = document.getElementById('hoverJS');
  116.       kill.disabled = true;
  117.     }
  118.   }
  119.   // -->
  120. </script>
  121. </head>
  122. <body onLoad="init()">
  123. <!-- header //-->
  124. <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
  125. <!-- header_eof //-->
  126.  
  127. <!-- body //-->
  128. <table border="0" width="100%" cellspacing="2" cellpadding="2">
  129.   <tr>
  130. <!-- body_text //-->
  131.     <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  132.       <tr>
  133.         <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  134.           <tr>
  135.             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  136.             <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
  137.           </tr>
  138.         </table></td>
  139.       </tr>
  140.       <tr>
  141.         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  142.           <tr>
  143.             <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  144.               <tr class="dataTableHeadingRow">
  145.                 <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_MODULES; ?></td>
  146.                 <td class="dataTableHeadingContent">&nbsp;</td>
  147.                 <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_SORT_ORDER; ?></td>
  148. <?php
  149.   if ($set == 'payment') {
  150. ?>
  151.                 <td class="dataTableHeadingContent" align="center" width="100"><?php echo TABLE_HEADING_ORDERS_STATUS; ?></td>
  152. <?php } ?>
  153.                 <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
  154.               </tr>
  155. <?php
  156.   $file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.'));
  157.   $directory_array = array();
  158.   if ($dir = @dir($module_directory)) {
  159.     while ($file = $dir->read()) {
  160.       if (!is_dir($module_directory . $file)) {
  161.         if (substr($file, strrpos($file, '.')) == $file_extension) {
  162.           $directory_array[] = $file;
  163.         }
  164.       }
  165.     }
  166.     sort($directory_array);
  167.     $dir->close();
  168.   }
  169.  
  170.   $installed_modules = array();
  171.   for ($i=0, $n=sizeof($directory_array); $i<$n; $i++) {
  172.     $file = $directory_array[$i];
  173.     if (file_exists(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/' . $module_type . '/' . $file)) {
  174.       include(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/' . $module_type . '/' . $file);
  175.       include($module_directory . $file);
  176.       $class = substr($file, 0, strrpos($file, '.'));
  177.       if (zen_class_exists($class)) {
  178.         $module = new $class;
  179.         if ($module->check() > 0) {
  180.           if ($module->sort_order > 0) {
  181.             if ($installed_modules[$module->sort_order] != '') {
  182.               $zc_valid = false;
  183.             }
  184.             $installed_modules[$module->sort_order] = $file;
  185.           } else {
  186.             $installed_modules[] = $file;
  187.           }
  188.         }
  189.         if ((!isset($_GET['module']) || (isset($_GET['module']) && ($_GET['module'] == $class))) && !isset($mInfo)) {
  190.           $module_info = array('code' => $module->code,
  191.                                'title' => $module->title,
  192.                                'description' => $module->description,
  193.                                'status' => $module->check());
  194.           $module_keys = $module->keys();
  195.           $keys_extra = array();
  196.           for ($j=0, $k=sizeof($module_keys); $j<$k; $j++) {
  197.             $key_value = $db->Execute("select configuration_title, configuration_value, configuration_key,
  198.                                          configuration_description, use_function, set_function
  199.                                          from " . TABLE_CONFIGURATION . "
  200.                                          where configuration_key = '" . $module_keys[$j] . "'");
  201.  
  202.             $keys_extra[$module_keys[$j]]['title'] = $key_value->fields['configuration_title'];
  203.             $keys_extra[$module_keys[$j]]['value'] = $key_value->fields['configuration_value'];
  204.             $keys_extra[$module_keys[$j]]['description'] = $key_value->fields['configuration_description'];
  205.             $keys_extra[$module_keys[$j]]['use_function'] = $key_value->fields['use_function'];
  206.             $keys_extra[$module_keys[$j]]['set_function'] = $key_value->fields['set_function'];
  207.           }
  208.           $module_info['keys'] = $keys_extra;
  209.           $mInfo = new objectInfo($module_info);
  210.         }
  211.         if (isset($mInfo) && is_object($mInfo) && ($class == $mInfo->code) ) {
  212.           if ($module->check() > 0) {
  213.             echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $class . '&action=edit', 'NONSSL') . '\'">' . "\n";
  214.           } else {
  215.             echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)">' . "\n";
  216.           }
  217.         } else {
  218.           echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $class, 'NONSSL') . '\'">' . "\n";
  219.         }
  220. //print_r($module) . '<br><BR>';
  221. //echo (!empty($module->enabled) ? 'ENABLED' : 'NOT ENABLED') . ' vs ' . (is_numeric($module->sort_order) ? 'ON' : 'OFF') . '<BR><BR>' ;
  222. ?>
  223.                 <td class="dataTableContent"><?php echo $module->title; ?></td>
  224.                 <td class="dataTableContent"><?php echo (strstr($module->code, 'paypal') ? 'PayPal' : $module->code); ?></td>
  225.                 <td class="dataTableContent" align="right">
  226.                   <?php if (is_numeric($module->sort_order)) echo $module->sort_order; ?>
  227.                   <?php
  228.                     // show current status
  229.                     if ($set == 'payment' || $set == 'shipping') {
  230.                       echo '&nbsp;' . ((!empty($module->enabled) && is_numeric($module->sort_order)) ? zen_image(DIR_WS_IMAGES . 'icon_status_green.gif') : ((empty($module->enabled) && is_numeric($module->sort_order)) ? zen_image(DIR_WS_IMAGES . 'icon_status_yellow.gif') : zen_image(DIR_WS_IMAGES . 'icon_status_red.gif')));
  231.                     } else {
  232.                       echo '&nbsp;' . (is_numeric($module->sort_order) ? zen_image(DIR_WS_IMAGES . 'icon_status_green.gif') : zen_image(DIR_WS_IMAGES . 'icon_status_red.gif'));
  233.                     }
  234.                   ?>
  235.                 </td>
  236. <?php
  237.   if ($set == 'payment') {
  238.     $orders_status_name = $db->Execute("select orders_status_id, orders_status_name from " . TABLE_ORDERS_STATUS . " where orders_status_id='" . $module->order_status . "' and language_id='" . $_SESSION['languages_id'] . "'");
  239. ?>
  240.                 <td class="dataTableContent" align="left">&nbsp;&nbsp;&nbsp;<?php echo (is_numeric($module->sort_order) ? (($orders_status_name->fields['orders_status_id'] < 1) ? TEXT_DEFAULT : $orders_status_name->fields['orders_status_name']) : ''); ?>&nbsp;&nbsp;&nbsp;</td>
  241. <?php } ?>
  242.                 <td class="dataTableContent" align="right"><?php if (isset($mInfo) && is_object($mInfo) && ($class == $mInfo->code) ) { echo zen_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '<a href="' . zen_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $class, 'NONSSL') . '">' . zen_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
  243.               </tr>
  244. <?php
  245.       }
  246.     } else {
  247.       echo ERROR_MODULE_FILE_NOT_FOUND . DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/' . $module_type . '/' . $file . '<br />';
  248.     }
  249.   }
  250.   ksort($installed_modules);
  251.   $check = $db->Execute("select configuration_value
  252.                         from " . TABLE_CONFIGURATION . "
  253.                         where configuration_key = '" . $module_key . "'");
  254.  
  255.   if ($check->RecordCount() > 0) {
  256.     if ($check->fields['configuration_value'] != implode(';', $installed_modules)) {
  257.       $db->Execute("update " . TABLE_CONFIGURATION . "
  258.                    set configuration_value = '" . implode(';', $installed_modules) . "', last_modified = now()
  259.                    where configuration_key = '" . $module_key . "'");
  260.     }
  261.   } else {
  262.     $db->Execute("insert into " . TABLE_CONFIGURATION . "
  263.                (configuration_title, configuration_key, configuration_value,
  264.                 configuration_description, configuration_group_id, sort_order, date_added)
  265.                 values ('Installed Modules', '" . $module_key . "', '" . implode(';', $installed_modules) . "',
  266.                         'This is automatically updated. No need to edit.', '6', '0', now())");
  267.   }
  268.   if (isset($zc_valid) && $zc_valid == false) {
  269.     echo '<span class="alert">' . WARNING_MODULES_SORT_ORDER . '</span>';
  270.   }
  271. ?>
  272.               <tr>
  273.                 <td colspan="3" class="smallText"><?php echo TEXT_MODULE_DIRECTORY . ' ' . $module_directory; ?></td>
  274.               </tr>
  275.             </table></td>
  276. <?php
  277.   $heading = array();
  278.   $contents = array();
  279.   switch ($action) {
  280.     case 'edit':
  281.       $keys = '';
  282.       reset($mInfo->keys);
  283.       while (list($key, $value) = each($mInfo->keys)) {
  284.         $keys .= '<b>' . $value['title'] . '</b><br>' . $value['description'] . '<br>';
  285.         if ($value['set_function']) {
  286.           eval('$keys .= ' . $value['set_function'] . "'" . $value['value'] . "', '" . $key . "');");
  287.         } else {
  288.           $keys .= zen_draw_input_field('configuration[' . $key . ']', $value['value']);
  289.         }
  290.         $keys .= '<br><br>';
  291.       }
  292.       $keys = substr($keys, 0, strrpos($keys, '<br><br>'));
  293.       $heading[] = array('text' => '<b>' . $mInfo->title . '</b>');
  294.       $contents = array('form' => zen_draw_form('modules', FILENAME_MODULES, 'set=' . $set . ($_GET['module'] != '' ? '&module=' . $_GET['module'] : '') . '&action=save', 'post', '', true));
  295.       if (ADMIN_CONFIGURATION_KEY_ON == 1) {
  296.         $contents[] = array('text' => '<strong>Key: ' . $mInfo->code . '</strong><br />');
  297.       }
  298.       $contents[] = array('text' => $keys);
  299.       $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_update.gif', IMAGE_UPDATE, 'name="saveButton"') . ' <a href="' . zen_href_link(FILENAME_MODULES, 'set=' . $set . ($_GET['module'] != '' ? '&module=' . $_GET['module'] : ''), 'NONSSL') . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL, 'name="cancelButton"') . '</a>');
  300.       break;
  301.     default:
  302.       $heading[] = array('text' => '<b>' . $mInfo->title . '</b>');
  303.  
  304.       if ($mInfo->status == '1') {
  305.         $keys = '';
  306.         reset($mInfo->keys);
  307.         while (list(, $value) = each($mInfo->keys)) {
  308.           $keys .= '<b>' . $value['title'] . '</b><br>';
  309.           if ($value['use_function']) {
  310.             $use_function = $value['use_function'];
  311.             if (preg_match('/->/', $use_function)) {
  312.               $class_method = explode('->', $use_function);
  313.               if (!is_object(${$class_method[0]})) {
  314.                 include(DIR_WS_CLASSES . $class_method[0] . '.php');
  315.                 ${$class_method[0]} = new $class_method[0]();
  316.               }
  317.               $keys .= zen_call_function($class_method[1], $value['value'], ${$class_method[0]});
  318.             } else {
  319.               $keys .= zen_call_function($use_function, $value['value']);
  320.             }
  321.           } else {
  322.             $keys .= $value['value'];
  323.           }
  324.           $keys .= '<br><br>';
  325.         }
  326.  
  327.         if (ADMIN_CONFIGURATION_KEY_ON == 1) {
  328.           $contents[] = array('text' => '<strong>Key: ' . $mInfo->code . '</strong><br />');
  329.         }
  330.         $keys = substr($keys, 0, strrpos($keys, '<br><br>'));
  331.         $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $mInfo->code . '&action=remove', 'NONSSL') . '">' . zen_image_button('button_module_remove.gif', IMAGE_MODULE_REMOVE, 'name="removeButton"') . '</a> <a href="' . zen_href_link(FILENAME_MODULES, 'set=' . $set . (isset($_GET['module']) ? '&module=' . $_GET['module'] : '') . '&action=edit', 'NONSSL') . '">' . zen_image_button('button_edit.gif', IMAGE_EDIT, 'name="editButton"') . '</a>');
  332.         $contents[] = array('text' => '<br>' . $mInfo->description);
  333.         $contents[] = array('text' => '<br>' . $keys);
  334.       } else {
  335.         $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $mInfo->code . '&action=install', 'NONSSL') . '">' . zen_image_button('button_module_install.gif', IMAGE_MODULE_INSTALL, 'name="installButton"') . '</a>');
  336.         $contents[] = array('text' => '<br>' . $mInfo->description);
  337.       }
  338.       break;
  339.   }
  340.   if ( (zen_not_null($heading)) && (zen_not_null($contents)) ) {
  341.     echo '            <td width="25%" valign="top">' . "\n";
  342.     $box = new box;
  343.     echo $box->infoBox($heading, $contents);
  344.     echo '            </td>' . "\n";
  345.   }
  346. ?>
  347.           </tr>
  348.         </table></td>
  349.       </tr>
  350.     </table></td>
  351. <!-- body_text_eof //-->
  352.   </tr>
  353. </table>
  354. <!-- body_eof //-->
  355. <!-- footer //-->
  356. <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
  357. <!-- footer_eof //-->
  358. <br>
  359. </body>
  360. </html>
  361. <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>


cron