Exemplo n.º 1
0
// check if config files had errors
if ($err_str = $RCMAIL->config->get_error()) {
    raise_error(array('code' => 601, 'type' => 'php', 'message' => $err_str), false, true);
}
// check DB connections and exit on failure
if ($err_str = $DB->is_error()) {
    raise_error(array('code' => 603, 'type' => 'db', 'message' => $err_str), FALSE, TRUE);
}
// error steps
if ($RCMAIL->action == 'error' && !empty($_GET['_code'])) {
    raise_error(array('code' => hexdec($_GET['_code'])), FALSE, TRUE);
}
// check if https is required (for login) and redirect if necessary
if (empty($_SESSION['user_id']) && ($force_https = $RCMAIL->config->get('force_https', false))) {
    $https_port = is_bool($force_https) ? 443 : $force_https;
    if (!rcube_https_check($https_port)) {
        header('Location: https://' . $_SERVER['HTTP_HOST'] . ($https_port != 443 ? ':' . $https_port : '') . $_SERVER['REQUEST_URI']);
        exit;
    }
}
// trigger startup plugin hook
$startup = $RCMAIL->plugins->exec_hook('startup', array('task' => $RCMAIL->task, 'action' => $RCMAIL->action));
$RCMAIL->set_task($startup['task']);
$RCMAIL->action = $startup['action'];
// try to log in
if ($RCMAIL->action == 'login' && $RCMAIL->task == 'mail') {
    // purge the session in case of new login when a session already exists
    $RCMAIL->kill_session();
    $auth = $RCMAIL->plugins->exec_hook('authenticate', array('host' => $RCMAIL->autoselect_host(), 'user' => trim(get_input_value('_user', RCUBE_INPUT_POST)), 'cookiecheck' => true)) + array('pass' => get_input_value('_pass', RCUBE_INPUT_POST, true, 'ISO-8859-1'));
    // check if client supports cookies
    if ($auth['cookiecheck'] && empty($_COOKIE)) {
Exemplo n.º 2
0
 /**
  * Helper method to set a cookie with the current path and host settings
  *
  * @param string Cookie name
  * @param string Cookie value
  * @param string Expiration time
  */
 public static function setcookie($name, $value, $exp = 0)
 {
     if (headers_sent()) {
         return;
     }
     $cookie = session_get_cookie_params();
     setcookie($name, $value, $exp, $cookie['path'], $cookie['domain'], rcube_https_check(), true);
 }
Exemplo n.º 3
0
 /**
  * Build an absolute URL with the given parameters
  */
 public function get_url($param = array())
 {
     $param += array('task' => 'calendar');
     $schema = 'http';
     $default_port = 80;
     if (rcube_https_check()) {
         $schema = 'https';
         $default_port = 443;
     }
     $url = $schema . '://' . preg_replace('/:\\d+$/', '', $_SERVER['HTTP_HOST']);
     if ($_SERVER['SERVER_PORT'] != $default_port) {
         $url .= ':' . $_SERVER['SERVER_PORT'];
     }
     if (dirname($_SERVER['SCRIPT_NAME']) != '/') {
         $url .= str_replace("\\", '', dirname($_SERVER['SCRIPT_NAME']));
     }
     $url .= preg_replace('!^\\./!', '/', $this->rc->url($param));
     return $url;
 }
Exemplo n.º 4
0
 /**
  * Curl initialization
  *
  * @return void
  */
 public function curl_init($header = false)
 {
     if (empty($this->curl)) {
         $this->curl = curl_init();
         curl_setopt($this->curl, CURLOPT_HEADER, $header);
         curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, rcmail::get_instance()->config->get('carddav_curl_verify_host', false));
         curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, rcmail::get_instance()->config->get('carddav_curl_verify_peer', false));
         curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($this->curl, CURLOPT_USERAGENT, self::USERAGENT . self::VERSION);
         curl_setopt($this->curl, CURLOPT_REFERER, 'http' . (rcube_https_check() ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
         if ($this->auth !== null) {
             if ($_SESSION['access_token'] && substr($this->auth, 0, strlen('***TOKEN***')) == '***TOKEN***') {
                 if (!is_array($this->headers)) {
                     $this->headers = array();
                 }
                 $this->headers = array_merge($this->headers, array('authorization' => 'Authorization: Bearer ' . $_SESSION['access_token']));
             } else {
                 $auth = 0;
                 switch ($this->authtype) {
                     case 'basic':
                         $auth = self::AUTH_BASIC;
                         break;
                     case 'digest':
                         $auth = self::AUTH_DIGEST;
                         break;
                     default:
                         $auth = self::AUTH_BASIC | self::AUTH_DIGEST;
                 }
                 curl_setopt($this->curl, CURLOPT_HTTPAUTH, $auth);
                 curl_setopt($this->curl, CURLOPT_USERPWD, $this->auth);
             }
             curl_setopt($this->curl, CURLOPT_HEADER, true);
         }
     } else {
         curl_setopt($this->curl, CURLOPT_HEADER, $header);
     }
 }