Advertisement:

Author Topic: Expert SSI FAQ  (Read 125979 times)

Offline Tomer

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 1,652
  • Gender: Male
    • Aromazing
Expert SSI FAQ
« on: June 28, 2004, 07:31:34 PM »
Expert SSI FAQ

Hello and welcome to the Expert SSI FAQ, in this FAQ you will learn expert stuff with SSI, this FAQ is written assuming you have already read the 'Basic SSI FAQ' and 'Advanced SSI FAQ'. 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'


How can I check if a user is part of a special membergroup?

We have already learned how to tell if a person is a guest, user or admin, but now we can also check if a user is part of a special membergorup, lets take an example to help us out:

Example:

You have a site, and a forum, and you have made a special membergroup where some users are part of, you want that membergroup to have access to a special page, and other users will see an error message.

This can be easily done, first, you need to know that special membergroup ID, go to 'Edit Membergroups', in your admin center, there you should see your membergroup, click on the 'Modify' link of your membergroup, then in the URL you should see something like this: 'action=membergroups;sa=edit;id=#'.
You should see a number istead of the blue '#' shown, that number is that membergroup ID.

Now that you got the membergroup ID, we can continue. This is the code we will be using:
We are assuming that id=9 is our special membergroup for our example!

Code: [Select]
<?php

if (in_array(9$user_info[&#39;groups&#39;]))
   
{
       echo &
#39;Yay! Im in group 9!&#39;;
   
}
else
   {
       echo &
#39;We are sorry, it seems you dont have access to this page.&#39;;
   
}

?>


Well thats how you can do that, you guys know the rest!  :P

Is there anything else?

Glad you asked, because just so happens as there is some more, SSI has some advanced configuration that you can define with a simple code, here are the configurations that you can change.

$ssi_gzip = 'true/false';
$ssi_ban = 'true/false';
$ssi_theme = 'themeID#';
$ssi_layers = array('main');

Simple write these variables in your SSI page before the incude statment, here is a working example:
Code: [Select]
<?php

$ssi_gzip 
false;
$ssi_ban true;
$ssi_theme = &#39;2&#39;;
$ssi_layers = array(&#39;main&#39;);

ob_start();

require(
"/SSI.php");

?>


Lets explain the above code:

$ssi_gzip = false; means gzip is turned off.
$ssi_ban = true; means a banned forum user will be banned also in the SSI page.
$ssi_theme = '2'; uses the theme [images, buttons, colors] with ID=2, which usually is classic theme.
$ssi_layers = array('main'); uses the pair of main sub templates.
ob_start(); is needed not to get errors.
require("/SSI.php"); note its after the variables, but before any output.

Dont worry if it looks a bit hard, this is the expert faq. :) Just experiment with it and you will get the hang of it.



Well this pretty much covers the expert Guide, dont quote me on this, but maybe i'll write a Master SSI FAQ later on.

Attached to the end of this post are some sample scripts that may help you out.
    None Yet
    [/list]

    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: August 17, 2005, 11:34:54 AM by Daniel D. »

    Offline Owdy

    • SMF Fossil
    • SMF Friend
    • SMF Super Hero
    • *
    • Posts: 15,590
    • Gender: Male
    • W00t!
      • janoloferiksson on LinkedIn
      • @@jaoler on Twitter
    Re: Expert SSI FAQ
    « Reply #1 on: June 28, 2004, 07:38:17 PM »
    Good job dude ;)


    Well this pretty much covers the expert Guide, dont quote me on this, but maybe i'll write a Master SSI FAQ later on.

    [offtopic]
    LOL, what comes after 'Master'? SuperHero SSI FAQ?  :P  ;D
    [/offtopic]
    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 Tomer

    • SMF Friend
    • SMF Hero
    • *
    • Posts: 1,652
    • Gender: Male
      • Aromazing
    Re: Expert SSI FAQ
    « Reply #2 on: June 28, 2004, 07:41:35 PM »
    Good job dude ;)

    [offtopic]
    LOL, what comes after 'Master'? SuperHero SSI FAQ?  :P  ;D
    [/offtopic]


    Thanks!

    No that will be the last one [if I make it] and if theres more SSI stuff added I will also make a Intermediate SSI FAQ so the order will be this:

    Basic >>> Intermediate >>> Advanced >>> Expert >>> Master.

    Like on Pogo.com  8)
    « Last Edit: June 28, 2004, 07:43:14 PM by Lamper »

    Offline Cerberus

    • Jr. Member
    • **
    • Posts: 278
    • Gender: Male
      • My main site: Pocket PC Russia
    Re: Expert SSI FAQ
    « Reply #3 on: July 03, 2004, 10:56:29 AM »
    Nice one :D
    Best Regards, Cerberus
    YaBB Gold -> YaBB 1.1 -> YaBB SE (YaPP -> PfaBB) -> SMF
    Pocket PC Russia

    Offline Tomer

    • SMF Friend
    • SMF Hero
    • *
    • Posts: 1,652
    • Gender: Male
      • Aromazing
    Re: Expert SSI FAQ
    « Reply #4 on: July 04, 2004, 06:06:56 AM »
    Thanks. :d

    Offline LaurieC

    • Jr. Member
    • **
    • Posts: 139
    • Gender: Female
    • I've been Hooked!
    Re: Expert SSI FAQ
    « Reply #5 on: July 21, 2004, 11:39:16 PM »
    Thank you, thank you, thank you! I have read all of the SSI FAQS and I think I am finally getting the hang of it! Can't wait for more  :)
    LaurieC

    Offline Tomer

    • SMF Friend
    • SMF Hero
    • *
    • Posts: 1,652
    • Gender: Male
      • Aromazing
    Re: Expert SSI FAQ
    « Reply #6 on: August 09, 2004, 05:26:01 PM »
    Dont think that will happen... :(

    Nothing more the explain.

    Offline Elissen

    • Full Member
    • ***
    • Posts: 466
    • Gender: Male
      • ICSC
    Re: Expert SSI FAQ
    « Reply #7 on: August 09, 2004, 05:59:34 PM »
    Dont think that will happen... :(

    Nothing more the explain.
    You sure? You can do some funky stuff with the template system and SSI ;)

    Offline Tomer

    • SMF Friend
    • SMF Hero
    • *
    • Posts: 1,652
    • Gender: Male
      • Aromazing
    Re: Expert SSI FAQ
    « Reply #8 on: August 09, 2004, 06:03:13 PM »
    You talking about the ssi_layers?

    Offline Elissen

    • Full Member
    • ***
    • Posts: 466
    • Gender: Male
      • ICSC
    Re: Expert SSI FAQ
    « Reply #9 on: August 09, 2004, 08:34:01 PM »
    Nope, creating your own "sub"-templates (like BoardIndex.template.php) and load those. The template system that SMF uses is very flexible and you split your logic from the apperance (template/theme). Being able to use that system on your SSI-powered pages is very nice to work with.

    Also, more (internal) functions would be nice (like db_query, is_admin, is_loggedin). A lot can be learned from reading SSI.php, but still, explanations on what, why and how are always good.

    Your FAQ's are excellent. I find them very thorough. This just might be an interesting addition.

    Offline Elissen

    • Full Member
    • ***
    • Posts: 466
    • Gender: Male
      • ICSC
    Re: Expert SSI FAQ
    « Reply #10 on: August 24, 2004, 05:52:20 AM »
    Example of what I mean.

    regions.php
    Code: [Select]
    <?php
    $ssi_gzip 
    1;
    $ssi_ban 1;

    ob_start();

    include_once &
    #39;../forum/SSI.php&#39;;
    include_once &#39;customhelper.php&#39;;

    global $context;

    loadTemplate(&#39;eli_map_regions&#39;);
    $context[&#39;linktree&#39;][] = array(
            &#39;url&#39; => &#39;/map&#39;,
            &#39;name&#39; => "Map"
            );

    $context[&#39;page_title&#39;] = "Regions";
    $context[&#39;factions&#39;] = loadFactions();

    $res db_query("SELECT *
                    FROM map_regions
                    ORDER BY regionName"
    __FILE____LINE__);
    $context[&#39;regions&#39;] = array();
    while ($row mysql_fetch_assoc($res))
            $context[&#39;regions&#39;][] = array(
                    &#39;name&#39; => $row[&#39;regionName&#39;],
                    &#39;faction&#39; => $row[&#39;factionID&#39;],
                    &#39;id&#39; => $row[&#39;regionID&#39;]
                    );
    mysql_free_result($res);

    obExit();
    ?>
    loadFactions() loads another table. It is used in more files so hence the function.
    loadTemplate('eli_map_regions'); loads a custom (sub-)template. I prefix mine with eli_ so I won't run into problems with mods or future additions to SMF.

    Themes/default/eli_map_regions.template.php
    Code: [Select]
    <?php

    function template_main()
    {
            global $context$settings$options$scripturl$txt;

            // Show the link tree.
            echo &#39;
                    <table width="100%" cellpadding="3" cellspacing="0">
                            <tr>
                                    <td>&#39;, theme_linktree(), &#39;</td>
                            </tr>
                    </table>&#39;;
            // Tha content
            echo &#39;<table width="100%" cellpadding="6" cellspacing="0" border="0" class="tborder" style="margin-bottom: 1ex;">
                    <tr>
                            <td align="left" class="catbg" width="100%" height="24">Regions</td>
                    </tr>
            </table>
            <table border="0" cellspacing="1" cellpadding="4" align="center" width="100%" class="bordercolor">
                    <tr class="titlebg">
                            <td>Region</td>
                            <td>Faction</td>
                    </tr>&#39;;
            foreach ($context[&#39;regions&#39;] as $r) {
                    echo &#39;<tr class="windowbg2">
                            <td><a href="constellations.php?regionID=&#39; . $r[&#39;id&#39;] . &#39;">&#39; . htmlentities($r[&#39;name&#39;]) . &#39;</a></td>
                            <td>&#39;;
                    if (!empty($r[&#39;faction&#39;]))
                            echo htmlentities($context[&#39;factions&#39;][$r[&#39;faction&#39;]]);
                    echo &#39;</td></tr>&#39;;
            }
            echo &#39;</table>&#39;;

    }

    ?>

    result: www.ascend-ind.com/map

    About the forum: it is a clan/guild forum of the corporation I am in in EVE Online (clans are called corporations in EVE). The template system will be very important for me in the future. The next major patch, called Shiva will have a decent ingame browser, but it will NOT support javascript. I have done some testing with the alpha/beta version of the client and with a modified theme I can log into the forum. It requires some work, but I will be able to get the whole forum and everything attached, except coppermine maybe, to work in it. Thanks to the template system.
    I use the subtemplates in preparation for this since I can just make a new subtemplate in the folder of the special theme for the ingame browser if the "normal" one doesn't work or looks ugly.

    Long read maybe, but I hope this is usefull for somebody

    Totally off-topic, if you want a 7-day trail send me a PM with your e-mail address :P Every player can give out those trials

    Offline LaurieC

    • Jr. Member
    • **
    • Posts: 139
    • Gender: Female
    • I've been Hooked!
    Re: Expert SSI FAQ
    « Reply #11 on: September 18, 2004, 02:32:26 PM »
    I have managed to get a page working with the great information here in the ssi faq and now I am hooked.

    I have a question. The page is for our charter members and I used this
    Code: [Select]
    <?php

    if (in_array(9$user_info[&#39;groups&#39;]))
       {
           echo &#39;Yay! Im in group 9!&#39;;
       }
    else
       {
           echo &#39;We are sorry, it seems you dont have access to this page.&#39;;
       }

    ?>

    my question is how or what do you add so that the admin will also be able to access the page?

    Lace


    woops Link to page
    « Last Edit: September 18, 2004, 02:34:03 PM by lace1215 »
    LaurieC

    Offline Metho

    • SMF Friend
    • Full Member
    • *
    • Posts: 564
    • Gender: Male
    Re: Expert SSI FAQ
    « Reply #12 on: September 18, 2004, 02:43:57 PM »
    Code: [Select]
    <?php

    if (in_array(9$user_info[&#39;groups&#39;]) || $context[&#39;user&#39;][&#39;is_admin&#39;])
       
    {
           echo &
    #39;Yay! Im in group 9!&#39;;
       
    }
    else
       {
           echo &
    #39;We are sorry, it seems you dont have access to this page.&#39;;
       
    }

    ?>

    Believe that should work.

    - Methonis
    Joshua "Methonis" Frazer
    Support Specialist
    The Simple Machines Team

    Offline LaurieC

    • Jr. Member
    • **
    • Posts: 139
    • Gender: Female
    • I've been Hooked!
    Re: Expert SSI FAQ
    « Reply #13 on: September 18, 2004, 02:57:23 PM »
    Like a charm  ;)

    Thank you Metho.....

    Lace
    LaurieC

    Offline Superboy

    • Semi-Newbie
    • *
    • Posts: 83
    • Gender: Male
    Re: Expert SSI FAQ
    « Reply #14 on: November 02, 2004, 03:33:24 PM »
    Hi everyone,
    I have tiried to get this:
    Code: [Select]
    <?php
    require("/Library/WebServer/Documents/goosesoft/forum/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;;
    }



    ?>


    to work with my forum. All of the other tags like
    Code: [Select]
    <?php ssi_recentPosts(); ?> work fine. Also, if I do get this working, is there a way to list downloads after the "Here are your downloads:" bit or redirect them to another page?

    Thanks! :)
    Windows (n): 32 bit extension and a graphical shell for a 16 bit patch to an 8 bit operating system originally coded for a 4 bit microprocessor, written by a 2 bit company that can't stand 1 bit of competition.

    Offline Tomer

    • SMF Friend
    • SMF Hero
    • *
    • Posts: 1,652
    • Gender: Male
      • Aromazing
    Re: Expert SSI FAQ
    « Reply #15 on: November 02, 2004, 04:00:58 PM »
    Hi everyone,
    I have tiried to get this:
    Code: [Select]
    <?php
    require("/Library/WebServer/Documents/goosesoft/forum/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;;
    }



    ?>


    to work with my forum. All of the other tags like
    Code: [Select]
    <?php ssi_recentPosts(); ?> work fine. Also, if I do get this working, is there a way to list downloads after the "Here are your downloads:" bit or redirect them to another page?

    Thanks! :)

    Does it work for you?

    The part about the downloads was an example, you can change the download part to anything you want, remember, everything inside the "else" will be done if user is logged in.

    If you want logged in users to be redirected to another page, use this:

    Code: [Select]
    <?php
    require("/Library/WebServer/Documents/goosesoft/forum/SSI.php");

    if (!
    $context[&#39;user&#39;][&#39;is_guest&#39;])
    {
       
    header("Location: www.your-page.com");
    }



    ?>


    Offline Superboy

    • Semi-Newbie
    • *
    • Posts: 83
    • Gender: Male
    Re: Expert SSI FAQ
    « Reply #16 on: November 02, 2004, 07:38:11 PM »
    Thanks for your reply :)

    Sorry, for some reason i seemed to miss out the part that actually said that it wouldn't work...  :-\

    I have tried the code you have written but I only get a blank page.

    Here is the URL to the page: http://brazil2005.dyndns.org/goosesoft/test.php

    Thanks for the help! :)
    Windows (n): 32 bit extension and a graphical shell for a 16 bit patch to an 8 bit operating system originally coded for a 4 bit microprocessor, written by a 2 bit company that can't stand 1 bit of competition.

    Offline [Unknown]

    • SMF Friend
    • SMF Master
    • *
    • Posts: 36,102
    • Gender: Male
    Re: Expert SSI FAQ
    « Reply #17 on: November 02, 2004, 07:42:53 PM »
    Don't do that... use:

    if ($context['user']['is_guest'])
       redirectexit('http://www.google.com/', false);

    Or similar...

    -[Unknown]

    Offline Superboy

    • Semi-Newbie
    • *
    • Posts: 83
    • Gender: Male
    Re: Expert SSI FAQ
    « Reply #18 on: November 03, 2004, 01:44:16 PM »
    Still comes up as a blank page :(
    Windows (n): 32 bit extension and a graphical shell for a 16 bit patch to an 8 bit operating system originally coded for a 4 bit microprocessor, written by a 2 bit company that can't stand 1 bit of competition.

    Offline Superboy

    • Semi-Newbie
    • *
    • Posts: 83
    • Gender: Male
    Re: Expert SSI FAQ
    « Reply #19 on: November 04, 2004, 07:28:20 AM »
    Anyone have any suggestions...? Please...? :)
    Windows (n): 32 bit extension and a graphical shell for a 16 bit patch to an 8 bit operating system originally coded for a 4 bit microprocessor, written by a 2 bit company that can't stand 1 bit of competition.