/** * @param $strSearchterm * @param class_search_result[] $arrResults * * @return string */ private function createSearchXML($strSearchterm, $arrResults) { $strReturn = ""; $strReturn .= "<search>\n" . " <searchterm>" . xmlSafeString($strSearchterm) . "</searchterm>\n" . " <nrofresults>" . count($arrResults) . "</nrofresults>\n"; //And now all results $intI = 0; $strReturn .= " <resultset>\n"; foreach ($arrResults as $objOneResult) { $objPage = class_module_pages_page::getPageByName($objOneResult->getStrPagename()); if ($objPage === null || !$objPage->rightView() || $objPage->getIntRecordStatus() != 1) { continue; } if (++$intI > self::$INT_MAX_NR_OF_RESULTS) { break; } //create a correct link if ($objOneResult->getStrPagelink() == "") { $objOneResult->setStrPagelink(getLinkPortal($objOneResult->getStrPagename(), "", "_self", $objOneResult->getStrPagename(), "", "&highlight=" . $strSearchterm . "#" . $strSearchterm)); } $strReturn .= " <item>\n" . " <pagename>" . $objOneResult->getStrPagename() . "</pagename>\n" . " <pagelink>" . $objOneResult->getStrPagelink() . "</pagelink>\n" . " <score>" . $objOneResult->getIntHits() . "</score>\n" . " <description>" . xmlSafeString(uniStrTrim($objOneResult->getStrDescription(), 200)) . "</description>\n" . " </item>\n"; } $strReturn .= " </resultset>\n"; $strReturn .= "</search>"; return $strReturn; }
/** * Renders the complete rss-feed. * * @return string */ public function generateFeed() { $strReturn = "<rss version=\"2.0\">\n" . " <channel>\n"; $strReturn .= " <title>" . xmlSafeString($this->strTitle) . "</title>\n" . " <link>" . xmlSafeString($this->strLink) . "</link>\n" . " <description>" . xmlSafeString($this->strDesc) . "</description>\n" . " <generator>" . xmlSafeString($this->strGenerator) . "</generator>\n"; $strReturn .= $this->strEntries; $strReturn .= " </channel>\n" . "</rss>"; return $strReturn; }
/** * Renderes the content of a single widget. * * @return string * @permissions view */ protected function actionGetWidgetContent() { //load the aspect and close the session afterwards class_module_system_aspect::getCurrentAspect(); $objWidgetModel = new class_module_dashboard_widget($this->getSystemid()); if ($objWidgetModel->rightView()) { $objConcreteWidget = $objWidgetModel->getConcreteAdminwidget(); if (!$objConcreteWidget->getBitBlockSessionClose()) { class_carrier::getInstance()->getObjSession()->sessionClose(); } //disable the internal changelog class_module_system_changelog::$bitChangelogEnabled = false; class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_JSON); $strReturn = json_encode($objConcreteWidget->generateWidgetOutput()); } else { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_UNAUTHORIZED); $strReturn = "<message><error>" . xmlSafeString($this->getLang("commons_error_permissions")) . "</error></message>"; } return $strReturn; }
/** * @param string $strSearchterm * @param class_search_result[] $arrResults * * @return string */ private function createSearchXML($strSearchterm, $arrResults) { $strReturn = ""; $strReturn .= "<search>\n" . " <searchterm>" . xmlSafeString($strSearchterm) . "</searchterm>\n" . " <nrofresults>" . count($arrResults) . "</nrofresults>\n"; //And now all results $strReturn .= " <resultset>\n"; foreach ($arrResults as $objOneResult) { //create a correct link if ($objOneResult->getObjObject() == null || !$objOneResult->getObjObject()->rightView()) { continue; } $strIcon = ""; if ($objOneResult->getObjObject() instanceof interface_admin_listable) { $strIcon = $objOneResult->getObjObject()->getStrIcon(); if (is_array($strIcon)) { $strIcon = $strIcon[0]; } } $strLink = $objOneResult->getStrPagelink(); if ($strLink == "") { $strLink = class_link::getLinkAdminHref($objOneResult->getObjObject()->getArrModule("modul"), "edit", "&systemid=" . $objOneResult->getStrSystemid()); } $strReturn .= " <item>\n" . " <systemid>" . $objOneResult->getStrSystemid() . "</systemid>\n" . " <icon>" . xmlSafeString($strIcon) . "</icon>\n" . " <score>" . $objOneResult->getIntHits() . "</score>\n" . " <description>" . xmlSafeString(uniStrTrim($objOneResult->getObjObject()->getStrDisplayName(), 200)) . "</description>\n" . " <link>" . xmlSafeString($strLink) . "</link>\n" . " </item>\n"; } $strReturn .= " </resultset>\n"; $strReturn .= "</search>"; return $strReturn; }
/** * Tries to save the passed cropping. * The following params are needed: * action = saveCropping * folder = the files' location * file = the file to crop * systemid = the repo-id * intX * intY * intWidth * intHeight * @return string * @permissions edit */ protected function actionSaveCropping() { $strReturn = ""; $strFile = $this->getParam("file"); $objImage = new class_image2(); $objImage->setUseCache(false); $objImage->load($strFile); $objImage->addOperation(new class_image_crop($this->getParam("intX"), $this->getParam("intY"), $this->getParam("intWidth"), $this->getParam("intHeight"))); if ($objImage->save($strFile)) { class_logger::getInstance()->addLogRow("cropped file " . $strFile, class_logger::$levelInfo); $strReturn .= "<message>" . xmlSafeString($this->getLang("xml_cropping_success")) . "</message>"; } else { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_UNAUTHORIZED); $strReturn .= "<message><error>" . xmlSafeString($this->getLang("commons_error_permissions")) . "</error></message>"; } return $strReturn; }
/** * Creates a table filled with the sessions currently registered. * Returned structure: * <sessions> * <session> * <username></username> * <loginstatus></loginstatus> * <releasetime></releasetime> * <activity></activity> * </session> * </sessions> * * @return string * @permissions right1 */ protected function actionSystemSessions() { $strReturn = ""; //check needed rights $arrSessions = class_module_system_session::getAllActiveSessions(); $strReturn .= "<sessions>"; foreach ($arrSessions as $objOneSession) { $strReturn .= "<session>"; $strUsername = ""; if ($objOneSession->getStrUserid() != "") { $objUser = new class_module_user_user($objOneSession->getStrUserid()); $strUsername = $objUser->getStrUsername(); } $strLoginStatus = ""; if ($objOneSession->getStrLoginstatus() == class_module_system_session::$LOGINSTATUS_LOGGEDIN) { $strLoginStatus = $this->getLang("session_loggedin"); } else { $strLoginStatus = $this->getLang("session_loggedout"); } //find out what the user is doing... $strLastUrl = $objOneSession->getStrLasturl(); if (uniStrpos($strLastUrl, "?") !== false) { $strLastUrl = uniSubstr($strLastUrl, uniStrpos($strLastUrl, "?")); } $strActivity = ""; if (uniStrpos($strLastUrl, "admin=1") !== false) { $strActivity .= $this->getLang("session_admin"); foreach (explode("&", $strLastUrl) as $strOneParam) { $arrUrlParam = explode("=", $strOneParam); if ($arrUrlParam[0] == "module") { $strActivity .= $arrUrlParam[1]; } } } else { $strActivity .= $this->getLang("session_portal"); if ($strLastUrl == "") { $strActivity .= class_module_system_setting::getConfigValue("_pages_indexpage_"); } else { foreach (explode("&", $strLastUrl) as $strOneParam) { $arrUrlParam = explode("=", $strOneParam); if ($arrUrlParam[0] == "page") { $strActivity .= $arrUrlParam[1]; } } if ($strActivity == $this->getLang("session_portal") && uniSubstr($strLastUrl, 0, 5) == "image") { $strActivity .= $this->getLang("session_portal_imagegeneration"); } } } $strReturn .= "<username>" . xmlSafeString($strUsername) . "</username>"; $strReturn .= "<loginstatus>" . xmlSafeString($strLoginStatus) . "</loginstatus>"; $strReturn .= "<releasetime>" . xmlSafeString(timeToString($objOneSession->getIntReleasetime())) . "</releasetime>"; $strReturn .= "<activity>" . xmlSafeString($strActivity) . "</activity>"; $strReturn .= "</session>"; } $strReturn .= "</sessions>"; return $strReturn; }
/** * Ends the session of the current user * * @return string */ protected function actionLogout() { $this->objSession->logout(); return "<message><success>" . xmlSafeString($this->getLang("logout_xml", "system")) . "</success></message>"; }
/** * Used to handle the current exception. * Decides, if the execution should be stopped, or continued. * Therefore the errorlevel defines the "weight" of the exception * * @return void */ public function processException() { //set which POST parameters should read out $arrPostParams = array("module", "action", "page", "systemid"); $objHistory = new class_history(); //send an email to the admin? $strAdminMail = ""; try { if (class_db::getInstance()->getBitConnected()) { $strAdminMail = class_module_system_setting::getConfigValue("_system_admin_email_"); } } catch (Exception $objEx) { } if ($strAdminMail != "") { $strMailtext = ""; $strMailtext .= "The system installed at " . _webpath_ . " registered an error!\n\n"; $strMailtext .= "The error message was:\n"; $strMailtext .= "\t" . $this->getMessage() . "\n\n"; $strMailtext .= "The level of this error was:\n"; $strMailtext .= "\t"; if ($this->getErrorlevel() == self::$level_FATALERROR) { $strMailtext .= "FATAL ERROR"; } if ($this->getErrorlevel() == self::$level_ERROR) { $strMailtext .= "REGULAR ERROR"; } $strMailtext .= "\n\n"; $strMailtext .= "File and line number the error was thrown:\n"; $strMailtext .= "\t" . basename($this->getFile()) . " in line " . $this->getLine() . "\n\n"; $strMailtext .= "Callstack / Backtrace:\n\n"; $strMailtext .= $this->getTraceAsString(); $strMailtext .= "\n\n"; $strMailtext .= "User: "******" (" . class_carrier::getInstance()->getObjSession()->getUsername() . ")\n"; $strMailtext .= "Source host: " . getServer("REMOTE_ADDR") . " (" . @gethostbyaddr(getServer("REMOTE_ADDR")) . ")\n"; $strMailtext .= "Query string: " . getServer("REQUEST_URI") . "\n"; $strMailtext .= "POST data (selective):\n"; foreach ($arrPostParams as $strParam) { if (getPost($strParam) != "") { $strMailtext .= "\t" . $strParam . ": " . getPost($strParam) . "\n"; } } $strMailtext .= "\n\n"; $strMailtext .= "Last actions called:\n"; $strMailtext .= "Admin:\n"; $arrHistory = $objHistory->getArrAdminHistory(); if (is_array($arrHistory)) { foreach ($arrHistory as $intIndex => $strOneUrl) { $strMailtext .= " #" . $intIndex . ": " . $strOneUrl . "\n"; } } $strMailtext .= "Portal:\n"; $arrHistory = $objHistory->getArrPortalHistory(); if (is_array($arrHistory)) { foreach ($arrHistory as $intIndex => $strOneUrl) { $strMailtext .= " #" . $intIndex . ": " . $strOneUrl . "\n"; } } $strMailtext .= "\n\n"; $strMailtext .= "If you don't know what to do, feel free to open a ticket.\n\n"; $strMailtext .= "For more help visit http://www.kajona.de.\n\n"; $objMail = new class_mail(); $objMail->setSubject("Error on website " . _webpath_ . " occured!"); $objMail->setSender($strAdminMail); $objMail->setText($strMailtext); $objMail->addTo($strAdminMail); $objMail->sendMail(); $objMessageHandler = new class_module_messaging_messagehandler(); $objMessage = new class_module_messaging_message(); $objMessage->setStrBody($strMailtext); $objMessage->setObjMessageProvider(new class_messageprovider_exceptions()); $objMessageHandler->sendMessageObject($objMessage, new class_module_user_group(class_module_system_setting::getConfigValue("_admins_group_id_"))); } if ($this->intErrorlevel == class_exception::$level_FATALERROR) { //Handle fatal errors. $strLogMessage = basename($this->getFile()) . ":" . $this->getLine() . " -- " . $this->getMessage(); class_logger::getInstance()->addLogRow($strLogMessage, class_logger::$levelError); //fatal errors are displayed in every case if (_xmlLoader_ === true) { $strErrormessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; $strErrormessage .= "<error>" . xmlSafeString($this->getMessage()) . "</error>"; } else { $strErrormessage = "<html><head></head><body><div style=\"border: 1px solid red; padding: 5px; margin: 20px; font-family: arial,verdana,sans-serif; font-size: 12px; \">\n"; $strErrormessage .= "<div style=\"background-color: #cccccc; color: #000000; font-weight: bold; \">A fatal error occurred:</div>\n"; $strErrormessage .= "<pre>" . htmlspecialchars($this->getMessage(), ENT_QUOTES, "UTF-8", false) . "</pre><br />"; $strErrormessage .= "Please inform the administration about the error above."; $strErrormessage .= "</div></body></html>"; } print $strErrormessage; //Execution has to be stopped here! if (class_response_object::getInstance()->getStrStatusCode() == "" || class_response_object::getInstance()->getStrStatusCode() == class_http_statuscodes::SC_OK) { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_INTERNAL_SERVER_ERROR); } class_response_object::getInstance()->sendHeaders(); die; } elseif ($this->intErrorlevel == class_exception::$level_ERROR) { //handle regular errors $strLogMessage = basename($this->getFile()) . ":" . $this->getLine() . " -- " . $this->getMessage(); class_logger::getInstance()->addLogRow($strLogMessage, class_logger::$levelWarning); //check, if regular errors should be displayed: if ($this->intDebuglevel >= 1) { if (_xmlLoader_ === true) { $strErrormessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; $strErrormessage .= "<error>" . xmlSafeString($this->getMessage()) . "</error>"; } else { $strErrormessage = "<html><head></head><body><div style=\"border: 1px solid red; padding: 5px; margin: 20px; font-family: arial,verdana,sans-serif; font-size: 12px; \">\n"; $strErrormessage .= "<div style=\"background-color: #cccccc; color: #000000; font-weight: bold; \">An error occurred:</div>\n"; $strErrormessage .= "<pre>" . htmlspecialchars($this->getMessage(), ENT_QUOTES, "UTF-8", false) . "</pre><br />"; //$strErrormessage .= basename($this->getFile()) ." in Line ".$this->getLine(); $strErrormessage .= "Please inform the administration about the error above."; $strErrormessage .= "</div></body></html>"; } print $strErrormessage; //if error was displayed, stop execution //die(); } } }
/** * Returns a xml-based representation of a single news. * Return format: * <news> * <title></title> * <systemid></systemid> * <intro></intro> * <text></text> * <image></image> * <categories></categories> * <startdate></startdate> * <enddate></enddate> * <archivedate></archivedate> * </news> * * @return string * @xml */ protected function actionNewsDetails() { $strReturn = ""; $objNews = new class_module_news_news($this->getSystemid()); $arrCats = class_module_news_category::getNewsMember($objNews->getSystemid()); array_walk($arrCats, function (class_module_news_category &$objValue) { $objValue = $objValue->getSystemid(); }); if ($objNews->rightView()) { $strReturn .= " <news>\n"; $strReturn .= " <title>" . xmlSafeString($objNews->getStrTitle()) . "</title>"; $strReturn .= " <systemid>" . $objNews->getSystemid() . "</systemid>"; $strReturn .= " <intro>" . xmlSafeString($objNews->getStrIntro()) . "</intro>"; $strReturn .= " <text>" . xmlSafeString($objNews->getStrText()) . "</text>"; $strReturn .= " <image>" . xmlSafeString($objNews->getStrImage()) . "</image>"; $strReturn .= " <categories>" . xmlSafeString(implode(",", $arrCats)) . "</categories>"; $strReturn .= " <startdate>" . xmlSafeString($objNews->getObjStartDate() != null ? $objNews->getObjStartDate()->getTimeInOldStyle() : "") . "</startdate>"; $strReturn .= " <enddate>" . xmlSafeString($objNews->getObjEndDate() != null ? $objNews->getObjEndDate()->getTimeInOldStyle() : "") . "</enddate>"; $strReturn .= " <archivedate>" . xmlSafeString($objNews->getObjDateSpecial() != null ? $objNews->getObjDateSpecial()->getTimeInOldStyle() : "") . "</archivedate>"; $strReturn .= " </news>\n"; } else { $strReturn = "<error>" . $this->getLang("commons_error_permissions") . "</error>"; } return $strReturn; }