/    Sign up×
Community /Pin to ProfileBookmark

creating a install.php feature.

I have made a hit counter script but I would like a client to be able to download it upload it and run install.php. They then fill in a form with mysql address password etc, and a config.php file is created with all this information for the script to use, the script then creates tables in the database and then self combusts (deletes its self) how can I go about doing this?

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@NightShift58Jan 28.2007 — The self-combustion part sounds sexy but why?

You could have the install routine reside in your main script so that it will always be available if and when it cannot find "config.php" (please don't call it that...).[code=php]<?
IF (!file_exists["config.php")) {
// (Re-)Install
$everything_ok = install_function();
ENDIF;
?>[/code]
You have to ensure this only comes up when your customer calls up the script and not some visitor trying to increment the counter...
Copy linkTweet thisAlerts:
@PezmcauthorJan 28.2007 — but how do i: make php chmod a folder, create a file and put stuff in the file?
Copy linkTweet thisAlerts:
@NightShift58Jan 28.2007 — Quick and dirty... an excerpt from a script where it had to install itself in a different directory, move itself there and restart itself. Maybe you can get some ideas to get started...[code=php]<?php
$thisDIR = trim($_POST['installDIR']);
IF (substr($thisDIR,0,1) <> "/") :
$thisDIR = "/" . $thisDIR;
ENDIF;
$status = false;
IF (@mkdir($BASEdir . $thisDIR)) :
@chmod($BASEdir . $thisDIR, 0777);
IF (@rename(__FILE__, $BASEdir . $thisDIR . "/" . basename(__FILE__))) :
$status = true;
ELSE :
print "An error has occurred moving the script to the specified directory (<b>$thisDIR</b>).<br>";
print "Please attempt to install the script manually.";
ENDIF;
ELSE :
print "An error has occured creating the directory <b>$thisDIR</b><br>";
print "Please attempt to install the script manually.";
ENDIF;
IF ($status) :
header("Location: " . $BASEhost . $thisDIR . '/' . basename(__FILE__) );
exit;
ENDIF;
?>[/code]
Copy linkTweet thisAlerts:
@PezmcauthorJan 28.2007 — is there not a tutorial of something I can follow?
×

Success!

Help @Pezmc spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...