Commit 92853a62 authored by Tariq Khan's avatar Tariq Khan 💬

Update index.php

parent 52c43bda
<?php
$url = strtok($_SERVER["REQUEST_URI"],'?');
require_once getcwd().'/oauth2.php';
$oauth2 = new Oauth2(array(
'occupieUrl' => 'https://api.occupie.com',
'client' => 'trustedclient',
'clientSecret' => '',
'scope' => 'hubapi'));
?>
<!DOCTYPE html>
<html>
<head>
<title>Occupie API sample</title>
<link href="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.2/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="container">
<div class="navbar">
<div class="navbar-inner">
<ul class="nav">
<?php if($oauth2->isUserAuthenticated()) { ?>
<li><a href="<?php echo $url; ?>">API</a></li>
<?php } ?>
<!-- <li><a href="/#/oauth2Config">OAuth2 config</a></li> -->
<?php if(!$oauth2->isUserAuthenticated()) { ?>
<li><a href="<?php echo $url; ?>">Login</a></li>
<?php } if($oauth2->isUserAuthenticated()) { ?>
<li><a href="<?php echo $url; ?>?logout">Logout</a></li>
<?php } if($oauth2->isUserAuthenticated()) { ?>
<li><a href="<?php echo $url; ?>?refreshToken">Refresh token</a></li>
<?php } ?>
</ul>
</div>
</div>
<div class="row">
<div class="span12">
<div class="well">
<?php if(!$oauth2->isUserAuthenticated()) { ?>
<h3>Log in</h3>
<p>Logging in retrieves access token for the provided credentials. This token is then used for all calls to api, so credentials don't have to be kept.</p>
<form action="<?php echo $url; ?>" method="post">
<div>
<label for="user">Username:</label>
<input type="text" name="user" id="user" value="name@domain.com">
</div>
<div>
<label for="pass">Password:</label>
<input type="password" name="pass" id="pass" value="replaceme">
</div>
<input type="submit" name="login" value="Log in" class="btn btn-default">
</form>
<?php } else { ?>
<div class="navbar">
<div class="navbar-inner">
<ul class="nav">
<li><a href="<?php echo $url; ?>">Tracking devices</a></li>
<li><a href="<?php echo $url; ?>?create">Create tracking device</a></li>
</ul>
</div>
</div>
<?php if(isset($_GET['create'])) { ?>
<h3>Create Tracking Device</h3>
<form action="<?php echo $url; ?>?create" method="post">
<div>
<label for="name">Name:</label>
<input type="text" name="trackingdevicename" id="trackingdevicename"
required placeholder="Some string">
</div>
<div>
<label for="">Type:</label>
<input type="text" name="trackingtype" id="trackingtype"
required placeholder="IN, OUT or IN/OUT">
</div>
<div>
<label for="uid">Unique id:</label>
<input type="text" name="uniquedeviceid" id="uniquedeviceid"
required placeholder="Some string">
</div>
<div>
<label for="siteid">Site id:</label>
<input type="text" name="siteid" id="siteid"
required placeholder="Some number">
</div>
<div>
<label for="active">Active:</label>
<input type="text" name="active" id="active"
required placeholder="True or False">
</div>
<input type="submit" name="create" value="Create" class="btn btn-default">
</form>
<?php } elseif(isset($_GET['entries'])) { ?>
<h3>Tracking Devices Entries</h3>
<table class="table table-striped">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Type</th>
<th>Time</th>
</tr>
</thead>
<tbody>
<?php if($oauth2->trackingEntries) foreach($oauth2->trackingEntries as $entry) { ?>
<tr>
<td>{{entry.trackingentriesid}}</td>
<td>{{entry.trackingentriesname}}</td>
<td>{{entry.trackingtype}}</td>
<td>{{entry.creationdate}}</td>
</tr>
<?php } ?>
</tbody>
</table>
<?php } elseif(isset($_GET['add'])) { ?>
<h3>Add Tracking Entry</h3>
<form action="<?php echo $url; ?>?add=<?php echo $_GET['add']; ?>" method="post">
<div>
<label for="trackingentriesname">Name:</label>
<input type="text" name="trackingentriesname" id="trackingentriesname"
required placeholder="Some string">
</div>
<div>
<label for="trackingtype">Type:</label>
<input type="text" name="trackingtype" id="trackingtype"
required placeholder="IN or OUT">
</div>
<div>
<label for="contactid">Contact id:</label>
<input type="text" name="contactid" id="contactid"
required placeholder="Some number">
</div>
<input type="submit" name="add" value="Create" class="btn btn-default">
</form>
<?php } else { ?>
<div>
<h3>Tracking Devices</h3>
<?php if($oauth2->trackingDevices) { ?>
<table class="table table-striped">
<thead>
<tr>
<th>Id</th>
<th>name</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<?php foreach($oauth2->trackingDevices as $key => $value) { ?>
<tr>
<td><?php echo $value->trackingdeviceid; ?></td>
<td><?php echo $value->trackingdevicename; ?></td>
<td>
<a href="<?php echo $url; ?>?entries=<?php echo $value->trackingdeviceid; ?>">
show entries
</a>
</td>
<td>
<a href="<?php echo $url; ?>?add=<?php echo $value->trackingdeviceid; ?>">
add entry
</a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<?php } else { ?><p>No data!</p><?php } ?>
</div>
<?php } ?>
<?php } ?>
</div>
</div>
</div>
</body>
</html>
<?php
$url = strtok($_SERVER["REQUEST_URI"],'?');
require_once getcwd().'/oauth2.php';
$oauth2 = new Oauth2(array(
'occupieUrl' => 'https://api.occupie.com',
'client' => 'trustedclient',
'clientSecret' => 'you-client-secret-key-goes-here',
'scope' => 'hubapi'));
?>
<!DOCTYPE html>
<html>
<head>
<title>Occupie API sample</title>
<link href="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.2/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="container">
<div class="navbar">
<div class="navbar-inner">
<ul class="nav">
<?php if($oauth2->isUserAuthenticated()) { ?>
<li><a href="<?php echo $url; ?>">API</a></li>
<?php } ?>
<!-- <li><a href="/#/oauth2Config">OAuth2 config</a></li> -->
<?php if(!$oauth2->isUserAuthenticated()) { ?>
<li><a href="<?php echo $url; ?>">Login</a></li>
<?php } if($oauth2->isUserAuthenticated()) { ?>
<li><a href="<?php echo $url; ?>?logout">Logout</a></li>
<?php } if($oauth2->isUserAuthenticated()) { ?>
<li><a href="<?php echo $url; ?>?refreshToken">Refresh token</a></li>
<?php } ?>
</ul>
</div>
</div>
<div class="row">
<div class="span12">
<div class="well">
<?php if(!$oauth2->isUserAuthenticated()) { ?>
<h3>Log in</h3>
<p>Logging in retrieves access token for the provided credentials. This token is then used for all calls to api, so credentials don't have to be kept.</p>
<form action="<?php echo $url; ?>" method="post">
<div>
<label for="user">Username:</label>
<input type="text" name="user" id="user" value="name@domain.com">
</div>
<div>
<label for="pass">Password:</label>
<input type="password" name="pass" id="pass" value="operatePassword">
</div>
<input type="submit" name="login" value="Log in" class="btn btn-default">
</form>
<?php } else { ?>
<div class="navbar">
<div class="navbar-inner">
<ul class="nav">
<li><a href="<?php echo $url; ?>">Tracking devices</a></li>
<li><a href="<?php echo $url; ?>?create">Create tracking device</a></li>
</ul>
</div>
</div>
<?php if(isset($_GET['create'])) { ?>
<h3>Create Tracking Device</h3>
<form action="<?php echo $url; ?>?create" method="post">
<div>
<label for="name">Name:</label>
<input type="text" name="trackingdevicename" id="trackingdevicename"
required placeholder="Some string">
</div>
<div>
<label for="">Type:</label>
<input type="text" name="trackingtype" id="trackingtype"
required placeholder="IN, OUT or IN/OUT">
</div>
<div>
<label for="uid">Unique id:</label>
<input type="text" name="uniquedeviceid" id="uniquedeviceid"
required placeholder="Some string">
</div>
<div>
<label for="siteid">Site id:</label>
<input type="text" name="siteid" id="siteid"
required placeholder="Some number">
</div>
<div>
<label for="active">Active:</label>
<input type="text" name="active" id="active"
required placeholder="True or False">
</div>
<input type="submit" name="create" value="Create" class="btn btn-default">
</form>
<?php } elseif(isset($_GET['entries'])) { ?>
<h3>Tracking Devices Entries</h3>
<table class="table table-striped">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Type</th>
<th>Time</th>
</tr>
</thead>
<tbody>
<?php if($oauth2->trackingEntries) foreach($oauth2->trackingEntries as $entry) { ?>
<tr>
<td>{{entry.trackingentriesid}}</td>
<td>{{entry.trackingentriesname}}</td>
<td>{{entry.trackingtype}}</td>
<td>{{entry.creationdate}}</td>
</tr>
<?php } ?>
</tbody>
</table>
<?php } elseif(isset($_GET['add'])) { ?>
<h3>Add Tracking Entry</h3>
<form action="<?php echo $url; ?>?add=<?php echo $_GET['add']; ?>" method="post">
<div>
<label for="trackingentriesname">Name:</label>
<input type="text" name="trackingentriesname" id="trackingentriesname"
required placeholder="Some string">
</div>
<div>
<label for="trackingtype">Type:</label>
<input type="text" name="trackingtype" id="trackingtype"
required placeholder="IN or OUT">
</div>
<div>
<label for="contactid">Contact id:</label>
<input type="text" name="contactid" id="contactid"
required placeholder="Some number">
</div>
<input type="submit" name="add" value="Create" class="btn btn-default">
</form>
<?php } else { ?>
<div>
<h3>Tracking Devices</h3>
<?php if($oauth2->trackingDevices) { ?>
<table class="table table-striped">
<thead>
<tr>
<th>Id</th>
<th>name</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<?php foreach($oauth2->trackingDevices as $key => $value) { ?>
<tr>
<td><?php echo $value->trackingdeviceid; ?></td>
<td><?php echo $value->trackingdevicename; ?></td>
<td>
<a href="<?php echo $url; ?>?entries=<?php echo $value->trackingdeviceid; ?>">
show entries
</a>
</td>
<td>
<a href="<?php echo $url; ?>?add=<?php echo $value->trackingdeviceid; ?>">
add entry
</a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<?php } else { ?><p>No data!</p><?php } ?>
</div>
<?php } ?>
<?php } ?>
</div>
</div>
</div>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment