This commit has been accessed 914 times via Git panel.
commit fad04c570edf82e4bcab26724660cd600bbcf23c
tree 52316ec10a1dd49dccdd0266433a14e5c7fcc33b
parent 2f785d86eda00c58cd3ce3065836bab2c993081e
author Engels Antonio <engels@majcms.org> 1353888186 +0800
committer Engels Antonio <engels@majcms.org> 1353888186 +0800
Add contacts clean up for deleted domains
diff --git a/index.php b/index.php
index 3cabb5c..9b01025 100644
--- a/index.php
+++ b/index.php
@@ -300,7 +300,7 @@ if (isset($_SESSION['logged_uid'])) {
$a_fname = ucwords(trim(strip_tags($_POST['a_fname'])));
$a_lname = ucwords(trim(strip_tags($_POST['a_lname'])));
- $addr_query = mysql_query("create table if not exists contacts (id varchar(255) not null, lname varchar(64) not null, fname varchar(64) not null, email varchar(255) not null);");
+ $addr_query = mysql_query("create table if not exists contacts (id varchar(255) not null, lname varchar(64) not null, fname varchar(64) not null, email varchar(255) not null, domain varchar(128) not null);");
$addr_query = mysql_query("select * from contacts where id='{$_SESSION['logged_uid']}' and email='$a_email';");
@@ -308,7 +308,7 @@ if (isset($_SESSION['logged_uid'])) {
nak("$a_email exists");
}
else {
- $addr_query = mysql_query("insert into contacts values('{$_SESSION['logged_uid']}','$a_lname','$a_fname','$a_email');");
+ $addr_query = mysql_query("insert into contacts values('{$_SESSION['logged_uid']}','$a_lname','$a_fname','$a_email','{$usr_data[4]}');");
if (isset($_FILES['a_photo']) and !empty($_FILES['a_photo'])) {
@@ -914,7 +914,19 @@ if (isset($_SESSION['logged_uid'])) {
if (isset($_POST['dom_del']) and !empty($_POST['dom_del'])) {
$dom_del = trim($_POST['dom_del']);
-
+
+ $dom_query = mysql_query("select id from users where domain='$dom_del'");
+
+ while ($dom_id = mysql_fetch_array($dom_query)) {
+
+ $dom_id = sha1($dom_id[id]);
+
+ if (file_exists("images/contacts/$dom_id")) {
+ rmdirr("images/contacts/$dom_id");
+ }
+ }
+
+ $dom_query = mysql_query("delete from contacts where domain='$dom_del'");
$dom_query = mysql_query("delete from aliases where domain='$dom_del'");
$dom_query = mysql_query("delete from users where domain='$dom_del'");
$dom_query = mysql_query("delete from domains where id='$dom_del'");
tree 52316ec10a1dd49dccdd0266433a14e5c7fcc33b
parent 2f785d86eda00c58cd3ce3065836bab2c993081e
author Engels Antonio <engels@majcms.org> 1353888186 +0800
committer Engels Antonio <engels@majcms.org> 1353888186 +0800
Add contacts clean up for deleted domains
diff --git a/index.php b/index.php
index 3cabb5c..9b01025 100644
--- a/index.php
+++ b/index.php
@@ -300,7 +300,7 @@ if (isset($_SESSION['logged_uid'])) {
$a_fname = ucwords(trim(strip_tags($_POST['a_fname'])));
$a_lname = ucwords(trim(strip_tags($_POST['a_lname'])));
- $addr_query = mysql_query("create table if not exists contacts (id varchar(255) not null, lname varchar(64) not null, fname varchar(64) not null, email varchar(255) not null);");
+ $addr_query = mysql_query("create table if not exists contacts (id varchar(255) not null, lname varchar(64) not null, fname varchar(64) not null, email varchar(255) not null, domain varchar(128) not null);");
$addr_query = mysql_query("select * from contacts where id='{$_SESSION['logged_uid']}' and email='$a_email';");
@@ -308,7 +308,7 @@ if (isset($_SESSION['logged_uid'])) {
nak("$a_email exists");
}
else {
- $addr_query = mysql_query("insert into contacts values('{$_SESSION['logged_uid']}','$a_lname','$a_fname','$a_email');");
+ $addr_query = mysql_query("insert into contacts values('{$_SESSION['logged_uid']}','$a_lname','$a_fname','$a_email','{$usr_data[4]}');");
if (isset($_FILES['a_photo']) and !empty($_FILES['a_photo'])) {
@@ -914,7 +914,19 @@ if (isset($_SESSION['logged_uid'])) {
if (isset($_POST['dom_del']) and !empty($_POST['dom_del'])) {
$dom_del = trim($_POST['dom_del']);
-
+
+ $dom_query = mysql_query("select id from users where domain='$dom_del'");
+
+ while ($dom_id = mysql_fetch_array($dom_query)) {
+
+ $dom_id = sha1($dom_id[id]);
+
+ if (file_exists("images/contacts/$dom_id")) {
+ rmdirr("images/contacts/$dom_id");
+ }
+ }
+
+ $dom_query = mysql_query("delete from contacts where domain='$dom_del'");
$dom_query = mysql_query("delete from aliases where domain='$dom_del'");
$dom_query = mysql_query("delete from users where domain='$dom_del'");
$dom_query = mysql_query("delete from domains where id='$dom_del'");