vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Conditional Help (https://vborg.vbsupport.ru/showthread.php?t=209431)

UKBusinessLive 03-25-2009 06:22 PM

Conditional Help
 
Hi guys ;)

I need a little help and i hope that one of you guys can help me here

i'm using the conditional below, in my header

Code:

<if condition="$bbuserinfo['usergroupid'] == x">
<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.ukbusinesslive.co.uk/warning.html">
</if>

But the problem is that, it keeps repeating, the HTML code i wrote has a redirect back to the forum URL, But by using the above it keeps repeating in a loop :(

Is there a way to make a conditional run once and then end??

Thanks in advance

Gerry ;)

TigerC10 03-26-2009 12:30 PM

Try:

Code:

<if condition="THIS_SCRIPT != "index" && $bbuserinfo['usergroupid'] == x">
<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.ukbusinesslive.co.uk/warning.html">
</if>


UKBusinessLive 03-26-2009 06:56 PM

Quote:

Originally Posted by TigerC10 (Post 1777425)
Try:

Code:

<if condition="THIS_SCRIPT != "index" && $bbuserinfo['usergroupid'] == x">
<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.ukbusinesslive.co.uk/warning.html">
</if>


Thanks Tiger, will give it a shot ;)

Lynne 03-26-2009 07:00 PM

Are you saying when you get redirected to http://www.ukbusinesslive.co.uk/warning.html then it keeps repeating?

UKBusinessLive 03-27-2009 06:10 AM

Quote:

Originally Posted by Lynne (Post 1777724)
Are you saying when you get redirected to http://www.ukbusinesslive.co.uk/warning.html then it keeps repeating?

hi Lynne,

Firstly the above url is only an example ;) its not working,

What i've done is written a piece of code which re-directs back to the forum upon completion, But to get someone to go to that code when they type the forums url i used this conditional

Code:

<if condition="$bbuserinfo['usergroupid'] == x">
<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.ukbusinesslive.co.uk/warning.html">
</if>

But, thats not gonna work as it will divert to the warning.html, then goes to the forum url, before starting all over again :o

is there a way that the above conditional can be changed, so that it onlt works the once??

The only other way would be with some form of cookie control using javascript, like the code below??


Code:

var expDays = 1;    How long the cookie lasts for

var page = "warning.html";
var windowprops = "width=100%,height=100%,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes";

function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function amt(){
var count = GetCookie('count')
if(count == null) {
SetCookie('count','1')
return 1
}
else {
var newcount = parseInt(count) + 1;
DeleteCookie('count')
SetCookie('count',newcount,exp)
return count
  }
}
function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}

function checkCount() {
var count = GetCookie('count');
if (count == null) {
count=1;
SetCookie('count', count, exp);

window.open(page, "", windowprops);

}
else {
count++;
SetCookie('count', count, exp);
  }
}
//  End -->
</script>

Any have any other ides??

Lynne 03-27-2009 02:32 PM

Why don't you have the redirect pass a variable and if that variable exists then don't redirect anymore?

User gets redirected to http://www.ukbusinesslive.co.uk/warning.html and then when that is done, they get sent back to index.php except the url would be index.php?myscript=done. And then on the page, if $_GET[myscript] == done, don't redirect again?

A cookie would work also (as you said). Look in the API to see about a function to set cookies using vB.


All times are GMT. The time now is 12:19 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.01006 seconds
  • Memory Usage 1,735KB
  • 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
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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