summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: efdc98d)
raw | patch | inline | side by side (parent: efdc98d)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 14 Apr 2008 08:23:13 +0000 (08:23 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 14 Apr 2008 08:23:13 +0000 (08:23 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10384 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/html/getfax.php | [deleted file] | patch | blob | history |
gosa-core/html/getvcard.php | [deleted file] | patch | blob | history |
gosa-plugins/gofax/gofax/faxreports/detail.tpl | patch | blob | history | |
gosa-plugins/gofax/html/gofax/getfax.php | [new file with mode: 0644] | patch | blob |
diff --git a/gosa-core/html/getfax.php b/gosa-core/html/getfax.php
+++ /dev/null
@@ -1,150 +0,0 @@
-<?php
-/*
- * This code is part of GOsa (http://www.gosa-project.org)
- * Copyright (C) 2003-2008 GONICUS GmbH
- *
- * ID: $$Id$$
- *
- * 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; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/* Basic setup, remove eventually registered sessions */
-@require_once ("../include/php_setup.inc");
-@require_once ("functions.inc");
-error_reporting (0);
-session::start();
-session::set('errorsAlreadyPosted',array());
-
-/* Logged in? Simple security check */
-if (!session::is_set('ui')){
- new log("security","faxreport/faxreport","",array(),"Error: getfax.php called without session") ;
- header ("Location: index.php");
- exit;
-}
-$ui= session::is_set("ui");
-
-/* User object present? */
-if (!session::is_set('fuserfilter')){
- new log("security","faxreport/faxreport","",array(),"getfax.php called without propper session data") ;
- header ("Location: index.php");
- exit;
-}
-
-/* Get loaded servers */
-foreach (array("FAX_SERVER", "FAX_LOGIN", "FAX_PASSWORD") as $val){
- if (session::is_set($val)){
- $$val= session::get($val);
- }
-}
-
-/* Load fax entry */
-$config= session::get('config');
-$cfg= $config->data['SERVERS']['FAX'];
-$link = mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD'])
- or die(_("Could not connect to database server!"));
-
-mysql_select_db("gofax") or die(_("Could not select database!"));
-
-
-/* Permission to view? */
-$query = "SELECT id,uid FROM faxlog WHERE id = '".validate(stripcslashes($_GET['id']))."'";
-$result = mysql_query($query) or die(_("Database query failed!"));
-$line = mysql_fetch_array($result, MYSQL_ASSOC);
-if (!preg_match ("/'".$line["uid"]."'/", session::get('fuserfilter'))){
- die ("No permissions to view fax!");
-}
-
-$query = "SELECT id,fax_data FROM faxdata WHERE id = '".
- validate(stripcslashes($_GET['id']))."'";
-$result = mysql_query($query) or die(_("Database query failed!"));
-
-/* Load pic */
-$data = mysql_result ($result, 0, "fax_data");
-mysql_close ($link);
-
-if (!isset($_GET['download'])){
-
- /* display picture */
- header("Content-type: image/png");
-
- /* Fallback if there's no image magick support in PHP */
- if (!function_exists("imagick_blob2image")){
-
- /* Write to temporary file and call convert, because TIFF sucks */
- $tmpfname = tempnam ("/tmp", "GOsa");
- $temp= fopen($tmpfname, "w");
- fwrite($temp, $data);
- fclose($temp);
-
- /* Read data written by convert */
- $output= "";
- $query= "convert -size 420x594 $tmpfname -resize 420x594 +profile \"*\" png:- 2> /dev/null";
- $sh= popen($query, 'r');
- $data= "";
- while (!feof($sh)){
- $data.= fread($sh, 4096);
- }
- pclose($sh);
-
- unlink($tmpfname);
-
- } else {
-
- /* Loading image */
- if(!$handle = imagick_blob2image($data)) {
- new log("view","faxreport/faxreport","",array(), "Cannot load fax image") ;
- }
-
- /* Converting image to PNG */
- if(!imagick_convert($handle,"PNG")) {
- new log("view","faxreport/faxreport","",array(),"Cannot convert fax image to png") ;
- }
-
- /* Resizing image to 420x594 and blur */
- if(!imagick_resize($handle,420,594,IMAGICK_FILTER_GAUSSIAN,1)){
- new log("view","faxreport/faxreport","",array(),"Cannot resize fax image") ;
- }
-
- /* Creating binary Code for the Image */
- if(!$data = imagick_image2blob($handle)){
- new log("view","faxreport/faxreport","",array(),"Reading fax image image failed") ;
- }
- }
-
-} else {
-
- /* force download dialog */
- header("Content-type: application/tiff\n");
- if (preg_match('/MSIE 5.5/', $HTTP_USER_AGENT) ||
- preg_match('/MSIE 6.0/', $HTTP_USER_AGENT)) {
- header('Content-Disposition: filename="fax.tif"');
- } else {
- header('Content-Disposition: attachment; filename="fax.tif"');
- }
- header("Content-transfer-encoding: binary\n");
- header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
- header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
- header("Cache-Control: no-cache");
- header("Pragma: no-cache");
- header("Cache-Control: post-check=0, pre-check=0");
-
-}
-
-/* print the tiff image and close the connection */
-echo "$data";
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
-
diff --git a/gosa-core/html/getvcard.php b/gosa-core/html/getvcard.php
+++ /dev/null
@@ -1,170 +0,0 @@
-<?php
-/*
- * This code is part of GOsa (http://www.gosa-project.org)
- * Copyright (C) 2003-2008 GONICUS GmbH
- *
- * ID: $$Id$$
- *
- * 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; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/* Basic setup, remove eventually registered sessions */
-@require_once ("../include/php_setup.inc");
-@require_once ("functions.inc");
-error_reporting (0);
-session::start();
-session::set('errorsAlreadyPosted',array());
-
-/* Logged in? Simple security check */
-if (!session::is_set('ui')){
- new log("security","all/all","",array(),"Error: getvcard.php called without session") ;
- header ("Location: index.php");
- exit;
-}
-
-/* Uid parameter set? */
-if (!isset($_GET['dn']) || $_GET['dn'] == ""){
- msg_dialog::display(_("Internal error"), _("Missing parameters!"), FATAL_ERROR_DIALOG);
- exit;
-}
-
-header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
-header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
-header("Cache-Control: no-cache");
-header("Pragma: no-cache");
-header("Cache-Control: post-check=0, pre-check=0");
-header("Content-type: text/x-vcard; charset=utf-8");
-header("Content-type: text/plain");
-if (preg_match('/MSIE 5.5/', $HTTP_USER_AGENT) ||
- preg_match('/MSIE 6.0/', $HTTP_USER_AGENT)) {
-
- header('Content-Disposition: filename="'.$name.'.vcf"');
-} else {
- header('Content-Disposition: attachment; filename="'.$name.'.vcf"');
-}
-
-/* Get entry */
-$config= session::get('config');
-$ldap= $config->get_ldap_link();
-$ldap->cat(base64_decode(validate($_GET['dn'])));
-
-/*
- * Generate vcard for specified IDs
- */
-while ($attrs= $ldap->fetch()){
- /* Header / Name */
- echo "BEGIN:VCARD\n";
- echo "VERSION:3.0\n";
- echo "FN:".preg_replace('/,/', '\\,', $attrs['cn'][0])."\n";
-
- /* Assemble titles for N attribute */
- $titles= "";
- if (isset($attrs['personalTitle'])){
- $titles= $attrs['personalTitle'][0];
- }
- if (isset($attrs['academicTitle'])){
- if ($titles != ""){
- $titles.= ",".$attrs['academicTitle'][0];
- } else {
- $titles= $attrs['academicTitle'][0];
- }
- }
- echo "N:".$attrs['sn'][0].";".$attrs['givenName'][0].";;;$titles\n";
-
- /* Generate random UID */
- $uid= "";
- srand(make_seed());
- $chars= '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
- for ($i= 0; $i<16; $i++){
- $uid.= $chars[rand(0, strlen($chars)-1)];
- }
- echo "UID:$uid\n";
-
- /* Mail addresses */
- if (isset($attrs['mail'][0])){
- echo "EMAIL;TYPE=internet,pref:".$attrs['mail'][0]."\n";
- if (isset($attrs['gosaMailAlternateAddress'])){
- for ($i= 0; $i<$attrs['gosaMailAlternateAddress']['count']; $i++){
- echo "EMAIL;TYPE=internet:".
- $attrs['gosaMailAlternateAddress'][$i]."\n";
- }
- }
- }
-
- /* Export date */
- echo "REV:".date("Y-m-d")."\n";
- echo "CLASS:PUBLIC\n";
-
- /* Fill address */
- if (isset($attrs['homePostalAddress'])){
- @list($street,$town,$country)= preg_split('/\n/', $attrs['homePostalAddress'][0]);
- echo "ADR;TYPE=home:;;".trim($street).";".trim($town).";;;".
- trim($country)."\n";
- }
- if (isset($attrs['postalAddress'])){
- @list($street,$town,$country)= preg_split('/\n/', $attrs['postalAddress'][0]);
- echo "ADR;TYPE=work,pref:;;".trim($street).";".trim($town).";;;".
- trim($country)."\n";
- }
-
- /* Telephone numbers */
- if (isset($attrs['homePhone'])){
- echo "TEL;TYPE=home:".$attrs['homePhone'][0]."\n";
- }
- if (isset($attrs['telephoneNumber'])){
- echo "TEL;TYPE=work,pref:".$attrs['telephoneNumber'][0]."\n";
- }
- if (isset($attrs['mobile'])){
- echo "TEL;TYPE=cell:".$attrs['mobile'][0]."\n";
- }
- if (isset($attrs['pager'])){
- echo "TEL;TYPE=pager:".$attrs['pager'][0]."\n";
- }
-
- /* Set organization */
- if (isset($attrs['o'])){
- echo "ORG:".$attrs['o'][0]."\n";
- }
-
- echo "NOTE:Exported by GOsa - https://gosa.gonicus.de\n";
- echo "SORT-STRING:".$attrs['sn'][0]."\n";
- if (isset($attrs['labeledURI'][0])){
- echo "URL:".$attrs['labeledURI'][0]."\n";
- }
-
- /* Add user certificate */
-#if (isset($attrs['userCertificate;binary'])){
-# $cert= $ldap->get_attribute($ldap->getDN(), "userCertificate;binary");
-# $cert= preg_replace('/\r\n/', chr(10).' ', chunk_split(base64_encode($cert)));
-# echo "KEY;ENCODING=b:".preg_replace('/\n $/', '', $cert)."\n";
-#}
-
- /* Add picture */
- if (isset($attrs['jpegPhoto'])){
- $photodata= $ldap->get_attribute($ldap->getDN(), "jpegPhoto");
- $photodata= preg_replace('/\r\n/', chr(10).' ', chunk_split(base64_encode($photodata)));
- echo "PHOTO;ENCODING=b;TYPE=JPEG:".preg_replace('/\n $/', '', $photodata)."\n";
- }
-
- /* Day of birth */
- if (isset($attrs['dayOfBirth'][0])){
- echo "BDAY:".$attrs['dayOfBirth'][0]."\n";
- }
-
- echo "END:VCARD\n\n";
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-plugins/gofax/gofax/faxreports/detail.tpl b/gosa-plugins/gofax/gofax/faxreports/detail.tpl
index 4a8f045d80abd7c088a3ea4ef1407ec4994bae4e..b3cbf296e5b4edb4ea46074194e9376c18aff34c 100644 (file)
<table summary="">
<tr>
<td>
- <a href="getfax.php?id={$detail}&download=1">
- <img align="bottom" width="420" height="594" src="getfax.php?id={$detail}" alt="{t}FAX preview - please wait{/t}" border=1>
+ <a href="gofax/getfax.php?id={$detail}&download=1">
+ <img align="bottom" width="420" height="594" src="gofax/getfax.php?id={$detail}" alt="{t}FAX preview - please wait{/t}" border=1>
</a>
<p style="margin-top-width:0px; text-align:center;">
{t}Click on fax to download{/t}
diff --git a/gosa-plugins/gofax/html/gofax/getfax.php b/gosa-plugins/gofax/html/gofax/getfax.php
--- /dev/null
@@ -0,0 +1,150 @@
+<?php
+/*
+ * This code is part of GOsa (http://www.gosa-project.org)
+ * Copyright (C) 2003-2008 GONICUS GmbH
+ *
+ * ID: $$Id$$
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/* Basic setup, remove eventually registered sessions */
+@require_once ("../include/php_setup.inc");
+@require_once ("functions.inc");
+error_reporting (0);
+session::start();
+session::set('errorsAlreadyPosted',array());
+
+/* Logged in? Simple security check */
+if (!session::is_set('ui')){
+ new log("security","faxreport/faxreport","",array(),"Error: getfax.php called without session") ;
+ header ("Location: index.php");
+ exit;
+}
+$ui= session::is_set("ui");
+
+/* User object present? */
+if (!session::is_set('fuserfilter')){
+ new log("security","faxreport/faxreport","",array(),"getfax.php called without propper session data") ;
+ header ("Location: index.php");
+ exit;
+}
+
+/* Get loaded servers */
+foreach (array("FAX_SERVER", "FAX_LOGIN", "FAX_PASSWORD") as $val){
+ if (session::is_set($val)){
+ $$val= session::get($val);
+ }
+}
+
+/* Load fax entry */
+$config= session::get('config');
+$cfg= $config->data['SERVERS']['FAX'];
+$link = mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD'])
+ or die(_("Could not connect to database server!"));
+
+mysql_select_db("gofax") or die(_("Could not select database!"));
+
+
+/* Permission to view? */
+$query = "SELECT id,uid FROM faxlog WHERE id = '".validate(stripcslashes($_GET['id']))."'";
+$result = mysql_query($query) or die(_("Database query failed!"));
+$line = mysql_fetch_array($result, MYSQL_ASSOC);
+if (!preg_match ("/'".$line["uid"]."'/", session::get('fuserfilter'))){
+ die ("No permissions to view fax!");
+}
+
+$query = "SELECT id,fax_data FROM faxdata WHERE id = '".
+ validate(stripcslashes($_GET['id']))."'";
+$result = mysql_query($query) or die(_("Database query failed!"));
+
+/* Load pic */
+$data = mysql_result ($result, 0, "fax_data");
+mysql_close ($link);
+
+if (!isset($_GET['download'])){
+
+ /* display picture */
+ header("Content-type: image/png");
+
+ /* Fallback if there's no image magick support in PHP */
+ if (!function_exists("imagick_blob2image")){
+
+ /* Write to temporary file and call convert, because TIFF sucks */
+ $tmpfname = tempnam ("/tmp", "GOsa");
+ $temp= fopen($tmpfname, "w");
+ fwrite($temp, $data);
+ fclose($temp);
+
+ /* Read data written by convert */
+ $output= "";
+ $query= "convert -size 420x594 $tmpfname -resize 420x594 +profile \"*\" png:- 2> /dev/null";
+ $sh= popen($query, 'r');
+ $data= "";
+ while (!feof($sh)){
+ $data.= fread($sh, 4096);
+ }
+ pclose($sh);
+
+ unlink($tmpfname);
+
+ } else {
+
+ /* Loading image */
+ if(!$handle = imagick_blob2image($data)) {
+ new log("view","faxreport/faxreport","",array(), "Cannot load fax image") ;
+ }
+
+ /* Converting image to PNG */
+ if(!imagick_convert($handle,"PNG")) {
+ new log("view","faxreport/faxreport","",array(),"Cannot convert fax image to png") ;
+ }
+
+ /* Resizing image to 420x594 and blur */
+ if(!imagick_resize($handle,420,594,IMAGICK_FILTER_GAUSSIAN,1)){
+ new log("view","faxreport/faxreport","",array(),"Cannot resize fax image") ;
+ }
+
+ /* Creating binary Code for the Image */
+ if(!$data = imagick_image2blob($handle)){
+ new log("view","faxreport/faxreport","",array(),"Reading fax image image failed") ;
+ }
+ }
+
+} else {
+
+ /* force download dialog */
+ header("Content-type: application/tiff\n");
+ if (preg_match('/MSIE 5.5/', $HTTP_USER_AGENT) ||
+ preg_match('/MSIE 6.0/', $HTTP_USER_AGENT)) {
+ header('Content-Disposition: filename="fax.tif"');
+ } else {
+ header('Content-Disposition: attachment; filename="fax.tif"');
+ }
+ header("Content-transfer-encoding: binary\n");
+ header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+ header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
+ header("Cache-Control: no-cache");
+ header("Pragma: no-cache");
+ header("Cache-Control: post-check=0, pre-check=0");
+
+}
+
+/* print the tiff image and close the connection */
+echo "$data";
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
+