2 $Page->api = $_SERVER['HTTP_ACCEPT'] == 'text/plain';
4 function userupload($input, $target = NULL, $filename = NULL)
6 switch ($input['error']) {
9 case UPLOAD_ERR_INI_SIZE:
10 case UPLOAD_ERR_FORM_SIZE:
11 throw new Exception('bestand te groot');
13 case UPLOAD_ERR_NO_FILE:
16 throw new Exception('bestand niet goed ontvangen: '.$input['error']);
20 if (!file_exists($target) and !@mkdir($target, 0777, TRUE)) {
21 throw new Exception("bestand kon niet geplaatst worden in $target");
25 if (isset($filename)) {
29 $target .= $input['name'];
32 if (!@move_uploaded_file($input['tmp_name'], $target)) {
33 throw new Exception("bestand kon niet worden opgeslagen in $target");
36 foreach (@glob('thumb/*/') as $thumbres) {
37 # attempt to remove old derivations
38 @unlink($thumbres . '/' . $target);
43 function messagehtml($input)
45 # convert user textarea post to formatted html
50 if ($User->admin and preg_match('/\A<[a-z][^>]*>/', $input)) {
51 return $input; # allow html input as is if privileged
54 ["/\r?\n/", "'(?:<br />\n?){2}'"],
55 ["<br />\n", "</p>\n\n<p>"],
56 htmlspecialchars($input)
58 return "<p>$html</p>";