I don't know if it is correct part of formum for this topic but I will try.....if not please move to proper part.
I have some aplication - mail client which is very slow because of imap_open function repetition each time calling request.
This is MVC architecture, all request goes thru index.php than to controllers which perform actions.
For example while sending login and password it goes to mailbox function which looks like this :
Code: Select all
function mailbox() {
$_SESSION['login'] = $_POST['mailbox'];
$_SESSION['pass'] = $_POST['pass'];
if(($this->model->connect('gmail.com',$_SESSION['login'],$_SESSION['pass'],'993','imap')) == false) {
$this->view = new LoginView;
$this->view->display('login');
echo 'Wrong login or/and password!';
} else {
//echo 'Loged!';
$this->model->inbox();
$view = new LoginView;
$boxes = $this->model->getMailboxes();
$msgsParts = $this->model->getMsgsParts(333);
$view->setVars('boxes', $boxes);
$view->setVars('parts',$msgsParts);
$view->display($_POST['action']);
}
}
Code: Select all
$this->model->connect('gmail.com',$_SESSION['login'],$_SESSION['pass'],'993','imap')
Than when the user wants to see the specific message he is sending the request over bootstrap (index.php) to other controller which looks like this :
Code: Select all
function mailbox() {
//echo 'MailboxController action mailbox!';
print_r($_SESSION);
$this->model->connect('gmail.com',$_SESSION['login'],$_SESSION['pass'],'993','imap');
$this->model->reconnect($_POST['mailbox']);
$view = new LoginView;
$boxes = $this->model->getMailboxes();
$msgsParts = $this->model->getMsgsParts(3);
$view->setVars('boxes', $boxes);
$view->setVars('parts',$msgsParts);
$view->display($_POST['action']);
}
function message($params) {
print_r($params['id']);
$view = new LoginView;
$this->model->connect('gmail.com',$_SESSION['login'],$_SESSION['pass'],'993','imap');
$view->setVars('message', $this->model->getMessage($params['id']));
$view->display('message');
}
Any idea how to accelerate the application ?