summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/mm/controllers/Messages.class.php (renamed from src/controllers/Messages.class.php)24
-rw-r--r--apps/mm/ext/GoogleVoice.class.php (renamed from src/ext/GoogleVoice.class.php)0
-rw-r--r--apps/mm/ext/Identica.class.php (renamed from src/ext/Identica.class.php)0
-rw-r--r--apps/mm/ext/MimeMailParser.class.php (renamed from src/ext/MimeMailParser.class.php)0
-rw-r--r--apps/mm/ext/MimeMailParser_attachment.class.php (renamed from src/ext/MimeMailParser_attachment.class.php)0
-rw-r--r--apps/mm/ext/README.txt (renamed from src/ext/README.txt)5
-rw-r--r--apps/mm/models/Message.class.php116
-rw-r--r--apps/mm/plugins/SenderGVSMS.class.php (renamed from src/plugins/SenderGVSMS.class.php)2
-rw-r--r--apps/mm/plugins/SenderIdentica.class.php (renamed from src/plugins/SenderIdentica.class.php)2
-rw-r--r--apps/mm/scripts/newmail.php (renamed from src/controllers/NewMessage.class.php)35
-rw-r--r--apps/um/controllers/Authenticator.class.php (renamed from src/controllers/AuthPage.class.php)8
-rw-r--r--apps/um/controllers/Config.class.php (renamed from src/controllers/Config.class.php)0
-rw-r--r--apps/um/controllers/Groups.class.php (renamed from src/controllers/Groups.class.php)0
-rw-r--r--apps/um/controllers/Http404.class.php (renamed from src/controllers/Http404.class.php)0
-rw-r--r--apps/um/controllers/Main.class.php (renamed from src/controllers/Main.class.php)0
-rw-r--r--apps/um/controllers/Plugins.class.php (renamed from src/controllers/Plugins.class.php)0
-rw-r--r--apps/um/controllers/Users.class.php (renamed from src/controllers/Users.class.php)0
-rw-r--r--apps/um/ext/PasswordHash.class.php (renamed from src/ext/PasswordHash.class.php)0
-rw-r--r--apps/um/ext/README.txt12
-rw-r--r--apps/um/ext/recaptchalib.php (renamed from src/ext/recaptchalib.php)0
-rw-r--r--apps/um/lib/DB.class.php (renamed from src/lib/DB.class.php)0
-rw-r--r--apps/um/lib/Database.class.php (renamed from src/lib/Database.class.php)0
-rw-r--r--apps/um/lib/Hasher.class.php (renamed from src/lib/Hasher.class.php)0
-rw-r--r--apps/um/lib/Login.class.php (renamed from src/lib/Login.class.php)0
-rw-r--r--apps/um/lib/Plugin.class.php (renamed from src/lib/Plugin.class.php)0
-rw-r--r--apps/um/lib/PluginManager.class.php (renamed from src/lib/PluginManager.class.php)0
-rw-r--r--apps/um/lib/Site.class.php (renamed from src/lib/Site.class.php)0
-rw-r--r--apps/um/models/Auth.class.php (renamed from src/models/Auth.class.php)1
-rw-r--r--apps/um/models/ContactMethod.class.php (renamed from src/models/ContactMethod.class.php)0
-rw-r--r--apps/um/models/Group.class.php (renamed from src/models/Group.class.php)0
-rw-r--r--apps/um/models/User.class.php (renamed from src/models/User.class.php)0
-rw-r--r--apps/um/plugins/InformationPlugin.class.php (renamed from src/plugins/InformationPlugin.class.php)0
-rw-r--r--apps/um/plugins/ReCaptcha.class.php (renamed from src/plugins/ReCaptcha.class.php)0
-rw-r--r--apps/um/views/Template.class.php (renamed from src/views/Template.class.php)0
-rw-r--r--apps/um/views/includes/header-include.php (renamed from src/views/includes/header-include.php)0
-rw-r--r--apps/um/views/includes/header.php (renamed from src/views/includes/header.php)0
-rw-r--r--apps/um/views/pages/auth/badrequest.html.php (renamed from src/views/pages/auth/badrequest.html.php)0
-rw-r--r--apps/um/views/pages/auth/index.html.php (renamed from src/views/pages/auth/index.html.php)0
-rw-r--r--apps/um/views/pages/auth/login.html.php (renamed from src/views/pages/auth/login.html.php)5
-rw-r--r--apps/um/views/pages/auth/logout.html.php (renamed from src/views/pages/auth/logout.html.php)0
-rw-r--r--apps/um/views/pages/groups/401.html.php (renamed from src/views/pages/groups/401.html.php)0
-rw-r--r--apps/um/views/pages/http404.html.php (renamed from src/views/pages/http404.html.php)0
-rw-r--r--apps/um/views/pages/index.html.php (renamed from src/views/pages/index.html.php)0
-rw-r--r--apps/um/views/pages/messages/401.html.php (renamed from src/views/pages/messages/401.html.php)0
-rw-r--r--apps/um/views/pages/messages/frame.html.php (renamed from src/views/pages/messages/frame.html.php)33
-rw-r--r--apps/um/views/pages/messages/index.html.php (renamed from src/views/pages/messages/index.html.php)0
-rw-r--r--apps/um/views/pages/plugins/401.html.php (renamed from src/views/pages/plugins/401.html.php)0
-rw-r--r--apps/um/views/pages/plugins/index.html.php (renamed from src/views/pages/plugins/index.html.php)0
-rw-r--r--apps/um/views/pages/users/401.html.php (renamed from src/views/pages/users/401.html.php)0
-rw-r--r--apps/um/views/pages/users/404.html.php (renamed from src/views/pages/users/404.html.php)0
-rw-r--r--apps/um/views/pages/users/500.html.php (renamed from src/views/pages/users/500.html.php)0
-rw-r--r--apps/um/views/pages/users/created.html.php (renamed from src/views/pages/users/created.html.php)0
-rw-r--r--apps/um/views/pages/users/index.csv.php (renamed from src/views/pages/users/index.csv.php)0
-rw-r--r--apps/um/views/pages/users/index.html.php (renamed from src/views/pages/users/index.html.php)0
-rw-r--r--apps/um/views/pages/users/individual.html.php (renamed from src/views/pages/users/individual.html.php)0
-rw-r--r--apps/um/views/pages/users/individual.json.php27
-rw-r--r--apps/um/views/pages/users/new-locked.html.php (renamed from src/views/pages/users/new-locked.html.php)0
-rw-r--r--apps/um/views/pages/users/new-logged-in.html.php (renamed from src/views/pages/users/new-logged-in.html.php)0
-rw-r--r--apps/um/views/pages/users/new.html.php (renamed from src/views/pages/users/new.html.php)0
-rw-r--r--index.php35
-rw-r--r--lpf/ext/HTTP_Accept.class.php (renamed from src/ext/HTTP_Accept.class.php)0
-rw-r--r--lpf/ext/README.txt11
-rw-r--r--lpf/lib/Controller.class.php (renamed from src/lib/Controller.class.php)0
-rw-r--r--lpf/lib/Mime.class.php (renamed from src/lib/Mime.class.php)0
-rw-r--r--lpf/lib/Model.class.php (renamed from src/lib/Model.class.php)0
-rw-r--r--lpf/lib/Router.class.php (renamed from src/lib/Router.class.php)0
-rw-r--r--lpf/lib/Singleton.class.php (renamed from src/lib/Singleton.class.php)0
-rw-r--r--lpf/lib/View.class.php (renamed from src/lib/View.class.php)0
-rw-r--r--lpf/views/pages/no-conf.html.php (renamed from src/views/pages/no-conf.html.php)0
-rw-r--r--src/plugins/maildir.php58
-rw-r--r--stub.php55
71 files changed, 282 insertions, 147 deletions
diff --git a/src/controllers/Messages.class.php b/apps/mm/controllers/Messages.class.php
index 717e18e..d9decc9 100644
--- a/src/controllers/Messages.class.php
+++ b/apps/mm/controllers/Messages.class.php
@@ -1,17 +1,20 @@
<?php
require_once('Login.class.php');
require_once('Auth.class.php');
+require_once('Database.class.php');
+require_once('Message.class.php');
+require_once('MimeMailParser.class.php');
Router::register('messages', 'Messages', 'index');
Router::register('messages/index', 'Messages', 'index');
Router::register('messages/*', 'Messages', 'message');
class Messages extends Controller {
- public static $msgdir;
+ private $msgdir;
public function __construct() {
- require_once('MimeMailParser.class.php');
- $this->msgdir = BASEPATH.'/msg';
+ $db = Database::getInstance();
+ $this->msgdir = $db->getSysConf('msgdir');
}
public function index($routed, $remainder) {
@@ -48,35 +51,30 @@ class Messages extends Controller {
}
$msg_id = $remainder[0];// We can trust the router that this is set
- $msg_file = $this->msgdir."/$msg_id";
- if (!is_file($msg_file)) {
+ $msg = new Message($msg_id);
+ if ($msg === false) {
$this->http404($routed, $remainder);
return;
}
@$part = $remainder[1];
@$subpart = $remainder[2];
- $parser = new MimeMailParser();
- $parser->setPath($msg_file);
switch ($part) {
case '':
$this->showView('messages/frame',
- array('msg_id'=>$msg_id,
- 'parser'=>$parser,
- 'msgdir'=>$this->msgdir,
- ));
+ array('msg'=>$msg));
break;
case 'body':
require_once('Mime.class.php');
header('Content-type: '.Mime::ext2mime(PAGE_EXT));
$map = array('html'=>'html',
'txt' =>'text');
- echo $parser->getMessageBody($map[PAGE_EXT]);
+ echo $msg->getMessageBody($map[PAGE_EXT]);
break;
case 'attachment':
$attachment_id = $subpart;
- $attachments = $parser->getAttachments();
+ $attachments = $msg->getAttachments();
$attachment = $attachments[$attachment_id];
$type = $attachment->getContentType();
diff --git a/src/ext/GoogleVoice.class.php b/apps/mm/ext/GoogleVoice.class.php
index 9638416..9638416 100644
--- a/src/ext/GoogleVoice.class.php
+++ b/apps/mm/ext/GoogleVoice.class.php
diff --git a/src/ext/Identica.class.php b/apps/mm/ext/Identica.class.php
index a3e62a9..a3e62a9 100644
--- a/src/ext/Identica.class.php
+++ b/apps/mm/ext/Identica.class.php
diff --git a/src/ext/MimeMailParser.class.php b/apps/mm/ext/MimeMailParser.class.php
index 0080199..0080199 100644
--- a/src/ext/MimeMailParser.class.php
+++ b/apps/mm/ext/MimeMailParser.class.php
diff --git a/src/ext/MimeMailParser_attachment.class.php b/apps/mm/ext/MimeMailParser_attachment.class.php
index 6bd327c..6bd327c 100644
--- a/src/ext/MimeMailParser_attachment.class.php
+++ b/apps/mm/ext/MimeMailParser_attachment.class.php
diff --git a/src/ext/README.txt b/apps/mm/ext/README.txt
index e5cb94a..6d31122 100644
--- a/src/ext/README.txt
+++ b/apps/mm/ext/README.txt
@@ -1,7 +1,6 @@
These are class files that I've gathered from around the internet.
I've renamed the files to follow a standard scheme.
-(Could we get a standard scheme, please?)
This is where each file came from:
@@ -10,8 +9,6 @@ GoogleVoice.class.php : class.googlevoice.php : https://code.go
Identica.class.php : identica.lib.php : https://code.google.com/p/identica-php/
MimeMailParser.class.php : MimeMailParser.class.php : https://code.google.com/p/php-mime-mail-parser/
MimeMailParser_attachment.class.php : attachment.php : https://code.google.com/p/php-mime-mail-parser/
-PasswordHash.class.php : PasswordHash.php : http://www.openwall.com/phpass/
-recaptchalib.php : recaptchalib.php : https://code.google.com/p/recaptcha/
-~ Luke Shumaker <lukeshu.ath.cx>
+~ Luke Shumaker <http://lukeshu.ath.cx>
Happy Hacking!
diff --git a/apps/mm/models/Message.class.php b/apps/mm/models/Message.class.php
new file mode 100644
index 0000000..b2a2b7e
--- /dev/null
+++ b/apps/mm/models/Message.class.php
@@ -0,0 +1,116 @@
+<?php
+require_once('MimeMailParser.class.php');
+require_once('Database.class.php');
+
+class Message extends Model {
+ public static function add($infile) {
+ $parser = new MimeMailParser();
+ $parser->setPath($infile);
+ $id = preg_replace('/<(.*)>/', '$1',
+ $parser->getHeader('message-id'));
+ $id = str_replace('/', '', $id); // For security purposes
+
+ $db = Database::getInstance();
+ $msgdir = $db->getSysConf('msgdir');
+ $msg_file = "$msgdir/$id";
+
+ rename($infile, $msg_file);
+ return new Message($id);
+ }
+
+ private $_msgid;
+ private $_msgdir;
+ private $_parser;
+
+ public function __construct($msgid) {
+ $this->_msgid = str_replace('/', '', $msgid);
+ if (!file_exists($this->file())) {
+ return false;
+ }
+ }
+
+ public function msgid() {
+ return $this->_msgid;
+ }
+
+ private function msgdir() {
+ if (!isset($this->_msgdir)) {
+ $db = Database::getInstance();
+ $this->_msgdir = $db->getSysConf('msgdir');
+ }
+ return $this->_msgdir;
+ }
+
+ private function file() {
+ return $this->msgdir().'/'.$this->msgid();
+ }
+
+ private function parser() {
+ if (!isset($this->_parser)) {
+ $this->_parser = new MimeMailParser();
+ $this->_parser->setPath($this->file());
+ }
+ return $this->_parser;
+ }
+
+ /**
+ * Retrieve the Email Headers
+ * @return Array
+ */
+ public function getHeaders() {
+ return $this->parser()->getHeaders();
+ }
+
+ /**
+ * Retrieve the raw Email Headers
+ * @return string
+ */
+ public function getHeadersRaw() {
+ return $this->parser()->getHeadersRaw();
+ }
+
+ /**
+ * Retrieve a specific Email Header
+ * @return String
+ * @param $name String Header name
+ */
+ public function getHeader($name) {
+ return $this->parser()->getHeader($name);
+ }
+
+ /**
+ * Returns the part for the message body in the specified format
+ * @return Part or False if not found
+ * @param $type String[optional]
+ */
+ public function getMessageBodyPart($type = 'text') {
+ return $this->parser()->getMessageBodyPart($type);
+ }
+
+ /**
+ * Returns the email message body in the specified format
+ * @return Mixed String Body or False if not found
+ * @param $type Object[optional]
+ */
+ public function getMessageBody($type = 'text') {
+ return $this->parser()->getMessageBody($type);
+ }
+
+ /**
+ * get the headers for the message body part.
+ * @return Array
+ * @param $type Object[optional]
+ */
+ public function getMessageBodyHeaders($type = 'text') {
+ return $this->parser()->getMessageBodyHeaders($type);
+ }
+
+ /**
+ * Returns the attachments contents in order of appearance
+ * @return Array
+ * @param $type Object[optional]
+ */
+ public function getAttachments() {
+ return $this->parser()->getAttachments();
+ }
+}
diff --git a/src/plugins/SenderGVSMS.class.php b/apps/mm/plugins/SenderGVSMS.class.php
index 7919007..76db208 100644
--- a/src/plugins/SenderGVSMS.class.php
+++ b/apps/mm/plugins/SenderGVSMS.class.php
@@ -1,5 +1,5 @@
<?php
-
+require_once('Plugin.class.php');
require_once('GoogleVoice.class.php');
class SenderGVSMS extends Plugin {
diff --git a/src/plugins/SenderIdentica.class.php b/apps/mm/plugins/SenderIdentica.class.php
index ea9b343..ab55eb9 100644
--- a/src/plugins/SenderIdentica.class.php
+++ b/apps/mm/plugins/SenderIdentica.class.php
@@ -1,5 +1,5 @@
<?php
-
+require_once('Plugin.class.php');
require_once('Identica.class.php');
class SenderIdentica extends Plugin {
diff --git a/src/controllers/NewMessage.class.php b/apps/mm/scripts/newmail.php
index e778385..e4fc740 100644
--- a/src/controllers/NewMessage.class.php
+++ b/apps/mm/scripts/newmail.php
@@ -1,12 +1,17 @@
<?php
- /*
-class NewMessage extends Controller {
+// What directory are we in on the server? /////////////////////////////////////
+$_dir_scripts = dirname(__FILE__);
+$_dir_app = dirname($_dir_scripts);
+$_dir_apps = dirname($_dir_app);
+$_dir_base = dirname($_dir_apps);
+require_once($_dir_base.'/stub.php');
+
$cmdline = isset($argv[0]); // called from the command line
@$method = $_SERVER['REQUEST_METHOD']; // What HTTP method was used
-if ( ($method=='PUT') || ($method=='POST') || $cmdline ) {
+if ( ($method=='PUT') || $cmdline ) {
// We're going to be uploading a new message.
- // so uniqid isn't 'secure', it doesn't need to be, it's to prevent
+ // uniqid() isn't 'secure', it doesn't need to be, it's to prevent
// random collisions.
$tmpfile = "$BASE/tmp/".uniqid(getmypid().'.');
$infile = ($cmdline?'php://stdin':'php://input');
@@ -16,22 +21,16 @@ if ( ($method=='PUT') || ($method=='POST') || $cmdline ) {
fwrite($out, $data);
fclose($out);
fclose($in);
- //apache_request_headers()
- require_once('MimeMailParser.class.php');
- $parser = new MimeMailParser();
- $parser->setPath($tmpfile);
- $id = preg_replace('/<(.*)>/', '$1',
- $parser->getHeader('message-id'));
- $id = str_replace('/', '', $id); // for security reasons
- $msg_file = "$BASE/msg/$id";
- rename($tmpfile, $msg_file);
- if (!$cmdline) {
+ require_once('Message.class.php');
+ $msg = Message::add($tmpfile);
+ $id = $msg->msgid();
+
+ if ($cmdline) {
+ echo $id."\n";
+ } else {
$m->status('201 Created');
header("Location: ".$m->baseUrl().'messages/'.$id);
}
exit();
-}
-
-}
- */ \ No newline at end of file
+} \ No newline at end of file
diff --git a/src/controllers/AuthPage.class.php b/apps/um/controllers/Authenticator.class.php
index 1f46f72..0c1bf0c 100644
--- a/src/controllers/AuthPage.class.php
+++ b/apps/um/controllers/Authenticator.class.php
@@ -2,12 +2,12 @@
require_once('Login.class.php');
require_once('Auth.class.php');
-Router::register('auth', 'AuthPage');
+Router::register('auth', 'Authenticator');
-class AuthPage extends Controller {
+class Authenticator extends Controller {
public function index($routed, $remainder) {
- // So if $_POST['action'] isn't set, it will trip on '', which
- // is great, so we don't have to handle GET and PUT separately.
+ // If $_POST['action'] isn't set, it will trip on '', which is
+ // great, so we don't have to handle GET and PUT separately.
@$action = $_POST['action'];
switch ($action) {
case 'login' : $this->login(); break;
diff --git a/src/controllers/Config.class.php b/apps/um/controllers/Config.class.php
index dc6a884..dc6a884 100644
--- a/src/controllers/Config.class.php
+++ b/apps/um/controllers/Config.class.php
diff --git a/src/controllers/Groups.class.php b/apps/um/controllers/Groups.class.php
index 9d99d99..9d99d99 100644
--- a/src/controllers/Groups.class.php
+++ b/apps/um/controllers/Groups.class.php
diff --git a/src/controllers/Http404.class.php b/apps/um/controllers/Http404.class.php
index 322feaa..322feaa 100644
--- a/src/controllers/Http404.class.php
+++ b/apps/um/controllers/Http404.class.php
diff --git a/src/controllers/Main.class.php b/apps/um/controllers/Main.class.php
index 7651b62..7651b62 100644
--- a/src/controllers/Main.class.php
+++ b/apps/um/controllers/Main.class.php
diff --git a/src/controllers/Plugins.class.php b/apps/um/controllers/Plugins.class.php
index 2ed6e7a..2ed6e7a 100644
--- a/src/controllers/Plugins.class.php
+++ b/apps/um/controllers/Plugins.class.php
diff --git a/src/controllers/Users.class.php b/apps/um/controllers/Users.class.php
index 9978ef8..9978ef8 100644
--- a/src/controllers/Users.class.php
+++ b/apps/um/controllers/Users.class.php
diff --git a/src/ext/PasswordHash.class.php b/apps/um/ext/PasswordHash.class.php
index 12958c7..12958c7 100644
--- a/src/ext/PasswordHash.class.php
+++ b/apps/um/ext/PasswordHash.class.php
diff --git a/apps/um/ext/README.txt b/apps/um/ext/README.txt
new file mode 100644
index 0000000..78c4f70
--- /dev/null
+++ b/apps/um/ext/README.txt
@@ -0,0 +1,12 @@
+These are class files that I've gathered from around the internet.
+
+I've renamed the files to follow a standard scheme.
+
+This is where each file came from:
+
+My Name : Original Name : From
+PasswordHash.class.php : PasswordHash.php : http://www.openwall.com/phpass/
+recaptchalib.php : recaptchalib.php : https://code.google.com/p/recaptcha/
+
+~ Luke Shumaker <http://lukeshu.ath.cx>
+Happy Hacking!
diff --git a/src/ext/recaptchalib.php b/apps/um/ext/recaptchalib.php
index 32c4f4d..32c4f4d 100644
--- a/src/ext/recaptchalib.php
+++ b/apps/um/ext/recaptchalib.php
diff --git a/src/lib/DB.class.php b/apps/um/lib/DB.class.php
index ac8dafe..ac8dafe 100644
--- a/src/lib/DB.class.php
+++ b/apps/um/lib/DB.class.php
diff --git a/src/lib/Database.class.php b/apps/um/lib/Database.class.php
index a76d891..a76d891 100644
--- a/src/lib/Database.class.php
+++ b/apps/um/lib/Database.class.php
diff --git a/src/lib/Hasher.class.php b/apps/um/lib/Hasher.class.php
index dc16d68..dc16d68 100644
--- a/src/lib/Hasher.class.php
+++ b/apps/um/lib/Hasher.class.php
diff --git a/src/lib/Login.class.php b/apps/um/lib/Login.class.php
index bb21928..bb21928 100644
--- a/src/lib/Login.class.php
+++ b/apps/um/lib/Login.class.php
diff --git a/src/lib/Plugin.class.php b/apps/um/lib/Plugin.class.php
index 9d2fc2e..9d2fc2e 100644
--- a/src/lib/Plugin.class.php
+++ b/apps/um/lib/Plugin.class.php
diff --git a/src/lib/PluginManager.class.php b/apps/um/lib/PluginManager.class.php
index ce5a3ef..ce5a3ef 100644
--- a/src/lib/PluginManager.class.php
+++ b/apps/um/lib/PluginManager.class.php
diff --git a/src/lib/Site.class.php b/apps/um/lib/Site.class.php
index 1204089..1204089 100644
--- a/src/lib/Site.class.php
+++ b/apps/um/lib/Site.class.php
diff --git a/src/models/Auth.class.php b/apps/um/models/Auth.class.php
index 39f627e..a7cc629 100644
--- a/src/models/Auth.class.php
+++ b/apps/um/models/Auth.class.php
@@ -1,5 +1,4 @@
<?php
-require_once('Model.class.php');
require_once('Login.class.php');
require_once('Database.class.php');
diff --git a/src/models/ContactMethod.class.php b/apps/um/models/ContactMethod.class.php
index 1dd40ee..1dd40ee 100644
--- a/src/models/ContactMethod.class.php
+++ b/apps/um/models/ContactMethod.class.php
diff --git a/src/models/Group.class.php b/apps/um/models/Group.class.php
index f981a4f..f981a4f 100644
--- a/src/models/Group.class.php
+++ b/apps/um/models/Group.class.php
diff --git a/src/models/User.class.php b/apps/um/models/User.class.php
index b6dbede..b6dbede 100644
--- a/src/models/User.class.php
+++ b/apps/um/models/User.class.php
diff --git a/src/plugins/InformationPlugin.class.php b/apps/um/plugins/InformationPlugin.class.php
index 70ec8ac..70ec8ac 100644
--- a/src/plugins/InformationPlugin.class.php
+++ b/apps/um/plugins/InformationPlugin.class.php
diff --git a/src/plugins/ReCaptcha.class.php b/apps/um/plugins/ReCaptcha.class.php
index 165493b..165493b 100644
--- a/src/plugins/ReCaptcha.class.php
+++ b/apps/um/plugins/ReCaptcha.class.php
diff --git a/src/views/Template.class.php b/apps/um/views/Template.class.php
index 9d55b75..9d55b75 100644
--- a/src/views/Template.class.php
+++ b/apps/um/views/Template.class.php
diff --git a/src/views/includes/header-include.php b/apps/um/views/includes/header-include.php
index 3826b3a..3826b3a 100644
--- a/src/views/includes/header-include.php
+++ b/apps/um/views/includes/header-include.php
diff --git a/src/views/includes/header.php b/apps/um/views/includes/header.php
index 0a3e161..0a3e161 100644
--- a/src/views/includes/header.php
+++ b/apps/um/views/includes/header.php
diff --git a/src/views/pages/auth/badrequest.html.php b/apps/um/views/pages/auth/badrequest.html.php
index c1fe726..c1fe726 100644
--- a/src/views/pages/auth/badrequest.html.php
+++ b/apps/um/views/pages/auth/badrequest.html.php
diff --git a/src/views/pages/auth/index.html.php b/apps/um/views/pages/auth/index.html.php
index ac80140..ac80140 100644
--- a/src/views/pages/auth/index.html.php
+++ b/apps/um/views/pages/auth/index.html.php
diff --git a/src/views/pages/auth/login.html.php b/apps/um/views/pages/auth/login.html.php
index a246a9e..4e3e0e6 100644
--- a/src/views/pages/auth/login.html.php
+++ b/apps/um/views/pages/auth/login.html.php
@@ -3,6 +3,11 @@ $t = $VARS['template'];
$username = $VARS['username'];
$password = $VARS['password'];
+switch ($VARS['login_code']) {
+case 1: $t->status('401 Unauthorized'); break;
+case 2: $t->status('404 Not Found'); break;
+}
+
$t->header('Authentication');
$t->openTag('form',array('action'=>$t->url('auth'), 'method'=>"post"));
diff --git a/src/views/pages/auth/logout.html.php b/apps/um/views/pages/auth/logout.html.php
index 2d00998..2d00998 100644
--- a/src/views/pages/auth/logout.html.php
+++ b/apps/um/views/pages/auth/logout.html.php
diff --git a/src/views/pages/groups/401.html.php b/apps/um/views/pages/groups/401.html.php
index 23e3778..23e3778 100644
--- a/src/views/pages/groups/401.html.php
+++ b/apps/um/views/pages/groups/401.html.php
diff --git a/src/views/pages/http404.html.php b/apps/um/views/pages/http404.html.php
index 730b0ee..730b0ee 100644
--- a/src/views/pages/http404.html.php
+++ b/apps/um/views/pages/http404.html.php
diff --git a/src/views/pages/index.html.php b/apps/um/views/pages/index.html.php
index 71b0091..71b0091 100644
--- a/src/views/pages/index.html.php
+++ b/apps/um/views/pages/index.html.php
diff --git a/src/views/pages/messages/401.html.php b/apps/um/views/pages/messages/401.html.php
index 0b24f80..0b24f80 100644
--- a/src/views/pages/messages/401.html.php
+++ b/apps/um/views/pages/messages/401.html.php
diff --git a/src/views/pages/messages/frame.html.php b/apps/um/views/pages/messages/frame.html.php
index e64bc2f..30fc1cc 100644
--- a/src/views/pages/messages/frame.html.php
+++ b/apps/um/views/pages/messages/frame.html.php
@@ -1,19 +1,18 @@
<?php global $VARS;
$t = $VARS['template'];
-$msg_id = $VARS['msg_id'];
-$parser = $VARS['parser'];
-$msgdir = $VARS['msgdir'];
+$msg = $VARS['msg'];
function messageLink($id) {
if (is_array($id)) { $id = $id[1]; }
- global $VARS; $t = $VARS['template']; $msgdir = $VARS['msgdir'];
- $exists = is_file("$msgdir/$id");
- $class =
- $id = htmlentities($id);
+ global $VARS; $t = $VARS['template'];
+
+ $msg = new Message($id);
+ $exists = ($msg?true:false);
+
return sprintf('&lt;<a href="%1$s"%2$s>%3$s</a>&gt;',
$t->url("messages/$id/"),
($exists?'':' class="http404"'),
- $id);
+ htmlentities($id));
}
function parseMessageIDs($string) {
$base = $_SERVER['REQUEST_URL'];
@@ -26,26 +25,28 @@ function parseMessageIDs($string) {
$t->header('View Message');
$t->openTag('table');
-$t->row(array('To:' , htmlentities( $parser->getHeader('to' ))));
-$t->row(array('From:' , htmlentities( $parser->getHeader('from' ))));
-$t->row(array('Subject:' , htmlentities( $parser->getHeader('subject' ))));
-$t->row(array('In-Reply-to:', parseMessageIDs($parser->getHeader('in-reply-to'))));
-$t->row(array('References:' , parseMessageIDs($parser->getHeader('references' ))));
+$t->row(array('To:' , htmlentities( $msg->getHeader('to' ))));
+$t->row(array('From:' , htmlentities( $msg->getHeader('from' ))));
+$t->row(array('Subject:' , htmlentities( $msg->getHeader('subject' ))));
+$t->row(array('In-Reply-to:', parseMessageIDs($msg->getHeader('in-reply-to'))));
+$t->row(array('References:' , parseMessageIDs($msg->getHeader('references' ))));
$t->closeTag('table');
+$msg_id = htmlentities($msg->msgid());
+
$t->openTag('div', array('class'=>'message-body'));
-if ($parser->getMessageBodyPart('html')!==false) {
+if ($msg->getMessageBodyPart('html')!==false) {
$t->tag('h2', array(), 'HTML');
$t->tag('iframe', array('src'=>$t->url("messages/$msg_id/body.html")), '');
}
-if ($parser->getMessageBodyPart('text')!==false) {
+if ($msg->getMessageBodyPart('text')!==false) {
$t->tag('h2', array(), 'Plain Text');
$t->tag('iframe', array('src'=>$t->url("messages/$msg_id/body.txt")), '');
}
$t->closeTag('div');
$t->tag('h2', array(), 'Attachments');
$t->openTag('table');
-$attachments = $parser->getAttachments();
+$attachments = $msg->getAttachments();
foreach ($attachments as $id => $attachment) {
$t->row(array(
htmlentities($attachment->getContentType()),
diff --git a/src/views/pages/messages/index.html.php b/apps/um/views/pages/messages/index.html.php
index 111b6c6..111b6c6 100644
--- a/src/views/pages/messages/index.html.php
+++ b/apps/um/views/pages/messages/index.html.php
diff --git a/src/views/pages/plugins/401.html.php b/apps/um/views/pages/plugins/401.html.php
index 5b1b222..5b1b222 100644
--- a/src/views/pages/plugins/401.html.php
+++ b/apps/um/views/pages/plugins/401.html.php
diff --git a/src/views/pages/plugins/index.html.php b/apps/um/views/pages/plugins/index.html.php
index b182288..b182288 100644
--- a/src/views/pages/plugins/index.html.php
+++ b/apps/um/views/pages/plugins/index.html.php
diff --git a/src/views/pages/users/401.html.php b/apps/um/views/pages/users/401.html.php
index 0a5a1ce..0a5a1ce 100644
--- a/src/views/pages/users/401.html.php
+++ b/apps/um/views/pages/users/401.html.php
diff --git a/src/views/pages/users/404.html.php b/apps/um/views/pages/users/404.html.php
index 00f9dca..00f9dca 100644
--- a/src/views/pages/users/404.html.php
+++ b/apps/um/views/pages/users/404.html.php
diff --git a/src/views/pages/users/500.html.php b/apps/um/views/pages/users/500.html.php
index 339fe63..339fe63 100644
--- a/src/views/pages/users/500.html.php
+++ b/apps/um/views/pages/users/500.html.php
diff --git a/src/views/pages/users/created.html.php b/apps/um/views/pages/users/created.html.php
index d3027cc..d3027cc 100644
--- a/src/views/pages/users/created.html.php
+++ b/apps/um/views/pages/users/created.html.php
diff --git a/src/views/pages/users/index.csv.php b/apps/um/views/pages/users/index.csv.php
index 0a69cee..0a69cee 100644
--- a/src/views/pages/users/index.csv.php
+++ b/apps/um/views/pages/users/index.csv.php
diff --git a/src/views/pages/users/index.html.php b/apps/um/views/pages/users/index.html.php
index 159ff76..159ff76 100644
--- a/src/views/pages/users/index.html.php
+++ b/apps/um/views/pages/users/index.html.php
diff --git a/src/views/pages/users/individual.html.php b/apps/um/views/pages/users/individual.html.php
index 39360b7..39360b7 100644
--- a/src/views/pages/users/individual.html.php
+++ b/apps/um/views/pages/users/individual.html.php
diff --git a/apps/um/views/pages/users/individual.json.php b/apps/um/views/pages/users/individual.json.php
new file mode 100644
index 0000000..c3dee50
--- /dev/null
+++ b/apps/um/views/pages/users/individual.json.php
@@ -0,0 +1,27 @@
+<?php global $VARS, $CONTACT_METHODS;
+$t = $VARS['template'];
+$users = $VARS['users'];
+$username = $VARS['username'];
+
+$json = array();
+
+foreach ($users as $user_obj) {
+ $user_json = array();
+ $user_json['username'] = $user_obj->getName();
+ $user_json['uid'] = $user_obj->getUID();
+ foreach ($CONTACT_METHODS as $method) {
+ $field = $method->addr_slug;
+ $user_json[$field] = $user_obj->getConf($field);
+ }
+ foreach ($VARS['config_options'] as $groupname=>$options) {
+ foreach ($options as $option) {
+ $fieldname = $option[0];
+ $fieldlabel = $option[1];
+ $fieldtype = $option[2];
+ $user_json[$fieldname] = $user_obj->getConf($fieldname);
+ }
+ }
+ $json[] = $user_json;
+}
+
+echo json_encode($json); \ No newline at end of file
diff --git a/src/views/pages/users/new-locked.html.php b/apps/um/views/pages/users/new-locked.html.php
index dc7ad0d..dc7ad0d 100644
--- a/src/views/pages/users/new-locked.html.php
+++ b/apps/um/views/pages/users/new-locked.html.php
diff --git a/src/views/pages/users/new-logged-in.html.php b/apps/um/views/pages/users/new-logged-in.html.php
index 51823fe..51823fe 100644
--- a/src/views/pages/users/new-logged-in.html.php
+++ b/apps/um/views/pages/users/new-logged-in.html.php
diff --git a/src/views/pages/users/new.html.php b/apps/um/views/pages/users/new.html.php
index 9df376f..9df376f 100644
--- a/src/views/pages/users/new.html.php
+++ b/apps/um/views/pages/users/new.html.php
diff --git a/index.php b/index.php
index 6c17d47..e32df84 100644
--- a/index.php
+++ b/index.php
@@ -11,25 +11,13 @@ if (file_exists($xss_file)) {
exit();
}
}
+unset($xss_file);
-// Decide where to look for things. ////////////////////////////////////////////
-define('LIBPATH', BASEPATH.'/src/lib'.PATH_SEPARATOR.BASEPATH.'/src/ext');
-define('MODELPATH', BASEPATH.'/src/models');
-define('VIEWPATH', BASEPATH.'/src/views');// views are not objects
-define('CONTROLLERPATH',BASEPATH.'/src/controllers');
-define('PLUGINPATH', BASEPATH.'/src/plugins');
-
-set_include_path(get_include_path()
- .PATH_SEPARATOR.LIBPATH
- .PATH_SEPARATOR.MODELPATH
- .PATH_SEPARATOR.CONTROLLERPATH
- .PATH_SEPARATOR.PLUGINPATH
- );
+require_once(BASEPATH.'/stub.php');
// Figure what page is trying to be loaded. ////////////////////////////////////
// We don't have to do any check if it's a real file being looked for, if the
// requested page exists as a real file, .htaccess won't even let us load
-// thisfile.
@$PAGE_RAW = $_GET['p'];
$PAGE_PARTS = explode('/', $PAGE_RAW);
$FILE = array_pop($PAGE_PARTS);
@@ -42,27 +30,12 @@ if (preg_match($regex, $FILE, $matches)) {
} else {
$PAGE = $PAGE_RAW;
}
+unset($PAGE_RAW); unset($PAGE_PARTS); unset($FILE); unset($regex);
+
if ($PAGE=='') $PAGE = 'index';
define('PAGE', $PAGE); unset($PAGE);
define('PAGE_EXT', $EXT); unset($EXT);
-// Include base MVC classes ////////////////////////////////////////////////////
-require_once('Model.class.php');
-require_once('View.class.php');
-require_once('Controller.class.php');
-
-// Check if we have a database configuration ///////////////////////////////////
-$conf_file = BASEPATH.'/conf.php';
-if (file_exists($conf_file)) {
- require_once('Database.class.php');
- new Database($conf_file);
- session_start();
-} else {
- $view = new View('no-conf');
- $view->show(array());
- exit();
-}
-
// Kludgy ugly hacky hack //////////////////////////////////////////////////////
require_once('ContactMethod.class.php');
require(BASEPATH.'/conf-contacts.php');
diff --git a/src/ext/HTTP_Accept.class.php b/lpf/ext/HTTP_Accept.class.php
index 5efaa5d..5efaa5d 100644
--- a/src/ext/HTTP_Accept.class.php
+++ b/lpf/ext/HTTP_Accept.class.php
diff --git a/lpf/ext/README.txt b/lpf/ext/README.txt
new file mode 100644
index 0000000..c8eddb6
--- /dev/null
+++ b/lpf/ext/README.txt
@@ -0,0 +1,11 @@
+These are class files that I've gathered from around the internet.
+
+I've renamed the files to follow a standard scheme.
+
+This is where each file came from:
+
+My Name : Original Name : From
+HTTP_Accept.class.php : HTTP_Accept.php : http://kevinlocke.name/programs/http_accept.php
+
+~ Luke Shumaker <http://lukeshu.ath.cx>
+Happy Hacking!
diff --git a/src/lib/Controller.class.php b/lpf/lib/Controller.class.php
index 05736ee..05736ee 100644
--- a/src/lib/Controller.class.php
+++ b/lpf/lib/Controller.class.php
diff --git a/src/lib/Mime.class.php b/lpf/lib/Mime.class.php
index f37c1eb..f37c1eb 100644
--- a/src/lib/Mime.class.php
+++ b/lpf/lib/Mime.class.php
diff --git a/src/lib/Model.class.php b/lpf/lib/Model.class.php
index 0cce525..0cce525 100644
--- a/src/lib/Model.class.php
+++ b/lpf/lib/Model.class.php
diff --git a/src/lib/Router.class.php b/lpf/lib/Router.class.php
index 238e3f8..238e3f8 100644
--- a/src/lib/Router.class.php
+++ b/lpf/lib/Router.class.php
diff --git a/src/lib/Singleton.class.php b/lpf/lib/Singleton.class.php
index 2f8c74f..2f8c74f 100644
--- a/src/lib/Singleton.class.php
+++ b/lpf/lib/Singleton.class.php
diff --git a/src/lib/View.class.php b/lpf/lib/View.class.php
index d7a21d3..d7a21d3 100644
--- a/src/lib/View.class.php
+++ b/lpf/lib/View.class.php
diff --git a/src/views/pages/no-conf.html.php b/lpf/views/pages/no-conf.html.php
index 1f4e3d3..1f4e3d3 100644
--- a/src/views/pages/no-conf.html.php
+++ b/lpf/views/pages/no-conf.html.php
diff --git a/src/plugins/maildir.php b/src/plugins/maildir.php
deleted file mode 100644
index 28211b5..0000000
--- a/src/plugins/maildir.php
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-require_once('Getter.class.php');
-////////////////////////////////////////////////////////////////////////////////
-class Maildir implements Getter {
- private $config = array('dir'=>'');
-
- public function configList() {
- return array('dir'=>'text');
- }
-
- public function init() {}
-
- public function get() {
- $this->handle_new();
- $this->handle_cur();
- $this->handle_tmp();
- }
-
- private function handle_new() {
- // move files in new to cur
- $new = $this->config['dir'].'/new';
- $cur = $this->config['dir'].'/cur';
- $dh = opendir($new);
-
- while (($file = readdir($dh)) !== false) {
- if (substr($file,0,1)!='.' && is_file($new.'/'.$file)) {
- rename($new.'/'.$file,
- $cur.'/'.$file.':');
- }
- }
- }
- private function handle_cur() {
- $cur = $this->config['dir'].'/cur';
- $dh = opendir($cur);
-
- while (($file = readdir($dh)) !== false) {
- if (substr($file,0,1)!='.' && is_file($cur.'/'.$file)) {
-
- }
- }
- }
- private function handle_tmp() {
- // Clean up files that haven't been accessed for 36 hours
- $tmp = $this->config['dir'].'/tmp';
- $dh = opendir($cur);
-
- while (($file = readdir($dh)) !== false) {
- if (is_file($tmp.'/'.$file)) {
- $atime = fileatime($tmp.'/'.$file);
- $time = time();
- if (($time-$atime)>(36*60*60)) {
- unlink($tmp.'/'.$file);
- }
- }
- }
- }
-
-}
diff --git a/stub.php b/stub.php
new file mode 100644
index 0000000..2771fec
--- /dev/null
+++ b/stub.php
@@ -0,0 +1,55 @@
+<?php
+// What directory are we in on the server? /////////////////////////////////////
+define('BASEPATH', dirname(__FILE__));
+
+// Decide where to look for things. ////////////////////////////////////////////
+$app_path = glob(BASEPATH.'/apps/*');
+array_unshift($app_path, BASEPATH.'/lpf');
+
+$libpath = array();
+$modelpath = array();
+$viewpath = array();
+$controllerpath = array();
+$pluginpath = array();
+
+foreach ($app_path as $dir) {
+ if (is_dir($dir.'/lib' )) { $libpath[] = $dir.'/lib'; }
+ if (is_dir($dir.'/ext' )) { $libpath[] = $dir.'/ext'; }
+ if (is_dir($dir.'/models' )) { $modelpath[] = $dir.'/models'; }
+ if (is_dir($dir.'/views' )) { $viewpath[] = $dir.'/views'; }
+ if (is_dir($dir.'/controllers')) { $controllerpath[] = $dir.'/controllers'; }
+ if (is_dir($dir.'/plugins' )) { $controllerpath[] = $dir.'/plugins'; }
+}
+unset($app_path);
+
+define('LIBPATH', implode(PATH_SEPARATOR, $libpath )); unset($libpath);
+define('MODELPATH', implode(PATH_SEPARATOR, $modelpath )); unset($modelpath);
+/*define('VIEWPATH', implode(PATH_SEPARATOR, $viewpath ));*/ unset($viewpath);
+define('VIEWPATH', BASEPATH.'/apps/um/views');
+define('CONTROLLERPATH',implode(PATH_SEPARATOR, $controllerpath)); unset($controllerpath);
+define('PLUGINPATH', implode(PATH_SEPARATOR, $pluginpath )); unset($pluginpath);
+
+set_include_path(get_include_path()
+ .PATH_SEPARATOR.LIBPATH
+ .PATH_SEPARATOR.MODELPATH
+ .PATH_SEPARATOR.CONTROLLERPATH
+ .PATH_SEPARATOR.PLUGINPATH
+ );
+
+// Include base MVC classes ////////////////////////////////////////////////////
+require_once('Model.class.php');
+require_once('View.class.php');
+require_once('Controller.class.php');
+
+// Check if we have a database configuration ///////////////////////////////////
+$conf_file = BASEPATH.'/conf.php';
+if (file_exists($conf_file)) {
+ require_once('Database.class.php');
+ new Database($conf_file);
+ session_start();
+} else {
+ $view = new View('no-conf');
+ $view->show(array());
+ exit();
+}
+unset($conf_file);