Advertisement:

Author Topic: Basic SSI FAQ  (Read 155469 times)

Offline Ravyn

  • Jr. Member
  • **
  • Posts: 139
  • Gender: Male
Re: Basic SSI FAQ
« Reply #80 on: August 26, 2006, 12:16:44 AM »
Hi there,

I just started messing around with Server Side Includes, and found this tutorial.  I've got the ssi_menubar working, sort of, it displays all the proper links for the menubar, however it only displays the text versions, how do I get it to display the graphic interface that is used on the forums when visiting my homepage?

Edit: I got it working properly by looking at the code for the ssi_example.php file.  However, I was hoping someone could just give me a quick breakdown of what each part of the code I added to make it work does.

The part between the <body> tags being the addition that made it work.

Code: [Select]
<?php

require("/home/virtual/site45/fst/var/www/html/forums/SSI.php");
ssi_menubar();
?>

<html>
<body>
<?php

echo 
'
<link rel="stylesheet" type="text/css" href="'
$settings['default_theme_url'], '/style.css" />
<script language="JavaScript" type="text/javascript" src="'
$settings['default_theme_url'], '/script.js"></script>
<style type="text/css">
body
{
margin: 1ex;
}'
;

if ($context['browser']['needs_size_fix'])
echo '
@import('
$settings['default_theme_url'], '/fonts-compat.css);';

echo '
</style>'
;

?>

</body>
</html>
« Last Edit: August 26, 2006, 12:23:42 AM by Ravyn »
Ravyn
-SMF Newbie in Training

Offline pctwo

  • Semi-Newbie
  • *
  • Posts: 68
Re: Basic SSI FAQ
« Reply #81 on: August 26, 2006, 05:57:01 PM »
Is there a variable and function which returns the full URL of the current file.

I have to do something like

$_SERVER['SCRIPT_NAME'] or $_SERVER['REQUEST_URI'] only returns /path/file.php.  I need the full http://www.mysite.com/path/file.php for ssi_login and ssi_logout to redirect to the proper place.

I guess I could reconstruct it with server_protocol and name and port but that's kinda ugly, and I'll probably get it wrong too :)

