#!/usr/bin/env php 'enable given domain, will accept wildcards', 'disable|d=s' => 'disable given domain, will accept wildcards' )); $opts->setOption('ruleMode', Zend_Console_Getopt::MODE_GNU); $opts->parse(); if (null == $opts->getOptions()) { throw new Zend_Console_Getopt_Exception('no options supplied', $opts->getUsageMessage()); } try { $db = new Zend_Db_Adapter_Pdo_Sqlite(array( 'dbname' => '/home/cameron/projects/vhost-tool/db/vhosts.sqdb' )); } catch (Zend_Db_Adapter_Exception $e) { echo $e->getMessage(), "\n"; exit; } $username = $_SERVER['USERNAME']; $arg = array_shift($opts->getOptions()); $domain = $opts->getOption($arg); if ($arg === 'enable' || $arg === 'disable') { $results = $db->fetchAll($db->quoteInto('SELECT * FROM vhosts WHERE vhost_domain = ?', $domain)); if ($username === $results[0]['vhost_owner']) { if ('enable' === $arg) { $output = shell_exec("a2ensite $domain"); } if ('disable' === $arg) { $output = shell_exec("a2dissite $domain"); } } else { $output = 'you do not own this site, there for you can not disable or enable it.'; } } /* add support for adding vhosts and removing them via this tool else if ($arg === 'add' || $arg === 'delete') { } */ echo $output, "\n"; exit; } catch (Zend_Console_Getopt_Exception $e) { echo $e->getUsageMessage(), "\n"; exit; }