Location: PHPKode > scripts > CosmicCounter > counter/install.php
<?

##-----------------------------------------------------------------##
##                                                                 ##
##                                                                 ##
## © Copyright Stephen Heylings 2003. All rights reserved. No part ##
## of this or any of the attached documents shall be               ##
## reproduced/stored in any way whatsoever without written         ##
## permission from the Copyright holder.                           ##
##   The Copyright holder holds no responsibility for errors or    ##
## omissions. No liability is assumed in any way for damages       ##
## resulting from the use of this document/program.                ##
##                                                                 ##
## Have a nice day.                                                ##
##                                                                 ##
##                                                                 ##
##-----------------------------------------------------------------##

if ($action=="") 
{
	$action="step1";
}

switch ($action)
{
case "save1":
	$str="<? $"."filename='".$filename."';  $"."imgdir='".$imgdir."';  $"."image=".$image.";?>";
	fwrite(fopen("config.php","w+"), $str) or die ("Directory CHMOD not set!");
	if (!fopen($filename,"w+")) 
	{
		echo "Directory CHMOD not set!";
	}

PRINT <<<END
	<Script language="Javascript">
		self.location = '$PHP_SELF?action=step2';
	</script>
END;
break;

case "save2":
	if ($ch=="a") 
	{
		if (chmod($filename,0777)) 
		{
			PRINT <<<END
				CHMOD successful.<br>"; else echo "Couldn't CHMOD, please do it manually.
END;
		}
	}
	$link="http://$HTTP_HOST".$PHP_SELF;
	$code="&lt;? inclu"."de('$link') ?&gt;";

PRINT <<<END
	Install Complete<br>Please copy and paste the following code into your pages : <br><br><code>$code</code><br>
	<br><p><font color=red>Don't forget to delete this page</font>
END;

break;

case "step2":
	include ("config.php");
	
	PRINT <<<END
	<html>
	<head>
	<title>Install -- STEP 2</title>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	</head>
	
	<body>
	<div align="center">
		<p><font face="Verdana" size=2><b>Install Script</b></font></p>
	  <p><font face="Verdana" size=2>Your install is complete but you must CHMOD
	    $filename to 755 (or 777)</font></p>
	  <p><font face="Verdana" size=2>We may CHMOD it automatically but this is not always
	    possible. </font></p>
	  <form action="$PHP_SELF" method="get" name="form2" id="form2">
	  <input type="hidden" name="action" value="save2">
	    <div align="left">
	      <p align="center">
	        <font face="Verdana" size=2>
	        <select name="ch" id="ch">
	          <option value="a" selected>Attempt to CHMOD automatically</option>
	          <option value="m">Do it manually</option>
	        </select>
	        </font>
	      </p>
	      <div align="left">
	        <p align="center">
	        <code>Please CHMOD manually before continuing...</code><br><br>
	          <input type="submit" value="Next >>">
	          <input type="reset" value="Reset">
	        </p>
	      </div>
	  </div>
	  </form>
	  <p align="left">&nbsp; </p>
	</div>
	<center><font size=1 face=verdana>
	<br><br><br><br>
	&copy;<a href=http://www.cosmicphp.com>CosmicPHP</a> 2003
	</font></center></body>
	</html>
END;
break;

default:
PRINT <<<END
	<html>
	<head>
	<title>Install --- STEP 1</title>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	</head>

	<body>
	<div align="center">
		<p><font face="Verdana" size=2><b>Install Script</b></font></p>
		<p>&nbsp;</p>

		<form action="$PHP_SELF" method="get" name="form1" id="form1">
			<div align="left">
				<p><font face="Verdana" size=2>
					File name where to store data :
					<input name="filename" type="text" id="filename" value="counter.txt">
					<input name="action" type="hidden" id="action" value="save1">
				</font></p>
				
				<p><font face="Verdana" size=2>
					Directory where images can be found :
					<input name="imgdir" type="text" id="imgdir" value="numbers">
					<em>(Please remove the trailing slash &quot;/&quot;)</em>
				</font></p>
				
				<p><font face="Verdana" size=2>
					Display :
					<select name="image" id="image">
						<option value="1" selected>Images</option>
						<option value="0">Numbers</option>
					</select>
				</font></p>
				
				<div align="center">
					<input type="submit" value="Save Changes">
				</div>
				
				<p>&nbsp; </p>
			</div>
		</form>
		<p align="left">&nbsp; </p>
	</div>
	<center>
	<font size=1 face=verdana>
	<br><br><br><br>
		&copy;<a href=http://www.cosmicphp.com>CosmicPHP</a> 2003
	</font></center></body></html>
END;
break;
}

?>
Return current item: CosmicCounter