Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
6 kaklik 1
<?
2
/*
3
 +-------------------------------------------------------------------+
4
 |                      S H O U T B O X   (v1.0)                     |
5
 |                          P a r t   II                             |
6
 |                                                                   |
7
 | Copyright Gerd Tentler               http://www.gerd-tentler.de   |
8
 | Created: Jun. 1, 2004                Last modified: Jul. 21, 2005 |
9
 +-------------------------------------------------------------------+
10
 | This program may be used and hosted free of charge by anyone for  |
11
 | personal purpose as long as this copyright notice remains intact. |
12
 |                                                                   |
13
 | Obtain permission before selling the code for this program or     |
14
 | hosting this software on a commercial website or redistributing   |
15
 | this software over the Internet or in any other medium. In all    |
16
 | cases copyright must remain intact.                               |
17
 +-------------------------------------------------------------------+
18
*/
19
  error_reporting(E_WARNING);
20
 
21
//========================================================================================================
22
// Cookies
23
//========================================================================================================
24
 
25
  if(isset($Name)) {
26
    $shouter = $Name;
27
    setcookie('shouter', $shouter);
28
  }
29
  if(isset($EMail)) {
30
    $shouter_mail = $EMail;
31
    setcookie('shouter_mail', $shouter_mail);
32
  }
33
 
34
//========================================================================================================
35
// Includes
36
//========================================================================================================
37
 
38
  include('config.inc.php');
39
  include('smilies.inc');
40
 
41
//========================================================================================================
42
// Functions
43
//========================================================================================================
44
 
45
  function db_connect() {
46
    global $db_name, $db_server, $db_user, $db_pass;
47
 
48
    $status = true;
49
    if(!@mysql_connect($db_server, $db_user, $db_pass)) {
50
      echo '<font color=red>' . mysql_errno() . ': ' . mysql_error() . '</font><br>';
51
      $status = false;
52
    }
53
    else if(!@mysql_select_db($db_name)) {
54
      echo '<font color=red>' . mysql_errno() . ': ' . mysql_error() . '</font><br>';
55
      $status = false;
56
    }
57
    return $status;
58
  }
59
 
60
  function timeStamp($ts) {
61
    return substr($ts, 0, 4) . '-' . substr($ts, 4, 2) . '-' . substr($ts, 6, 2) . ' ' . substr($ts, 8, 2) . ':' . substr($ts, 10, 2) . ':' . substr($ts, 12);
62
  }
63
 
64
//========================================================================================================
65
// Main
66
//========================================================================================================
67
 
68
  if(db_connect()) {
69
    $error = '';
70
 
71
    header('Cache-control: private, no-cache, must-revalidate');
72
    header('Expires: Sat, 01 Jan 2000 00:00:00 GMT');
73
    header('Date: Sat, 01 Jan 2000 00:00:00 GMT');
74
    header('Pragma: no-cache');
75
?>
76
    <html>
77
    <head>
78
    <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
79
    <meta http-equiv="refresh" content="<? echo $boxRefresh; ?>; URL=<? echo basename($PHP_SELF); ?>">
80
    <title>Output</title>
81
    <link rel="stylesheet" href="shoutbox.css" type="text/css">
82
    </head>
83
    <body marginwidth=0 marginheight=0 topmargin=0 leftmargin=0>
84
<?
85
    if($Text) {
86
      $tstamp = date('YmdHis');
87
      $sql = "INSERT INTO $tbl_name ($fld_timestamp, $fld_name, $fld_email, $fld_text) ";
88
      $sql .= "VALUES ('$tstamp', '$Name', '$EMail', '$Text')";
89
      if(!mysql_query($sql)) $error .= mysql_error() . '<br>';
90
 
91
      $sql = "SELECT $fld_id FROM $tbl_name ORDER BY $fld_timestamp DESC LIMIT 1";
92
      $id = mysql_result(mysql_query($sql), $fld_id) - $boxEntries;
93
      if($id > 0) {
94
        $sql = "DELETE FROM $tbl_name WHERE $fld_id<=$id";
95
        if(!mysql_query($sql)) $error .= mysql_error() . '<br>';
96
      }
97
    }
98
?>
99
    <table border=0 cellspacing=0 cellpadding=2 width=100%><tr>
100
    <td>
101
<?
102
    if($error) echo "<font color=red>$error</font><br>";
103
?>
104
    <table border=0 cellspacing=0 cellpadding=0 width=100%>
105
<?
106
    $sm_code = $sm_img = array();
107
 
108
    while(list($code, $img) = each($sm)) {
109
      $sm_code[] = $code;
110
      $sm_img[] = "<img src='smilies/$img' width=15 height=15 align=top>";
111
    }
112
 
113
    $sql = "SELECT * FROM $tbl_name ORDER BY $fld_timestamp DESC LIMIT $boxEntries";
114
    $result = mysql_query($sql);
115
 
116
    while($row = mysql_fetch_array($result)) {
117
      $tstamp = timeStamp($row[$fld_timestamp]);
118
      $name = $row[$fld_name] ? htmlentities($row[$fld_name]) : '???';
119
      $email = $row[$fld_email];
120
      $text = htmlentities($row[$fld_text]);
121
      $text = str_replace($sm_code, $sm_img, $text);
122
      $bgcolor = ($bgcolor != '#FFFFFF') ? '#FFFFFF' : '#F6F6F6';
123
?>
124
      <tr bgcolor=<? echo $bgcolor; ?>>
125
      <td class="cssSmall" align=right><font color=#A0A0A0><? echo $tstamp; ?></font></td>
126
      </tr><tr bgcolor=<? echo $bgcolor; ?>>
127
      <td class="cssShoutText"><? if($email) echo '<a href="mailto:' . $email . '">'; ?>
128
      <b><? echo $name; ?>:</b><? if($email) echo '</a>'; ?> <? echo $text; ?></td>
129
      </tr>
130
<?
131
    }
132
    mysql_close();
133
?>
134
    </table>
135
    </td>
136
    </tr></table>
137
    </body>
138
    </html>
139
<?
140
  }
141
?>