Quick Search:

View

Revision:

Diff

Diff from 978 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/tags/oscommerce-3.0a3/admin/countries.php

Annotated File View

hpdl
1
1 <?php
2 /*
mattice
151
3   $Id: countries.php 758 2006-08-23 12:30:07Z hpdl $
hpdl
1
4
5   osCommerce, Open Source E-Commerce Solutions
6   http://www.oscommerce.com
7
hpdl
410
8   Copyright (c) 2006 osCommerce
hpdl
1
9
10   Released under the GNU General Public License
11 */
12
13   require('includes/application_top.php');
14
15   $action = (isset($_GET['action']) ? $_GET['action'] : '');
16
17   if (!isset($_GET['page']) || (isset($_GET['page']) && !is_numeric($_GET['page']))) {
18     $_GET['page'] = 1;
19   }
20
21   if (!empty($action)) {
22     switch ($action) {
23       case 'save':
24         if (isset($_GET['cID']) && is_numeric($_GET['cID'])) {
hpdl
757
25           $Qcountry = $osC_Database->query('update :table_countries set countries_name = :countries_name, countries_iso_code_2 = :countries_iso_code_2, countries_iso_code_3 = :countries_iso_code_3, address_format = :address_format where countries_id = :countries_id');
hpdl
1
26           $Qcountry->bindInt(':countries_id', $_GET['cID']);
27         } else {
hpdl
757
28           $Qcountry = $osC_Database->query('insert into :table_countries (countries_name, countries_iso_code_2, countries_iso_code_3, address_format) values (:countries_name, :countries_iso_code_2, :countries_iso_code_3, :address_format)');
hpdl
1
29         }
30         $Qcountry->bindTable(':table_countries', TABLE_COUNTRIES);
31         $Qcountry->bindValue(':countries_name', $_POST['countries_name']);
32         $Qcountry->bindValue(':countries_iso_code_2', $_POST['countries_iso_code_2']);
33         $Qcountry->bindValue(':countries_iso_code_3', $_POST['countries_iso_code_3']);
hpdl
757
34         $Qcountry->bindValue(':address_format', $_POST['address_format']);
hpdl
1
35         $Qcountry->execute();
36
37         if ($osC_Database->isError() === false) {
38           if ($Qcountry->affectedRows()) {
39             $osC_MessageStack->add_session('header', SUCCESS_DB_ROWS_UPDATED, 'success');
40           } else {
41             $osC_MessageStack->add_session('header', WARNING_DB_ROWS_NOT_UPDATED, 'warning');
42           }
43         } else {
44           $osC_MessageStack->add_session('header', ERROR_DB_ROWS_NOT_UPDATED, 'error');
45         }
46
47         if (isset($_GET['cID']) && is_numeric($_GET['cID'])) {
hpdl
758
48           osc_redirect(osc_href_link_admin(FILENAME_COUNTRIES, 'page=' . $_GET['page'] . '&cID=' . $_GET['cID']));
hpdl
1
49         } else {
hpdl
758
50           osc_redirect(osc_href_link_admin(FILENAME_COUNTRIES));
hpdl
1
51         }
52
53         break;
54       case 'deleteconfirm':
55         if (isset($_GET['cID']) && is_numeric($_GET['cID'])) {
56           $error = false;
57
58           $osC_Database->startTransaction();
59
60           $Qzones = $osC_Database->query('delete from :table_zones where zone_country_id = :zone_country_id');
61           $Qzones->bindTable(':table_zones', TABLE_ZONES);
62           $Qzones->bindInt(':zone_country_id', $_GET['cID']);
63           $Qzones->execute();
64
65           if ($osC_Database->isError() === false) {
66             $Qcountry = $osC_Database->query('delete from :table_countries where countries_id = :countries_id');
67             $Qcountry->bindTable(':table_countries', TABLE_COUNTRIES);
68             $Qcountry->bindInt(':countries_id', $_GET['cID']);
69             $Qcountry->execute();
70
71             if ($osC_Database->isError()) {
72               $error = true;
73             }
74           } else {
75             $error = true;
76           }
77
78           if ($error === false) {
79             $osC_Database->commitTransaction();
80
81             $osC_MessageStack->add_session('header', SUCCESS_DB_ROWS_UPDATED, 'success');
82           } else {
83             $osC_Database->rollbackTransaction();
84
85             $osC_MessageStack->add_session('header', ERROR_DB_ROWS_NOT_UPDATED, 'error');
86           }
87         }
88
hpdl
758
89         osc_redirect(osc_href_link_admin(FILENAME_COUNTRIES, 'page=' . $_GET['page']));
hpdl
1
90         break;
91     }
92   }
93
94   $page_contents = 'countries.php';
95
96   require('templates/default.php');
97
98   require('includes/application_bottom.php');
99 ?>