Author Topic: Shoutbox help  (Read 9064 times)

0 Members and 1 Guest are viewing this topic.

Offline uksoreeyes

  • Full Member
  • ***
  • Posts: 117
    • View Profile
    • http://www.myleeneklass.com
Shoutbox help
« 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.

Code: [Select]
<?php

if &#40;$shout&#41;&#123;
 
define&#40;'ROOT_PATH', './'&#41;;
include&#40;ROOT_PATH.'global.php'&#41;; 
require&#40;ROOT_PATH.'includes/sessions.php'&#41;;

if &#40;$message == !""&#41;&#123;
$ip $REMOTE_ADDR;
$info $HTTP_USER_AGENT;
$goto $HTTP_REFERER;
$add_date=time &#40;void&#41;;
$message stripslashes&#40;$message&#41;;
$message htmlspecialchars&#40;$message&#41;;
$user_name $user_info['user_name'&#93;;
$result=MYSQL_QUERY&#40;"INSERT INTO shoutbox &#40;id,name,message,timestamp,ip,browser,block&#41;".
"VALUES &#40;'NULL', '$user_name', '$message', '$add_date', '$ip', '$info', '$block'&#41;"&#41;;  
echo "<META http-equiv='refresh' content='0;URL=$goto'>"
&
#125;
else &#123;
echo "<META http-equiv='refresh' content='0;URL=http&#58;//www.myleeneklass.com'>"
&
#125;
&#125;
?>

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Shoutbox help
« Reply #1 on: May 01, 2003, 10:36:39 AM »
use this:
Code: [Select]
if ($user_info['user_level'] < USER) {
  show_error_page($lang['no_permission']);
  exit;
}
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline uksoreeyes

  • Full Member
  • ***
  • Posts: 117
    • View Profile
    • http://www.myleeneklass.com
Shoutbox help
« Reply #2 on: May 01, 2003, 11:06:36 AM »
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?

Offline uksoreeyes

  • Full Member
  • ***
  • Posts: 117
    • View Profile
    • http://www.myleeneklass.com
Shoutbox help
« Reply #3 on: May 01, 2003, 11:11:47 AM »
Me again I added this piece of code to my shout.php below require(ROOT_PATH.'includes/sessions.php');
Code: [Select]
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

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Shoutbox help
« Reply #4 on: May 01, 2003, 11:16:59 AM »
Quote from: uksoreeyes
Me again I added this piece of code to my shout.php below require(ROOT_PATH.'includes/sessions.php');
Code: [Select]
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.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Shoutbox help
« Reply #5 on: May 01, 2003, 11:20:24 AM »
ok maybe the easiest way to do, is just ignore the message if user is not logged in?
just use
Code: [Select]
if ($user_info['user_level'] >= USER) {
...your code to insert new message into DB...
}
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline uksoreeyes

  • Full Member
  • ***
  • Posts: 117
    • View Profile
    • http://www.myleeneklass.com
Shoutbox help
« Reply #6 on: May 01, 2003, 11:22:51 AM »
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?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Shoutbox help
« Reply #7 on: May 01, 2003, 11:39:25 AM »
I'm not sure, but since my first post I cant even open your site anymore...
I get this error message:
Quote
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"...
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline uksoreeyes

  • Full Member
  • ***
  • Posts: 117
    • View Profile
    • http://www.myleeneklass.com
Shoutbox help
« Reply #8 on: May 01, 2003, 11:54:11 AM »
Yeah you got that error because I was trying out a few bits of code which didn't work. Site should load now.
Quote
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.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Shoutbox help
« Reply #9 on: May 01, 2003, 12:03:27 PM »
then do this way?:
Code: [Select]
<?php 

if &#40;$shout&#41;&#123; 

define&#40;'ROOT_PATH', './'&#41;; 
include&#40;ROOT_PATH.'global.php'&#41;;  
require&#40;ROOT_PATH.'includes/sessions.php'&#41;; 
if &#40;$message != "" && $user_info['user_level'&#93; >= USER&#41;&#123; 
$ip $REMOTE_ADDR
$info $HTTP_USER_AGENT
$goto $HTTP_REFERER
$add_date=time &#40;void&#41;; 
$message stripslashes&#40;$message&#41;; 
$message htmlspecialchars&#40;$message&#41;; 
$user_name $user_info['user_name'&#93;; 
$result=MYSQL_QUERY&#40;"INSERT INTO shoutbox &#40;id,name,message,timestamp,ip,browser,block&#41;". 
"VALUES &#40;'NULL', '$user_name', '$message', '$add_date', '$ip', '$info', '$block'&#41;"&#41;;   
echo "<META http-equiv='refresh' content='0;URL=$goto'>";  
&
#125; 
else &#123; 
echo "<META http-equiv='refresh' content='0;URL=http&#58;//www.myleeneklass.com'>";  
&
#125; 
&#125; 
?>


it will react as no message was typed and redirect to the main site.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline uksoreeyes

  • Full Member
  • ***
  • Posts: 117
    • View Profile
    • http://www.myleeneklass.com
Shoutbox help
« Reply #10 on: May 01, 2003, 12:08:28 PM »
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 :)