Skip to content

Instantly share code, notes, and snippets.

@Tjoosten
Created January 12, 2015 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tjoosten/7795fefaffeeab6c5967 to your computer and use it in GitHub Desktop.
Save Tjoosten/7795fefaffeeab6c5967 to your computer and use it in GitHub Desktop.
GitHub reporter
<?php
/**
* Issue reporter for GitHub (http://www.st-joris-turnhout.be)
* -----------------------------------------------------------
* @author: Tim Joosten
* @license: Closed Source license
* @since: 2015
* @package: GitHub issue reporter
*/
// Mysql shit
$Server = 'localhost';
$Username = 'USERNAME';
$Password = 'PASSWORD';
$Database = 'DATABASE';
// Create connection
$MySQLi = new mysqli($Server, $Username, $Password, $Database);
// Check connection
if($MySQLi->connect_error) {
die('Cannection failed:'. $MySQLi->connect_error);
}
// Escape $_POST
$Title = $MySQLi->real_escape_string($_POST['title']);
$Body = $MySQLi->real_escape_string($_POST['body']);
// Insert database
$SQL = "INSERT INTO Issues (Title , Body)
VALUES(' $Title ' , ' $Body ')";
if($MySQLi->query($SQL) === TRUE) {
$MySQLi->close();
// Push to github
require_once 'vendor/autoload.php';
$client = new \Github\Client();
$client->authenticate('EMAIL', 'PASSWORD', Github\Client::AUTH_HTTP_PASSWORD);
$client->api('issue')->create('tjoosten', 'website-scouts', array('title' => $Title, 'body' => $Body));
// Redirect
header('Location: '. $_SERVER['HTTP_REFERER']);
} else {
echo 'Kan de statistieken niet in de database steken' . $MySQLi->error;
$MySQLi->close();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment