From: cajus Date: Mon, 14 Apr 2008 08:23:58 +0000 (+0000) Subject: Moved gefax around. No need for subdirectory X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4edd44b2de70bf3f0659690cc4726ca6eeb3c8e3;p=gosa.git Moved gefax around. No need for subdirectory git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10385 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/gofax/html/getfax.php b/gosa-plugins/gofax/html/getfax.php new file mode 100644 index 000000000..6a066b067 --- /dev/null +++ b/gosa-plugins/gofax/html/getfax.php @@ -0,0 +1,150 @@ +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-plugins/gofax/html/gofax/getfax.php b/gosa-plugins/gofax/html/gofax/getfax.php deleted file mode 100644 index 6a066b067..000000000 --- a/gosa-plugins/gofax/html/gofax/getfax.php +++ /dev/null @@ -1,150 +0,0 @@ -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: -?> -