Example #1
0
 |                                                                         |
 | You should have received a copy of the GNU General Public License along |
 | with this program; if not, write to the Free Software Foundation, Inc., |
 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.             |
 |                                                                         |
 +-------------------------------------------------------------------------+
 | Author: Thomas Bruederli <*****@*****.**>                          |
 +-------------------------------------------------------------------------+
 $Id$
*/
// include environment
require_once 'program/include/iniset.php';
// init application, start session, init output class, etc.
$RCMAIL = rcmail::get_instance();
// Make the whole PHP output non-cacheable (#1487797)
send_nocacheing_headers();
// turn on output buffering
ob_start();
// 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
 /**
  * Helper method to send the zip archive to the browser
  */
 private function _deliver_zipfile($tmpfname, $filename)
 {
     $browser = new rcube_browser();
     send_nocacheing_headers();
     if ($browser->ie && $browser->ver < 7) {
         $filename = rawurlencode(abbreviate_string($filename, 55));
     } else {
         if ($browser->ie) {
             $filename = rawurlencode($filename);
         } else {
             $filename = addcslashes($filename, '"');
         }
     }
     // send download headers
     header("Content-Type: application/octet-stream");
     if ($browser->ie) {
         header("Content-Type: application/force-download");
     }
     // don't kill the connection if download takes more than 30 sec.
     @set_time_limit(0);
     header("Content-Disposition: attachment; filename=\"" . $filename . "\"");
     header("Content-length: " . filesize($tmpfname));
     readfile($tmpfname);
 }
 /**
  * Send an AJAX response with executable JS code
  *
  * @param  string  Additional JS code
  * @param  boolean True if output buffer should be flushed
  * @return void
  * @deprecated
  */
 public function remote_response($add = '')
 {
     static $s_header_sent = false;
     if (!$s_header_sent) {
         $s_header_sent = true;
         send_nocacheing_headers();
         header('Content-Type: text/plain; charset=' . $this->get_charset());
     }
     // unset default env vars
     unset($this->env['task'], $this->env['action'], $this->env['comm_path']);
     $rcmail = rcmail::get_instance();
     $response = array('action' => $rcmail->action, 'unlock' => (bool) $_REQUEST['_unlock']);
     if (!empty($this->env)) {
         $response['env'] = $this->env;
     }
     if (!empty($this->texts)) {
         $response['texts'] = $this->texts;
     }
     // send function calls
     $response['exec'] = $this->get_js_commands() . $add;
     if (!empty($this->callbacks)) {
         $response['callbacks'] = $this->callbacks;
     }
     echo json_serialize($response);
 }
 /**
  * Send an AJAX response with executable JS code
  *
  * @param  string  Additional JS code
  * @param  boolean True if output buffer should be flushed
  * @return void
  * @deprecated
  */
 public function remote_response($add = '', $flush = false)
 {
     static $s_header_sent = false;
     if (!$s_header_sent) {
         $s_header_sent = true;
         send_nocacheing_headers();
         header('Content-Type: application/x-javascript; charset=' . $this->get_charset());
         print '/** ajax response [' . date('d/M/Y h:i:s O') . "] **/\n";
     }
     // unset default env vars
     unset($this->env['task'], $this->env['action'], $this->env['comm_path']);
     // send response code
     echo $this->get_js_commands() . $add;
     // flush the output buffer
     if ($flush) {
         flush();
     }
 }