/home
/deploy
/EHungry-4-simon
/PHP
/vendor
/illuminate
/database
/Connectors
/Connector.php
);
}
}
/**
* Create a new PDO connection instance.
*
* @param string $dsn
* @param string $username
* @param string $password
* @param array $options
* @return \PDO
*/
protected function createPdoConnection($dsn, $username, $password, $options)
{
if (class_exists(PDOConnection::class) && ! $this->isPersistentConnection($options)) {
return new PDOConnection($dsn, $username, $password, $options);
}
return new PDO($dsn, $username, $password, $options);
}
/**
* Determine if the connection is persistent.
*
* @param array $options
* @return bool
*/
protected function isPersistentConnection($options)
{
return isset($options[PDO::ATTR_PERSISTENT]) &&
$options[PDO::ATTR_PERSISTENT];
}
/**
* Handle an exception that occurred during connect execution.
*
* @param \Exception $e
* @param string $dsn
* @param string $username
Arguments
"SQLSTATE[HY000] [1040] Too many connections"
/home
/deploy
/EHungry-4-simon
/PHP
/vendor
/illuminate
/database
/Connectors
/Connector.php
);
}
}
/**
* Create a new PDO connection instance.
*
* @param string $dsn
* @param string $username
* @param string $password
* @param array $options
* @return \PDO
*/
protected function createPdoConnection($dsn, $username, $password, $options)
{
if (class_exists(PDOConnection::class) && ! $this->isPersistentConnection($options)) {
return new PDOConnection($dsn, $username, $password, $options);
}
return new PDO($dsn, $username, $password, $options);
}
/**
* Determine if the connection is persistent.
*
* @param array $options
* @return bool
*/
protected function isPersistentConnection($options)
{
return isset($options[PDO::ATTR_PERSISTENT]) &&
$options[PDO::ATTR_PERSISTENT];
}
/**
* Handle an exception that occurred during connect execution.
*
* @param \Exception $e
* @param string $dsn
* @param string $username
Arguments
"mysql:host=10.21.3.62;dbname=EHungry-2-joel"
"EHungry-2-joel"
"32749238742938472"
array:6 [
8 => 0
3 => 2
11 => 0
17 => false
20 => false
1002 => "SET time_zone = "-08:00""
]
/home
/deploy
/EHungry-4-simon
/PHP
/vendor
/illuminate
/database
/Connectors
/Connector.php
PDO::ATTR_EMULATE_PREPARES => false,
];
/**
* Create a new PDO connection.
*
* @param string $dsn
* @param array $config
* @param array $options
* @return \PDO
*/
public function createConnection($dsn, array $config, array $options)
{
list($username, $password) = [
Arr::get($config, 'username'), Arr::get($config, 'password'),
];
try {
return $this->createPdoConnection(
$dsn, $username, $password, $options
);
} catch (Exception $e) {
return $this->tryAgainIfCausedByLostConnection(
$e, $dsn, $username, $password, $options
);
}
}
/**
* Create a new PDO connection instance.
*
* @param string $dsn
* @param string $username
* @param string $password
* @param array $options
* @return \PDO
*/
protected function createPdoConnection($dsn, $username, $password, $options)
{
if (class_exists(PDOConnection::class) && ! $this->isPersistentConnection($options)) {
Arguments
"mysql:host=10.21.3.62;dbname=EHungry-2-joel"
"EHungry-2-joel"
"32749238742938472"
array:6 [
8 => 0
3 => 2
11 => 0
17 => false
20 => false
1002 => "SET time_zone = "-08:00""
]
/home
/deploy
/EHungry-4-simon
/PHP
/vendor
/illuminate
/database
/Connectors
/MySqlConnector.php
use PDO;
class MySqlConnector extends Connector implements ConnectorInterface
{
/**
* Establish a database connection.
*
* @param array $config
* @return \PDO
*/
public function connect(array $config)
{
$dsn = $this->getDsn($config);
$options = $this->getOptions($config);
// We need to grab the PDO options that should be used while making the brand
// new connection instance. The PDO options control various aspects of the
// connection's behavior, and some might be specified by the developers.
$connection = $this->createConnection($dsn, $config, $options);
if (! empty($config['database'])) {
$connection->exec("use `{$config['database']}`;");
}
$this->configureEncoding($connection, $config);
// Next, we will check to see if a timezone has been specified in this config
// and if it has we will issue a statement to modify the timezone with the
// database. Setting this DB timezone is an optional configuration item.
$this->configureTimezone($connection, $config);
$this->setModes($connection, $config);
return $connection;
}
/**
* Set the connection character set and collation.
*
Arguments
"mysql:host=10.21.3.62;dbname=EHungry-2-joel"
array:10 [
"driver" => "mysql"
"host" => "10.21.3.62"
"database" => "EHungry-2-joel"
"username" => "EHungry-2-joel"
"password" => "32749238742938472"
"charset" => "latin1"
"collation" => "latin1_swedish_ci"
"options" => array:1 [
1002 => "SET time_zone = "-08:00""
]
"prefix" => ""
"name" => "default"
]
array:6 [
8 => 0
3 => 2
11 => 0
17 => false
20 => false
1002 => "SET time_zone = "-08:00""
]
/home
/deploy
/EHungry-4-simon
/PHP
/vendor
/illuminate
/database
/Connectors
/ConnectionFactory.php
{
return array_key_exists('host', $config)
? $this->createPdoResolverWithHosts($config)
: $this->createPdoResolverWithoutHosts($config);
}
/**
* Create a new Closure that resolves to a PDO instance with a specific host or an array of hosts.
*
* @param array $config
* @return \Closure
*/
protected function createPdoResolverWithHosts(array $config)
{
return function () use ($config) {
foreach (Arr::shuffle($hosts = $this->parseHosts($config)) as $key => $host) {
$config['host'] = $host;
try {
return $this->createConnector($config)->connect($config);
} catch (PDOException $e) {
if (count($hosts) - 1 === $key && $this->container->bound(ExceptionHandler::class)) {
$this->container->make(ExceptionHandler::class)->report($e);
}
}
}
throw $e;
};
}
/**
* Parse the hosts configuration item into an array.
*
* @param array $config
* @return array
*/
protected function parseHosts(array $config)
{
$hosts = array_wrap($config['host']);
Arguments
array:10 [
"driver" => "mysql"
"host" => "10.21.3.62"
"database" => "EHungry-2-joel"
"username" => "EHungry-2-joel"
"password" => "32749238742938472"
"charset" => "latin1"
"collation" => "latin1_swedish_ci"
"options" => array:1 [
1002 => "SET time_zone = "-08:00""
]
"prefix" => ""
"name" => "default"
]
/home
/deploy
/EHungry-4-simon
/PHP
/vendor
/illuminate
/database
/Connection.php
if (is_null($this->doctrineConnection)) {
$data = ['pdo' => $this->getPdo(), 'dbname' => $this->getConfig('database')];
$this->doctrineConnection = new DoctrineConnection(
$data, $this->getDoctrineDriver()
);
}
return $this->doctrineConnection;
}
/**
* Get the current PDO connection.
*
* @return \PDO
*/
public function getPdo()
{
if ($this->pdo instanceof Closure) {
return $this->pdo = call_user_func($this->pdo);
}
return $this->pdo;
}
/**
* Get the current PDO connection used for reading.
*
* @return \PDO
*/
public function getReadPdo()
{
if ($this->transactions >= 1) {
return $this->getPdo();
}
if ($this->readPdo instanceof Closure) {
return $this->readPdo = call_user_func($this->readPdo);
}
/home
/deploy
/EHungry-4-simon
/PHP
/vendor
/illuminate
/database
/Connection.php
if (is_null($this->doctrineConnection)) {
$data = ['pdo' => $this->getPdo(), 'dbname' => $this->getConfig('database')];
$this->doctrineConnection = new DoctrineConnection(
$data, $this->getDoctrineDriver()
);
}
return $this->doctrineConnection;
}
/**
* Get the current PDO connection.
*
* @return \PDO
*/
public function getPdo()
{
if ($this->pdo instanceof Closure) {
return $this->pdo = call_user_func($this->pdo);
}
return $this->pdo;
}
/**
* Get the current PDO connection used for reading.
*
* @return \PDO
*/
public function getReadPdo()
{
if ($this->transactions >= 1) {
return $this->getPdo();
}
if ($this->readPdo instanceof Closure) {
return $this->readPdo = call_user_func($this->readPdo);
}
Arguments
Closure {
class: "Illuminate\Database\Connectors\ConnectionFactory"
this: ConnectionFactory { …}
use: {
$config: array:10 [
"driver" => "mysql"
"host" => "10.21.3.62"
"database" => "EHungry-2-joel"
"username" => "EHungry-2-joel"
"password" => "32749238742938472"
"charset" => "latin1"
"collation" => "latin1_swedish_ci"
"options" => array:1 [
1002 => "SET time_zone = "-08:00""
]
"prefix" => ""
"name" => "default"
]
}
}
/home
/deploy
/EHungry-4-simon
/Web
/classes
/DB.php
'username' => $user,
'password' => $pwd,
'charset' => 'latin1',
'collation' => 'latin1_swedish_ci',
'options' => [PDO::MYSQL_ATTR_INIT_COMMAND => 'SET time_zone = "'.date('P').'"'] //if it gets a bit lost
]);
static::$capsule->setAsGlobal();
static::$capsule->setEventDispatcher(new EventDispatcher);
static::$capsule->bootEloquent();
//extras: add a CacheManager and, possibly for later, a Translator helper
//TODO: migrate this to serializeDate() when Eloquent 7.x lands
\Carbon\Carbon::serializeUsing(function (\Carbon\Carbon $c) {
return $c->format('c');
});
try {
//using customized PDO classes to be able to log them - to DebugBar and the test logger
static::$pdo = new TraceablePDO(self::$capsule->getConnection()->getPdo());
static::$pdo->setAttribute(PDO::ATTR_STATEMENT_CLASS, [LoggablePDOStatement::class, [static::$pdo]]);
static::$capsule->getConnection()->setPdo(static::$pdo);
} catch (PDOException $e) {
if (DevLevel >= 2) {
throw $e;
} else {
static::dberror($e->getMessage());
return false;
}
}
if (App::debugbar()) {
App::debugbar()['db']->addConnection(static::$pdo, '');
}
return true;
}
protected static function installMysqlSilent() {
Connection::resolverFor('mysql', function ($pdo, $db, $prefix, $config) {
/home
/deploy
/EHungry-4-simon
/PHP
/Global.php
// TODO: figure out a way to enable IS_DEBUG through domains in production (i.e. in the customer pages of custom domain restaurants)
define(
'IS_DEBUG',
(DevLevel > 0 || isset($_SESSION['admin_id'])) //is a developer or a SuperAdmin
&& (isset($_REQUEST['debug']) || isset($_COOKIE['debug'])) //enabled debug, now or previously
&& (!isset($_REQUEST['debug']) || $_REQUEST['debug'] != '0') //and is passively using it, and not trying to disable
);
if (isset($_REQUEST['debug']) && $_REQUEST['debug'] == '0') {
deletecookie('debug', '/');
} elseif (IS_DEBUG) {
setcookie('debug', '1', time() + (60 * 60), '/');
}
App::initializeDebugbar();
///////////////////////////////////////////////////////////////////////////////
// Database, randomized logs, and i18n (which "depends" on debugbar)
$db_conn = DB::conn();
if (!DB::configure(DB_HOST, DB_USER, DB_PASS, DB_NAME)) {
Splunk::log(Splunk::LOG_DB_CONN, ['error' => DB::getError()]);
http_response_code(503);
include(App_Path.'/Web/closed.php');
exit(0);
}
App::initializeRandomizedLogs();
\eHungry\i18n\Locale::setup();
///////////////////////////////////////////////////////////////////////////////
// Now that we have a database, we can check for necessary session overrides.
// In some cases, we still allow URL-based session tokens. It may come from a bunch of *internal* places:
// - mercury/vantiv redirects after the payment is completed/declined
// - stripe redirects after admin/processor (check?)
// - anywhere else using:
// - formatCustomerLink()
// - getSessionTokenForUrl()
// - redirectToCustomerFromAdmin - ordering/editing in behalf of a customer account
// - redirecting from an insecure URL that requested a secure operation (i.e. login, credit cards, password...) (Global.php:446)
Arguments
"10.21.3.62"
"EHungry-2-joel"
"32749238742938472"
"EHungry-2-joel"
/home
/deploy
/EHungry-4-simon
/Web
/index.php
<? /** @noinspection PhpIncludeInspection - to avoid marking dynamic includes */
//TODO create a «root»/_bootstrap.php which can be used by .psysh.php, tests/bootstrap.php and Web/index.php
require(dirname(__DIR__).'/PHP/base_consts.php');
require(dirname(__DIR__).'/PHP/autoloader.php');
initializeAutoLoader();
//disabled for now since we already have our own Alerts infrastructure, and it's not worth it to append another cloud provider to the startup of every freaking request; it's also not possible to catch errors this early if we depend on database checks, but we'll leave it here in case we change our mind?
//ErrorHandlers::sentryInit(); //early catch of errors and failsafe for smaller controllers, not in Sentry
App::startTime();
ErrorHandlers::register();
// Global.php is the core setup file for the application
App::debugbarTime('Global.php');
require(dirname(__DIR__) . '/PHP/Global.php');
App::debugbarTime('Global.php');
/** @var string $controller The main controller - defined at /PHP/Global.php */
App::debugbarTime('Sentry - controller');
ErrorHandlers::sentryInit($controller); //doesn't always do much - not every controller has a Sentry project
App::debugbarTime('Sentry - controller');
App::debugbarTime("controller: $controller");
apache_note('AppController', $controller);
if (file_exists(CORE_PATH."lib/helpers/$controller.php")) {
require CORE_PATH."lib/helpers/$controller.php";
}
require CORE_PATH."controllers/$controller.php";
App::debugbarTime("controller: $controller");
Arguments
"/home/deploy/EHungry-4-simon/PHP/Global.php"