[ Index ] |
PHP Cross Reference of osCMax 2.0.4 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 $Id: modules.php 3 2006-05-27 04:59:07Z user $ 4 5 osCMax Power E-Commerce 6 http://oscdox.com 7 8 Copyright 2006 osCMax 9 10 Released under the GNU General Public License 11 */ 12 13 require ('includes/application_top.php'); 14 15 $set = (isset($HTTP_GET_VARS['set']) ? $HTTP_GET_VARS['set'] : ''); 16 17 if (tep_not_null($set)) { 18 switch ($set) { 19 case 'shipping': 20 $module_type = 'shipping'; 21 $module_directory = DIR_FS_CATALOG_MODULES . 'shipping/'; 22 $module_key = 'MODULE_SHIPPING_INSTALLED'; 23 define('HEADING_TITLE', HEADING_TITLE_MODULES_SHIPPING); 24 break; 25 case 'ordertotal': 26 $module_type = 'order_total'; 27 $module_directory = DIR_FS_CATALOG_MODULES . 'order_total/'; 28 $module_key = 'MODULE_ORDER_TOTAL_INSTALLED'; 29 define('HEADING_TITLE', HEADING_TITLE_MODULES_ORDER_TOTAL); 30 break; 31 case 'payment': 32 default: 33 $module_type = 'payment'; 34 $module_directory = DIR_FS_CATALOG_MODULES . 'payment/'; 35 $module_key = 'MODULE_PAYMENT_INSTALLED'; 36 define('HEADING_TITLE', HEADING_TITLE_MODULES_PAYMENT); 37 break; 38 } 39 } 40 41 $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : ''); 42 43 if (tep_not_null($action)) { 44 switch ($action) { 45 case 'save': 46 while (list($key, $value) = each($HTTP_POST_VARS['configuration'])) { 47 // BOF: LINES ADDED 48 if( is_array( $value ) ){ 49 $value = implode( ", ", $value); 50 $value = ereg_replace (", --none--", "", $value); 51 } 52 // EOF: LINES ADDED 53 tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $value . "' where configuration_key = '" . $key . "'"); 54 } 55 tep_redirect(tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $HTTP_GET_VARS['module'])); 56 break; 57 case 'install': 58 case 'remove': 59 $file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.')); 60 $class = basename($HTTP_GET_VARS['module']); 61 if (file_exists($module_directory . $class . $file_extension)) { 62 include($module_directory . $class . $file_extension); 63 $module = new $class; 64 if ($action == 'install') { 65 $module->install(); 66 } elseif ($action == 'remove') { 67 $module->remove(); 68 } 69 } 70 tep_redirect(tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $class)); 71 break; 72 } 73 } 74 ?> 75 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> 76 <html <?php echo HTML_PARAMS; ?>> 77 <head> 78 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> 79 <title><?php echo TITLE; ?></title> 80 <link rel="stylesheet" type="text/css" href="includes/stylesheet.css"> 81 <script language="javascript" src="includes/general.js"></script> 82 </head> 83 <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF"> 84 <!-- header //--> 85 <?php require (DIR_WS_INCLUDES . 'header.php'); ?> 86 <!-- header_eof //--> 87 88 <!-- body //--> 89 <table border="0" width="100%" cellspacing="2" cellpadding="2"> 90 <tr> 91 <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft"> 92 <!-- left_navigation //--> 93 <?php require (DIR_WS_INCLUDES . 'column_left.php'); ?> 94 <!-- left_navigation_eof //--> 95 </table></td> 96 <!-- body_text //--> 97 <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> 98 <tr> 99 <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0"> 100 <tr> 101 <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> 102 <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> 103 </tr> 104 </table></td> 105 </tr> 106 <tr> 107 <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> 108 <tr> 109 <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> 110 <tr class="dataTableHeadingRow"> 111 <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_MODULES; ?></td> 112 <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_SORT_ORDER; ?></td> 113 <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td> 114 </tr> 115 <?php 116 $file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.')); 117 $directory_array = array(); 118 if ($dir = @dir($module_directory)) { 119 while ($file = $dir->read()) { 120 if (!is_dir($module_directory . $file)) { 121 if (substr($file, strrpos($file, '.')) == $file_extension) { 122 $directory_array[] = $file; 123 } 124 } 125 } 126 sort($directory_array); 127 $dir->close(); 128 } 129 130 $installed_modules = array(); 131 for ($i=0, $n=sizeof($directory_array); $i<$n; $i++) { 132 $file = $directory_array[$i]; 133 134 include(DIR_FS_CATALOG_LANGUAGES . $language . '/modules/' . $module_type . '/' . $file); 135 include($module_directory . $file); 136 137 $class = substr($file, 0, strrpos($file, '.')); 138 if (tep_class_exists($class)) { 139 $module = new $class; 140 if ($module->check() > 0) { 141 if ($module->sort_order > 0) { 142 $installed_modules[$module->sort_order] = $file; 143 } else { 144 $installed_modules[] = $file; 145 } 146 } 147 148 if ((!isset($HTTP_GET_VARS['module']) || (isset($HTTP_GET_VARS['module']) && ($HTTP_GET_VARS['module'] == $class))) && !isset($mInfo)) { 149 $module_info = array('code' => $module->code, 150 'title' => $module->title, 151 'description' => $module->description, 152 'status' => $module->check(), 153 'signature' => (isset($module->signature) ? $module->signature : null)); 154 155 $module_keys = $module->keys(); 156 157 $keys_extra = array(); 158 for ($j=0, $k=sizeof($module_keys); $j<$k; $j++) { 159 $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] . "'"); 160 $key_value = tep_db_fetch_array($key_value_query); 161 162 $keys_extra[$module_keys[$j]]['title'] = $key_value['configuration_title']; 163 $keys_extra[$module_keys[$j]]['value'] = $key_value['configuration_value']; 164 $keys_extra[$module_keys[$j]]['description'] = $key_value['configuration_description']; 165 $keys_extra[$module_keys[$j]]['use_function'] = $key_value['use_function']; 166 $keys_extra[$module_keys[$j]]['set_function'] = $key_value['set_function']; 167 } 168 169 $module_info['keys'] = $keys_extra; 170 171 $mInfo = new objectInfo($module_info); 172 } 173 174 if (isset($mInfo) && is_object($mInfo) && ($class == $mInfo->code) ) { 175 if ($module->check() > 0) { 176 echo ' <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $class . '&action=edit') . '\'">' . "\n"; 177 } else { 178 echo ' <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)">' . "\n"; 179 } 180 } else { 181 echo ' <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $class) . '\'">' . "\n"; 182 } 183 ?> 184 <td class="dataTableContent"><?php echo $module->title; ?></td> 185 <td class="dataTableContent" align="right"><?php if (is_numeric($module->sort_order)) echo $module->sort_order; ?></td> 186 <td class="dataTableContent" align="right"><?php if (isset($mInfo) && is_object($mInfo) && ($class == $mInfo->code) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '<a href="' . tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $class) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td> 187 </tr> 188 <?php 189 } 190 } 191 192 ksort($installed_modules); 193 $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = '" . $module_key . "'"); 194 if (tep_db_num_rows($check_query)) { 195 $check = tep_db_fetch_array($check_query); 196 if ($check['configuration_value'] != implode(';', $installed_modules)) { 197 tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . implode(';', $installed_modules) . "', last_modified = now() where configuration_key = '" . $module_key . "'"); 198 } 199 } else { 200 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())"); 201 } 202 ?> 203 <tr> 204 <td colspan="3" class="smallText"><?php echo TEXT_MODULE_DIRECTORY . ' ' . $module_directory; ?></td> 205 </tr> 206 </table></td> 207 <?php 208 $heading = array(); 209 $contents = array(); 210 211 switch ($action) { 212 case 'edit': 213 $keys = ''; 214 reset($mInfo->keys); 215 while (list($key, $value) = each($mInfo->keys)) { 216 $keys .= '<b>' . $value['title'] . '</b><br>' . $value['description'] . '<br>'; 217 218 if ($value['set_function']) { 219 eval('$keys .= ' . $value['set_function'] . "'" . $value['value'] . "', '" . $key . "');"); 220 } else { 221 $keys .= tep_draw_input_field('configuration[' . $key . ']', $value['value']); 222 } 223 $keys .= '<br><br>'; 224 } 225 $keys = substr($keys, 0, strrpos($keys, '<br><br>')); 226 227 $heading[] = array('text' => '<b>' . $mInfo->title . '</b>'); 228 229 $contents = array('form' => tep_draw_form('modules', FILENAME_MODULES, 'set=' . $set . '&module=' . $HTTP_GET_VARS['module'] . '&action=save')); 230 $contents[] = array('text' => $keys); 231 $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_update.gif', IMAGE_UPDATE) . ' <a href="' . tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $HTTP_GET_VARS['module']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'); 232 break; 233 default: 234 $heading[] = array('text' => '<b>' . $mInfo->title . '</b>'); 235 236 if ($mInfo->status == '1') { 237 $keys = ''; 238 reset($mInfo->keys); 239 while (list(, $value) = each($mInfo->keys)) { 240 $keys .= '<b>' . $value['title'] . '</b><br>'; 241 if ($value['use_function']) { 242 $use_function = $value['use_function']; 243 if (ereg('->', $use_function)) { 244 $class_method = explode('->', $use_function); 245 if (!is_object(${$class_method[0]})) { 246 include(DIR_WS_CLASSES . $class_method[0] . '.php'); 247 ${$class_method[0]} = new $class_method[0](); 248 } 249 $keys .= tep_call_function($class_method[1], $value['value'], ${$class_method[0]}); 250 } else { 251 $keys .= tep_call_function($use_function, $value['value']); 252 } 253 } else { 254 $keys .= $value['value']; 255 } 256 $keys .= '<br><br>'; 257 } 258 $keys = substr($keys, 0, strrpos($keys, '<br><br>')); 259 260 $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $mInfo->code . '&action=remove') . '">' . tep_image_button('button_module_remove.gif', IMAGE_MODULE_REMOVE) . '</a> <a href="' . tep_href_link(FILENAME_MODULES, 'set=' . $set . (isset($HTTP_GET_VARS['module']) ? '&module=' . $HTTP_GET_VARS['module'] : '') . '&action=edit') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a>'); 261 if (isset($mInfo->signature) && (list($scode, $smodule, $sversion, $soscversion) = explode('|', $mInfo->signature))) { 262 $contents[] = array('text' => '<br>' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ' <b>' . TEXT_INFO_VERSION . '</b> ' . $sversion . ' (<a href="http://sig.oscommerce.com/' . $mInfo->signature . '" target="_blank">' . TEXT_INFO_ONLINE_STATUS . '</a>)'); 263 } 264 $contents[] = array('text' => '<br>' . $mInfo->description); 265 $contents[] = array('text' => '<br>' . $keys); 266 } else { 267 $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $mInfo->code . '&action=install') . '">' . tep_image_button('button_module_install.gif', IMAGE_MODULE_INSTALL) . '</a>'); 268 if (isset($mInfo->signature) && (list($scode, $smodule, $sversion, $soscversion) = explode('|', $mInfo->signature))) { 269 $contents[] = array('text' => '<br>' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ' <b>' . TEXT_INFO_VERSION . '</b> ' . $sversion . ' (<a href="http://sig.oscommerce.com/' . $mInfo->signature . '" target="_blank">' . TEXT_INFO_ONLINE_STATUS . '</a>)'); 270 } 271 $contents[] = array('text' => '<br>' . $mInfo->description); 272 } 273 break; 274 } 275 276 if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) { 277 echo ' <td width="25%" valign="top">' . "\n"; 278 279 $box = new box; 280 echo $box->infoBox($heading, $contents); 281 282 echo ' </td>' . "\n"; 283 } 284 ?> 285 </tr> 286 </table></td> 287 </tr> 288 </table></td> 289 <!-- body_text_eof //--> 290 </tr> 291 </table> 292 <!-- body_eof //--> 293 294 <!-- footer //--> 295 <?php require (DIR_WS_INCLUDES . 'footer.php'); ?> 296 <!-- footer_eof //--> 297 <br> 298 </body> 299 </html> 300 <?php require (DIR_WS_INCLUDES . 'application_bottom.php'); ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Jan 1 13:43:16 2010 | Cross-referenced by PHPXref 0.7 |