コード例 #1
0
<?php

$file = filename(__FILE__);
$github = \shgysk8zer0\Core\Resources\Parser::parseFile('github.json');
$PDO = new \shgysk8zer0\Core\PDO($github);
$parser = new \Parsedown\Parsedown();
if (!$PDO->connected) {
    return;
}
$issues = $PDO->prepare("SELECT `Number`,\n\t\t\t`Repository` AS `repo`,\n\t\t\t`Repository_URL` AS `repo_url`,\n\t\t\t`Title`,\n\t\t\t`Body`,\n\t\t\t`URL`,\n\t\t\t`Labels`,\n\t\t\t`Assignee`,\n\t\t\t`Milestone`,\n\t\t\t`Milestone_URL`,\n\t\t\t`Created_At` AS `Created`,\n\t\t\t`Updated_At` AS `Updated`\n\t\tFROM `Issues`\n\t\tWHERE `State` = :state\n\t\tORDER BY `Created` ASC;")->execute(['state' => 'open'])->getResults();
$new_issue = "<a href=\"https://github.com/{$github->repository->full_name}/issues/new\" target=\"_blank\" title=\"New\" role=\"button\" data-icon=\"+\"></a>";
?>
<dialog id="<?php 
echo $file;
?>
_dialog">
	<button type="button" data-delete="#<?php 
echo $file;
?>
_dialog"></button><br />
	<table border="1">
		<caption>
			<?php 
echo count($issues);
?>
 Open Issues on <a href="<?php 
echo $github->repository->html_url;
?>
" target="_blank"><?php 
echo $github->repository->name;
?>
コード例 #2
0
ファイル: webhook.php プロジェクト: gitter-badger/chriszuber
                if ($PDO->connected) {
                    $stm = $PDO->prepare('INSERT INTO `Commits` (
							`SHA`,
							`Branch`,
							`Repository_Name`,
							`Repository_URL`,
							`Commit_URL`,
							`Commit_Message`,
							`Author_Name`,
							`Author_Username`,
							`Author_Email`,
							`Modified`,
							`Added`,
							`Removed`,
							`Time`
						) VALUES (
							:SHA,
							:Branch,
							:Repository_Name,
							:Repository_URL,
							:Commit_URL,
							:Commit_Message,
							:Author_Name,
							:Author_Username,
							:Author_Email,
							:Modified,
							:Added,
							:Removed,
							:Time
						);');
                    $successes = array_filter($webhook->parsed->commits, function ($commit) use($stm, $webhook) {
コード例 #3
0
ファイル: form.php プロジェクト: gitter-badger/chriszuber
         file_put_contents($config_dir . DIRECTORY_SEPARATOR . 'connect.json', json_encode(['user' => $con->user, 'password' => $con->password, 'database' => $con->user], JSON_PRETTY_PRINT));
     } else {
         $resp->notify('Could not save database connection settings to file', 'Make sure that config/ is writable');
         exit($resp);
     }
 }
 $con_json = \shgysk8zer0\Core\resources\Parser::parseFile('connect.json');
 $database = "`{$pdo->escape($con_json->database)}`";
 $pdo->query("CREATE DATABASE IF NOT EXISTS {$database}");
 $created = $pdo->prepare("GRANT ALL ON {$database}.*\n\t\t\t\t\t\t\tTO :user@'localhost'\n\t\t\t\t\t\t\tIDENTIFIED BY :password;")->bind(['user' => $con_json->user, 'password' => $con_json->password])->execute();
 unset($DB);
 $DB = new \shgysk8zer0\Core\PDO('connect.json');
 if ($DB->connected and $created) {
     if (file_exists(BASE . '/default.sql')) {
         if ($DB->restore('default')) {
             $DB->prepare("INSERT INTO `head` (`name`, `value`)\n\t\t\t\t\t\t\t\t\t\tVALUES (:name, :value);");
             foreach (['title', 'keywords', 'description', 'robots', 'viewport', 'charset', 'author', 'author_g_plus', 'publisher', 'google_analytics_code', 'rss'] as $prop) {
                 if (isset($head->{$prop})) {
                     $DB->bind(['name' => $prop, 'value' => $head->{$prop}])->execute();
                 }
             }
             $login = new \shgysk8zer0\Core\login($con_json);
             $login->createFrom(['user' => $site->user, 'password' => $site->password, 'role' => 'admin', 'g_plus' => isset($head->author_g_plus) ? $head->author_g_plus : null, 'name' => $head->author]);
             $resp->notify('All done! Congratulations!', 'Everything is setup and ready to go!')->reload();
             exit($resp);
         } else {
             /**
              * Unable to restore from default.sql
              */
             $resp->notify('We have a problem :(', 'The default database file is invalid. Do a "git pull" and try again. If that still doesn\'t work, file a bug');
         }
コード例 #4
0
        if (!is_numeric($headers->{'content-length'}) or strlen($report) !== (int) $headers->{'content-length'}) {
            throw new \Exception('Content-Length not set or invalid', 411);
        }
        $report = json_decode($report)->{'csp-report'};
        if (!is_object($report) or empty($report)) {
            throw new \Exception('Invalid csp-report', 400);
        }
        if (!isset($report->{'script-sample'})) {
            $report->{'script-sample'} = '';
        }
        if (!isset($report->{'source-file'})) {
            $report->{'source-file'} = null;
        }
        $DB = new \shgysk8zer0\Core\PDO('connect.json');
        if (!$DB->connected) {
            throw new \Exception('Database connection failed', 504);
        }
        $stm = $DB->prepare("INSERT INTO `CSP_errors` (\n\t\t\t\t`blocked-uri`,\n\t\t\t\t`document-uri`,\n\t\t\t\t`violated-directive`,\n\t\t\t\t`source-file`,\n\t\t\t\t`script-sample`\n\t\t\t) VALUES (\n\t\t\t\t:blocked_uri,\n\t\t\t\t:document_uri,\n\t\t\t\t:violated_directive,\n\t\t\t\t:source_file,\n\t\t\t\t:script_sample\n\t\t\t);")->bind(['blocked_uri' => $report->{'blocked-uri'}, 'document_uri' => $report->{'document-uri'}, 'violated_directive' => $report->{'violated-directive'}, 'source_file' => $report->{'source-file'}, 'script_sample' => $report->{'script-sample'}]);
        if (!$stm->execute()) {
            throw new \Exception('Error not successfully recorded', 504);
        } else {
            http_response_code(202);
            exit(json_encode($report, JSON_PRETTY_PRINT));
        }
    } else {
        throw new \Exception('Invalid Content-Type header', 405);
    }
} catch (\Exception $e) {
    http_response_code($e->getCode());
    exit(json_encode(['Message' => $e->getMessage(), 'Request' => ['Headers' => $headers, 'Body' => $report]], JSON_PRETTY_PRINT));
}