Files
crash-processor/htdocs/lib/init.php.in
Latif Khalifa 5731b4ae24 Switched to Google Oauth2 for login.
Copy init.php.in to init.php

Set database username, password

Set $GoogleClientID and $GoogleClientSecret

To get those:

* Navigate to the Google Cloud Console. https://cloud.google.com/console
* Click on the Create Project button on top of the page, enter the following values and then click on the Create button.
* Once the project has been created, open the APIs & auth group (left navigation pannel) and then click on Consent screen and set it up (this is just for what is shown to the user, values not important)
* Open the APIs & auth group in the left pannel (if it's not already open) and click on Credentials.
* Click on the CREATE NEW CLIENT ID button, enter/tick the following values and then click on the Create Client ID button.

  Application type: Web Application
  Authorized Javascript origins: http://crash.replex.org
  Authorized redirect URI: http://crash.replex.org/process_login.php
  (replace with appropriate links. imporant bit is url to process_login.php)

You will now have Client ID and Client secret
2014-06-05 18:01:33 +02:00

99 lines
2.0 KiB
PHP

<?php
if (!defined('SITE_ROOT')) {
exit(1);
}
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT));
ini_set('display_errors',1);
if (!extension_loaded('kl')) {
require_once SITE_ROOT.'/lib/ext_kl.php';
}
function __autoload($class)
{
require_once(SITE_ROOT . '/lib/' . $class . '.php');
}
Memc::init();
/* Directory relative to server root
* No leading or trailing slash.
* Example: http://www.example.com/applications/app1/
*/
define('REL_DIR', '');
if (!defined('URL_ROOT')) {
$init_port = "";
$init_ssl = strlen($_SERVER["HTTPS"]) > 0 ? true:false;
define('USE_SSL', $init_ssl);
$init_url = $init_ssl ? "https://" : "http://";
if ($init_ssl && $_SERVER['PORT']!=443) {
$init_port = $_SERVER['PORT'];
}
if (!$init_ssl && $_SERVER['PORT']!=80) {
$init_port = $_SERVER['PORT'];
}
$init_url .= $_SERVER['HTTP_HOST'];
if ($init_port) {
$init_url .= ":" . $init_port;
}
if (defined('REL_DIR') && strlen(REL_DIR)) {
$init_url .= '/' . REL_DIR;
}
define ('URL_ROOT', $init_url);
}
if (!defined('IMG_ROOT')) {
define('IMG_ROOT', URL_ROOT . '/images');
}
$DB = DBH::getInstance();
$DB_NAME = 'replex_crash';
$DB_USER = 'replex_crash';
$DB_PASS = 'replex_sekrit';
$DB_HOST = 'localhost';
if (!DBH::$db->connect($DB_NAME, $DB_HOST, $DB_USER, $DB_PASS)) {
echo "System is down for mantainence. Please try again later.";
die();
}
// Google API settings
set_include_path(get_include_path() . PATH_SEPARATOR . SITE_ROOT . '/lib');
require_once 'Google/Client.php';
$GoogleClientID = "get client id at google dev console";
$GoogleClientSecret = "secret from google dev console";
GoogleLogin::init($GoogleClientID, $GoogleClientSecret);
// Options
Option::init();
// Session
if (!defined('NO_SESSION') && PHP_SAPI != "cli") {
$S = new Session();
$S->check();
}
/* Prevent XSS attacks via PHP_SELF */
$_SERVER['PHP_SELF'] = htmlspecialchars($_SERVER['PHP_SELF']);
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
*/
?>