Scripts

PHP Setup Creator

Ooit heb ik een PHP Setup gemaakt maar die moest je in de script veranderen. Hier heb ik een maker ervoor. Je kunt gewoon met forms alles instellen. Probeer het maar eens uit. Hij slaat wel alles op in de /files/ map. Dit keer zit er ook een uninstaller bij! De session wordt nu gemaakt gebaseerd op je IP. Dus geen Session already exists meer!

php-setup-creator
Maak eerst de map: files aan met CHMOD 777.
Alle process bestanden zijn aangegeven met: p_

//////////////////
///index.php///
/////////////////
[code]
<?php

$ip=$_SERVER['REMOTE_ADDR'];

?>
<div align=center>
Welcome to the Setup Creator!
This generator will help you creating a stand-alone setup of all your php files!
But first you must click this button to create a session!
<form action="p_index.php" type="application/x-www-form-urlencoded">
Give up a session name!<INPUT type="hidden" name="sess" value="<?php echo $ip ?>"><br>
<INPUT type="submit" value="Create Session">
</form>
</div>
[/code]

////////////////////
///p_index.php//
///////////////////
[code]
<?php

include('functions.php');
$sess=$_GET['sess'];
if (file_exists('files/'.$sess.'/sess.lock'))
{
   alert('Session already exists\nWait 30 minutes or choose another name!');
   back();
}
Else
{
   mkdir ("files/".$sess."", 0755);
   create("files/".$sess."/sess.lock", "");
   create("files/".$sess."/setup.php", "<?php\n\n//Start Config Part");
   create("files/".$sess."/uninstall.php", "<?php\n\n//Start Config Part");
}

redirect('config.php?sess='.$sess);

?>
[/code]

///////////////////
////config.php///
///////////////////
[code]
<?php

$sess=$_GET['sess'];

?>
<div align=center>
Fill in these forms!
<form action="p_config.php" type="application/x-www-form-urlencoded">
<INPUT type="hidden" name="sess" value="<?php echo $sess ?>">
Enter the name of the program:<br>
<INPUT type="text" name="n"><br>
Enter the image host of the program:<br><INPUT type="text" name="i" value="http://renrik.freehostia.com/setup/img/"><br>The host: http://renrik.freehostia.com/setup/img/ is recommened!<br>
Enter the file to be opened after the install:<br><INPUT type="text" name="d"><br>
<INPUT type="submit" value="Submit">
</form>
</div>
[/code]

///////////////////
//p_config.php//
//////////////////
[code]
<?php

$sess=$_GET['sess'];

include('functions.php');
$n=$_GET['n'];
$i=$_GET['i'];
$d=$_GET['d'];
$nw='$name';
$iw='$img_host';
$dw='$done';

add("files/".$sess."/setup.php", "\n".$nw."='".$n."';\n".$iw."='".$i."';\n".$dw."='".$d."';\n//End Config Part\n\n");
add("files/".$sess."/uninstall.php", "\n".$nw."='".$n."';\n".$iw."='".$i."';\n//End Config Part\n\n");
$inpat1 = implode ('', file ('inpat1.php'));
add("files/".$sess."/setup.php", $inpat1);
$unpat1 = implode ('', file ('unpat1.php'));
add("files/".$sess."/uninstall.php", $unpat1);

redirect('files.php?sess='.$sess.'');

?>
[/code]

//////////////////
////files.php////
/////////////////
[code]
<?php

$sess=$_GET['sess'];

?>
<div align=center>
<form action="p_files.php" type="application/x-www-form-urlencoded">
<INPUT type="hidden" name="sess" value="<?php echo $sess ?>">
Enter the filename here:<br><INPUT type="text" name="filename"><br>
Enter the script here:<br><textarea name="filedata" rows="30" cols="120"></textarea><br>
<INPUT type="submit" value="Submit!">
</form>
</div>
[/code]

///////////////////
///p_files.php///
///////////////////
[code]
<?php

$sess=$_GET['sess'];
$mode=$_GET['mode'];
$filn=$_GET['filename'];
$fild=$_GET['filedata'];
include('functions.php');

$fila=urlencode($fild);

