mirror of
https://github.com/valentineus/iii-module.git
synced 2025-07-01 11:00:27 +03:00
Alpha version
This commit is contained in:
17
test/components/communication.php
Normal file
17
test/components/communication.php
Normal file
@ -0,0 +1,17 @@
|
||||
<!-- Home side panel -->
|
||||
<form class="form-horizontal" method="post">
|
||||
<div class="row">
|
||||
<!-- Text field -->
|
||||
<div class="col-md-8">
|
||||
<textarea class="form-control" rows="3" name="textarea"></textarea>
|
||||
</div>
|
||||
<!-- Control buttons -->
|
||||
<div class="col-md-4">
|
||||
<button type="submit" class="btn btn-default">Submit</button>
|
||||
<button type="button" class="btn btn-success" data-toggle="modal" data-target="#SettingsModal">Settings</button>
|
||||
<button type="button" class="btn btn-danger">Reset</button>
|
||||
</div>
|
||||
</div><!-- row -->
|
||||
</form>
|
||||
<br/>
|
||||
<!-- End side panel -->
|
66
test/components/engine.php
Normal file
66
test/components/engine.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
function ShowRecord($id) {
|
||||
for ($i=0; $i < $id; $i++) {
|
||||
$cookie = json_decode($_COOKIE['TALK'.$i], true);
|
||||
echo("<tr>");
|
||||
echo("<td>".$cookie['type']."</td>");
|
||||
echo("<td>".$cookie['textarea']."</td>");
|
||||
echo("<td>".date("H:i:s", $cookie['time'])."</td>");
|
||||
echo("</tr>");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (isset($_COOKIE['BOT_TOKEN'])) {
|
||||
$BOT_TOKEN = $_COOKIE['BOT_TOKEN'];
|
||||
}
|
||||
|
||||
if (isset($_POST['BOT_TOKEN'])) {
|
||||
unset($_COOKIE); // Clear the session
|
||||
SetCookie("BOT_TOKEN", htmlspecialchars($_POST['BOT_TOKEN']));
|
||||
$BOT_TOKEN = htmlspecialchars($_POST['BOT_TOKEN']);
|
||||
}
|
||||
|
||||
if (isset($BOT_TOKEN)) {
|
||||
define('BOT_TOKEN', $BOT_TOKEN);
|
||||
$bot = new Bot(BOT_TOKEN);
|
||||
if (isset($_COOKIE['BOT_SESSION'])) {
|
||||
$session = $bot->session($_COOKIE['BOT_SESSION']);
|
||||
} else {
|
||||
$session = $bot->session();
|
||||
SetCookie("BOT_SESSION", $session);
|
||||
}
|
||||
if (!isset($session)) { ?>
|
||||
<div class="container">
|
||||
<div class="alert alert-danger" role="alert">Session is not initialized, check the settings!</div>
|
||||
</div>
|
||||
<?php }
|
||||
}
|
||||
|
||||
if (isset($_POST['textarea'])) {
|
||||
$textarea = htmlspecialchars($_POST['textarea']);
|
||||
if (isset($_COOKIE['CURRENT_ID'])) {
|
||||
$current_id = (int)$_COOKIE['CURRENT_ID'];
|
||||
SetCookie('CURRENT_ID', $current_id+1);
|
||||
} else {
|
||||
$current_id = 0;
|
||||
SetCookie('CURRENT_ID', $current_id);
|
||||
}
|
||||
|
||||
$cookie = array(
|
||||
'type' => 'user',
|
||||
'textarea' => $textarea,
|
||||
'time' => time()
|
||||
);
|
||||
SetCookie("TALK".$current_id, json_encode($cookie));
|
||||
|
||||
$current_id = $current_id+1;
|
||||
SetCookie('CURRENT_ID', $current_id+1);
|
||||
$cookie = array(
|
||||
'type' => 'bot',
|
||||
'textarea' => $bot->say($textarea),
|
||||
'time' => time()
|
||||
);
|
||||
SetCookie("TALK".$current_id, json_encode($cookie));
|
||||
}
|
||||
?>
|
9
test/components/footer.php
Normal file
9
test/components/footer.php
Normal file
@ -0,0 +1,9 @@
|
||||
<!-- Beginning footer -->
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<a href="mailto:valentineus@gmail.com">valentineus@gmail.com</a>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<!-- End footer -->
|
36
test/components/navbar.php
Normal file
36
test/components/navbar.php
Normal file
@ -0,0 +1,36 @@
|
||||
<!-- Start navigation bar -->
|
||||
<nav class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="container">
|
||||
<div class="collapse navbar-collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<!-- Home project -->
|
||||
<a href="https://github.com/valentineus/Module-III-API"><span class="github" aria-hidden="true"></span> GitHub.com</a>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- The right side of the navigation bar -->
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<p class="navbar-text" data-toggle="popover" data-placement="auto" data-trigger="hover" data-content="Cookies must be enabled in your browser!"><?php
|
||||
// Check the ability to use Cookie
|
||||
if (SetCookie("TestCookie", "Success")) { ?>
|
||||
<span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
|
||||
<?php } else { ?>
|
||||
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
|
||||
<?php }
|
||||
?> Cookie</p>
|
||||
|
||||
<p class="navbar-text" data-toggle="popover" data-placement="auto" data-trigger="hover" data-content="Before the work necessary to configure!"><?php
|
||||
// Checking the portal settings
|
||||
if (isset($_COOKIE['BOT_TOKEN']) OR isset($_POST['BOT_TOKEN'])) { ?>
|
||||
<span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
|
||||
<?php } else { ?>
|
||||
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
|
||||
<?php }
|
||||
?> Settings</p>
|
||||
</li>
|
||||
</ul><!-- navbar-right -->
|
||||
</div>
|
||||
</div><!-- container -->
|
||||
</nav>
|
||||
<!-- End navigation bar -->
|
20
test/components/results.php
Normal file
20
test/components/results.php
Normal file
@ -0,0 +1,20 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Text</th>
|
||||
<th>Date</th>
|
||||
</tr>
|
||||
<?php
|
||||
if (isset($current_id)) {
|
||||
ShowRecord($current_id);
|
||||
} elseif (isset($_COOKIE['CURRENT_ID'])) {
|
||||
ShowRecord((int)$_COOKIE['CURRENT_ID']);
|
||||
} else {
|
||||
echo("Error!");
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
24
test/components/settings.php
Normal file
24
test/components/settings.php
Normal file
@ -0,0 +1,24 @@
|
||||
<!-- Start pop-up window for the settings -->
|
||||
<div class="modal fade" id="SettingsModal" tabindex="-1" role="dialog" aria-labelledby="SettingsModal">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<form class="form-horizontal" method="post">
|
||||
<div class="modal-body">
|
||||
<!-- Elements of a modal window -->
|
||||
<div class="form-group">
|
||||
<label for="inputPassword" class="col-sm-2 control-label">ID:</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" id="inputPassword" name="BOT_TOKEN" placeholder="109cd867-0ef3-4473-af71-7543a9b2fccd">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- The window control buttons -->
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||
<button type="submit" class="btn btn-success">Save changes</button>
|
||||
</div>
|
||||
</form>
|
||||
</div><!-- modal-content -->
|
||||
</div><!-- modal-dialog -->
|
||||
</div>
|
||||
<!-- End pop-up window for the settings -->
|
Reference in New Issue
Block a user