<?php /** * Created by PhpStorm. * User: a6y * Date: 25.08.15 * Time: 16:16 */ require_once 'src/autoload.php'; $checker = new \Parser\Checker(); $return = array('Type' => 'Error', 'Mess' => 'Неизвестная ошибка'); if (!empty($_POST['algo']) && array_key_exists($_POST['algo'], $checker->getAlgo())) { if (!empty($_POST['filters']) && is_array($_POST['filters'])) { $filters = array_intersect(array_keys($checker->getFilters()), $_POST['filters']); if (!empty($filters)) { if ($checker->setOldDomain((string) $_POST['old_url'])) { if ($checker->setNewDomain((string) $_POST['new_url'])) { $threads = empty($_POST['threads']) ? 10 : intval($_POST['threads']); $return = array('Type' => 'Ok', 'Data' => json_encode($checker->run((string) $_POST['algo'], $filters, $threads))); } else { $return = array('Type' => 'Error', 'Mess' => 'Неверный новый домен'); } } else { $return = array('Type' => 'Error', 'Mess' => 'Неверный старый домен'); } } else { $return = array('Type' => 'Error', 'Mess' => 'Неверный фильтр'); } } else { $return = array('Type' => 'Error', 'Mess' => 'Не выбран не один фильтр'); }
<form class="compare-form ajax-form" method="POST" action="ajax_compare.php"> <div class="form-group"> <label for="algo">Алгоритм оценки:</label> <?foreach ($checker->getAlgo() as $name => $obj):?> <label class="radio-inline"><input type="radio" id="algo" name="algo" value="<?php echo $name; ?> "><?php echo $name; ?> </label> <?endforeach;?> </div> <div class="form-group"> <label for="filters">Фильтры:</label> <?foreach ($checker->getFilters() as $name => $obj):?> <label class="checkbox-inline"><input name='filters[]' type="checkbox" value="<?php echo $name; ?> "><?php echo $name; ?> </label> <?endforeach;?> </div> <div class="form-group"> <input type="text" class="form-control" id="old_url" name="old_url" placeholder="Старый домен (без www)" value=""> </div> <div class="form-group"> <input type="text" class="form-control" id="new_url" name="new_url" placeholder="Новый домен" value=""> </div>