Hi, I am new user and I'm sorry if I abrogated your rules... I have PHP script, which creates subdomain on cpanel. <? define('CPANELUSER','here username'); define('CPANELPASS','here password'); define('INPUT_FILE','domainslist.txt'); define('CPANEL_SKIN','skinname'); define('DOMAIN','rootdomain'); function getVar($name, $def = '') { if (isset($_REQUEST[$name]) && ($_REQUEST[$name] != '')) return $_REQUEST[$name]; else return $def; } $cpaneluser=getVar('cpaneluser', CPANELUSER); $cpanelpass=getVar('cpanelpass', CPANELPASS); $cpanel_skin = getVar('cpanelskin', CPANEL_SKIN); $doms = @file(INPUT_FILE); function subd($host,$port,$ownername,$passw,$request) { $sock = fsockopen('localhost',2082); if(!$sock) { print('Socket error'); die("<script type=\"text/javascript\">location = '../register.php?error=6&name={$name}&mail={$mail}&skype={$skype}'</script>"); } $authstr = "$ownername:$passw"; $pass = base64_encode($authstr); $in = "GET $request\r\n"; $in .= "HTTP/1.0\r\n"; $in .= "Host:$host\r\n"; $in .= "Authorization: Basic $pass\r\n"; $in .= "\r\n"; fputs($sock, $in); while (!feof($sock)) { $result .= fgets ($sock,128); } fclose( $sock ); return $result; } foreach($doms as $dom) { $lines = explode(';',$dom); if (count($lines) == 2) { // domain and subdomain passed $domain = trim($lines[0]); $subd = trim($lines[1]); } else { // only subdomain passed $domain = getVar('domain', DOMAIN); $subd = trim($lines[0]); } // http://[domainhere]:2082/frontend/x/subdomain/doadddomain.html?domain=[subdomain here]&rootdomain=[domain here] $request = "/frontend/$cpanel_skin/subdomain/doadddomain.html?rootdomain=$domain&domain=$subd&dir=public_html/blog/sites/$filebody88"; $result = subd('localhost',2082,$cpaneluser,$cpanelpass,$request); } Code (markup): this script works correctly, but there are one problem, when it finish working, it stops... and I can't redirect it. I am using javascript also to redirect it: die("<script type='text/javascript'>location = '../done.php?done=2'</script>"); Code (markup): But it does not work... Also does not work "echo"... Can anyone help me? Thanks...
You could try this to redirect it: header("Location: ../done.php"); //Redirect die(); //End script Code (markup): Example: if(!something) { echo "Error!"; //error occurred } else { //no error occurred, so redirect them! //completed successfully header("Location: ../done.php"); //Redirect die(); //End script } Code (markup):
Would'nt work as single quotes are 'non-eval' quotes, theirfore remove the quotes so the function header() can be declared.
Hmm, the redirect should work. Try the revised code again, and make sure you don't use echo before header("location:") or die(); and try replacing <? Code (markup): at the beginning of the script with: <?php Code (markup): and see if it works. BTW are there any errors given when the page is loaded/the script is being used?
I've replaced it "<?php" but it does not work yet... There are no any error when it is being used... But it successfully finish anything... So I've created two frame, in the first frame is javascript code, which is writing "loading..." and after 20 seconds it change the following text: "finished successfully... click here to redirect." And in the second frame is PHP script and it works during this 20 seconds...... So I've solved this problem. ===================================================================== But there are one interesting thing: In the PHP script also included mkdir() function, it creates direction for subdomain. if this folder already exists there are one error "direction already exist" and in this case redirect works... Do you have any idea what is happening? P.S. sorry for my bad English...
die("<script type='text/javascript'>location.href = '../done.php?done=2';</script>"); or die("<script type='text/javascript'>location.replace('../done.php?done=2');</script>"); or header('refresh:0;url=../done.php?done=2'); // put this line before a buffer is started die();