Changeset 702 for trunk/forum/includes/acp/acp_styles.php
- Timestamp:
- Mar 31, 2010, 6:32:40 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/forum/includes/acp/acp_styles.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_styles.php 9152 2008-12-02 16:49:59Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 38 38 $bitfield = new bitfield(); 39 39 $bitfield->set(0); 40 $bitfield->set(1); 41 $bitfield->set(2); 40 42 $bitfield->set(3); 43 $bitfield->set(4); 41 44 $bitfield->set(8); 42 45 $bitfield->set(9); … … 208 211 } 209 212 210 $sql = 'UPDATE ' . STYLES_TABLE . ' 211 SET style_active = ' . (($action == 'activate') ? 1 : 0) . ' 212 WHERE style_id = ' . $style_id; 213 $db->sql_query($sql); 214 215 // Set style to default for any member using deactivated style 216 if ($action == 'deactivate') 213 if (($action == 'deactivate' && confirm_box(true)) || $action == 'activate') 217 214 { 218 $sql = 'UPDATE ' . USERS_TABLE . '219 SET user_style = ' . $config['default_style'] . "220 WHERE user_style = $style_id";215 $sql = 'UPDATE ' . STYLES_TABLE . ' 216 SET style_active = ' . (($action == 'activate') ? 1 : 0) . ' 217 WHERE style_id = ' . $style_id; 221 218 $db->sql_query($sql); 222 219 223 $sql = 'UPDATE ' . FORUMS_TABLE . ' 224 SET forum_style = 0 225 WHERE forum_style = ' . $style_id; 226 $db->sql_query($sql); 220 // Set style to default for any member using deactivated style 221 if ($action == 'deactivate') 222 { 223 $sql = 'UPDATE ' . USERS_TABLE . ' 224 SET user_style = ' . $config['default_style'] . " 225 WHERE user_style = $style_id"; 226 $db->sql_query($sql); 227 228 $sql = 'UPDATE ' . FORUMS_TABLE . ' 229 SET forum_style = 0 230 WHERE forum_style = ' . $style_id; 231 $db->sql_query($sql); 232 } 233 } 234 else if ($action == 'deactivate') 235 { 236 $s_hidden_fields = array( 237 'i' => $id, 238 'mode' => $mode, 239 'action' => $action, 240 'style_id' => $style_id, 241 ); 242 confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields)); 227 243 } 228 244 break; … … 628 644 while (($file = readdir($dp)) !== false) 629 645 { 646 if (!is_dir($phpbb_root_path . 'styles/' . $file)) 647 { 648 continue; 649 } 650 630 651 $subpath = ($mode != 'style') ? "$mode/" : ''; 631 652 if ($file[0] != '.' && file_exists("{$phpbb_root_path}styles/$file/$subpath$mode.cfg")) … … 732 753 if (!($fp = @fopen($file, 'wb'))) 733 754 { 734 trigger_error($user->lang['NO_TEMPLATE'] . adm_back_link($this->u_action), E_USER_WARNING); 755 // File exists and is writeable, but still not able to be written to 756 trigger_error(sprintf($user->lang['TEMPLATE_FILE_NOT_WRITABLE'], htmlspecialchars($template_file)) . adm_back_link($this->u_action), E_USER_WARNING); 735 757 } 736 758 fwrite($fp, $template_data); … … 744 766 if (!$template_info['template_storedb']) 745 767 { 746 if ($ this->get_super('template', $template_id))768 if ($super = $this->get_super('template', $template_id)) 747 769 { 748 770 $this->store_in_db('template', $super['template_id']); … … 825 847 } 826 848 849 if (empty($filelist[''])) 850 { 851 trigger_error($user->lang['NO_TEMPLATE'] . adm_back_link($this->u_action), E_USER_WARNING); 852 } 853 827 854 // Now create the categories 828 855 $filelist_cats[''] = array(); … … 1022 1049 foreach ($file_ary as $file) 1023 1050 { 1024 $file 1051 $file = str_replace('/', '.', $file); 1025 1052 1026 1053 // perform some dirty guessing to get the path right. 1027 1054 // We assume that three dots in a row were '../' 1028 $tpl_file 1029 $tpl_file 1055 $tpl_file = str_replace('.', '/', $file); 1056 $tpl_file = str_replace('///', '../', $tpl_file); 1030 1057 1031 1058 $filename = "{$cache_prefix}_$file.html.$phpEx"; … … 1059 1086 } 1060 1087 1088 // Correct the filename if it is stored in database and the file is in a subfolder. 1089 if ($template_row['template_storedb']) 1090 { 1091 $file = str_replace('.', '/', $file); 1092 } 1061 1093 1062 1094 $template->assign_block_vars('file', array( … … 1066 1098 'FILENAME' => $file, 1067 1099 'FILENAME_PATH' => $file_tpl, 1068 'FILESIZE' => sprintf('%.1f ' . $user->lang['KIB'], filesize("{$phpbb_root_path}cache/$filename") / 1024),1100 'FILESIZE' => get_formatted_filesize(filesize("{$phpbb_root_path}cache/$filename")), 1069 1101 'MODIFIED' => $user->format_date((!$template_row['template_storedb']) ? filemtime($file_tpl) : $filemtime[$file . '.html'])) 1070 1102 ); … … 1264 1296 } 1265 1297 1266 1267 1298 /** 1268 1299 * Edit imagesets … … 1276 1307 $this->page_title = 'EDIT_IMAGESET'; 1277 1308 1309 if (!$imageset_id) 1310 { 1311 trigger_error($user->lang['NO_IMAGESET'] . adm_back_link($this->u_action), E_USER_WARNING); 1312 } 1313 1278 1314 $update = (isset($_POST['update'])) ? true : false; 1279 1315 1280 $imgname = request_var('imgname', ''); 1281 $imgpath = request_var('imgpath', ''); 1282 $imgsize = request_var('imgsize', false); 1283 $imgwidth = request_var('imgwidth', 0); 1284 $imgheight = request_var('imgheight', 0); 1285 1316 $imgname = request_var('imgname', 'site_logo'); 1286 1317 $imgname = preg_replace('#[^a-z0-9\-+_]#i', '', $imgname); 1287 $imgpath = str_replace('..', '.', $imgpath); 1288 1289 if ($imageset_id) 1290 { 1291 $sql = 'SELECT imageset_path, imageset_name 1292 FROM ' . STYLES_IMAGESET_TABLE . " 1293 WHERE imageset_id = $imageset_id"; 1294 $result = $db->sql_query($sql); 1295 $imageset_row = $db->sql_fetchrow($result); 1296 $db->sql_freeresult($result); 1297 1298 $imageset_path = $imageset_row['imageset_path']; 1299 $imageset_name = $imageset_row['imageset_name']; 1300 1301 $sql_extra = ''; 1302 if (strpos($imgname, '-') !== false) 1303 { 1304 list($imgname, $imgnamelang) = explode('-', $imgname); 1305 $sql_extra = " AND image_lang IN ('" . $db->sql_escape($imgnamelang) . "', '')"; 1306 } 1307 1308 $sql = 'SELECT image_filename, image_width, image_height, image_lang, image_id 1309 FROM ' . STYLES_IMAGESET_DATA_TABLE . " 1310 WHERE imageset_id = $imageset_id 1311 AND image_name = '" . $db->sql_escape($imgname) . "'$sql_extra"; 1312 $result = $db->sql_query($sql); 1313 $imageset_data_row = $db->sql_fetchrow($result); 1314 $db->sql_freeresult($result); 1315 1316 $image_filename = $imageset_data_row['image_filename']; 1317 $image_width = $imageset_data_row['image_width']; 1318 $image_height = $imageset_data_row['image_height']; 1319 $image_lang = $imageset_data_row['image_lang']; 1320 $image_id = $imageset_data_row['image_id']; 1321 1322 if (!$imageset_row) 1323 { 1324 trigger_error($user->lang['NO_IMAGESET'] . adm_back_link($this->u_action), E_USER_WARNING); 1325 } 1326 1327 // Check to see whether the selected image exists in the table 1328 $valid_name = ($update) ? false : true; 1329 1330 foreach ($this->imageset_keys as $category => $img_ary) 1331 { 1332 if (in_array($imgname, $img_ary)) 1333 { 1334 $valid_name = true; 1335 break; 1336 } 1337 } 1338 1339 if ($update && isset($_POST['imgpath'])) 1340 { 1341 if ($valid_name) 1342 { 1343 // If imgwidth and imgheight are non-zero grab the actual size 1344 // from the image itself ... we ignore width settings for the poll center image 1345 $imgwidth = request_var('imgwidth', 0); 1346 $imgheight = request_var('imgheight', 0); 1347 $imglang = ''; 1348 1349 if ($imgpath && !file_exists("{$phpbb_root_path}styles/$imageset_path/imageset/$imgpath")) 1350 { 1351 trigger_error($user->lang['NO_IMAGE_ERROR'] . adm_back_link($this->u_action), E_USER_WARNING); 1352 } 1353 1354 if ($imgsize && $imgpath) 1355 { 1356 if (!$imgwidth || !$imgheight) 1357 { 1358 list($imgwidth_file, $imgheight_file) = getimagesize("{$phpbb_root_path}styles/$imageset_path/imageset/$imgpath"); 1359 $imgwidth = ($imgwidth) ? $imgwidth : $imgwidth_file; 1360 $imgheight = ($imgheight) ? $imgheight : $imgheight_file; 1361 } 1362 $imgwidth = ($imgname != 'poll_center') ? (int) $imgwidth : 0; 1363 $imgheight = (int) $imgheight; 1364 } 1365 1366 1367 if (strpos($imgpath, '/') !== false) 1368 { 1369 list($imglang, $imgfilename) = explode('/', $imgpath); 1370 } 1371 else 1372 { 1373 $imgfilename = $imgpath; 1374 } 1375 1376 $sql_ary = array( 1377 'image_filename' => (string) $imgfilename, 1378 'image_width' => (int) $imgwidth, 1379 'image_height' => (int) $imgheight, 1380 'image_lang' => (string) $imglang, 1381 ); 1382 1383 // already exists 1384 if ($imageset_data_row) 1385 { 1386 $sql = 'UPDATE ' . STYLES_IMAGESET_DATA_TABLE . ' 1387 SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " 1388 WHERE image_id = $image_id"; 1389 $db->sql_query($sql); 1390 } 1391 // does not exist 1392 else if (!$imageset_data_row) 1393 { 1394 $sql_ary['image_name'] = $imgname; 1395 $sql_ary['imageset_id'] = (int) $imageset_id; 1396 $db->sql_query('INSERT INTO ' . STYLES_IMAGESET_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); 1397 } 1398 1399 $cache->destroy('sql', STYLES_IMAGESET_DATA_TABLE); 1400 1401 add_log('admin', 'LOG_IMAGESET_EDIT', $imageset_name); 1402 1403 $template->assign_var('SUCCESS', true); 1404 1405 $image_filename = $imgfilename; 1406 $image_width = $imgwidth; 1407 $image_height = $imgheight; 1408 $image_lang = $imglang; 1409 } 1410 } 1318 $sql_extra = $imgnamelang = ''; 1319 1320 $sql = 'SELECT imageset_path, imageset_name 1321 FROM ' . STYLES_IMAGESET_TABLE . " 1322 WHERE imageset_id = $imageset_id"; 1323 $result = $db->sql_query($sql); 1324 $imageset_row = $db->sql_fetchrow($result); 1325 $db->sql_freeresult($result); 1326 1327 if (!$imageset_row) 1328 { 1329 trigger_error($user->lang['NO_IMAGESET'] . adm_back_link($this->u_action), E_USER_WARNING); 1330 } 1331 1332 $imageset_path = $imageset_row['imageset_path']; 1333 $imageset_name = $imageset_row['imageset_name']; 1334 1335 if (strpos($imgname, '-') !== false) 1336 { 1337 list($imgname, $imgnamelang) = explode('-', $imgname); 1338 $sql_extra = " AND image_lang IN ('" . $db->sql_escape($imgnamelang) . "', '')"; 1339 } 1340 1341 $sql = 'SELECT image_filename, image_width, image_height, image_lang, image_id 1342 FROM ' . STYLES_IMAGESET_DATA_TABLE . " 1343 WHERE imageset_id = $imageset_id 1344 AND image_name = '" . $db->sql_escape($imgname) . "'$sql_extra"; 1345 $result = $db->sql_query($sql); 1346 $imageset_data_row = $db->sql_fetchrow($result); 1347 $db->sql_freeresult($result); 1348 1349 $image_filename = $imageset_data_row['image_filename']; 1350 $image_width = $imageset_data_row['image_width']; 1351 $image_height = $imageset_data_row['image_height']; 1352 $image_lang = $imageset_data_row['image_lang']; 1353 $image_id = $imageset_data_row['image_id']; 1354 $imgsize = ($imageset_data_row['image_width'] && $imageset_data_row['image_height']) ? 1 : 0; 1355 1356 // Check to see whether the selected image exists in the table 1357 $valid_name = ($update) ? false : true; 1358 1359 foreach ($this->imageset_keys as $category => $img_ary) 1360 { 1361 if (in_array($imgname, $img_ary)) 1362 { 1363 $valid_name = true; 1364 break; 1365 } 1366 } 1367 1368 if ($update && isset($_POST['imgpath']) && $valid_name) 1369 { 1370 // If imgwidth and imgheight are non-zero grab the actual size 1371 // from the image itself ... we ignore width settings for the poll center image 1372 $imgwidth = request_var('imgwidth', 0); 1373 $imgheight = request_var('imgheight', 0); 1374 $imgsize = request_var('imgsize', 0); 1375 $imgpath = request_var('imgpath', ''); 1376 $imgpath = str_replace('..', '.', $imgpath); 1377 1378 // If no dimensions selected, we reset width and height to 0 ;) 1379 if (!$imgsize) 1380 { 1381 $imgwidth = $imgheight = 0; 1382 } 1383 1384 $imglang = ''; 1385 1386 if ($imgpath && !file_exists("{$phpbb_root_path}styles/$imageset_path/imageset/$imgpath")) 1387 { 1388 trigger_error($user->lang['NO_IMAGE_ERROR'] . adm_back_link($this->u_action), E_USER_WARNING); 1389 } 1390 1391 // Determine width/height. If dimensions included and no width/height given, we detect them automatically... 1392 if ($imgsize && $imgpath) 1393 { 1394 if (!$imgwidth || !$imgheight) 1395 { 1396 list($imgwidth_file, $imgheight_file) = getimagesize("{$phpbb_root_path}styles/$imageset_path/imageset/$imgpath"); 1397 $imgwidth = ($imgwidth) ? $imgwidth : $imgwidth_file; 1398 $imgheight = ($imgheight) ? $imgheight : $imgheight_file; 1399 } 1400 $imgwidth = ($imgname != 'poll_center') ? (int) $imgwidth : 0; 1401 $imgheight = (int) $imgheight; 1402 } 1403 1404 if (strpos($imgpath, '/') !== false) 1405 { 1406 list($imglang, $imgfilename) = explode('/', $imgpath); 1407 } 1408 else 1409 { 1410 $imgfilename = $imgpath; 1411 } 1412 1413 $sql_ary = array( 1414 'image_filename' => (string) $imgfilename, 1415 'image_width' => (int) $imgwidth, 1416 'image_height' => (int) $imgheight, 1417 'image_lang' => (string) $imglang, 1418 ); 1419 1420 // already exists 1421 if ($imageset_data_row) 1422 { 1423 $sql = 'UPDATE ' . STYLES_IMAGESET_DATA_TABLE . ' 1424 SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " 1425 WHERE image_id = $image_id"; 1426 $db->sql_query($sql); 1427 } 1428 // does not exist 1429 else if (!$imageset_data_row) 1430 { 1431 $sql_ary['image_name'] = $imgname; 1432 $sql_ary['imageset_id'] = (int) $imageset_id; 1433 $db->sql_query('INSERT INTO ' . STYLES_IMAGESET_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); 1434 } 1435 1436 $cache->destroy('sql', STYLES_IMAGESET_DATA_TABLE); 1437 1438 add_log('admin', 'LOG_IMAGESET_EDIT', $imageset_name); 1439 1440 $template->assign_var('SUCCESS', true); 1441 1442 $image_filename = $imgfilename; 1443 $image_width = $imgwidth; 1444 $image_height = $imgheight; 1445 $image_lang = $imglang; 1411 1446 } 1412 1447 … … 1530 1565 'NAME' => $imageset_name, 1531 1566 'A_NAME' => addslashes($imageset_name), 1567 'PATH' => $imageset_path, 1568 'A_PATH' => addslashes($imageset_path), 1532 1569 'ERROR' => !$valid_name, 1533 1570 'IMG_SRC' => ($image_found) ? '../styles/' . $imageset_path . '/imageset/' . $img_val : 'images/no_image.png', … … 2396 2433 } 2397 2434 2398 2399 2435 if ($mode == 'template') 2400 2436 { … … 2527 2563 trigger_error("Could not open {$phpbb_root_path}styles/$template_path$pathfile$file", E_USER_ERROR); 2528 2564 } 2529 $template_data = fread($fp, filesize("{$phpbb_root_path}styles/$template_path$pathfile$file")); 2565 2566 $filesize = filesize("{$phpbb_root_path}styles/$template_path$pathfile$file"); 2567 2568 if ($filesize) 2569 { 2570 $template_data = fread($fp, $filesize); 2571 } 2572 2530 2573 fclose($fp); 2574 2575 if (!$filesize) 2576 { 2577 // File is empty 2578 continue; 2579 } 2531 2580 2532 2581 if (preg_match_all('#<!-- INCLUDE (.*?\.html) -->#is', $template_data, $matches)) … … 3196 3245 $db->sql_freeresult($result); 3197 3246 3198 3199 3247 if ($row) 3200 3248 { … … 3211 3259 if (isset($cfg_data['inherit_from']) && $cfg_data['inherit_from']) 3212 3260 { 3213 $sql = "SELECT {$mode}_id, {$mode}_name, {$mode}_path, {$mode}_storedb 3261 if ($mode === 'template') 3262 { 3263 $select_bf = ', bbcode_bitfield'; 3264 } 3265 else 3266 { 3267 $select_bf = ''; 3268 } 3269 3270 $sql = "SELECT {$mode}_id, {$mode}_name, {$mode}_path, {$mode}_storedb $select_bf 3214 3271 FROM $sql_from 3215 3272 WHERE {$mode}_name = '" . $db->sql_escape($cfg_data['inherit_from']) . "' … … 3226 3283 $inherit_id = $row["{$mode}_id"]; 3227 3284 $inherit_path = $row["{$mode}_path"]; 3285 $inherit_bf = ($mode === 'template') ? $row["bbcode_bitfield"] : false; 3228 3286 $cfg_data['store_db'] = $row["{$mode}_storedb"]; 3229 3287 $store_db = $row["{$mode}_storedb"]; … … 3234 3292 $inherit_id = 0; 3235 3293 $inherit_path = ''; 3236 }3237 3294 $inherit_bf = false; 3295 } 3238 3296 3239 3297 if (sizeof($error)) … … 3255 3313 { 3256 3314 $sql_ary['bbcode_bitfield'] = $cfg_data['template_bitfield']; 3315 } 3316 else if ($inherit_bf) 3317 { 3318 $sql_ary['bbcode_bitfield'] = $inherit_bf; 3257 3319 } 3258 3320 else … … 3502 3564 } 3503 3565 3504 3505 3566 $sql = "SELECT {$mode}_inherits_id 3506 3567 FROM $sql_from
Note:
See TracChangeset
for help on using the changeset viewer.