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

$folderss = "upload";
$uploadDir = "../upload/";

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

IF ($action=="add"){
?>
<div id="x1">
<form name="vbform1" method="post" action="video.php?action=insert" enctype="multipart/form-data">

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

    <tr>
      <td width="20%" class='xtr'><?php echo $LANGAUGE_CP[156]; ?></td>
      <td width="80%" class='xtd'><input size="50" name="name" /></td>
    </tr>

    <tr>
      <td width="20%" class='xtr'><?php echo $LANGAUGE_CP[88]; ?></td>
      <td width="80%" class='xtd'><input type="file" size="50" name="image" /></td>
    </tr>

    <tr>
      <td width="20%" class='xtr'><?php echo $LANGAUGE_CP[94]; ?></td>
      <td width="80%" class='xtd'><input size="10" name="order_cat" /></td>
    </tr>

     <tr>
      <td width="100%" colspan="2" class='xtr' align="center"><input class='buttonx' type="submit" value=" <?php echo $LANGAUGE_CP[18]; ?> " name="cmdAdd" /></td>
    </tr>
  </table>
</form>
</div>
<?php
$queryx = mysql_query("SELECT * FROM videocategory order by id desc");
$xx = mysql_num_rows($queryx);
if($xx == 0){
echo "";
}else{

echo "<form name='xxx1' action='video.php?action=opx' method='post'>

<table class='xtable' width='100%' id='AutoNumbe5r15'>
<tr>
      <td width='100%' colspan='5' align='center' class='xtx'>".$LANGAUGE_CP[97]."</td>
</tr>

  <tr>
      <td width='72%' align='center' class='xtr'>".$LANGAUGE_CP[158]."</td>
      <td width='7%' align='center' class='xtr'>".$LANGAUGE_CP[152]."</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'] = stripslashes($p['name']);
$p['name'] = htmlspecialchars($p['name']);

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

$su = "» ".$p['name']."";

echo "<input type='hidden' name='idx[]' value='".$p['id']."' />
<tr>
      <td width='72%' class='xtd'>".$su."</td>
      <td width='7%' align='center' class='xtd'><input style='text-align:center;' size='2' name='order[]' value='".$p['order_cat']."' /></td>
      <td width='7%' align='center' class='xtd'><a href='$li'><img border='0' src='$im' alt='$te ".$p['name']."' /></a></td>
      <td width='7%' align='center' class='xtd'><a href='video.php?action=edit&id=$p[id]'><img border='0' src='images/edit.gif' alt='".$p['name']."' /></a></td>
      <td width='7%' align='center' class='xtd'><a href='video.php?action=delete&id=$p[id]'><img border='0' src='images/delete.gif' alt='".$p['name']."' /></a></td>
    </tr>";
}
echo "<tr>
<td colspan='5' align='center' class='xtr'><input class='buttonx' name='activ' type='submit' id='activ' value=' ".$LANGAUGE_CP[152]." ' />
</td>
</tr>
</table></form>";
}

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

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

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

$fileName = $_FILES['image']['name'];
$tmpName  = $_FILES['image']['tmp_name'];
$fileSize = $_FILES['image']['size'];
$fileType = $_FILES['image']['type'];

