Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: caal0403 on August 10, 2012, 06:02:40 AM

Title: SSI help
Post by: caal0403 on August 10, 2012, 06:02:40 AM
Hi there i am trying to show my latest posts on my website.
I tried putting
<?php require("/home/mysite/public_html/core/modules/forum/SSI.php"); ?>

at the top of my page but when i goto my website now it redirects to my forum
Title: Re: SSI help
Post by: Ricky. on August 10, 2012, 06:10:35 AM
Hope you are calling it with right path, addition to call / include SSI.php , you also need to add following:
<?php ssi_recentTopics(); ?>
It will show your recent topics.

More example you can see here :
http://www.simplemachines.org/community/ssi_examples.php
Title: Re: SSI help
Post by: caal0403 on August 10, 2012, 06:18:53 AM
sorry for posting in wrong place :-[
Thanks for the reply. I am sorry I only have basic knowledge of this
so i need to put at the top of my page before the HTML tag


<?php require("/home/mysite/public_html/core/modules/forum/SSI.php"); ?>
<?php ssi_recentTopics(); ?>

I tried this and it still went to my forum
Title: Re: SSI help
Post by: Kays on August 10, 2012, 11:44:26 AM
Hi, and welcome to SMF. :)

What sort of a page is your site? .php or .html? Gotta link to you site. (post it inside code tags since you've got less than 10 post)

Normally, if you just include SSI.php, nothing should happen. If it's added to an empty page that's all you'll see, nothing. So what else is on that page which could cause this?

Quote
so i need to put at the top of my page before the HTML tag

The code to include SSI.php should be at the beginning of the page. The code for ssi_recentTopics() should go after the <body> tag.
Title: Re: SSI help
Post by: caal0403 on August 10, 2012, 01:45:14 PM
hi my site is www.caalair.com

Thanks for the reply
Title: Re: SSI help
Post by: Kays on August 10, 2012, 06:54:57 PM
Thanks, but that doesn't show me much expect that the page is probably php.

Any chance you can attach whatever page you are trying to edit so that we can have a look at it.
Title: Re: SSI help
Post by: caal0403 on August 10, 2012, 07:07:06 PM
Hi there here is the cde for the page

<html>

<img src="http://www.caalair.com/core/jet.gif">



<p> </p>
<div style="width:600px;height:270px;border:2px solid green;">
<div style='text-align: left; font-weight: bold; font-size: 200%;
                                      color: #009933'>WELCOME TO CAAL AIRWAYS VIRTUAL <p> </p> </div>
<p>
<span style="color: #00f"><strong><span style="font-size: 14px">This VA came into existance on the 20/8/11 and has its main hub in Belfast Aldergrove N Ireland. Our callsign is CLOVER. The VA is split into 4 aeras of operations. They are Ireland(north&amp;south), UK, USA and South Africa. &nbsp;There is also a cargo hub at London Stansted which is run by our Fleet Manager. Each area of operations has an Operations Manager who lives local to that aera, and each aera has 2 hubs with the exception of the USA which has 3.It is not compulsory to fly online although we do encourage it, but it is totally up to you. It is totally fictional and routes will be added on request. Caal Airways is for fun and enjoyment for everyone who enjoys flight sim and can be as real life as you want. We are not bound by alot of rules and regulations all we ask is that you fly whenever you can.. Feel free to browse the website and register if you think it is for you.</span></strong></span></p>


</div>
<p>
<div style="width:600px;height:40px;border:2px solid green;">
<p style="text-align: center">
<strong><span style="color: #f00">IF YOU VISITED AND DID NOT JOIN PLEASE TELL US WHY , OR IF YOU WOULD LIKE TO COMMENT CLICK <a href="http://www.caalair.com/core/feedback_form.html">HERE</a></span></strong></p>

</div>
<p> </p>


<?php MainController::Run('Mail', 'checkmail'); ?>
<p> </p>
<?php
   $pilotsflying
= count(ACARSData::GetACARSData());
        echo
'<marquee align="left" direction="left" onmouseover="this.stop();" onmouseout="this.start();" behavior="scroll" width="600">';
       if(
$pilotsflying > 0)
           { echo
'There are '.$pilotsflying.' xacars flights in progress - click <a href="'.SITE_URL.'/index.php/acars">here</a> to view'; }
           else
           { echo
'There are no flights in progress'; }
       echo
'</marquee>';
?>
<p> </p>

<p> </p>
<p> </p>
<div id="fboard"><?php MainController::Run('FrontBids', 'RecentFrontPage', 10); ?></div>
<p> </p>
<h2>Vatsim Live Flights</h2>
CLICK ON THE BOARD AT THE ICAO CODE TO CHANGE TO A DIFFERENT AIRLINE OR AIRPORT
<object id='RealtimeNG' codeBase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0' align='middle' style='width:600px;height:328px' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' salign='t'><param name='Movie' value='http://www.utr-online.com/RealtimeNG.swf?refApt=NIR'><param name='bgcolor' value='#000000'><param name='menu' value='false'><param name='allowScriptAccess' value='always'><param name='FlashVars' value='fontcolor1=DDDDDD&fontcolor2=000000&fontcolor3=2ECF14&network=VATSIM&NRLines=15&switch=30&switchnetwork=0&locked=0&range=0&sound=0&logos=1&VAName=CAAL AIRWAYS'><embed src='http://www.utr-online.com/RealtimeNG.swf?refApt=NIR' allowScriptAccess='always' FlashVars='fontcolor1=DDDDDD&fontcolor2=000000&fontcolor3=2ECF14&network=VATSIM&NRLines=15&switch=30&switchnetwork=0&locked=0&range=0&sound=0&logos=1&VAName=CAAL AIRWAYS' quality='high' bgcolor='#000000' width='600' height='328' name='RealtimeNG' menu='false' align='middle' salign='t' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed></object>
<p> </p>
<p> </p>
<div style="width:600px;height:185px;border:2px solid green;">
<center><?php Screenshots::show_random_screenshot(); ?></center>

</div>
<p> </p>
<iframe width="600" height="315" src="http://www.youtube.com/embed/FLYAd-pAGvE" frameborder="0" allowfullscreen></iframe>
<p> </p>

<h2>OUR STATS</h2>

<table style="border:1px solid grey;" cellspacing="0" cellpadding="0" bgcolor="#1F1F1F">


                                     

<tr>
<td valign="top" width="40%" nowrap="nowrap" >
<strong>Total Pilots: </strong><?php echo StatsData::PilotCount(); ?><br />
<strong>Total Flights: </strong><?php echo StatsData::TotalFlights(); ?><br />
<strong>Total Hours Flown: </strong><?php echo StatsData::TotalHours(); ?>
</td>
<td valign="top" width="33%" nowrap="nowrap" >
<strong>Miles Flown: </strong><?php echo StatsData::TotalMilesFlown(); ?><br />
<strong>Total Schedules: </strong><?php echo StatsData::TotalSchedules(); ?><br />
<strong>Flights Today: </strong><?php echo StatsData::TotalFlightsToday();?>
               

</td>
</tr>
</table>


<p> </p>


<h2>LAST FIVE FLIGHTS</h2>
<div style="width:550px;height:130px;border:2px solid green;">
<?php>

$count = 5;
$pireps = PIREPData::getRecentReportsByCount($count);
?>
<div>
<table>

   <thead>

     <tr>
       <th>Flight </th>
       <th>Departure</th>
       <th>Arrival</th>
       <th>Duration</th>
       <th>Pilot</th>
       <th>Landing Rate</th>
     </tr>
    </thead>
    <tbody>
    </div>
<?php

if(count($pireps) > 0)
{
 foreach (
$pireps as $pirep)
 {
   
$pilotinfo = PilotData::getPilotData($pirep->pilotid);
   
$pilotid = PilotData::getPilotCode($pilotinfo->code, $pilotinfo->pilotid);

   echo
'<tr>';
   echo
'<td>'.$pirep->code.$pirep->flightnum.'</td>';
   echo
'<td>'.$pirep->depicao.'</td>';
   echo
'<td>'.$pirep->arricao.'</td>';
   echo
'<td>'.$pirep->flighttime.'</td>';
   echo
'<td>'.$pilotid.' '.$pilotinfo->firstname.' '.$pilotinfo->lastname.'</td>';
   echo
'<td>'.$pirep->landingrate.'</td>';
   echo
'</tr>';
 }
}
else
{
   echo
'<tr><td colspan="6">There are no recent flights!</td></tr>';
}
?>
</table>
</div>

   </tbody>


</div>



is this what you need.
Thanks
Title: Re: SSI help
Post by: Kays on August 10, 2012, 08:09:07 PM
Yes that helps, thanks. :)

You should be able to include SSI.php at the top of that page. ssi_recentTopics() is returned as a table. So it should go outside of any <div> or <table>. For a start to test it. Place it right after the call to SSI.php.
Title: Re: SSI help
Post by: caal0403 on August 10, 2012, 08:37:58 PM
I tried this but no luck. Did i do it right

<?php require("/home/airlingu/public_html/core/modules/forum/SSI.php"); ?>
<?php ssi_recentTopics($num_recent = 8, $exclude_boards = null, $include_boards = null, $output_method = 'echo'); ?>

<html>

<img src="http://www.caalair.com/core/jet.gif">



<p> </p>
<div style="width:600px;height:270px;border:2px solid green;">
<div style='text-align: left; font-weight: bold; font-size: 200%;
                                      color: #009933'>WELCOME TO CAAL AIRWAYS VIRTUAL <p> </p> </div>
<p>
<span style="color: #00f"><strong><span style="font-size: 14px">This VA came into existance on the 20/8/11 and has its main hub in Belfast Aldergrove N Ireland. Our callsign is CLOVER. The VA is split into 4 aeras of operations. They are Ireland(north&amp;south), UK, USA and South Africa. &nbsp;There is also a cargo hub at London Stansted which is run by our Fleet Manager. Each area of operations has an Operations Manager who lives local to that aera, and each aera has 2 hubs with the exception of the USA which has 3.It is not compulsory to fly online although we do encourage it, but it is totally up to you. It is totally fictional and routes will be added on request. Caal Airways is for fun and enjoyment for everyone who enjoys flight sim and can be as real life as you want. We are not bound by alot of rules and regulations all we ask is that you fly whenever you can.. Feel free to browse the website and register if you think it is for you.</span></strong></span></p>


</div>
<p>
<div style="width:600px;height:40px;border:2px solid green;">
<p style="text-align: center">
<strong><span style="color: #f00">IF YOU VISITED AND DID NOT JOIN PLEASE TELL US WHY , OR IF YOU WOULD LIKE TO COMMENT CLICK <a href="http://www.caalair.com/core/feedback_form.html">HERE</a></span></strong></p>

</div>
<p> </p>


<?php MainController::Run('Mail', 'checkmail'); ?>
<p> </p>
<?php
   $pilotsflying
= count(ACARSData::GetACARSData());
        echo
'<marquee align="left" direction="left" onmouseover="this.stop();" onmouseout="this.start();" behavior="scroll" width="600">';
       if(
$pilotsflying > 0)
           { echo
'There are '.$pilotsflying.' xacars flights in progress - click <a href="'.SITE_URL.'/index.php/acars">here</a> to view'; }
           else
           { echo
'There are no flights in progress'; }
       echo
'</marquee>';
?>
<p> </p>

<p> </p>
<p> </p>
<div id="fboard"><?php MainController::Run('FrontBids', 'RecentFrontPage', 10); ?></div>
<p> </p>
<h2>Vatsim Live Flights</h2>
CLICK ON THE BOARD AT THE ICAO CODE TO CHANGE TO A DIFFERENT AIRLINE OR AIRPORT
<object id='RealtimeNG' codeBase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0' align='middle' style='width:600px;height:328px' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' salign='t'><param name='Movie' value='http://www.utr-online.com/RealtimeNG.swf?refApt=NIR'><param name='bgcolor' value='#000000'><param name='menu' value='false'><param name='allowScriptAccess' value='always'><param name='FlashVars' value='fontcolor1=DDDDDD&fontcolor2=000000&fontcolor3=2ECF14&network=VATSIM&NRLines=15&switch=30&switchnetwork=0&locked=0&range=0&sound=0&logos=1&VAName=CAAL AIRWAYS'><embed src='http://www.utr-online.com/RealtimeNG.swf?refApt=NIR' allowScriptAccess='always' FlashVars='fontcolor1=DDDDDD&fontcolor2=000000&fontcolor3=2ECF14&network=VATSIM&NRLines=15&switch=30&switchnetwork=0&locked=0&range=0&sound=0&logos=1&VAName=CAAL AIRWAYS' quality='high' bgcolor='#000000' width='600' height='328' name='RealtimeNG' menu='false' align='middle' salign='t' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed></object>
<p> </p>
<p> </p>
<div style="width:600px;height:185px;border:2px solid green;">
<center><?php Screenshots::show_random_screenshot(); ?></center>

</div>
<p> </p>
<iframe width="600" height="315" src="http://www.youtube.com/embed/FLYAd-pAGvE" frameborder="0" allowfullscreen></iframe>
<p> </p>

<h2>OUR STATS</h2>

<table style="border:1px solid grey;" cellspacing="0" cellpadding="0" bgcolor="#1F1F1F">


                                     

<tr>
<td valign="top" width="40%" nowrap="nowrap" >
<strong>Total Pilots: </strong><?php echo StatsData::PilotCount(); ?><br />
<strong>Total Flights: </strong><?php echo StatsData::TotalFlights(); ?><br />
<strong>Total Hours Flown: </strong><?php echo StatsData::TotalHours(); ?>
</td>
<td valign="top" width="33%" nowrap="nowrap" >
<strong>Miles Flown: </strong><?php echo StatsData::TotalMilesFlown(); ?><br />
<strong>Total Schedules: </strong><?php echo StatsData::TotalSchedules(); ?><br />
<strong>Flights Today: </strong><?php echo StatsData::TotalFlightsToday();?>
               

</td>
</tr>
</table>


<p> </p>


<h2>LAST FIVE FLIGHTS</h2>
<div style="width:550px;height:130px;border:2px solid green;">
<?php>

$count = 5;
$pireps = PIREPData::getRecentReportsByCount($count);
?>
<div>
<table>

   <thead>

     <tr>
       <th>Flight </th>
       <th>Departure</th>
       <th>Arrival</th>
       <th>Duration</th>
       <th>Pilot</th>
       <th>Landing Rate</th>
     </tr>
    </thead>
    <tbody>
    </div>
<?php

if(count($pireps) > 0)
{
 foreach (
$pireps as $pirep)
 {
   
$pilotinfo = PilotData::getPilotData($pirep->pilotid);
   
$pilotid = PilotData::getPilotCode($pilotinfo->code, $pilotinfo->pilotid);

   echo
'<tr>';
   echo
'<td>'.$pirep->code.$pirep->flightnum.'</td>';
   echo
'<td>'.$pirep->depicao.'</td>';
   echo
'<td>'.$pirep->arricao.'</td>';
   echo
'<td>'.$pirep->flighttime.'</td>';
   echo
'<td>'.$pilotid.' '.$pilotinfo->firstname.' '.$pilotinfo->lastname.'</td>';
   echo
'<td>'.$pirep->landingrate.'</td>';
   echo
'</tr>';
 }
}
else
{
   echo
'<tr><td colspan="6">There are no recent flights!</td></tr>';
}
?>
</table>
</div>

   </tbody>


</div>


Title: Re: SSI help
Post by: Kays on August 10, 2012, 10:03:18 PM
Just using <?php ssi_recentTopics(); ?> should work as it will display the default values. You can get fancy later. :)

Since your forum appears to be buried deep in your site, verify these settings. Especially the middle one.

In the Admin CP> Server Settings > Cookies and Sessions:

Enable local storage of cookies - unchecked
Use subdomain independent cookies - checked
Use database driven sessions - checked
Title: Re: SSI help
Post by: caal0403 on August 11, 2012, 06:11:11 AM
ok i have changed all that but it is still going to my log in page arghhhhhh
Title: Re: SSI help
Post by: Kays on August 11, 2012, 12:07:46 PM
Is it doing that with only SSI.php included or when you add ssi_recentTopics().

There's another page which is generated to add the <head> information. Try and locate that and add the call to SSI.php there.
Title: Re: SSI help
Post by: caal0403 on August 11, 2012, 12:33:02 PM
Yes it is doing it with just the ssi.php as well as with ssi_recentTopics().

