<?
#Старт сессии
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_serf = mysql_fetch_array( mysql_query( "SELECT * FROM dynlink WHERE id = '" . ( int ) $_GET['id'] . "' LIMIT 1" ) );
  $edit_serf_reklamodatel = mysql_fetch_array( mysql_query( "SELECT username, userdel FROM user WHERE id = '" . ( int ) $edit_serf['iduser'] . "' LIMIT 1" ) );
  ?>
    <script type="text/javascript">
      function config_1() {
		$.ajax ({
            url: 'ajax_update.php?func=editserf',
            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_serf['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="idserf" id="idserf" value="<?=$edit_serf['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_serf['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 ">Описание</label>
						<div class="col-sm-10 input-size-one">
						  <input type="text" class="form-control" name="description" id="description" value="<?=$edit_serf['description']?>">
						  <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_serf['url']?>">
						  <span class="help-block m-b-none"></span> 
						</div>
					  </div>
					
					  <? if( $edit_serf['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_serf['iduser']?>">
						    <span class="help-block m-b-none">Ник:&nbsp;<?=$edit_serf_reklamodatel['username']?>&nbsp;<? if($edit_serf_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_serf['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_serf['timer'] == 0 ) echo 'selected';?>>10 секунд&nbsp;&nbsp;(<?=$config['dyn10']?> <?=$config['valutaname'] ?>) - Mini</option>
							  <option value="1" <? if( $edit_serf['timer'] == 1 ) echo 'selected';?>>20 секунд&nbsp;&nbsp;(<?=$config['dyn20']?> <?=$config['valutaname'] ?>) - Mini</option>
							  <option value="2" <? if( $edit_serf['timer'] == 2 ) echo 'selected';?>>30 секунд&nbsp;&nbsp;(<?=$config['dyn30']?> <?=$config['valutaname'] ?>) - Standart</option>
							  <option value="3" <? if( $edit_serf['timer'] == 3 ) echo 'selected';?>>40 секунд&nbsp;&nbsp;(<?=$config['dyn40']?> <?=$config['valutaname'] ?>) - Standart</option>
							  <option value="4" <? if( $edit_serf['timer'] == 4 ) echo 'selected';?>>50 секунд&nbsp;&nbsp;(<?=$config['dyn50']?> <?=$config['valutaname'] ?>) - Standart</option>
							  <option value="5" <? if( $edit_serf['timer'] == 5 ) echo 'selected';?>>60 секунд&nbsp;&nbsp;(<?=$config['dyn60']?> <?=$config['valutaname'] ?>) - Standart</option>
							  <option value="6" <? if( $edit_serf['timer'] == 6 ) echo 'selected';?>>70 секунд&nbsp;&nbsp;(<?=$config['dyn70']?> <?=$config['valutaname'] ?>) - Standart</option>
							  <option value="7" <? if( $edit_serf['timer'] == 7 ) echo 'selected';?>>80 секунд&nbsp;&nbsp;(<?=$config['dyn80']?> <?=$config['valutaname'] ?>) - Standart</option>
							  <option value="8" <? if( $edit_serf['timer'] == 8 ) echo 'selected';?>>90 секунд&nbsp;&nbsp;(<?=$config['dyn90']?> <?=$config['valutaname'] ?>) - Standart</option>
							  <option value="9" <? if( $edit_serf['timer'] == 9 ) echo 'selected';?>>100 секунд&nbsp;&nbsp;(<?=$config['dyn100']?> <?=$config['valutaname'] ?>) - Mega</option>
							  <option value="10" <? if( $edit_serf['timer'] == 10 ) echo 'selected';?>>125 секунд&nbsp;&nbsp;(<?=$config['dyn125']?> <?=$config['valutaname'] ?>) - Mega</option>
							  <option value="11" <? if( $edit_serf['timer'] == 11 ) echo 'selected';?>>150 секунд&nbsp;&nbsp;(<?=$config['dyn150']?> <?=$config['valutaname'] ?>) - Mega</option>
							  <option value="12" <? if( $edit_serf['timer'] == 12 ) echo 'selected';?>>200 секунд&nbsp;&nbsp;(<?=$config['dyn200']?> <?=$config['valutaname'] ?>) - Mega</option>
							  <option value="13" <? if( $edit_serf['timer'] == 13 ) echo 'selected';?>>250 секунд&nbsp;&nbsp;(<?=$config['dyn250']?> <?=$config['valutaname'] ?>) - Mega</option>
							  <option value="14" <? if( $edit_serf['timer'] == 14 ) echo 'selected';?>>300 секунд&nbsp;&nbsp;(<?=$config['dyn300']?> <?=$config['valutaname'] ?>) - Mega</option>
							  
							</optgroup>
						  </select>
						</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="obper" id="obper">
							<optgroup label="Переход после просмотра на сайт рекламодателя:">
							  <option value="0" <? if( $edit_serf['obper'] == 0 ) echo 'selected';?>>Нет</option>
							  <option value="1" <? if( $edit_serf['obper'] == 1 ) echo 'selected';?>>Да&nbsp;&nbsp;(+ <?=$config['obper'] ?> <?=$config['valutaname']?>)</option>
							</optgroup>
						  </select>
						</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="active_window" id="active_window">
							<optgroup label="Пользователь не сможет покинуть вкладку или свернуть браузер, таймер будет остановлен:">
							  <option value="0" <? if( $edit_serf['active_window'] == 0 ) echo 'selected';?>>Нет</option>
							  <option value="1" <? if( $edit_serf['active_window'] == 1 ) echo 'selected';?>>Да&nbsp;&nbsp;(+ <?=$config['active_window'] ?> <?=$config['valutaname']?>)</option>
							</optgroup>
						  </select>
						</div>
					  </div>
					  
					  <div class="hr-dashed"></div>
					  <div class="form-group">
						<label class="col-sm-2 control-label ">V.I.P</label>
						<div class="col-sm-10">
						  <select class="select-form" name="vip" id="vip">
							<optgroup label="Вип ссылки отображаются выше других, и отмечены особым статусом:">
							  <option value="0" <? if( $edit_serf['vip'] == 0 ) echo 'selected';?>>Нет</option>
							  <option value="1" <? if( $edit_serf['vip'] == 1 ) echo 'selected';?>>Да&nbsp;&nbsp;(+ <?=$config['vipdyn'] ?> <?=$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_serf['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_serf['geo_ua'] == 'ua' ) echo 'checked="selected"';?> /> 
								  <label>&nbsp;<img src="/theme/images/flags/ua.png" class="flagcountry" alt="" />&nbsp;&nbsp;Украина</label>
							  </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_serf['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_serf['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_serf['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_serf['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_serf['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_serf['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_serf['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_serf['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_serf['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_serf['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_serf['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_serf['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_serf['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_serf['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_serf['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_serf['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_serf['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_serf['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_serf['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_serf['geo_all'] == 'all' ) echo 'checked="selected"';?> /> <label>Другие страны</label>
								</div>
							  </td>
							</tr>
						  </table>
						</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">
						  <div class="checkbox checkbox-primary">
						    <input type="checkbox" size="50" name="erotic" id="erotic" <?if( $edit_serf['erotic'] == 1 ) echo 'checked="checked"'?> />
						    <label for="">
							  Ограничение 18+
						    </label>
					      </div>
					    </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">
						  <div class="checkbox checkbox-primary">
						    <input type="checkbox" size="50" name="freeid" id="freeid" <?if( $edit_serf['freeid'] == 1 ) echo 'checked="checked"'?> />
						    <label for="">
							  Для свободных рефералов
						    </label>
					      </div>
					    </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>
  <?
} 
?>