diff --git a/cron.php b/cron.php index d6d627f7..b79bff18 100644 --- a/cron.php +++ b/cron.php @@ -35,8 +35,6 @@ while($row = mysqli_fetch_array($sql_companies)){ $config_mail_from_name = $row['config_mail_from_name']; $config_recurring_auto_send_invoice = $row['config_recurring_auto_send_invoice']; $config_base_url = $row['config_base_url']; - $config_backup_enable = $row['config_backup_enable']; - $config_backup_path = $row['config_backup_path']; // Tickets $config_ticket_prefix = $row['config_ticket_prefix']; @@ -50,77 +48,6 @@ while($row = mysqli_fetch_array($sql_companies)){ //Logging mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Cron', log_action = 'Started', log_description = 'Cron started for $company_name', company_id = $company_id"); - if($config_backup_enable == 1){ - // DATABASE BACKUP - // This needs to be set to the full file system path or else when cron runs php it will break cron.php and cron will not run properly - //$backup_dir = "backups/"; - $backup_dir = "$config_backup_path/"; - - // Get All Table Names From the Database - $tables = array(); - $sql = "SHOW TABLES"; - $result = mysqli_query($mysqli, $sql); - while ($row = mysqli_fetch_row($result)) { - $tables[] = $row[0]; - } - - $sqlScript = ""; - foreach ($tables as $table) { - - // Prepare SQLscript for creating table structure - $query = "SHOW CREATE TABLE $table"; - $result = mysqli_query($mysqli, $query); - $row = mysqli_fetch_row($result); - - $sqlScript .= "\n\n" . $row[1] . ";\n\n"; - - $query = "SELECT * FROM $table"; - $result = mysqli_query($mysqli, $query); - - $columnCount = mysqli_num_fields($result); - - // Prepare SQLscript for dumping data for each table - for ($i = 0; $i < $columnCount; $i ++) { - while ($row = mysqli_fetch_row($result)) { - $sqlScript .= "INSERT INTO $table VALUES("; - for ($j = 0; $j < $columnCount; $j ++) { - - if (isset($row[$j])) { - $sqlScript .= '"' . $row[$j] . '"'; - } else { - $sqlScript .= '""'; - } - if ($j < ($columnCount - 1)) { - $sqlScript .= ','; - } - } - $sqlScript .= ");\n"; - } - } - $sqlScript .= "\n"; - } - - // Save the SQL script to a backup file - if(!empty($sqlScript)) { - $random_string = key32gen(); - if(!empty($random_string)){ - $backup_file_name = date('Y-m-d') . '_backup__' . $random_string . '.sql'; - $fileHandler = fopen($backup_dir . '/' .$backup_file_name, 'w+'); - $number_of_lines = fwrite($fileHandler, $sqlScript); - fclose($fileHandler); - } - } - - // Delete backups older than 30 days - $now = time(); - foreach (glob($backup_dir."*.sql") as $file) { - if(time() - filectime($file) > 2592000){ - unlink($file); - } - } - - } - // GET NOTIFICATIONS // DOMAINS EXPIRING diff --git a/database_updates.php b/database_updates.php index 54abcec3..054760b1 100644 --- a/database_updates.php +++ b/database_updates.php @@ -300,18 +300,27 @@ if(LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION){ } if(CURRENT_DATABASE_VERSION == '0.1.6'){ - // Insert queries here required to update to DB version 0.1.7 + // Insert queries here required to update to DB version 0.1.7 //Remove custom links mysqli_query($mysqli, "DROP TABLE custom_links"); - // Then, update the database to the next sequential version - mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.1.7'"); + // Then, update the database to the next sequential version + mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.1.7'"); } - //if(CURRENT_DATABASE_VERSION == '0.1.7'){ + if(CURRENT_DATABASE_VERSION == '0.1.7'){ // Insert queries here required to update to DB version 0.1.8 + mysqli_query($mysqli, "ALTER TABLE `settings` DROP `config_backup_enable`"); + mysqli_query($mysqli, "ALTER TABLE `settings` DROP `config_backup_path`"); // Then, update the database to the next sequential version - // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.1.8'"); + mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.1.8'"); + } + + //if(CURRENT_DATABASE_VERSION == '0.1.8'){ + // Insert queries here required to update to DB version 0.1.9 + + // Then, update the database to the next sequential version + // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.1.9'"); //} } diff --git a/database_version.php b/database_version.php index f69e4149..be61bdaa 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.1.7"); \ No newline at end of file +DEFINE("LATEST_DATABASE_VERSION", "0.1.8"); \ No newline at end of file diff --git a/db.sql b/db.sql index e0b2f171..b9a66ff5 100644 --- a/db.sql +++ b/db.sql @@ -339,25 +339,6 @@ CREATE TABLE `contacts` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `custom_links` --- - -DROP TABLE IF EXISTS `custom_links`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `custom_links` ( - `custom_link_id` int(11) NOT NULL AUTO_INCREMENT, - `custom_link_name` varchar(250) NOT NULL, - `custom_link_icon` varchar(100) DEFAULT NULL, - `custom_link_url` varchar(250) NOT NULL, - `custom_link_order` int(11) DEFAULT NULL, - `custom_link_created_at` datetime NOT NULL DEFAULT current_timestamp(), - `company_id` int(11) NOT NULL, - PRIMARY KEY (`custom_link_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `documents` -- @@ -1052,8 +1033,6 @@ CREATE TABLE `settings` ( `config_stripe_secret` varchar(255) DEFAULT NULL, `config_azure_client_id` varchar(200) DEFAULT NULL, `config_azure_client_secret` varchar(200) DEFAULT NULL, - `config_backup_enable` tinyint(1) NOT NULL DEFAULT 0, - `config_backup_path` varchar(250) DEFAULT NULL, `config_module_enable_itdoc` tinyint(1) NOT NULL DEFAULT 1, `config_module_enable_accounting` tinyint(1) NOT NULL DEFAULT 1, `config_module_enable_ticketing` tinyint(1) NOT NULL DEFAULT 1, @@ -1494,4 +1473,4 @@ CREATE TABLE `vendors` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-09-17 16:34:13 +-- Dump completed on 2022-09-17 17:15:06 diff --git a/get_settings.php b/get_settings.php index 3b256200..b62b314f 100644 --- a/get_settings.php +++ b/get_settings.php @@ -70,10 +70,6 @@ $config_stripe_enable = $row['config_stripe_enable']; $config_stripe_publishable = $row['config_stripe_publishable']; $config_stripe_secret = $row['config_stripe_secret']; -// Backups -$config_backup_enable = $row['config_backup_enable']; -$config_backup_path = $row['config_backup_path']; - // Modules $config_module_enable_itdoc = $row['config_module_enable_itdoc']; $config_module_enable_ticketing = $row['config_module_enable_ticketing']; diff --git a/post.php b/post.php index 3e9d00d5..8038cde6 100644 --- a/post.php +++ b/post.php @@ -1053,24 +1053,6 @@ if(isset($_POST['edit_integrations_settings'])){ } -if(isset($_POST['edit_backup_settings'])){ - - validateAdminRole(); - - $config_backup_enable = intval($_POST['config_backup_enable']); - $config_backup_path = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_backup_path']))); - - mysqli_query($mysqli,"UPDATE settings SET config_backup_enable = $config_backup_enable, config_backup_path = '$config_backup_path' WHERE company_id = $session_company_id"); - - //Logging - mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Settings', log_action = 'Modify', log_description = '$session_name modified backup settings', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id, company_id = $session_company_id"); - - $_SESSION['alert_message'] = "Backup Settings updated"; - - header("Location: " . $_SERVER["HTTP_REFERER"]); - -} - if(isset($_POST['edit_module_settings'])){ validateAdminRole(); diff --git a/settings-backup.php b/settings-backup.php index cb356df1..5996bb38 100644 --- a/settings-backup.php +++ b/settings-backup.php @@ -1,42 +1,12 @@ -