piler/webui/controller/import/test.php

83 lines
2.4 KiB
PHP
Raw Permalink Normal View History

2013-08-23 13:02:51 +02:00
<?php
class ControllerImportTest extends Controller {
private $error = array();
public function index(){
$this->id = "content";
$this->template = "import/list.tpl";
$this->layout = "common/layout";
require_once 'Zend/Mail/Protocol/Imap.php';
require_once 'Zend/Mail/Protocol/Pop3.php';
$request = Registry::get('request');
$db = Registry::get('db');
$lang = Registry::get('language');
2013-09-09 15:02:30 +02:00
2013-08-23 13:02:51 +02:00
if($this->request->post['type'] == 'pop3') {
try {
$conn = new Zend_Mail_Protocol_Pop3($this->request->post['server'], '110', false);
} catch (Zend_Mail_Protocol_Exception $e) {
print "<span class=\"text-error\">" . $this->request->post['server'] . ": " . $lang->data['text_connection_failed'] . "</span> ";
}
if($conn) {
$s = $conn->connect($this->request->post['server']);
if($s) {
try {
$conn->login($this->request->post['username'], $this->request->post['password']);
print "<span class=\"text-success\">" . $lang->data['text_connection_ok'] . "</span> ";
}
catch (Zend_Mail_Protocol_Exception $e) {
print "<span class=\"text-error\">" . $this->request->post['username'] . ": " . $lang->data['text_login_failed'] . "</span> ";
}
}
}
}
else if($this->request->post['type'] == 'imap' || $this->request->post['type'] == 'imap-ssl') {
$ssl = false;
if($this->request->post['type'] == 'imap-ssl') {
$ssl = 'SSL';
}
2013-09-09 15:02:30 +02:00
try {
$conn = new Zend_Mail_Protocol_Imap($this->request->post['server'], null, $ssl);
2013-09-09 15:02:30 +02:00
$login = $conn->login($this->request->post['username'], $this->request->post['password']);
if($login) {
print "<span class=\"text-success\">" . $lang->data['text_connection_ok'] . "</span> ";
} else {
print "<span class=\"text-error\">" . $this->request->post['username'] . ": " . $lang->data['text_login_failed'] . "</span> ";
}
2013-09-09 15:02:30 +02:00
} catch (Zend_Mail_Protocol_Exception $e) {
print "<span class=\"text-error\">" . $this->request->post['server'] . ": " . $lang->data['text_connection_failed'] . "</span> ";
}
}
2013-08-23 13:02:51 +02:00
else {
print "<span class=\"text-error\">" . $lang->data['text_error'] . "</span> ";
}
}
}