Skip to content

Commit

Permalink
Removed generated files from source resolving #4.
Browse files Browse the repository at this point in the history
  • Loading branch information
ihofmann committed Jun 21, 2015
1 parent 52faa69 commit 816d5d7
Show file tree
Hide file tree
Showing 17 changed files with 346 additions and 29 deletions.
20 changes: 2 additions & 18 deletions build.gradle
@@ -1,4 +1,4 @@
def releaseVersion = "5.2.3"
def releaseVersion = "5.2.4-SNAPSHOT"
def targetDirBase = './release/' + releaseVersion + '/'
def targetDir = targetDirBase + "/websoccer"
def targetUpdateDir = targetDirBase + '/update/websoccer'
Expand Down Expand Up @@ -37,28 +37,12 @@ release << {
exclude 'uploads/stadium/*'
exclude 'uploads/stadiumbuilding/*'
exclude 'uploads/users/*'
exclude 'generated/*'
}

println 'Copied files'
}

release << {

configfile = new File(targetDir + '/admin/config/config.inc.php')
configfile.text = ''

imprintfile = new File(targetDir + '/admin/config/imprint.php')
imprintfile.text = 'n.a.'

adminlog = new File(targetDir + '/admin/config/adminlog.php')
adminlog.text = ''

entitylog = new File(targetDir + '/admin/config/entitylog.php')
entitylog.text = ''

println 'Emptied files'
}

