TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,019
  • Total Topics: 21,332
  • Online today: 1,062
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 246
  • Total: 246

Can You Help Me Out With This PHP Code?

Started by Reality12, April 24, 2007, 06:29:16 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Reality12

Maybe the title to this thread doesn't justify what I'm asking for...But, I currently have Torniyo's SMF Radio installed; it's not set up on the top menu bar as others have it, instead I have it linked on the FORUM index (in a block). I'm using HTML to make it pop up in it's own window, however, I need some help.

I want to add my website's banner to that page and also Google Adsense.

Here's the code for the Radio.php file:

<?php
// Version: 1.1; SMF Radio
/* Written By:
ToRNiYO
torniyo@hotmail.com
http://www.policoncepto.com
*/
if (!defined('SMF'))
die('Hacking attempt...');
function 
Radio_popup()
{
global $context, $txt;
$context['template_layers'] = array();
$context['page_title'] = $context['forum_name'].' - '.$txt['radio_modname'];
$context['sub_template'] = 'Radio';
}
function 
Radio_refresh()
{
global $context, $txt;
$context['template_layers'] = array();
$context['page_title'] = $context['forum_name'].' - '.$txt['radio_modname'];
$context['sub_template'] = 'Refresh';
}
function 
template_Radio()
{
global 
$settings, $context, $modSettings, $txt, $rn, $rvt;
global 
$gn, $rq, $ra, $data, $scripturl, $open, $rparse;
echo 
'<!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"'
,$context['right_to_left'] ? ' dir="rtl"' : '', '>
<head>
<meta http-equiv="Content-Type" content="text/html; charset='
,$context['character_set'],'" />
<title>'
,$context['page_title'],'</title>
<link rel="stylesheet" type="text/css" href="'
,$settings['theme_url'],'/style.css" />
</head>
<body>
<br />'
;
if (
allowedTo('radio_view') && $modSettings['racdc'] == 1)
{
CStations();
$r_st = $rparse['scheme'].'://'.$rparse['host'];
if (isset($rparse['port']))
$r_st = $r_st.':'.$rparse['port'];
if (isset($rparse['path']))
$r_st = $r_st.$rparse['path'];

$tvext = array(".mp",".wm",".as",".rm",".ra",".sm");
foreach ($tvext as $ck_ext)
if (strstr($r_st, $ck_ext))
$obj_inf = $ck_ext;
if (empty($obj_inf) || $obj_inf == ".as" || $obj_inf == ".wm" || $obj_inf == ".mp")
$tv_object = '<object id="MediaPlayer" classid="" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" type="application/x-mplayer2" width="320" height="50"><param name="showstatusbar" value="1"/><param name="autostart" value="true"/><param name="src" value="'.$r_st.'" /><embed width="320" height="50" src="'.$r_st.'" autostart="true" showstatusbar="1" type="application/x-mplayer2"></embed></object>';
elseif ($obj_inf == ".ra" || $obj_inf == ".rm" || $obj_inf == ".sm") 
$tv_object = '<object id="RealPlayer" classid="" codebase="" type="audio/x-pn-realaudio-plugin" width="320" height="50"><param name="console" value="video"><param name="controls" value="controlpanel"/><param name="autostart" value="true" /><param name="src" value="'.$r_st.'"/><embed width="320" height="50" src="'.$r_st.'" autostart="true" controls="controlpanel" console="video" type="audio/x-pn-realaudio-plugin" pluginspage="http://www.real.com"></embed></object>';
if ($modSettings['rstats'] == 1 && $rparse['scheme'] == "http" && (empty($obj_inf) || $obj_inf == ".as" || $obj_inf == ".wm" || $obj_inf == ".mp"))
{
R_PHP();
if ($open)
{
$rsd = isset($rq) ? "rm=$rq[ID_MEMBER]" : "ch=$rn";
echo '<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
Refresh()
function Refresh()
{
var pet = false
var exp = navigator.appName
if (exp == "Microsoft Internet Explorer")
pet = new ActiveXObject("Microsoft.XMLHTTP")
else
pet = new XMLHttpRequest()
var url = "'
.$scripturl.'?action=radiorefresh"
pet.open("POST", url, true)
pet.onreadystatechange = Verify_Conn
function Verify_Conn()
{
if (pet.readyState == 4)
{
if (pet.status == 200) 
{
var read = pet.responseText;
var data = new Array()
if (read.indexOf("," != -1))
{
data = read.split(",")
if (data[1] == 1)
{
document.getElementById("users").innerHTML = data[3]
document.getElementById("song").innerHTML = data[6]
if (data[3] == "'
.$txt['ratten'].'")
setTimeout("window.close()", 10000)
}
}
}
}
}
pet.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
pet.send("'
.$rsd.'")
}
setInterval("Refresh()",60000)
// ]]></script>'
;
}
}
echo '
<table width="495" align="center" cellspacing="0" cellpadding="4" class="tborder">
<tr class="titlebg">
<td colspan="2">'
,$txt['radio_modname'],'</td>
</tr>
<tr>
<td colspan="2" style="padding: 7px 17px 7px 17px;">
<form action="'
.$scripturl.'?action=radio" method="post">
<table align="left" cellspacing="0" class="tborder">
<tr>
<td class="smalltext">
<select name="ch" onchange="this.form.submit();" style="font-weight: bold;">'
;
if (!empty($rq))
echo ' <option value="0" selected="selected">',strtoupper($rq['radioTitle']),' - *',$rq['memberName'],'*</option>';
for ($cnum= 1; $cnum < ($modSettings['nstat'] + 1); $cnum++)
if ((empty($rm)) && $cnum == $rn)
echo ' <option value="',$cnum,'" selected="selected">NÃ,º ',$cnum,' - ',strtoupper($modSettings['rname'.$cnum]),'</option>';
elseif ((empty($rm)) && $modSettings['rsgenre'.$cnum] == $gn)
echo ' <option value="',$cnum,'">NÃ,º ',$cnum,' - ',strtoupper($modSettings['rname'.$cnum]),'</option>';
else
echo ' <option value="',$cnum,'" style="color: silver;">NÃ,º ',$cnum,' - ',strtoupper($modSettings['rname'.$cnum]),'</option>';
echo ' </select>
</td>
</tr>
</table>
</form>
<form action="'
.$scripturl.'?action=radio" method="post">
<table align="right" cellspacing="0" class="tborder">
<tr>
<td style="font-size: 7pt;">
<select name="gn" onchange="this.form.submit();" style="font-weight: bold;">'
;
if (!empty($rq))
echo ' <option value="0" selected="selected">',$txt['rpers'],'</option>';
for ($cnum = 1; $cnum < ($modSettings['ngenre'] + 1); $cnum++)
if ((empty($rm)) && (@$modSettings['rsgenre'.$rn] == $cnum))
echo ' <option value="',$cnum,'" selected="selected">',strtoupper($modSettings['rgenre'.$cnum]),'</option>';
else
echo ' <option value="',$cnum,'" style="color: silver;">',strtoupper($modSettings['rgenre'.$cnum]),'</option>';
echo ' </select>
</td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td colspan="2" height="101">
<table align="center" border="0">
<tr>
<td colspan="3" height="17" align="center" valign="bottom" class="smalltext">'
;
if ($modSettings['rstats'] == 1 && $open && $data[1] == 1)
echo '<div id="users"></div>';
echo ' </td>
</tr>
<tr>
<td valign="top" style="padding-top:20px;" class="smalltext">
<form action="'
.$scripturl.'?action=radio" method="post">
<label>&lt;&lt;-
<input type="submit" name="ch" value="'
,($rn-1),'"/>
-</label>
</form>
</td>
<td style="padding:2px;" class="tborder">
'
,$tv_object,'
</td>
<td valign="top" style="padding-top:20px;" class="smalltext">
<form action="'
.$scripturl.'?action=radio" method="post">
<label>-
<input type="submit" name="ch" value="'
,($rn+1),'"/>
->></label>
</form>
</td>
</tr>
<tr>
<td colspan="3" height="15" align="center" class="smalltext">'
;
if ($modSettings['rstats'] == 1 && $open)
{
if ($data[1] == 1)
echo '<div id="song"></div>';
if ($data[1] == 0)
echo $txt['roff'];
}
if ($context['user']['is_admin'] && $modSettings['rstats'] == 1 && $rparse['scheme'] == "http" && !$open && empty($obj_inf))
echo ' <span class="error">',$txt['rnfsock'],'</span>';
echo ' </td>
</tr>
</table>
</td>
</tr>'
;
if (empty($rq))
{
echo ' <tr>
<td align="center" style="font-weight: bold; font-size: 6pt;">
<form action="'
.$scripturl.'?action=radio" method="post">
<table cellspacing="0" class="tborder">
<tr>
<td style="font-size: 6pt;">'
;
for ($cnum = 1; $cnum < 6; $cnum++)
if ((@round($ra / $rvt)) == $cnum)
echo ' <input type="submit" name="ra" style="color: red; font-weight: bold;" value="',$cnum,'"/>';
else
echo ' <input type="submit" name="ra" style="font-weight: bold;" value="',$cnum,'"/>';
echo ' '.$txt['rvts'].' '.$rvt.' 
<input type="hidden" name="ch" value="'
,$rn,'"/>
</td>
</tr>
</table>
</form>
</td>'
;
}
else
echo ' <tr>';
}
else
{
echo '<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
setTimeout("window.close()", 5000) // ]]></script>
<table width="495" align="center" border="0" cellspacing="0" cellpadding="4" class="tborder">
<tr class="titlebg">
<td>'
,$txt['radio_modname'],'</td>
</tr>
<tr>
<td align="center" height="137" class="smalltext">
<b>'
.(($modSettings['racdc'] == 0) ? $txt['roff'] : $txt['nope']).'</b>
</td>
</tr>
<tr>'
;
}
// Copy - Not change or delete!!!
echo ' <td align="right" height="36" valign="bottom" style="font-size: xx-small; padding-right: 17px;">SMF Radio &copy; <a href="http://www.policoncepto.com/" target="_blank">ToRNiYO</a></td>

</tr>
</table>
</body>
</html>'
;
}
function 
template_Refresh()
{
global $modSettings, $data, $scripturl, $rparse, $txt;
header('Content-Type: text/plain');
if (allowedTo('radio_view') && $modSettings['racdc'] == 1)
{
CStations();
R_PHP();
echo '<HTML><meta http-equiv="Pragma" content="no-cache"></head><body>SMF ,',$data[1],', Radio ,',$data[3],', by , ToRNiYO ,',$data[6],'</body></html>';
}
else
echo '<HTML><meta http-equiv="Pragma" content="no-cache"></head><body>SMF ,',1,', Radio ,',$txt['ratten'],', by , ToRNiYO ,',$txt['rtoff'],'</body></html>';
}
function 
CStations()
{
global $rn, $gn, $rq, $rvt, $ra;
global $modSettings, $db_prefix, $rparse;
$rm = isset($_REQUEST['rm']) ? (int) $_REQUEST['rm'] : "";
if (!empty($rm))
{
$rreq = db_query("
SELECT ID_MEMBER, memberName, radioTitle, radioUrl
FROM 
{$db_prefix}members 
WHERE ID_MEMBER = 
$rm ", __FILE__, __LINE__);
$rq = mysql_fetch_assoc($rreq);
mysql_free_result($rreq);
$gn = 0;
$rparse = !empty($rq['radioUrl']) ? parse_url($rq['radioUrl']) : "";
}
if (empty($rparse))
{
$ch = isset($_POST['ch']) ? (int) $_POST['ch'] : "";
$gn = isset($_POST['gn']) ? (int) $_POST['gn'] : $modSettings['rsgenre1'];
if (!empty($ch))
$rn = $ch > $modSettings['nstat'] || $ch <= 0  ? 1 : $ch;
else
{
$rn = 0;
do {
$rn++;
if ($rn >= $modSettings['nstat'])
{
$rn = 1;
break;
}
} while ($modSettings['rsgenre'.$rn] != $gn);
}
$gn = isset($modSettings['rsgenre'.$rn]) ? $modSettings['rsgenre'.$rn] : $txt['tgnone'];
$rparse = parse_url($modSettings['rst'.$rn]);
}
$ra = isset($_POST['ra']) ? (int) $_POST['ra'] : "";
if (empty($rm) && !empty($ra) && $ra >= 1 && $ra < 6)
{
$rvt = (isset($modSettings['rnrate'.$rn]) ? $modSettings['rnrate'.$rn] : 0) + 1;
$ra = (isset($modSettings['rrate'.$rn]) ? $modSettings['rrate'.$rn] : 0) + $ra;
db_query("
UPDATE 
{$db_prefix}settings
                SET value = 
$ra
                WHERE variable = 'rrate"
.$rn."' ", __FILE__, __LINE__);
db_query("
UPDATE 
{$db_prefix}settings
SET value = 
$rvt
WHERE variable = 'rnrate"
.$rn."' ", __FILE__, __LINE__);

}
elseif (!empty($rn))
{
$rvt = isset($modSettings['rnrate'.$rn]) ? $modSettings['rnrate'.$rn] : 0;
$ra = isset($modSettings['rrate'.$rn]) ? $modSettings['rrate'.$rn] : 0;
}
}
function 
R_PHP()
{
global $txt, $open, $data, $rn, $rparse, $db_prefix;
$open = @fsockopen($rparse['host'], $rparse['port'], $errno, $errstr, 8);
if ($open)
{
$rreq = db_query("
SELECT count(*)
FROM 
{$db_prefix}log_online 
WHERE url LIKE '%radio%'"
, __FILE__, __LINE__);
list ($rcuser) = mysql_fetch_row($rreq);
mysql_free_result($rreq);
if (empty($rparse['path']))
{
fwrite($open,"GET /7.html HTTP/1.0\nUser-Agent:Mozilla\n\n");
$read = fread($open,1000);
$data = explode("content-type:text/html",$read); 
$data = explode(",",$data[1]);
if ($data[1] == 1)
{
if ($data[4] != 1)
$data[3] = '<b>'.$data[4].' ('.$rcuser.' '.$txt['rinforum'].')</b> '.$txt['rnum'].' '.$data[3].' '.$txt['rmen'].($data[3] != 1 ? $txt['rvvar'] : "").' '.$txt['rlist'].':';
}
}
else
{
fwrite($open,"GET ".$rparse['path']." HTTP/1.0\nUser-Agent:Mozilla\nIcy-Metadata:1\n\n");
$rt = time() + 8;
while (substr(@$read, -9) != "StreamUrl")
{
$part = fgetc($open);
@$read .= $part;
if(substr(@$read, -13) == "StreamTitle='")
unset($read);
if ($rt < time())
return;
}
if (isset($read))
{
$data[6] = substr($read, 0, -11);
$data[1] = 1;
}
$data[3] = '<b>'.$rcuser.' '.$txt['rinforum'].'</b> '.$txt['rlist'].':';
}
if (strlen($data[6]) > 55)
$data[6] = (substr($data[6], 0, 51)).' ...'; 
$data[6] = '<b>'.$data[6].'</b>';
fclose($open);
}
}
function 
Radio_admin()
{
global $context, $txt, $scripturl;
isAllowedTo('admin_forum');
adminIndex('radio_admin');
loadLanguage('ModSettings');
$context['page_title'] = $txt['radmin'];
$context['sub_template'] = 'show_settings';
$subActions = array(
'config' => 'Radio_config',
'stations' => 'Radio_stations',
'genres' => 'Radio_genres',
);
$_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'config';
$context['sub_action'] = $_REQUEST['sa'];
$context['admin_tabs'] = array(
'title' => $txt['radmin'],
'help' => 'modsettings',
'description' => $txt['radmd'],
'tabs' => array(
'config' => array(
'title' => $txt['rconf'],
'href' => $scripturl.'?action=radioadmin;sa=config;sesc='.$context['session_id'],
),
'stations' => array(
'title' => $txt['rstatis'],
'href' => $scripturl.'?action=radioadmin;sa=stations;sesc='.$context['session_id'],
),
'genres' => array(
'title' => $txt['rgenres'],
'href' => $scripturl.'?action=radioadmin;sa=genres;sesc='.$context['session_id'],
),
),
);
if (isset($context['admin_tabs']['tabs'][$context['sub_action']]))
$context['admin_tabs']['tabs'][$context['sub_action']]['is_selected'] = true;
$subActions[$_REQUEST['sa']]();
}
function 
Radio_config()
{
global $txt, $scripturl, $context, $sourcedir, $modSettings, $db_prefix;
require_once($sourcedir.'/ManageServer.php');
$config_vars = array(
'',
array('check', 'racdc'),
array('int', 'nstat'),
array('int', 'ngenre'),
'',
array('check', 'rstats'),
'',);
if (isset($_GET['save']))
{
$scnum = $modSettings['nstat'];
$gcnum = $modSettings['ngenre'];
saveDBSettings($config_vars);
for ($cnum = ($modSettings['nstat'] + 1); $cnum < ($scnum + 1); $cnum++)
{
db_query("
DELETE FROM 
{$db_prefix}settings
WHERE variable = 'rname"
.$cnum."' OR
variable = 'rsgenre"
.$cnum."' OR
variable = 'rrate"
.$cnum."' OR
variable = 'rnrate"
.$cnum."' OR
variable = 'rst"
.$cnum."'", __FILE__, __LINE__);
}
for ($cnum = ($modSettings['ngenre'] + 1); $cnum < ($gcnum + 1); $cnum++)
{
db_query("
DELETE FROM 
{$db_prefix}settings
WHERE variable = 'rgenre"
.$cnum."'", __FILE__, __LINE__);
}
redirectexit('action=radioadmin;sa=config');
}
$context['post_url'] = $scripturl .'?action=radioadmin;save;sa=config';
$context['settings_title'] = $txt['rconf'];
prepareDBSettingContext($config_vars);
}
function 
Radio_stations()
{
global $txt, $scripturl, $context, $sourcedir, $modSettings, $db_prefix;
require_once($sourcedir.'/ManageServer.php');
$config_gnrs = array($txt['rgnone']);
for ($cnum = 1; $cnum < ($modSettings['ngenre'] + 1); $cnum++) 
{
$config_gnrs_tmp = array($modSettings['rgenre'.$cnum]);
$config_gnrs = array_merge($config_gnrs, $config_gnrs_tmp);
}
$config_vars = array();
for ($cnum = 1; $cnum < ($modSettings['nstat'] + 1); $cnum++) 
{
if (!isset($modSettings['rrate'.$cnum]))
db_query("
INSERT INTO 
{$db_prefix}settings (variable, value)
VALUES ('rrate"
.$cnum."', 0) ", __FILE__, __LINE__);
if (!isset($modSettings['rnrate'.$cnum]))
db_query("
INSERT INTO 
{$db_prefix}settings (variable, value)
VALUES ('rnrate"
.$cnum."', 0) ", __FILE__, __LINE__);
$config_vars_tmp = array(
'',
array('text', 'rname'.$cnum.'', 40),
array('text', 'rst'.$cnum.'', 60),
array('select', 'rsgenre'.$cnum.'', $config_gnrs),
array('float', 'rrate'.$cnum.'', 10),
array('int', 'rnrate'.$cnum.'', 10),
'',);
$config_vars = array_merge($config_vars, $config_vars_tmp);
}
if (isset($_GET['save']))
{
saveDBSettings($config_vars);
redirectexit('action=radioadmin;sa=stations');
}
$context['post_url'] = $scripturl.'?action=radioadmin;save;sa=stations';
$context['settings_title'] = $txt['rstatis'];
prepareDBSettingContext($config_vars);
}
function 
Radio_genres()
{
global $txt, $scripturl, $context, $sourcedir, $modSettings;
require_once($sourcedir.'/ManageServer.php');
$config_vars = array();
for ($cnum = 1; $cnum < ($modSettings['ngenre'] + 1); $cnum++) 
{
$config_vars_tmp = array(
'',
array('text', 'rgenre'.$cnum.'', 25),
'',);
$config_vars = array_merge($config_vars, $config_vars_tmp);
}
if (isset($_GET['save']))
{
saveDBSettings($config_vars);
redirectexit('action=radioadmin;sa=genres');
}
$context['post_url'] = $scripturl.'?action=radioadmin;save;sa=genres';
$context['settings_title'] = $txt['rgenres'];
prepareDBSettingContext($config_vars);
}
?>



What code would I use to modify this and where would I place it?

Thank you in advance.


This website is proudly hosted on Crocweb Cloud Website Hosting.