Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: Tomer on June 28, 2004, 07:31:34 PM

Title: Expert SSI FAQ
Post by: Tomer 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 (http://www.simplemachines.org/community/index.php?topic=12936.0)' and 'Advanced SSI FAQ (http://www.simplemachines.org/community/index.php?topic=13016.0)'. 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!


<?php

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

?>



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:

<?php

$ssi_gzip 
false;
$ssi_ban true;
$ssi_theme '2';
$ssi_layers = array('main');

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
Title: Re: Expert SSI FAQ
Post by: Owdy on June 28, 2004, 07:38:17 PM
Good job dude ;)

Quote from: Lamper on June 28, 2004, 07:31:34 PM

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]
Title: Re: Expert SSI FAQ
Post by: Tomer on June 28, 2004, 07:41:35 PM
Quote from: Owdy on June 28, 2004, 07:38:17 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)
Title: Re: Expert SSI FAQ
Post by: Cerberus on July 03, 2004, 10:56:29 AM
Nice one :D
Title: Re: Expert SSI FAQ
Post by: Tomer on July 04, 2004, 06:06:56 AM
Thanks. :d
Title: Re: Expert SSI FAQ
Post by: LaurieC 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  :)
Title: Re: Expert SSI FAQ
Post by: Tomer on August 09, 2004, 05:26:01 PM
Dont think that will happen... :(

Nothing more the explain.
Title: Re: Expert SSI FAQ
Post by: Elissen on August 09, 2004, 05:59:34 PM
Quote from: Tomer Dean on August 09, 2004, 05:26:01 PM
Dont think that will happen... :(

Nothing more the explain.
You sure? You can do some funky stuff with the template system and SSI ;)
Title: Re: Expert SSI FAQ
Post by: Tomer on August 09, 2004, 06:03:13 PM
You talking about the ssi_layers?
Title: Re: Expert SSI FAQ
Post by: Elissen 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.
Title: Re: Expert SSI FAQ
Post by: Elissen on August 24, 2004, 05:52:20 AM
Example of what I mean.

regions.php
<?php
$ssi_gzip 
1;
$ssi_ban 1;

ob_start();

include_once 
'../forum/SSI.php';
include_once 
'customhelper.php';

global 
$context;

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

$context['page_title'] = "Regions";
$context['factions'] = loadFactions();

$res db_query("SELECT *
                FROM map_regions
                ORDER BY regionName"
__FILE____LINE__);
$context['regions'] = array();
while (
$row mysql_fetch_assoc($res))
        $context['regions'][] = array(
                'name' => $row['regionName'],
                'faction' => $row['factionID'],
                'id' => $row['regionID']
                );
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
<?php

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

        // Show the link tree.
        echo '
                <table width="100%" cellpadding="3" cellspacing="0">
                        <tr>
                                <td>'
theme_linktree(), '</td>
                        </tr>
                </table>'
;
        // Tha content
        echo '<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>'
;
        foreach ($context['regions'] as $r) {
                echo '<tr class="windowbg2">
                        <td><a href="constellations.php?regionID=' 
$r['id'] . '">' htmlentities($r['name']) . '</a></td>
                        <td>'
;
                if (!empty($r['faction']))
                        echo htmlentities($context['factions'][$r['faction']]);
                echo '</td></tr>';
        }
        echo '</table>';

}

?>


result: www.ascend-ind.com/map

About the forum: it is a clan/guild forum of the corporation I am in in EVE Online (http://www.eve-online.com) (clans are called corporations in EVE). The template system will be very important for me in the future. The next major patch, called Shiva (http://www.eve-online.com/features/shiva/) will have a decent ingame browser (http://www.eve-online.com/features/shiva/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
Title: Re: Expert SSI FAQ
Post by: LaurieC 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
<?php

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

?>


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 (http://ultimatebass.com/lbf/CMdownloads1.php)
Title: Re: Expert SSI FAQ
Post by: Metho on September 18, 2004, 02:43:57 PM
<?php

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

?>


Believe that should work.

- Methonis
Title: Re: Expert SSI FAQ
Post by: LaurieC on September 18, 2004, 02:57:23 PM
Like a charm  ;)

Thank you Metho.....

Lace
Title: Re: Expert SSI FAQ
Post by: Superboy on November 02, 2004, 03:33:24 PM
Hi everyone,
I have tiried to get this:
<?php
require("/Library/WebServer/Documents/goosesoft/forum/SSI.php"); 

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



?>



to work with my forum. All of the other tags like <?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! :)
Title: Re: Expert SSI FAQ
Post by: Tomer on November 02, 2004, 04:00:58 PM
Quote from: Superboy on November 02, 2004, 03:33:24 PM
Hi everyone,
I have tiried to get this:
<?php
require("/Library/WebServer/Documents/goosesoft/forum/SSI.php"); 

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



?>



to work with my forum. All of the other tags like <?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:


<?php
require("/Library/WebServer/Documents/goosesoft/forum/SSI.php");

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



?>

Title: Re: Expert SSI FAQ
Post by: Superboy 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 (http://brazil2005.dyndns.org/goosesoft/test.php)

Thanks for the help! :)
Title: Re: Expert SSI FAQ
Post by: [Unknown] 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]
Title: Re: Expert SSI FAQ
Post by: Superboy on November 03, 2004, 01:44:16 PM
Still comes up (http://www.goosesoft.co.uk/test.php) as a blank page :(
Title: Re: Expert SSI FAQ
Post by: Superboy on November 04, 2004, 07:28:20 AM
Anyone have any suggestions...? Please...? :)
Title: Re: Expert SSI FAQ
Post by: [Unknown] on November 04, 2004, 04:10:04 PM
I'm not sure what to tell you.  Looks like somethings wrong with the inclusion of SSI.php, and you're using frames (redirection) too...

-[Unknown]
Title: Re: Expert SSI FAQ
Post by: Superboy on November 04, 2004, 05:43:29 PM
That redirection thing doesn't use frames, it just redirects. Do you have to put the php file with the SSI include in it in any specific place, or can it be anywhere in the webserver directory?

Thanks for your help :)
Title: Re: Expert SSI FAQ
Post by: [Unknown] on November 04, 2004, 07:55:36 PM
It should be inside the same directory as SMF.

It does indeed use frames; I found myself in a frameset (with just one frame) when I went to the link you provided.

-[Unknown]
Title: Re: Expert SSI FAQ
Post by: Superboy on November 04, 2004, 08:08:42 PM
Ok, I believe that it uses frames :) You are an expert programmer after all :)
I still can't get it to work, but thanks for the help anyway [Unknown]  :) I expect that I will get it going... What I find weird is that some PHP tags like the login and logout ones work fine... :-\
Oh well
Thanks again everyone!
Title: Re: Expert SSI FAQ
Post by: aaronsnet on November 09, 2004, 05:32:51 PM
I am wanting to make a page where more then one user group will be able to access a page, and if they are not authorized, they would get an error msg. I am sure that this isn't right, would it be something like the code below?

<?php

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

?>


thanks!
Title: Re: Expert SSI FAQ
Post by: [Unknown] on November 09, 2004, 08:22:33 PM
<?php

