PDA

View Full Version : Help with making a installer config script


dazz
09-28-03, 02:13 PM
I really like a little help with some coding, i be told this is the place to come :P

What i am trying to do is make a script that a user enters there name, and then that name is then saved into a config.php file as a string.

So when a user say types "sqldb"

It would place in the config

<?
$sql="sqldb"
?>

And so on with other items entered.

MadDog
09-28-03, 02:26 PM
Topic moved to more appropriate forum.

rob2132
09-29-03, 01:42 AM
I really like a little help with some coding, i be told this is the place to come :P

What i am trying to do is make a script that a user enters there name, and then that name is then saved into a config.php file as a string.

So when a user say types "sqldb"

It would place in the config

<?
$sql="sqldb"
?>

And so on with other items entered.


This is very simple. What sort of input are you wanting to accept and why? And, how? After all, this could be a security issue if you just allow for anything to be written to an interpreted script or any config file a script or program would use.

dazz
09-29-03, 03:51 AM
Well i am trying to make a script that allows me to enter the following into a submit field.

Sql username
Sql password
Sql database

Then the details from those 3 above would be copied into a config.php file showing.

$sqluser="input 1 from above"
$sqlpass="input 2 from above"
$sqldata="input 3 from above"

But i need to to write to a config that is already there, so it would only add these lines and not delete the rest of the contents.

Once that is working i need to be able to make a new script that lets me enter a username and a password that then is copied into the sql tables.

So far this only works from 2 files.


Ok this is the installer file for entering the sql details into the database.


<?php

include "admin/conf.php";
$installip="CREATE TABLE IP (
ID bigint(20) NOT NULL auto_increment,
IP varchar(255) NOT NULL default '',
votedfor varchar(255) NOT NULL default '',
time bigint(20) NOT NULL default '0',
PRIMARY KEY(ID)
)";
mysql_query($installip) or die("Sorry, Could not install IP table");
$intalladmin="CREATE TABLE admin (
ID int(11) NOT NULL auto_increment,
adminname varchar(255) NOT NULL default '',
password varchar(255) NOT NULL default '',
PRIMARY KEY(ID)
)";
mysql_query($intalladmin) or die(mysql_error());
$installcategories="CREATE TABLE categories (
ID bigint(20) NOT NULL auto_increment,
catname varchar(255) NOT NULL default '',
PRIMARY KEY(ID)
)";
mysql_query($installcategories) or die("Sorry, Could not install categories");
$installreset="CREATE TABLE reset (
ID bigint(20) NOT NULL auto_increment,
lastreset bigint(20) NOT NULL default '0',
res varchar(255) NOT NULL default '',
PRIMARY KEY(ID)
)";
mysql_query($installreset) or die("Sorry, Could not reset install table");
$installreviews="CREATE TABLE reviews (
ID bigint(20) NOT NULL auto_increment,
atid bigint(20) NOT NULL default '0',
review mediumtext NOT NULL,
name varchar(80) NOT NULL default '',
IP varchar(255) NOT NULL default '',
catid bigint(20) NOT NULL default '0',
PRIMARY KEY(ID)
)";
mysql_query($installreviews) or die("Sorry, Could not install reviews");
$installsites="CREATE TABLE sites (
ID bigint(20) NOT NULL auto_increment,
hitsin bigint(20) NOT NULL default '0',
out bigint(20) NOT NULL default '0',
url varchar(255) NOT NULL default '',
title varchar(40) NOT NULL default '',
description varchar(255) NOT NULL default '',
username varchar(255) NOT NULL default '',
password varchar(255) NOT NULL default '',
button varchar(255) NOT NULL default '',
email varchar(255) NOT NULL default '',
validated int(11) NOT NULL default '0',
allin bigint(20) NOT NULL default '0',
allout bigint(20) NOT NULL default '0',
lastvote bigint(20) NOT NULL default '0',
catparent varchar(255) NOT NULL default '',
totalscore bigint(20) NOT NULL default '0',
totalvotes bigint(20) NOT NULL default '0',
avgvote float NOT NULL default '0',
PRIMARY KEY(ID)
)";
mysql_query($installsites) or die("Sorry, Could not install sites");
$installvoteip="CREATE TABLE voteip (
ID bigint(20) NOT NULL auto_increment,
IP varchar(255) NOT NULL default '0',
votedfor bigint(20) NOT NULL default '0',
time bigint(20) NOT NULL default '0',
PRIMARY KEY(ID)
)";
mysql_query($installvoteip) or die("Sorry, Could not install vote ips");
print "Installed Sucessfully.";
?>



This is the conf file that is used.



<?php
// edit below for username and password for sql database.
$db = mysql_connect("localhost", "dazz", "house") or die("Sorry, Could not connect.");
// edit above for username and password for sql database.
if(!$db) die("no db");



// edit below for the database name you plan to install this into.
if(!mysql_select_db("test",$db))
// edit above for the database name you plan to install this into.
die("Sorry, No database selected.");



//edit below for the path to your install(do not include the slash at the end)
$path="http://local.co.uk/dazz/" ;
//edit below for the path to your install(do not include the slash at the end)


//edit below with the Admin e-mail address.
$adminemail="dazz@";
//edit above with the Admin e-mail address.


//General setting that can be changed.

//Title for this Listings
$title="The listings";

//Allow people to rate sites ? yes/no
$votepage="Yes";

//number of sites per page on Top List.
$numentries=4;

//Allow user reviews to be added ? yes/no
$usereviews="Yes";

//Do you want to verify sites before they are added? yes/no
$adminverify="yes";

//number of days before Listings resets itself.
$resetdays=365;

// These setting are not to be change or no images will show on your Listings.
$showfeatured="yes";
$showbutton="Yes";
$showad="Yes";
?>


As for once this is installed the install file would be deleted so that its no longer able to be used again.

Hope this helps

Thanks for looking at this, i been going no where now.