forked from toollabs/convert
-
Notifications
You must be signed in to change notification settings - Fork 1
/
restart.php
80 lines (78 loc) · 2.24 KB
/
restart.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
$tool_user_name = 'svgworkaroundbot';
include_once ( 'shared/common.php' ) ;
error_reporting( E_ALL & ~E_NOTICE ); # Don't clutter the directory with unhelpful stuff
$url = getProtocol() . "://tools.wmflabs.org/$tool_user_name/";
if ( !array_key_exists( 'file', $_FILES ) ) {
header( "Location: $url" );
die();
}
$uploadName = $_FILES['file']['tmp_name'];
$fileName = $uploadName . '.svg';
$svgcleanerEnabled = isset( $_POST['svgcleaner'] );
$drei='NO';
if ( $svgcleanerEnabled ) {
$drei = 'YES';
}
$scourEnabled = isset( $_POST['scour'] );
$vier='NO';
if ( $scourEnabled ) {
$vier = 'YES';
}
$validEnabled = isset( $_POST['valid'] );
$funf='NO';
if ( $validEnabled ) {
$funf = 'YES';
}
$inkscapeEnabled = isset( $_POST['RunInkscape'] );
$sechs='NO';
if ( $RunInkscape ) {
$sechs = 'YES';
}
$targetName = $fileName . '.svg';
if ( $_FILES['file']['size'] > 5*0x100000 ) {
unlink( $uploadName );
header( "Location: $url#tooBig" );
die();
}
if ( !move_uploaded_file( $uploadName, $fileName ) ) {
unlink( $uploadName );
header( "Location: $url#cantmove" );
echo( 'cant move uploaded file' );
die();
}
exec( 'webservice restart');
unlink( $fileName );
// $file = 'tmp_svg2svg.log';
// // Öffnet die Datei, um den vorhandenen Inhalt zu laden
// $current = file_get_contents($file);
// // Fügt eine neue Person zur Datei hinzu
// $current .= "John Smith\n";
// // Schreibt den Inhalt in die Datei zurück
file_put_contents($file, $current);
$handle = fopen( $targetName, 'r' );
// if ( $handle === false ) {
// header( "Location: $url#conversionError" );
// echo( 'error converting the file' );
// // die();
// }
if ( filesize( $targetName ) > 10*0x100000 ) {
fclose( $handle );
unlink( $targetName );
header( "Location: $url#outputTooHuge" );
echo( 'output unexpectedly huge' );
die();
}
$content = file_get_contents( $targetName );
fclose( $handle );
unlink( $targetName );
if ( strlen( $content ) > 10*0x100000 ) {
header( "Location: $url#outputTooHuge2" );
echo( 'output unexpectedly huge 2' );
die();
}
header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' );
header( 'Content-type: image/svg+xml' );
header( 'Content-Disposition: attachment; filename="' . addslashes( $_FILES['file']['name'] ) . '.svg"' );
echo $content;
die();