if (empty($name)){
echo $LANGAUGE_CP[159];
}else{
if(!empty($fileName)){
$time = time();
$ext = substr(strrchr($fileName, "."), 1);
$randName = md5(rand() * time());
$randName = substr($randName, 0, 5);
$filePath = $uploadDir . $time . '-' . $randName . '.' . $ext;
$nameindatabase = $time . '-' . $randName . '.' . $ext;
$pathimages = "$folderss/$nameindatabase";

$result = move_uploaded_file($tmpName, $filePath);
if (!$result) {
echo $LANGAUGE_CP[562];
}else{
echo $LANGAUGE_CP[563];
}
}

$query =  mysql_query ("INSERT INTO videocategory (name,active,order_cat,image) VALUES ('$name',1,'$order_cat','$pathimages')") or die ("error");
echo $LANGAUGE_CP[21];
echo "<META HTTP-EQUIV='refresh' CONTENT='1; URL=video.php?action=add' />";
}

}ELSEIF ($action=="opx"){
if(isset($_POST['activ'])){

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

for($i=0;$i<$number;$i++){
$id = $_POST['idx'][$i];
$orders = $_POST['order'][$i];
$sqld = mysql_query("UPDATE videocategory SET order_cat='".$orders."' WHERE id=$id");
echo "<META HTTP-EQUIV='refresh' CONTENT='1; URL=video.php' />";
}

}else{
echo $LANGAUGE_CP[255];
}

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

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

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

if($p['image']==""){
$irm = "";
}else{
$irm = '<br /><a target="_blank" href="../'.$p['image'].'">'.$LANGAUGE_CP[564].'</a>';
}

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

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

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

<tr>
<td width='20%' class='xtr'>".$LANGAUGE_CP[156]."</td>
<td width='80%' class='xtd'><input name='name' size='50' value='".$p['name']."' /></td>
</tr>

<tr>
<td width='20%' class='xtr'>".$LANGAUGE_CP[88]."</td>
<td width='80%' class='xtd'><input type='file' name='image' size='50' /> <input name='up' type='checkbox' value='yes' /> ".$LANGAUGE_CP[566]." ".$irm."</td>
</tr>

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

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

</table>
</form>";

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

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

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

$fileName = $_FILES['image']['name'];
$tmpName  = $_FILES['image']['tmp_name'];
$fileSize = $_FILES['image']['size'];
$fileType = $_FILES['image']['type'];

if (empty($name)){
echo $LANGAUGE_CP[159];
}else{
if($_POST['up']=="yes"){
if(!empty($fileName)){
$time = time();
$ext = substr(strrchr($fileName, "."), 1);
$randName = md5(rand() * time());
$randName = substr($randName, 0, 5);
$filePath = $uploadDir . $time . '-' . $randName . '.' . $ext;
$nameindatabase = $time . '-' . $randName . '.' . $ext;
$pathimages = "$folderss/$nameindatabase";

$result = move_uploaded_file($tmpName, $filePath);
if (!$result) {
echo $LANGAUGE_CP[562];
}else{
echo $LANGAUGE_CP[563];
}
}
$qqq = ",image='$pathimages'";
}

$query =  mysql_query("UPDATE videocategory SET name='$name', order_cat='$order_cat' ".$qqq." where id='$id'");
echo $LANGAUGE_CP[34];
echo "<META HTTP-EQUIV='Refresh' CONTENT='1;URL=video.php?action=add' />";
}

}ELSEIF ($action=="delete"){
$id = intval($_GET['id']);

if(isset($_POST['ok']) && $_POST['ok']=="yes"){
$idx = intval($_POST['idx']);
$query =  mysql_query("DELETE FROM videocategory where id='$idx'");
if($_POST['dxx']==1){
$query1 =  mysql_query("DELETE FROM videocontent where cat='$idx'");
}

echo $LANGAUGE_CP[35];
echo "<META HTTP-EQUIV='Refresh' CONTENT='1;URL=video.php?action=add' />";
}else{
echo "<div align='center'>
<form name='form' method='POST' action='video.php?action=delete'>
<input type='hidden' name='idx' value='".$id."' />
<input type='hidden' name='ok' value='yes' />
<input type='submit' value=' ".$LANGAUGE_CP[85]." ' name='B1' /><br /><br />
<input name='dxx' type='checkbox' value='1' id='cd' /> <label for='cd'>".$LANGAUGE_CP[567]."</label>
</form></div>";
}

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


}ELSEIF ($action=="content"){
$queryx = mysql_query("SELECT * FROM videocategory");
$xx = mysql_num_rows($queryx);
if($xx == 0){
echo '<a href="video.php?action=add">'.$LANGAUGE_CP[629].'</a>';
}else{
?>
<form name="vbform" method="post" action="video.php?action=insertc" enctype="multipart/form-data">

<table class='xtable' width="100%" id="AutoNumber1">

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

    <tr>
      <td width="20%" class='xtr'><?php echo $LANGAUGE_CP[103]; ?></td>
      <td width="80%" class='xtd'><input size="60" name="name" /></td>
    </tr>

    <tr>
      <td width="20%" class='xtr'><?php echo $LANGAUGE_CP[569]; ?></td>
      <td width="80%" class='xtd'><input dir="ltr" size="60" name="url" /></td>
    </tr>

    <tr>
      <td width="100%" colspan="2" class='xtr' align="center">
<input id="ccc" name="selectcode" type="checkbox" value="1" /> <label for="ccc"><?php echo $LANGAUGE_CP[570]; ?></label><br /><br />
<textarea dir="ltr" name="textcode" rows="5" cols="131"></textarea>
      </td>
    </tr>

    <tr>
      <td width="20%" class='xtr'><?php echo $LANGAUGE_CP[95]; ?></td>
      <td width="80%" class='xtd'>
      <select  size='1' name='cat'>
<?php
$sql =  mysql_query ("SELECT * FROM videocategory order by id desc") or die ("error");
while($cat=mysql_fetch_array($sql))
{
$cat['name'] = stripslashes($cat['name']);
$cat['name'] = htmlspecialchars($cat['name']);

$tt = "» ".$cat['name']."";
echo "<option ".$ss." value='".$cat['id']."'>".$tt."</option>";
}
?>
</select>
</td>
    </tr>

     <tr>
      <td width="100%" colspan="2" class='xtr' align="center"><input class='buttonx' type="submit" value=" <?php echo $LANGAUGE_CP[18]; ?> " name="cmdAdd" /></td>
    </tr>
  </table>
</form>
<?php
$page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]);
$page = ($page == 0 ? 1 : $page);
$perpage = 30;
$startpoint = ($page * $perpage) - $perpage;

$queryx = mysql_query("SELECT id,name,date,visitor,cat,active FROM videocontent order by id desc LIMIT $startpoint,$perpage");
$xx = mysql_num_rows($queryx);
if($xx == 0){
echo "";
}else{

echo "<div id='x3'>
<table class='xtable' width='100%' id='AutoNumber5515'>

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

<tr>
      <td width='30%' align='center' class='xtr'>".$LANGAUGE_CP[105]."</td>
      <td width='27%' align='center' class='xtr'>".$LANGAUGE_CP[237]."</td>
      <td width='15%' align='center' class='xtr'>".$LANGAUGE_CP[57]."</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))
{
$p['name'] = stripslashes($p['name']);
$p['name'] = htmlspecialchars($p['name']);

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

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

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

echo "<tr>
      <td width='30%' class='xtd'>» ".$p['name']."</td>
      <td width='27%' align='center' class='xtd'>".$pc['name']."</td>
      <td width='15%' align='center' class='xtd'>".$d."</td>
      <td width='7%' align='center' class='xtd'>".$p['visitor']."</td>
      <td width='7%' align='center' class='xtd'><a href='$li'><img border='0' src='$im' alt='$te ".$p['name']."' /></a></td>
      <td width='7%' align='center' class='xtd'><a href='video.php?action=editc&id=$p[id]'><img border='0' src='images/edit.gif' alt='".$p['name']."' /></a></td>
      <td width='7%' align='center' class='xtd'><a href='video.php?action=deletec&id=$p[id]'><img border='0' src='images/delete.gif' alt='".$p['name']."' /></a></td>
    </tr>";
}
echo "</table></div>";

$pagesnum = @ceil(mysql_num_rows(mysql_query("SELECT id FROM videocontent")) / $perpage);
if($pagesnum > 1){
echo "<br />
<p align='center'>";
for ($i=1; $i<=$pagesnum; $i++) {
if ($i != $page) {
$z = "[<a href='video.php?action=content&page=$i&type=content'>$i</a>] ";
} else {
$z = "[<u>$i</u>]";
}
echo "$z";
}
echo "</p>";
}
}
}

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

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

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

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

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

if($_POST['selectcode']==1){
$selectcode = 1;
}else{
$selectcode = 0;
}

if (empty($name)){
echo $LANGAUGE_CP[571];
}else{
$query = mysql_query ("INSERT INTO videocontent (name,cat,url,active,textcode,date,selectcode) VALUES ('$name','$cat','$url',1,'$textcode','".time()."','$selectcode')") or die ("error");
echo $LANGAUGE_CP[21];
echo "<META HTTP-EQUIV='refresh' CONTENT='1; URL=video.php?action=content' />";
}



}ELSEIF ($action=="deletec"){
$id = intval($_GET['id']);

if(isset($_POST['ok']) && $_POST['ok']=="yes"){
$idx = intval($_POST['idx']);
$query =  mysql_query("DELETE FROM videocontent where id='$idx'");
echo $LANGAUGE_CP[35];
echo "<META HTTP-EQUIV='Refresh' CONTENT='1;URL=video.php?action=content&type=content#x3' />";
}else{
echo "<div align='center'>
<form name='form' method='POST' action='video.php?action=deletec'>
<input type='hidden' name='idx' value='".$id."' />
<input type='hidden' name='ok' value='yes' />
<input type='submit' value=' ".$LANGAUGE_CP[85]." ' name='B1' />
</form></div>";
}

}ELSEIF ($action=="actxc"){
$id = intval($_GET['id']);
$act = intval($_GET['act']);
if ($act == 0){
$query =  mysql_query("UPDATE videocontent SET active='$act' where id='$id'");
echo $LANGAUGE_CP[61];
echo "<META HTTP-EQUIV='Refresh' CONTENT='1;URL=video.php?action=content&type=content#x3' />";
}elseif ($act == 1){
$query =  mysql_query("UPDATE videocontent SET active='$act' where id='$id'");
echo $LANGAUGE_CP[62];
echo "<META HTTP-EQUIV='Refresh' CONTENT='1;URL=video.php?action=content&type=content#x3' />";
}else{
echo $LANGAUGE_CP[63];
echo "<META HTTP-EQUIV='Refresh' CONTENT='1;URL=video.php?action=content&type=content#x3' />";
}

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

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

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

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

if($p['selectcode']==1){
$chtt = '<input id="ccc" name="selectcode" type="checkbox" value="1" checked="checked" /> <label for="ccc">'.$LANGAUGE_CP[570].'</label><br /><br />';
}else{
$chtt = '<input id="ccc" name="selectcode" type="checkbox" value="1" /> <label for="ccc">'.$LANGAUGE_CP[570].'</label><br /><br />';
}
?>
<form name="vbform" method="post" action="video.php?action=updatec" enctype="multipart/form-data">
<input name='id' type='hidden' value='<?php echo $id; ?>' />
<table class='xtable' width="100%" id="AutojNumber1">

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

    <tr>
      <td width="20%" class='xtr'><?php echo $LANGAUGE_CP[103]; ?></td>
      <td width="80%" class='xtd'><input type="text" size="60" name="name" value="<?php echo $p['name']; ?>" /></td>
    </tr>

    <tr>
      <td width="20%" class='xtr'><?php echo $LANGAUGE_CP[569]; ?></td>
      <td width="80%" class='xtd'><input dir="ltr" type="text" size="60" name="url" value="<?php echo $p['url']; ?>" /></td>
    </tr>

    <tr>
      <td width="100%" colspan="2" class='xtr' align="center">
<?php
echo $chtt;
?>
<textarea dir="ltr" name="textcode" rows="5" cols="131"><?php echo $p['textcode']; ?></textarea>
      </td>
    </tr>

    <tr>
      <td width="20%" class='xtr'><?php echo $LANGAUGE_CP[95]; ?></td>
      <td width="80%" class='xtd'>
      <select  size='1' name='cat'>
<?php
$sql =  mysql_query ("SELECT * FROM videocategory order by id desc") or die ("error");
while($cat=mysql_fetch_array($sql))
{
$cat['name'] = stripslashes($cat['name']);
$cat['name'] = htmlspecialchars($cat['name']);


$tt = "» ".$cat['name']."";


if($cat['id'] == $p['cat']){
echo "<option value='".$cat['id']."' selected='selected'>".$tt."</option>";
}else{
echo "<option value='".$cat['id']."'>".$tt."</option>";
}


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

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

$id = intval($_POST['id']);

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

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

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

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

if($_POST['selectcode']==1){
$selectcode = 1;
}else{
$selectcode = 0;
}

if (empty($name)){
echo $LANGAUGE_CP[571];
}else{
$query =  mysql_query("UPDATE videocontent SET name='$name', cat='$cat', textcode='$textcode', selectcode='$selectcode', url='$url' where id='$id'");
echo $LANGAUGE_CP[34];
echo "<META HTTP-EQUIV='refresh' CONTENT='1; URL=video.php?action=content#x3' />";
}

}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['d14'] = stripslashes($p_cats['d14']);
$p_cats['d14'] = htmlspecialchars($p_cats['d14']);

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

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

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

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

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

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

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

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

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

if($p_cats['foldervideo'] == ""){
$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['foldervideo']){
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='k14' rows='3' cols='70'>".$p_cats['k14']."</textarea><br /><br />
".$LANGAUGE_CP[124]."
<textarea name='d14' rows='3' cols='70'>".$p_cats['d14']."</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"){
$video_catsloop     = $_POST['video_catsloop'];
$limitmenu_video        = $_POST['limitmenu_video'];
$limit_video        = $_POST['limit_video'];
$foldervideo =  $_POST['foldervideo'];

$k14 = addslashes($_POST['k14']);
$d14 = addslashes($_POST['d14']);

$query1 =  mysql_query("UPDATE opitions SET
video_catsloop='$video_catsloop',
limitmenu_video='$limitmenu_video',limit_video='$limit_video',foldervideo='$foldervideo',k14='$k14',d14='$d14' where id='1'");
echo $LANGAUGE_CP[34];
echo "<META HTTP-EQUIV='Refresh' CONTENT='1;URL=video.php?action=setting' />";
}

echo $f;
?>