diff --git a/interface/lib/classes/functions.inc.php b/interface/lib/classes/functions.inc.php
index 661e5574ebb065826ff2a51d23df4ceed4e00e48..50b3e6cb555087fa2670d521f28661ce0a81c0f0 100644
--- a/interface/lib/classes/functions.inc.php
+++ b/interface/lib/classes/functions.inc.php
@@ -61,52 +61,6 @@ class functions {
$app->ispcmail->send($to);
$app->ispcmail->finish();
- /* left in here just for the case...
- if($filepath != '') {
- if(!file_exists($filepath)) $app->error("Mail attachement does not exist ".$filepath);
-
- $content = file_get_contents($filepath);
- $content = chunk_split(base64_encode($content));
- $uid = strtoupper(md5(uniqid(time())));
- $subject = "=?utf-8?B?".base64_encode($subject)."?=";
-
- if($filename == '') {
- $path_parts = pathinfo($filepath);
- $filename = $path_parts["basename"];
- unset($path_parts);
- }
-
- $header = "Return-Path: $from\nFrom: $from\nReply-To: $from\n";
- if($cc != '') $header .= "Cc: $cc\n";
- if($bcc != '') $header .= "Bcc: $bcc\n";
- $header .= "MIME-Version: 1.0\n";
- $header .= "Content-Type: multipart/mixed; boundary=$uid\n";
-
- $header .= "--$uid\n";
- $header .= "Content-Type: text/plain;\n\tcharset=\"UTF-8\"\n";
- $header .= "Content-Transfer-Encoding: 8bit\n\n";
- $header .= "$text\n";
-
- $header .= "--$uid\n";
- $header .= "Content-Type: $filetype; name=\"$filename\"\n";
-
- $header .= "Content-Transfer-Encoding: base64\n";
- $header .= "Content-Disposition: attachment; filename=\"$filename\"\n\n";
- $header .= "$content\n";
-
- $header .= "--$uid--";
-
- mail($to, $subject, "", $header);
- } else {
- $header = "From: $from\nReply-To: $from\n";
- if($cc != '') $header .= "Cc: $cc\n";
- if($bcc != '') $header .= "Bcc: $bcc\n";
- $header .= "Content-Type: text/plain;\n\tcharset=\"UTF-8\"\n";
- $header .= "Content-Transfer-Encoding: 8bit\n\n";
- $subject = "=?utf-8?B?".base64_encode($subject)."?=";
- mail($to, $subject, $text, $header);
- }
- */
return true;
}
diff --git a/interface/lib/classes/ispconfig_request.inc.php b/interface/lib/classes/ispconfig_request.inc.php
new file mode 100644
index 0000000000000000000000000000000000000000..75e06eef97e9ac50e4777e52de6c963663e39ba2
--- /dev/null
+++ b/interface/lib/classes/ispconfig_request.inc.php
@@ -0,0 +1,260 @@
+ array('ciphers' => 'ALL:!AES:!3DES:!RC4:@STRENGTH'))));
+ @$fp = fsockopen('sslv3://' . $url_info['host'], $port, $errno, $errstr, 10);
+ } else {
+ $port = isset($url_info['port']) ? $url_info['port'] : 80;
+ @$fp = fsockopen($url_info['host'], $port, $errno, $errstr, 10);
+ }
+
+ if($store_in) {
+ $outfp = fopen($store_in, 'w');
+ if(!$outfp) return false;
+ }
+ if($fp) {
+ stream_set_timeout($fp, 10);
+ $head = 'GET ' . (isset($url_info['path']) ? $url_info['path'] : '/') . (isset($url_info['query']) ? '?' . $url_info['query'] : '');
+ $head .= " HTTP/1.0\r\nHost: " . (isset($url_info['host']) ? $url_info['host'] : '') . "\r\n";
+ $head .= "User-Agent: " . $user_agent . "\r\n";
+ if(isset($url_info['user'])) {
+ if(!array_key_exists('pass', $url_info)) $url_info['pass'] = '';
+ $head .= "Authorization: basic " . base64_encode($url_info['user'] . ':' . $url_info['pass']) . "\r\n";
+ }
+ $head .= "Connection: Close\r\n";
+ $head .= "Accept: */*\r\n\r\n";
+
+ $data = '';
+ $eoheader = false;
+ fputs($fp, $head);
+ while(!feof($fp)) {
+ if($header = fgets($fp, 1024)) {
+ if($eoheader == true) {
+ if($store_in) fputs($outfp, $header);
+ else $data .= $header;
+ continue;
+ }
+
+ if ($header == "\r\n") {
+ $eoheader = true;
+ continue;
+ } else {
+ $header = trim($header);
+ }
+ $sc_pos = strpos($header, ':');
+ if($sc_pos === false) {
+ $headers['status'] = $header;
+ $headers['http_code'] = intval(preg_replace('/^HTTP\/\d+\.\d+\s+(\d+)\s+.*$/', '$1', $header));
+ } else {
+ $label = substr($header, 0, $sc_pos);
+ $value = substr($header, $sc_pos + 1);
+ $headers[strtolower($label)] = trim($value);
+ }
+ }
+ }
+ fclose($fp);
+ if(isset($headers['http_code']) && isset($headers['location']) && ($headers['http_code'] == 301 || $headers['http_code'] == 302) && $follow_redirects > 0) {
+ if($store_in) fclose($outfp);
+ return $self::get_with_headers($headers['location'], $store_in, $follow_redirects);
+ }
+ if($store_in) {
+ fclose($outfp);
+
+ $code = intval(preg_replace('/^HTTP\/\d+\.\d+\s+(\d+)\s+.*$/', '$1', $headers['status']));
+ if($code != 200) {
+ return false;
+ }
+ return $headers;
+ } else {
+ return array($headers, $data);
+ }
+ } else {
+ if($store_in) {
+ fclose($outfp);
+ @unlink($store_in);
+ }
+ return false;
+ }
+ }
+
+ /**
+ * Gets the content of an url
+ *
+ * Checks for the php function file_get_contents and uses an alternative if not found
+ *
+ * @access public
+ * @param string $url url to get
+ * @return string url data including headers
+ * @see file_get_contents
+ */
+ public static function get($url) {
+ if(function_exists('file_get_contents')) return file_get_contents($url);
+
+ $fp = fopen($url, 'r');
+ $data = '';
+ while(!feof($fp)) {
+ $data .= fgets($fp, 8192);
+ }
+ fclose($fp);
+
+ return $data;
+ }
+
+
+ /**
+ * Make a post request and get data
+ *
+ * Calls an url with a post request and returns the data - and optionally the header content
+ *
+ * @access public
+ * @param string $url the url to call
+ * @param string $data the post data to send
+ * @param bool $get_headers if true, the function will return an array like PXUrl::get_with_headers(), otherwise the content is returned as a string
+ * @return mixed Content data as string or - if get_headers is true - the array with header data at index 0 and page content at index 1
+ * @see get_url_and_headers
+ */
+ public static function post($url, $data, $get_headers = false, $user_agent = false) {
+ $url_info = parse_url($url);
+ if((isset($url_info['scheme']) && $url_info['scheme'] == 'https') || $url_info['port'] == 443) {
+ $port = (!isset($url_info['port']) || !$url_info['port'] || $url_info['port'] == 443 || $url_info['port'] == 80) ? 443 : $url_info['port'];
+ //@$fp = stream_socket_client('ssl://' . $url_info['host'] . ':' . $port, $errno, $errstr, 10, STREAM_CLIENT_CONNECT, stream_context_create(array('ssl' => array('ciphers' => 'ALL:!AES:!3DES:!RC4:@STRENGTH'))));
+ @$fp = fsockopen('sslv3://' . $url_info['host'], $port, $errno, $errstr, 10);
+ } else {
+ $port = isset($url_info['port']) ? $url_info['port'] : 80;
+ @$fp = fsockopen($url_info['host'], $port, $errno, $errstr, 10);
+ }
+
+ if(!$fp) return '';
+
+ if(!$user_agent) $user_agent = 'pxFW GET proxy';
+
+ $header = 'POST ' . (isset($url_info['path']) ? $url_info['path'] : '/') . (isset($url_info['query']) ? '?' . @$url_info['query'] : '') . " HTTP/1.1\r\n";
+ $header .= "Host: " . @$url_info['host'] . "\r\n";
+ $header .= "User-Agent: " . $user_agent . "\r\n";
+ if(isset($url_info['user'])) {
+ if(!array_key_exists('pass', $url_info)) $url_info['pass'] = '';
+ $header .= "Authorization: basic " . base64_encode($url_info['user'] . ':' . $url_info['pass']) . "\r\n";
+ }
+ $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
+ $header .= "Content-Length: " . strlen($data) . "\r\n";
+ $header .= "Connection: close\r\n\r\n";
+ $header .= $data . "\r\n\r\n";
+
+ fwrite($fp, $header);
+
+ $response = '';
+ $eoheader = false;
+ $header = '';
+ $tmpdata = '';
+ $chunked = false;
+ $chunklen = 0;
+
+ while(!feof($fp)) {
+ if($header = @fgets($fp, 1024)) {
+ if($eoheader == true) {
+ $response .= $header;
+ continue;
+ }
+
+ if ($header == "\r\n") {
+ $eoheader = true;
+ continue;
+ } else {
+ $tmpdata .= $header;
+ if(preg_match('/Transfer-Encoding:\s+chunked/i', $tmpdata)) $chunked = true;
+ }
+ }
+ }
+ //var_dump($response, $chunked, $header);
+ if($chunked == true) {
+ $lines = explode("\n", $response);
+ $response = '';
+ $chunklen = 0;
+ foreach($lines as $line) {
+ $line .= "\n";
+ if($chunklen <= 0) {
+ if(preg_match('/^([0-9a-f]+)\s*$/is', $line, $matches)) {
+ $chunklen = hexdec($matches[1]);
+ }
+ continue;
+ }
+
+ if(strlen($line) > $chunklen) {
+ //echo "Warnung: " . strlen($line) . " > " . $chunklen . "\n";
+ $line = substr($line, 0, $chunklen);
+ }
+ $response .= $line;
+ $chunklen -= strlen($line);
+ }
+
+ $start = strpos($response,'');
+ if($start !== false && $end !== false) $response = substr($response, $start, $end - $start + 1);
+ }
+
+ fclose($fp);
+
+ if($get_headers == true) {
+ $tmpheaders = explode("\n", $tmpdata);
+ $headers = array();
+ foreach($tmpheaders as $cur) {
+ if(preg_match('/^(\w+)\:\s*(.*)$/is', $cur, $matches)) {
+ $headers["$matches[1]"] = trim($matches[2]);
+ }
+ }
+ return array($headers, $response);
+ } else return $response;
+ }
+}
+
+?>
diff --git a/interface/web/index.php b/interface/web/index.php
index a7d2965e13049d2e58a319ed8d2459e376055dfb..c0005bc56d3a3af803047952ae3627bd7f66700e 100644
--- a/interface/web/index.php
+++ b/interface/web/index.php
@@ -60,6 +60,22 @@ if(isset($_SESSION['show_error_msg'])) {
unset($_SESSION['show_error_msg']);
}
+// read js.d files
+$js_d = ISPC_WEB_PATH . '/js/js.d';
+$js_d_files = array();
+if(@is_dir($js_d)) {
+ $dir = opendir($js_d);
+ while($file = readdir($dir)) {
+ $filename = $js_d . '/' . $file;
+ if($file === '.' || $file === '..' || !is_file($filename)) continue;
+ if(substr($file, -3) !== '.js') continue;
+ $js_d_files[] = array('file' => $file);
+ }
+ closedir($dir);
+}
+
+$app->tpl->setLoop('js_d_includes', $js_d_files);
+unset($js_d_files);
$app->tpl_defaults();
$app->tpl->pparse();
diff --git a/interface/web/js/scrigo.js.php b/interface/web/js/scrigo.js.php
index 418b26bd4a8730b891ad0f0aa943160937883ca6..33be65e01cbcfeb16299c7f5d1b5c1c333e0a115 100644
--- a/interface/web/js/scrigo.js.php
+++ b/interface/web/js/scrigo.js.php
@@ -18,6 +18,7 @@ var requestsRunning = 0;
var indicatorPaddingH = -1;
var indicatorPaddingW = -1;
var indicatorCompleted = false;
+var registeredHooks = new Array();
redirect = '';
function reportError(request) {
@@ -28,6 +29,20 @@ function reportError(request) {
/*alert(request);*/
}
+function registerHook(name, callback) {
+ if(!registeredHooks[name]) registeredHooks[name] = new Array();
+ var newindex = registeredHooks[name].length;
+ registeredHooks[name][newindex] = callback;
+}
+
+function callHook(name, params) {
+ if(!registeredHooks[name]) return;
+ for(var i = 0; i < registeredHooks[name].length; i++) {
+ var callback = registeredHooks[name][i];
+ callback(name, params);
+ }
+}
+
function resetFormChanged() {
pageFormChanged = false;
}
@@ -73,7 +88,9 @@ function hideLoadIndicator() {
}
}
-function onAfterContentLoad() {
+function onAfterContentLoad(url, data) {
+ if(!data) data = '';
+ else data = '&' + data;
@@ -81,6 +98,7 @@ if($server_config_array['misc']['use_combobox'] == 'y'){
+ callHook('onAfterContentLoad', {'url': url, 'data': data });
}
function loadContentRefresh(pagename) {
@@ -96,7 +114,7 @@ function loadContentRefresh(pagename) {
success: function(data, textStatus, jqXHR) {
hideLoadIndicator();
jQuery('#pageContent').html(jqXHR.responseText);
- onAfterContentLoad();
+ onAfterContentLoad(pagename, "refresh="+document.getElementById('refreshinterval').value);
pageFormChanged = false;
},
error: function() {
@@ -175,7 +193,7 @@ function submitLoginForm(formname) {
document.location.href = 'index.php';
} else {
jQuery('#pageContent').html(jqXHR.responseText);
- onAfterContentLoad();
+ onAfterContentLoad('content.php', jQuery('#'+formname).serialize());
pageFormChanged = false;
}
loadMenus();
@@ -213,7 +231,7 @@ function submitForm(formname,target) {
//window.setTimeout('loadContent(redirect)', 1000);
} else {
jQuery('#pageContent').html(jqXHR.responseText);
- onAfterContentLoad();
+ onAfterContentLoad(target, jQuery('#'+formname).serialize());
pageFormChanged = false;
}
hideLoadIndicator();
@@ -252,7 +270,7 @@ function submitFormConfirm(formname,target,confirmation) {
//window.setTimeout('loadContent(redirect)', 1000);
} else {
jQuery('#pageContent').html(jqXHR.responseText);
- onAfterContentLoad();
+ onAfterContentLoad(target, jQuery('#'+formname).serialize());
pageFormChanged = false;
}
hideLoadIndicator();
@@ -330,7 +348,7 @@ function loadContent(pagename) {
//jQuery.each(reponseScript, function(idx, val) { eval(val.text); } );
jQuery('#pageContent').html(jqXHR.responseText);
- onAfterContentLoad();
+ onAfterContentLoad(pagename, (params ? params : null));
pageFormChanged = false;
}
hideLoadIndicator();
@@ -357,7 +375,7 @@ function loadInitContent() {
loadContent(parts[1]);
} else {
jQuery('#pageContent').html(jqXHR.responseText);
- onAfterContentLoad();
+ onAfterContentLoad('content.php', "s_mod=login&s_pg=index");
pageFormChanged = false;
}
hideLoadIndicator();
diff --git a/interface/web/themes/default/templates/main.tpl.htm b/interface/web/themes/default/templates/main.tpl.htm
index d148a5feb811081b8e62ef4a0ebaf484d18c818e..c503718fca345f32dcda86e2eb3f2cbceeef1bae 100644
--- a/interface/web/themes/default/templates/main.tpl.htm
+++ b/interface/web/themes/default/templates/main.tpl.htm
@@ -18,6 +18,9 @@
+
+
+