If ( $mode == '' )
{
   add("files/".$sess."/setup.php", "   create('".$filn."', '".$fila."');\n");
   add("files/".$sess."/uninstall.php", "   unlink('".$filn."');\n");
   redirect('p_files.php?sess='.$sess.'&mode=form');
}
Else If ( $mode == 'form' )
{
   ?><form action="p_files.php" type="application/x-www-form-urlencoded">
   <INPUT type="hidden" name="sess" value="<?php echo $sess ?>">
   Do you want to add another file?<br>
   <INPUT type="submit" name="mode" value="Yes">
   <INPUT type="submit" name="mode" value="No"></form><?php
}
Else If ( $mode == 'Yes' )
{
   redirect('files.php?sess='.$sess);
} 
Else If ( $mode == 'No' )
{
   $inpat2 = implode ('', file ('inpat2.php'));
   $unpat2 = implode ('', file ('unpat2.php'));
   add("files/".$sess."/uninstall.php", $unpat2);
   $unins = implode ('', file ('files/'.$sess.'/uninstall.php'));
   $unpadder = urlencode($unins);
   add("files/".$sess."/setup.php", "   create('uninstall.php', '".$unpadder."');\n");
   add("files/".$sess."/setup.php", $inpat2);
   redirect('download.php?sess='.$sess);
}

?>
[/code]

///////////////////
//functions.php//
///////////////////
[code]
<?php

function alert($alert)
{
   print('<script language=javascript> alert("'.$alert.'"); </script>');
}

function back()
{
   print('<script language=javascript> history.go(-1); </script>');
}

function create($filename, $filedata)
{
   $fh = fopen($filename, 'w') or die("can't open file");
   fwrite($fh, $filedata);
   fclose($fh);
}

function add($filename, $filedata)
{
   $fh = fopen($filename, 'a') or die("can't open file");
   fwrite($fh, $filedata);
   fclose($fh);
}

function redirect($url)
{
   print('<script language=javascript> window.location.reload("'.$url.'"); </script>');
}

?>
[/code]

Hier zijn de klaargezette scripts:
/////////////////
///inpat1.php//
/////////////////
[code]
function create($filename, $filedata)
{
   $filedat1 = urldecode($filedata);
   $filedat2 = stripslashes($filedat1);
   $fh = fopen($filename, 'w') or die("can't open file");
   fwrite($fh, $filedat2);
   fclose($fh);
}

$step=$_GET['step'];
If ( $step == '' )
{
   $step=1;
}
echo '<HTML><HEAD><meta http-equiv="imagetoolbar" content="no"><title>'.$name.' setup :: Step: '.$step.'</title>';

If ( $step == '1' )
{
   $text='Welcome to the setup of '.$name.'. We are happy you decided to use our software on your webserver. This setup will create the neccesary files on your server.<br><br><br><br>Press the Next button!';
}
Else If ( $step == '2' )
{

[/code]

//////////////////
///inpat2.php///
/////////////////
[code]
   $text='The files have been uninstalled succesfully!';
}
Else If ( $step == '3' )
{
   $text='Press the finish button to completely delete this file (uninstaller) too!';
}
Else
{
   ?> <script language=javascript>
   alert("You left the knows steps, please try again!");
   history.go(-1);
   </script><?php
}

$next=$step + 1;
$prev=$step - 1;
If ( $prev == '0' )
{
   $prev='1';
}

?>
<!-- Start Design Part --!>
<IMG src="<?php echo $img_host ?>back.jpg" alt="" align="top" border="0" width="574" height="439" style="position:absolute;left:188px;top:40px;width:574px;height:439px;z-index:0">
<A href="javascript:window.close();"><IMG src="<?php echo $img_host ?>close.jpg" alt="Close the setup of <?php echo $name ?>" align="top" border="0" width="34" height="40" style="position:absolute;left:713px;top:43px;width:34px;height:40px;z-index:1"></A>
<DIV style="position:absolute;left:231px;top:55px;width:481px;height:16px;z-index:2" align="left">
<FONT style="font-size:13px" color="#FFFFFF" face="Arial"><?php echo $name ?> setup :: Step: <?php echo $step ?></FONT>
</DIV>
<DIV style="position:absolute;left:373px;top:96px;width:353px;height:16px;z-index:3" align="left">
<FONT style="font-size:13px" color="#000000" face="Arial"><?php echo $text ?></FONT>
</DIV>
<button onclick="javascript:window.close();" style="position:absolute;left:650px;top:423px;width:75px;height:24px;z-index:4">Exit</button>
<?php
If ( $step == '3' )
{
   ?><form action="uninstall.php" type="application/x-www-form-urlencoded">
   <INPUT type="submit" name="" value="Finish" style="position:absolute;left:563px;top:423px;width:75px;height:24px;z-index:5">
   <INPUT type="hidden" name="deletethis" value="1">
   </form><?php
}
Else
{
   ?><form action="uninstall.php" type="application/x-www-form-urlencoded">
   <INPUT type="hidden" name="step" value="<?php echo $next ?>">
   <INPUT type="submit" name="" value="Next" style="position:absolute;left:563px;top:423px;width:75px;height:24px;z-index:5">
   </form><?php
}
?><form action="uninstall.php" type="application/x-www-form-urlencoded">
<INPUT type="hidden" name="step" value="<?php echo $prev ?>">
<INPUT type="submit" name="" value="Previous" style="position:absolute;left:476px;top:423px;width:75px;height:24px;z-index:6">
</form>
<!-- End Design Part --!>
[/code]

/////////////////
//unpat1.php//
/////////////////
[code]
function create($filename, $filedata)
{
   $fh = fopen($filename, 'w') or die("can't open file");
   fwrite($fh, $filedata);
   fclose($fh);
}

$step=$_GET['step'];
$deti=$_GET['deletethis'];
If ( $deti == '1' )
{
   unlink('uninstall.php');
}
If ( $step == '' )
{
   $step=1;
}
echo '<HTML><HEAD><meta http-equiv="imagetoolbar" content="no"><title>'.$name.' uninstall :: Step: '.$step.'</title>';

If ( $step == '1' )
{
   $text='Welcome to the uninstaller of '.$name.'! This file lets you uninstall all the files that are installed with the setup!<br><br>Please set this directory to CHMOD 777.<br><br>Press the Next button!';
}
Else If ( $step == '2' )
{

[/code]

/////////////////
//unpat2.php//
////////////////
[code]
   $text='The files have been uninstalled succesfully!';
}
Else If ( $step == '3' )
{
   $text='Press the finish button to completely delete this file (uninstaller) too!';
}
Else
{
   ?> <script language=javascript>
   alert("You left the knows steps, please try again!");
   history.go(-1);
   </script><?php
}

$next=$step + 1;
$prev=$step - 1;
If ( $prev == '0' )
{
   $prev='1';
}

?>
<!-- Start Design Part --!>
<IMG src="<?php echo $img_host ?>back.jpg" alt="" align="top" border="0" width="574" height="439" style="position:absolute;left:188px;top:40px;width:574px;height:439px;z-index:0">
<A href="javascript:window.close();"><IMG src="<?php echo $img_host ?>close.jpg" alt="Close the setup of <?php echo $name ?>" align="top" border="0" width="34" height="40" style="position:absolute;left:713px;top:43px;width:34px;height:40px;z-index:1"></A>
<DIV style="position:absolute;left:231px;top:55px;width:481px;height:16px;z-index:2" align="left">
<FONT style="font-size:13px" color="#FFFFFF" face="Arial"><?php echo $name ?> setup :: Step: <?php echo $step ?></FONT>
</DIV>
<DIV style="position:absolute;left:373px;top:96px;width:353px;height:16px;z-index:3" align="left">
<FONT style="font-size:13px" color="#000000" face="Arial"><?php echo $text ?></FONT>
</DIV>
<button onclick="javascript:window.close();" style="position:absolute;left:650px;top:423px;width:75px;height:24px;z-index:4">Exit</button>
<?php
If ( $step == '3' )
{
   ?><form action="uninstall.php" type="application/x-www-form-urlencoded">
   <INPUT type="submit" name="" value="Finish" style="position:absolute;left:563px;top:423px;width:75px;height:24px;z-index:5">
   <INPUT type="hidden" name="deletethis" value="1">
   </form><?php
}
Else
{
   ?><form action="uninstall.php" type="application/x-www-form-urlencoded">
   <INPUT type="hidden" name="step" value="<?php echo $next ?>">
   <INPUT type="submit" name="" value="Next" style="position:absolute;left:563px;top:423px;width:75px;height:24px;z-index:5">
   </form><?php
}
?><form action="uninstall.php" type="application/x-www-form-urlencoded">
<INPUT type="hidden" name="step" value="<?php echo $prev ?>">
<INPUT type="submit" name="" value="Previous" style="position:absolute;left:476px;top:423px;width:75px;height:24px;z-index:6">
</form>
<!-- End Design Part --!>
[/code]

Reacties

0
Nog geen reacties.