/**
  * Adds metadata-query parts to the statement to be generated
  *
  * @param string &$strQuery
  * @param string[] &$arrParams
  * @return void
  */
 public function getQuery(&$strQuery, &$arrParams)
 {
     //add the module filter
     if (count($this->arrFilterModules) > 0) {
         $strIn = "";
         foreach ($this->arrFilterModules as $intModuleId) {
             $arrParams[] = $intModuleId;
             $strIn .= "?,";
         }
         $strIn = substr($strIn, 0, -1);
         $strQuery .= " AND system_module_nr in (" . $strIn . ") ";
     }
     //add the user filter
     if (!empty($this->strFilterUser)) {
         $strQuery .= " AND system_owner = ? ";
         $arrParams[] = $this->strFilterUser;
     }
     //add the class filter
     if (count($this->arrFilterClasses) > 0) {
         $strIn = "";
         foreach ($this->arrFilterClasses as $strOneClass) {
             $arrParams[] = $strOneClass;
             $strIn .= "?,";
         }
         $strIn = substr($strIn, 0, -1);
         $strQuery .= " AND system_class in (" . $strIn . ") ";
     }
     //add the start-date filter
     if ($this->objFilterChangeStartDate !== null) {
         $strQuery .= "AND system_lm_time >= ? ";
         $arrParams[] = $this->objFilterChangeStartDate->getTimeInOldStyle();
     }
     //add the end-date filter
     if ($this->objFilterChangeEndDate !== null) {
         $strQuery .= "AND system_lm_time <= ? ";
         $arrParams[] = $this->objFilterChangeEndDate->getTimeInOldStyle();
     }
     if ($this->getBitPortalSearch()) {
         $strQuery .= " AND D.search_ix_portal_object = 1 ";
         $strQuery .= " AND system_status = 1 ";
     }
     if ($this->getStrPortalLang() != "") {
         $strQuery .= " AND ( D.search_ix_content_lang IS NULL OR D.search_ix_content_lang ='' OR D.search_ix_content_lang = ? )";
         $arrParams[] = $this->getStrPortalLang();
     }
 }
 /**
  * Creates int-values of the passed date-values
  */
 private function processDates()
 {
     if ($this->getParam("filter") == "true") {
         $this->objDateStart = new class_date();
         $this->objDateStart->generateDateFromParams("start", $this->getAllParams());
         $this->objDateEnd = new class_date();
         $this->objDateEnd->generateDateFromParams("end", $this->getAllParams());
         class_carrier::getInstance()->getObjSession()->setSession(self::$STR_SESSION_KEY_DATE_START, $this->objDateStart->getTimeInOldStyle());
         class_carrier::getInstance()->getObjSession()->setSession(self::$STR_SESSION_KEY_DATE_END, $this->objDateEnd->getTimeInOldStyle());
         if ($this->getParam("interval") != "") {
             $this->intInterval = (int) $this->getParam("interval");
         } else {
             $this->intInterval = 2;
         }
         class_carrier::getInstance()->getObjSession()->setSession(self::$STR_SESSION_KEY_INTERVAL, $this->intInterval);
     }
 }
 /**
  * This method is called, when the widget should generate it's content.
  * Return the complete content using the methods provided by the base class.
  * Do NOT use the toolkit right here! 
  *
  * @return string
  */
 public function getWidgetOutput()
 {
     $strReturn = "";
     if (!class_module_system_module::getModuleByName("stats")->rightView()) {
         return $this->getLang("commons_error_permissions");
     }
     $objStatsCommon = new class_stats_report_common(class_carrier::getInstance()->getObjDB(), class_carrier::getInstance()->getObjToolkit("admin"), class_carrier::getInstance()->getObjLang());
     //check wich infos to produce
     if ($this->getFieldValue("current") == "checked") {
         $strReturn .= $this->getLang("stats_online") . $objStatsCommon->getNumberOfCurrentUsers();
         $strReturn .= $this->widgetSeparator();
     }
     if ($this->getFieldValue("chart") == "checked") {
         //load the last view days
         $objDate = new class_date();
         $objDate->setIntHour(0);
         $objDate->setIntMin(0);
         $objDate->setIntSec(0);
         $arrHits = array();
         $arrLabels = array();
         for ($intI = 0; $intI < 7; $intI++) {
             $objEndDate = clone $objDate;
             $objEndDate->setNextDay();
             $objStatsCommon->setStartDate($objDate->getTimeInOldStyle());
             $objStatsCommon->setEndDate($objEndDate->getTimeInOldStyle());
             $arrHits[] = $objStatsCommon->getHits();
             $arrLabels[] = $objDate->getIntDay();
             $objDate->setPreviousDay();
         }
         $arrHits = array_reverse($arrHits);
         $arrLabels = array_reverse($arrLabels);
         $strReturn .= $this->widgetText($this->getLang("stats_hits"));
         $objChart = class_graph_factory::getGraphInstance();
         $objChart->setArrXAxisTickLabels($arrLabels);
         $objChart->addLinePlot($arrHits, "");
         $objChart->setBitRenderLegend(false);
         $objChart->setIntHeight(220);
         $objChart->setIntWidth(300);
         $objChart->setStrXAxisTitle("");
         $objChart->setStrYAxisTitle("");
         $strReturn .= $objChart->renderGraph();
     }
     if ($this->getFieldValue("day") == "checked") {
         //current day:
         //pass date to commons-object
         $objDate = new class_date();
         $objDate->setIntHour(0);
         $objDate->setIntMin(0);
         $objDate->setIntSec(0);
         $strReturn .= $this->widgetText(dateToString($objDate, false));
         $objStatsCommon->setStartDate($objDate->getTimeInOldStyle());
         $objDate->setNextDay();
         $objStatsCommon->setEndDate($objDate->getTimeInOldStyle());
         $strReturn .= $this->widgetText($this->getLang("stats_hits") . " " . $objStatsCommon->getHits());
         $strReturn .= $this->widgetText($this->getLang("stats_visitors") . " " . $objStatsCommon->getVisitors());
         $strReturn .= $this->widgetSeparator();
     }
     if ($this->getFieldValue("last") == "checked") {
         $strReturn .= $this->widgetText($this->getLang("stats_ip") . " " . $this->getLang("stats_page"));
         $intMaxRecords = $this->getFieldValue("nrLast");
         if (!is_numeric($intMaxRecords) || $intMaxRecords > 15) {
             $intMaxRecords = 15;
         }
         $arrRecordsets = class_carrier::getInstance()->getObjDB()->getPArray("SELECT * FROM " . _dbprefix_ . "stats_data ORDER BY stats_date DESC ", array(), 0, $intMaxRecords - 1);
         foreach ($arrRecordsets as $arrOneRecord) {
             $strReturn .= $this->widgetText($arrOneRecord["stats_ip"] . " " . $arrOneRecord["stats_page"]);
         }
     }
     return $strReturn;
 }
