2014-12-25 20:31:01 +00:00
|
|
|
<?php
|
2014-12-26 11:06:37 +00:00
|
|
|
$start_time = microtime(true);
|
|
|
|
function logstr($str, $newline = true, $showtime = true)
|
|
|
|
{
|
|
|
|
global $start_time;
|
|
|
|
if($showtime)
|
|
|
|
echo("[ " . round(microtime(true) - $start_time, 4) . " ] ");
|
|
|
|
echo($str);
|
|
|
|
if($newline)
|
|
|
|
echo("\n");
|
|
|
|
}
|
|
|
|
|
2014-12-26 11:14:29 +00:00
|
|
|
function removeouterphptags($phpcode)
|
|
|
|
{
|
|
|
|
$firstindex = strpos($phpcode, "\n", strpos($phpcode, "<?php"));
|
|
|
|
$lastindex = strrpos($phpcode, "?>");
|
|
|
|
|
|
|
|
return substr($phpcode, $firstindex, $lastindex - $firstindex);
|
|
|
|
}
|
|
|
|
|
2014-12-25 20:31:01 +00:00
|
|
|
header("content-type: text/plain");
|
2014-12-26 11:06:37 +00:00
|
|
|
|
2014-12-26 11:14:29 +00:00
|
|
|
// Protects against users wiping the settings if run via CGI
|
2014-12-26 11:06:37 +00:00
|
|
|
logstr("Checking for existing build....", false);
|
2014-12-25 20:31:01 +00:00
|
|
|
if(file_exists("index.php"))
|
2014-12-26 11:06:37 +00:00
|
|
|
{
|
|
|
|
log_str("fail!", true, false);
|
|
|
|
log_str("A build already exists in this directory.");
|
|
|
|
log_str("Please delete it and then run this script again.");
|
2014-12-25 20:31:01 +00:00
|
|
|
|
2014-12-26 11:06:37 +00:00
|
|
|
exit();
|
|
|
|
}
|
2014-12-25 20:31:01 +00:00
|
|
|
|
2014-12-26 11:06:37 +00:00
|
|
|
logstr("pass - no other builds were found.", true, false);
|
|
|
|
|
|
|
|
logstr("Reading `core.php`...", false);
|
2014-12-25 20:31:01 +00:00
|
|
|
$build = file_get_contents("core.php");
|
2014-12-26 11:06:37 +00:00
|
|
|
logstr("done", true, false);
|
|
|
|
logstr("Reading `settings.fragment.php`...", false);
|
2014-12-26 11:14:29 +00:00
|
|
|
$settings = removeouterphptags(file_get_contents("settings.fragment.php"));
|
2014-12-26 11:06:37 +00:00
|
|
|
logstr("done", true, false);
|
|
|
|
|
|
|
|
logstr("Building.....", false);
|
|
|
|
$build = str_replace([
|
|
|
|
"{settings}"
|
|
|
|
], [
|
|
|
|
$settings
|
|
|
|
], $build);
|
|
|
|
logstr("done", true, false);
|
2014-12-25 20:31:01 +00:00
|
|
|
|
2014-12-26 11:06:37 +00:00
|
|
|
logstr("Writing build....", false);
|
2014-12-25 20:31:01 +00:00
|
|
|
file_put_contents("index.php", $build);
|
2014-12-26 11:06:37 +00:00
|
|
|
logstr("done!", true, false);
|
|
|
|
logstr("*** Build Completed ***");
|