* @desc Process and renders virtualhost config related requests */ // must be run within Dokuwiki if(!defined('DOKU_INC')) die(); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC.'lib/plugins/'); if(!defined('DOKU_FARM_PLUGIN')) define('DOKU_FARM_PLUGIN', DOKU_PLUGIN.'farm/'); if(!defined('DOKU_FARMPLUGINLOADED')) define('DOKU_FARMPLUGINLOADED', true); class dokuwiki_farm_virtualhostconfig { var $data = array(); var $manager = null; var $errors = array(); /** * @param $manager object that must handle error(), success(), nicesize(), getLang() ... calls */ function __construct($manager) { $this->manager = & $manager; } /** * Builds a link inside SOAP config tab * @param $opts farm option array * @return url string */ function wl($opts = array()) { return $this->manager->wl('virtualhostconfig', $opts); } /** * Process requests */ function process() { // Parameters check if(!isset($this->manager->opt['save'])) return; // Security check if(!checkSecurityToken()) { $this->manager->error('system_errors', 'system_badtoken_failure'); return; // any changes done by post } // Text mode save request if(isset($this->manager->opt['save'])) { if(!isset($_POST['virtualhost_config_advanced']) || empty($_POST['virtualhost_config_advanced'])) { $this->manager->error('system_errors', 'postparametermissing_failure'); return; } if($fp = fopen(DOKU_FARM_PLUGIN.'virtual_hosts.php', 'w')) { fwrite($fp, ''."\n".$_POST['virtualhost_config_advanced']); fclose($fp); }else $this->manager->error('virtualhostconfig_errors', 'virtualhostconfig_save_failure'); return; } } /** * Renders */ function html() { global $ID; ptln('
'.$this->manager->getLang('virtualhostconfig_title').'
'); ptln('
'.$this->manager->getLang('virtualhostconfig_info').'
'); require_once DOKU_FARM_PLUGIN.'animal.class.php'; $l = dokuwiki_farm_animal::listAnimals($this->manager); $vh = $this->getVH(); $this->manager->formHead(array('farm_cmd' => 'virtualhostconfig')); ptln('
'); ptln(' '.$this->manager->getLang('virtualhost_config_for').' '); ptln(' '); ptln('
'); ptln('
'); ptln(' '); ptln('
'); ptln(''); } /** * Returns the list of virtualhosts * @return array of virtualhosts descriptors */ function getVH() { $vh = array(); foreach(explode("\n", @file_get_contents(DOKU_FARM_PLUGIN.'virtual_hosts.php')) as $l) { if(preg_match('`^\s*([^\s]+)\s+([^\s#]+)`', $l, $m)) $vh[$m[1]] = $m[2]; } return $vh; } } ?>