echo str_pad("Visitors", 15);
echo str_pad("Downloads", 15);
echo str_pad("PServer-Requests", 20);
echo str_pad("PServer-Unique", 20);
echo "\n";
for ($intYear = 2012; $intYear <= 2014; $intYear++) {
    for ($intMonth = 1; $intMonth <= 12; $intMonth++) {
        $objStartDate->setIntDay(1)->setIntMonth($intMonth)->setIntYear($intYear)->setIntHour(0)->setIntMin(0)->setIntSec(1);
        $objEndDate = clone $objStartDate;
        $objEndDate->setNextDay();
        while ($objEndDate->getIntDay() != 1) {
            $objEndDate->setNextDay();
        }
        $objEndDate->setPreviousDay()->setIntHour(23)->setIntMin(59)->setIntSec(59);
        echo str_pad($objStartDate->getIntMonth() . "/" . $objStartDate->getIntYear(), 10);
        echo str_pad(getHits($objStartDate->getTimeInOldStyle(), $objEndDate->getTimeInOldStyle()), 15, " ", STR_PAD_LEFT);
        echo str_pad(getVisitors($objStartDate->getTimeInOldStyle(), $objEndDate->getTimeInOldStyle()), 15, " ", STR_PAD_LEFT);
        echo str_pad(getDownloads($objStartDate->getTimeInOldStyle(), $objEndDate->getTimeInOldStyle()), 15, " ", STR_PAD_LEFT);
        echo str_pad(getPackageserverRequests($objStartDate->getLongTimestamp(), $objEndDate->getLongTimestamp()), 20, " ", STR_PAD_LEFT);
        echo str_pad(getUniquePackageserverSystems($objStartDate->getLongTimestamp(), $objEndDate->getLongTimestamp()), 20, " ", STR_PAD_LEFT);
        echo "\n";
        flush();
        ob_flush();
    }
}
echo "Total unique installations: \n";
getTotalUniquePackagesererSystems();
function getTotalUniquePackagesererSystems()
{
    $strQuery = "SELECT log_hostname, count(*) AS ANZ\n                FROM " . _dbprefix_ . "packageserver_log\n                GROUP BY log_hostname\n                ORDER BY ANZ DESC   ";
    $intI = 0;
 /**
  * Shows a form or deltes a timeintervall from the logs
  *
  * @throws class_exception
  * @return string "" in case of success
  * @permissions edit
  * @autoTestable
  */
 protected function actionLogbookFlush()
 {
     $strReturn = "";
     if ($this->getParam("flush") == "") {
         $strReturn .= $this->objToolkit->formHeader(class_link::getLinkAdminHref($this->getArrModule("modul"), "logbookFlush", "flush=1"));
         $strReturn .= $this->objToolkit->formTextRow($this->getLang("logbook_hint_date"));
         $strReturn .= $this->objToolkit->formDateSingle("date", $this->getLang("commons_date"), new class_date());
         $strReturn .= $this->objToolkit->formInputSubmit($this->getLang("commons_save"));
         $strReturn .= $this->objToolkit->formClose();
     } elseif ($this->getParam("flush") == "1") {
         //Build the date
         $objDate = new class_date();
         $objDate->generateDateFromParams("date", $this->getAllParams());
         if (!class_module_mediamanager_logbook::deleteFromLogs($objDate->getTimeInOldStyle())) {
             throw new class_exception("Error deleting log-rows", class_exception::$level_ERROR);
         }
         $this->adminReload(class_link::getLinkAdminHref($this->getArrModule("modul"), "logbook"));
     }
     return $strReturn;
 }