Cronwerks MCCode/MCCodes Forums

Please login or register.

Login with username, password and session length

News:

Have you purchased a mod and lost your copy? Just file a support ticket through your "My Mods" page.


This forum is now closed and has moved to a new location! Click here to find out why.
Pages: [1] 2

AuthorTopic: [Re-Code] Installer  (Read 1853 times)

Danny696

  • Senior Member
  • ****
  • Reputation Power: 317
  • Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.
  • Offline Offline
  • Posts: 540
    • View Profile
    • WWW
[Re-Code] Installer
« on: December 18, 2009, 05:15:35 PM »
Where else to start, than the installer.php.  Has not been tested.
Heres mine:
Code: [Select]
<?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 />&gt; <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 />&gt; <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 />&gt; <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>
« Last Edit: December 22, 2009, 01:09:51 PM by danny696 »
Logged
Project Choosen - 10%
Daniel - Hanson . Com

dominion

  • Active Member
  • **
  • Reputation Power: 89
  • dominion barely matters.dominion barely matters.
  • Offline Offline
  • Posts: 129
    • View Profile
    • Email
Re: [Re-Code] Installer
« Reply #1 on: December 18, 2009, 05:18:14 PM »
nice work i will test it in a few mins for you

edit - works fine :)
« Last Edit: December 18, 2009, 05:36:26 PM by dominion »
Logged

Danny696

  • Senior Member
  • ****
  • Reputation Power: 317
  • Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.
  • Offline Offline
  • Posts: 540
    • View Profile
    • WWW
Re: [Re-Code] Installer
« Reply #2 on: December 19, 2009, 07:22:13 AM »
Thanks.
Logged
Project Choosen - 10%
Daniel - Hanson . Com

Danny696

  • Senior Member
  • ****
  • Reputation Power: 317
  • Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.
  • Offline Offline
  • Posts: 540
    • View Profile
    • WWW
Re: [Re-Code] Installer
« Reply #3 on: December 22, 2009, 01:10:08 PM »
Updated, the file will delete itself after install.
Logged
Project Choosen - 10%
Daniel - Hanson . Com

Cronus

  • Administrator
  • Senior Member
  • *****
  • Reputation Power: 2901
  • Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!
  • Offline Offline
  • Posts: 550
    • MSN Messenger - preston__08@hotmail.com
    • View Profile
    • WWW
Re: [Re-Code] Installer
« Reply #4 on: December 22, 2009, 03:55:11 PM »
Very nice danny, that should make it a bit easier for the beginners.
Logged
My msn is preston__08@hotmail.com if anyone is interested, I am online frequently.

Danny696

  • Senior Member
  • ****
  • Reputation Power: 317
  • Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.
  • Offline Offline
  • Posts: 540
    • View Profile
    • WWW
Re: [Re-Code] Installer
« Reply #5 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.
Logged
Project Choosen - 10%
Daniel - Hanson . Com

HauntedDawg

  • Basic Member
  • *
  • Reputation Power: 12
  • HauntedDawg has no influence.
  • Offline Offline
  • Posts: 25
    • View Profile
Re: [Re-Code] Installer
« Reply #6 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.
Logged

Cronus

  • Administrator
  • Senior Member
  • *****
  • Reputation Power: 2901
  • Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!
  • Offline Offline
  • Posts: 550
    • MSN Messenger - preston__08@hotmail.com
    • View Profile
    • WWW
Re: [Re-Code] Installer
« Reply #7 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
Logged
My msn is preston__08@hotmail.com if anyone is interested, I am online frequently.

Danny696

  • Senior Member
  • ****
  • Reputation Power: 317
  • Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.
  • Offline Offline
  • Posts: 540
    • View Profile
    • WWW
Re: [Re-Code] Installer
« Reply #8 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
Logged
Project Choosen - 10%
Daniel - Hanson . Com

Danny696

  • Senior Member
  • ****
  • Reputation Power: 317
  • Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.
  • Offline Offline
  • Posts: 540
    • View Profile
    • WWW
Re: [Re-Code] Installer
« Reply #9 on: December 23, 2009, 11:34:07 AM »
just a question, isnt anyone else gonna do a page/script. -.-
Logged
Project Choosen - 10%
Daniel - Hanson . Com

catles

  • Basic Member
  • *
  • Reputation Power: 24
  • catles has no influence.
  • Offline Offline
  • Posts: 26
    • View Profile
    • WWW
    • Email
Re: [Re-Code] Installer
« Reply #10 on: December 23, 2009, 04:53:37 PM »
someone esle will... or i will just at a later time lol
Logged

Cronus

  • Administrator
  • Senior Member
  • *****
  • Reputation Power: 2901
  • Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!
  • Offline Offline
  • Posts: 550
    • MSN Messenger - preston__08@hotmail.com
    • View Profile
    • WWW
Re: [Re-Code] Installer
« Reply #11 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
Logged
My msn is preston__08@hotmail.com if anyone is interested, I am online frequently.

HauntedDawg

  • Basic Member
  • *
  • Reputation Power: 12
  • HauntedDawg has no influence.
  • Offline Offline
  • Posts: 25
    • View Profile
Re: [Re-Code] Installer
« Reply #12 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..
Logged

crimevillage

  • Basic Member
  • *
  • Reputation Power: 2
  • crimevillage has no influence.
  • Offline Offline
  • Posts: 4
    • View Profile
    • Email
Re: [Re-Code] Installer
« Reply #13 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?
Logged

Danny696

  • Senior Member
  • ****
  • Reputation Power: 317
  • Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.
  • Offline Offline
  • Posts: 540
    • View Profile
    • WWW
Re: [Re-Code] Installer
« Reply #14 on: January 05, 2010, 01:29:04 AM »
Make a new post with your mod in.
Logged
Project Choosen - 10%
Daniel - Hanson . Com
Pages: [1] 2
« previous next »
 


This forum is now closed and has moved to a new location! Click here to find out why.