1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.
163.
164.
165.
166.
167.
168.
169.
170.
171.
172.
173.
174.
175.
176.
177.
178.
179.
180.
181.
182.
183.
184.
185.
186.
187.
188.
189.
190.
191.
192.
193.
194.
195.
196.
197.
198.
199.
200.
201.
202.
203.
204.
205.
206.
207.
208.
209.
210.
211.
212.
| 1. / 2. / ...
<?php
// ClanSphere 2009 - www.clansphere.net
// $Id: edit.php 2266 2009-03-21 10:37:39Z duRiel $
$cs_lang = cs_translate('clans');
$files = cs_files();
$clans_id = $_REQUEST['id'];
settype($clans_id,'integer');
$op_clans = cs_sql_option(__FILE__,'clans');
$img_filetypes = array('gif','jpg','png');
if(isset($_POST['submit'])) {
$cs_clans['clans_name'] = $_POST['clans_name'];
$cs_clans['clans_short'] = $_POST['clans_short'];
$cs_clans['clans_tag'] = $_POST['clans_tag'];
$cs_clans['clans_tagpos'] = $_POST['tag_pos'];
$cs_clans['clans_country'] = $_POST['clans_country'];
$cs_clans['clans_url'] = $_POST['clans_url'];
$cs_clans['clans_since'] = cs_datepost('since','date');
$cs_clans['clans_zusatz'] = $_POST['clans_zusatz'];
$picture = cs_sql_select(__FILE__,'clans','clans_picture',"clans_id = '" . $clans_id . "'");
$cs_clans['clans_picture'] = empty($_POST['clans_picture']) ? $picture['clans_picture'] : $_POST['clans_picture'];
$cs_clans['clans_pwd'] = $_POST['clans_pwd'];
$cs_clans['users_id'] = $_POST['users_id'];
$error = 0;
$errormsg = '';
if(isset($_POST['delete'])) {
cs_unlink('clans', $cs_clans['clans_picture']);
$cs_clans['clans_picture'] = '';
}
$img_size = getimagesize($files['picture']['tmp_name']);
if(!empty($files['picture']['tmp_name']) AND empty($img_size) OR $img_size[2] > 3) {
$message .= $cs_lang['ext_error'] . cs_html_br(1);
$error++;
}
elseif(!empty($files['picture']['tmp_name'])) {
switch($img_size[2]) {
case 1:
$ext = 'gif'; break;
case 2:
$ext = 'jpg'; break;
case 3:
$ext = 'png'; break;
}
$filename = 'picture-' . $clans_id . '.' . $ext;
if($img_size[0]>$op_clans['max_width']) {
$message .= $cs_lang['too_wide'] . cs_html_br(1);
$error++;
}
if($img_size[1]>$op_clans['max_height']) {
$message .= $cs_lang['too_high'] . cs_html_br(1);
$error++;
}
if($files['picture']['size']>$op_clans['max_size']) {
$message .= $cs_lang['too_big'] . cs_html_br(1);
$error++;
}
if(empty($error) AND cs_upload('clans', $filename, $files['picture']['tmp_name']) OR !empty($error) AND extension_loaded('gd') AND cs_resample($files['picture']['tmp_name'], 'uploads/clans/' . $filename, $op_clans['max_width'], $op_clans['max_height'])) {
$error = 0;
$message = '';
if($cs_clans['clans_picture'] != $filename AND !empty($cs_clans['clans_picture'])) {
cs_unlink('clans', $cs_clans['clans_picture']);
}
$cs_clans['clans_picture'] = $filename;
}
else {
$message .= $cs_lang['up_error'];
$error++;
}
}
if(empty($cs_clans['clans_name'])) {
$error++;
$errormsg .= $cs_lang['no_name'] . cs_html_br(1);
}
if(empty($cs_clans['clans_short'])) {
$error++;
$errormsg .= $cs_lang['no_short'] . cs_html_br(1);
}
if(empty($cs_clans['clans_zusatz'])) {
$error++;
$errormsg .= $cs_lang['no_zusatz'] . cs_html_br(1);
}
$where = "clans_name = '" . cs_sql_escape($cs_clans['clans_name']) . "'";
$where .= " AND clans_id != '" . $clans_id . "'";
$search = cs_sql_count(__FILE__,'clans',$where);
if(!empty($search)) {
$error++;
$errormsg .= $cs_lang['name_exists'] . cs_html_br(1);
}
}
else {
$cells = 'clans_name, clans_short, clans_tag, clans_tagpos, clans_country, clans_url, clans_since, clans_pwd,clans_zusatz, clans_picture, users_id';
$cs_clans = cs_sql_select(__FILE__,'clans',$cells,"clans_id = '" . $clans_id . "'");
}
if(!isset($_POST['submit'])) {
$data['lang']['body'] = $cs_lang['errors_here'];
}
if(!empty($error)) {
$data['lang']['body'] = $errormsg;
}
if(!empty($error) OR !isset($_POST['submit'])) {
$data['lang']['mod'] = $cs_lang[$op_clans['label']];
$data['url']['form'] = cs_url('clans','edit');
$data['clans']['name'] = $cs_clans['clans_name'];
$data['clans']['short'] = $cs_clans['clans_short'];
$data['clans']['tag'] = $cs_clans['clans_tag'];
$data['clans']['zusatz'] = $cs_clans['clans_zusatz'];
if($cs_clans['clans_tagpos'] == '1') {
$data['select']['before'] = 'selected="selected"';
}
else {
$data['select']['before'] = '';
}
if($cs_clans['clans_tagpos'] == '2') {
$data['select']['next'] = 'selected="selected"';
}
else {
$data['select']['next'] = '';
}
$el_id = 'country_1';
$onc = "document.getElementById('" . $el_id . "').src='" . $cs_main['php_self']['dirname'] . "symbols/countries/' + this.form.";
$onc .= "clans_country.options[this.form.clans_country.selectedIndex].value + '.png'";
$data['clans']['country'] = cs_html_select(1,'clans_country',"onchange=\"" . $onc . "\"");
include_once('lang/' . $account['users_lang'] . '/countries.php');
foreach ($cs_country AS $short => $full) {
$short == $cs_clans['clans_country'] ? $sel = 1 : $sel = 0;
$data['clans']['country'] .= cs_html_option($full,$short,$sel);
}
$data['clans']['country'] .= cs_html_select(0) . ' ' . cs_html_img('symbols/countries/' . $cs_clans['clans_country'] . '.png',11,16,'id="' . $el_id . '"');
$data['clans']['url'] = $cs_clans['clans_url'];
$data['clans']['since'] = cs_dateselect('since','date',$cs_clans['clans_since']);
$data['clans']['password'] = $cs_clans['clans_pwd'];
$users_data = cs_sql_select(__FILE__,'users','users_nick,users_id',0,'users_nick',0,0);
$users_data_loop = count($users_data);
if(empty($users_data_loop)) {
$data['users'] = '';
}
for($run=0; $run<$users_data_loop; $run++) {
$data['users'][$run]['id'] = $users_data[$run]['users_id'];
$data['users'][$run]['name'] = $users_data[$run]['users_nick'];
if($cs_clans['users_id'] == $users_data[$run]['users_id']) {
$data['users'][$run]['select'] = 'selected="selected"';
}
else {
$data['users'][$run]['select'] = '';
}
}
if(empty($cs_clans['clans_picture'])) {
$data['clans']['pic'] = $cs_lang['nopic'];
}
else {
$place = 'uploads/clans/' . $cs_clans['clans_picture'];
$size = getimagesize($cs_main['def_path'] . '/' . $place);
$data['clans']['pic'] = cs_html_img($place,$size[1],$size[0]);
}
$matches[1] = $cs_lang['pic_infos'];
$return_types = '';
foreach($img_filetypes AS $add) {
$return_types .= empty($return_types) ? $add : ', ' . $add;
}
$matches[2] = $cs_lang['max_width'] . $op_clans['max_width'] . ' px' . cs_html_br(1);
$matches[2] .= $cs_lang['max_height'] . $op_clans['max_height'] . ' px' . cs_html_br(1);
$matches[2] .= $cs_lang['max_size'] . cs_filesize($op_clans['max_size']) . cs_html_br(1);
$matches[2] .= $cs_lang['filetypes'] . $return_types;
$data['clans']['clip'] = cs_abcode_clip($matches);
$data['data']['id'] = $clans_id;
$data['clip']['plus'] = cs_html_img('symbols/clansphere/plus.gif',0,0,'id="img_pass"');
echo cs_subtemplate(__FILE__,$data,'clans','edit');
}
else {
$clans_cells = array_keys($cs_clans);
$clans_save = array_values($cs_clans);
cs_sql_update(__FILE__,'clans',$clans_cells,$clans_save,$clans_id);
cs_redirect($cs_lang['changes_done'], 'clans') ;
}
?> |