Change to PHP Default tmp Path for checking DB changes on update. This prevents data being written to a common /tmp path on shared hosting environments

This commit is contained in:
johnnyq 2022-03-27 14:54:13 -04:00
parent 974cac0e86
commit ee97c479bf
2 changed files with 8 additions and 6 deletions

View File

@ -15,8 +15,8 @@
<?php
$fmt = numfmt_create( 'us_EN', NumberFormatter::CURRENCY );
echo numfmt_format_currency($fmt, -199.99, "USD")."\n";
$temp_path = sys_get_temp_dir() . "/file.txt";
echo $temp_path."\n";
?>

View File

@ -59,15 +59,17 @@ $git_log = shell_exec("git log master..origin/master --pretty=format:'<tr><td>%h
// Display a diff between the current DB structure and the latest DB structure, *NIX only
if((strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')){
$tmp_path = sys_get_temp_dir();
// Get DB structure as it is
exec("mysqldump --user=$dbusername --password=$dbpassword --skip-extended-insert -d --no-data $database | sed 's/ AUTO_INCREMENT=[0-9]*//g' | egrep -v 'MariaDB dump|Host:|Server version|Dump completed' > /tmp/current-structure.sql");
exec("mysqldump --user=$dbusername --password=$dbpassword --skip-extended-insert -d --no-data $database | sed 's/ AUTO_INCREMENT=[0-9]*//g' | egrep -v 'MariaDB dump|Host:|Server version|Dump completed' > $tmp_path/current-structure.sql");
// Get the new structure from db.sql
exec("egrep -v 'MariaDB dump|Host:|Server version|Dump completed' db.sql > /tmp/new-structure.sql");
exec("egrep -v 'MariaDB dump|Host:|Server version|Dump completed' db.sql > $tmp_path/new-structure.sql");
// Compare
exec("diff /tmp/current-structure.sql /tmp/new-structure.sql > /tmp/diff.txt");
$diff = file_get_contents("/tmp/diff.txt");
exec("diff $tmp_path/current-structure.sql $tmp_path/new-structure.sql > $tmp_path/diff.txt");
$diff = file_get_contents("$tmp_path/diff.txt");
// Display, if there is a difference
if(!empty($diff)){