News:

Wondering if this will always be free?  See why free is better.

Main Menu

SMF SSI Problem

Started by anthonymims, October 29, 2012, 02:20:54 AM

Previous topic - Next topic

anthonymims

Hey Guys,

I am trying to use the SSI.php file to use the login function.  I want to use SMF's login functions with the rest of the website.  The issue I am having is when I require the SSI.php file, it completely takes over the page that I am working on.   The screenshots attached are before I add the php code to require the SSI.php file (Which is being put at the very top of the page, line 1).  I'm not quite sure why it is automatically trying to turn my page I am building into the index.php page of the forums.  Thanks for any assistance. 

Colin

Welcome to SMF.

Can you please attach the PHP file for the page in which SSI is being called.
"If everybody is thinking alike, then somebody is not thinking." - Gen. George S. Patton Jr.

Colin

anthonymims

This is the code for the entire page.

<?php require("/home/scrace5/public_html/dirtracefans.com/forums/SSI.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Dirt Race Fans Videos</title>

<style type="text/css">
@import url("style.css");
</style>

<script type="text/javascript">

var currPic=1;

var totPics=10;

var keepTime;

function setupPicChange()

{ keepTime=setTimeout("changePic()", 5000); }

function changePic()

{ currPic++; if(currPic>totPics) currPic=1;

document.getElementById("picture").src="images/pic"+currPic+".jpg";

setupPicChange(); }

</script>

</head>
<div id="headcontainer">
<div id="banner">
    </div>
   
    <div id="rotate">
    <div><img id="picture" src="pic1.jpg"/></div>
    </div>
</div>
<body onload="setupPicChange();">

<div id="bodycontainer">

<div id="nav"><?php include("navbar.html"); ?></div> <!-- This is for the navbar.  To edit the Navbar, check the instructions file. -->
   
<div id="space"></div>
   
<div id="textone"><p><?php include("homedocuments/textone.txt"); ?></p></div> <!-- This is for the first text box.  Edit the textone.txt file in your documentation folder to change the content of this text box. -->
   
    <div id="space"></div>
   
<div id="texttwo"><p><?php include("dvdsdocuments/main.php"); ?></p></div><!-- This is for the second text box.  Edit the texttwo.txt file in your documentation folder to change the content of this text box. -->
   
    <div id="space"></div>
   
    <div id="containerfoot">

    <div id="textleft"><p><?php include("homedocuments/textfour.txt"); ?></p></div><!-- This is for the fourth text box.  Edit the textfour.txt file in your documentation folder to change the content of this text box. -->
       
        <div id="textright"><p><?php include("homedocuments/textfive.txt"); ?></p></div><!-- This is for the fifth text box.  Edit the textfive.txt file in your documentation folder to change the content of this text box. -->
       
<div id="textmid"><p><?php include("homedocuments/textsix.txt"); ?></p></div><!-- This is for the sixth text box.  Edit the textsix.txt file in your documentation folder to change the content of this text box. -->
       
    </div>
   
<div id="space"></div>   
   
    <div id="containerfoot">

    <div id="textone"><p><?php include("homedocuments/textseven.txt"); ?></p></div><!-- This is for the seventh text box.  Edit the textseven.txt file in your documentation folder to change the content of this text box. -->
       
        <div id="space"></div>
        <div id="space"></div>
       
        <div id="links"><p><?php include("links.txt"); ?></p></div><!-- This is for the bottom links text box.  Edit the links.txt file to change the content of this text box. -->
       
</div>
</div>

<script src='https://www.paypalobjects.com/js/external/dg.js'

type='text/javascript'></script>
<!-- Add Digital goods in-context experience. Ensure that this script is added before the

closing of html body tag -->
<script>

var dg = new PAYPAL.apps.DGFlow(
{
trigger: 'paypal_submit1',
expType: 'instant'
//PayPal will decide the experience type for the buyer based on his/her
});

var dg = new PAYPAL.apps.DGFlow(
{
trigger: 'paypal_submit2',
expType: 'instant'
//PayPal will decide the experience type for the buyer based on his/her
});

var dg = new PAYPAL.apps.DGFlow(
{
trigger: 'paypal_submit3',
expType: 'instant'
//PayPal will decide the experience type for the buyer based on his/her
});

var dg = new PAYPAL.apps.DGFlow(
{
trigger: 'paypal_submit4',
expType: 'instant'
//PayPal will decide the experience type for the buyer based on his/her
});

var dg = new PAYPAL.apps.DGFlow(
{
trigger: 'paypal_submit5',
expType: 'instant'
//PayPal will decide the experience type for the buyer based on his/her
});

var dg = new PAYPAL.apps.DGFlow(
{
trigger: 'paypal_submit6',
expType: 'instant'
//PayPal will decide the experience type for the buyer based on his/her
});
var dg = new PAYPAL.apps.DGFlow(
{
trigger: 'paypal_submit7',
expType: 'instant'
//PayPal will decide the experience type for the buyer based on his/her
});

var dg = new PAYPAL.apps.DGFlow(
{
trigger: 'paypal_submit8',
expType: 'instant'
//PayPal will decide the experience type for the buyer based on his/her
});

var dg = new PAYPAL.apps.DGFlow(
{
trigger: 'paypal_submit9',
expType: 'instant'
//PayPal will decide the experience type for the buyer based on his/her
});

var dg = new PAYPAL.apps.DGFlow(
{
trigger: 'paypal_submit10',
expType: 'instant'
//PayPal will decide the experience type for the buyer based on his/her
});

var dg = new PAYPAL.apps.DGFlow(
{
trigger: 'paypal_submit11',
expType: 'instant'
//PayPal will decide the experience type for the buyer based on his/her
});

var dg = new PAYPAL.apps.DGFlow(
{
trigger: 'paypal_submit12',
expType: 'instant'
//PayPal will decide the experience type for the buyer based on his/her
});
</script>



</body>
</html>

anthonymims

I copied the SSI.php file to a different directory, changed the reference links so i could point to it and play with it without causing issues.  I deleted some code out of it and it stopped hyjacking my page, however, the functions didnt work after that either.

Colin

Quote from: anthonymims on October 29, 2012, 05:16:37 PM
I copied the SSI.php file to a different directory, changed the reference links so i could point to it and play with it without causing issues.  I deleted some code out of it and it stopped hyjacking my page, however, the functions didnt work after that either.
Yep, because SSI is not meant to be moved from the forum root :).
"If everybody is thinking alike, then somebody is not thinking." - Gen. George S. Patton Jr.

Colin

anthonymims

Quote from: Colin on October 29, 2012, 07:04:06 PM
Quote from: anthonymims on October 29, 2012, 05:16:37 PM
I copied the SSI.php file to a different directory, changed the reference links so i could point to it and play with it without causing issues.  I deleted some code out of it and it stopped hyjacking my page, however, the functions didnt work after that either.
Yep, because SSI is not meant to be moved from the forum root :).

I know.  But as I said, I changed the reference links so it would run outside of the forum root.  Either way it ran, it still hyjacked the page I am working on.

Kindred

1- leave SSI in the forum root.   All sorts of things can get screwed up if you move it.  Just call it form the forum root, as it is intended to be used.

2- I don't see any call to an ssi function...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

anthonymims

Quote from: Kindred on October 30, 2012, 10:06:20 AM
1- leave SSI in the forum root.   All sorts of things can get screwed up if you move it.  Just call it form the forum root, as it is intended to be used.

2- I don't see any call to an ssi function...

AS I had said twice before now...  I only moved the SSI file to test things.  The problem is within the SSI file itself.   After my test was done, I deleted my copy...

There is no call to an SSI function.  That is the issue. ALL I am doing is requiring the file SO I can use the functions and it is hyjacking my page as you can see in the screenshots above.

Kindred

then that is NOT the standard SSI file...    please attach your SSI.php file
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

anthonymims

Here is the SSI.php file.

<?php

/**
 * Simple Machines Forum (SMF)
 *
 * @package SMF
 * @author Simple Machines http://www.simplemachines.org
 * @copyright 2011 Simple Machines
 * @license http://www.simplemachines.org/about/smf/license.php BSD
 *
 * @version 2.0
 */

// Don't do anything if SMF is already loaded.
if (defined('SMF'))
return true;

define('SMF''SSI');

// We're going to want a few globals... these are all set later.
global $time_start$maintenance$msubject$mmessage$mbname$language;
global 
$boardurl$boarddir$sourcedir$webmaster_email$cookiename;
global 
$db_server$db_name$db_user$db_prefix$db_persist$db_error_send$db_last_error;
global 
$db_connection$modSettings$context$sc$user_info$topic$board$txt;
global 
$smcFunc$ssi_db_user$scripturl$ssi_db_passwd$db_passwd$cachedir;

// Remember the current configuration so it can be set back.
$ssi_magic_quotes_runtime function_exists('get_magic_quotes_gpc') && get_magic_quotes_runtime();
if (
function_exists('set_magic_quotes_runtime'))
@set_magic_quotes_runtime(0);
$time_start microtime();

// Just being safe...
foreach (array('db_character_set''cachedir') as $variable)
if (isset($GLOBALS[$variable]))
unset($GLOBALS[$variable]);

// Get the forum's settings for database and file paths.
require_once(dirname(__FILE__) . '/Settings.php');

// Make absolutely sure the cache directory is defined.
if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir '/cache'))
$cachedir $boarddir '/cache';

