Example #1
0
 private function writeToHistoryArray($strSessionKey)
 {
     $strQueryString = getServer("QUERY_STRING");
     //Clean querystring of empty actions
     if (uniSubstr($strQueryString, -8) == "&action=") {
         $strQueryString = substr_replace($strQueryString, "", -8);
     }
     //Just do s.th., if not in the rights-mgmt
     if (uniStrpos($strQueryString, "module=right") !== false) {
         return;
     }
     $arrHistory = $this->objSession->getSession($strSessionKey);
     //And insert just, if different to last entry
     if ($strQueryString == $this->getHistoryEntry(0, $strSessionKey)) {
         return;
     }
     //If we reach up here, we can enter the current query
     if ($arrHistory !== false) {
         array_unshift($arrHistory, $strQueryString);
         while (count($arrHistory) > 10) {
             array_pop($arrHistory);
         }
     } else {
         $arrHistory = array($strQueryString);
     }
     //saving the new array to session
     $this->objSession->setSession($strSessionKey, $arrHistory);
 }
 /**
  * Invokes the installer, if given.
  * The installer itself is capable of detecting whether an update or a plain installation is required.
  *
  * @throws class_exception
  * @return string
  */
 public function installOrUpdate()
 {
     $strReturn = "";
     if (uniStrpos($this->getObjMetadata()->getStrPath(), "core") === false) {
         throw new class_exception("Current module not located at /core*.", class_exception::$level_ERROR);
     }
     if (!$this->isInstallable()) {
         throw new class_exception("Current module isn't installable, not all requirements are given", class_exception::$level_ERROR);
     }
     //search for an existing installer
     $objFilesystem = new class_filesystem();
     $arrInstaller = $objFilesystem->getFilelist($this->objMetadata->getStrPath() . "/installer/", array(".php"));
     if ($arrInstaller === false) {
         $strReturn .= "Updating default template pack...\n";
         $this->updateDefaultTemplate();
         class_cache::flushCache();
         return $strReturn;
     }
     //proceed with elements
     foreach ($arrInstaller as $strOneInstaller) {
         //skip samplecontent files
         if (uniStrpos($strOneInstaller, "element") !== false) {
             class_logger::getInstance(class_logger::PACKAGEMANAGEMENT)->addLogRow("triggering updateOrInstall() on installer " . $strOneInstaller . ", all requirements given", class_logger::$levelInfo);
             //trigger update or install
             $strName = uniSubstr($strOneInstaller, 0, -4);
             /** @var $objInstaller interface_installer */
             $objInstaller = new $strName();
             $strReturn .= $objInstaller->installOrUpdate();
         }
     }
     $strReturn .= "Updating default template pack...\n";
     $this->updateDefaultTemplate();
     return $strReturn;
 }
 /**
  * This method returns all plugins registered for the current extension point searching at the predefined path.
  * By default, new instances of the classes are returned. If the implementing
  * class requires specific constructor arguments, pass them as the second argument and they will be
  * used during instantiation.
  *
  * @param array $arrConstructorArguments
  *
  * @static
  * @return interface_generic_plugin[]
  */
 public function getPlugins($arrConstructorArguments = array())
 {
     //load classes in passed-folders
     $strKey = md5($this->strSearchPath . $this->strPluginPoint);
     if (!array_key_exists($strKey, self::$arrPluginClasses)) {
         $strPluginPoint = $this->strPluginPoint;
         $arrClasses = class_resourceloader::getInstance()->getFolderContent($this->strSearchPath, array(".php"), false, function ($strOneFile) use($strPluginPoint) {
             $strOneFile = uniSubstr($strOneFile, 0, -4);
             if (uniStripos($strOneFile, "class_") === false || uniStrpos($strOneFile, "class_testbase") !== false) {
                 return false;
             }
             $objReflection = new ReflectionClass($strOneFile);
             if (!$objReflection->isAbstract() && $objReflection->implementsInterface("interface_generic_plugin")) {
                 $objMethod = $objReflection->getMethod("getExtensionName");
                 if ($objMethod->invoke(null) == $strPluginPoint) {
                     return true;
                 }
             }
             return false;
         }, function (&$strOneFile) {
             $strOneFile = uniSubstr($strOneFile, 0, -4);
         });
         self::$arrPluginClasses[$strKey] = $arrClasses;
     }
     $arrReturn = array();
     foreach (self::$arrPluginClasses[$strKey] as $strOneClass) {
         $objReflection = new ReflectionClass($strOneClass);
         if (count($arrConstructorArguments) > 0) {
             $arrReturn[] = $objReflection->newInstanceArgs($arrConstructorArguments);
         } else {
             $arrReturn[] = $objReflection->newInstance();
         }
     }
     return $arrReturn;
 }
Example #4
0
 /**
  * Sends the requested file to the browser
  * @return string
  */
 public function actionDownload()
 {
     //Load filedetails
     if (validateSystemid($this->getSystemid())) {
         /** @var $objFile class_module_mediamanager_file */
         $objFile = class_objectfactory::getInstance()->getObject($this->getSystemid());
         //Succeeded?
         if ($objFile instanceof class_module_mediamanager_file && $objFile->getIntRecordStatus() == "1" && $objFile->getIntType() == class_module_mediamanager_file::$INT_TYPE_FILE) {
             //Check rights
             if ($objFile->rightRight2()) {
                 //Log the download
                 class_module_mediamanager_logbook::generateDlLog($objFile);
                 //Send the data to the browser
                 $strBrowser = getServer("HTTP_USER_AGENT");
                 //Check the current browsertype
                 if (uniStrpos($strBrowser, "IE") !== false) {
                     //Internet Explorer
                     class_response_object::getInstance()->addHeader("Content-type: application/x-ms-download");
                     class_response_object::getInstance()->addHeader("Content-type: x-type/subtype\n");
                     class_response_object::getInstance()->addHeader("Content-type: application/force-download");
                     class_response_object::getInstance()->addHeader("Content-Disposition: attachment; filename=" . preg_replace('/\\./', '%2e', saveUrlEncode(trim(basename($objFile->getStrFilename()))), substr_count(basename($objFile->getStrFilename()), '.') - 1));
                 } else {
                     //Good: another browser vendor
                     class_response_object::getInstance()->addHeader("Content-Type: application/octet-stream");
                     class_response_object::getInstance()->addHeader("Content-Disposition: attachment; filename=" . saveUrlEncode(trim(basename($objFile->getStrFilename()))));
                 }
                 //Common headers
                 class_response_object::getInstance()->addHeader("Expires: Mon, 01 Jan 1995 00:00:00 GMT");
                 class_response_object::getInstance()->addHeader("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
                 class_response_object::getInstance()->addHeader("Pragma: no-cache");
                 class_response_object::getInstance()->addHeader("Content-description: JustThum-Generated Data\n");
                 class_response_object::getInstance()->addHeader("Content-Length: " . filesize(_realpath_ . $objFile->getStrFilename()));
                 //End Session
                 $this->objSession->sessionClose();
                 class_response_object::getInstance()->sendHeaders();
                 //Loop the file
                 $ptrFile = @fopen(_realpath_ . $objFile->getStrFilename(), 'rb');
                 fpassthru($ptrFile);
                 @fclose($ptrFile);
                 ob_flush();
                 flush();
                 return "";
             } else {
                 class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_FORBIDDEN);
             }
         } else {
             class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_NOT_FOUND);
         }
     } else {
         class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_NOT_FOUND);
     }
     //if we reach up here, something gone wrong :/
     class_response_object::getInstance()->setStrRedirectUrl(str_replace(array("_indexpath_", "&"), array(_indexpath_, "&"), class_link::getLinkPortalHref(class_module_system_setting::getConfigValue("_pages_errorpage_"))));
     class_response_object::getInstance()->sendHeaders();
     class_response_object::getInstance()->sendContent();
     return "";
 }
 /**
  * @return interface_messageprovider[]
  */
 public function getMessageproviders()
 {
     return class_resourceloader::getInstance()->getFolderContent("/system/messageproviders", array(".php"), false, function ($strOneFile) {
         if (uniStrpos($strOneFile, "interface") !== false) {
             return false;
         }
         return true;
     }, function (&$strOneFile) {
         $strOneFile = uniSubstr($strOneFile, 0, -4);
         $strOneFile = new $strOneFile();
     });
 }
Example #6
0
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;
    foreach (class_carrier::getInstance()->getObjDB()->getPArray($strQuery, array()) as $arrOneRow) {
        if (uniStrpos($arrOneRow["log_hostname"], "localhost/") === false && uniStrpos($arrOneRow["log_hostname"], "kajona.de") === false && uniStrpos($arrOneRow["log_hostname"], "kajonabase") === false && uniStrpos($arrOneRow["log_hostname"], "aquarium") === false && uniStrpos($arrOneRow["log_hostname"], "stb400s") === false && $arrOneRow["log_hostname"] != "") {
            echo sprintf("%4d", $arrOneRow["ANZ"]) . " => " . $arrOneRow["log_hostname"] . "<br />";
            $intI++;
        }
    }
    echo "Total: " . $intI . " systems<br />";
}
 /**
  * Queries the local filesystem in order to find all packages available.
  * This may include packages of all providers.
  * Optionally you may reduce the list of packages using a simple filter-string
  *
  * @param string $strFilterText
  *
  * @return class_module_packagemanager_metadata[]
  */
 public function getAvailablePackages($strFilterText = "")
 {
     $arrReturn = array();
     $objModuleProvider = new class_module_packagemanager_packagemanager_module();
     $arrReturn = array_merge($arrReturn, $objModuleProvider->getInstalledPackages());
     $objPackageProvider = new class_module_packagemanager_packagemanager_template();
     $arrReturn = array_merge($objPackageProvider->getInstalledPackages(), $arrReturn);
     if ($strFilterText != "") {
         $arrReturn = array_filter($arrReturn, function ($objOneMetadata) use($strFilterText) {
             return uniStrpos($objOneMetadata->getStrTitle(), $strFilterText) !== false;
         });
     }
     return $arrReturn;
 }
Example #8
0
/**
 * Helper to load and scan all module-ids available. Triggered by the bootloader.
 * Change with care
 *
 * @return void
 */
function bootstrapIncludeModuleIds()
{
    //Module-Constants
    foreach (scandir(_realpath_) as $strRootFolder) {
        if (uniStrpos($strRootFolder, "core") === false) {
            continue;
        }
        foreach (scandir(_realpath_ . "/" . $strRootFolder) as $strDirEntry) {
            if (is_dir(_realpath_ . "/" . $strRootFolder . "/" . $strDirEntry) && is_dir(_realpath_ . "/" . $strRootFolder . "/" . $strDirEntry . "/system/") && is_dir(_realpath_ . "/" . $strRootFolder . "/" . $strDirEntry . "/system/config/")) {
                foreach (scandir(_realpath_ . "/" . $strRootFolder . "/" . $strDirEntry . "/system/config/") as $strModuleEntry) {
                    if (preg_match("/module\\_([a-z0-9\\_])+\\_id\\.php/", $strModuleEntry)) {
                        @(include_once _realpath_ . "/" . $strRootFolder . "/" . $strDirEntry . "/system/config/" . $strModuleEntry);
                    }
                }
            }
        }
    }
}
Example #9
0
 public function testZipFileread()
 {
     $objFileSystem = new class_filesystem();
     echo "\ttesting class_zip file-reading...\n";
     $objZip = new class_zip();
     echo "\topening " . _realpath_ . "/test.zip\n";
     $this->assertTrue($objZip->openArchiveForWriting("/files/cache/test.zip"), __FILE__ . " openArchive");
     $this->assertTrue($objZip->addFile(class_resourceloader::getInstance()->getCorePathForModule("module_system") . "/module_system/metadata.xml"), __FILE__ . " addFile");
     $this->assertTrue($objZip->closeArchive(), __FILE__ . " closeArchive");
     $this->assertFileExists(_realpath_ . "/files/cache/test.zip", __FILE__ . " checkFileExists");
     echo "\treading files\n";
     $strContent = $objZip->getFileFromArchive("/files/cache/test.zip", class_resourceloader::getInstance()->getCorePathForModule("module_system") . "/module_system/metadata.xml");
     $this->assertTrue(uniStrpos($strContent, "xsi:noNamespaceSchemaLocation=\"https://apidocs.kajona.de/xsd/package.xsd\"") !== false);
     echo "\tremoving testfile\n";
     $this->assertTrue($objFileSystem->fileDelete("/files/cache/test.zip"), __FILE__ . " deleteFile");
     $this->assertFileNotExists(_realpath_ . "/files/cache/test.zip", __FILE__ . " checkFileNotExists");
     $objFileSystem->folderDeleteRecursive("/files/cache/zipextract");
     $this->assertFileNotExists(_realpath_ . "/files/cache/zipextract", __FILE__ . " checkFileNotExists");
 }
 /**
  * @see interface_admin_systemtask::getAdminForm()
  * @return string
  */
 public function getAdminForm()
 {
     $strReturn = "";
     //show dropdown to select db-dump
     $objFilesystem = new class_filesystem();
     $arrFiles = $objFilesystem->getFilelist(_projectpath_ . "/dbdumps/", array(".sql", ".gz"));
     $arrOptions = array();
     foreach ($arrFiles as $strOneFile) {
         $arrDetails = $objFilesystem->getFileDetails(_projectpath_ . "/dbdumps/" . $strOneFile);
         $strTimestamp = "";
         if (uniStrpos($strOneFile, "_") !== false) {
             $strTimestamp = uniSubstr($strOneFile, uniStrrpos($strOneFile, "_") + 1, uniStrpos($strOneFile, ".") - uniStrrpos($strOneFile, "_"));
         }
         if (uniStrlen($strTimestamp) > 9 && is_numeric($strTimestamp)) {
             $arrOptions[$strOneFile] = $strOneFile . " (" . bytesToString($arrDetails["filesize"]) . ")" . "<br />" . $this->getLang("systemtask_dbimport_datefilename") . " " . timeToString($strTimestamp) . "<br />" . $this->getLang("systemtask_dbimport_datefileinfo") . " " . timeToString($arrDetails['filechange']);
         } else {
             $arrOptions[$strOneFile] = $strOneFile . " (" . bytesToString($arrDetails["filesize"]) . ")" . "<br />" . $this->getLang("systemtask_dbimport_datefileinfo") . " " . timeToString($arrDetails['filechange']);
         }
     }
     $strReturn .= $this->objToolkit->formInputRadiogroup("dbImportFile", $arrOptions, $this->getLang("systemtask_dbimport_file"));
     return $strReturn;
 }
 /**
  * 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 ($this->getFieldValue("location") == "") {
         return "Please set up a location";
     }
     if (uniStrpos($this->getFieldValue("location"), "GM") !== false) {
         return "This widget changed, please update your location by editing the widget";
     }
     //request the xml...
     try {
         $strFormat = "metric";
         if ($this->getFieldValue("unit") == "f") {
             $strFormat = "imperial";
         }
         $objRemoteloader = new class_remoteloader();
         $objRemoteloader->setStrHost("api.openweathermap.org");
         $objRemoteloader->setStrQueryParams("/data/2.5/forecast/daily?APPID=4bdceecc2927e65c5fb712d1222c5293&q=" . $this->getFieldValue("location") . "&units=" . $strFormat . "&cnt=4");
         $strContent = $objRemoteloader->getRemoteContent();
     } catch (class_exception $objExeption) {
         $strContent = "";
     }
     if ($strContent != "" && json_decode($strContent, true) !== null) {
         $arrResponse = json_decode($strContent, true);
         $strReturn .= $this->widgetText($this->getLang("weather_location_string") . $arrResponse["city"]["name"] . ", " . $arrResponse["city"]["country"]);
         foreach ($arrResponse["list"] as $arrOneForecast) {
             $objDate = new class_date($arrOneForecast["dt"]);
             $strReturn .= "<div>";
             $strReturn .= $this->widgetText("<div style='float: left;'>" . dateToString($objDate, false) . ": " . round($arrOneForecast["temp"]["day"], 1) . "°</div>");
             $strReturn .= $this->widgetText("<img src='http://openweathermap.org/img/w/" . $arrOneForecast["weather"][0]["icon"] . ".png' style='float: right;' />");
             $strReturn .= "</div><div style='clear: both;'></div>";
         }
     } else {
         $strReturn .= $this->getLang("weather_errorloading");
     }
     return $strReturn;
 }
 public function setStrPath($strPath)
 {
     if (uniStrpos(uniSubstr($strPath, 0, 7), "files") === false) {
         $strPath = "/files" . $strPath;
     }
     $this->strPath = $strPath;
 }
Example #13
0
 /**
  * Creates a raw Link for the portal (just the href)
  *
  * @param string $strPageI
  * @param string $strPageE
  * @param string $strAction
  * @param string $strParams
  * @param string $strSystemid
  * @param string $strLanguage
  * @param string $strSeoAddon Only used if using mod_rewrite
  * @return string
  */
 public static function getLinkPortalHref($strPageI, $strPageE = "", $strAction = "", $strParams = "", $strSystemid = "", $strLanguage = "", $strSeoAddon = "")
 {
     $strReturn = "";
     $bitInternal = true;
     //return "#" if neither an internal nor an external page is set
     if ($strPageI == "" && $strPageE == "") {
         return "#";
     }
     //Internal links are more important than external links!
     if ($strPageI == "" && $strPageE != "") {
         $bitInternal = false;
     }
     //create an array out of the params
     if ($strSystemid != "") {
         $strParams .= "&systemid=" . $strSystemid;
         $strSystemid = "";
     }
     $arrParams = self::parseParamsString($strParams, $strSystemid);
     // any anchors set to the page?
     $strAnchor = "";
     if (uniStrpos($strPageI, "#") !== false) {
         //get anchor, remove anchor from link
         $strAnchor = urlencode(uniSubstr($strPageI, uniStrpos($strPageI, "#") + 1));
         $strPageI = uniSubstr($strPageI, 0, uniStrpos($strPageI, "#"));
     }
     //urlencoding
     $strPageI = urlencode($strPageI);
     $strAction = urlencode($strAction);
     //more than one language installed?
     if ($strLanguage == "" && self::getIntNumberOfPortalLanguages() > 1) {
         $strLanguage = self::getStrPortalLanguage();
     } else {
         if ($strLanguage != "" && self::getIntNumberOfPortalLanguages() <= 1) {
             $strLanguage = "";
         }
     }
     $strHref = "";
     if ($bitInternal) {
         //check, if we could use mod_rewrite
         $bitRegularLink = true;
         if (class_module_system_setting::getConfigValue("_system_mod_rewrite_") == "true") {
             $strAddKeys = "";
             //used later to add seo-relevant keywords
             $objPage = class_module_pages_page::getPageByName($strPageI);
             if ($objPage !== null) {
                 if ($strLanguage != "") {
                     $objPage->setStrLanguage($strLanguage);
                     $objPage->initObject();
                 }
                 $strAddKeys = $objPage->getStrSeostring() . ($strSeoAddon != "" && $objPage->getStrSeostring() != "" ? "-" : "") . urlSafeString($strSeoAddon);
                 if (uniStrlen($strAddKeys) > 0 && uniStrlen($strAddKeys) <= 2) {
                     $strAddKeys .= "__";
                 }
                 //trim string
                 $strAddKeys = uniStrTrim($strAddKeys, 100, "");
                 if ($strLanguage != "") {
                     $strHref .= $strLanguage . "/";
                 }
                 $strPath = $objPage->getStrPath();
                 if ($strPath == "") {
                     $objPage->updatePath();
                     $strPath = $objPage->getStrPath();
                     $objPage->updateObjectToDb();
                 }
                 if ($strPath != "") {
                     $strHref .= $strPath . "/";
                 }
             }
             //ok, here we go. schema for rewrite_links: pagename.addKeywords.action.systemid.language.html
             //but: special case: just pagename & language
             if ($strAction == "" && $strSystemid == "" && $strAddKeys == "") {
                 $strHref .= $strPageI . ".html";
             } elseif ($strAction == "" && $strSystemid == "") {
                 $strHref .= $strPageI . ($strAddKeys == "" ? "" : "." . $strAddKeys) . ".html";
             } elseif ($strAction != "" && $strSystemid == "") {
                 $strHref .= $strPageI . "." . $strAddKeys . "." . $strAction . ".html";
             } else {
                 $strHref .= $strPageI . "." . $strAddKeys . "." . $strAction . "." . $strSystemid . ".html";
             }
             //params?
             if (count($arrParams) > 0) {
                 $strHref .= "?" . implode("&amp;", $arrParams);
             }
             // add anchor if given
             if ($strAnchor != "") {
                 $strHref .= "#" . $strAnchor;
             }
             //plus the domain as a prefix
             $strHref = "_webpath_" . "/" . $strHref;
             $bitRegularLink = false;
         }
         if ($bitRegularLink) {
             $strHref = "_indexpath_" . "?" . ($strPageI != "" ? "page=" . $strPageI : "") . "" . ($strSystemid != "" ? "&amp;systemid=" . $strSystemid : "") . ($strAction != "" ? "&amp;action=" . $strAction : "") . ($strLanguage != "" ? "&amp;language=" . $strLanguage : "") . (count($arrParams) > 0 ? "&amp;" . implode("&amp;", $arrParams) : "") . ($strAnchor != "" ? "#" . $strAnchor : "") . "";
         }
     } else {
         $strHref = $strPageE;
     }
     $strReturn .= $strHref;
     return $strReturn;
 }
