--- index.php.old 2007-04-23 13:36:53.000000000 -0700 +++ index.php 2007-04-23 13:01:36.000000000 -0700 @@ -20,8 +20,9 @@ You should have received a copy of the GNU General Public License along with TorrentFlux; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + Modified by Cameron Dale for Ajax, v3 +*/ include_once("config.php"); include_once("functions.php"); @@ -34,17 +35,38 @@ if(getRequestVar("pagerefresh") == "false") { $_SESSION['prefresh'] = false; - header("location: index.php"); + header("location: ".$_SERVER['PHP_SELF']); exit(); } if(getRequestVar("pagerefresh") == "true") { $_SESSION["prefresh"] = true; - header("location: index.php"); + header("location: ".$_SERVER['PHP_SELF']); exit(); } } +// set ajax refresh option into the session cookie +if(array_key_exists("ajaxrefresh", $_GET)) +{ + if(getRequestVar("ajaxrefresh") == "false") + { + $_SESSION['use_ajax'] = false; + header("location: ".$_SERVER['PHP_SELF']); + exit(); + } + + if(getRequestVar("ajaxrefresh") == "true") + { + $_SESSION["use_ajax"] = true; + header("location: ".$_SERVER['PHP_SELF']); + exit(); + } +} + +include_once("Sajax.php"); +include_once("functionsAjax.php"); + // Check to see if QManager is running if not Start it. if (checkQManager() == 0 ) { @@ -325,7 +347,7 @@ } else { - header("location: index.php"); + header("location: ".$_SERVER['PHP_SELF']); exit(); } } @@ -415,7 +437,7 @@ if ($messages == "") { AuditAction($cfg["constants"]["url_upload"], $file_name); - header("location: index.php"); + header("location: ".$_SERVER['PHP_SELF']); exit(); } else @@ -453,7 +475,7 @@ AuditAction($cfg["constants"]["file_upload"], $file_name); - header("location: index.php"); + header("location: ".$_SERVER['PHP_SELF']); } else { @@ -497,7 +519,7 @@ AuditAction($cfg["constants"]["delete_torrent"], $delfile); - header("location: index.php"); + header("location: ".$_SERVER['PHP_SELF']); exit(); } else @@ -566,7 +588,7 @@ } else { - header("location: index.php"); + header("location: ".$_SERVER['PHP_SELF']); exit(); } } @@ -621,16 +643,20 @@ { // torrent has been started... try and kill it. AuditAction($cfg["constants"]["unqueued_torrent"], $QEntry . "has been started -- TRY TO KILL IT"); - header("location: index.php?alias_file=".$alias_file."&kill=true&kill_torrent=".urlencode($QEntry)); + header("location: ".$_SERVER['PHP_SELF']."?alias_file=".$alias_file."&kill=true&kill_torrent=".urlencode($QEntry)); exit(); } - header("location: index.php"); + header("location: ".$_SERVER['PHP_SELF']); exit(); } $drivespace = getDriveSpace($cfg["path"]); +sajax_init(); +// $sajax_debug_mode = 1; +sajax_export("ajaxUpdate"); +sajax_handle_client_request(); /************************************************************ @@ -646,7 +672,10 @@ "; + if (!isset($cfg['use_ajax'])) $cfg['use_ajax'] = 0; + if (((isset($_SESSION['use_ajax'])) && ($_SESSION['use_ajax'] == false)) || + ((!isset($_SESSION['use_ajax'])) && ($cfg['use_ajax'] == false))) { + echo ""; ?> "; + + echo " + + @@ -686,7 +791,13 @@ + "> + +"> +
@@ -715,7 +826,7 @@ "> - + - + "; @@ -819,11 +931,11 @@ - +
:
@@ -724,7 +835,7 @@

:
@@ -789,7 +900,7 @@ } echo "
"; - echo ""._ONLINE.":
"; + echo ""._ONLINE.":
"; for($inx = 0; $inx < count($arOnlineUsers); $inx++) { @@ -797,11 +908,11 @@ echo "". $arOnlineUsers[$inx]; echo "
\n"; } - + echo "
"; // Does the user want to see offline users? if ($cfg["hide_offline"] == false) { - echo ""._OFFLINE.":
"; + echo ""._OFFLINE.":
"; // Show offline users for($inx = 0; $inx < count($arOfflineUsers); $inx++) @@ -810,6 +921,7 @@ echo "".$arOfflineUsers[$inx]; echo "
\n"; } + echo "
"; } echo "
" colspan="2"> + " colspan="2">
-
" colspan="2"> @@ -851,7 +963,7 @@
" colspan="6"> @@ -903,7 +1015,7 @@ if(checkQManager() > 0) { echo " Queue Manager Running
"; - echo "".strval(getRunningTorrentCount())." torrent(s) running and ".strval(getNumberOfQueuedTorrents())." queued.
"; + echo "".strval(getRunningTorrentCount())." torrent(s) running and ".strval(getNumberOfQueuedTorrents())." queued.
"; echo "Total torrents server will run: ".$cfg["maxServerThreads"]."
"; echo "Total torrents a user may run: ".$cfg["maxUserThreads"]."
"; echo "* Torrents are queued when limits are met.
"; @@ -921,8 +1033,17 @@ if(!isset($_SESSION['prefresh']) || ($_SESSION['prefresh'] == true)) { + if (((isset($_SESSION['use_ajax'])) && ($_SESSION['use_ajax'] == false)) || + ((!isset($_SESSION['use_ajax'])) && ($cfg['use_ajax'] == false))) { echo "*** "._PAGEWILLREFRESH." ".$cfg["page_refresh"]." "._SECONDS." ***
"; + echo ""._TURNOFFREFRESH.""; + echo "   Turn ON Ajax"; + } else { + echo "*** "._PAGEWILLREFRESH." ".$cfg["ajax_refresh"]." "._SECONDS." ***
"; echo ""._TURNOFFREFRESH.""; + echo "   Turn OFF Ajax"; + } } else { @@ -948,15 +1069,15 @@ - + - + - + @@ -966,7 +1087,7 @@ { $loadavg_array = explode(" ", exec("cat ".escapeshellarg($cfg["loadavg_path"]))); $loadavg = $loadavg_array[2]; - echo "".$loadavg.""; + echo "".$loadavg.""; } else {
: kB/s kB/s
: kB/s kB/s
:
: