summaryrefslogtreecommitdiff
path: root/lib/account
diff options
context:
space:
mode:
authorNicolas BERNSTEIN <alexis211@gmail.com>2012-02-12 19:50:55 +0100
committerNicolas BERNSTEIN <alexis211@gmail.com>2012-02-12 19:50:55 +0100
commit24547ccec6526fcef3cccb34bc35fb81f31236b3 (patch)
treefc908fb06a6b8b4d4131c7303c4fb3b7d348f9bf /lib/account
parentcd76af42463bd80539db8c9671a427a9f0fe5d69 (diff)
downloadBits-24547ccec6526fcef3cccb34bc35fb81f31236b3.tar.gz
Bits-24547ccec6526fcef3cccb34bc35fb81f31236b3.zip
A lot of changes : blogging system essentially.
Diffstat (limited to 'lib/account')
-rw-r--r--lib/account/list.php23
-rw-r--r--lib/account/new.php10
2 files changed, 31 insertions, 2 deletions
diff --git a/lib/account/list.php b/lib/account/list.php
new file mode 100644
index 0000000..dcb6575
--- /dev/null
+++ b/lib/account/list.php
@@ -0,0 +1,23 @@
+<?php
+
+$filters = array (
+ "order" => array (
+ "name" => "username",
+ "reg_date" => "date registered",
+ "nbNotes" => "number of notes",
+ ),
+ "way" => $ord_ways,
+);
+$fdefaults = array (
+ "order" => "name",
+ "way" => "ASC",
+);
+
+$users = array();
+$n = sql("SELECT account.id AS id, login AS name, nc.count AS nbNotes, pc.count AS nbPosts ".
+ "FROM account ".
+ "LEFT JOIN (SELECT notes.owner AS owner, COUNT(notes.id) AS count FROM notes WHERE notes.public != 0 GROUP BY notes.owner) nc ON nc.owner = account.id ".
+ "LEFT JOIN (SELECT blog_posts.owner AS owner, COUNT(blog_posts.id) AS count FROM blog_posts GROUP BY blog_posts.owner) pc ON pc.owner = account.id ".
+ "ORDER BY " . get_filter("order") . " " . get_filter("way"));
+while ($nn = mysql_fetch_assoc($n)) $users[] = $nn;
+require("tpl/account/list.php");
diff --git a/lib/account/new.php b/lib/account/new.php
index c06083e..2366fbb 100644
--- a/lib/account/new.php
+++ b/lib/account/new.php
@@ -3,18 +3,23 @@
$title = "Register";
$login = "";
+$email = "";
if (isset($_POST['login']) && isset($_POST['pw1']) && isset($_POST['pw2'])) {
$login = esca($_POST["login"]);
+ $email = esca($_POST["email"]);
$pw1 = esc($_POST["pw1"]);
$pw2 = esc($_POST["pw2"]);
if ($login == "") {
$error = "You must enter a username.";
+ } else if (!preg_match('#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,6}$#', $email)) {
+ $error = "You must enter a valid email address.";
} else if ($pw1 != $pw2) {
$error = "You must enter twice the same password.";
} else if ($pw1 == "") {
$error = "You must enter a password";
} else {
- sql("INSERT INTO account(login, password) VALUES('" . escs($login) . "', PASSWORD('$pw1'))");
+ sql("INSERT INTO account(login, password, email, reg_date) ".
+ "VALUES('" . escs($login) . "', PASSWORD('$pw1'), '" . escs($email) . "', NOW())");
$message = "Your account has been created. Please log in now.";
$url = $homepage;
require("tpl/account/login.php");
@@ -25,7 +30,8 @@ $form_message = "Please fill in the following form to create an account :";
$fields = array(
array("label" => "Username : ", "name" => "login", "value" => $login),
array("label" => "Password : ", "name" => "pw1", "type" => "password"),
- array("label" => "Confirm password : ", "name" => "pw2", "type" => "password")
+ array("label" => "Confirm password : ", "name" => "pw2", "type" => "password"),
+ array("label" => "Email address : ", "name" => "email", "value" => $email)
);
$validate = "Create an account";