if (in_array(9$user_info['groups']) || in_array(12$user_info['groups']))
{
    echo 
'Yay! Im in group 9 ';

    if (
in_array(9$user_info['groups']) && in_array(12$user_info['groups']))
        echo 
'and';
    else
        echo 
'or';

    echo 
' 12!';
}
else
{
    echo 
'We are sorry, it seems you dont have access to this page.';
}

?>


-[Unknown]
Title: Re: Expert SSI FAQ
Post by: Kender on November 10, 2004, 07:20:31 PM
ok, in the same file that i have ssi_welcome() in, directly under that.. i want to place a menu that only the members of group 1 and 2 can see.....

i tried

if (in_array(1, $user_info['groups']) || in_array(2, $user_info['groups']))
{
   echo ' menu items ';
}

but doest work....
Title: Re: Expert SSI FAQ
Post by: [Unknown] on November 10, 2004, 08:45:57 PM
Did you global $user_info?

-[Unknown]
Title: Re: Expert SSI FAQ
Post by: Kender on November 10, 2004, 08:54:23 PM
probably not
*sheepish*

little things that arent in the SSI_examples.. that should be  ;)
thanks [unknown]
Title: Re: Expert SSI FAQ
Post by: Kender on November 12, 2004, 07:03:10 PM
ok, have a new problem

i have login - on main page  http://domain.com
i have forum - http://forum.domain.com

when i log in today, then come back tomorrow, i cannot log out from main page..  (session verification error) but can log out from forum
Title: Re: Expert SSI FAQ
Post by: [Unknown] on November 13, 2004, 06:01:42 PM
Change the cookie name for one of them.

-[Unknown]
Title: Re: Expert SSI FAQ
Post by: Kender on November 13, 2004, 06:42:23 PM
i am using the SMF login, so wouldnt it be the same cookie?

i am not setting a different cookie..  i can log in and out fine on same day, but have problems when it spans days..

exact error is (Session verification failed. Please try logging out and back in again, and then try again.)
Title: Re: Expert SSI FAQ
Post by: [Unknown] on November 13, 2004, 07:49:29 PM
Yes, it will cause problems over multiple days if both forums are using the same cookie name and either of them is using global (sub domain independent) cookies.

-[Unknown]
Title: Re: Expert SSI FAQ
Post by: Kender on November 13, 2004, 09:04:43 PM
thanks for the info

is there a fix, is a fix possible, or is it not a workable problem
Title: Re: Expert SSI FAQ
Post by: [Unknown] on November 14, 2004, 03:46:22 AM
Quote from: Kender on November 13, 2004, 09:04:43 PM
thanks for the info

is there a fix, is a fix possible, or is it not a workable problem

You just asked me:

Okay, so I understand that I cannot give two files the same filename and extension, and that it is quite a perfect solution to add to the name of the other (for example, adding " (2)") - now, is a fix possible?

I just said there was a freaking fix.  What is it that is being miscommunicated?!

Forum #1 -> cookie named "Hello"
Forum #2 -> cookie named "Hello"

Login to forum #1 -> that login also affects forum #2 (because the cookies have the same name!)
Change name of cookie for forum #2 -> EVERYTHING IS PERFECT.

What is the problem with renaming the cookie, most specifically, in at least four sentences?  Be verbose.  I can't understand short, cryptic, and seemingly confused responses.

-[Unknown]
Title: Re: Expert SSI FAQ
Post by: Kender on November 14, 2004, 07:45:03 AM
i see the confusion, sorry if i miscommunicated

it is not 2 forums, it is SSI login (name and password boxes) (checks topic.. yes.. SSI FAQ) with 1 forum

i log in SSI login, or Forum login, doesnt matter which
wait 2 days, reboot or not, close browser, open it several times..  and from index page of website (not forum)(SSI logout) cannot log out.. brings me to forum error telling me to try logging out and back in

if i try and log out from forum.. no problem
Title: Re: Expert SSI FAQ
Post by: [Unknown] on November 15, 2004, 03:24:25 PM
You'll have better luck in 1.0, for that.

-[Unknown]
Title: Re: Expert SSI FAQ
Post by: Kender on November 15, 2004, 04:24:56 PM
do we have a release date?  :)
Title: Re: Expert SSI FAQ
Post by: Jerry on November 19, 2004, 01:06:19 AM
I am trying to use ssi_layers lake shown on page one by Elissen, so far it has been successful. But I can't seem to figure out how to make it show the footer like on the rest of the SMF pages.
http://www.raclan.org/index2.php is what I have so far. It shows the header, but only a partial footer. How would I make it show the full footer like my current forums footer for example:

[RA] Rebel Alliance | Powered by SMF 1.0 RC2.
© 2001-2004, Lewis Media. All Rights Reserved.
Page created in 0.114 seconds with 15 queries.
The bold is what my page only shows currently.
Title: Re: Expert SSI FAQ
Post by: Elissen on November 19, 2004, 03:18:13 AM
My SSI-pages also don't show the full copyrights. But it is your page, right? :)
Title: Re: Expert SSI FAQ
Post by: Jerry on November 19, 2004, 04:14:03 AM
but the page wouldn't be generated without SMF, plus I like the looks of the copyright =P, it just looks blank down there without them :(.
Title: Re: Expert SSI FAQ
Post by: Elissen on November 19, 2004, 06:11:24 AM
Very true :). It must be disabled somewhere for SSI, but I have no idea where. Maybe one of the developers can comment on this.
Title: Re: Expert SSI FAQ
Post by: Jerry on November 19, 2004, 06:48:31 AM
I will look for it :) but if some one could tell me howit would be cool ;D
Title: Re: Expert SSI FAQ
Post by: giga on January 31, 2005, 02:02:32 PM
my first post .. hope that help

check out ..

http://www.simplemachines.org/community/index.php?topic=18633.0

or just add

$forum_version = 'SMF 1.0.1';

above the include_once('../SSI.php');

to get the copyright in SSI
Title: Re: Expert SSI FAQ
Post by: Jerry on January 31, 2005, 02:05:05 PM
thanks for pointing that out giga :)
Title: Re: Expert SSI FAQ
Post by: Reinier on February 11, 2005, 04:12:47 PM
I've been playing with the SSI functions and I like them a lot, finally the main page and forum of my girlfriend's site are integrated!

I use the ssi_boardNews function to display some news items on the main page. I would like to show an image next to the message body (since that is also the way the news items looked before I used SSI). Is there a way to display an image that is attached to the message? Just displaying the image http://mydomain.com/smf/index.php?action=dlattach;id=X is not possible, since it is unknown what the ID of the image is.

Does anybody have a clue how to do this?

Title: Re: Expert SSI FAQ
Post by: Reinier on February 13, 2005, 05:59:00 PM
Okay, I found the solution here: http://www.simplemachines.org/community/index.php?topic=20394.0
Thanks [Unknown] :)
Title: Re: Expert SSI FAQ
Post by: jazz on April 16, 2005, 04:47:32 PM
<?php ssi_welcome(); ?>  Just shows Welcome User you have so many messages...

Is there any way to add all the information from the welcome box for the forum?  Recent posts, avatar, etc...
Title: Re: Expert SSI FAQ
Post by: Owdy on April 16, 2005, 04:49:13 PM
You can pull allmost everything from forum with SSI.

Example, avatar:

<?

if ($context['user']['is_logged'])
{
   
echo '', $context['user']['avatar']['image'], '
 
';

}
?>
Title: Re: Expert SSI FAQ
Post by: jazz on April 16, 2005, 05:01:51 PM
I appreciate you answering this for me.  As I just discovered, a simple search would have done the trick.  Thanks again!
Title: Re: Expert SSI FAQ
Post by: Owdy on May 16, 2005, 12:31:37 PM
Quote from: Tomer on June 28, 2004, 07:31:34 PM


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');

Do we have more of them now?
Title: Re: Expert SSI FAQ
Post by: [Unknown] on May 22, 2005, 12:48:13 AM
The true/false ones CANNOT be 'true' or 'false'.  They simply will not do anything.  They must be true (without quotes!) or false.

$ssi_gzip = true;
$ssi_maintenance_off = true;
$ssi_ban = true;
$ssi_theme = 1; // <-- integer, please, no quotes.
$ssi_layers = array('main', 'etc');

-[Unknown]
Title: Re: Expert SSI FAQ
Post by: weekend camper on August 05, 2005, 06:54:00 PM
Not able to get my head around a 'quick' way to let selected member groups have access to certain page content.  I am dealing with roughly 30 member groups and at different times will be using up to 29 groups (ie, excluding one or two groups or more).

questions:

1 - how to exclude a group using (in_array(1, $user_info['groups']))

self answered:  (!in_array(1, $user_info['groups']))

2 - is there any easy way to cycle through, say 10 groups in (in_array(X, $user_info['groups']))?
like with an array in a loop?  Or should I just write it long ways like below? 

(!in_array(12, $user_info['groups'])) || (!in_array(23, $user_info['groups'])) || (!in_array(54, $user_info['groups'])) etc?
Title: Re: Expert SSI FAQ
Post by: eclips on August 29, 2005, 10:42:45 PM
How do I translate $user_info['groups'] into something I can use from the web board?

The $user_info array does not exist. I found most things such as $user_info['username'] had to be changed to $context['user']['name'] but I can't find anything in $context for the membergroup.
Title: Re: Expert SSI FAQ
Post by: kegobeer on August 29, 2005, 11:56:11 PM
Quote from: eclips on August 29, 2005, 10:42:45 PM
How do I translate $user_info['groups'] into something I can use from the web board?

The $user_info array does not exist. I found most things such as $user_info['username'] had to be changed to $context['user']['name'] but I can't find anything in $context for the membergroup.

What are you trying to do?  Can you give an example of what you are looking for?
Title: Re: Expert SSI FAQ
Post by: TXSherry on August 30, 2005, 12:00:56 AM
Quote from: weekend camper on August 05, 2005, 06:54:00 PM
Not able to get my head around a 'quick' way to let selected member groups have access to certain page content.  I am dealing with roughly 30 member groups and at different times will be using up to 29 groups (ie, excluding one or two groups or more).

...8<...snippity....8<.....

2 - is there any easy way to cycle through, say 10 groups in (in_array(X, $user_info['groups']))?
like with an array in a loop?  Or should I just write it long ways like below? 



Here's one way to skin this cat.  Junk echos included for ease of transforming it to your own use.



$go_away_groups=array(2,3,5,7,2,10,6,40);
$go_away = false;

foreach ($go_away_groups as $grp)
{
    if (in_array($grp, $user_info['groups'])) $go_away =true;
}


if  ($go_away)    echo 'Go away!';
else                    echo 'Come on in!';



HTH,
Sherry
Title: Re: Expert SSI FAQ
Post by: TXSherry on August 30, 2005, 12:13:42 AM
Quote from: eclips on August 29, 2005, 10:42:45 PM
How do I translate $user_info['groups'] into something I can use from the web board?

The $user_info array does not exist. I found most things such as $user_info['username'] had to be changed to $context['user']['name'] but I can't find anything in $context for the membergroup.

You don't need to translate it, but do use the in_array as shown to test for if the 'Group ID#' is in the array of the
'person accessing the page'.  (Englishizing it)

If you wonder what $user_info['groups'] holds, then make yourself a test page and print_r() it.

So, to get to the answer of your question.  how to use it from your web board.

Well, I'm having trouble with your phrasing.  If you mean the Bulliten board (Forum) when you say 'web board', then you use it as is, and as the example given.

However, if by web board you mean you want to use it on your web site, outside of your forum, then try this.   make this test page, and pull it up. (ftp it or run it locally, however you work)


<?php
require_once("{$_SERVER['DOCUMENT_ROOT']}/forum/SSI.php");
echo 
'<html><body>';

if (
in_array(18$user_info['groups'])) 
      echo 
'Hello, you ARE in group #18.';
else
      echo 
'Hello, you are NOT in group #18.';

echo 
'</body></html>';

?>




Now, to find out what group # the group you want to test is, DO
Admin > edit membergroups

And run your mouse over the MODIFY  beside the group names, and look at your status bar, you should see something like
http://www.privacy.com/forum/index.php?action=membergroups;sa=edit;id=8
The number at the end is the id of the group.
You can also go into the tables and look it up :)

HTH,
Sherry


Title: Re: Expert SSI FAQ
Post by: kegobeer on August 30, 2005, 12:20:30 AM
If you are looking for a match from one array to another, and then allow if a match is found, try this:

if (array_intersect($allowed_groups, $user_info['groups']))
{
 ... allowed code ..
} else {
  ... denied code ...
}


Of course, this assumes both $allowed_groups and $user_info['groups'] are arrays.
Title: Re: Expert SSI FAQ
Post by: Sting on October 23, 2005, 03:00:30 PM
Ok I have a problem http://www.sscont.x10hosting.com/xf/

ok I am calling the ssi_welcome(); but no matter if the user is logged in or not it gives the:

Welcome, Guest. Please login or register.

Does this mean they have to sign in through the site itself where it is being shown or do I need to change something?

Also by this happening it keeps the user of who's online shown as both a guest and a member if I use ssi_logOnline();. I even tried using just the ssi_whosOnline(); but it won't help. when I look at the examples the welcome tage works as it should.
Title: Re: Expert SSI FAQ
Post by: JayBachatero on October 23, 2005, 08:33:30 PM
check if Help     Use subdomain independent cookies are on in admin > features and options
Title: Re: Expert SSI FAQ
Post by: Sting on October 23, 2005, 09:28:25 PM
Quote from: JayBachatero on October 23, 2005, 08:33:30 PM
check if Help     Use subdomain independent cookies are on in admin > features and options

That did it, thnx.
Title: Re: Expert SSI FAQ
Post by: JayBachatero on October 23, 2005, 09:29:18 PM
Quote from: Sting on October 23, 2005, 09:28:25 PM
Quote from: JayBachatero on October 23, 2005, 08:33:30 PM
check if Help     Use subdomain independent cookies are on in admin > features and options

That did it, thnx.

You welcome.
Title: Re: Expert SSI FAQ
Post by: Sting on October 23, 2005, 09:47:49 PM
ok I think I remember reading this somewhere but with the search being disabled I can't find it. Now that that works I cannot logout.

EDIT: Ok, I cleared cookies and it fixed it.  :P
Title: Re: Expert SSI FAQ
Post by: Sting on October 29, 2005, 02:59:50 PM
ok, this is a request I guess you would say. Earlier in another post I inquired about a way to use the ssi_boardNews() function to show particular posts inside of a board. Since I was unable to get a response to it I would assume that the ssi_boardNews() function does not allow for this and I am now requesting that if someone has some spare time could they code an ssi_boardTopics() function. If I knew what I was doing I would attempt it myself... but yea...

Ok, here's exactly what I want:

example: In an instance where multiple topics have been posted under a board, I want it to show a particular post, not just the first. I would assume it would pull it the same way ssi_boardNews() would as far as designating which to use (ssi_boardNews(15) for example).

If someone knows how to do this already please let me know, and if you would like to try this and need more infor I will be glad to provide it.
Title: Re: Expert SSI FAQ
Post by: psychophat on January 14, 2006, 05:18:21 PM
I'm trying to make this work somebody please help, I'm new to PHP and I wish to make this work:

Saw this code and tried to put an else statement which is wrong.

<?php 

if ($context['user']['is_logged'])
{
   
echo ''$context['user']['avatar']['image'], '';
else echo 
'ssi_login();' }
  ?>


What I want it to show username and avatar if not show the login boxes in 1.1RC2 like in the very top of this page and also I want to have the Hey, membername, you don't have... ah, sorry I want the top part you see in this forum where the login boxes changes to login info to appear in my other pages so that they'll know if they have a message plus they can see their avatar, can this be done using SSI?

Heheheh hehe . . . the PHP book that I bought is glowing I think it wants me to read it, I'm scared I might get burned.
Title: Re: Expert SSI FAQ
Post by: psychophat on January 14, 2006, 05:38:49 PM
Man I love this forum, I should have not bought that PHP book I'm already learning from reading the posts and trying them out even if I continue to get errors I'm still learning somthing the do's and don't still far from learning it all but I'm stepping forward .1% at a time. Heheheh heh . . .

I didn't touch the thick PHP glowing book instead I've retried several posibile codes and would you know it the part that was wrong was the } placement. Geez, I'm so, so, so zero knowledgeable in PHP.

Okay got it working ah, can someone tell me how to add the following to the script?

Hey, membername, you don't have any messages...
Total time logged...
Show unread posts since last visit...
Show new replies to your posts...

Basically its like the top part of this forum and could anyone point me to the direction or CSS codes for the above parts that I need to modify in size and font (.ssi_??? codes to put in CSS file).

Thank you in advance,


-Patrick Grey
I adore this forum
Title: Re: Expert SSI FAQ
Post by: Acf on January 30, 2006, 06:18:03 PM
Is there a way to make this work in ssi?

theme_copyright()
Title: Re: Expert SSI FAQ
Post by: kegobeer on January 30, 2006, 07:39:55 PM
Quote from: ªcF on January 30, 2006, 06:18:03 PM
Is there a way to make this work in ssi?

theme_copyright()

Does it not work?  I can't check it out at this moment.
Title: Re: Expert SSI FAQ
Post by: Acf on January 31, 2006, 05:07:31 AM
Quote from: kegobeer on January 30, 2006, 07:39:55 PM
Quote from: ªcF on January 30, 2006, 06:18:03 PM
Is there a way to make this work in ssi?

theme_copyright()


Does it not work?  I can't check it out at this moment.

it doesnt work in yesterdays cvs :|
It only works with the " $forum_version = 'SMF';" hack around...
Title: Re: Expert SSI FAQ
Post by: paki on April 25, 2006, 06:17:49 PM
Just thought I would update this here since I had some trouble finding it in the first place.

To make the membergroup check work on the forums, use this instead of the code posted:

if (in_array(###, $GLOBALS['user_info']['groups']))

where ### is the membergroup ID number.

Searched a lot and found it in this thread: http://www.simplemachines.org/community/index.php?topic=26899.0

Just thought I would try and help out anyone who may be looking for that.. I will be using it for the ads on my forums as well
Title: Re: Expert SSI FAQ
Post by: bashmyex on September 10, 2006, 02:55:17 PM
Could someone give a Smarty Template Engine Example for use with SSI.php?

Preferrably for ssi_recentTopics()
Thanks!
Title: Re: Expert SSI FAQ
Post by: bashmyex on September 10, 2006, 04:34:17 PM
Ahh nevermind. I was making it more complex then it had to be.

Simply doing the below works for me:

PHP Side:

$smarty->assign ("recent_forum_topics", ssi_recentTopics(5, 0, 'array'));


Template Side:
   
    {foreach from=$recent_forum_topics item="recent_topic"}
         {$recent_topic.subject} //do same for each row you want displayed
    {/foreach}
Title: Re: Expert SSI FAQ
Post by: Nicc on October 12, 2006, 03:56:31 PM
Just wanted to say thanks for these great guides! This SSI.php-file opens up a whole lot of possibilites - I love it!

- Nicc
Title: Re: Expert SSI FAQ
Post by: humanporkrind on December 08, 2006, 10:56:28 PM
ok trying to get a php page to pull the theme info and I keep getting errors

<?php

$ssi_gzip 
false;
$ssi_ban true;
$ssi_theme '15';
$ssi_layers = array('main');

ob_start();

require(
"C:\Program Files\EasyPHP1-8\www\Smf 1.1 final/SSI.php");

?>

<embed src="http://www.xxxxxxxx.com/xxxx/xxxxx/xxxxxxx.mp3" autostart="true" loop="true"
hidden="true" />
<div align="center">
  <p><img name="Header" src="http://www.devilsrejectsdod.com/untitled4.jpg" width="85%" height="412" alt=""></p>
  <div align="left"></div>
  <table width="613" height="472" border="0" align="left">
    <tr>
      <th scope="row"><?php ssi_recentPosts(); ?><div align="left"></div></th>
    </tr>
  </table>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
</div>


See Screen shot for out put.
(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fimg83.imageshack.us%2Fimg83%2F3831%2Ferroref1.jpg&hash=c01966ecc6209ce22fe2294b872c67d337e4090e)
Title: Re: Expert SSI FAQ
Post by: perplexed on June 05, 2007, 11:04:33 AM
Humanporkrind did you ever fix this problem as I have seen someone with a similar problem, and would like to know the answer.  thanks
Title: Re: Expert SSI FAQ
Post by: Scrambled Egg on August 02, 2007, 08:01:57 PM
Would love to have a poll on my board home page, but this stuff is just too difficult for me.
Title: Re: Expert SSI FAQ
Post by: [SiNaN] on January 03, 2008, 02:32:44 PM
Quote from: Tomer on June 28, 2004, 07:31:34 PM
**PLEASE DO NOT EDIT YOUR 'SSI.PHP' FILE**
Everything done here is done without having to edit 'SSI.php'


Why we mustn't edit our SSI.php?
Title: Re: Expert SSI FAQ
Post by: spottedhog on January 04, 2008, 09:21:52 PM
It is OK, to add new SSI calls to the bottom of the file, however, it is not necessary to modify any of the original SSI code.  You can use the variables called in SSI to make your own way of displaying the data. 

For example, on the basic ssi_boardNews() I made my own News module.  Here is the code to give you an example:

$array = ssi_boardNews($board = $newsboard, $limit = 5, $start = null, $length = 500, $output_method = 'array');

     

if (empty($array))

   echo _NOTOPICSPOSTED;



foreach ($array as $news)

{

echo '

<div style="width:100%" class="option">

        ', $news['icon'], '&nbsp;<b>', $news['subject'], '</b><br />

<span style="font-size:x-small">Posted On:&nbsp;&nbsp;', $news['time'], '</span><br />

<span class="option">', $news['body'],' <a href="', $news['href'], '">', _READMORE ,'</a></span></div><br />

<span style="font-size:smaller">', $news['link'], $news['locked'] ? '' : ' | ' . $news['comment_link'], ' |

<a href="forum/index.php?action=post;board=', $newsboard ,'">', _POSTNEWSARTICLE ,'</a></span><br /><br />';



if (!$news['is_last'])

echo '<hr style="width:50%;text-align:left; margin: 0 auto 0 0" /><br />';



}
Title: Re: Expert SSI FAQ
Post by: [SiNaN] on January 07, 2008, 05:04:20 AM
Is it because that makes upgrade hard? Is is the only reason?
Title: Re: Expert SSI FAQ
Post by: spottedhog on January 08, 2008, 05:09:50 PM
It is not about being "hard".  It is about not being necessary.  All the ssi functions pull all the existing data and places it into variables.  Then all you need to do is to call the ssi function by "array" instead of "echo".

In other words, all the info needed to display is already being called, so why modify something when it is not needed?
Title: Re: Expert SSI FAQ
Post by: [SiNaN] on January 09, 2008, 04:26:18 AM
Because that seems as easy way.

I'll be using this way from now on, thanks.

Title: Re: Expert SSI FAQ
Post by: spottedhog on January 09, 2008, 10:29:15 AM
I would still recommend to do it via an $array as with the example I put up earlier.
Title: Re: Expert SSI FAQ
Post by: [SiNaN] on January 10, 2008, 05:14:10 AM
My awful English caused a misunderstanding again.

I meant, from now on, I'll will be using the way you gave.

Another question: When I use ssi_shutdown(), it doesn't display the copyright. Is there a solution so that I can show the copyright also?
Title: Re: Expert SSI FAQ
Post by: spottedhog on January 11, 2008, 05:37:17 PM
I would not worry about it....  also, I have not used that function, so I am not totally sure what it does.
Title: Re: Expert SSI FAQ
Post by: Kender on February 17, 2008, 09:21:47 AM
looked through teh basic and expert faq and didnt see the answer
also looked in the docs section....

is there a way to use the users default theme, or forum default (by selection, or for guests) with the ssi ?

like a ssi header, for the top half of the page
then insert conten
then ssi footer, for the bottom half of the page
Title: Re: Expert SSI FAQ
Post by: [SiNaN] on February 17, 2008, 09:30:03 AM
You can use this:

<?php
error_reporting
(E_ALL);

// Theme we're going to use
$ssi_theme 4;
// Layers we're going to use
$ssi_layers = array('main');
// Enable GZip compression (saves bandwidth)
$ssi_gzip true;

require(
'SSI.php');

?>

Put your HTML content here!
<?php

ssi_shutdown
();
?>
Title: Re: Expert SSI FAQ
Post by: Kender on February 17, 2008, 09:41:52 AM
Quote from: [SiNaN] on February 17, 2008, 09:30:03 AM
You can use this:

<?php
error_reporting
(E_ALL);

// Theme we're going to use
$ssi_theme 4;
// Layers we're going to use
$ssi_layers = array('main');
// Enable GZip compression (saves bandwidth)
$ssi_gzip true;

require(
'SSI.php');

?>

Put your HTML content here!
<?php

ssi_shutdown
();
?>

This works beautifully, thanks, but is there a way to allow for using the members preferred theme as well? 
not to be a pain, you have me 1000% happier than i was an hour ago.. and i thank you for that
Title: Re: Expert SSI FAQ
Post by: spottedhog on February 17, 2008, 09:56:11 AM
comment out this line...  make it like this:
//$ssi_theme = 4;
Title: Re: Expert SSI FAQ
Post by: [SiNaN] on February 17, 2008, 10:18:06 AM
Yes, as spottedhog said, if you do not set an ssi_theme, it will use the theme of user.

Not at all.
Title: Re: Expert SSI FAQ
Post by: spottedhog on February 17, 2008, 11:38:13 AM
If you wish to include IP banning, add this line under $ssi_theme:

$ssi_ban = true;  //true--means a banned forum user will be banned also in the SSI page.
Title: Re: Expert SSI FAQ
Post by: Kender on February 17, 2008, 06:28:48 PM
you guys are great! thanks a lot
Title: Re: Expert SSI FAQ
Post by: Kender on February 19, 2008, 07:39:11 AM
Okay, I am pulling a Poll from a board

when logged in as admin, the poll shows as unanswered

the poll shows unanswered in all 3 situations, admin, member and logged out when using toppoll and recentpoll...

using showpoll(6) as logged in member, it shows results, and as guest it shows results, but as admin it shows unanswered (admin created the poll)

this is using   ssi_showPoll(6); with 6 being the post number, unless you can get me using top or recent poll and limiting it to a specific board/post
Title: Re: Expert SSI FAQ
Post by: [SiNaN] on February 19, 2008, 07:45:49 AM
Have a look at this:

http://www.simplemachines.org/community/index.php?topic=135131.msg860679#msg860679
Title: Re: Expert SSI FAQ
Post by: Kender on February 19, 2008, 08:07:17 AM
lol, thanks for that.. my search didnt show up with this on the first page, or second (half of it at least before i gave up)

appreciated!
Title: Re: Expert SSI FAQ
Post by: Kender on February 19, 2008, 08:16:39 AM
is there a way to show a poll from a board, not a post in SSI?

using ssi_showPoll($number); isnt really effective for a changing environment, but i have a board dedicated to polls, and i would love to have it change on the SSI page to the most recent poll, not whatever is coded into it

(i can made a database query and fill in the $number if necessary, but would rather do it through SSI if possible)
Title: Re: Expert SSI FAQ
Post by: Kender on February 21, 2008, 12:30:23 PM
hey, need some SSI assistance, still looking for help with my last question, but would also like to know...

what do i need to add to my includes on a SSI page to get $modSettings enabled ?

trying to get the ad manage mod to work, along with just getting a menu button for felblog (when user is allowed to view it) -- reads like.. if(isset($modSettings['felblog_enabled']))
Title: Re: Expert SSI FAQ
Post by: [SiNaN] on February 22, 2008, 02:51:18 AM
In the function that you use the $modSettings variable, you should firstly define it after defining the function. To give an example:

<?php
//This is an example function.
function ssi_test($output_method 'echo')
{
global $context$txt$scripturl;

if (
$output_method == 'echo')

echo 
'Test, Test, Test, Test';

}
?>


After $scripturl you should add $modSettings as done below;

<?php
//This is an example function.
function ssi_test($output_method 'echo')
{
global $context$txt$scripturl$modSettings;

if (
$output_method == 'echo')

echo 
'Test, Test, Test, Test';

}
?>

Title: Re: Expert SSI FAQ
Post by: Kender on February 22, 2008, 08:50:44 AM
in ssi.php  $modsettings is global, shoudnt it already be enforced?
Title: Re: Expert SSI FAQ
Post by: [SiNaN] on February 23, 2008, 08:46:04 AM
Quote from: Kender on February 22, 2008, 08:50:44 AM
in ssi.php  $modsettings is global, shoudnt it already be enforced?

You should make it global for the function you use it in also.
Title: Re: Expert SSI FAQ
Post by: Gantry on March 03, 2008, 11:45:27 AM
I would like to use some SSI functions on Joomla pages, but what I don't want is those users navigating to what amounts to a wrapped forum.  For instance, if I show a top poster on the front page with ssi_topPoster(); , it displays the top poster's name, which is also a link to his or her profile. If the user clicks to the profile, it's just one more click to the full forum, and I don't want users to be browsing my forum inside an iframe in Joomla.  My thinking is that the SSI output should be for informative purposes, not navigational purposes, and would like to prevent this.

I would like to prevent the output of any of the SSI functions as a link, instead just a plain text result.  Alternatively, if it isn't possible, could I make the links open up in a new window/tab? How would I change the output of any of the SSI functions to do either of these?
Title: Re: Expert SSI FAQ
Post by: Sarge on March 06, 2008, 11:16:01 PM
Quote from: Gantry on March 03, 2008, 11:45:27 AM
I would like to prevent the output of any of the SSI functions as a link, instead just a plain text result.

You can simply call the SSI function with the last parameter different from 'echo' and it will simply return the results as an array instead of displaying them. Then you can format the results and display them the way you want:
Make SSI functions return the results instead of displaying them. (http://www.simplemachines.org/community/index.php?topic=225220.msg1446536#msg1446536)

Let us know if you need more information.
Title: Re: Expert SSI FAQ
Post by: Gantry on March 08, 2008, 07:20:26 PM
Ah, I didn't find that one in my search... thanks Sarge!
Title: Re: Expert SSI FAQ
Post by: Darkness_ on April 30, 2008, 10:02:33 AM
when I use this code from the begin post
<?php

$ssi_gzip 
false;
$ssi_ban true;
$ssi_theme '2';
$ssi_layers = array('main');

ob_start();

require(
"/SSI.php");

?>


i get this error at the place of a button I made (it's a button for another page I made, its olmost the same as of the index.template in the theme end index.php in the sources, only e little difference) button name is lounge

      Notice: Use of undefined constant Lounge - assumed 'Lounge' in /mnt/web1/42/36/51651736/htdocs/forum/Sources/Load.php(1731) : eval()'d code on line 439
      Lounge

Title: Re: Expert SSI FAQ
Post by: fwitt on April 30, 2008, 03:36:24 PM
the most likely cause of that error is that somewhere you have entered the word Lounge without quotes to show its a string not a variable.

so

echo Lounge;


instead of


echo 'Lounge';
Title: Re: Expert SSI FAQ
Post by: aldo on May 01, 2008, 01:39:05 AM
Cool, this is why I love SMF, from what I am aware of, no other forum system has a prebuilt SSI file like SMF.

Not sure if this has been mentioned, but if you put this in a PHP file you can view a lot more of SMF's SSI variables and such you can use:

<?php
require("{PATH_TO_FORUM}/SSI.php");
echo 
'<pre>';
print_r($GLOBALS);
echo 
'</pre>';
?>


Be aware! That in that file, it will show your MySQL connection info, like your MySQL User pass, DB, and User, so don't let anyone you don't want to see it, um, see it ;)
Title: Re: Expert SSI FAQ
Post by: Darkness_ on May 03, 2008, 02:31:02 PM
how can we give these functions a class?

a little explanation what I'm meaning

I want to use this ss function


ssi_recentPosts($num_recent = 8, $exclude_boards = null, $output_method = 'echo')


But I want to give it a class (windowbg, catbg things like that)
the place where I want it, en the heigts and weight?

I hope someone will get what I mean
Title: Re: Expert SSI FAQ
Post by: fwitt on May 04, 2008, 06:30:34 PM
it already has the class ssi_table, just add that to your css with the atributes required
Title: Re: Expert SSI FAQ
Post by: Darkness_ on May 04, 2008, 06:58:52 PM
but how can I change the pictures widthness and things like that, for every different ssi function?
Title: Re: Expert SSI FAQ
Post by: metallica48423 on May 05, 2008, 03:25:31 AM
look into using the 'array' output rather than 'echo' you could apply your own HTML/PHP mix.  Look at the functions and look how they echo when the last parameter is set to echo

I do believe that is covered in one of the SSI faqs.  If you use the function DB off the support section of this site, you can see what attributes are expected.  If you look at the SSI function itself in SSI.php, you can see how it references the data bits -- usually with $row['row_title'].

Its a learning curve a bit but it can lead to some interesting uses of SSI.
Title: Re: Expert SSI FAQ
Post by: Darkness_ on May 05, 2008, 05:52:38 PM
do you maybe have any example of what you mean?
I don't really get what you mean
Title: Re: Expert SSI FAQ
Post by: metallica48423 on May 05, 2008, 06:36:48 PM

                $topics = ssi_RecentTopics('6', array(1,5,21,24,14), '',  'array');
                foreach ($topics as $topic)
                        echo '<b><a href="', $topic['href'], '">', $topic['subject'], '</a></b>';


Sort of basic example.

Basically, It calls the 6 last updated topics that the member can view, excluding the boards in the array, and saves the result as an array in $topics.

the foreach will go through each element in $topics recursively (there would be 6 instances in this case), and its keys will be saved to $topic['key']

The next line is what is looped. 

If you were to put echo '<pre>', print_r($topics), '</pre>'; above the foreach line, it should output each value for $topic.  By doing that I know i can use $topic['subject'] to represent the subject and $topic['href'] to be the link to the topic.

The result? (this is taken from my site)


<b><a href="http://www.zentendo.com/forums/index.php?topic=5325.msg80919;topicseen#new">What's your favorite Zelda game? And</a></b>
<b><a href="http://www.zentendo.com/forums/index.php?topic=5417.msg80917;topicseen#new">Iwata Asks: Link's "Bowgun" Training</a></b>
<b><a href="http://www.zentendo.com/forums/index.php?topic=5418.msg80916;topicseen#new">Crosswords DS - free</a></b>
<b><a href="http://www.zentendo.com/forums/index.php?topic=5422.msg80907;topicseen#new">Two New Games Added to Virtual Console</a></b>
<b><a href="http://www.zentendo.com/forums/index.php?topic=5414.msg80901;topicseen#new">Rygar delayed to 2009</a></b>
<b><a href="http://www.zentendo.com/forums/index.php?topic=4432.msg80900;topicseen#new">The Unofficial ZREO Podcast</a></b>
Title: Re: Expert SSI FAQ
Post by: Darkness_ on May 05, 2008, 08:00:29 PM
can I give them a class to?

like windowbg? or something?

or can it be so that the page has 2 sides en that I place something at the left en something at te right?
Title: Re: Expert SSI FAQ
Post by: metallica48423 on May 05, 2008, 09:24:14 PM
you can do any html.  That is just one example.  The array method will just turn the data into variables you can use, which is what i've done.

you do need some php knowledge for this too though
Title: Re: Expert SSI FAQ
Post by: Darkness_ on May 05, 2008, 09:46:55 PM
Ok, thanks I hope I will get along with this.
If I have any questions further can I maybe PM you ?
Title: Re: Expert SSI FAQ
Post by: metallica48423 on May 05, 2008, 10:35:08 PM
you can post here -- it'll show up in my unreads :)
Title: Re: Expert SSI FAQ
Post by: Darkness_ on May 06, 2008, 04:49:15 AM
Ok thanks
Title: Re: Expert SSI FAQ
Post by: metallica48423 on May 06, 2008, 04:51:12 AM
np ;)
Title: Re: Expert SSI FAQ
Post by: Darkness_ on May 09, 2008, 08:34:07 PM
<?php {
echo 
'
<div width="50%" align="left">
<table width="50%" class="tborder" style="margin-bottom: 1ex cellspacing="1" cellpadding="4";">
<tr class="catbg" align="center">
<td>'
$txt['test'], '</td>
</tr>'
;
$topics ssi_recentPosts($num_recent 8$exclude_boards null$output_method 'array');
                foreach (
$topics as $topic)

                        echo 
'
<td valign="middle" align="center">
<table border="0" cellpadding="0" cellspacing="0">
<b><a href="'
$topic['href'], '">'$topic['subject'], '</a></b></div>';
}


?>

<?php {
echo 
'
<div width="50%" align="right">
<table width="50%" class="tborder" style="margin-bottom: 1ex cellspacing="1" cellpadding="4";">
<tr class="catbg" align="center">
<td>'
$txt['test'], '</td>
</tr>'
;
ssi_showPoll($topic 13$output_method 'echo');
      

                        echo 
'
<td valign="middle" align="center">
<table border="0" cellpadding="0" cellspacing="0">
<b><a href="'
$topic['href'], '">'$topic['subject'], '</a></b></div>';
}


?>


The First part is looking ok to me, the second part to but it's not how I want to be
I try to get the "echo" to "array" but then I can't see the poll
and another problem is The first part I want to get it on te left side of the page and the other on iets right side.
But when I save the codes like this, the second part gets in to the table of the firt one
Title: Re: Expert SSI FAQ
Post by: Black_Paolo on June 27, 2008, 10:36:38 AM
Really interesting faq :D
But you can't use sth like:
"If you aren't in group 12, so don't show the page you searched but the login one"?
Without using else..
So you can place this code at the top of the page and you don't have to include anything..
So you don't have to do:
if xxx
You can't
else
all the code
close the }
etc..
Title: Re: Expert SSI FAQ
Post by: shadownexusruler on June 27, 2008, 02:11:20 PM
i have a question is there a way to pull my forums login in to an tabled layout of my hompage is there a way to add these two things
<?php ssi_login(); ?>
Username:     
Password:     
   
Log Out Function: <?php ssi_logout(); ?> and
Board Stats: <?php ssi_boardStats(); ?>
Total Members: 7
Total Posts: 59
Total Topics: 38
Total Categories: 4
Total Boards: 22
Title: Re: Expert SSI FAQ
Post by: [SiNaN] on June 28, 2008, 03:52:36 AM
Quote from: shadownexusruler on June 27, 2008, 02:11:20 PM
i have a question is there a way to pull my forums login in to an tabled layout of my hompage is there a way to add these two things
<?php ssi_login(); ?>
Username:     
Password:     
   
Log Out Function: <?php ssi_logout(); ?> and
Board Stats: <?php ssi_boardStats(); ?>
Total Members: 7
Total Posts: 59
Total Topics: 38
Total Categories: 4
Total Boards: 22

Better modify the functions in the SSI.php. (In my opinion - just for these two functions)
Title: Re: Expert SSI FAQ
Post by: shadownexusruler on June 28, 2008, 10:39:42 AM
is there anyone who could show me how to bring up the board stats function
Title: Re: Expert SSI FAQ
Post by: [SiNaN] on June 29, 2008, 09:15:26 AM
Let's try this, add this to your page:

<?php
global $txt;
$totals ssi_boardStats();

echo '<table>
<tr><td>'
$txt[488], ': <a href="'$scripturl '?action=mlist">'$totals['members'], '</a></td></tr>
<tr><td>'
$txt[489], ': '$totals['posts'], '</td></tr>
<tr><td>'
$txt[490], ': '$totals['topics'], '</td></tr>
<tr><td>'
$txt[658], ': '$totals['categories'], '</td></tr>
<tr><td>'
$txt[665], ': '$totals['boards'], '</td></tr>
</table>'
;
?>

Title: Re: Expert SSI FAQ
Post by: shadownexusruler on June 30, 2008, 11:22:24 AM
what bout the ssi login: <?php ssi_login(); ?>
Title: Re: Expert SSI FAQ
Post by: [SiNaN] on July 01, 2008, 06:54:21 AM
<?php
global 
$scripturl$txt$user_info$context;

$array ssi_login('''array');

echo '
<form action="'
$scripturl'?action=login2" method="post" accept-charset="'$context['character_set'], '">
<table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
<tr>
<td align="right"><label for="user">'
$txt[35], ':</label>&nbsp;</td>
<td><input type="text" id="user" name="user" size="9" value="'
$user_info['username'], '" /></td>
</tr><tr>
<td align="right"><label for="passwrd">'
$txt[36], ':</label>&nbsp;</td>
<td><input type="password" name="passwrd" id="passwrd" size="9" /></td>
</tr><tr>
<td><input type="hidden" name="cookielength" value="-1" /></td>
<td><input type="submit" value="'
$txt[34], '" /></td>
</tr>
</table>
</form>'
;
?>
Title: Re: Expert SSI FAQ
Post by: shadownexusruler on July 01, 2008, 10:53:18 AM
should i save that in a separate file from my homepage like name the file login.php

what bout  <?php ssi_whosOnline(); ?> and <?php ssi_welcome(); ?>
Title: Re: Expert SSI FAQ
Post by: [SiNaN] on July 02, 2008, 03:49:00 AM
No need for that, just add them to your php file.

Quote from: shadownexusruler on July 01, 2008, 10:53:18 AM
what bout  <?php ssi_whosOnline(); ?> and <?php ssi_welcome(); ?>

What do you mean?

Title: Re: Expert SSI FAQ
Post by: shadownexusruler on July 02, 2008, 10:43:18 AM
is there a way to call the function of who's online <?php ssi_whosOnline(); ?> and could i add <?php ssi_welcome(); ?> to th login
Title: Re: Expert SSI FAQ
Post by: estokwa on November 07, 2008, 07:31:26 PM
 i don't know where to post my question.. i can't post my question on the basic SSI FAQ because there is no quick reply section at the bottom though i was log in....
here is my question.... i want to put on my default page just a login nothing else but the login module. i tried the two files on the basic SSI, it only show the user name and password and every time i put my username and password and  hit the enter it will erased the info i entered and that's it.. it will show again the username and password and nothing happen.. no page came out but the two input box for username and password...
hope you can enlighten me with this query.. my apology if i put my question on this topic...
thank you for reading this and giving your inputs...
Title: Re: Expert SSI FAQ
Post by: [SiNaN] on December 06, 2008, 11:05:48 AM
shadownexusruler:

I'm not sure what you mean.

estokwa:

Is it possible to see the page? You say you are not redirected to anywhere, right?
Title: Re: Expert SSI FAQ
Post by: bfeo on January 11, 2009, 05:19:35 PM
Any way to prevent page access to guests and members who aren't logged in?
Title: Re: Expert SSI FAQ
Post by: fwitt on January 12, 2009, 09:11:20 AM
Quote from: bfeo on January 11, 2009, 05:19:35 PM
Any way to prevent page access to guests and members who aren't logged in?

http://docs.simplemachines.org/index.php?topic=789.msg1688#msg1688
Title: Re: Expert SSI FAQ
Post by: adrunkentheory on January 12, 2009, 03:44:42 PM
Hello,

I am trying to execute a custom mysql query but keep getting the error ...
"No Database Selected"

I have setup a table within the SMF database and want to access that information based on $context['user']['username'] data variable.

I have tried using the db_query() function that I see in the SSI.php to no avail. I have tried writing my own function within the SSI.php but still receive the same error.

Now I know there's a database connection happening, but how do I use it to execute my own queries?
Title: Re: Expert SSI FAQ
Post by: metallica48423 on January 12, 2009, 03:50:41 PM
posting your code might help -- i also reccommend starting a new topic in this board for the issue :)
Title: Re: Expert SSI FAQ
Post by: adrunkentheory on January 12, 2009, 04:11:32 PM
Thank you for that quick reply. Hopefully I won't have to start another thread. I will if I cannot be helped here.

Below is the function I tried...
I did not global any variables cause I didn't know which ones exactly to use.
I also left out the __FILE__ and __LINE__, well because I don't know what they do.

Even with global variables and other attributes added, I still receive the same error, so I figured it was irrelevant.



function get_random_profile() {

$request = db_query("SELECT * FROM mytableprefix_profile", false, false) or die(mysql_error());
$row = mysql_fetch_array($request);

echo $row['cod4_guid'];
//mysql_free_result($request);
}


I also tried using just mysql_query() php function.

Really, I just want to know how to do your most basic query using SSI.php.

Quote from: metallica48423 on January 12, 2009, 03:50:41 PM
posting your code might help -- i also reccommend starting a new topic in this board for the issue :)
Title: Re: Expert SSI FAQ
Post by: metallica48423 on January 12, 2009, 04:19:49 PM
You didn't tell MySQL which database you want the data from

$request = db_query("SELECT * FROM {$db_prefix}mytableprefix_profile", false, false) or die(mysql_error());

As for __FILE__, __LINE__ -- leave them there, they're there for debugging so that the error log can pick up the right file and line number for debugging :)
Title: Re: Expert SSI FAQ
Post by: adrunkentheory on January 12, 2009, 04:48:31 PM
BOOOOM. Thank you so much man :)

Last question, but not that important.

Originally, my custom table name did not have the same prefix as my forum tables. Is there another way to reference the database. I don't have a problem renaming my custom tables to match the forum structure, but I'm just curious.

Thank you very much again.  ;D
Title: Re: Expert SSI FAQ
Post by: metallica48423 on January 12, 2009, 05:09:05 PM
you could do like databasename.tablename

ie: $request = db_query("SELECT * FROM other_forum.mytableprefix_profile", false, false) or die(mysql_error());

where other_forum is the name of the database
Title: Re: Expert SSI FAQ
Post by: adrunkentheory on January 12, 2009, 08:30:25 PM
Excellent! Your my SMF super hero.

I can't believe my previous searches didn't come up with anything. After installing SMF and learning about SSI.php doing a custom query using the information provided by $context was one of the first things I wanted to do.  I hope this helps somebody as much as it's helped me as now I am on my way to a completely SMF integrated website  8)

Metallica, best wishes and I can't thank you enough. :)

Title: Re: Expert SSI FAQ
Post by: Acans on January 12, 2009, 09:07:14 PM
blue dream

will this script log you in but not redirect you to your forum

<?php
global 
$scripturl$txt$user_info$context;

$array ssi_login('''array');

echo '
<form action="'
$scripturl'?action=login2" method="post" accept-charset="'$context['character_set'], '">
<table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
<tr>
<td align="right"><label for="user">'
$txt[35], ':</label>&nbsp;</td>
<td><input type="text" id="user" name="user" size="9" value="'
$user_info['username'], '" /></td>
</tr><tr>
<td align="right"><label for="passwrd">'
$txt[36], ':</label>&nbsp;</td>
<td><input type="password" name="passwrd" id="passwrd" size="9" /></td>
</tr><tr>
<td><input type="hidden" name="cookielength" value="-1" /></td>
<td><input type="submit" value="'
$txt[34], '" /></td>
</tr>
</table>
</form>'
;
?>
Title: Re: Expert SSI FAQ
Post by: [SiNaN] on January 13, 2009, 08:48:14 AM
That should redirect to forum.
Title: Re: Expert SSI FAQ
Post by: Darkness_ on January 13, 2009, 08:51:26 AM
is it possible with SSI to get the color changer (if the theme is MC)?
how could I do that?
Title: Re: Expert SSI FAQ
Post by: [SiNaN] on January 13, 2009, 08:55:20 AM
If you use template layers, it should already be there for a usual MC theme.
Title: Re: Expert SSI FAQ
Post by: Darkness_ on January 13, 2009, 08:59:17 AM
I made the theme MC
There is a color changer in the 'theme index' in the profile
but I want a dorpdownbox in the boardindex
Title: Re: Expert SSI FAQ
Post by: Acans on January 13, 2009, 09:00:02 AM
Quote from: Blue Dream on January 13, 2009, 08:48:14 AM
That should redirect to forum.

how do you make it not redirect to the forum when you log in using SSI on a webpage
Title: Re: Expert SSI FAQ
Post by: fwitt on January 13, 2009, 12:11:45 PM
the simplest code that directs users to the webpage when they login from the webpage is along the lines of...


ssi_login('http://www.example.com/index.php');


where the url is where you wish the user to be sent on login, mine is set so they are taken to whichever page they were sent to my login page from or the website index if they came straight to the login page from elsewhere.

Title: Re: Expert SSI FAQ
Post by: Mamoun on May 06, 2009, 09:30:38 PM
Hi,
I wonder how I can be able to make the boardnews command look for pictures only in the body of the latest topics and display them? is there a way to do it?
Title: Re: Expert SSI FAQ
Post by: ebonywolf on June 16, 2009, 10:50:53 AM
can someone help me pull the memberlist via ssi please
Title: Re: Expert SSI FAQ
Post by: parminder on June 21, 2009, 12:47:48 PM
is there any way to view Member Groups like profile

i mean click able Membergroup names for Users.

like we use ?action=profile;u="id"


same for ?action=membergroups;m="id' something like that
Title: Re: Expert SSI FAQ
Post by: [SiNaN] on June 22, 2009, 10:58:23 AM
Quote from: Mamoun on May 06, 2009, 09:30:38 PM
Hi,
I wonder how I can be able to make the boardnews command look for pictures only in the body of the latest topics and display them? is there a way to do it?

http://www.simplemachines.org/community/index.php?topic=274167.msg1882353#msg1882353

Quote from: ebonywolf on June 16, 2009, 10:50:53 AM
can someone help me pull the memberlist via ssi please

Your request sounds too general. Why don't you just redirect them to the member list page?

Quote from: parminder on June 21, 2009, 12:47:48 PM
is there any way to view Member Groups like profile

i mean click able Membergroup names for Users.

like we use ?action=profile;u="id"


same for ?action=membergroups;m="id' something like that

It's /index.php?action=groups;sa=members;group={group_id} in SMF 2.0 versions. Not available in SMF 1.1 versions though.