<?

/**************************************************************************/
/* 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.         */
/*                                                                        */
/*                                                                        */
/**************************************************************************/

if (!eregi("admin.php", $PHP_SELF)) { die ("Á¢±ÙÀÌ °ÅÀýµÇ¾ú½À´Ï´Ù."); }

$result = sql_query("select radminsuper, admlanguage from $prefix"._authors." where aid='$aid'", $dbi);
list($radminsuper) = sql_fetch_row($result, $dbi);

if ($radminsuper==1) {

function IRdisplay() {
	global $language, $admin, $prefix, $dbi, $radioid ;
	include ('header.php');
	GraphicAdmin();
	OpenTable();
	echo ("<center><font class=\"title\"><b>ÀÎÅÍ³Ý ¶óµð¿À "._ADMINISTRATION."</b></font></center>");
	CloseTable();
	echo "<br>";
	OpenTable();
	  echo "<center><b>"._INRADPROG."</b></center><br>";
    $count = 0;
$idnum = 1;
    $result = sql_query("SELECT radio_id, radio_name, radio_language FROM ".$prefix."_internet_radio ORDER BY radio_name ASC", $dbi);
    while(list($radio_id, $radio_name, $radio_language) = sql_fetch_row($result, $dbi)) {
	if ($radio_language == "") {
	    $radio_language = ""._ALL."";
	}
	if ($radio_id != "") {
	    if ($count == 0) {
		echo "<table border=\"1\" width=\"100%\">";
		$count = 1;
	    }
	 echo "<tr><td><b>$idnum</b></td><td width=\"100%\">&nbsp;$radio_name&nbsp;</td><td align=\"center\">&nbsp;$radio_language&nbsp;</td><td nowrap>&nbsp;(<a href=\"admin.php?op=IRedit&amp;radioid=$radio_id\">"._EDIT."</a>-<a href=\"admin.php?op=IRdelete&amp;radioid=$radio_id\">"._DELETE."</a>)&nbsp;</td></tr>"; 
$idnum = $idnum + 1;
	   } }
  
    if (($radio_id == "") AND ($count == 0)) {
	echo "<center><i>"._INRADNOST."</i></center>";
    }
    if ($count == 1) {
        echo "</table>";
    }
	echo "<br><center><a href=\"admin.php?op=IRnew\">"._INRADNEW."</a>";
  CloseTable();
  echo "<br>";
  OpenTable();
	$result = sql_query("SELECT modulename, auto_start, picture, picture_dir, defpicture, nopicture_name FROM ".$prefix."_internet_radio_settings", $dbi);
  list($modulename, $auto_start, $picture, $picture_dir, $defpicture, $nopicture_name) = sql_fetch_row($result, $dbi);
	echo "<center><b>"._INRADBLSET."</b></center><br>"
  ."<form action='admin.php' method='post'>"
  ."<table border='0'><tr><td>"
  .""._INRADMODNAME.":</td><td><select name='xmodulename'>";
    $handle=opendir('modules');
    while ($file = readdir($handle)) {
	if ( (!ereg("[.]",$file)) ) {
		$modulelist .= "$file ";
	}
    }
    closedir($handle);
    $modulelist = explode(" ", $modulelist);
    sort($modulelist);
    for ($i=0; $i < sizeof($modulelist); $i++) {
	if($modulelist[$i]!="") {
	  echo "<option name='xmodulename' value='$modulelist[$i]' ";
		if($modulelist[$i]==$modulename) echo "selected";
		echo ">$modulelist[$i]\n";
	}
    }
  echo "</select>"  
  ."</td></tr><tr><td>"._INRADAUTOST.":</td><td>";
  if ($auto_start==1) {
	  echo "<input type='radio' name='xautostart' value='1' checked>"._YES." &nbsp;
	  <input type='radio' name='xautostart' value='0'>"._NO."";
    } else {
	  echo "<input type='radio' name='xautostart' value='1'>"._YES." &nbsp;
	  <input type='radio' name='xautostart' value='0' checked>"._NO."";
    }
  echo "</td></tr><tr><td>"._INRADPICCHO.":</td><td>";
  if ($picture==1) {
	  echo "<input type='radio' name='xpicture' value='1' checked>"._YES." &nbsp;
	  <input type='radio' name='xpicture' value='0'>"._NO."";
    } else {
	  echo "<input type='radio' name='xpicture' value='1'>"._YES." &nbsp;
	  <input type='radio' name='xpicture' value='0' checked>"._NO."";
    }
  echo "</td></tr><tr><td>"
  .""._INRADPICDIR.":</td><td>"
	."<input type=\"text\" name=\"xpicturedir\" size=\"50\" maxlength=\"50\" value=\"$picture_dir\">"
	."</td></tr><tr><td>"._INRADPICDEF.":</td><td>";
  if ($defpicture==1) {
	  echo "<input type='radio' name='xdefpicture' value='1' checked>"._YES." &nbsp;
	  <input type='radio' name='xdefpicture' value='0'>"._NO."";
    } else {
	  echo "<input type='radio' name='xdefpicture' value='1'>"._YES." &nbsp;
	  <input type='radio' name='xdefpicture' value='0' checked>"._NO."";
    }
  echo "</td></tr><tr><td>"
  .""._INRADNOPICNAME.":</td><td>"
	."<input type=\"text\" name=\"xnopicturename\" size=\"50\" maxlength=\"50\" value=\"$nopicture_name\">"
	."</td></tr><tr><td><br><br>"
  ."<input type=\"hidden\" name=\"op\" value=\"IRsettings\">"
  ."<input type=\"submit\" value=\""._SAVECHANGES."\">"
	."</tr></td></table></form>";
	CloseTable();
  include ('footer.php');
}

function IRdelete() {
    global $prefix, $radioid, $dbi;
    sql_query("DELETE FROM ".$prefix."_internet_radio WHERE radio_id=$radioid", $dbi);
    Header("Location: admin.php?op=IRdisplay");
}

function IRedit() {
 global $radioid, $prefix, $dbi, $multilingual;
  include ('header.php');
	GraphicAdmin();
echo "
<script language=\"JavaScript\" type=\"text/javascript\">  
function checkform (form)
{
  if (form.radioname.value == \"\") {
  alert(\""._INRADERR1."\" );
  form.radioname.focus();
  return false ;
  }
  if (form.radiostream.value == \"http://\" OR form.radiostream.value == \"\") {
  alert( \""._INRADERR2."\" );
  form.radiostream.focus();
  return false ;
  }
  return true ;
}
</script>";
	OpenTable();
	echo "<center><font class=\"title\"><b>Internet Radio "._ADMINISTRATION."</b></font></center>";
	CloseTable();
	echo "<br>";
	$result = sql_query("SELECT radio_name, radio_stream, radio_url, radio_picture, radio_language FROM ".$prefix."_internet_radio WHERE radio_id=$radioid", $dbi);
        list($radio_name, $radio_stream, $radio_url, $radio_picture, $radio_language) = sql_fetch_row($result, $dbi);
	      OpenTable();
        echo "<center><font class=\"option\"><b>"._INRADEDIT."</b></font></center><br>";
	echo "<br><br>"
	    ."<form action=\"admin.php\" method=\"post\" onsubmit=\"return checkform(this);\">"
			."<table border='0'><tr><td>"
	    .""._INRADNAME.":</td><td>"
	    ."<input type=\"text\" name=\"radioname\" size=\"20\" maxlength=\"20\" value=\"$radio_name\">"
		  ."</td></tr><tr><td>"
	    .""._INRADSTREAM.":</td><td>"
			."<input type=\"text\" name=\"radiostream\" size=\"50\" maxlength=\"75\" value=\"$radio_stream\">"
			."</td></tr><tr><td>"
      .""._INRADURL.":</td><td>"
			."<input type=\"text\" name=\"radiourl\" size=\"50\" maxlength=\"50\" value=\"$radio_url\">"
			."&nbsp;("._OPTION.")</td></tr><tr><td>"
			.""._INRADPICT.":</td><td>"
			."<input type=\"text\" name=\"radiopicture\" size=\"50\" maxlength=\"50\" value=\"$radio_picture\">&nbsp;("._INRADPICTDIR.")"
			."</td></tr><tr><td>";
	if ($multilingual == 1) {
	    echo ""._LANGUAGE.":</td><td>"
		."<select name=\"radiolanguage\">";
	    $handle=opendir('language');
	    while ($file = readdir($handle)) {
		if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
	    	    $langFound = $matches[1];
	    	    $languageslist .= "$langFound ";
	    	}
	    }
	    closedir($handle);
	    $languageslist = explode(" ", $languageslist);
	    sort($languageslist);
	    for ($i=0; $i < sizeof($languageslist); $i++) {
	        if($languageslist[$i]!="") {
		    echo "<option name=\"radiolanguage\" value=\"$languageslist[$i]\" ";
		    if($languageslist[$i]==$radio_language) echo "selected";
		    echo ">".ucfirst($languageslist[$i])."\n</option>";
		}
	    }
	    if ($radio_language == "") {
		$sellang = "selected";
	    } else {
    		$sellang = "";
	    }
	    echo "<option value=\"\" $sellang>"._ALL."</option></select>";
	} else {
	    echo "<input type=\"hidden\" name=\"radiolanguage\" value=\"\">";
	}
	     echo "</td></tr><tr><td><br><br>"
			 ."<input type=\"hidden\" NAME=\"radioid\" size=\"50\" value=\"$radioid\">"
			 ."<input type=\"hidden\" name=\"op\" value=\"IRchange\">"
			 ."<input type=\"submit\" value=\""._SAVECHANGES."\">"
	     ."</tr></td></table></form>";
	CloseTable();
	include ('footer.php');
  }


function IRchange($radioid, $radioname, $radiostream, $radiourl, $radiopicture, $radiolanguage) {
 global $prefix, $dbi;
 sql_query("UPDATE ".$prefix."_internet_radio SET radio_name='$radioname', radio_stream='$radiostream', radio_url='$radiourl', radio_picture='$radiopicture', radio_language='$radiolanguage' WHERE radio_id=$radioid", $dbi);
 Header("Location: admin.php?op=IRdisplay");
    
}

function IRnew() {
 global $radioid, $prefix, $dbi, $multilingual;
  include ('header.php');
	GraphicAdmin();
echo "
<script language=\"JavaScript\" type=\"text/javascript\">  
function checkform (form)
{
  if (form.radioname.value == \"\") {
  alert(\""._INRADERR1."\" );
  form.radioname.focus();
  return false ;
  }
  if (form.radiostream.value == \"http://\" OR form.radiostream.value == \"\") {
  alert( \""._INRADERR2."\" );
  form.radiostream.focus();
  return false ;
  }
  return true ;
}
</script>";
	OpenTable();
	echo "<center><font class=\"title\"><b>Internet Radio "._ADMINISTRATION."</b></font></center>";
	CloseTable();
	echo "<br>";
	OpenTable();
  echo "<center><font class=\"option\"><b>"._INRADNEW."</b></font></center><br>";
	echo "<br><br>"
	    ."<form action=\"admin.php\" method=\"post\" onsubmit=\"return checkform(this);\">"
			."<table border='0'><tr><td>"
	    .""._INRADNAME.":</td><td>"
	    ."<input type=\"text\" name=\"radioname\" size=\"20\" maxlength=\"20\">"
		  ."</td></tr><tr><td>"
	    .""._INRADSTREAM.":</td><td>"
			."<input type=\"text\" name=\"radiostream\" size=\"50\" maxlength=\"75\" value=\"http://\">"
			."</td></tr><tr><td>"
      .""._INRADURL.":</td><td>"
			."<input type=\"text\" name=\"radiourl\" size=\"50\" maxlength=\"50\" value=\"http://\">"
				."&nbsp;("._OPTION.")</td></tr><tr><td>"
			.""._INRADPICT.":</td><td>"
			."<input type=\"text\" name=\"radiopicture\" size=\"50\" maxlength=\"50\" >&nbsp;("._INRADPICTDIR.")"
			."</td></tr><tr><td>";
	if ($multilingual == 1) {
	    echo ""._LANGUAGE.":</td><td>"
		."<select name=\"radiolanguage\">"
    ."<option value=\"\">"._ALL."</option>";
	    $handle=opendir('language');
	    while ($file = readdir($handle)) {
		if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
	    	    $langFound = $matches[1];
	    	    $languageslist .= "$langFound ";
	    	}
	    }
	    closedir($handle);
	    $languageslist = explode(" ", $languageslist);
	    sort($languageslist);
	    for ($i=0; $i < sizeof($languageslist); $i++) {
	        if($languageslist[$i]!="") {
		    echo "<option name=\"radiolanguage\" value=\"$languageslist[$i]\" ";
		    echo ">".ucfirst($languageslist[$i])."\n</option>";
		}
	    }
	    echo "</select>";
	} else {
	    echo "<input type=\"hidden\" name=\"radiolanguage\" value=\"\">";
	}
	     echo "</td></tr><tr><td><br><br>"
			 ."<input type=\"hidden\" name=\"op\" value=\"IRadd\">"
			 ."<input type=\"submit\" value=\""._SAVECHANGES."\">"
	     ."</tr></td></table></form>";
	CloseTable();
	include ('footer.php');
  }



function IRadd($radioname, $radiostream, $radiourl, $radiopicture, $radiolanguage) {
    global $prefix, $dbi;
sql_query("INSERT INTO ".$prefix."_internet_radio VALUES ('','$radioname', '$radiostream', '$radiourl', '$radiopicture', '$radiolanguage')", $dbi);
	Header("Location: admin.php?op=IRdisplay");
    
}

function IRsettings($xmodulename, $xautostart, $xpicture, $xpicturedir, $xdefpicture, $xnopicturename) {
 global $prefix, $dbi;
 sql_query("UPDATE ".$prefix."_internet_radio_settings SET modulename='$xmodulename', auto_start='$xautostart', picture='$xpicture', picture_dir='$xpicturedir', defpicture='$xdefpicture', nopicture_name='$xnopicturename'", $dbi);
 Header("Location: admin.php?op=IRdisplay");
   
}


switch($op) {

    case "IRdisplay":
    IRdisplay();
    break;

		case "IRdelete":
    IRdelete();
    break;

		case "IRedit":
    IRedit();
    break;

		case "IRchange":
    IRchange($radioid, $radioname, $radiostream, $radiourl, $radiopicture, $radiolanguage);
    break;

		case "IRnew":
    IRnew();
    break;

		case "IRadd":
	  IRadd($radioname, $radiostream, $radiourl, $radiopicture, $radiolanguage);
		break;

    case "IRsettings":
	  IRsettings($xmodulename, $xautostart, $xpicture, $xpicturedir, $xdefpicture, $xnopicturename);
		break;

}





} else {

    echo "Access Denied";
}
  
?>