<?
require($_SERVER['DOCUMENT_ROOT'].'/all_zapros.php');

// Псевдо меню
if($_POST['func'] == "add") {
$name = check_text($_POST["name"]);
$url = valideurl($_POST["url"]);
$icon = check_text($_POST["icon"]);
$ip_r = check_text($_POST["ip"]);
$cena = (isset($_POST["cena"])) ? abs(floatval(str_replace(",",".",trim($_POST["cena"])))) : false;
$vozrast = check_text($_POST["vozrast"]);
$tar = check_tar($_POST["tar"]);
$vrema = check_text($_POST["vrem"]);
$r_st = check_text($_POST["r_st"]);
$pol = check_text($_POST["pol"]);
$capcha = check_text($_POST["capcha"]);

$vr = explode(",", $vrema);
$vrem = $vr[0];
$vrem_1 = $vr[1];

if($tar == NULL) {
echo "5";
}elseif($name == NULL OR $url == NULL) {
echo "1";
}elseif(strlen(iconv('UTF-8', 'windows-1251', $name)) > 20) {
echo "2";
}elseif($_SESSION['capcha'] == $capcha){
	
mysql_query("INSERT INTO `nano_rek_psmenu` (`moder`,`id_user`, `name`, `time`, `url`, `activ`, `cena`, `icon`, `ip`, `tar`, `vozrast`, `vrem`, `vrem_1`, `r_st`, `pol`) VALUES ('$moder_rek','$id_login','$name','$time','$url','0','$cena','$icon','$ip_r','$tar','$vozrast','$vrem','$vrem_1','$r_st','$pol')") or die(mysql_error());
mysql_query("INSERT INTO `nano_history` (`id_user`, `asoc`, `time`, `text`) VALUES ('$id_login','1','$time','Вы добавили псевдо меню $name. Сумма показа составляет: $cena руб.')") or die(mysql_error());
unset($_SESSION['capcha']);

echo "4";
}else{
echo "3";
}
}

// Контекстная ссылка
if($_POST['func'] == "add_kon") {
$name = check_text($_POST["name"]);
$text = check_text($_POST["text"]);
$url = valideurl($_POST["url"]);
$cvet = check_text($_POST["cvet"]);
$cena = (isset($_POST["cena"])) ? abs(floatval(str_replace(",",".",trim($_POST["cena"])))) : false;
$ip_r = check_text($_POST["ip"]);
$vip = check_text($_POST["vip"]);
$vozrast = check_text($_POST["vozrast"]);
$tar = check_tar($_POST["tar"]);
$vrema = check_text($_POST["vrem"]);
$r_st = check_text($_POST["r_st"]);
$pol = check_text($_POST["pol"]);
$capcha = check_text($_POST["capcha"]);

$vr = explode(",", $vrema);
$vrem = $vr[0];
$vrem_1 = $vr[1];

if($tar == NULL) {
echo "5";
}elseif($name == NULL OR $text == NULL OR $url == NULL) {
echo "1";
}elseif(strlen(iconv('UTF-8', 'windows-1251', $name)) >= 40) {
echo "2";
}elseif($_SESSION['capcha'] == $capcha){
	
mysql_query("INSERT INTO `nano_rek_kontext` (`moder`,`id_user`, `name`, `text`, `time`, `url`, `activ`, `cena`, `cvet`, `ip`, `vip`, `tar`, `vozrast`, `vrem`, `vrem_1`, `r_st`, `pol`) VALUES ('$moder_rek','$id_login','$name','$text','$time','$url','0','$cena','$cvet','$ip_r','$vip','$tar','$vozrast','$vrem','$vrem_1','$r_st','$pol')") or die(mysql_error());
mysql_query("INSERT INTO `nano_history` (`id_user`, `asoc`, `time`, `text`) VALUES ('$id_login','1','$time','Вы добавили контекстную ссылку $name. Сумма показа составляет: $cena руб.')") or die(mysql_error());
unset($_SESSION['capcha']);

echo "4";
}else{
echo "3";
}
}

