After editing a php file add new user

s_dastjani

Verified User
Joined
Jun 16, 2014
Messages
6
hello
What's a config.php file after making a add new user and password database that can be edited?
config.php Is in public_html

I am using this code to create a database
And then I want to store variables in config.php file

Code:
# read mysql access stuff
DA_MYSQL=/usr/local/directadmin/conf/mysql.conf
DA_USER=`cat $DA_MYSQL | grep user= | cut -d= -f2`
DA_PASS=`cat $DA_MYSQL | grep passwd= | cut -d= -f2`

NEW_DB="${username}_db1"
NEW_USER="${username}@localhost"

# create database
mysql -u $DA_USER -p$DA_PASS --execute="CREATE DATABASE $NEW_DB"

#create user
mysql -u $DA_USER -p$DA_PASS --execute="GRANT ALL on $NEW_DB.* to $NEW_USER identified by '${passwd}'"

#create default user
NEW_USER="${username}_usr@localhost"
mysql -u $DA_USER -p$DA_PASS --execute="GRANT ALL on $NEW_DB.* to $NEW_USER identified by '${passwd}'"

code config.php
Code:
<?php

$database = "domain_domain";		//Datenbankname
$sqlhost = "localhost";    	//Datenbank Hostname
$sqluser = "domain_domain";         	//Datenbank Username
$sqlpass = "15824135113";    			//Datenbank Passwort
?>

Thank
 
What link doesn't exist? The link posted by user scsi, which you quoted in your reply, does exist and works for me.

Jeff
 
There is no answer my question in link
I have written the script, but the problem was

Code:
# read mysql access stuff
DA_MYSQL=/usr/local/directadmin/conf/mysql.conf
DA_USER=`cat $DA_MYSQL | grep user= | cut -d= -f2`
DA_PASS=`cat $DA_MYSQL | grep passwd= | cut -d= -f2`

NEW_DB="${username}_db1"
NEW_USER="${username}@localhost"

# create database
mysql -u $DA_USER -p$DA_PASS --execute="CREATE DATABASE $NEW_DB"

#create user
mysql -u $DA_USER -p$DA_PASS --execute="GRANT ALL on $NEW_DB.* to $NEW_USER identified by '${passwd}'"

#create default user
NEW_USER="${username}_usr@localhost"
mysql -u $DA_USER -p$DA_PASS --execute="GRANT ALL on $NEW_DB.* to $NEW_USER identified by '${passwd}'"

#!/usr/bin/perl -w
use strict;
use warnings;
my $line = 0;
my @newlines;
my $file_name = "/home/user/domains/domain.com/public_html/config.php";
open(my $fh, '<', $file_name) || die "file could not open $! \n";
while( $line = <$fh>) {
        $line =~ s/domain_domain/$NEW_USER/ig;
        $line =~ s/15824135113/${passwd}/ig;
        push(@newlines,$line);

}
close($fh);
open(my $file, '>', $file_name) || die "file could not open $! \n";
print $file @newlines;
close($file);
 
why you dont use directadmin api?
its very simple and secure
check this link:
http://directadmin.com/api.html

you can do Creating Accounts
Get Reseller's List of IP and IP information
Deleting Accounts
Suspending/Activating Accounts
Get List of Users owned by Reseller
Get List of Resellers on server
Get List of Admins on server
Get List of all Users on server
Modifying Accounts
Server Information
Reseller and User Packages
Sessions and Passwords
User APIs
Email accounts and password changing
and ....
 
Back
Top