@@ -19,12 +19,9 @@ class HttpuploadComponent extends AppComponent
19
19
{
20
20
21
21
var $ tmpDirectory = '' ;
22
- var $ tokenParamName = '' ;
22
+ var $ tokenParamName = 'uploadtoken ' ;
23
23
var $ testingEnable = false ;
24
24
25
- var $ logFile = '' ;
26
- var $ logType = 0 ;
27
-
28
25
/** Set the upload temporary directory */
29
26
public function setTmpDirectory ($ dir )
30
27
{
@@ -81,25 +78,20 @@ public function process($args)
81
78
{
82
79
$ uploadOffset = (float )0 ; // bytes received
83
80
84
- //check parameters
85
81
if (!array_key_exists ('filename ' , $ args ))
86
82
{
87
- error_log (__FILE__ .": " .__FUNCTION__ .": " .__LINE__ ." - " ."Parameter filename is not defined " , $ this ->logType , $ this ->logFile );
88
83
throw new Exception ('Parameter filename is not defined ' , -150 );
89
84
}
85
+ $ filename = $ args ['filename ' ];
90
86
91
- $ filename = $ args ['filename ' ]; // XXXX.ISP
92
-
93
- if (!array_key_exists ($ this ->tokenParamName , $ args ))
87
+ if (!array_key_exists ($ this ->tokenParamName , $ args ))
94
88
{
95
- error_log (__FILE__ .": " .__FUNCTION__ .": " .__LINE__ ." - " ."Parameter " .$ this ->tokenParamName ." is not defined " , $ this ->logType , $ this ->logFile );
96
89
throw new Exception ('Parameter ' .$ this ->tokenParamName .' is not defined ' , -150 );
97
90
}
98
- $ uploadToken = $ args [$ this ->tokenParamName ]; //XXX123.TMP
91
+ $ uploadToken = $ args [$ this ->tokenParamName ];
99
92
100
- if (!array_key_exists ('length ' , $ args ))
93
+ if (!array_key_exists ('length ' , $ args ))
101
94
{
102
- error_log (__FILE__ .": " .__FUNCTION__ .": " .__LINE__ ." - " ."Parameter length is not defined " , $ this ->logType , $ this ->logFile );
103
95
throw new Exception ('Parameter length is not defined ' , -150 );
104
96
}
105
97
$ length = (float )($ args ['length ' ]);
@@ -113,7 +105,6 @@ public function process($args)
113
105
$ pathTemporaryFilename = $ this ->tmpDirectory .'/ ' .$ uploadToken ;
114
106
if (!file_exists ($ pathTemporaryFilename ))
115
107
{
116
- error_log (__FILE__ .': ' .__FUNCTION__ .': ' .__LINE__ .' - ' .'Invalid upload token ' , $ this ->logType , $ this ->logFile );
117
108
throw new Exception ('Invalid upload token ' , -141 );
118
109
}
119
110
else
@@ -125,28 +116,26 @@ public function process($args)
125
116
$ streamChecksum = $ uploadOffset == 0 ;
126
117
127
118
set_time_limit (0 ); // Timeout of the PHP script set to Infinite
128
- ignore_user_abort (TRUE );
119
+ ignore_user_abort (true );
129
120
130
121
$ inputfile = 'php://input ' ; // Stream (Client -> Server) Mode: Read, Binary
131
- if ($ this ->testingEnable && array_key_exists ('localinput ' , $ args ))
122
+ if ($ this ->testingEnable && array_key_exists ('localinput ' , $ args ))
132
123
{
133
124
$ inputfile = $ localinput ; // Stream (LocalServerFile -> Server) Mode: Read, Binary
134
125
}
135
126
136
- $ in = fopen ($ inputfile , 'rb ' ); // Stream (LocalServerFile -> Server) Mode: Read, Binary
137
- if ($ in === FALSE )
138
- {
139
- error_log (__FILE__ .': ' .__FUNCTION__ .': ' .__LINE__ .' - ' ."Failed to open source: $ inputfile " , $ this ->logType , $ this ->logFile );
140
- throw new Exception ("Failed to open [ $ inputfile] source " , -142 );
141
- }
127
+ $ in = fopen ($ inputfile , 'rb ' ); // Stream (LocalServerFile -> Server) Mode: Read, Binary
128
+ if ($ in === false )
129
+ {
130
+ throw new Exception ('Failed to open [ ' .$ inputfile .'] source ' , -142 );
131
+ }
142
132
143
133
// open target output
144
134
$ out = fopen ($ pathTemporaryFilename , 'ab ' ); // Stream (Server -> TempFile) Mode: Append, Binary
145
- if ($ out === false )
146
- {
147
- error_log (__FILE__ .': ' .__FUNCTION__ .': ' .__LINE__ .' - ' ."Failed to open output file: $ pathTemporaryFilename " , $ this ->logType , $ this ->logFile );
148
- throw new Exception ("Failed to open output file [ $ pathTemporaryFilename] " , -143 );
149
- }
135
+ if ($ out === false )
136
+ {
137
+ throw new Exception ('Failed to open output file [ ' .$ pathTemporaryFilename .'] ' , -143 );
138
+ }
150
139
151
140
if ($ streamChecksum )
152
141
{
@@ -174,8 +163,7 @@ public function process($args)
174
163
175
164
if ($ uploadOffset < $ length )
176
165
{
177
- error_log (__FILE__ .': ' .__FUNCTION__ .': ' .__LINE__ .' - ' ."Failed to upload file - {$ uploadOffset }/ {$ length } bytes transferred " , $ this ->logType , $ this ->logFile );
178
- throw new Exception ("Failed to upload file - {$ uploadOffset }/ {$ length } bytes transferred " , -105 );
166
+ throw new Exception ('Failed to upload file - ' .$ uploadOffset .'/ ' .$ length .' bytes transferred ' , -105 );
179
167
}
180
168
181
169
$ data ['filename ' ] = $ filename ;
0 commit comments