From 0f91ad7bf32f2eda483c71e058f995e4a9a3f151 Mon Sep 17 00:00:00 2001 From: Exile Date: Sun, 31 Aug 2014 02:54:38 +0400 Subject: [PATCH] Terms fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Переделка страницы с правилами под стандарты + отдельный кеш для конфига. --- install/sql/mysql.sql | 1 + upload/admin/admin_cron.php | 2 +- upload/admin/admin_terms.php | 33 +++--- upload/common.php | 2 - upload/config.php | 49 ++++---- upload/includes/functions.php | 5 +- upload/includes/init_bb.php | 38 +++--- upload/language/en/main.php | 3 +- upload/language/ru/main.php | 3 +- upload/language/uk/main.php | 3 +- upload/templates/admin/admin_cron.tpl | 143 +++++++++++------------ upload/templates/admin/admin_terms.tpl | 42 +++---- upload/templates/default/page_header.tpl | 4 +- upload/templates/default/terms.tpl | 27 +++-- upload/terms.php | 28 ++--- 15 files changed, 187 insertions(+), 196 deletions(-) diff --git a/install/sql/mysql.sql b/install/sql/mysql.sql index 2b2d15e73..08af7c232 100644 --- a/install/sql/mysql.sql +++ b/install/sql/mysql.sql @@ -581,6 +581,7 @@ INSERT INTO `bb_config` VALUES ('show_mod_index', '0'); INSERT INTO `bb_config` VALUES ('premod', '0'); INSERT INTO `bb_config` VALUES ('new_tpls', '1'); INSERT INTO `bb_config` VALUES ('tor_comment', '1'); +INSERT INTO `bb_config` VALUES ('terms', ''); -- -------------------------------------------------------- diff --git a/upload/admin/admin_cron.php b/upload/admin/admin_cron.php index fc168e67f..2f45987c6 100644 --- a/upload/admin/admin_cron.php +++ b/upload/admin/admin_cron.php @@ -38,7 +38,7 @@ foreach ($sql as $row) if (isset($_POST['submit']) && $row['config_value'] != $new[$config_name]) { - bb_update_config(array($config_name => $new[$config_name])); + bb_update_config(array($config_name => $new[$config_name])); } } diff --git a/upload/admin/admin_terms.php b/upload/admin/admin_terms.php index a7847e461..cb9437927 100644 --- a/upload/admin/admin_terms.php +++ b/upload/admin/admin_terms.php @@ -1,32 +1,25 @@ $_POST['message'])); -} +require(INC_DIR .'bbcode.php'); -$message = ''; -$sql = "SELECT config_value FROM " . BB_CONFIG . " WHERE config_name='" . TERMS_KEY . "'"; - -if ($result = DB()->sql_query($sql)) { - $row = DB()->sql_fetchrow($result); - $message = $row['config_value']; +if (isset($_POST['post']) && $bb_cfg['terms'] != $_POST['message']) +{ + bb_update_config(array('terms' => $_POST['message'])); + bb_die($lang['CONFIG_UPDATED']); } $template->assign_vars(array( - 'S_CONFIG_ACTION' => 'admin_terms.php', - 'CONFIG' => true, - 'MESSAGE' => $message, - 'EXT_LINK_NEW_WIN' => $bb_cfg['ext_link_new_win'], - 'PREVIEW_HTML' => (isset($_REQUEST['preview'])) ? bbcode2html($message) : '' - + 'S_ACTION' => 'admin_terms.php', + 'EXT_LINK_NW' => $bb_cfg['ext_link_new_win'], + 'MESSAGE' => ($bb_cfg['terms']) ? $bb_cfg['terms'] : '', + 'PREVIEW_HTML' => (isset($_REQUEST['preview'])) ? bbcode2html($_POST['message']) : '', )); print_page('admin_terms.tpl', 'admin'); \ No newline at end of file diff --git a/upload/common.php b/upload/common.php index 1967d5ffc..42ca82e41 100644 --- a/upload/common.php +++ b/upload/common.php @@ -48,8 +48,6 @@ define('TOR_TYPE_SILVER', 2); define('GUEST_UID', -1); define('BOT_UID', -746); -define('TERMS_KEY', 'terms'); - // DBS class DBS { diff --git a/upload/config.php b/upload/config.php index 648bc3088..904042443 100644 --- a/upload/config.php +++ b/upload/config.php @@ -72,8 +72,8 @@ $domain_name = (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : $do // Version info $bb_cfg['tp_version'] = '2.1 (RC)'; -$bb_cfg['tp_release_date'] = '30-08-2014'; -$bb_cfg['tp_release_state'] = 'R599'; +$bb_cfg['tp_release_date'] = '31-08-2014'; +$bb_cfg['tp_release_state'] = 'R599b'; // Database $charset = 'utf8'; @@ -88,18 +88,18 @@ $bb_cfg['db']['db1'] = array('localhost', 'dbase', 'user', 'pass', $charset, $pc $bb_cfg['db_alias'] = array( // 'alias' => 'srv_name' # db1 - 'log' => 'db1', // BB_LOG - 'search' => 'db1', // BB_TOPIC_SEARCH - 'sres' => 'db1', // BB_BT_USER_SETTINGS, BB_SEARCH_RESULTS - 'u_ses' => 'db1', // BB_USER_SES, BB_USER_LASTVISIT + 'log' => 'db1', // BB_LOG + 'search' => 'db1', // BB_TOPIC_SEARCH + 'sres' => 'db1', // BB_BT_USER_SETTINGS, BB_SEARCH_RESULTS + 'u_ses' => 'db1', // BB_USER_SES, BB_USER_LASTVISIT # db2 - 'dls' => 'db1', // BB_BT_DLS_* - 'ip' => 'db1', // BB_POSTS_IP - 'ut' => 'db1', // BB_TOPICS_USER_POSTED + 'dls' => 'db1', // BB_BT_DLS_* + 'ip' => 'db1', // BB_POSTS_IP + 'ut' => 'db1', // BB_TOPICS_USER_POSTED # db3 - 'cap' => 'db1', // BB_CAPTCHA - 'pm' => 'db1', // BB_PRIVMSGS, BB_PRIVMSGS_TEXT - 'pt' => 'db1', // BB_POSTS_TEXT + 'cap' => 'db1', // BB_CAPTCHA + 'pm' => 'db1', // BB_PRIVMSGS, BB_PRIVMSGS_TEXT + 'pt' => 'db1', // BB_POSTS_TEXT ); // Cache @@ -121,12 +121,13 @@ $bb_cfg['cache']['redis'] = array( // Available cache types: memcache, sqlite, redis, eaccelerator, apc, xcache (default of filecache) # name => array( (string) type, (array) cfg ) $bb_cfg['cache']['engines'] = array( - 'bb_cache' => array('filecache', array()), - 'tr_cache' => array('filecache', array()), - 'session_cache' => array('filecache', array()), - 'bb_cap_sid' => array('filecache', array()), - 'bb_login_err' => array('filecache', array()), - 'bb_poll_data' => array('filecache', array()), + 'bb_cache' => array('filecache', array()), + 'bb_config' => array('filecache', array()), + 'tr_cache' => array('filecache', array()), + 'session_cache' => array('filecache', array()), + 'bb_cap_sid' => array('filecache', array()), + 'bb_login_err' => array('filecache', array()), + 'bb_poll_data' => array('filecache', array()), ); // Datastore // Available datastore types: memcache, sqlite, redis, eaccelerator, apc, xcache (default filecache) @@ -148,8 +149,8 @@ $bb_cfg['js_ver'] = 1; $bb_cfg['css_ver'] = 1; // Backup -$bb_cfg['db_backup_shell_cmd'] = ''; // '/path/to/db_backup.sh 2>&1' -$bb_cfg['site_backup_shell_cmd'] = ''; +$bb_cfg['db_backup_shell_cmd'] = ''; // '/path/to/db_backup.sh 2>&1' +$bb_cfg['site_backup_shell_cmd'] = ''; // GZip $bb_cfg['gzip_compress'] = true; // compress output @@ -292,10 +293,10 @@ else } $bb_cfg['languages'] = array( -// 'folder' => 'Name', - 'ru' => 'Русский', - 'uk' => 'Український', - 'en' => 'English', +// 'folder' => 'Name', + 'ru' => 'Русский', + 'uk' => 'Український', + 'en' => 'English', ); // Templates diff --git a/upload/includes/functions.php b/upload/includes/functions.php index d6b7e5e25..bb7aaea27 100644 --- a/upload/includes/functions.php +++ b/upload/includes/functions.php @@ -1288,7 +1288,7 @@ function get_attachments_dir ($cfg = null) function bb_get_config ($table, $from_db = false, $update_cache = true) { - if ($from_db OR !$cfg = CACHE('bb_cache')->get("config_{$table}")) + if ($from_db OR !$cfg = CACHE('bb_config')->get("config_{$table}")) { $cfg = array(); foreach (DB()->fetch_rowset("SELECT * FROM $table") as $row) @@ -1297,7 +1297,7 @@ function bb_get_config ($table, $from_db = false, $update_cache = true) } if ($update_cache) { - CACHE('bb_cache')->set("config_{$table}", $cfg); + CACHE('bb_config')->set("config_{$table}", $cfg); } } return $cfg; @@ -1316,6 +1316,7 @@ function bb_update_config ($params, $table = BB_CONFIG) $updates = DB()->build_array('MULTI_INSERT', $updates); DB()->query("REPLACE INTO $table $updates"); + // Update cache bb_get_config($table, true, true); } diff --git a/upload/includes/init_bb.php b/upload/includes/init_bb.php index 38592736f..c022bd5a3 100644 --- a/upload/includes/init_bb.php +++ b/upload/includes/init_bb.php @@ -215,18 +215,18 @@ define('TOR_TMP', 10); // временная define('TOR_PREMOD', 11); // премодерация $bb_cfg['tor_icons'] = array( - TOR_NOT_APPROVED => '*', - TOR_CLOSED => 'x', - TOR_APPROVED => '', - TOR_NEED_EDIT => '?', - TOR_NO_DESC => '!', - TOR_DUP => 'D', - TOR_CLOSED_CPHOLD => '©', - TOR_CONSUMED => '', - TOR_DOUBTFUL => '#', - TOR_CHECKING => '%', - TOR_TMP => 'T', - TOR_PREMOD => '', + TOR_NOT_APPROVED => '*', + TOR_CLOSED => 'x', + TOR_APPROVED => '', + TOR_NEED_EDIT => '?', + TOR_NO_DESC => '!', + TOR_DUP => 'D', + TOR_CLOSED_CPHOLD => '©', + TOR_CONSUMED => '', + TOR_DOUBTFUL => '#', + TOR_CHECKING => '%', + TOR_TMP => 'T', + TOR_PREMOD => '', ); // Запрет на скачивание @@ -468,10 +468,8 @@ $html = new html_common(); $log_action = new log_action(); $ads = new ads_common(); -// !!! Temporarily (??) 'cat_forums' always enqueued -$datastore->enqueue(array( - 'cat_forums', -)); +// TODO temporarily 'cat_forums' always enqueued +$datastore->enqueue(array('cat_forums')); // Дата старта вашего проекта if (!$bb_cfg['board_startdate']) @@ -488,13 +486,13 @@ if ((empty($_POST) && !defined('IN_ADMIN') && !defined('IN_AJAX') && !file_exist // Update cron_last_check bb_update_config(array('cron_last_check' => (TIMENOW + 10))); - define('CRON_LOG_ENABLED', true); // global ON/OFF - define('CRON_FORCE_LOG', false); // always log regardless of job settings + define('CRON_LOG_ENABLED', true); // global ON/OFF + define('CRON_FORCE_LOG', false); // always log regardless of job settings define('CRON_DIR', INC_DIR .'cron/'); define('CRON_JOB_DIR', CRON_DIR .'jobs/'); - define('CRON_LOG_DIR', 'cron/'); // inside LOG_DIR - define('CRON_LOG_FILE', 'cron'); // without ext + define('CRON_LOG_DIR', 'cron/'); // inside LOG_DIR + define('CRON_LOG_FILE', 'cron'); // without ext bb_log(date('H:i:s - ') . getmypid() .' -x-- DB-LOCK try'. LOG_LF, CRON_LOG_DIR .'cron_check'); diff --git a/upload/language/en/main.php b/upload/language/en/main.php index 1cc156aed..23e870088 100644 --- a/upload/language/en/main.php +++ b/upload/language/en/main.php @@ -2879,4 +2879,5 @@ $lang['ATOM_NO_USER'] = 'This user does not have a feed (no ongoing topics)'; $lang['HASH_INVALID'] = 'Hash %s is invalid'; $lang['HASH_NOT_FOUND'] = 'Release with hash %s not found'; -$lang['TERMS_ADMIN_EMPTY_TEXT'] = '[align=center]The text of this page is edited at [url]http://%s/admin/admin_terms.php[/url][/align]'; \ No newline at end of file +$lang['TERMS_EMPTY_TEXT'] = '[align=center]The text of this page is edited at: [url=http://%s/admin/admin_terms.php]admin/admin_terms.php[/url]. This line can see only administrators.[/align]'; +$lang['TERMS_EXPLAIN'] = 'On this page, you can specify the text of the basic rules of the resource is displayed to users.'; \ No newline at end of file diff --git a/upload/language/ru/main.php b/upload/language/ru/main.php index 68a55fa13..a1d1a699f 100644 --- a/upload/language/ru/main.php +++ b/upload/language/ru/main.php @@ -2879,4 +2879,5 @@ $lang['ATOM_NO_USER'] = 'Для этого пользователя нет ле $lang['HASH_INVALID'] = 'Хэш %s некорректен'; $lang['HASH_NOT_FOUND'] = 'Раздача с хэшем %s не найдена'; -$lang['TERMS_ADMIN_EMPTY_TEXT'] = '[align=center]Текст этой страницы редактируется по адресу [url]http://%s/admin/admin_terms.php[/url][/align]'; \ No newline at end of file +$lang['TERMS_EMPTY_TEXT'] = '[align=center]Текст этой страницы редактируется по адресу: [url=http://%s/admin/admin_terms.php]admin/admin_terms.php[/url]. Эту строку видят только администраторы.[/align]'; +$lang['TERMS_EXPLAIN'] = 'На данной странице вы можете указать текст основных правил ресурса, выводящихся пользователям.'; \ No newline at end of file diff --git a/upload/language/uk/main.php b/upload/language/uk/main.php index 121aea388..705082b02 100644 --- a/upload/language/uk/main.php +++ b/upload/language/uk/main.php @@ -2879,4 +2879,5 @@ $lang['ATOM_NO_USER'] = 'Для цього користувача немає с $lang['HASH_INVALID'] = 'Хеш %s некоректний'; $lang['HASH_NOT_FOUND'] = 'Роздача з хешем %s не знайдено'; -$lang['TERMS_ADMIN_EMPTY_TEXT'] = '[align=center]Текст цієї сторінки редагується за адресою [url]http://%s/admin/admin_terms.php[/url][/align]'; \ No newline at end of file +$lang['TERMS_EMPTY_TEXT'] = '[align=center]Текст цієї сторінки редагується за адресою: [url=http://%s/admin/admin_terms.php]admin/admin_terms.php[/url]. Цю рядок бачать тільки адміністраторам.[/align]'; +$lang['TERMS_EXPLAIN'] = 'На цій сторінці ви можете вказати текст основних правил ресурсу, які виводяться користувачам.'; \ No newline at end of file diff --git a/upload/templates/admin/admin_cron.tpl b/upload/templates/admin/admin_cron.tpl index 856cc9661..fb6159715 100644 --- a/upload/templates/admin/admin_cron.tpl +++ b/upload/templates/admin/admin_cron.tpl @@ -1,11 +1,11 @@ @@ -24,60 +24,59 @@ tr.hl-tr:hover td { background-color: #CFC !important; } - - - - + + + +
-

{L_CRON}

- - {L_CRON_EDIT_HEAD_ADD} -
- - - - - - - - - -
{L_CRON_ENABLED} -    - - {L_CRON_CHECK_INTERVAL} - - - -
- - - - - -
-

{L_CRON_WORKS} {L_REPAIR_CRON}

-
- -
+

{L_CRON}

+ {L_CRON_EDIT_HEAD_ADD} +
+ + + + + + + + + +
{L_CRON_ENABLED} +    + + {L_CRON_CHECK_INTERVAL} + + + +
+ + + + + +
+

{L_CRON_WORKS} {L_REPAIR_CRON}

+
+ +

- + - - - - - - - - - - + + + + + + + + + + @@ -101,20 +100,20 @@ tr.hl-tr:hover td { background-color: #CFC !important; }
{L_CRON_LIST}{L_CRON_LIST}
{L_CRON_ID}{L_CRON_ACTIVE}{L_CRON_TITLE}{L_CRON_SCRIPT}{L_CRON_SCHEDULE}{L_CRON_LAST_RUN}{L_CRON_NEXT_RUN}{L_CRON_RUN_COUNT}{L_CRON_MANAGE}{L_CRON_ID}{L_CRON_ACTIVE}{L_CRON_TITLE}{L_CRON_SCRIPT}{L_CRON_SCHEDULE}{L_CRON_LAST_RUN}{L_CRON_NEXT_RUN}{L_CRON_RUN_COUNT}{L_CRON_MANAGE}
- - - + + +
- {L_WITH_SELECTED} - -   - -
+ {L_WITH_SELECTED} + +   + +

@@ -142,12 +141,12 @@ tr.hl-tr:hover td { background-color: #CFC !important; } -

{L_CRON_ACTIVE}

+

{L_CRON_ACTIVE}

{L_CRON_ACTIVE_EXPL}
-    - +    + @@ -189,7 +188,7 @@ tr.hl-tr:hover td { background-color: #CFC !important; }

{L_LOG_ENABLED}

-    +    @@ -200,14 +199,14 @@ tr.hl-tr:hover td { background-color: #CFC !important; }

{L_LOG_SQL_QUERIES}

-    +   

{L_FORUM_DISABLE}

{L_BOARD_DISABLE_EXPL}
-    +    diff --git a/upload/templates/admin/admin_terms.tpl b/upload/templates/admin/admin_terms.tpl index cc73c5edf..4da5dcd63 100644 --- a/upload/templates/admin/admin_terms.tpl +++ b/upload/templates/admin/admin_terms.tpl @@ -1,25 +1,25 @@ - - -
- - - - - class="hidden"> - - - - - -
{L_TERMS}
-
{PREVIEW_HTML}
-
- -
+

{L_TERMS}

+ +

{L_TERMS_EXPLAIN}

+
+ + + + + + + class="hidden"> + + + + + +
{L_TERMS}
+
{PREVIEW_HTML}
+
+ +

\ No newline at end of file diff --git a/upload/templates/default/page_header.tpl b/upload/templates/default/page_header.tpl index 52d8ef08d..eab1df04f 100644 --- a/upload/templates/default/page_header.tpl +++ b/upload/templates/default/page_header.tpl @@ -21,8 +21,8 @@ window.encURL = encodeURIComponent;