diff --git a/src/core/init/loader.php b/src/core/init/loader.php index 8255be7..47ea6f7 100644 --- a/src/core/init/loader.php +++ b/src/core/init/loader.php @@ -19,9 +19,6 @@ class Loader { break; default: $p = $this->get_page_name(); - if (substr($p,0,6) != "/admin") { - header('Content-Type: application/json'); // <-- header declaration - } if(substr($p,0,1) == "/") { Core::$CurrentPage = substr($p,1); } else { diff --git a/src/core/init/responder.php b/src/core/init/responder.php index 1c5e292..9a49c66 100644 --- a/src/core/init/responder.php +++ b/src/core/init/responder.php @@ -1,5 +1,6 @@ get_response(); @@ -13,8 +14,19 @@ class Responder { } } private function send_response($response){ - // Send json encoded response - echo json_encode($response, true); + switch ($response->content_type){ + case "json": + header('Content-Type: application/json'); + // Send json encoded response + echo json_encode($response, true); + break; + case "xml": + header('Content-Type: application/xml'); + include ($response->content); + break; + } + + } private function get_response(){ $resp = false; @@ -25,8 +37,8 @@ class Responder { case "get/all": $resp = $this->all_urls(); break; - case "get/select": - $resp = $this->selection(); + case "mail/config-v1.1.xml": + $resp = $this->moz_auto_config(); break; case "none": case "test": @@ -40,8 +52,6 @@ class Responder { return $resp; } private function all_urls(){ - - // This would be the default request from, say, an app. $response = new Response(); // TODO:: Will work out a better message later @@ -49,23 +59,22 @@ class Responder { // Cycle through each service and add to payload foreach (Core::$Config["Services"] as $key => $service){ - $response->payload[$key] = $service; + $response->content[$key] = $service; } return $response; } - private function selection(){ + private function moz_auto_config(){ $response = new Response(); - $response->message = "Not Implemented"; - $uri = Core::full_url(); - $response->payload = parse_url($uri); + $response->content_type = "xml"; + $response->content = "public/autoconfig.php"; return $response; } private function dummy_response(){ // Generate a dummy response for testing $response = new Response(); $response->message = "OK, here's some scrumptious data! Enjoy!"; - $response->payload = array("data" => array("some_data" => "Ohhhhhmmmm nom nom nom nom nom nom", + $response->content = array("data" => array("some_data" => "Ohhhhhmmmm nom nom nom nom nom nom", "extra_data" => array("garnish" => "buuuuuuuuuuurp")), "more_data" => "yuuuuuum yum yum yum"); return $response; @@ -79,8 +88,9 @@ class Responder { } class Response { public $url; + public $content_type = "json"; public $message; - public $payload = array(); + public $content = array(); public function __construct(){ // add requested page to response. I don't know why, but it could helpful for diagnostics at some point $this->url = Core::$CurrentPage; diff --git a/src/public/autoconfig.php b/src/public/autoconfig.php new file mode 100644 index 0000000..a3dc9a7 --- /dev/null +++ b/src/public/autoconfig.php @@ -0,0 +1,39 @@ + + + "> + + + + "> + + + + + + + + + "> + + + + + + + + + diff --git a/src/public/autodiscover.php b/src/public/autodiscover.php new file mode 100644 index 0000000..4c62467 --- /dev/null +++ b/src/public/autodiscover.php @@ -0,0 +1,30 @@ + + + + email + settings + + IMAP + server.hostname.com + 993 + off + + off + on + on + + + SMTP + server.hostname.com + 587 + off + + off + TLS + on + off + off + + + + diff --git a/src/sample-config/config.sample.ini b/src/sample-config/config.sample.ini index d5ecc51..8653f68 100644 --- a/src/sample-config/config.sample.ini +++ b/src/sample-config/config.sample.ini @@ -1,6 +1,9 @@ ; Sample config.ini file. ; Copy this file to "config/config.ini" and adjust the settings to your requirements +; Set the base domain for use with this service +Domain = example.com + ; Admin User configuration ; not in use yet ;[AdminUser] diff --git a/src/sample-config/services.sample.ini b/src/sample-config/services.sample.ini index 1464ae0..1632eb7 100644 --- a/src/sample-config/services.sample.ini +++ b/src/sample-config/services.sample.ini @@ -1,14 +1,16 @@ [InMail] +Type = "IMAP" Server = "imap.example.com" -Protocol = "IMAP" Port = 993 -TLS = true +SocketType = SSL +Authentication = password-cleartext [OutMail] +Type = "SMTP" Server = "smtp.example.com" -Protocol = "SMTP" Port = 465 -TLS = true +SocketType = SSL +Authentication = password-cleartext [CalDav] Server = "https://caldav.example.com/etc/etc/"