(I don't want to hard code it either b/c it needs to work both on my test machine and real server)

thanks

Offline pctwo

  • Semi-Newbie
  • *
  • Posts: 68
Re: Basic SSI FAQ
« Reply #82 on: August 26, 2006, 08:13:28 PM »
Ok, Someone needsto help me. I took the code from the welcome file from the first post, and put it in my php file at the very top, and I still can't see nothing.

Code: [Select]
<?php
require("/www/home/goalforums.net/forums/SSI.php"); 

// Script writen by Tomer "Lamper" Dean.
// **NOTE** Always check that the require statement is correct!
// A script that checks if your a guest, and if guest, puts a login box,
// and if user, put a welcome message.

// Checks which membergroup you are in.

if ($context['user']['is_guest'])
   {
      
ssi_login();
   }
else
   {
      
ssi_welcome();
   }

?>

Am I missing something? please help a PHP retard XD

Where in your file did you insert this?

If you insert it at the top, above <html>, that may be why it doesn't show up.

You need to put the require statement at the top.  The rest goes inside the <body></body> tag.

Code: [Select]
<?php
require("/www/home/goalforums.net/forums/SSI.php"); 
?>

<html>
<body>
....
if ($context['user']['is_guest'])
   {
      ssi_login();
   }
else
   {
      ssi_welcome();
   }

?>
</body>
</html>

Offline pctwo

  • Semi-Newbie
  • *
  • Posts: 68
Re: Basic SSI FAQ
« Reply #83 on: August 26, 2006, 08:24:21 PM »
i would like to do something that another user here mentioned as well. i am building a site from the ground up without using a CMS. i have SMF installed that is being used, and would like to take the main page from the site and use SSI to handle logins and authentication. my problem with doing it with ssi_login(); is that the form posts to the root page of the forums. is there any way to have ssi_login(); post back to the root page of the site itself, and not take you into the forums?

everything is working flawlessly so far...i just need to get this one thing sorted out :D

you need to pass ssi_login the full url of the page you ant to redirect to

ssi_login('http://www.123.com/path/file.php') it will then redirect to the page

I ended up writing a function called ssi_thisurl() that returns the url of the current page

Code: [Select]
function ssi_thisurl()
{
return
  (preg_match("/^https/i", $_SERVER['SERVER_PROTOCOL']) ? 'https' : 'http') . '://' . $_SERVER['SERVER_NAME'] .
  ($_SERVER['SERVER_PORT']==80 ? '' : ':' . $_SERVER['SERVER_PORT']) .
  $_SERVER['SCRIPT_NAME'];
}

and I can now just use ssi_login(ssi_thisurl()) and it redirects right back to the page the user was at.

This way, it works for all pages and you can include this anywhere.

note: this code is hacky and not what the doctor recommends!
« Last Edit: August 26, 2006, 08:27:07 PM by pctwo »

Offline gregy

  • Jr. Member
  • **
  • Posts: 111
  • Gender: Male
  • I'm a llama!
Re: Basic SSI FAQ
« Reply #84 on: September 05, 2006, 07:03:27 AM »
hi

is it possible to use SSI.php on other domain ..?

like, forum is on 123.com and i want to be able to use SSI.php as infobox on domain 345.com ..

thanx in advance

Offline pctwo

  • Semi-Newbie
  • *
  • Posts: 68
Re: Basic SSI FAQ
« Reply #85 on: September 05, 2006, 09:43:21 AM »
hi

is it possible to use SSI.php on other domain ..?

like, forum is on 123.com and i want to be able to use SSI.php as infobox on domain 345.com ..

thanx in advance

I think you'd need to install smf on 345.com and point it to 123.com, e.g., Setting.php looks something like this

Code: [Select]
<?php
########## Forum Info ##########
$boardurl 'http://www.123.com/smf'; # URL to your forum's folder. (without the trailing /!)
########## Database Info ##########
$db_server 'db.123.com';
$db_name 'mysmfforum';
$db_user 'mysmfuser';
$db_passwd 'mypasswd';


########## Directories/Files ##########
# Note: These directories do not have to be changed unless you move things.
$boarddir '/home/user/www/smf'; # These would have to be path on 345.com
$sourcedir '/home/user/www/smf/Sources'; # Path to the Sources directory.

?>


this is assuming your host allows mysql connection from outside domain.  If yes, you can usually specify and acces list and you just add 345.com to the list.

Offline gregy

  • Jr. Member
  • **
  • Posts: 111
  • Gender: Male
  • I'm a llama!
Re: Basic SSI FAQ
« Reply #86 on: September 05, 2006, 09:57:17 AM »
hi

thanx for help .. i did another trick ( i was having probelms with SSI into Oscommerce .. i managed with hand made file .. include :)

no, i have another question ... can i use SSI.php recent posts from specific category or Board? (cat=11 or boards 113,114,115,116)

Offline pctwo

  • Semi-Newbie
  • *
  • Posts: 68
Re: Basic SSI FAQ
« Reply #87 on: September 05, 2006, 11:08:45 AM »
hi

thanx for help .. i did another trick ( i was having probelms with SSI into Oscommerce .. i managed with hand made file .. include :)

no, i have another question ... can i use SSI.php recent posts from specific category or Board? (cat=11 or boards 113,114,115,116)

for boards, it's easy b/c the function already lets you EXCLUDE board, so one small change should do it.  For example, in ssi_recentPosts() change

         AND b.ID_BOARD NOT IN (" . implode(', ', $exclude_boards) . ")") . "

to

         AND b.ID_BOARD IN (" . implode(', ', $exclude_boards) . ")") . "

i.e., take out the NOT.  It's best to make a copy that function and call it something else, like ssi_myRecentPosts. You may want to change the variable name $exclude_boards to $include_boards so it's not confusing.  Then you just call it like this

ssi_myRecentPosts( 10, array( 110,114,120))

(get 10 most recent posts from boards 110, 114, and 120)

Offline gregy

  • Jr. Member
  • **
  • Posts: 111
  • Gender: Male
  • I'm a llama!
Re: Basic SSI FAQ
« Reply #88 on: September 05, 2006, 11:27:29 AM »
thank you very much for these lines .. so if i understood right

<?php include("http://www.domain.com/SSI.php?ssi_function=recentPosts( 10, array( 113,114,115,116))"); ?>

will show last 10 posts from these boards? guess not .. it's not working :(

Offline pctwo

  • Semi-Newbie
  • *
  • Posts: 68
Re: Basic SSI FAQ
« Reply #89 on: September 05, 2006, 12:04:26 PM »
define "not working"?

Offline gregy

  • Jr. Member
  • **
  • Posts: 111
  • Gender: Male
  • I'm a llama!
Re: Basic SSI FAQ
« Reply #90 on: September 05, 2006, 12:34:42 PM »
i have deleted NOT in two instances in SSI.php and made include like statedin prevoius my post, now, no posts show up  :-[

Offline pctwo

  • Semi-Newbie
  • *
  • Posts: 68
Re: Basic SSI FAQ
« Reply #91 on: September 05, 2006, 02:39:48 PM »
do you get anything if you put NOT back in?

Is that include statement correct? Try the function call without any arguments.

Offline gregy

  • Jr. Member
  • **
  • Posts: 111
  • Gender: Male
  • I'm a llama!
Re: Basic SSI FAQ
« Reply #92 on: September 06, 2006, 02:28:03 AM »
function recentposts works great without thoe yours modifications .. or i'm doing something wrong .. i'll check that again ...

Offline pctwo

  • Semi-Newbie
  • *
  • Posts: 68
Re: Basic SSI FAQ
« Reply #93 on: September 06, 2006, 01:42:23 PM »
try doing it the way ssi_exaples.php does, like this

Code: [Select]
<?php require('/absolute_local_path_to_your_smf/SSI.php'); ?>

<?php ssi_recentPosts(10,array(110,115)); flush(); ?>

the first line should go on top of the page.  2nd line goes where you want to insert the output.

Offline gregy

  • Jr. Member
  • **
  • Posts: 111
  • Gender: Male
  • I'm a llama!
Re: Basic SSI FAQ
« Reply #94 on: September 06, 2006, 03:45:11 PM »
hmm .. but this "require" would stop my site loading if other domain won't be available!?

Offline pctwo

  • Semi-Newbie
  • *
  • Posts: 68
Re: Basic SSI FAQ
« Reply #95 on: September 06, 2006, 04:54:07 PM »
I don't know.

when you do it your way, do you get an error msg? anything?

Offline gregy

  • Jr. Member
  • **
  • Posts: 111
  • Gender: Male
  • I'm a llama!
Re: Basic SSI FAQ
« Reply #96 on: September 07, 2006, 02:08:47 AM »
it works  ;)

OK .. here is what i did .. of course with big help of you pctwo  ;D

.. for noobies like me

My forum resides at original.com in root .. my wish was to pull out recent posts and show them on another domain on another server, at otherdomain.com.

I created a file called recent.php and put it on otherdomain.com and in this file i calles all SSI that i needed, now my recent .php on otherdomain.com looks like this

Quote
<html>
<head>
</head>
<body>
<?php require('/home/web/original.com/www/SSI.php'); ?>
<font face="verdana" size="1"><?php ssi_recentPosts(10,array(113,114,115,116)); flush(); ?></font><br>
<?php include("http://www.original.com/SSI.php?ssi_function=boardStats"); ?>,&nbsp; Online: <?php include("http://www.original.com/SSI.php?ssi_function=logOnline"); ?>
</body>
</html>

i had to make it in special file, cause Oscommerce somehow is not allowing to call into those files .. dunno why .. but this way it works very well!

thanx a gain for supoort

Offline pctwo

  • Semi-Newbie
  • *
  • Posts: 68
Re: Basic SSI FAQ
« Reply #97 on: September 07, 2006, 10:07:11 AM »
I think that works because your original and other domains are both hosted on the same machine, right?

See, I don't know what I'm talking about and together we lucked into the right answer :)

For the poor unsuspecting soul who tumbles on this topic, here's (I think) the correct way to do this:

Because we can't pass function parameters via the URL, we need to define a function that does it for us.  In the original.com's SSI.php, add a function like this

Code: [Select]
function ssi_myRecentPosts()
{
     ssi_recentPosts( 10, array(100,120,140)); // or whatever parameters you need
}

If you don't know where to put this, insert it at the end at the line before the ?>

Then call it like you did with the other functions

Code: [Select]
<?php include("http://www.original.com/SSI.php?ssi_function=myRecentPosts"); ?>
Get rid of the line <?php require ... ?>

.
« Last Edit: September 07, 2006, 10:09:42 AM by pctwo »

Offline sastian

  • Newbie
  • *
  • Posts: 3
Re: Basic SSI FAQ
« Reply #98 on: October 03, 2006, 10:25:45 PM »
am i having the same issue with SMO Shoutbox?
my log is full of ...
Quote
Apply Filter: Only show the error messages of this member  XXXX       Today at 09:54:51 PM
Apply Filter: Only show the error messages of this IP address XXXX      Apply Filter: Only show the error messages of this session XXXX
Apply Filter: Only show the error messages of this URL hxxp:XXXX.com/index.php?option=com_smf&amp;Itemid=52&amp;option=com_smf&amp;amp;Itemid=52&amp;amp;action=viewErrorLog;desc [nonactive]
Apply Filter: Only show the errors with the same message
8: Undefined variable: context
File: /home/XXXX/public_html/modules/mod_smo_ajax_shoutbox.php
Line: 456
   
Apply Filter: Only show the error messages of this member XXXX    Today at 09:54:51 PM
Apply Filter: Only show the error messages of this IP address XXXX      Apply Filter: Only show the error messages of this session XXXX
Apply Filter: Only show the error messages of this URL hxxp:XXXX.com/index.php?option=com_smf&amp;Itemid=52&amp;option=com_smf&amp;amp;Itemid=52&amp;amp;action=viewErrorLog;desc [nonactive]
Apply Filter: Only show the errors with the same message
8: Undefined variable: context
File: /home/XXXX/public_html/modules/mod_smo_ajax_shoutbox.php
Line: 455


Code: [Select]
array(
'tag' => 'glow',
'type' => 'unparsed_commas',
'test' => '[#0-9a-z\-]{3,12},([012]\d{1,2}|\d{1,2})(,[^]]+)?\]',
'before' => $context['browser']['is_ie'] ? '<table border="0" cellpadding="0" cellspacing="0" style="display: inline; vertical-align: middle; font: inherit;"><tr><td style="filter: Glow(color=$1, strength=$2); font: inherit;">' : '<span style="background-color: $1;">',
'after' => $context['browser']['is_ie'] ? '</td></tr></table> ' : '</span>',
),

Offline abney317

  • Newbie
  • *
  • Posts: 7
Re: Basic SSI FAQ
« Reply #99 on: October 09, 2006, 08:34:13 PM »
how do I import the forum news??