PDA

View Full Version : Proper use of continue;


Lionel
04-23-2005, 06:08 AM
Why would the below display a blank page when using continue;?
I am trying to tell it to do nothing if it's a member, go ahead and open the script

<?php
chdir('/var/www/forums');
define('NO_REGISTER_GLOBALS', 1);
$phrasegroups = array();
$actiontemplates = array('lostpw' => array('lostpw'));
require_once('./global.php');
require_once('./includes/functions_login.php');
if ($bbuserinfo['userid'])
{
continue;
}
else
{
print_no_permission();
}
?>

Jolten
04-23-2005, 06:12 AM
if (!$bbuserinfo['userid'])
{
print_no_permission();
}


You don't need continue. In addition continue is for loop statements not if statement.


continue is used within looping structures to skip the rest of the current loop iteration and continue execution at the beginning of the next iteration.

Lionel
04-23-2005, 06:25 AM
Thanks, but that gives me a blank page. As per the script writer it will work only with:

<?php
if (logon is set) then
do nothing / continue
else
redirect to logon page
end if
?>

so I cannot put ! in font of !$bbuserinfo['userid']

Deaths
04-23-2005, 06:31 AM
Just place
if (!$bbuserinfo['userid'])
{
print_no_permission();
}
Above your main script, and start coding.
Everything you code below that will be parsed for logged in users, and the guests will get the no permission page ;)

Lionel
04-23-2005, 06:35 AM
wish that was easy. I am using one of those scripts that you absolutely cannot touched the php or it ceases to work. Everything is acomplished thru an external file. In there, I tell it to use the external logon file logon.php. And this is what I need to put in logon.php. Any other way it enters into a loop. That why the loop needs to be broken with continue;

BTW, if the condition of bbuserinfo is not met, it does ask you to login.
I was told that vbportal uses it, so it is possible
I also know that phpNuke uses it.
I am with vbadvanced and am very happy with it.

Again, the problem is the loop.

Deaths
04-23-2005, 07:58 AM
It might help if you'd post the script, or atleast the part which you are editing.

Lionel
04-23-2005, 08:00 AM
the entire script is posted above (let's call it logon.php). So is the complete synthax to use as per author.

in the preferences file you simply put
#coreInclude logon.php

and logon.php posted above does it's thing.

Deaths
04-23-2005, 08:02 AM
<?php
chdir('/var/www/forums');
define('NO_REGISTER_GLOBALS', 1);
$phrasegroups = array();
$actiontemplates = array('lostpw' => array('lostpw'));
require_once('./global.php');
require_once('./includes/functions_login.php');
if ($bbuserinfo['userid'])
{
readfile('your_file');
}
else
{
print_no_permission();
}
?>
That should work.

Lionel
04-23-2005, 08:06 AM
Nope, it does not. I get a blank page. I must use the continue clause as per author.

and the readfile clause (that you edited it to instead of require) makes it look ugly by displaying the raw html

Marco van Herwaarden
04-23-2005, 09:08 AM
If you MUST use a continue (i can really not think of any reason for this) then recode and use a case construct.

Lionel
04-23-2005, 09:17 AM
I must. But what is a case construct?

ok. Here is the story. I got a license of this great script (free download)
http://www.turnstyle.com/andromeda/download.asp

the script is a dream. All you do is drop in the files and it reads folders, files etc... and sorts them.
Unfortunately, that php simply cannot be touched, not even one comma. They provided with an external prefs file to accomplish whatever you want. And so far so good. It uses many type of authentication including a built in that uses a flat file.

The author told me that if I use the synthax posted above, I will be able to integrate it with vbulletin.

Vbportal did it for vbulletin.

So this is why I must use contimue;, or otherwise it either enters in a loop or displays a blank page once you log in. Apparently, the continue satement breaks that loop by telling it to stop and go nowhere, just display the thing.

akanevsky
04-25-2005, 01:47 AM
That script is not that great once you look at its source code.

Besides, maybe you should change

chdir('/var/www/forums');

to

chdir('/var/www/forums/');

?

And change

if ($bbuserinfo['userid'])
{
readfile('your_file');
}
else
{
print_no_permission();
}

to

if (!$bbuserinfo['userid'])
{
print_no_permission();
}