File: /home/srv52894/test/balkon.php
<?php
$find_marks = array(
'url' => array("'siteurl',",","),
'city' => array('всем жителям г.','.</'),
'city2' => array('Балконы и лоджии под ключ в ',"'"),
'address' => array('address="','"'),
'phone' => array('phone="','"'),
'email' => array("'bc_plugin_option',","',"),
'email2' => array("'bc_plugin_option',","',"),
'YmetricaId' => array("'YmetricaId',",','),
'VENYOOId' => array("'VENYOOId',",','),
'GMiframe' => array("'GMiframe',",",")
);
function get_string_between($string, $start, $end){
$string = ' ' . $string;
$ini = strpos($string, $start);
if ($ini == 0) return '';
$ini += strlen($start);
$len = strpos($string, $end, $ini) - $ini;
return substr($string, $ini, $len);
}
function get_data_from_dump($dump,$marks=array()){
$data = array();
foreach ($marks as $name=>$mark){
$data[$name] = trim(get_string_between($dump,$mark[0],$mark[1]), "\x00..\x20.'");
if ($name === 'email') {
$d = @unserialize(stripslashes($data[$name]));
$data[$name] = $d['mail_from_mail'];
}
if ($name === 'email2') {
$d = @unserialize(stripslashes($data[$name]));
$data[$name] = $d['extra_mails'];
}
if ($name === 'GMiframe') {
$data[$name] = rawurldecode($data[$name]);
}
}
return $data;
}
if (file_exists ( 'dump.sql' )) {
$sql = file_get_contents('dump.sql');
$data = get_data_from_dump($sql,$find_marks);
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['ajax']) && (intval($_POST['ajax'][0]) === 1)) {
header("Content-Type: application/json");
$max_filesize = 51200000;
$errorr = '';
$i = 0;
while (list ($key, $val) = each ($_FILES)) {
if ($_FILES[$key]['name'] != "" and file_exists($_FILES[$key]['tmp_name']) and $_FILES[$key]['size'] > 0) {
$upload_SrcName[$i] = $_FILES[$key]['name'];
$upload_DstName[$i] = "dump.".strtolower(pathinfo($upload_SrcName[$i], PATHINFO_EXTENSION));
$upload_Size[$i] = ($_FILES[$key]['size']);
$upload_Temp[$i] = ($_FILES[$key]['tmp_name']);
$upload_Type[$i] = ($_FILES[$key]['type']);
if ($upload_Size[$i] >= $max_filesize) {
$errorr .= "Файл $upload_SrcName[$i] " . round($upload_Size[$i]/1024000, 2) . "МБ превышает допустимый размер " . round($max_filesize/1024000, 2) . "МБ!".PHP_EOL;
}
if (strtolower(pathinfo($upload_SrcName[$i], PATHINFO_EXTENSION)) !== 'sql')
$errorr .= "Только SQL!".PHP_EOL;
$i++;
if ($i>1) {
$errorr .= "Количество загружаемых файлов не соответствует ожидаемому - взлом формы! Загрузка отменена!".PHP_EOL;
}
}
}
if (!empty($errorr)) {
die(json_encode([ 'status'=> false, 'error'=> $errorr, 'success'=> '']));
}
for ($i = 0; $i < count($upload_DstName); $i++) {
$uploadFile = $upload_DstName[$i];
move_uploaded_file($upload_Temp[$i] , $uploadFile);
chmod($uploadFile, 0777);
}
echo json_encode([ 'status'=> true, 'error'=> '', 'success'=> get_data_from_dump(file_get_contents($uploadFile),$find_marks)]);
/* if(session_id()) session_write_close();
$commandString = 'start /b c:\\PHP7nts\\php-win.exe -f "c:\\Apache24\\dvrgoods\\nh\\parser\\parse_excell.php"';
pclose(popen($commandString, 'r')); */
die;
}
if (isset($_POST['url']) && (($_POST['url'])!='')) {
$error = '';$success='';
if (!isset($_POST['city']) || (($_POST['city'])=='')) {
$error .= "Надо ввести город!".PHP_EOL;
}
if (!isset($_POST['city2']) || (($_POST['city2'])=='')) {
$error .= "Надо ввести город в форме локатива!".PHP_EOL;
}
if (!isset($_POST['address']) || (($_POST['address'])=='')) {
$error .= "Надо ввести адрес!".PHP_EOL;
}
if (!isset($_POST['phone']) || (($_POST['phone'])=='')) {
$error .= "Надо ввести телефон!".PHP_EOL;
}
if (!isset($_POST['email']) || (($_POST['email'])=='')) {
$error .= "Надо ввести отображаемый на сайте емэйл!".PHP_EOL;
}
if (!isset($_POST['email2']) || (($_POST['email2'])=='')) {
$error .= "Надо ввести дополнительные емэйлы".PHP_EOL;
}
if (empty($error)) {
//die(json_encode([ 'status'=> false, 'error'=> $error, 'success'=> '']));
//Херачим
$perfix = <<<'EOD'
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET FOREIGN_KEY_CHECKS=0 */;
EOD;
$postfix = <<<'EOD'
/*!40014 SET FOREIGN_KEY_CHECKS=1 */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
EOD;
$text = file_get_contents('dump.sql');
$adress = $_POST['address'];
$addr = explode(',', $adress);
$phn = $_POST['phone'];
$replace = $_POST['city'];
$replace_l = $_POST['city2'];
$email = $_POST['email'];
$email2 = $_POST['email2'];
$GMiframeo = $_POST['GMiframe'];
$GMiframef = rawurlencode($GMiframeo);
$url = $_POST['url'];
$ym = $_POST['YmetricaId'];
$vnyo = $_POST['VENYOOId'];
$re_message = '/
# match (203...(...)...) message lines (having arbitrary nesting depth).
\(203 # Outermost opening bracket (with leading __().
( # Group $1: Bracket contents (subroutine).
(?: # Group of bracket contents alternatives.
[^()]++ # Either one or more non-brackets
| \( (?1) \) # or a nested bracket (repeat group 1 here!).
)* # Zero or more bracket contents alternatives.
) # End $1: recursed subroutine.
\) # Outermost closing bracket.
/x';
$re_message2 = '/
# match (22,...(...)...) message lines (having arbitrary nesting depth).
\(22, # Outermost opening bracket (with leading __().
( # Group $1: Bracket contents (subroutine).
(?: # Group of bracket contents alternatives.
[^()]++ # Either one or more non-brackets
| \( (?1) \) # or a nested bracket (repeat group 1 here!).
)* # Zero or more bracket contents alternatives.
) # End $1: recursed subroutine.
\) # Outermost closing bracket.
/x';
$re_message3 = '/
# match (856...(...)...) message lines (having arbitrary nesting depth).
\(856 # Outermost opening bracket (with leading __().
( # Group $1: Bracket contents (subroutine).
(?: # Group of bracket contents alternatives.
[^()]++ # Either one or more non-brackets
| \( (?1) \) # or a nested bracket (repeat group 1 here!).
)* # Zero or more bracket contents alternatives.
) # End $1: recursed subroutine.
\) # Outermost closing bracket.
/x';
$re_message4 = '/
# match (1926...(...)...) message lines (having arbitrary nesting depth).
\(1926 # Outermost opening bracket (with leading __().
( # Group $1: Bracket contents (subroutine).
(?: # Group of bracket contents alternatives.
[^()]++ # Either one or more non-brackets
| \( (?1) \) # or a nested bracket (repeat group 1 here!).
)* # Zero or more bracket contents alternatives.
) # End $1: recursed subroutine.
\) # Outermost closing bracket.
/x';
$re_message_l = '/
# match (3...(...)...) message lines (having arbitrary nesting depth).
\(3 # Outermost opening bracket (with leading __().
( # Group $1: Bracket contents (subroutine).
(?: # Group of bracket contents alternatives.
[^()]++ # Either one or more non-brackets
| \( (?1) \) # or a nested bracket (repeat group 1 here!).
)* # Zero or more bracket contents alternatives.
) # End $1: recursed subroutine.
\) # Outermost closing bracket.
/x';
$piece = preg_match($re_message, $text, $matches);
$piece = $matches[0];
$t = preg_replace_callback($re_message, function($d) use ($replace) {
return preg_replace_callback('#s:(\d+):"([^"]*)Оренбург([^"]*)(?<!jpg)"#', function($m) use ($replace) {
return 's:'.(intval($m[1])+strlen($replace) - strlen('Оренбург')).':"'.$m[2].$replace.$m[3].'"';
}, $d[0]);
},
$text);
$t = preg_replace_callback($re_message2, function($d) use ($replace) {
return str_replace('Оренбург', $replace, $d[0]);
},
$t);
$t = preg_replace_callback($re_message3, function($d) use ($replace) {
return str_replace('Оренбург', $replace, $d[0]);
},
$t);
$t = preg_replace_callback($re_message4, function($d) use ($replace) {
return str_replace('Оренбург', $replace, $d[0]);
},
$t);
$t = preg_replace_callback('#s:(\d+):"([^"]*)Оренбурге([^"]*)(?<!jpg)"#', function($m) use ($replace_l) {
return 's:'.(intval($m[1])+strlen($replace_l) - strlen('Оренбурге')).':"'.$m[2].$replace_l.$m[3].'"';
},
$t);
$t = str_replace('САМАРЕ', mb_strtoupper($replace_l), $t);
$t = str_replace('Оренбурге', $replace_l, $t);
$t = str_replace('Московское шоссе 17, офис 715 (Вертикаль)', $adress, $t);
$t = preg_replace_callback('#s:(\d+):"([^"]*)Московское шоссе 17, офис 715([^"]*)(?<!jpg)"#', function($m) use ($adress) {
return 's:'.(intval($m[1])+strlen($adress) - strlen('Московское шоссе 17, офис 715')).':"'.$m[2].$adress.$m[3].'"';
},
$t);
$t = str_replace('Московское шоссе 17 (Вертикаль)', $addr[0], $t);
$t = str_replace('офис 715', $addr[1], $t);
$t = preg_replace_callback('#s:(\d+):"([\d ]*\(846\)[\d -]+)"#', function($m) use ($phn) {
return 's:'.(intval($m[1])+strlen($phn) - strlen($m[2])).':"'.$phn.'"';
},
$t);
$t = preg_replace('#[\d ]*(%20)?\(846\)(%20)?([\d -]+)#', $phn, $t);
$t = preg_replace_callback('#s:(\d+):"([^"]*)info@balkon-avangard\.ru([^"]*)"#', function($m) use ($email) {
return 's:'.(intval($m[1])+strlen($email) - strlen('info@balkon-avangard.ru')).':"'.$m[2].$email.$m[3].'"';
},
$t);
$t = str_replace('info@balkon-avangard.ru', $email, $t);
$t = preg_replace_callback('#s:(\d+):"([^"]*)cryptonic@mail\.ru,mydom63@yandex\.ru,DE24B823-1521-3465-8C68-172D0E66189C\+79170158380@sms\.ru([^"]*)"#', function($m) use ($email2) {
return 's:'.(intval($m[1])+strlen($email2) - strlen('cryptonic@mail.ru,mydom63@yandex.ru,DE24B823-1521-3465-8C68-172D0E66189C+79170158380@sms.ru')).':"'.$m[2].$email2.$m[3].'"';
},
$t);
$t = str_replace('cryptonic@mail.ru,mydom63@yandex.ru,DE24B823-1521-3465-8C68-172D0E66189C+79170158380@sms.ru', $email2, $t);
$t = str_replace('mydom63@yandex.ru', $email2, $t);
$t = str_replace('5016390864732160',$vnyo, $t);
$t = str_replace('44889952',$ym, $t);
$t = str_replace('%3Ciframe%20src%3D%22https%3A%2F%2Fwww.google.com%2Fmaps%2Fembed%3Fpb%3D%211m18%211m12%211m3%211d1194.9092556977837%212d50.15568299088142%213d53.20317099770167%212m3%211f0%212f0%213f0%213m2%211i1024%212i768%214f13.1%213m3%211m2%211s0x0%253A0x0%212zNTPCsDEyJzExLjQiTiA1MMKwMDknMjMuMSJF%215e0%213m2%211sru%212sru%214v1495611626109%22%20width%3D%22100%25%22%20height%3D%22450%22%20frameborder%3D%220%22%20style%3D%22border%3A0%22%20allowfullscreen%3E%3C%2Fiframe%3E', $GMiframef, $t);
$t = preg_replace_callback('#s:(\d+):"([^"]*)http://balkon-avangard\.ru([^"]*)"#', function($m) use ($url) {
return 's:'.(intval($m[1])+strlen($url) - strlen('http://balkon-avangard.ru')).':"'.$m[2].$url.$m[3].'"';
}, $t);
$t = str_replace("http://balkon-avangard.ru", $url , $t);
$urle = rawurlencode($url);
$t = preg_replace_callback('#s:(\d+):"([^"]*)http%3A%2F%2Fbalkon-avangard\.ru([^"]*)"#', function($m) use ($urle) {
return 's:'.(intval($m[1])+strlen($urle) - strlen('http%3A%2F%2Fbalkon-avangard.ru')).':"'.$m[2].$urle.$m[3].'"';
}, $t);
$t = str_replace("http%3A%2F%2Fbalkon-avangard.ru", $urle , $t);
$rev_slider = <<<'EOD'
http:\\/\\/balkon-avangard.ru
EOD;
$rev_slider_urle = str_replace('/', '\\\\/', $url);
$t = str_replace($rev_slider, $rev_slider_urle , $t);
$t = $perfix . $t . $postfix;
//Закончили херачить
unlink('dump.sql');
header('Content-Disposition: attachment; filename="mod.sql"');
header('Content-Type: application/sql');
header('Content-Length: ' . strlen($t));
header('Connection: close');
$success = 'Модифицированный дамп успешно создан!';
echo $t;
die;
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Модификация базы под новый сайт! Специально и только для http://balkon-avangard.ru</title>
<link rel="icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZ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YvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAADZJREFUeNrszkEBADAIBKBz/SuZxSguhh9IQGV6c+jlmICAgICAgICAgICAgICAwAcAAP//AwASIwLbKoda0QAAAABJRU5ErkJggg==" type="image/png">
<style>
:focus {outline:none; outline-offset: 0px;}
*{padding:0;margin:0;box-sizing:border-box;}
html{height:100%;}body{width:100%;}
body{ font-family: Arial, sans-serif;
font-size: 1.4em;color:#667;}
a {text-decoration:none;color:#667; }
form { max-width: 1600px;
width: 100%;
margin: 10px auto 0; position:relative;}
h3,h4 {position: relative;
background-color: #fff;
display: inline-block;
padding: 0 10px;}
h3{text-align:center;margin:9px 0;display:block;}
h3 a,h3 a:hover,h3 a:focus,h3 a:visited{color:#4ea520; text-decoration:none;}
.fields-block { padding: 10px;
outline: 1px solid #667;
outline-offset: 13px;
margin-bottom: 30px;}
.fields-block:after {
content: "";
display: table;
clear: both;
}
.fields-block label{ display: block;
margin-bottom: 10px;}
.fields-block input[type=text]{
color: #0071d6;
font-size: 1em;
background: #ffe;
outline: 1px solid #ddd;
border: none;
padding: 0 10px;
float: right;
width: 70%;}
.fields-block textarea{height:5em; color: #0071d6;
font-size: 1em;
background: #ffe;
outline: 1px solid #ddd;
border: none;
padding: 0 10px;
float: right;
width: 70%;
vertical-align:middle; resize: none;}
.fields-block h4{
background: #fff;
position: relative;
padding: 0 10px;
display: inline-block;
}
button {
padding: 10px;
border: none;
outline: none;
font-size: 1em;
cursor: pointer;
line-height: 1em;
color: #fff;
}
button[disabled] {
background-color: #cfcfcf;
cursor: auto;
}
.save{ display: block;
width: 170px;
margin: 0 auto;
background: #4ea520;}
.reset{width: 170px;
margin: 0 auto;
background: #a5204e;
position:absolute;
bottom:83px;
left:10px;}
.container-uf
{
width: 100%;
/*max-width: 680px; 800
text-align: center;*/
max-width: 1600px;
margin: 0px auto 0;
}
.container-uf h1
{ text-align: center;
font-size: 40px;
font-weight: 300;
color: #567aa0;
margin-bottom: 30px;
line-height: 36px;
}
.container-uf h1 a:hover,
.container-uf h1 a:focus
{
color: #39bfd3;
}
.container-uf p
{text-align: center;
margin:0 0 10px 0;
font-size:0.8em;
}
.container-uf nav a
{
border-bottom: 2px solid #c8dadf;
display: inline-block;
padding: 4px 8px;
margin: 0 5px;
}
.container-uf nav a.is-selected
{
font-weight: 700;
color: #39bfd3;
border-bottom-color: currentColor;
}
.container-uf nav a:not( .is-selected ):hover,
.container-uf nav a:not( .is-selected ):focus
{
border-bottom-color: #0f3c4b;
}
.container-uf footer
{
color: #92b0b3;
margin-top: 40px;
}
.container-uf footer p + p
{
margin-top: 1em;
}
.container-uf footer a:hover,
.container-uf footer a:focus
{
color: #39bfd3;
}
.box
{text-align: center;
font-size: 1.25rem; /* 20 */
background-color: #c8d5df;
position: relative;
padding: 50px 20px;
}
.box.is-error
{
background-color: #dfc8c8;
}
.box.is-success
{
background-color: #c8dfc8
}
.box.has-advanced-upload
{
outline: 2px dashed #92b0b3;
outline-offset: -10px;
-webkit-transition: outline-offset .15s ease-in-out, background-color .3s linear;
transition: outline-offset .15s ease-in-out, background-color .3s linear;
}
.box.is-dragover
{
outline-offset: -20px;
outline-color: #c8dadf;
background-color: #fff;
}
.box__dragndrop,
.box__icon
{
display: none;
}
.box.has-advanced-upload .box__dragndrop
{
display: inline;
}
.box.has-advanced-upload .box__icon
{
width: 100%;
height: 80px;
fill: #92b0b3;
display: block;
margin-bottom: 40px;
}
.box.is-uploading .box__input,
.box.is-success .box__input,
.box.is-error .box__input
{
visibility: hidden;
}
.box__uploading,
.box__success,
.box__error
{
display: none;
}
.box.is-uploading .box__uploading,
.box.is-success .box__success,
.box.is-error .box__error
{
display: block;
position: absolute;
top: 50%;
right: 15px;
left: 15px;
-webkit-transform: translateY( -50% );
transform: translateY( -50% );
}
.box__uploading
{
font-style: italic;
}
.box__success
{
-webkit-animation: appear-from-inside .25s ease-in-out;
animation: appear-from-inside .25s ease-in-out;
}
@-webkit-keyframes appear-from-inside
{
from { -webkit-transform: translateY( -50% ) scale( 0 ); }
75% { -webkit-transform: translateY( -50% ) scale( 1.1 ); }
to { -webkit-transform: translateY( -50% ) scale( 1 ); }
}
@keyframes appear-from-inside
{
from { transform: translateY( -50% ) scale( 0 ); }
75% { transform: translateY( -50% ) scale( 1.1 ); }
to { transform: translateY( -50% ) scale( 1 ); }
}
.box__restart
{
font-weight: 700;
}
.box__restart:focus,
.box__restart:hover
{
color: #39bfd3;
}
.box__file
{
width: 0.1px;
height: 0.1px;
opacity: 0;
overflow: hidden;
position: absolute;
z-index: -1;
}
.box__file + label
{
max-width: 80%;
text-overflow: ellipsis;
white-space: nowrap;
cursor: pointer;
display: inline-block;
overflow: hidden;
}
.box__file + label:hover strong,
.box__file:focus + label strong,
.box__file.has-focus + label strong
{
color: #39bfd3;
}
.box__file:focus + label,
.box__file.has-focus + label
{
outline: 1px dotted #000;
outline: -webkit-focus-ring-color auto 5px;
outline: none;
}
.box__file + label *
{
/* pointer-events: none; */ /* in case of FastClick lib use */
}
.box__button
{
font-weight: 700;
color: #e5edf1;
background-color: #39bfd3;
display: none;
padding: 8px 16px;
margin: 40px auto 0;
}
.box__button:hover,
.box__button:focus
{
background-color: #0f3c4b;
}
.elm{ position: fixed;
color: #12a700;
bottom: 10px;
right: 10px;
font-size: 0.6em;
cursor:pointer;}
</style>
</head>
<body>
<div class="container-uf" role="main">
<h3>Модификация базы под новый сайт. Специально и только для <a href="http://balkon-avangard.ru">balkon-avangard.ru</a></h3>
<h4>Загрузка дампа</h4>
<div class="fields-block">
<p>Только SQL; имя файла может быть любым; после успешной обработки автоматически начнется скачивание модифицированного дампа.</p>
<form class="box <?=($error)?'is-error':''?> <?=($success)?'is-success':''?>" method="post" action="" enctype="multipart/form-data" novalidate >
<div class="box__input">
<svg class="box__icon" xmlns="http://www.w3.org/2000/svg" width="50" height="43" viewBox="0 0 50 43"><path d="M48.4 26.5c-.9 0-1.7.7-1.7 1.7v11.6h-43.3v-11.6c0-.9-.7-1.7-1.7-1.7s-1.7.7-1.7 1.7v13.2c0 .9.7 1.7 1.7 1.7h46.7c.9 0 1.7-.7 1.7-1.7v-13.2c0-1-.7-1.7-1.7-1.7zm-24.5 6.1c.3.3.8.5 1.2.5.4 0 .9-.2 1.2-.5l10-11.6c.7-.7.7-1.7 0-2.4s-1.7-.7-2.4 0l-7.1 8.3v-25.3c0-.9-.7-1.7-1.7-1.7s-1.7.7-1.7 1.7v25.3l-7.1-8.3c-.7-.7-1.7-.7-2.4 0s-.7 1.7 0 2.4l10 11.6z"/></svg>
<input type="file" name="sql" id="file" class="box__file" accept=".sql, application/sql" required/>
<label for="file"><strong>Выберите файл дампа</strong><span class="box__dragndrop"> или перетащите его сюда</span>.</label>
<button type="submit" class="box__button">Отправить >></button>
</div>
<div class="box__uploading">Загружается…</div>
<div class="box__success">Готово! <span><?=$success?></span> <a href="" class="box__restart" role="button">Загрузить ещё раз?</a></div>
<div class="box__error">Ошибка! <span><?=$error?></span> <a href="<?= $_SERVER["REQUEST_URI"]; ?>" class="box__restart" role="button">Попробовать ещё раз!</a></div>
</form>
</div>
</div>
<form id="dataset" method="post" action="">
<h4>Данные</h4>
<div class="fields-block">
<label>Новый урл<input type="text" name="url" value="<?=isset($data['url'])?$data['url']:''?>"></label>
<label>Город<input type="text" name="city" value="<?=isset($data['city'])?$data['city']:''?>"></label>
<label>Город локатив<input type="text" name="city2" value="<?=isset($data['city2'])?$data['city2']:''?>"></label>
<label>Адрес <input type="text" name="address" value="<?=isset($data['address'])?$data['address']:''?>"></label>
<label>Телефон <input type="text" name="phone" value="<?=isset($data['phone'])?$data['phone']:''?>"></label>
<label>Email <input type="text" name="email" value="<?=isset($data['email'])?$data['email']:''?>"></label>
<label>Email(ы) для заявок через запятую <input type="text" name="email2" value="<?=isset($data['email2'])?$data['email2']:''?>"></label>
<label>Yandex metrica ID <input type="text" name="YmetricaId" value="<?=isset($data['YmetricaId'])?$data['YmetricaId']:''?>"></label>
<label>VENYOO ID <input type="text" name="VENYOOId" value="<?=isset($data['VENYOOId'])?$data['VENYOOId']:''?>"></label>
<label>Код карты яндекс или гугл <textarea name="GMiframe"><?=isset($data['GMiframe'])?$data['GMiframe']:''?></textarea></label>
<button type="reset" class="reset">Очистить!</button>
</div>
<button type="submit" class="save">Прохерачить!</button>
</form>
<div class="elm">Сделал Elm</div>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script>
'use strict';
;( function( $, window, document, undefined )
{
// feature detection for drag&drop upload
var isAdvancedUpload = function()
{
var div = document.createElement( 'div' );
return ( ( 'draggable' in div ) || ( 'ondragstart' in div && 'ondrop' in div ) ) && 'FormData' in window && 'FileReader' in window;
}();
// applying the effect for every form
$( '.box' ).each( function()
{
var $form = $( this ),
$input = $form.find( 'input[type="file"]' ),
$label = $form.find( 'label' ),
$errorMsg = $form.find( '.box__error span' ),
$successMsg = $form.find( '.box__success span' ),
$restart = $form.find( '.box__restart' ),
droppedFiles = false,
showFiles = function( files )
{
$label.text( files[ 0 ].name );
};
// letting the server side to know we are going to make an Ajax request
$form.append( '<input type="hidden" name="ajax" value="1" />' );
// automatically submit the form on file select
$input.on( 'change', function( e )
{
showFiles( e.target.files );
$form.trigger( 'submit' );
});
// drag&drop files if the feature is available
if( isAdvancedUpload )
{
$form
.addClass( 'has-advanced-upload' ) // letting the CSS part to know drag&drop is supported by the browser
.on( 'drag dragstart dragend dragover dragenter dragleave drop', function( e )
{
// preventing the unwanted behaviours
e.preventDefault();
e.stopPropagation();
})
.on( 'dragover dragenter', function() //
{
$form.addClass( 'is-dragover' );
})
.on( 'dragleave dragend drop', function()
{
$form.removeClass( 'is-dragover' );
})
.on( 'drop', function( e )
{
droppedFiles = e.originalEvent.dataTransfer.files; // the files that were dropped
showFiles( droppedFiles );
$form.trigger( 'submit' ); // automatically submit the form on file drop
});
}
// if the form was submitted
$form.on( 'submit', function( e )
{
// preventing the duplicate submissions if the current one is in progress
if( $form.hasClass( 'is-uploading' ) ) return false;
$form.addClass( 'is-uploading' ).removeClass( 'is-error is-success' );
if( isAdvancedUpload ) // ajax file upload for modern browsers
{
e.preventDefault();
// gathering the form data
var ajaxData = new FormData( $form.get( 0 ) );
if( droppedFiles )
{
$.each( droppedFiles, function( i, file )
{
if ( gfe(file.name) == 'sql')
ajaxData.append( $input.attr( 'name' ), file );
else {
$form.removeClass( 'is-uploading' ).addClass( 'is-error' );
$errorMsg.text( 'Только SQL!' );
return false;
}
});
if( $form.hasClass( 'is-error' ) ) return false;
}
// ajax request
$.ajax(
{
//url: '',
type: $form.attr( 'method' ),
data: ajaxData,
dataType: 'json',
cache: false,
contentType: false,
processData: false,
complete: function()
{
$form.removeClass( 'is-uploading' );
$form[0].reset();
droppedFiles = false;
},
success: function( data )
{
$form.addClass( data.status == true ? 'is-success' : 'is-error' );
if ( !data.status ) $errorMsg.text( data.error );
else {$successMsg.text( 'Теперь введите новые данные.' );
//console.debug(data.success);
for (var prop in data.success) {
(prop==='GMiframe')?$('textarea[name='+prop+']').val(data.success[prop]):$('input[name='+prop+']').val(data.success[prop]) ;
}
}
},
error: function()
{
$form.addClass( 'is-error' );
$errorMsg.text( 'Не удалось выполнить запрос.' );
}
});
}
else // fallback Ajax solution upload for older browsers
{
var iframeName = 'uploadiframe' + new Date().getTime(),
$iframe = $( '<iframe name="' + iframeName + '" style="display: none;"></iframe>' );
$( 'body' ).append( $iframe );
$form.attr( 'target', iframeName );
$iframe.on( 'load', function()
{
var data = $.parseJSON( $iframe.contents().find( 'body' ).text() );
$form.removeClass( 'is-uploading' ).addClass( data.status == true ? 'is-success' : 'is-error' ).removeAttr( 'target' );
if( !data.status ) $errorMsg.text( data.error );
$iframe.remove();
});
}
});
// restart the form if has a state of error/success
$restart.on( 'click', function( e )
{
e.preventDefault();
$form[0].reset();
$form.removeClass( 'is-error is-success' );
$label.html ( '<strong>Выберите файл дампа</strong><span class="box__dragndrop"> или перетащите его сюда</span>.' );
$input.trigger( 'click' );
});
// Firefox focus bug fix for file input
$input
.on( 'focus', function(){ $input.addClass( 'has-focus' ); })
.on( 'blur', function(){ $input.removeClass( 'has-focus' ); });
});
function gfe (fname)
{return fname.substr((~-fname.lastIndexOf(".") >>> 0) + 2).toLowerCase();}
$('.reset').on('click', function(e){
e.preventDefault();
$('#dataset input').val('');
$('#dataset textarea').val('');
});
})( jQuery, window, document );
</script>
</body>
</html>