release << {

copy {
Expand Down
Empty file.
Empty file.
Empty file.
4 changes: 2 additions & 2 deletions websoccer/admin/config/global.inc.php
Expand Up @@ -62,7 +62,7 @@ function classes_autoloader($class) {
// constants
define('FOLDER_MODULES', BASE_FOLDER . '/modules');
define('MODULE_CONFIG_FILENAME', 'module.xml');
define('GLOBAL_CONFIG_FILE', BASE_FOLDER . '/admin/config/config.inc.php');
define('GLOBAL_CONFIG_FILE', BASE_FOLDER . '/generated/config.inc.php');
define('CONFIGCACHE_FILE_FRONTEND', BASE_FOLDER . '/cache/wsconfigfront.inc.php');
define('CONFIGCACHE_FILE_ADMIN', BASE_FOLDER . '/cache/wsconfigadmin.inc.php');
define('CONFIGCACHE_MESSAGES', BASE_FOLDER . '/cache/messages_%s.inc.php');
Expand All @@ -71,7 +71,7 @@ function classes_autoloader($class) {
define('CONFIGCACHE_SETTINGS', BASE_FOLDER . '/cache/settingsconfig.inc.php');
define('CONFIGCACHE_EVENTS', BASE_FOLDER . '/cache/eventsconfig.inc.php');
define('UPLOAD_FOLDER', BASE_FOLDER . '/uploads/');
define('IMPRINT_FILE', BASE_FOLDER . '/admin/config/imprint.php');
define('IMPRINT_FILE', BASE_FOLDER . '/generated/imprint.php');
define('TEMPLATES_FOLDER', BASE_FOLDER . '/templates');
define('PROFPIC_UPLOADFOLDER', UPLOAD_FOLDER . 'users');

Expand Down
1 change: 0 additions & 1 deletion websoccer/admin/config/imprint.php

This file was deleted.

1 change: 1 addition & 0 deletions websoccer/admin/config/lockfile.txt
@@ -0,0 +1 @@
Prevent concurrent writes on jobs.xml.
2 changes: 1 addition & 1 deletion websoccer/admin/config/version.txt
@@ -1 +1 @@
5.2.2
5.2.4-SNAPSHOT
2 changes: 1 addition & 1 deletion websoccer/admin/functions.inc.php
Expand Up @@ -103,7 +103,7 @@ function createMessage($severity, $title, $message) {
function logAdminAction(WebSoccer $websoccer, $type, $username, $entity, $entityValue) {
$userIp = getenv('REMOTE_ADDR');
$message = $websoccer->getFormattedDatetime($websoccer->getNowAsTimestamp()) . ';' . $username . ';' . $userIp . ';' . $type . ';' . $entity . ';' . $entityValue;
$file = BASE_FOLDER . '/admin/config/entitylog.php';
$file = BASE_FOLDER . '/generated/entitylog.php';

$fw = new FileWriter($file, FALSE);
$fw->writeLine($message);
Expand Down
2 changes: 1 addition & 1 deletion websoccer/admin/login.php
Expand Up @@ -88,7 +88,7 @@
$content = $admin['name'] .', '. $ip .', '. date('d.m.y - H:i:s');
$content .= "\n";

$datei = 'config/adminlog.php';
$datei = '../generated/adminlog.php';
$fp = fopen($datei, 'a+');

if (filesize($datei)) {
Expand Down
2 changes: 1 addition & 1 deletion websoccer/admin/pages/all_logging.php
Expand Up @@ -37,7 +37,7 @@

<?php

$datei = 'config/adminlog.php';
$datei = '../generated/adminlog.php';

if (!file_exists($datei)) echo createErrorMessage($i18n->getMessage('alert_error_title'), $i18n->getMessage('all_logging_filenotfound'));
elseif ($admin['r_demo']) echo createErrorMessage($i18n->getMessage('error_access_denied'), '');
Expand Down
2 changes: 1 addition & 1 deletion websoccer/admin/pages/entitylogging.php
Expand Up @@ -39,7 +39,7 @@

<?php

$datei = 'config/entitylog.php';
$datei = '../generated/entitylog.php';

if (!file_exists($datei)) echo createErrorMessage($i18n->getMessage('alert_error_title'), $i18n->getMessage('all_logging_filenotfound'));
else {
Expand Down
2 changes: 2 additions & 0 deletions websoccer/generated/.gitignore
@@ -0,0 +1,2 @@
*
!.gitignore
6 changes: 3 additions & 3 deletions websoccer/install/index.php
Expand Up @@ -23,9 +23,9 @@
define("BASE_FOLDER", __DIR__ ."/..");

define("PHP_MIN_VERSION", "5.3.0");
define("WRITABLE_FOLDERS", "uploads/club/,uploads/cup/,uploads/player/,uploads/sponsor/,uploads/stadium/,uploads/stadiumbuilder/,uploads/stadiumbuilding/,uploads/users/,cache/,admin/config/adminlog.php,admin/config/entitylog.php,admin/config/config.inc.php,admin/config/imprint.php,admin/config/jobs.xml,admin/config/termsandconditions.xml");
define("WRITABLE_FOLDERS", "generated/,uploads/club/,uploads/cup/,uploads/player/,uploads/sponsor/,uploads/stadium/,uploads/stadiumbuilder/,uploads/stadiumbuilding/,uploads/users/,admin/config/jobs.xml,admin/config/termsandconditions.xml");
define("DEFAULT_DB_PREFIX", "ws3");
define("CONFIGFILE", BASE_FOLDER . "/admin/config/config.inc.php");
define("CONFIGFILE", BASE_FOLDER . "/generated/config.inc.php");
define("DDL_FULL", "ws3_ddl_full.sql");
define("DDL_MIGRATION", "ws3_ddl_upgrade.sql");
define("DDL_INDEX", "ws3_ddl_index.sql");
Expand Down Expand Up @@ -334,7 +334,7 @@ function actionSaveConfig() {
$filecontent .= "\$conf['systememail'] = \"". $_POST["systememail"] . "\";" . PHP_EOL;
$filecontent .= "?>" . PHP_EOL;

$fp = fopen(CONFIGFILE, 'w');
$fp = fopen(CONFIGFILE, 'w+');
fwrite($fp, $filecontent);
fclose($fp);

Expand Down
272 changes: 272 additions & 0 deletions websoccer/update/index.php
@@ -0,0 +1,272 @@
<?php
/******************************************************
HSE WebSoccer-Sim
Copyright (c) 2013-2014 by
Hofmann Software Engineering
EMail: info@websoccer-sim.com
Homepage: http://www.websoccer-sim.com
THIS IS NOT FREEWARE! YOU NEED TO OBTAIN A
VALID LICENCE IN ORDER TO BE ALLOWED TO USE
THIS SOURCE CODE!
DIES IST KEINE FREEWARE (KEINE KOSTENLOSE SOFTWARE).
SIE MUESSEN EINE KORREKTE LIZENZ BESITZEN, UM DIESEN
PROGRAMMCODE BENUTZEN ZU DUERFEN!
******************************************************/


error_reporting(E_ALL);
define("BASE_FOLDER", __DIR__ ."/..");

define("WRITABLE_FOLDERS", "generated/");
define("DEFAULT_DB_PREFIX", "ws3");

define("CONFIGFILE", BASE_FOLDER . "/generated/config.inc.php");
define("CONFIGFILE_OLD", BASE_FOLDER . "/admin/config/config.inc.php");

define("DDL_FILE", "update_ddl.sql");

session_start();
$supportedLanguages = array("de" => "Deutsch", "en" => "English");

ignore_user_abort(TRUE);
set_time_limit(0);

include(BASE_FOLDER . "/classes/DbConnection.class.php");

/**
* Step 1: Welcome Screen -> Language Selection
*/
function printWelcomeScreen() {
global $supportedLanguages;

echo "<h2>Sprache wählen / Choose language</h2>";

echo "<form method=\"post\">";
$first = TRUE;
foreach ($supportedLanguages as $langId => $langLabel) {
echo "<label class=\"radio\">";
echo "<input type=\"radio\" name=\"lang\" id=\"$langId\" value=\"$langId\"";
if ($first) {
echo " checked";
$first = FALSE;
}
echo "> $langLabel";
echo "</label>";
}

echo "<button type=\"submit\" class=\"btn\">Wählen / Choose</button>";
echo "<input type=\"hidden\" name=\"action\" value=\"actionSetLanguage\">";
echo "</form>";
}

function actionSetLanguage() {
if (!isset($_POST["lang"])) {
global $errors;
$errors[] = "Please select a language.";
return "printWelcomeScreen";
}

global $supportedLanguages;
$lang = $_POST["lang"];
if (key_exists($lang, $supportedLanguages)) {
$_SESSION["lang"] = $lang;
return "printSystemCheck";
}

return "printWelcomeScreen";
}

/**
* Step 2: System Check
*/
function printSystemCheck($messages) {
echo "<h2>". $messages["check_title"] . "</h2>";

?>

<?php

$requirments = array();

$writableFiles = explode(",", WRITABLE_FOLDERS);
foreach ($writableFiles as $writableFile) {
$file = BASE_FOLDER . "/" . $writableFile;

$requirments[] = array(
"requirement" => $messages["check_req_writable"] . " <i>" . $writableFile . "</i>",
"min" => $messages["check_req_yes"],
"actual" => (is__writable($file)) ? $messages["check_req_yes"] : $messages["check_req_no"],
"status" => (is__writable($file)) ? "success" : "error"
);
}

?>

<table class="table">
<thead>
<tr>
<th><?php echo $messages["check_head_requirement"] ?></th>
<th><?php echo $messages["check_head_required_value"] ?></th>
<th><?php echo $messages["check_head_actual_value"] ?></th>
</tr>
</thead>
<tbody>
<?php
$valid = TRUE;
foreach($requirments as $requirement) {
echo "<tr class=\"". $requirement["status"] . "\">";
echo "<td>" . $requirement["requirement"] . "</td>";
echo "<td>" . $requirement["min"] . "</td>";
echo "<td>" . $requirement["actual"] . "</td>";
echo "</tr>";

if ($requirement["status"] == "error") {
$valid = FALSE;
}
}
?>
</tbody>
</table>

<?php

if ($valid) {
echo "<form method=\"post\">";
echo "<button type=\"submit\" class=\"btn\">". $messages["button_next"] . "</button>";
echo "<input type=\"hidden\" name=\"action\" value=\"actionMoveFiles\">";
echo "</form>";
} else {
echo "<p>". $messages["check_req_error"] . "</p>";
}
}


function actionMoveFiles() {

$fileNames = array("config.inc.php", "adminlog.php", "imprint.php", "entitylog.php");
$oldDir = BASE_FOLDER . "/admin/config/";
$newDir = BASE_FOLDER . "/generated/";

foreach ($fileNames as $fileName) {
if (file_exists($oldDir . $fileName)) {
rename($oldDir . $fileName, $newDir . $fileName);
}
}

return "printFinalPage";
}


/**
* Final page
*/
function printFinalPage($messages) {
include(CONFIGFILE);
?>

<div class="alert alert-success"><strong><?php echo $messages["final_success_alert"]; ?></strong></div>

<div class="alert"><strong><?php echo $messages["final_success_note"]; ?></strong></div>

<p><i class="icon-arrow-right"></i> <a href="<?php echo $conf["context_root"]; ?>/admin"><?php echo $messages["final_link"]; ?></a></p>
<?php
}
?>
<!DOCTYPE html>
<html lang="de">
<head>
<title>Open WebSoccer-Sim Update Installation</title>
<link href="../admin/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link rel="shortcut icon" type="image/x-icon" href="../favicon.ico" />
<meta charset="UTF-8">
<style type="text/css">
body {
padding-top: 100px;
padding-bottom: 40px;
}
</style>
</head>
<body>

<div class="container">

<h1>Open WebSoccer-Sim Update Installation</h1>

<hr>

<?php

$errors = array();

$messagesIncluded = FALSE;
if(isset($_SESSION["lang"])) {
include("messages_" . $_SESSION["lang"] . ".inc.php");
$messagesIncluded = $_SESSION["lang"];
}

$action = (isset($_REQUEST["action"])) ? $_REQUEST["action"] : "";
if (!strlen($action) || substr($action, 0, 6) !== "action") {
$view = "printWelcomeScreen";
} else {
$view = $action();
}

if(isset($_SESSION["lang"]) && $_SESSION["lang"] !== $messagesIncluded) {
include("messages_" . $_SESSION["lang"] . ".inc.php");
}

if (count($errors)) {
foreach($errors as $error) {
echo "<div class=\"alert alert-error\">$error</div>";
}
}

if (isset($messages)) {
$view($messages);
} else {
$view();
}

?>

<hr>

<footer>
<p>Powered by <a href="http://www.websoccer-sim.com" target="_blank">Open WebSoccer-Sim</a></p>
</footer>
</div>

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="../admin/bootstrap/js/bootstrap.min.js"></script>
</body>
</html>

<?php
// real is_writable (http://www.php.net/manual/en/function.is-writable.php#73596)
function is__writable($path) {
//will work in despite of Windows ACLs bug
//NOTE: use a trailing slash for folders!!!
//see http://bugs.php.net/bug.php?id=27609
//see http://bugs.php.net/bug.php?id=30931

if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
return is__writable($path.uniqid(mt_rand()).'.tmp');
else if (is_dir($path))
return is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
// check tmp file for read/write capabilities
$rm = file_exists($path);
$f = @fopen($path, 'a');
if ($f===false)
return false;
fclose($f);
if (!$rm)
unlink($path);
return true;
}
?>

0 comments on commit 816d5d7

Please sign in to comment.