From 64c11c767699917ad426ad5e3ad03e6171a3e753 Mon Sep 17 00:00:00 2001 From: "gemini_13@torba.su" Date: Wed, 20 Feb 2013 02:00:24 +0000 Subject: [PATCH] r495 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ревизия для бета-тестеров. Её нельзя ставить еще на боевой трекер, дождитесь следующей с исправлением возможных багов. git-svn-id: https://torrentpier2.googlecode.com/svn/trunk@495 a8ac35ab-4ca4-ca47-4c2d-a49a94f06293 --- ReadMe.txt | 16 ++--- install/sql/mysql.sql | 2 +- upload/ajax.php | 35 ++++------ upload/ajax/edit_user_profile.php | 10 +-- upload/config.php | 6 +- upload/includes/cron/jobs/tr_maintenance.php | 2 +- upload/includes/datastore/build_stats.php | 6 +- upload/includes/functions.php | 2 +- upload/includes/ucp/usercp_register.php | 26 ++++--- upload/includes/ucp/usercp_viewdraft.php | 69 +++++++++++-------- upload/includes/ucp/usercp_viewprofile.php | 6 +- upload/language/lang_english/lang_main.php | 1 + upload/templates/default/usercp_viewdraft.tpl | 63 ++++++++++++----- upload/viewtopic.php | 4 +- 14 files changed, 142 insertions(+), 106 deletions(-) diff --git a/ReadMe.txt b/ReadMe.txt index a4d248427..79c741fdc 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -14,14 +14,7 @@ Устанавливаем права доступа на данные папки 777, на файлы внутри этих папок (кроме .htaccess) 666: - ajax -- ajax/html -- images -- images/avatars -- images/avatars/gallery -- images/captcha -- images/logo -- images/ranks -- images/smiles +- ajax/html - cache - cache/filecache - cache/filecache/bb_cache @@ -29,6 +22,13 @@ - cache/filecache/session_cache - files - files/thumbs +- images +- images/avatars +- images/avatars/gallery +- images/captcha +- images/logo +- images/ranks +- images/smiles - log - pictures - triggers diff --git a/install/sql/mysql.sql b/install/sql/mysql.sql index 0d9f5e2d0..d67a8e1dc 100644 --- a/install/sql/mysql.sql +++ b/install/sql/mysql.sql @@ -1443,7 +1443,7 @@ CREATE TABLE IF NOT EXISTS `bb_users` ( `user_avatar` varchar(100) NOT NULL DEFAULT '', `user_avatar_type` tinyint(4) NOT NULL DEFAULT '0', `user_gender` tinyint(1) NOT NULL DEFAULT '0', - `user_birthday` int(11) NOT NULL DEFAULT '0', + `user_birthday` date DEFAULT NULL, `user_next_birthday_greeting` int(11) NOT NULL DEFAULT '0', `user_email` varchar(255) NOT NULL DEFAULT '', `user_skype` varchar(32) NOT NULL DEFAULT '', diff --git a/upload/ajax.php b/upload/ajax.php index adb10d1ed..e60608b3d 100644 --- a/upload/ajax.php +++ b/upload/ajax.php @@ -526,33 +526,26 @@ class ajax_common function modify_draft() { - global $userdata; - - //if($bb_cfg['status_of_draft'] || !$bb_cfg['status_of_draft']) $this->ajax_die('Профилактика !!!'); - - $tid = (int) $this->request['id_draft']; - $mode = (int) $this->request['mode']; - - $row = DB()->fetch_row("SELECT * FROM " . BB_TOPICS . " WHERE topic_id = {$tid}"); + global $userdata, $bb_cfg, $lang; - if(!$row) $this->ajax_die('Нет такого черновика'); + if(!$bb_cfg['status_of_draft']) $this->ajax_die($lang['MODULE_OFF']); - if($row['topic_poster'] != $userdata['user_id'] && !IS_ADMIN) + $tid = (int)$this->request["id_draft"]; + $mode = (int)$this->request["mode"]; + $sql = "SELECT * FROM ". BB_TOPICS ." WHERE topic_id = {$tid}"; + + if (!$row = DB()->fetch_row($sql)) $this->ajax_die("Нет такого черновика"); + + if ($row["topic_poster"] != $userdata["user_id"] && !IS_ADMIN) $this->ajax_die("Нельзя удалять чужие черновики"); + + if (!$mode) { - $this->ajax_die('Нельзя удалять чужие черновики'); + DB()->query("DELETE FROM ". BB_TOPICS ." WHERE topic_id = {$tid} LIMIT 1"); } - - print_r($mode); - - if(!$mode) - { - DB()->query("DELETE FROM ". BB_TOPICS ." WHERE topic_id = {$tid}"); - } - else + else { DB()->query("UPDATE ". BB_TOPICS ." SET is_draft = 0 WHERE topic_id = {$tid}"); } - - $this->response['tid'] = $tid; + $this->response["tid"] = $tid; } } diff --git a/upload/ajax/edit_user_profile.php b/upload/ajax/edit_user_profile.php index 9c29e680a..f95230c49 100644 --- a/upload/ajax/edit_user_profile.php +++ b/upload/ajax/edit_user_profile.php @@ -58,9 +58,9 @@ switch ($field) case 'user_birthday': if(!$bb_cfg['birthday_enabled']) $this->ajax_die($lang['MODULE_OFF']); $data = explode('-', $value); - $b_day = (isset($data[2])) ? (int) $data[2] : 0; - $b_md = (isset($data[1])) ? (int) $data[1] : 0; - $b_year = (isset($data[0])) ? (int) $data[0] : 0; + $b_day = (isset($data[2])) ? (int) $data[2] : ''; + $b_md = (isset($data[1])) ? (int) $data[1] : ''; + $b_year = (isset($data[0])) ? (int) $data[0] : ''; if($b_day || $b_md || $b_year) { @@ -78,13 +78,13 @@ switch ($field) } else { - $value = mkrealdate($b_day, $b_md, $b_year); + $value = "$b_year-$b_md-$b_day"; $next_birthday_greeting = (date('md') < $b_md . (($b_day <= 9) ? '0' : '') . $b_day) ? date('Y') : date('Y')+1; } } else { - $value = 0; + $value = ''; $next_birthday_greeting = 0; } DB()->query("UPDATE $table SET user_next_birthday_greeting = $next_birthday_greeting WHERE user_id = $user_id LIMIT 1"); diff --git a/upload/config.php b/upload/config.php index ed7d6be1a..b16adaa37 100644 --- a/upload/config.php +++ b/upload/config.php @@ -56,8 +56,8 @@ $domain_name = (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : $do // Increase number of revision after update $bb_cfg['tp_version'] = '2.5 pre-stable'; -$bb_cfg['tp_release_date'] = '23-01-2013'; -$bb_cfg['tp_release_state'] = 'R493'; +$bb_cfg['tp_release_date'] = '20-02-2013'; +$bb_cfg['tp_release_state'] = 'R495'; // Database $charset = 'utf8'; @@ -531,4 +531,4 @@ $bb_cfg['captcha'] = array( $bb_cfg['seo_link_home_page'] = false; // Status of draft -$bb_cfg['status_of_draft'] = true; \ No newline at end of file +$bb_cfg['status_of_draft'] = false; \ No newline at end of file diff --git a/upload/includes/cron/jobs/tr_maintenance.php b/upload/includes/cron/jobs/tr_maintenance.php index 0703035cd..430e3d495 100644 --- a/upload/includes/cron/jobs/tr_maintenance.php +++ b/upload/includes/cron/jobs/tr_maintenance.php @@ -2,7 +2,7 @@ if (!defined('BB_ROOT')) die(basename(__FILE__)); -if ($bb_cfg['seeder_last_seen_days_keep'] == 0 || $bb_cfg['seeder_never_seen_days_keep'] == 0) +if (empty($bb_cfg['seeder_last_seen_days_keep']) || empty($bb_cfg['seeder_never_seen_days_keep'])) { return; } diff --git a/upload/includes/datastore/build_stats.php b/upload/includes/datastore/build_stats.php index 7838866bf..b2b5d0149 100644 --- a/upload/includes/datastore/build_stats.php +++ b/upload/includes/datastore/build_stats.php @@ -52,7 +52,7 @@ if ($bb_cfg['gender']) // birthday stat if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled']) { - $sql = DB()->fetch_rowset("SELECT user_id, username, user_birthday, user_rank FROM ". BB_USERS ." WHERE user_id NOT IN(". EXCLUDED_USERS_CSV .") AND user_birthday != 0 ORDER BY user_level DESC, username"); + $sql = DB()->fetch_rowset("SELECT user_id, username, user_birthday, user_rank FROM ". BB_USERS ." WHERE user_id NOT IN(". EXCLUDED_USERS_CSV .") AND user_birthday IS NOT NULL ORDER BY user_level DESC, username"); $this_year = bb_date(TIMENOW, 'Y', 'false'); $date_today = bb_date(TIMENOW, 'Ymd', 'false'); $date_forward = bb_date(TIMENOW + ($bb_cfg['birthday_check_day']*86400), 'Ymd', 'false'); @@ -61,7 +61,7 @@ if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled']) foreach ($sql as $row) { - $user_birthday = realdate($row['user_birthday'], 'md'); + $user_birthday = date('md', strtotime($row['user_birthday'])); $user_birthday2 = $this_year . $user_birthday; if ($user_birthday2 < $date_today) $user_birthday2 += 10000; @@ -92,4 +92,4 @@ if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled']) $data['birthday_week_list'] = $birthday_week_list; } -$this->store('stats', $data); +$this->store('stats', $data); \ No newline at end of file diff --git a/upload/includes/functions.php b/upload/includes/functions.php index 6674d3608..590bebd33 100644 --- a/upload/includes/functions.php +++ b/upload/includes/functions.php @@ -1713,7 +1713,7 @@ function realdate($date, $format = "Ymd") function birthday_age($date, $list = 0) { if(!$date) return; - return delta_time(mktime(11, 0, 0, realdate($date, 'm'), realdate($date, 'd'), (realdate($date, 'Y') - $list))); + return delta_time(mktime(11, 0, 0, date('m', strtotime($date)), date('d', strtotime($date)), (date('Y', strtotime($date)) - $list))); } // diff --git a/upload/includes/ucp/usercp_register.php b/upload/includes/ucp/usercp_register.php index 523c08030..1be0074ec 100644 --- a/upload/includes/ucp/usercp_register.php +++ b/upload/includes/ucp/usercp_register.php @@ -227,8 +227,10 @@ foreach ($profile_fields as $field => $can_edit) $errors[] = $err; } if($can_edit && $username != $pr_data['username'] || $mode == 'register') - { $pr_data['username'] = $username; - $db_data['username'] = $username; } + { + $pr_data['username'] = $username; + $db_data['username'] = $username; + } } $tp_data['CAN_EDIT_USERNAME'] = $can_edit; $tp_data['USERNAME'] = $pr_data['username']; @@ -358,35 +360,39 @@ foreach ($profile_fields as $field => $can_edit) break; /** - * Возраст (edit, reg) + * Возраст (edit) */ case 'user_birthday': - $b_day = (isset($_POST['b_day'])) ? (int) $_POST['b_day'] : realdate($pr_data['user_birthday'], 'j'); - $b_md = (isset($_POST['b_md'])) ? (int) $_POST['b_md'] : realdate($pr_data['user_birthday'], 'n'); - $b_year = (isset($_POST['b_year'])) ? (int) $_POST['b_year'] : realdate($pr_data['user_birthday'], 'Y'); + $user_birthday = ($pr_data['user_birthday'] != '0000-00-00') ? strtotime($pr_data['user_birthday']) : false; + + $b_day = (isset($_POST['b_day'])) ? (int) $_POST['b_day'] : (($user_birthday) ? date('j', $user_birthday) : 0); + $b_md = (isset($_POST['b_md'])) ? (int) $_POST['b_md'] : (($user_birthday) ? date('n', $user_birthday) : 0); + $b_year = (isset($_POST['b_year'])) ? (int) $_POST['b_year'] : (($user_birthday) ? date('Y', $user_birthday) : 0); if ($b_day || $b_md || $b_year) { if (!checkdate($b_md, $b_day, $b_year)) { $errors[] = $lang['WRONG_BIRTHDAY_FORMAT']; - $birthday = $next_birthday_greeting = 0; + $birthday = ''; + $next_birthday_greeting = 0; } else { - $birthday = mkrealdate($b_day, $b_md, $b_year); + $birthday = "$b_year-$b_md-$b_day"; $next_birthday_greeting = (date('md') < $b_md . (($b_day <= 9) ? '0' : '') . $b_day) ? date('Y') : date('Y')+1; } } else { - $birthday = $next_birthday_greeting = 0; + $birthday = ''; + $next_birthday_greeting = 0; } if ($submit && $birthday != $pr_data['user_birthday']) { $pr_data['user_birthday'] = $birthday; - $db_data['user_birthday'] = (int) $birthday; + $db_data['user_birthday'] = $birthday; $db_data['user_next_birthday_greeting'] = $next_birthday_greeting; } break; diff --git a/upload/includes/ucp/usercp_viewdraft.php b/upload/includes/ucp/usercp_viewdraft.php index f92902f0f..ffe3fb9d3 100644 --- a/upload/includes/ucp/usercp_viewdraft.php +++ b/upload/includes/ucp/usercp_viewdraft.php @@ -2,43 +2,54 @@ if (!defined('BB_ROOT')) die(basename(__FILE__)); -if (empty($_GET[POST_USERS_URL]) || $_GET[POST_USERS_URL] == ANONYMOUS) +if (empty($_GET[POST_USERS_URL]) || $_GET[POST_USERS_URL] == ANONYMOUS) bb_die($lang['NO_USER_ID_SPECIFIED']); + +if (!$profiledata = get_userdata($_GET[POST_USERS_URL])) bb_die($lang['NO_USER_ID_SPECIFIED']); + +if (!$userdata['session_logged_in']) redirect("login.php?redirect={$_SERVER['REQUEST_URI']}"); + +if ($profiledata["user_id"] != $userdata["user_id"] && !IS_ADMIN) bb_die("Ты ноги мыла, Дездемона? :)"); + +$sql = " + SELECT t.*, f.forum_name, f.cat_id, f.forum_parent AS parent_id, f2.forum_name AS parent_name, c.cat_title + FROM ". BB_TOPICS." t + LEFT JOIN ". BB_FORUMS." f ON (f.forum_id = t.forum_id) + LEFT JOIN ". BB_CATEGORIES." c ON (f.cat_id = c.cat_id) + LEFT JOIN ". BB_FORUMS." f2 ON (f.forum_parent = f2.forum_id) + WHERE t.topic_poster = ". $profiledata["user_id"] ." + AND t.is_draft = 1 +"; + +if(!$rows = DB()->fetch_rowset($sql)) { - bb_die($lang['NO_USER_ID_SPECIFIED']); + bb_die('Список черновиков пуст

