forked from Dwist/WoWFailureCMS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchatbox.php
More file actions
97 lines (86 loc) · 2.63 KB
/
Copy pathchatbox.php
File metadata and controls
97 lines (86 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
include("configs.php");
//Connect to db
$conn = mysql_connect("$serveraddress", "$serveruser", "$serverpass")or die("Couldn't connect to database");
//Site Shoutbox
#Post Shouts
function shout()
{
if(isset($_POST['shout']))
{
//Shout Is Empty
if(empty($_POST['body']))
{
return'<center>Shout was empty.</center><br/><br/>';
}
else
{
global $query, $conn, $server_db, $cap, $login, $_STRIP_1, $_STRIP_2, $_STRIP_3;
//Check If Logged In
if(!$login)
{
return'<center>You Must Login To Shout.</center><br/><br/>';
}
else
{
//Set Date
$date = date('M d, Y');
//Post Shout, Cap & Strip
$body = $cap($_STRIP_1($_STRIP_2($_STRIP_3($_POST['body']))));
//Success, Shout Is Posted
$sql= $query("INSERT INTO $server_db.shouts (author, body, date) VALUES ('$login', '$body', '$date')")or die(mysql_error());
header("Location: ./#shoutid");
}
}
}
}
//View Shouts
class shouts
{
public $view_shouts = array();
public $shout_url;
function shouts()
{
global $query, $array, $assoc, $num, $conn, $server_db, $cap;
//ShoutBox Table
$table = "shouts";
// How many adjacent pages should be shown on each side?
$adjacents = 3;
$sql = $query("SELECT COUNT(id) as num FROM $server_db.$table")or die(mysql_error());
$total_pages = $assoc($sql);
$total_pages = $total_pages['num'];
$targetpage = "./"; //your file name (the name of this file)
$limit = 5; //how many items to show per page
if(isset($_GET['shout']))
{
$page = $_GET['shout'];
}
else
{
$page = 1;
}
if($page)
{
$start = ($page - 1) * $limit;
} //first item to display on this page
else
{
$start = 0;
}
/* Get data. */
$result = $query("SELECT id, author, body, date FROM $server_db.$table ORDER BY id DESC LIMIT $start, $limit")or die(mysql_error());
/* Setup page vars for display. */
if ($page == 0) $page = 1; //if no page var is given, default to 1.
$prev = $page - 1; //previous page is page - 1
$next = $page + 1; //next page is page + 1
$lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up.
$lpm1 = $lastpage - 1; //last page minus 1
while($get = $array($result))
{
$get = str_replace(array("\r\n", "\r", "\n"), "<br />", $get);
$this->view_shouts[] = $get;
}
$this->shout_url = '<br/><center>Page: <a href="./?shout='.$prev.'#shoutid"><u>Previous</u></a> - <a href="./?shout='.$next.'#shoutid"><u>Next</u></a></center><br/>';
}
}
?>