seifhate Posted December 31, 2011 Posted December 31, 2011 HelloPlease i am doing a php script that creates a subdomain but it doesn't workHere 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 helpThanks in advance
Guest xaav Posted December 31, 2011 Posted December 31, 2011 Sub-domain creation does not work on Stevie. cPanel staff are working on the problem. 1
Guest xaav Posted December 31, 2011 Posted December 31, 2011 echo stream_get_contents($path) to see what the problem is. 1
seifhate Posted December 31, 2011 Author Posted December 31, 2011 When i do this code It creates the subdomain but how to make it without showing it to the userbecause he can toggle in cpanelThanks in advance Brw i used "$f" not "$path"
Guest xaav Posted December 31, 2011 Posted December 31, 2011 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.
seifhate Posted December 31, 2011 Author Posted December 31, 2011 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
Guest xaav Posted December 31, 2011 Posted December 31, 2011 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. 1
seifhate Posted December 31, 2011 Author Posted December 31, 2011 It finally workedThank you very very very much :D and Happy New Year
Byron Posted December 31, 2011 Posted December 31, 2011 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>
Guest xaav Posted January 1, 2012 Posted January 1, 2012 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. 1
seifhate Posted January 1, 2012 Author Posted January 1, 2012 Don't worryThis will be for students to upload their deaigned webaites on so no one will try to hack it
seifhate Posted January 3, 2012 Author Posted January 3, 2012 HelloHere 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"a=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
Guest xaav Posted January 3, 2012 Posted January 3, 2012 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. 1
seifhate Posted January 4, 2012 Author Posted January 4, 2012 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 1Thank you very vey much
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now