Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 128 lines (121 sloc) 4.317 kB
19ef3b3 @sucaritas DataStorage First Commit
authored
1 <?
2 require_once("../Global/Config.php");
3 require_once("../Global/".$__DatabaseImport);
4
5 $Role = 13; //Add Files
6 $Auth = AuthForObject($_REQUEST["sk"],"FID",$_REQUEST["FID"],$Role);
7 $sk = $_REQUEST["sk"];
8 $_REQUEST["Usr"] = GetUserName($sk);
9 if($Auth)
10 {
11 if($pic = GetFile($_REQUEST["FID"]))
12 {
13 //print_r($pic);
14 //exit();
15 $md5 = md5_file($pic[1].$pic[0]);
16 if($md5 == $pic[3] || $_REQUEST["SkipHash"]=="TRUE")
17 {
18 if($__LogFileAccess)
19 {
20 try
21 {
22 LogAction($_REQUEST["Usr"],"Downloaded File",$_REQUEST["FID"],"FID",$pic[1].$pic[0]);
23 }
24 catch(Exception $e)
25 {
26 try
27 {
28 if($__LogErrors)
29 LogAction($_REQUEST["Usr"],"Error while logging error",$_REQUEST["FID"],"FID",$pic[1].$pic[0]."\n".print_r($e,true));
30 }
31 catch(Exception $e){}
32 }
33
34 }
35
36
37 $t = strtolower($pic[2]);
38 if(!AuthForObject($sk,"FID",$_REQUEST["FID"],24/*Retrieve Originals*/))
39 {
40 $ext = ".png";
41 $log = fopen ( "./ServiceLog.txt", 'w');
42 //if($t=="tif" || $t=="tiff" || $t=="jpg" || $t=="pdf" || $t=="gif" || $t=="gif")
43 {
44 $f = basename($pic[0],".".$pic[2]).".pdf";
45 if(file_exists($pic[1].$f."_PDFexp.pdf"))
46 {
47 header("Content-Disposition: attachment; filename=".$pic[0]."_PDFcopy.pdf");
48 readfile($pic[1].$f."_PDFexp.pdf");
49 // unlink($pic[1].$pic[0]."_PDFexp.pdf");
50 fclose($log);
51 exit();
52 }
53 if($t!="tif" && $t!="tiff" && $t!="jpg" && $t!="jpeg" && $t!="gif" && $t!="giff" && $t!="png" && $t!="bmp")
54 {
55 $CMD = "unoconv -f pdf ".$pic[1].$pic[0];
56 //fwrite($log, "\nUnoconv:\n".$CMD);
57 $output = array();
58 $result = exec($CMD,$output);
59
60 $CMD = "convert ".$pic[1].$f." ".$pic[1].$f."%d".$ext;
61 //fwrite($log, "\nSplit1:\n".$CMD);
62 $output = array();
63 $result = exec($CMD,$output);
64 //fwrite($log, "\nSplit:\n".$CMD);
65 }
66 else
67 {
68 $CMD = "convert ".$pic[1].$pic[0]." ".$pic[1].$f."%d".$ext;
69 //fwrite($log, "\nSplit2:\n".$CMD);
70 $output = array();
71 $result = exec($CMD,$output);
72 }
73 //$CMD = "convert -size 140x80 xc:none -fill grey -gravity NorthWest -draw \"text 10,10 '".$__Watermark."'\" -gravity SouthEast -draw \"text 5,15 '".$__Watermark."'\" ".$pic[1]."Stamp.png";
74 //$output = array();
75 //$result = exec($CMD,$output);
76 //fwrite($log, "\nLooking for:".$pic[1].$f."*".$ext."\n");
77 foreach (glob($pic[1].$f."*".$ext) as $filename)
78 {
79 $CMD = "composite -format png -tile ./Stamp.png ".$filename." ".$filename;
80 $output = array();
81 $result = exec($CMD,$output);
82 //fwrite($log, "\npic:".$filename."\n".$CMD);
83 //fwrite($log, "\nResult:".$result);
84 //fwrite($log, "\nOutput:".print_r($output,true));
85 }
86
87 $CMD = "convert ".$pic[1].$f."*".$ext." ".$pic[1].$f."_PDFexp.pdf";
88 //fwrite($log, "\nPacking:".$CMD);
89 $output = array();
90 $result = exec($CMD,$output);
91 foreach (glob($pic[1].$pic[0]."*".$ext) as $filename)
92 unlink($filename);
93
94 //fwrite($log, "\nLooking for copy:".$pic[1].$f."_PDFexp.pdf\n");
95 if(file_exists($pic[1].$f."_PDFexp.pdf"))
96 {
97 header("Content-Disposition: attachment; filename=".$pic[0]."_PDFcopy.pdf");
98 readfile($pic[1].$f."_PDFexp.pdf");
99 // unlink($pic[1].$pic[0]."_PDFexp.pdf");
100 fclose($log);
101 exit();
102 }
103 }
104 }
105 header("Content-Disposition: attachment; filename=".$pic[4]);
106 readfile($pic[1].$pic[0]);
107 }
108 else
109 {
110 print "<FONT COLOR='RED'>This file has been modified from the original!!!...</FONT><br>";
111 print "<input type='button' value='Download File anyway?' OnClick=\"window.location='./GetFile.php?sk=".$_REQUEST["sk"]."&FID=".$_REQUEST["FID"]."&SkipHash=TRUE'\">";
112 if($__LogErrors)
113 LogAction($_REQUEST["Usr"],"Error File Hash Failed",$_REQUEST["FID"],"FID",$pic[1].$pic[0]);
114 }
115 exit();
116 }
117 }
118 else
119 {
120 print "Access Denied.";
121 if($__LogFileAccess)
122 LogAction($_REQUEST["Usr"],"Error File Access Denied",$_REQUEST["FID"],"FID",$pic[1].$pic[0]);
123 exit();
124 }
125 if($__LogErrors)
126 LogAction($_REQUEST["Usr"],"Error File missing",$_REQUEST["FID"],"FID",$pic[1].$pic[0]."\n".print_r($e,true));
127 print "No such file.";
128 ?>
Something went wrong with that request. Please try again.