[Tutos-commits] SF.net SVN: tutos:[1007] trunk/php
Projects / CRM / PLM / Calendar / Tasks / SCRUM / Test / Inventory
Brought to you by:
gokohnert
|
From: <gok...@us...> - 2013-03-10 13:26:41
|
Revision: 1007
http://sourceforge.net/p/tutos/code/1007
Author: gokohnert
Date: 2013-03-10 13:26:38 +0000 (Sun, 10 Mar 2013)
Log Message:
-----------
centralized headers generation
Modified Paths:
--------------
trunk/php/address_show.php
trunk/php/app_show.php
trunk/php/excel.pinc
trunk/php/file/file.pinc
trunk/php/file/file_show.php
trunk/php/graph_bars.php
trunk/php/layout/classic_base.pinc
trunk/php/layout/mobile_layout.pinc
trunk/php/layout/new2_layout.pinc
trunk/php/layout/new_layout.pinc
trunk/php/mail.pinc
trunk/php/mailbox/mail_show.php
trunk/php/url/url_show.php
trunk/php/webelements.p3
Modified: trunk/php/address_show.php
===================================================================
--- trunk/php/address_show.php 2013-03-09 06:17:14 UTC (rev 1006)
+++ trunk/php/address_show.php 2013-03-10 13:26:38 UTC (rev 1007)
@@ -6,12 +6,12 @@
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; version 2 of the License.
*
- * SVN Info $Id$
- * $Author$
+ * SVN Info $Id$
+ * $Author$
*
- * @modulegroup address
- * @module adr_ldap_overview
- * @package address
+ * @modulegroup address
+ * @module adr_ldap_overview
+ * @package address
*/
$tutos['files'][__FILE__] = '$Rev$';
@@ -75,8 +75,7 @@
if ( $this->format == "vcard" ) {
$b = $this->obj->getVcard();
- Header("Expires: 0");
- Header("Pragma: no-cache");
+ export_headers_base();
// set content to text/calendar
if (strstr($_SERVER["HTTP_USER_AGENT"],"MSIE 5") || strstr($_SERVER["HTTP_USER_AGENT"],"MSIE 6") ) {
Header("Cache-Control:");
Modified: trunk/php/app_show.php
===================================================================
--- trunk/php/app_show.php 2013-03-09 06:17:14 UTC (rev 1006)
+++ trunk/php/app_show.php 2013-03-10 13:26:38 UTC (rev 1007)
@@ -9,11 +9,11 @@
* SVN Info $Id$
* $Author$
*
- * A four week calendar
+ * A four week calendar
*
- * @modulegroup appointment
- * @module app_show
- * @package appointment
+ * @modulegroup appointment
+ * @module app_show
+ * @package appointment
*/
$tutos['files'][__FILE__] = '$Rev$';
@@ -43,8 +43,7 @@
$r = '';
if ( $this->format == "ical") {
- Header("Expires: 0");
- Header("Pragma: no-cache");
+ export_headers_base();
// set content to text/calendar
if (strstr($_SERVER["HTTP_USER_AGENT"],"MSIE 5") || strstr($_SERVER["HTTP_USER_AGENT"],"MSIE 6") ) {
Header("Cache-Control:");
Modified: trunk/php/excel.pinc
===================================================================
--- trunk/php/excel.pinc 2013-03-09 06:17:14 UTC (rev 1006)
+++ trunk/php/excel.pinc 2013-03-10 13:26:38 UTC (rev 1007)
@@ -1,79 +1,77 @@
<?php
/**
- * Copyright 2004 - 2009 by Gero Kohnert
+ * Copyright 2004 - 2013 by Gero Kohnert
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
* Free Software Foundation; version 2 of the License.
*
- * base format for TUTOS excel output
+ * base format for TUTOS excel output
*
* SVN Info $Id$
* $Author$
*/
+$tutos['files'][__FILE__] = '$Rev$';
class Tutos_excel {
- function tutos_excel()
- {
- $this->wb = -1;
- $this->ws = array();
- }
+ function tutos_excel()
+ {
+ $this->wb = -1;
+ $this->ws = array();
+ }
- function open()
- {
- global $tutos;
+ function open()
+ {
+ global $tutos;
- $this->tmpname = tempnam ($tutos[sessionpath], "excel");
- $this->wb = new Workbook($this->tmpname);
- }
+ $this->tmpname = tempnam ($tutos[sessionpath], "excel");
+ $this->wb = new Workbook($this->tmpname);
+ }
- function send($name)
- {
- $this->wb->close();
- $fh = fopen($this->tmpname, "rb");
- if ($fh == false) {
- die("Can't read temporary file.");
- }
+ function send($name)
+ {
+ $this->wb->close();
+ $fh = fopen($this->tmpname, "rb");
+ if ($fh == false) {
+ die("Can't read temporary file.");
+ }
-#die ($this->tmpname);
- header("Content-type: application/vnd.ms-excel");
- header("Content-Disposition: attachment; filename=". $name .".xls");
- header("Expires: 0");
- header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
- header("Pragma: public");
+ export_headers_base();
+ header("Content-type: application/vnd.ms-excel");
+ header("Content-Disposition: attachment; filename=". $name .".xls");
- fpassthru($fh);
- fclose($fh);
- @unlink($this->tmpname);
- return;
- }
+ fpassthru($fh);
+ fclose($fh);
+ @unlink($this->tmpname);
+ return;
+ }
- function add_sheet($name)
- {
- global $lang;
+ function add_sheet($name)
+ {
+ global $lang;
- $id = count($this->ws);
- $this->ws[$id] =& $this->wb->add_worksheet($name);
- $this->ws[$id]->set_landscape();
- $this->ws[$id]->set_header('TUTOS');
- $this->ws[$id]->set_footer("generated by TUTOS");
+ $id = count($this->ws);
+ $this->ws[$id] =& $this->wb->add_worksheet($name);
+ $this->ws[$id]->set_landscape();
+ $this->ws[$id]->set_header('TUTOS');
+ $this->ws[$id]->set_footer("generated by TUTOS");
- return $id;
- }
+ return $id;
+ }
- function add_formats()
- {
- $this->format_default =& $this->wb->add_format();
- $this->format_default->set_size(10);
+ function add_formats()
+ {
+ $this->format_default =& $this->wb->add_format();
+ $this->format_default->set_size(10);
- $this->format_header =& $this->wb->add_format();
- $this->format_header->set_bold(1);
- $this->format_header->set_align('center');
- $this->format_header->set_fg_color(43);
- $this->format_header->set_color(8);
- $this->format_header->set_size(12);
- $this->format_header->set_pattern();
+ $this->format_header =& $this->wb->add_format();
+ $this->format_header->set_bold(1);
+ $this->format_header->set_align('center');
+ $this->format_header->set_fg_color(43);
+ $this->format_header->set_color(8);
+ $this->format_header->set_size(12);
+ $this->format_header->set_pattern();
- }
- }
+ }
+}
?>
\ No newline at end of file
Modified: trunk/php/file/file.pinc
===================================================================
--- trunk/php/file/file.pinc 2013-03-09 06:17:14 UTC (rev 1006)
+++ trunk/php/file/file.pinc 2013-03-10 13:26:38 UTC (rev 1007)
@@ -6,7 +6,7 @@
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; version 2 of the License.
*
- * Class to maintain files their location ,version and history
+ * Class to maintain files their location ,version and history
*
* SVN Info $Id$
* $Author$
@@ -738,10 +738,8 @@
die ('no file: '.$fname);
return;
}
-
- Header("Expires: 0");
- Header("Cache-Control:");
- Header("Pragma:");
+ export_headers_base();
+ Header("Content-Description: ". $this->name );
if ( ($v == '') || ($this->vsys == FILE_NOVERS) ) {
$this->myreadfile ($fname);
return;
@@ -797,17 +795,12 @@
* preview this file (for popups)
*/
function preview($version,$ly) {
-
$fname = $this->getFilename();
if ( ! file_exists($fname) ) {
return;
}
-
- Header("Expires: 0");
- Header("Cache-control:");
- Header("Pragma:");
+ export_headers_base();
Header("Content-Description: ". $this->name );
-
$info = '';
$url = dirname(getBaseUrl()) .'/'. addSessionKey($this->getUrl().'&format=show');
@@ -842,9 +835,7 @@
return;
}
//error_log($fname."\n", 3, $tutos[errlog]);
- Header("Expires: 0");
- Header("Cache-control:");
- Header("Pragma:");
+ export_headers_base();
Header("Content-Description: ". $this->name );
if ( $this->filetype == 'text/plain'
|| $this->filetype == 'text/x-log'
@@ -870,8 +861,6 @@
return;
} else if ( preg_match("#\.zip$#i",$this->filename) ) {
if (class_exists("ZipArchive")) {
- # Header("Content-type: text/html");
- # Header("Content-Disposition: inline; filename=\"". $this->filename .".html\"");
echo $ly->HTML_Start();
echo $ly->layout_start();
echo showzip($fname);
Modified: trunk/php/file/file_show.php
===================================================================
--- trunk/php/file/file_show.php 2013-03-09 06:17:14 UTC (rev 1006)
+++ trunk/php/file/file_show.php 2013-03-10 13:26:38 UTC (rev 1007)
@@ -14,6 +14,7 @@
* @package file
*/
$tutos['files'][__FILE__] = '$Rev$';
+
$tutos['base'] = "../..";
ini_set("include_path","..");
require_once 'webelements.p3';
@@ -37,9 +38,7 @@
Function info_thumb() {
global $tutos,$lang;
- Header("Expires: 0");
- Header("Cache-control:");
- Header("Pragma:");
+ export_headers_base();
Header("Content-Description: ". $this->name );
Header("Content-Type: application/octet-stream");
Modified: trunk/php/graph_bars.php
===================================================================
--- trunk/php/graph_bars.php 2013-03-09 06:17:14 UTC (rev 1006)
+++ trunk/php/graph_bars.php 2013-03-10 13:26:38 UTC (rev 1007)
@@ -1,17 +1,17 @@
<?php
-/*
- * Copyright 1999 - 2011 by Gero Kohnert
+/**
+ * Copyright 1999 - 2013 by Gero Kohnert
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; version 2 of the License.
*
- * SVN Info $Id$
- * $Author$
+ * SVN Info $Id$
+ * $Author$
*
*/
+$tutos['files'][__FILE__] = '$Rev$';
-
require_once 'webelements.p3';
require_once 'permission.p3';
@@ -24,8 +24,7 @@
function basic (&$f,&$t0,&$t1) {
global $msg;
- Header("Expires: 0");
- Header("Pragma: no-cache");
+ export_headers_base();
Header("content-type: image/png");
$x2 = count($f) * 110;
Modified: trunk/php/layout/classic_base.pinc
===================================================================
--- trunk/php/layout/classic_base.pinc 2013-03-09 06:17:14 UTC (rev 1006)
+++ trunk/php/layout/classic_base.pinc 2013-03-10 13:26:38 UTC (rev 1007)
@@ -41,26 +41,15 @@
global $tutos,$lang;
$r = '';
- # ob_start("ob_gzhandler");
@ob_start();
if ( !isset($this->name) || empty($this->name) ) {
$this->name = "TUTOS";
}
- Header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
- Header("Expires: -1");
- Header("Cache-Control: no-store, no-cache, must-revalidate");
- Header("Cache-Control: max_age=0 ,post-check=0, pre-check=0",false);
- Header("Pragma: no-cache");
+ export_headers_base();
Header('Content-Description: a TUTOS Page -- '.preg_replace('#\n#',' ',trim($this->name)));
Header("Content-Type: text/html;charset=". $lang['content_encoding']);
- /**
- $r .= "<?xml version=\"1.0\"?>";
- $r .= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"";
- $r .= " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">";
- */
-
if (true) {
$r .= "<?xml version=\"1.0\"?>\n";
$r .= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
@@ -443,19 +432,19 @@
);
$this->addMenu($x);
- # Logout
- $x = array( url => "logout.php",
- image => $this->theme->getImage(logout,'menu'),
- text => $lang['Logout'],
- info => $lang['LogoutInfo'],
- category => array("logout","admin","default")
- );
+ // Logout
+ $x = array( url => "logout.php",
+ image => $this->theme->getImage(logout,'menu'),
+ text => $lang['Logout'],
+ info => $lang['LogoutInfo'],
+ category => array("logout","admin","default")
+ );
$this->addMenu($x);
- # Team Stuff
- if ( ! class_exists ("url") ) {
- loadmodule("url");
- }
+ // Team Stuff
+ if ( ! class_exists ("url") ) {
+ loadmodule("url");
+ }
if ( class_exists ("url") ) {
if ( $this->user->feature_ok(useurl,PERM_SEE) ) {
Modified: trunk/php/layout/mobile_layout.pinc
===================================================================
--- trunk/php/layout/mobile_layout.pinc 2013-03-09 06:17:14 UTC (rev 1006)
+++ trunk/php/layout/mobile_layout.pinc 2013-03-10 13:26:38 UTC (rev 1007)
@@ -723,12 +723,7 @@
if ( !isset($this->name) || empty($this->name) ) {
$this->name = 'TUTOS';
}
- Header('Last-Modified: ' . gmdate('D, d M Y H:i:s') .' GMT');
- // Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
- Header('Expires: -1');
- Header('Cache-Control: no-store, no-cache, must-revalidate');
- Header('Cache-Control: max_age=0 ,post-check=0, pre-check=0',false);
- Header('Pragma: no-cache');
+ export_headers_base();
Header('Content-Description: a TUTOS Page -- '.preg_replace('#\n#',' ',trim($this->name)));
Header('Content-Type: text/html;charset='. $lang['content_encoding']);
Modified: trunk/php/layout/new2_layout.pinc
===================================================================
--- trunk/php/layout/new2_layout.pinc 2013-03-09 06:17:14 UTC (rev 1006)
+++ trunk/php/layout/new2_layout.pinc 2013-03-10 13:26:38 UTC (rev 1007)
@@ -451,12 +451,7 @@
if ( !isset($this->name) || empty($this->name) ) {
$this->name = 'TUTOS';
}
- Header('Last-Modified: ' . gmdate('D, d M Y H:i:s') .' GMT');
- // Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
- Header('Expires: -1');
- Header('Cache-Control: no-store, no-cache, must-revalidate');
- Header('Cache-Control: max_age=0 ,post-check=0, pre-check=0',false);
- Header('Pragma: no-cache');
+ export_headers_base();
Header('Content-Description: a TUTOS Page -- '.preg_replace('#\n#',' ',trim($this->name)));
Header('Content-Type: text/html;charset='. $lang['content_encoding']);
Modified: trunk/php/layout/new_layout.pinc
===================================================================
--- trunk/php/layout/new_layout.pinc 2013-03-09 06:17:14 UTC (rev 1006)
+++ trunk/php/layout/new_layout.pinc 2013-03-10 13:26:38 UTC (rev 1007)
@@ -363,12 +363,7 @@
if ( !isset($this->name) || empty($this->name) ) {
$this->name = 'TUTOS';
}
- Header('Last-Modified: ' . gmdate('D, d M Y H:i:s') .' GMT');
- // Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
- Header('Expires: -1');
- Header('Cache-Control: no-store, no-cache, must-revalidate');
- Header('Cache-Control: max_age=0 ,post-check=0, pre-check=0',false);
- Header('Pragma: no-cache');
+ export_headers_base();
Header('Content-Description: a TUTOS Page -- '.preg_replace('#\n#',' ',trim($this->name)));
Header('Content-Type: text/html;charset='. $lang['content_encoding']);
Modified: trunk/php/mail.pinc
===================================================================
--- trunk/php/mail.pinc 2013-03-09 06:17:14 UTC (rev 1006)
+++ trunk/php/mail.pinc 2013-03-10 13:26:38 UTC (rev 1007)
@@ -6,7 +6,7 @@
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; version 2 of the License.
*
- * Give a good interface to send mail
+ * Give a good interface to send mail
*
* SVN Info $Id$
* $Author$
@@ -323,16 +323,14 @@
if(!$skip && ($mformat == "download") ) {
$show_raw = true;
$show_text = false;
- Header("Expires: 0");
- Header("Pragma: no-cache");
+ export_headers_base();
Header("Content-type: " . $this->contenttype.';charset='.$this->charset);
Header("Content-Disposition: attachment; filename=\"". $this->contentdisponame ."\"");
Header("Content-Description: Upload from TUTOS" );
} elseif (!$skip && ($mformat == "show") ) {
$show_raw = true;
$show_text = false;
- Header("Expires: 0");
- Header("Pragma: no-cache");
+ export_headers_base();
Header("Content-type: " . $this->contenttype.';charset='.$this->charset);
} elseif (!$skip && $show_headline) {
if ($mformat == 'reply') {
Modified: trunk/php/mailbox/mail_show.php
===================================================================
--- trunk/php/mailbox/mail_show.php 2013-03-09 06:17:14 UTC (rev 1006)
+++ trunk/php/mailbox/mail_show.php 2013-03-10 13:26:38 UTC (rev 1007)
@@ -17,6 +17,7 @@
*
*/
$tutos['files'][__FILE__] = '$Rev$';
+
$tutos['base'] = "../..";
ini_set("include_path","..");
require_once 'webelements.p3';
@@ -40,8 +41,7 @@
global $lang,$tutos;
if (($this->part == 0) && ($this->format == 'download')) {
- Header("Expires: 0");
- Header("Pragma: no-cache");
+ export_headers_base();
Header("Content-type: message/rfc822");
Header("Content-Disposition: attachment; filename=\"". $this->mno .".eml\"");
Header("Content-Description: Upload from TUTOS" );
Modified: trunk/php/url/url_show.php
===================================================================
--- trunk/php/url/url_show.php 2013-03-09 06:17:14 UTC (rev 1006)
+++ trunk/php/url/url_show.php 2013-03-10 13:26:38 UTC (rev 1007)
@@ -1,6 +1,6 @@
<?php
/**
- * Copyright 2000 - 2012 by Gero Kohnert
+ * Copyright 2000 - 2013 by Gero Kohnert
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -10,6 +10,8 @@
* @module note_show
* @package note
*/
+$tutos['files'][__FILE__] = '$Rev$';
+
$tutos['base'] = "../..";
ini_set("include_path","..");
require_once 'webelements.p3';
@@ -69,13 +71,11 @@
if (preg_match("<@BASEURL@>",$this->obj->url)) {
leave_insert($this->obj->dbconn,$this->obj->getTargetUrl(),$msg,$info);
} else {
+ export_headers_base();
Header('Status: 302 Moved Temporarily');
Header("Content-Description: TUTOS Redirect" );
- Header("Expires: -1"); // required by google chrome
Header('Location: '. $this->obj->url);
}
-
- # $this->redirect = 'http://www.tutos.de';
}
}
Modified: trunk/php/webelements.p3
===================================================================
--- trunk/php/webelements.p3 2013-03-09 06:17:14 UTC (rev 1006)
+++ trunk/php/webelements.p3 2013-03-10 13:26:38 UTC (rev 1007)
@@ -1159,13 +1159,13 @@
}
/**
- if ( (isset($tutos['SESSID'])) && (!isset($_COOKIE['TUTOS'])) ) {
- if ( session_id() != '' ) {
- //$href .= $pre . session_name() .'='. session_id();
- $href .= $pre . SID;
- $pre = $pre2;
- }
- }
+ if ( (isset($tutos['SESSID'])) && (!isset($_COOKIE['TUTOS'])) ) {
+ if ( session_id() != '' ) {
+ //$href .= $pre . session_name() .'='. session_id();
+ $href .= $pre . SID;
+ $pre = $pre2;
+ }
+ }
*/
return $href . $add;
}
@@ -1195,11 +1195,11 @@
$r .= ' <input type="hidden" name="ss" value="'. $_REQUEST['ss'] ."\" />\n";
}
/**
- if ( (isset($tutos['SESSID'])) && (!isset($_COOKIE['TUTOS'])) ) {
- if ( SID != '' ) {
- $r .= ' <input type="hidden" name="'. session_name() .'" value="'. session_id() ."\" />\n";
- }
- }
+ if ( (isset($tutos['SESSID'])) && (!isset($_COOKIE['TUTOS'])) ) {
+ if ( SID != '' ) {
+ $r .= ' <input type="hidden" name="'. session_name() .'" value="'. session_id() ."\" />\n";
+ }
+ }
*/
return $r;
}
@@ -2946,12 +2946,9 @@
$gotourl = addSessionKey($gotourl,true);
// go to a better place
+ export_headers_base();
Header("Content-Description: TUTOS Redirect" );
Header('Content-Type: text/html;charset='. $lang['content_encoding']);
- Header("Expires: -1"); // required by google chrome
- Header('Cache-Control: no-store, no-cache, must-revalidate');
- Header('Cache-Control: max_age=0 ,post-check=0, pre-check=0',false);
- Header('Pragma: no-cache');
Header("Status: 302 Moved Temporarily");
if (preg_match('#^http#',$gotourl)) {
Header("Location: ". $gotourl );
@@ -2966,16 +2963,29 @@
* HTTP Header for exporting files
* do not allow caching
*/
+function export_headers_base() {
+ if(headers_sent()) {
+ Fatal_Error('Some data has already been output to browser, can\'t send data');
+ }
+ Header('Expires: -1');
+ Header('Cache-Control: no-store, no-cache, must-revalidate');
+ Header('Cache-Control: max_age=0 ,post-check=0, pre-check=0',false);
+ // Header("Pragma: no-cache"); // won't work with IE7
+ // Header("Pragma: public");
+ Header('Pragma: no-cache');
+ Header('Last-Modified: ' . gmdate('D, d M Y H:i:s') .' GMT');
+}
+
+/**
+ * HTTP Header for exporting files
+ * do not allow caching
+ */
function export_headers($filename = '',$type = '',$attach = true) {
if(headers_sent()) {
Fatal_Error('Some data has already been output to browser, can\'t send "'.$type.'" file');
}
- Header("Expires: -1");
- Header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
- // Header("Pragma: no-cache"); // won't work with IE7
- Header("Pragma: public");
- Header("Content-Description: Upload from TUTOS" );
- Header('Last-Modified: ' . gmdate('D, d M Y H:i:s') .' GMT');
+ export_headers_base();
+ Header('Content-Description: '.$filename );
if ($filename != '') {
if ($type == 'csv') {
$filename .= '_'.date('YmdHis').'.csv';
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|