Jump to content

Recommended Posts

Posted

Hello

Please i am doing a php script that creates a subdomain but it doesn't work

Here is the code


<?
$username = $_POST['subdomain'];
$path="http://seifhate:pass@seifhatem.co.cc:2082/frontend/x3/subdomain/doadddomain.html?rootdomain=seifhatem.co.cc&domain=$username";
$f = fopen($path, "r");
echo $path;
fclose($f);
?>
<html>
<form method="POST" action="">
Subdomain: <input type="text" name="subdomain"/>
<input type="submit" name="submit" value="Create"/>
</html>

please help

Thanks in advance

Posted

Sub-domain creation does not work on Stevie. cPanel staff are working on the problem.

  • Like 1
Posted

echo stream_get_contents($path) to see what the problem is.

  • Like 1
Posted

When i do this code

It creates the subdomain but how to make it without showing it to the userbecause he can toggle in cpanel

Thanks in advance

 

Brw i used "$f" not "$path"

Posted

Yeah, sorry about that careless mistake.

 

Just use above code (without the careless mistake), except without the echo statement. The code should look like this:

<?
$username = $_POST['subdomain'];
$path="http://seifhate:pass@seifhatem.co.cc:2082/frontend/x3/subdomain/doadddomain.html?rootdomain=seifhatem.co.cc&domain=$username";
$f = fopen($path, "r");
stream_get_contents($f);
fclose($f);
?>
<html>
<form method="POST" action="">
Subdomain: <input type="text" name="subdomain"/>
<input type="submit" name="submit" value="Create"/>
</html>

 

BTW, I would just run a cron script every 24 hours that updates cPanel with your database data.

Posted

BTW, I would just run a cron script every 24 hours that updates cPanel with your database data.

Sorry i can't understand this part

Thanks

 

The code didn't work :(

Posted

Try this:

 

<?
$username = $_POST['subdomain'];
$path="http://seifhate:pass@seifhatem.co.cc:2082/frontend/x3/subdomain/doadddomain.html?rootdomain=seifhatem.co.cc&domain=$username";
$f = fopen($path, "r");
file_put_contents(__DIR__.'/log.txt',stream_get_contents($f));
fclose($f);
?>
<html>
<form method="POST" action="">
Subdomain: <input type="text" name="subdomain"/>
<input type="submit" name="submit" value="Create"/>
</html>

.

 

Then, check the contents of log.txt to see the problem

 

BTW, I would just run a cron script every 24 hours that updates cPanel with your database data.

Sorry i can't understand this part

 

You can do this in your cPanel under "cron jobs." See this for instructions of how to create a PHP cron script.

  • Like 1
Posted

You really should put that script inside an if statement. That way it will only try to execute when the form is submitted.

 

<?
if ($_POST['subdomain'])
{

$username = $_POST['subdomain'];
$path="http://seifhate:pass@seifhatem.co.cc:2082/frontend/x3/subdomain/doadddomain.html?rootdomain=seifhatem.co.cc&domain=$username";
$f = fopen($path, "r");
file_put_contents(__DIR__.'/log.txt',stream_get_contents($f));
fclose($f);

}
?> 
<html> 
<form method="POST" action=""> 
Subdomain: <input type="text" name="subdomain"/> 
<input type="submit" name="submit" value="Create"/> 
</html>

 

Posted

This entire script he has is not very secure, as someone could possibly inject malicious content into the $username parameter, but it's his account.

  • Like 1
Posted

Hello

Here is a part of mu final code enter to database,crete subdomain and ftp if anyone need it he can copy it or post it on other forums.

Thanks for xaav for helping me with it

<?php
include 'mysql-connect.php';
$username = $_POST['username'];
$password = $_POST['password'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$ip = $_SERVER['REMOTE_ADDR'];
$strCheckUserSQL = "SELECT * FROM subs WHERE username='$username'"; 
$CheckUserQuery = mysql_query($strCheckUserSQL); 
$strCheckEmailSQL = "SELECT * FROM subs WHERE email='$email'"; 
$CheckEmailQuery = mysql_query($strCheckEmailSQL);
$path="http://seifhate:pass@seifhatem.co.cc:2082/frontend/x3/subdomain/doadddomain.html?rootdomain=seifhatem.co.cc&domain=$username";
$path2="http://seifhate:pass@seifhatem.co.cc:2082/frontend/x3/ftp/doaddftp.html?login=$username&password=$password&quota=13";
mysql_query("INSERT INTO subs (username, password, firstname, lastname, ip, email) 
VALUES ('$username', '$password', '$firstname', '$lastname', '$ip', '$email')");
$f = fopen($path, "r");
stream_get_contents($f);
$f2 = fopen($path2, "r");
stream_get_contents($f2);

but there is a problwm am facing that johnny is extremely slow and always returns an error and sometimes just do one or two of the three (subdomain,ftp and mysql) so can anyone help me with a sample cron script that retrieves data from mysql and create the subdomain abd ftp accounts because i am new to cron scripts.

Thanks in advance

Posted

First, you need to modify your "subs" table to include "created" column. Make this column a type of boolean, and give it a default value of FALSE.

 

Then, break this up into two scripts.

 

First script:

<?php
include 'mysql-connect.php';
$username = $_POST['username'];
$password = $_POST['password'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$ip = $_SERVER['REMOTE_ADDR'];
$strCheckUserSQL = "SELECT * FROM subs WHERE username='$username'";
$CheckUserQuery = mysql_query($strCheckUserSQL);
$strCheckEmailSQL = "SELECT * FROM subs WHERE email='$email'";
$CheckEmailQuery = mysql_query($strCheckEmailSQL);

// You really should escape these values, but I'm not going to do that here
mysql_query("INSERT INTO subs (username, password, firstname, lastname, ip, email)
VALUES ('$username', '$password', '$firstname', '$lastname', '$ip', '$email')");

 

Create this cron script in your [home] folder, NOT your public_html folder.

 

#!/usr/bin/php
<?php
$strCheckSubSQL = "SELECT * FROM subs WHERE created=false";

//Connect to the database

$result = mysql_query($strCheckSubSQL);
while($row = mysql_fetch_array($result)) {
//Create the user in cPanel
//Update the record with created=true
}

//Close the connection

 

You'll also need to chmod the cron script to 777.

  • Like 1
Posted

So the first acript will be in the public_html folder normallyand the user will register to add the user to the db

And the cron script is in home that will be excuted manually to get the uncreated users and create them, am i right??

And what do you mean with escaping these values in script 1

Thank you very vey much :)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...