/** * Triggers the "real" creation of the report and wraps the code inline into a xml-structure * * @return string * @permissions view */ protected function actionGetReport() { $strPlugin = $this->getParam("plugin"); $strReturn = ""; $objPluginManager = new class_pluginmanager(class_module_stats_admin::$STR_PLUGIN_EXTENSION_POINT, "/admin/statsreports"); $objPlugin = null; foreach ($objPluginManager->getPlugins(array(class_carrier::getInstance()->getObjDB(), $this->objToolkit, $this->getObjLang())) as $objOneReport) { if (uniStrReplace("class_stats_report_", "", get_class($objOneReport)) == $strPlugin) { $objPlugin = $objOneReport; break; } } if ($objPlugin !== null && $objPlugin instanceof interface_admin_statsreports) { //get date-params as ints $intStartDate = mktime(0, 0, 0, $this->objDateStart->getIntMonth(), $this->objDateStart->getIntDay(), $this->objDateStart->getIntYear()); $intEndDate = mktime(0, 0, 0, $this->objDateEnd->getIntMonth(), $this->objDateEnd->getIntDay(), $this->objDateEnd->getIntYear()); $objPlugin->setEndDate($intEndDate); $objPlugin->setStartDate($intStartDate); $objPlugin->setInterval($this->intInterval); $arrImage = $objPlugin->getReportGraph(); if (!is_array($arrImage)) { $arrImage = array($arrImage); } foreach ($arrImage as $strImage) { if ($strImage != "") { $strReturn .= $this->objToolkit->getGraphContainer($strImage); } } $strReturn .= $objPlugin->getReport(); $strReturn = "<content><![CDATA[" . $strReturn . "]]></content>"; } return $strReturn; }
/** * Responsible for creating the xml-feed * * @param string $strTitle * @param string $strLink * @param string $strDesc * @param string $strPage * @param class_module_news_news[] $arrNews * * @return string */ private function createNewsfeedXML($strTitle, $strLink, $strDesc, $strPage, $arrNews) { $objFeed = new class_rssfeed(); $objFeed->setStrTitle($strTitle); $objFeed->setStrLink($strLink); $objFeed->setStrDesc($strDesc); foreach ($arrNews as $objOneNews) { if ($objOneNews->rightView()) { $objDate = $objOneNews->getObjStartDate(); if ($objDate == null) { $objDate = new class_date(); } $objFeed->addElement($objOneNews->getStrTitle(), getLinkPortalHref($strPage, "", "newsDetail", "", $objOneNews->getSystemid(), "", $objOneNews->getStrTitle()), $objOneNews->getSystemid(), $objOneNews->getStrIntro(), mktime($objDate->getIntHour(), $objDate->getIntMin(), $objDate->getIntSec(), $objDate->getIntMonth(), $objDate->getIntDay(), $objDate->getIntYear())); } } return $objFeed->generateFeed(); }
/** * Returns a simple date-form element. By default used to enter a date without a time. * * @param string $strName * @param string $strTitle * @param class_date $objDateToShow * @param string $strClass = inputDate * @param boolean $bitWithTime * * @throws class_exception * @return string * @since 3.2.0.9 */ public function formDateSingle($strName, $strTitle, $objDateToShow, $strClass = "", $bitWithTime = false) { //check passed param if ($objDateToShow != null && !$objDateToShow instanceof class_date) { throw new class_exception("param passed to class_toolkit_admin::formDateSingle is not an instance of class_date", class_exception::$level_ERROR); } if ($bitWithTime) { $strTemplateID = $this->objTemplate->readTemplate("/elements.tpl", "input_datetime_simple"); } else { $strTemplateID = $this->objTemplate->readTemplate("/elements.tpl", "input_date_simple"); } $arrTemplate = array(); $arrTemplate["class"] = $strClass; $arrTemplate["titleDay"] = $strName . "_day"; $arrTemplate["titleMonth"] = $strName . "_month"; $arrTemplate["titleYear"] = $strName . "_year"; $arrTemplate["titleHour"] = $strName . "_hour"; $arrTemplate["titleMin"] = $strName . "_minute"; $arrTemplate["title"] = $strTitle; $arrTemplate["valueDay"] = $objDateToShow != null ? $objDateToShow->getIntDay() : ""; $arrTemplate["valueMonth"] = $objDateToShow != null ? $objDateToShow->getIntMonth() : ""; $arrTemplate["valueYear"] = $objDateToShow != null ? $objDateToShow->getIntYear() : ""; $arrTemplate["valueHour"] = $objDateToShow != null ? $objDateToShow->getIntHour() : ""; $arrTemplate["valueMin"] = $objDateToShow != null ? $objDateToShow->getIntMin() : ""; $arrTemplate["valuePlain"] = dateToString($objDateToShow, false); // if($bitWithTime) $arrTemplate["dateFormat"] = class_carrier::getInstance()->getObjLang()->getLang("dateStyleShort", "system"); // else // $arrTemplate["dateFormat"] = class_carrier::getInstance()->getObjLang()->getLang("dateStyleLong", "system"); $arrTemplate["calendarLang"] = class_carrier::getInstance()->getObjSession()->getAdminLanguage(); $arrTemplate["titleTime"] = class_carrier::getInstance()->getObjLang()->getLang("titleTime", "system"); //set up the container div $arrTemplate["calendarId"] = $strName; $strContainerId = $strName . "_calendarContainer"; $arrTemplate["calendarContainerId"] = $strContainerId; $arrTemplate["calendarLang_weekday"] = " [" . class_carrier::getInstance()->getObjLang()->getLang("toolsetCalendarWeekday", "system") . "]\n"; $arrTemplate["calendarLang_month"] = " [" . class_carrier::getInstance()->getObjLang()->getLang("toolsetCalendarMonth", "system") . "]\n"; return $this->objTemplate->fillTemplate($arrTemplate, $strTemplateID); }
public function testReports() { if (!defined("_skinwebpath_")) { define("_skinwebpath_", "1"); } echo "processing reports...\n"; $arrReportsInFs = class_resourceloader::getInstance()->getFolderContent("/admin/statsreports", array(".php"), false, function ($strOneFile) { if (uniStripos($strOneFile, "class_stats_report") === false) { return false; } return true; }, function (&$strOneFile) { $strOneFile = uniSubstr($strOneFile, 0, -4); $strOneFile = new $strOneFile(class_carrier::getInstance()->getObjDB(), class_carrier::getInstance()->getObjToolkit("admin"), class_carrier::getInstance()->getObjLang()); }); $arrReports = array(); foreach ($arrReportsInFs as $objReport) { if ($objReport instanceof interface_admin_statsreports) { $arrReports[$objReport->getTitle()] = $objReport; } $objStartDate = new class_date(); $objStartDate->setPreviousDay(); $objEndDate = new class_date(); $objEndDate->setNextDay(); $intStartDate = mktime(0, 0, 0, $objStartDate->getIntMonth(), $objStartDate->getIntDay(), $objStartDate->getIntYear()); $intEndDate = mktime(0, 0, 0, $objEndDate->getIntMonth(), $objEndDate->getIntDay(), $objEndDate->getIntYear()); $objReport->setEndDate($intEndDate); $objReport->setStartDate($intStartDate); $objReport->setInterval(2); } /** @var interface_admin_statsreports $objReport */ foreach ($arrReports as $objReport) { ob_start(); echo "processing report " . $objReport->getTitle() . "\n"; $objReport->getReport(); $objReport->getReportGraph(); } }
/** * Renders the field itself. * In most cases, based on the current toolkit. * * @return string */ public function renderField() { $objToolkit = class_carrier::getInstance()->getObjToolkit("admin"); //create a date object if possible $objDate = null; if ($this->getStrValue() instanceof class_date) { $objDate = $this->getStrValue(); } else { if ($this->getStrValue() != "") { $objDate = new class_date($this->getStrValue()); } } //set selected value $intMonth = null; $intYear = null; $intDay = 1; if ($objDate != null) { $intMonth = $objDate->getIntMonth(); $intYear = $objDate->getIntYear(); $intDay = $objDate->getIntDay(); } //create hint and form elements $strReturn = ""; if ($this->getStrHint() != null) { $strReturn .= $objToolkit->formTextRow($this->getStrHint()); } if ($this->bitRenderDay) { $strReturn .= $objToolkit->formInputText($this->getStrEntryName() . "ph", $this->getStrLabel(), $intDay, "", "", true); $strReturn .= $objToolkit->formInputHidden($this->getStrEntryName() . self::DAY_SUFFIX, $intDay); } else { $strReturn .= $objToolkit->formInputHidden($this->getStrEntryName() . self::DAY_SUFFIX, $intDay); } $strReturn .= $objToolkit->formInputDropdown($this->getStrEntryName() . self::MONTH_SUFFIX, self::$arrDropDownMonth, $this->bitRenderDay ? "" : $this->getStrLabel(), $intMonth, "", !$this->getBitReadonly()); $strReturn .= $objToolkit->formInputDropdown($this->getStrEntryName() . self::YEAR_SUFFIX, self::$arrDropDownYear, "", $intYear, "", !$this->getBitReadonly()); return $strReturn; }
/** * Converts a dateobject to a readable string * * @param class_date $objDate * @param bool $bitLong * @param string $strFormat if given, the passed format will be used, otherwise the format defined in the i18n files * usable placeholders are: d, m, y, h, i, s * * @return string */ function dateToString($objDate, $bitLong = true, $strFormat = "") { $strReturn = ""; //if the $objDate is a string, convert it to date object if ($objDate != null && !$objDate instanceof class_date && uniEreg("([0-9]){14}", $objDate)) { $objDate = new class_date($objDate); } if ($objDate instanceof class_date) { //convert to a current date if ($strFormat == "") { if ($bitLong) { $strReturn = uniStrtolower(class_carrier::getInstance()->getObjLang()->getLang("dateStyleLong", "system")); } else { $strReturn = uniStrtolower(class_carrier::getInstance()->getObjLang()->getLang("dateStyleShort", "system")); } } else { $strReturn = $strFormat; } //"d.m.Y H:i:s"; $strReturn = uniStrReplace("d", $objDate->getIntDay(), $strReturn); $strReturn = uniStrReplace("m", $objDate->getIntMonth(), $strReturn); $strReturn = uniStrReplace("y", $objDate->getIntYear(), $strReturn); $strReturn = uniStrReplace("h", $objDate->getIntHour(), $strReturn); $strReturn = uniStrReplace("i", $objDate->getIntMin(), $strReturn); $strReturn = uniStrReplace("s", $objDate->getIntSec(), $strReturn); } return $strReturn; }
/** * Calculates the first day of the given period depending on the given date. * * For period Weeks: Last day of a week is always sunday * * @param class_date_period_enum $objPeriod * @param class_date $objDate * * @return class_date */ public function lastDayOfThis(class_date_period_enum $objPeriod, class_date $objDate) { $strRelativeString = ""; if ($objPeriod->equals(class_date_period_enum::YEAR())) { $strRelativeString = "last day of december"; } else { if ($objPeriod->equals(class_date_period_enum::HALFYEAR())) { $intMonth = $objDate->getIntMonth(); if ($intMonth < 7) { $strRelativeString = "last day of june"; } else { $strRelativeString = "last day of december"; } } else { if ($objPeriod->equals(class_date_period_enum::QUARTER())) { $intMonth = $objDate->getIntMonth(); if ($intMonth < 4) { $strRelativeString = "last day of march"; } elseif ($intMonth > 3 && $intMonth < 7) { $strRelativeString = "last day of june"; } elseif ($intMonth > 6 && $intMonth < 10) { $strRelativeString = "last day of september"; } elseif ($intMonth > 9) { $strRelativeString = "last day of december"; } } else { if ($objPeriod->equals(class_date_period_enum::MONTH())) { $strRelativeString = "last day of this month"; } else { if ($objPeriod->equals(class_date_period_enum::WEEK())) { if ($objDate->getIntDayOfWeek() == 0) { $strRelativeString = "now"; } else { //check if correct? $strRelativeString = "sunday this week"; } } } } } } $objNewDate = self::calcDateRelativeFormatString($objDate, $strRelativeString); $objNewDate->setIntHour($objDate->getIntHour()); $objNewDate->setIntMin($objDate->getIntMin()); $objNewDate->setIntSec($objDate->getIntSec()); return $objNewDate; }
/** * Creates a form to edit a users data * * @return string */ private function editUserData() { $arrErrors = array(); $bitForm = true; //what to do? if ($this->getParam("submitUserForm") != "") { if ($this->getParam("password") != "") { if ($this->getParam("password") != $this->getParam("password2")) { $arrErrors[] = $this->getLang("passwordsUnequal"); } } $objValidator = new class_email_validator(); if (!$objValidator->validate($this->getParam("email"))) { $arrErrors[] = $this->getLang("invalidEmailadress"); } if (count($arrErrors) == 0) { $bitForm = false; } } if ($bitForm) { if ($this->arrElementData["portallogin_editmode"] == 1) { $strTemplateID = $this->objTemplate->readTemplate("/element_portallogin/" . $this->arrElementData["portallogin_template"], "portallogin_userdataform_complete"); } else { $strTemplateID = $this->objTemplate->readTemplate("/element_portallogin/" . $this->arrElementData["portallogin_template"], "portallogin_userdataform_minimal"); } $arrTemplate = array(); $objUser = new class_module_user_user($this->objSession->getUserID()); if ($objUser->getObjSourceUser()->isEditable() && $objUser->getStrSubsystem() == "kajona" && $objUser->getObjSourceUser() instanceof class_usersources_user_kajona) { $arrTemplate["username"] = $objUser->getStrUsername(); $arrTemplate["email"] = $objUser->getObjSourceUser()->getStrEmail(); $arrTemplate["forename"] = $objUser->getObjSourceUser()->getStrForename(); $arrTemplate["name"] = $objUser->getObjSourceUser()->getStrName(); $arrTemplate["street"] = $objUser->getObjSourceUser()->getStrStreet(); $arrTemplate["postal"] = $objUser->getObjSourceUser()->getStrPostal(); $arrTemplate["city"] = $objUser->getObjSourceUser()->getStrCity(); $arrTemplate["phone"] = $objUser->getObjSourceUser()->getStrTel(); $arrTemplate["mobile"] = $objUser->getObjSourceUser()->getStrMobile(); $arrTemplate["portallogin_elsystemid"] = $this->arrElementData["content_id"]; $objDate = new class_date($objUser->getObjSourceUser()->getLongDate()); $arrTemplate["date_day"] = $objDate->getIntDay(); $arrTemplate["date_month"] = $objDate->getIntMonth(); $arrTemplate["date_year"] = $objDate->getIntYear(); $arrTemplate["formaction"] = class_link::getLinkPortalHref($this->getPagename(), "", "portalEditProfile"); $arrTemplate["formErrors"] = ""; if (count($arrErrors) > 0) { foreach ($arrErrors as $strOneError) { $strErrTemplate = $this->objTemplate->readTemplate("/element_portallogin/" . $this->arrElementData["portallogin_template"], "errorRow"); $arrTemplate["formErrors"] .= "" . $this->fillTemplate(array("error" => $strOneError), $strErrTemplate); } } return $this->fillTemplate($arrTemplate, $strTemplateID); } else { return "Login provider not supported."; } } else { $objUser = new class_module_user_user($this->objSession->getUserID()); if ($objUser->getObjSourceUser() instanceof class_usersources_user_kajona) { $objUser->getObjSourceUser()->setStrEmail($this->getParam("email")); $objUser->getObjSourceUser()->setStrForename($this->getParam("forename")); $objUser->getObjSourceUser()->setStrName($this->getParam("name")); $objUser->getObjSourceUser()->setStrPass($this->getParam("password")); if ($this->arrElementData["portallogin_editmode"] == 1) { $objUser->getObjSourceUser()->setStrStreet($this->getParam("street")); $objUser->getObjSourceUser()->setStrPostal($this->getParam("postal")); $objUser->getObjSourceUser()->setStrCity($this->getParam("city")); $objUser->getObjSourceUser()->setStrTel($this->getParam("phone")); $objUser->getObjSourceUser()->setStrMobile($this->getParam("mobile")); $objDate = new class_date(); $objDate->setIntDay($this->getParam("date_day")); $objDate->setIntMonth($this->getParam("date_month")); $objDate->setIntYear($this->getParam("date_year")); $objUser->getObjSourceUser()->setLongDate($objDate->getLongTimestamp()); } $objUser->getObjSourceUser()->updateObjectToDb(); } $this->portalReload(class_link::getLinkPortalHref($this->getPagename())); } return ""; }
echo str_pad("Hits", 15); 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 ";
/** * @return string * @permissions view */ protected function actionRenderCalendar() { $strReturn = ""; $strContent = ""; $arrJsHighlights = array(); $strReturn .= "<content><![CDATA["; /** @var interface_calendarsource_admin[] $arrRelevantModules */ $arrRelevantModules = array(); //fetch modules relevant for processing $arrModules = class_module_system_module::getAllModules(); foreach ($arrModules as $objSingleModule) { if ($objSingleModule->getIntRecordStatus() == 1 && $objSingleModule->getAdminInstanceOfConcreteModule() instanceof interface_calendarsource_admin) { $arrRelevantModules[] = $objSingleModule->getAdminInstanceOfConcreteModule(); } } //the header row $arrWeekdays = explode(",", $this->getLang("calendar_weekday")); foreach ($arrWeekdays as $intKey => $strValue) { $arrWeekdays[$intKey] = trim(uniStrReplace("\"", "", $strValue)); } $strContent .= $this->objToolkit->getCalendarHeaderRow($arrWeekdays); //render the single rows. calculate the first day of the row $objDate = new class_date(); $objDate->setIntDay(1); //set to interval stored in session if ($this->objSession->getSession($this->strStartMonthKey) != "") { $objDate->setIntMonth($this->objSession->getSession($this->strStartMonthKey)); } if ($this->objSession->getSession($this->strStartYearKey) != "") { $objDate->setIntYear($this->objSession->getSession($this->strStartYearKey)); } $intCurMonth = $objDate->getIntMonth(); $intCurYear = $objDate->getIntYear(); $objToday = new class_date(); //start by monday while ($objDate->getIntDayOfWeek() != 1) { $objDate->setPreviousDay(); } $strEntries = ""; $intRowEntryCount = 0; while ($objDate->getIntMonth() <= $intCurMonth && $objDate->getIntYear() <= $intCurYear || $objDate->getIntMonth() == 12 && $objDate->getIntYear() < $intCurYear || $intRowEntryCount % 7 != 0) { $intRowEntryCount++; $strDate = $objDate->getIntDay(); $arrEvents = array(); if ($objDate->getIntMonth() == $intCurMonth) { //Query modules for dates $objStartDate = clone $objDate; $objStartDate->setIntHour(0)->setIntMin(0)->setIntSec(0); $objEndDate = clone $objDate; $objEndDate->setIntHour(23)->setIntMin(59)->setIntSec(59); foreach ($arrRelevantModules as $objOneModule) { $arrEvents = array_merge($objOneModule->getArrCalendarEntries($objStartDate, $objEndDate), $arrEvents); } } while (count($arrEvents) <= 3) { $objDummy = new class_calendarentry(); $objDummy->setStrClass("spacer"); $objDummy->setStrName(" "); $arrEvents[] = $objDummy; } $strEvents = ""; /** @var class_calendarentry $objOneEvent */ foreach ($arrEvents as $objOneEvent) { $strName = $objOneEvent->getStrName(); $strSecondLine = $objOneEvent->getStrSecondLine(); if ($strSecondLine != "") { $strSecondLine = "<br />" . $strSecondLine; } //register mouse-over highlight relations if ($objOneEvent->getStrHighlightId() != "" && $objOneEvent->getStrSystemid() != "") { if (!isset($arrJsHighlights[$objOneEvent->getStrHighlightId()])) { $arrJsHighlights[$objOneEvent->getStrHighlightId()] = array(); } $arrJsHighlights[$objOneEvent->getStrHighlightId()][] = $objOneEvent->getStrSystemid(); } $strEvents .= $this->objToolkit->getCalendarEvent($strName . $strSecondLine, $objOneEvent->getStrSystemid(), $objOneEvent->getStrHighlightId(), $objOneEvent->getStrClass()); } $bitBlocked = false; if ($objDate->getIntDayOfWeek() == 0 || $objDate->getIntDayOfWeek() == 6) { $bitBlocked = true; } $strToday = ""; if ($objToday->getIntYear() == $objDate->getIntYear() && $objToday->getIntMonth() == $objDate->getIntMonth() && $objToday->getIntDay() == $objDate->getIntDay()) { $strToday = " calendarDateToday"; } if ($objDate->getIntMonth() != $intCurMonth) { $strEntries .= $this->objToolkit->getCalendarEntry($strEvents, $strDate, "calendarEntryOutOfRange" . $strToday); } else { if ($bitBlocked) { $strEntries .= $this->objToolkit->getCalendarEntry($strEvents, $strDate, "calendarEntryBlocked" . $strToday); } else { $strEntries .= $this->objToolkit->getCalendarEntry($strEvents, $strDate, "calendarEntry" . $strToday); } } if ($intRowEntryCount % 7 == 0) { $strContent .= $this->objToolkit->getCalendarRow($strEntries); $strEntries = ""; } $objDate->setNextDay(); } if ($strEntries != "") { $strContent .= $this->objToolkit->getCalendarRow($strEntries); } $strReturn .= $this->objToolkit->getCalendarWrapper($strContent); //build js-arrays $strJs = "<script type=\"text/javascript\">"; foreach ($arrJsHighlights as $strCommonId => $arrEntries) { $strJs .= " var kj_cal_" . $strCommonId . " = new Array();"; foreach ($arrEntries as $strOneIdentifier) { $strJs .= "kj_cal_" . $strCommonId . ".push('" . $strOneIdentifier . "');"; } } $strJs .= "</script>"; $strReturn .= $strJs; $strReturn .= "]]></content>"; return $strReturn; }