1
maxima
Can an SQL query be made from a popup window?
  • 2006/11/4 3:21

  • maxima

  • Not too shy to talk

  • Posts: 152

  • Since: 2006/3/4 4


I use the debaser module and would like only registered users to play the radio. It works with setting the block access to registered users but debaser opens a popup to play the internet radio. This is ideal as the viewer can listen while browsing the site.

The problem is that the URL of that popup can access the radio without being logged in and I tried adding the isuser smarty to the popup page and it executes correctly but can't recognize the user so it returns the {else} result. I guess it is because there is no SQL query in the page. What must be done to make it work?

This is code for debaser_radiopopup.html. My edit is red.
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<{$xoops_langcode}>" lang="<{$xoops_langcode}>">
<
head>
<
meta http-equiv="content-type" content="text/html; charset=<{$xoops_charset}>" />
<
meta http-equiv="content-language" content="<{$xoops_langcode}>" />
<
title><{$radio_name}>title>
<
link rel="stylesheet" type="text/css" media="screen" href="<{$xoops_url}>/xoops.css" />
<
link rel="stylesheet" type="text/css" media="screen" href="<{$maintheme}>" />
<
script src='<{$xoops_url}>/modules/debaser/js/resizewindow.js' type='text/javascript'>script>
head>
<
body onload="resizeWinTo('radiodiv');" style="padding:0px; margin:0px;">
<
div style="position: absolute; top: 0px; left:0px; width:350px;" id="radiodiv">
[
color=990000]<{if $xoops_isuser}>[/color]
<
table class="outer"><tr><td class="odd">
<{if 
$pictureavail == true}>
<
div align="center"><img src="<{$xoops_url}>/modules/debaser/images/<{$radio_picture}>" alt="<{$radio_name}>" />div>
<{/if}>
<
div align="center"><{$radioplayer}>div>
<{if 
$urlavail == true}>
<
div align="center"><a href="<{$radio_url}>" target="_blank"><{$radio_name}>a>div>
<{/if}>
td>tr>table>
[
color=990000]<{else}>
You must be logged in to play radio
<{/if}>[/color]
div>
body>
html>


And this for popup.php which I didn't make any changes.
/**************************************************************************/
/* PHP-NUKE: Internet Radio Block/Module                                  */
/* =====================================                                  */
/*                                                                        */
/* Copyright (c) 2003 by René Hart (webmaster@just4me.nl)                 */
/* http://www.just4me.nl                                                  */
/*                                                                        */
/* This program is free software. You can redistribute it and/or modify   */
/* it under the terms of the GNU General Public License as published by   */
/* the Free Software Foundation; either version 2 of the License.         */
/*                                                                        */
/* Internet Radio Block/Module V3.0 by Rene Hart (webmaster@just4me.nl)   */
/* http://www.just4me.nl                                                  */
/* For PHP-Nuke                                                           */
/*                                                                        */
/*                                                                        */
/**************************************************************************/
//******************************************//
// DO NOT CHANGE ANYTHING ON THIS SCRIPT !! //
//       LEAVE COPYRIGHT IN PLACE           //
//******************************************//

/* This version ported to E-Xoops and extensively modifiedby Bob Janes 
18 October 2003
This version ported to XOOPS and extensively modified
by frankblack */

    
include '../../mainfile.php';

    require_once 
XOOPS_ROOT_PATH.'/class/template.php';

    
$xoopsTpl = new XoopsTpl();

    
$radio_id $_GET['select'];

    
$sql "
    SELECT radio_name, radio_stream, radio_url, radio_picture
    FROM "
.$xoopsDB->prefix('debaserradio')."
    WHERE radio_id = "
.intval($radio_id)."";

    
$result $xoopsDB->query($sql);

    list(
$radio_name$radio_stream$radio_url$radio_picture) = $xoopsDB->fetchRow($result);

    
$xoopsTpl->assign('radio_name'$radio_name);
    
$xoopsTpl->assign('radio_url'$radio_url);

        if (
$radio_url != '') {
        
$xoopsTpl->assign('urlavail'true);
        
$xoopsTpl->assign('radio_url'$radio_url);
        }

        if (
$radio_picture != '') {
        
$xoopsTpl->assign('pictureavail'true);
        
$xoopsTpl->assign('radio_picture'$radio_picture);
        }

        if (
check_real($radio_stream) == true) {
        
$xoopsTpl->assign('radioplayer'"
        
        
        
        $radio_stream' />
        $radio_stream' type='audio/x-pn-realaudio-plugin' console='clip1' controls='controlpanel,statusfield' height='60' width='300' autostart='true' pluginspage='http://www.real.com/'>
        
        <a href='</span><span style="color: #0000BB">$radio_stream</span><span style="color: #DD0000">>play </span><span style="color: #0000BB">$radio_name</span><span style="color: #DD0000"></a>
        "
);
        }
        else {
        
$xoopsTpl->assign('radioplayer'"
        
        $radio_stream' />
        
        
        
        
        $radio_stream' name='player' width='300 height='60' autostart='true' showcontrols='1' showstatusbar='1' showdisplay='1'>
        
        <a href='</span><span style="color: #0000BB">$radio_stream</span><span style="color: #DD0000">'>play </span><span style="color: #0000BB">$radio_name</span><span style="color: #DD0000"></a>
        "
);
        }

    
/* Function to check for real player files */

    
function check_real($t_url) {

    
$temp_url basename($t_url);
    
$temp_url trim($temp_url);
    
$temp_url strtolower($temp_url);
    
$check_ram substr($temp_url, -3);
    
$check_rm substr($temp_url, -2);
    
$check_smil substr($temp_url, -4);

        if (
$check_rm == "rm") {
        return 
true;
        }
        elseif (
$check_ram == "ram") {
        return 
true;
        }
        elseif (
$check_rm == "ra") {
        return 
true;
        }
        elseif (
$check_ram == "pls") {
        return 
true;
        }
        elseif (
$check_ram == "rpm") {
        return 
true;
        }
        elseif (
$check_smil == "smil") {
        return 
true;
        }
        else {
        return 
false;
        }
    }

    
$xoopsTpl->assign("maintheme"xoops_getcss($xoopsConfig['theme_set']));

    
$xoopsTpl->display('db:debaser_radiopopup.html');

?>

2
maxima
Re: Can an SQL query be made from a popup window?
  • 2006/11/7 16:01

  • maxima

  • Not too shy to talk

  • Posts: 152

  • Since: 2006/3/4 4


Still trying to figure this out.

3
m0nty
Re: Can an SQL query be made from a popup window?
  • 2006/11/7 16:29

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


try

find in popup.php

$xoopsTpl = new XoopsTpl();


add right after:

global $xoopsUser;
if (
is_object($xoopsUser)
{
$is_user 1;
$xoopsTpl->assign('is_user'$is_user);


then near the end of file, find

$xoopsTpl->assign("maintheme"xoops_getcss($xoopsConfig['theme_set']));


add right Before:

}
else
{
$is_user 0;
$xoopsTpl->assign('is_user'$is_user);
$xoopsTpl->assign('need_login''You must be logged in to play radio');
}


then in the template debaser_radiopopup.html

find:

<table class="outer"><tr><td class="odd">


add right Before:

<{if $is_user !== 1}>


find

td>tr>table>


add right After

<{else}>
<
div><{$need_login}>div>
<{/if}>


not tried it at all, but worth a try

4
maxima
Re: Can an SQL query be made from a popup window?
  • 2006/11/8 15:37

  • maxima

  • Not too shy to talk

  • Posts: 152

  • Since: 2006/3/4 4


Monty thanks for the help. I have applied the mods and I get the following error when accessing the popup
Quote:
Parse error: syntax error, unexpected '{' in /home/sobezone/html/modules/debaser/popup.php on line 38

line 38
global $xoopsUser;
    if (
is_object($xoopsUser)
[
color=990000]line 38[/color]    {
    
$is_user 1;
    
$xoopsTpl->assign('is_user'$is_user);

5
m0nty
Re: Can an SQL query be made from a popup window?
  • 2006/11/8 15:58

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


sorry i missed a closing ) round the if statement.

should be:

if (is_object($xoopsUser))

6
maxima
Re: Can an SQL query be made from a popup window?
  • 2006/11/9 6:00

  • maxima

  • Not too shy to talk

  • Posts: 152

  • Since: 2006/3/4 4


The popup comes up blank and when tested in guest mode the page is also blank.

Login

Who's Online

319 user(s) are online (282 user(s) are browsing Support Forums)


Members: 0


Guests: 319


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits