sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't obtain weblogs information.", "", __LINE__, __FILE__, $sql);
}
}
else
{
message_die(GENERAL_MESSAGE, 'Weblog_not_exist');
}
//Added for weblog category by Rajkumar
if( isset($HTTP_GET_VARS['wc']) || isset($HTTP_POST_VARS['wc']) )
{
$blog_cat = ( isset($HTTP_POST_VARS['wc']) ) ? $HTTP_POST_VARS['wc'] : $HTTP_GET_VARS['wc'];
$blog_cat_sql = " AND t.weblog_cat_id = $blog_cat ";
}
else
{
$blog_cat = '';
}
//
// If the query doesn't return any rows this isn't a valid weblog. Inform
// the user.
//
if( !($weblog_row = $db->sql_fetchrow($result)) )
{
message_die(GENERAL_MESSAGE, 'Weblog_not_exist');
}
//
// Start auth check
//
$is_auth = array();
$is_auth = auth(AUTH_ALL, $weblog_id, $userdata, $weblog_row);
if ( !$is_auth['auth_read'] )
{
//
// The user is not authed to read this weblog ...
//
$message = $lang['Weblog_not_allowed'];
message_die(GENERAL_MESSAGE, $message);
}
//
// End of auth check
//
$sql = "SELECT u.*
FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g, " . USERS_TABLE . " u
WHERE aa.forum_id = $weblog_id
AND aa.auth_mod = " . TRUE . "
AND ug.group_id = aa.group_id
AND g.group_single_user = 1
AND u.user_id = ug.user_id
AND g.group_id = aa.group_id
GROUP BY u.user_id, u.username
ORDER BY u.user_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not obtain weblog owner information for this weblog.", '', __LINE__, __FILE__, $sql);
}
while( $row = $db->sql_fetchrow($result) )
{
$weblog_ownerdata = get_userdata($row['user_id']);
}
//
// User authorisation levels output
//
$s_auth_can = ( ( $is_auth['auth_post'] ) ? $lang['Weblog_post_can'] : $lang['Weblog_post_cannot'] ) . "
";
$s_auth_can .= ( ( $is_auth['auth_reply'] ) ? $lang['Weblog_reply_can'] : $lang['Weblog_reply_cannot'] ) . "
";
$s_auth_can .= ( ( $is_auth['auth_edit'] ) ? $lang['Weblog_edit_can'] : $lang['Weblog_edit_cannot'] ) . "
";
$s_auth_can .= ( ( $is_auth['auth_delete'] ) ? $lang['Weblog_delete_can'] : $lang['Weblog_delete_cannot'] ) . "
";
if ( defined('ATTACH_VERSION') )
{
attach_build_auth_levels($is_auth, $s_auth_can);
}
// Let the weblog owner see the new entry button
if( $is_auth['auth_mod'] )
{
$new_entry = '';
$new_edit = '';
$category = 'Categories';
// Update here allows better control over links. Kept the old one to maintain compatibility with older weblogs.
$template->assign_vars(array(
'U_NEW_ENTRY' => append_sid("weblog_posting.$phpEx?mode=newtopic&" . POST_WEBLOG_URL . "=$weblog_id"),
'U_NEW_EDIT' => append_sid("weblog_posting.$phpEx?mode=editpost&" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&wc=" . $postrow[$i]['weblog_cat_id'] . "&" . POST_WEBLOG_URL . "=$weblog_id"),
'U_CATEGORY' => append_sid("weblog_category.$phpEx?" . POST_WEBLOG_URL . "=$weblog_id"),
'NEW_ENTRY_A' => '',
'NEW_ENTRY_B' => '',
'BLOG_CATEGORY' => $category,
'NEW_ENTRY' => $new_entry,
'NEW_EDIT' => $new_edit)
);
$template->assign_block_vars('switch_owner', array());
}
else
{
$new_entry = '';
$new_edit = '';
}
//
// Increment the number of views for this weblog.
//
$sql = "UPDATE " . FORUMS_TABLE . "
SET forum_views = '" . ($weblog_row['forum_views'] + 1) . "'
WHERE forum_id = $weblog_id";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't update weblog views information.", "", __LINE__, __FILE__, $sql);
}
//ADDED by Rajkumar for Category
$sql="SELECT weblog_cat_id , weblog_cat_name from ". WEBLOG_CATEGORIES ." WHERE forum_id=$weblog_id";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't obtain weblog category information.", "", __LINE__, __FILE__, $sql);
}
while( $row = $db->sql_fetchrow($result) )
{
$blog_cat_dat[] = $row;
}
$blog_cat_count = count($blog_cat_dat);
$blog_cat_id = array();
$blog_cat_name = array();
$catname='';
if ($blog_cat == '' && $blog_cat_count >= 1)
{
$catname = " All " ;
}
elseif ($blog_cat)
{
$catname = " All ";
}
else
{
$catname='';
}
for ($i = 0; $i < $blog_cat_count; $i++)
{
$blog_cat_id[$i] = $blog_cat_dat[$i]['weblog_cat_id'];
$blog_cat_name[$i] = $blog_cat_dat[$i]['weblog_cat_name'];
if ($blog_cat == $blog_cat_id[$i])
$catname .= "| ". $blog_cat_name[$i]." ";
else
$catname .= "| " . $blog_cat_name[$i] ." ";
}
//
// Start output of page
//
define('IN_WEBLOGS', true);
$page_title = $weblog_row['forum_name'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$template->set_filenames(array(
'body' => '../../weblogs/weblog_' . $weblog_ownerdata['user_id'] . '.cfg')
);
if ( $weblog_ownerdata['weblog_show_profile'] == WEBLOG_SHOW )
{
$template->assign_block_vars('switch_show_profile', array());
}
if ( $weblog_ownerdata['weblog_contact_info'] == WEBLOG_SHOW )
{
$template->assign_block_vars('switch_contact_user', array());
}
if ( $weblog_ownerdata['weblog_show_info'] == WEBLOG_SHOW )
{
$template->assign_block_vars('switch_show_info', array());
}
if ( $weblog_ownerdata['weblog_show_desc'] == WEBLOG_SHOW )
{
$template->assign_block_vars('switch_user_center', array());
}
else if ( $weblog_ownerdata['weblog_show_desc'] == WEBLOG_HIDE )
{
$template->assign_block_vars('switch_user_right', array());
}
// Prepare Avatar Image
$avatar_img = '';
if ( $weblog_ownerdata['user_avatar_type'] && $weblog_ownerdata['user_allowavatar'] )
{
switch( $weblog_ownerdata['user_avatar_type'] )
{
case USER_AVATAR_UPLOAD:
$avatar_img = ( $board_config['allow_avatar_upload'] ) ? '' : '';
break;
case USER_AVATAR_REMOTE:
$avatar_img = ( $board_config['allow_avatar_remote'] ) ? '' : '';
break;
case USER_AVATAR_GALLERY:
$avatar_img = ( $board_config['allow_avatar_local'] ) ? '' : '';
break;
}
}
$temp_url = append_sid("privmsg.$phpEx?mode=post&" . POST_USERS_URL . "=" . $weblog_ownerdata['user_id']);
$pm_img = '';
$pm = $lang['Send_private_message'];
$pm_a = '';
$pm_b = '';
if ( !empty($weblog_ownerdata['user_viewemail']) || $userdata['user_level'] == ADMIN )
{
$email_uri = ( $board_config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&" . POST_USERS_URL .'=' . $weblog_ownerdata['user_id']) : 'mailto:' . $weblog_ownerdata['user_email'];
$email_img = '';
$email = $lang['Send_email'];
$email_a = '';
$email_b = '';
}
else
{
$email_img = ' ';
$email = ' ';
$email_a = '';
$email_b = '';
}
$www_img = ( $weblog_ownerdata['user_website'] ) ? '' : ' ';
$www = ( $weblog_ownerdata['user_website'] ) ? '' . $weblog_ownerdata['user_website'] . '' : ' ';
if ( !empty($weblog_ownerdata['user_icq']) )
{
$icq_status_img = '';
$icq_img = '';
$icq = $lang['ICQ'];
$icq_a = '';
$icq_b = '';
}
else
{
$icq_status_img = ' ';
$icq_img = ' ';
$icq = ' ';
$icq_a = '';
$icq_b = '';
}
$aim_img = ( $weblog_ownerdata['user_aim'] ) ? '' : ' ';
$aim = ( $weblog_ownerdata['user_aim'] ) ? $lang['AIM'] : ' ';
$aim_a = ( $weblog_ownerdata['user_aim'] ) ? '' : '';
$aim_b = ( $weblog_ownerdata['user_aim'] ) ? '' : '';
$msn_img = ( $weblog_ownerdata['user_msnm'] ) ? $weblog_ownerdata['user_msnm'] : ' ';
$msn = $msn_img;
$yim_img = ( $weblog_ownerdata['user_yim'] ) ? '' : '';
$yim = ( $weblog_ownerdata['user_yim'] ) ? $lang['YIM'] : '';
$yim_a = ( $weblog_ownerdata['user_yim'] ) ? '' : '';
$yim_b = ( $weblog_ownerdata['user_yim'] ) ? '' : '';
// Birthday Mod support - Taken and modified directly from Niels' Birthday Mod
if ( $weblog_config['birthday_mod'] == 1 )
{
$this_year = create_date('Y', time(), $board_config['board_timezone']);
$this_date = create_date('md', time(), $board_config['board_timezone']);
if ( $weblog_ownerdata['user_birthday'] != 999999 )
{
$poster_birthdate = realdate('md', $weblog_ownerdata['user_birthday']);
if ( $weblog_config['birthday_zodiac_mod'] == 1 )
{
$n=0;
while ( $n<26 )
{
if ( $poster_birthdate >= $zodiacdates[$n] & $poster_birthdate <= $zodiacdates[$n+1] )
{
$zodiac = $lang[$zodiacs[($n/2)]];
$u_zodiac = $images[$zodiacs[($n/2)]];
$zodiac_img = '';
$n = 26;
}
else
{
$n = $n + 2;
}
}
}
$poster_age = $this_year - realdate ('Y',$weblog_ownerdata['user_birthday']);
if ( $this_date < $poster_birthdate )
{
$poster_age--;
}
}
else
{
$zodiac = '';
$u_zodiac = '';
$zodiac_img = '';
$poster_age = '';
}
}
//
// Fetch Posts from Weblog Forum
//
// Get the user's clearence levels
$access_level = 0;
if ( $userdata['session_logged_in'] )
{
$access_level++;
$group_id = intval($weblog_ownerdata['weblog_group']);
//
// Get user information for this group
//
$sql = "SELECT ug.group_id, ug.user_id, ug.user_pending
FROM " . USER_GROUP_TABLE . " ug
WHERE ug.group_id = $group_id
AND ug.user_id = " . $userdata['user_id'] . "
ORDER BY ug.user_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Error getting user list for group', '', __LINE__, __FILE__, $sql);
}
$group_members = $db->sql_fetchrowset($result);
if ( count($group_members) == 1 || $userdata['user_level'] == ADMIN )
{
$access_level++;
}
if ( $weblog_ownerdata['user_id'] == $userdata['user_id'] || $userdata['user_level'] == ADMIN )
{
$access_level++;
}
}
$entry_sql = 't.topic_first_post_id, t.topic_poster, t.topic_status, t.topic_mood, t.topic_currently1, t.topic_currently2, t.topic_time, t.topic_title, t.topic_replies, t.topic_id, t.topic_auth, t.topic_vote, t.weblog_cat_id, p.post_id, p.enable_smilies, u.username, u.user_id, pt.post_text, pt.post_id, pt.bbcode_uid';
if ( defined('ATTACH_VERSION') )
{
$entry_sql .= ', t.topic_attachment';
}
//
// Fetch Entries
//
// Account for the "Go Back" or "Go Forward"
if ( !$day )
{
$limit_sql = "LIMIT " . ($weblog_ownerdata['weblog_show_entries'] + $previous);
}
$sql = "SELECT $entry_sql
FROM " . TOPICS_TABLE . " AS t, " . USERS_TABLE . " AS u, " . POSTS_TEXT_TABLE . " AS pt, " . POSTS_TABLE . " AS p
WHERE t.forum_id IN (" . $weblog_id . ")
AND t.topic_time <= " . time() . "
AND t.topic_poster = u.user_id
AND t.topic_first_post_id = pt.post_id
AND t.topic_first_post_id = p.post_id
AND t.topic_status <> 2
AND t.topic_auth <= " . $access_level;
$sql .= "$blog_cat_sql";
$sql .= " ORDER BY t.topic_time DESC " . $limit_sql;
if(!($result = $db->sql_query($sql)))
{
message_die(GENERAL_ERROR, 'Could not query weblog entry information', '', __LINE__, __FILE__, $sql);
}
$i = 0;
while ( $row = $db->sql_fetchrow($result) )
{
$entry_data[$i] = $row;
$i++;
}
if ( defined('ATTACH_VERSION') )
{
$post_id_array = array();
for ($i = 0; $i < count($entry_data); $i++)
{
if ($entry_data[$i]['topic_attachment'] == 1)
{
$post_id_array[] = $entry_data[$i]['post_id'];
}
}
$rows = get_attachments_from_post($post_id_array);
$num_rows = count($rows);
@reset($attachments);
if ( $num_rows != 0 )
{
for ($i = 0; $i < $num_rows; $i++)
{
$attachments['_' . $rows[$i]['post_id']][] = $rows[$i];
}
init_display_template('body', '{postrow.ATTACHMENTS}', '../../weblogs/styles/' . $weblog_ownerdata['weblog_style'] . '/attach_body.cfg');
init_complete_extensions_data();
$template->assign_vars(array(
'L_POSTED_ATTACHMENTS' => $lang['Posted_attachments'],
'L_KILOBYTE' => $lang['KB'])
);
}
}
for ($i = $previous; $i < count($entry_data); $i++)
{
//
// Prepare every entry
//
$entry_data[$i]['post_text'] = stripslashes($entry_data[$i]['post_text']);
$entry_data[$i]['post_text'] = bbencode_second_pass($entry_data[$i]['post_text'], $entry_data[$i]['bbcode_uid']);
// Smilies
if ($entry_data[$i]['enable_smilies'] == 1)
{
$entry_data[$i]['post_text'] = smilies_pass($entry_data[$i]['post_text']);
}
$entry_data[$i]['post_text'] = make_clickable($entry_data[$i]['post_text']);
// Define censored word matches
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
// Censor text and title
if (count($orig_word))
{
$entry_data[$i]['topic_title'] = preg_replace($orig_word, $replacement_word, $entry_data[$i]['topic_title']);
$entry_data[$i]['post_text'] = preg_replace($orig_word, $replacement_word, $entry_data[$i]['post_text']);
}
$entry_data[$i]['post_text'] = nl2br($entry_data[$i]['post_text']);
$icon = '';
# Code added to display the hidden and poll tags for the posts - Godwin -->
if( $entry_data[$i]['topic_auth'] == 3 )
{
$topic_type = $lang['Post_Hidden'] . ' ';
}
else
{
$topic_type='';
}
if( $entry_data[$i]['topic_vote'] == 1 )
{
$topic_type = $lang['Topic_Poll'] . ' ';
}
# Godwin <--
// Mood Icons
$mood = $entry_data[$i]['topic_mood'] - 1;
if ( $mood_data[$mood]['mood'] != $lang['Weblog_none'] && $mood_data[$mood]['mood'] != '' && $mood > 0 )
{
$icon = '[ ' . $lang['Weblog_mood'] . ': ' . $mood_data[$mood]['mood'] . ' ]
';
}
// Currently Icons
$currently = $entry_data[$i]['topic_currently1'] - 1;
if ( $currently_data[$currently]['image_url'] != '' && $currently_data[$currently]['currently'] != $lang['Weblog_none'] && $currently_data[$currently]['currently'] != $lang['Weblog_custom'] && $currently > 0 )
{
$icon .= '[ ' . $lang['Weblog_currently'] . ': ' . $currently_data[$currently]['currently'] . ' ' . $entry_data[$i]['topic_currently2'] . ' ]
';
}
$time = '';
// Say Today At, or Yesterday At instead of the the time - borrowed from the Today At/Yesterday At Mod
if ( $board_config['time_today'] < $entry_data[$i]['topic_time'])
{
$time = sprintf($lang['Today_at'], create_date($board_config['default_timeformat'], $entry_data[$i]['topic_time'], $board_config['board_timezone'])) . '';
}
else if ( $board_config['time_yesterday'] < $entry_data[$i]['topic_time'])
{
$time = sprintf($lang['Yesterday_at'], create_date($board_config['default_timeformat'], $entry_data[$i]['topic_time'], $board_config['board_timezone'])) . '';
}
else
{
$time = create_date($board_config['default_dateformat'], $entry_data[$i]['topic_time'], $board_config['board_timezone']);
}
//Month variable added to fix calendar search post - Isaac
if ( $day && $year && $month)
{
if ( create_date("d", $entry_data[$i]['topic_time'], $board_config['board_timezone']) == $day && create_date("Y", $entry_data[$i]['topic_time'], $board_config['board_timezone']) == $year && create_date("m", $entry_data[$i]['topic_time'], $board_config['board_timezone']) == $month )
{
// Output
$template->assign_block_vars('postrow', array(
'ICON' => $icon,
'TITLE' => $entry_data[$i]['topic_title'],
'POSTER' => $entry_data[$i]['username'],
'TIME' => $time,
'TEXT' => $entry_data[$i]['post_text'],
'POST_COMMENT' => ( $entry_data[$i]['topic_status'] != TOPIC_LOCKED ) ? sprintf($weblog_ownerdata['weblog_post_comment_name'], $entry_data[$i]['topic_replies']) : '',
'REPLIES' => ( $entry_data[$i]['topic_status'] != TOPIC_LOCKED ) ? sprintf($weblog_ownerdata['weblog_comment_name'], $entry_data[$i]['topic_replies']) : '',
'U_VIEW_COMMENTS' => ( $entry_data[$i]['topic_status'] != TOPIC_LOCKED ) ? append_sid('weblog_entry.' . $phpEx . '?' . POST_ENTRY_URL . '=' . $entry_data[$i]['topic_id']) : '',
'U_EDIT_POST' => ( $entry_data[$i]['topic_status'] != TOPIC_LOCKED ) ? append_sid('weblog_posting.' . $phpEx . '?mode=editpost&' . POST_POST_URL . '=' . $entry_data[$i]['post_id'] . '&wc=' . $entry_data[$i]['weblog_cat_id'] . '&' . POST_WEBLOG_URL . '=' . $weblog_id) : '',
'U_POST_COMMENT' => ( $entry_data[$i]['topic_status'] != TOPIC_LOCKED ) ? append_sid('weblog_posting.' . $phpEx . '?mode=reply&' . POST_ENTRY_URL . '=' . $entry_data[$i]['topic_id']) : '',
'ENTRY_ATTACHMENT_IMG' => ( defined('ATTACH_VERSION') ) ? topic_attachment_image($entry_data[$i]['topic_attachment']) : "")
);
}
}
else
{
// Output
$template->assign_block_vars('postrow', array(
'ICON' => $icon,
'TITLE' => $entry_data[$i]['topic_title'],
'POSTER' => $entry_data[$i]['username'],
'TIME' => $time,
'TOPIC_TYPE' => $topic_type, // Godwin - to display poll & hidden tag
'TEXT' => $entry_data[$i]['post_text'],
'POST_COMMENT' => ( $entry_data[$i]['topic_status'] != TOPIC_LOCKED ) ? sprintf($weblog_ownerdata['weblog_post_comment_name'], $entry_data[$i]['topic_replies']) : '',
'REPLIES' => ( $entry_data[$i]['topic_status'] != TOPIC_LOCKED ) ? sprintf($weblog_ownerdata['weblog_comment_name'], $entry_data[$i]['topic_replies']) : '',
'U_VIEW_COMMENTS' => ( $entry_data[$i]['topic_status'] != TOPIC_LOCKED ) ? append_sid('weblog_entry.' . $phpEx . '?' . POST_ENTRY_URL . '=' . $entry_data[$i]['topic_id']) : '',
'U_EDIT_POST' => ( $entry_data[$i]['topic_status'] != TOPIC_LOCKED ) ? append_sid('weblog_posting.' . $phpEx . '?mode=editpost&' . POST_POST_URL . '=' . $entry_data[$i]['post_id'] . '&wc=' . $entry_data[$i]['weblog_cat_id'] . '&' . POST_WEBLOG_URL . '=' . $weblog_id) : '',
'U_POST_COMMENT' => ( $entry_data[$i]['topic_status'] != TOPIC_LOCKED ) ? append_sid('weblog_posting.' . $phpEx . '?mode=reply&' . POST_ENTRY_URL . '=' . $entry_data[$i]['topic_id']) : '',
'ENTRY_ATTACHMENT_IMG' => ( defined('ATTACH_VERSION') ) ? topic_attachment_image($entry_data[$i]['topic_attachment']) : "")
);
if ( defined('ATTACH_VERSION') )
{
display_attachments($entry_data[$i]['post_id']);
}
}
}
//
// Prepare the calendar - some parts were borrowed the the Calendar Mod by WebSnail
//
$firstday = (date('w', (mktime(0,0,0,$month,1,$year))) - $cal_config['week_start']) % 7;
$firstday = ( $firstday < 0 ) ? ($firstday + 7) : $firstday;
$lastday = date('t', mktime(0,0,0,$month,1,$year));
$end_day = 7 - (($firstday + $lastday) % 7);
$end_day = ( $end_day == 7 ) ? 0 : $end_day; // day 7 same as day 0
// Fetch the topic time, for use with the calendar
$sql = "SELECT t.topic_first_post_id, t.topic_poster, t.topic_status, t.topic_time, t.topic_auth, p.post_id, u.user_id, pt.post_id
FROM " . TOPICS_TABLE . " AS t, " . USERS_TABLE . " AS u, " . POSTS_TEXT_TABLE . " AS pt, " . POSTS_TABLE . " AS p
WHERE t.forum_id IN (" . $weblog_id . ")
AND t.topic_time <= " . time() . "
AND t.topic_poster = u.user_id
AND t.topic_first_post_id = pt.post_id
AND t.topic_first_post_id = p.post_id
AND t.topic_status <> 2
AND t.topic_auth <= " . $access_level;
$sql .= "$blog_cat_sql";
$sql .= " ORDER BY t.topic_time DESC";
if(!($result = $db->sql_query($sql)))
{
message_die(GENERAL_ERROR, 'Could not query entry time information', '', __LINE__, __FILE__, $sql);
}
$i = 0;
while ( $row = $db->sql_fetchrow($result) )
{
$entry_time[$i] = $row;
$i++;
}
// Make table cells for "empty" days (The blank squares in the calendar)
for ( $i = 0; $i < $firstday; $i++ )
{
$template->assign_block_vars('no_day', array());
}
// Make table cells with numbers in them. Make a new line whenever all 7 spaces have been filled
for ($currentday = 1; $currentday <= $lastday; $currentday++)
{
$countDay = 0;
for ($i = 0; $i < count($entry_time); $i++)
{
if ( $currentday == create_date("j", $entry_time[$i]['topic_time'], $board_config['board_timezone']) && $month == create_date("n", $entry_time[$i]['topic_time'], $board_config['board_timezone']) && $year == create_date("Y", $entry_time[$i]['topic_time'], $board_config['board_timezone']))
$countDay++;
}
$template->assign_block_vars('day_cell', array(
'NUM_DAY' => ( $countDay != 0 ) ? '' . $currentday . '' : $currentday,
'WEEK_ROW' => ( ($currentday + $firstday) % 7 == 0 ) ? '