$ssi_error_reporting error_reporting(defined('E_STRICT') ? E_ALL E_STRICT E_ALL);
/* Set this to one of three values depending on what you want to happen in the case of a fatal error.
false: Default, will just load the error sub template and die - not putting any theme layers around it.
true: Will load the error sub template AND put the SMF layers around it (Not useful if on total custom pages).
string: Name of a callback function to call in the event of an error to allow you to define your own methods. Will die after function returns.
*/
$ssi_on_error_method false;

// Don't do john didley if the forum's been shut down competely.
if ($maintenance == && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true))
die($mmessage);

// Fix for using the current directory as a path.
if (substr($sourcedir01) == '.' && substr($sourcedir11) != '.')
$sourcedir dirname(__FILE__) . substr($sourcedir1);

// Load the important includes.
require_once($sourcedir '/QueryString.php');
require_once(
$sourcedir '/Subs.php');
require_once(
$sourcedir '/Errors.php');
require_once(
$sourcedir '/Load.php');
require_once(
$sourcedir '/Security.php');

// Using an pre-PHP 5.1 version?
if (@version_compare(PHP_VERSION'5.1') == -1)
require_once($sourcedir '/Subs-Compat.php');

// Create a variable to store some SMF specific functions in.
$smcFunc = array();

// Initate the database connection and define some database functions to use.
loadDatabase();

// Load installed 'Mods' settings.
reloadSettings();
// Clean the request variables.
cleanRequest();

// Seed the random generator?
if (empty($modSettings['rand_seed']) || mt_rand(1250) == 69)
smf_seed_generator();

// Check on any hacking attempts.
if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS']))
die('Hacking attempt...');
elseif (isset(
$_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme)
die('Hacking attempt...');
elseif (isset(
$_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme)
die('Hacking attempt...');
elseif (isset(
$_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers)
die('Hacking attempt...');
if (isset(
$_REQUEST['context']))
die('Hacking attempt...');

// Make sure wireless is always off.
define('WIRELESS'false);

// Gzip output? (because it must be boolean and true, this can't be hacked.)
if (isset($ssi_gzip) && $ssi_gzip === true && @ini_get('zlib.output_compression') != '1' && @ini_get('output_handler') != 'ob_gzhandler' && @version_compare(PHP_VERSION'4.2.0') != -1)
ob_start('ob_gzhandler');
else
$modSettings['enableCompressedOutput'] = '0';

// Primarily, this is to fix the URLs...
ob_start('ob_sessrewrite');

// Start the session... known to scramble SSI includes in cases...
if (!headers_sent())
loadSession();
else
{
if (isset($_COOKIE[session_name()]) || isset($_REQUEST[session_name()]))
{
// Make a stab at it, but ignore the E_WARNINGs generated because we can't send headers.
$temp error_reporting(error_reporting() & !E_WARNING);
loadSession();
error_reporting($temp);
}

if (!isset($_SESSION['session_value']))
{
$_SESSION['session_var'] = substr(md5(mt_rand() . session_id() . mt_rand()), 0rand(712));
$_SESSION['session_value'] = md5(session_id() . mt_rand());
}
$sc $_SESSION['session_value'];
}

// Get rid of $board and $topic... do stuff loadBoard would do.
unset($board$topic);
$user_info['is_mod'] = false;
$context['user']['is_mod'] = &$user_info['is_mod'];
$context['linktree'] = array();

// Load the user and their cookie, as well as their settings.
loadUserSettings();

// Load the current user's permissions....
loadPermissions();

// Bad Behavior Start
require_once($sourcedir '/bad-behavior/BadBehavior-SMF.php');
// Bad Behavior End

// Load the current or SSI theme. (just use $ssi_theme = id_theme;)
loadTheme(isset($ssi_theme) ? (int) $ssi_theme 0);

// Take care of any banning that needs to be done.
if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true))
is_not_banned();

// Do we allow guests in here?
if (empty($ssi_guest_access) && empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && basename($_SERVER['PHP_SELF']) != 'SSI.php')
{
require_once($sourcedir '/Subs-Auth.php');
KickGuest();
obExit(nulltrue);
}

// Load the stuff like the menu bar, etc.
if (isset($ssi_layers))
{
$context['template_layers'] = $ssi_layers;
template_header();
}
else
setupThemeContext();

// Make sure they didn't muss around with the settings... but only if it's not cli.
if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '')
trigger_error($txt['ssi_session_broken'], E_USER_NOTICE);

// Without visiting the forum this session variable might not be set on submit.
if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote'))
$_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT'];

// Call a function passed by GET.
if (isset($_GET['ssi_function']) && function_exists('ssi_' $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest']))
{
call_user_func('ssi_' $_GET['ssi_function']);
exit;
}
if (isset(
$_GET['ssi_function']))
exit;
// You shouldn't just access SSI.php directly by URL!!
elseif (basename($_SERVER['PHP_SELF']) == 'SSI.php')
die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' addslashes(__FILE__) . '\'' '\'SSI.php\''));