Example #14
0
 public function kajonaTestTrigger()
 {
     //setUp
     $this->setUp();
     //loop test methods
     $objReflection = new ReflectionClass($this);
     $arrMethods = $objReflection->getMethods();
     foreach ($arrMethods as $objOneMethod) {
         if (uniStrpos($objOneMethod->getName(), "test") !== false) {
             echo "calling " . $objOneMethod->getName() . "...\n";
             $objOneMethod->invoke($this);
         }
     }
     //tearDown
     $this->tearDown();
 }
 /**
  * Returns a list of objects implementing the changelog-provider-interface
  * @return interface_changelog_provider[]
  */
 public static function getAdditionalProviders()
 {
     if (self::$arrCachedProviders != null) {
         return self::$arrCachedProviders;
     }
     $arrReturn = class_resourceloader::getInstance()->getFolderContent("/system", array(".php"), false, function ($strOneFile) {
         if (uniStrpos($strOneFile, "class_changelog_provider") === false) {
             return false;
         }
         $objReflection = new ReflectionClass(uniSubstr($strOneFile, 0, -4));
         if ($objReflection->implementsInterface("interface_changelog_provider")) {
             return true;
         }
         return false;
     }, function (&$strOneFile) {
         $objReflection = new ReflectionClass(uniSubstr($strOneFile, 0, -4));
         $strOneFile = $objReflection->newInstance();
     });
     self::$arrCachedProviders = $arrReturn;
     return $arrReturn;
 }
 /**
  * Checks, if the record is already rated by the current user to avoid double-ratings
  *
  * @return bool
  */
 public function isRateableByCurrentUser()
 {
     $bitReturn = true;
     //sql-check - only if user is not a guest
     $arrRow = array();
     $arrRow["COUNT(*)"] = 0;
     if ($this->objSession->getUserID() != "") {
         $strQuery = "SELECT COUNT(*) FROM " . $this->objDB->encloseTableName(_dbprefix_ . "rating_history") . "\n\t    \t               WHERE rating_history_rating = ?\n\t    \t                 AND rating_history_user = ?";
         $arrRow = $this->objDB->getPRow($strQuery, array($this->getSystemid(), $this->objSession->getUserID()));
     }
     if ($arrRow["COUNT(*)"] == 0) {
         //cookie available?
         $objCookie = new class_cookie();
         if ($objCookie->getCookie(class_module_rating_rate::RATING_COOKIE) != "") {
             $strRatingCookie = $objCookie->getCookie(class_module_rating_rate::RATING_COOKIE);
             if (uniStrpos($strRatingCookie, $this->getSystemid()) !== false) {
                 $bitReturn = false;
             }
         }
     } else {
         $bitReturn = false;
     }
     return $bitReturn;
 }
 /**
  * Internal helper, loads all files available including a traversal
  * of the nested folders.
  *
  * @param $strParentId
  * @param int|bool $strCategoryFilter
  * @param int $intStart
  * @param int $intEnd
  * @param bool $strNameFilter
  *
  * @return class_module_mediamanager_file[]
  */
 private function getAllPackages($strParentId, $strCategoryFilter = false, $intStart = null, $intEnd = null, $strNameFilter = false)
 {
     $arrReturn = array();
     if (validateSystemid($strParentId)) {
         $arrSubfiles = class_module_mediamanager_file::loadFilesDB($strParentId, false, true, null, null, true);
         foreach ($arrSubfiles as $objOneFile) {
             if ($objOneFile->getIntType() == class_module_mediamanager_file::$INT_TYPE_FILE) {
                 //filename based check if the file should be included
                 if ($strNameFilter !== false) {
                     if (uniStrpos($strNameFilter, ",") !== false) {
                         if (in_array($objOneFile->getStrName(), explode(",", $strNameFilter))) {
                             $arrReturn[] = $objOneFile;
                         }
                     } else {
                         if (uniSubstr($objOneFile->getStrName(), 0, uniStrlen($strNameFilter)) == $strNameFilter) {
                             $arrReturn[] = $objOneFile;
                         }
                     }
                 } else {
                     $arrReturn[] = $objOneFile;
                 }
             } else {
                 $arrReturn = array_merge($arrReturn, $this->getAllPackages($objOneFile->getSystemid()));
             }
         }
         if ($intStart !== null && $intEnd !== null && $intStart > 0 && $intEnd > $intStart) {
             if ($intEnd > count($arrReturn)) {
                 $intEnd = count($arrReturn);
             }
             $arrTemp = array();
             for ($intI = $intStart; $intI <= $intEnd; $intI++) {
                 $arrTemp[] = $arrReturn[$intI];
             }
             $arrReturn = $arrTemp;
         }
         //sort them by filename
         usort($arrReturn, function (class_module_mediamanager_file $objA, class_module_mediamanager_file $objB) {
             return strcmp($objA->getStrName(), $objB->getStrName());
         });
     } else {
         $arrReturn = class_module_mediamanager_file::getFlatPackageList($strCategoryFilter, true, $intStart, $intEnd, $strNameFilter);
     }
     return $arrReturn;
 }
 /**
  * Creates a form to handle a new post
  *
  * @param array $arrTemplateOld
  *
  * @internal param mixed $arrTemplate values to fill in
  * @return string
  */
 protected function actionInsertGuestbook($arrTemplateOld = array())
 {
     $strReturn = "";
     $strTemplateID = $this->objTemplate->readTemplate("/module_guestbook/" . $this->arrElementData["guestbook_template"], "entry_form");
     $strErrors = "";
     if (count($this->arrErrors) > 0) {
         $strErrorTemplateID = $this->objTemplate->readTemplate("/module_guestbook/" . $this->arrElementData["guestbook_template"], "error_row");
         foreach ($this->arrErrors as $strOneError) {
             $strErrors .= $this->fillTemplate(array("error" => $strOneError), $strErrorTemplateID);
         }
     }
     //update elements
     $arrTemplate = array();
     $arrTemplate["eintragen_fehler"] = $this->getParam("eintragen_fehler") . $strErrors;
     $arrTemplate["gb_post_name"] = $this->getParam("gb_post_name");
     $arrTemplate["gb_post_email"] = $this->getParam("gb_post_email");
     $arrTemplate["gb_post_text"] = $this->getParam("gb_post_text");
     $arrTemplate["gb_post_page"] = $this->getParam("gb_post_page");
     foreach ($arrTemplate as $strKey => $strValue) {
         if (uniStrpos($strKey, "gb_post_") !== false) {
             $arrTemplate[$strKey] = htmlspecialchars($strValue, ENT_QUOTES, "UTF-8", false);
         }
     }
     $arrTemplate["action"] = getLinkPortalHref($this->getPagename(), "", "saveGuestbook");
     $strReturn .= $this->fillTemplate($arrTemplate, $strTemplateID);
     return $strReturn;
 }
 /**
  * Loads the validator identified by the passed name.
  *
  * @param string $strClassname
  *
  * @throws class_exception
  * @return interface_validator
  */
 private function getValidatorInstance($strClassname)
 {
     if (uniStrpos($strClassname, "class_") === false) {
         $strClassname = "class_" . $strClassname . "_validator";
     }
     if (class_resourceloader::getInstance()->getPathForFile("/system/validators/" . $strClassname . ".php")) {
         return new $strClassname();
     } else {
         throw new class_exception("failed to load validator of type " . $strClassname, class_exception::$level_ERROR);
     }
 }
 /**
  * Returns a list of comments.
  *
  * @return string
  * @permissions view
  */
 protected function actionList()
 {
     $strReturn = "";
     $strPosts = "";
     $strForm = "";
     $strNewButton = "";
     //pageid or systemid to filter?
     $strSystemidfilter = "";
     $strPagefilter = $this->strPagefilter;
     if ($this->getSystemid() != "") {
         $strSystemidfilter = $this->getSystemid();
     }
     if ($strPagefilter === null && class_module_pages_page::getPageByName($this->getPagename()) !== null) {
         $strPagefilter = class_module_pages_page::getPageByName($this->getPagename())->getSystemid();
     }
     $intNrOfPosts = isset($this->arrElementData["int1"]) ? $this->arrElementData["int1"] : 0;
     //Load all posts
     $objArraySectionIterator = new class_array_section_iterator(class_module_postacomment_post::getNumberOfPostsAvailable(true, $strPagefilter, $strSystemidfilter, $this->getStrPortalLanguage()));
     $objArraySectionIterator->setIntElementsPerPage($intNrOfPosts);
     $objArraySectionIterator->setPageNumber((int) ($this->getParam("pvPAC") != "" ? $this->getParam("pvPAC") : 1));
     $objArraySectionIterator->setArraySection(class_module_postacomment_post::loadPostList(true, $strPagefilter, $strSystemidfilter, $this->getStrPortalLanguage(), $objArraySectionIterator->calculateStartPos(), $objArraySectionIterator->calculateEndPos()));
     //params to add?
     $strAdd = "";
     if ($this->getParam("action") != "") {
         $strAdd .= "&action=" . $this->getParam("action");
     }
     if ($this->getParam("systemid") != "") {
         $strAdd .= "&systemid=" . $this->getParam("systemid");
     }
     if ($this->getParam("pv") != "") {
         $strAdd .= "&pv=" . $this->getParam("pv");
     }
     $arrComments = $this->objToolkit->simplePager($objArraySectionIterator, $this->getLang("commons_next"), $this->getLang("commons_back"), "", $this->getPagename(), $strAdd, "pvPAC");
     $strTemplateID = $this->objTemplate->readTemplate("/module_postacomment/" . $this->arrElementData["char1"], "postacomment_post");
     if (!$objArraySectionIterator->valid()) {
         $strPosts .= $this->getLang("postacomment_empty");
     }
     //Check rights
     /** @var class_module_postacomment_post $objOnePost */
     foreach ($objArraySectionIterator as $objOnePost) {
         if ($objOnePost->rightView()) {
             $strOnePost = "";
             $arrOnePost = array();
             $arrOnePost["postacomment_post_name"] = $objOnePost->getStrUsername();
             $arrOnePost["postacomment_post_subject"] = $objOnePost->getStrTitle();
             $arrOnePost["postacomment_post_message"] = $objOnePost->getStrComment();
             $arrOnePost["postacomment_post_systemid"] = $objOnePost->getSystemid();
             $arrOnePost["postacomment_post_date"] = timeToString($objOnePost->getIntDate(), true);
             //ratings available?
             if ($objOnePost->getFloatRating() !== null) {
                 /** @var $objRating class_module_rating_portal */
                 $objRating = class_module_system_module::getModuleByName("rating")->getPortalInstanceOfConcreteModule();
                 $arrOnePost["postacomment_post_rating"] = $objRating->buildRatingBar($objOnePost->getFloatRating(), $objOnePost->getIntRatingHits(), $objOnePost->getSystemid(), $objOnePost->isRateableByUser(), $objOnePost->rightRight2());
             }
             $strOnePost .= $this->objTemplate->fillTemplate($arrOnePost, $strTemplateID, false);
             //Add pe code
             $arrPeConfig = array("pe_module" => "postacomment", "pe_action_edit" => "edit", "pe_action_edit_params" => "&systemid=" . $objOnePost->getSystemid(), "pe_action_new" => "", "pe_action_new_params" => "", "pe_action_delete" => "delete", "pe_action_delete_params" => "&systemid=" . $objOnePost->getSystemid());
             $strPosts .= class_element_portal::addPortalEditorCode($strOnePost, $objOnePost->getSystemid(), $arrPeConfig);
         }
     }
     //Create form
     if ($this->getObjModule()->rightRight1()) {
         $strTemplateID = $this->objTemplate->readTemplate("/module_postacomment/" . $this->arrElementData["char1"], "postacomment_form");
         $arrForm = array();
         if ($this->getParam("comment_name") == "" && $this->objSession->isLoggedin()) {
             $this->setParam("comment_name", $this->objSession->getUsername());
         }
         $arrForm["formaction"] = class_link::getLinkPortalHref($this->getPagename(), "", "postComment", "", $this->getSystemid());
         $arrForm["comment_name"] = $this->getParam("comment_name");
         $arrForm["comment_subject"] = $this->getParam("comment_subject");
         $arrForm["comment_message"] = $this->getParam("comment_message");
         $arrForm["comment_template"] = $this->arrElementData["char1"];
         $arrForm["comment_systemid"] = $this->getSystemid();
         $arrForm["comment_page"] = $this->getPagename();
         $arrForm["validation_errors"] = $this->strErrors;
         foreach ($arrForm as $strKey => $strValue) {
             if (uniStrpos($strKey, "comment_") !== false) {
                 $arrForm[$strKey] = htmlspecialchars($strValue, ENT_QUOTES, "UTF-8", false);
             }
         }
         $strForm .= $this->objTemplate->fillTemplate($arrForm, $strTemplateID, false);
         //button to show the form
         $strTemplateNewButtonID = $this->objTemplate->readTemplate("/module_postacomment/" . $this->arrElementData["char1"], "postacomment_new_button");
         $strNewButton = $this->objTemplate->fillTemplate(array("comment_systemid" => $this->getSystemid()), $strTemplateNewButtonID, false);
     }
     //add sourrounding list template
     $strTemplateID = $this->objTemplate->readTemplate("/module_postacomment/" . $this->arrElementData["char1"], "postacomment_list");
     //link to the post-form & pageview links
     $arrTemplate = array();
     $arrTemplate["postacomment_forward"] = $arrComments["strForward"];
     $arrTemplate["postacomment_pages"] = $arrComments["strPages"];
     $arrTemplate["postacomment_back"] = $arrComments["strBack"];
     $arrTemplate["postacomment_form"] = $strForm;
     $arrTemplate["postacomment_new_button"] = $strNewButton;
     $arrTemplate["postacomment_systemid"] = $this->getSystemid();
     $arrTemplate["postacomment_list"] = $strPosts;
     $strReturn .= $this->fillTemplate($arrTemplate, $strTemplateID);
     return $strReturn;
 }
