Skip to content

Commit

Permalink
Working on a nice little installation routine.
Browse files Browse the repository at this point in the history
  • Loading branch information
mre committed Jun 21, 2010
1 parent be1b30b commit 3382a96
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 119 deletions.
4 changes: 4 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
$template = new Template;
echo($template->header("Karban - Installation"));
?>
14 changes: 14 additions & 0 deletions install/header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>KARBAN - Setup</title>
<link rel="shortcut icon" href="../karban_icon.png" type="image/png" />
<link rel="icon" href="../karban_icon.png" type="image/png" />
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="center"><img alt="karban" src="../karban.png" /><br />
<h1>Welcome!</h1>
You are one step away from a simple project management system that is <em>fun</em> to use.<br />
<br />
162 changes: 90 additions & 72 deletions install/index.php
Original file line number Diff line number Diff line change
@@ -1,46 +1,66 @@
<?php

require_once("../settings.php"); // Load often used settings and objects
/*
* _| _| _|_| _|_|_| _|_|_| _|_| _| _|
* _| _| _| _| _| _| _| _| _| _| _|_| _|
* _|_| _|_|_|_| _|_|_| _|_|_| _|_|_|_| _| _| _|
* _| _| _| _| _| _| _| _| _| _| _| _|_|
* _| _| _| _| _| _| _|_|_| _| _| _| _|
*
* This script installs karban on a server (bootstrap) using settings.php from the
* root directory. Delete the install folder after the installation is complete.
*/

include_once("header.html");

