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

Zen Cart 源代码 countries.php




下载文件

文件名: countries.php
文件类型: PHP文件
文件大小: 16.11 KiB
MD5: b8c6df241e194c9eb9b03b338f04934d

countries.php - 关闭高亮
  1. <?php
  2. /**
  3.  * @package admin
  4.  * @copyright Copyright 2003-2014 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 GIT: $Id: Author: DrByte  Jun 30 2014 Modified in v1.5.4 $
  8.  */
  9.  
  10.   require('includes/application_top.php');
  11.  
  12.   $action = (isset($_GET['action']) ? $_GET['action'] : '');
  13.  
  14.   if (zen_not_null($action)) {
  15.     switch ($action) {
  16.       case 'insert':
  17.         $countries_name = zen_db_prepare_input($_POST['countries_name']);
  18.         $countries_iso_code_2 = strtoupper(zen_db_prepare_input($_POST['countries_iso_code_2']));
  19.         $countries_iso_code_3 = strtoupper(zen_db_prepare_input($_POST['countries_iso_code_3']));
  20.         $address_format_id = zen_db_prepare_input($_POST['address_format_id']);
  21.         $status = $_POST['status'] == 'on' ? 1 : 0;
  22.  
  23.         $db->Execute("insert into " . TABLE_COUNTRIES . "
  24.                    (countries_name, countries_iso_code_2, countries_iso_code_3, status, address_format_id)
  25.                    values ('" . zen_db_input($countries_name) . "',
  26.                            '" . zen_db_input($countries_iso_code_2) . "',
  27.                            '" . zen_db_input($countries_iso_code_3) . "',
  28.                            '" . (int)$status . "',
  29.                            '" . (int)$address_format_id . "')");
  30.         zen_record_admin_activity('Country added: ' . $countries_iso_code_3, 'info');
  31.         zen_redirect(zen_href_link(FILENAME_COUNTRIES));
  32.         break;
  33.       case 'save':
  34.         $countries_id = zen_db_prepare_input($_GET['cID']);
  35.         $countries_name = zen_db_prepare_input($_POST['countries_name']);
  36.         $countries_iso_code_2 = strtoupper(zen_db_prepare_input($_POST['countries_iso_code_2']));
  37.         $countries_iso_code_3 = strtoupper(zen_db_prepare_input($_POST['countries_iso_code_3']));
  38.         $address_format_id = zen_db_prepare_input($_POST['address_format_id']);
  39.         $status = $_POST['status'] == 'on' ? 1 : 0;
  40.  
  41.         $db->Execute("update " . TABLE_COUNTRIES . "
  42.                      set countries_name = '" . zen_db_input($countries_name) . "',
  43.                          countries_iso_code_2 = '" . zen_db_input($countries_iso_code_2) . "',
  44.                          countries_iso_code_3 = '" . zen_db_input($countries_iso_code_3) . "',
  45.                          address_format_id = '" . (int)$address_format_id . "',
  46.                          status = " . (int)$status . "
  47.                      where countries_id = '" . (int)$countries_id . "'");
  48.         zen_record_admin_activity('Country updated: ' . $countries_iso_code_3, 'info');
  49.         zen_redirect(zen_href_link(FILENAME_COUNTRIES, 'page=' . $_GET['page'] . '&cID=' . $countries_id));
  50.         break;
  51.       case 'deleteconfirm':
  52.         // demo active test
  53.         if (zen_admin_demo()) {
  54.           $_GET['action']= '';
  55.           $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution');
  56.           zen_redirect(zen_href_link(FILENAME_COUNTRIES, 'page=' . $_GET['page']));
  57.         }
  58.         $countries_id = zen_db_prepare_input($_POST['cID']);
  59.         $sql = "select entry_country_id from " . TABLE_ADDRESS_BOOK . " where entry_country_id = :countryID: LIMIT 1";
  60.         $sql = $db->bindVars($sql, ':countryID:', $countries_id, 'integer');
  61.         $result = $db->Execute($sql);
  62.         if ($result->recordCount() == 0) {
  63.           $db->Execute("delete from " . TABLE_COUNTRIES . "
  64.                        where countries_id = '" . (int)$countries_id . "'");
  65.           zen_record_admin_activity('Country deleted: ' . $countries_id, 'warning');
  66.         } else {
  67.           $messageStack->add_session(ERROR_COUNTRY_IN_USE, 'error');
  68.         }
  69.         zen_redirect(zen_href_link(FILENAME_COUNTRIES, 'page=' . $_GET['page']));
  70.         break;
  71.       case 'setstatus':
  72.         $countries_id = zen_db_prepare_input($_GET['cID']);
  73.         if (isset($_POST['current_status']) && ($_POST['current_status'] == '0' || $_POST['current_status'] == '1')) {
  74.           $sql = "update " . TABLE_COUNTRIES . " set status='" . ($_POST['current_status'] == 0 ? 1 : 0) . "' where countries_id='" . (int)$countries_id . "'";
  75.           $db->Execute($sql);
  76.           zen_record_admin_activity('Country with ID number: ' . $countries_id . ' changed status to ' . ($_POST['current_status'] == 0 ? 1 : 0), 'info');
  77.           zen_redirect(zen_href_link(FILENAME_COUNTRIES, 'cID=' . (int)$countries_id . '&page=' . $_GET['page']));
  78.         }
  79.         $action = '';
  80.         break;
  81.     }
  82.   }
  83. ?>
  84. <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  85. <html <?php echo HTML_PARAMS; ?>>
  86. <head>
  87. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
  88. <title><?php echo TITLE; ?></title>
  89. <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
  90. <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
  91. <script language="javascript" src="includes/menu.js"></script>
  92. <script language="javascript" src="includes/general.js"></script>
  93. <script type="text/javascript">
  94.   <!--
  95.   function init()
  96.   {
  97.     cssjsmenu('navbar');
  98.     if (document.getElementById)
  99.     {
  100.       var kill = document.getElementById('hoverJS');
  101.       kill.disabled = true;
  102.     }
  103.   }
  104.   // -->
  105. </script>
  106. </head>
  107. <body onload="init()">
  108. <!-- header //-->
  109. <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
  110. <!-- header_eof //-->
  111.  
  112. <!-- body //-->
  113. <table border="0" width="100%" cellspacing="2" cellpadding="2">
  114.   <tr>
  115. <!-- body_text //-->
  116.     <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  117.       <tr>
  118.         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  119.           <tr>
  120.             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  121.             <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
  122.           </tr>
  123.         </table></td>
  124.       </tr>
  125.       <tr>
  126.         <td class="smallText" align="right" width="350" valign="top"><?php echo ISO_COUNTRY_CODES_LINK; ?></td>
  127.       </tr>
  128.       <tr>
  129.         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  130.           <tr>
  131.             <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  132.               <tr class="dataTableHeadingRow">
  133.                 <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_COUNTRY_NAME; ?></td>
  134.                 <td class="dataTableHeadingContent" align="center" colspan="2"><?php echo TABLE_HEADING_COUNTRY_CODES; ?></td>
  135.                 <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_COUNTRY_STATUS; ?></td>
  136.                 <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
  137.               </tr>
  138. <?php
  139.   $countries_query_raw = "select countries_id, countries_name, countries_iso_code_2, countries_iso_code_3, address_format_id, status from " . TABLE_COUNTRIES . " order by countries_name";
  140.   $countries_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS, $countries_query_raw, $countries_query_numrows);
  141.   $countries = $db->Execute($countries_query_raw);
  142.   while (!$countries->EOF) {
  143.     if ((!isset($_GET['cID']) || (isset($_GET['cID']) && ($_GET['cID'] == $countries->fields['countries_id']))) && !isset($cInfo) && (substr($action, 0, 3) != 'new')) {
  144.       $cInfo = new objectInfo($countries->fields);
  145.     }
  146.  
  147.     if (isset($cInfo) && is_object($cInfo) && ($countries->fields['countries_id'] == $cInfo->countries_id)) {
  148.       echo '                  <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_COUNTRIES, 'page=' . $_GET['page'] . '&cID=' . $cInfo->countries_id . '&action=edit') . '\'">' . "\n";
  149.     } else {
  150.       echo '                  <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_COUNTRIES, 'page=' . $_GET['page'] . '&cID=' . $countries->fields['countries_id']) . '\'">' . "\n";
  151.     }
  152. ?>
  153.                 <td class="dataTableContent"><?php echo zen_output_string_protected($countries->fields['countries_name']); ?></td>
  154.                 <td class="dataTableContent" align="center" width="40"><?php echo $countries->fields['countries_iso_code_2']; ?></td>
  155.                 <td class="dataTableContent" align="center" width="40"><?php echo $countries->fields['countries_iso_code_3']; ?></td>
  156.                 <td class="dataTableContent" align="center" width="40">
  157. <?php
  158.     echo zen_draw_form('setstatus', FILENAME_COUNTRIES, 'action=setstatus&cID=' . $countries->fields['countries_id'] . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . (isset($_GET['search']) ? '&search=' . $_GET['search'] : ''));
  159.     if ($countries->fields['status'] == '0') {
  160.       $formSRC   = 'icon_red_on.gif';
  161.       $formTITLE = IMAGE_ICON_STATUS_OFF;
  162.     } else {
  163.       $formSRC   = 'icon_green_on.gif';
  164.       $formTITLE = IMAGE_ICON_STATUS_ON;
  165.     }
  166. ?>
  167.                     <input type="image" src="<?php echo DIR_WS_IMAGES . $formSRC; ?>" alt="<?php echo $formTITLE; ?>" />
  168.                     <input type="hidden" name="current_status" value="<?php echo $countries->fields['status']; ?>" />
  169.                   </form>
  170.                 </td>
  171.                 <td class="dataTableContent" align="right"><?php if (isset($cInfo) && is_object($cInfo) && ($countries->fields['countries_id'] == $cInfo->countries_id) ) { echo zen_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . zen_href_link(FILENAME_COUNTRIES, 'page=' . $_GET['page'] . '&cID=' . $countries->fields['countries_id']) . '">' . zen_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
  172.               </tr>
  173. <?php
  174.     $countries->MoveNext();
  175.   }
  176. ?>
  177.               <tr>
  178.                 <td colspan="5"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  179.                   <tr>
  180.                     <td class="smallText" valign="top"><?php echo $countries_split->display_count($countries_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $_GET['page'], TEXT_DISPLAY_NUMBER_OF_COUNTRIES); ?></td>
  181.                     <td class="smallText" align="right"><?php echo $countries_split->display_links($countries_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $_GET['page']); ?></td>
  182.                   </tr>
  183. <?php
  184.   if (empty($action)) {
  185. ?>
  186.                   <tr>
  187.                     <td colspan="2" align="right"><?php echo '<a href="' . zen_href_link(FILENAME_COUNTRIES, 'page=' . $_GET['page'] . '&action=new') . '">' . zen_image_button('button_new_country.gif', IMAGE_NEW_COUNTRY) . '</a>'; ?></td>
  188.                   </tr>
  189. <?php
  190.   }
  191. ?>
  192.                 </table></td>
  193.               </tr>
  194.             </table></td>
  195. <?php
  196.   $heading = array();
  197.   $contents = array();
  198.  
  199.   switch ($action) {
  200.     case 'new':
  201.       $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_NEW_COUNTRY . '</b>');
  202.       $contents = array('form' => zen_draw_form('countries', FILENAME_COUNTRIES, 'page=' . $_GET['page'] . '&action=insert'));
  203.       $contents[] = array('text' => TEXT_INFO_INSERT_INTRO);
  204.       $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_NAME . '<br>' . zen_draw_input_field('countries_name'));
  205.       $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_CODE_2 . '<br>' . zen_draw_input_field('countries_iso_code_2'));
  206.       $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_CODE_3 . '<br>' . zen_draw_input_field('countries_iso_code_3'));
  207.       $contents[] = array('text' => '<br>' . TEXT_INFO_ADDRESS_FORMAT . '<br>' . zen_draw_pull_down_menu('address_format_id', zen_get_address_formats()));
  208.       $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_STATUS . '<br>' . zen_draw_checkbox_field('status', '', true));
  209.       $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_insert.gif', IMAGE_INSERT) . '&nbsp;<a href="' . zen_href_link(FILENAME_COUNTRIES, 'page=' . $_GET['page']) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
  210.       break;
  211.     case 'edit':
  212.       $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_EDIT_COUNTRY . '</b>');
  213.       $contents = array('form' => zen_draw_form('countries', FILENAME_COUNTRIES, 'page=' . $_GET['page'] . '&cID=' . $cInfo->countries_id . '&action=save'));
  214.       $contents[] = array('text' => TEXT_INFO_EDIT_INTRO);
  215.       $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_NAME . '<br>' . zen_draw_input_field('countries_name', htmlspecialchars($cInfo->countries_name, ENT_COMPAT, CHARSET, TRUE)));
  216.       $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_CODE_2 . '<br>' . zen_draw_input_field('countries_iso_code_2', $cInfo->countries_iso_code_2));
  217.       $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_CODE_3 . '<br>' . zen_draw_input_field('countries_iso_code_3', $cInfo->countries_iso_code_3));
  218.       $contents[] = array('text' => '<br>' . TEXT_INFO_ADDRESS_FORMAT . '<br>' . zen_draw_pull_down_menu('address_format_id', zen_get_address_formats(), $cInfo->address_format_id));
  219.       $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_STATUS . '<br>' . zen_draw_checkbox_field('status', '', $cInfo->status));
  220.       $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_update.gif', IMAGE_UPDATE) . '&nbsp;<a href="' . zen_href_link(FILENAME_COUNTRIES, 'page=' . $_GET['page'] . '&cID=' . $cInfo->countries_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
  221.       break;
  222.     case 'delete':
  223.       $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_COUNTRY . '</b>');
  224.       $contents = array('form' => zen_draw_form('countries', FILENAME_COUNTRIES, 'page=' . $_GET['page'] . '&action=deleteconfirm') . zen_draw_hidden_field('cID', $cInfo->countries_id));
  225.       $contents[] = array('text' => TEXT_INFO_DELETE_INTRO);
  226.       $contents[] = array('text' => '<br><b>' . zen_output_string_protected($cInfo->countries_name) . '</b>');
  227.       $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_delete.gif', IMAGE_UPDATE) . '&nbsp;<a href="' . zen_href_link(FILENAME_COUNTRIES, 'page=' . $_GET['page'] . '&cID=' . $cInfo->countries_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
  228.       break;
  229.     default:
  230.       if (is_object($cInfo)) {
  231.         $heading[] = array('text' => '<b>' . zen_output_string_protected($cInfo->countries_name) . '</b>');
  232.         $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_COUNTRIES, 'page=' . $_GET['page'] . '&cID=' . $cInfo->countries_id . '&action=edit') . '">' . zen_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . zen_href_link(FILENAME_COUNTRIES, 'page=' . $_GET['page'] . '&cID=' . $cInfo->countries_id . '&action=delete') . '">' . zen_image_button('button_delete.gif', IMAGE_DELETE) . '</a>');
  233.         $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_NAME . '<br>' . zen_output_string_protected($cInfo->countries_name));
  234.         $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_CODE_2 . ' ' . $cInfo->countries_iso_code_2);
  235.         $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_CODE_3 . ' ' . $cInfo->countries_iso_code_3);
  236.         $contents[] = array('text' => '<br>' . TEXT_INFO_ADDRESS_FORMAT . ' ' . $cInfo->address_format_id);
  237.         $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_STATUS . ' ' . ($cInfo->status == 0 ? TEXT_NO : TEXT_YES));
  238.       }
  239.       break;
  240.   }
  241.  
  242.   if ( (zen_not_null($heading)) && (zen_not_null($contents)) ) {
  243.     echo '            <td width="25%" valign="top">' . "\n";
  244.  
  245.     $box = new box;
  246.     echo $box->infoBox($heading, $contents);
  247.  
  248.     echo '            </td>' . "\n";
  249.   }
  250. ?>
  251.           </tr>
  252.         </table></td>
  253.       </tr>
  254.     </table></td>
  255. <!-- body_text_eof //-->
  256.   </tr>
  257. </table>
  258. <!-- body_eof //-->
  259.  
  260. <!-- footer //-->
  261. <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
  262. <!-- footer_eof //-->
  263. <br>
  264. </body>
  265. </html>
  266. <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
  267.  


cron