$theTitle=wp_title(" - ", false); if($theTitle != "") { ?> } else { ?> } ?>
by Andrew Johnstone
In: PHP
15 Jan 2006Update: I tested the script in my previous post to generate domains on an alternative server and it worked flawlessly (Not quite sure why, and I need to test further). However, one of the features that are missing from Plesk is to create aliases of domains. Through the Plesk API, you can create a redirect on a domain (HTTP Redirect) or a Frameset for example…
<packet version="1.3.1.0"> <domain> <add> <gen_setup> <name>alternative.ajohnstone.com</name> <client_id>1</client_id> <status>0</status> <ip_address>70.85.198.202</ip_address> <std_fwd> <dest_url>ajohnstone.com</dest_url> <ip_address>70.85.198.202</ip_address> </std_fwd> <htype>std_fwd</htype> </gen_setup> <hosting> <std_fwd> <dest_url>ajohnstone.com</dest_url> <ip_address>70.85.198.202</ip_address> </std_fwd> </hosting> <prefs> <www>true</www> </prefs> </add> </domain> </packet>
Although thats not quite what I desired, anyway heres a quick modifcation to the PleskDomainsCommand class. There are a few limitations, the first being that it needs to write to vhost.conf file in “/home/httpd/vhosts/ajohnstone.com/conf/vhost.conf” and that open_basedir allows access to that file.
class PleskDomainsCommand extends PleskObjectCommand { function PleskDomainsCommand($Data=null) { parent::PleskObjectCommand($Data); } function Command() { } //Stub function addAliasDomain($AliasedDomain, $ActualDomain) { $FileName= '/home/httpd/vhosts/'.$ActualDomain.'/conf/vhost.conf'; $ServerAlias = 'ServerAlias '.$AliasedDomain."\r\n"; if (is_writable($FileName)) { if (!$Handle = fopen($FileName, 'a')) trigger_error("Cannot open file: ({$FileName})", E_USER_ERROR); if (fwrite($Handle, $ServerAlias) === FALSE) trigger_error("Cannot write to file: ({$FileName})", E_USER_ERROR); fclose($Handle); } else { trigger_error("The file ({$FileName}) is not writable", E_USER_ERROR); } $Data = "<packet version=\"{$this->Version}\"><server><get><services_state /></get></server></packet>"; //restart server id = web $Data = "<packet version=\"{$this->Version}\"><server><get><srv_man><id>web</id><operation>restart</operation></srv_man></get></server></packet>"; parent::PleskObjectCommand($Data); $this->connect(); } } $Domains = new PleskDomainsCommand($Data); $Domains->setOptions('https://admin:***@localhost:8443/enterprise/control/agent.php'); $Domains->Command(); $Domains->addAliasDomain('alternative.test.ajohnstone.com', 'ajohnstone.com');
I have been a developer for roughly 10 years and have worked with an extensive range of technologies. Whilst working for relatively small companies, I have worked with all aspects of the development life cycle, which has given me a broad and in-depth experience.