ihr wollt eine eigene CMS oder Bildergallerie anfangen und wisst nicht wie?
Kein Problem: mit diesem Installationsscript habt ihr das wichtigste (nämlich die Datenbank anlegen+Administratoraccount) schon vorab getan.
Als erstes beginnen wir mit der .htaccess. Sie schützt die darin aufgelisteten Dateien.
Code :
1 2 3 4 5 6 7 8 9 | <Files "config.php">
Order allow,deny
Deny from all
</Files>
<Files "common.php">
Order allow,deny
Deny from all
</Files> |
Als zweites erstellen wir die index.php.
PHP-Code:
<?php
$filename = 'config.php';
if (file_exists($filename)) {
header("Location: sites.php");
}
else {
echo "Sie müssen erst die Installation durchführen. <a href='http://www.tutorials.de/install.php'>Zur Installation</a>.";
}
?>
Die sites.php enthält den Inhalt, den Sie für die index.php geplant hatten. Also das, was der Internetuser sieht, wenn er auf Ihre Seite stößt und Sie die Installation durchgeführt haben.
Die dritte Datei, die wir erstellen ist die install.php
PHP-Code:
<?php
header("Location: install/index.php");
?>
Dazu erstellen wir als nächstes den Ordner install/
In diesen Ordner erstellen wir dann den Ordner mysql/
Im Ordner mysql werden zwei Dateien erstellt.
1. tables.php (hier ein Beispiel)
PHP-Code:
<?php
$create[user] = "CREATE TABLE $user (
`id` int(11) NOT NULL auto_increment,
`name` varchar(255) collate latin1_general_ci NOT NULL default '',
`password` varchar(255) collate latin1_general_ci NOT NULL default '',
`email` varchar(255) collate latin1_general_ci NOT NULL default '',
`level` int(11) NOT NULL default '0',
`autologin` int(1) NOT NULL default '0',
`location` varchar(30) collate latin1_general_ci NOT NULL default '',
`interests` varchar(100) collate latin1_general_ci NOT NULL default '',
`icq_nr` varchar(12) NOT NULL default '0',
`job` varchar(30) collate latin1_general_ci NOT NULL default '',
`ban` int(1) NOT NULL default '0',
`session_time` varchar(25) collate latin1_general_ci NOT NULL,
`time` varchar(5) collate latin1_general_ci NOT NULL,
`active` char(1) collate latin1_general_ci NOT NULL default '',
`act_key` varchar(255) collate latin1_general_ci NOT NULL default '',
`ice` int(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=1";
$create[sessions] = "CREATE TABLE $sessions (
`id` int(11) NOT NULL auto_increment,
`session_time` varchar(30) collate latin1_general_ci NOT NULL,
`session_ip` varchar(30) collate latin1_general_ci NOT NULL,
`time` varchar(30) collate latin1_general_ci NOT NULL,
`name` varchar(14) collate latin1_general_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=1";
$create[config] = "CREATE TABLE $config (
`menu_title` varchar(20) collate latin1_general_ci NOT NULL default '',
`default_style` varchar(35) collate latin1_general_ci NOT NULL default '',
`default_language` varchar(28) collate latin1_general_ci NOT NULL default '',
`footer_title` varchar(255) collate latin1_general_ci NOT NULL default '',
`path` varchar(55) collate latin1_general_ci NOT NULL default '',
`domain_name` varchar(255) collate latin1_general_ci NOT NULL default '',
`website_name` varchar(90) collate latin1_general_ci NOT NULL default '',
`logo_url` varchar(255) collate latin1_general_ci NOT NULL default '',
`email` varchar(255) collate latin1_general_ci NOT NULL default '',
`gb_entries_per_site` int(11) NOT NULL,
`comments_per_site` int(11) NOT NULL,
`frontpage` varchar(31) collate latin1_general_ci NOT NULL default '',
`gb_wait` int(11) NOT NULL,
`gb_on` int(11) NOT NULL,
`contact_form_on` int(1) NOT NULL,
`change_of_name` int(1) NOT NULL,
`wio_on` int(1) NOT NULL,
`max_pms` int(11) NOT NULL,
`disable` int(1) NOT NULL,
`editor_on` int(1) NOT NULL,
`website_title` varchar(56) collate latin1_general_ci NOT NULL,
`v_ai` int(1) NOT NULL,
`v_hpi` int(1) NOT NULL,
`v_so` int(1) NOT NULL,
`v_ans` int(1) NOT NULL,
`v_co` int(1) NOT NULL,
`v_anc` int(1) NOT NULL,
`v_mo` int(1) NOT NULL,
`v_anm` int(1) NOT NULL,
`v_cc` int(1) NOT NULL,
`v_cot` int(1) NOT NULL,
`v_cu` int(1) NOT NULL,
`v_trash` int(1) NOT NULL,
`comments` int(1) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci";
?>
Die zweite Datei nennen wir mal data.php (auch ein Beispiel)
PHP-Code:
<?php
$insert[user] = "INSERT INTO $user VALUES (1, '$username', '$md5_pass', '$admin_email', '1', '0', '', '', '', '', '0', '0', '0', '1', '-1', '0')";
$insert[sessions] = "INSERT INTO $sessions VALUES (1, '0', '0', '0', '$username')";
?>
So, damit wäre bis auf den Installationsscript alles gesagt. Die Grundlagen sind euch hoffentlich klar.
Der Installationsscript liegt im Ordner install/ und heißt index.php
Ich habe versucht ihn einfach und selbsterklärend zubauen.
index.php
PHP-Code:
<?php
$step = $_GET['step'];
$host = $_SERVER['HTTP_HOST'];
@include "../config.php";
$path = substr(str_replace("/install/index.php", "", $_SERVER['SCRIPT_NAME']), '1');
// Connect to the database
$connection = @mysql_connect($server, $dbusername, $dbpassword);
// Select the database
@mysql_select_db($dbname);
$mode = $_GET['mode'];
// MySQL tables und datas
include "mysql/tables.php";
include "mysql/data.php";
// Start installation-assistent
if (!isset($step)) {
echo "<div><b>Willkommen zur Installation</b></div>";
echo "<div>";
echo "Vielen Dank, dass Sie sich zur Installation von MatzeCMS entschieden hast. Um MatzeCMS zu installieren, klicken Sie bitte auf weiter. Wenn Sie MatzeCMS vergebens installiert haben, löschen sie die config.php und starten diesen Installationsassistenten erneut.";
echo "<a rel='nofollow' href='http://www.tutorials.de/index.php?step=1'>Weiter</a></div>";
echo "</div>";
}
// Step 1: MySQL-Data
if ($step == '1') {
echo "<div><b>Installation - MySQL-Zugangsdaten</b></div>";
echo "<div>";
echo "Geben Sie hier bitte ihre MySQL-Zugangsdaten ein.";
echo "<br>";
echo "<form action='http://www.tutorials.de/index.php?step=2' method='post'>";
echo "<table width='100%'>";
echo "<tr><td width='17%'>Server:</font></td><td><input class='input' type='text' name='server' value='localhost' /></td></tr>";
echo "<tr><td width='17%'>Username:</font></td><td><input class='input' type='text' name='mysql_username' /></td></tr>";
echo "<tr><td width='17%'>Passwort:</font></td><td><input class='input' type='password' name='mysql_password' /></td></tr>";
echo "<tr><td width='17%'>Datenbank:</font></td><td><input class='input' type='text' name='mysql_db' /></td></tr>";
echo "<tr><td width='17%'>Tabellen-Prefix:</font></td><td><input class='input' type='text' name='mysql_prefix' value='Matze Community CMS' /></td></tr>";
echo "</table>";
echo "<br>";
if (!($handle = @fopen("../config.php", w))) {
echo "<font color='red'><b>Deine config.php ist nicht beschreibbar!</b></font>";
} else {
echo "<font color='green'><b>Deine config.php ist beschreibbar.</b></font>";
}
echo "<br>";
$_SESSION['prefix'] = $_POST['mysql_prefix'];
echo "<input class='button' type='submit' value='Weiter'>";
echo "</form></div>";
}
// Step 2: Check Connection
if ($step == '2') {
$server = $_POST['server'];
$mysql_username = $_POST['mysql_username'];
$mysql_password = $_POST['mysql_password'];
$mysql_db = $_POST['mysql_db'];
$mysql_prefix = $_POST['mysql_prefix'];
// error MySQL-Username
if (empty($mysql_username)) {
echo "<div><b>Fehlende Angaben</b></div>";
echo "<div>";
echo "Sie haben vergessen einen MySQL-Usernamen anzugeben. Korrigiere Sie bitte ihre Angaben.";
echo "<br>";
echo "<a rel='nofollow' href='http://www.tutorials.de/index.php?step=1' style='text-decoration: none'>Zurück</a>";
echo "</div>";
exit();
}
// error MySQL-Database
if (empty($mysql_db)) {
echo "<div><b>Fehlende Angaben</b></div>";
echo "<div id='content'>";
echo "Sie haben vergessen eine MySQL-Datenbank anzugeben. Korrigieren Sie bitte ihre Angaben.";
echo "<br>";
echo "<a rel='nofollow' href='http://www.tutorials.de/index.php?step=1' style='text-decoration: none'>Zurück</a>";
echo "</div>";
exit();
}
// error config.php
if (!($handle = @fopen("../config.php", w))) {
echo "<div><b>Fehler</b></div>";
echo "<div>";
echo "Ihre <b>config.php</b> ist leider nicht beschreibbar. Sie müssen die Rechte der Datei auf <b>0777</b> setzen.";
echo "<br>";
echo "<a rel='nofollow' href='http://www.tutorials.de/index.php?step=1' style='text-decoration: none'>Zurück</a></div>";
} else {
//
// Let's go and write the config.php
//
$write_config = "<?php\n\n";
$write_config .= "\$server = \"$server\";\n";
$write_config .= "\$dbname = \"$mysql_db\";\n";
$write_config .= "\$dbusername = \"$mysql_username\";\n";
$write_config .= "\$dbpassword = \"$mysql_password\";\n";
$write_config .= "\$dbprefix = \"$mysql_prefix\";\n\n";
$write_config .= "\n\n?>";
fwrite($handle, $write_config);
fclose($handle);
echo "<div><b>MySQL-Konfiguration abgeschlossen.</b></div>";
echo "<div id='content'>";
echo "Glückwunsch, das Erste haben Sie geschafft. Die config.php wurde erstellt. Jetzt muss nur noch der Administrator eingerichtet werden.";
echo "<br>";
echo "<a rel='nofollow' href='http://www.tutorials.de/index.php?step=3' style='text-decoration: none'>Weiter</a></div>";
}
}
// Step 3: Configurate the Administrator
if ($step == '3') {
if ($connection == false) {
echo "<div><b>Falsche Zugangsdaten</b></div>";
echo "<div>";
echo "Die eingegebenen Zugangsdaten für Ihre Datenbank waren falsch. Bitte versuchen Sie es erneut.";
echo "<br>";
echo "<a href='http://www.tutorials.de/forum.php' style='text-decoration: none'>Zurück</a>";
echo "</div>";
@unlink("../config.php");
exit();
}
echo "<div><b>Installation - Abschluss</b></div>";
echo "<div>";
echo "Bitte geben Sie hier noch die letzten Daten zur Konfiguration ihrer Homepage ein.";
echo "<br><br>";
echo "<b>Allgemeine Konfigurationsdaten</b>";
echo "<br><br>";
echo "<form action='http://www.tutorials.de/index.php?step=4' method='post'>";
echo "<table width='100%'>";
echo "<tr><td width='20%'>Domainname:</font></td><td><input class='input' type='text' name='domain_name' size='32' value='$host' /></td></tr>";
echo "<tr><td width='20%'>Websitename:</font></td><td><input class='input' type='text' name='website_name' size='32' /></td></tr>";
echo "<tr><td width='20%'>Pfad:</font></td><td><input class='input' type='text' name='path_name' size='32' value='$path' /></td></tr>";
echo "<tr><td width='20%'>E-Mail-Adresse:</font></td><td><input class='input' type='text' name='email' size='32' /></td></tr>";
echo "<tr><td width='20%'>Footer-Titel:</font></td><td><input class='input' type='text' name='footer_name' size='32' /></td></tr>";
echo "</table>";
echo "<br>";
echo "<b>Zugangsdaten für den Administrator:</b>";
echo "<br /><br />";
echo "<table width='100%'>";
echo "<tr><td width='20%'>Username:</font></td><td><input class='input' type='text' name='username' /></td></tr>";
echo "<tr><td width='20%'>Passwort:</font></td><td><input class='input' type='password' name='password' /></td></tr>";
echo "<tr><td width='20%'>E-Mail-Adresse:</font></td><td><input class='input' type='text' name='admin_email' /></td></tr>";
echo "</table>";
echo "<br />";
echo "<input class='button' type='submit' value='Weiter'/>";
echo "</form></div>";
}
// Step 4: create and fill in mysql-tables
if ($step == '4') {
if (empty($dn) OR empty($email) OR empty($username) OR empty($md5_pass) OR empty($admin_email)) {
echo "<div><b>Fehlende Angaben</b></div>";
echo "<div>";
echo "Sie haben vergessen, ein oder mehrere Felder auszufüllen. Bitte korregieren sie ihre Angaben.";
echo "<br>";
echo "<a rel='nofollow' href='http://www.tutorials.de/index.php?step=3' style='text-decoration: none'>Zurück</a>";
echo "</div>";
exit();
}
mysql_query($create[abq]);
mysql_query($insert[categories]);
echo "<div><b>Installation erfolgreich!</b></div>";
echo "<div>";
echo "Vielen Dank, dass Sie sich für MatzeCMS entschieden haben. Die Installation war erfolgreich. Bitte löschen Sie unbedingt den Ordner <b>install/</b>!";
echo "<br><br>";
echo "<a href='../index.php' style='text-decoration: none'>Zur Startseite</a>";
echo "</div>";
}
// fertig
?>
Ich gebe zu, dass der Script nicht außergewönlich oder großartig ist. Jedoch zum Einstieg gut nachvollziehbar.
Die Sicherheit ist schon top. Über das Design kann man sich streiten. Braucht ein Installationsscript ein Design?
Wenn ja kann man beispielsweise eine .css einbinden, den Text, Links und Divs formatieren. Dann vielleicht noch ein Header-Logo, gescheide Weiter Buttons und Hintergrundbild.
Mein Tipp:
1. eine .css-Datei erstellen
2. in die <div>-Befehle die einzelnen Elemente aus der css mit id=example einbauen.
Wer eine CMS baut, sollte vielleicht noch ein License-Agreement vor der Datenbankkonfiguration einbauen und sich statt einen Header, ein Logo überlegen. Dann unten noch eine Copyright-Zeile und das ganze passt.
Ich werde vielleicht selber nochmal einen neueren Script mit Design und License-Agreement posten.
Aber zum rumbasteln reichts.
So und jetzt zu einem neuerem Code, wie versprochen.
Das ganze könnte wieder für eine CMS oder Bildergallerie verwendet werden. Ich hab es zum Beispiel für mein CMS-Projekt genutzt. In Englisch, da meine CMS International genutzt werden könnte, wenn ich mal fertig werde.
die install/index.php
PHP-Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>MatzeCMS Install</title>
<style type="text/css">
<!--
#main {
color: #333;
background-color: #eeeeee;
width: 950px;
margin-top: 30px;
margin-bootom: 20px;
margin-right: auto;
margin-left: auto;
padding: 20px;
border: 1px solid #666;
}
body {
margin: 0px;
padding: 0px;
background-color: #333;
color: #000000;
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
font-weight: bold;
}
input {
background-color: #eeeeee;
border: 1px solid #9FC54E;
color: #666;
font-size: 14px;
padding:4px;
}
strong {
color: #9FC54E;
border-bottom-width: 1px;
border-bottom-style: dotted;
border-bottom-color: #9FC54E;
display: block;
margin-top: 10px;
font-size: 18px;
line-height: 30px;
}
.success {
cursor:pointer;
height: 50px;
text-indent: 55px;
margin: 5px;
line-height: 50px;
padding: 5px;
background-position: 5px;
font-size: 16px;
width: 700px;
border:1px solid #739F1D;
background-color: #D4F684;
background-image: url(admin/images/tick.png);
background-repeat: no-repeat;
display:block;
color: #333;
}
.warning {
height: auto;
color:#333;
text-indent: 55px;
margin: 5px;
line-height: 50px;
padding: 5px;
background-position: 5px;
font-size: 16px;
width: 700px;
border:1px solid #F1AA2D;
background-color: #FEFFC8;
background-image: url(admin/images/alert.png);
background-repeat: no-repeat;
display:block;
cursor:pointer;
}
-->
</style>
</head>
<body>
<script type="text/javascript"><!--
var _gaq = _gaq || [];
_gaq.push(
['_setAccount', 'UA-1691844-1'],
['_trackPageview']
);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
//-->
</script>
<script type="text/javascript"><!--
var _gaq = _gaq || [];
_gaq.push(
['_setAccount', 'UA-1691844-1'],
['_trackPageview']
);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
//-->
</script>
<div id='main'>
<?php
if ($_POST)
{
$error = "";
$db_host = $_POST['host'];
$db_username = $_POST['username'];
$db_password = $_POST['password'];
$db_name = $_POST['db'];
$db_prefix = $_POST['prefix'];
$site_name = $_POST['name'];
$site_username = $_POST['site_username'];
$site_password = md5($_POST['site_password']);
$site_email = $_POST['site_email'];
$site_url = $_POST['site_url'];
$path = $_POST['path'];
// config.php
$config = fopen("../config.php", 'a');
$contents = '<?php
//This File is auto-generatad;
$server = \''. $db_host . '\';
$username = \''. $db_username . '\';
$password = \''. $db_password . '\';
$dbname = \''. $db_name . '\';
$dbprefix = \''. $db_prefix . '\';
define("MatzeCMS_INSTALLED", true);
?>';
$write = fwrite($config, $contents);
if ($write)
{
fclose($config);
} else
{
$error .= "<div class='warning'>Failed to write the config file.</div>";
}
$mysql_con = @mysql_connect($db_host,$db_username,$db_password);
if (!$mysql_con) {
$error .= "<div class='warning'>Unable to connect to mysql.</div>";
}
$mysql_db = @mysql_select_db($db_name);
if (!$mysql_db) {
$error .= "<div class='warning'>Unable to select database.</div>";
}
//
// extern files
//
include "mysql/create.php";
include "mysql/insert.php";
// said that only querys 1-58 are copied in the mysql-database
for ($i=1; $i<=58; $i++)
{
$sql[$i] = str_replace('[TABLE_NAME]', $db_prefix, $sql[$i]);
$q = mysql_query($sql[$i]);
if (!$q)
{
$m_error = mysql_error();
$error .= "<div class='warning'>Error in mysql query $i.<br>$m_error</div>";
}
}
if (empty($error))
{ ?>
<div class="success">Success! - MatzeCMS has been successfully installed - visit the admin <a href="../admin/">Here</a>.</div>
<?php } else
{
?>
<div class="warning"> Error has occured - Please check settings</div>
<?=$error?>
<?php }
} else
{
?>
<form id="form1" name="form1" method="post" action="http://www.tutorials.de/">
<table width="953" border="0">
<tr>
<td width="240"><h3><strong>Welcome to MatzeCMS</strong></h3></td>
<td width="673"></td>
</tr>
<tr>
<td>Informations</td>
<td>Welcome to the automatically installationsscript of MatzeCMS. Please check before you install MatzeCMS that no other Version of MatzeCMS is installed. Have Fun wih my content management system. <br> Matthias Doerflinger</td>
</tr>
<tr>
<td width="240"><h3><strong>Mysql Database Settings</strong></h3></td>
<td width="673"></td>
</tr>
<tr>
<td>Host</td>
<td><input name="host" type="text" value="localhost" /></td>
</tr>
<tr>
<td>Username</td>
<td><input type="text" name="username" id="username" /></td>
</tr>
<tr>
<td>Password</td>
<td><input name="password" type="text" /></td>
</tr>
<tr>
<td>Database Name</td>
<td><input name="db" type="text" id="db" /> </td>
</tr>
<tr>
<td>Database Prefix</td>
<td><input name="prefix" type="text" id="prefix" value="matze_cms_"/> </td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td><h3><strong>Website Settings</strong></h3></td>
<td></td>
</tr>
<tr>
<td>Domain</td>
<?php
$full_url = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$full_url = explode("/", $full_url);
$full_url = $full_url[0];
// $full_url = str_replace("install/","", $full_url);
// $full_url = str_replace("install.php","", $full_url);
// $full_url = str_replace("index.php","", $full_url);
?>
<td><input name="site_url" type="text" id="site_url" value="<?=$full_url?>" size="50"/></td>
</tr>
<tr>
<td>Path</td>
<?php
$full_url = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$full_url = explode("/", $full_url);
$path = $full_url[1];
?>
<td><input name="path" type="text" id="path" value="<?=$path?>" size="50"/></td>
</tr>
<tr>
<td>Admin Username</td>
<td><input name="site_username" type="text" size="50" id="site_username" /></td>
</tr>
<tr>
<td>Admin Password</td>
<td><input name="site_password" type="text" size="50" id="site_password" /></td>
</tr>
<tr>
<td>Admin Email</td>
<td><input name="site_email" type="text" size="50" id="site_email" /></td>
</tr>
<tr>
<td>Website Name</td>
<td><input name="name" type="text" size="50" /></td>
</tr>
<tr>
<td width="240"><h3><strong>License</strong></h3></td>
<td width="673"></td>
</tr>
<tr>
<td><input onclick="document.getElementById('submit').removeAttribute('disabled', 0);" type="checkbox" align="right" name="license" value="1"/><br><br></td>
<td>I have read the <a href='../docs/license.htm' onclick='FensterOeffnen(this.href); return false'>License</a> and agree with it.<br><br></td>
</tr>
<tr>
<td></td>
<td><label>
<input type="submit" disabled="disabled" name="submit" id="submit" value="Install" onclick="confirm('Are you sure everything is right?')" />
</label></td>
</tr>
</table>
</form>
<?php } ?>
</div>
<div class="footer_morecopyright" style="margin-top: 0px;color:#FFFFFF;">Page Time: <b>0,08118</b> seconds *****Memory: <b>10,953</b> KB *****Queries: <b>76</b> *****Templates: <b>42</b> (<b>22</b> uncached)<br />Server Uptime: <b>23 days 7 hours 53 mins</b> *****Server Load: <b>0.73</b> : 0.72 : 0.71<br /><table cellspacing="0" cellpadding="0" border="0" style="margin-left: auto; margin-right: auto;"><tr><td style="color: #cccccc; text-align: left;"><b>editor_clientscript</b></td><td style="padding-left: 10px;">(2)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>editor_jsoptions_font</b></td><td style="padding-left: 10px;">(2)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>editor_jsoptions_size</b></td><td style="padding-left: 10px;">(2)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>editor_smilie</b></td><td style="padding-left: 10px;">(20)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>editor_smilie_category</b></td><td style="padding-left: 10px;">(2)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>editor_smilie_row</b></td><td style="padding-left: 10px;">(30)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>editor_smiliebox</b></td><td style="padding-left: 10px;">(2)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>editor_toolbar_colors</b></td><td style="padding-left: 10px;">(2)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>editor_toolbar_fontname</b></td><td style="padding-left: 10px;">(42)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>editor_toolbar_fontsize</b></td><td style="padding-left: 10px;">(14)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>editor_toolbar_on</b></td><td style="padding-left: 10px;">(1)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>newpost_attachment</b></td><td style="padding-left: 10px;">(1)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>newpost_disablesmiliesoption</b></td><td style="padding-left: 10px;">(2)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>tagbit_wrapper</b></td><td style="padding-left: 10px;">(1)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>vbcms_article_editor</b></td><td style="padding-left: 10px;">(1)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>vbcms_content_article_inline</b></td><td style="padding-left: 10px;">(1)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>vbcms_content_edit_editbar</b></td><td style="padding-left: 10px;">(1)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>vbcms_edit_block</b></td><td style="padding-left: 10px;">(1)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>vbcms_edit_metadataeditor</b></td><td style="padding-left: 10px;">(1)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>vbcms_edit_page</b></td><td style="padding-left: 10px;">(1)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>vbcms_edit_publisher</b></td><td style="padding-left: 10px;">(1)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>vbcms_editor_toolbar_on</b></td><td style="padding-left: 10px;">(1)</td></tr></table></div></body>
</html>
Oben wird erstmal das Design festgelegt, dann die config.php generiert und die Tabellen sowie die Tabelleninhalte eingebunden (install/mysql/insert und create.php) und unten ist das Formular. Habe das ganze mit nur AGB-Checkbox und mit einer Abfrage (Are you sure everything is right?) modifiziert.
Als nächstes kann man dann die AGB anlegen.
Diese sollte als docs/license.htm in das Stammverzeichnis ihres Codes legen (oder gegebenfalls meine Codes bearbeiten).
Sie könnte so aussehen:
HTML-Code:
<style type="text/css"> <!-- #main { color: #333; background-color: #eeeeee; width: 900px; margin-top: 50px; margin-right: auto; margin-left: auto; padding: 20px; border: 1px solid #666; } body { background-color: #333; } --> </style> <div id='main'> <p> <h2>License</h2> Text Text Text Text Text </p> </div>

Die install/create.php kann so aussehen:
PHP-Code:
<?php
$sql[1] = "CREATE TABLE IF NOT EXISTS `[TABLE_NAME]articles` (
`id` int(11) unsigned NOT NULL auto_increment,
`title` varchar(42) collate latin1_general_ci NOT NULL,
`text` mediumtext collate latin1_general_ci NOT NULL,
`cat` varchar(255) collate latin1_general_ci NOT NULL default '',
`date` varchar(255) collate latin1_general_ci NOT NULL default '',
`set_date` int(1) NOT NULL default '0',
`level` int(11) NOT NULL default '0',
`trash` int(1) NOT NULL,
`trash_date` varchar(255) collate latin1_general_ci NOT NULL,
`comments_on` int(11) NOT NULL default '0',
`show_author` int(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;";
$sql[2] = "CREATE TABLE IF NOT EXISTS `[TABLE_NAME]article_categories` (
`id` int(10) unsigned NOT NULL auto_increment,
`title` varchar(255) collate latin1_general_ci NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=1;";
... ?>
Die install/insert.php könnten so aussehen:
PHP-Code:
<?php
$sql[32] = "INSERT INTO `[TABLE_NAME]articles` VALUES (1, 'CSS-Grundkurs', 'CSS bedeutet Casding Style Sheet. Es wird unter vor allem in HTML und somit auch PHP, Java, etc. verwendet. CSS ist eine Scriptsprache, die hsuptsächlich zur Designbestimmung geeignet ist.', 'Tutorials', '27.05.10, 18:46', '', 5, 0, 0, 1, 1);";
$sql[33] = "INSERT INTO `[TABLE_NAME]article_categories` VALUES (1, 'Nachrichten');";
... ?>
In meinem Beispiel ist $sql[x] in meinem Beispiel maximal 58 (siehe oben im Installscript). Kann man leicht bearbeiten, musste ich aber zur Erklärung mailen.
So man könnte dann noch eine MySQL-Verbindung einbauen. Bei mir wird das in der includes/mysql.php gemach. Diese wird in jedem weiterem Code includet.
Hier ein kleiner Ausschnitt:
Code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
// Try to connect to the database
$connection = @mysql_connect($server, $username, $password);
// Select database
@mysql_select_db($name);
if (!defined('MatzeCMS_INSTALLED')) {
header('Location: install/');
}
include 'includes/tables.php.';
// Query to test connection
$query[test] = @mysql_query("SELECT default_style FROM " . CONFIG_TABLE);
if (!$query[test]) {
echo "<html>";
echo "<head><title>General Error</title>
<script type="text/javascript">
//<![CDATA[
window.google_analytics_uacct = "UA-1691844-1";
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
window.google_analytics_uacct = "UA-1691844-1";
//]]>
</script>
</head>";
echo "<b>General Error</b><br></font>";
echo "Sorry, could not connect to the database. Please check your <i>config.php</i><br>";
echo "<b>SQL ERROR:</b> " . mysql_error();
echo "<div class="footer_morecopyright" style="margin-top: 0px;color:#FFFFFF;">Page Time: <b>0,08118</b> seconds *****Memory: <b>10,953</b> KB *****Queries: <b>76</b> *****Templates: <b>42</b> (<b>22</b> uncached)<br />Server Uptime: <b>23 days 7 hours 53 mins</b> *****Server Load: <b>0.73</b> : 0.72 : 0.71<br /><table cellspacing="0" cellpadding="0" border="0" style="margin-left: auto; margin-right: auto;"><tr><td style="color: #cccccc; text-align: left;"><b>editor_clientscript</b></td><td style="padding-left: 10px;">(2)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>editor_jsoptions_font</b></td><td style="padding-left: 10px;">(2)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>editor_jsoptions_size</b></td><td style="padding-left: 10px;">(2)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>editor_smilie</b></td><td style="padding-left: 10px;">(20)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>editor_smilie_category</b></td><td style="padding-left: 10px;">(2)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>editor_smilie_row</b></td><td style="padding-left: 10px;">(30)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>editor_smiliebox</b></td><td style="padding-left: 10px;">(2)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>editor_toolbar_colors</b></td><td style="padding-left: 10px;">(2)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>editor_toolbar_fontname</b></td><td style="padding-left: 10px;">(42)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>editor_toolbar_fontsize</b></td><td style="padding-left: 10px;">(14)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>editor_toolbar_on</b></td><td style="padding-left: 10px;">(1)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>newpost_attachment</b></td><td style="padding-left: 10px;">(1)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>newpost_disablesmiliesoption</b></td><td style="padding-left: 10px;">(2)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>tagbit_wrapper</b></td><td style="padding-left: 10px;">(1)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>vbcms_article_editor</b></td><td style="padding-left: 10px;">(1)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>vbcms_content_article_inline</b></td><td style="padding-left: 10px;">(1)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>vbcms_content_edit_editbar</b></td><td style="padding-left: 10px;">(1)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>vbcms_edit_block</b></td><td style="padding-left: 10px;">(1)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>vbcms_edit_metadataeditor</b></td><td style="padding-left: 10px;">(1)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>vbcms_edit_page</b></td><td style="padding-left: 10px;">(1)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>vbcms_edit_publisher</b></td><td style="padding-left: 10px;">(1)</td></tr><tr><td style="color: #cccccc; text-align: left;"><b>vbcms_editor_toolbar_on</b></td><td style="padding-left: 10px;">(1)</td></tr></table></div></body>";
echo "</html>";
exit();
} |
Die Tabellen kann man so definieren
Code :
1 | define('CONFIG_TABLE', $dbprefix . 'config'); |
Ich denke, dass man aus diesen Codes viel lernen kann. Ist aber eigentlich ganz einfach und zum Einstieg perfekt.
Matze




Bereiche
Kategorien
Forum - Programming





tutorials.de-Systemmitteilung