'. $lang['RETURN_PROFILE'] .'

'. sprintf($lang['CLICK_RETURN_INDEX'], '', '')); } -if (!$profiledata = get_userdata($_GET[POST_USERS_URL])) -{ - bb_die($lang['NO_USER_ID_SPECIFIED']); -} - -if (!$userdata['session_logged_in']) -{ - redirect("login.php?redirect={$_SERVER['REQUEST_URI']}"); -} - -if($profiledata["user_id"] != $userdata["user_id"] && !IS_ADMIN) { - bb_die("Нельзя смотреть чужие черновики"); -} - -$sql = "SELECT * FROM ". BB_TOPICS." WHERE topic_poster = ".$profiledata["user_id"]." AND is_draft = 1"; - -$rows = DB()->fetch_rowset($sql); $i = 0; -foreach ($rows as $row) { - $template->assign_block_vars("DRAFT", array( - "ROW_CLASS" => ($i % 2) ? 2 : 1, - "TITLE" => $row["topic_title"], - "T_ID" => $row["topic_id"], - "DT_CREATE" => date("d-m-Y (H:i:s)", $row["topic_time"]), - "POST_FIRST_ID" => $row["topic_first_post_id"] - )); +foreach ($rows as $row) +{ + $category = ''. $row["cat_title"] .''; + $forum = ''. $row["forum_name"] .''; + $topic = ''. $row["topic_title"] .''; + if($row["parent_id"] != 0) $forum .= ' » '. $row["parent_name"] .''; + + $template->assign_block_vars("DRAFT", array( + "ROW_CLASS" => ($i % 2) ? 2 : 1, + "TOPIC_ID" => $row["topic_id"], + "TOPIC" => $topic, + 'FORUM' => $forum, + "CATEGORY" => $category, + "DT_CREATE" => bb_date($row["topic_time"], "Y-m-d H:i"), + "EDIT_POST" => make_url('posting.php?mode=editpost&p='. $row["topic_first_post_id"]) + )); $i++; } $template->assign_vars(array( - "USERNAME" => $profiledata["username"] + "PAGE_TITLE" => $lang["DRAFTS"], + "USERNAME" => $profiledata["username"], + "PROFILE" => profile_url(array('username' => $profiledata["username"], 'user_id' => $profiledata["user_id"])), )); -print_page('usercp_viewdraft.tpl'); +print_page('usercp_viewdraft.tpl'); \ No newline at end of file diff --git a/upload/includes/ucp/usercp_viewprofile.php b/upload/includes/ucp/usercp_viewprofile.php index ed4130fb9..adf887fe3 100644 --- a/upload/includes/ucp/usercp_viewprofile.php +++ b/upload/includes/ucp/usercp_viewprofile.php @@ -125,8 +125,8 @@ $template->assign_vars(array( 'SKYPE' => $profiledata['user_skype'], 'USER_POINTS' => $profiledata['user_points'], 'GENDER' => ($bb_cfg['gender'] && $profiledata['user_gender']) ? $lang['GENDER_SELECT'][$profiledata['user_gender']] : '', - 'BIRTHDAY' => ($bb_cfg['birthday_enabled'] && $profiledata['user_birthday']) ? realdate($profiledata['user_birthday'], 'Y-m-d') : '', - 'AGE' => ($bb_cfg['birthday_enabled'] && $profiledata['user_birthday']) ? birthday_age($profiledata['user_birthday']) : '', + 'BIRTHDAY' => ($bb_cfg['birthday_enabled'] && $profiledata['user_birthday'] != '0000-00-00') ? date('Y-m-d', strtotime($profiledata['user_birthday'])) : '', + 'AGE' => ($bb_cfg['birthday_enabled'] && $profiledata['user_birthday'] != '0000-00-00') ? birthday_age($profiledata['user_birthday']) : '', 'AVATAR_IMG' => get_avatar($profiledata['user_avatar'], $profiledata['user_avatar_type'], !bf($profiledata['user_opt'], 'user_opt', 'allow_avatar')), 'L_VIEWING_PROFILE' => sprintf($lang['VIEWING_USER_PROFILE'], $profiledata['username']), @@ -255,4 +255,4 @@ if (bf($profiledata['user_opt'], 'user_opt', 'allow_topic')) $user_restricti $template->assign_var('USER_RESTRICTIONS', join('
  • ', $user_restrictions)); -print_page('usercp_viewprofile.tpl'); +print_page('usercp_viewprofile.tpl'); \ No newline at end of file diff --git a/upload/language/lang_english/lang_main.php b/upload/language/lang_english/lang_main.php index 35b2d6d15..0a7410e9e 100644 --- a/upload/language/lang_english/lang_main.php +++ b/upload/language/lang_english/lang_main.php @@ -566,6 +566,7 @@ $lang['GENDER_SELECT'] = array( 1 => 'Male', 2 => 'Female' ); +$lang['MODULE_OFF'] = 'Module is disabled!'; $lang['BIRTHDAY'] = 'Birthday'; $lang['HAPPY_BIRTHDAY'] = 'Happy Birthday!'; diff --git a/upload/templates/default/usercp_viewdraft.tpl b/upload/templates/default/usercp_viewdraft.tpl index 8eebf66ea..fb062c8f5 100644 --- a/upload/templates/default/usercp_viewdraft.tpl +++ b/upload/templates/default/usercp_viewdraft.tpl @@ -3,9 +3,9 @@ var _mode = (!mode) ? 0 : 1; ajax.exec({ - action:"modify_draft", - id_draft:tid, - mode:_mode + action : "modify_draft", + id_draft : tid, + mode : _mode }); }; @@ -14,26 +14,51 @@ }; +

    {PAGE_TITLE}

    + + + + + + + + + + + + - - - - - - - - - - + + + + - - - + + + -
    {L_CATEGORY}{L_FORUM}{L_TOPIC}{L_DATE}{L_ACTION}
    Черновики пользователя {USERNAME}
    Название темыДата созданияМодифицировать
    {DRAFT.TITLE}
    {DRAFT.CATEGORY}{DRAFT.FORUM}{DRAFT.TOPIC} {DRAFT.DT_CREATE}Редактировать - УдалитьПубликовать{L_EDIT}{L_DELETE}Публиковать
    \ No newline at end of file + + +   + + + + +
    + +
    +
    +

    {LAST_VISIT_DATE}

    +

    {CURRENT_TIME}

    +

    {S_TIMEZONE}

    +
    +
    +
    \ No newline at end of file diff --git a/upload/viewtopic.php b/upload/viewtopic.php index 04a5cc32c..e2c59ab74 100644 --- a/upload/viewtopic.php +++ b/upload/viewtopic.php @@ -818,7 +818,7 @@ for($i = 0; $i < $total_posts; $i++) $poster_id = $postrow[$i]['user_id']; $poster = ( $poster_id == ANONYMOUS ) ? $lang['GUEST'] : $postrow[$i]['username']; - $poster_birthday = ($postrow[$i]['user_id'] != ANONYMOUS) ? realdate($postrow[$i]['user_birthday'], 'md') : 0; + $poster_birthday = ($postrow[$i]['user_id'] != ANONYMOUS) ? date('md', strtotime($postrow[$i]['user_birthday'])) : ''; $post_date = bb_date($postrow[$i]['post_time'], $bb_cfg['post_date_format']); $max_post_time = max($max_post_time, $postrow[$i]['post_time']); @@ -1109,4 +1109,4 @@ if (IS_ADMIN) )); } -print_page('viewtopic.tpl'); +print_page('viewtopic.tpl'); \ No newline at end of file