Example #21
0
 /**
  * Returns a list of all core directories available
  *
  * @return array
  */
 public static function getCoreDirectories()
 {
     $arrCores = array();
     foreach (scandir(_realpath_) as $strRootFolder) {
         if (uniStrpos($strRootFolder, "core") === false) {
             continue;
         }
         $arrCores[] = $strRootFolder;
     }
     return $arrCores;
 }
 /**
  * Method to move an element from one placeholder to another
  * Expects the params
  * - systemid
  * - placeholder
  *
  * @permissions edit
  * @xml
  * @return string
  */
 protected function actionMoveElement()
 {
     $strReturn = "";
     //get the object to update
     /** @var $objObject class_module_pages_pageelement */
     $objObject = class_objectfactory::getInstance()->getObject($this->getSystemid());
     if ($objObject instanceof class_module_pages_pageelement && $objObject->rightEdit()) {
         $strPageSystemid = $objObject->getPrevId();
         $objLockmanager = new class_lockmanager($objObject->getSystemid());
         $strPlaceholder = $this->getParam("placeholder");
         $arrParts = explode("_", $strPlaceholder);
         if (uniStrpos($arrParts[1], $objObject->getStrElement()) !== false) {
             if (!$objLockmanager->isLocked()) {
                 $objLockmanager->lockRecord();
             }
             if ($objLockmanager->isLockedByCurrentUser()) {
                 //ph_placeholder
                 $objObject->setStrPlaceholder($strPlaceholder);
                 //ph_name
                 $objObject->setStrName($arrParts[0]);
                 $objObject->updateObjectToDb();
                 //Edit Date of page & unlock
                 $objPage = class_objectfactory::getInstance()->getObject($strPageSystemid);
                 $objPage->updateObjectToDb();
                 $objLockmanager->unlockRecord();
                 //Loading the data of the corresp site
                 $this->flushCompletePagesCache();
                 $strReturn = "<message><success>element update succeeded</success></message>";
             } else {
                 class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_UNAUTHORIZED);
                 $strReturn = "<message><error>element not allowed for target placeholder</error></message>";
             }
         }
     } else {
         class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_UNAUTHORIZED);
         $strReturn = "<message><error>" . $this->getLang("ds_gesperrt") . "." . $this->getLang("commons_error_permissions") . "</error></message>";
     }
     return $strReturn;
 }
 /**
  * Returns the list of top-queries
  *
  * @return mixed
  */
 public function getTopQueries()
 {
     //Load all records in the passed interval
     $arrBlocked = explode(",", class_module_system_setting::getConfigValue("_stats_exclusionlist_"));
     $arrParams = array($this->intDateStart, $this->intDateEnd);
     $strExclude = "";
     foreach ($arrBlocked as $strBlocked) {
         if ($strBlocked != "") {
             $strExclude .= " AND stats_referer NOT LIKE ? \n";
             $arrParams[] = "%" . str_replace("%", "\\%", $strBlocked) . "%";
         }
     }
     $strQuery = "SELECT stats_referer\n\t\t\t\t\t\tFROM " . _dbprefix_ . "stats_data\n\t\t\t\t\t\tWHERE stats_date > ?\n\t\t\t\t\t\t  AND stats_date <= ?\n\t\t\t\t\t\t  AND stats_referer != ''\n\t\t\t\t\t\t  AND stats_referer IS NOT NULL\n\t\t\t\t\t\t    " . $strExclude . "\n\t\t\t\t\t\tORDER BY stats_date desc";
     $arrRecords = $this->objDB->getPArray($strQuery, $arrParams);
     $arrHits = array();
     //Suchpatterns: q=, query=
     $arrQuerypatterns = array("q=", "query=");
     foreach ($arrRecords as $arrOneRecord) {
         foreach ($arrQuerypatterns as $strOnePattern) {
             if (uniStrpos($arrOneRecord["stats_referer"], $strOnePattern) !== false) {
                 $strQueryterm = uniSubstr($arrOneRecord["stats_referer"], uniStrpos($arrOneRecord["stats_referer"], $strOnePattern) + uniStrlen($strOnePattern));
                 $strQueryterm = uniSubstr($strQueryterm, 0, uniStrpos($strQueryterm, "&"));
                 $strQueryterm = uniStrtolower(trim(urldecode($strQueryterm)));
                 if ($strQueryterm != "") {
                     if (isset($arrHits[$strQueryterm])) {
                         $arrHits[$strQueryterm]++;
                     } else {
                         $arrHits[$strQueryterm] = 1;
                     }
                 }
                 break;
             }
         }
     }
     arsort($arrHits);
     return $arrHits;
 }
Example #24
0
 /**
  * Wrapper to the real, fast resizing
  * @return void
  */
 private function resizeImage()
 {
     //Load the image-dimensions
     if (is_file(_realpath_ . $this->strFilename) && (uniStrpos($this->strFilename, "/files") !== false || uniStrpos($this->strFilename, "/templates") !== false)) {
         //check headers, maybe execution could be terminated right here
         if (checkConditionalGetHeaders(md5(md5_file(_realpath_ . $this->strFilename) . $this->intMaxWidth . $this->intMaxHeight . $this->intFixedWidth . $this->intFixedHeight))) {
             class_response_object::getInstance()->sendHeaders();
             return;
         }
         $objImage = new class_image2();
         $objImage->load($this->strFilename);
         $objImage->addOperation(new class_image_scale_and_crop($this->intFixedWidth, $this->intFixedHeight));
         $objImage->addOperation(new class_image_scale($this->intMaxWidth, $this->intMaxHeight));
         //send the headers for conditional gets
         setConditionalGetHeaders(md5(md5_file(_realpath_ . $this->strFilename) . $this->intMaxWidth . $this->intMaxHeight . $this->intFixedWidth . $this->intFixedHeight));
         //TODO: add expires header for browser caching (optional)
         /*
         $intCacheSeconds = 604800; //default: 1 week (60*60*24*7)
         header("Expires: ".gmdate("D, d M Y H:i:s", time() + $intCacheSeconds)." GMT", true);
         header("Cache-Control: public, max-age=".$intCacheSeconds, true);
         header("Pragma: ", true);
         */
         //and send it to the browser
         $objImage->setJpegQuality((int) $this->intQuality);
         $objImage->sendToBrowser();
         return;
     }
     class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_NOT_FOUND);
     class_response_object::getInstance()->sendHeaders();
 }
 /**
  * Creates a sitemap recursive level by level
  *
  * @param int $intLevel
  * @param array $objStartEntry
  * @param string $strStack
  *
  * @internal param string $strSystemid
  * @return string
  */
 private function sitemapRecursive($intLevel, $objStartEntry, $strStack)
 {
     $strReturn = "";
     $arrChilds = $objStartEntry["subnodes"];
     $intNrOfChilds = count($arrChilds);
     //Anything to do right here?
     if ($intNrOfChilds == 0) {
         return "";
     }
     //Iterate over every child
     for ($intI = 0; $intI < $intNrOfChilds; $intI++) {
         $arrOneChild = $arrChilds[$intI];
         //Check the rights
         if ($arrOneChild["node"]->rightView()) {
             //check if it's a foreign node and whether foreign nodes should be included
             if ($arrOneChild["node"]->getBitIsForeignNode() && $this->arrElementData["navigation_foreign"] === 0) {
                 continue;
             }
             //current point active?
             $bitActive = false;
             if (uniStripos($strStack, $arrOneChild["node"]->getSystemid()) !== false) {
                 $bitActive = true;
             }
             //Create the navigation point
             if ($intI == 0) {
                 $strCurrentPoint = $this->createNavigationPoint($arrOneChild["node"], $bitActive, $intLevel, true);
             } elseif ($intI == $intNrOfChilds - 1) {
                 $strCurrentPoint = $this->createNavigationPoint($arrOneChild["node"], $bitActive, $intLevel, false, true);
             } else {
                 $strCurrentPoint = $this->createNavigationPoint($arrOneChild["node"], $bitActive, $intLevel);
             }
             //And load all points below
             $strChilds = "";
             if (uniStrpos($strCurrentPoint, "level" . ($intLevel + 1)) !== false) {
                 $strChilds = $this->sitemapRecursive($intLevel + 1, $arrOneChild, $strStack);
             }
             //Put the childs below into the current template
             $this->objTemplate->setTemplate($strCurrentPoint);
             $arrTemp = array("level" . ($intLevel + 1) => $strChilds);
             $strTemplate = $this->objTemplate->fillCurrentTemplate($arrTemp);
             $strReturn .= $strTemplate;
         }
     }
     //wrap into the wrapper-section
     $strLevelTemplateID = $this->objTemplate->readTemplate("/module_navigation/" . $this->arrElementData["navigation_template"], "level_" . $intLevel . "_wrapper");
     $strWrappedLevel = $this->fillTemplate(array("level" . $intLevel => $strReturn), $strLevelTemplateID);
     if (uniStrlen($strWrappedLevel) > 0) {
         $strReturn = $strWrappedLevel;
     }
     return $strReturn;
 }
    /**
     * Shows a form to manage memberships of a user in groups
     *
     * @return string
     * @permissions edit
     */
    protected function actionEditMemberships()
    {
        $strReturn = "";
        //open the form
        $strReturn .= $this->objToolkit->formHeader(class_link::getLinkAdminHref($this->getArrModule("modul"), "saveMembership"));
        //Create a list of checkboxes
        $objUser = new class_module_user_user($this->getSystemid());
        $strReturn .= $this->objToolkit->formHeadline($this->getLang("user_memberships") . "\"" . $objUser->getStrUsername() . "\"");
        //Collect groups from the same source
        $objUsersources = new class_module_user_sourcefactory();
        $objSourcesytem = $objUsersources->getUsersource($objUser->getStrSubsystem());
        $arrGroups = $objSourcesytem->getAllGroupIds();
        $arrUserGroups = $objUser->getArrGroupIds();
        $arrRows = array();
        foreach ($arrGroups as $strSingleGroup) {
            //to avoid privilege escalation, the admin-group has to be treated in a special manner
            //only render the group, if the current user is member of this group
            $objSingleGroup = new class_module_user_group($strSingleGroup);
            if (!$this->isGroupEditable($objSingleGroup)) {
                continue;
            }
            $strCheckbox = $this->objToolkit->formInputCheckbox($objSingleGroup->getSystemid(), "", in_array($strSingleGroup, $arrUserGroups));
            $strCheckbox = uniSubstr($strCheckbox, uniStrpos($strCheckbox, "<input"));
            $strCheckbox = uniSubstr($strCheckbox, 0, uniStrpos($strCheckbox, ">") + 1);
            $arrRows[] = array($strCheckbox, $objSingleGroup->getStrName());
            //            $strReturn .= $this->objToolkit->formInputCheckbox($objSingleGroup->getSystemid(), $objSingleGroup->getStrName(), in_array($strSingleGroup, $arrUserGroups));
        }
        $strReturn .= <<<HTML
    <a href="javascript:KAJONA.admin.permissions.toggleEmtpyRows('[lang,permissions_toggle_visible,system]', '[lang,permissions_toggle_hidden,system]', 'table.kajona-data-table tr');" id="rowToggleLink" class="rowsVisible">[lang,permissions_toggle_visible,system]</a><br /><br />
HTML;
        $strReturn .= $this->objToolkit->dataTable(null, $arrRows);
        $strReturn .= "<script type=\"text/javascript\">\r\n                KAJONA.admin.permissions.toggleEmtpyRows('" . $this->getLang("permissions_toggle_visible", "system") . "', '" . $this->getLang("permissions_toggle_hidden", "system") . "', 'table.kajona-data-table tr');\r\n                </script>";
        $strReturn .= $this->objToolkit->formInputHidden("systemid", $this->getSystemid());
        $strReturn .= $this->objToolkit->formInputSubmit($this->getLang("commons_save"));
        $strReturn .= $this->objToolkit->formClose();
        return $strReturn;
    }
Example #27
0
 /**
  * A general action to delete a record.
  * This method may be overwritten by subclasses.
  *
  * @permissions delete
  * @throws class_exception
  * @return void
  */
 protected function actionDelete()
 {
     $objRecord = class_objectfactory::getInstance()->getObject($this->getSystemid());
     if ($objRecord != null && $objRecord->rightDelete()) {
         if (!$objRecord->deleteObject()) {
             throw new class_exception("error deleting object " . strip_tags($objRecord->getStrDisplayName()), class_exception::$level_ERROR);
         }
         $strTargetUrl = urldecode($this->getParam("reloadUrl"));
         if ($strTargetUrl == "" || uniStrpos($strTargetUrl, $this->getSystemid()) !== false) {
             $strTargetUrl = "admin=1&module=" . $this->getArrModule("modul");
             $intI = 1;
             while ($this->getHistory($intI) !== null) {
                 $strTargetUrl = $this->getHistory($intI++);
                 if (uniStrpos($strTargetUrl, $this->getSystemid()) === false) {
                     if (uniStrpos($strTargetUrl, "admin=1") === false) {
                         $strTargetUrl = "admin=1&module=" . $this->getArrModule("modul");
                     }
                     break;
                 }
             }
         }
         $this->adminReload(_indexpath_ . "?" . $strTargetUrl . ($this->getParam("pe") != "" ? "&peClose=1&blockAction=1" : ""));
     } else {
         throw new class_exception("error loading object " . $this->getSystemid(), class_exception::$level_ERROR);
     }
 }
 /**
  * saves a post in the database and returns the post as html.
  * In case of missing fields, the form is returned again
  *
  * @return string
  * @permissons right1
  */
 protected function actionSavePost()
 {
     $strXMLContent = "";
     //validate needed fields
     if (!$this->validateForm()) {
         //Create form to reenter values
         $strTemplateID = $this->objTemplate->readTemplate("/module_postacomment/" . $this->getParam("comment_template"), "postacomment_form");
         $arrForm = array();
         $arrForm["formaction"] = class_link::getLinkPortalHref($this->getPagename(), "", "postComment", "", $this->getSystemid());
         $arrForm["comment_name"] = $this->getParam("comment_name");
         $arrForm["comment_subject"] = $this->getParam("comment_subject");
         $arrForm["comment_message"] = $this->getParam("comment_message");
         $arrForm["comment_template"] = $this->getParam("comment_template");
         $arrForm["comment_systemid"] = $this->getParam("comment_systemid");
         $arrForm["comment_page"] = $this->getParam("comment_page");
         $arrForm["validation_errors"] = $this->strErrors;
         foreach ($arrForm as $strKey => $strValue) {
             if (uniStrpos($strKey, "comment_") !== false) {
                 $arrForm[$strKey] = htmlspecialchars($strValue, ENT_QUOTES, "UTF-8", false);
             }
         }
         //texts
         $arrForm["postacomment_write_new"] = $this->getLang("postacomment_write_new");
         $arrForm["form_name_label"] = $this->getLang("form_name_label");
         $arrForm["form_subject_label"] = $this->getLang("form_subject_label");
         $arrForm["form_message_label"] = $this->getLang("form_message_label");
         $arrForm["form_captcha_label"] = $this->getLang("commons_captcha");
         $arrForm["form_captcha_reload_label"] = $this->getLang("commons_captcha_reload");
         $arrForm["form_submit_label"] = $this->getLang("form_submit_label");
         $strXMLContent .= $this->fillTemplate($arrForm, $strTemplateID);
     } else {
         //save the post to the db
         //pageid or systemid to filter?
         $strSystemidfilter = $this->getParam("comment_systemid");
         if (class_module_pages_page::getPageByName($this->getParam("comment_page")) !== null) {
             $strPagefilter = class_module_pages_page::getPageByName($this->getParam("comment_page"))->getSystemid();
         } else {
             $strPagefilter = "";
         }
         $objPost = new class_module_postacomment_post();
         $objPost->setStrUsername($this->getParam("comment_name"));
         $objPost->setStrTitle($this->getParam("comment_subject"));
         $objPost->setStrComment($this->getParam("comment_message"));
         $objPost->setStrAssignedPage($strPagefilter);
         $objPost->setStrAssignedSystemid($strSystemidfilter);
         $objPost->setStrAssignedLanguage($this->getStrPortalLanguage());
         $objPost->updateObjectToDb();
         $this->flushPageFromPagesCache($this->getPagename());
         $strMailtext = $this->getLang("new_comment_mail") . "\r\n\r\n" . $objPost->getStrComment() . "\r\n";
         $strMailtext .= class_link::getLinkAdminHref("postacomment", "edit", "&systemid=" . $objPost->getSystemid(), false);
         $objMessageHandler = new class_module_messaging_messagehandler();
         $arrGroups = array();
         $allGroups = class_module_user_group::getObjectList();
         foreach ($allGroups as $objOneGroup) {
             if (class_rights::getInstance()->checkPermissionForGroup($objOneGroup->getSystemid(), class_rights::$STR_RIGHT_EDIT, $this->getObjModule()->getSystemid())) {
                 $arrGroups[] = $objOneGroup;
             }
         }
         $objMessageHandler->sendMessage($strMailtext, $arrGroups, new class_messageprovider_postacomment());
         //reinit post -> encoded entities
         $objPost->initObject();
         //load the post as a new post to add it at top of the list
         $arrOnePost = array();
         $arrOnePost["postacomment_post_name"] = $objPost->getStrUsername();
         $arrOnePost["postacomment_post_subject"] = $objPost->getStrTitle();
         $arrOnePost["postacomment_post_message"] = $objPost->getStrComment();
         $arrOnePost["postacomment_post_systemid"] = $objPost->getSystemid();
         $arrOnePost["postacomment_post_date"] = timeToString($objPost->getIntDate(), true);
         $strTemplateID = $this->objTemplate->readTemplate("/module_postacomment/" . $this->getParam("comment_template"), "postacomment_post");
         $strXMLContent .= $this->objTemplate->fillTemplate($arrOnePost, $strTemplateID);
     }
     class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_JSON);
     return $strXMLContent;
 }
Example #29
0
 /**
  * Transforms the prepared statement into a valid oracle syntax.
  * This is done by replying the ?-chars by :x entries.
  *
  * @param string $strQuery
  *
  * @return string
  */
 private function processQuery($strQuery)
 {
     $intCount = 1;
     while (uniStrpos($strQuery, "?") !== false) {
         $intPos = uniStrpos($strQuery, "?");
         $strQuery = substr($strQuery, 0, $intPos) . ":" . $intCount++ . substr($strQuery, $intPos + 1);
     }
     return $strQuery;
 }
 /**
  * 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("&amp;", $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("&amp;", $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;
 }