Skip to content

Commit 1a29eaf

Browse files
New update script.
1 parent 072d135 commit 1a29eaf

File tree

1 file changed

+12
-31
lines changed

1 file changed

+12
-31
lines changed

updater/update.php

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,31 @@
11
<?php
22
//error_reporting(E_ALL);
33
//ini_set('display_errors', 'On');
4-
//Update Script for Updating BlogDraw to v0.0.1-beta-2.1
4+
//Update Script for Updating BlogDraw to v0.0.1-rc-1
55
echo '<h1>Starting Update...</h1>';
66
echo '<p>Thank you for your patience.</p>';
77

8-
file_put_contents("BlogDrawSrc.tar.gz", fopen("https://github.com/TuxSoftLimited/BlogDraw/archive/v0.0.1-beta-2.1.tar.gz", 'r'));// Get the release from GitHub.
8+
file_put_contents("BlogDrawSrc.tar.gz", fopen("https://github.com/TuxSoftLimited/BlogDraw/archive/v0.0.1-rc-1.tar.gz", 'r'));// Get the release from GitHub.
99
exec('tar -xf BlogDrawSrc.tar.gz');// Unpack it.
1010

1111
//Alter the functions file
1212
$functionsFile = file_get_contents('../functions.php');
1313
$functionsFileData = explode('?><?php', $functionsFile);// Split the client data from the primary functions.
14-
$functionsFile = $functionsFileData[0] . "?>" . file_get_contents('./BlogDraw-0.0.1-beta-2.1/functions.php');
14+
$functionsFile = $functionsFileData[0] . "?>" . file_get_contents('./BlogDraw-0.0.1-rc-1/functions.php');
1515
file_put_contents('../functions.php', $functionsFile);// replace the functions.
1616

1717
//Alter the .htaccess file
1818
$htaccessFile = file_get_contents('../.htaccess');
19-
if (!(strpos($htaccessFile, 'RewriteRule ^(Back/functions) - [F,L,NC]') !== false))// If they don't have the new rewrite rule:
20-
{
21-
$htaccessFileData = explode('RewriteRule ^(functions\.php) - [F,L,NC]', $htaccessFile);
22-
$htaccessFile = $htaccessFileData[0] . "RewriteRule ^(functions\.php) - [F,L,NC]
23-
RewriteRule ^(Back/functions) - [F,L,NC]" . $htaccessFileData[1];
24-
file_put_contents('../.htaccess', $htaccessFile);// Write it in.
25-
}
19+
$htaccessFile = str_replace("Back/", "control/", $htaccessFile);
20+
file_put_contents('../.htaccess', $htaccessFile);// Write it in.
2621

27-
//Remove old analytics table from database
28-
$dBServerLocation = explode("DBSERVER', '", $functionsFileData[0]);
29-
$DBSERVER = explode("')", $dBServerLocation[1])[0];
30-
$dBUserLocation = explode("DBUSER', '", $functionsFileData[0]);
31-
$DBUSER = explode("')", $dBUserLocation[1])[0];
32-
$dBPassLocation = explode("DBPASS', '", $functionsFileData[0]);
33-
$DBPASS = explode("')", $dBPassLocation[1])[0];
34-
$dBNameLocation = explode("DBNAME', '", $functionsFileData[0]);
35-
$DBNAME = explode("')", $dBNameLocation[1])[0];
36-
$dBPrefixLocation = explode("DBPREFIX', '", $functionsFileData[0]);
37-
$DBPREFIX = explode("')", $dBPrefixLocation[1])[0];
38-
$dBConnection = mysqli_connect($DBSERVER,$DBUSER,$DBPASS,$DBNAME);
39-
if (!$dBConnection)
40-
die('Could not connect to database. Please try again later.');
41-
$dBQuery = "CREATE TABLE ". $DBPREFIX . "_AnalyticsTable IF NOT EXISTS;";
42-
mysqli_query($dBConnection,$dBQuery);// To ensure we're not deleting a non-existent table.
43-
$dBQuery = "DROP TABLE ". $DBPREFIX . "_AnalyticsTable;";
44-
mysqli_query($dBConnection,$dBQuery);// Get rid of the table.
45-
mysqli_close($dBConnection);
22+
//Alter the robots.txt file
23+
$robotsFile = file_get_contents('../robots.txt');
24+
$robotsFile = str_replace("/Back", "/control", $robotsFile);
25+
file_put_contents('../robots.txt', $robotsFile);// Write it in.
4626

4727
//Change files
48-
$rootDir = "BlogDraw-0.0.1-beta-2.1";// The root node containing new files.
28+
$rootDir = "BlogDraw-0.0.1-rc-1";// The root node containing new files.
4929
scan_folder($rootDir);// Replaces old BlogDraw files with new ones from the root node.
5030

5131
/**
@@ -68,7 +48,7 @@ function scan_folder($dir)
6848
if ($file != ".htaccess" && $file != "functions.php" && $file != "install.php" )// Files we don't want to deal with.
6949
{
7050
$from = explode("updater", realpath($dir) . '/' . $file);
71-
$to = explode("BlogDraw-0.0.1-beta-2.1", realpath($dir) . '/' . $file);
51+
$to = explode("BlogDraw-0.0.1-rc-1", realpath($dir) . '/' . $file);
7252
if (!file_put_contents($_SERVER['DOCUMENT_ROOT'] . $to[1], file_get_contents('.' . $from[1])))
7353
{
7454
$copyToDir = implode('/', explode('/', ($_SERVER['DOCUMENT_ROOT'] . $to[1]), -1));
@@ -83,4 +63,5 @@ function scan_folder($dir)
8363
}
8464

8565
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>";
8667
?>

0 commit comments

Comments
 (0)