Ignore:
Timestamp:
Mar 31, 2010, 6:32:40 PM (14 years ago)
Author:
george
Message:
  • Upraveno: Aktualizace fóra.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/forum/includes/acp/acp_styles.php

    r400 r702  
    33*
    44* @package acp
    5 * @version $Id: acp_styles.php 9152 2008-12-02 16:49:59Z acydburn $
     5* @version $Id$
    66* @copyright (c) 2005 phpBB Group
    77* @license http://opensource.org/licenses/gpl-license.php GNU Public License
     
    3838                $bitfield = new bitfield();
    3939                $bitfield->set(0);
     40                $bitfield->set(1);
     41                $bitfield->set(2);
    4042                $bitfield->set(3);
     43                $bitfield->set(4);
    4144                $bitfield->set(8);
    4245                $bitfield->set(9);
     
    208211                                                }
    209212
    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')
    217214                                                {
    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;
    221218                                                        $db->sql_query($sql);
    222219
    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));
    227243                                                }
    228244                                        break;
     
    628644                        while (($file = readdir($dp)) !== false)
    629645                        {
     646                                if (!is_dir($phpbb_root_path . 'styles/' . $file))
     647                                {
     648                                        continue;
     649                                }
     650
    630651                                $subpath = ($mode != 'style') ? "$mode/" : '';
    631652                                if ($file[0] != '.' && file_exists("{$phpbb_root_path}styles/$file/$subpath$mode.cfg"))
     
    732753                                if (!($fp = @fopen($file, 'wb')))
    733754                                {
    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);
    735757                                }
    736758                                fwrite($fp, $template_data);
     
    744766                                if (!$template_info['template_storedb'])
    745767                                {
    746                                         if ($this->get_super('template', $template_id))
     768                                        if ($super = $this->get_super('template', $template_id))
    747769                                        {
    748770                                                $this->store_in_db('template', $super['template_id']);
     
    825847                }
    826848
     849                if (empty($filelist['']))
     850                {
     851                        trigger_error($user->lang['NO_TEMPLATE'] . adm_back_link($this->u_action), E_USER_WARNING);
     852                }
     853
    827854                // Now create the categories
    828855                $filelist_cats[''] = array();
     
    10221049                foreach ($file_ary as $file)
    10231050                {
    1024                         $file           = str_replace('/', '.', $file);
     1051                        $file           = str_replace('/', '.', $file);
    10251052
    10261053                        // perform some dirty guessing to get the path right.
    10271054                        // We assume that three dots in a row were '../'
    1028                         $tpl_file       = str_replace('.', '/', $file);
    1029                         $tpl_file       = str_replace('///', '../', $tpl_file);
     1055                        $tpl_file       = str_replace('.', '/', $file);
     1056                        $tpl_file       = str_replace('///', '../', $tpl_file);
    10301057
    10311058                        $filename = "{$cache_prefix}_$file.html.$phpEx";
     
    10591086                        }
    10601087
     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                        }
    10611093
    10621094                        $template->assign_block_vars('file', array(
     
    10661098                                'FILENAME'              => $file,
    10671099                                '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")),
    10691101                                'MODIFIED'              => $user->format_date((!$template_row['template_storedb']) ? filemtime($file_tpl) : $filemtime[$file . '.html']))
    10701102                        );
     
    12641296        }
    12651297
    1266 
    12671298        /**
    12681299        * Edit imagesets
     
    12761307                $this->page_title = 'EDIT_IMAGESET';
    12771308
     1309                if (!$imageset_id)
     1310                {
     1311                        trigger_error($user->lang['NO_IMAGESET'] . adm_back_link($this->u_action), E_USER_WARNING);
     1312                }
     1313
    12781314                $update         = (isset($_POST['update'])) ? true : false;
    12791315
    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');
    12861317                $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;
    14111446                }
    14121447
     
    15301565                        'NAME'                          => $imageset_name,
    15311566                        'A_NAME'                        => addslashes($imageset_name),
     1567                        'PATH'                          => $imageset_path,
     1568                        'A_PATH'                        => addslashes($imageset_path),
    15321569                        'ERROR'                         => !$valid_name,
    15331570                        'IMG_SRC'                       => ($image_found) ? '../styles/' . $imageset_path . '/imageset/' . $img_val : 'images/no_image.png',
     
    23962433                }
    23972434
    2398 
    23992435                if ($mode == 'template')
    24002436                {
     
    25272563                                        trigger_error("Could not open {$phpbb_root_path}styles/$template_path$pathfile$file", E_USER_ERROR);
    25282564                                }
    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
    25302573                                fclose($fp);
     2574
     2575                                if (!$filesize)
     2576                                {
     2577                                        // File is empty
     2578                                        continue;
     2579                                }
    25312580
    25322581                                if (preg_match_all('#<!-- INCLUDE (.*?\.html) -->#is', $template_data, $matches))
     
    31963245                $db->sql_freeresult($result);
    31973246
    3198 
    31993247                if ($row)
    32003248                {
     
    32113259                if (isset($cfg_data['inherit_from']) && $cfg_data['inherit_from'])
    32123260                {
    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
    32143271                                FROM $sql_from
    32153272                                WHERE {$mode}_name = '" . $db->sql_escape($cfg_data['inherit_from']) . "'
     
    32263283                                $inherit_id = $row["{$mode}_id"];
    32273284                                $inherit_path = $row["{$mode}_path"];
     3285                                $inherit_bf = ($mode === 'template') ? $row["bbcode_bitfield"] : false;
    32283286                                $cfg_data['store_db'] = $row["{$mode}_storedb"];
    32293287                                $store_db = $row["{$mode}_storedb"];
     
    32343292                        $inherit_id = 0;
    32353293                        $inherit_path = '';
    3236                 }
    3237 
     3294                        $inherit_bf = false;
     3295                }
    32383296
    32393297                if (sizeof($error))
     
    32553313                                {
    32563314                                        $sql_ary['bbcode_bitfield'] = $cfg_data['template_bitfield'];
     3315                                }
     3316                                else if ($inherit_bf)
     3317                                {
     3318                                        $sql_ary['bbcode_bitfield'] = $inherit_bf;
    32573319                                }
    32583320                                else
     
    35023564                }
    35033565
    3504 
    35053566                $sql = "SELECT {$mode}_inherits_id
    35063567                        FROM $sql_from
Note: See TracChangeset for help on using the changeset viewer.