Added some trimming around some VARCHAR records
This commit is contained in:
parent
7972a197ee
commit
5d5f8c4af7
|
@ -35,32 +35,34 @@ if(!isset($_SESSION['type']) || $_SESSION['type'] != "admin") {
|
||||||
|
|
||||||
if(isset($input->action) && $input->action == "addDomain") {
|
if(isset($input->action) && $input->action == "addDomain") {
|
||||||
$soaData = Array();
|
$soaData = Array();
|
||||||
$soaData[] = $input->primary;
|
$soaData[] = trim($input->primary);
|
||||||
$soaData[] = mail_to_soa($input->mail);
|
$soaData[] = trim(mail_to_soa($input->mail));
|
||||||
$soaData[] = date("Ymd") . "00";
|
$soaData[] = date("Ymd") . "00";
|
||||||
$soaData[] = $input->refresh;
|
$soaData[] = $input->refresh;
|
||||||
$soaData[] = $input->retry;
|
$soaData[] = $input->retry;
|
||||||
$soaData[] = $input->expire;
|
$soaData[] = $input->expire;
|
||||||
$soaData[] = $input->ttl;
|
$soaData[] = $input->ttl;
|
||||||
|
|
||||||
|
$domainsName = trim($input->name);
|
||||||
|
|
||||||
$soaContent = implode(" ", $soaData);
|
$soaContent = implode(" ", $soaData);
|
||||||
|
|
||||||
$db->beginTransaction();
|
$db->beginTransaction();
|
||||||
|
|
||||||
$stmt = $db->prepare("INSERT INTO domains(name,type) VALUES (:name,:type)");
|
$stmt = $db->prepare("INSERT INTO domains(name,type) VALUES (:name,:type)");
|
||||||
$stmt->bindValue(':name', $input->name, PDO::PARAM_STR);
|
$stmt->bindValue(':name', $domainsName, PDO::PARAM_STR);
|
||||||
$stmt->bindValue(':type', $input->type, PDO::PARAM_STR);
|
$stmt->bindValue(':type', $input->type, PDO::PARAM_STR);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$stmt = $db->prepare("SELECT MAX(id) FROM domains WHERE name=:name AND type=:type");
|
$stmt = $db->prepare("SELECT MAX(id) FROM domains WHERE name=:name AND type=:type");
|
||||||
$stmt->bindValue(':name', $input->name, PDO::PARAM_STR);
|
$stmt->bindValue(':name', $domainsName, PDO::PARAM_STR);
|
||||||
$stmt->bindValue(':type', $input->type, PDO::PARAM_STR);
|
$stmt->bindValue(':type', $input->type, PDO::PARAM_STR);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$newDomainId = $stmt->fetchColumn();
|
$newDomainId = $stmt->fetchColumn();
|
||||||
|
|
||||||
$stmt = $db->prepare("INSERT INTO records(domain_id,name,type,content,ttl) VALUES (:domain_id,:name,'SOA',:content,:ttl)");
|
$stmt = $db->prepare("INSERT INTO records(domain_id,name,type,content,ttl) VALUES (:domain_id,:name,'SOA',:content,:ttl)");
|
||||||
$stmt->bindValue(':domain_id', $newDomainId, PDO::PARAM_INT);
|
$stmt->bindValue(':domain_id', $newDomainId, PDO::PARAM_INT);
|
||||||
$stmt->bindValue(':name', $input->name, PDO::PARAM_STR);
|
$stmt->bindValue(':name', $domainsName, PDO::PARAM_STR);
|
||||||
$stmt->bindValue(':content', $soaContent, PDO::PARAM_STR);
|
$stmt->bindValue(':content', $soaContent, PDO::PARAM_STR);
|
||||||
$stmt->bindValue(':ttl', $input->ttl, PDO::PARAM_INT);
|
$stmt->bindValue(':ttl', $input->ttl, PDO::PARAM_INT);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
|
@ -184,8 +184,8 @@ if(isset($input->action) && $input->action == "saveSoa") {
|
||||||
$content = explode(" ", $content);
|
$content = explode(" ", $content);
|
||||||
$serial = $content[2];
|
$serial = $content[2];
|
||||||
|
|
||||||
$newsoa = $input->primary . " ";
|
$newsoa = trim($input->primary) . " ";
|
||||||
$newsoa .= mail_to_soa($input->email) . " ";
|
$newsoa .= trim(mail_to_soa($input->email)) . " ";
|
||||||
$newsoa .= $serial . " ";
|
$newsoa .= $serial . " ";
|
||||||
$newsoa .= $input->refresh . " ";
|
$newsoa .= $input->refresh . " ";
|
||||||
$newsoa .= $input->retry . " ";
|
$newsoa .= $input->retry . " ";
|
||||||
|
@ -208,11 +208,13 @@ if(isset($input->action) && $input->action == "saveSoa") {
|
||||||
//Action for saving Record
|
//Action for saving Record
|
||||||
if(isset($input->action) && $input->action == "saveRecord") {
|
if(isset($input->action) && $input->action == "saveRecord") {
|
||||||
$domainId = $input->domain;
|
$domainId = $input->domain;
|
||||||
|
$recordName = trim($input->name);
|
||||||
|
$recordContent = trim($input->content);
|
||||||
|
|
||||||
$stmt = $db->prepare("UPDATE records SET name=:name,type=:type,content=:content,ttl=:ttl,prio=:prio WHERE id=:id AND domain_id=:domain_id");
|
$stmt = $db->prepare("UPDATE records SET name=:name,type=:type,content=:content,ttl=:ttl,prio=:prio WHERE id=:id AND domain_id=:domain_id");
|
||||||
$stmt->bindValue(':name', $input->name, PDO::PARAM_STR);
|
$stmt->bindValue(':name', $recordName, PDO::PARAM_STR);
|
||||||
$stmt->bindValue(':type', $input->type, PDO::PARAM_STR);
|
$stmt->bindValue(':type', $input->type, PDO::PARAM_STR);
|
||||||
$stmt->bindValue(':content', $input->content, PDO::PARAM_STR);
|
$stmt->bindValue(':content', $recordContent, PDO::PARAM_STR);
|
||||||
$stmt->bindValue(':ttl', $input->ttl, PDO::PARAM_INT);
|
$stmt->bindValue(':ttl', $input->ttl, PDO::PARAM_INT);
|
||||||
$stmt->bindValue(':prio', $input->prio, PDO::PARAM_INT);
|
$stmt->bindValue(':prio', $input->prio, PDO::PARAM_INT);
|
||||||
$stmt->bindValue(':id', $input->id, PDO::PARAM_INT);
|
$stmt->bindValue(':id', $input->id, PDO::PARAM_INT);
|
||||||
|
@ -224,22 +226,25 @@ if(isset($input->action) && $input->action == "saveRecord") {
|
||||||
//Action for adding Record
|
//Action for adding Record
|
||||||
if(isset($input->action) && $input->action == "addRecord") {
|
if(isset($input->action) && $input->action == "addRecord") {
|
||||||
$domainId = $input->domain;
|
$domainId = $input->domain;
|
||||||
|
$recordName = trim($input->name);
|
||||||
|
$recordContent = trim($input->content);
|
||||||
|
|
||||||
$db->beginTransaction();
|
$db->beginTransaction();
|
||||||
|
|
||||||
$stmt = $db->prepare("INSERT INTO records (domain_id, name, type, content, prio, ttl) VALUES (:domain_id,:name,:type,:content,:prio,:ttl)");
|
$stmt = $db->prepare("INSERT INTO records (domain_id, name, type, content, prio, ttl) VALUES (:domain_id,:name,:type,:content,:prio,:ttl)");
|
||||||
$stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT);
|
$stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT);
|
||||||
$stmt->bindValue(':name', $input->name, PDO::PARAM_STR);
|
$stmt->bindValue(':name', $recordName, PDO::PARAM_STR);
|
||||||
$stmt->bindValue(':type', $input->type, PDO::PARAM_STR);
|
$stmt->bindValue(':type', $input->type, PDO::PARAM_STR);
|
||||||
$stmt->bindValue(':content', $input->content, PDO::PARAM_STR);
|
$stmt->bindValue(':content', $recordContent, PDO::PARAM_STR);
|
||||||
$stmt->bindValue(':ttl', $input->ttl, PDO::PARAM_INT);
|
$stmt->bindValue(':ttl', $input->ttl, PDO::PARAM_INT);
|
||||||
$stmt->bindValue(':prio', $input->prio, PDO::PARAM_INT);
|
$stmt->bindValue(':prio', $input->prio, PDO::PARAM_INT);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$stmt = $db->prepare("SELECT MAX(id) FROM records WHERE domain_id=:domain_id AND name=:name AND type=:type AND content=:content AND prio=:prio AND ttl=:ttl");
|
$stmt = $db->prepare("SELECT MAX(id) FROM records WHERE domain_id=:domain_id AND name=:name AND type=:type AND content=:content AND prio=:prio AND ttl=:ttl");
|
||||||
$stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT);
|
$stmt->bindValue(':domain_id', $domainId, PDO::PARAM_INT);
|
||||||
$stmt->bindValue(':name', $input->name, PDO::PARAM_STR);
|
$stmt->bindValue(':name', $recordName, PDO::PARAM_STR);
|
||||||
$stmt->bindValue(':type', $input->type, PDO::PARAM_STR);
|
$stmt->bindValue(':type', $input->type, PDO::PARAM_STR);
|
||||||
$stmt->bindValue(':content', $input->content, PDO::PARAM_STR);
|
$stmt->bindValue(':content', $recordContent, PDO::PARAM_STR);
|
||||||
$stmt->bindValue(':ttl', $input->ttl, PDO::PARAM_INT);
|
$stmt->bindValue(':ttl', $input->ttl, PDO::PARAM_INT);
|
||||||
$stmt->bindValue(':prio', $input->prio, PDO::PARAM_INT);
|
$stmt->bindValue(':prio', $input->prio, PDO::PARAM_INT);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
Loading…
Reference in a new issue