-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.php
199 lines (187 loc) · 13.9 KB
/
index.php
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Anonymous ChatBox</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="Keywords" content="ChatBox, php, script, free, chat, SQLite, Anonymous">
<meta name="Description" content="ChatBox this chat is in pure php without MySQL(only SQLite database) and without javascripts">
<link rel="stylesheet" href="bootstrap.min.css">
<link href="data:image/x-icon;base64,AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACdlXD/n5Zx/5+VcP+ekm3/m4xo/3JgPf9SPhr/PykF/0AqA/9AKQD/PigA/0AoAP8/KQD/PSkA/zwnBf9CMS//kIeA/6WbgP+XiJz/UESF/y4dNv8+JwT/QCgA/z4oAP8/KAD/PykA/z4pAP8/KAD/PikA/z4pAP8/KQD/PykA/52Vcf+elXD/nZZu/5+Wb/+glm//opNv/5yMaf98aEX/RTAM/z4oAv86JQH/RCkA/0UpAP9BKAT/OygX/3Nla/+VkJf/paSu/3VsrP9CM5P/OydM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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" rel="icon" type="image/x-icon" />
<style>
<?php include $_SERVER['DOCUMENT_ROOT']."/chat-box/include/style.php";?>
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-lg-12"><!-- Change ChatBox name to your site name -->
<h1 class="shadow"><a href="/">ChatBox</a> <small>Welcome to our chat!</small></h1>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<!-- ##### ChatBox-primary ###### -->
<div class="panel panel-primary"><div class="panel-heading"><h3 class="panel-title text-center">Anonymous ChatBox</h3></div>
<div class="panel-body">
<div class="form-group">
<div style="overflow:auto!important;-webkit-overflow-scrolling:touch!important;">
<iframe class="panel panel-primary" style="width:100%;height:200px;display:block;overflow:scroll;-webkit-overflow-scrolling:touch;" name="chat" src="chat.php">
Your browser does not support iframes!
</iframe>
</div>
<?php
// Sign the ChatBox
$missing = false;
// Form has been submitted
if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
// a crude trick to inhibit header injection
if ( !isset($_SERVER['HTTP_USER_AGENT']) ) die();
// Get form input
$name = htmlspecialchars($_POST['name']);
$ava = htmlspecialchars($_POST['ava']);
$message = htmlspecialchars($_POST['message']);
$captcha = +$_POST['captcha'];
$cvalue = +$_POST['cvalue'];
// Validate form input
$noMessage = ( $message == '') ? true : false;
$noCaptcha = ( $captcha == '' ) ? true : false;
if ( $captcha != $cvalue ) $noCaptcha = true;
$missing = $noMessage || $noCaptcha;
}
if ( $_SERVER['REQUEST_METHOD'] == 'POST' && !$missing ) :
// No missing fields, update database
try {
// Open db connection
$db = new PDO('sqlite:admin_similar-to-password/ChatBox.sqlite');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$datetime = date('Y-m-d h:i:s');
$time = date('h:i:s');
$approved = 1; // set to 0 if prior approval required
// Update database
$query = 'INSERT INTO ChatBox (name, ava, message, datetime, time, approved) VALUES (:name, :ava, :message, :datetime, :time, :approved);';
$stmt = $db->prepare($query);
$stmt->bindParam(':name', $name);
$stmt->bindParam(':ava', $ava);
$stmt->bindParam(':message', $message);
$stmt->bindParam(':datetime', $datetime);
$stmt->bindParam(':time', $time);
$stmt->bindParam(':approved', $approved);
$stmt->execute();
// Tell me a message has been posted (remove if not required)
echo '
<p class="text-success text-center"><small><strong>Success!</strong> If approval is enabled, your message will be after it.</small></p>
<meta http-equiv="refresh" content="3">
';
}
// Error handling
catch ( PDOException $e ) {
echo $e->getMessage();
}
// Close the database
$db = null;
else :
// Missing fields OR form not submitted
if ( $missing ) {
echo '<p class="text-danger text-center"><small>You have not completed the form. Please fill in all fields and press
Post when complete.</small></p>',"\n";
} else {
echo '<p class="text-muted text-center"><small>Your name and avatar optional, the default will be Anonymous</small></p>',"\n";
}
$a = rand(1,7);
$b = rand(2,8);
$cvalue = $a + $b;
$noCaptcha = isset($noCaptcha) ? $noCaptcha : false;
$noMessage = isset($noMessage) ? $noMessage : false;
?>
<?php
endif;
?>
<form class="form-horizontal" method="post" action="<?php echo htmlspecialchars('/chat-box/') ?>";>
<input type="hidden" id="cvalue" name="cvalue" value="<?php echo $cvalue; ?>">
<div class="row">
<div class="col-md-8"><!-- ##### Left block ###### -->
<div class="form-group">
<div class="col-lg-12">
<div class="input-group">
<input class="form-control" type="name" name="name" maxlength="18" placeholder="Name (optional)">
<div class="input-group-btn">
<select class="btn btn-default dropdown-toggle" name="ava" for="ava">
<option selected>Choose a hero on avatar</option>
<option value="Aquaman">Aquaman</option>
<option value="Batman">Batman</option>
<option value="Black Widow">Black Widow</option>
<option value="Blue Beetle">Blue Beetle</option>
<option value="Boba Fett">Boba Fett</option>
<option value="Captain America">Captain America</option>
<option value="Cyborg">Cyborg</option>
<option value="Daredevil">Daredevil</option>
<option value="Green Arrow">Green Arrow</option>
<option value="Green Lantern">Green Lantern</option>
<option value="Hawkeye">Hawkeye</option>
<option value="Hulk">Hulk</option>
<option value="Iron Man">Iron Man</option>
<option value="Martian Manhunter">Martian Manhunter</option>
<option value="Nick Fury">Nick Fury</option>
<option value="Robin">Robin</option>
<option value="Spider Man">Spider Man</option>
<option value="Spock">Spock</option>
<option value="Superman">Superman</option>
<option value="The Flash">The Flash</option>
<option value="Thor">Thor</option>
<option value="Wonder Woman">Wonder Woman</option>
</select>
</div><!-- /btn-group -->
</div><!-- /input-group -->
</div><!-- /.col-lg-6 -->
</div>
<div class="form-group">
<div class="col-lg-12">
<textarea <?php if ( $noMessage ) echo 'style="background-color:#800000;"'; ?> class="form-control" rows="4" id="textArea" type="text" name="message" placeholder="Message" required ng-trim="true"></textarea>
</div>
</div>
</div>
<div class="col-md-4"><!-- ##### Right block ###### -->
<div class="form-group">
<div class="col-lg-12 text-center">
<a target="chat" href="chat.php" class="btn btn-default tt-info hover-tt-top" data-hover="Refresh chat"><span class="glyphicon glyphicon-comment"></span></a>
<a target="chat" href="emoji.php" class="btn btn-default tt-info hover-tt-top" data-hover="Emoji"><span class="glyphicon glyphicon-picture"></span></a>
<a target="chat" href="-chat10sec-.php" class="btn btn-default tt-info hover-tt-top" data-hover="Auto refresh 10 second"><span class="glyphicon glyphicon-refresh"></span></a>
<a target="chat" href="rules.php" class="btn btn-default tt-info hover-tt-top" data-hover="Rules"><span class="glyphicon glyphicon-alert"></span></a>
<a target="chat" href="info.php" class="btn btn-default tt-info hover-tt-top" data-hover="Info"><span class="glyphicon glyphicon-info-sign"></span></a>
</div>
</div>
<div class="form-group">
<div class="col-lg-12">
<input <?php if ( $noCaptcha ) echo 'style="background-color:#800000;"'; ?> class="form-control" name="captcha" id="captcha" type="text" placeholder="<?php echo 'What is ',$a,'+',$b,'?'; ?>" required></p>
</div>
</div>
<div class="form-group">
<div class="col-lg-12">
<button type="submit" name="submit" class="btn btn-primary btn-lg btn-block">Post <span class="glyphicon glyphicon-send"></span></button>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<!-- ###### end ChatBox-primary ####### -->
</div>
</div>
<div class="row">
<div class="col-xs-12"></div>
</div>
<div class="row">
<div class="col-xs-12">
<ul class="list-unstyled">
<li class="pull-right text-muted"><abbr title="Version 2.4.0">v2.4</abbr></li>
<li><a target="_blank" href="https://github.com/7ife/chat-box" class="text-muted tt-default hover-tt-right" data-hover="Get ChatBox" style="color:#fffff;text-decoration:none;"><img alt="GitHub" height="22" width="22" src="github.svg"></a></li>
</ul>
</div>
</div>
<div class="row lines"></div>
</div>
</body>
</html>