[ Index ] |
PHP Cross Reference of phpwcms V1.5.0 _r431 (28.01.12) |
[Summary view] [Print] [Text view]
1 <?php 2 /************************************************************************************* 3 Copyright notice 4 5 (c) 2002-2012 Oliver Georgi <oliver@phpwcms.de> // All rights reserved. 6 7 This script is part of PHPWCMS. The PHPWCMS web content management system is 8 free software; you can redistribute it and/or modify it under the terms of 9 the GNU General Public License as published by the Free Software Foundation; 10 either version 2 of the License, or (at your option) any later version. 11 12 The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html 13 A copy is found in the textfile GPL.txt and important notices to the license 14 from the author is found in LICENSE.txt distributed with these scripts. 15 16 This script is distributed in the hope that it will be useful, but WITHOUT ANY 17 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 18 PARTICULAR PURPOSE. See the GNU General Public License for more details. 19 20 This copyright notice MUST APPEAR in all copies of the script! 21 *************************************************************************************/ 22 23 // ---------------------------------------------------------------- 24 // obligate check for phpwcms constants 25 if (!defined('PHPWCMS_ROOT')) { 26 die("You Cannot Access This Script Directly, Have a Nice Day."); 27 } 28 // ---------------------------------------------------------------- 29 30 31 if($action == 'edit') { 32 33 34 $plugin['data']['cat_id'] = intval($_GET['edit']); 35 36 if( isset($_POST['cat_id']) ) { 37 38 // check if form should be closed only -> and back to listing mode 39 if( isset($_POST['close']) ) { 40 headerRedirect( shop_url('controller=cat', '') ); 41 } 42 43 $plugin['data']['cat_changedate'] = time(); 44 $plugin['data']['cat_name'] = clean_slweg($_POST['cat_name']); 45 $plugin['data']['cat_info'] = clean_slweg($_POST['cat_info']); 46 $plugin['data']['cat_status'] = empty($_POST['cat_status']) ? 0 : 1; 47 $plugin['data']['cat_pid'] = intval($_POST['cat_pid']); 48 $plugin['data']['cat_sort'] = intval($_POST['cat_sort']); 49 50 if(!$plugin['data']['cat_name']) { 51 $plugin['error']['cat_name'] = 'No name'; 52 } else { 53 $sql = 'SELECT COUNT(cat_id) FROM '.DB_PREPEND.'phpwcms_categories WHERE '; 54 $sql .= "cat_type='module_shop' AND cat_name LIKE '". aporeplace($plugin['data']['cat_name']) ."'"; 55 $sql .= $plugin['data']['cat_id'] ? ' AND cat_id != ' . $plugin['data']['cat_id'] : ''; 56 if( _dbQuery($sql, 'COUNT') ) { 57 $plugin['error']['cat_name'] = 'Duplicate category name'; 58 } 59 } 60 61 if( empty($plugin['error'] )) { 62 63 // Update 64 if( $plugin['data']['cat_id'] ) { 65 66 $sql = 'UPDATE '.DB_PREPEND.'phpwcms_categories SET '; 67 $sql .= "cat_changedate = '".aporeplace( date('Y-m-d H:i:s', $plugin['data']['cat_changedate']) )."', "; 68 $sql .= "cat_pid = ".$plugin['data']['cat_pid'].", "; 69 $sql .= "cat_status = ".$plugin['data']['cat_status'].", "; 70 $sql .= "cat_name = '".aporeplace($plugin['data']['cat_name'])."', "; 71 $sql .= "cat_info = '".aporeplace($plugin['data']['cat_info'])."', "; 72 $sql .= "cat_sort = ".$plugin['data']['cat_sort']." "; 73 $sql .= "WHERE cat_type='module_shop' AND cat_id = " . $plugin['data']['cat_id']; 74 75 _dbQuery($sql, 'UPDATE'); 76 77 // INSERT 78 } else { 79 80 $sql = 'INSERT INTO '.DB_PREPEND.'phpwcms_categories ('; 81 $sql .= 'cat_type, cat_pid, cat_createdate, cat_changedate, cat_status, cat_name, cat_info, cat_sort'; 82 $sql .= ') VALUES ('; 83 $sql .= "'module_shop', "; 84 $sql .= $plugin['data']['cat_pid'].', '; 85 $sql .= "'".aporeplace( date('Y-m-d H:i:s', $plugin['data']['cat_changedate']) )."', "; 86 $sql .= "'".aporeplace( date('Y-m-d H:i:s', $plugin['data']['cat_changedate']) )."', "; 87 $sql .= $plugin['data']['cat_status'].", "; 88 $sql .= "'".aporeplace($plugin['data']['cat_name'])."', "; 89 $sql .= "'".aporeplace($plugin['data']['cat_info'])."',"; 90 $sql .= $plugin['data']['cat_sort']; 91 $sql .= ')'; 92 93 $result = _dbQuery($sql, 'INSERT'); 94 95 if( !empty($result['INSERT_ID']) ) { 96 $plugin['data']['cat_id'] = $result['INSERT_ID']; 97 } 98 99 } 100 101 // save and back to listing mode 102 if( isset($_POST['save']) ) { 103 headerRedirect( shop_url('controller=cat', '') ); 104 } else { 105 headerRedirect( shop_url( array('controller=cat', 'edit='.$plugin['data']['cat_id']), '') ); 106 } 107 108 } 109 110 111 } elseif( $plugin['data']['cat_id'] == 0 ) { 112 113 $plugin['data']['cat_id'] = 0; 114 $plugin['data']['cat_pid'] = 0; 115 $plugin['data']['cat_changedate'] = time(); 116 $plugin['data']['cat_name'] = ''; 117 $plugin['data']['cat_info'] = ''; 118 $plugin['data']['cat_status'] = 1; 119 $plugin['data']['cat_sort'] = 0; 120 121 } else { 122 123 $sql = 'SELECT * FROM '.DB_PREPEND.'phpwcms_categories WHERE '; 124 $sql .= "cat_type='module_shop' AND cat_id = " . $plugin['data']['cat_id'] . ' LIMIT 1'; 125 126 $plugin['data'] = _dbQuery($sql); 127 128 if( isset($plugin['data'][0]) ) { 129 $plugin['data'] = $plugin['data'][0]; 130 131 $plugin['data']['cat_changedate'] = strtotime($plugin['data']['cat_changedate']); 132 133 } else { 134 headerRedirect( shop_url('controller=cat', '') ); 135 } 136 137 } 138 139 } elseif($action == 'status') { 140 141 list($plugin['data']['cat_id'], $plugin['data']['cat_status']) = explode( '-', $_GET['status'] ); 142 143 $plugin['data']['cat_id'] = intval($plugin['data']['cat_id']); 144 $plugin['data']['cat_status'] = empty($plugin['data']['cat_status']) ? 1 : 0; 145 146 $sql = 'UPDATE '.DB_PREPEND.'phpwcms_categories SET '; 147 $sql .= "cat_status = ".$plugin['data']['cat_status']." "; 148 $sql .= "WHERE cat_type='module_shop' AND cat_id = " . $plugin['data']['cat_id']; 149 150 _dbQuery($sql, 'UPDATE'); 151 152 headerRedirect( shop_url('controller=cat', '') ); 153 154 } elseif($action == 'delete') { 155 156 $plugin['data']['cat_id'] = intval($_GET['delete']); 157 158 $sql = 'UPDATE '.DB_PREPEND.'phpwcms_categories SET '; 159 $sql .= "cat_status = 9 "; 160 $sql .= "WHERE cat_type='module_shop' AND "; 161 $sql .= "(cat_id = " . $plugin['data']['cat_id'] . " OR cat_pid = " . $plugin['data']['cat_id'] . ")"; 162 163 _dbQuery($sql, 'UPDATE'); 164 165 headerRedirect( shop_url('controller=cat', '') ); 166 167 } 168 169 170 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Jan 29 16:31:14 2012 | Cross-referenced by PHPXref 0.7.1 |