-
- 786 Posts
where are you trying to put this code?
Put the code into a snippet, assign all output to a variable, and have it return the output of the variable to the page.
Ryan Thrash, MODX Co-Founder
Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
-
- 18 Posts
Ryan, you lost me. I got the put it in a snippet bit but thats as far as i follow. I dont suppose if i gave you access you could work your magic on it?
-
- 258 Posts
TSOne,
You’d probably get a lot more help if you gave more details about what version of modx you’re running and what problems specifically you’re encountering. Just saying "it doesn’t work" isn’t very helpful for diagnosing problems.
-
- 786 Posts
To setup you snippet do the following: create a variable named output, everything you want to have displayed needs to be added to this variable. So as you move down your code add the output to the variable. Then at the end of your code use a return statement to display your variable output.
-
- 4,213 Posts
Here’s your script as a snippet. Compare it to the original and you see what we’re about. I did only the necessary changes, now you could enhance that by putting the html to a chunck as template etc...
$d = str_replace(" ","",$_POST['domain']);
if($_POST) {
ob_start();
@readfile("http://www.whois.net/whois.cgi2?d=".$d);
$content=strip_tags(ob_get_contents());
ob_end_clean();
if(strstr($content,"No match") || strstr($content,"Not found:")) {
$r='<span style="color:#00AA00;">Available</span>';$a=true;
} else if(strstr($content,"is registered") || strstr($content,"WHOIS information")) {
$r='<span style="color:#AA0000;">Registered</span>';
} else {
$r='an <span style="color:#0000AA;">Invalid Domain</span>';
}
}
$output = '<div class="subHead"><br />
TSOne.info handles domain purchases for hosting clients and non-hosting clients.
To purchase a domain check it is available below:</div>
<div class="padding">
<form name="checkdomain" action="" method="POST">
<input type="text" name="domain" size="27" value="'. $d .'">
<input type="submit" value="Check"><br />
</form>
.com/org/.uk/.net/.info domains are £8 per year. All other prices upon
request<a href="%5B%7E17%7E%5D"></a>.<br />';
if($_POST){
$output .= '<br /><b>'.$_POST['domain'].' is '.$r.'!</b><br /><br />';
}
if($a) {
$output .= '
<div style="display:table;text-align:center;margin-left:10px;padding:4px;" class="subContent">
<b>You can purchase it here:</b><br />
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but24.gif" border="0" name="submit" alt="Make payments with PayPal - it\'s fast, free and secure!">
<img alt="" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1">
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHmAYJKoZIhvcNAQcEoIIHiTCCB4UCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYAakbxmvqgCJiWrYcPh4AuWK8ZXMVphDJ67oo9RlgNx74G2tsimn2LidGk4mPohpzoCuteyzfyj6gQCGV1Vez2a0T3ZxYCed5js7BY5AEfQ9LOg8fuoWM+v3w5ASq0+TWSJOq3cl4Hnn0uKqSJ3Xwhn3asaylYvZhYhr+Ch4HndzTELMAkGBSsOAwIaBQAwggEUBgkqhkiG9w0BBwEwFAYIKoZIhvcNAwcECORFQKgJsuYdgIHwCGFy2BsQtZte3t4B8KUfcbIqJ+e3etNgbSgmJBxsbStlEz2bzM+k4Dg5MmoQeLrtzYgTC9BVXTAQ3Q5ntwXDt1UzQemPZkQnQTQSI9Sb1WcHsKixW7Ryqebyw4U+SOTH4zU9ELfMhZCWQv+whZmGFIHySb6rzHJDlSzqn7PGNKrxyCTmA1U+IfB/gLXMs+GcrJYxxHbIgmHdoR0dNLMoWCOM/UtCvB8hqPB4cxQO7+F53gZaNnui7Wu49SnEnjHnoDd00vZlCw7D/kjvC9XhFUJnabZbT38YK1mKNd6sffR2Z0uvD5v9M4zHRVU2QKXboIIDhzCCA4MwggLsoAMCAQICAQAwDQYJKoZIhvcNAQEFBQAwgY4xCzAJBgNVBAYT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KddvTjyGw/XqXa+LSTlDYkqI8OwR8GEYj4efEtcRpRYBxV8KxAW93YDWzFGvruKnnLbDAF6VR5w/cCMn5hzGCAZowggGWAgEBMIGUMIGOMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExFjAUBgNVBAcTDU1vdW50YWluIFZpZXcxFDASBgNVBAoTC1BheVBhbCBJbmMuMRMwEQYDVQQLFApsaXZlX2NlcnRzMREwDwYDVQQDFAhsaXZlX2FwaTEcMBoGCSqGSIb3DQEJARYNcmVAcGF5cGFsLmNvbQIBADAJBgUrDgMCGgUAoF0wGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMDYwNjE5MTUzNDM0WjAjBgkqhkiG9w0BCQQxFgQUtDx8mALKpK0hlDsj5e0s6foJioIwDQYJKoZIhvcNAQEBBQAEgYByA7yNZEmAYT+oSO3RgIgASD5k0cSCtykOXiwELST1yaohTOuB8NKH2weEdjvFY+fgfX3GVEJOouT48RmSMLT0NT/xwIYxMJuj8BdcpndM/PFekkmZL3BNMhqt7lONR2naASZO09ZHuMDKo/AtX275BQ5a5hy55q/ETam9XR26RA==-----END PKCS7-----
">
</form>
<br /></div>';
}
$output .= '<span class="small"> <br />
</span>
</div>';
return $output;
"He can have a lollipop any time he wants to. That's what it means to be a programmer."
-
- 18 Posts
Doze, yer a genius! I couldnt have done that I dont really have a clue it was a piece of code i was given a while ago from a friend who a rarely speak to now. I’m just learning php and i could edit it roughly but no way could i have done that. Thanks again.