Zubrag.com
June 23, 2018, 02:17:44 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Adding an (A) record Automatically  (Read 2704 times)
beng1990
Newbie
*
Posts: 1


« on: January 14, 2014, 11:59:10 AM »

Hi

I am very sorry in advance for my lack in coding skills but i have put together this script with that makes a sql database adds a user and uploads a sql database depending on what plan is picked.

I would like it to also add an (A) record for for a domain would you be able to give me a hand in doing it please, i have been trying but I cant get it to work.

Regards



<?php

// your cPanel username
$cpanel_user = 'USERNAME';

// your cPanel password
$cpanel_pass = 'PASSWORD';

// your cPanel skin
$cpanel_skin = 'x3';

// your cPanel domain
$cpanel_host = 'HOSTADDRESS';

// database username
$db_user = 'SQLUSER';

// database username
$db_website = $_POST['websitenameform'];

// database password
$db_pass = 'PASSWORD';

// Index.html
$cpanel_url = 'USER_' ;
$db_name= $_POST['dbnameform'];
$db_domain_name= $_POST['domainnameform'];

// Database
$mysqlHostName ='localhost';

// SQL File
$mysqlImportFilename = $_POST['importnameform'];


// create the database
//try for http or https and maby change port to 2082 or 2083 or better check that from cpanel
$site = "https://$cpanel_user:$cpanel_pass@$cpanel_host:2083/frontend/$cpanel_skin/sql/";
$result = file_get_contents("{$site}addb.html?db={$db_name}");
$result = file_get_contents("{$site}addusertodb.html?user={$db_user}&db={$db_name}&ALL=ALL");




//DONT EDIT BELOW THIS LINE
//Export the database and output the status to the page
$command='mysql -h' .$mysqlHostName .' -u' .$db_user .' -p' .$db_pass .' ' .$db_name .' < ' .$mysqlImportFilename;
exec($command,$output=array(),$worked);
switch($worked){
    case 0:
        echo 'Creation of <b>' .$db_name .'</b> was successfully<br/>';
        echo 'Permissions Added for <b>' .$db_user .'</b><br/>';
        echo 'Added rows for  <b>' .$db_name .'</b><br/>';
        echo 'Import file <b>' .$mysqlImportFilename .'</b> successfully imported to database <b>' .$db_name .'</b>';
        break;
    case 1:
        echo 'There was an error during import. Please make sure the import file is saved in the same folder as this script and check your values:<br/><br/><table><tr><td>MySQL Database Name:</td><td><b>' .$mysqlDatabaseName .'</b></td></tr><tr><td>MySQL User Name:</td><td><b>' .$mysqlUserName .'</b></td></tr><tr><td>MySQL Password:</td><td><b>NOTSHOWN</b></td></tr><tr><td>MySQL Host Name:</td><td><b>' .$mysqlHostName .'</b></td></tr><tr><td>MySQL Import Filename:</td><td><b>' .$mysqlImportFilename .'</b></td></tr></table>';
        break;
}

$con=mysql_connect("$mysqlHostName", "$db_user", "$db_pass")or die("cannot connect"); //mysql connection
mysql_select_db("$db_name")or die("can not select DB"); //select your database

$user_name = 'path';
$user_email = '/data/';
$user_name1 = 'docroot';
$user_email1 = '/users/';
$user_slash = '/';
$update_user = 'user_';

mysql_query("INSERT INTO tf_settings (tf_key, tf_value) VALUES ('$user_name', '{$user_email}{$db_domain_name}'), ('$user_name1', '{$user_email1}{$db_website}{$user_slash}{$db_domain_name}')");
?>   [/sup]

Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC