Webbserver - Love Blomberg

Show sourcecode

The following files exists in this folder. Click to view.

public_html/crumbs/

.gitignore
admin/
config.php
createtable.php
crumbs_design_system.html
dbconnection.php
icons/
includes/
index.php
js/
login.php
logout.php
order/
register.php
style/

dbconnection.php

33 lines UTF-8 Windows (CRLF)
<?php
// Kolla om local eller på labbserver
$local = ($_SERVER['HTTP_HOST'] === 'localhost' || $_SERVER['HTTP_HOST'] === '127.0.0.1');

// Config med variablar
include('config.php');

if (
$local) {
  
$dbname $DB_NAME_LOCAL;
  
$hostname $DB_HOST_LOCAL;
  $
/* DB_USER, is removed and hidden for security reasons */ ;
  $
/* DB_PASSWORD, is removed and hidden for security reasons */ ;
} else {
  
$dbname $DB_NAME_PROD;
  
$hostname $DB_HOST_PROD;
  $
/* DB_USER, is removed and hidden for security reasons */ ;
  $
/* DB_PASSWORD, is removed and hidden for security reasons */ ;
}

$options  = array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'");

try {
  
$dbconn = new PDO("mysql:host=$hostname;dbname=$dbname;", $/* DB_USER, is removed and hidden for security reasons */ ;
  
$dbconn->setAttribute(PDO::ATTR_ERRMODEPDO::ERRMODE_EXCEPTION);
  
// Echo a message saying we have connected.
  //echo 'Connected to database.<br />';
} catch (PDOException $e) {
  
// For debug purpose, shows all connection details
  //echo 'Connection failed: ' . $e->getMessage() . "<br />";
  // Hide connection details.
  
echo 'Could not connect to database.<br />';
}