[ Index ] |
PHP Cross Reference of osCMax 2.0.4 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 $Id: admin_files.php 3 2006-05-27 04:59:07Z user $ 4 5 osCMax Power E-Commerce 6 http://oscdox.com 7 8 Copyright 2006 osCMax2005 osCMax, 2002 osCommerce 9 10 Released under the GNU General Public License 11 */ 12 13 require ('includes/application_top.php'); 14 15 $current_boxes = DIR_FS_ADMIN . DIR_WS_BOXES; 16 $current_files = DIR_FS_ADMIN; 17 18 if ($HTTP_GET_VARS['action']) { 19 switch ($HTTP_GET_VARS['action']) { 20 case 'box_store': 21 $sql_data_array = array('admin_files_name' => tep_db_prepare_input($HTTP_GET_VARS['box']), 22 'admin_files_is_boxes' => '1'); 23 tep_db_perform(TABLE_ADMIN_FILES, $sql_data_array); 24 $admin_boxes_id = tep_db_insert_id(); 25 26 tep_redirect(tep_href_link(FILENAME_ADMIN_FILES, 'cID=' . $admin_boxes_id)); 27 break; 28 case 'box_remove': 29 // NOTE: ALSO DELETE FILES STORED IN REMOVED BOX // 30 $admin_boxes_id = tep_db_prepare_input($HTTP_GET_VARS['cID']); 31 tep_db_query("delete from " . TABLE_ADMIN_FILES . " where admin_files_id = '" . $admin_boxes_id . "' or admin_files_to_boxes = '" . $admin_boxes_id . "'"); 32 33 tep_redirect(tep_href_link(FILENAME_ADMIN_FILES)); 34 break; 35 case 'file_store': 36 $sql_data_array = array('admin_files_name' => tep_db_prepare_input($HTTP_POST_VARS['admin_files_name']), 37 'admin_files_to_boxes' => tep_db_prepare_input($HTTP_POST_VARS['admin_files_to_boxes'])); 38 tep_db_perform(TABLE_ADMIN_FILES, $sql_data_array); 39 $admin_files_id = tep_db_insert_id(); 40 41 tep_redirect(tep_href_link(FILENAME_ADMIN_FILES, 'cPath=' . $HTTP_GET_VARS['cPath'] . '&fID=' . $admin_files_id)); 42 break; 43 case 'file_remove': 44 $admin_files_id = tep_db_prepare_input($HTTP_POST_VARS['admin_files_id']); 45 tep_db_query("delete from " . TABLE_ADMIN_FILES . " where admin_files_id = '" . $admin_files_id . "'"); 46 47 tep_redirect(tep_href_link(FILENAME_ADMIN_FILES, 'cPath=' . $HTTP_GET_VARS['cPath'])); 48 break; 49 } 50 } 51 52 ?> 53 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> 54 <html <?php echo HTML_PARAMS; ?>> 55 <head> 56 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> 57 <title><?php echo TITLE; ?></title> 58 <link rel="stylesheet" type="text/css" href="includes/stylesheet.css"> 59 <script language="javascript" src="includes/general.js"></script> 60 </head> 61 <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();"> 62 <!-- header //--> 63 <?php require (DIR_WS_INCLUDES . 'header.php'); ?> 64 <!-- header_eof //--> 65 66 <!-- body //--> 67 <table border="0" width="100%" cellspacing="2" cellpadding="2"> 68 <tr> 69 <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft"> 70 <!-- left_navigation //--> 71 <?php require (DIR_WS_INCLUDES . 'column_left.php'); ?> 72 <!-- left_navigation_eof //--> 73 </table></td> 74 <!-- body_text //--> 75 <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> 76 <tr> 77 <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0"> 78 <tr> 79 <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> 80 <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> 81 </tr> 82 </table></td> 83 </tr> 84 <tr> 85 <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> 86 <tr> 87 <td valign="top"> 88 <?php 89 if ($HTTP_GET_VARS['fID'] || $HTTP_GET_VARS['cPath']) { 90 //$current_box_query_raw = "select admin_files_name as admin_box_name from " . TABLE_ADMIN_FILES . " where admin_files_id = " . $HTTP_GET_VARS['cPath'] . " "; 91 $current_box_query = tep_db_query("select admin_files_name as admin_box_name from " . TABLE_ADMIN_FILES . " where admin_files_id = " . $HTTP_GET_VARS['cPath']); 92 $current_box = tep_db_fetch_array($current_box_query); 93 ?> 94 <table border="0" width="100%" cellspacing="0" cellpadding="2"> 95 <tr class="dataTableHeadingRow"> 96 <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_FILENAME; ?></td> 97 <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td> 98 </tr> 99 <?php 100 $db_file_query_raw = "select * from " . TABLE_ADMIN_FILES . " where admin_files_to_boxes = " . $HTTP_GET_VARS['cPath'] . " order by admin_files_name"; 101 $db_file_query = tep_db_query($db_file_query_raw); 102 $file_count = 0; 103 104 while ($files = tep_db_fetch_array($db_file_query)) { 105 $file_count++; 106 107 if (((!$HTTP_GET_VARS['fID']) || ($HTTP_GET_VARS['fID'] == $files['admin_files_id'])) && (!$fInfo) ) { 108 $fInfo = new objectInfo($files); 109 } 110 111 if ( (is_object($fInfo)) && ($files['admin_files_id'] == $fInfo->admin_files_id) ) { 112 echo ' <tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . tep_href_link(FILENAME_ADMIN_FILES, 'cPath=' . $HTTP_GET_VARS['cPath'] . '&fID=' . $files['admin_files_id'] . '&action=edit_file') . '\'">' . "\n"; 113 } else { 114 echo ' <tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'hand\'" onmouseout="this.className=\'dataTableRow\'" onclick="document.location.href=\'' . tep_href_link(FILENAME_ADMIN_FILES, 'cPath=' . $HTTP_GET_VARS['cPath'] . '&fID=' . $files['admin_files_id']) . '\'">' . "\n"; 115 } 116 ?> 117 <td class="dataTableContent"><?php echo $files['admin_files_name']; ?></td> 118 <td class="dataTableContent" align="right"><?php if ( (is_object($fInfo)) && ($files['admin_files_id'] == $fInfo->admin_files_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '<a href="' . tep_href_link(FILENAME_ADMIN_FILES, 'cPath=' . $HTTP_GET_VARS['cPath'] . '&fID=' . $files['admin_files_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td> 119 </tr> 120 <?php 121 } 122 123 ?> 124 <tr> 125 <td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2"> 126 <tr> 127 <td class="smallText" valign="top"><?php echo TEXT_COUNT_FILES . $file_count; ?></td> 128 <td class="smallText" valign="top" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_ADMIN_FILES, 'cID=' . $HTTP_GET_VARS['cPath']) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a> <a href="' . tep_href_link(FILENAME_ADMIN_FILES, 'cPath=' . $HTTP_GET_VARS['cPath'] . '&action=store_file') . '">' . tep_image_button('button_admin_files.gif', IMAGE_INSERT_FILE) . '</a>'; ?> </td> 129 </tr> 130 </table></td> 131 </tr> 132 </table> 133 <?php 134 } else { 135 ?> 136 <table border="0" width="100%" cellspacing="0" cellpadding="2"> 137 <tr class="dataTableHeadingRow"> 138 <td class="dataTableHeadingContent" width="60%"><?php echo TABLE_HEADING_BOXES; ?></td> 139 <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_STATUS; ?></td> 140 <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td> 141 </tr> 142 <?php 143 $installed_boxes_query = tep_db_query("select admin_files_name as admin_boxes_name from " . TABLE_ADMIN_FILES . " where admin_files_is_boxes = 1 order by admin_files_name"); 144 $installed_boxes = array(); 145 while($db_boxes = tep_db_fetch_array($installed_boxes_query)) { 146 $installed_boxes[] = $db_boxes['admin_boxes_name']; 147 } 148 149 $none = 0; 150 $boxes = array(); 151 $dir = dir(DIR_WS_BOXES); 152 while ($boxes_file = $dir->read()) { 153 if ( (substr("$boxes_file", -4) == '.php') && !(in_array($boxes_file, $installed_boxes))){ 154 $boxes[] = array('admin_boxes_name' => $boxes_file, 155 'admin_boxes_id' => 'b' . $none); 156 } elseif ( (substr("$boxes_file", -4) == '.php') && (in_array($boxes_file, $installed_boxes))) { 157 $db_boxes_id_query = tep_db_query("select admin_files_id as admin_boxes_id from " . TABLE_ADMIN_FILES . " where admin_files_is_boxes = 1 and admin_files_name = '" . $boxes_file . "'"); 158 $db_boxes_id = tep_db_fetch_array($db_boxes_id_query); 159 $boxes[] = array('admin_boxes_name' => $boxes_file, 160 'admin_boxes_id' => $db_boxes_id['admin_boxes_id']); 161 } 162 163 $none++; 164 } 165 $dir->close(); 166 sort($boxes); 167 reset ($boxes); 168 169 170 $boxnum = sizeof($boxes); 171 $i = 0; 172 while ($i < $boxnum) { 173 if (((!$HTTP_GET_VARS['cID']) || ($HTTP_GET_VARS['none'] == $boxes[$i]['admin_boxes_id']) || ($HTTP_GET_VARS['cID'] == $boxes[$i]['admin_boxes_id'])) && (!$cInfo) ) { 174 $cInfo = new objectInfo($boxes[$i]); 175 } 176 if ( (is_object($cInfo)) && ($boxes[$i]['admin_boxes_id'] == $cInfo->admin_boxes_id) ) { 177 if ( substr("$cInfo->admin_boxes_id", 0,1) == 'b') { 178 echo ' <tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . tep_href_link(FILENAME_ADMIN_FILES, 'cID=' . $boxes[$i]['admin_boxes_id']) . '\'">' . "\n"; 179 } else { 180 echo ' <tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . tep_href_link(FILENAME_ADMIN_FILES, 'cPath=' . $boxes[$i]['admin_boxes_id'] . '&action=store_file') . '\'">' . "\n"; 181 } 182 } else { 183 echo ' <tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'hand\'" onmouseout="this.className=\'dataTableRow\'" onclick="document.location.href=\'' . tep_href_link(FILENAME_ADMIN_FILES, 'cID=' . $boxes[$i]['admin_boxes_id']) . '\'">' . "\n"; 184 } 185 ?> 186 <td class="dataTableContent"><?php echo tep_image(DIR_WS_ICONS . 'folder.gif', ICON_FOLDER) . ' <b>' . ucfirst (substr_replace ($boxes[$i]['admin_boxes_name'], '' , -4)) . '</b>'; ?></td> 187 <td class="dataTableContent" align="center"><?php 188 if ( (is_object($cInfo)) && ($HTTP_GET_VARS['cID'] == $boxes[$i]['admin_boxes_id'])) { 189 if (substr($boxes[$i]['admin_boxes_id'], 0,1) == 'b') { 190 echo tep_image(DIR_WS_IMAGES . 'icon_status_red.gif', STATUS_BOX_NOT_INSTALLED, 10, 10) . ' <a href="' . tep_href_link(FILENAME_ADMIN_FILES, 'cID=' . $boxes[$i]['admin_boxes_id'] . '&box=' . $boxes[$i]['admin_boxes_name'] . '&action=box_store') . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_green_light.gif', STATUS_BOX_INSTALL, 10, 10) . '</a>'; 191 } else { 192 echo '<a href="' . tep_href_link(FILENAME_ADMIN_FILES, 'cID=' . $HTTP_GET_VARS['cID'] . '&action=box_remove') . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_red_light.gif', STATUS_BOX_REMOVE, 10, 10) . '</a> ' . tep_image(DIR_WS_IMAGES . 'icon_status_green.gif', STATUS_BOX_INSTALLED, 10, 10); 193 } 194 } else { 195 if (substr($boxes[$i]['admin_boxes_id'], 0,1) == 'b') { 196 echo tep_image(DIR_WS_IMAGES . 'icon_status_red.gif', '', 10, 10) . ' ' . tep_image(DIR_WS_IMAGES . 'icon_status_green_light.gif', '', 10, 10) . '</a>'; 197 } else { 198 echo tep_image(DIR_WS_IMAGES . 'icon_status_red_light.gif', '', 10, 10) . '</a> ' . tep_image(DIR_WS_IMAGES . 'icon_status_green.gif', '', 10, 10); 199 } 200 } 201 ?> 202 </td> 203 <td class="dataTableContent" align="right"><?php if ( (is_object($cInfo)) && ($boxes[$i]['admin_boxes_id'] == $cInfo->admin_boxes_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '<a href="' . tep_href_link(FILENAME_ADMIN_FILES, 'cID=' . $db_cat['admin_boxes_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td> 204 </tr> 205 <?php 206 $i++; 207 } 208 ?> 209 <tr> 210 <td colspan="3"><table border="0" width="100%" cellspacing="0" cellpadding="2"> 211 <tr> 212 <td class="smallText" valign="top"><?php echo TEXT_COUNT_BOXES . $boxnum; ?></td> 213 <td class="smallText" valign="top" align="right"> </td> 214 </tr> 215 </table></td> 216 </tr> 217 </table> 218 <?php 219 } 220 ?> 221 </td> 222 <?php 223 $heading = array(); 224 $contents = array(); 225 switch ($HTTP_GET_VARS['action']) { 226 case 'store_file': 227 $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_NEW_FILE . '</b>'); 228 229 $file_query = tep_db_query("select admin_files_name from " . TABLE_ADMIN_FILES . " where admin_files_is_boxes = '0' "); 230 while ($fetch_files = tep_db_fetch_array($file_query)) { 231 $files_array[] = $fetch_files['admin_files_name']; 232 } 233 234 $file_dir = array(); 235 $dir = dir(DIR_FS_ADMIN); 236 237 while ($file = $dir->read()) { 238 if ((substr("$file", -4) == '.php') && $file != FILENAME_DEFAULT && $file != FILENAME_LOGIN && $file != FILENAME_LOGOFF && $file != FILENAME_FORBIDDEN && $file != FILENAME_POPUP_IMAGE && $file != FILENAME_PASSWORD_FORGOTTEN && $file != FILENAME_ADMIN_ACCOUNT && $file != 'invoice.php' && $file != 'packingslip.php') { 239 $file_dir[] = $file; 240 } 241 } 242 243 $result = $file_dir; 244 if (sizeof($files_array) > 0) { 245 $result = array_values (array_diff($file_dir, $files_array)); 246 } 247 248 sort ($result); 249 reset ($result); 250 while (list ($key, $val) = each ($result)) { 251 $show[] = array('id' => $val, 252 'text' => $val); 253 } 254 255 $contents = array('form' => tep_draw_form('store_file', FILENAME_ADMIN_FILES, 'cPath=' . $HTTP_GET_VARS['cPath'] . '&fID=' . $files['admin_files_id'] . '&action=file_store', 'post', 'enctype="multipart/form-data"')); 256 $contents[] = array('text' => '<b>' . TEXT_INFO_NEW_FILE_BOX . ucfirst(substr_replace ($current_box['admin_box_name'], '', -4)) . '</b>'); 257 $contents[] = array('text' => TEXT_INFO_NEW_FILE_INTRO ); 258 $contents[] = array('align' => 'left', 'text' => '<br> ' . tep_draw_pull_down_menu('admin_files_name', $show, $show)); 259 $contents[] = array('text' => tep_draw_hidden_field('admin_files_to_boxes', $HTTP_GET_VARS['cPath'])); 260 $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_save.gif', IMAGE_SAVE) . ' <a href="' . tep_href_link(FILENAME_ADMIN_FILES, 'cPath=' . $HTTP_GET_VARS['cPath']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'); 261 break; 262 case 'remove_file': 263 $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_FILE . '</b>'); 264 265 $contents = array('form' => tep_draw_form('remove_file', FILENAME_ADMIN_FILES, 'action=file_remove&cPath=' . $HTTP_GET_VARS['cPath'] . '&fID=' . $files['admin_files_id'], 'post', 'enctype="multipart/form-data"')); 266 $contents[] = array('text' => tep_draw_hidden_field('admin_files_id', $HTTP_GET_VARS['fID'])); 267 $contents[] = array('text' => sprintf(TEXT_INFO_DELETE_FILE_INTRO, $fInfo->admin_files_name, ucfirst(substr_replace ($current_box['admin_box_name'], '', -4))) ); 268 $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_confirm.gif', IMAGE_CONFIRM) . ' <a href="' . tep_href_link(FILENAME_ADMIN_FILES, 'cPath=' . $HTTP_GET_VARS['cPath'] . '&fID=' . $HTTP_GET_VARS['fID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'); 269 break; 270 default: 271 if (is_object($cInfo)) { 272 $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DEFAULT_BOXES . $cInfo->admin_boxes_name . '</b>'); 273 if ( substr($cInfo->admin_boxes_id, 0,1) == 'b') { 274 $contents[] = array('text' => '<b>' . $cInfo->admin_boxes_name . ' ' . TEXT_INFO_DEFAULT_BOXES_NOT_INSTALLED . '</b><br> '); 275 $contents[] = array('text' => TEXT_INFO_DEFAULT_BOXES_INTRO); 276 } else { 277 $contents = array('form' => tep_draw_form('newfile', FILENAME_ADMIN_FILES, 'cPath=' . $cInfo->admin_boxes_id . '&action=store_file', 'post', 'enctype="multipart/form-data"')); 278 $contents[] = array('align' => 'center', 'text' => tep_image_submit('button_admin_files.gif', IMAGE_INSERT_FILE) ); 279 $contents[] = array('text' => tep_draw_hidden_field('this_category', $cInfo->admin_boxes_id)); 280 $contents[] = array('text' => '<br>' . TEXT_INFO_DEFAULT_BOXES_INTRO); 281 } 282 $contents[] = array('text' => '<br>'); 283 } 284 if (is_object($fInfo)) { 285 $heading[] = array('text' => '<b>' . TEXT_INFO_NEW_FILE_BOX . ucfirst(substr_replace ($current_box['admin_box_name'], '', -4)) . '</b>'); 286 287 $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_ADMIN_FILES, 'cPath=' . $HTTP_GET_VARS['cPath'] . '&action=store_file') . '">' . tep_image_button('button_admin_files.gif', IMAGE_INSERT_FILE) . '</a> <a href="' . tep_href_link(FILENAME_ADMIN_FILES, 'cPath=' . $HTTP_GET_VARS['cPath'] . '&fID=' . $fInfo->admin_files_id . '&action=remove_file') . '">' . tep_image_button('button_admin_remove.gif', IMAGE_DELETE) . '</a>'); 288 $contents[] = array('text' => '<br>' . TEXT_INFO_DEFAULT_FILE_INTRO . ucfirst(substr_replace ($current_box['admin_box_name'], '', -4))); 289 } 290 } 291 292 if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) { 293 echo ' <td width="25%" valign="top">' . "\n"; 294 295 $box = new box; 296 echo $box->infoBox($heading, $contents); 297 298 echo ' </td>' . "\n"; 299 } 300 ?> 301 </tr> 302 </table></td> 303 </tr> 304 </table></td> 305 <!-- body_text_eof //--> 306 </tr> 307 </table> 308 <!-- body_eof //--> 309 310 <!-- footer //--> 311 <?php require (DIR_WS_INCLUDES . 'footer.php'); ?> 312 <!-- footer_eof //--> 313 <br> 314 </body> 315 </html> 316 <?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 |