Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dokuwiki
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BRIC
dokuwiki
Commits
36625b96
Commit
36625b96
authored
12 years ago
by
Andreas Gohr
Browse files
Options
Downloads
Patches
Plain Diff
run main code only for non-tests in lib/exe/fetch.php
parent
3b399a1b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/exe/fetch.php
+72
-69
72 additions, 69 deletions
lib/exe/fetch.php
with
72 additions
and
69 deletions
lib/exe/fetch.php
+
72
−
69
View file @
36625b96
...
...
@@ -9,81 +9,84 @@
if
(
!
defined
(
'DOKU_INC'
))
define
(
'DOKU_INC'
,
dirname
(
__FILE__
)
.
'/../../'
);
define
(
'DOKU_DISABLE_GZIP_OUTPUT'
,
1
);
require_once
(
DOKU_INC
.
'inc/init.php'
);
//close session
session_write_close
();
$mimetypes
=
getMimeTypes
();
//get input
$MEDIA
=
stripctl
(
getID
(
'media'
,
false
));
// no cleaning except control chars - maybe external
$CACHE
=
calc_cache
(
$INPUT
->
str
(
'cache'
));
$WIDTH
=
$INPUT
->
int
(
'w'
);
$HEIGHT
=
$INPUT
->
int
(
'h'
);
$REV
=
&
$INPUT
->
ref
(
'rev'
);
//sanitize revision
$REV
=
preg_replace
(
'/[^0-9]/'
,
''
,
$REV
);
list
(
$EXT
,
$MIME
,
$DL
)
=
mimetype
(
$MEDIA
,
false
);
if
(
$EXT
===
false
)
{
$EXT
=
'unknown'
;
$MIME
=
'application/octet-stream'
;
$DL
=
true
;
}
// check for permissions, preconditions and cache external files
list
(
$STATUS
,
$STATUSMESSAGE
)
=
checkFileStatus
(
$MEDIA
,
$FILE
,
$REV
);
// prepare data for plugin events
$data
=
array
(
'media'
=>
$MEDIA
,
'file'
=>
$FILE
,
'orig'
=>
$FILE
,
'mime'
=>
$MIME
,
'download'
=>
$DL
,
'cache'
=>
$CACHE
,
'ext'
=>
$EXT
,
'width'
=>
$WIDTH
,
'height'
=>
$HEIGHT
,
'status'
=>
$STATUS
,
'statusmessage'
=>
$STATUSMESSAGE
,
);
// handle the file status
$evt
=
new
Doku_Event
(
'FETCH_MEDIA_STATUS'
,
$data
);
if
(
$evt
->
advise_before
())
{
// redirects
if
(
$data
[
'status'
]
>
300
&&
$data
[
'status'
]
<=
304
)
{
send_redirect
(
$data
[
'statusmessage'
]);
session_write_close
();
//close session
// BEGIN main (if not testing)
if
(
!
defined
(
'SIMPLE_TEST'
))
{
$mimetypes
=
getMimeTypes
();
//get input
$MEDIA
=
stripctl
(
getID
(
'media'
,
false
));
// no cleaning except control chars - maybe external
$CACHE
=
calc_cache
(
$INPUT
->
str
(
'cache'
));
$WIDTH
=
$INPUT
->
int
(
'w'
);
$HEIGHT
=
$INPUT
->
int
(
'h'
);
$REV
=
&
$INPUT
->
ref
(
'rev'
);
//sanitize revision
$REV
=
preg_replace
(
'/[^0-9]/'
,
''
,
$REV
);
list
(
$EXT
,
$MIME
,
$DL
)
=
mimetype
(
$MEDIA
,
false
);
if
(
$EXT
===
false
)
{
$EXT
=
'unknown'
;
$MIME
=
'application/octet-stream'
;
$DL
=
true
;
}
// send any non 200 status
if
(
$data
[
'status'
]
!=
200
)
{
header
(
'HTTP/1.0 '
.
$data
[
'status'
]
.
' '
.
$data
[
'statusmessage'
]);
// check for permissions, preconditions and cache external files
list
(
$STATUS
,
$STATUSMESSAGE
)
=
checkFileStatus
(
$MEDIA
,
$FILE
,
$REV
);
// prepare data for plugin events
$data
=
array
(
'media'
=>
$MEDIA
,
'file'
=>
$FILE
,
'orig'
=>
$FILE
,
'mime'
=>
$MIME
,
'download'
=>
$DL
,
'cache'
=>
$CACHE
,
'ext'
=>
$EXT
,
'width'
=>
$WIDTH
,
'height'
=>
$HEIGHT
,
'status'
=>
$STATUS
,
'statusmessage'
=>
$STATUSMESSAGE
,
);
// handle the file status
$evt
=
new
Doku_Event
(
'FETCH_MEDIA_STATUS'
,
$data
);
if
(
$evt
->
advise_before
())
{
// redirects
if
(
$data
[
'status'
]
>
300
&&
$data
[
'status'
]
<=
304
)
{
send_redirect
(
$data
[
'statusmessage'
]);
}
// send any non 200 status
if
(
$data
[
'status'
]
!=
200
)
{
header
(
'HTTP/1.0 '
.
$data
[
'status'
]
.
' '
.
$data
[
'statusmessage'
]);
}
// die on errors
if
(
$data
[
'status'
]
>
203
)
{
print
$data
[
'statusmessage'
];
exit
;
}
}
// die on errors
if
(
$data
[
'status'
]
>
203
)
{
print
$data
[
'statusmessage'
];
exit
;
$evt
->
advise_after
();
unset
(
$evt
);
//handle image resizing/cropping
if
((
substr
(
$MIME
,
0
,
5
)
==
'image'
)
&&
$WIDTH
)
{
if
(
$HEIGHT
)
{
$data
[
'file'
]
=
$FILE
=
media_crop_image
(
$data
[
'file'
],
$EXT
,
$WIDTH
,
$HEIGHT
);
}
else
{
$data
[
'file'
]
=
$FILE
=
media_resize_image
(
$data
[
'file'
],
$EXT
,
$WIDTH
,
$HEIGHT
);
}
}
}
$evt
->
advise_after
();
unset
(
$evt
);
//handle image resizing/cropping
if
((
substr
(
$MIME
,
0
,
5
)
==
'image'
)
&&
$WIDTH
)
{
if
(
$HEIGHT
)
{
$data
[
'file'
]
=
$FILE
=
media_crop_image
(
$data
[
'file'
],
$EXT
,
$WIDTH
,
$HEIGHT
);
}
else
{
$data
[
'file'
]
=
$FILE
=
media_resize_image
(
$data
[
'file'
],
$EXT
,
$WIDTH
,
$HEIGHT
);
// finally send the file to the client
$evt
=
new
Doku_Event
(
'MEDIA_SENDFILE'
,
$data
);
if
(
$evt
->
advise_before
())
{
sendFile
(
$data
[
'file'
],
$data
[
'mime'
],
$data
[
'download'
],
$data
[
'cache'
]);
}
}
// Do something after the download finished.
$evt
->
advise_after
();
// finally send the file to the client
$evt
=
new
Doku_Event
(
'MEDIA_SENDFILE'
,
$data
);
if
(
$evt
->
advise_before
())
{
sendFile
(
$data
[
'file'
],
$data
[
'mime'
],
$data
[
'download'
],
$data
[
'cache'
]);
}
// Do something after the download finished.
$evt
->
advise_after
();
}
// END DO main
/* ------------------------------------------------------------------------ */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment