Everything was working perfectly until this happened. When the main website address (
http://meanvent.com/) is typed in the URL bar, it automatically forwards to a weird error page in the forum (
http://meanvent.com/forum). However when the script is deleted from the index page the site shows everything like it should. There's also another thing that happens where the forum shows the message: This board has no forums. However the forums show up when I log in as an Admin, but I checked to make sure the forums can be viewed by everyone. The same thing happens when I go to the main site (
http://meanvent.com/) and am also logged into the forum (
http://meanvent.com/forum). The script works perfectly and the error doesn't show (although the message: This board has no forums still shows up at the forum).
Script:
Code: Select all
<?php
/*
* home.php
* Description: example file for displaying latest posts and topics
* by battye (for phpBB.com MOD Team)
* September 29, 2009
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('viewforum');
/* create_where_clauses( int[] gen_id, String type )
* This function outputs an SQL WHERE statement for use when grabbing
* posts and topics */
function create_where_clauses($gen_id, $type)
{
global $db, $auth;
$size_gen_id = sizeof($gen_id);
switch($type)
{
case 'forum':
$type = 'forum_id';
break;
case 'topic':
$type = 'topic_id';
break;
default:
trigger_error('No type defined');
}
// Set $out_where to nothing, this will be used of the gen_id
// size is empty, in other words "grab from anywhere" with
// no restrictions
$out_where = '';
if( $size_gen_id > 0 )
{
// Get a list of all forums the user has permissions to read
$auth_f_read = array_keys($auth->acl_getf('f_read', true));
if( $type == 'topic_id' )
{
$sql = 'SELECT topic_id FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', $gen_id) . '
AND ' . $db->sql_in_set('forum_id', $auth_f_read);
$result = $db->sql_query($sql);
while( $row = $db->sql_fetchrow($result) )
{
// Create an array with all acceptable topic ids
$topic_id_list[] = $row['topic_id'];
}
unset($gen_id);
$gen_id = $topic_id_list;
$size_gen_id = sizeof($gen_id);
}
$j = 0;
for( $i = 0; $i < $size_gen_id; $i++ )
{
$id_check = (int) $gen_id[$i];
// If the type is topic, all checks have been made and the query can start to be built
if( $type == 'topic_id' )
{
$out_where .= ($j == 0) ? 'WHERE ' . $type . ' = ' . $id_check . ' ' : 'OR ' . $type . ' = ' . $id_check . ' ';
}
// If the type is forum, do the check to make sure the user has read permissions
else if( $type == 'forum_id' && $auth->acl_get('f_read', $id_check) )
{
$out_where .= ($j == 0) ? 'WHERE ' . $type . ' = ' . $id_check . ' ' : 'OR ' . $type . ' = ' . $id_check . ' ';
}
$j++;
}
}
if( $out_where == '' && $size_gen_id > 0 )
{
trigger_error('A list of topics/forums has not been created');
}
return $out_where;
}
$search_limit = 5;
$forum_id = array(1, 4);
$forum_id_where = create_where_clauses($forum_id, 'forum');
$topic_id = array();
$topic_id_where = create_where_clauses($topic_id, 'topic');
$posts_ary = array(
'SELECT' => 'p.*, t.*',
'FROM' => array(
POSTS_TABLE => 'p',
),
'LEFT_JOIN' => array(
array(
'FROM' => array(TOPICS_TABLE => 't'),
'ON' => 't.topic_first_post_id = p.post_id'
)
),
'WHERE' => str_replace( array('WHERE ', 'forum_id'), array('', 't.forum_id'), $forum_id_where) . '
AND t.topic_status <> ' . ITEM_MOVED . '
AND t.topic_approved = 1',
'ORDER_BY' => 'p.post_id DESC',
);
$posts = $db->sql_build_query('SELECT', $posts_ary);
$posts_result = $db->sql_query_limit($posts, $search_limit);
while( $posts_row = $db->sql_fetchrow($posts_result) )
{
$topic_title = $posts_row['topic_title'];
$topic_replies = $posts_row['topic_replies'];
$topic_author = get_username_string('full', $posts_row['topic_poster'], $posts_row['topic_first_poster_name'], $posts_row['topic_first_poster_colour']);
$topic_date = $user->format_date($posts_row['topic_time']);
$topic_link = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $posts_row['forum_id'] . '&t=' . $posts_row['topic_id']);
$post_text = nl2br($posts_row['post_text']);
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
$bbcode->bbcode_second_pass($post_text, $posts_row['bbcode_uid'], $posts_row['bbcode_bitfield']);
$post_text = smiley_text($post_text);
echo '<h1>' . $topic_title . '</h1>';
echo $post_text . '<br /><br />';
echo 'Written by ' . $topic_author . ' - ';
echo $topic_date . ' - ';
echo '<a href="' . $topic_link . '">Comments (' . $topic_replies . ')</a>' . '<br /><hr>';
}
So I'm just wondering why exactly this is happening? Was my website hacked? Or did the web host (
http://bluehost.com/) have something to do with it? Thanks I'm pretty lost on this one. It was working perfectly one day then a week or so later it just didn't work, even though I haven't edited any of my website when this happened.