<?php
include('header.php');
echo $h;

$action = $_GET['action'];
if(!isset($action)) $action = "add";

IF ($action=="add"){
?>
<form name="vbform" method="post" action="quran_cp.php?action=insert">

<table class='xtable' width="100%" id="AutoNumber1">
     <tr>
      <td width="100%" colspan="2" class='xtx' align="center"><?php echo $LANGAUGE_CP[393]; ?></td>
    </tr>
    <tr>
      <td width="35%" class='xtr'><?php echo $LANGAUGE_CP[394]; ?></td>
      <td width="65%" class='xtd'><input size="50" name="name_cat" /></td>
    </tr>
    <tr>
      <td width="35%" class='xtr'><?php echo $LANGAUGE_CP[91]; ?></td>
      <td width="65%" class='xtd'><textarea name="keywords" rows="3" cols="50"></textarea></td>
    </tr>
    <tr>
      <td width="35%" class='xtr'><?php echo $LANGAUGE_CP[92]; ?></td>
      <td width="65%" class='xtd'><textarea name="description" rows="3" cols="50"></textarea></td>
    </tr>
    <tr>
      <td width="35%" class='xtr'><?php echo $LANGAUGE_CP[94]; ?></td>
      <td width="65%" class='xtd'><input size="10" name="order_cat" /></td>
    </tr>

<tr>
<td width='35%' class='xtr'><?php echo $LANGAUGE_CP[95]; ?></td>
<td width='65%' class='xtd'>
<select  size='1' name='sub'>
<OPTION value='0' selected="selected"><?php echo $LANGAUGE_CP[96]; ?></OPTION>
<?php
$sql = mysql_query ("SELECT * FROM  telawat_cat where sub=0");
while($cat=mysql_fetch_array($sql))
{
echo "<OPTION value='".$cat['id']."'>".$cat['name_cat']."</OPTION>";
}
?>
</select>
</td>
</tr>

     <tr>
      <td width="100%" colspan="2" class='xtr' align="center"><input type="submit" value=" <?php echo $LANGAUGE_CP[18]; ?> " name="cmdAdd" /></td>
    </tr>
  </table>
</form>
<?php

$queryx = mysql_query("SELECT * FROM telawat_cat order by id desc");
$xx = mysql_num_rows($queryx);
if($xx == 0){
echo "";
}else{

echo "<table class='xtable' width='100%' id='AutoN4umber15'>
  <tr>
<td width='100%' colspan='4' class='xtt' align='center'>".$LANGAUGE_CP[97]."</td>
</tr>
  <tr>
      <td width='79%' align='center' class='xtr'>".$LANGAUGE_CP[395]."</td>
      <td width='7%' align='center' class='xtr'>".$LANGAUGE_CP[28]."</td>
      <td width='7%' align='center' class='xtr'>".$LANGAUGE_CP[26]."</td>
      <td width='7%' align='center' class='xtr'>".$LANGAUGE_CP[27]."</td>
    </tr>";
while($p = mysql_fetch_array($queryx))
{
$p['name_cat'] = stripslashes($p['name_cat']);
$p['name_cat'] = htmlspecialchars($p['name_cat']);

if($p['active'] == 1){
$im = "images/on.gif";
$li = "quran_cp.php?action=actxcat&id=$p[id]&act=0";
$te = $LANGAUGE_CP[72];
}else{
$im = "images/off.gif";
$li = "quran_cp.php?action=actxcat&id=$p[id]&act=1";
$te = $LANGAUGE_CP[73];
}

echo "<tr>
      <td width='79%' class='xtd'>» ".$p['name_cat']."</td>
      <td width='7%' align='center' class='xtd'><a href='$li'><img border='0' src='$im' alt='$te ".$p['name_cat']."' /></a></td>
      <td width='7%' align='center' class='xtd'><a href='quran_cp.php?action=edit&id=$p[id]'><img border='0' src='images/edit.gif' alt='".$p['name_cat']."' /></a></td>
      <td width='7%' align='center' class='xtd'><a href='quran_cp.php?action=delete&id=$p[id]'><img border='0' src='images/delete.gif' alt='".$p['name_cat']."' /></a></td>
    </tr>";
}
echo "</table>";
}

}ELSEIF ($action=="insert"){

$title = addslashes($_POST['name_cat']);
$title = trim($title);

$keywords = addslashes($_POST['keywords']);
$keywords = trim($keywords);

$description = addslashes($_POST['description']);
$description = trim($description);

if($description==""){
$xm1 = $title;
}else{
$xm1 = $description;
}

if($keywords==""){
$m2x = str_replace(" ",",",$title);
$xm2 = $m2x;
}else{
$xm2 = $keywords;
}

$order_cat = $_POST['order_cat'];
$sub = $_POST['sub'];

if (empty($title)){
echo $LANGAUGE_CP[159];
}else{
$query =  mysql_query ("INSERT INTO telawat_cat (name_cat,order_cat,sub,description,keywords,active) VALUES ('$title','$order_cat','$sub','$xm1','$xm2','1')") or die ("error");
print $LANGAUGE_CP[21];
echo "<META HTTP-EQUIV='refresh' CONTENT='1; URL=quran_cp.php?action=add' />";
}


}ELSEIF ($action=="edit"){
$id = intval($_GET['id']);
$query = mysql_query("SELECT * FROM telawat_cat where id='$id'");
$p = mysql_fetch_array($query);

$p['name_cat'] = stripslashes($p['name_cat']);
$p['name_cat'] = htmlspecialchars($p['name_cat']);

$p['keywords'] = stripslashes($p['keywords']);
$p['keywords'] = htmlspecialchars($p['keywords']);

$p['description'] = stripslashes($p['description']);
$p['description'] = htmlspecialchars($p['description']);

echo "<form name='vbform' method='POST' action='quran_cp.php?action=editok'>
<input type='hidden' name='id' value='$p[id]' />

<table class='xtable' width='100%' id='AutoNumber15'>

<tr>
<td width='100%' colspan='2' class='xtx' align='center'>".$LANGAUGE_CP[32]."</td>
</tr>

<tr>
<td width='30%' class='xtr'>".$LANGAUGE_CP[394]."</td>
<td width='70%' class='xtd'><input name='name_cat' size='60' value='".$p['name_cat']."' /></td>
</tr>

<tr>
<td width='30%' class='xtr'>".$LANGAUGE_CP[91]."</td>
<td width='70%' class='xtd'><textarea name='keywords' rows='3' cols='60'>".$p['keywords']."</textarea>
</td>
</tr>

<tr>
<td width='30%' class='xtr'>".$LANGAUGE_CP[92]."</td>
<td width='70%' class='xtd'><textarea name='description' rows='3' cols='60'>".$p['description']."</textarea>
</td>
</tr>

<tr>
<td width='30%' class='xtr'>".$LANGAUGE_CP[94]."</td>
<td width='70%' class='xtd'><input name='order_cat' size='10' value='".$p['order_cat']."' /></td>
</tr>

<tr>
<td width='20%' class='xtr'>".$LANGAUGE_CP[95]."</td>
<td width='80%' class='xtd'>
<select size='1' name='cat'>";
echo "<option value='0'>".$LANGAUGE_CP[96]."</option>";
$sql = mysql_query ("SELECT * FROM telawat_cat where sub=0 AND id != '$id'") or die ("error");
while($sub = mysql_fetch_array($sql))
{
if($sub['id'] ==  $p['sub']){
echo "<option value='$sub[id]' selected='selected'>$sub[name_cat]</option>";
}else{
echo "<option value='$sub[id]'>$sub[name_cat]</option>";
}

}
echo "</select>
</td>
</tr>

<tr>
<td width='100%' colspan='2' align='center' class='xtr'><input type='submit' value=' ".$LANGAUGE_CP[18]." ' name='B1' /></td>
</tr>

</table>
</form>";

}ELSEIF ($action=="editok"){

$id    = intval($_POST['id']);
$title = addslashes($_POST['name_cat']);
$title = trim($title);

$keywords = addslashes($_POST['keywords']);
$keywords = trim($keywords);

$description = addslashes($_POST['description']);
$description = trim($description);

if($description==""){
$xm1 = $title;
}else{
$xm1 = $description;
}

if($keywords==""){
$m2x = str_replace(" ",",",$title);
$xm2 = $m2x;
}else{
$xm2 = $keywords;
}

$order_cat = intval($_POST['order_cat']);
$cat = intval($_POST['cat']);

if (empty($title)){
echo $LANGAUGE_CP[159];
}else{
$query =  mysql_query("UPDATE telawat_cat SET name_cat='$title',order_cat='$order_cat',sub='$cat', description='$xm1', keywords='$xm2' where id='$id'");
echo $LANGAUGE_CP[34];
echo "<META HTTP-EQUIV='Refresh' CONTENT='1;URL=quran_cp.php?action=add' />";
}

}ELSEIF ($action=="delete"){
$id = intval($_GET['id']);
$query =  mysql_query("DELETE FROM telawat_cat WHERE id='$id'");
echo $LANGAUGE_CP[35];
echo "<META HTTP-EQUIV='Refresh' CONTENT='1;URL=quran_cp.php?action=add' />";

}ELSEIF ($action=="actxcat"){
$id = intval($_GET['id']);
$act = intval($_GET['act']);
if ($act == 0){
$query =  mysql_query("UPDATE telawat_cat SET active='$act' where id='$id'");
echo $LANGAUGE_CP[61];
echo "<META HTTP-EQUIV='Refresh' CONTENT='1;URL=quran_cp.php?action=add' />";
}ELSEif ($act == 1){
$query =  mysql_query("UPDATE telawat_cat SET active='$act' where id='$id'");
echo $LANGAUGE_CP[62];
echo "<META HTTP-EQUIV='Refresh' CONTENT='1;URL=quran_cp.php?action=add' />";
}else{
echo $LANGAUGE_CP[63];
echo "<META HTTP-EQUIV='Refresh' CONTENT='1;URL=quran_cp.php?action=add' />";
}












}ELSEIF ($action=="addsounds"){
$queryx = mysql_query("SELECT * FROM telawat_cat");
$xx = mysql_num_rows($queryx);
if($xx == 0){
echo '<a href="quran_cp.php?action=add">'.$LANGAUGE_CP[629].'</a>';
}else{

if(isset($_GET['num']) AND $_GET['num'] != 0){
$number = intval($_GET['num']);
}else{
$number = 5;
}

if(isset($_GET['str']) AND $_GET['str'] != 0){
$numstr = intval($_GET['str']);
}else{
$numstr = 1;
}
?>
<form name="vbform" method="GET" action="">
<input name="action" type="hidden" value="addsounds" />

<table class='xtable' width='100%' id='AutoNumber15'>
     <tr>
      <td width="100%" colspan="2" class='xtx' align="center"><?php echo $LANGAUGE_CP[396]; ?></td>
    </tr>

    <tr>
      <td width="30%" class='xtr'><?php echo $LANGAUGE_CP[397]; ?></td>
      <td width="70%" class='xtd'><input name="num" type="text" size=10 value="<?php echo $number; ?>" /></td>
    </tr>

    <tr>
      <td width="30%" class='xtr'><?php echo $LANGAUGE_CP[95]; ?></td>
      <td width="70%" class='xtd'>
<?php
echo "<select size='1' name='xcat'>";
$querys = mysql_query("SELECT * FROM telawat_cat order by id desc");
while($cats = mysql_fetch_array($querys))
{
$cats['name_cat'] = stripslashes($cats['name_cat']);
$cats['name_cat'] = htmlspecialchars($cats['name_cat']);

if($_GET['xcat'] == $cats[id]){
echo "<OPTION class='$cla' value='$cats[id]' selected='selected'>» ".$cats['name_cat']."</OPTION>";
}else{
echo "<OPTION class='$cla' value='$cats[id]'>» ".$cats['name_cat']."</OPTION>";
}
}
echo "</select>\n";
?>
      </td>
    </tr>

    <tr>
      <td width="30%" class='xtr'><?php echo $LANGAUGE_CP[398]; ?></td>
      <td width="70%" class='xtd'><input name="xfile" type="text" size=50 dir="ltr" value="<?php echo $_GET['xfile']; ?>" /> <?php echo $LANGAUGE_CP[399]; ?></td>
    </tr>

    <tr>
      <td width="30%" class='xtr'><?php echo $LANGAUGE_CP[401]; ?></td>
      <td width="70%" class='xtd'>
<?php
if($_GET['auto'] == 1){
echo "<select size='1' name='auto'>
  <option value='1' selected='selected'>".$LANGAUGE_CP[139]."</option>
  <option value='0'>".$LANGAUGE_CP[140]."</option>
</select>";
}else{
echo "<select size='1' name='auto'>
  <option value='1'>".$LANGAUGE_CP[139]."</option>
  <option value='0' selected='selected'>".$LANGAUGE_CP[140]."</option>
</select>";
}
?>
      </td>
    </tr>

    <tr>
      <td width="30%" class='xtr'><?php echo $LANGAUGE_CP[402]; ?></td>
      <td width="70%" class='xtd'><input name="str" type="text" size=10 value="<?php echo intval($_GET['str']); ?>" /></td>
    </tr>

    <tr>
      <td width="30%" class='xtr'><?php echo $LANGAUGE_CP[403]; ?></td>
      <td width="70%" class='xtd'>
<?php
if($_GET['z'] == 1){
echo "<select size='1' name='z'>
  <option value='1' selected='selected'>".$LANGAUGE_CP[139]."</option>
  <option value='0'>".$LANGAUGE_CP[140]."</option>
</select>";
}else{
echo "<select size='1' name='z'>
  <option value='1'>".$LANGAUGE_CP[139]."</option>
  <option value='0' selected='selected'>".$LANGAUGE_CP[140]."</option>
</select>";
}
?>
      </td>
    </tr>


<tr>
      <td width="100%" colspan="2" class='xtr' align="center"><input type="submit" value=" <?php echo $LANGAUGE_CP[33]; ?> " name="u" /></td>
    </tr>
  </table>

</form>




<form name="GGG" method="post" action="quran_cp.php?action=insertsound">

<table class='xtable' width='100%' id='AutoNumbedr15'>
     <tr>
      <td width="100%" class='xtt' colspan="2" align="center"><?php echo $LANGAUGE_CP[404]; ?></td>
    </tr>

<?php
for($i=$numstr;$i<$number;$i++){
echo "<tr>
      <td width='20%' class='xtr'>".$LANGAUGE_CP[405]."</td>
      <td width='80%' class='xtd'><select size='1' name='name[]'>";
for($loop=1;$loop<115;$loop++)
{
if($_GET['z']==1){
$numbercharurl = strlen($i);
if($numbercharurl==1){
$xxz = str_replace("*","00".$i,$_GET['xfile']);
}elseif($numbercharurl==2){
$xxz = str_replace("*","0".$i,$_GET['xfile']);
}elseif($numbercharurl==3){
$xxz = str_replace("*",$i,$_GET['xfile']);
}
}else{
$xxz = str_replace("*",$i,$_GET['xfile']);
}

if($_GET['auto']==1){
if($i==$loop){
echo "<OPTION value='$loop' selected='selected'>» $q[$loop]</OPTION>";
}else{
echo "<OPTION value='$loop'>» $q[$loop]</OPTION>";
}
}else{
echo "<OPTION value='$loop'>» $q[$loop]</OPTION>";
}
}
echo "</select></td>
    </tr>

     <tr>
      <td width='20%' class='xtr'>".$LANGAUGE_CP[406]."</td>
      <td width='80%' class='xtd'><input size='80' name='url[]' dir='ltr' value='".$xxz."' /></td>
    </tr>

    <tr>
      <td width='20%' class='xtr'>".$LANGAUGE_CP[95]."</td>
      <td width='80%' class='xtd'><select size='1' name='cat[]'>";
$query = mysql_query("SELECT * FROM telawat_cat order by id desc");
while($cat = mysql_fetch_array($query))
{
$cat['name_cat'] = stripslashes($cat['name_cat']);
$cat['name_cat'] = htmlspecialchars($cat['name_cat']);

if($_GET['xcat'] == $cat[id]){
echo "<OPTION value='$cat[id]' selected='selected'>» ".$cat['name_cat']."</OPTION>";
}else{
echo "<OPTION value='$cat[id]'>» ".$cat['name_cat']."</OPTION>";
}
}
echo "</select></td>
    </tr>";

echo '<tr>
<td width="100%" colspan="2" class="xtr" align="center">- - - - - - - -</td>
</tr>';

}
?>

<tr>
      <td width="100%" colspan="2" class='xtr' align="center"><input type="submit" value=" <?php echo $LANGAUGE_CP[18]; ?> " name="cmdAdd" /></td>
</tr>
  </table>

</form>


<?php
if(!isset($_GET['num']) AND !isset($_GET['xcat'])){
if($_GET["s"] == 1){
$hh = "checked='checked'";
}elseif($_GET["s"] == 0){
$hh = "";
}else{
$hh = "";
}

$page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]);
$page = ($page == 0 ? 1 : $page);
$perpage = 20;
$startpoint = ($page * $perpage) - $perpage;

$queryx = mysql_query("SELECT * FROM telawat order by id desc LIMIT $startpoint,$perpage");
$xx = mysql_num_rows($queryx);
if($xx == 0){
echo "";
}else{
$i = 0;
echo "<form name='xxx' action='quran_cp.php?action=op' method='post'>
<div id='quran'>
<table class='xtable' width='100%' id='AutoaNumber15'>
<tr>
<td width='100%' colspan='7' class='xtt' align='center'>".$LANGAUGE_CP[97]."</td>
</tr>
<tr>
      <td width='2%' align='center' class='xtr'>#</td>
      <td width='40%' align='center' class='xtr'>".$LANGAUGE_CP[407]."</td>
      <td width='30%' align='center' class='xtr'>".$LANGAUGE_CP[408]."</td>
      <td width='7%' align='center' class='xtr'>".$LANGAUGE_CP[106]."</td>
      <td width='7%' align='center' class='xtr'>".$LANGAUGE_CP[28]."</td>
      <td width='7%' align='center' class='xtr'>".$LANGAUGE_CP[26]."</td>
      <td width='7%' align='center' class='xtr'>".$LANGAUGE_CP[27]."</td>
</tr>";
while($p = mysql_fetch_array($queryx))
{
$i++;

$queryxc = mysql_query("SELECT * FROM telawat_cat where id='".$p['cat']."'");
$pc = mysql_fetch_array($queryxc);
$pc['name_cat'] = stripslashes($pc['name_cat']);
$pc['name_cat'] = htmlspecialchars($pc['name_cat']);

if($p['active'] == 1){
$im = "images/on.gif";
$li = "quran_cp.php?action=actx&id=$p[id]&act=0";
$te = $LANGAUGE_CP[72];
}else{
$im = "images/off.gif";
$li = "quran_cp.php?action=actx&id=$p[id]&act=1";
$te = $LANGAUGE_CP[73];
}

$d = date("j/n/Y",$p['date']);

echo "<tr>
      <td align='center' width='2%' class='xtr'><input id='qur".$p['id']."' ".$hh." type='checkbox' name='del[$i]' value='".$p['id']."' /></td>
      <td width='40%' class='xtd'><label for='qur".$p['id']."'>» ".$q[$p['name']]."</label></td>
      <td width='30%' class='xtd' align='center'>".$pc['name_cat']."</td>
      <td width='7%' class='xtd' align='center'>".$p['vis']."</td>
      <td width='7%' align='center' class='xtd'><a href='$li'><img border='0' src='$im' alt='$te ".$q[$p['name']]."' /></a></td>
      <td width='7%' align='center' class='xtd'><a href='quran_cp.php?action=editsound&id=$p[id]'><img border='0' src='images/edit.gif' alt='".$q[$p['name']]."' /></a></td>
      <td width='7%' align='center' class='xtd'><a href='quran_cp.php?action=deletesound&id=$p[id]'><img border='0' src='images/delete.gif' alt='".$q[$p['name']]."' /></a></td>
    </tr>";
}
echo "<tr>
<td colspan='7' align='center' class='xtr'><input name='activ' class='addsubmit' type='submit' value=' ".$LANGAUGE_CP[108]." ' /> <input class='addsubmit' name='noact' type='submit' value=' ".$LANGAUGE_CP[107]." ' /> <input class='addsubmit' name='edit' type='submit' value=' ".$LANGAUGE_CP[26]." ' /> <input name='delete' class='addsubmit' type='submit' id='delete' value=' ".$LANGAUGE_CP[27]." ' /><br />
<a href='quran_cp.php?action=addsounds&s=1#quran'>".$LANGAUGE_CP[109]."</a> - <a href='quran_cp.php?action=addsounds&s=0#quran'>".$LANGAUGE_CP[110]."</a></td>
</tr>
</table>
</div>
</form>";

$pagesnum = @ceil(mysql_num_rows(mysql_query("SELECT id FROM telawat")) / $perpage);
if($pagesnum > 1){
echo "<p align='center'>";
for ($i=1; $i<=$pagesnum; $i++) {
if ($i != $page) {
$z = "[<a href='quran_cp.php?action=addsounds&page=$i#quran'>$i</a>] ";
} else {
$z = "[<u>$i</u>]";
}
echo "$z";
}
echo "</p>";
}
}
}
}
}ELSEIF ($action=="insertsound"){
$number = count($_POST['name']);
echo "<table class='xtable' width='100%' id='AutoNumber15'>

<tr>
      <td class='xtt' align='center'>".$LANGAUGE_CP[409]."</td>
</tr>
<tr>
      <td class='xtd'>";
for($i=0;$i<$number;$i++){
$title = $_POST['name'][$i];
$url = addslashes($_POST['url'][$i]);
$url = trim($url);
$cat = $_POST['cat'][$i];

if(!empty($url)){
$query =  mysql_query ("INSERT INTO telawat (name,url,active,cat,date) VALUES ('$title','$url','1','$cat','".time()."')") or die ("error");
echo "<p>$q[$title] ....... ".$LANGAUGE_CP[111]."</p>";
}
}
echo "</td>
</tr>
</table>";
echo "<META HTTP-EQUIV='refresh' CONTENT='2; URL=quran_cp.php?action=addsounds' />";

}ELSEIF ($action=="editsound"){
$id = intval($_GET['id']);
$query = mysql_query("SELECT * FROM telawat where id='$id'");
$p = mysql_fetch_array($query);

$p['name'] = intval($p['name']);

$p['url'] = stripslashes($p['url']);
$p['url'] = htmlspecialchars($p['url']);

echo "<form name='vbform' method='POST' action='quran_cp.php?action=editsoundok'>
<input type='hidden' name='id' value='$p[id]' />

<table class='xtable' width='100%' id='AutoNumber15'>

<tr>
      <td width='100%' colspan='2' class='xtt' align='center'>".$LANGAUGE_CP[410]." ".$q[$p['name']]."</td>
</tr>

<tr>
<td width='20%' class='xtr'>".$LANGAUGE_CP[405]."</td>
<td width='80%' class='xtd'>";

echo "<select  size='1' name='name'>";
for($loop=1;$loop<115;$loop++)
{
if($loop == $p['name']){
echo "<OPTION value='$loop' selected='selected'>$q[$loop]</OPTION>";
}else{
echo "<OPTION value='$loop'>$q[$loop]</OPTION>";
}
}
echo "</select>";

echo "</td>
</tr>

<tr>
<td width='20%' class='xtr'>".$LANGAUGE_CP[406]."</td>
<td width='80%' class='xtd'><input dir='ltr' name='url' size='60' value='".$p['url']."' /></td>
</tr>


<tr>
<td width='20%' class='xtr'>".$LANGAUGE_CP[95]."</td>
<td width='80%' class='xtd'>
<select size='1' name='cat'>";

$sql = mysql_query ("SELECT * FROM telawat_cat order by id") or die ("error");
while($sub = mysql_fetch_array($sql))
{
if($sub['id'] ==  $p['cat']){
echo "<option value='$sub[id]' selected='selected'>$sub[name_cat]</option>";
}else{
echo "<option value='$sub[id]'>$sub[name_cat]</option>";
}

}
echo "</select>
</td>
</tr>

<tr>
<td width='100%' colspan='2' align='center' class='xtr'><input type='submit' value=' ".$LANGAUGE_CP[33]." ' name='B1' /></td>
</tr>

</table>
</form>";

}ELSEIF ($action=="editsoundok"){

$id    = intval($_POST['id']);
$name  = intval($_POST['name']);
$url   = addslashes($_POST['url']);
$cat   = intval($_POST['cat']);

if (empty($name)){
echo $LANGAUGE_CP[411];
}elseif (empty($url)){
echo $LANGAUGE_CP[412];
}else{
$query =  mysql_query("UPDATE telawat SET name='$name', url='$url', cat='$cat' where id='$id'");
echo $LANGAUGE_CP[34];
echo "<META HTTP-EQUIV='Refresh' CONTENT='1;URL=quran_cp.php?action=addsounds#quran' />";
}

}ELSEIF ($action=="deletesound"){
$id = intval($_GET['id']);
$query =  mysql_query("DELETE FROM telawat WHERE id='$id'");
echo $LANGAUGE_CP[35];
echo "<META HTTP-EQUIV='Refresh' CONTENT='1;URL=quran_cp.php?action=addsounds#quran' />";

}ELSEIF ($action=="op"){

if(isset($_POST['delete'])){
if(count($_POST['del']) > 0){
$del_id = join(',',$_POST['del']);
$sql = mysql_query("DELETE FROM telawat WHERE id IN($del_id)");
print $LANGAUGE_CP[35];
echo "<META HTTP-EQUIV='refresh' CONTENT='1; URL=quran_cp.php?action=addsounds#quran' />";
}else{
echo $LANGAUGE_CP[255];
}
}


if(isset($_POST['noact'])){
if(count($_POST['del']) > 0){
$del_id = join(',',$_POST['del']);
$sql = mysql_query("UPDATE telawat SET active='0' WHERE id IN($del_id)");
print $LANGAUGE_CP[61];
echo "<META HTTP-EQUIV='refresh' CONTENT='1; URL=quran_cp.php?action=addsounds#quran' />";
}else{
echo $LANGAUGE_CP[255];
}
}

if(isset($_POST['activ'])){
if(count($_POST['del']) > 0){
$del_id = join(',',$_POST['del']);
$sql = mysql_query("UPDATE telawat SET active='1' WHERE id IN($del_id)");
print $LANGAUGE_CP[62];
echo "<META HTTP-EQUIV='refresh' CONTENT='1; URL=quran_cp.php?action=addsounds#quran' />";
}else{
echo $LANGAUGE_CP[255];
}
}

if(isset($_POST['edit'])){

if(count($_POST['del']) > 0){
$c = count($_POST['del']);

$del_id = join(',',$_POST['del']);
$queryx = mysql_query("SELECT * FROM telawat where id IN($del_id) order by id desc");

echo "<form name='vbform' method='POST' action='quran_cp.php?action=editall'>
<table class='xtable' width='100%' id='AutoNumber15555'>

<tr>
      <td width='100%' colspan='2' class='xtt' align='center'>".$LANGAUGE_CP[32]."</td>
</tr>";
$ii = 0;
while($p = mysql_fetch_array($queryx))
{
++$ii;

$p['name'] = intval($p['name']);

$p['url'] = stripslashes($p['url']);
$p['url'] = htmlspecialchars($p['url']);

echo "<input type='hidden' name='id[]' value='".$p['id']."' />
<tr>
<td width='20%' class='xtr'>".$LANGAUGE_CP[405]."</td>
<td width='80%' class='xtd'><select  size='1' name='name[]'>";
for($loop=1;$loop<115;$loop++)
{
if($loop == $p['name']){
echo "<OPTION value='$loop' selected='selected'>» $q[$loop]</OPTION>";
}else{
echo "<OPTION value='$loop'>» $q[$loop]</OPTION>";
}

}
echo "</select>
</td>
</tr>

<tr>
<td width='20%' class='xtr'>".$LANGAUGE_CP[406]."</td>
<td width='80%' class='xtd'><input size='60' name='url[]' dir='ltr' value='".$p['url']."' />
</td>
</tr>

<tr>
<td width='20%' class='xtr'>".$LANGAUGE_CP[95]."</td>
<td width='80%' class='xtd'>
<select size='1' name='cat[]'>";
$sql = mysql_query ("SELECT * FROM telawat_cat") or die ("error");
while($sub = mysql_fetch_array($sql))
{
if($sub['id'] ==  $p['cat']){
echo "<option value='".$sub['id']."' selected='selected'>".$sub['name_cat']."</option>";
}else{
echo "<option value='".$sub['id']."'>".$sub['name_cat']."</option>";
}

}
echo "</select>
</td>
</tr>

<tr>
<td width='30%' class='xtr'>".$LANGAUGE_CP[117]."</td>
<td width='70%' class='xtd'>
<select size='1' name='active[]'>";
if($p['active'] == 1){
echo "<option value='1' selected='selected'>".$LANGAUGE_CP[108]."</option>";
echo "<option value='0'>".$LANGAUGE_CP[107]."</option>";
}else{
echo "<option value='1'>".$LANGAUGE_CP[108]."</option>";
echo "<option value='0' selected='selected'>".$LANGAUGE_CP[107]."</option>";
}
echo "</select>
</td>
</tr>";

if($ii != $c){
echo "<tr>
<td width='100%' colspan='2' align='center' class='xtr'>- - - - - - - -</td>
</tr>";
}

}

echo "<tr>
<td width='100%' colspan='2' align='center' class='xtr'><input class='addsubmit' type='submit' value=' ".$LANGAUGE_CP[33]." ' name='B1' /></td>
</tr>

</table>
</form>";

}else{
echo $LANGAUGE_CP[255];
}

}

}ELSEIF ($action=="editall"){

$number = count($_POST['id']);

for($i=0;$i<$number;$i++){
$id = $_POST['id'][$i];
$id = intval($id);

$title = $_POST['name'][$i];

$url = $_POST['url'][$i];
$url = addslashes($url);
$url = trim($url);

$cat = $_POST['cat'][$i];
$active = $_POST['active'][$i];

if(!empty($title) OR !empty($url)){
echo "$q[$title] . . . ".$LANGAUGE_CP[111]."<br />";
$query =  mysql_query ("UPDATE telawat SET name='$title',url='$url',cat='$cat',active='$active' where id='$id'");
}

}
echo "<META HTTP-EQUIV='refresh' CONTENT='2; URL=quran_cp.php?action=addsounds#quran' />";

}ELSEIF ($action=="setting"){
$sql = "SELECT * FROM opitions where id=1";
$result = mysql_query ($sql) or die ("Query failed");
$p_cats = mysql_fetch_array($result);

$p_cats['d1'] = stripslashes($p_cats['d1']);
$p_cats['d1'] = htmlspecialchars($p_cats['d1']);

$p_cats['k1'] = stripslashes($p_cats['k1']);
$p_cats['k1'] = htmlspecialchars($p_cats['k1']);

$td1 = "70%";
$td2 = "30%";

echo "<form method='POST' action='quran_cp.php?action=update'>

<table class='xtable' width='100%' id='AutoNumber15'>

<tr>
<td width='100%' colspan='2' class='xtt' align='center'>".$LANGAUGE_CP[413]."</td>
</tr>

<tr>
<td width='$td1' class='xtr'>".$LANGAUGE_CP[414]."</td>
<td width='$td2' class='xtd'><input name='telawat_catsloop' size='10' value='$p_cats[telawat_catsloop]' /></td>
</tr>

<tr>
<td width='$td1' class='xtr'>".$LANGAUGE_CP[415]."</td>
<td width='$td2' class='xtd'><input name='limit_telawat' size='10' value='$p_cats[limit_telawat]' /></td>
</tr>

<tr>
<td width='$td1' class='xtr'>".$LANGAUGE_CP[416]."</td>
<td width='$td2' class='xtd'>";
echo " <select size='1' name='folderquran'>";

if($p_cats['folderquran'] == ""){
$result = mysql_query ("SELECT * FROM pathstyle") or die ("Query failed");
while ($p_s=mysql_fetch_array($result))
{
$p_s['name'] = stripslashes($p_s['name']);
$p_s['name'] = htmlspecialchars($p_s['name']);

$p_s['pathfolder'] = stripslashes($p_s['pathfolder']);
$p_s['pathfolder'] = htmlspecialchars($p_s['pathfolder']);

if($p_s['pathfolder'] == $p_cats['folder']){
echo "<option value='".$p_s['pathfolder']."' selected='selected'>".$p_s['name']."</option>";
}else{
echo "<option value='".$p_s['pathfolder']."'>".$p_s['name']."</option>";
}
}

}else{

$result = mysql_query ("SELECT * FROM pathstyle") or die ("Query failed");
while ($p_s=mysql_fetch_array($result))
{
$p_s['name'] = stripslashes($p_s['name']);
$p_s['name'] = htmlspecialchars($p_s['name']);

$p_s['pathfolder'] = stripslashes($p_s['pathfolder']);
$p_s['pathfolder'] = htmlspecialchars($p_s['pathfolder']);

if($p_s['pathfolder'] == $p_cats['folderquran']){
echo "<option value='".$p_s['pathfolder']."' selected='selected'>".$p_s['name']."</option>";
}else{
echo "<option value='".$p_s['pathfolder']."'>".$p_s['name']."</option>";
}
}
}


echo "</select>";

echo "</td>
</tr>

<tr>
<td width='100%' colspan='2' class='xtd' align='center'>
".$LANGAUGE_CP[123]."
<textarea name='k1' rows='3' cols='70'>".$p_cats['k1']."</textarea><br /><br />
".$LANGAUGE_CP[124]."
<textarea name='d1' rows='3' cols='70'>".$p_cats['d1']."</textarea>
</td>
</tr>

<tr>
<td width='100%' colspan='2' align='center' class='xtr'><input type='submit' value=' ".$LANGAUGE_CP[33]." ' name='B1' /></td>
</tr>

</table>

</form>";
}ELSEIF ($action=="update"){
$telawat_catsloop     = $_POST['telawat_catsloop'];
$limit_telawat        = $_POST['limit_telawat'];
$folderquran =  $_POST['folderquran'];

$k1 = addslashes($_POST['k1']);
$d1 = addslashes($_POST['d1']);

$query1 =  mysql_query("UPDATE opitions SET
telawat_catsloop='$telawat_catsloop',
limit_telawat='$limit_telawat',folderquran='$folderquran',k1='$k1',d1='$d1' where id='1'");
echo $LANGAUGE_CP[34];
echo "<META HTTP-EQUIV='Refresh' CONTENT='1;URL=quran_cp.php?action=setting' />";
}
echo $f;
?>