<?php
/**
*名称 ChatOnline
*作者 铅华 pinerge@gmail.com
*介绍 在线聊天室
*版本 18.7.25
*/
header('content-type:text/html;charset=utf-8');
$startTime = microtime(true);
$name1 = array('欧阳', '太史', '上官', '司马', '东方', '独孤', '夏侯', '诸葛', '公孙', '慕容', '司徒', '令狐', '西门', '百里', '皇甫', '南宫', '长孙', '轩辕', '公伯', '司空');
$name11 = mt_rand(0, 19);
$name2 = array('嗝屁', '令堂', '建仁', '嗯嗯', '双击', '万解', '卒', '赞', '悙册索', '崔旦', '制杖', '若智', '淳霍', '守瓜', '冲册索', '求子', '爆基丁', '不败', '雷猴', '耳明');
$name22 = mt_rand(0, 19);
$name = $name1[$name11] . $name2[$name22];
date_default_timezone_set('Asia/Hong_kong');
$Db = new SQLite3('chat.db');
if (file_exists('install.lock')) {
if (!empty($_COOKIE['name'])) {
if (empty($_POST['name'])) {
if (empty($_POST['randname'])) {
if (empty($_POST['say'])) {
####################
echo '<html><head><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>ChatOnline</title><style>.button3{width:100%;background-color:#9dfd8c;border-radius:5px;border:1px solid #bca;padding:;}.textarea{width:100%;border-radius:6px;border:1px solid #edc;background-color:#e0ffd5;height:60px;}.button1{border:none;border-radius:4px;background-color:#d2fd7e;}.button2{border:none;border-radius:4px;background-color:#d2fd7e;}.name{border-radius:4px;border:1px solid #cde;}.say{padding:6px;border-radius:6px;border:solid 1px #edf;}</style></head><body>你的昵称:<b>' . $_COOKIE['name'] . '</b><br /><form method="post"><input class="name" type="text" name="name"><button class="button1" type="submit">改名</button> Or <button class="button2" type="submit" name="randname" value="randname">随机</button></form><hr />';
$Re = $Db->query('select * from chat order by time limit 30');
while ($Ro = $Re->fetchArray(SQLITE3_ASSOC)) {
echo '<div class="say" width="100%">' . $Ro['say'] . '<br /><b>' . $Ro['name'] . '</b> - <sub>' . $Ro['time'] . '</sub></div>';
}
echo '<hr />聊天室展示最新三十条记录。<hr /><form method="post"><textarea class="textarea" name="say"></textarea><button class="button3" type="submit">发言</button></form><hr />程序执行耗时:<b>' . substr((microtime(true) - $startTime) * 1000, 0, 6) . '</b>毫秒</body></html>';
####################
} else {
if ($Db->query("insert into chat values ('" . date('Y-m-d H:i:s') . "','" . $_COOKIE['name'] . "','" . $_POST['say'] . "')")) {
####################
echo '<html><head><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>ChatOnline</title><style>.button3{width:100%;background-color:#9dfd8c;border-radius:5px;border:1px solid #bca;padding:;}.textarea{width:100%;border-radius:6px;border:1px solid #edc;background-color:#e0ffd5;height:60px;}.button1{border:none;border-radius:4px;background-color:#d2fd7e;}.button2{border:none;border-radius:4px;background-color:#d2fd7e;}.name{border-radius:4px;border:1px solid #cde;}.say{padding:6px;border-radius:6px;border:solid 1px #edf;}</style></head><body>你的昵称:<b>' . $_COOKIE['name'] . '</b><br /><form method="post"><input class="name" type="text" name="name"><button class="button1" type="submit">改名</button> Or <button class="button2" type="submit" name="randname" value="randname">随机</button></form><hr />';
$Re = $Db->query('select * from chat order by time limit 30');
while ($Ro = $Re->fetchArray(SQLITE3_ASSOC)) {
echo '<div class="say" width="100%">' . $Ro['say'] . '<br /><b>' . $Ro['name'] . '</b> - <sub>' . $Ro['time'] . '</sub></div>';
}
echo '<hr />聊天室展示最新三十条记录。<hr /><form method="post"><textarea class="textarea" name="say"></textarea><button class="button3" type="submit">发言</button></form><hr />程序执行耗时:<b>' . substr((microtime(true) - $startTime) * 1000, 0, 6) . '</b>毫秒</body></html>';
####################
} else {
echo '<html><head><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>ChatOnline</title></head><body><b>发言失败。</b><hr /><i>两秒后跳转,请稍等……</i></body></html>';
header('refresh:2;url=/');
}
}
} else {
setcookie('name', $name, time() + 86400);
echo '<html><head><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>ChatOnline</title></head><body><b>昵称随机更改成功。</b><hr /><i>两秒后跳转,请稍等……</i></body></html>';
header('refresh:2;url=/');
}
} else {
setcookie('name', $_POST['name'], time() + 86400);
echo '<html><head><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>ChatOnline</title></head><body><b>昵称手动更改成功。</b><hr /><i>两秒后跳转,请稍等……</i></body></html>';
header('refresh:2;url=/');
}
} else {
setcookie('name', $name, time() + 86400);
echo '<html><head><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>ChatOnline</title></head><body><b>随机设定初始昵称。</b><hr /><i>两秒后跳转,请稍等……</i></body></html>';
header('refresh:2;url=/');
}
} else {
if ($Db->query('create table chat (time TEXT primary key not null,name TEXT not null,say TEXT not null)') && $Db->query("insert into chat values ('" . date('Y-m-d H:i:s') . "','系统消息','恭喜,聊天室安装成功!')") && file_put_contents('install.lock', 'locked', LOCK_EX)) {
echo '<html><head><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>ChatOnline</title></head><body><b>恭喜,安装成功。</b><hr /><i>两秒后跳转,请稍等……</i></body></html>';
header('refresh:2;url=/');
} else {
echo '<html><head><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>ChatOnline</title></head><body><b>抱歉,安装失败。</b><hr /><i>两秒后跳转,请稍等……</i></body></html>';
header('refresh:2;url=/');
}
}
Αυτό το άρθρο προέρχεται από http://www.chieng.cn, αναπαράγεται διευκρινίστε!
评论