-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
134 lines (108 loc) · 3.35 KB
/
index.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php?>
<?
if( isset($_GET['download'] ) ){
$filename = 'StickyThumb.class.php';
header('Content-Disposition: attachment; filename="' . $filename . '"');
readfile( $filename );
exit;
}
?>
<html>
<head>
<title>StickyThumb!</title>
</head>
<body>
<h1>StickyThumb!</h1>
<form>
<p>
<label>Input Filename or URL</label><br/>
<input type="text" name="inFile" value="<?=@$_GET['inFile'] ?: 'Arnold-Standing-Smiling.jpg'?>" size="100"/>
</p>
<p>
<label>Output Filename</label><br/>
<input type="text" name="outFile" value="<?=@$_GET['outFile'] ?: 'thumb.jpg' ?>" size="100"/>
</p>
<p>
<label>Size</label><br/>
<input type="text" name="width" value="<?=@$_GET['width'] ?: 200?>" size="30"/> x <input type="text" name="height" value="<?=@$_GET['height'] ?: 200?>" size="30"/>
</p>
<p>
<label>Mode</label><br/>
<?
$modes = array('cover','fit');
if( isset( $_GET['mode'] ) ){
$selectedMode = @$_GET['mode'];
}
else{
$selectedMode = current( $modes );
}
foreach( $modes as $mode ){
?><label for="mode_<?=$mode?>"><input id="mode_<?=$mode?>" type="radio" name="mode" value="<?=$mode?>"<? if( $mode == $selectedMode ){ ?> checked="checked"<? } ?>/> <?=$mode?></label><br/><?
}
?>
</p>
<p>
<?
$sizeUp = ( @$_GET['sizeUp'] ) != 'no';
$sizeUpIsDefault = $sizeUp == true;
?>
<label>Upsizeing</label><br/>
<input type="hidden" name="sizeUp" value="no" />
<label for="sizeUp">
<input id="sizeUp" type="checkbox" name="sizeUp" value="yes" <? if( $sizeUp ){ ?>checked="checked" <? } ?> />
Upsize small images
</label>
</p>
<p>
<?
if( empty( $_GET['backgroundColor'] ) ){
$backgroundColor = 0xffffff;
}
else{
$backgroundColor = hexdec( $_GET['backgroundColor'] );
}
$backgroundColorIsDefault = $backgroundColor == 0xffffff;
$backgroundColorHex = str_pad( dechex( $backgroundColor ), 6, '0', STR_PAD_LEFT );
?>
<label>Background color</label><br/>
<label for="backgroundColor">
<input id="backgroundColor" type="text" name="backgroundColor" value="<?=$backgroundColorHex?>" />
</label>
</p>
<p>
<input type="submit" value="Try it!"/>
<input type="button" value="Download the PHP class file!" onclick="location='index.php?download';"/>
</p>
</form>
<?
if( !empty( $_GET['inFile'] ) and !empty( $_GET['outFile'] ) and !empty( $_GET['width'] ) and !empty( $_GET['height'] ) ){
if( end(explode('.',$_GET['outFile'])) != 'php' ){
include'StickyThumb.class.php';
$sticky = new StickyThumb( $_GET['width'], $_GET['height'], $_GET['mode'], $sizeUp, $backgroundColor );
$sticky->makeThumb( $_GET['inFile'], $_GET['outFile'] );
?>
<pre>
$thumb = new StickyThumb( <?=$_GET['width']?>, <?=$_GET['height']?>, '<?=$_GET['mode']?>'<?
if( !$sizeUpIsDefault || !$backgroundColorIsDefault ){
?>, <? var_export( $sizeUp )?><?
}
if( !$backgroundColorIsDefault ){
?>, 0x<?=$backgroundColorHex?> );<?
}
?> );<?
echo "\n"
?>$thumb->makeThumb( <? var_export( $_GET['inFile'] )?>, <? var_export( $_GET['outFile'])?> );
</pre>
<p>
<img src="<?=$_GET['outFile']?>"/><br/>
<?
list( $width, $height ) = getimagesize( $_GET['outFile'] );
?>
<?=$width?> x <?=$height?>
</p>
<?
}
}
?>
</body>
</html>