// Баннеры
if($_POST['func'] == "add_ban") {
$name = check_text($_POST["name"]);
$url = valideurl($_POST["url"]);
$razmer = intval($_POST["razmer"]);
$cena = (isset($_POST["cena"])) ? abs(floatval(str_replace(",",".",trim($_POST["cena"])))) : false;
$ip_r = check_text($_POST["ip"]);
$vozrast = check_text($_POST["vozrast"]);
$tar = check_tar($_POST["tar"]);
$load = check_text($_POST["load"]);
$vrema = check_text($_POST["vrem"]);
$r_st = check_text($_POST["r_st"]);
$pol = check_text($_POST["pol"]);
$capcha = check_text($_POST["capcha"]);
$vr = explode(",", $vrema);
$vrem = $vr[0];
$vrem_1 = $vr[1];
// для записи баннера
$path = ($_SERVER['DOCUMENT_ROOT'].'/upload/banner');
switch($razmer) {
case 468: $size_1 = "468"; $size_2 = "60";break;
case 200: $size_1 = "200"; $size_2 = "300";break;
}

if(is_url_img($load)!="true") {
echo "7";
}elseif(is_img_size($size_1,$size_2,$load)!="true") {
echo "6";
}elseif($tar == NULL) {
echo "5";
}elseif($name == NULL OR $url == NULL) {
echo "1";
}elseif(strlen(iconv('UTF-8', 'windows-1251', $name)) >= 40) {
echo "2";
}elseif($_SESSION['capcha'] == $capcha){
mysql_query("INSERT INTO `nano_rek_banner` (`moder`,`id_user`, `name`, `time`, `orig_banner`, `url`, `activ`, `cena`, `razmer`, `ip`, `tar`, `vozrast`, `vrem`, `vrem_1`, `r_st`, `pol`) VALUES ('$moder_rek','$id_login','$name','$time','$load','$url','0','$cena','$razmer','$ip_r','$tar','$vozrast','$vrem','$vrem_1','$r_st','$pol')") or die(mysql_error());
mysql_query("INSERT INTO `nano_history` (`id_user`, `asoc`, `time`, `text`) VALUES ('$id_login','1','$time','Вы добавили баннерную рекламу $name. Сумма показа составляет: $cena руб.')") or die(mysql_error());
$new_id = mysql_result(mysql_query("SELECT `id` FROM `nano_rek_banner` ORDER BY `id` DESC"),0,0);
$f = basename($load);
$file = $id_login."_".$new_id."_".$f;
$content = file_get_contents($load);
$f = fopen("$path/$file", "w");
fwrite($f, $content);
fclose($f);
mysql_query("UPDATE `nano_rek_banner` SET `banner`='$file' WHERE `id`='$new_id'");
unset($_SESSION['capcha']);
echo "4";
}else{
echo "3";
}
}

