Skip to content

Instantly share code, notes, and snippets.

@AdnanHussainTurki
Created September 17, 2019 20:19
Show Gist options
  • Save AdnanHussainTurki/49138d48fd00b1846474ba166648e426 to your computer and use it in GitHub Desktop.
Save AdnanHussainTurki/49138d48fd00b1846474ba166648e426 to your computer and use it in GitHub Desktop.
test
<?php
session_start();
if (isset($_SESSION['gusername']) AND isset($_SESSION['gtoken'])) {
header("location: home.php");
die();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Gist API Example by myPHPnotes.com</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
<style>
body,html {
height: 100%;
}
.bg {
/* The image used */
background-image: url("/images/bg.jpg");
/* Full height */
height: 100%;
/* Center and scale the image nicely */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.caption {
font-family: 'Times New Roman';
text-transform: uppercase;
position: absolute;
left: 0;
top: 50%;
width: 100%;
text-align: center;
color: #000;
}
.caption span.border {
background-color: #111;
color: #fff;
padding: 18px;
font-size: 25px;
}
</style>
</head>
<body class="bg" >
<div class="container" id="panel">
<br><br><br>
<div class="row" >
<div class="col-md-6 offset-md-3" style="background: white; padding: 20px; box-shadow: 10px 10px 5px #888888;">
<div class="panel-heading"><h1>Gist API</h1></div>
<hr>
<form action="login.php" method="post" autocomplete="off">
<input type="text" style="border-radius: 0px;" name="gusername" id="text" class="form-control" placeholder="GitHub Username" value="">
<br>
<input type="password" style="border-radius: 0px;" name="gtoken" id="text" class="form-control" placeholder="GitHub Personal Access Token" value="">
<br>
<div class="alert alert-warning">
No non-consent use of access token will be done from our end. The above access token will be stored as a file session on the server and cleared within a week among all sessions.
</div>
<input type="submit" style="border-radius: 0px;" class="btn btn-lg btn-block btn-outline-success" value="Log Me In"/>
<a id="blank"></a>
</form>
</div>
</div>
</div>
</body>
</html>
<?php
session_start();
use myPHPnotes\Gist;
use myPHPnotes\GistObject;
require_once "Gist.php";
require_once "GistObject.php";
$username = $_SESSION['gusername'];
$token = $_SESSION['gtoken'];
$gist = new Gist($username, $token);
$gists = $gist->myGists();
$gists = json_decode($gists);
if ($gists->message == "Bad credentials") {
session_destroy();
header("location: index.php?badcredentials=true");
die();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment