title: Parse error: syntax error, unexpected T_ELSE in ..... modules.php on line 243
body: <p>I'm getting this error after inserting manually a module for oscommerce. I know it has something to do with this part after adding the module beneath to the excisting code.</p>
  
  <p>Does anyone see what is wrong here?</p>
  
  <pre><code>// STS V4.6 drop start
          } else {
              if($key == 'MODULE_STS_TEMPLATE_FOLDER'){
                  $dir_name = array();
                  if ($handle = opendir('../'.MODULE_STS_TEMPLATES_FOLDER.'/')) {
                     while (false !== ($file = readdir($handle))) {
                          $pos = strpos($file, ".");
                          if($pos === false){
                              $dir_name[] = array("id" =&gt; $file, "text" =&gt; $file);
                              $i++;
                          }
                      }
                      closedir($handle);
                  }
                  $keys .= tep_draw_pull_down_menu('configuration[MODULE_STS_TEMPLATE_FOLDER]', $dir_name, $value['value']);
              }else{
                  $keys .= tep_draw_input_field('configuration[' . $key . ']', $value['value']);
              }
          }
          // STS V4.6 drop end
  
  
  &lt;?php
  /*
    $Id: modules.php,v 1.47 2003/06/29 22:50:52 hpdl Exp $
  
    osCommerce, Open Source E-Commerce Solutions
    http://www.oscommerce.com
  
    Copyright (c) 2003 osCommerce
  
    Released under the GNU General Public License
  */
  
    require('includes/application_top.php');
  
    $set = (isset($HTTP_GET_VARS['set']) ? $HTTP_GET_VARS['set'] : '');
  
    if (tep_not_null($set)) {
  
   switch ($set) {
   // START STS 4.1
  case 'sts':
  $module_type = 'sts';
  $module_directory = DIR_FS_CATALOG_MODULES . 'sts/';
  $module_key = 'MODULE_STS_INSTALLED';
  define('HEADING_TITLE', HEADING_TITLE_MODULES_STS); 
  break;
  // END STS 4.1
        case 'shipping':
          $module_type = 'shipping';
          $module_directory = DIR_FS_CATALOG_MODULES . 'shipping/';
          $module_key = 'MODULE_SHIPPING_INSTALLED';
          define('HEADING_TITLE', HEADING_TITLE_MODULES_SHIPPING);
          break;
        case 'ordertotal':
          $module_type = 'order_total';
          $module_directory = DIR_FS_CATALOG_MODULES . 'order_total/';
          $module_key = 'MODULE_ORDER_TOTAL_INSTALLED';
          define('HEADING_TITLE', HEADING_TITLE_MODULES_ORDER_TOTAL);
          break;
        case 'payment':
        default:
          $module_type = 'payment';
          $module_directory = DIR_FS_CATALOG_MODULES . 'payment/';
          $module_key = 'MODULE_PAYMENT_INSTALLED';
          define('HEADING_TITLE', HEADING_TITLE_MODULES_PAYMENT);
          break;
      }
    }
  
    $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
  
    if (tep_not_null($action)) {
      switch ($action) {
        case 'save':
          while (list($key, $value) = each($HTTP_POST_VARS['configuration'])) {
            tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $value . "' where configuration_key = '" . $key . "'");
          }
          tep_redirect(tep_href_link(FILENAME_MODULES, 'set=' . $set . '&amp;module=' . $HTTP_GET_VARS['module']));
          break;
        case 'install':
        case 'remove':
          $file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.'));
          $class = basename($HTTP_GET_VARS['module']);
          if (file_exists($module_directory . $class . $file_extension)) {
            include($module_directory . $class . $file_extension);
            $module = new $class;
            if ($action == 'install') {
              $module-&gt;install();
            } elseif ($action == 'remove') {
              $module-&gt;remove();
            }
          }
          tep_redirect(tep_href_link(FILENAME_MODULES, 'set=' . $set . '&amp;module=' . $class));
          break;
      }
    }
  ?&gt;
  &lt;!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;
  &lt;html &lt;?php echo HTML_PARAMS; ?&gt;&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=&lt;?php echo CHARSET; ?&gt;"&gt;
  &lt;title&gt;&lt;?php echo TITLE; ?&gt;&lt;/title&gt;
  &lt;link rel="stylesheet" type="text/css" href="includes/stylesheet.css"&gt;
  &lt;script language="javascript" src="includes/general.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF"&gt;
  &lt;!-- header //--&gt;
  &lt;?php require(DIR_WS_INCLUDES . 'header.php'); ?&gt;
  &lt;!-- header_eof //--&gt;
  
  &lt;!-- body //--&gt;
  &lt;table border="0" width="100%" cellspacing="2" cellpadding="2"&gt;
    &lt;tr&gt;
      &lt;td width="&lt;?php echo BOX_WIDTH; ?&gt;" valign="top"&gt;&lt;table border="0" width="&lt;?php echo BOX_WIDTH; ?&gt;" cellspacing="1" cellpadding="1" class="columnLeft"&gt;
  &lt;!-- left_navigation //--&gt;
  &lt;?php require(DIR_WS_INCLUDES . 'column_left.php'); ?&gt;
  &lt;!-- left_navigation_eof //--&gt;
      &lt;/table&gt;&lt;/td&gt;
  &lt;!-- body_text //--&gt;
      &lt;td width="100%" valign="top"&gt;&lt;table border="0" width="100%" cellspacing="0" cellpadding="2"&gt;
        &lt;tr&gt;
          &lt;td width="100%"&gt;&lt;table border="0" width="100%" cellspacing="0" cellpadding="0"&gt;
            &lt;tr&gt;
              &lt;td class="pageHeading"&gt;&lt;?php echo HEADING_TITLE; ?&gt;&lt;/td&gt;
              &lt;td class="pageHeading" align="right"&gt;&lt;?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?&gt;&lt;/td&gt;
            &lt;/tr&gt;
          &lt;/table&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;&lt;table border="0" width="100%" cellspacing="0" cellpadding="0"&gt;
            &lt;tr&gt;
              &lt;td valign="top"&gt;&lt;table border="0" width="100%" cellspacing="0" cellpadding="2"&gt;
                &lt;tr class="dataTableHeadingRow"&gt;
                  &lt;td class="dataTableHeadingContent"&gt;&lt;?php echo TABLE_HEADING_MODULES; ?&gt;&lt;/td&gt;
                  &lt;td class="dataTableHeadingContent" align="right"&gt;&lt;?php echo TABLE_HEADING_SORT_ORDER; ?&gt;&lt;/td&gt;
                  &lt;td class="dataTableHeadingContent" align="right"&gt;&lt;?php echo TABLE_HEADING_ACTION; ?&gt;&amp;nbsp;&lt;/td&gt;
                &lt;/tr&gt;
  &lt;?php
    $file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.'));
    $directory_array = array();
    if ($dir = @dir($module_directory)) {
      while ($file = $dir-&gt;read()) {
        if (!is_dir($module_directory . $file)) {
          if (substr($file, strrpos($file, '.')) == $file_extension) {
            $directory_array[] = $file;
          }
        }
      }
      sort($directory_array);
      $dir-&gt;close();
    }
  
    $installed_modules = array();
    for ($i=0, $n=sizeof($directory_array); $i&lt;$n; $i++) {
      $file = $directory_array[$i];
  
      include(DIR_FS_CATALOG_LANGUAGES . $language . '/modules/' . $module_type . '/' . $file);
      include($module_directory . $file);
  
      $class = substr($file, 0, strrpos($file, '.'));
      if (tep_class_exists($class)) {
        $module = new $class;
        if ($module-&gt;check() &gt; 0) {
          if ($module-&gt;sort_order &gt; 0) {
            $installed_modules[$module-&gt;sort_order] = $file;
          } else {
            $installed_modules[] = $file;
          }
        }
  
        if ((!isset($HTTP_GET_VARS['module']) || (isset($HTTP_GET_VARS['module']) &amp;&amp; ($HTTP_GET_VARS['module'] == $class))) &amp;&amp; !isset($mInfo)) {
          $module_info = array('code' =&gt; $module-&gt;code,
                               'title' =&gt; $module-&gt;title,
                               'description' =&gt; $module-&gt;description,
                               'status' =&gt; $module-&gt;check());
  
          $module_keys = $module-&gt;keys();
  
          $keys_extra = array();
          for ($j=0, $k=sizeof($module_keys); $j&lt;$k; $j++) {
            $key_value_query = tep_db_query("select configuration_title, configuration_value, configuration_description, use_function, set_function from " . TABLE_CONFIGURATION . " where configuration_key = '" . $module_keys[$j] . "'");
            $key_value = tep_db_fetch_array($key_value_query);
  
            $keys_extra[$module_keys[$j]]['title'] = $key_value['configuration_title'];
            $keys_extra[$module_keys[$j]]['value'] = $key_value['configuration_value'];
            $keys_extra[$module_keys[$j]]['description'] = $key_value['configuration_description'];
            $keys_extra[$module_keys[$j]]['use_function'] = $key_value['use_function'];
            $keys_extra[$module_keys[$j]]['set_function'] = $key_value['set_function'];
          }
  
          $module_info['keys'] = $keys_extra;
  
          $mInfo = new objectInfo($module_info);
        }
  
        if (isset($mInfo) &amp;&amp; is_object($mInfo) &amp;&amp; ($class == $mInfo-&gt;code) ) {
          if ($module-&gt;check() &gt; 0) {
            echo '              &lt;tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_MODULES, 'set=' . $set . '&amp;module=' . $class . '&amp;action=edit') . '\'"&gt;' . "\n";
          } else {
            echo '              &lt;tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)"&gt;' . "\n";
          }
        } else {
          echo '              &lt;tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_MODULES, 'set=' . $set . '&amp;module=' . $class) . '\'"&gt;' . "\n";
        }
  ?&gt;
                  &lt;td class="dataTableContent"&gt;&lt;?php echo $module-&gt;title; ?&gt;&lt;/td&gt;
                  &lt;td class="dataTableContent" align="right"&gt;&lt;?php if (is_numeric($module-&gt;sort_order)) echo $module-&gt;sort_order; ?&gt;&lt;/td&gt;
                  &lt;td class="dataTableContent" align="right"&gt;&lt;?php if (isset($mInfo) &amp;&amp; is_object($mInfo) &amp;&amp; ($class == $mInfo-&gt;code) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '&lt;a href="' . tep_href_link(FILENAME_MODULES, 'set=' . $set . '&amp;module=' . $class) . '"&gt;' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '&lt;/a&gt;'; } ?&gt;&amp;nbsp;&lt;/td&gt;
                &lt;/tr&gt;
  &lt;?php
      }
    }
  
    ksort($installed_modules);
    $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = '" . $module_key . "'");
    if (tep_db_num_rows($check_query)) {
      $check = tep_db_fetch_array($check_query);
      if ($check['configuration_value'] != implode(';', $installed_modules)) {
        tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . implode(';', $installed_modules) . "', last_modified = now() where configuration_key = '" . $module_key . "'");
      }
    } else {
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Installed Modules', '" . $module_key . "', '" . implode(';', $installed_modules) . "', 'This is automatically updated. No need to edit.', '6', '0', now())");
    }
  ?&gt;
                &lt;tr&gt;
                  &lt;td colspan="3" class="smallText"&gt;&lt;?php echo TEXT_MODULE_DIRECTORY . ' ' . $module_directory; ?&gt;&lt;/td&gt;
                &lt;/tr&gt;
              &lt;/table&gt;&lt;/td&gt;
  &lt;?php
    $heading = array();
    $contents = array();
  
    switch ($action) {
      case 'edit':
        $keys = '';
        reset($mInfo-&gt;keys);
        while (list($key, $value) = each($mInfo-&gt;keys)) {
          $keys .= '&lt;b&gt;' . $value['title'] . '&lt;/b&gt;&lt;br&gt;' . $value['description'] . '&lt;br&gt;';
  
          if ($value['set_function']) {
            eval('$keys .= ' . $value['set_function'] . "'" . $value['value'] . "', '" . $key . "');");
            // STS V4.6 drop start
          } else {
              if($key == 'MODULE_STS_TEMPLATE_FOLDER'){
                  $dir_name = array();
                  if ($handle = opendir('../'.MODULE_STS_TEMPLATES_FOLDER.'/')) {
                     while (false !== ($file = readdir($handle))) {
                          $pos = strpos($file, ".");
                          if($pos === false){
                              $dir_name[] = array("id" =&gt; $file, "text" =&gt; $file);
                              $i++;
                          }
                      }
                      closedir($handle);
                  }
                  $keys .= tep_draw_pull_down_menu('configuration[MODULE_STS_TEMPLATE_FOLDER]', $dir_name, $value['value']);
              }else{
                  $keys .= tep_draw_input_field('configuration[' . $key . ']', $value['value']);
              }
          }
          // STS V4.6 drop end
  
          } else {
            $keys .= tep_draw_input_field('configuration[' . $key . ']', $value['value']);
          }
          $keys .= '&lt;br&gt;&lt;br&gt;';
        }
        $keys = substr($keys, 0, strrpos($keys, '&lt;br&gt;&lt;br&gt;'));
  
        $heading[] = array('text' =&gt; '&lt;b&gt;' . $mInfo-&gt;title . '&lt;/b&gt;');
  
        $contents = array('form' =&gt; tep_draw_form('modules', FILENAME_MODULES, 'set=' . $set . '&amp;module=' . $HTTP_GET_VARS['module'] . '&amp;action=save'));
        $contents[] = array('text' =&gt; $keys);
        $contents[] = array('align' =&gt; 'center', 'text' =&gt; '&lt;br&gt;' . tep_image_submit('button_update.gif', IMAGE_UPDATE) . ' &lt;a href="' . tep_href_link(FILENAME_MODULES, 'set=' . $set . '&amp;module=' . $HTTP_GET_VARS['module']) . '"&gt;' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '&lt;/a&gt;');
        break;
      default:
        $heading[] = array('text' =&gt; '&lt;b&gt;' . $mInfo-&gt;title . '&lt;/b&gt;');
  
        if ($mInfo-&gt;status == '1') {
          $keys = '';
          reset($mInfo-&gt;keys);
          while (list(, $value) = each($mInfo-&gt;keys)) {
            $keys .= '&lt;b&gt;' . $value['title'] . '&lt;/b&gt;&lt;br&gt;';
            if ($value['use_function']) {
              $use_function = $value['use_function'];
              if (ereg('-&gt;', $use_function)) {
                $class_method = explode('-&gt;', $use_function);
                if (!is_object(${$class_method[0]})) {
                  include(DIR_WS_CLASSES . $class_method[0] . '.php');
                  ${$class_method[0]} = new $class_method[0]();
                }
                $keys .= tep_call_function($class_method[1], $value['value'], ${$class_method[0]});
              } else {
                $keys .= tep_call_function($use_function, $value['value']);
              }
            } else {
              $keys .= $value['value'];
            }
            $keys .= '&lt;br&gt;&lt;br&gt;';
          }
          $keys = substr($keys, 0, strrpos($keys, '&lt;br&gt;&lt;br&gt;'));
  
          $contents[] = array('align' =&gt; 'center', 'text' =&gt; '&lt;a href="' . tep_href_link(FILENAME_MODULES, 'set=' . $set . '&amp;module=' . $mInfo-&gt;code . '&amp;action=remove') . '"&gt;' . tep_image_button('button_module_remove.gif', IMAGE_MODULE_REMOVE) . '&lt;/a&gt; &lt;a href="' . tep_href_link(FILENAME_MODULES, 'set=' . $set . (isset($HTTP_GET_VARS['module']) ? '&amp;module=' . $HTTP_GET_VARS['module'] : '') . '&amp;action=edit') . '"&gt;' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '&lt;/a&gt;');
          $contents[] = array('text' =&gt; '&lt;br&gt;' . $mInfo-&gt;description);
          $contents[] = array('text' =&gt; '&lt;br&gt;' . $keys);
        } else {
          $contents[] = array('align' =&gt; 'center', 'text' =&gt; '&lt;a href="' . tep_href_link(FILENAME_MODULES, 'set=' . $set . '&amp;module=' . $mInfo-&gt;code . '&amp;action=install') . '"&gt;' . tep_image_button('button_module_install.gif', IMAGE_MODULE_INSTALL) . '&lt;/a&gt;');
          $contents[] = array('text' =&gt; '&lt;br&gt;' . $mInfo-&gt;description);
        }
        break;
    }
  
    if ( (tep_not_null($heading)) &amp;&amp; (tep_not_null($contents)) ) {
      echo '            &lt;td width="25%" valign="top"&gt;' . "\n";
  
      $box = new box;
      echo $box-&gt;infoBox($heading, $contents);
  
      echo '            &lt;/td&gt;' . "\n";
    }
  ?&gt;
            &lt;/tr&gt;
          &lt;/table&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/table&gt;&lt;/td&gt;
  &lt;!-- body_text_eof //--&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  &lt;!-- body_eof //--&gt;
  
  &lt;!-- footer //--&gt;
  &lt;?php require(DIR_WS_INCLUDES . 'footer.php'); ?&gt;
  &lt;!-- footer_eof //--&gt;
  &lt;br&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  &lt;?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?&gt;
  </code></pre>