TorrentFlux.com Hey, OppTupacShakur, you have 11 messages, 0 are new.
05-07-2007, 12:21:19
Home Help Search Profile Logout donate chat
News:


+  TorrentFlux Forums
|-+  Code Hacks and Tools
| |-+  TorrentFlux 2.1 Hacks
| | |-+  Ajax the index page [Updated v3]
« previous next »
Pages: 1 ... 3 4 [5] 6 7 8 Go Down Reply Notify of replies Send this topic Print
Author Topic: Ajax the index page [Updated v3]  (Read 15877 times)
steveholt
Jr. Member
**
Offline Offline

TF Base: Linux 2.x
Posts: 60


Debian Packager





View Profile WWW Email Personal Message (Offline)
« Reply #60 on: 08-30-2006, 22:57:00 » Reply with quote

1) when I move mouse over torrent status there is small popup (not new window) which resreshes itself couple times a second and then it stops (choked or smth) is there a way to force e.g. 1 refresh per second? (more often refreshing makes it unreadable)

Hmm, on mine the popup doesn't update at all while it's open, only if I let it close by mousing away and then open it by mousing over it again. Are you using Firefox (I am)? Do you have the ajax_refresh option in the tf_settings table set to something less than 1?

2) is there a way to modify original index.php to work with ajax instead of using new file? because I have few hacks in index.php and indexAjax.php looks little different and I dont know how to enable them (but I didn't spend more than 3 min trying:P)

I'll attach a patch that makes it very simple to see what the changes are. Hopefully you can apply it to your index.php. There are no deletions, only additions, so it shouldn't be too hard. A lot of the changes are replacing 'index.php' with "$_SERVER['PHP_SELF']" which isn't necessary if you actually make the ajaxed file the index.php file.

* indexAjax.diff.gz (3.61 KB - downloaded 18 times.)
Report to moderator   Logged

AthlonXP 2400+ | 3x300GB | 512MB RAM | Debian Testing | TF 2.3 | Python 2.4.4 | Apache 2.2.3 | PHP 5.2.0 (module)
qiuness
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 36



View Profile Email Personal Message (Offline)
« Reply #61 on: 09-10-2006, 15:20:47 » Reply with quote

steveholt is it possible to use ajax with xfer bandwidth/transfer statistics hack 2.1.1 ?

i did the update.. but all the statistics are gone

thanks
Report to moderator   Logged
steveholt
Jr. Member
**
Offline Offline

TF Base: Linux 2.x
Posts: 60


Debian Packager





View Profile WWW Email Personal Message (Offline)
« Reply #62 on: 09-10-2006, 23:59:06 » Reply with quote

steveholt is it possible to use ajax with xfer bandwidth/transfer statistics hack 2.1.1 ?

i did the update.. but all the statistics are gone

I looked at the changes to index.php that the xfer bandwidth/statistics hack makes, and it looks like there are some incompatible ones. I don't use the xfer hack myself, so I can't really help you with modifying your index.php file, but it should be possible to get the two working together. I suggest you use a program such as WinMerge for windows or xxdiff for Linux to compare the two index.php files (1 after applying the xfer hack, 1 after applying this hack) and see if you can create a new file that contains all the necessary components for both.

Good luck.
Report to moderator   Logged

AthlonXP 2400+ | 3x300GB | 512MB RAM | Debian Testing | TF 2.3 | Python 2.4.4 | Apache 2.2.3 | PHP 5.2.0 (module)
cpunch
Newbie
*
Offline Offline

Posts: 1



View Profile Personal Message (Offline)
« Reply #63 on: 09-14-2006, 22:16:00 » Reply with quote

I've installed this on my tflux2.1 server but two of my users are complaining that the AJAX page absolutely does not work for them.
They are both using Firefox 1.5.0.6 or 1.5.0.7.  No notable extension conflicts that I can see. 
They both claim that every time the page is supposed to do a quick easy AJAX refresh/update, instead it does a full refresh, the same as if they hit F5.

Using my own install of Firefox 1.5.0.6 I cannot reproduce these problems and I'm at a complete loss to explain why they might be happening only to these two users.

Also, I was curious if someone who has completely AJAX'd their index page would be kind enough to share the code.  While stats alone are cool, a page that didn't have to refresh every time you started/stopped/uploaded a torrent would be really nice.
Report to moderator   Logged
dragon_788
Newbie
*
Offline Offline

Posts: 12



View Profile Personal Message (Offline)
« Reply #64 on: 09-19-2006, 21:22:30 » Reply with quote

I noticed this doesn't refresh the logged in users either, is there a way to add that in without too much trouble?
Report to moderator   Logged
steveholt
Jr. Member
**
Offline Offline

TF Base: Linux 2.x
Posts: 60


Debian Packager





View Profile WWW Email Personal Message (Offline)
« Reply #65 on: 09-19-2006, 23:12:02 » Reply with quote

I've installed this on my tflux2.1 server but two of my users are complaining that the AJAX page absolutely does not work for them.
They are both using Firefox 1.5.0.6 or 1.5.0.7.  No notable extension conflicts that I can see. 
They both claim that every time the page is supposed to do a quick easy AJAX refresh/update, instead it does a full refresh, the same as if they hit F5.

Using my own install of Firefox 1.5.0.6 I cannot reproduce these problems and I'm at a complete loss to explain why they might be happening only to these two users.

Also, I was curious if someone who has completely AJAX'd their index page would be kind enough to share the code.  While stats alone are cool, a page that didn't have to refresh every time you started/stopped/uploaded a torrent would be really nice.

Sorry I can't be of more help, but I also can't reproduce this so I can't fix it. Perhaps the mysql entries are incorrect? Though if it works for you then I doubt it.

I am working on improving it, and adding the functionality you mention, but it may be awhile before that's done. You can try TorrentJax, though the last time I checked it was based on the 2.0 version, and if you use hacks then they won't work.
Report to moderator   Logged

AthlonXP 2400+ | 3x300GB | 512MB RAM | Debian Testing | TF 2.3 | Python 2.4.4 | Apache 2.2.3 | PHP 5.2.0 (module)
steveholt
Jr. Member
**
Offline Offline

TF Base: Linux 2.x
Posts: 60


Debian Packager





View Profile WWW Email Personal Message (Offline)
« Reply #66 on: 09-19-2006, 23:14:29 » Reply with quote

I noticed this doesn't refresh the logged in users either, is there a way to add that in without too much trouble?

There is, and I will do it soon, but you can try yourself if you want. I already added the identifiers to mark the logged in users area. All that's left is to add that info to the data that gets AJAXed in.
Report to moderator   Logged

AthlonXP 2400+ | 3x300GB | 512MB RAM | Debian Testing | TF 2.3 | Python 2.4.4 | Apache 2.2.3 | PHP 5.2.0 (module)
dragon_788
Newbie
*
Offline Offline

Posts: 12



View Profile Personal Message (Offline)
« Reply #67 on: 09-23-2006, 02:48:17 » Reply with quote

One thing I also ran into is that if left open for long periods of time it seems to stop updating, and I have to click a link to jumpstart it again, even if its only the home link, would be be possible to have it do a full page refresh every n number of AJAX refreshes?
Report to moderator   Logged
Paczesiowa
Full Member
***
Offline Offline

TF Base: Linux 2.x
Posts: 177



View Profile Email Personal Message (Offline)
« Reply #68 on: 09-23-2006, 05:59:05 » Reply with quote

i think there is a way to do that: in indexAjax.php there is
Code:
if (!isset($cfg['ajax_full_refresh'])) $cfg['ajax_full_refresh'] = 3600;

so I think u just need to change 3600 to n*5 where n is number of AJAX refreshes
Report to moderator   Logged

steveholt
Jr. Member
**
Offline Offline

TF Base: Linux 2.x
Posts: 60


Debian Packager





View Profile WWW Email Personal Message (Offline)
« Reply #69 on: 09-23-2006, 17:14:17 » Reply with quote

Actually, it's even easier than that. All you need to do is create a new entry in your settings table with the key "ajax_full_refresh" and the value of however many seconds you want between full refreshes.
Report to moderator   Logged

AthlonXP 2400+ | 3x300GB | 512MB RAM | Debian Testing | TF 2.3 | Python 2.4.4 | Apache 2.2.3 | PHP 5.2.0 (module)
atto
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 4



View Profile Personal Message (Offline)
« Reply #70 on: 09-24-2006, 06:58:32 » Reply with quote

I'm getting the following error when I click "turn ajax on" and "turn ajax off":

Code:
Warning: Cannot modify header information - headers already sent by (output started at /var/www/tf/functionsAjax.php:1759) in /var/www/tf/indexAjax.php on line 113

I'm having trouble reproducing this error. I've never seen it before, and I can't find the code on line 113 which is causing the problem. Have you modified indexAjax.php at all? If so, could you PM me and show me your modified file somehow. If not, did this error just start with the new version, and it worked fine before? Where does the error appear, on screen or in the apache logs?

Is anyone else getting an error like this?

The error shows up on the client (i.e. in my web browser.)  From what I can tell PHP thinks it has already sent headers by the time it gets to that line.  I'm running the default apache2 config for Debian Unstable (had to go to unstable to get the php5 libs).  Currently using an unmodified version of this mod, and I've had the same issue with all the versions I've tried.

same problem here. when trying to activate the ajax refresh through the link, i get an error message
Code:
Warning: Cannot modify header information - headers already sent by (output started at /var/www/torrentflux_2.1/html/functionsAjax.php:1745) in /var/www/torrentflux_2.1/html/index.php on line 123
after reloading the page (without the ajaxrefresh parameter), it shows "Turn OFF Ajax", seems to be that ajax is active, but it doesn't work. no values on the page are refreshed.
Report to moderator   Logged
steveholt
Jr. Member
**
Offline Offline

TF Base: Linux 2.x
Posts: 60


Debian Packager





View Profile WWW Email Personal Message (Offline)
« Reply #71 on: 09-24-2006, 12:50:49 » Reply with quote

same problem here. when trying to activate the ajax refresh through the link, i get an error message

OK, it seems a few people at least have this problem, though I am still unable to reproduce it. I suspect that browser differences are why some see the error and others don't, but I'm not sure.

As a first check to see if this is an error with my code or something else, have you tried clicking the "Turn Off Page Refresh" link to see if that generates the same error?

Whether or not that does create an error, I think I know how to fix this. Below are some directions for modifying your indexAjax.php file (I can't seem to post files anymore). It's basically the same except I moved the includes for the new files to below the lines that are generating the error.

Move the following 2 lines:

Code:
require("Sajax.php");
include_once("functionsAjax.php");

to below the following lines [I also changed require("Sajax.php") to include_once("Sajax.php")]:

Code:
    if($_GET["ajaxrefresh"] == "true")
    {
        $_SESSION["use_ajax"] = true;
        header("location: ".$_SERVER['PHP_SELF']);
        exit();
    }
}

So, now the top of your indexAjax.php file should look like this:

Code:
    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, v2
*/

include_once("config.php");
include_once("functions.php");

$messages = "";

// set refresh option into the session cookie
if(array_key_exists("pagerefresh", $_GET))
{
    if($_GET["pagerefresh"] == "false")
    {
        $_SESSION['prefresh'] = false;
        header("location: ".$_SERVER['PHP_SELF']);
        exit();
    }

    if($_GET["pagerefresh"] == "true")
    {
        $_SESSION["prefresh"] = true;
        header("location: ".$_SERVER['PHP_SELF']);
        exit();
    }
}
// set ajax refresh option into the session cookie
if(array_key_exists("ajaxrefresh", $_GET))
{
    if($_GET["ajaxrefresh"] == "false")
    {
        $_SESSION['use_ajax'] = false;
        header("location: ".$_SERVER['PHP_SELF']);
        exit();
    }

    if($_GET["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 )
{
    if ($cfg["AllowQueing"])
    {

Let me know if this helps, and thanks for reporting the problems.
Report to moderator   Logged

AthlonXP 2400+ | 3x300GB | 512MB RAM | Debian Testing | TF 2.3 | Python 2.4.4 | Apache 2.2.3 | PHP 5.2.0 (module)
atto
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 4



View Profile Personal Message (Offline)
« Reply #72 on: 09-24-2006, 13:58:36 » Reply with quote

Let me know if this helps, and thanks for reporting the problems.

hi,
thx for your help. i tried to use the "Turn Off Page Refresh" and i got the same error (this time indexAjax.php on line 75).
when i changed the code the way you submitted, the error messages are gone. but still there is no ajax update Sad
i tested this with firefox and konqueror, so i don't think the browser is the reason.
the webserver is an apache 1.3.34 with php5 (both from debian etch).
« Last Edit: 09-25-2006, 09:58:17 by atto » Report to moderator   Logged
thecarlhall
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 3



View Profile Personal Message (Offline)
« Reply #73 on: 09-25-2006, 20:12:46 » Reply with quote

The logic here doesn't make sense but here's what I did to the PHP pages for this hack.

1.  Removed ^M from the 3 PHP files  (sed s/^M$//g -i ...)
2.  Removed all empty lines from the PHP files (s '/^$/d' -i ...)
3.  Incorporate changes for moving require and include lines further down the code
4.  I turned on debug mode (look for $sajax_debug_mode = 1; and uncomment it).  I watched the debug roll through a few times and noticed the page was updating.  I turned off debugging and everything has been working since.

I don't know what made things work and the above changes don't seem like the kind of things that would affect this but something in there has kicked the Ajax into gear.
Report to moderator   Logged
thecarlhall
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 3



View Profile Personal Message (Offline)
« Reply #74 on: 09-26-2006, 00:02:47 » Reply with quote

Seems like the updates don't happen whenever there items in the queue.  Once I remove all items from the queue, updates start working again.
Report to moderator   Logged
Pages: 1 ... 3 4 [5] 6 7 8 Go Up Reply Notify of replies Send this topic Print 
« previous next »
Jump to:  


Powered by MySQL Powered by SMF 1.1.1 | SMF © 2006, Simple Machines LLC Powered by PHP