'."\n"; $data .= 'locked='.($this->locked ? 1 : 0)."\n"; $data .= 'tstamp='.$this->tstamp."\n"; $data .= 'nonce='.$this->nonce; $filename = $this->getStorageFilename(); jimport('joomla.filesystem.file'); return JFile::write($filename, $data); } /** * When was the last backup time using this plugin? * @return int The timestamp of the last backup */ private function getLastBackupTime() { // If we're in test mode, the last backup time is always 0, so as to // trigger a backup. if( $this->params->get('test',0) == 1 ) { return 0; } $db = JFactory::getDBO(); $sql = 'SELECT `backupstart` FROM `#__ak_stats` WHERE `origin` = "lazy" AND NOT(`status` = "failed") ORDER BY `backupstart` DESC LIMIT 0,1'; $db->setQuery($sql); $tstamp = $db->loadResult(); if($db->getError()) { return time(); } if(empty($tstamp)) { $sql = 'SELECT COUNT(*) FROM `#__ak_stats` WHERE `origin` = "lazy" AND NOT(`status` = "failed")'; $numRows = $db->loadResult(); if($numRows == 0) { return 0; } else { return time(); } } jimport('joomla.utilities.date'); $date = new JDate($tstamp); return $date->toUnix(); } /** * Get the Javascript to create the iFrame in the background, when page * caching is enabled. * @return string */ private function getJavascript() { $proxyurl = JURI::base().'index.php?aklazy=check'; return << function aklazyinit() { var xhr = undefined; if (typeof XMLHttpRequest == "undefined") { try { xhr = new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch (e) {} if(xhr == 'undefined') try { xhr = ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch (e) {} if(xhr == 'undefined') try { xhr = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {} } else { xhr = new XMLHttpRequest(); xhr.open('GET', '$proxyurl', true); xhr.onreadystatechange = function (aEvt) { if (xhr.readyState == 4) { if(xhr.status == 200) { var msg = xhr.responseText; // Start processing the message var junk = null; var message = ""; // Get rid of junk before the data var valid_pos = msg.indexOf('###'); if( valid_pos == -1 ) { return; } else if( valid_pos != 0 ) { // Data is prefixed with junk junk = msg.substr(0, valid_pos); message = msg.substr(valid_pos); } else { message = msg; } message = message.substr(3); // Remove triple hash in the beginning // Get of rid of junk after the data var valid_pos = message.lastIndexOf('###'); if( valid_pos == -1 ) { return; } else if( valid_pos == 0 ) { // No data return; } message = message.substr(0, valid_pos); // Remove triple hash in the end // Create the iFrame var iframe = document.createElement('iframe'); iframe.setAttribute('width', '0'); iframe.setAttribute('height', '0'); iframe.setAttribute('src', message); document.body.appendChild(iframe); } } }; xhr.send(null); } } window.onload=aklazyinit; ENDJS; } } function AkeebaBackupLazyShutdown() { if(connection_status() >= CONNECTION_TIMEOUT ) { // Oops! We timed out. Try to clean up. $filename = JPATH_SITE.DS.'cache'.DS.'plg_aklazy.php'; jimport('joomla.filesystem.file'); if(JFile::exists($filename)) { JFile::delete($filename); } AECoreKettenrad::reset(); } }