summaryrefslogtreecommitdiffstats
path: root/usr/local/www
diff options
context:
space:
mode:
authorBill Marquette <bill.marquette@gmail.com>2009-03-14 01:25:46 -0500
committerBill Marquette <bill.marquette@gmail.com>2009-03-14 01:26:52 -0500
commit01da41cf8a21a07734e25a5bce4c2d35f81a0134 (patch)
tree3500d038d20cbf08e1d6dc3102304cf5f5df1f1b /usr/local/www
parent9050b9f970dc6531c749be488f57f7c14a89b77a (diff)
downloadpfsense-01da41cf8a21a07734e25a5bce4c2d35f81a0134.zip
pfsense-01da41cf8a21a07734e25a5bce4c2d35f81a0134.tar.gz
Sajax is no more, long live Prototype
This eliminates one AJAX library, but not all "non-Prototype" AJAX code
Diffstat (limited to 'usr/local/www')
-rw-r--r--usr/local/www/getstats.php40
-rwxr-xr-xusr/local/www/head.inc10
-rw-r--r--usr/local/www/includes/sajax.class.php266
-rwxr-xr-xusr/local/www/index.php106
-rw-r--r--usr/local/www/javascript/index/ajax.js (renamed from usr/local/www/javascript/index/sajax.js)22
-rwxr-xr-xusr/local/www/sajax/index.sajax.php14
6 files changed, 97 insertions, 361 deletions
diff --git a/usr/local/www/getstats.php b/usr/local/www/getstats.php
new file mode 100644
index 0000000..1de82b2
--- /dev/null
+++ b/usr/local/www/getstats.php
@@ -0,0 +1,40 @@
+<?php
+/*
+ carp_status.php
+ Copyright (C) 2009 Bill Marquette
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+##|+PRIV
+##|*IDENT=page-status-carp
+##|*NAME=Status: CARP page
+##|*DESCR=Allow access to the 'Status: CARP' page.
+##|*MATCH=carp_status.php*
+##|-PRIV
+
+require_once("guiconfig.inc");
+include_once("includes/functions.inc.php");
+echo get_stats();
+
+?> \ No newline at end of file
diff --git a/usr/local/www/head.inc b/usr/local/www/head.inc
index bbb3b5c..0d48fa2 100755
--- a/usr/local/www/head.inc
+++ b/usr/local/www/head.inc
@@ -73,14 +73,6 @@ $pagetitle = gentitle( $pgtitle );
}
}
- if ($oSajax):
-?>
- <script language="javascript" type="text/javascript">
- <?php $oSajax->sajax_show_javascript(); ?>
- </script>
-
-<? endif; ?>
-
-<?php if (!isset($closehead))
+if (!isset($closehead))
echo "</head>";
?>
diff --git a/usr/local/www/includes/sajax.class.php b/usr/local/www/includes/sajax.class.php
deleted file mode 100644
index dc070bd..0000000
--- a/usr/local/www/includes/sajax.class.php
+++ /dev/null
@@ -1,266 +0,0 @@
-<?php
-
-if(Connection_Aborted()) {
- exit;
-}
-
-class sajax {
-
- var $sajax_debug_mode = 0;
- var $sajax_export_list = array();
- var $sajax_request_type = "GET";
- var $sajax_remote_uri = "";
- var $sajax_js_has_been_shown = 0;
-
-
- /**
- * PHP 5 Constructor
- *
- * @param string $remoteURI
- */
- function __construct($remoteURI = NULL)
- {
- if (!isset($remoteURL))
- $this->sajax_remote_uri = $this->sajax_get_my_uri();
- }
-
-
- /**
- * PHP 4 Constructor
- *
- * @param string $remoteURI
- */
- function sajax($remoteURI = NULL)
- {
- $this->__construct($$remoteURI);
- }
-
-
- /**
- *
- *
- */
- function sajax_get_my_uri()
- {
- global $REQUEST_URI;
-
- return $REQUEST_URI;
- }
-
-
-
- function sajax_handle_client_request() {
-
- $mode = "";
-
- if (! empty($_GET["rs"]))
- $mode = "get";
-
- if (!empty($_POST["rs"]))
- $mode = "post";
-
- if (empty($mode))
- return;
-
- if ($mode == "get") {
- // Bust cache in the head
- header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
- header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
- // always modified
- header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
- header ("Pragma: no-cache"); // HTTP/1.0
- $func_name = $_GET["rs"];
- if (! empty($_GET["rsargs"]))
- $args = $_GET["rsargs"];
- else
- $args = array();
- }
- else {
- $func_name = $_POST["rs"];
- if (! empty($_POST["rsargs"]))
- $args = $_POST["rsargs"];
- else
- $args = array();
- }
-
- if (! in_array($func_name, $this->sajax_export_list))
- echo "-:$func_name not callable";
- else {
- echo "+:";
- $result = call_user_func_array($func_name, $args);
- echo $result;
- }
- exit;
- } // End sajax_handle_client_request() function ...
-
-
- function sajax_get_common_js() {
-
- $t = strtoupper($this->sajax_request_type);
- if ($t != "GET" && $t != "POST")
- return "// Invalid type: $t.. \n\n";
-
- ob_start();
- ?>
- <!--
- // remote scripting library
- // (c) copyright 2005 modernmethod, inc
- var sajax_debug_mode = <?php echo $this->sajax_debug_mode ? "true" : "false"; ?>;
- var sajax_request_type = "<?php echo $t; ?>";
-
- function sajax_debug(text) {
- if (sajax_debug_mode)
- alert("RSD: " + text)
- }
- function sajax_init_object() {
- sajax_debug("sajax_init_object() called..")
-
- var A;
-/*
- try {
- A=new ActiveXObject("Msxml2.XMLHTTP");
- } catch (e) {
- try {
- A=new ActiveXObject("Microsoft.XMLHTTP");
- } catch (oc) {
- A=null;
- }
- }
-*/
- if(!A && typeof XMLHttpRequest != "undefined")
- A = new XMLHttpRequest();
- if (!A)
- sajax_debug("Could not create connection object.");
- return A;
- }
- function sajax_do_call(func_name, args) {
- var i, x, n;
- var uri;
- var post_data;
-
- uri = "<?php echo $this->sajax_remote_uri; ?>";
- if (sajax_request_type == "GET") {
- if (uri.indexOf("?") == -1)
- uri = uri + "?rs=" + escape(func_name);
- else
- uri = uri + "&rs=" + escape(func_name);
- for (i = 0; i < args.length-1; i++)
- uri = uri + "&rsargs[]=" + escape(args[i]);
- uri = uri + "&rsrnd=" + new Date().getTime();
- post_data = null;
- } else {
- post_data = "rs=" + escape(func_name);
- for (i = 0; i < args.length-1; i++)
- post_data = post_data + "&rsargs[]=" + escape(args[i]);
- }
-
- x = sajax_init_object();
- x.open(sajax_request_type, uri, true);
- if (sajax_request_type == "POST") {
- x.setRequestHeader("Method", "POST " + uri + " HTTP/1.1");
- x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- }
- x.onreadystatechange = function() {
- if (x.readyState != 4)
- return;
- sajax_debug("received " + x.responseText);
-
- var status;
- var data;
- status = x.responseText.charAt(0);
- data = x.responseText.substring(2);
- if (status == "-")
- alert("Error: " + data);
- else
- args[args.length-1](data);
- }
- x.send(post_data);
- sajax_debug(func_name + " uri = " + uri + "/post = " + post_data);
- sajax_debug(func_name + " waiting..");
- delete x;
- }
- //-->
- <?php
- $html = ob_get_contents();
- ob_end_clean();
- return $html;
- }
-
-
- function sajax_show_common_js()
- {
- echo $this->sajax_get_common_js();
- }
-
-
- function sajax_esc($val)
- {
- return str_replace('"', '\\\\"', $val);
- }
-
-
- /**
- * sajax_get_one_stub
- *
- * @param string $func_name
- */
- function sajax_get_one_stub($func_name)
- {
- ob_start();
- ?>
-
- // wrapper for <?php echo $func_name; ?>
-
- function x_<?php echo $func_name; ?>() {
- sajax_do_call("<?php echo $func_name; ?>",
- x_<?php echo $func_name; ?>.arguments);
- }
-
- <?php
- $html = ob_get_contents();
- ob_end_clean();
- return $html;
- }
-
-
- function sajax_show_one_stub($func_name) {
- echo sajax_get_one_stub($func_name);
- }
-
-
- /**
- * export user functions to sajax ...
- *
- */
- function sajax_export() {
- $n = func_num_args();
- for ($i = 0; $i < $n; $i++) {
- $this->sajax_export_list[] = func_get_arg($i);
- }
- }
-
-
- function sajax_get_javascript()
- {
- $html = "";
- if (! $this->sajax_js_has_been_shown) {
- $html .= $this->sajax_get_common_js();
- $this->sajax_js_has_been_shown = 1;
- }
- foreach ($this->sajax_export_list as $func) {
- $html .= $this->sajax_get_one_stub($func);
- }
- return $html;
- }
-
-
- function sajax_show_javascript()
- {
- echo $this->sajax_get_javascript();
- }
-
-
-} // End sajax class
-
-
-?> \ No newline at end of file
diff --git a/usr/local/www/index.php b/usr/local/www/index.php
index 198211b..ac2dc68 100755
--- a/usr/local/www/index.php
+++ b/usr/local/www/index.php
@@ -59,20 +59,6 @@
## Load Functions Files
require_once('includes/functions.inc.php');
-
- ## Load AJAX, Initiate Class ###############################################
- require_once('includes/sajax.class.php');
-
- ## Initiate Class and Set location of ajax file containing
- ## the information that we need for this page. Also set functions
- ## that SAJAX will be using.
- $oSajax = new sajax();
- $oSajax->sajax_remote_uri = 'sajax/index.sajax.php';
- $oSajax->sajax_request_type = 'POST';
- $oSajax->sajax_export("get_stats");
- $oSajax->sajax_handle_client_request();
- ############################################################################
-
## Check to see if we have a swap space,
## if true, display, if false, hide it ...
@@ -551,69 +537,61 @@ echo $jscriptstr;
}
if ($config['widgets'] && $pconfig['sequence'] != ""){
- if ($displayarray[$widgetcounter] == "show"){
- $divdisplay = "block";
- $display = "block";
- $inputdisplay = "show";
- $showWidget = "none";
- $mindiv = "inline";
- }
- else if ($displayarray[$widgetcounter] == "hide") {
- $divdisplay = "block";
- $display = "none";
- $inputdisplay = "hide";
- $showWidget = "inline";
- $mindiv = "none";
- }
- else if ($displayarray[$widgetcounter] == "close"){
- $divdisplay = "none";
- $display = "block";
- $inputdisplay = "close";
- $showWidget = "none";
- $mindiv = "inline";
- }
- else{
- $divdisplay = "none";
- $display = "block";
- $inputdisplay = "none";
- $showWidget = "none";
- $mindiv = "inline";
- }
- }
- else
- {
- if ($firstprint == false){
- $divdisplay = "block";
- $display = "block";
- $inputdisplay = "show";
- $showWidget = "none";
- $mindiv = "inline";
- $firstprint = true;
- }
- else
- {
- if ($widget == "interfaces.widget.php")
- {
+ switch($displayarray[$widgetcounter]){
+ case "show":
$divdisplay = "block";
$display = "block";
$inputdisplay = "show";
$showWidget = "none";
$mindiv = "inline";
- }
- else if ($widget == "traffic_graphs.widget.php")
- {
+ break;
+ case "hide":
$divdisplay = "block";
+ $display = "none";
+ $inputdisplay = "hide";
+ $showWidget = "inline";
+ $mindiv = "none";
+ berak;
+ case "close":
+ $divdisplay = "none";
$display = "block";
- $inputdisplay = "show";
+ $inputdisplay = "close";
$showWidget = "none";
$mindiv = "inline";
- }
- else {
+ break;
+ default:
$divdisplay = "none";
$display = "block";
- $inputdisplay = "close";
+ $inputdisplay = "none";
$showWidget = "none";
$mindiv = "inline";
+ break;
+ }
+ } else {
+ if ($firstprint == false){
+ $divdisplay = "block";
+ $display = "block";
+ $inputdisplay = "show";
+ $showWidget = "none";
+ $mindiv = "inline";
+ $firstprint = true;
+ } else {
+ switch ($widget) {
+ case "interfaces.widget.php":
+ case "traffic_graphs.widget.php":
+ $divdisplay = "block";
+ $display = "block";
+ $inputdisplay = "show";
+ $showWidget = "none";
+ $mindiv = "inline";
+ break;
+ default:
+ $divdisplay = "none";
+ $display = "block";
+ $inputdisplay = "close";
+ $showWidget = "none";
+ $mindiv = "inline";
+ break;
}
}
}
diff --git a/usr/local/www/javascript/index/sajax.js b/usr/local/www/javascript/index/ajax.js
index f44f8f0..79bd898 100644
--- a/usr/local/www/javascript/index/sajax.js
+++ b/usr/local/www/javascript/index/ajax.js
@@ -6,8 +6,15 @@
var update_interval = 11000;
function updateMeters() {
- x_get_stats(stats);
- window.setTimeout('updateMeters()', update_interval);
+ url = '/getstats.php'
+
+ new Ajax.Request(url, {
+ method: 'get',
+ onSuccess: function(transport) {
+ stats(transport.responseText);
+ }
+ });
+ setTimeout('updateMeters()', update_interval);
}
function stats(x) {
@@ -133,16 +140,15 @@ function updateInterfaces(x){
}
function widgetActive(x) {
- var widget = document.getElementById(x + '-container');
+ var widget = $(x + '-container');
if (widget.style.display != "none")
return true;
else
return false;
}
-/* start ajax helper "thread" if not started */
-if(!ajaxStarted) {
- window.setTimeout('updateMeters()', update_interval);
- var ajaxStarted = true;
-}
+/* start updater */
+document.observe('dom:loaded', function(){
+ setTimeout('updateMeters()', update_interval);
+});
diff --git a/usr/local/www/sajax/index.sajax.php b/usr/local/www/sajax/index.sajax.php
deleted file mode 100755
index 13a5acb..0000000
--- a/usr/local/www/sajax/index.sajax.php
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/local/bin/php
-<?
- if(Connection_Aborted()) {
- exit;
- }
- require_once("auth.inc");
-
- require("../includes/sajax.class.php");
- require("../includes/functions.inc.php");
-
- $oSajax = new sajax();
- $oSajax->sajax_export("get_stats");
- $oSajax->sajax_handle_client_request();
-?> \ No newline at end of file
OpenPOWER on IntegriCloud