<?

  include_once '../../config.inc.php';
  if (!include '../autorization.php')
  {
    echo 'Access denied!';
    exit ();
  }

  if (!($result_proper = mysql_query ('select * from properties')))
  {
    exit ('<b>Error:</b>' . mysql_error ());
    ;
  }

  $proper = mysql_fetch_array ($result_proper);
  include '../lang/' . $proper['admin_language'];
  echo '
<HTML><BODY STYLE="color: Navy;"><LINK HREF="../style.css" REL="stylesheet" TYPE="text/css"><TABLE WIDTH="600" BORDER=0 CELLSPACING=0 CELLPADDING=1><TR><TD style="background-color:#505090;"><TABLE WIDTH="100%" BORDER=0 CELLSPACING=0 CELLPADDING=5 BGCOLOR="#EFEFF8">
<TR><TD VALIGN=top BGCOLOR="#BFBFDF" STYLE="border-bottom: 1px solid #505090;"><FONT COLOR="navy"><B>';
  echo $admin_Add_new_banner;
  echo '</B></FONT></TD></TR><TR><TD VALIGN=top>

';
  echo '<S';
  echo 'CRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
function confirmSubmit(record) 
{
if (confirm("Are you sure you wish to delete user \\"" + record + "\\"?"))
	return true ;
else
	return false ;
}
//-->
</SCRIPT>




<FORM ACTION="';
  echo $php_self;
  echo '" METHOD="post" ENCTYPE="multipart/form-data">

';
  echo $admin_Banner_Name;
  echo '<BR>	
<INPUT TYPE="text" NAME="name" SIZE="50"><BR><BR>

';
  echo $admin_table4[0];
  echo ':
';
  echo '<S';
  echo 'ELECT NAME="groupID">
';
  if (!($result = mysql_query ('SELECT * FROM ban_group')))
  {
    exit ('Invalid query');
    ;
  }

  while ($row = mysql_fetch_array ($result))
  {
    echo '<OPTION VALUE="';
    echo $row['id'];
    echo '">';
    echo $row['width'] . 'x' . $row['height'];
    echo '</OPTION>';
  }

  echo '</SELECT><BR><BR>

';
  echo $admin_Banner_Image;
  echo '<BR>	
<INPUT TYPE="file" NAME="image" SIZE="50"><BR><BR>
		
';
  echo $admin_Impression_Limit;
  echo '<BR>	
<INPUT TYPE="text" NAME="imp_limit" SIZE="20" Value=0> (0 ';
  echo $admin_means_unlimited_impressions;
  echo ')<BR><BR>

';
  echo $admin_Destination_URL;
  echo '<BR>
<INPUT TYPE="text" NAME="url" SIZE="70" VALUE="http://"><BR><BR>
		
<INPUT TYPE="submit" NAME="ban_upload" VALUE="';
  echo $admin_Upload_Banner;
  echo '">

</FORM>



';
  if ($_GET['delete'])
  {
    if (!(mysql_query ('' . 'DELETE FROM ban_source WHERE id=\'' . $_GET['delete'] . '\'')))
    {
      exit ('Query failed');
      ;
    }
  }

  echo '




';
  if ($_POST['name'] != '')
  {
    $SQL = '' . 'select * from ban_source WHERE name=\'' . $_POST['name'] . '\'';
    if (!($result = mysql_query ($SQL)))
    {
      exit ('Query failed1');
      ;
    }

    $row = mysql_fetch_array ($result);
    if (!$row)
    {
      if ($_FILES['image']['name'])
      {
        if (copy ($_FILES['image']['tmp_name'], $documentroot . ('' . '/upload/banners/' . $curtime['0'] . '.') . substr ($_FILES['image']['type'], 6)))
        {
          unlink ($_FILES['image']['tmp_name']);
        }

        $SQL = '' . 'INSERT INTO ban_source VALUES(
				\'\',
				\'' . $_POST['name'] . '\',
				\'' . $curtime[0] . '.' . substr ($_FILES['image']['type'], 6) . ('' . '\',
				' . $_POST['groupID'] . ',
				\'' . $_POST['url'] . '\',
				\'on\',
				\'' . $_POST['imp_limit'] . '\',
				\'1\',
				\'1\'
				)');
      }

      if (!(mysql_query ($SQL)))
      {
        exit ('Query failed');
        ;
      }
    }
    else
    {
      echo '<S';
      echo 'CRIPT LANGUAGE="JavaScript" TYPE="text/javascript">alert("Banner \\"';
      echo $_POST['name'];
      echo '\\" already exist!")</SCRIPT>';
    }
  }

  echo '

<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=3>
<TR BGCOLOR="#505090">
<TD><FONT COLOR="#FFFFFF">';
  echo $admin_table5[0];
  echo '</FONT></TD>
<td><FONT COLOR="#FFFFFF">';
  echo $admin_table5[1];
  echo '</FONT></td>
<td><FONT COLOR="#FFFFFF">';
  echo $admin_table5[2];
  echo '</FONT></td>
<td><FONT COLOR="#FFFFFF">';
  echo $admin_table5[3];
  echo '</FONT></td>
<td><FONT COLOR="#FFFFFF">';
  echo $admin_table5[4];
  echo '</FONT></td>
</tr>

';
  if (!($result = mysql_query ('SELECT * FROM ban_source')))
  {
    exit ('Query failed4');
    ;
  }

  while ($row = mysql_fetch_array ($result))
  {
    if (!($result1 = mysql_query ('' . 'SELECT * FROM ban_group WHERE id=' . $row['gr'])))
    {
      exit ('Query failed4');
      ;
    }

    $row1 = mysql_fetch_array ($result1);
    echo '					<TR bgcolor="';
    if ($i % 2)
    {
      echo '#BFBFDF';
    }
    else
    {
      echo '#DCDCED';
    }

    echo '">

					<TD>
							<A HREF="javascript:" onClick="window.open(\'show.php?id=';
    echo $row['image'];
    echo '\',\'popup\',\'width=';
    echo $row1['width'] + 20;
    echo ',height=';
    echo $row1['height'] + 25;
    echo '\');" STYLE="color:blue;" >';
    echo $row['name'];
    echo '</A>
					</TD>




					<TD>(';
    echo $row['gr'];
    echo ') - ';
    echo $row1['width'] . 'x' . $row1['height'];
    echo '</TD>
					<TD>';
    echo date ('d/m/y', $row['image']);
    echo '</TD>
					<TD ALIGN=center>';
    echo $row['active'];
    echo '</TD>
					<TD ALIGN=center>
							<A HREF="edit.php?record=';
    echo $row['id'];
    echo '"><IMG SRC="../images/edit.gif" ALT="Edit" BORDER=0></A>
							<A onclick="return confirmSubmit(\'';
    echo $row['name'];
    echo '\')" HREF="add.php?delete=';
    echo $row['id'];
    echo '"><IMG SRC="../images/delete.gif" ALT="Delete" BORDER=0></A>
							<A HREF="stat.php?id=';
    echo $row['id'];
    echo '"><IMG SRC="../images/stat.gif" ALT="Statistics" BORDER=0></A></TD>
					</TR>
			';
  }

  echo '</TABLE>






</TD></TR></TABLE></TD></TR></TABLE></BODY></HTML>';
?>