// Let's see if we can load the setting file.
if(!file_exists("../settings.php")) {
echo("<p class='warning'>Can't find the settings.php file in root directory.
Please get a proper version of karban.</p>");
exit;
}

// Load often used settings and objects
require_once("../settings.php");

// Database setup
Prosper\Query::configure(Prosper\Query::MYSQL_MODE, DB_USER, DB_PASS, DB_HOST, "");

$template = new Template;
echo($template->header("Karban - Installation"));

$installed = Prosper\Query::select()->from(DB_PREFIX."Groups");
if ($installed) {
echo "ist da";
// Is karban already installed?
$installed_tables = Prosper\Query::select()->from(DB_PREFIX."*");
if (is_array($installed_tables)) {
foreach ($installed_tables as $table) {
echo $table;
}
} else {
// Check if we can connect to the database
echo "fehler";
}
foreach ($installed as $table) {
echo $table;
}

exit;

if($installed)
{
echo "<strong>UserCake has already been installed.<br /> Please remove the install directory for security reasons.</strong>";
}
else
if($installed)
{
echo "<strong>UserCake has already been installed.<br /> Please remove the install directory for security reasons.</strong>";
}
else
{
if(isset($_GET["install"]))
{
if(isset($_GET["install"]))
{
$groups_sql = "
$groups_sql = "
CREATE TABLE IF NOT EXISTS `".$db_table_prefix."Groups` (
`Group_ID` int(11) NOT NULL auto_increment,
`Group_Name` varchar(225) NOT NULL,
PRIMARY KEY (`Group_ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
";
$group_entry = "

$group_entry = "
INSERT INTO `".$db_table_prefix."Groups` (`Group_ID`, `Group_Name`) VALUES
(1, 'Standard User');
";
$users_sql = "

$users_sql = "
CREATE TABLE IF NOT EXISTS `".$db_table_prefix."Users` (
`User_ID` int(11) NOT NULL auto_increment,
`Username` varchar(150) NOT NULL,
Expand All @@ -57,58 +77,56 @@
PRIMARY KEY (`User_ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
";


if(Prosper\Query::native($groups_sql))
{
echo "<p>".$db_table_prefix."Groups table created.....</p>";
}
else
{
echo "<p>Error constructing ".$db_table_prefix."Groups table.</p><br /><br /> DBMS said: ";

echo print_r($db->_sql_error());
$db_issue = true;
}

if(Prosper\Query::native($group_entry))
{
echo "<p>Inserted Standard User group into ".$db_table_prefix."Groups table.....</p>";
}
else
{
echo "<p>Error constructing Groups table.</p><br /><br /> DBMS said: ";

echo print_r($db->_sql_error());
$db_issue = true;
}

if(Prosper\Query::native($users_sql))
{
echo "<p>".$db_table_prefix."Users table created.....</p>";
}
else
{
echo "<p>Error constructing user table.</p><br /><br /> DBMS said: ";

echo print_r($db->_sql_error());
$db_issue = true;
}

if(!$db_issue)
echo "<p><strong>Database setup complete, please delete the install folder.</strong></p>";
else
echo "<p><a href=\"?install=true\">Sorry. Something went wrong with the database setup. Please check your configuration and again</a></p>";


if(Prosper\Query::native($groups_sql))
{
echo "<p>".$db_table_prefix."Groups table created.....</p>";
}
else
{
?>

echo "<p>Error constructing ".$db_table_prefix."Groups table.</p><br /><br /> DBMS said: ";

echo print_r($db->_sql_error());
$db_issue = true;
}

if(Prosper\Query::native($group_entry))
{
echo "<p>Inserted Standard User group into ".$db_table_prefix."Groups table.....</p>";
}
else
{
echo "<p>Error constructing Groups table.</p><br /><br /> DBMS said: ";

echo print_r($db->_sql_error());
$db_issue = true;
}

if(Prosper\Query::native($users_sql))
{
echo "<p>".$db_table_prefix."Users table created.....</p>";
}
else
{
echo "<p>Error constructing user table.</p><br /><br /> DBMS said: ";

echo print_r($db->_sql_error());
$db_issue = true;
}

if(!$db_issue)
echo "<p><strong>Database setup complete, please delete the install folder.</strong></p>";
else
echo "<p><a href=\"?install=true\">Sorry. Something went wrong with the database setup. Please check your configuration and again</a></p>";
}
else
{
?>
Welcome to KARBAN! <br />
The setup will create all necessary database entries... <br />
<a href="?install=true">Install</a>

<?php } }

include_once("../themes/default/footer.php");
?>
<a href="?install=true">Install</a></div>
<?php } }

include_once("../themes/default/footer.php");
?>
42 changes: 0 additions & 42 deletions install/sql.txt

This file was deleted.

1 change: 1 addition & 0 deletions install/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes
2 changes: 1 addition & 1 deletion settings.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php// Please adjust the configuration for your sitedefine("DB_NAME", "karban"); // Database Namedefine("DB_USER", "root"); // Database user namedefine("DB_PASS", "password"); // Database password// That's it! Save and quit.//--------------------------------------------------------------------------// Advanced settings (for experienced users)

define("TITLE", "KARBAN - Simple accounting"); // Site titledefine("DESIGN", "default"); // Design for sitedefine("DB_HOST", "localhost"); // Database Serverdefine("HOST_URL", "http://localhost/"); // URL of serverdefine("DB_PREFIX", "karban_"); // For multiple installations// Internal settings (don't change)if ( !defined("KARBAN_PATH") ) // Path to KARBAN define("KARBAN_PATH", dirname(__FILE__) . "/"); define("THEME_PATH", KARBAN_PATH . "themes/"); // Path to karban themes// Prosper General Settings//--------------------------------------------------------------------------define("PROSPER_PATH", KARBAN_PATH . "lib/prosper/prosper/"); // Path to database library//---------------------------------------------------------------------------// UserCake General Settings//--------------------------------------------------------------------------define("USERCAKE_PATH", KARBAN_PATH . "lib/userCake/"); // Path to database library//Database Information - will be set automatically$dbtype = "mysql";$db_host = DB_HOST;$db_user = DB_USER;$db_pass = DB_PASS;$db_name = DB_NAME;$db_port = "";$db_table_prefix = DB_PREFIX;$langauge = "en";//Generic website variables$websiteName = TITLE;$websiteUrl = HOST_URL; //including trailing slash//Do you wish UserCake to send out emails for confirmation of registration?//We recommend this be set to true to prevent spam bots.//False = instant activation//If this variable is falses the resend-activation file not work.$emailActivation = true;//In hours, how long before UserCake will allow a user to request another account activation email//Set to 0 to remove threshold$resend_activation_threshold = 1;//Tagged onto our outgoing emails$emailAddress = "noreply@" . $websiteUrl;//Date format used on email's$emailDate = date("l \\t\h\e jS");//Directory where txt files are stored for the email templates.$mail_templates_dir = "models/mail-templates/";$default_hooks = array("#WEBSITENAME#","#WEBSITEURL#","#DATE#");$default_replace = array($websiteName,$websiteUrl,$emailDate);//Display explicit error messages?$debug_mode = false;//---------------------------------------------------------------------------// For simplicity include common filesrequire_once(PROSPER_PATH . "adapters/_common_.php"); // Database adaptersrequire_once(PROSPER_PATH . "Query.php"); // Database communicationrequire_once(USERCAKE_PATH. "models/funcs.user.php"); // User managementinclude_once(THEME_PATH . "Template.php"); // Design files?>
define("TITLE", "KARBAN - Simple accounting"); // Site titledefine("DESIGN", "default"); // Design for sitedefine("DB_HOST", "localhost"); // Database Serverdefine("HOST_URL", "http://localhost/"); // URL of serverdefine("DB_PREFIX", "karban_"); // For multiple installations// Internal settings (don't change)if ( !defined("KARBAN_PATH") ) // Path to KARBAN define("KARBAN_PATH", dirname(__FILE__) . "/"); define("THEME_PATH", KARBAN_PATH . "themes/"); // Path to karban themes// Prosper General Settings//--------------------------------------------------------------------------define("PROSPER_PATH", KARBAN_PATH . "lib/prosper/prosper/"); // Path to database library//---------------------------------------------------------------------------// UserCake General Settings//--------------------------------------------------------------------------define("USERCAKE_PATH", KARBAN_PATH . "lib/userCake/"); // Path to database library//Database Information - will be set automatically$dbtype = "mysql";$db_host = DB_HOST;$db_user = DB_USER;$db_pass = DB_PASS;$db_name = DB_NAME;$db_port = "";$db_table_prefix = DB_PREFIX;$langauge = "en";//Generic website variables$websiteName = TITLE;$websiteUrl = HOST_URL; //including trailing slash//Do you wish UserCake to send out emails for confirmation of registration?//We recommend this be set to true to prevent spam bots.//False = instant activation//If this variable is falses the resend-activation file not work.$emailActivation = true;//In hours, how long before UserCake will allow a user to request another account activation email//Set to 0 to remove threshold$resend_activation_threshold = 1;//Tagged onto our outgoing emails$emailAddress = "noreply@" . $websiteUrl;//Date format used on email's$emailDate = date("l \\t\h\e jS");//Directory where txt files are stored for the email templates.$mail_templates_dir = "models/mail-templates/";$default_hooks = array("#WEBSITENAME#","#WEBSITEURL#","#DATE#");$default_replace = array($websiteName,$websiteUrl,$emailDate);//Display explicit error messages?$debug_mode = false;//---------------------------------------------------------------------------// For simplicity include common filesrequire_once(PROSPER_PATH . "adapters/_common_.php"); // Database adaptersrequire_once(PROSPER_PATH . "Query.php"); // Database communicationrequire_once(USERCAKE_PATH. "models/funcs.user.php"); // User managementinclude_once(THEME_PATH . "Template.php"); // Design files?>
Expand Down
2 changes: 1 addition & 1 deletion themes/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private function load($templatename) {
private function parser($template_file, $values='') {
if(is_array($values)) {
foreach($values as $key => $value) {
$pattern = "/<%%(".strtoupper($key).")%%>/si";
$pattern = "/__(".strtoupper($key).")__/si";
// Replace values
$template_file = preg_replace($pattern, $value, $template_file);
}
Expand Down
6 changes: 3 additions & 3 deletions themes/default/header.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>KARBAN - Setup</title>
<link href="<%%STYLESHEET%%>" rel="stylesheet" type="text/css" />
<title>__TITLE__</title>
<link href="__STYLESHEET__" rel="stylesheet" type="text/css" />
<body>
<p><img alt="karban" src="<%%LOGO%%>" /></p>
<p><img alt="karban" src="__LOGO__" /></p>
Binary file added themes/karban_small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3382a96

Please sign in to comment.