Tivoilos Posted April 18, 2008 Share Posted April 18, 2008 I am working on a Website Software that is built in PHP I want to make it easier for my clients to install an setup there site but I don't know how to make a install.php What would need to be done with this is to make it so I can do as Follows Place in MySQL Database Name/Login/Password Setup a Admin Account with the Login info so they can edit news etc. Link to comment https://forums.phpfreaks.com/topic/101729-solved-how-to-make-a-installphp/ Share on other sites More sharing options...
Fadion Posted April 18, 2008 Share Posted April 18, 2008 I usually place the DB name, login and password in an "connection.inc.php" file, so in my case i would make the installer write the file. Its pretty basic, just a form with post which after submition writes the file with file manipulation functions (fopen, fread, fwrite). After that u execute the sql instructions to fill in the database with correct tables and information (if any). The admin account should be in a database i guess, so u just insert/update a database row. Link to comment https://forums.phpfreaks.com/topic/101729-solved-how-to-make-a-installphp/#findComment-520469 Share on other sites More sharing options...
jonsjava Posted April 18, 2008 Share Posted April 18, 2008 Here's a sample of what I've done: example config.inc.php <?php /* ######################################################################################## */ /* Mailer Group Solution -- Multi-User Mass Mailing System with opt out and Admin abilities */ /* Copyright (C) 2008 Jon Harris */ /* */ /* This program is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU General Public License */ /* as published by the Free Software Foundation. */ /* */ /* This program is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ /* along with this program; if not, write to the Free Software */ /* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* ######################################################################################## */ /* ################################################################################### */ /* Database connection and date variables */ /* ################################################################################### */ $host = "localhost"; $db = "database_name"; $db_user = "database_username"; $db_password = "database_password"; $day = date("d"); $month = date("M"); $year = date("Y"); $ccdate = $day."/".$month."/".$year; $link = mysql_connect($host, $db_user, $db_password); mysql_select_db($db); /* ################################################################################### */ /* END Database connection and date variables */ /* ################################################################################### */ /* ################################################################################### */ /* Variables for the removal/mailer system */ /* ################################################################################### */ $web_addr = "http://example.com"; $server_root = "/mailer/"; $list_name = "name_for_this_install"; $template = "blue"; /* ################################################################################### */ /* END Variables for the removal/mailer system */ /* ################################################################################### */ if ($install_in_progress != true){ $sql11 = "SELECT * from system where `name` ='{$list_name}';"; $result11 = mysql_query($sql11); $row11 = mysql_fetch_assoc($result11); $system_status = $row11['status']; $tos = $row11['tos']; } $template_dir = "templates/"; $template_inc = $template_dir.$template."/"; $site_address = $web_addr.$server_root; ?> Sample Installer <?php session_start(); /* ######################################################################################## */ /* Mailer Group Solution -- Multi-User Mass Mailing System with opt out and Admin abilities */ /* Copyright (C) 2008 Jon Harris */ /* */ /* This program is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU General Public License */ /* as published by the Free Software Foundation. */ /* */ /* This program is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ /* along with this program; if not, write to the Free Software */ /* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* ######################################################################################## */ $install_in_progress = true; include("../config.inc.php"); if ($_GET['go'] == "install"){ $sql= "CREATE TABLE IF NOT EXISTS `system` ( `id` int(30) NOT NULL auto_increment, `name` varchar(66) NOT NULL, `status` varchar(4) NOT NULL default 'up', `password` varchar(66) NOT NULL, `tos` longtext NOT NULL, `total_sent` int(60) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;"; mysql_query($sql); $sql = "INSERT INTO `system` (`id`, `name`, `status`, `password`, `tos`, `total_sent`) VALUES ('', '{$list_name}', 'up', '{$_POST['system_pass']}', 'Admin has not set the TOS yet.', 0);"; mysql_query($sql); $sql = "CREATE TABLE IF NOT EXISTS `system_stats_{$list_name}` ( `total_sent` int(60) NOT NULL, `top_sender` varchar(60) NOT NULL, `top_sender_total` int(60) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1;"; mysql_query($sql); $sql = "INSERT INTO `system_stats_{$list_name}` (`total_sent`, `top_sender`, `top_sender_total`) VALUES (0, 'nobody', 0);"; mysql_query($sql); $sql = "CREATE TABLE IF NOT EXISTS `moderator_{$list_name}` ( `id` int(60) NOT NULL auto_increment, `level` int(1) NOT NULL, `uname` varchar(55) NOT NULL, `password` varchar(55) NOT NULL, `last_login` varchar(55) NOT NULL, `history` longtext NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `uname` (`uname`), KEY `level` (`level`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=12 ;"; mysql_query($sql); $sql = "INSERT INTO `moderator_{$list_name}` (`id`, `level`, `uname`, `password`, `last_login`, `history`) VALUES (1, 3, '{$_POST['admin_user']}', '{$_POST['admin_pass']}', '', 'Created by Installer Script on {$ccdate}\n************\n');"; mysql_query($sql); $sql = "CREATE TABLE IF NOT EXISTS `users_{$list_name}` ( `id` int(60) NOT NULL auto_increment, `email_address` varchar(60) NOT NULL, `last_name` varchar(55) NOT NULL, `first_name` varchar(55) NOT NULL, `uname` varchar(55) NOT NULL, `password` varchar(55) NOT NULL, `gid` varchar(60) NOT NULL, `last_login` varchar(55) NOT NULL, `logs` longtext NOT NULL, `pieces_sent` int(60) NOT NULL, `total_sent` int(60) NOT NULL, `accepted_tos` int(1) NOT NULL default '0', `valid_user` int(1) NOT NULL default '0', `can_form` int(1) NOT NULL, `refer_url` varchar(99) NOT NULL, PRIMARY KEY (`id`), KEY `read_tos` (`accepted_tos`), KEY `email_address` (`email_address`), KEY `valid_user` (`valid_user`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=15 ;"; mysql_query($sql); header("location:index.php?go=complete"); exit(); } include("header.php"); include("navbar.php"); if ($_GET['go'] == "complete"){ ?> <center><h2>INSTALL COMPLETE</h2><br /> <p>Please remove the /insaller folder before going any further</p> <p>Once you have done that, go to <a href="<?php print $site_address; ?>admin/"><?php print $site_address; ?>admin/</a> and login</p> <p>with the username/password you used in the setup.</p> <?php } else{ ?> <form method="POST" action="index.php?go=install"> <table> <tr> <td> <p>Very rudimentiry installer script. To be fixed when I get a chance</p> <p>You can use the same database on different installs, simply change</p> <p>the <strong>config.inc.php</strong> for each install, and it will take care of the </p> <p>rest. Each user must be added my an admin/moderator/supervisor</p> <p><h2>MAKE SURE YOU HAVE THE DATABASE CREATED BEFORE USING THIS SCRIPT!</h2></p><br /> </td> </tr> <tr> <td> Admin Username: </td> <td> <input type="text" name="admin_user"> </td> </tr> <tr> <td> Admin Password(will be shown): </td> <td> <input type="text" name="admin_pass"> </td> </tr> <tr> <td> System Shutdown Password(will be shown): </td> <td> <input type="text" name="system_pass"> </td> </tr> <tr><td><input type="submit" value="Submit" name="submit"></td></tr> </table></form> <?php } include("footer.php"); ?> Sample Header (for installer) <html xml:lang="en" dir="ltr"> <head> <meta http-equiv="Content-type" content="text/html;charset=iso-8859-1" /> <link rel="shortcut icon" href="favicon.ico" /> <title>Mail Group Solution -- Install</title> <link rel="stylesheet" type="text/css" href="../templates/blue/main.css" /> </head> <div id="container"> <div id="head"> <div id="headleft"> </div> <div style="float: right; text-align: right;"> </div> </div> <div id="main"> <br /> <table align="center" style="width: 100%; margin-top: 5px; border: 1px solid #bbd2e0;" border="0" cellpadding="2" cellspacing="2"> <tr class="browse_rows_actions"> <td colspan="12"> <table style="width: 100%;" border="0" cellpadding="2" cellspacing="0"><tr><td valign="top" style="text-align: left;"> Sample Footer(For installer) </td></tr></table></td> </tr> </table> <div style="font-size: 90%; margin-top: 10px; margin-left: 780px;"> </div> </div> <div id="foot"> </div> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/101729-solved-how-to-make-a-installphp/#findComment-520472 Share on other sites More sharing options...
Tivoilos Posted April 18, 2008 Author Share Posted April 18, 2008 Thanks Link to comment https://forums.phpfreaks.com/topic/101729-solved-how-to-make-a-installphp/#findComment-520475 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.