PDA

View Full Version : How can I make more that one error page?


JamesAB
09-26-2007, 01:53 AM
I'm currently looking at attachment.php and trying to give users different error messages based on the extension of the file they are downloading.

Here's the original:
if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) OR !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads']) OR !($forumperms & $vbulletin->bf_ugp_forumpermissions['cangetattachment']) OR (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) AND ($attachmentinfo['postuserid'] != $vbulletin->userinfo['userid'] OR $vbulletin->userinfo['userid'] == 0)))
{
print_no_permission();
}

Now instead of calling print_no_permission(); first, I would like to give a customized error message.

I'd like to do something like this:
if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) OR !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads']) OR !($forumperms & $vbulletin->bf_ugp_forumpermissions['cangetattachment']) OR (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) AND ($attachmentinfo['postuserid'] != $vbulletin->userinfo['userid'] OR $vbulletin->userinfo['userid'] == 0)))
{
if (in_array($extension, array('wmv', 'asx', 'asf', 'mpg', 'mpeg', 'mov', 'flv', '3gp', 'avi', 'zip')))
{
DO SOMETHING;
}
else
{
print_no_permission();
}
}

What do you suggest I use instead of print_no_permission();?

Thanks for your help.

--------------- Added at 05:05 ---------------

Okay. I did some searching and I think I solved it myself by adding a phrase called "my_no_permisission_videos" in the "Front-End Error Messages" section.

The new code looks like this:
if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) OR !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads']) OR !($forumperms & $vbulletin->bf_ugp_forumpermissions['cangetattachment']) OR (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) AND ($attachmentinfo['postuserid'] != $vbulletin->userinfo['userid'] OR $vbulletin->userinfo['userid'] == 0)))
{
if (in_array($extension, array('wmv', 'asx', 'asf', 'mpg', 'mpeg', 'mov', 'flv', '3gp', 'avi')))
{
eval(standard_error(fetch_error('my_no_permisissio n_videos')));
}
else
{
print_no_permission();
}
}

Is this the best solution?

Dismounted
09-26-2007, 06:36 AM
It depends on what you want the error message to look like. Are you happy with it now?

JamesAB
09-28-2007, 03:31 AM
It depends on what you want the error message to look like. Are you happy with it now?
Yes. I'm happy with it now.

Dismounted
09-28-2007, 05:05 AM
Then it's good :).