Php photo gallery TWG | JFUploader | TWG Flash upload | WFU | Forum

Get help for TinyWebGallery, the best image gallery. The forum is also home for the Joomla JFUploader, TWG Flash Uploader and the Wordpress flash uploader.
It is currently 12. Dec 2024, 15:17

This forum is readonly now. Please use the new forum if you don't find the answer to your question here. The new forum is at https://www.tinywebgallery.com/blog/forum/


All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: 7. Mar 2012, 22:48 
Offline

Joined: 19. Dec 2011, 20:13
Posts: 5
I'm trying to solve some problem with a "session expired" system message, and i came upon the subject behavior.keepalive .
Joomla uses this by ..
Code:
echo JHTML::_('behavior.keepalive');

.. I think this inserts the following code lines into the <head> by MooTools:
(some info: http://www.joomlatonight.com/joomla-tut ... -in-joomla )
Code:
function keepAlive() { new Ajax("index.php", {method: "get"}).request(); }
window.addEvent("domready", function() { keepAlive.periodical(2640000); });


Strange is this code piece, found in /components/com_jfuploader/jfuploader.html.php ..

Code:
$jConfig = new JConfig();
// we can only have a keepalive if Joomla and JFU use the same session!
if ($jConfig->session_handler != 'database') {
  echo JHTML::_('behavior.keepalive');
}
// now I overwrite the existing function.
echo '
<script type="text/javascript">
function debugError(errorString) { }

function getIDN() {
   return "'.$jfu_config['idn_url'].'/";
}

function uploadRunning(val) {
   acivateKeep = (val == "true");
   if (oldKeepAlive != null) {
     oldKeepAlive();
   }
}
var oldKeepAlive = window.keepAlive;
var acivateKeep = false;
window.keepAlive = function() {
  if (acivateKeep && (oldKeepAlive != null)) {
    oldKeepAlive();   
  }
}
</script>';


.. to me this overwrite method is a tricky way to hack / adjust some Joomla functionality.
Why isn't the MooTools way used?
And what happens if i just comment-out this code piece? (which i did in my override /templates/mytemplate/html/com_jfuploader/jfuploader.html.php)


Top
 Profile  
 
PostPosted: 8. Mar 2012, 00:49 
Offline
Site Admin
User avatar

Joined: 1. Aug 2005, 12:53
Posts: 11232
adding JHTML::_('behavior.keepalive'); would mean that the page will never time out.

I only wanted that the page does not time out during the upload (+ the normal session time)
The flash calles the uploadRunning with true during the upload. After the upload is is caling it once with false so that the session does time out then.

If you remove the extra functions the session will not time out (leaving uploadRunning empty because this is called by the flash) or if you remove the JHTML::_('behavior.keepalive'); the session will time out if a upload is longer than the session timeout (not on all browsers because some do sent a proper session cookie while other do not!).

Best, Michael


Top
 Profile  
 
PostPosted: 8. Mar 2012, 01:40 
Offline

Joined: 19. Dec 2011, 20:13
Posts: 5
ok, and .. is there no other way to "..overwrite the existing function..", as done in the code?

when you say "..that the page does not time out during the upload.." what's the practical use? Why not keep things simple and just suppose that the user picks some files and clicks the upload button shortly after!? (which will happen 99% i guess). Then only the code line JHTML::_('behavior.keepalive') is sufficient. And remember, MooTools can nicely dynamically add/remove HTML parts, even JS functions etc. - this should be better coding anyhow, i think.


Top
 Profile  
 
PostPosted: 8. Mar 2012, 11:17 
Offline
Site Admin
User avatar

Joined: 1. Aug 2005, 12:53
Posts: 11232
this is not big magic. I simply wrap my function around the one Joomla creates. For everything else Joomla code would have to be modified.

It's about the upload time. At a slow line e.g. the upload takes 3 hours. If the timeout is 30 min you can access Joomla for the next 30 min after the upload finishes.
with only using JHTML::_('behavior.keepalive') the page does never time out. So if you forget your upload and someone comes to the computer the next day he can still use your login. so you can of course remove the overwriting on the function but I still think that keeping a page alive forever is not good.

So it's up to you...

Best, Michael


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 34 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
powered by phpbb | Datenschutz/ Privacy policy