<?php include ("app_needed/config.php");
require_once("app_classes/module_tags.inc"); 
$tag = new class_tags($_GET[unique]);
if(!$_SESSION[unique])
header("Location: ".APP_WEBSITE."/login.html");
if($_GET[unique]) $type = $tag->get_ad_type(); else $type = $_GET[type];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?= language("CHARSET") ?>" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title><?php if($_GET[unique]) echo language('PAGE_edit_tag_title'); else echo language('PAGE_create_tag_title'); ?> - <?= $config->get_value('platform_title') ?></title>
<link rel="shortcut icon" type="image/png" href="<?= $config->get_value('platform_favicon') ?>"/>
<link href="app_needed/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="app_needed/style.tipsy.css" type="text/css" />
</head>

<body>
<div id="wrapper">
	<?php include("module.header.php"); ?>
	<?php include ("module.menu.php"); ?>
	<div class="content">
		<div class="info">
		<h1><?php if($_GET[unique]) echo language('PAGE_edit_tag_title'); else echo language('PAGE_create_tag_title'); ?></h1>
		</div>
    <form name="my-form" action="app_needed/ajax.functions.php" method="POST" enctype="multipart/form-data">
    <input type="hidden" name="<?php if($_GET[unique]) echo"edit";else echo"create"; ?>_tag" value="1" />
    <input type="hidden" name="ad_type" value="<?= $type ?>" />
    <?php if($_GET[unique]) { ?> <input type="hidden" name="unique" value="<?= $_GET[unique] ?>" /><?php } ?>
      <div class="box">
	    <div class="inside">
       	  <div class="title">
                <h2><?= language('PAGE_tag_subtitle') ?></h2>
         		</div>
          <table width="100%" border="0">
           	  <tr>
           	    <td width="17%"><?= language('FORM_tag_name') ?></td>
           	    <td width="83%"><input type="text" placeholder="" name="tag_name" value="<?= $tag->get_name() ?>"/>
           	      <br />
       	        <?= language('FORM_tag_name_text') ?></td>
       	      </tr>
           	  <tr>
           	    <td><?= language('FORM_ad_type') ?></td>
           	    <td>                  
                <select name="size">
 <?php 
				$sql = "SELECT * FROM `app_sizes` ";
				$result = mysql_query ($sql);
				while ($size = mysql_fetch_array($result)){
					?>
                  <option value="<?= $size[unique] ?>" <?php if($size[width].'x'.$size[height] === $tag->get_ad_type()) echo "selected";?>   >
                    Banner <?= $size[width] ?>x<?= $size[height] ?>
                  </option>
                  <?php
				}
				?>
				  </select>
                  </td>
       	    </tr>
           	  <tr>
           	    <td><?= language('FORM_website_url') ?></td>
           	    <td><input type="text" placeholder="" name="tag_url" value="<?php if($tag->get_unique()) echo "http://".$tag->get_website(); else echo "http://"; ?>"/>
           	      <br />
       	        <?= language('FORM_website_url_text') ?></td>
       	    </tr>
           	  <tr>
           	    <td><input type="submit"  value="<?= language('BUTTON_submit') ?>" /></td>
           	    <td id="response"></td>
       	    </tr>
            <?php if($tag->get_unique()){ ?>
           	  <tr>
           	    <td><strong><?= language('FORM_tag_code') ?></strong></td>
           	    <td><?= language('FORM_tag_code_text') ?></td>
       	    </tr>
           	  <tr>
           	    <td> <?= language('FORM_your_code') ?></td>
           	    <td>
                
            
                  <strong>
                <?php if($tag->get_valid() == 1 || $tag->get_valid() == 2){ 
				$split = explode("x",$tag->get_ad_type());
				?>
               
                 &lt;script type="text/javascript" src="<?= APP_WEBSITE ?>/adb.php?tag=<?= $tag->get_unique() ?>&amp;width=<?= $split[0] ?>&amp;height=<?= $split[1] ?>"&gt;&lt;/script&gt;
				<?php } ?>
           
               
                </strong></td>
       	    </tr>
            <?php } ?>
       	  </table>
           </div>
        </div>
        </form>

	</div>
            

</div>
<div id='confirm'>
<div class="left">
	<div class='title'><span><?= language('CONFIRM') ?></span></div>
	<div class='message'></div>
</div>
<div class="right">
	<div class='buttons'>
				<span class='no simplemodal-close'><?= language('NO') ?></span><span class='yes'><?= language('YES') ?></span>
               
	</div>
</div>
<div class="clear"></div>
	</div>
		<!-- preload the images -->
	<div style='display:none'>
		<img src='img/confirm/header.gif' alt='' />
		<img src='img/confirm/button.gif' alt='' />
	</div>


<script type="text/javascript" src="app_needed/jquery-1.9.0.min.js"></script>
<script type='text/javascript' src='app_needed/jquery.accordionmenu.js'></script>
<script type='text/javascript' src='app_needed/jquery.checkbox.js'></script>
<script type='text/javascript' src='app_needed/jquery.tipsy.js'></script>
<script type='text/javascript' src='app_needed/function.ajax.js'></script>
<script type='text/javascript' src='app_needed/simply-toast.min.js'></script>
<script type='text/javascript' src='app_needed/jquery.simplemodal.js'></script>
<script type='text/javascript' src='app_needed/functions.js'></script>
</body>
</html>
<?php mysql_close($conn); ?>