<?php
include('header.php');
if($xg18 != 1){
echo $h;
echo $LANGAUGE_CP[626];
echo $f;
exit;
}
echo $h;

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

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

<table class='xtable' width='100%' id='AutoNu4mber15'>
     <tr>
      <td width="100%" colspan="2" class='xtx' align="center"><?php echo $LANGAUGE_CP[366]; ?></td>
    </tr>
    <tr>
      <td width="20%" class='xtr'><?php echo $LANGAUGE_CP[367]; ?></td>
      <td width="80%" class='xtd'><input size="60" name="name" /></td>
    </tr>
    <tr>
      <td width="20%" class='xtr'><?php echo $LANGAUGE_CP[92]; ?></td>
      <td width="80%" class='xtd'><input size="60" name="m1" /></td>
    </tr>
    <tr>
      <td width="20%" class='xtr'><?php echo $LANGAUGE_CP[91]; ?></td>
      <td width="80%" class='xtd'><input size="60" name="m2" /></td>
    </tr>

    <tr>
      <td width="20%" class='xtr'><?php echo $LANGAUGE_CP[368]; ?></td>
      <td width="80%" class='xtd'><input size="60" name="url" /> <select size="1" name="urlactive">
  <option value="0"><?php echo $LANGAUGE_CP[140]; ?></option>
  <option value="1"><?php echo $LANGAUGE_CP[139]; ?></option>
</select></td>
    </tr>

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

    <tr>
      <td width="20%" class='xtr'><?php echo $LANGAUGE_CP[369]; ?></td>
      <td width="80%" class='xtd'><select size="1" name="target">
  <option value="0"><?php echo $LANGAUGE_CP[370]; ?></option>
  <option value="1"><?php echo $LANGAUGE_CP[371]; ?></option>
</select></td>
    </tr>

    <tr>
      <td width="20%" class='xtr'><?php echo $LANGAUGE_CP[372]; ?></td>
      <td width="80%" class='xtd'><select size="1" name="addmenu">
  <option value="1"><?php echo $LANGAUGE_CP[139]; ?></option>
  <option value="0" selected="selected"><?php echo $LANGAUGE_CP[140]; ?></option>
</select></td>
    </tr>

    <tr>
      <td width="100%" class='xtd' colspan="2" align="center"><?php echo $LANGAUGE_CP[373]; ?><textarea id="textarea1" name="threads" rows="8" cols="60"></textarea>

</td>
    </tr>

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

</form>

