public function xmlExportFileUpdate() { $currenttime = time(); $xmlHelper = new xmlHelper(); $db = JFactory::getDbo(); $query = "SELECT * FROM " . $this->_table_prefix . "xml_export AS x " . "WHERE x.published=1 " . "AND x.auto_sync=1 " . "AND x.sync_on_request=0 " . "AND x.auto_sync_interval!=0 "; $db->setQuery($query); $exportlist = $db->loadObjectlist(); for ($i = 0; $i < count($exportlist); $i++) { $db = JFactory::getDbo(); $query = "SELECT * FROM " . $this->_table_prefix . "xml_export_log AS xl " . "WHERE xl.xmlexport_id = " . (int) $exportlist[$i]->xmlexport_id . " " . "ORDER BY xl.xmlexport_date DESC "; $db->setQuery($query); $lastrs = $db->loadObject(); if (count($lastrs) > 0) { $difftime = $currenttime - $lastrs->xmlexport_date; $hours = $difftime / (60 * 60); if ($exportlist[$i]->auto_sync_interval < $hours) { $xmlHelper->writeXMLExportFile($lastrs->xmlexport_id); } } } }
/** * Method to store the information * * @access public * @return boolean */ public function store($data, $export = 0) { $resarray = array(); $xmlhelper = new xmlHelper(); $data['xmlexport_on_category'] = @implode(',', $data['xmlexport_on_category']); $row =& $this->getTable(); if (!$row->bind($data)) { $this->setError($this->_db->getErrorMsg()); return false; } if (!$row->xmlexport_on_category) { $row->xmlexport_on_category = ''; } $row->published = $data['xmlpublished']; if (!$row->store()) { $this->setError($this->_db->getErrorMsg()); return false; } $xmlexport_ip_id = $data['xmlexport_ip_id']; $access_ipaddress = $data['access_ipaddress']; for ($i = 0; $i < count($xmlexport_ip_id); $i++) { if ($access_ipaddress[$i] != "") { if ($xmlexport_ip_id[$i] != 0) { $query = "UPDATE " . $this->_table_prefix . "xml_export_ipaddress " . "SET access_ipaddress='" . $access_ipaddress[$i] . "' " . "WHERE xmlexport_ip_id='" . $xmlexport_ip_id[$i] . "' "; } else { $query = "INSERT INTO " . $this->_table_prefix . "xml_export_ipaddress " . "(xmlexport_id, access_ipaddress) " . "VALUES " . "('" . $row->xmlexport_id . "', '" . $access_ipaddress[$i] . "') "; } $this->_db->setQuery($query); $this->_db->query(); } } if ($export == 1) { $filename = $xmlhelper->writeXMLExportFile($row->xmlexport_id); } return $row; }
/** * Generate XML file. * * @return void */ public function generateXMLExportFile() { $app = JFactory::getApplication(); $option = JRequest::getVar('option', 'com_redshop', 'request', 'string'); $xmlexport_id = JRequest::getInt('xmlexport_id'); if ($xmlexport_id) { require_once JPATH_ADMINISTRATOR . '/components/com_redshop/helpers/xmlhelper.php'; $xmlHelper = new xmlHelper(); $xmlHelper->writeXMLExportFile($xmlexport_id); $row = $xmlHelper->getXMLExportInfo($xmlexport_id); $link = JURI::root() . 'index.php?option=com_redshop&view=category&tmpl=component&task=download&file=' . $row->filename; $app->redirect($link); } }