git-svn-id: https://torrentpier2.googlecode.com/svn/trunk@276 a8ac35ab-4ca4-ca47-4c2d-a49a94f06293
This commit is contained in:
nanosimbiot 2011-09-02 04:27:02 +00:00
commit 8aae1582af
4 changed files with 272 additions and 103 deletions

View file

@ -11,77 +11,176 @@ require('./pagestart.php');
require(LANG_DIR .'lang_admin_bt.php'); require(LANG_DIR .'lang_admin_bt.php');
$forums = DB()->fetch_rowset(" $mode = (string) request_var('mode', '');
SELECT f.forum_id, f.forum_parent, f.topic_tpl_id, f.forum_name
FROM ". BB_CATEGORIES ." c, ". BB_FORUMS ." f
WHERE f.cat_id = c.cat_id
ORDER BY c.cat_order, f.forum_order
");
$tpl_ary = array(); if ($mode == 'templates')
$available_tpl_id = array(0);
$tpl_select = array($lang['TPL_NONE'] => 0);
$sql = "SELECT * FROM ". BB_TOPIC_TPL ." ORDER BY tpl_name";
foreach (DB()->fetch_rowset($sql) as $row)
{ {
$tpl_ary[$row['tpl_id']] = $row; $sql = "SELECT * FROM ". BB_TOPIC_TPL ." ORDER BY tpl_name";
$available_tpl_id[] = $row['tpl_id'];
$name = isset($lang[strtoupper('TPL_'. $row['tpl_name'])]) ? $lang[strtoupper('TPL_'. $row['tpl_name'])] : $row['tpl_desc']; foreach (DB()->fetch_rowset($sql) as $i => $row)
$tpl_select[$name] = $row['tpl_id'];
}
if (isset($_POST['submit']) && @is_array($_POST['forum_tpl']))
{
$cur_val = $new_val = array();
foreach ($forums as $forum)
{ {
$cur_val["{$forum['forum_id']}"] = (int) $forum['topic_tpl_id']; $template->assign_block_vars('tpl', array(
} 'ROW_CLASS' => !($i % 2) ? 'row4' : 'row5',
foreach ($_POST['forum_tpl'] as $forum_id => $tpl_id) 'ID' => $row['tpl_id'],
{ 'NAME' => $row['tpl_name'],
if (isset($cur_val["$forum_id"]) && in_array($tpl_id, $available_tpl_id)) ));
{
$new_val["$forum_id"] = (int) $tpl_id;
}
}
if ($new_settings = array_diff_assoc($new_val, $cur_val))
{
foreach ($new_settings as $forum_id => $tpl_id)
{
DB()->query("
UPDATE ". BB_FORUMS ." SET
topic_tpl_id = ". (int) $tpl_id ."
WHERE forum_id = ". (int) $forum_id ."
");
}
} }
$message = $lang['CONFIG_UPD'] .'<br /><br />'; $template->assign_vars(array(
$message .= sprintf($lang['RETURN_CONFIG'], '<a href="'. append_sid("admin_topic_templates.php") .'">', '</a>') .'<br /><br />'; 'TPL_LIST' => true,
$message .= sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="'. append_sid("index.php?pane=right") .'">', '</a>'); 'S_ACTION' => append_sid("admin_topic_templates.php?mode=delete"),
message_die(GENERAL_MESSAGE, $message);
}
foreach ($forums as $i => $forum)
{
$template->assign_block_vars('forum', array(
'ROW_CLASS' => !($i % 2) ? 'row4' : 'row5',
'SF_PAD' => ($forum['forum_parent']) ? 'padding-left: 20px;' : '',
'TPL_SELECT' => build_select("forum_tpl[{$forum['forum_id']}]", $tpl_select, $forum['topic_tpl_id']),
'FORUM_CLASS' => ($forum['forum_parent']) ? 'gen' : 'gen',
'FORUM_STYLE' => ($forum['topic_tpl_id']) ? 'font-weight: bold;' : '',
'FORUM_ID' => $forum['forum_id'],
'FORUM_NAME' => htmlCHR($forum['forum_name']),
)); ));
} }
else if ($mode == 'add' || $mode == 'edit')
{ $template->assign_vars(array(
'TPL' => true,
));
$template->assign_vars(array( if($mode == 'edit')
'S_ACTION' => append_sid("admin_topic_templates.php"), { $tpl_id = (int) request_var('tpl', '');
)); if(!$tpl_id) bb_die('');
$row = DB()->fetch_row("SELECT * FROM ". BB_TOPIC_TPL ." WHERE tpl_id = $tpl_id");
if(!$row) bb_die('');
$template->assign_vars(array(
'S_ACTION' => append_sid("admin_topic_templates.php?mode=edit&tpl=$tpl_id"),
));
}
else
{ $template->assign_vars(array(
'S_ACTION' => append_sid("admin_topic_templates.php?mode=add"),
)); }
$tpl_name = isset($_POST['tpl_name']) ? $_POST['tpl_name'] : @$row['tpl_name'];
$tpl_script = isset($_POST['tpl_script']) ? $_POST['tpl_script'] : @$row['tpl_script'];
$tpl_template = isset($_POST['tpl_template']) ? $_POST['tpl_template'] : @$row['tpl_template'];
$tpl_desc = isset($_POST['tpl_desc']) ? $_POST['tpl_desc'] : @$row['tpl_desc'];
$template->assign_vars(array(
'NAME' => $tpl_name,
'SCRIPT' => $tpl_script,
'TEMP' => $tpl_template,
'DESC' => $tpl_desc,
));
if(isset($_POST['submit']))
{
if($mode == 'edit')
{ DB()->query("UPDATE ". BB_TOPIC_TPL ." SET
tpl_name = '". DB()->escape($tpl_name) ."',
tpl_script = '". DB()->escape($tpl_script) ."',
tpl_template = '". DB()->escape($tpl_template) ."',
tpl_desc = '". DB()->escape($tpl_desc) ."'
WHERE tpl_id = $tpl_id
");
$message = 'изменено'; }
else
{ DB()->query("INSERT INTO ". BB_TOPIC_TPL ." (tpl_name, tpl_script, tpl_template, tpl_desc)
VALUES ('". DB()->escape($tpl_name) ."', '". DB()->escape($tpl_script) ."', '". DB()->escape($tpl_template) ."', '". DB()->escape($tpl_desc) ."')");
$message = 'добавлено'; }
bb_die($message);
}
}
else if ($mode == 'delete')
{ $tpl_ids = isset($_POST['tpl_id']) ? $_POST['tpl_id'] : bb_die('вы ничего не выбрали');
foreach ($tpl_ids as $tpl_id)
{
$hidden_fields['tpl_id'][] = $tpl_id;
}
if (isset($_POST['confirm']))
{
DB()->query("DELETE ". BB_TOPIC_TPL ." WHERE tpl_id IN(". join(',', $tpl_ids) .")");
bb_die('Удалено');
}
else
{
$names = DB()->fetch_rowset("SELECT tpl_name FROM ". BB_TOPIC_TPL ." WHERE tpl_id IN(". join(',', $tpl_ids) .") ORDER BY tpl_name", 'tpl_name');
print_confirmation(array(
'QUESTION' => 'Вы уверены, что хотите удалить?',
'ITEMS_LIST' => join("\n</li>\n<li>\n", $names),
'FORM_ACTION' => "admin_topic_templates.php?mode=delete",
'HIDDEN_FIELDS' => build_hidden_fields($hidden_fields),
));
} }
else
{
$forums = DB()->fetch_rowset("
SELECT f.forum_id, f.forum_parent, f.topic_tpl_id, f.forum_name
FROM ". BB_CATEGORIES ." c, ". BB_FORUMS ." f
WHERE f.cat_id = c.cat_id
ORDER BY c.cat_order, f.forum_order
");
$tpl_ary = array();
$available_tpl_id = array(0);
$tpl_select = array($lang['TPL_NONE'] => 0);
$sql = "SELECT * FROM ". BB_TOPIC_TPL ." ORDER BY tpl_name";
foreach (DB()->fetch_rowset($sql) as $row)
{
$tpl_ary[$row['tpl_id']] = $row;
$available_tpl_id[] = $row['tpl_id'];
$name = isset($lang[strtoupper('TPL_'. $row['tpl_name'])]) ? $lang[strtoupper('TPL_'. $row['tpl_name'])] : $row['tpl_desc'];
$tpl_select[$name] = $row['tpl_id'];
}
if (isset($_POST['submit']) && @is_array($_POST['forum_tpl']))
{
$cur_val = $new_val = array();
foreach ($forums as $forum)
{
$cur_val["{$forum['forum_id']}"] = (int) $forum['topic_tpl_id'];
}
foreach ($_POST['forum_tpl'] as $forum_id => $tpl_id)
{
if (isset($cur_val["$forum_id"]) && in_array($tpl_id, $available_tpl_id))
{
$new_val["$forum_id"] = (int) $tpl_id;
}
}
if ($new_settings = array_diff_assoc($new_val, $cur_val))
{
foreach ($new_settings as $forum_id => $tpl_id)
{
DB()->query("
UPDATE ". BB_FORUMS ." SET
topic_tpl_id = ". (int) $tpl_id ."
WHERE forum_id = ". (int) $forum_id ."
");
}
}
$message = $lang['CONFIG_UPD'] .'<br /><br />';
$message .= sprintf($lang['RETURN_CONFIG'], '<a href="'. append_sid("admin_topic_templates.php") .'">', '</a>') .'<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="'. append_sid("index.php?pane=right") .'">', '</a>');
message_die(GENERAL_MESSAGE, $message);
}
foreach ($forums as $i => $forum)
{
$template->assign_block_vars('forum', array(
'ROW_CLASS' => !($i % 2) ? 'row4' : 'row5',
'SF_PAD' => ($forum['forum_parent']) ? 'padding-left: 20px;' : '',
'TPL_SELECT' => build_select("forum_tpl[{$forum['forum_id']}]", $tpl_select, $forum['topic_tpl_id']),
'FORUM_CLASS' => ($forum['forum_parent']) ? 'gen' : 'gen',
'FORUM_STYLE' => ($forum['topic_tpl_id']) ? 'font-weight: bold;' : '',
'FORUM_ID' => $forum['forum_id'],
'FORUM_NAME' => htmlCHR($forum['forum_name']),
));
}
$template->assign_vars(array(
'FORUM_LIST' => true,
'S_ACTION' => append_sid("admin_topic_templates.php"),
));
}
print_page('admin_topic_templates.tpl', 'admin'); print_page('admin_topic_templates.tpl', 'admin');

View file

@ -343,7 +343,6 @@ define('BB_CATEGORIES', 'bb_categories');
define('BB_CAPTCHA', 'bb_captcha'); define('BB_CAPTCHA', 'bb_captcha');
define('BB_CONFIG', 'bb_config'); define('BB_CONFIG', 'bb_config');
define('BB_CRON', 'bb_cron'); define('BB_CRON', 'bb_cron');
define('BB_DATASTORE', 'bb_datastore');
define('BB_DISALLOW', 'bb_disallow'); define('BB_DISALLOW', 'bb_disallow');
define('BB_EXTENSION_GROUPS', 'bb_extension_groups'); define('BB_EXTENSION_GROUPS', 'bb_extension_groups');
define('BB_EXTENSIONS', 'bb_extensions'); define('BB_EXTENSIONS', 'bb_extensions');
@ -359,7 +358,7 @@ define('BB_PRIVMSGS_TEXT', 'bb_privmsgs_text');
define('BB_QUOTA_LIMITS', 'bb_quota_limits'); define('BB_QUOTA_LIMITS', 'bb_quota_limits');
define('BB_QUOTA', 'bb_attach_quota'); define('BB_QUOTA', 'bb_attach_quota');
define('BB_RANKS', 'bb_ranks'); define('BB_RANKS', 'bb_ranks');
define('BB_REPORTS', 'bb_reports'); // Report define('BB_REPORTS', 'bb_reports'); // Report
define('BB_REPORTS_CHANGES', 'bb_reports_changes'); // Report Change's define('BB_REPORTS_CHANGES', 'bb_reports_changes'); // Report Change's
define('BB_REPORTS_MODULES', 'bb_reports_modules'); // Report Module Table define('BB_REPORTS_MODULES', 'bb_reports_modules'); // Report Module Table
define('BB_REPORTS_REASONS', 'bb_reports_reasons'); // Report Reasons define('BB_REPORTS_REASONS', 'bb_reports_reasons'); // Report Reasons
@ -548,9 +547,7 @@ $datastore->enqueue(array(
if(!$bb_cfg['board_startdate']) if(!$bb_cfg['board_startdate'])
{ {
bb_update_config(array('board_startdate' => TIMENOW)); bb_update_config(array('board_startdate' => TIMENOW));
DB()->query("UPDATE ". BB_USERS ." SET user_regdate = ". TIMENOW ." WHERE user_id = -1"); DB()->query("UPDATE ". BB_USERS ." SET user_regdate = ". TIMENOW ." WHERE user_id IN(2, ". EXCLUDED_USERS_CSV);
DB()->query("UPDATE ". BB_USERS ." SET user_regdate = ". TIMENOW ." WHERE user_id = 2");
DB()->query("UPDATE ". BB_USERS ." SET user_regdate = ". TIMENOW ." WHERE user_id = -746");
} }
// Cron // Cron

View file

@ -21,13 +21,12 @@ if(bf($profiledata['user_opt'], 'user_opt', 'view_profile') && IS_GUEST)
{ meta_refresh(append_sid("login.php?redirect={$_SERVER['REQUEST_URI']}", true)); { meta_refresh(append_sid("login.php?redirect={$_SERVER['REQUEST_URI']}", true));
bb_die("<b>{$profiledata['username']}</b> " . $lang['FORBADE_VIEWING']); } bb_die("<b>{$profiledata['username']}</b> " . $lang['FORBADE_VIEWING']); }
$avatar_img = get_avatar($profiledata['user_avatar'], $profiledata['user_avatar_type'], !bf($profiledata['user_opt'], 'user_opt', 'allow_avatar'));
if (!$ranks = $datastore->get('ranks')) if (!$ranks = $datastore->get('ranks'))
{ {
$datastore->update('ranks'); $datastore->update('ranks');
$ranks = $datastore->get('ranks'); $ranks = $datastore->get('ranks');
} }
$poster_rank = $rank_image = $rank_select = ''; $poster_rank = $rank_image = $rank_select = '';
if ($user_rank = $profiledata['user_rank'] AND isset($ranks[$user_rank])) if ($user_rank = $profiledata['user_rank'] AND isset($ranks[$user_rank]))
{ {
@ -91,42 +90,42 @@ else if ($signature)
} }
$template->assign_vars(array( $template->assign_vars(array(
'PAGE_TITLE' => sprintf($lang['VIEWING_USER_PROFILE'], $profiledata['username']), 'PAGE_TITLE' => sprintf($lang['VIEWING_USER_PROFILE'], $profiledata['username']),
'USERNAME' => $profiledata['username'], 'USERNAME' => $profiledata['username'],
'PROFILE_USER_ID' => $profiledata['user_id'], 'PROFILE_USER_ID' => $profiledata['user_id'],
'USER_REGDATE' => bb_date($profiledata['user_regdate'], 'Y-m-d H:i'), 'USER_REGDATE' => bb_date($profiledata['user_regdate'], 'Y-m-d H:i', 'false'),
'POSTER_RANK' => $poster_rank, 'POSTER_RANK' => $poster_rank,
'RANK_IMAGE' => $rank_image, 'RANK_IMAGE' => $rank_image,
'RANK_SELECT' => $rank_select, 'RANK_SELECT' => $rank_select,
'POSTS' => $profiledata['user_posts'], 'POSTS' => $profiledata['user_posts'],
'PM' => '<a href="'. append_sid('privmsg.php?mode=post&amp;'. POST_USERS_URL .'='. $profiledata['user_id']) .'">'. $lang['SEND_PRIVATE_MESSAGE'] .'</a>', 'PM' => '<a href="'. append_sid('privmsg.php?mode=post&amp;'. POST_USERS_URL .'='. $profiledata['user_id']) .'">'. $lang['SEND_PRIVATE_MESSAGE'] .'</a>',
'EMAIL' => $email, 'EMAIL' => $email,
'WWW' => $profiledata['user_website'], 'WWW' => $profiledata['user_website'],
'ICQ' => $profiledata['user_icq'], 'ICQ' => $profiledata['user_icq'],
'LAST_VISIT_TIME' => ($profiledata['user_lastvisit']) ? (bf($profiledata['user_opt'], 'user_opt', 'allow_viewonline') && !IS_ADMIN) ? $lang['HIDDEN_USER'] : bb_date($profiledata['user_lastvisit'], 'Y-m-d H:i') : $lang['NEVER'], 'LAST_VISIT_TIME' => ($profiledata['user_lastvisit']) ? (bf($profiledata['user_opt'], 'user_opt', 'allow_viewonline') && !IS_ADMIN) ? $lang['HIDDEN_USER'] : bb_date($profiledata['user_lastvisit'], 'Y-m-d H:i', 'false') : $lang['NEVER'],
'LAST_ACTIVITY_TIME' => ($profiledata['user_session_time']) ? (bf($profiledata['user_opt'], 'user_opt', 'allow_viewonline') && !IS_ADMIN) ? $lang['HIDDEN_USER'] : bb_date($profiledata['user_session_time'], 'Y-m-d H:i') : $lang['NEVER'], 'LAST_ACTIVITY_TIME' => ($profiledata['user_session_time']) ? (bf($profiledata['user_opt'], 'user_opt', 'allow_viewonline') && !IS_ADMIN) ? $lang['HIDDEN_USER'] : bb_date($profiledata['user_session_time'], 'Y-m-d H:i', 'false') : $lang['NEVER'],
'LOCATION' => ($profiledata['user_from']) ? $profiledata['user_from'] : '', 'LOCATION' => $profiledata['user_from'],
'USER_ACTIVE' => $profiledata['user_active'], 'USER_ACTIVE' => $profiledata['user_active'],
'OCCUPATION' => $profiledata['user_occ'], 'OCCUPATION' => $profiledata['user_occ'],
'INTERESTS' => $profiledata['user_interests'], 'INTERESTS' => $profiledata['user_interests'],
'SKYPE' => $profiledata['user_skype'], 'SKYPE' => $profiledata['user_skype'],
'GENDER' => ($bb_cfg['gender'] && $profiledata['user_gender']) ? $lang['GENDER_SELECT'][$profiledata['user_gender']] : '', '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') : '', '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']) : '', 'AGE' => ($bb_cfg['birthday']['enabled'] && $profiledata['user_birthday']) ? birthday_age($profiledata['user_birthday']) : '',
'AVATAR_IMG' => $avatar_img, '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']), 'L_VIEWING_PROFILE' => sprintf($lang['VIEWING_USER_PROFILE'], $profiledata['username']),
'L_ABOUT_USER_PROFILE' => sprintf($lang['ABOUT_USER'], $profiledata['username']), 'L_ABOUT_USER_PROFILE' => sprintf($lang['ABOUT_USER'], $profiledata['username']),
'U_SEARCH_USER' => "search.php?search_author=1&amp;uid={$profiledata['user_id']}", 'U_SEARCH_USER' => "search.php?search_author=1&amp;uid={$profiledata['user_id']}",
'U_SEARCH_TOPICS' => "search.php?uid={$profiledata['user_id']}&amp;myt=1", 'U_SEARCH_TOPICS' => "search.php?uid={$profiledata['user_id']}&amp;myt=1",
'U_SEARCH_RELEASES' => "tracker.php?rid={$profiledata['user_id']}#results", 'U_SEARCH_RELEASES' => "tracker.php?rid={$profiledata['user_id']}#results",
'S_PROFILE_ACTION' => "profile.php", 'S_PROFILE_ACTION' => "profile.php",
'SIGNATURE' => $signature, 'SIGNATURE' => $signature,
)); ));
//bt //bt

View file

@ -1,5 +1,11 @@
<h1>{L_RELEASE_TEMPLATES}</h1> <h1>{L_RELEASE_TEMPLATES}</h1>
<a href="./admin_topic_templates.php">Список форумов</a> &#0183;
<a href="./admin_topic_templates.php?mode=templates">Список шаблонов</a> &#0183;
<a href="./admin_topic_templates.php?mode=add">Добавить шаблон</a>
<br /><br />
<!-- IF FORUM_LIST -->
<P>{L_RELEASE_EXP}</p> <P>{L_RELEASE_EXP}</p>
<br /> <br />
@ -26,3 +32,71 @@
</table> </table>
</form> </form>
<!-- ENDIF -->
<!-- IF TPL_LIST -->
<P>На этой странице отображаются шаблоны</p>
<br />
<form method="post" action="{S_ACTION}">
<table class="forumline w70 tCenter">
<tr>
<th width="100%">{L_TEMPLATE}</th>
<th>{L_DELETE}</th>
</tr>
<!-- BEGIN tpl -->
<tr class="{tpl.ROW_CLASS}">
<td class="tLeft"><div class="floatL">{tpl.NAME}</div> <div class="floatR"><a href="./admin_topic_templates.php?mode=edit&tpl={tpl.ID}">{L_EDIT_DELETE_POST_TXTB}</a></div></td>
<td><input id="tpl" type="checkbox" name="tpl_id[]" value="{tpl.ID}" /></td>
</tr>
<!-- END tpl -->
<tr>
<td class="catBottom">
<input type="submit" name="submit" id="send" value="{L_SUBMIT}" class="mainoption" disabled="disabled" />&nbsp;&nbsp;
<label for="conf">{L_CONFIRM}&nbsp;<input onclick="toggle_disabled('send', this.checked)" id="confirm" type="checkbox" name="conf" value="1" /></label>
<a href=""></a>
</td>
<td class="catBottom">
<input type="checkbox" onclick="$('input#tpl').attr({ checked: this.checked });" />
</td>
</tr>
</table>
</form>
<!-- ENDIF -->
<!-- IF TPL -->
<form method="post" action="{S_ACTION}">
<table class="forumline w70 tCenter">
<tr>
<th width="50%">Описание</th>
<th width="50%">Значение</th>
</tr>
<tr class="row3">
<td class="tLeft">Имя</td>
<td><input type="text" name="tpl_name" value="{NAME}" /></td>
</tr>
<tr class="row4">
<td class="tLeft">Скрипт</td>
<td><input type="text" name="tpl_script" value="{SCRIPT}" /></td>
</tr>
<tr class="row3">
<td class="tLeft">{L_TEMPLATE}</td>
<td><input type="text" name="tpl_template" value="{TEMP}" /></td>
</tr>
<tr class="row4">
<td class="tLeft">{L_DESC}</td>
<td><input type="text" name="tpl_desc" value="{DESC}" /></td>
</tr>
<tr>
<td class="catBottom" colspan="2">
<input type="submit" name="submit" value="{L_SUBMIT}" class="mainoption" />
</td>
</tr>
</table>
</form>
<!-- ENDIF -->