My login page contains the blurb that is setting the cookie.
benanamen What I do with it is log the errors and fire off an email to myself with the error details as well a provide a generic Fatal Error message to the user.
Could you show me an example of a query that would call an email function in the event of an error?
benanamen If you really want to get this top notch, put the whole project on Github so we can review it as a whole.
I would like to at least finish of the conversion to the new format and wrap up some of the partial stuff as it's really too much a mess currently to bother anyone else with.
Here's my config file as it stands. I've made the changes suggested and moved some stuff to the index file as it began to not make sense to have it here. Hopefully I'm close to being ready to move the changes on to the other files.
<?php
/* File: /includities/configlio.php */
session_start();
if(!defined('parentInclude')) {
header("Location: /");
exit;
}
/* DB creds */
/* Connect to the DB */
$pdo = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpasswd);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
/* Query to get necessary settings for general use. */
$stmt = $pdo->query("SELECT is_online, offline_excuse, title, description, keywords FROM settings");
$site = $stmt->fetch();
if(isset($_COOKIE[$site_cookie])){
/* User has a cookie. Is it valid?*/
$stmt = $db->prepare("SELECT id, username, user_email, gid, role, avatar FROM users WHERE cookie=:cookie LIMIT 1");
$usr = $stmt->bindParam(':cookie', $_COOKIE[$cookie_name], PDO::PARAM_STR);
if ($usr->rowCount() > 0) {
$usr['sid'] = session_id();
if($usr['avatar'] == ''){
$usr['avatar'] = 'no_avatar.png';
}
}else{
/* Has a cookie but isn't legitimate */
$is_anon = '1';
}
}else{
/* Doesn't have a cookie */
$is_anon = '1';
}
if($is_anon){
/* No cookie means visitor is anonymous */
$usr['user_id'] = '0';
$usr['username'] = 'Anonymous';
$usr['sid'] = session_id();
$usr['gid'] = '1'; // 6 eqals bot
$usr['role'] = 'user';
$usr['avatar'] = 'anonymous.png';
}
//Get the forwarded IP if it exists
if(array_key_exists('X-Forwarded-For', $_SERVER) && filter_var($_SERVER['X-Forwarded-For'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)){
$vu_ip = $_SERVER['X-Forwarded-For'];
$vu_proxy = $_SERVER['REMOTE_ADDR'];
}elseif(array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER) && filter_var($_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)){
$vu_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
$vu_proxy = $_SERVER['REMOTE_ADDR'];
}else{
$vu_ip = filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
}
?>