<?php
/*---------------------------------------------------+
| LightNEasy Content Management System
| Copyright 2007 - 2009 Fernando Baptista
| http://lightNEasy.org
+----------------------------------------------------+
| Install module install.php
| no database Version 2.2.1
+----------------------------------------------------+
| Released under the terms & conditions of v2 of the
| GNU General Public License. For details refer to
| the included gpl.txt file or visit http://gnu.org
+----------------------------------------------------*/
?>
<html><head><title>LightNEasy 2.2.1 Install</title></head>
<body style="background: #606060;">
<div style="width: 550px; margin: auto; background: #004DBF; color: #fff; padding: 10px;">
<img src="../images/Logo.png" alt="LightNEasy" align="middle" border="0" style="float: left;" />
<h1><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Install</h1>
<div style="background: #f0f0f0; padding-left: 30px; padding-top: 10px; color: #000;">
<?php
clearstatcache();
if($_POST['submit'] == "Create Data Files") {
unset($_POST['submit']);
if($_POST['password']!="" && $_POST['password1']!="" && $_POST['password']==$_POST['password1']) {
$pass=sha1($_POST['password']);
$admin=$_POST['admin'];
$email=$_POST['email'];
$wemail=$_POST['wemail'];
if(!is_dir("../galeries")) mkdir("../galeries", 0777) or die ("could not create galeries folder");
if(!is_dir("../data")) mkdir("../data", 0755) or die ("could not create data folder");
if(!is_dir("../downloads")) mkdir("../downloads", 0777) or die ("could not create downloads folder");
if(!is_dir("../plugins")) mkdir("../plugins", 0777) or die ("could not create plugins folder");
$fp=fopen("../data/config.php","w");
fwrite($fp,"<?php\n");
fwrite($fp,'$set[\'password\']="'.$pass.'";'."\n");
fwrite($fp,'$set[\'homepath\']="./";'."\n");
fwrite($fp,'$set[\'template\']="lightneasy";'."\n");
fwrite($fp,'$set[\'title\']="LightNEasy";'."\n");
fwrite($fp,'$set[\'subtitle\']="Light, simple, practical";'."\n");
fwrite($fp,'$set[\'keywords\']="LightNEasy, CMS, Content Management, PHP, Free CMS, Website builder, Open Source";'."\n");
fwrite($fp,'$set[\'description\']="LightNEasy is a light and simple Content Management System and Website Builder";'."\n");
fwrite($fp,'$set[\'author\']="Fernando Baptista";'."\n");
fwrite($fp,'$set[\'footer\']="Copyright &amp;copy; 2009 LightNEasy";'."\n");
fwrite($fp,'$set[\'openfield\']="$#";'."\n");
fwrite($fp,'$set[\'closefield\']="#$";'."\n");
fwrite($fp,'$set[\'gzip\']="0";'."\n");
fwrite($fp,'$set[\'timeoffset\']="0";'."\n");
fwrite($fp,'$set[\'extension\']="php";'."\n");
fwrite($fp,'$set[\'indexfile\']="LightNEasy.php";'."\n");
fwrite($fp,'$set[\'fromname\']="'.$admin.'";'."\n");
fwrite($fp,'$set[\'fromemail\']="'.$wemail.'";'."\n");
fwrite($fp,'$set[\'toemail\']="'.$email.'";'."\n");
fwrite($fp,'$set[\'language\']="en_US";'."\n");
fwrite($fp,'$set[\'langeditor\']="en";'."\n");
fwrite($fp,'$set[\'dateformat\']="%m/%d/%y - %I:%M %p";'."\n");
fwrite($fp,"?>\n");
fclose($fp);

$fp=fopen("../data/menu.dat","w");
fwrite($fp,"1|0|0|index|Home||\n");
fwrite($fp,"1|1|0|home1|Home Submenu||\n");
fwrite($fp,"1|1|1|home2|Home Sub-submenu||\n");
fwrite($fp,"2|0|0|about|About||\n");
fwrite($fp,"5|0|0|news|News||\n");
fclose($fp);

$fp=fopen("../data/pages.dat","w");
fwrite($fp,"index|-|-||\n");
fwrite($fp,"home1|-|-||\n");
fwrite($fp,"home2|-|-||\n");
fwrite($fp,"about|-|-||\n");
fwrite($fp, "news|-|-||\n");
fclose($fp);

$fp=fopen("../data/news.dat","w");
fwrite($fp,"1|Admin|admin@email.com|First News|&lt;p&gt;This is the first news.&lt;/p&gt;
&lt;p&gt;Of course, you can edit/delete this news and enter your own.&lt;/p&gt;|1230643655|1|1||\n");
fclose($fp);

$fp=fopen("../data/newscat.dat","w");
fwrite($fp,"1|General|General||");
fclose($fp);

$fp=fopen("../data/linkcat.dat","w");
fwrite($fp,"1|General|General||");
fclose($fp);

$fp=fopen("../data/downloadcat.dat","w");
fwrite($fp,"1|General|General||");
fclose($fp);

$fp=fopen("../data/index.html","w");
fwrite($fp,"<h1>LightNEasy 2.2.1 index page</h1><p>If you are seeing this, that means <strong>LightNEasy</strong> installation worked!</p><p>This is the start page of your website. <strong>You should never delete this page!</strong> Instead, edit its content and enter whatever you want as content for this page. You can also alter the menu label (edit the menu). But there should always exist a page which filename is <b>index</b>.</p><p>Report to <a href=\"http://lightneasy.org\">LightNEasy website</a> to look at the instructions manual and how to use LightNEasy functionalities.</p><p>Login, using the password you entered, chose the template you want or make your own LightNEasy template, and start building your website!</p><p>Take a look at the bundled template files and see how easy it is to build a LightNEasy template!</p>");
fclose($fp);

$fp=fopen("../data/about.html","w");
fwrite($fp,"<h1>LightNEasy runs anywhere</h1>
<p align=\"justify\">LightNEasy doesn\'t require any fancy server stuff, just pure PHP, so will run smoothly in any web host, including most of the free ones. And yes, it works with PHP safe mode on.</p>
<h3>FCK WYSIWYG editor</h3>
<p align=\"justify\">LighNEasy uses the excelent open source online editor <a title=\"FCKEditor\" target=\"_blank\" href=\"http://www.fckeditor.net\">FCK Editor</a> &copy; by Frederico Caldeira Knabben, whose work i thank and apreciate.</p><p>FCK Editor is a javascript aplication so you need javascript enabled in your browser in order to edit the content in WYSIYG mode. You don\'t need javascript, however, to run the website or LightNEasy.</p>");
fclose($fp);

$fp=fopen("../data/news.html","w");
fwrite($fp,"<h1 class=\"LNE_title\">News</h1>\n<p>%!\$news 1 10 1$!%</p>\n");
fclose($fp);

$fp=fopen("../data/extra.htm","w");
fwrite($fp,"<p align=\"left\">This is an extra content that you can create to include in <strong>all your pages</strong>. This is usefull for announcements and news. Just place the <strong>$#extra#$</strong> tag wherever you want it on the template.</p><p align=\"left\">You can edit it from the <strong>Settings</strong> menu.</p>");
fclose($fp);

$fp=fopen("../data/home1.html","w");
fwrite($fp,"<h1>Home Submenu</h1><p>This is a subpage of Home page, just so that you can look at the menu structure.</p>");
fclose($fp);

$fp=fopen("../data/home2.html","w");
fwrite($fp,"<h1>Home Sub-submenu</h1><p>Yes, you can make sub-subpages.</p>");
fclose($fp);

?>
<h4>Installation Successfull!</h4>
<p>You should now delete the file install.php inside LightNEasy folder, for security reasons.</p>
<p align="center"><a href="../LightNEasy.php">Start LightNEasy!</a></p>
<?php
} else {
?>
<h4>Please try Again!</h4>
<p>All fields have to be filled</p>
<p>Passwords are either empty or don't match!</p>
<?php entryform();
}
} else {
?>
<h4>LightNEasy will now attempt to create the folders and data files</h4>
<p>Please note eventual error messages,and take apropriate measures.</p>
<p>If you get an error message, please set data folder permissions to 777</p>
<? entryform();
} ?>
<p>&nbsp;</p>
</div>
</div>
</body>
</html>
<?php
function entryform() {
?>
<form name="form1" action="" method="post"><table>
<tr><td>Enter password:</td><td><input type="password" name="password" value=""></td></tr>
<tr><td>Repeat password:</td><td><input type="password" name="password1" value=""></td></tr>
<tr><td>Admin name:</td><td><input type="text" name="admin" value=""></td></tr>
<tr><td>Admin email:</td><td><input type="text" name="email" value=""></td></tr>
<tr><td>Website email:</td><td><input type="text" name="wemail" value=""></td></tr>
<tr><td>&nbsp;</td><td><input type="submit" name="submit" value="Create Data Files" /></td></tr>
</table></form>
<?php }
?>