Title: [Re-Code] Installer
Post by: Danny696 on December 18, 2009, 05:15:35 PM
Where else to start, than the installer.php. Has not been tested. Heres mine:
<?php //This file was Coded by Danny696 //Coded for McCodes Lite V2 ?> <html><head> <title>McCodes Lite V2 Installer.</title> <style type="text/css" media="screen"> body { font-family:helvetica, arial, geneva, sans-serif;font-size:12;color: black; scrollbar-base-color: #005B70; scrollbar-arrow-color: #F3960B; scrollbar-DarkShadow-Color: #000000; } a:visited,a:active,a:hover,a:link { color: black;text-decoration: none; } table,tr,td { font-family:helvetica, arial, geneva, sans-serif;font-size: 12; } img { border:none; } textarea { font-family:helvetica, arial, geneva, sans-serif;font-size:12;color: black; } </style> </head> <h1>McCodes Lite V2 Install Process.</h1> <?php $_REQUEST['action'] = isset($_REQUEST['action']) && is_string($_REQUEST['action']) ? strtolower(trim($_REQUEST['action'])) : false; //check the action is a word switch($_REQUEST['action']) { default: Start_my_install(); break; case'installl':Done_my_install(); break; } function Done_my_install() { echo'Step 1. Config -> <span style="font-weight: 800px;">Step 2. Install.</span><br />'; echo'<script type="text/javascript"> function notice() { alert(\'This file will be delete when you have installed the game.\'); } <body onload\'notice()\'> '; if(!is_writable('mysql.php')) { echo'<script type="text/javascript"> function error_1() { alert(\'Error. The file mysql.php is not writeable, please CHMOD it to 0777.\'); } </script> <body onload=\'error_1()\'> '; exit; } if(!$_POST['dbHostName'] || !$_POST['dbUserName'] || !$_POST['dbDatabase'] || !$_POST['adUsername'] || !$_POST['adPassword'] || !$_POST['adCPassword'] || !$_POST['adEmail']) { echo'<script type="text/javascript"> function error_2() { alert(\'Error. You missed one or more fields Go back and try again.\'); } </script> <body onload=\'error_2()\'> '; exit; } if($_POST['adPassword'] != $_POST['adCPassword']) { echo'<script type="text/javascript"> function error_3() { alert(\'Error. The passwords you spplied, do not match.\'); } </script> <body onload=\'error_3()\'> '; exit; } $c = mysql_connect($_POST['dbHostName'], $_POST['dbUserName'], $_POST['dbPassword']) or die("<span style='font-color: red; font-weight: 800px;>INSTALLATION ERROR:</span><span style='font-weight: 800px;> ".mysql_error()."<br />> <a href='installer.php'>Back</a></span>"); mysql_select_db($_POST['dbDatabase'], $c) or die("<span style='font-color: red; font-weight: 800px;>INSTALLATION ERROR:</span><span style='font-weight: 800px;> ".mysql_error()."<br />> <a href='installer.php'>Back</a></span>"); $l=fopen("mysql.php","w"); $mykey=rand(1,2147483647); fwrite($l,"<?php \$c = mysql_connect('{$_POST['dbHostName']}', '{$_POST['dbUserName']}', '{$_POST['dbPassword']}'); mysql_select_db('{$_POST['dbDatabase']}', \$c); \$mykey={$mykey}; ?>"); fclose($l); echo'Wrote mysql.php file..Adding Database...<br />'; $fo=fopen("dbdata.sql","r"); $query=""; $lines=explode("\n",fread($fo,1024768)); fclose($fo); foreach($lines as $line) { if(!(strpos($line,"--") === 0) && $line != "") //check for commented lines or blankies { $query.=$line; if(!(strpos($line,";") === FALSE)) { $query=str_replace(array('adUsername', 'adPassword', 'adEmail'), array($_POST['adUsername'], $_POST['adPassword'], $_POST['adEmail']), $query); mysql_query($query,$c) or die("<span style='font-color: red; font-weight: 800px;>INSTALLATION ERROR:</span><span style='font-weight: 800px;> ".mysql_error()."<br />> <a href='installer.php'>Back</a></span>"); $query=""; } } } echo'Wrote Database..Making crons...<br />'; $path=$_SERVER['HTTP_HOST'].str_replace('installer.php','',$_SERVER['SCRIPT_NAME']); $cj1="http://".$path."cron_fivemins.php?code=".md5($path.$mykey); $cj2="http://".$path."cron_day.php?code=".md5($path.$mykey); echo'<hr /><span style="font-weight: 800px;">Done!<hr />Do not close this window!</span><br /> You need to install these crons into cPanel or whatever Control panel you have.<br /> <pre> */5 * * * * curl '.$cj1.' 0 0 * * * curl '.$cj2.' </pre> When you have done this, login and Enjoy McCodes Lite V2.'; unlink("installer.php"); } function Start_my_install() { echo'<span style="font-weight: 800px;">Step 1. Config</span> -> Step 2. Install.<br />'; if(!is_writable('mysql.php')) { echo'<script type="text/javascript"> function error_1() { alert(\'Error. The file mysql.php is not writeable, please CHMOD it to 0777.\'); } </script> <body onload=\'error_1()\'> '; exit; } ?><span style="font-weight: 800px;">Database Details:</span><br /> <form action='?action=installl' method='post'> <table width='70%' border='1'> <tr> <td>MySQL Hostname:<br /> <small><span style="font-weight: 800px;">localhost</span> is the default on most servers.</small></td> <td><input type='text' name='dbHostName' /></td> </tr> <tr> <td>MySQL Username:</td> <td><input type='text' name='dbUserName' /></td> </tr> <tr> <td>MySQL Password:</td> <td><input type='password' name='dbPassword' /></td> </tr> <tr> <td>MySQL Database:<br /> <small>Please make sure the user has access to the database.</small></td> <td><input type='text' name='dbDatabase' /></td> </tr> </table> <hr /> <span style="font-weight: 800px;">Game Admin Details</span><br /> <table width='70%' border='1'> <tr> <td>Admin Username:</td> <td><input type='text' name='adUsername' /></td> </tr> <tr> <td>Admin Password:</td> <td><input type='password' name='adPassword' /></td> </tr> <tr> <td>Confirm Password:</td> <td><input type='password' name='adCPassword' /></td> </tr> <tr> <td>Admin Email Address:</td> <td><input type='text' name='adEmail' /></td> </tr> </table> <input type='submit' value='Install' /> </form> <?php } ?> </body></html>
Title: Re: [Re-Code] Installer
Post by: dominion on December 18, 2009, 05:18:14 PM
nice work i will test it in a few mins for you
edit - works fine :)
Title: Re: [Re-Code] Installer
Post by: Danny696 on December 19, 2009, 07:22:13 AM
Thanks.
Title: Re: [Re-Code] Installer
Post by: Danny696 on December 22, 2009, 01:10:08 PM
Updated, the file will delete itself after install.
Title: Re: [Re-Code] Installer
Post by: Cronus on December 22, 2009, 03:55:11 PM
Very nice danny, that should make it a bit easier for the beginners.
Title: Re: [Re-Code] Installer
Post by: Danny696 on December 22, 2009, 04:23:03 PM
I originally had a pop-up saying delete it, i just changed it to say it will be delete and then unlinked it.
Title: Re: [Re-Code] Installer
Post by: HauntedDawg on December 23, 2009, 07:58:37 AM
I see you have used multiple javascript in this. I would go for an ajax installer. Oh and you might want to google on how to setup crons into the crontab via PHP. So it's all automatic.
Title: Re: [Re-Code] Installer
Post by: Cronus on December 23, 2009, 10:58:04 AM
Good thinking HD, there should end up being only one or two cron in the end though, I'd like to mostly run on timestamps
Title: Re: [Re-Code] Installer
Post by: Danny696 on December 23, 2009, 11:22:18 AM
Thanks HD, more work ;) Ill check them out, and i only know javascrip alert and write :P
Title: Re: [Re-Code] Installer
Post by: Danny696 on December 23, 2009, 11:34:07 AM
just a question, isnt anyone else gonna do a page/script. -.-
Title: Re: [Re-Code] Installer
Post by: catles on December 23, 2009, 04:53:37 PM
someone esle will... or i will just at a later time lol
Title: Re: [Re-Code] Installer
Post by: Cronus on December 24, 2009, 01:50:56 PM
Keep the topic on subject. Also its the holidays, people are busy, can't expect them to be sitting around programming lol
Title: Re: [Re-Code] Installer
Post by: HauntedDawg on December 27, 2009, 01:30:09 PM
i would suggest removing crons totaly as the server you are running on might not support minute crons. An ajax installer would deffinatly go well..
Title: Re: [Re-Code] Installer
Post by: crimevillage on January 04, 2010, 11:27:17 PM
ok for this game we are all working on do we save it to the MCCodes Lite v1.0 - UNEDITED.rar and re upload it or what?
Title: Re: [Re-Code] Installer
Post by: Danny696 on January 05, 2010, 01:29:04 AM
Make a new post with your mod in.
Title: Re: [Re-Code] Installer
Post by: crimevillage on January 05, 2010, 01:34:54 PM
Ok thanks Danny
Title: Re: [Re-Code] Installer
Post by: Spudinski on February 07, 2010, 05:26:08 AM
I'd think that would be a rather good idea Haunted, then the installer can become a web installer, using ftp to download, and the main system user to alter permissions of directories and similar tasks. Only thing about that concept is; what if the user isn't running unix/linux, and rather windows?
Title: Re: [Re-Code] Installer
Post by: HauntedDawg on February 14, 2010, 11:40:52 AM
I'd think that would be a rather good idea Haunted, then the installer can become a web installer, using ftp to download, and the main system user to alter permissions of directories and similar tasks. Only thing about that concept is; what if the user isn't running unix/linux, and rather windows?
Then you create an installer for window's?
Title: Re: [Re-Code] Installer
Post by: Spudinski on February 14, 2010, 01:11:33 PM
Also true, but there are a few features Linux uses that Win does not, and visa versa. But I guess if you take the main problem, crontabs, everything else can be done trough the COM interface of Win - if even needed.
Title: Re: [Re-Code] Installer
Post by: HauntedDawg on February 22, 2010, 06:55:47 PM
A simple, yet effective way is to just produce a simple free version, yet standard mccode's v1 and v2 with timestamps to trigger what ever is needed.
|