diff --git a/.gitignore b/.gitignore index e0874880..ed4f7d6a 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,12 @@ ext/upload_cmd ext/wiki ext/word_filter ext/zoom + +/ext/resize/main.php +/ext/resize/style.css +/ext/resize/theme.php +/ext/twitter_soc/main.php +/ext/twitter_soc/script.js +/ext/twitter_soc/style.css +/ext/twitter_soc/test.php +/ext/twitter_soc/theme.php diff --git a/contrib/artists/main.php b/contrib/artists/main.php index c86a8e10..ada1b4e5 100644 --- a/contrib/artists/main.php +++ b/contrib/artists/main.php @@ -138,7 +138,10 @@ class Artists implements Extension { } $database->execute("UPDATE images SET author = ? WHERE id = ?" - , array($artistName, $event->image->id)); + , array( + $artistName + , $event->image->id + )); } public function handle_commands($event) { @@ -465,7 +468,9 @@ class Artists implements Extension { global $database; $result = $database->get_one("SELECT COUNT(1) FROM artist_alias WHERE artist_id = ? AND alias = ?", array( - $artistID, $alias)); + $artistID + , $alias + )); return ($result != 0); } @@ -625,7 +630,12 @@ class Artists implements Extension { global $database; $database->execute("UPDATE artists SET name = ?, notes = ?, updated = now(), user_id = ? WHERE id = ? " - , array( $name, $notes, $userID, $artistID )); + , array( + $name + , $notes + , $userID + , $artistID + )); // ALIAS MATCHING SECTION $i = 0; @@ -716,7 +726,11 @@ class Artists implements Extension { global $database; $database->execute("UPDATE artist_alias SET alias = ?, updated = now(), user_id = ? WHERE id = ? " - , array( $alias, $userID, $aliasID )); + , array( + $alias + , $userID + , $aliasID + )); } private function update_url() @@ -741,7 +755,11 @@ class Artists implements Extension { global $database; $database->execute("UPDATE artist_urls SET url = ?, updated = now(), user_id = ? WHERE id = ?" - , array( $url, $userID, $urlID )); + , array( + $url + , $userID + , $urlID + )); } private function update_member() @@ -767,7 +785,11 @@ class Artists implements Extension { global $database; $database->execute("UPDATE artist_members SET name = ?, updated = now(), user_id = ? WHERE id = ?" - , array( $memberName, $userID, $memberID )); + , array( + $memberName + , $userID + , $memberID + )); } /* @@ -839,7 +861,11 @@ class Artists implements Extension { (user_id, name, notes, created, updated) VALUES (?, ?, ?, now(), now())", - array( $user->id, $name, $notes )); + array( + $user->id + , $name + , $notes + )); $result = $database->get_row("SELECT LAST_INSERT_ID() AS artistID", array()); @@ -853,7 +879,9 @@ class Artists implements Extension { global $database; $result = $database->get_one("SELECT COUNT(1) FROM artists WHERE name = ?" - , array($name)); + , array( + $name + )); return ($result != 0); } @@ -917,7 +945,9 @@ class Artists implements Extension { private function get_artist_id($name){ global $database; $artistID = $database->get_row("SELECT id FROM artists WHERE name = ?" - , array( $name )); + , array( + $name + )); return $artistID['id']; } @@ -926,7 +956,9 @@ class Artists implements Extension { global $database; $artistID = $database->get_row("SELECT artist_id FROM artist_alias WHERE alias = ?" - , array( $alias )); + , array( + $alias + )); return $artistID["artist_id"]; } @@ -940,7 +972,9 @@ class Artists implements Extension { global $database; $database->execute("DELETE FROM artists WHERE id = ? " - , array( $artistID )); + , array( + $artistID + )); } @@ -1064,7 +1098,11 @@ class Artists implements Extension { global $database; $database->execute("INSERT INTO artist_urls (artist_id, created, updated, url, user_id) VALUES (?, now(), now(), ?, ?)" - , array( $artistID, $url, $userID )); + , array( + $artistID + , $url + , $userID + )); } private function add_alias() @@ -1094,7 +1132,11 @@ class Artists implements Extension { global $database; $database->execute("INSERT INTO artist_alias (artist_id, created, updated, alias, user_id) VALUES (?, now(), now(), ?, ?)" - , array( $artistID, $alias, $userID )); + , array( + $artistID + , $alias + , $userID + )); } private function add_members() @@ -1123,7 +1165,11 @@ class Artists implements Extension { global $database; $database->execute("INSERT INTO artist_members (artist_id, name, created, updated, user_id) VALUES (?, ?, now(), now(), ?)" - , array( $artistID, $member, $userID )); + , array( + $artistID + , $member + , $userID + )); } private function member_exists($artistID, $member) @@ -1133,7 +1179,10 @@ class Artists implements Extension { global $database; $result = $database->get_one("SELECT COUNT(1) FROM artist_members WHERE artist_id = ? AND name = ?" - , array( $artistID, $member )); + , array( + $artistID + , $member + )); return ($result != 0); } @@ -1144,7 +1193,10 @@ class Artists implements Extension { global $database; $result = $database->get_one("SELECT COUNT(1) FROM artist_urls WHERE artist_id = ? AND url = ?" - , array( $artistID, $url )); + , array( + $artistID + , $url + )); return ($result != 0); } diff --git a/contrib/favorites/main.php b/contrib/favorites/main.php index f6c6ef5b..ad37edd0 100644 --- a/contrib/favorites/main.php +++ b/contrib/favorites/main.php @@ -144,8 +144,10 @@ class Favorites extends SimpleExtension { image_id INTEGER NOT NULL, user_id INTEGER NOT NULL, created_at DATETIME NOT NULL, + INDEX(image_id), UNIQUE(image_id, user_id), - INDEX(image_id) + FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, + FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE ) "); $config->set_int("ext_favorites_version", 1); diff --git a/ext/user/main.php b/ext/user/main.php index fc0da212..d964d6b9 100644 --- a/ext/user/main.php +++ b/ext/user/main.php @@ -144,6 +144,12 @@ class UserPage extends SimpleExtension { // join (select owner_id,count(*) as comment_count from comments group by owner_id) as _comments on _comments.owner_id=users.id; $this->theme->display_user_list($page, User::by_list(0), $user); } + else if($event->get_arg(0) == "delete_user") { + $this->delete_user($page); + } + else if($event->get_arg(0) == "delete_user_with_images") { + $this->delete_user_with_images($page); + } } if(($event instanceof PageRequestEvent) && $event->page_matches("user")) { @@ -463,6 +469,72 @@ class UserPage extends SimpleExtension { ORDER BY most_recent DESC", array("id"=>$duser->id)); return $rows; } + + private function delete_user($page) { + global $user; + global $config; + global $database; + + $page->set_title("Error"); + $page->set_heading("Error"); + $page->add_block(new NavBlock()); + + if (!$user->is_admin()) { + $page->add_block(new Block("Not Admin", "Only admins can delete accounts")); + } + else if(!isset($_POST['id']) || !is_numeric($_POST['id'])) { + $page->add_block(new Block("No ID Specified", + "You need to specify the account number to edit")); + } + else{ + $rows = $database->get_all("SELECT * FROM images WHERE owner_id = :owner_id", array("owner_id" => $_POST['id'])); + foreach ($rows as $key => $value) + { + $database->Execute("UPDATE images SET owner_id = :owner_id WHERE id = :id;", array("owner_id" => 1, "id" => $value['id'])); + } + $database->execute("DELETE FROM users + WHERE id = :id" + , array("id"=>$_POST['id'])); + + $page->set_mode("redirect"); + $page->set_redirect(make_link("post/list")); + } + } + + private function delete_user_with_images($page) { + global $user; + global $config; + global $database; + + $page->set_title("Error"); + $page->set_heading("Error"); + $page->add_block(new NavBlock()); + + if (!$user->is_admin()) { + $page->add_block(new Block("Not Admin", "Only admins can delete accounts")); + } + else if(!isset($_POST['id']) || !is_numeric($_POST['id'])) { + $page->add_block(new Block("No ID Specified", + "You need to specify the account number to edit")); + } + else{ + $rows = $database->get_all("SELECT * FROM images WHERE owner_id = :owner_id", array("owner_id" => $_POST['id'])); + foreach ($rows as $key => $value) + { + $image = Image::by_id($value['id']); + if($image) { + send_event(new ImageDeletionEvent($image)); + } + } + $database->execute("DELETE FROM users + WHERE id = :id" + , array("id"=>$_POST['id'])); + + $page->set_mode("redirect"); + $page->set_redirect(make_link("post/list")); + } + } + // }}} } add_event_listener(new UserPage()); diff --git a/ext/user/theme.php b/ext/user/theme.php index 5f1491e1..e258d186 100644 --- a/ext/user/theme.php +++ b/ext/user/theme.php @@ -17,7 +17,7 @@ class UserPageTheme extends Themelet { $html .= "
Change Password | |
---|---|
Password | |
Repeat Password | |
".make_form(make_link("user_admin/change_email"))." - -
Change Email | |
---|---|
Address | |
".make_form(make_link("user_admin/set_more"))." - - Admin: - - + ".make_form(make_link("user_admin/change_pass"))." + +
Change Password | |
---|---|
Password | |
Repeat Password | |
".make_form(make_link("user_admin/change_email"))." + +
Change Email | |
---|---|
Address | |
".make_form(make_link("user_admin/set_more"))." + + Admin: + + + + ".make_form(make_link("user_admin/delete_user"))." + + + + + ".make_form(make_link("user_admin/delete_user_with_images"))." + + + "; + } } return $html; } diff --git a/install.php b/install.php index e5f2e5cc..359642e4 100755 --- a/install.php +++ b/install.php @@ -76,6 +76,15 @@ if(is_readable("config.php")) { "; */ + echo "