Skip to content

Commit 1b1b91c

Browse files
Added database updates, code cleanup.
1 parent 1a29eaf commit 1b1b91c

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

updater/update.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
<?php
2+
/**
3+
* Update Script for Updating BlogDraw to v0.0.1-rc-1
4+
**/
5+
////Development error reporting. Should usually be turned off in production systems.
26
//error_reporting(E_ALL);
37
//ini_set('display_errors', 'On');
4-
//Update Script for Updating BlogDraw to v0.0.1-rc-1
8+
59
echo '<h1>Starting Update...</h1>';
610
echo '<p>Thank you for your patience.</p>';
711

@@ -28,6 +32,18 @@
2832
$rootDir = "BlogDraw-0.0.1-rc-1";// The root node containing new files.
2933
scan_folder($rootDir);// Replaces old BlogDraw files with new ones from the root node.
3034

35+
//Update Database
36+
require_once('../functions.php');
37+
$DBConnection = mysqli_connect(DBSERVER,DBUSER,DBPASS,DBNAME);
38+
if (!$DBConnection)
39+
die('Failed to update Database.');
40+
$DBQuery = "ALTER TABLE ". DBPREFIX . "_LoginTable ADD COLUMN DisplayName VARCHAR(25) NOT NULL;";// Add the rc-1 DisplayName feature.
41+
mysqli_query($DBConnection,$DBQuery);
42+
mysqli_close($DBConnection);
43+
44+
echo "<p>Done! You can now close this window and delete the &quot;updater&quot; directory.</p>";
45+
echo "<p><strong>NEXT STEPS: </strong> For your previous uploads to appear in future versions of BlogDraw, please copy and paste them from the \"Uploads\"directory to the \"uploads\" directory. To ensure better system security, please delete the \"Back\" directory. New versions of those files are now available in the \"control\" directory.</p>";
46+
3147
/**
3248
* This recursively reads a directory and all of it's subdirectories given a relative filepath, then replaces the old files with the new ones.
3349
* Essentially filesystem traversal.
@@ -52,7 +68,8 @@ function scan_folder($dir)
5268
if (!file_put_contents($_SERVER['DOCUMENT_ROOT'] . $to[1], file_get_contents('.' . $from[1])))
5369
{
5470
$copyToDir = implode('/', explode('/', ($_SERVER['DOCUMENT_ROOT'] . $to[1]), -1));
55-
mkdir($copyToDir, 0755);
71+
if (! mkdir($copyToDir, 0755, TRUE))
72+
echo '<br />Failed to create directory ' . $copyToDir . '!';
5673
$newFile = fopen($_SERVER['DOCUMENT_ROOT'] . $to[1], "w");
5774
fwrite($newFile, file_get_contents('.' . $from[1]));
5875
fclose($newFile);
@@ -61,7 +78,4 @@ function scan_folder($dir)
6178
}
6279
}
6380
}
64-
65-
echo "<p>Done! You can now close this window and delete the &quot;updater&quot; directory.</p>";
66-
echo "<p><strong>NEXT STEPS: </strong> For your previous uploads to appear in future versions of BlogDraw, please copy and paste them from the \"Uploads\"directory to the \"uploads\" directory. To ensure better system security, please delete the \"Back\" directory. New versions of those files are now available in the \"control\" directory.</p>";
67-
?>
81+
?>

0 commit comments

Comments
 (0)