2 function userupload($input, $target = NULL, $filename = NULL)
4 switch ($input['error']) {
7 case UPLOAD_ERR_INI_SIZE:
8 case UPLOAD_ERR_FORM_SIZE:
9 throw new Exception('bestand te groot');
11 case UPLOAD_ERR_NO_FILE:
14 throw new Exception('bestand niet goed ontvangen: '.$input['error']);
18 if (!file_exists($target) and !@mkdir($target, 0777, TRUE)) {
19 throw new Exception("bestand kon niet geplaatst worden in $target");
23 if (isset($filename)) {
27 $target .= $input['name'];
30 if (!@move_uploaded_file($input['tmp_name'], $target)) {
31 throw new Exception("bestand kon niet worden opgeslagen in $target");
34 foreach (@glob('thumb/*/') as $thumbres) {
35 # attempt to remove old derivations
36 @unlink($thumbres . '/' . $target);
41 function messagehtml($input)
43 # convert user textarea post to formatted html
47 $html = htmlspecialchars($input);
48 $html = preg_replace('"(?:<br />){2}"', "</p>\n\n<p>", nl2br($html));
49 return "<p>$html</p>";