Subversion Repositories Applications.papyrus

Rev

Rev 1688 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
831 florian 1
<?php
2
 
3
////////////////////////////////////////////////////////////////////////////////
4
//                                                                            //
5
//   Copyright (C) 2006  Phorum Development Team                              //
6
//   http://www.phorum.org                                                    //
7
//                                                                            //
8
//   This program is free software. You can redistribute it and/or modify     //
9
//   it under the terms of either the current Phorum License (viewable at     //
10
//   phorum.org) or the Phorum License that was distributed with this file    //
11
//                                                                            //
12
//   This program is distributed in the hope that it will be useful,          //
13
//   but WITHOUT ANY WARRANTY, without even the implied warranty of           //
14
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     //
15
//                                                                            //
16
//   You should have received a copy of the Phorum License                    //
17
//   along with this program.                                                 //
18
////////////////////////////////////////////////////////////////////////////////
19
 
20
if(!defined("PHORUM")) return;
21
 
22
// Create an empty message structure.
23
$message = array();
24
 
25
// Inject form field data into the message structure. No checks
26
// are done on the data over here. Here we just take care of
27
// putting the data in the right format in the data structure.
28
foreach ($PHORUM["post_fields"] as $var => $spec)
29
{
30
    // Format and store the data based on the configuration.
31
    switch ($spec[pf_TYPE])
32
    {
33
    	case "boolean":
34
    	    $message[$var] = isset($_POST[$var]) && $_POST[$var] ? 1 : 0;
35
    	    break;
36
 
37
    	case "integer":
38
    	    $message[$var] = isset($_POST[$var]) ? (int) $_POST[$var] : NULL;
39
    	    break;
40
 
41
        case "array":
42
    	    $message[$var] = isset($_POST[$var]) ? unserialize($_POST[$var]) : array();
43
    	    break;
44
 
45
        case "string":
46
    	    $message[$var] = isset($_POST[$var]) ? trim($_POST[$var]) : '';
47
            // Prevent people from impersonating others by using
48
            // multiple spaces in the author name.
49
            if ($var == 'author') {
50
                $message[$var] = preg_replace('/\s+/', ' ', $message[$var]);
51
            }
52
    	    break;
53
 
54
    	default:
55
    	    die ("Illegal field type used for field $var: " . $spec[pf_TYPE]);
56
    }
57
}
58
 
59
?>