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

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

IF ($action=="add"){
?>
<div id="x1">
<form name="vbform1" method="post" action="album.php?action=insert">

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

    <tr>
      <td width="40%" align="center" class='xtr'><?php echo $LANGAUGE_CP[66]; ?></td>
      <td width="30%" align="center" class='xtr'><?php echo $LANGAUGE_CP[67]; ?></td>
      <td width="15%" align="center" class='xtr'><?php echo $LANGAUGE_CP[68]; ?></td>
      <td width="15%" align="center" class='xtr'><?php echo $LANGAUGE_CP[69]; ?></td>
    </tr>

    <tr>
      <td width="40%" align="center" class='xtd'><input size="40" name="name" /></td>
      <td width="30%" align="center" class='xtd'><input dir="ltr" size="30" name="pathalbum" /></td>
      <td width="15%" align="center" class='xtd'><input size="5" name="widthalbum" /></td>
      <td width="15%" align="center" class='xtd'><input size="5" name="heightalbum" /></td>
    </tr>

     <tr>
      <td width="100%" colspan="4" 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 swfobject order by id desc");
$xx = mysql_num_rows($queryx);
if($xx == 0){
echo "";
}else{

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

  <tr>
      <td width='30%' align='center' class='xtr'>".$LANGAUGE_CP[66]."</td>
      <td width='19%' align='center' class='xtr'>".$LANGAUGE_CP[67]."</td>
      <td width='15%' align='center' class='xtr'>".$LANGAUGE_CP[68]."</td>
      <td width='15%' align='center' class='xtr'>".$LANGAUGE_CP[69]."</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']);

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

if (file_exists("../album/".$p['pathalbum']."")) {
$alerts = "album/".$p['pathalbum'];
}else{
$alerts = "album/".$p['pathalbum']." ".$LANGAUGE_CP[71]."";
}

if($p['active'] == 1){
$im = "images/on.gif";
$li = "album.php?action=actx&id=$p[id]&act=0";
$te = $LANGAUGE_CP[72];
}else{
$im = "images/off.gif";
$li = "album.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='30%' class='xtd'>".$su."</td>
      <td width='19%' align='center' class='xtd'>".$alerts."</td>
      <td width='15%' align='center' class='xtd'>".$p['widthalbum']."</td>
      <td width='15%' align='center' class='xtd'>".$p['heightalbum']."</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='album.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='album.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']);
$name = trim($name);

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

$widthalbum = intval($_POST['widthalbum']);
$heightalbum = intval($_POST['heightalbum']);


if (empty($name)){
$alert = $LANGAUGE_CP[74];
$che = "no";
}

if (empty($pathalbum)){
$alert .= $LANGAUGE_CP[75];
$che = "no";
}

if (empty($widthalbum)){
$alert .= $LANGAUGE_CP[76];
$che = "no";
}

if (empty($heightalbum)){
$alert .= $LANGAUGE_CP[77];
$che = "no";
}


if (!file_exists("../album/".$pathalbum."")) {
if(!is_dir($pathalbum) && !@mkdir("../album/".$pathalbum, 0777)) {
$alert .= $LANGAUGE_CP[78];
$che = "no";
}
}


if($che != "no"){
$query =  mysql_query ("INSERT INTO swfobject (name,active,pathalbum,widthalbum,heightalbum,date) VALUES ('$name',1,'$pathalbum','$widthalbum','$heightalbum','".time()."')") or die ("إستعلام خاطيء");
echo "<p align='center'>".$LANGAUGE_CP[79]." ".$pathalbum."<br />".$LANGAUGE_CP[80]."</p>";
echo "<META HTTP-EQUIV='refresh' CONTENT='3; URL=album.php?action=add' />";
}else{
echo $alert.$LANGAUGE_CP[81];
}

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

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

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

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

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

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

<tr>
<td width='40%' class='xtr' align='center'>".$LANGAUGE_CP[66]."</td>
<td width='30%' class='xtr' align='center'>".$LANGAUGE_CP[67]."</td>
<td width='15%' class='xtr' align='center'>".$LANGAUGE_CP[68]."</td>
<td width='15%' class='xtr' align='center'>".$LANGAUGE_CP[69]."</td>
</tr>

<tr>
<td width='40%' class='xtd' align='center'><input name='name' size='40' value='".$p['name']."' /></td>
<td width='30%' class='xtd' align='center'><input name='pathalbum' size='30' value='".$p['pathalbum']."' /></td>
<td width='15%' class='xtd' align='center'><input name='widthalbum' size='5' value='".$p['widthalbum']."' /></td>
<td width='15%' class='xtd' align='center'><input name='heightalbum' size='5' value='".$p['heightalbum']."' /></td>
</tr>

<tr>
<td width='100%' colspan='4' 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);

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

$widthalbum = intval($_POST['widthalbum']);
$heightalbum = intval($_POST['heightalbum']);

if (empty($name)){
$alert = $LANGAUGE_CP[74];
$che = "no";
}

if (empty($pathalbum)){
$alert .= $LANGAUGE_CP[75];
$che = "no";
}

if (empty($widthalbum)){
$alert .= $LANGAUGE_CP[76];
$che = "no";
}

if (empty($heightalbum)){
$alert .= $LANGAUGE_CP[77];
$che = "no";
}

if($_POST['xfo']==$pathalbum){
$xxxq = "";
}else{
if (!file_exists("../album/".$pathalbum."")) {
if(!is_dir($pathalbum) && !@mkdir("../album/".$pathalbum, 0777)) {
$alert .= $LANGAUGE_CP[78];
$che = "no";
}
}
$xxxq = "".$LANGAUGE_CP[83]." ".$pathalbum."<br />".$LANGAUGE_CP[80]."";
}

if($che != "no"){
$query =  mysql_query("UPDATE swfobject SET name='$name', pathalbum='$pathalbum', widthalbum='$widthalbum', heightalbum='$heightalbum' where id='$id'");
echo "<p align='center'>".$LANGAUGE_CP[84]." ".$xxxq."</p>";
echo "<META HTTP-EQUIV='refresh' CONTENT='3; URL=album.php?action=add' />";
}else{
echo $alert.$LANGAUGE_CP[81];
}


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

if(isset($_POST['ok']) && $_POST['ok']=="yes"){
$idx = intval($_POST['idx']);
$query =  mysql_query("DELETE FROM swfobject where id='$idx'");
echo $LANGAUGE_CP[35];
echo "<META HTTP-EQUIV='Refresh' CONTENT='1;URL=album.php?action=add' />";
}else{
echo "<div align='center'>
<form name='form' method='POST' action='album.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 />
</form></div>";
}

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

}

echo $f;
?>