diff --git a/api/v1/validate_api_key.php b/api/v1/validate_api_key.php index fceeaa7c..6fa07065 100644 --- a/api/v1/validate_api_key.php +++ b/api/v1/validate_api_key.php @@ -17,7 +17,7 @@ header('Content-Type: application/json'); $_POST = json_decode(file_get_contents('php://input'), true); // Get user IP -$ip = strip_tags(mysqli_real_escape_string($mysqli, get_ip())); +$ip = strip_tags(mysqli_real_escape_string($mysqli, getIP())); // Get user agent $user_agent = strip_tags(mysqli_real_escape_string($mysqli, $_SERVER['HTTP_USER_AGENT'])); @@ -114,4 +114,4 @@ if (isset($api_key)) { } } -} \ No newline at end of file +} diff --git a/check_login.php b/check_login.php index aee7fb35..be452ffa 100644 --- a/check_login.php +++ b/check_login.php @@ -23,7 +23,7 @@ if (!isset($_SESSION['logged']) || !$_SESSION['logged']) { } // SESSION FINGERPRINT -$session_ip = strip_tags(mysqli_real_escape_string($mysqli,get_ip())); +$session_ip = strip_tags(mysqli_real_escape_string($mysqli,getIP())); // User agent $session_user_agent = strip_tags(mysqli_real_escape_string($mysqli,$_SERVER['HTTP_USER_AGENT'])); diff --git a/client_logs.php b/client_logs.php index 7557808c..0ba9c132 100644 --- a/client_logs.php +++ b/client_logs.php @@ -76,8 +76,8 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); $log_description = htmlentities($row['log_description']); $log_ip = htmlentities($row['log_ip']); $log_user_agent = htmlentities($row['log_user_agent']); - $log_user_os = get_os($log_user_agent); - $log_user_browser = get_web_browser($log_user_agent); + $log_user_os = getOS($log_user_agent); + $log_user_browser = getWebBrowser($log_user_agent); $log_created_at = $row['log_created_at']; $user_id = $row['user_id']; $user_name = htmlentities($row['user_name']); @@ -110,4 +110,4 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); - \ No newline at end of file + diff --git a/functions.php b/functions.php index 1ea893a7..c570dcc8 100644 --- a/functions.php +++ b/functions.php @@ -66,12 +66,11 @@ function removeDirectory($path) { rmdir($path); } -function get_user_agent() { +function getUserAgent() { return $_SERVER['HTTP_USER_AGENT']; } -function get_ip() { - +function getIP() { if (defined("CONST_GET_IP_METHOD")) { if (CONST_GET_IP_METHOD == "HTTP_X_FORWARDED_FOR") { $ip = getenv('HTTP_X_FORWARDED_FOR'); @@ -85,7 +84,7 @@ function get_ip() { return $ip; } -function get_web_browser($user_browser) { +function getWebBrowser($user_browser) { $browser = "Unknown Browser"; $browser_array = array( '/msie/i' => " Internet Explorer", @@ -103,7 +102,7 @@ function get_web_browser($user_browser) { return $browser; } -function get_os($user_os) { +function getOS($user_os) { $os_platform = "Unknown OS"; $os_array = array( '/windows nt 10/i' => " Windows 10", @@ -130,7 +129,7 @@ function get_os($user_os) { return $os_platform; } -function get_device() { +function getDevice() { $tablet_browser = 0; $mobile_browser = 0; if (preg_match('/(tablet|ipad|playbook)|(android(?!.*(mobi|opera mini)))/i', strtolower($_SERVER['HTTP_USER_AGENT']))) { @@ -142,7 +141,7 @@ function get_device() { if ((strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml') > 0) || ((isset($_SERVER['HTTP_X_WAP_PROFILE']) || isset($_SERVER['HTTP_PROFILE'])))) { $mobile_browser++; } - $mobile_ua = strtolower(substr(get_user_agent(), 0, 4)); + $mobile_ua = strtolower(substr(getUserAgent(), 0, 4)); $mobile_agents = array( 'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac', 'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno', @@ -156,7 +155,7 @@ function get_device() { if (in_array($mobile_ua,$mobile_agents)) { $mobile_browser++; } - if (strpos(strtolower(get_user_agent()),'opera mini') > 0) { + if (strpos(strtolower(getUserAgent()),'opera mini') > 0) { $mobile_browser++; //Check for tablets on Opera Mini alternative headers $stock_ua = strtolower(isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA'])?$_SERVER['HTTP_X_OPERAMINI_PHONE_UA']:(isset($_SERVER['HTTP_DEVICE_STOCK_UA'])?$_SERVER['HTTP_DEVICE_STOCK_UA']:'')); @@ -216,7 +215,7 @@ function formatPhoneNumber($phoneNumber) { return $phoneNumber; } -function mkdir_missing($dir) { +function mkdirMissing($dir) { if (!is_dir($dir)) { mkdir($dir); } @@ -437,12 +436,9 @@ function getSSL($name) { return $certificate; } -function strto_AZaz09($string) { +function strtoAZaz09($string) { $string = ucwords(strtolower($string)); - // Replace spaces with _ - //$string = str_replace(' ', '_', $string); - // Gets rid of non-alphanumerics return preg_replace('/[^A-Za-z0-9_]/', '', $string); } diff --git a/get_credential.php b/get_credential.php index 39f41fda..687cbf1e 100644 --- a/get_credential.php +++ b/get_credential.php @@ -30,7 +30,7 @@ include_once("config.php"); include_once("functions.php"); // IP & User Agent for logging -$ip = strip_tags(mysqli_real_escape_string($mysqli,get_ip())); +$ip = strip_tags(mysqli_real_escape_string($mysqli,getIP())); $user_agent = strip_tags(mysqli_real_escape_string($mysqli,$_SERVER['HTTP_USER_AGENT'])); // Define wording for the user @@ -147,4 +147,4 @@ if (isset($_GET['host'])) { } //TODO: Future work:- -// - Showing multiple logins for a single URL \ No newline at end of file +// - Showing multiple logins for a single URL diff --git a/guest_download_file.php b/guest_download_file.php index 0f024388..6d069203 100644 --- a/guest_download_file.php +++ b/guest_download_file.php @@ -2,7 +2,7 @@ // Not including the guest header as we don't want any HTML output include("config.php"); include("functions.php"); -$ip = trim(strip_tags(mysqli_real_escape_string($mysqli,get_ip()))); +$ip = trim(strip_tags(mysqli_real_escape_string($mysqli,getIP()))); $user_agent = strip_tags(mysqli_real_escape_string($mysqli,$_SERVER['HTTP_USER_AGENT'])); if (isset($_GET['id']) && isset($_GET['key'])) { @@ -65,4 +65,4 @@ if (isset($_GET['id']) && isset($_GET['key'])) { mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Sharing', log_action = 'View', log_description = 'Downloaded shared file $file_name via link', log_client_id = '$client_id', log_created_at = NOW(), log_ip = '$ip', log_user_agent = '$user_agent', company_id = '1'"); -} \ No newline at end of file +} diff --git a/guest_header.php b/guest_header.php index 04e26ac7..0fc66cca 100644 --- a/guest_header.php +++ b/guest_header.php @@ -5,7 +5,7 @@ include("functions.php"); session_start(); -$ip = trim(strip_tags(mysqli_real_escape_string($mysqli,get_ip()))); +$ip = trim(strip_tags(mysqli_real_escape_string($mysqli,getIP()))); $user_agent = strip_tags(mysqli_real_escape_string($mysqli,$_SERVER['HTTP_USER_AGENT'])); ?> @@ -61,4 +61,4 @@ $user_agent = strip_tags(mysqli_real_escape_string($mysqli,$_SERVER['HTTP_USER_A unset($_SESSION['alert_message']); } - ?> \ No newline at end of file + ?> diff --git a/guest_view_invoice.php b/guest_view_invoice.php index bb3cfbe2..df3c074f 100644 --- a/guest_view_invoice.php +++ b/guest_view_invoice.php @@ -65,11 +65,11 @@ if (isset($_GET['invoice_id'], $_GET['url_key'])) { //Set Currency Format $currency_format = numfmt_create($company_locale, NumberFormatter::CURRENCY); - $ip = strip_tags(mysqli_real_escape_string($mysqli,get_ip())); + $ip = strip_tags(mysqli_real_escape_string($mysqli,getIP())); $session_user_agent = strip_tags(mysqli_real_escape_string($mysqli,$_SERVER['HTTP_USER_AGENT'])); - $os = strip_tags(mysqli_real_escape_string($mysqli,get_os($session_user_agent))); - $browser = strip_tags(mysqli_real_escape_string($mysqli,get_web_browser($session_user_agent))); + $os = strip_tags(mysqli_real_escape_string($mysqli,getOS($session_user_agent))); + $browser = strip_tags(mysqli_real_escape_string($mysqli,getWebBrowser($session_user_agent))); //Set Badge color based off of invoice status if ($invoice_status == "Sent") { diff --git a/guest_view_quote.php b/guest_view_quote.php index 033fd9ee..dba3dc65 100644 --- a/guest_view_quote.php +++ b/guest_view_quote.php @@ -64,11 +64,11 @@ if (isset($_GET['quote_id'], $_GET['url_key'])) { //Set Currency Format $currency_format = numfmt_create($company_locale, NumberFormatter::CURRENCY); - $ip = strip_tags(mysqli_real_escape_string($mysqli,get_ip())); + $ip = strip_tags(mysqli_real_escape_string($mysqli,getIP())); $session_user_agent = strip_tags(mysqli_real_escape_string($mysqli,$_SERVER['HTTP_USER_AGENT'])); - $os = strip_tags(mysqli_real_escape_string($mysqli,get_os($session_user_agent))); - $browser = strip_tags(mysqli_real_escape_string($mysqli,get_web_browser($session_user_agent))); + $os = strip_tags(mysqli_real_escape_string($mysqli,getOS($session_user_agent))); + $browser = strip_tags(mysqli_real_escape_string($mysqli,getWebBrowser($session_user_agent))); //Update status to Viewed only if invoice_status = "Sent" if ($quote_status == 'Sent') { diff --git a/login.php b/login.php index 2d5a7e3e..f31af0b9 100644 --- a/login.php +++ b/login.php @@ -10,7 +10,7 @@ require_once("functions.php"); require_once("rfc6238.php"); // IP & User Agent for logging -$ip = strip_tags(mysqli_real_escape_string($mysqli, get_ip())); +$ip = strip_tags(mysqli_real_escape_string($mysqli, getIP())); $user_agent = strip_tags(mysqli_real_escape_string($mysqli, $_SERVER['HTTP_USER_AGENT'])); // Block brute force password attacks - check recent failed login attempts for this IP diff --git a/logs.php b/logs.php index 450e8e96..8274a395 100644 --- a/logs.php +++ b/logs.php @@ -141,8 +141,8 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); $log_description = htmlentities($row['log_description']); $log_ip = htmlentities($row['log_ip']); $log_user_agent = htmlentities($row['log_user_agent']); - $log_user_os = get_os($log_user_agent); - $log_user_browser = get_web_browser($log_user_agent); + $log_user_os = getOS($log_user_agent); + $log_user_browser = getWebBrowser($log_user_agent); $log_created_at = $row['log_created_at']; $user_id = $row['user_id']; $user_name = htmlentities($row['user_name']); diff --git a/portal/check_login.php b/portal/check_login.php index 8d044cc4..d09b9e83 100644 --- a/portal/check_login.php +++ b/portal/check_login.php @@ -21,7 +21,7 @@ if (!$_SESSION['client_logged_in']) { } // SESSION FINGERPRINT -$session_ip = strip_tags(mysqli_real_escape_string($mysqli, get_ip())); +$session_ip = strip_tags(mysqli_real_escape_string($mysqli, getIP())); // Get user agent $session_user_agent = strip_tags(mysqli_real_escape_string($mysqli, $_SERVER['HTTP_USER_AGENT'])); diff --git a/portal/login.php b/portal/login.php index 68380559..ceecafe6 100644 --- a/portal/login.php +++ b/portal/login.php @@ -19,7 +19,7 @@ if (!isset($_SESSION)) { session_start(); } -$ip = strip_tags(mysqli_real_escape_string($mysqli, get_ip())); +$ip = strip_tags(mysqli_real_escape_string($mysqli, getIP())); $user_agent = strip_tags(mysqli_real_escape_string($mysqli, $_SERVER['HTTP_USER_AGENT'])); $sql_settings = mysqli_query($mysqli, "SELECT config_azure_client_id FROM settings WHERE company_id = '1'"); diff --git a/portal/login_reset.php b/portal/login_reset.php index 664a7ef7..2b179d14 100644 --- a/portal/login_reset.php +++ b/portal/login_reset.php @@ -24,7 +24,7 @@ if (!isset($_SESSION)) { session_start(); } -$ip = strip_tags(mysqli_real_escape_string($mysqli,get_ip())); +$ip = strip_tags(mysqli_real_escape_string($mysqli,getIP())); $user_agent = strip_tags(mysqli_real_escape_string($mysqli, $_SERVER['HTTP_USER_AGENT'])); $company_sql = mysqli_query($mysqli, "SELECT company_name FROM companies WHERE company_id = '1'"); diff --git a/post.php b/post.php index fb176fee..f8e6c5e5 100644 --- a/post.php +++ b/post.php @@ -4371,7 +4371,7 @@ if(isset($_GET['export_client_contacts_csv'])){ $sql = mysqli_query($mysqli,"SELECT * FROM contacts LEFT JOIN locations ON location_id = contact_location_id WHERE contact_client_id = $client_id ORDER BY contact_name ASC"); if($sql->num_rows > 0){ $delimiter = ","; - $filename = strto_AZaz09($client_name) . "-Contacts-" . date('Y-m-d') . ".csv"; + $filename = strtoAZaz09($client_name) . "-Contacts-" . date('Y-m-d') . ".csv"; //create a file pointer $f = fopen('php://memory', 'w'); @@ -4509,7 +4509,7 @@ if(isset($_GET['download_client_contacts_csv_template'])){ $client_name = $row['client_name']; $delimiter = ","; - $filename = strto_AZaz09($client_name) . "-Contacts-Template.csv"; + $filename = strtoAZaz09($client_name) . "-Contacts-Template.csv"; //create a file pointer $f = fopen('php://memory', 'w'); @@ -4789,7 +4789,7 @@ if(isset($_GET['export_client_locations_csv'])){ $sql = mysqli_query($mysqli,"SELECT * FROM locations WHERE location_client_id = $client_id AND location_archived_at IS NULL AND company_id = $session_company_id ORDER BY location_name ASC"); if($sql->num_rows > 0){ $delimiter = ","; - $filename = strto_AZaz09($client_name) . "-Locations-" . date('Y-m-d') . ".csv"; + $filename = strtoAZaz09($client_name) . "-Locations-" . date('Y-m-d') . ".csv"; //create a file pointer $f = fopen('php://memory', 'w'); @@ -4915,7 +4915,7 @@ if(isset($_GET['download_client_locations_csv_template'])){ $client_name = $row['client_name']; $delimiter = ","; - $filename = strto_AZaz09($client_name) . "-Locations-Template.csv"; + $filename = strtoAZaz09($client_name) . "-Locations-Template.csv"; //create a file pointer $f = fopen('php://memory', 'w'); @@ -5189,7 +5189,7 @@ if(isset($_GET['download_client_assets_csv_template'])){ $client_name = $row['client_name']; $delimiter = ","; - $filename = strto_AZaz09($client_name) . "-Assets-Template.csv"; + $filename = strtoAZaz09($client_name) . "-Assets-Template.csv"; //create a file pointer $f = fopen('php://memory', 'w'); @@ -5226,7 +5226,7 @@ if(isset($_GET['export_client_assets_csv'])){ $sql = mysqli_query($mysqli,"SELECT * FROM assets LEFT JOIN contacts ON asset_contact_id = contact_id LEFT JOIN locations ON asset_location_id = location_id WHERE asset_client_id = $client_id ORDER BY asset_name ASC"); if($sql->num_rows > 0){ $delimiter = ","; - $filename = strto_AZaz09($client_name) . "-Assets-" . date('Y-m-d') . ".csv"; + $filename = strtoAZaz09($client_name) . "-Assets-" . date('Y-m-d') . ".csv"; //create a file pointer $f = fopen('php://memory', 'w'); @@ -5632,7 +5632,7 @@ if(isset($_GET['export_client_logins_csv'])){ $sql = mysqli_query($mysqli,"SELECT * FROM logins WHERE login_client_id = $client_id ORDER BY login_name ASC"); if($sql->num_rows > 0){ $delimiter = ","; - $filename = strto_AZaz09($client_name) . "-Logins-" . date('Y-m-d') . ".csv"; + $filename = strtoAZaz09($client_name) . "-Logins-" . date('Y-m-d') . ".csv"; //create a file pointer $f = fopen('php://memory', 'w'); @@ -5751,7 +5751,7 @@ if(isset($_GET['download_client_logins_csv_template'])){ $client_name = $row['client_name']; $delimiter = ","; - $filename = strto_AZaz09($client_name) . "-Logins-Template.csv"; + $filename = strtoAZaz09($client_name) . "-Logins-Template.csv"; //create a file pointer $f = fopen('php://memory', 'w'); @@ -7864,7 +7864,7 @@ if(isset($_GET['export_client_pdf'])){ var docDefinition = { info: { - title: '- IT Documentation', + title: '- IT Documentation', author: }, @@ -9046,7 +9046,7 @@ if(isset($_GET['export_client_pdf'])){ }; - pdfMake.createPdf(docDefinition).download('-IT_Documentation-.pdf'); + pdfMake.createPdf(docDefinition).download('-IT_Documentation-.pdf'); diff --git a/setup.php b/setup.php index 9d08bfc2..8c8e8bf7 100644 --- a/setup.php +++ b/setup.php @@ -857,7 +857,7 @@ if (isset($_POST['add_user'])) { $user_id = mysqli_insert_id($mysqli); - mkdir_missing("uploads/users/$user_id"); + mkdirMissing("uploads/users/$user_id"); //Check to see if a file is attached if ($_FILES['file']['tmp_name'] != '') { @@ -934,13 +934,13 @@ if (isset($_POST['add_company_settings'])) { $company_id = mysqli_insert_id($mysqli); - mkdir_missing("uploads/clients/$company_id"); + mkdirMissing("uploads/clients/$company_id"); file_put_contents("uploads/clients/$company_id/index.php", ""); - mkdir_missing("uploads/expenses/$company_id"); + mkdirMissing("uploads/expenses/$company_id"); file_put_contents("uploads/expenses/$company_id/index.php", ""); - mkdir_missing("uploads/settings/$company_id"); + mkdirMissing("uploads/settings/$company_id"); file_put_contents("uploads/settings/$company_id/index.php", ""); - mkdir_missing("uploads/tmp/$company_id"); + mkdirMissing("uploads/tmp/$company_id"); file_put_contents("uploads/tmp/$company_id/index.php", ""); //Check to see if a file is attached diff --git a/user_profile.php b/user_profile.php index b71ddd2f..e8245fbb 100644 --- a/user_profile.php +++ b/user_profile.php @@ -156,8 +156,8 @@ $sql_recent_logs = mysqli_query($mysqli, "SELECT * FROM logs $log_id = $row['log_id']; $log_ip = htmlentities($row['log_ip']); $log_user_agent = htmlentities($row['log_user_agent']); - $log_user_os = get_os($log_user_agent); - $log_user_browser = get_web_browser($log_user_agent); + $log_user_os = getOS($log_user_agent); + $log_user_browser = getWebBrowser($log_user_agent); $log_created_at = $row['log_created_at']; ?> diff --git a/users.php b/users.php index 10e53d7c..9e3d6e8a 100644 --- a/users.php +++ b/users.php @@ -99,8 +99,8 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); $log_created_at = $row['log_created_at']; $log_ip = htmlentities($row['log_ip']); $log_user_agent = htmlentities($row['log_user_agent']); - $log_user_os = get_os($log_user_agent); - $log_user_browser = get_web_browser($log_user_agent); + $log_user_os = getOS($log_user_agent); + $log_user_browser = getWebBrowser($log_user_agent); $last_login = "$log_user_os
$log_user_browser
$log_ip"; if (empty($last_login)) { $last_login = "Never logged in";