error_reporting($ssi_error_reporting);
if (
function_exists('set_magic_quotes_runtime'))
@set_magic_quotes_runtime($ssi_magic_quotes_runtime);

return 
true;

// This shuts down the SSI and shows the footer.
function ssi_shutdown()
{
if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown')
template_footer();
}

// Display a welcome message, like:  Hey, User, you have 0 messages, 0 are new.
function ssi_welcome($output_method 'echo')
{
global $context$txt$scripturl;

if ($output_method == 'echo')
{
if ($context['user']['is_guest'])
echo sprintf($txt['welcome_guest'], $txt['guest_title']);
else
echo $txt['hello_member'], ' <strong>'$context['user']['name'], '</strong>'allowedTo('pm_read') ? ', ' $txt['msg_alert_you_have'] . ' <a href="' $scripturl '?action=pm">' $context['user']['messages'] . ' ' . ($context['user']['messages'] == '1' $txt['message_lowercase'] : $txt['msg_alert_messages']) . '</a>' $txt['newmessages4'] . ' ' $context['user']['unread_messages'] . ' ' . ($context['user']['unread_messages'] == '1' $txt['newmessages0'] : $txt['newmessages1']) : '''.';
}
// Don't echo... then do what?!
else
return $context['user'];
}

// Display a menu bar, like is displayed at the top of the forum.
function ssi_menubar($output_method 'echo')
{
global $context;

if ($output_method == 'echo')
template_menu();
// What else could this do?
else
return $context['menu_buttons'];
}

// Show a logout link.
function ssi_logout($redirect_to ''$output_method 'echo')
{
global $context$txt$scripturl;

if ($redirect_to != '')
$_SESSION['logout_url'] = $redirect_to;

// Guests can't log out.
if ($context['user']['is_guest'])
return false;

$link '<a href="' $scripturl '?action=logout;' $context['session_var'] . '=' $context['session_id'] . '">' $txt['logout'] . '</a>';

if ($output_method == 'echo')
echo $link;
else
return $link;
}

// Recent post list:   [board] Subject by Poster Date
function ssi_recentPosts($num_recent 8$exclude_boards null$include_boards null$output_method 'echo'$limit_body true)
{
global $context$settings$scripturl$txt$db_prefix$user_info;
global $modSettings$smcFunc;

// Excluding certain boards...
if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
$exclude_boards = array($modSettings['recycle_board']);
else
$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));

// What about including certain boards - note we do some protection here as pre-2.0 didn't have this parameter.
if (is_array($include_boards) || (int) $include_boards === $include_boards)
{
$include_boards is_array($include_boards) ? $include_boards : array($include_boards);
}
elseif ($include_boards != null)
{
$include_boards = array();
}

// Let's restrict the query boys (and girls)
$query_where '
m.id_msg >= {int:min_message_id}
. (empty($exclude_boards) ? '' '
AND b.id_board NOT IN ({array_int:exclude_boards})'
) . '
. ($include_boards === null '' '
AND b.id_board IN ({array_int:include_boards})'
) . '
AND {query_wanna_see_board}' 
. ($modSettings['postmod_active'] ? '
AND m.approved = {int:is_approved}' 
'');

$query_where_params = array(
'is_approved' => 1,
'include_boards' => $include_boards === null '' $include_boards,
'exclude_boards' => empty($exclude_boards) ? '' $exclude_boards,
'min_message_id' => $modSettings['maxMsgID'] - 25 min($num_recent5),
);

// Past to this simpleton of a function...
return ssi_queryPosts($query_where$query_where_params$num_recent'm.id_msg DESC'$output_method$limit_body);
}

// Fetch a post with a particular ID. By default will only show if you have permission to the see the board in question - this can be overriden.
function ssi_fetchPosts($post_ids$override_permissions false$output_method 'echo')
{
global $user_info$modSettings;

// Allow the user to request more than one - why not?
$post_ids is_array($post_ids) ? $post_ids : array($post_ids);

// Restrict the posts required...
$query_where '
m.id_msg IN ({array_int:message_list})' 
. ($override_permissions '' '
AND {query_wanna_see_board}'
) . ($modSettings['postmod_active'] ? '
AND m.approved = {int:is_approved}' 
'');
$query_where_params = array(
'message_list' => $post_ids,
'is_approved' => 1,
);

// Then make the query and dump the data.
return ssi_queryPosts($query_where$query_where_params'''m.id_msg DESC'$output_method);
}

// This removes code duplication in other queries - don't call it direct unless you really know what you're up to.
function ssi_queryPosts($query_where ''$query_where_params = array(), $query_limit ''$query_order 'm.id_msg DESC'$output_method 'echo'$limit_body false)
{
global $context$settings$scripturl$txt$db_prefix$user_info;
global $modSettings$smcFunc;

// Find all the posts. Newer ones will have higher IDs.
$request $smcFunc['db_query']('substring''
SELECT
m.poster_time, m.subject, m.id_topic, m.id_member, m.id_msg, m.id_board, b.name AS board_name,
IFNULL(mem.real_name, m.poster_name) AS poster_name, ' 
. ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from'
) . ', ' . ($limit_body 'SUBSTRING(m.body, 1, 384) AS body' 'm.body') . ', m.smileys_enabled
FROM {db_prefix}messages AS m
INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' 
. (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = {int:current_member})
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = m.id_board AND lmr.id_member = {int:current_member})' 
'') . '
. (empty($query_where) ? '' 'WHERE ' $query_where) . '
ORDER BY ' 
$query_order '
. ($query_limit == '' '' 'LIMIT ' $query_limit),
array_merge($query_where_params, array(
'current_member' => $user_info['id'],
))
);
$posts = array();
while ($row $smcFunc['db_fetch_assoc']($request))
{
$row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);

// Censor it!
censorText($row['subject']);
censorText($row['body']);

$preview strip_tags(strtr($row['body'], array('<br />' => '&#38;#10;')));

// Build the array.
$posts[] = array(
'id' => $row['id_msg'],
'board' => array(
'id' => $row['id_board'],
'name' => $row['board_name'],
'href' => $scripturl '?board=' $row['id_board'] . '.0',
'link' => '<a href="' $scripturl '?board=' $row['id_board'] . '.0">' $row['board_name'] . '</a>'
),
'topic' => $row['id_topic'],
'poster' => array(
'id' => $row['id_member'],
'name' => $row['poster_name'],
'href' => empty($row['id_member']) ? '' $scripturl '?action=profile;u=' $row['id_member'],
'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' $scripturl '?action=profile;u=' $row['id_member'] . '">' $row['poster_name'] . '</a>'
),
'subject' => $row['subject'],
'short_subject' => shorten_subject($row['subject'], 25),
'preview' => $smcFunc['strlen']($preview) > 128 $smcFunc['substr']($preview0128) . '...' $preview,
'body' => $row['body'],
'time' => timeformat($row['poster_time']),
'timestamp' => forum_time(true$row['poster_time']),
'href' => $scripturl '?topic=' $row['id_topic'] . '.msg' $row['id_msg'] . ';topicseen#new',
'link' => '<a href="' $scripturl '?topic=' $row['id_topic'] . '.msg' $row['id_msg'] . '#msg' $row['id_msg'] . '" rel="nofollow">' $row['subject'] . '</a>',
'new' => !empty($row['is_read']),
'is_new' => empty($row['is_read']),
'new_from' => $row['new_from'],
);
}
$smcFunc['db_free_result']($request);

// Just return it.
if ($output_method != 'echo' || empty($posts))
return $posts;

echo '
<table border="0" class="ssi_table">'
;
foreach ($posts as $post)
echo '
<tr>
<td align="right" valign="top" nowrap="nowrap">
['
$post['board']['link'], ']
</td>
<td valign="top">
<a href="'
$post['href'], '">'$post['subject'], '</a>
'
$txt['by'], ' '$post['poster']['link'], '
'
$post['is_new'] ? '<a href="' $scripturl '?topic=' $post['topic'] . '.msg' $post['new_from'] . ';topicseen#new" rel="nofollow"><img src="' $settings['lang_images_url'] . '/new.gif" alt="' $txt['new'] . '" /></a>' '''
</td>
<td align="right" nowrap="nowrap">
'
$post['time'], '
</td>
</tr>'
;
echo '
</table>'
;
}

// Recent topic list:   [board] Subject by Poster Date
function ssi_recentTopics($num_recent 8$exclude_boards null$include_boards null$output_method 'echo')
{
global $context$settings$scripturl$txt$db_prefix$user_info;
global $modSettings$smcFunc;

if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
$exclude_boards = array($modSettings['recycle_board']);
else
$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));

// Only some boards?.
if (is_array($include_boards) || (int) $include_boards === $include_boards)
{
$include_boards is_array($include_boards) ? $include_boards : array($include_boards);
}
elseif ($include_boards != null)
{
$output_method $include_boards;
$include_boards = array();
}

$stable_icons = array('xx''thumbup''thumbdown''exclamation''question''lamp''smiley''angry''cheesy''grin''sad''wink''moved''recycled''wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

// Find all the posts in distinct topics.  Newer ones will have higher IDs.
$request $smcFunc['db_query']('substring''
SELECT
m.poster_time, ms.subject, m.id_topic, m.id_member, m.id_msg, b.id_board, b.name AS board_name, t.num_replies, t.num_views,
IFNULL(mem.real_name, m.poster_name) AS poster_name, ' 
. ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from'
) . ', SUBSTRING(m.body, 1, 384) AS body, m.smileys_enabled, m.icon
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_last_msg)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' 
. (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:current_member})
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = {int:current_member})' 
'') . '
WHERE t.id_last_msg >= {int:min_message_id}
. (empty($exclude_boards) ? '' '
AND b.id_board NOT IN ({array_int:exclude_boards})'
) . '
. (empty($include_boards) ? '' '
AND b.id_board IN ({array_int:include_boards})'
) . '
AND {query_wanna_see_board}' 
. ($modSettings['postmod_active'] ? '
AND t.approved = {int:is_approved}
AND m.approved = {int:is_approved}' 
'') . '
ORDER BY t.id_last_msg DESC
LIMIT ' 
$num_recent,
array(
'current_member' => $user_info['id'],
'include_boards' => empty($include_boards) ? '' $include_boards,
'exclude_boards' => empty($exclude_boards) ? '' $exclude_boards,
'min_message_id' => $modSettings['maxMsgID'] - 35 min($num_recent5),
'is_approved' => 1,
)
);
$posts = array();
while ($row $smcFunc['db_fetch_assoc']($request))
{
$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br />' => '&#38;#10;')));
if ($smcFunc['strlen']($row['body']) > 128)
$row['body'] = $smcFunc['substr']($row['body'], 0128) . '...';

// Censor the subject.
censorText($row['subject']);
censorText($row['body']);

if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' $row['icon'] . '.gif') ? 'images_url' 'default_images_url';

// Build the array.
$posts[] = array(
'board' => array(
'id' => $row['id_board'],
'name' => $row['board_name'],
'href' => $scripturl '?board=' $row['id_board'] . '.0',
'link' => '<a href="' $scripturl '?board=' $row['id_board'] . '.0">' $row['board_name'] . '</a>'
),
'topic' => $row['id_topic'],
'poster' => array(
'id' => $row['id_member'],
'name' => $row['poster_name'],
'href' => empty($row['id_member']) ? '' $scripturl '?action=profile;u=' $row['id_member'],
'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' $scripturl '?action=profile;u=' $row['id_member'] . '">' $row['poster_name'] . '</a>'
),
'subject' => $row['subject'],
'replies' => $row['num_replies'],
'views' => $row['num_views'],
'short_subject' => shorten_subject($row['subject'], 25),
'preview' => $row['body'],
'time' => timeformat($row['poster_time']),
'timestamp' => forum_time(true$row['poster_time']),
'href' => $scripturl '?topic=' $row['id_topic'] . '.msg' $row['id_msg'] . ';topicseen#new',
'link' => '<a href="' $scripturl '?topic=' $row['id_topic'] . '.msg' $row['id_msg'] . '#new" rel="nofollow">' $row['subject'] . '</a>',
// Retained for compatibility - is technically incorrect!
'new' => !empty($row['is_read']),
'is_new' => empty($row['is_read']),
'new_from' => $row['new_from'],
'icon' => '<img src="' $settings[$icon_sources[$row['icon']]] . '/post/' $row['icon'] . '.gif" align="middle" alt="' $row['icon'] . '" />',
);
}
$smcFunc['db_free_result']($request);

// Just return it.
if ($output_method != 'echo' || empty($posts))
return $posts;

echo '
<table border="0" class="ssi_table">'
;
foreach ($posts as $post)
echo '
<tr>
<td align="right" valign="top" nowrap="nowrap">
['
$post['board']['link'], ']
</td>
<td valign="top">
<a href="'
$post['href'], '">'$post['subject'], '</a>
'
$txt['by'], ' '$post['poster']['link'], '
'
, !$post['is_new'] ? '' '<a href="' $scripturl '?topic=' $post['topic'] . '.msg' $post['new_from'] . ';topicseen#new" rel="nofollow"><img src="' $settings['lang_images_url'] . '/new.gif" alt="' $txt['new'] . '" /></a>''
</td>
<td align="right" nowrap="nowrap">
'
$post['time'], '
</td>
</tr>'
;
echo '
</table>'
;
}

// Show the top poster's name and profile link.
function ssi_topPoster($topNumber 1$output_method 'echo')
{
global $db_prefix$scripturl$smcFunc;

// Find the latest poster.
$request $smcFunc['db_query']('''
SELECT id_member, real_name, posts
FROM {db_prefix}members
ORDER BY posts DESC
LIMIT ' 
$topNumber,
array(
)
);
$return = array();
while ($row $smcFunc['db_fetch_assoc']($request))
$return[] = array(
'id' => $row['id_member'],
'name' => $row['real_name'],
'href' => $scripturl '?action=profile;u=' $row['id_member'],
'link' => '<a href="' $scripturl '?action=profile;u=' $row['id_member'] . '">' $row['real_name'] . '</a>',
'posts' => $row['posts']
);
$smcFunc['db_free_result']($request);

// Just return all the top posters.
if ($output_method != 'echo')
return $return;

// Make a quick array to list the links in.
$temp_array = array();
foreach ($return as $member)
$temp_array[] = $member['link'];

echo implode(', '$temp_array);
}

// Show boards by activity.
function ssi_topBoards($num_top 10$output_method 'echo')
{
global $context$settings$db_prefix$txt$scripturl$user_info$modSettings$smcFunc;

// Find boards with lots of posts.
$request $smcFunc['db_query']('''
SELECT
b.name, b.num_topics, b.num_posts, b.id_board,' 
. (!$user_info['is_guest'] ? ' 1 AS is_read' '
(IFNULL(lb.id_msg, 0) >= b.id_last_msg) AS is_read'
) . '
FROM {db_prefix}boards AS b
LEFT JOIN {db_prefix}log_boards AS lb ON (lb.id_board = b.id_board AND lb.id_member = {int:current_member})
WHERE {query_wanna_see_board}' 
. (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > '
AND b.id_board != {int:recycle_board}' 
'') . '
ORDER BY b.num_posts DESC
LIMIT ' 
$num_top,
array(
'current_member' => $user_info['id'],
'recycle_board' => (int) $modSettings['recycle_board'],
)
);
$boards = array();
while ($row $smcFunc['db_fetch_assoc']($request))
$boards[] = array(
'id' => $row['id_board'],
'num_posts' => $row['num_posts'],
'num_topics' => $row['num_topics'],
'name' => $row['name'],
'new' => empty($row['is_read']),
'href' => $scripturl '?board=' $row['id_board'] . '.0',
'link' => '<a href="' $scripturl '?board=' $row['id_board'] . '.0">' $row['name'] . '</a>'
);
$smcFunc['db_free_result']($request);

// If we shouldn't output or have nothing to output, just jump out.
if ($output_method != 'echo' || empty($boards))
return $boards;

echo '
<table class="ssi_table">
<tr>
<th align="left">'
$txt['board'], '</th>
<th align="left">'
$txt['board_topics'], '</th>
<th align="left">'
$txt['posts'], '</th>
</tr>'
;
foreach ($boards as $board)
echo '
<tr>
<td>'
$board['link'], $board['new'] ? ' <a href="' $board['href'] . '"><img src="' $settings['lang_images_url'] . '/new.gif" alt="' $txt['new'] . '" /></a>' '''</td>
<td align="right">'
comma_format($board['num_topics']), '</td>
<td align="right">'
comma_format($board['num_posts']), '</td>
</tr>'
;
echo '
</table>'
;
}

// Shows the top topics.
function ssi_topTopics($type 'replies'$num_topics 10$output_method 'echo')
{
global $db_prefix$txt$scripturl$user_info$modSettings$smcFunc$context;

if ($modSettings['totalMessages'] > 100000)
{
// !!! Why don't we use {query(_wanna)_see_board}?
$request $smcFunc['db_query']('''
SELECT id_topic
FROM {db_prefix}topics
WHERE num_' 
. ($type != 'replies' 'views' 'replies') . ' != 0' . ($modSettings['postmod_active'] ? '
AND approved = {int:is_approved}' 
'') . '
ORDER BY num_' 
. ($type != 'replies' 'views' 'replies') . ' DESC
LIMIT {int:limit}'
,
array(
'is_approved' => 1,
'limit' => $num_topics 100 ? ($num_topics + ($num_topics 2)) : 100,
)
);
$topic_ids = array();
while ($row $smcFunc['db_fetch_assoc']($request))
$topic_ids[] = $row['id_topic'];
$smcFunc['db_free_result']($request);
}
else
$topic_ids = array();

$request $smcFunc['db_query']('''
SELECT m.subject, m.id_topic, t.num_views, t.num_replies
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
WHERE {query_wanna_see_board}' 
. ($modSettings['postmod_active'] ? '
AND t.approved = {int:is_approved}' 
'') . (!empty($topic_ids) ? '
AND t.id_topic IN ({array_int:topic_list})' 
'') . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > '
AND b.id_board != {int:recycle_enable}' 
'') . '
ORDER BY t.num_' 
. ($type != 'replies' 'views' 'replies') . ' DESC
LIMIT {int:limit}'
,
array(
'topic_list' => $topic_ids,
'is_approved' => 1,
'recycle_enable' => $modSettings['recycle_board'],
'limit' => $num_topics,
)
);
$topics = array();
while ($row $smcFunc['db_fetch_assoc']($request))
{
censorText($row['subject']);

$topics[] = array(
'id' => $row['id_topic'],
'subject' => $row['subject'],
'num_replies' => $row['num_replies'],
'num_views' => $row['num_views'],
'href' => $scripturl '?topic=' $row['id_topic'] . '.0',
'link' => '<a href="' $scripturl '?topic=' $row['id_topic'] . '.0">' $row['subject'] . '</a>',
);
}
$smcFunc['db_free_result']($request);

if ($output_method != 'echo' || empty($topics))
return $topics;

echo '
<table class="ssi_table">
<tr>
<th align="left"></th>
<th align="left">'
$txt['views'], '</th>
<th align="left">'
$txt['replies'], '</th>
</tr>'
;
foreach ($topics as $topic)
echo '
<tr>
<td align="left">
'
$topic['link'], '
</td>
<td align="right">'
comma_format($topic['num_views']), '</td>
<td align="right">'
comma_format($topic['num_replies']), '</td>
</tr>'
;
echo '
</table>'
;
}

// Shows the top topics, by replies.
function ssi_topTopicsReplies($num_topics 10$output_method 'echo')
{
return ssi_topTopics('replies'$num_topics$output_method);
}

// Shows the top topics, by views.
function ssi_topTopicsViews($num_topics 10$output_method 'echo')
{
return ssi_topTopics('views'$num_topics$output_method);
}

// Show a link to the latest member:  Please welcome, Someone, out latest member.
function ssi_latestMember($output_method 'echo')
{
global $db_prefix$txt$scripturl$context;

if ($output_method == 'echo')
echo '
'
$txt['welcome_member'], ' '$context['common_stats']['latest_member']['link'], ''$txt['newest_member'], '<br />';
else
return $context['common_stats']['latest_member'];
}

// Fetch a random member - if type set to 'day' will only change once a day!
function ssi_randomMember($random_type ''$output_method 'echo')
{
global $modSettings;

// If we're looking for something to stay the same each day then seed the generator.
if ($random_type == 'day')
{
// Set the seed to change only once per day.
mt_srand(floor(time() / 86400));
}

// Get the lowest ID we're interested in.
$member_id mt_rand(1$modSettings['latestMember']);

$where_query '
id_member >= {int:selected_member}
AND is_activated = {int:is_activated}'
;

$query_where_params = array(
'selected_member' => $member_id,
'is_activated' => 1,
);

$result ssi_queryMembers($where_query$query_where_params1'id_member ASC'$output_method);

// If we got nothing do the reverse - in case of unactivated members.
if (empty($result))
{
$where_query '
id_member <= {int:selected_member}
AND is_activated = {int:is_activated}'
;

$query_where_params = array(
'selected_member' => $member_id,
'is_activated' => 1,
);

$result ssi_queryMembers($where_query$query_where_params1'id_member DESC'$output_method);
}

// Just to be sure put the random generator back to something... random.
if ($random_type != '')
mt_srand(time());

return $result;
}

// Fetch a specific member.
function ssi_fetchMember($member_ids$output_method 'echo')
{
// Can have more than one member if you really want...
$member_ids is_array($member_ids) ? $member_ids : array($member_ids);

// Restrict it right!
$query_where '
id_member IN ({array_int:member_list})'
;

$query_where_params = array(
'member_list' => $member_ids,
);

// Then make the query and dump the data.
return ssi_queryMembers($query_where$query_where_params'''id_member'$output_method);
}

anthonymims

#10
Code brackets kept dissapearing. 

Colin

You might be better off attaching the file.
"If everybody is thinking alike, then somebody is not thinking." - Gen. George S. Patton Jr.

Colin

anthonymims

Yeah I gave up trying to get the bracket to stay for the last half of the code.  It is attached.

Kindred

hmmmm.....    not sure, but try this:

Save the existing file as SSI-backup.php and load in a fresh copy of the SSI file from the distribution archive.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

anthonymims


anthonymims

I am completely out of ideas

anthonymims

Hmm  I moved a temp copy of the page into the root for the forums and no longer have the issue.  A LOT of stuff I have to change if that is where it is going to be.  Is there possibly a setting somewhere that is making it go to index.php for the forums instead when it enters that directory?

Kindred

something very odd is going on with your system...   because I have used SSI successfully not only in a different directoy, but across subdomains.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

anthonymims

What could make a require() function point to index.php instead of a different file when going to another directory?

anthonymims

Also if I require the SSI.php file and nothing else (the file I am using to require the SSI.php file is in same directory as the SSI.php file) in firefox, nothing comes up.  White screen.  Was a good sign in my opinion, means the page wasn't being hyjacked.  BUT viewing the same file in internet explorer, the page is being hyjacked again.

http://www.dirtracefans.com/forums/dvds.php [nofollow]     View the link in FireFox and IE to see what I mean.

Advertisement: