diff options
Diffstat (limited to 'test/components')
-rw-r--r-- | test/components/communication.php | 17 | ||||
-rw-r--r-- | test/components/engine.php | 66 | ||||
-rw-r--r-- | test/components/footer.php | 9 | ||||
-rw-r--r-- | test/components/navbar.php | 36 | ||||
-rw-r--r-- | test/components/results.php | 20 | ||||
-rw-r--r-- | test/components/settings.php | 24 |
6 files changed, 172 insertions, 0 deletions
diff --git a/test/components/communication.php b/test/components/communication.php new file mode 100644 index 0000000..3f00204 --- /dev/null +++ b/test/components/communication.php @@ -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 -->
diff --git a/test/components/engine.php b/test/components/engine.php new file mode 100644 index 0000000..bc89d8e --- /dev/null +++ b/test/components/engine.php @@ -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));
+ }
+?>
diff --git a/test/components/footer.php b/test/components/footer.php new file mode 100644 index 0000000..fa5a161 --- /dev/null +++ b/test/components/footer.php @@ -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 -->
diff --git a/test/components/navbar.php b/test/components/navbar.php new file mode 100644 index 0000000..ed858b5 --- /dev/null +++ b/test/components/navbar.php @@ -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 -->
diff --git a/test/components/results.php b/test/components/results.php new file mode 100644 index 0000000..def09b1 --- /dev/null +++ b/test/components/results.php @@ -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>
diff --git a/test/components/settings.php b/test/components/settings.php new file mode 100644 index 0000000..fe8e5ff --- /dev/null +++ b/test/components/settings.php @@ -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 -->
|