Topic: Mp3 player guest restriction

I have searched and read numerous posts and could not find an answer. My apologies if I missed the info.
I have installed the easy video BB codes mod, and have installed the mp3 player, that all works just fine.
I placed the mp3 player code in the main.tpl file, it works fine., and shows where I want it.
The problem I'm having is the mp3 player also shows on the index page when not logged in or you are a guest. I dont want guests to be able to see it.
Is there a way to place it so only users logged in can see and use the player?
thanks in advance
Beagle

2

Re: Mp3 player guest restriction

You'd need to enclose it within an if clause where the link is parsed and finalised in the parser, I believe. Not sure if the one liner type entries in the array will allow that level of control, however.

Re: Mp3 player guest restriction

If it makes any difference, I have re-placed the player by using the pun_include function. The player is still visible to guests. I sort of understand the need for the if statement, I just have no idea where it should go.
thanks again
Beagle

4 (edited by MattF 2008-01-27 19:58)

Re: Mp3 player guest restriction

Where the player is added, or the link generated, enclose it within:

if (!$pun_user['is_guest'])
{
    [player code]
}

Obviously, however, that method depends upon your code.

Edit: If you're still unsure, just post the code from the included file. smile

Re: Mp3 player guest restriction

I've placed a file in the dir "include/user" named player.html. That calls a flash player via javascript.
and in "main.tpl" i've placed the string "<pun_include "player.html">"
between <pun_announcement> and <pun_main>
The player works perfectly.
Can i place the "<pun_include "player.html"> in the code you provided?
thanks for your help
Beagle

Re: Mp3 player guest restriction

I tried placing that code into "main.tpl". It shows the code as text with the player between the brackets.
Beagle

7

Re: Mp3 player guest restriction

You can't use code in the tpl files directly.

Re: Mp3 player guest restriction

yeah, I got that..lol
Beagle

9

Re: Mp3 player guest restriction

Without seeing some code, it's pretty hard to suggest anything. smile

Re: Mp3 player guest restriction

what do you need to see?
Beagle

11

Re: Mp3 player guest restriction

What's in the include file? Can you enclose that within php code tags, if not so already?

12 (edited by HMS Beagle 2008-01-28 10:50)

Re: Mp3 player guest restriction

this is what i placed in the include folder.
I'm not sure if this is the file you meant.
And, thank you for your time, I imagine dealing with a noob can be frustrating.
Beagle


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN">
<html>

    <head>
        <title>mp3 player</title>
    </head>
    <body>
<script type="text/javascript" src="http://www.mywebsite.com/forum/swfobject.js"></script>

<div id="player">Loading MP3 Player</div>

<script type="text/javascript">
var so = new SWFObject('http://www.mywebsite.com/forum/mod_mediaplayer.swf','mpl','600','75','8');
so.addParam('allowscriptaccess','always');
so.addParam('allowfullscreen','true');
so.addVariable('height','75');
so.addVariable('width','600');
so.addVariable('file','http://www.mywebsite.com/forum/mp3/upload/statistics.xml');
so.addVariable('backcolor','0x009900');
so.addVariable('frontcolor','0xFFFF00');
so.addVariable('lightcolor','0x999999');
so.addVariable('displaywidth','140');
so.addVariable('showstop','true');
so.addVariable('showdownload','true');
so.write('player');
</script>

    </body>
</html>

13

Re: Mp3 player guest restriction

At the very top of that file add:

<?php
if (!$pun_user['is_guest'])
{
?>

and at the very bottom of that file add:

<?php
}
?>

Can't say whether you'll need to change the extension back to .php or not. Would think you will though. smile Is that opening up in a separate page of it's own, btw?

Re: Mp3 player guest restriction

No, it appears on every page except, admin.
Beagle

15

Re: Mp3 player guest restriction

If its appearing within a PunBB page then, you can get rid of all that head and body code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN">
<html>

    <head>
        <title>mp3 player</title>
    </head>
    <body>
    </body>
</html>

That will be throwing the html validity out of the window as it is. big_smile

16 (edited by MattF 2008-01-28 14:27)

Re: Mp3 player guest restriction

Yup. You can definitely get rid of that head/body info. Pop this code into a file, (for example: include/user/player.php), as is:

<?php
if (!$pun_user['is_guest'])
{
?>
<script type="text/javascript" src="http://www.example.com/forum/swfobject.js"></script>

<div id="player">Loading MP3 Player</div>

<script type="text/javascript">
var so = new SWFObject('http://www.example.com/forum/mod_mediaplayer.swf','mpl','600','75','8');
so.addParam('allowscriptaccess','always');
so.addParam('allowfullscreen','true');
so.addVariable('height','75');
so.addVariable('width','600');
so.addVariable('file','http://www.example.com/forum/mp3/upload/statistics.xml');
so.addVariable('backcolor','0x009900');
so.addVariable('frontcolor','0xFFFF00');
so.addVariable('lightcolor','0x999999');
so.addVariable('displaywidth','140');
so.addVariable('showstop','true');
so.addVariable('showdownload','true');
so.write('player');
</script>
<?php
}
?>

and then put that filename in the include inplace of the old filename. That should then only display once logged in. smile

Re: Mp3 player guest restriction

Thank you very much! It works great.
Really, thanks for your time.
Beagle