-
Notifications
You must be signed in to change notification settings - Fork 1
/
jhot.php
executable file
·70 lines (54 loc) · 1.91 KB
/
jhot.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
<?php
// $Id: /cvsroot/tikiwiki/tiki/jhot.php,v 1.21 2007-10-15 07:43:27 sept_7 Exp $
// Copyright (c) 2002-2007, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
# $Id: /cvsroot/tikiwiki/tiki/jhot.php,v 1.21 2007-10-15 07:43:27 sept_7 Exp $
include_once ('tiki-setup.php');
include_once ('lib/drawings/drawlib.php');
if (($tiki_p_admin_drawings != 'y') && ($tiki_p_edit_drawings != 'y') && ($prefs['feature_drawings'] != 'y')) {
die;
}
if (isset($_FILES['filepath']) && is_uploaded_file($_FILES['filepath']['tmp_name'])) {
$size = $_FILES['filepath']['size'];
$name = $_FILES['filepath']['name'];
$type = $_FILES['filepath']['type'];
$pos = strpos($name, 'img/wiki/');
$name = substr($name, $pos);
if ($tikidomain) {
$absolute_name = str_replace("img/wiki/$tikidomain/", '', $name);
} else {
$absolute_name = str_replace("img/wiki/", '', $name);
}
$absolute_name = str_replace('.gif', '', $absolute_name);
$absolute_name = str_replace('.pad_xml', '', $absolute_name);
$now = $tikilib->now;
if (substr($name,-4,4) == '.gif') {
$hash = $absolute_name . md5(uniqid('.')). '.gif';
} elseif (substr($name,-8,8) == '.pad_xml') {
$hash = $absolute_name . md5(uniqid('.')). '.pad_xml';
} else {
die();
}
if (strstr($name, '.pad_xml')) {
$drawlib->update_drawing($absolute_name, $hash, $user);
} else {
$drawlib->set_drawing_gif($absolute_name, $hash);
}
if ($tikidomain) {
$hash = "$tikidomain/$hash";
$name = "$tikidomain/$name";
}
@$fw = fopen("img/wiki/$hash", "wb");
@$fw2 = fopen("img/wiki/$name", "wb");
@$fp = fopen($_FILES['filepath']['tmp_name'], "rb");
while (!feof($fp)) {
$data = fread($fp, 8192 * 16);
fwrite($fw, $data);
fwrite($fw2, $data);
}
fclose ($fp);
fclose ($fw);
fclose ($fw2);
}
?>