-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnection.php.example
More file actions
96 lines (85 loc) · 2.89 KB
/
Copy pathconnection.php.example
File metadata and controls
96 lines (85 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/**
* Database Connection Configuration - Example File
*
* INSTRUCTIONS:
* 1. Copy this file and rename it to "connection.php"
* 2. Update the database credentials below with your actual values
* 3. Never commit connection.php to version control (it's in .gitignore)
*
* SECURITY NOTE:
* - Use strong passwords for production environments
* - Restrict database user privileges to only what's needed
* - Consider using environment variables for credentials in production
*/
// Database Configuration
// Replace these values with your actual database credentials
$conn = mysqli_connect(
"localhost", // Database host (usually 'localhost')
"payroll_user", // Database username
"YourSecurePassword123!", // Database password - CHANGE THIS!
"payroll_db" // Database name
);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
// Error Reporting Configuration
// PRODUCTION: Set display_errors to '0' and log_errors to '1'
// DEVELOPMENT: Set display_errors to '1' for debugging
error_reporting(E_ALL);
ini_set('display_errors', '1'); // Change to '0' in production
ini_set('log_errors', '1'); // Always log errors
// Date/Time Helper Functions
function datetime_to($datetime=""){
$unixdatetime = strtotime($datetime);
return date("F d, Y at h:i A", $unixdatetime);
}
function date_only($datetime=""){
$unixdatetime = strtotime($datetime);
return date("F d, Y ", $unixdatetime);
}
function time_only($datetime=""){
$unixdatetime = strtotime($datetime);
return date("h:i A ", $unixdatetime);
}
function year_only($datetime=""){
$unixdatetime = strtotime($datetime);
return date("Y ", $unixdatetime);
}
function no_year($datetime=""){
$unixdatetime = strtotime($datetime);
return date("md", $unixdatetime);
}
function months_year($datetime=""){
$unixdatetime = strtotime($datetime);
return date("F, Y", $unixdatetime);
}
// Company Settings Helper Functions
function get_company_settings($conn) {
static $settings = null;
if($settings === null) {
$sql = "SELECT * FROM company_settings ORDER BY id DESC LIMIT 1";
$result = mysqli_query($conn, $sql);
if($result && mysqli_num_rows($result) > 0) {
$settings = mysqli_fetch_assoc($result);
} else {
// Default settings if none exist
$settings = array(
'company_name' => 'Payroll CO',
'company_address' => '',
'company_phone' => '',
'company_email' => '',
'company_ein' => '',
'pay_period_type' => 'bi-weekly'
);
}
}
return $settings;
}
// Get company name (shorthand)
function get_company_name($conn) {
$settings = get_company_settings($conn);
return !empty($settings['company_name']) ? $settings['company_name'] : 'Payroll CO';
}
?>