| [ Index ] | osCommerce
Docs :: PHP Cross Reference For osCommerce 2.2 MS2 Provided By OSCdox.com |
1 <?php 2 /* 3 $Id: define_language.php,v 1.15 2003/07/08 21:51:37 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 if (!isset($HTTP_GET_VARS['lngdir'])) $HTTP_GET_VARS['lngdir'] = $language; 16 17 $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : ''); 18 19 if (tep_not_null($action)) { 20 switch ($action) { 21 case 'save': 22 if (isset($HTTP_GET_VARS['lngdir']) && isset($HTTP_GET_VARS['filename'])) { 23 if ($HTTP_GET_VARS['filename'] == $HTTP_GET_VARS['lngdir'] . '.php') { 24 $file = DIR_FS_CATALOG_LANGUAGES . $HTTP_GET_VARS['filename']; 25 } else { 26 $file = DIR_FS_CATALOG_LANGUAGES . $HTTP_GET_VARS['lngdir'] . '/' . $HTTP_GET_VARS['filename']; 27 } 28 29 if (file_exists($file)) { 30 if (file_exists('bak' . $file)) { 31 @unlink('bak' . $file); 32 } 33 34 @rename($file, 'bak' . $file); 35 36 $new_file = fopen($file, 'w'); 37 $file_contents = stripslashes($HTTP_POST_VARS['file_contents']); 38 fwrite($new_file, $file_contents, strlen($file_contents)); 39 fclose($new_file); 40 } 41 tep_redirect(tep_href_link(FILENAME_DEFINE_LANGUAGE, 'lngdir=' . $HTTP_GET_VARS['lngdir'])); 42 } 43 break; 44 } 45 } 46 47 $languages_array = array(); 48 $languages = tep_get_languages(); 49 $lng_exists = false; 50 for ($i=0, $n=sizeof($languages); $i<$n; $i++) { 51 if ($languages[$i]['directory'] == $HTTP_GET_VARS['lngdir']) $lng_exists = true; 52 53 $languages_array[] = array('id' => $languages[$i]['directory'], 54 'text' => $languages[$i]['name']); 55 } 56 57 if (!$lng_exists) $HTTP_GET_VARS['lngdir'] = $language; 58 ?> 59 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> 60 <html <?php echo HTML_PARAMS; ?>> 61 <head> 62 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> 63 <title><?php echo TITLE; ?></title> 64 <link rel="stylesheet" type="text/css" href="includes/stylesheet.css"> 65 </head> 66 <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF"> 67 <!-- header //--> 68 <?php require (DIR_WS_INCLUDES . 'header.php'); ?> 69 <!-- header_eof //--> 70 71 <!-- body //--> 72 <table border="0" width="100%" cellspacing="2" cellpadding="2"> 73 <tr> 74 <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft"> 75 <!-- left_navigation //--> 76 <?php require (DIR_WS_INCLUDES . 'column_left.php'); ?> 77 <!-- left_navigation_eof //--> 78 </table></td> 79 <!-- body_text //--> 80 <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> 81 <tr> 82 <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> 83 <tr><?php echo tep_draw_form('lng', FILENAME_DEFINE_LANGUAGE, '', 'get'); ?> 84 <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> 85 <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', '1', HEADING_IMAGE_HEIGHT); ?></td> 86 <td class="pageHeading" align="right"><?php echo tep_draw_pull_down_menu('lngdir', $languages_array, $language, 'onChange="this.form.submit();"'); ?></td> 87 </form></tr> 88 </table></td> 89 </tr> 90 <tr> 91 <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> 92 <?php 93 if (isset($HTTP_GET_VARS['lngdir']) && isset($HTTP_GET_VARS['filename'])) { 94 if ($HTTP_GET_VARS['filename'] == $HTTP_GET_VARS['lngdir'] . '.php') { 95 $file = DIR_FS_CATALOG_LANGUAGES . $HTTP_GET_VARS['filename']; 96 } else { 97 $file = DIR_FS_CATALOG_LANGUAGES . $HTTP_GET_VARS['lngdir'] . '/' . $HTTP_GET_VARS['filename']; 98 } 99 100 if (file_exists($file)) { 101 $file_array = file($file); 102 $contents = implode('', $file_array); 103 104 $file_writeable = true; 105 if (!is_writeable($file)) { 106 $file_writeable = false; 107 $messageStack->reset(); 108 $messageStack->add(sprintf(ERROR_FILE_NOT_WRITEABLE, $file), 'error'); 109 echo $messageStack->output(); 110 } 111 112 ?> 113 <tr><?php echo tep_draw_form('language', FILENAME_DEFINE_LANGUAGE, 'lngdir=' . $HTTP_GET_VARS['lngdir'] . '&filename=' . $HTTP_GET_VARS['filename'] . '&action=save'); ?> 114 <td><table border="0" cellspacing="0" cellpadding="2"> 115 <tr> 116 <td class="main"><b><?php echo $HTTP_GET_VARS['filename']; ?></b></td> 117 </tr> 118 <tr> 119 <td class="main"><?php echo tep_draw_textarea_field('file_contents', 'soft', '80', '20', $contents, (($file_writeable) ? '' : 'readonly')); ?></td> 120 </tr> 121 <tr> 122 <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 123 </tr> 124 <tr> 125 <td align="right"><?php if ($file_writeable == true) { echo tep_image_submit('button_save.gif', IMAGE_SAVE) . ' <a href="' . tep_href_link(FILENAME_DEFINE_LANGUAGE, 'lngdir=' . $HTTP_GET_VARS['lngdir']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; } else { echo '<a href="' . tep_href_link(FILENAME_DEFINE_LANGUAGE, 'lngdir=' . $HTTP_GET_VARS['lngdir']) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; } ?></td> 126 </tr> 127 </table></td> 128 </form></tr> 129 <?php 130 } else { 131 ?> 132 <tr> 133 <td class="main"><b><?php echo TEXT_FILE_DOES_NOT_EXIST; ?></b></td> 134 </tr> 135 <tr> 136 <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 137 </tr> 138 <tr> 139 <td><?php echo '<a href="' . tep_href_link(FILENAME_DEFINE_LANGUAGE, 'lngdir=' . $HTTP_GET_VARS['lngdir']) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td> 140 </tr> 141 <?php 142 } 143 } else { 144 $filename = $HTTP_GET_VARS['lngdir'] . '.php'; 145 ?> 146 <tr> 147 <td><table width="100%" border="0" cellspacing="0" cellpadding="0"> 148 <tr> 149 <td class="smallText"><a href="<?php echo tep_href_link(FILENAME_DEFINE_LANGUAGE, 'lngdir=' . $HTTP_GET_VARS['lngdir'] . '&filename=' . $filename); ?>"><b><?php echo $filename; ?></b></a></td> 150 <?php 151 $left = false; 152 if ($dir = dir(DIR_FS_CATALOG_LANGUAGES . $HTTP_GET_VARS['lngdir'])) { 153 $file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.')); 154 while ($file = $dir->read()) { 155 if (substr($file, strrpos($file, '.')) == $file_extension) { 156 echo ' <td class="smallText"><a href="' . tep_href_link(FILENAME_DEFINE_LANGUAGE, 'lngdir=' . $HTTP_GET_VARS['lngdir'] . '&filename=' . $file) . '">' . $file . '</a></td>' . "\n"; 157 if (!$left) { 158 echo ' </tr>' . "\n" . 159 ' <tr>' . "\n"; 160 } 161 $left = !$left; 162 } 163 } 164 $dir->close(); 165 } 166 ?> 167 </tr> 168 </table></td> 169 </tr> 170 <tr> 171 <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 172 </tr> 173 <tr> 174 <td align="right"><?php echo '<a href="' . tep_href_link(FILENAME_FILE_MANAGER, 'current_path=' . DIR_FS_CATALOG_LANGUAGES . $HTTP_GET_VARS['lngdir']) . '">' . tep_image_button('button_file_manager.gif', IMAGE_FILE_MANAGER) . '</a>'; ?></td> 175 </tr> 176 <?php 177 } 178 ?> 179 </table></td> 180 </tr> 181 </table></td> 182 <!-- body_text_eof //--> 183 </tr> 184 </table> 185 <!-- body_eof //--> 186 187 <!-- footer //--> 188 <?php require (DIR_WS_INCLUDES . 'footer.php'); ?> 189 <!-- footer_eof //--> 190 <br> 191 </body> 192 </html> 193 <?php require (DIR_WS_INCLUDES . 'application_bottom.php'); ?>
title
Description
Body
title
Description
Body
| Generated: Tue Nov 4 23:53:39 2003 | Hosted By :: AABox.com |
Cross-referenced by PHPXref 0.4 |