// Динамические ссылки
if($_POST['func'] == "add_dyn") {
$name = check_text($_POST["name"]);
$text = check_text($_POST["text"]);
$url = valideurl($_POST["url"]);
$vrema = check_text($_POST["vrema"]);
$cena = (isset($_POST["cena"])) ? abs(floatval(str_replace(",",".",trim($_POST["cena"])))) : false;
$vip = check_text($_POST["vip"]);
$activ = check_text($_POST["activ"]);
$vozrast = check_text($_POST["vozrast"]);
$tar = check_tar($_POST["tar"]);
$vremy = check_text($_POST["vrem"]);
$r_st = check_text($_POST["r_st"]);
$pol = check_text($_POST["pol"]);
$capcha = check_text($_POST["capcha"]);
$clik = $cena*60/100;

$vr = explode(",", $vremy);
$vrem = $vr[0];
$vrem_1 = $vr[1];

if($tar == NULL) {
echo "5";
}elseif($name == NULL OR $text == NULL OR $url == NULL) {
echo "1";
}elseif(strlen(iconv('UTF-8', 'windows-1251', $name)) >= 50) {
echo "2";
}elseif($_SESSION['capcha'] == $capcha){
mysql_query("INSERT INTO `nano_rek_dinamika` (`moder`,`id_user`, `name`, `text`, `time`, `url`, `activ`, `cena`, `pay`, `vrema`, `vip`, `act`, `tar`, `vozrast`, `vrem`, `vrem_1`, `r_st`, `pol`) VALUES ('$moder_rek','$id_login','$name','$text','$time','$url','0','$cena','$clik','$vrema','$vip','$activ','$tar','$vozrast','$vrem','$vrem_1','$r_st','$pol')") or die(mysql_error());
mysql_query("INSERT INTO `nano_history` (`id_user`, `asoc`, `time`, `text`) VALUES ('$id_login','1','$time','Вы добавили контекстную ссылку $name. Сумма показа составляет: $cena руб.')") or die(mysql_error());
echo "4";
$new_id = mysql_result(mysql_query("SELECT `id` FROM `nano_rek_dinamika` ORDER BY `id` DESC"),0,0);
$nam = translit($name);
$screen = screen($url, "1280x1024", "270", "jpeg", $new_id."_".$nam);
mysql_query("UPDATE `nano_rek_dinamika` SET `screen`='$screen' WHERE `id`='$new_id'");
unset($_SESSION['capcha']);
}else{
echo "3";
}
}

// Оплачиваемые задания
if($_POST['func'] == "add_task") {
$name = check_text($_POST["name"]);
$kat = check_text($_POST["kat"]);
$text = check_text($_POST["text"]);
$vip = check_text($_POST["vip"]);
$info = check_text($_POST["info"]);
$url = valideurl($_POST["url"]);
$zad = check_text($_POST["zad"]);
$max = check_text($_POST["max"]);
$skolko = (isset($_POST["skolko"])) ? abs(floatval(str_replace(",",".",trim($_POST["skolko"])))) : false;
$cena = (isset($_POST["cena"])) ? abs(floatval(str_replace(",",".",trim($_POST["cena"])))) : false;
$vozrast = check_text($_POST["vozrast"]);
$tar = check_tar($_POST["tar"]);
$vrema = check_text($_POST["vrem"]);
$r_st = check_text($_POST["r_st"]);
$pol = check_text($_POST["pol"]);
$capcha = check_text($_POST["capcha"]);

$vr = explode(",", $vrema);
$vrem = $vr[0];
$vrem_1 = $vr[1];

if($skolko < $task_min){
echo "6";
}elseif($tar == NULL) {
echo "5";
}elseif($name == NULL OR $text == NULL OR $info == NULL OR $url == NULL OR $cena == NULL) {
echo "1";
}elseif(strlen(iconv('UTF-8', 'windows-1251', $name)) >= 40) {
echo "2";
}elseif($_SESSION['capcha'] == $capcha){
	
mysql_query("INSERT INTO `nano_rek_task` (`up_task`,`moder`,`id_user`, `name`, `kat`, `text`, `vip`, `info`, `url`, `zad`, `max`, `skolko`, `cena`, `activ`, `time`, `tar`, `vozrast`, `vrem`, `vrem_1`, `r_st`, `pol`) VALUES ('$time','0','$id_login','$name','$kat','$text','$vip','$info','$url','$zad','$max','$skolko','$cena','0','$time','$tar','$vozrast','$vrem','$vrem_1','$r_st','$pol')") or die(mysql_error());
mysql_query("INSERT INTO `nano_history` (`id_user`, `asoc`, `time`, `text`) VALUES ('$id_login','1','$time','Вы добавили оплачиваемое задание $name. Цена выполнения составляет: $skolko руб, общая сумма составила: $cena руб.')") or die(mysql_error());
unset($_SESSION['capcha']);

echo "4";
}else{
echo "3";
}
}

// Оплачиваемые письма
if($_POST['func'] == "add_mail") {
$name = check_text($_POST["name"]);
$text = check_text($_POST["text"]);
$url = valideurl($_POST["url"]);
$vrema = check_text($_POST["vrema"]);
$vopros = check_text($_POST["vopros"]);
$otvet_1 = check_text($_POST["otvet_1"]);
$otvet_2 = check_text($_POST["otvet_2"]);
$otvet_3 = check_text($_POST["otvet_3"]);
$cena = (isset($_POST["cena"])) ? abs(floatval(str_replace(",",".",trim($_POST["cena"])))) : false;
$vip = check_text($_POST["vip"]);
$vozrast = check_text($_POST["vozrast"]);
$tar = check_tar($_POST["tar"]);
$vremy = check_text($_POST["vrem"]);
$r_st = check_text($_POST["r_st"]);
$pol = check_text($_POST["pol"]);
$capcha = check_text($_POST["capcha"]);

if($cena < '0.040'){$clik = $cena*"0.$proc_1";}
if($cena < '0.045' AND $cena >= '0.040'){$clik = $cena*"0.$proc_2";}
if($cena < '0.050' AND $cena >= '0.045'){$clik = $cena*"0.$proc_3";}
if($cena < '0.055' AND $cena >= '0.050'){$clik = $cena*"0.$proc_4";}
if($cena >= '0.050'){$clik = $cena*"0.$proc_5";}

$vr = explode(",", $vremy);
$vrem = $vr[0];
$vrem_1 = $vr[1];

if($tar == NULL) {
echo "5";
}elseif($name == NULL OR $text == NULL OR $url == NULL) {
echo "1";
}elseif(strlen(iconv('UTF-8', 'windows-1251', $name)) >= 50) {
echo "2";
}elseif($_SESSION['capcha'] == $capcha){
mysql_query("INSERT INTO `nano_rek_mail` (`moder`,`id_user`, `name`, `text`, `time`, `url`, `activ`, `cena`, `pay`, `vrema`, `vip`, `vopros`, `otvet_1`, `otvet_2`, `otvet_3`, `tar`, `vozrast`, `vrem`, `vrem_1`, `r_st`, `pol`) VALUES ('$moder_rek','$id_login','$name','$text','$time','$url','0','$cena','$clik','$vrema','$vip','$vopros','$otvet_1','$otvet_2','$otvet_3','$tar','$vozrast','$vrem','$vrem_1','$r_st','$pol')") or die(mysql_error());
mysql_query("INSERT INTO `nano_history` (`id_user`, `asoc`, `time`, `text`) VALUES ('$id_login','1','$time','Вы добавили оплачиваемое письмо $name. Сумма показа составляет: $cena руб.')") or die(mysql_error());
unset($_SESSION['capcha']);

echo "4";
}else{
echo "3";
}
}

// Динамические ссылки без регистрации
if($_POST['func'] == "add_dyn_reg") {
$name = check_text($_POST["name"]);
$text = check_text($_POST["text"]);
$url = valideurl($_POST["url"]);
$vrema = check_text($_POST["vrema"]);
$cena = (isset($_POST["cena"])) ? abs(floatval(str_replace(",",".",trim($_POST["cena"])))) : false;
$korzina = (isset($_POST["korzina"])) ? abs(floatval(str_replace(",",".",trim($_POST["korzina"])))) : false;
$merch = intval($_POST["merchant"]);
$vip = check_text($_POST["vip"]);
$activ = check_text($_POST["activ"]);
$vozrast = check_text($_POST["vozrast"]);
$tar = check_tar($_POST["tar"]);
$vremy = check_text($_POST["vrem"]);
$r_st = check_text($_POST["r_st"]);
$pol = check_text($_POST["pol"]);
$capcha = check_text($_POST["capcha"]);
$nano_order = $_SESSION["key"];

if($cena < '0.035'){$clik = $cena*"0.$proc_1";}
if($cena < '0.040' AND $cena >= '0.035'){$clik = $cena*"0.$proc_2";}
if($cena < '0.045' AND $cena >= '0.040'){$clik = $cena*"0.$proc_3";}
if($cena < '0.050' AND $cena >= '0.045'){$clik = $cena*"0.$proc_4";}
if($cena >= '0.050'){$clik = $cena*"0.$proc_5";}

$vr = explode(",", $vremy);
$vrem = $vr[0];
$vrem_1 = $vr[1];

if($tar == NULL) {
echo "5";
}elseif($name == NULL OR $text == NULL OR $url == NULL) {
echo "1";
}elseif(strlen(iconv('UTF-8', 'windows-1251', $name)) >= 50) {
echo "2";
}elseif($_SESSION['capcha'] == $capcha){
mysql_query("INSERT INTO `nano_rek_dinamika` (`moder`,`id_user`, `name`, `text`, `time`, `url`, `activ`, `cena`, `pay`, `vrema`, `vip`, `act`, `tar`, `vozrast`, `vrem`, `vrem_1`, `r_st`, `pol`) VALUES ('$moder_rek','$nano_order','$name','$text','$time','$url','0','$cena','$clik','$vrema','$vip','$activ','$tar','$vozrast','$vrem','$vrem_1','$r_st','$pol')") or die(mysql_error());
$new_id = mysql_result(mysql_query("SELECT `id` FROM `nano_rek_dinamika` ORDER BY `id` DESC"),0,0);
mysql_query("INSERT INTO `nano_korzina` (`id_user`, `id_rek`, `time`, `summ`, `rek_asoc`, `reg`) VALUES ('$nano_order','$new_id','$time','$korzina','4','1')") or die(mysql_error());
$nam = translit($name);
$screen = screen($url, "1280x1024", "270", "jpeg", $new_id."_".$nam);
mysql_query("UPDATE `nano_rek_dinamika` SET `screen`='$screen' WHERE `id`='$new_id'");
echo "
<div class='col-md-12'>
<div class='panel panel-primary'>
<div class='panel-heading'>
<div class='panel-title-box'>
<h3>Подтверждение оплаты</h3>
<span>сумма вашего заказа составила $korzina руб.</span>
</div>
</div>
<div class='panel-body'>
";
$summ = number_format(payment_comis_p($merch, $korzina), 2, '.', "");
require_once($_SERVER['DOCUMENT_ROOT']."/merchant/form-merchant.php");
echo "
</div>
</div>
";
unset($_SESSION['capcha']);
}else{
echo "3";
}
}

// Псевдо меню без регистрации
if($_POST['func'] == "add_reg") {
$name = check_text($_POST["name"]);
$url = valideurl($_POST["url"]);
$icon = check_text($_POST["icon"]);
$ip_r = check_text($_POST["ip"]);
$cena = (isset($_POST["cena"])) ? abs(floatval(str_replace(",",".",trim($_POST["cena"])))) : false;
$korzina = (isset($_POST["korzina"])) ? abs(floatval(str_replace(",",".",trim($_POST["korzina"])))) : false;
$merch = intval($_POST["merchant"]);
$vozrast = check_text($_POST["vozrast"]);
$tar = check_tar($_POST["tar"]);
$vrema = check_text($_POST["vrem"]);
$r_st = check_text($_POST["r_st"]);
$pol = check_text($_POST["pol"]);
$capcha = check_text($_POST["capcha"]);
$nano_order = $_SESSION["key"];

$vr = explode(",", $vrema);
$vrem = $vr[0];
$vrem_1 = $vr[1];

if($tar == NULL) {
echo "5";
}elseif($name == NULL OR $url == NULL) {
echo "1";
}elseif(strlen(iconv('UTF-8', 'windows-1251', $name)) > 20) {
echo "2";
}elseif($_SESSION['capcha'] == $capcha){
mysql_query("INSERT INTO `nano_rek_psmenu` (`moder`,`id_user`, `name`, `time`, `url`, `activ`, `cena`, `icon`, `ip`, `tar`, `vozrast`, `vrem`, `vrem_1`, `r_st`, `pol`) VALUES ('$moder_rek','$nano_order','$name','$time','$url','0','$cena','$icon','$ip_r','$tar','$vozrast','$vrem','$vrem_1','$r_st','$pol')") or die(mysql_error());
$new_id = mysql_result(mysql_query("SELECT `id` FROM `nano_rek_psmenu` ORDER BY `id` DESC"),0,0);
mysql_query("INSERT INTO `nano_korzina` (`id_user`, `id_rek`, `time`, `summ`, `rek_asoc`, `reg`) VALUES ('$nano_order','$new_id','$time','$korzina','2','1')") or die(mysql_error());
echo "
<div class='col-md-12'>
<div class='panel panel-primary'>
<div class='panel-heading'>
<div class='panel-title-box'>
<h3>Подтверждение оплаты</h3>
<span>сумма вашего заказа составила $korzina руб.</span>
</div>
</div>
<div class='panel-body'>
";
$summ = number_format(payment_comis_p($merch, $korzina), 2, '.', "");
require_once($_SERVER['DOCUMENT_ROOT']."/merchant/form-merchant.php");
echo "
</div>
</div>
";
unset($_SESSION['capcha']);
}else{
echo "3";
}
}

// Баннеры без регистрации
if($_POST['func'] == "add_ban_reg") {
$name = check_text($_POST["name"]);
$url = valideurl($_POST["url"]);
$razmer = intval($_POST["razmer"]);
$cena = (isset($_POST["cena"])) ? abs(floatval(str_replace(",",".",trim($_POST["cena"])))) : false;
$korzina = (isset($_POST["korzina"])) ? abs(floatval(str_replace(",",".",trim($_POST["korzina"])))) : false;
$merch = intval($_POST["merchant"]);
$ip_r = check_text($_POST["ip"]);
$vozrast = check_text($_POST["vozrast"]);
$tar = check_tar($_POST["tar"]);
$load = check_text($_POST["load"]);
$vrema = check_text($_POST["vrem"]);
$r_st = check_text($_POST["r_st"]);
$pol = check_text($_POST["pol"]);
$capcha = check_text($_POST["capcha"]);
$nano_order = $_SESSION["key"];
$vr = explode(",", $vrema);
$vrem = $vr[0];
$vrem_1 = $vr[1];
// для записи баннера
$path = ($_SERVER['DOCUMENT_ROOT'].'/upload/banner');
switch($razmer) {
case 468: $size_1 = "468"; $size_2 = "60";break;
case 200: $size_1 = "200"; $size_2 = "300";break;
}

if(is_url_img($load)!="true") {
echo "7";
}elseif(is_img_size($size_1,$size_2,$load)!="true") {
echo "6";
}elseif($tar == NULL) {
echo "5";
}elseif($name == NULL OR $url == NULL) {
echo "1";
}elseif(strlen(iconv('UTF-8', 'windows-1251', $name)) >= 40) {
echo "2";
}elseif($_SESSION['capcha'] == $capcha){
mysql_query("INSERT INTO `nano_rek_banner` (`moder`,`id_user`, `name`, `time`, `orig_banner`, `url`, `activ`, `cena`, `razmer`, `ip`, `tar`, `vozrast`, `vrem`, `vrem_1`, `r_st`, `pol`) VALUES ('$moder_rek','$nano_order','$name','$time','$load','$url','0','$cena','$razmer','$ip_r','$tar','$vozrast','$vrem','$vrem_1','$r_st','$pol')") or die(mysql_error());
$new_id = mysql_result(mysql_query("SELECT `id` FROM `nano_rek_banner` ORDER BY `id` DESC"),0,0);
mysql_query("INSERT INTO `nano_korzina` (`id_user`, `id_rek`, `time`, `summ`, `rek_asoc`, `reg`) VALUES ('$nano_order','$new_id','$time','$korzina','3','1')") or die(mysql_error());
$f = basename($load);
$file = $id_login."_".$new_id."_".$f;
$content = file_get_contents($load);
$f = fopen("$path/$file", "w");
fwrite($f, $content);
fclose($f);
mysql_query("UPDATE `nano_rek_banner` SET `banner`='$file' WHERE `id`='$new_id'");
echo "
<div class='col-md-12'>
<div class='panel panel-primary'>
<div class='panel-heading'>
<div class='panel-title-box'>
<h3>Подтверждение оплаты</h3>
<span>сумма вашего заказа составила $korzina руб.</span>
</div>
</div>
<div class='panel-body'>
";
$summ = number_format(payment_comis_p($merch, $korzina), 2, '.', "");
require_once($_SERVER['DOCUMENT_ROOT']."/merchant/form-merchant.php");
echo "
</div>
</div>
";
unset($_SESSION['capcha']);
}else{
echo "3";
}
}

