#!/usr/local/bin/php -d variables_order="EGPCS" this manual for mor information on how to upgrade.'; exit; } unset($version); /** * Check for Curl */ if (!function_exists('curl_init')) { echo 'You need cURL to use this plugin.'; exit; } /** * Check SimpleXML */ if (!function_exists(simplexml_load_string)) { die('ERROR: SimpleXML not availible'. PHP_EOL); } /** * Read plugin config file */ $config = $_ENV['DOCUMENT_ROOT'] .'/../etc/oneclick.conf'; $settings = unserialize(file_get_contents($config)); /** * Check for Settings */ if (!(strlen($settings['da_user']) > 0 && strlen($settings['da_passwd']) > 0)) { echo 'You need to configure this plugin before you can use it'; exit; } /** * Read user config file */ $usrConfig = $_ENV['DOCUMENT_ROOT'] .'/../etc/usr_'. $_ENV['USERNAME'] .'.conf'; if (file_exists($usrConfig)) { $usrSettings = unserialize(@file_get_contents($usrConfig)); } else { $usrSettings = array(); } $replace = array(); $replace['{{ voucher_url }}'] = htmlentities(strip_tags($settings['voucher_url'])); parse_str($_ENV['QUERY_STRING'], $qstr); parse_str($_ENV['POST'], $_POST); $replace['{{ domain }}'] = htmlentities(strip_tags(trim($_POST['domain']))); $replace['{{ voucher }}'] = htmlentities(strip_tags(trim($_POST['voucher']))); $replace['{{ email }}'] = htmlentities(strip_tags(trim($_POST['email']))); $replace['{{ revoke }}'] = htmlentities(strip_tags(trim($_POST['revoke']))); if ($_SERVER['REQUEST_METHOD'] == 'POST' && !isset($qstr['action'])) { $error = false; if (!@checkdnsrr(str_replace('*.', '', $replace['{{ domain }}']), 'ANY')) { $errorMsg .= "The hostname ". str_replace('*.', '', $replace['{{ domain }}']) ." does not revolve to an ip address.
". PHP_EOL; $error = true; } $mail = explode("@", $replace['{{ email }}'], 2); if (!@checkdnsrr($mail[1], 'ANY')) { $errorMsg .= "The domain '". $mail[1] ."' is not able to receive mail, can't resolve domain.
". PHP_EOL; $error = true; } if (strlen($_POST['voucher']) < 4) { $errorMsg .= "Invalid voucher, the voucher should be minimal 5 characters.
". PHP_EOL; $error = true; } if (!array_key_exists('subagree', $_POST)) { $errorMsg .= "Please check and agree the terms and conditions
". PHP_EOL; $error = true; } if ($error) { echo '

'. $errorMsg .'

'. PHP_EOL; } /* * User settings */ } else if ($_SERVER['REQUEST_METHOD'] == 'POST' && $qstr['action'] == 'settings') { parse_str($_ENV['POST'], $_POST); if ($_POST['remote_admin']) { $usrSettings['remote_admin'] = 1; } else { $usrSettings['remote_admin'] = 0; } $usrSettings['sni'] = $_POST['sni']; $usrSettings['auto_ip'] = $_POST['auto_ip']; $usrSettings['debug_level'] = $_POST['debug_level']; $fp = fopen($usrConfig, 'w'); fwrite($fp, serialize($usrSettings)); fclose($fp); } /** * Handle a post request */ if ($_SERVER['REQUEST_METHOD'] == 'POST' && $error == false && !isset($qstr['action']) ) { $tplFile = 'user_process.tpl'; /** * Revoke */ } elseif ($qstr['action'] == 'revoke' && $_SERVER['REQUEST_METHOD'] == 'POST' ) { $tplFile = 'user_process.tpl'; } elseif ($qstr['action'] == 'revoke') { $replace['{{ domain }}'] = str_replace('www.', '', $qstr['domain']); $tplFile = 'user_revoke.tpl'; /** * Settings */ } elseif ($qstr['action'] == 'settings') { if ($usrSettings['remote_admin'] === 1) { $replace['{{ remote_admin }}'] = ' checked'; } else { $replace['{{ remote_admin }}'] = ''; } if (ctype_digit($usrSettings['auto_ip'])) { $replace['{{ auto_ip }}'] = $usrSettings['auto_ip']; } else { $replace['{{ auto_ip }}'] = ''; } if (ctype_digit($usrSettings['sni'])) { $replace['{{ sni }}'] = $usrSettings['sni']; } else { $replace['{{ sni }}'] = ''; } if (ctype_digit($usrSettings['debug_level'])) { $replace['{{ debug_level }}'] = $usrSettings['debug_level']; } else { $replace['{{ debug_level }}'] = ''; } $tplFile = 'user_settings.tpl'; /** * Default -> Order */ } else { $replace['{{ domain }}'] = str_replace('www.', '', $qstr['domain']); $tplFile = 'user_index.tpl'; } /** * Load translation */ define('LANGPATH', $_ENV['DOCUMENT_ROOT'] .'/../etc/'); require($_ENV['DOCUMENT_ROOT'] ."/../lib/i18n.php"); $replace = array_merge($replace, getTranslation($_SERVER['LANGUAGE'])); /** * Load template */ $template = file_get_contents($_ENV['DOCUMENT_ROOT'] .'/../skins/default/'. $tplFile); /* * Include files (Django style) */ preg_match_all("/\{% include \"([^\"]*)\" %\}/", $template , $includeMatch); foreach ($includeMatch[1] as $include){ $replace['{% include "'. $include .'" %}'] = file_get_contents($_ENV['DOCUMENT_ROOT'] .'/../skins/default/'. basename($include)); } echo strtr($template, $replace);