<?php
$queryx = mysql_query("SELECT id,name,vis,active,urlactive,target,addmenu,url_trteeb FROM pages order by id desc");
$xx = mysql_num_rows($queryx);
if($xx == 0){
echo "";
}else{

echo "<table class='xtable' width='100%' id='AutoNu4mber15'>
<tr>
<td width='100%' colspan='8' class='xtt' align='center'>".$LANGAUGE_CP[97]."</td>
</tr>
<tr>
      <td width='51%' align='center' class='xtr'>".$LANGAUGE_CP[374]."</td>
      <td width='7%' align='center' class='xtr'>".$LANGAUGE_CP[375]."</td>
      <td width='7%' align='center' class='xtr'>".$LANGAUGE_CP[376]."</td>
      <td width='7%' align='center' class='xtr'>".$LANGAUGE_CP[221]."</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']);

if($p['target']==1){
$target = $LANGAUGE_CP[371];
}else{
$target = $LANGAUGE_CP[370];
}

$turl="page.php?id=".$p['id']."";

if($p['urlactive']==1){
$tau = $LANGAUGE_CP[375];
}else{
$tau = $LANGAUGE_CP[377];
}

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

echo "<tr>
      <td width='51%' class='xtd'>» <a target='_blank' href='../page.php?id=".$p['id']."'>".$p['name']."</a></td>
      <td width='7%' align='center' class='xtd'>".$tau."</td>
      <td width='7%' align='center' class='xtd'>".$target."</td>
      <td width='7%' align='center' class='xtd'>".$p['url_trteeb']."</td>
      <td width='7%' align='center' class='xtd'>".$p['vis']."</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='page_cp.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='page_cp.php?action=delete&id=$p[id]'><img border='0' src='images/delete.gif' alt='".$p['name']."' /></a></td>
    </tr>";
}
echo "</table>";
}
}ELSEIF ($action=="insert"){

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

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

$m1 = addslashes($_POST['m1']);
$m2 = addslashes($_POST['m2']);
$addmenu = addslashes($_POST['addmenu']);
$url = addslashes($_POST['url']);
$urlactive = addslashes($_POST['urlactive']);
$url_trteeb = addslashes($_POST['url_trteeb']);
$target = addslashes($_POST['target']);

if($m1==""){
$xm1 = $name;
}else{
$xm1 = $m1;
}

if($m2==""){
$m2x = str_replace(" ",",",$name);
$xm2 = $m2x;
}else{
$xm2 = $m2;
}

if (empty($name)){
echo $LANGAUGE_CP[378];
}else{
$query =  mysql_query ("INSERT INTO pages (name,threads,m1,m2,addmenu,url,urlactive,url_trteeb,target) VALUES ('$name','$threads','$xm1','$xm2','$addmenu','$url','$urlactive','$url_trteeb','$target')") or die ("error");
echo $LANGAUGE_CP[21];
echo "<META HTTP-EQUIV='refresh' CONTENT='1; URL=page_cp.php?action=add' />";
}

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



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

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

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

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

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

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

if($p['addmenu']==1){
$ad = '<select size="1" name="addmenu">
  <option value="1" selected="selected">'.$LANGAUGE_CP[139].'</option>
  <option value="0">'.$LANGAUGE_CP[140].'</option>
</select>';
}else{
$ad = '<select size="1" name="addmenu">
  <option value="1">'.$LANGAUGE_CP[139].'</option>
  <option value="0" selected="selected">'.$LANGAUGE_CP[140].'</option>
</select>';
}

if($p['urlactive']==1){
$adu = '<select size="1" name="urlactive">
  <option value="1" selected="selected">'.$LANGAUGE_CP[139].'</option>
  <option value="0">'.$LANGAUGE_CP[140].'</option>
</select>';
}else{
$adu = '<select size="1" name="urlactive">
  <option value="1">'.$LANGAUGE_CP[139].'</option>
  <option value="0" selected="selected">'.$LANGAUGE_CP[140].'</option>
</select>';
}

if($p['target']==1){
$aduw = '<select size="1" name="target">
  <option value="1" selected="selected">'.$LANGAUGE_CP[371].'</option>
  <option value="0">'.$LANGAUGE_CP[370].'</option>
</select>';
}else{
$aduw = '<select size="1" name="target">
  <option value="1">'.$LANGAUGE_CP[371].'</option>
  <option value="0" selected="selected">'.$LANGAUGE_CP[370].'</option>
</select>';
}

echo "<form name='vbform' method='POST' action='page_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='20%' class='xtr'>".$LANGAUGE_CP[367]."</td>
<td width='80%' class='xtd'><input name='name' size='60' value='".$p['name']."' /></td>
</tr>

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

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

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

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

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

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


<tr>
<td width='100%' class='xtd' colspan='2' align='center'>".$LANGAUGE_CP[373]."<textarea id='textarea1' name='threads' rows='5' cols='90'>".$p['threads']."</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=="editok"){

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

$m1 = addslashes($_POST['m1']);
$m2 = addslashes($_POST['m2']);
$addmenu = addslashes($_POST['addmenu']);
$url = addslashes($_POST['url']);
$urlactive = addslashes($_POST['urlactive']);
$url_trteeb = addslashes($_POST['url_trteeb']);
$target = addslashes($_POST['target']);

if($m1==""){
$xm1 = $name;
}else{
$xm1 = $m1;
}

if($m2==""){
$m2x = str_replace(" ",",",$name);
$xm2 = $m2x;
}else{
$xm2 = $m2;
}

if (empty($name)){
echo $LANGAUGE_CP[373];
}else{
$query =  mysql_query("UPDATE pages SET name='$name', threads='$threads',m1='$xm1',m2='$xm2',addmenu='$addmenu',url='$url',urlactive='$urlactive',url_trteeb='$url_trteeb',target='$target' where id='$id'");
echo $LANGAUGE_CP[34];
echo "<META HTTP-EQUIV='Refresh' CONTENT='1;URL=page_cp.php?action=add' />";
}

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