// Контекстная ссылка без регистрации
if($_POST['func'] == "add_kon_reg") {
$name = check_text($_POST["name"]);
$text = check_text($_POST["text"]);
$url = valideurl($_POST["url"]);
$cvet = check_text($_POST["cvet"]);
$cena = (isset($_POST["cena"])) ? abs(floatval(str_replace(",",".",trim($_POST["cena"])))) : false;
$korzina = (isset($_POST["korzina"])) ? abs(floatval(str_replace(",",".",trim($_POST["korzina"])))) : false;
$merch = intval($_POST["merchant"]);
$ip_r = check_text($_POST["ip"]);
$vip = check_text($_POST["vip"]);
$vozrast = check_text($_POST["vozrast"]);
$tar = check_tar($_POST["tar"]);
$vrema = check_text($_POST["vrem"]);
$r_st = check_text($_POST["r_st"]);
$pol = check_text($_POST["pol"]);
$capcha = check_text($_POST["capcha"]);
$nano_order = $_SESSION["key"];
$vr = explode(",", $vrema);
$vrem = $vr[0];
$vrem_1 = $vr[1];

if($tar == NULL) {
echo "5";
}elseif($name == NULL OR $text == NULL OR $url == NULL) {
echo "1";
}elseif(strlen(iconv('UTF-8', 'windows-1251', $name)) >= 40) {
echo "2";
}elseif($_SESSION['capcha'] == $capcha){
	
mysql_query("INSERT INTO `nano_rek_kontext` (`moder`,`id_user`, `name`, `text`, `time`, `url`, `activ`, `cena`, `cvet`, `ip`, `vip`, `tar`, `vozrast`, `vrem`, `vrem_1`, `r_st`, `pol`) VALUES ('$moder_rek','$nano_order','$name','$text','$time','$url','0','$cena','$cvet','$ip_r','$vip','$tar','$vozrast','$vrem','$vrem_1','$r_st','$pol')") or die(mysql_error());
$new_id = mysql_result(mysql_query("SELECT `id` FROM `nano_rek_kontext` ORDER BY `id` DESC"),0,0);
mysql_query("INSERT INTO `nano_korzina` (`id_user`, `id_rek`, `time`, `summ`, `rek_asoc`, `reg`) VALUES ('$nano_order','$new_id','$time','$korzina','1','1')") or die(mysql_error());
echo "
<div class='col-md-12'>
<div class='panel panel-primary'>
<div class='panel-heading'>
<div class='panel-title-box'>
<h3>Подтверждение оплаты</h3>
<span>сумма вашего заказа составила $korzina руб.</span>
</div>
</div>
<div class='panel-body'>
";
$summ = number_format(payment_comis_p($merch, $korzina), 2, '.', "");
require_once($_SERVER['DOCUMENT_ROOT']."/merchant/form-merchant.php");
echo "
</div>
</div>
";
unset($_SESSION['capcha']);
}else{
echo "3";
}
}
?>