4images Forum & Community
4images Issues / Ausgaben => Discussion & Troubleshooting => Topic started by: uksoreeyes on May 01, 2003, 10:32:20 AM
-
Hello I was wondering if someone could help me with a little bug in my shoutbox that I intergrated into 4images. The first is actually quite simple but I can't seem to figure out the code to use.
On my gallery I have a shoutbox where the user cannot post unless he/she is logged in. I used the {if user_loggedin} to show the form if the user is logged in, if the user is a guest I used the {if user_loggedout} to show an image stating that u must be logged into post.
The problem is that sometimes a user logs out of the gallery and their browser has cached the page and the form is visible which lets the visitor post even though he/she is logged out. I want to add a bit code to the script below that will be along the lines of:
if user_level=guest or user_awaiting // popup a javascript message stating that you must be logged into post then when the user clicks ok he/she is redirected back to the page they came from. and if user_level=registered or admin //continue with the post as normal.
If anyone could help with this I would be very greatful. I wrote this little script myself and am trying to get rid of a few bugs but when I do I will post this as a mod unless someone else wants to, your free to do so. My code is below so you can see what I'm getting at.
<?php
if ($shout){
define('ROOT_PATH', './');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
if ($message == !""){
$ip = $REMOTE_ADDR;
$info = $HTTP_USER_AGENT;
$goto = $HTTP_REFERER;
$add_date=time (void);
$message = stripslashes($message);
$message = htmlspecialchars($message);
$user_name = $user_info['user_name'];
$result=MYSQL_QUERY("INSERT INTO shoutbox (id,name,message,timestamp,ip,browser,block)".
"VALUES ('NULL', '$user_name', '$message', '$add_date', '$ip', '$info', '$block')");
echo "<META http-equiv='refresh' content='0;URL=$goto'>";
}
else {
echo "<META http-equiv='refresh' content='0;URL=http://www.myleeneklass.com'>";
}
}
?>
-
use this:
if ($user_info['user_level'] < USER) {
show_error_page($lang['no_permission']);
exit;
}
-
Hi I added thie code below my:
require(ROOT_PATH.'includes/sessions.php');
It works and redirects but the template doesnt display the header or footer which results in a messed up page. Can you tell me why this is happening?
-
Me again I added this piece of code to my shout.php below require(ROOT_PATH.'includes/sessions.php');
include(ROOT_PATH.'includes/page_header.php');
and its fixed the broken images problem, but the page still doesnt include the header or footer of the page
-
Me again I added this piece of code to my shout.php below require(ROOT_PATH.'includes/sessions.php');
include(ROOT_PATH.'includes/page_header.php');
and its fixed the broken images problem, but the page still doesnt include the header or footer of the page
The page that opens when GUESTs trying to post a message?
the error page?
if so, check error.html template, make sure it has {header} on top of it.
-
ok maybe the easiest way to do, is just ignore the message if user is not logged in?
just useif ($user_info['user_level'] >= USER) {
...your code to insert new message into DB...
}
-
yep it has the {header} at the top and the {footer} at the bottom. I dont quite understand. I dont know if this helps but the address in the address bar reads mydomain.com/shout.php
Maybe theres someting missing from that file?
-
I'm not sure, but since my first post I cant even open your site anymore...
I get this error message:Fatal error: Cannot redeclare affiliates_1() in c:\php4\pear\myleeneklass.php on line 7
maybe because your browser cached the webpage u dont see it, but see page without "style"...
-
Yeah you got that error because I was trying out a few bits of code which didn't work. Site should load now.
maybe because your browser cached the webpage u dont see it, but see page without "style"...
Thats the same problem I'm getting, the error page doesnt have the styles because there all included in the header which if you look at the source you can see it hasn't loaded it. I don't know why it's doing this.
-
then do this way?:
<?php
if ($shout){
define('ROOT_PATH', './');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
if ($message != "" && $user_info['user_level'] >= USER){
$ip = $REMOTE_ADDR;
$info = $HTTP_USER_AGENT;
$goto = $HTTP_REFERER;
$add_date=time (void);
$message = stripslashes($message);
$message = htmlspecialchars($message);
$user_name = $user_info['user_name'];
$result=MYSQL_QUERY("INSERT INTO shoutbox (id,name,message,timestamp,ip,browser,block)".
"VALUES ('NULL', '$user_name', '$message', '$add_date', '$ip', '$info', '$block')");
echo "<META http-equiv='refresh' content='0;URL=$goto'>";
}
else {
echo "<META http-equiv='refresh' content='0;URL=http://www.myleeneklass.com'>";
}
}
?>
it will react as no message was typed and redirect to the main site.
-
Yeah that will work for now, just as long as it stops messages in the shoutbox having no names above them. Thanks for your help you have given me some ideas which I will try out tonight when the site is less busy and people won't see any major errors.
If I find the solution I'll let you know :)