Results 1 to 7 of 7
  1. #1
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default Using cookies to keep a radio turned off

    If you own a site which dosn't use iframes or ajax, and want a radio player like Habbox, then why not use cookies

    To do this, all you need is two pages. player.php and setplayer.php.

    A demo of this can be found here.

    player.php
    PHP Code:
    <?php
    $cookie_name 
    "RadioPlayer";

    if(
    $_COOKIE[$cookie_name]) {
    ?>
    You have set the Radio not to play.<br>
    <a href="setplayer.php?play=yes">Listen To the Radio</a>
    <?
    }
    if(!
    $_COOKIE[$cookie_name]) {
    ?>
    <object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" standby="Loading" name="player" width="168" height="45" codebase="http://habbcrazy.net/CODEBASE=http:/activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715">
        <param ref name="url" value="http://67.152.46.182:8002">
        <param value="-1" name="autostart">
        <param value="mini" name="uimode">
        <param value="1" name="rate">
        <param value="0" name="balance">
        <param value="0" name="currentPosition">
        <param value name="defaultFrame">
        <param value="1" name="playCount">
        <param value="0" name="currentMarker">
        <param value="-1" name="invokeURLs">
        <param value name="baseURL">
        <param value="100" name="volume">
        <param value="0" name="mute">
        <param value="0" name="stretchToFit">
        <param value="0" name="windowlessVideo">
        <param value="-1" name="enabled">
        <param value="-1" name="enableContextMenu">
        <param value="0" name="fullScreen">
        <param value name="SAMIStyle">
        <param value name="SAMILang">
        <param value name="SAMIFilename">
        <param value name="captioningID">
        <param value="0" name="enableErrorDialogs">
        <embed name="player" uimode="mini" autoplay="true" url="http://www.habbcrazy.net/pages/radio/mediafile.asx" showstatusbar="false" controls="playbutton" autostart="True" src="mediafile.asx" width="168" height="45"></object>
        <br>
        <a href="setplayer.php?play=no" title="Stop the Radio">Stop the Radio</a>
    <?
    }
    ?>
    setplayer.php
    PHP Code:
    <?php
    $cookie_name 
    "RadioPlayer";

    if(
    $_GET["play"] == "no") {
        echo(
    "The radio will stop playing for 31 days if your cookies are enabled.
            Do you wish to continue?<br>
            <a href=\"setplayer.php?stop=yes\" title=\"Yes\">Yes</a> | <a href=\"setplayer.php?stop=no\" title=\"No\">No</a>"
    );
    }
    elseif(
    $_GET["play"] == "yes") {
        
    header('Location: setplayer.php?stop=no');
    }
    elseif(
    $_GET["stop"] == "yes") {
        
    setcookie($cookie_name"stop_radio"time() + (30*24*60*60) );
        
    header('Location: player.php');
    }
    elseif(
    $_GET["stop"] == "no") {
        
    $value "stop_radio";
        
    setcookie($cookie_name"stop_radio"time() - 3600 );
        
    header('Location: player.php');
    }
    else {
        
    header('Location: player.php');
    }
    ?>
    Moved by Invent (Forum Moderator) from Designing & Development: Please post in the correct forum next time, thanks .
    Last edited by Invent; 24-08-2008 at 01:33 AM.

  2. #2
    Join Date
    May 2008
    Posts
    605
    Tokens
    0

    Default

    Great little script, + rep

    Edit: I'd just cut the shortags due to some hosts now allowing them
    Last edited by Excellent1; 18-08-2008 at 05:10 PM.

  3. #3
    Join Date
    Mar 2008
    Posts
    940
    Tokens
    75

    Default

    I was looking for this good job.


  4. #4
    Join Date
    Oct 2006
    Location
    Peterborough, UK
    Posts
    3,855
    Tokens
    216

    Latest Awards:

    Default

    And now for some self contained code that doesn't suck:

    1 file: player.php

    PHP Code:
    <?php
    $start 
    '';
    $act = isset( $_GET'act' ] ) ? $_GET'act' ] : 'nothing';
    switch( 
    $act )
    {
        case 
    'stopconf':
            
    setcookie'radio''no'time() + ( 31 24 60 60 ) );
            break;
            
        case 
    'start':
            
    setcookie'radio''yes''1000000000' );
            
    $start 'yes';
            break;
            
        case 
    'stop':
            echo( 
    'The radio will stop playing for 31 days if cookies are enabled.
            Do you wish to continue?<br>
            <a href="player.php?act=stopconf" title=\"Yes\">Yes</a> | <a href="player.php" title="No">No</a>' 
    );
            break;
    }

    if( 
    $_COOKIE'radio' ] !== 'no' || $start === 'yes' )
    {
        echo( 
    '<object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" standby="Loading" name="player" width="168" height="45" codebase="http://habbcrazy.net/CODEBASE=http:/activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715">
        <param ref name="url" value="http://67.152.46.182:8002">
        <param value="-1" name="autostart">
        <param value="mini" name="uimode">
        <param value="1" name="rate">
        <param value="0" name="balance">
        <param value="0" name="currentPosition">
        <param value name="defaultFrame">
        <param value="1" name="playCount">
        <param value="0" name="currentMarker">
        <param value="-1" name="invokeURLs">
        <param value name="baseURL">
        <param value="100" name="volume">
        <param value="0" name="mute">
        <param value="0" name="stretchToFit">
        <param value="0" name="windowlessVideo">
        <param value="-1" name="enabled">
        <param value="-1" name="enableContextMenu">
        <param value="0" name="fullScreen">
        <param value name="SAMIStyle">
        <param value name="SAMILang">
        <param value name="SAMIFilename">
        <param value name="captioningID">
        <param value="0" name="enableErrorDialogs">
        <embed name="player" uimode="mini" autoplay="true" url="http://www.habbcrazy.net/pages/radio/mediafile.asx" showstatusbar="false" controls="playbutton" autostart="True" src="mediafile.asx" width="168" height="45"></object>
        <br>
        <a href="player.php?act=stop" title="Stop the Radio">Stop the Radio</a>' 
    );
    }
    else
    {
        echo( 
    'You have turned the radio off<br>
        <a href="player.php?act=start">Listen To the Radio</a>' 
    );
    }
    ?>
    Last edited by Jewish Bear; 19-08-2008 at 03:43 AM. Reason: MUST REMEMBER STRICT PHP


    visit my internet web site on the internet
    http://dong.engineer/
    it is just videos by bill wurtz videos you have been warned

  5. #5
    Join Date
    Jul 2008
    Location
    Hastings, UK.
    Posts
    2,050
    Tokens
    0

    Latest Awards:

    Default

    I remember that Habbox use's this.

  6. #6
    Join Date
    Apr 2007
    Posts
    2,431
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Jack120 View Post
    If you own a site which dosn't use iframes or ajax, and want a radio player like Habbox, then why not use cookies
    Quote Originally Posted by Calon View Post
    I remember that Habbox use's this.
    Looool,

    Yeah ima be using this, very useful - I can barely ever find radio code let alone to stop it.

    +rep

    [X] [X] [X]

  7. #7
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default

    Quote Originally Posted by Jewish Bear View Post
    And now for some self contained code that doesn't suck:

    1 file: player.php

    PHP Code:
    <?php
    $start 
    '';
    $act = isset( $_GET'act' ] ) ? $_GET'act' ] : 'nothing';
    switch( 
    $act )
    {
        case 
    'stopconf':
            
    setcookie'radio''no'time() + ( 31 24 60 60 ) );
            break;
            
        case 
    'start':
            
    setcookie'radio''yes''1000000000' );
            
    $start 'yes';
            break;
            
        case 
    'stop':
            echo( 
    'The radio will stop playing for 31 days if cookies are enabled.
            Do you wish to continue?<br>
            <a href="player.php?act=stopconf" title=\"Yes\">Yes</a> | <a href="player.php" title="No">No</a>' 
    );
            break;
    }

    if( 
    $_COOKIE'radio' ] !== 'no' || $start === 'yes' )
    {
        echo( 
    '<object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" standby="Loading" name="player" width="168" height="45" codebase="http://habbcrazy.net/CODEBASE=http:/activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715">
        <param ref name="url" value="http://67.152.46.182:8002">
        <param value="-1" name="autostart">
        <param value="mini" name="uimode">
        <param value="1" name="rate">
        <param value="0" name="balance">
        <param value="0" name="currentPosition">
        <param value name="defaultFrame">
        <param value="1" name="playCount">
        <param value="0" name="currentMarker">
        <param value="-1" name="invokeURLs">
        <param value name="baseURL">
        <param value="100" name="volume">
        <param value="0" name="mute">
        <param value="0" name="stretchToFit">
        <param value="0" name="windowlessVideo">
        <param value="-1" name="enabled">
        <param value="-1" name="enableContextMenu">
        <param value="0" name="fullScreen">
        <param value name="SAMIStyle">
        <param value name="SAMILang">
        <param value name="SAMIFilename">
        <param value name="captioningID">
        <param value="0" name="enableErrorDialogs">
        <embed name="player" uimode="mini" autoplay="true" url="http://www.habbcrazy.net/pages/radio/mediafile.asx" showstatusbar="false" controls="playbutton" autostart="True" src="mediafile.asx" width="168" height="45"></object>
        <br>
        <a href="player.php?act=stop" title="Stop the Radio">Stop the Radio</a>' 
    );
    }
    else
    {
        echo( 
    'You have turned the radio off<br>
        <a href="player.php?act=start">Listen To the Radio</a>' 
    );
    }
    ?>
    you always get one

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •