Created
January 12, 2015 22:21
-
-
Save Tjoosten/7795fefaffeeab6c5967 to your computer and use it in GitHub Desktop.
GitHub reporter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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