0byt3m1n1-V2
Path:
/
home
/
a
/
c
/
a
/
academiac
/
www
/
[
Home
]
File: log.php.tar
home/academiac/www/administrator/components/com_virtuemart/controllers/log.php 0000604 00000002520 15137243210 0024145 0 ustar 00 <?php if( !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' ); /** * * @version * @package VirtueMart * @subpackage Log * @copyright Copyright (C) VirtueMart Team - All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * VirtueMart is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details. * * http://virtuemart.org */ // Load the controller framework jimport('joomla.application.component.controller'); if(!class_exists('VmController'))require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'vmcontroller.php'); /** * Report Controller * * @package VirtueMart * @subpackage Report * @author Wicksj */ class VirtuemartControllerLog extends VmController { /** * Log Controller Constructor */ function __constuct(){ parent::__construct(); } /** * Generic cancel task * */ public function cancel(){ // back from order $this->setRedirect('index.php?option=com_virtuemart&view=log' ); } } // pure php no closing tag home/academiac/www/libraries/joomla/error/log.php 0000644 00000001120 15137260424 0016065 0 ustar 00 <?php /** * @package Joomla.Platform * @subpackage Error * * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die; // TODO: Wack this into a language file when this gets merged if (JDEBUG) { JError::raiseWarning(100, "JLog has moved to jimport('joomla.log.log'), please update your code."); JError::raiseWarning(100, "JLog has changed its behaviour; please update your code."); } require_once JPATH_LIBRARIES . '/joomla/log/log.php'; home/academiac/www/plugins/system/log/log.php 0000644 00000002362 15137441141 0015273 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // no direct access defined('_JEXEC') or die; /** * Joomla! System Logging Plugin * * @package Joomla.Plugin * @subpackage System.log */ class plgSystemLog extends JPlugin { function onUserLoginFailure($response) { $log = JLog::getInstance(); $errorlog = array(); switch($response['status']) { case JAuthentication::STATUS_SUCCESS : { $errorlog['status'] = $response['type'] . " CANCELED: "; $errorlog['comment'] = $response['error_message']; $log->addEntry($errorlog); } break; case JAuthentication::STATUS_FAILURE : { $errorlog['status'] = $response['type'] . " FAILURE: "; if ($this->params->get('log_username', 0)) { $errorlog['comment'] = $response['error_message'] . ' ("' . $response['username'] . '")'; } else { $errorlog['comment'] = $response['error_message']; } $log->addEntry($errorlog); } break; default : { $errorlog['status'] = $response['type'] . " UNKNOWN ERROR: "; $errorlog['comment'] = $response['error_message']; $log->addEntry($errorlog); } break; } } } home/academiac/www/libraries/joomla/log/log.php 0000644 00000024204 15137461461 0015531 0 ustar 00 <?php /** * @package Joomla.Platform * @subpackage Log * * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die; jimport('joomla.log.logger'); JLoader::register('LogException', JPATH_PLATFORM . '/joomla/log/logexception.php'); JLoader::discover('JLogger', dirname(__FILE__) . '/loggers'); // @deprecated 12.1 jimport('joomla.filesystem.path'); /** * Joomla! Log Class * * This class hooks into the global log configuration settings to allow for user configured * logging events to be sent to where the user wishes them to be sent. On high load sites * SysLog is probably the best (pure PHP function), then the text file based loggers (CSV, W3C * or plain FormattedText) and finally MySQL offers the most features (e.g. rapid searching) * but will incur a performance hit due to INSERT being issued. * * @package Joomla.Platform * @subpackage Log * @since 11.1 */ class JLog { /** * All log priorities. * @var integer * @since 11.1 */ const ALL = 30719; /** * The system is unusable. * @var integer * @since 11.1 */ const EMERGENCY = 1; /** * Action must be taken immediately. * @var integer * @since 11.1 */ const ALERT = 2; /** * Critical conditions. * @var integer * @since 11.1 */ const CRITICAL = 4; /** * Error conditions. * @var integer * @since 11.1 */ const ERROR = 8; /** * Warning conditions. * @var integer * @since 11.1 */ const WARNING = 16; /** * Normal, but significant condition. * @var integer * @since 11.1 */ const NOTICE = 32; /** * Informational message. * @var integer * @since 11.1 */ const INFO = 64; /** * Debugging message. * @var integer * @since 11.1 */ const DEBUG = 128; /** * The global JLog instance. * @var JLog * @since 11.1 */ protected static $instance; /** * The array of instances created through the deprecated getInstance method. * @var array * @since 11.1 * @see JLog::getInstance() * @deprecated 12.1 */ public static $legacy = array(); /** * Container for JLogger configurations. * @var array * @since 11.1 */ protected $configurations = array(); /** * Container for JLogger objects. * @var array * @since 11.1 */ protected $loggers = array(); /** * Lookup array for loggers. * @var array * @since 11.1 */ protected $lookup = array(); /** * Constructor. * * @since 11.1 */ protected function __construct() { } /** * Method to add an entry to the log. * * @param mixed $entry The JLogEntry object to add to the log or the message for a new JLogEntry object. * @param integer $priority Message priority. * @param string $category Type of entry * @param string $date Date of entry (defaults to now if not specified or blank) * * @return void * * @since 11.1 */ public static function add($entry, $priority = JLog::INFO, $category = '', $date = null) { // Automatically instantiate the singleton object if not already done. if (empty(self::$instance)) { self::setInstance(new JLog); } // If the entry object isn't a JLogEntry object let's make one. if (!($entry instanceof JLogEntry)) { $entry = new JLogEntry((string) $entry, $priority, $category, $date); } self::$instance->addLogEntry($entry); } /** * Method to set the way the JError will handle different error levels. * Use this if you want to override the default settings. * * @param array $options The object configuration array. * @param integer $priorities Message priority * @param array $categories Types of entry * * @return void * * @since 11.1 */ public static function addLogger(array $options, $priorities = JLog::ALL, $categories = array()) { // Automatically instantiate the singleton object if not already done. if (empty(self::$instance)) { self::setInstance(new JLog); } // The default logger is the formatted text log file. if (empty($options['logger'])) { $options['logger'] = 'formattedtext'; } $options['logger'] = strtolower($options['logger']); // Generate a unique signature for the JLog instance based on its options. $signature = md5(serialize($options)); // Register the configuration if it doesn't exist. if (empty(self::$instance->configurations[$signature])) { self::$instance->configurations[$signature] = $options; } self::$instance->lookup[$signature] = (object) array( 'priorities' => $priorities, 'categories' => array_map('strtolower', (array) $categories)); } /** * Returns a JLog object for a given log file/configuration, only creating it if it doesn't already exist. * * This method must be invoked as: * <code>$log = JLog::getInstance($file, $options, $path);</code> * * @param string $file The filename of the log file. * @param array $options The object configuration array. * @param string $path The base path for the log file. * * @return JLog * * @since 11.1 * * @deprecated 12.1 */ public static function getInstance($file = 'error.php', $options = null, $path = null) { // Deprecation warning. JLog::add('JLog::getInstance() is deprecated. See JLog::addLogger().', JLog::WARNING, 'deprecated'); // Get the system configuration object. $config = JFactory::getConfig(); // Set default path if not set and sanitize it. if (!$path) { $path = $config->get('log_path'); } // If no options were explicitly set use the default from configuration. if (empty($options)) { $options = (array) $config->get('log_options'); } // Fix up the options so that we use the w3c format. $options['text_entry_format'] = empty($options['format']) ? null : $options['format']; $options['text_file'] = $file; $options['text_file_path'] = $path; $options['logger'] = 'w3c'; // Generate a unique signature for the JLog instance based on its options. $signature = md5(serialize($options)); // Only create the object if not already created. if (empty(self::$legacy[$signature])) { self::$legacy[$signature] = new JLog; // Register the configuration. self::$legacy[$signature]->configurations[$signature] = $options; // Setup the lookup to catch all. self::$legacy[$signature]->lookup[$signature] = (object) array('priorities' => JLog::ALL, 'categories' => array()); } return self::$legacy[$signature]; } /** * Returns a reference to the a JLog object, only creating it if it doesn't already exist. * Note: This is principally made available for testing and internal purposes. * * @param JLog $instance The logging object instance to be used by the static methods. * * @return void * * @since 11.1 */ public static function setInstance($instance) { if (($instance instanceof JLog) || $instance === null) { self::$instance = & $instance; } } /** * Method to add an entry to the log file. * * @param array $entry Array of values to map to the format string for the log file. * * @return boolean True on success. * * @since 11.1 * * @deprecated 12.1 Use JLog::add() instead. */ public function addEntry($entry) { // Deprecation warning. JLog::add('JLog::addEntry() is deprecated, use JLog::add() instead.', JLog::WARNING, 'deprecated'); // Easiest case is we already have a JLogEntry object to add. if ($entry instanceof JLogEntry) { return $this->addLogEntry($entry); } // We have either an object or array that needs to be converted to a JLogEntry. elseif (is_array($entry) || is_object($entry)) { $tmp = new JLogEntry(''); foreach ((array) $entry as $k => $v) { switch ($k) { case 'c-ip': $tmp->clientIP = $v; break; case 'status': $tmp->category = $v; break; case 'level': $tmp->priority = $v; break; case 'comment': $tmp->message = $v; break; default: $tmp->$k = $v; break; } } } // Unrecognized type. else { return false; } return $this->addLogEntry($tmp); } /** * Method to add an entry to the appropriate loggers. * * @param JLogEntry $entry The JLogEntry object to send to the loggers. * * @return void * * @since 11.1 * @throws LogException */ protected function addLogEntry(JLogEntry $entry) { // Find all the appropriate loggers based on priority and category for the entry. $loggers = $this->findLoggers($entry->priority, $entry->category); foreach ((array) $loggers as $signature) { // Attempt to instantiate the logger object if it doesn't already exist. if (empty($this->loggers[$signature])) { $class = 'JLogger' . ucfirst($this->configurations[$signature]['logger']); if (class_exists($class)) { $this->loggers[$signature] = new $class($this->configurations[$signature]); } else { throw new LogException(JText::_('Unable to create a JLogger instance: ')); } } // Add the entry to the logger. $this->loggers[$signature]->addEntry($entry); } } /** * Method to find the loggers to use based on priority and category values. * * @param integer $priority Message priority. * @param string $category Type of entry * * @return array The array of loggers to use for the given priority and category values. * * @since 11.1 */ protected function findLoggers($priority, $category) { // Initialize variables. $loggers = array(); // Sanitize inputs. $priority = (int) $priority; $category = strtolower($category); // Let's go iterate over the loggers and get all the ones we need. foreach ((array) $this->lookup as $signature => $rules) { // Check to make sure the priority matches the logger. if ($priority & $rules->priorities) { // If either there are no set categories (meaning all) or the specific category is set, add this logger. if (empty($category) || empty($rules->categories) || in_array($category, $rules->categories)) { $loggers[] = $signature; } } } return $loggers; } } home/academiac/www/administrator/components/com_csvi/models/log.php 0000604 00000042656 15140166502 0021644 0 ustar 00 <?php /** * Log model * * @package CSVI * @author Roland Dalmulder * @link http://www.csvimproved.com * @copyright Copyright (C) 2006 - 2013 RolandD Cyber Produksi. All rights reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html * @version $Id: log.php 2275 2013-01-03 21:08:43Z RolandD $ */ defined('_JEXEC') or die; jimport( 'joomla.application.component.modellist' ); /** * Log Model * * @package CSVI */ class CsviModelLog extends JModelList { /** @var Set the context */ var $_context = 'com_csvi.log'; /** @var int holds the log ID */ private $_id = null; /** @var object holds the pagination */ private $_page = null; /** @var int holds the total number of items in database */ private $_limittotal = null; /** @var int holds the number of items to display */ private $_limit = null; /** @var int holds the offset where to start */ private $_limitstart = null; /** * Constructor * * @copyright * @author RolandD * @todo * @see * @access public * @param * @return * @since 4.0 */ public function __construct() { if (empty($config['filter_fields'])) { $config['filter_fields'] = array('l.action', 'l.action_type', 'l.template_name', 'l.records', 'l.file_name', 'l.run_cancelled', 'l.userid', 'l.logstamp'); } parent::__construct($config); } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @copyright * @author RolandD * @todo * @see * @access protected * @param * @return void * @since 4.0 */ protected function populateState() { // Initialise variables. $app = JFactory::getApplication('administrator'); // Load the filter state $this->setState('filter.action', $app->getUserStateFromRequest($this->_context.'.filter.action', 'filter_actiontype', false, 'word')); // List state information. // Controls the query ORDER BY parent::populateState('l.logstamp', 'desc'); } /** * Build an SQL query to load the list data. * * @copyright * @author RolandD * @todo * @see * @access protected * @param * @return object the query to execute * @since 4.0 */ protected function getListQuery() { // Create a new query object. $jinput = JFactory::getApplication()->input; $db = $this->getDbo(); $query = $db->getQuery(true); // Select the required fields from the table. $query->select('run_id AS id, userid, logstamp, action, action_type, template_name, records, run_id, file_name, run_cancelled'); $query->from('#__csvi_logs AS l'); // Add all the filters $filters = array(); if ($this->getState('filter.action')) $filters[] = $db->quoteName('action').' = '.$db->Quote($this->getState('filter.action')); if (!empty($filters)) { // Add the clauses to the query. $query->where('('.implode(' AND ', $filters).')'); } // Add the list ordering clause. $orderCol = $this->state->get('list.ordering'); $orderDirn = $this->state->get('list.direction'); $query->order($db->getEscaped($orderCol.' '.$orderDirn)); return $query; } /** * Set the log ID * * @copyright * @author RolandD * @todo * @see * @access public * @param * @return * @since 4.0 */ public function setId($id) { $this->_id = $id; } /** * Store the log results after import/export * * @copyright * @author RolandD * @todo * @see * @access public * @param * @return void * @since 3.0 */ public function getStoreLogResults() { // Load the settings $jinput = JFactory::getApplication()->input; $settings = $jinput->get('settings', null, null); if ($settings->get('log.log_store', 1)) { $db = JFactory::getDbo(); $csvilog = $jinput->get('csvilog', null, null); $template = $jinput->get('template', null, null); $logresult = $csvilog->getStats(); $details = array(); $logcount = array(); // Get the number of lines processed based on type switch ($logresult['action']) { case 'import': $logcount['import'] = $jinput->get('recordsprocessed', 0, 'int'); break; case 'export': $logcount['export'] = $jinput->get('logcount', 0, 'int'); break; case 'maintenance': $logcount['maintenance'] = $csvilog->GetLineNumber(); break; } // Get the database connector $rowlog = $this->getTable('csvi_logs'); // Check for an existing ID if (!$csvilog->getLogid()) { // Get user ID $my = JFactory::getUser(); $details['userid'] = $my->id; // Create GMT timestamp jimport('joomla.utilities.date'); $jnow = new JDate(time()); $details['logstamp'] = $jnow->toMySQL(); // Set action if it is import or export $details['action'] = $logresult['action']; // Type of action $details['action_type'] = $logresult['action_type']; // Name of template used $details['template_name'] = $logresult['action_template']; // Get the number of records $details['records'] = $logcount[$logresult['action']]; // Get the import ID $details['run_id'] = $csvilog->getId(); // Get the import filename $details['file_name'] = $csvilog->getFilename(); // Bind the data if (!$rowlog->bind($details)) { JError::raiseWarning(0, JText::_('COM_CSVI_CANNOT_BIND_LOG_DATA')); } // Check the data if (!$rowlog->check()) { JError::raiseWarning(0, JText::_('COM_CSVI_CANNOT_CHECK_LOG_DATA')); } // Store the data if (!$rowlog->store()) { JError::raiseWarning(0, JText::_('COM_CSVI_CANNOT_STORE_LOG_DATA')); } else { // Clean up any old logs $csvilog->cleanUpLogs(); } $csvilog->setLogid($rowlog->id); $rowlog->reset(); } else { $rowlog->load($csvilog->getLogid()); if (array_key_exists('action', $logresult) && isset($logcount[$logresult['action']])) $rowlog->records = $logcount[$logresult['action']]; else $rowlog->records = 0; $rowlog->store(); } // Store the log details if (is_array($logresult) && !empty($logresult)) { $q = 'INSERT INTO `#__csvi_log_details` ( `id`,`log_id`,`line`,`description`,`result`,`status` ) VALUES '; $qvalue = ''; foreach ($logresult as $linenr => $result) { if (is_int($linenr)) { foreach ($result['status'] as $status => $stat) { $qvalue .= "(0, ".$csvilog->getLogid().", ".$linenr.", ".$db->Quote(trim($stat['message'])).", '".$stat['result']."', '".$status."'),\n"; } } } if (!empty($qvalue)) { $q .= substr(trim($qvalue), 0, -1).';'; $db->setQuery($q); if ($db->query()) $csvilog->cleanStats(); } else $csvilog->cleanStats(); } } } /** * Delete 1 or more selected log entries * * @copyright * @author RolandD * @todo * @see * @access public * @param * @return array of results * @since 3.0 */ public function getDelete() { $jinput = JFactory::getApplication()->input; jimport('joomla.filesystem.file'); $db = JFactory::getDBO(); $cids = $jinput->get('cid', array(), 'array'); $file_not_found = 0; $file_deleted = 0; $file_not_deleted = 0; $log_del = 0; $log_del_error = 0; $log_detail_del = 0; $log_detail_del_error = 0; // Make it an array if (!is_array($cids)) (array)$cids; $rowlog = $this->getTable('csvi_logs'); foreach ($cids as $key => $run_id) { $filename = CSVIPATH_DEBUG.'/com_csvi.log.'.$run_id.'.php'; if (JFile::exists($filename)){ if (JFile::delete($filename)) { $file_deleted++; } else $file_not_deleted++; } else $file_not_found++; // Delete the log entry if (empty($run_id)) $q = "SELECT id FROM #__csvi_logs WHERE (run_id = '' OR run_id IS NULL)"; else $q = "SELECT id FROM #__csvi_logs WHERE run_id = ".$run_id; $db->setQuery($q); $ids = $db->loadResultArray(); foreach ($ids as $idkey => $id) { if (!$rowlog->delete($id)) $log_del_error++; else { $log_del++; } // Delete the log details $q = "DELETE FROM #__csvi_log_details WHERE log_id = ".$id; $db->setQuery($q); if (!$db->query()) $log_detail_del_error++; else $log_detail_del++; } } // Set the results $results = array(); if ($file_not_found > 0) { if ($file_not_found == 1) $results['ok'][] = JText::_('COM_CSVI_DELETE_LOG_FILE_NOT_FOUND'); else $results['ok'][] = JText::sprintf('COM_CSVI_DELETE_LOGS_FILE_NOT_FOUND', $file_not_found); } if ($file_deleted > 0) { if ($file_deleted == 1) $results['ok'][] = JText::_('COM_CSVI_DELETE_LOG_FILE'); else $results['ok'][] = JText::sprintf('COM_CSVI_DELETE_LOGS_FILE', $file_deleted); } if ($file_not_deleted > 0) { if ($file_not_deleted == 1) $results['nok'][] = JText::_('COM_CSVI_CANNOT_DELETE_LOG_FILE'); else $results['nok'][] = JText::sprintf('COM_CSVI_CANNOT_DELETE_LOGS_FILE', $file_not_deleted); } if ($log_del > 0) { if ($log_del == 1) $results['ok'][] = JText::_('COM_CSVI_DELETE_LOG_DATA'); else $results['ok'][] = JText::sprintf('COM_CSVI_DELETE_LOGS_DATA', $log_del); } if ($log_del_error > 0) { if ($log_del == 1) $results['nok'][] = JText::_('COM_CSVI_CANNOT_DELETE_LOG_DATA'); else $results['nok'][] = JText::sprintf('COM_CSVI_CANNOT_DELETE_LOGS_DATA', $log_del); } if ($log_detail_del > 0) { if ($log_del == 1) $results['ok'][] = JText::_('COM_CSVI_DELETE_LOG_DETAILS_DATA'); else $results['ok'][] = JText::sprintf('COM_CSVI_DELETE_LOGS_DETAILS_DATA', $log_detail_del); } if ($log_detail_del_error > 0) { if ($log_del == 1) $results['nok'][] = JText::_('COM_CSVI_CANNOT_DELETE_LOG_DETAILS_DATA'); else $results['nok'][] = JText::sprintf('COM_CSVI_CANNOT_DELETE_LOGS_DETAILS_DATA', $log_detail_del_error); } return $results; } /** * Delete all log entries * * @copyright * @author RolandD * @todo * @see * @access public * @param * @return array of results * @since 3.0 */ public function getDeleteAll() { $db = JFactory::getDBO(); $results = array(); // Empty the log table $q = "TRUNCATE ".$db->quoteName('#__csvi_logs'); $db->setQuery($q); if ($db->query()) $results['ok'][] = JText::_('COM_CSVI_DELETE_LOG_DATA_ALL_OK'); else $results['nok'][] = JText::_('COM_CSVI_DELETE_LOG_DATA_ALL_NOK'); // Empty the log details table $q = "TRUNCATE ".$db->quoteName('#__csvi_log_details'); $db->setQuery($q); if ($db->query()) $results['ok'][] = JText::_('COM_CSVI_DELETE_LOG_DATA_DETAILS_ALL_OK'); else $results['nok'][] = JText::_('COM_CSVI_DELETE_LOG_DATA_DETAILS_ALL_NOK'); return $results; } /** * Load the statistics for displaying * * @copyright * @author RolandD * @todo * @see * @access public * @param * @return * @since 3.0 */ public function getStats() { $jinput = JFactory::getApplication()->input; $db = JFactory::getDbo(); $csvilog = $jinput->get('csvilog', null, null); if ($csvilog) $run_id = $csvilog->getId(); else if ($jinput->get('run_id', '', 'int') > 0) $run_id = $jinput->get('run_id', '', 'int'); else { // Try to get it from the cid $cids = $jinput->get('cid', array(), 'array'); if (is_array($cids) && array_key_exists('0', $cids)) $run_id = $cids[0]; else return false; } $details = array(); if ($run_id) { jimport('joomla.filesystem.file'); // Add the run ID $details['run_id'] = $run_id; // Get the total number of records $q = "SELECT SUM(records) AS total_records FROM #__csvi_logs WHERE run_id = ".$run_id; $db->setQuery($q); $details['total_records'] = $db->loadResult(); // Get the general details $q = "SELECT MIN(id) AS min_id, MAX(id)+1 AS max_id, file_name, action, action_type, run_cancelled FROM #__csvi_logs WHERE run_id = ".$run_id." GROUP BY id"; $db->setQuery($q); $min_max = $db->loadObject(); if (!empty($min_max)) { // Protect against 'record not found' // Set the filename $details['file_name'] = $min_max->file_name; // Set the action $details['action'] = $min_max->action; // Set the action type $details['action_type'] = $min_max->action_type; // Set if the action was cancelled $details['run_cancelled'] = $min_max->run_cancelled; // Get some status results $q = "SELECT COUNT(status) AS total_result, result, status FROM #__csvi_log_details WHERE log_id BETWEEN ".$min_max->min_id." AND ".$min_max->max_id." GROUP BY status"; $db->setQuery($q); $details['result'] = $db->loadObjectList('status'); } // Check if there is a debug log file $logfile = CSVIPATH_DEBUG.'/com_csvi.log.'.$run_id.'.php'; if (JFile::exists($logfile)) { $details['debug'] = JHtml::_('link', JRoute::_('index.php?option=com_csvi&task=log.downloaddebug&run_id='.$run_id), JText::_('COM_CSVI_DOWNLOAD_DEBUG_LOG')); $attribs = 'class="modal" onclick="" rel="{handler: \'iframe\', size: {x: 950, y: 500}}"'; $details['debugview'] = JHtml::_('link', JRoute::_('index.php?option=com_csvi&task=log.logreader&tmpl=component&run_id='.$run_id), JText::_('COM_CSVI_VIEW_DEBUG_LOG'), $attribs); } else { $details['debug'] = JText::_('COM_CSVI_NO_DEBUG_LOG_FOUND'); $details['debugview'] = ''; } } return $details; } /** * Load the statistics */ public function getStatsMessage() { $jinput = JFactory::getApplication()->input; $db = JFactory::getDBO(); $run_id = $jinput->get('run_id', false, 'int'); if (!$run_id) { /* Try to get it from the cid */ $cids = $jinput->get('cid', array(), 'array'); if (is_array($cids) && array_key_exists('0', $cids)) $run_id = $cids[0]; else return false; } $details = array(); if ($run_id) { $q = "SELECT line, description, status, log_id, result FROM #__csvi_log_details WHERE log_id IN (SELECT id FROM #__csvi_logs WHERE run_id = ".$run_id.") ORDER BY line"; $db->setQuery($q); $details = $db->loadObjectList(); } return $details; } /** * Download a debug report */ public function downloadDebug() { jimport('joomla.filesystem.file'); jimport('joomla.filesystem.archive'); $jinput = JFactory::getApplication()->input; $run_id = $jinput->get('run_id', 0, 'int'); $filepath = CSVIPATH_DEBUG.'/'; $filename = 'com_csvi.log.'.$run_id.'.'; $zip = JArchive::getAdapter('zip'); $files = array(); $files[] = array('name' => $filename.'php', 'time' => filemtime($filepath.$filename.'php'), 'data' => JFile::read($filepath.$filename.'php')); $zip->create($filepath.$filename.'zip', $files); if (preg_match('/Opera[\s|\/]([^\s]+)/i', $_SERVER['HTTP_USER_AGENT'])) { $UserBrowser = "Opera"; } elseif (preg_match('/MSIE\s([^\s|;]+)/i', $_SERVER['HTTP_USER_AGENT'])) { $UserBrowser = "IE"; } else { $UserBrowser = ''; } $mime_type = ($UserBrowser == 'IE' || $UserBrowser == 'Opera') ? 'application/octetstream' : 'application/octet-stream'; /* Clean the buffer */ while( @ob_end_clean() ); header('Content-Description: File Transfer'); header('Content-Type: ' . $mime_type); header('Content-Transfer-Encoding: binary'); header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Content-Length: ' . filesize($filepath.$filename.'zip')); if ($UserBrowser == 'IE') { header('Content-Disposition: inline; filename="'.$filename.'zip"'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); } else { header('Content-Disposition: attachment; filename="'.$filename.'zip"'); header('Pragma: no-cache'); } /* Send the file */ readfile($filepath.$filename.'zip'); JFile::delete($filepath.$filename.'zip'); /* Close the transmission */ exit(); } /** * Get the action types * * @author RolandD * @access public * @return array list of action types */ public function getActionTypes() { $db = JFactory::getDbo(); $options = array(); $options[] = JHtml::_('select.option', '', JText::_('COM_CSVI_LOG_DONT_USE')); $q = "SELECT UPPER(action) FROM #__csvi_logs GROUP BY action"; $db->setQuery($q); $actions = $db->loadResultArray(); if (!empty($actions)) { foreach ($actions as $action) { $options[] = JHTML::_('select.option', $action, JText::_('COM_CSVI_'.$action)); } } return $options; } /** * Reads a log file and displays its results * * @author RolandD * @since 2.3.11 * @access public * @return array of log lines */ public function getLogfile() { $jinput = JFactory::getApplication()->input; $run_id = $jinput->get('run_id', 0, 'int'); $log = array(); if ($run_id > 0) { $logfile = CSVIPATH_DEBUG.'/com_csvi.log.'.$run_id.'.php'; $loglines = array(); if (file_exists($logfile)) { $loglines = file($logfile); foreach ($loglines as $key => $line) { switch ($key) { case '0': // Skip the first line break; case '1': // Get the date if (strstr($line, ':')) { list($text, $value) = explode(': ', $line); } else $value = ''; $log['date'] = $value; break; case '2': // Get the Joomla version if (strstr($line, ':')) { list($text, $value) = explode(': ', $line); } else $value = ''; $log['joomla'] = $value; break; case '3': // This is an empty line break; case '4': // Get the fields if (strstr($line, ':')) { list($text, $value) = explode(': ', $line); $fields = preg_split("/\t/", $value); foreach ($fields as $fkey => $field) { $log['fields'][] = $field; } } else $log['fields'] = array(); break; default: // The actual log lines $log['entries'][] = preg_split("/\t/", $line); break; } } } } return $log; } } ?>