Subversion Repositories svnkaklik

Rev

Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
6 kaklik 1
<?
2
$author = trim($_POST['author']);
3
$email = trim($_POST['email']);
4
$site = trim($_POST['site']);
5
 
6
preg_match("#http://[(www.|)a-z0-9(-|_|)a-z0-9]*.[a-z]*#i", $site, $sit);
7
$message = str_replace("\n", "<br>", ltrim(rtrim($_POST['message'])));
8
 
9
 
10
/* this "include" item relates to where the db config page is, no need to change it if you haven't moved it */
11
include('config.php');
12
 
13
$message = str_replace("\n", "<br />", ltrim(rtrim($_POST['message'])));
14
 
15
if($_POST['submit']) { 
16
    $back = "<a href=\"javascript: history.back(-2)\">Back</a>";
17
 
18
 
19
    if($author == 'Name' || $author == 'user' || $author == 'spam' || !$author){
20
        die("Error! : No name entered.<br>
21
        $back");
22
    }
23
    if(($site) && (!$sit)){
24
        die("Error! : Enter a valid website with 'http://' or no site at all.<br>
25
        $back");
26
    }
27
    if($message == 'Message' || !$message){
28
        die("Error! : No message entered<br>
29
        $back");
30
    }
31
 
32
/* strip html tag's, allow only <br> and <a> tags
33
if you wish to add more tags simple add the tag right after <a> (make sure to use a space after <a>)
34
you can do it to more then just the message also */
35
$message = strip_tags($message, '<br> <a>'); 
36
$email = strip_tags($email); 
37
$author = strip_tags($author); 
38
 
39
/* check message length change "200" to change the limit (includeing spaces) */
40
    $message_length = strlen(stripslashes($message));
41
    if($message_length > 200){
42
        die("Messages must be shorter then 200 characters. Your message is: $message_length characters");
43
    }
44
 
45
/* this the smilie tag area for each new one you want to add follow the example show below you then must also edit index.htm
46
"THING_USER_TYPES_IN" => " IMG_LOCATION ",
47
"ANOTHER_THING" => " ANOTHER_IMAGE "
48
commas between the smilies, spaces in the quotes with the <img> so they are bunched up or right ontop of text. */
49
$smiles = array(":)" => " <img src=/images/smilies/icon_smilie.gif> ",
50
                ":(" => " <img src=/images/smilies/icon_sad.gif> ",
51
                ":D" => " <img src=/images/smilies/icon_biggrin.gif> ");
52
$message = strtr($message, $smiles);
53
 
54
 
55
/* this inserts everything into the database then closes the connect to prevent hacking. */
56
mysql_query("INSERT INTO shoutbox (message, author, email, date, ip) 
57
VALUES ('$message','$author','$email','$date','$_SERVER[REMOTE_ADDR]')"); 
58
mysql_close(); 
59
 
60
    /* thank you page, redirects 5 seconds after the page is loaded. Change the <meta> tag's "content=5" to the number of seconds you want */
61
    echo "Your chat entry has been submitted, the top window will display your new entry shortly<BR>
62
    <a href=shoutbox.php>Return Home</A><meta http-equiv=refresh content=5;URL=shoutbox.php>";
63
}else{
64
 
65
 
66
    echo "<form method=POST name=shoutbox action=shoutbox.php>
67
    <input name=author type=text value=Name maxlength=15><br>
68
    <textarea name=message cols=18>Message</textarea><br>
69
    <input type=submit name=submit value=Submit> 
70
    </form>
71
    <a href=/>Return Home</a>";
72
}
73
#OPTIONAL, to save file size, delete the orange comments
74
?> 
75