vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Custom page + conditionals (https://vborg.vbsupport.ru/showthread.php?t=201062)

manning 01-08-2009 12:30 PM

Custom page + conditionals
 
I am using the code below to create custom pages in my forum - I thought it was working great until I started testing for cross browser compatibility.

For the most part, the file works in IE, FF, and OPERA just fine, but when adding the conditional in red - OPERA will not display the page after logging in - it just redisplays the no permission/login page even though its logged me in.

Any idea why OPERA does this? I know its <2% of users, but I like to work on all browsers.

Code:

<?php 

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'my-file'); // change this depending on your filename

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array(

);

// get special data templates from the datastore
$specialtemplates = array(
   
);

// pre-cache templates used by all actions
$globaltemplates = array(
    'My_Template',
);

// pre-cache templates used by specific actions
$actiontemplates = array(

);

// ######################### REQUIRE BACK-END ############################
require_once('global.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
if (!in_array($vbulletin->userinfo[usergroupid], array(2,6,7))) 

print_no_permission(); 

$navbits = array();
$navbits[$parent] = 'My Page';

$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('My_Template') . '");');

?>


Lynne 01-08-2009 02:05 PM

How about instead of:
PHP Code:

if (!in_array($vbulletin->userinfo[usergroupid], array(2,6,7))) 

You use:
PHP Code:

if (is_member_of($vbulletin->userinfo2,6,7)) 


Marco van Herwaarden 01-08-2009 02:10 PM

There is nothing in your PHP=code that is browser dependent. If there is a dependecy then it is in 1 of the templates used.

manning 01-09-2009 05:04 PM

Quote:

Originally Posted by Marco van Herwaarden (Post 1705141)
There is nothing in your PHP=code that is browser dependent. If there is a dependecy then it is in 1 of the templates used.

Only thing in template is basic html ... nothing that would cause OPERA to keep returning no permission screen... thats in this php file.

Code:


print_no_permission(); 
}


Lynne 01-09-2009 05:09 PM

Try commenting those lines out and see what the result is. Maybe it's some other function in global.php that is causing the problem.

manning 01-10-2009 01:38 AM

Well its important to me that page only allow certain groups in - If it dont work in OPERA oh well - was just wanting to see if I could find out why it wasnt working.

Lynne 01-10-2009 01:56 AM

If that function didn't work in Opera, don't you think a lot of vbulletin owners would be a bit peeved? That code is used throughout vbulletin only the condition used is a bit different (and, of course, other lines are different). Take a look at the other scripts that have no permission in them and you will see. I'm thinking something else is causing the problem in your script.

TigerC10 02-09-2009 05:22 AM

Quote:

Originally Posted by Marco van Herwaarden (Post 1705141)
There is nothing in your PHP=code that is browser dependent. If there is a dependecy then it is in 1 of the templates used.

He's right, manning. PHP is a server-side script - it doesn't care what browser you're using, it will always deliver the same HTML/Javascript/XML to your end user.


Quote:

Originally Posted by manning (Post 1706526)
Only thing in template is basic html ... nothing that would cause OPERA to keep returning no permission screen... thats in this php file.

Just how basic? Because some people use browser-dependent CSS with their HTML without realizing it. Some styles unwittingly use browser-dependent CSS too.


As an avid Opera user myself, I find that it's the other browsers that do funky things. After all, Firefox only just started passing the ACID 2 Browser Test (on the release build, FF has been passing for years on a few select nightly builds but they don't count). In fact, one thing that I absolutly detest about Firefox is that it makes assumptions about the code on the page - if a tag is not closed, Firefox will close it for you (this was a NIGHTMARE for some AJAX stuff). Needless to say, sometimes Firefox guessed where to close it incorrectly. I've had friends who abused the hell out of that feature, they would only write a quarter of the necessary code for a page to work properly and rely on Firefox to do everything else - when it didn't work for me they told me to switch to Firefox. I've come to loath the firefox subculture for that. But I digress...

I think the problem is that your other browsers cache is interfering with the results of the script. Force a re-download of the page

Firefox:
Hold shift and press the refresh button

Internet Explorer:
Hold CTRL and press the refresh button


If they don't come up with the same error that Opera does, then it's not what I think it is... However, if they do come up with errors then I think the problem is that you're missing this line from your PHP file:
Code:

global $vbulletin;
You can't use $vbulletin->userinfo[usergroupid] without knowing about $vbulletin in the first place (that it was defined in some other PHP file), and to do that you have to tell it that $vbulletin is defined globally.

Try printing the valueof usergroupid instead of printing no permission... That might give you a clue as to what the real cause is.




One time I had a very similar problem when it came to admin logins. After changing the subdomain on which vB was installed, vB couldn't find any of the cookie data. SessionIDs started appending to the ends of the URLs, and vB wouldn't even let me access the admin panel without a cookie login. I recommend that you upload the "tools.php" file from your "do_not_upload" folder and run the cookie repair utility just to rule out cookie settings errors.


All times are GMT. The time now is 02:55 PM.

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.01447 seconds
  • Memory Usage 1,741KB
  • 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
  • (3)bbcode_code_printable
  • (2)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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