I tried a couple of different file but still the same result  :(
Title: Re: SSI help
Post by: Kays on August 11, 2012, 01:15:53 PM
I can't see why that's happening. All that SSI.php does is to load the data from SMF to allow the ssi_ functions to be called. To the best of my knowledge, there's nothing in there to send you to the login page unless it's called. Unless it's something in that script which is doing that.

If there's support for that script, try posting there and see if anyone knows of a reason something like this is happening.
Title: Re: SSI help
Post by: caal0403 on August 11, 2012, 02:26:51 PM
Ok Kays thanks for all your help anyway. may just have to forget about this idea :(
Title: Re: SSI help
Post by: caal0403 on August 11, 2012, 02:57:50 PM
I have sent you a PM Kays as I didnt want to post sensitive info on the forum
Title: Re: SSI help
Post by: Kays on August 12, 2012, 10:13:37 AM
The only thing I can think to do is the create a separate page with the call to SSI.php on it and the ssi_recent topics. Access that page to verify that it does work as it should. Then try including that into your site page. If it still does the same at least you've verified that SSI.php does work as it should and the problem is probably with your that script you are using.
Title: Re: SSI help
Post by: caal0403 on August 12, 2012, 10:47:40 AM
Hi Kays,
Created the new page called it latestpost.php

<?php require("/home/airlingu/public_html/core/modules/forum/SSI.php"); ?>
<?php ssi_recentTopics(); ?>



Called the page and was redirected to the log in page
Title: Re: SSI help
Post by: caal0403 on August 12, 2012, 11:08:58 AM
Sorry Kays this is the address of the new page http://www.caalair.com/core/latestpost.php
Title: Re: SSI help
Post by: MrPhil on August 12, 2012, 11:11:52 AM
First of all, combine your separate PHP lines:
<?php
 
require("/home/airlingu/public_html/core/modules/forum/SSI.php");
 
ssi_recentTopics();
?>

That's so much cleaner and easier to read.

You've confirmed that /home/airlingu/public_html/core/modules/forum/ is where SSI.php actually is? Is SSI.php readable (typically 644 permissions)? Have you checked both your SMF and system error logs to see if it's complaining that it can't find/read the file?

You've tried commenting out (with //) the ssi_recentTopics() call, and it still redirects? If not, do you have something in your member permissions that could be denying access to members not signed on (guests)? I'm not sure that SSI even looks at permissions, but that's all I can think of that might be forcing guests to the login page once ssi_recentTopics() is called. If simply requiring the SSI.php file is causing a login page redirect, what do you have in .htaccess file(s)? Anything there that might be sending guests to login? You might try commenting out (#) redirection stuff to isolate the problem. Your "latestpost.php" is running in / (public_html)? AFAIK, it should be OK to call SSI functions from any directory (after SSI.php is loaded), but just for grins you might move latestpost.php to the same directory as SSI.php lives in (and change the "require" path), and see if it makes any difference.
Title: Re: SSI help
Post by: caal0403 on August 12, 2012, 11:26:34 AM
Mr Phil you are a star. I moved the latestpost.php to the same directory as th ssi.php as you said and it worked.
Thank you all for your help and if like me you will have all got a few more grey hairs lol ;D
Title: Re: SSI help
Post by: MrPhil on August 12, 2012, 04:52:50 PM
Well, I would have thought that you could have latestpost.php in any directory and it should work. I'm worried that it should have worked as you had it originally. Maybe someone more familiar with SSI usage can speak to this? Perhaps you have another mod installed which has "hard wired" some function to a specific directory?
Title: Re: SSI help
Post by: caal0403 on August 13, 2012, 11:39:49 AM
Hi all,
Just an update. I hadnt solved the issue so i went back to basics and I moved my forum folder to the root directory put in the ssi and hey presto its working. I guess i had my folder burried to far into my site. Just one question. How can I align the posts to the left as it looks a little untidy at the moment. I think they may be aligned to the centre. Once again thanks for all the help :)
Title: Re: SSI help
Post by: Kays on August 14, 2012, 10:54:17 AM
I thoughtthat it was buried a bit too deep. But that still is weird behaivour.

To change the display. You can either modify it in SSI.php. Not recommended if you intend to use that function elsewhere.

Or output it as an array. The second FAQ covers that. ssi_boardNews is used for the example but the principle is the same.

[README] SSI FAQ's (http://www.simplemachines.org/community/index.php?topic=14906.0)