vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Help with redirect and localdate (https://vborg.vbsupport.ru/showthread.php?t=46332)

Boofo 12-03-2002 07:32 AM

Help with redirect and localdate
 
Can someone please tell me how to send a redirect message to a user when they try to click on NEW THREAD or POST REPLY in a forum that is not open for posting to registered users? I'd like it to work like it does here at vb.org (i.e. the following):

Sorry! This forum is not accepting new posts.

I have a forum set up for a program hints, tips and tricks and the only ones allowed to post there are the mods of the forum and the Admin and Supermod. It is an information forum only.

Also, can you please also tell me how to get the users date (offset according to time offset and day of the week to display in $timezone.

I guess I've been away a little too long. This is elementary stuff, I know. :)

Xenon 12-03-2002 03:59 PM

hmm, not sure if i understood right

open newreply.php find
PHP Code:

if (($bbuserinfo['userid']!=$threadinfo['postuserid'] or $bbuserinfo['userid']==0) and (!$permissions['canviewothers'] or !$permissions['canreplyothers'])) {
  
show_nopermission();


change it to:
PHP Code:

if (($bbuserinfo['userid']!=$threadinfo['postuserid'] or $bbuserinfo['userid']==0) and (!$permissions['canviewothers'] or !$permissions['canreplyothers'])) {
  if(
$threadinfo['forumid'] != xx
  {
    
show_nopermission();
  } else {
    eval(
"standarderror(\"".gettemplate("error_cannotposthere")."\");");
  }


then create a template error_cannotposthere with the wanted text..
and replace the xx with the special forumid ;)

Boofo 12-03-2002 05:40 PM

Thank you Stefan, that is exactly what I was looking for. You have once again been proven to be "The Man!" ;)

How can I do it for multiple threads? I have about 6 I need it for right now. Also, I need to do it for the newthread, too. Would that be the same code?

Boofo 12-03-2002 06:02 PM

Stefan, is this the code I need for the newthread.php? I wanted to run it by you to make sure I did it right?

find (first instance of code):

Code:

  $permissions=getpermissions($forumid);
    if (!$permissions[canview] or !$permissions[canpostnew]) {
                        show_nopermission();
    }

change it to:

Code:

$permissions=getpermissions($forumid);
    if (!$permissions[canview] or !$permissions[canpostnew]) {
    if($foruminfo['forumid'] != 13)
    {
        show_nopermission();
      } else {
      eval("standarderror(\"".gettemplate("error_cannotposthere")."\");");
      }
    }


Xenon 12-04-2002 11:44 AM

last one first ;)

PHP Code:

$permissions=getpermissions($forumid);
    if (!
$permissions[canview] or !$permissions[canpostnew]) {
    if(
$forumid != 13)
     {
        
show_nopermission();
      } else {
       eval(
"standarderror(\"".gettemplate("error_cannotposthere")."\");");
      }
    } 

$forumid can be used here as you can see in the first line of the block but then its correct :)

so, first one now
do you mean do it by multiple threads or multiple forums?

forums:

instead of this
PHP Code:

if($threadinfo['forumid'] != xx

use this:
PHP Code:

if(!in_array($threadinfo['forumid'], array(xxyyzz)) 

for threads just change the forumid by threadid ;)
replace xx, yy and zz

Boofo 12-04-2002 06:13 PM

Thank you again, sir. :) I got a parser error at first but got it figured out. There needed to be another right bracket at the end of the line.

Code:

if(!in_array($threadinfo['forumid'], array(xx, yy, zz))
I want to be sure I have this right now. Here's what I ended up with:

for newreply.php:

PHP Code:

$permissions=getpermissions($threadinfo[forumid]);
if ((
$bbuserinfo['userid']!=$threadinfo['postuserid'] or $bbuserinfo['userid']==0) and (!$permissions['canviewothers'] or !$permissions['canreplyothers'])) {
  if(!
in_array($threadinfo['forumid'], array(13153,4,5,6,7,8)))
  {
    
show_nopermission();
  } else {
    eval(
"standarderror(\"".gettemplate("error_cannotposthere")."\");");
  }


and for newthread.php:

PHP Code:

$permissions=getpermissions($forumid);
    if (!
$permissions[canview] or !$permissions[canpostnew]) {
    if(!
in_array($forumid, array(13153,4,5,6,7,8)))
     {
        
show_nopermission();
      } else {
       eval(
"standarderror(\"".gettemplate("error_cannotposthere")."\");");
      }
    } 

and for threads instead of forums, it would be:

newreply.php

PHP Code:

if(!in_array($threadinfo['threadid'], array(13153,4,5,6,7,8))) 

right? Is there a limit to the amount of forum or thread IDs you can have in the one array statement?

And thank you again, Stefan. :)

Xenon 12-04-2002 08:17 PM

yes alright so :)

ups, forgot a bracket *gg*

no there is no limit there

threads in newthread.php
think that's a bit impossible ;)

Boofo 12-04-2002 08:43 PM

You're right, my mistake. I guess I just got so caught up in it, I wasn't thinking again. :) On doing threads, I would have no need to worry about the forums array. I edited the post above. Thanks again for all of the help in this. ;)

Xenon 12-05-2002 01:10 PM

:)
np, you're welcome as always :)

Boofo 12-05-2002 02:22 PM

Can I ask another favor? :)

This is from the first message:

Quote:

Also, can you please also tell me how to get the users date (offset according to time offset and day of the week to display in $timezone.
I'd like it to show up like:

7:33 am on Saturday, Dec 7, 2002

or something to that effect. I don't know about anyone else, but since the twins arrived 3 weeks ago, I don't know what day it is or even the time, most of the time, anymore. But only in a good way, you know what I mean? :)

Xenon 12-05-2002 02:32 PM

oh, congratulations, if i understand that right :)

hmm, you have to use the vbdate function and then just use the normal datefunction syntax for it, it'll automatically checks the timezone of a user and so on..

Boofo 12-05-2002 02:42 PM

Quote:

Originally posted by Xenon
oh, congratulations, if i understand that right :)


You understood ir tight. Twins boys. :) And thank you for the congratulations.

Quote:

hmm, you have to use the vbdate function and then just use the normal datefunction syntax for it, it'll automatically checks the timezone of a user and so on..
Like this?

Code:

$post['localtime'] = date($timeformat, time()+($post['timezoneoffset']-$timeoffset)*3600);
$post['localdate'] = date($dateformat, time()+($post['timezoneoffset']-$timeoffset)*3600);
$post['localday'] = day($dayformat, time()+($post['timezoneoffset']-$timeoffset)*3600);

How would I do this for the forumhome? In the index.php, I know, but I'm not sure wqhere to put it exactly. (I've been away from php for too long, it seems. :))

Xenon 12-05-2002 07:26 PM

things you want to show up in every post belong to functions.php

section getpostbit ;)

Boofo 12-05-2002 07:29 PM

Is the code above correct for getting the day? Putting it there won't work for the forumhome page though, will it?

Xenon 12-05-2002 07:33 PM

$post['localday'] = date("D", time()+($post['timezoneoffset']-$timeoffset)*3600);

would be correct for displaying for Example "Sun"

Boofo 12-05-2002 07:37 PM

Ahhh, ok, I see now. The D is just the php code for how you want the day to show up. That's pretty simple. I should have known that one. See what happens when you are away too long? :) Last question, I figured out that to have it show up on the forumhome, I need to put it in the index.php file. Can you tell me where it would need to go in there, please? Or is there a way to include it in the timezone variable?

Xenon 12-05-2002 07:48 PM

as you don't need it anywhere else, jsut put it before this line:
PHP Code:

eval("dooutput(\"".gettemplate('forumhome')."\");"); 


Boofo 12-05-2002 08:39 PM

I'd like to be bale to do it globally for all of the timezone variables on all of the pages. Can it be done that way?

Xenon 12-06-2002 11:41 AM

you can just change the standart date/time format in vb-options for that...

Boofo 12-06-2002 02:20 PM

Sorry about this. :) I'm not explaining myself very well. I don't want all of the date and times like that, only for the forumhome timezones that are also at the bottom of each page. The Forums and Threads listings would be too long with all of that.

Xenon 12-06-2002 09:54 PM

ahh i see what you mean now ;)

open global.php

find
PHP Code:

$timenow=vbdate($timeformat,time()); 

there replace $timeformat with a new format string :)

Boofo 12-07-2002 02:42 AM

Thank you. Now all I need to know is how you mean the "format string". Do I need to set it up somewhere else first? I'm sorry to sound so simple on this, but it has me totally baffled. :)

Xenon 12-07-2002 11:31 AM

instead of $timeformat use this (f.e.) string:
PHP Code:

"D H:i m-d-Y" 


Boofo 12-07-2002 04:32 PM

Ok, but will that work according to the users offset?

Xenon 12-07-2002 07:28 PM

yes it will, because vbdate function is used ^^

Boofo 12-08-2002 04:28 PM

Thank you, it worked. here's what I have now:

Code:

$timenow=vbdate("g:i a, D, M j, Y",time());
How would I get it to say this?

12:22 pm on Sun, Dec 8, 2002.

instead of:

12:22 pm, Sun, Dec 8, 2002.

Xenon 12-08-2002 05:32 PM

hmm, try this one:

PHP Code:

$timenow=vbdate("g:i a"time()) . " on " vbdate("D, M j, Y",time()); 


Boofo 12-08-2002 05:46 PM

Perfect! Worked like a charm. Thank you very much, kind sir. :)

I need to ask, though, what are the 2 periods for in the code?

Xenon 12-08-2002 06:06 PM

well, you have to divide the code, because the formatstring would be converted into numbers or other things

vbdate("g:i a", time()) gives out: "12:22 pm"
. " on " . adds the " on " to the string
and vbdate("D, M j, Y",time()); adds the "Sun, Dec 8, 2002"

Boofo 12-08-2002 06:36 PM

Ahh, ok, that makes sense now. Would it also work like this?

$timenow=vbdate("g:i a", time())." on ".vbdate("D, M j, Y",time());

or do the spaces have to be there, too?

Xenon 12-08-2002 06:38 PM

yes it would also work, spaces are just visual, it's like the vb3 coding structure i try to implement to my mind ;)


All times are GMT. The time now is 04:18 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01267 seconds
  • Memory Usage 1,829KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code_printable
  • (12)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (31)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete