News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Basic SSI FAQ

Started by Tomer, June 23, 2004, 05:06:24 AM

Previous topic - Next topic

Ravyn

#80
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.

<?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>
Ravyn
-SMF Newbie in Training

pctwo

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

pctwo

Quote from: ReD^DeviL on July 17, 2006, 04:17:44 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.

<?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.


<?php
require("/www/home/goalforums.net/forums/SSI.php"); 
?>

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

?>
</body>
</html>

pctwo

#83
Quote from: fluid on February 10, 2006, 01:06:47 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


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!

gregy

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

pctwo

Quote from: gregy 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

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


<?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.

gregy

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)

pctwo

Quote from: gregy 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)

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)

gregy

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 :(

pctwo


gregy

i have deleted NOT in two instances in SSI.php and made include like statedin prevoius my post, now, no posts show up  :-[

pctwo

do you get anything if you put NOT back in?

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

gregy

function recentposts works great without thoe yours modifications .. or i'm doing something wrong .. i'll check that again ...

pctwo

try doing it the way ssi_exaples.php does, like this


<?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.

gregy

hmm .. but this "require" would stop my site loading if other domain won't be available!?

pctwo

I don't know.

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

gregy

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

pctwo

#97
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


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

<?php include("http://www.original.com/SSI.php?ssi_function=myRecentPosts"); ?>

Get rid of the line <?php require ... ?>

.

sastian

am i having the same issue with SMO Shoutbox?
my log is full of ...
QuoteApply 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


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

abney317

how do I import the forum news??

Advertisement: