diff --git a/ajax.php b/ajax.php
index ff0f1cd9..d5e212c2 100644
--- a/ajax.php
+++ b/ajax.php
@@ -60,7 +60,7 @@ if(isset($_GET['certificate_fetch_parse_json_details'])){
if(isset($_GET['certificate_get_json_details'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -89,7 +89,7 @@ if(isset($_GET['certificate_get_json_details'])){
if(isset($_GET['domain_get_json_details'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -118,7 +118,7 @@ if(isset($_GET['domain_get_json_details'])){
if(isset($_GET['merge_ticket_get_json_details'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -146,7 +146,7 @@ if(isset($_GET['merge_ticket_get_json_details'])){
if(isset($_GET['network_get_json_details'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -230,7 +230,7 @@ if(isset($_GET['ticket_query_views'])){
if(isset($_GET['share_generate_link'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -282,7 +282,7 @@ if(isset($_GET['share_generate_link'])){
if(isset($_GET['scheduled_ticket_get_json_details'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
diff --git a/api/v1/assets/asset_model.php b/api/v1/assets/asset_model.php
new file mode 100644
index 00000000..feb177ba
--- /dev/null
+++ b/api/v1/assets/asset_model.php
@@ -0,0 +1,27 @@
+insert_id;
+ $insert_id = mysqli_insert_id($mysqli);
//Logging
- mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Asset', log_action = 'Created', log_description = '$name via API ($api_key_name)', log_ip = '$ip', log_created_at = NOW(), company_id = $company_id");
- mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'API', log_action = 'Success', log_description = 'Created asset $name via API ($api_key_name)', log_ip = '$ip', log_created_at = NOW(), company_id = $company_id");
+ mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Asset', log_action = 'Created', log_description = '$name via API ($api_key_name)', log_ip = '$ip', log_created_at = NOW(), log_client_id = '$client_id', company_id = $company_id");
+ mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'API', log_action = 'Success', log_description = 'Created asset $name via API ($api_key_name)', log_ip = '$ip', log_created_at = NOW(), log_client_id = '$client_id', company_id = $company_id");
}
}
-else{
- $insert_id = FALSE;
-}
// Output
include('../create_output.php');
\ No newline at end of file
diff --git a/api/v1/assets/read.php b/api/v1/assets/read.php
index 419ecfb1..5102f32b 100644
--- a/api/v1/assets/read.php
+++ b/api/v1/assets/read.php
@@ -5,37 +5,37 @@ require('../require_get_method.php');
// Asset via ID (single)
if(isset($_GET['asset_id'])){
- $id = intval($_GET['asset_id']);
- $sql = mysqli_query($mysqli, "SELECT * FROM assets WHERE asset_id = '$id' AND company_id = '$company_id'");
+ $id = intval($_GET['asset_id']);
+ $sql = mysqli_query($mysqli, "SELECT * FROM assets WHERE asset_id = '$id' AND asset_client_id LIKE '$client_id' AND company_id = '$company_id'");
}
// Asset query via type
elseif(isset($_GET['asset_type'])){
- $type = mysqli_real_escape_string($mysqli,ucfirst($_GET['asset_type']));
- $sql = mysqli_query($mysqli, "SELECT * FROM assets WHERE asset_type = '$type' AND company_id = '$company_id' ORDER BY asset_id LIMIT $limit OFFSET $offset");
+ $type = mysqli_real_escape_string($mysqli,ucfirst($_GET['asset_type']));
+ $sql = mysqli_query($mysqli, "SELECT * FROM assets WHERE asset_type = '$type' AND asset_client_id LIKE '$client_id' AND company_id = '$company_id' ORDER BY asset_id LIMIT $limit OFFSET $offset");
}
// Asset query via name
elseif(isset($_GET['asset_name'])){
- $name = mysqli_real_escape_string($mysqli,$_GET['asset_name']);
- $sql = mysqli_query($mysqli, "SELECT * FROM assets WHERE asset_name = '$name' AND company_id = '$company_id' ORDER BY asset_id LIMIT $limit OFFSET $offset");
+ $name = mysqli_real_escape_string($mysqli,$_GET['asset_name']);
+ $sql = mysqli_query($mysqli, "SELECT * FROM assets WHERE asset_name = '$name' AND asset_client_id LIKE '$client_id' AND company_id = '$company_id' ORDER BY asset_id LIMIT $limit OFFSET $offset");
}
// Asset query via serial
elseif(isset($_GET['asset_serial'])){
- $serial = mysqli_real_escape_string($mysqli,$_GET['asset_serial']);
- $sql = mysqli_query($mysqli, "SELECT * FROM assets WHERE asset_serial = '$serial' AND company_id = '$company_id' ORDER BY asset_id LIMIT $limit OFFSET $offset");
+ $serial = mysqli_real_escape_string($mysqli,$_GET['asset_serial']);
+ $sql = mysqli_query($mysqli, "SELECT * FROM assets WHERE asset_serial = '$serial' AND asset_client_id LIKE '$client_id' AND company_id = '$company_id' ORDER BY asset_id LIMIT $limit OFFSET $offset");
}
// Asset query via client ID
-elseif(isset($_GET['asset_client_id'])){
- $client = intval($_GET['asset_client_id']);
- $sql = mysqli_query($mysqli, "SELECT * FROM assets WHERE asset_client_id = '$client' AND company_id = '$company_id' ORDER BY asset_id LIMIT $limit OFFSET $offset");
+elseif(isset($_GET['client_id']) && $client_id == "%"){
+ $client_id = intval($_GET['client_id']);
+ $sql = mysqli_query($mysqli, "SELECT * FROM assets WHERE asset_client_id LIKE '$client_id' AND company_id = '$company_id' ORDER BY asset_id LIMIT $limit OFFSET $offset");
}
// All assets
else{
- $sql = mysqli_query($mysqli, "SELECT * FROM assets WHERE company_id = '$company_id' ORDER BY asset_id LIMIT $limit OFFSET $offset");
+ $sql = mysqli_query($mysqli, "SELECT * FROM assets WHERE asset_client_id LIKE '$client_id' AND company_id = '$company_id' ORDER BY asset_id LIMIT $limit OFFSET $offset");
}
// Output
diff --git a/api/v1/certificates/read.php b/api/v1/certificates/read.php
index f07ef6bc..25b9b343 100644
--- a/api/v1/certificates/read.php
+++ b/api/v1/certificates/read.php
@@ -5,25 +5,25 @@ require('../require_get_method.php');
// Specific certificate via ID (single)
if(isset($_GET['certificate_id'])){
- $id = intval($_GET['certificate_id']);
- $sql = mysqli_query($mysqli, "SELECT * FROM certificates WHERE certificate_id = '$id' AND company_id = '$company_id'");
+ $id = intval($_GET['certificate_id']);
+ $sql = mysqli_query($mysqli, "SELECT * FROM certificates WHERE certificate_id = '$id' AND certificate_client_id LIKE '$client_id' AND company_id = '$company_id'");
}
// Certificate by name
elseif(isset($_GET['certificate_name'])){
- $name = mysqli_real_escape_string($mysqli,$_GET['certificate_name']);
- $sql = mysqli_query($mysqli, "SELECT * FROM certificates WHERE certificate_name = '$name' AND company_id = '$company_id' ORDER BY certificate_id LIMIT $limit OFFSET $offset");
+ $name = mysqli_real_escape_string($mysqli,$_GET['certificate_name']);
+ $sql = mysqli_query($mysqli, "SELECT * FROM certificates WHERE certificate_name = '$name' AND certificate_client_id LIKE '$client_id' AND company_id = '$company_id' ORDER BY certificate_id LIMIT $limit OFFSET $offset");
}
-// Certificate via client ID
-elseif(isset($_GET['certificate_client_id'])){
- $client = intval($_GET['certificate_client_id']);
- $sql = mysqli_query($mysqli, "SELECT * FROM certificates WHERE certificate_client_id = '$client' AND company_id = '$company_id' ORDER BY certificate_id LIMIT $limit OFFSET $offset");
+// Certificate via client ID (if allowed)
+elseif(isset($_GET['client_id']) && $client_id == "%"){
+ $client_id = intval($_GET['client_id']);
+ $sql = mysqli_query($mysqli, "SELECT * FROM certificates WHERE certificate_client_id = '$client_id' AND company_id = '$company_id' ORDER BY certificate_id LIMIT $limit OFFSET $offset");
}
// All certificates
else{
- $sql = mysqli_query($mysqli, "SELECT * FROM certificates WHERE company_id = '$company_id' ORDER BY certificate_id LIMIT $limit OFFSET $offset");
+ $sql = mysqli_query($mysqli, "SELECT * FROM certificates WHERE certificate_client_id LIKE '$client_id' AND company_id = '$company_id' ORDER BY certificate_id LIMIT $limit OFFSET $offset");
}
// Output
diff --git a/api/v1/contacts/contact_model.php b/api/v1/contacts/contact_model.php
new file mode 100644
index 00000000..fb35f365
--- /dev/null
+++ b/api/v1/contacts/contact_model.php
@@ -0,0 +1,11 @@
+insert_id;
+// Default
+$insert_id = FALSE;
+
+if(!empty($name) && !empty($email) && !empty($client_id)){
+
+ // Check contact with $email doesn't already exist
+ $email_duplication_sql = mysqli_query($mysqli, "SELECT * FROM contacts WHERE contact_email = '$email' AND contact_client_id = '$client_id'");
+
+ if(mysqli_num_rows($email_duplication_sql) == 0){
+
+ // Insert contact
+ $insert_sql = mysqli_query($mysqli,"INSERT INTO contacts SET contact_name = '$name', contact_title = '$title', contact_phone = '$phone', contact_extension = '$extension', contact_mobile = '$mobile', contact_email = '$email', contact_notes = '$notes', contact_auth_method = '$auth_method', contact_created_at = NOW(), contact_department_id = $department, contact_location_id = $location_id, contact_client_id = $client_id, company_id = $company_id");
+
+ // Check insert & get insert ID
+ if($insert_sql){
+ $insert_id = mysqli_insert_id($mysqli);
+ //Logging
+ mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Contact', log_action = 'Created', log_description = '$name via API ($api_key_name)', log_ip = '$ip', log_created_at = NOW(), log_client_id = $client_id, company_id = $company_id");
+ mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'API', log_action = 'Success', log_description = 'Created contact $name via API ($api_key_name)', log_ip = '$ip', log_created_at = NOW(), log_client_id = $client_id, company_id = $company_id");
+ }
- //Logging
- mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Contact', log_action = 'Created', log_description = '$name via API ($api_key_name)', log_ip = '$ip', log_created_at = NOW(), company_id = $company_id");
- mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'API', log_action = 'Success', log_description = 'Created contact $name via API ($api_key_name)', log_ip = '$ip', log_created_at = NOW(), company_id = $company_id");
}
}
-else{
- $insert_id = FALSE;
-}
// Output
include('../create_output.php');
\ No newline at end of file
diff --git a/api/v1/contacts/read.php b/api/v1/contacts/read.php
index 72bf3314..2de010b5 100644
--- a/api/v1/contacts/read.php
+++ b/api/v1/contacts/read.php
@@ -6,18 +6,18 @@ require('../require_get_method.php');
// Specific contact via ID (single)
if(isset($_GET['contact_id'])){
$id = intval($_GET['contact_id']);
- $sql = mysqli_query($mysqli, "SELECT * FROM contacts WHERE contact_id = '$id' AND company_id = '$company_id'");
+ $sql = mysqli_query($mysqli, "SELECT * FROM contacts WHERE contact_id = '$id' AND contact_client_id LIKE '$client_id' AND company_id = '$company_id'");
}
// Specific contact via email (single)
elseif(isset($_GET['contact_email'])){
$email = trim(strip_tags(mysqli_real_escape_string($mysqli,$_GET['contact_email'])));
- $sql = mysqli_query($mysqli, "SELECT * FROM contacts WHERE contact_email = '$email' AND company_id = '$company_id'");
+ $sql = mysqli_query($mysqli, "SELECT * FROM contacts WHERE contact_email = '$email' AND contact_client_id LIKE '$client_id' AND company_id = '$company_id'");
}
// All contacts
else{
- $sql = mysqli_query($mysqli, "SELECT * FROM contacts WHERE company_id = '$company_id' ORDER BY contact_id LIMIT $limit OFFSET $offset");
+ $sql = mysqli_query($mysqli, "SELECT * FROM contacts WHERE contact_client_id LIKE '$client_id' AND company_id = '$company_id' ORDER BY contact_id LIMIT $limit OFFSET $offset");
}
// Output
diff --git a/api/v1/contacts/update.php b/api/v1/contacts/update.php
new file mode 100644
index 00000000..bf5c3152
--- /dev/null
+++ b/api/v1/contacts/update.php
@@ -0,0 +1,28 @@
+ 0){
}
else{
$return_arr['success'] = "False";
- $return_arr['message'] = "No resource (for this company) with the specified parameter(s).";
+ $return_arr['message'] = "No resource (for this client and company) with the specified parameter(s).";
echo json_encode($return_arr);
exit();
}
\ No newline at end of file
diff --git a/api/v1/require_get_method.php b/api/v1/require_get_method.php
index a6391c9f..4667bed7 100644
--- a/api/v1/require_get_method.php
+++ b/api/v1/require_get_method.php
@@ -5,4 +5,9 @@ if($_SERVER['REQUEST_METHOD'] !== "GET"){
$return_arr['message'] = "Can only send GET requests to this endpoint.";
echo json_encode($return_arr);
exit();
+}
+
+// Wildcard client ID for most SELECT queries
+if($client_id == 0){
+ $client_id = "%";
}
\ No newline at end of file
diff --git a/api/v1/require_post_method.php b/api/v1/require_post_method.php
new file mode 100644
index 00000000..cb13d64b
--- /dev/null
+++ b/api/v1/require_post_method.php
@@ -0,0 +1,15 @@
+ 0){
+ // Insert successful
+ $return_arr['success'] = "True";
+ $return_arr['count'] = $update_id;
+}
+
+// Query returned false: something went wrong, or it was declined due to required variables missing
+else{
+ $return_arr['success'] = "False";
+ $return_arr['message'] = "Auth success but update query failed/returned no results. Ensure ALL required variables are provided and database schema is up-to-date. Most likely cause: non-existent module (contact/ticket/etc) id";
+}
+
+echo json_encode($return_arr);
+exit();
\ No newline at end of file
diff --git a/api/v1/validate_api_key.php b/api/v1/validate_api_key.php
index 46ec587b..a026e42b 100644
--- a/api/v1/validate_api_key.php
+++ b/api/v1/validate_api_key.php
@@ -86,10 +86,11 @@ if(isset($api_key)){
// Success
else{
- // Set company ID & key name
+ // Set client ID, company ID & key name
$row = mysqli_fetch_array($sql);
- $company_id = $row['company_id'];
$api_key_name = $row['api_key_name'];
+ $client_id = $row['api_key_client_id'];
+ $company_id = $row['company_id'];
// Set limit & offset for queries
if(isset($_GET['limit'])){
diff --git a/api_key_add_modal.php b/api_key_add_modal.php
index e72ecc7f..a06dc3aa 100644
--- a/api_key_add_modal.php
+++ b/api_key_add_modal.php
@@ -1,3 +1,6 @@
+
- ">
+ ">
diff --git a/client_documents.php b/client_documents.php
index 7a3f797e..ef5f703c 100644
--- a/client_documents.php
+++ b/client_documents.php
@@ -1,12 +1,13 @@
$sb, 'o' => $o)));
@@ -26,15 +35,15 @@ $sql_no_tag = "SELECT SQL_CALC_FOUND_ROWS * FROM documents
WHERE document_client_id = $client_id
AND documents.company_id = $session_company_id
AND document_template = 0
- AND (document_name LIKE '%$q%' OR document_content LIKE '%$q%')
+ $query_snippet
ORDER BY $sb $o LIMIT $record_from, $record_to";
$sql_with_tag = "SELECT SQL_CALC_FOUND_ROWS * FROM documents
LEFT JOIN documents_tagged ON documents.document_id = documents_tagged.document_id
WHERE document_client_id = $client_id
- AND document_template = 0
AND documents.company_id = $session_company_id
- AND (document_name LIKE '%$q%' OR document_content LIKE '%$q%')
+ AND document_template = 0
+ $query_snippet
AND documents_tagged.tag_id LIKE '%$tag%'
ORDER BY $sb $o LIMIT $record_from, $record_to";
diff --git a/client_side_nav.php b/client_side_nav.php
index 269471fb..10699e48 100644
--- a/client_side_nav.php
+++ b/client_side_nav.php
@@ -228,7 +228,7 @@
- 2 AND $config_module_enable_accounting == 1){ ?>
+ 2 && $config_module_enable_accounting == 1){ ?>
diff --git a/clients.php b/clients.php
index 562fc091..f0ada755 100644
--- a/clients.php
+++ b/clients.php
@@ -167,7 +167,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
Name
Address
Contact
- Billing
+ Billing
Action
@@ -310,7 +310,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
-
+
Balance
diff --git a/cron.php b/cron.php
index 3a3dd061..03ebb6f0 100644
--- a/cron.php
+++ b/cron.php
@@ -201,13 +201,12 @@ while($row = mysqli_fetch_array($sql_companies)){
// Scheduled tickets
- // Get date now, and calculate tomorrow's date (presuming this is being run at 11 PM)
- $now = new DateTime();
- $tomorrow = date_add($now, date_interval_create_from_date_string('1 day'));
- $tomorrow_text = $tomorrow->format('Y-m-d');
+ // Get date for search
+ $today = new DateTime();
+ $today_text = $today->format('Y-m-d');
- // Get scheduled tickets for tomorrow
- $sql_scheduled_tickets = mysqli_query($mysqli, "SELECT * FROM scheduled_tickets WHERE scheduled_ticket_next_run = '$tomorrow_text'");
+ // Get scheduled tickets for today
+ $sql_scheduled_tickets = mysqli_query($mysqli, "SELECT * FROM scheduled_tickets WHERE scheduled_ticket_next_run = '$today_text'");
if(mysqli_num_rows($sql_scheduled_tickets) > 0){
while($row = mysqli_fetch_array($sql_scheduled_tickets)){
@@ -237,23 +236,23 @@ while($row = mysqli_fetch_array($sql_companies)){
if($frequency == "weekly"){
// Note: We seemingly have to initialize a new datetime for each loop to avoid stacking the dates
$now = new DateTime();
- $next_run = date_add($now, date_interval_create_from_date_string('1 week 1 day'));
+ $next_run = date_add($now, date_interval_create_from_date_string('1 week'));
}
elseif($frequency == "monthly"){
$now = new DateTime();
- $next_run = date_add($now, date_interval_create_from_date_string('1 month 1 day'));
+ $next_run = date_add($now, date_interval_create_from_date_string('1 month'));
}
elseif($frequency == "quarterly"){
$now = new DateTime();
- $next_run = date_add($now, date_interval_create_from_date_string('3 months 1 day'));
+ $next_run = date_add($now, date_interval_create_from_date_string('3 months'));
}
elseif($frequency == "biannually"){
$now = new DateTime();
- $next_run = date_add($now, date_interval_create_from_date_string('6 months 1 day'));
+ $next_run = date_add($now, date_interval_create_from_date_string('6 months'));
}
elseif($frequency == "annually"){
$now = new DateTime();
- $next_run = date_add($now, date_interval_create_from_date_string('12 months 1 day'));
+ $next_run = date_add($now, date_interval_create_from_date_string('12 months'));
}
// Update the run date
diff --git a/database_updates.php b/database_updates.php
index 7321ac76..2631bb5e 100644
--- a/database_updates.php
+++ b/database_updates.php
@@ -19,24 +19,46 @@ if(LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION){
if(CURRENT_DATABASE_VERSION == '0.0.1'){
// Insert queries here required to update to DB version 0.0.2
- // mysqli_query($mysqli, "ALTER TABLE .....");
+
mysqli_query($mysqli, "ALTER TABLE `settings` ADD `config_module_enable_itdoc` TINYINT(1) DEFAULT 1 AFTER `config_backup_path`");
mysqli_query($mysqli, "ALTER TABLE `settings` ADD `config_module_enable_ticketing` TINYINT(1) DEFAULT 1 AFTER `config_module_enable_itdoc`");
mysqli_query($mysqli, "ALTER TABLE `settings` ADD `config_module_enable_accounting` TINYINT(1) DEFAULT 1 AFTER `config_module_enable_ticketing`");
- // Then, update the database to the next sequential version
- //mysqli_query($mysqli, "UPDATE settings SET config_current_database_version = '0.0.2' WHERE company_id = '1'");
-
+ // Update the database to the next sequential version
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.0.2'");
}
if(CURRENT_DATABASE_VERSION == '0.0.2'){
// Insert queries here required to update to DB version 0.0.3
+
+ // Add document content raw column & index
+ mysqli_query($mysqli, "ALTER TABLE `documents` ADD `document_content_raw` LONGTEXT NOT NULL AFTER `document_content`, ADD FULLTEXT `document_content_raw` (`document_content_raw`)");
+
+ // Populate content raw column with existing document data
+ $documents_sql = mysqli_query($mysqli, "SELECT * FROM `documents`");
+ while($row = mysqli_fetch_array($documents_sql)){
+ $id = $row['document_id'];
+ $name = $row['document_name'];
+ $content = $row['document_content'];
+ $content_raw = trim(mysqli_real_escape_string($mysqli, strip_tags($name . " " . str_replace("<", " <", $content))));
+
+ mysqli_query($mysqli, "UPDATE `documents` SET `document_content_raw` = '$content_raw' WHERE `document_id` = '$id'");
+ }
+
+ // Add API key client column
+ mysqli_query($mysqli, "ALTER TABLE `api_keys` ADD `api_key_client_id` INT NOT NULL DEFAULT '0' AFTER `api_key_expire`");
+
+ // Then, update the database to the next sequential version
+ mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.0.3'");
+ }
+
+ if(CURRENT_DATABASE_VERSION == '0.0.3'){
+ // Insert queries here required to update to DB version 0.0.4
// mysqli_query($mysqli, "ALTER TABLE .....");
// Then, update the database to the next sequential version
- //mysqli_query($mysqli, "UPDATE settings SET config_current_database_version = '0.0.3' WHERE company_id = '1'");
+ //mysqli_query($mysqli, "UPDATE settings SET config_current_database_version = '0.0.3'");
}
diff --git a/database_version.php b/database_version.php
index f0f59d6c..e0581015 100644
--- a/database_version.php
+++ b/database_version.php
@@ -5,4 +5,4 @@
* It is used in conjunction with database_updates.php
*/
-DEFINE("LATEST_DATABASE_VERSION", "0.0.2");
\ No newline at end of file
+DEFINE("LATEST_DATABASE_VERSION", "0.0.3");
\ No newline at end of file
diff --git a/db.sql b/db.sql
index 6c02b03b..88a7b977 100644
--- a/db.sql
+++ b/db.sql
@@ -50,6 +50,7 @@ CREATE TABLE `api_keys` (
`api_key_created_at` datetime NOT NULL,
`api_key_updated_at` datetime DEFAULT NULL,
`api_key_expire` date NOT NULL,
+ `api_key_client_id` int(11) NOT NULL DEFAULT '0',
`company_id` int(11) NOT NULL,
PRIMARY KEY (`api_key_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -397,6 +398,7 @@ CREATE TABLE `documents` (
`document_id` int(11) NOT NULL AUTO_INCREMENT,
`document_name` varchar(200) NOT NULL,
`document_content` longtext NOT NULL,
+ `document_content_raw` longtext NOT NULL,
`document_created_at` datetime NOT NULL,
`document_updated_at` datetime DEFAULT NULL,
`document_archived_at` datetime DEFAULT NULL,
@@ -409,6 +411,11 @@ CREATE TABLE `documents` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Indexes for table `documents`
+--
+ALTER TABLE `documents` ADD FULLTEXT KEY `document_content_raw` (`document_content_raw`);
+
--
-- Table structure for table `documents_tagged`
--
diff --git a/global_search.php b/global_search.php
index 259173cf..4d012d43 100644
--- a/global_search.php
+++ b/global_search.php
@@ -15,7 +15,7 @@ if(isset($_GET['query'])){
$sql_contacts = mysqli_query($mysqli,"SELECT * FROM contacts LEFT JOIN clients ON client_id = contact_client_id LEFT JOIN departments ON contact_department_id = department_id WHERE (contact_name LIKE '%$query%' OR contact_title LIKE '%$query%' OR contact_email LIKE '%$query%' OR contact_phone LIKE '%$phone_query%' OR contact_mobile LIKE '%$phone_query%') AND contacts.company_id = $session_company_id ORDER BY contact_id DESC LIMIT 5");
$sql_vendors = mysqli_query($mysqli,"SELECT * FROM vendors WHERE (vendor_name LIKE '%$query%' OR vendor_phone LIKE '%$phone_query%') AND company_id = $session_company_id ORDER BY vendor_id DESC LIMIT 5");
$sql_products = mysqli_query($mysqli,"SELECT * FROM products WHERE product_name LIKE '%$query%' AND company_id = $session_company_id ORDER BY product_id DESC LIMIT 5");
- $sql_documents = mysqli_query($mysqli, "SELECT * FROM documents LEFT JOIN clients on document_client_id = clients.client_id WHERE document_name LIKE '%$query%' AND documents.company_id = $session_company_id ORDER BY document_id DESC LIMIT 5");
+ $sql_documents = mysqli_query($mysqli, "SELECT * FROM documents LEFT JOIN clients on document_client_id = clients.client_id WHERE MATCH(document_content_raw) AGAINST ('$query') AND documents.company_id = $session_company_id ORDER BY document_id DESC LIMIT 5");
$sql_tickets = mysqli_query($mysqli, "SELECT * FROM tickets LEFT JOIN clients on tickets.ticket_client_id = clients.client_id WHERE (ticket_subject LIKE '%$query%' OR ticket_number = '$query') AND tickets.company_id = $session_company_id ORDER BY ticket_id DESC LIMIT 5");
$sql_logins = mysqli_query($mysqli,"SELECT * FROM logins WHERE (login_name LIKE '%$query%' OR login_username LIKE '%$query%') AND company_id = $session_company_id ORDER BY login_id DESC LIMIT 5");
diff --git a/login.php b/login.php
index eeaabc52..38599ab5 100644
--- a/login.php
+++ b/login.php
@@ -8,17 +8,13 @@ if(!file_exists('config.php')){
include("config.php");
include("functions.php");
-//SESSION FINGERPRINT
+// SESSION FINGERPRINT
$ip = strip_tags(mysqli_real_escape_string($mysqli,get_ip()));
-//$os = strip_tags(mysqli_real_escape_string($mysqli,get_os()));
-//$browser = strip_tags(mysqli_real_escape_string($mysqli,get_web_browser()));
-//$device = strip_tags(mysqli_real_escape_string($mysqli,get_device()));
+$os = strip_tags(mysqli_real_escape_string($mysqli,get_os()));
-//$user_agent = "$os - $browser";
-// Get user agent
+// User agent
$user_agent = strip_tags(mysqli_real_escape_string($mysqli,$_SERVER['HTTP_USER_AGENT']));
-
// HTTP Only cookies
ini_set("session.cookie_httponly", True);
@@ -59,7 +55,7 @@ if(isset($_POST['login'])){
if(isset($_POST['current_code'])){
$current_code = strip_tags(mysqli_real_escape_string($mysqli, $_POST['current_code']));
}
- $sql = mysqli_query($mysqli, "SELECT * FROM users WHERE user_email = '$email'");
+ $sql = mysqli_query($mysqli, "SELECT * FROM users WHERE user_email = '$email' AND user_archived_at IS NULL");
$row = mysqli_fetch_array($sql);
if (password_verify($password, $row['user_password'])) {
diff --git a/pagination_head.php b/pagination_head.php
index ac4a8bfd..742f1689 100644
--- a/pagination_head.php
+++ b/pagination_head.php
@@ -34,7 +34,7 @@ if(isset($_GET['o'])){
// Search
if(isset($_GET['q'])){
- $q = mysqli_real_escape_string($mysqli,$_GET['q']);
+ $q = mysqli_real_escape_string($mysqli,trim($_GET['q']));
}else{
$q = "";
}
\ No newline at end of file
diff --git a/post.php b/post.php
index 0432295e..eaef7e1f 100644
--- a/post.php
+++ b/post.php
@@ -53,7 +53,7 @@ if(isset($_POST['add_user'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -135,7 +135,7 @@ if(isset($_POST['edit_user'])){
if($session_user_role != 3 && $_POST['user_id'] !== $session_user_id){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -231,6 +231,13 @@ if(isset($_POST['edit_user'])){
if(isset($_POST['edit_profile'])){
+ if($session_user_role != 3 && $_POST['user_id'] !== $session_user_id){
+ $_SESSION['alert_type'] = "danger";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
+ header("Location: " . $_SERVER["HTTP_REFERER"]);
+ exit();
+ }
+
$user_id = intval($_POST['user_id']);
$name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])));
$email = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['email'])));
@@ -330,6 +337,13 @@ if(isset($_POST['edit_profile'])){
if(isset($_POST['edit_user_companies'])){
+ if($session_user_role != 3){
+ $_SESSION['alert_type'] = "danger";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
+ header("Location: " . $_SERVER["HTTP_REFERER"]);
+ exit();
+ }
+
$user_id = intval($_POST['user_id']);
mysqli_query($mysqli,"DELETE FROM user_companies WHERE user_id = $user_id");
@@ -356,77 +370,49 @@ if(isset($_GET['archive_user'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
+ // Variables from GET
$user_id = intval($_GET['archive_user']);
+ $password = password_hash(key32gen(), PASSWORD_DEFAULT);
- mysqli_query($mysqli,"UPDATE users SET user_archived_at = NOW() WHERE user_id = $user_id");
-
- //Logging
- //Get User Name
+ // Get user details
$sql = mysqli_query($mysqli,"SELECT * FROM users WHERE user_id = $user_id");
$row = mysqli_fetch_array($sql);
$name = $row['user_name'];
+
+ // Archive user query
+ mysqli_query($mysqli,"UPDATE users SET user_name = '$name (archived)', user_password = '$password', user_specific_encryption_ciphertext = '', user_archived_at = NOW() WHERE user_id = $user_id");
+
+ // Logging
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'User', log_action = 'Archive', log_description = '$session_name archived user $name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_created_at = NOW(), log_user_id = $session_user_id, company_id = $session_company_id");
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "$name archived";
+ $_SESSION['alert_message'] = "User $name archived";
header("Location: users.php");
}
-if(isset($_GET['delete_user'])){
-
- if($session_user_role != 3){
- $_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
- header("Location: " . $_SERVER["HTTP_REFERER"]);
- exit();
- }
-
- $user_id = intval($_GET['delete_user']);
-
- mysqli_query($mysqli,"DELETE FROM users WHERE user_id = $user_id");
- mysqli_query($mysqli,"DELETE FROM user_settings WHERE user_id = $user_id");
- mysqli_query($mysqli,"DELETE FROM logs WHERE log_user_id = $user_id");
- mysqli_query($mysqli,"DELETE FROM tickets WHERE ticket_created_by = $user_id");
- mysqli_query($mysqli,"DELETE FROM tickets WHERE ticket_closed_by = $user_id");
- mysqli_query($mysqli,"DELETE FROM ticket_replies WHERE ticket_reply_by = $user_id");
- mysqli_query($mysqli,"DELETE FROM user_companies WHERE user_id = $user_id");
-
- //Logging
- //Get User Name
- $sql = mysqli_query($mysqli,"SELECT * FROM users WHERE user_id = $user_id");
- $row = mysqli_fetch_array($sql);
- $name = $row['user_name'];
- mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'User', log_action = 'Delete', log_description = '$session_name deleted user $name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_created_at = NOW(), log_user_id = $session_user_id, company_id = $session_company_id");
-
- $_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "User $name deleted";
-
- header("Location: " . $_SERVER["HTTP_REFERER"]);
-
-}
// API Key
if(isset($_POST['add_api_key'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
+ $secret = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['key'])));
$name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])));
$expire = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['expire'])));
- // Gen a Key
- $secret = keygen();
+ $client = intval($_POST['client']);
- mysqli_query($mysqli,"INSERT INTO api_keys SET api_key_name = '$name', api_key_secret = '$secret', api_key_expire = '$expire', api_key_created_at = NOW(), company_id = $session_company_id");
+ mysqli_query($mysqli,"INSERT INTO api_keys SET api_key_name = '$name', api_key_secret = '$secret', api_key_expire = '$expire', api_key_client_id = '$client', api_key_created_at = NOW(), company_id = $session_company_id");
$api_key_id = mysqli_insert_id($mysqli);
@@ -443,7 +429,7 @@ if(isset($_POST['edit_api_key'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -467,7 +453,7 @@ if(isset($_GET['delete_api_key'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -495,7 +481,7 @@ if(isset($_POST['add_company'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -601,7 +587,7 @@ if(isset($_POST['edit_company'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -704,7 +690,7 @@ if(isset($_GET['delete_company'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -798,7 +784,7 @@ if(isset($_POST['edit_general_settings'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -820,7 +806,7 @@ if(isset($_POST['edit_mail_settings'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -874,7 +860,7 @@ if(isset($_POST['test_email'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -918,7 +904,7 @@ if(isset($_POST['edit_invoice_settings'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -947,7 +933,7 @@ if(isset($_POST['edit_quote_settings'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -973,7 +959,7 @@ if(isset($_POST['edit_ticket_settings'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -998,7 +984,7 @@ if(isset($_POST['edit_default_settings'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -1026,7 +1012,7 @@ if(isset($_POST['edit_alert_settings'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -1051,7 +1037,7 @@ if(isset($_POST['edit_online_payment_settings'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -1074,7 +1060,7 @@ if(isset($_POST['edit_integrations_settings'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -1100,7 +1086,7 @@ if(isset($_POST['edit_backup_settings'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -1123,7 +1109,7 @@ if(isset($_POST['edit_module_settings'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -1175,7 +1161,7 @@ if(isset($_GET['download_database'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -1260,7 +1246,7 @@ if(isset($_POST['backup_master_key'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -1297,7 +1283,7 @@ if(isset($_GET['update'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -1325,7 +1311,7 @@ if(isset($_GET['update_db'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -1348,7 +1334,7 @@ if(isset($_POST['add_client'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -1430,7 +1416,7 @@ if(isset($_POST['edit_client'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -1469,7 +1455,7 @@ if(isset($_GET['delete_client'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -4193,7 +4179,7 @@ if(isset($_POST['add_contact'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -4280,7 +4266,7 @@ if(isset($_POST['edit_contact'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -4376,7 +4362,7 @@ if(isset($_GET['archive_contact'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -4398,7 +4384,7 @@ if(isset($_GET['delete_contact'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -4462,7 +4448,7 @@ if(isset($_POST['add_location'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -4548,7 +4534,7 @@ if(isset($_POST['edit_location'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -4638,7 +4624,7 @@ if(isset($_GET['delete_location'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -4703,7 +4689,7 @@ if(isset($_POST['add_department'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -4716,7 +4702,7 @@ if(isset($_POST['add_department'])){
$contact_id = mysqli_insert_id($mysqli);
//Logging
- mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Department', log_action = 'Create', log_description = '$department_name', log_created_at = NOW(), company_id = $session_company_id, log_client_id = $client_id, log_user_id = $session_user_id");
+ mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Department', log_action = 'Create', log_description = '$department_name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_created_at = NOW(), company_id = $session_company_id, log_client_id = $client_id, log_user_id = $session_user_id");
$_SESSION['alert_message'] .= "Department added";
@@ -4728,7 +4714,7 @@ if(isset($_POST['edit_department'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -4740,7 +4726,7 @@ if(isset($_POST['edit_department'])){
mysqli_query($mysqli,"UPDATE departments SET department_name = '$department_name', department_updated_at = NOW() WHERE department_id = $department_id AND company_id = $session_company_id");
//Logging
- mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Department', log_action = 'Modify', log_description = '$department_name', log_created_at = NOW(), log_client_id = $client_id, log_user_id = $session_user_id, company_id = $session_company_id");
+ mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Department', log_action = 'Modify', log_description = '$department_name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_created_at = NOW(), log_client_id = $client_id, log_user_id = $session_user_id, company_id = $session_company_id");
$_SESSION['alert_message'] .= "Department updated";
@@ -4752,7 +4738,7 @@ if(isset($_GET['archive_department'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -4762,7 +4748,7 @@ if(isset($_GET['archive_department'])){
mysqli_query($mysqli,"UPDATE departments SET department_archived_at = NOW() WHERE department_id = $department_id");
//logging
- mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Department', log_action = 'Archive', log_description = '$department_id', log_created_at = NOW(), log_user_id = $session_user_id, company_id = $session_company_id");
+ mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Department', log_action = 'Archive', log_description = '$department_id', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_created_at = NOW(), log_user_id = $session_user_id, company_id = $session_company_id");
$_SESSION['alert_message'] = "Department Archived!";
@@ -4774,7 +4760,7 @@ if(isset($_GET['delete_department'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -4796,7 +4782,7 @@ if(isset($_POST['add_asset'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -4852,7 +4838,7 @@ if(isset($_POST['edit_asset'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -4915,7 +4901,7 @@ if(isset($_GET['delete_asset'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -4937,7 +4923,7 @@ if(isset($_POST["import_client_assets_csv"])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -5074,7 +5060,7 @@ if(isset($_GET['export_client_assets_csv'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -5123,7 +5109,7 @@ if(isset($_POST['add_software'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -5187,7 +5173,7 @@ if(isset($_POST['edit_software'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -5258,7 +5244,7 @@ if(isset($_GET['delete_software'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -5284,7 +5270,7 @@ if(isset($_GET['export_client_software_csv'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -5333,7 +5319,7 @@ if(isset($_POST['add_login'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -5365,7 +5351,7 @@ if(isset($_POST['edit_login'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -5397,7 +5383,7 @@ if(isset($_GET['delete_login'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -5419,7 +5405,7 @@ if(isset($_GET['export_client_logins_csv'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -5469,7 +5455,7 @@ if(isset($_POST['add_network'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -5497,7 +5483,7 @@ if(isset($_POST['edit_network'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -5524,7 +5510,7 @@ if(isset($_POST['edit_network'])){
if(isset($_GET['delete_network'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -5546,7 +5532,7 @@ if(isset($_GET['export_client_networks_csv'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -5595,7 +5581,7 @@ if(isset($_POST['add_certificate'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -5637,7 +5623,7 @@ if(isset($_POST['edit_certificate'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -5679,7 +5665,7 @@ if(isset($_GET['delete_certificate'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -5701,7 +5687,7 @@ if(isset($_GET['export_client_certificates_csv'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -5750,7 +5736,7 @@ if(isset($_POST['add_domain'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -5827,7 +5813,7 @@ if(isset($_POST['edit_domain'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -5872,7 +5858,7 @@ if(isset($_GET['delete_domain'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -5894,7 +5880,7 @@ if(isset($_GET['export_client_domains_csv'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -5944,7 +5930,7 @@ if(isset($_POST['add_ticket'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -5975,13 +5961,14 @@ if(isset($_POST['add_ticket'])){
mysqli_query($mysqli,"UPDATE settings SET config_ticket_next_number = $new_config_ticket_next_number WHERE company_id = $session_company_id");
mysqli_query($mysqli,"INSERT INTO tickets SET ticket_prefix = '$config_ticket_prefix', ticket_number = $ticket_number, ticket_subject = '$subject', ticket_details = '$details', ticket_priority = '$priority', ticket_status = 'Open', ticket_asset_id = $asset_id, ticket_created_at = NOW(), ticket_created_by = $session_user_id, ticket_assigned_to = $assigned_to, ticket_contact_id = $contact, ticket_client_id = $client_id, company_id = $session_company_id");
+ $id = mysqli_insert_id($mysqli);
//Logging
- mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Ticket', log_action = 'Create', log_description = '$session_name created ticket $subject', log_created_at = NOW(), log_client_id = $client_id, company_id = $session_company_id, log_user_id = $session_user_id");
+ mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Ticket', log_action = 'Create', log_description = '$session_name created ticket $subject', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_created_at = NOW(), log_client_id = $client_id, company_id = $session_company_id, log_user_id = $session_user_id");
$_SESSION['alert_message'] = "Ticket created";
-
- header("Location: " . $_SERVER["HTTP_REFERER"]);
+
+ header("Location: ticket.php?ticket_id=" . $id);
}
@@ -5989,7 +5976,7 @@ if(isset($_POST['add_scheduled_ticket'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -6019,7 +6006,7 @@ if(isset($_POST['add_scheduled_ticket'])){
mysqli_query($mysqli, "INSERT INTO scheduled_tickets SET scheduled_ticket_subject = '$subject', scheduled_ticket_details = '$details', scheduled_ticket_priority = '$priority', scheduled_ticket_frequency = '$frequency', scheduled_ticket_start_date = '$start_date', scheduled_ticket_next_run = '$start_date', scheduled_ticket_created_at = NOW(), scheduled_ticket_created_by = '$session_user_id', scheduled_ticket_client_id = '$client_id', scheduled_ticket_contact_id = '$contact', scheduled_ticket_asset_id = '$asset_id', company_id = '$session_company_id'");
//Logging
- mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Ticket', log_action = 'Create', log_description = 'Created scheduled ticket for $subject - $frequency', log_created_at = NOW(), log_client_id = $client_id, company_id = $session_company_id, log_user_id = $session_user_id");
+ mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Ticket', log_action = 'Create', log_description = 'Created scheduled ticket for $subject - $frequency', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_created_at = NOW(), log_client_id = $client_id, company_id = $session_company_id, log_user_id = $session_user_id");
$_SESSION['alert_message'] = "Scheduled ticket created.";
@@ -6031,7 +6018,7 @@ if(isset($_POST['edit_scheduled_ticket'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -6067,7 +6054,7 @@ if(isset($_GET['delete_scheduled_ticket'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -6089,7 +6076,7 @@ if(isset($_POST['edit_ticket'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -6124,7 +6111,7 @@ if(isset($_POST['assign_ticket'])){
// Role check
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -6175,7 +6162,7 @@ if(isset($_GET['delete_ticket'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -6197,7 +6184,7 @@ if(isset($_POST['add_ticket_reply'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -6291,7 +6278,7 @@ if(isset($_POST['edit_ticket_reply'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -6320,7 +6307,7 @@ if(isset($_GET['archive_ticket_reply'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -6342,7 +6329,7 @@ if(isset($_POST['merge_ticket'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -6400,7 +6387,7 @@ if(isset($_GET['close_ticket'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -6519,7 +6506,7 @@ if(isset($_GET['export_client_tickets_csv'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -6568,7 +6555,7 @@ if(isset($_POST['add_service'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -6675,7 +6662,7 @@ if(isset($_POST['edit_service'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -6784,7 +6771,7 @@ if(isset($_GET['delete_service'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -6882,7 +6869,7 @@ if(isset($_GET['delete_file'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -6912,7 +6899,7 @@ if(isset($_POST['add_document'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -6927,11 +6914,13 @@ if(isset($_POST['add_document'])){
$name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])));
$tags_ids = $_POST['tags_ids'];
$content = trim(mysqli_real_escape_string($mysqli,$purifier->purify(html_entity_decode($_POST['content']))));
+ $content_raw = trim(mysqli_real_escape_string($mysqli, strip_tags($_POST['name'] . " " . str_replace("<", " <", $_POST['content']))));
+ // Content Raw is used for FULL INDEX searching. Adding a space before HTML tags to allow spaces between newlines, bulletpoints, etc. for searching.
$template = intval($_POST['template']);
$folder = intval($_POST['folder']);
// Document add query
- $add_document = mysqli_query($mysqli,"INSERT INTO documents SET document_name = '$name', document_content = '$content', document_created_at = NOW(), document_template = $template, document_folder_id = $folder, document_client_id = $client_id, company_id = $session_company_id");
+ $add_document = mysqli_query($mysqli,"INSERT INTO documents SET document_name = '$name', document_content = '$content', document_content_raw = '$content_raw', document_created_at = NOW(), document_template = $template, document_folder_id = $folder, document_client_id = $client_id, company_id = $session_company_id");
$document_id = $mysqli->insert_id;
// Logging
@@ -6955,7 +6944,7 @@ if(isset($_POST['edit_document'])){
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -6970,11 +6959,13 @@ if(isset($_POST['edit_document'])){
$name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])));
$tags_ids = $_POST['tags_ids'];
$content = trim(mysqli_real_escape_string($mysqli,$purifier->purify(html_entity_decode($_POST['content']))));
+ $content_raw = trim(mysqli_real_escape_string($mysqli, strip_tags($_POST['name'] . " " . str_replace("<", " <", $_POST['content']))));
+ // Content Raw is used for FULL INDEX searching. Adding a space before HTML tags to allow spaces between newlines, bulletpoints, etc. for searching.
$template = intval($_POST['template']);
$folder = intval($_POST['folder']);
// Document edit query
- mysqli_query($mysqli,"UPDATE documents SET document_name = '$name', document_content = '$content', document_updated_at = NOW(), document_template = $template, document_folder_id = $folder WHERE document_id = $document_id AND company_id = $session_company_id");
+ mysqli_query($mysqli,"UPDATE documents SET document_name = '$name', document_content = '$content', document_content_raw = '$content_raw', document_updated_at = NOW(), document_template = $template, document_folder_id = $folder WHERE document_id = $document_id AND company_id = $session_company_id");
//Logging
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Note', log_action = 'Modify', log_description = '$name', log_created_at = NOW(), company_id = $session_company_id, log_user_id = $session_user_id");
@@ -7000,7 +6991,7 @@ if(isset($_GET['delete_document'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -7025,7 +7016,7 @@ if (isset($_POST['add_document_tag'])) {
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -7043,7 +7034,7 @@ if (isset($_POST['delete_document_tag'])) {
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -7064,7 +7055,7 @@ if (isset($_POST['rename_document_tag'])) {
if($session_user_role == 1){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -7083,7 +7074,7 @@ if (isset($_POST['rename_document_tag'])) {
if(isset($_GET['deactivate_shared_item'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
@@ -7516,7 +7507,7 @@ if(isset($_GET['export_client_pdf'])){
if($session_user_role != 3){
$_SESSION['alert_type'] = "danger";
- $_SESSION['alert_message'] = "You are not permitted to do that!";
+ $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}
diff --git a/settings-api.php b/settings-api.php
index e3af4810..0375ae15 100644
--- a/settings-api.php
+++ b/settings-api.php
@@ -10,8 +10,9 @@
$url_query_strings_sb = http_build_query(array_merge($_GET,array('sb' => $sb, 'o' => $o)));
$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM api_keys
+ LEFT JOIN clients on api_keys.api_key_client_id = clients.client_id
WHERE (api_key_name LIKE '%$q%')
- AND company_id = $session_company_id
+ AND api_keys.company_id = $session_company_id
ORDER BY $sb $o LIMIT $record_from, $record_to");
$num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
@@ -40,6 +41,7 @@
">
Name
+ Client
Secret
Created
Expire
@@ -52,15 +54,24 @@
while($row = mysqli_fetch_array($sql)){
$api_key_id = $row['api_key_id'];
$api_key_name = $row['api_key_name'];
- $api_key_secret = $row['api_key_secret'];
+ $api_key_secret = "************" . substr($row['api_key_secret'], -4);
$api_key_created_at = $row['api_key_created_at'];
$api_key_expire = $row['api_key_expire'];
+ if($api_key_expire < date("Y-m-d H:i:s")){
+ $api_key_expire = $api_key_expire . " (Expired)";
+ }
+
+ if($row['api_key_client_id'] == 0){
+ $api_key_client = "All Clients ";
+ }
+ else{
+ $api_key_client = $row['client_name'];
+ }
?>
-
-
-
+
+
@@ -70,17 +81,13 @@
value="1" id="customSwitch1">
- Enable IT Documentation
+ Show IT Documentation
value="1" id="customSwitch2">
- Enable Ticketing
+ Show Ticketing
value="1" id="customSwitch3">
- Enable Invoicing / Accounting
+ Show Invoicing / Accounting
diff --git a/ticket.php b/ticket.php
index d7152550..656bd826 100644
--- a/ticket.php
+++ b/ticket.php
@@ -440,7 +440,7 @@ if(isset($_GET['ticket_id'])){
$row = mysqli_fetch_array($sql_closed_by);
$ticket_closed_by_display = $row['user_name'];
?>
- Closed by:
+ Closed by:
Feedback:
@@ -599,7 +599,7 @@ if(isset($_GET['ticket_id'])){
include("ticket_edit_modal.php");
include("ticket_merge_modal.php");
include("ticket_invoice_add_modal.php");
- include("ticket_invoice_existing_add_modal.php");
+ //include("ticket_invoice_existing_add_modal.php");
?>
" tabindex="-1">
+
+
+
+
+
+
Are you sure?
+
Do you really want to archive ? This process cannot be undone.
+
will no longer be able to login or use ITFlow, but all associated content will remain accessible.
+
Cancel
+
Yes, archive!
+
+
+
+
+
\ No newline at end of file
diff --git a/users.php b/users.php
index 51dd8f84..cd60c733 100644
--- a/users.php
+++ b/users.php
@@ -12,6 +12,7 @@
$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM users, user_settings
WHERE users.user_id = user_settings.user_id
AND (user_name LIKE '%$q%' OR user_email LIKE '%$q%')
+ AND user_archived_at IS NULL
ORDER BY $sb $o LIMIT $record_from, $record_to");
$num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
@@ -119,7 +120,7 @@
Company Access
- Archive
+ Archive
@@ -129,6 +130,7 @@
include("user_edit_modal.php");
include("user_companies_modal.php");
+ include("user_archive_modal.php");
}