Advertisement:

Author Topic: Basic SSI FAQ  (Read 148410 times)

Offline Tomer

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 1,652
  • Gender: Male
    • Aromazing
Basic SSI FAQ
« on: June 23, 2004, 05:06:24 AM »
Basic SSI FAQ

Hello and welcome to the Basic SSI FAQ, in this FAQ you will learn the basics of whats SSI, can it be used to my needs and how, this FAQ has commonly asked SSI questions as well as tips and tricks, you will also find a list of attached scripts to the end of this post that may help you with what you have learned in this FAQ. If at the end you still have questions or comments, please post them.
Your feedback if very imporant to me.

**PLEASE DO NOT EDIT YOUR 'SSI.PHP' FILE**
Everything done here is done without having to edit 'SSI.php'


Whats SSI?

SSI - Server Side Includes, is a feature we use to help link our community board to the rest of our site, it also helps us take forum stats, news, announcements, recent posts...etc and view those things on other pages in our site.

How Can SSI Help me?

Even you can find use with SSI, lets take an example:

Example:

You have a site, and also a forum, and you want that when members are logged in, they will see a special downloads area on the downloads screen.

For something like this, SSI is needed and can be created in minutes

Fine SSI is good, how do I start using it?

The first thing you need to do is open a new file somewhere in your site, and give it a .php extention. Then open your text editer for that file and write this code:

Code: [Select]
<?php
require("/home/simple/public_html/forum/SSI.php"); 
?>

But make sure the path is the correct path for you to the 'SSI.php' file located in your forum directory, to see YOUR correct path, check out the top part of 'ssi_examples.php' file located in your forum directory.

Ok I got the correct path to 'SSI.php', whats next?

Ok if you have got your correct path to SSI.php and written it in the file you created in the format I showed above, then good job.
Next we will try to add features to your page [eg. menu bar, whos online list...etc]. Try this code between the 'require...' statement and the '?>' code

Code: [Select]
ssi_menubar();

Now try going to your page in your browser, if everything went well, you should see your menu bar from your forum, if you dont see anything there or some error message, that is probaly because you didnt write that correct path to your 'SSI.php' file.
Well now that you got this working, you can go have fun with it, you can add many functions to your page, all the functions are listed in the 'ssi_examples.php' file located in your forum directory. [Also your correct 'SSI.php' path is listed in that file at the top]

That was cool, anymore?

Yes, there is more to SSI then the functions, now I will show you how the user premissions works with showing you how to write this example:

Example:

You have a site, and also a forum, and you want that when members are logged in, they will see a special downloads area on the downloads screen.
This is easy stuff to do, and I will show you how using PHP's 'if' statement:

Code: [Select]
<?php
require("YOUR_PATH_TO_SSI.php"); 

if (
$context[&#39;user&#39;][&#39;is_guest&#39;])
 
{
   echo 
   &
#39;<h5>Access Denied</h5>
   
We are sorry guestit seems you dont have premission to view these downloads.&#39;;
 
}
else
 {
   echo
   &
#39;<h5>Welcome &#39;, $context[&#39;user&#39;][&#39;name&#39;], &#39;!</h5>
   
Here are your downloads:&#39;;
 
}
?>


I will explain the script I have written above:
The 'if' statments works on true and flase, if the statement [In our case: ($context['user']['is_guest'])] is true, the first block is activated, and if false, the 'else' block is activated.
So in our case, if you aren't logged in [You are a guest] you will see an access denied message, and if you are logged in, you will see the downloads area. You can use that in any way you wish.

You can do the same thing but with admin

Code: [Select]
if ($context['allow_admin'])
  {
   Block of statements
  }
else
  {
   Block of statements
  }

Well this pretty much covers the basic Guide, the next guide is: 'Advanced SSI FAQ'.

Attached to the end of this post are some sample scripts that may help you out.
  • membergroup.txt Put's your membergroup in a variable for later use.
  • welcome.txt If your a guest, shows a login box, if not, a welcome message.

If this FAQ has helped you in any way please post in this thread your opinions of it, what was unclear, confusing...etc
Your feedback is very important to me. :)

Thanks

-Lamper
« Last Edit: January 27, 2006, 08:17:14 AM by ªcF »

Offline Owdy

  • SMF Fossil
  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 15,590
  • Gender: Male
  • W00t!
    • janoloferiksson on LinkedIn
    • @@jaoler on Twitter
Re: Basic SSI FAQ
« Reply #1 on: June 23, 2004, 12:47:19 PM »
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

Offline TodaysXt

  • Semi-Newbie
  • *
  • Posts: 61
  • www.TodaysXtra.com
    • TodaysXtra.com
Re: Basic SSI FAQ
« Reply #2 on: June 23, 2004, 06:27:27 PM »
I think it's helpful and want to read the advance section.  I had the bare min. on my page but now I know how to use the "if ($context['user']['is_guest'])," with this.
Thanks for your work
Xt.

TodaysXt

Offline Tomer

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 1,652
  • Gender: Male
    • Aromazing
Re: Basic SSI FAQ
« Reply #3 on: June 23, 2004, 06:31:17 PM »
Thanks, I will write the advanced soon.

Offline Cypher7

  • Sophist Member
  • *****
  • Posts: 1,246
  • Gender: Male
  • PMPN8EZ
    • Dublin Airport Tae Kwon Do
Re: Basic SSI FAQ
« Reply #4 on: June 23, 2004, 06:34:51 PM »
Yea, great work.

I really wanted to use SSI, but hadn't a clue how to implement it...! And that FAQ was all I needed to get started!

Now I can go have some fun!  ;D

Offline Tomer

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 1,652
  • Gender: Male
    • Aromazing
Re: Basic SSI FAQ
« Reply #5 on: June 23, 2004, 06:35:50 PM »
Thanks a lot! :d Really means a lot of I helped someone.

Anyone got any hints on how to make it better, something that wasnt clear, confusing, anything?

Offline Cypher7

  • Sophist Member
  • *****
  • Posts: 1,246
  • Gender: Male
  • PMPN8EZ
    • Dublin Airport Tae Kwon Do
Re: Basic SSI FAQ
« Reply #6 on: June 23, 2004, 07:02:13 PM »
Thanks a lot! :d Really means a lot of I helped someone.

Anyone got any hints on how to make it better, something that wasnt clear, confusing, anything?

nope, it was pretty clear to me! And I have NO clue about php!

only thing I could see was a typo  :P

Quote
The 'i'f statments works on true and flase


Offline Tomer

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 1,652
  • Gender: Male
    • Aromazing
Re: Basic SSI FAQ
« Reply #7 on: June 23, 2004, 07:03:39 PM »
Fixed.

Check out the sample scripts attachched to the first post.

Offline Cypher7

  • Sophist Member
  • *****
  • Posts: 1,246
  • Gender: Male
  • PMPN8EZ
    • Dublin Airport Tae Kwon Do
Re: Basic SSI FAQ
« Reply #8 on: June 23, 2004, 07:10:49 PM »
oooh, that welcome one is nice! and so simple!

I'll be using that one!!

Offline Rpg Cyco

  • Semi-Newbie
  • *
  • Posts: 52
  • Gender: Male
    • The Cyco Safe House
Re: Basic SSI FAQ
« Reply #9 on: June 24, 2004, 01:51:25 AM »
Great work Lamper, helped me a lot. :)

l8ter

Rpg Cyco

Offline Tomer

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 1,652
  • Gender: Male
    • Aromazing
Re: Basic SSI FAQ
« Reply #10 on: June 24, 2004, 03:04:00 AM »
Thanks. :)

Offline Anguz

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,430
  • Gender: Male
    • cristianlavaque.com
Re: Basic SSI FAQ
« Reply #11 on: June 24, 2004, 10:46:52 AM »
good work Lamper (^_^)

some may find it useful to know if they can restrict access to different areas depending on other membergroups other than Guest or Admin
Cristián Lávaque http://cristianlavaque.com

Offline mcdougrs

  • Semi-Newbie
  • *
  • Posts: 63
  • Gender: Male
    • MapleAve.net
Re: Basic SSI FAQ
« Reply #12 on: June 24, 2004, 03:43:30 PM »
VERY nice Basic Tutorial!! I can't WAIT for the Advanced version of it, especially if you could explain the array output method a little more in that one!!  :o

If someone could Sticky this I think that would be useful

Offline Tomer

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 1,652
  • Gender: Male
    • Aromazing
Re: Basic SSI FAQ
« Reply #13 on: June 24, 2004, 04:35:22 PM »
good work Lamper (^_^)

some may find it useful to know if they can restrict access to different areas depending on other membergroups other than Guest or Admin

Expert SSI FAQ :)

VERY nice Basic Tutorial!! I can't WAIT for the Advanced version of it, especially if you could explain the array output method a little more in that one!!  :o

If someone could Sticky this I think that would be useful

Advanced SSI FAQ :)
« Last Edit: June 28, 2004, 09:55:10 AM by Lamper »

Offline Tomer

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 1,652
  • Gender: Male
    • Aromazing
Re: Basic SSI FAQ
« Reply #14 on: June 30, 2004, 08:29:56 PM »
Here.

Code: [Select]
<?php

if ($context[&#39;user&#39;][&#39;is_guest&#39;])
   
{
      echo &
#39;&#39;, $txt[&#39;welcome_guest&#39;], &#39;&#39;;
   
}
else
   {
      
ssi_welcome();
   }

?>

Offline Cypher7

  • Sophist Member
  • *****
  • Posts: 1,246
  • Gender: Male
  • PMPN8EZ
    • Dublin Airport Tae Kwon Do
Re: Basic SSI FAQ
« Reply #15 on: July 01, 2004, 07:40:39 PM »
Cheers Lamper,

thanks to that and your FAQ's I now have some SSI on my main site airport-tkd.com!!

Nothing special, but I'm happy with it!

cheers!  :)

Jay K

Offline Ben_S

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 11,702
  • xxx
Re: Basic SSI FAQ
« Reply #16 on: July 02, 2004, 07:06:08 PM »
Is your home page suppose to scroll 7 miles to the right?
Liverpool FC Forum with 14 million+ posts.

Offline Cypher7

  • Sophist Member
  • *****
  • Posts: 1,246
  • Gender: Male
  • PMPN8EZ
    • Dublin Airport Tae Kwon Do
Re: Basic SSI FAQ
« Reply #17 on: July 04, 2004, 05:58:35 PM »
Darn, no, its not! Just checked it in Firefox... doesn't happen in IE is why I didnt notice it... I checked in firefox before I made some changes and it was fine...

tsk... and I dont have the time to go fix it... will have to wait a day or two! ah well!

Thanks for the heads up anyway...

Offline Vinoth

  • Full Member
  • ***
  • Posts: 569
  • Gender: Male
  • Hackers Are Not Crackers
Re: Basic SSI FAQ
« Reply #18 on: July 07, 2004, 06:38:37 AM »
fantastic work lamper/

1000 Beers to you.
Vinoth And Sachin ( SpecHackers Team )
The Best  Way to Help Poor Is not Becoming One Of Them.

Offline Tomer

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 1,652
  • Gender: Male
    • Aromazing
Re: Basic SSI FAQ
« Reply #19 on: July 07, 2004, 08:30:11 AM »
I prefer Root Beer, but thanks. :D