* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 6594 $ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ if (!defined('_CAN_LOAD_FILES_')) exit; class StatsEquipment extends ModuleGraph { private $_html = ''; private $_query = ''; private $_query2 = ''; function __construct() { $this->name = 'statsequipment'; $this->tab = 'analytics_stats'; $this->version = 1.0; $this->author = 'PrestaShop'; $this->need_instance = 0; parent::__construct(); $this->displayName = $this->l('Software'); $this->description = $this->l('Display the software used by your visitors.'); } public function install() { return (parent::install() AND $this->registerHook('AdminStatsModules')); } private function getEquipment() { $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT DISTINCT g.* FROM `'._DB_PREFIX_.'connections` c LEFT JOIN `'._DB_PREFIX_.'guest` g ON g.`id_guest` = c.`id_guest` WHERE c.`date_add` BETWEEN '.ModuleGraph::getDateBetween(), false); $calcArray = array('jsOK' => 0, 'jsKO' => 0, 'javaOK' => 0, 'javaKO' => 0, 'wmpOK' => 0, 'wmpKO' => 0, 'qtOK' => 0, 'qtKO' => 0, 'realOK' => 0, 'realKO' => 0, 'flashOK' => 0, 'flashKO' => 0, 'directorOK' => 0, 'directorKO' => 0); while ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->nextRow($result)) { if (!$row['javascript']) { ++$calcArray['jsKO']; continue; } ++$calcArray['jsOK']; ($row['windows_media']) ? ++$calcArray['wmpOK'] : ++$calcArray['wmpKO']; ($row['real_player']) ? ++$calcArray['realOK'] : ++$calcArray['realKO']; ($row['adobe_flash']) ? ++$calcArray['flashOK'] : ++$calcArray['flashKO']; ($row['adobe_director']) ? ++$calcArray['directorOK'] : ++$calcArray['directorKO']; ($row['sun_java']) ? ++$calcArray['javaOK'] : ++$calcArray['javaKO']; ($row['apple_quicktime']) ? ++$calcArray['qtOK'] : ++$calcArray['qtKO']; } if (!$calcArray['jsOK']) return false; $equip = array( 'Windows Media Player' => $calcArray['wmpOK'] / ($calcArray['wmpOK'] + $calcArray['wmpKO']), 'Real Player' => $calcArray['realOK'] / ($calcArray['realOK'] + $calcArray['realKO']), 'Apple Quicktime' => $calcArray['qtOK'] / ($calcArray['qtOK'] + $calcArray['qtKO']), 'Sun Java' => $calcArray['javaOK'] / ($calcArray['javaOK'] + $calcArray['javaKO']), 'Adobe Flash' => $calcArray['flashOK'] / ($calcArray['flashOK'] + $calcArray['flashKO']), 'Adobe Shockwave' => $calcArray['directorOK'] / ($calcArray['directorOK'] + $calcArray['directorKO']) ); arsort($equip); return $equip; } public function hookAdminStatsModules($params) { if (Tools::getValue('export')) if (Tools::getValue('exportType') == 'browser') $this->csvExport(array('type' => 'pie', 'option' => 'wb')); elseif (Tools::getValue('exportType') == 'os') $this->csvExport(array('type' => 'pie', 'option' => 'os')); $equipment = $this->getEquipment(); $this->_html = '