-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtool-image-editor-form.php
More file actions
152 lines (148 loc) · 5.85 KB
/
tool-image-editor-form.php
File metadata and controls
152 lines (148 loc) · 5.85 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?php
include_once dirname(__FILE__)."/functions.php";
include dirname(__FILE__)."/conf.php";
include_once dirname(__FILE__)."/auth.php";
include dirname(__FILE__)."/conf.php";
if($cfg->authentification_needed && !$userlogin)
{
exit();
}
$filepath = path_decode(kh_filter_input(INPUT_GET, 'filepath'), $cfg->rootdir);
$fileurl = htmlspecialchars(kh_filter_input(INPUT_GET, 'filepath', FILTER_SANITIZE_STRING));
$error_code = "";
if(file_exists($filepath))
{
if(!is_dir($filepath))
{
$size = getimagesize($filepath);
$url = path_decode_to_url(@$_GET['filepath'], $cfg->rooturl);
if(stripos($size['mime'], 'image')===0)
{
?>
<div id="image-editor-all">
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
<div class="image-editor-filename-name-area"><input type="text" name="curfilepath" id="curfilepath" value="<?php echo $fileurl;?>" /><input type="hidden" name="curfileurl" id="curfileurl" value="<?php echo htmlspecialchars(stripslashes($url));?>" />
<input type="button" name="openimage" id="openimage" value="Open" onClick="editImage($('#curfilepath').val())" class="com-button" />
<input type="button" name="closeeditor" id="closeeditor" value="Close" onClick="destroyImageEditor()" class="com-button delete-button" />
</div>
<div class="image-editor-middle">
<div class="image-editor-sidebar">
<?php
if(function_exists('imagecreatefromjpeg'))
{
?>
<div class="image-editor-sidebar-inner">
<div class="original-image"><img id="imageori" src="<?php echo htmlspecialchars(stripslashes($url));?>?rand=<?php echo mt_rand(111111,999999);?>" /></div>
<div class="current-dimension">
<table width="165" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="90">Current Width</td>
<td width="75"><?php echo $size[0];?> px <input type="hidden" name="curwidth" id="curwidth" value="<?php echo $size[0];?>" /></td>
</tr>
<tr>
<td>Current Height</td>
<td><?php echo $size[1];?> px <input type="hidden" name="curheight" id="curheight" value="<?php echo $size[1];?>" /></td>
</tr>
</table>
</div>
<div class="image-editor-tool">
<div class="image-editor-tool-item image-tool-resize"><a href="javascript:resizeImage('<?php echo $fileurl;?>')">Resize Image</a></div>
<div class="image-tool-resize-dimension">
<div class="new-dimension">
<table width="150" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="75">New Width</td>
<td><input type="text" name="newwidth" id="newwidth" class="image-dim" value="<?php echo $size[0];?>" />
px</td>
</tr>
<tr>
<td>New Height</td>
<td><input type="text" name="newheight" id="newheight" class="image-dim" value="<?php echo $size[1];?>" /> px</td>
</tr>
<tr>
<td colspan="2"><label><input type="checkbox" name="aspectratio" id="aspectratio" value="1" class="input-checkbox" checked="checked" /> Keep aspect ratio</label></td>
</tr>
<tr>
<td colspan="2"><label><input type="checkbox" name="cropimage" id="cropimage" value="1" class="input-checkbox" /> Crop image on center</label></td>
</tr>
</table>
</div>
</div>
<div class="image-editor-tool-item image-tool-rotate-cw"><a href="javascript:rotateCW('<?php echo $fileurl;?>')">Rotate Clockwise</a></div>
<div class="image-editor-tool-item image-tool-rotate-ccw"><a href="javascript:rotateCCW('<?php echo $fileurl;?>')">Rotate Counterclockwise</a></div>
<div class="image-editor-tool-item image-tool-flip-h"><a href="javascript:flipH('<?php echo $fileurl;?>')">Flip Horizontal</a></div>
<div class="image-editor-tool-item image-tool-flip-v"><a href="javascript:flipV('<?php echo $fileurl;?>')">Flip Vertical</a></div>
</div>
<div class="button-area">
<input type="button" name="save" id="save" value="Save" class="com-button" onclick="saveImage()" />
<input type="button" name="discharge" id="discharge" value="Close" class="com-button delete-button" onClick="destroyImageEditor()" />
</div>
</div>
<?php
}
else
{
?>
<div class="image-editor-sidebar-inner">
<div class="warning">GD module is not installed on this server.</div>
</div>
<?php
}
?>
</div>
<div class="image-editor-mainbar">
<div class="image-editor-mainbar-inner">
<div id="image-content">
<img id="image2edit" src="<?php echo htmlspecialchars(stripslashes($url));?>?rand=<?php echo mt_rand(111111,999999);?>" />
</div>
</div>
</div>
</div>
</form>
</div>
<?php
}
else
{
$error_code = "NOT_IMAGE";
}
}
else
{
$error_code = "NOT_FILE";
}
}
else
{
$error_code = "NOT_FOUND";
}
if(strlen($error_code))
{
?>
<div id="image-editor-all">
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
<div class="image-editor-filename-name-area"><input type="text" name="curfilepath" id="curfilepath" value="<?php echo $fileurl;?>" /><input type="hidden" name="curfileurl" id="curfileurl" value="<?php echo htmlspecialchars(stripslashes($url));?>" />
<input type="button" name="openimage" id="openimage" value="Open" onClick="editImage($('#curfilepath').val())" class="com-button" />
<input type="button" name="closeeditor" id="closeeditor" value="Close" onClick="destroyImageEditor()" class="com-button delete-button" />
</div>
</form>
<div class="image-editor-middle">
<?php
switch($error_code)
{
case "NOT_IMAGE":
echo "This file has not valid image format.";
break;
case "NOT_FILE":
echo "The path you type is not a file.";
break;
case "NOT_FOUND":
echo "File not found. Be sure that you type correct path of file.";
break;
}
?>
</div>
</div>
<?php
}
?>