<?
#Старт сессии
session_start();

#Подключаем базу
include '../engine/config.php';
  
#Проверяем способ вызова файла
if ( !defined( 'MISOFT_ADMIN_DIRR' ) ) exit();

if ( !isset( $_SESSION['iduser'] ) or $config_user['account'] != 5 ) {
    echo '<div class="stabilisacion-engine"><div class="alert alert-danger" role="alert">
	  <strong>Внимание!</strong> Нарушен механизм безопасности! В силу безопасности и целостности сайта, выполнение скриптов остановлено. Ошибка №A1
	</div></div>';
	exit();
} else {
  
  $edit_autoserf = mysql_fetch_array( mysql_query( "SELECT * FROM autodynlink WHERE id = '" . ( int ) $_GET['id'] . "' LIMIT 1" ) );
  $edit_autoserf_reklamodatel = mysql_fetch_array( mysql_query( "SELECT username, userdel FROM user WHERE id = '" . ( int ) $edit_autoserf['iduser'] . "' LIMIT 1" ) );
  ?>
    <script type="text/javascript">
      function config_1() {
		$.ajax ({
            url: 'ajax_update.php?func=editautoserf',
            type: 'POST',
			dataType: 'html',
			data: $("#editform").serialize(),
            success: function(data) {
              if(data == 1) {
                $('#block_title_error').fadeIn(0);
                $('#success_ajax').fadeIn(500);
                setTimeout(function() {
                    $('#success_ajax').fadeOut(500);
					$('#block_title_error').fadeOut(0);
					location.reload();
                }, 4000);
              } else {
				$('#block_title_error').fadeIn(0);
				$('#error_ajax').fadeIn(500).html(data);
                setTimeout(function() {
                    $('#error_ajax').fadeOut(500).html('&nbsp;');
					$('#block_title_error').fadeOut(0);
                }, 4000);
			  }
            }
        });
      }
    </script>
    <div class="content-wrapper">
	  <div class="container-fluid">
		<div class="row">
		  <div class="col-md-12">
		    <h2 class="page-title">Редактирование рекламной площадки.</h2>

			<div class="row">
			  <div class="col-md-6">
				<div class="panel panel-default">
				  <div class="panel-heading">Авто-серфинг (площадка ID:<?=( int ) $_GET['id']?>)</div>
				  <div class="panel-body">
					<? if( $edit_autoserf['nouser'] == 1 ) { ?>
					  <div class="alert alert-dismissible alert-warning">
					    <button type="button" class="close" data-dismiss="alert"><i class="fa fa-remove"></i></button>
					    Заказ площадки был осуществлен от не авторизированного пользователя (заказ без авторизации).
					  </div>
					<? } ?>
					<form id="editform" action="" method="POST" class="form-horizontal">
					  <input type="hidden" name="idautoserf" id="idautoserf" value="<?=$edit_autoserf['id']?>" />
					  
					  <div class="form-group">
						<label class="col-sm-2 control-label ">Описание ссылки</label>
						<div class="col-sm-10 input-size-one">
						  <input type="text" class="form-control" name="title" id="title" value="<?=$edit_autoserf['title']?>">
						  <span class="help-block m-b-none"></span>
						</div>
					  </div>
					
					  <div class="hr-dashed"></div>
					  <div class="form-group">
						<label class="col-sm-2 control-label ">URL сайта</label>
						<div class="col-sm-10 input-size-one">
						  <input type="text" class="form-control" name="url" id="url" value="<?=$edit_autoserf['url']?>">
						  <span class="help-block m-b-none"></span> 
						</div>
					  </div>
					
					  <? if( $edit_autoserf['nouser'] == 0 ) { ?>
					    <div class="hr-dashed"></div>
					    <div class="form-group">
						  <label class="col-sm-2 control-label ">Рекламодатель id</label>
						  <div class="col-sm-10 input-size-one">
						    <input type="text" class="form-control" name="iduser" id="iduser" value="<?=$edit_autoserf['iduser']?>">
						    <span class="help-block m-b-none">Ник:&nbsp;<?=$edit_autoserf_reklamodatel['username']?>&nbsp;<? if($edit_autoserf_reklamodatel['userdel'] == 1) { echo '<font color="red">(пользователь удален)</font>';} ?></span> 
						  </div>
					    </div>
					  <? } ?>
					
					  <div class="hr-dashed"></div>
					  <div class="form-group">
						<label class="col-sm-2 control-label ">Баланс</label>
						<div class="col-sm-10 input-size-one">
						  <input type="text" class="form-control" name="balance" id="balance" value="<?=$edit_autoserf['balance']?>">
						  <span class="help-block m-b-none"></span> 
						</div>
					  </div>
					  
					  <div class="hr-dashed"></div>
					  <div class="form-group">
						<label class="col-sm-2 control-label label-size-fix">Время просмотра</label>
						<div class="col-sm-10">
						  <select class="select-form" name="timer" id="timer">
							<optgroup label="Выберите таймер ссылки:">
							  <option value="0" <? if( $edit_autoserf['timer'] == 0 ) echo 'selected';?>>10 секунд&nbsp;&nbsp;(<?=$config['autodyn10']?> <?=$config['valutaname'] ?>) - Mini</option>
							  <option value="1" <? if( $edit_autoserf['timer'] == 1 ) echo 'selected';?>>20 секунд&nbsp;&nbsp;(<?=$config['autodyn20']?> <?=$config['valutaname'] ?>)</option>
							  <option value="2" <? if( $edit_autoserf['timer'] == 2 ) echo 'selected';?>>30 секунд&nbsp;&nbsp;(<?=$config['autodyn30']?> <?=$config['valutaname'] ?>)</option>
							  <option value="3" <? if( $edit_autoserf['timer'] == 3 ) echo 'selected';?>>40 секунд&nbsp;&nbsp;(<?=$config['autodyn40']?> <?=$config['valutaname'] ?>)</option>
							  <option value="4" <? if( $edit_autoserf['timer'] == 4 ) echo 'selected';?>>50 секунд&nbsp;&nbsp;(<?=$config['autodyn50']?> <?=$config['valutaname'] ?>)</option>
							  <option value="5" <? if( $edit_autoserf['timer'] == 5 ) echo 'selected';?>>60 секунд&nbsp;&nbsp;(<?=$config['autodyn60']?> <?=$config['valutaname'] ?>)</option>
							</optgroup>
						  </select>
						</div>
					  </div>
					  
					  <div class="hr-dashed"></div>
					  <div class="form-group">
						<label class="col-sm-2 control-label ">Геотаргетинг</label>
						<div class="col-sm-10">
						  <table class="table_geo_addtext">
							<tr>
							  <td style="width: 50%;">
							    <div class="checkbox checkbox-primary">
							      <input type="checkbox" name="geo_ru" id="geo_ru" value="ru" <? if( $edit_autoserf['geo_ru'] == 'ru' ) echo 'checked="selected"';?> /> 
								  <label>&nbsp;<img src="/theme/images/flags/ru.png" class="flagcountry" alt="" />&nbsp;&nbsp;Россия</label>
								</div>
							  </td>
							  <td style="width: 50%;">
							    <div class="checkbox checkbox-primary">
								  <input type="checkbox" name="geo_ua" id="geo_ua" value="ua" <? if( $edit_autoserf['geo_ua'] == 'ua' ) echo 'checked="selected"';?> /> 
								  <label>&nbsp;<img src="/theme/images/flags/ua.png" class="flagcountry" alt="" />&nbsp;&nbsp;Украина</label>
							    </div>
							  </td>
							</tr>
							<tr>
							  <td style="width: 50%;">
								<div class="checkbox checkbox-primary">
								  <input type="checkbox" name="geo_by" id="geo_by" value="by" <? if( $edit_autoserf['geo_by'] == 'by' ) echo 'checked="selected"';?> /> 
								  <label>&nbsp;<img src="/theme/images/flags/by.png" class="flagcountry" alt="" />&nbsp;&nbsp;Белоруссия</label>
								</div>
							  </td>
							  <td style="width: 50%;">
								<div class="checkbox checkbox-primary">
								  <input type="checkbox" name="geo_ge" id="geo_ge" value="ge" <? if( $edit_autoserf['geo_ge'] == 'ge' ) echo 'checked="selected"';?> /> 
								  <label>&nbsp;<img src="/theme/images/flags/ge.png" class="flagcountry" alt="" />&nbsp;&nbsp;Грузия</label>
								</div>
							  </td>
							</tr>
							<tr>
							  <td style="width: 50%;">
								<div class="checkbox checkbox-primary">
								  <input type="checkbox" name="geo_md" id="geo_md" value="md" <? if( $edit_autoserf['geo_md'] == 'md' ) echo 'checked="selected"';?> /> 
								  <label>&nbsp;<img src="/theme/images/flags/md.png" class="flagcountry" alt="" />&nbsp;&nbsp;Молдова</label>
								</div>
							  </td>
							  <td style="width: 50%;">
								<div class="checkbox checkbox-primary">
								  <input type="checkbox" name="geo_kz" id="geo_kz" value="kz" <? if( $edit_autoserf['geo_kz'] == 'kz' ) echo 'checked="selected"';?> /> 
								  <label>&nbsp;<img src="/theme/images/flags/kz.png" class="flagcountry" alt="" />&nbsp;&nbsp;Казакстан</label>
								</div>
							  </td>
							</tr>
							<tr>
							  <td style="width: 50%;">
								<div class="checkbox checkbox-primary">
								  <input type="checkbox" name="geo_am" id="geo_am" value="am" <? if( $edit_autoserf['geo_am'] == 'am' ) echo 'checked="selected"';?> />
								  <label>&nbsp;<img src="/theme/images/flags/am.png" class="flagcountry" alt="" />&nbsp;&nbsp;Армения</label>
								</div>
							  </td>
							  <td style="width: 50%;">
								<div class="checkbox checkbox-primary">
								  <input type="checkbox" name="geo_tj" id="geo_tj" value="tj" <? if( $edit_autoserf['geo_tj'] == 'tj' ) echo 'checked="selected"';?> /> 
								  <label>&nbsp;<img src="/theme/images/flags/tj.png" class="flagcountry" alt="" />&nbsp;&nbsp;Таджикистан</label>
								</div>
							  </td>
							</tr>
							<tr>
							  <td style="width: 50%;">
								<div class="checkbox checkbox-primary">
								  <input type="checkbox" name="geo_az" id="geo_az" value="az" <? if( $edit_autoserf['geo_az'] == 'az' ) echo 'checked="selected"';?> /> 
								  <label>&nbsp;<img src="/theme/images/flags/az.png" class="flagcountry" alt="" />&nbsp;&nbsp;Азербайджан</label>
								</div>
							  </td>
							  <td style="width: 50%;">
								<div class="checkbox checkbox-primary">
								  <input type="checkbox" name="geo_uz" id="geo_uz" value="uz" <? if( $edit_autoserf['geo_uz'] == 'uz' ) echo 'checked="selected"';?> />
								  <label>&nbsp;<img src="/theme/images/flags/uz.png" class="flagcountry" alt="" />&nbsp;&nbsp;Узбекистан</label>
								</div>
							  </td>
							</tr>
							<tr>
							  <td style="width: 50%;">
								<div class="checkbox checkbox-primary">
								  <input type="checkbox" name="geo_pt" id="geo_pt" value="pt" <? if( $edit_autoserf['geo_pt'] == 'pt' ) echo 'checked="selected"';?> /> 
								  <label>&nbsp;<img src="/theme/images/flags/pt.png" class="flagcountry" alt="" />&nbsp;&nbsp;Португалия</label>
								</div>
							  </td>
							  <td style="width: 50%;">
								<div class="checkbox checkbox-primary">
							      <input type="checkbox" name="geo_es" id="geo_es" value="es" <? if( $edit_autoserf['geo_es'] == 'es' ) echo 'checked="selected"';?> /> 
								  <label>&nbsp;<img src="/theme/images/flags/es.png" class="flagcountry" alt="" />&nbsp;&nbsp;Испания</label>
								</div>
							  </td>
							</tr>
							<tr>
							  <td style="width: 50%;">
								<div class="checkbox checkbox-primary">
							      <input type="checkbox" name="geo_ee" id="geo_ee" value="ee" <? if( $edit_autoserf['geo_ee'] == 'ee' ) echo 'checked="selected"';?> />
								  <label>&nbsp;<img src="/theme/images/flags/ee.png" class="flagcountry" alt="" />&nbsp;&nbsp;Эстония</label>
								</div>
							  </td>
							  <td style="width: 50%;">
								<div class="checkbox checkbox-primary">
							      <input type="checkbox" name="geo_lv" id="geo_lv" value="lv" <? if( $edit_autoserf['geo_lv'] == 'lv' ) echo 'checked="selected"';?> /> 
								  <label>&nbsp;<img src="/theme/images/flags/lv.png" class="flagcountry" alt="" />&nbsp;&nbsp;Латвия</label>
								</div>
							  </td>
							</tr>
							<tr>
							  <td style="width: 50%;">
								<div class="checkbox checkbox-primary">
							      <input type="checkbox" name="geo_lt" id="geo_lt" value="lt" <? if( $edit_autoserf['geo_lt'] == 'lt' ) echo 'checked="selected"';?> /> 
								  <label>&nbsp;<img src="/theme/images/flags/lt.png" class="flagcountry" alt="" />&nbsp;&nbsp;Литва</label>
								</div>
							  </td>
							  <td style="width: 50%;">
								<div class="checkbox checkbox-primary">
							      <input type="checkbox" name="geo_us" id="geo_us" value="us" <? if( $edit_autoserf['geo_us'] == 'us' ) echo 'checked="selected"';?> /> 
								  <label>&nbsp;<img src="/theme/images/flags/us.png" class="flagcountry" alt="" />&nbsp;&nbsp;Америка</label>
								</div>
							  </td>
							</tr>
							<tr>
							  <td style="width: 50%;">
								<div class="checkbox checkbox-primary">
							      <input type="checkbox" name="geo_gb" id="geo_gb" value="gb" <? if( $edit_autoserf['geo_gb'] == 'gb' ) echo 'checked="selected"';?> /> 
								  <label>&nbsp;<img src="/theme/images/flags/gb.png" class="flagcountry" alt="" />&nbsp;&nbsp;Англия</label>
								</div>
							  </td>
							  <td style="width: 50%;">
								<div class="checkbox checkbox-primary">
							      <input type="checkbox" name="geo_fr" id="geo_fr" value="fr" <? if( $edit_autoserf['geo_fr'] == 'fr' ) echo 'checked="selected"';?> /> 
								  <label>&nbsp;<img src="/theme/images/flags/fr.png" class="flagcountry" alt="" />&nbsp;&nbsp;Франция</label>
								</div>
							  </td>
							</tr>
							<tr>
							  <td style="width: 50%;">
								<div class="checkbox checkbox-primary">
							      <input type="checkbox" name="geo_de" id="geo_de" value="de" <? if( $edit_autoserf['geo_de'] == 'de' ) echo 'checked="selected"';?> /> 
								  <label>&nbsp;<img src="/theme/images/flags/de.png" class="flagcountry" alt="" />&nbsp;&nbsp;Германия</label>
								</div>
							  </td>
							  <td style="width: 50%;">
								<div class="checkbox checkbox-primary">
							      <input type="checkbox" name="geo_cn" id="geo_cn" value="cn" <? if( $edit_autoserf['geo_cn'] == 'cn' ) echo 'checked="selected"';?> /> 
								  <label>&nbsp;<img src="/theme/images/flags/cn.png" class="flagcountry" alt="" />&nbsp;&nbsp;Китай</label>
								</div>
							  </td>
							</tr>
							<tr>
							  <td style="width: 50%;">
								<div class="checkbox checkbox-primary">
							      <input type="checkbox" name="geo_it" id="geo_it" value="it" <? if( $edit_autoserf['geo_it'] == 'it' ) echo 'checked="selected"';?> /> 
								  <label>&nbsp;<img src="/theme/images/flags/it.png" class="flagcountry" alt="" />&nbsp;&nbsp;Италия</label>
								</div>
							  </td>
							  <td style="width: 50%;">
								<div class="checkbox checkbox-primary">
							      <input type="checkbox" name="geo_all" id="geo_all" value="all" <? if( $edit_autoserf['geo_all'] == 'all' ) echo 'checked="selected"';?> /> <label>Другие страны</label>
								</div>
							  </td>
							</tr>
						  </table>
						</div>
					  </div>
					  
					  <div class="form-group error-form-fix" id="block_title_error">
					    <div class="hr-dashed"></div>
						<div class="alert alert-dismissible alert-info" id="success_ajax">
						  Изменения успешно сохранены!
						</div>
						<div class="alert alert-dismissible alert-danger" id="error_ajax">
						  Внимание ошибка!
						</div>
					  </div>
					
					  <div class="hr-dashed"></div>
					  <div class="form-group class-float-right">
						<div class="col-sm-8 col-sm-offset-2">
						  <button class="btn btn-primary" type="submit" onclick="config_1();return false;">Сохранить изменения</button>
						</div>
					  </div>
					  
					</form>
				  </div>
				</div>
			  </div>
			  
			  
			  
			</div>
		  </div>
		</div>
	  </div>
	</div>
  <?
} 
?>