forked from Xkeeper0/jul
/
chat.php
125 lines (103 loc) · 3.18 KB
/
chat.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
<?php
require "lib/common.php";
// Discord - Main
$disc_chans = [];
foreach (explode("\n", $config['discord-invites']) as $row) {
if (!trim($row))
continue;
$chan = explode(";", $row, 2);
if (count($chan) < 2)
continue;
$disc_chans[] = array_map('trim', $chan);
}
define("HAS_IRC", $config['irc-servers'] && $config['irc-channels']);
define("HAS_DISCORD", $disc_chans);
if (!HAS_IRC && !HAS_DISCORD) {
errorpage("Chat hasn't been configured for this board.");
}
$show_server = isset($_GET['server']);
pageheader("Chat");
if (HAS_DISCORD && !$show_server) {
?>
<table class="table">
<tr><td class="tdbgh center b">Discord Chat - <?=$config['discord-guild-title'] ?></td></tr>
<tr><td class="tdbg1 center">You can choose any of the following Discord invite links:</td></tr>
<tr>
<td class="tdbg2">
<ul style="margin: 10px auto; display: table">
<?php foreach ($disc_chans as $x) { ?>
<li><a href="<?=$x[1]?>"><?=$x[0]?></a></li>
<?php } ?>
</ul>
</td>
</tr>
</table>
<br/>
<?php
}
if (HAS_IRC) {
// Pick an irc server, if unset show server selection
if (!$show_server) {
$_GET['server'] = -1;
} else {
$_GET['server'] = filter_int($_GET['server']);
if (!isset($config['irc-servers'][$_GET['server']])) errorpage("Server not found.");
}
?> <table class='table'>
<tr><td class='tdbgh center b'>
IRC Chat - <?=$config['irc-server-title']?>, <?=implode(",", $config['irc-channels'])?>
</td></tr>
<tr>
<td class='tdbg1 center'>
Server List:
<?php
foreach ($config['irc-servers'] as $num => $name) {
if ($num != 0) print " | ";
if ($_GET['server'] == $num) print "<u>";
print "<a href='?server={$num}'>{$name}</a>";
if ($_GET['server'] == $num) print "</u>";
if ($num == 0) print " (preferred)";
}
?> </td>
</tr>
<tr>
<td class='tdbg2 center' <?= $show_server ? "style=\"background: #FFF\"" : "" ?>>
<?php
if ($show_server) {
$badchars = array("~", "&", "@", "?", "!", ".", ",", "=", "+", "%", "*");
$name = str_replace(" ", "", $loguser['name']);
$name = str_replace($badchars, "_", $name);
if (!$name) {
$name = "J-Guest";
$guestmsg = "<br>Welcome, guest. When you connect to the IRC network, please use the command <tt>/nick NICKNAME</tt>.<br> <br>";
}
?>
<iframe src="https://kiwiirc.com/client/<?=$config['irc-servers'][$_GET['server']]?>/?nick=<?=$name?>|?<?=implode(",", $config['irc-channels'])?>" style="border:0;width:100%;height:500px;"></iframe>
<?php
} else {
?> <br>
Please choose a server to connect to.<br>
<?php
}
?> </td>
</tr>
</table>
<br>
<table class='table'>
<tr><td class='tdbgh center b'>Quick Help</td></tr>
<tr>
<td class='tdbg1'>
Commands:
<br><tt>/nick [name]</tt> - changes your name
<br><tt>/me [action]</tt> - does an action (try it)
<br><tt>/msg [name] [message]</tt> - send a private message to another user
<br><tt>/join [#channel]</tt> - joins a channel
<br><tt>/part [#channel]</tt> - leaves a channel
<br><tt>/quit [message]</tt> - obvious
</td>
</tr>
</table>
<?php
}
pagefooter();