/** * Validates the passed chunk of data. * In most cases, this'll be a string-object. * * @param string $objValue * @return bool */ public function validate($objValue) { if (is_string($objValue) && uniStrlen($objValue) == 1) { return true; } return false; }
/** * Validates the passed chunk of data. * In most cases, this'll be a string-object. * * @param string $objValue * @return bool */ public function validate($objValue) { if (!is_string($objValue) || uniStrlen($objValue) == 0) { return false; } return is_dir(_realpath_ . $objValue); }
/** * Validates the passed chunk of data. * In most cases, this'll be a string-object. * * @param string $objValue * @return bool */ public function validate($objValue) { if (!is_string($objValue) || uniStrlen($objValue) == 0) { return false; } return is_file(_realpath_ . $this->strBaseDir . $objValue); }
/** * @return string */ private function getUserlist() { $strReturn = ""; $strTemplateWrapperID = $this->objTemplate->readTemplate("/element_userlist/" . $this->arrElementData["char1"], "userlist_wrapper"); $strTemplateRowID = $this->objTemplate->readTemplate("/element_userlist/" . $this->arrElementData["char1"], "userlist_row"); $arrUserFinal = $this->loadUserlist(); $strRows = ""; foreach ($arrUserFinal as $objOneUser) { $objTargetUser = $objOneUser->getObjSourceUser(); if ($objTargetUser instanceof class_usersources_user_kajona) { $arrRow = array(); $arrRow["userName"] = $objTargetUser->getStrName(); $arrRow["userForename"] = $objTargetUser->getStrForename(); $arrRow["userStreet"] = $objTargetUser->getStrStreet(); $arrRow["userEmail"] = $objTargetUser->getStrEmail(); $arrRow["userPostal"] = $objTargetUser->getStrPostal(); $arrRow["userCity"] = $objTargetUser->getStrCity(); $arrRow["userPhone"] = $objTargetUser->getStrTel(); $arrRow["userMobile"] = $objTargetUser->getStrMobile(); $arrRow["userBirthday"] = uniStrlen($objTargetUser->getLongDate()) > 5 ? dateToString(new class_date($objTargetUser->getLongDate()), false) : ""; $strRows .= $this->fillTemplate($arrRow, $strTemplateRowID); } } $strLink = getLinkPortalHref($this->getPagename(), "", "exportToCsv"); $strReturn .= $this->fillTemplate(array("userlist_rows" => $strRows, "csvHref" => $strLink), $strTemplateWrapperID); return $strReturn; }
/** * Calls the single search-functions, sorts the results and creates the output. * Method for portal-searches. * * @param class_module_search_search $objSearch * * @return class_search_result[] */ public function doPortalSearch($objSearch) { $objSearch->setStrQuery(trim(uniStrReplace("%", "", $objSearch->getStrQuery()))); if (uniStrlen($objSearch->getStrQuery()) == 0) { return array(); } //create a search object $objSearch->setBitPortalObjectFilter(true); $arrHits = $this->doIndexedSearch($objSearch); $arrReturn = array(); foreach ($arrHits as $objOneResult) { $objInstance = $objOneResult->getObjObject(); if ($objInstance instanceof class_module_pages_pageelement) { $objInstance = $objInstance->getConcreteAdminInstance(); if ($objInstance != null) { $objInstance->loadElementData(); } else { continue; } } $arrUpdatedResults = $objInstance->updateSearchResult($objOneResult); if (is_array($arrUpdatedResults)) { $arrReturn = array_merge($arrReturn, $arrUpdatedResults); } else { if ($objOneResult != null && $objOneResult instanceof class_search_result) { $arrReturn[] = $objOneResult; } } } //log the query class_module_search_log::generateLogEntry($objSearch->getStrQuery()); $arrReturn = $this->mergeDuplicates($arrReturn); return $arrReturn; }
/** * Overwritten in order to load key-value pairs declared by annotations */ protected function updateValue() { parent::updateValue(); if ($this->getObjSourceObject() != null && $this->getStrSourceProperty() != "") { $objReflection = new class_reflection($this->getObjSourceObject()); //try to find the matching source property $arrProperties = $objReflection->getPropertiesWithAnnotation(self::STR_TEMPLATEDIR_ANNOTATION); $strSourceProperty = null; foreach ($arrProperties as $strPropertyName => $strValue) { if (uniSubstr(uniStrtolower($strPropertyName), uniStrlen($this->getStrSourceProperty()) * -1) == $this->getStrSourceProperty()) { $strSourceProperty = $strPropertyName; } } if ($strSourceProperty == null) { return; } $strTemplateDir = $objReflection->getAnnotationValueForProperty($strSourceProperty, self::STR_TEMPLATEDIR_ANNOTATION); //load templates $arrTemplates = class_resourceloader::getInstance()->getTemplatesInFolder($strTemplateDir); $arrTemplatesDD = array(); if (count($arrTemplates) > 0) { foreach ($arrTemplates as $strTemplate) { $arrTemplatesDD[$strTemplate] = $strTemplate; } } $this->setArrKeyValues($arrTemplatesDD); } }
/** * Overwritten in order to load key-value pairs declared by annotations */ protected function updateValue() { parent::updateValue(); if ($this->getObjSourceObject() != null && $this->getStrSourceProperty() != "") { $objReflection = new class_reflection($this->getObjSourceObject()); //try to find the matching source property $arrProperties = $objReflection->getPropertiesWithAnnotation(self::STR_DDVALUES_ANNOTATION); $strSourceProperty = null; foreach ($arrProperties as $strPropertyName => $strValue) { if (uniSubstr(uniStrtolower($strPropertyName), uniStrlen($this->getStrSourceProperty()) * -1) == $this->getStrSourceProperty()) { $strSourceProperty = $strPropertyName; } } if ($strSourceProperty == null) { return; } $strDDValues = $objReflection->getAnnotationValueForProperty($strSourceProperty, self::STR_DDVALUES_ANNOTATION); if ($strDDValues !== null && $strDDValues != "") { $arrDDValues = array(); foreach (explode(",", $strDDValues) as $strOneKeyVal) { $strOneKeyVal = uniSubstr(trim($strOneKeyVal), 1, -1); $arrOneKeyValue = explode("=>", $strOneKeyVal); $strKey = trim($arrOneKeyValue[0]) == "" ? " " : trim($arrOneKeyValue[0]); if (count($arrOneKeyValue) == 2) { $strValue = class_carrier::getInstance()->getObjLang()->getLang(trim($arrOneKeyValue[1]), $this->getObjSourceObject()->getArrModule("modul")); if ($strValue == "!" . trim($arrOneKeyValue[1]) . "!") { $strValue = $arrOneKeyValue[1]; } $arrDDValues[$strKey] = $strValue; } } $this->setArrKeyValues($arrDDValues); } } }
/** * Validates the passed chunk of data. * In most cases, this'll be a string-object. * * @param string $objValue * @return bool */ public function validate($objValue) { if (!is_string($objValue)) { return false; } return uniStrlen($objValue) === 2; }
/** * Splits the current text into several tokens * @return void */ private function tokenizeAndClearShortText() { $arrResults = array(); preg_match_all('/\\w{1,}/u', $this->getText(), $arrResults); $arrFiltered = array_filter($arrResults[0], function ($strOneHit) { return is_numeric($strOneHit) || uniStrlen($strOneHit) > 2; }); $this->setResults($arrFiltered); $this->setResults(array_count_values($this->getResults())); }
/** * Tries to authenticate a user with the given credentials. * The password is unencrypted, each source should take care of its own encryption. * * @param interface_usersources_user|class_usersources_user_kajona $objUser * @param string $strPassword * * @return bool */ public function authenticateUser(interface_usersources_user $objUser, $strPassword) { if ($objUser instanceof class_usersources_user_kajona) { $bitMD5Encryption = false; if (uniStrlen($objUser->getStrFinalPass()) == 32) { $bitMD5Encryption = true; } if ($objUser->getStrFinalPass() == self::encryptPassword($strPassword, $objUser->getStrSalt(), $bitMD5Encryption)) { return true; } } return false; }
/** * Tries to get the name of an action (edit, delete, list, new, save) for a given object-type. * Example: Converts list to listOtherObject for the object class_module_demo_demo if the annotation * @ objectListOtherObject class_module_demo_demo is declared * * @param string $strAction * @param $objInstance * * @return string */ protected function getActionNameForClass($strAction, $objInstance) { if (isset(self::$arrActionNameMapping[$strAction])) { $strAnnotationPrefix = self::$arrActionNameMapping[$strAction]; if ($strAction == "new") { return $strAction . $this->getStrCurObjectTypeName(); } else { $objReflection = new class_reflection($this); $arrAnnotations = $objReflection->getAnnotationsWithValueFromClass(get_class($objInstance)); foreach ($arrAnnotations as $strProperty) { if (uniStrpos($strProperty, $strAnnotationPrefix) === 0) { return $strAction . uniSubstr($strProperty, uniStrlen($strAnnotationPrefix)); } } } } return parent::getActionNameForClass($strAction, $objInstance); }
/** * Validates the passed chunk of data. * In most cases, this'll be a string-object. * * @param string $objValue * @return bool */ public function validate($objValue) { if (!is_string($objValue)) { return false; } $intMin = 1; $intMax = 0; //todo does not makes sense here as the else part will never be reached?extract intMax to class variable? $intLen = uniStrlen($objValue); if ($intMax == 0) { if ($intLen >= $intMin) { return true; } } else { if ($intLen >= $intMin && $intLen <= $intMax) { return true; } } return false; }
private function getSourceDir() { if ($this->getObjSourceObject() != null && $this->getStrSourceProperty() != "") { $objReflection = new class_reflection($this->getObjSourceObject()); //try to find the matching source property $arrProperties = $objReflection->getPropertiesWithAnnotation(self::STR_SOURCEDIR_ANNOTATION); $strSourceProperty = null; foreach ($arrProperties as $strPropertyName => $strValue) { if (uniSubstr(uniStrtolower($strPropertyName), uniStrlen($this->getStrSourceProperty()) * -1) == $this->getStrSourceProperty()) { $strSourceProperty = $strPropertyName; } } if ($strSourceProperty != null) { $strDir = $objReflection->getAnnotationValueForProperty($strSourceProperty, self::STR_SOURCEDIR_ANNOTATION); if ($strDir !== null && $strDir != "") { return $strDir; } } } return null; }
/** * @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; }
/** * Returns a textual representation of the formentries' value. * May contain html, but should be stripped down to text-only. * * @return string */ public function getValueAsText() { //load all matching and possible values based on the prefix if ($this->getObjSourceObject() == null || $this->getStrSourceProperty() == "") { return $this->getStrValue() . " Error: No target object mapped or missing @fieldValuePrefix annotation!"; } $objReflection = new class_reflection($this->getObjSourceObject()); //try to find the matching source property $arrProperties = $objReflection->getPropertiesWithAnnotation(self::STR_VALUE_ANNOTATION); $strSourceProperty = null; foreach ($arrProperties as $strPropertyName => $strValue) { if (uniSubstr(uniStrtolower($strPropertyName), uniStrlen($this->getStrSourceProperty()) * -1) == $this->getStrSourceProperty()) { $strSourceProperty = $strPropertyName; } } if ($strSourceProperty == null) { return $this->getStrValue(); } $strPrefix = trim($objReflection->getAnnotationValueForProperty($strSourceProperty, self::STR_VALUE_ANNOTATION)); if ($this->getStrValue() !== null && $this->getStrValue() !== "") { return $this->getObjSourceObject()->getLang($strPrefix . $this->getStrValue()); } return ""; }
/** * Returns the filter modules to edit the filter modules * * @return array */ public function getFilterModules() { if (uniStrlen($this->strInternalFilterModules) > 0 && $this->strInternalFilterModules != "-1") { return explode(",", $this->strInternalFilterModules); } return array(); }
/** * Returns a textual description of the current element, based * on the lang key element_description. * * @return string * @since 3.2.1 */ public function getElementDescription() { $strName = uniSubstr(get_class($this), uniStrlen("class_"), -6); $strDesc = $this->getLang($strName . "_description"); if ($strDesc == "!" . $strName . "_description!") { $strDesc = ""; } return $strDesc; }
/** * 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("&", $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 != "" ? "&systemid=" . $strSystemid : "") . ($strAction != "" ? "&action=" . $strAction : "") . ($strLanguage != "" ? "&language=" . $strLanguage : "") . (count($arrParams) > 0 ? "&" . implode("&", $arrParams) : "") . ($strAnchor != "" ? "#" . $strAnchor : "") . ""; } } else { $strHref = $strPageE; } $strReturn .= $strHref; return $strReturn; }
/** * Inserts a line-break to long legend-values * * @param $strLegend * @return string */ private function stripLegend($strLegend) { $intStart = $this->intLegendBreakCount; while (uniStrlen($strLegend) > $intStart) { $strLegend = uniSubstr($strLegend, 0, $intStart) . "\n" . uniSubstr($strLegend, $intStart); $intStart += $this->intLegendBreakCount; } return $strLegend; }
/** * 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; }
/** * 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; }
/** * Generates a captcha image to defend bots. * To generate a captcha image, use "kajonaCaptcha" as image-param * when calling image.php * Up to now, the size-params are ignored during the creation of a * captcha image * * @return void */ public function generateCaptchaImage() { if ($this->intMaxWidth == 0 || $this->intMaxWidth > 500) { $intWidth = 200; } else { $intWidth = $this->intMaxWidth; } if ($this->intMaxHeight == 0 || $this->intMaxHeight > 500) { $intHeight = 50; } else { $intHeight = $this->intMaxHeight; } $intMinfontSize = 15; $intMaxFontSize = 22; $intWidthPerChar = 30; $strCharsPossible = "abcdefghijklmnpqrstuvwxyz123456789"; $intHorizontalOffset = 10; $intVerticalOffset = 10; $intForegroundOffset = 2; $strCharactersPlaced = ""; //init the random-function srand((double) microtime() * 1000000); //v2 version $objImage2 = new class_image2(); $objImage2->create($intWidth, $intHeight); $objImage2->addOperation(new class_image_rectangle(0, 0, $intWidth, $intHeight, "#FFFFFF")); //draw vertical lines $intStart = 5; while ($intStart < $intWidth - 5) { $objImage2->addOperation(new class_image_line($intStart, 0, $intStart, $intWidth, $this->generateGreyLikeColor())); $intStart += rand(10, 17); } //draw horizontal lines $intStart = 5; while ($intStart < $intHeight - 5) { $objImage2->addOperation(new class_image_line(0, $intStart, $intWidth, $intStart, $this->generateGreyLikeColor())); $intStart += rand(10, 17); } //draw floating horizontal lines for ($intI = 0; $intI <= 3; $intI++) { $intXPrev = 0; $intYPrev = rand(0, $intHeight); while ($intXPrev <= $intWidth) { $intNewX = rand($intXPrev, $intXPrev + 50); $intNewY = rand(0, $intHeight); $objImage2->addOperation(new class_image_line($intXPrev, $intYPrev, $intNewX, $intNewY, $this->generateGreyLikeColor())); $intXPrev = $intNewX; $intYPrev = $intNewY; } } //calculate number of characters on the image $intNumberOfChars = floor($intWidth / $intWidthPerChar); //place characters in the image for ($intI = 0; $intI < $intNumberOfChars; $intI++) { //character to place $strCurrentChar = $strCharsPossible[rand(0, uniStrlen($strCharsPossible) - 1)]; $strCharactersPlaced .= $strCurrentChar; //color to use $intCol1 = rand(0, 200); $intCol2 = rand(0, 200); $intCol3 = rand(0, 200); //fontsize $intSize = rand($intMinfontSize, $intMaxFontSize); //calculate x and y pos $intX = $intHorizontalOffset + $intI * $intWidthPerChar; $intY = $intHeight - rand($intVerticalOffset, $intHeight - $intMaxFontSize); //the angle $intAngle = rand(-30, 30); //place the background character $objImage2->addOperation(new class_image_text($strCurrentChar, $intX, $intY, $intSize, "rgb(" . $intCol1 . "," . $intCol2 . "," . $intCol3 . ")", "dejavusans.ttf", $intAngle)); //place the foreground charater $objImage2->addOperation(new class_image_text($strCurrentChar, $intX + $intForegroundOffset, $intY + $intForegroundOffset, $intSize, "rgb(" . ($intCol1 + 50) . "," . ($intCol2 + 50) . "," . ($intCol3 + 50) . ")", "dejavusans.ttf", $intAngle)); } //register placed string to session class_carrier::getInstance()->getObjSession()->setCaptchaCode($strCharactersPlaced); //and send it to the browser //force no-cache headers class_response_object::getInstance()->addHeader("Expires: Thu, 19 Nov 1981 08:52:00 GMT", true); class_response_object::getInstance()->addHeader("Cache-Control: no-store, no-cache, must-revalidate, private", true); class_response_object::getInstance()->addHeader("Pragma: no-cache", true); $objImage2->setUseCache(false); $objImage2->sendToBrowser(class_image2::FORMAT_JPG); }
/** * Returns a list of available placeholders & elements on this page * * @return string * @permissions edit */ protected function actionList() { $strReturn = ""; class_module_languages_admin::enableLanguageSwitch(); $objPage = new class_module_pages_page($this->getSystemid()); //get infos about the page $arrToolbarEntries = array(); $arrToolbarEntries[0] = "<a href=\"" . class_link::getLinkAdminHref("pages", "editPage", "&systemid=" . $this->getSystemid()) . "\">" . class_adminskin_helper::getAdminImage("icon_edit") . $this->getLang("contentToolbar_pageproperties") . "</a>"; $arrToolbarEntries[1] = "<a href=\"" . class_link::getLinkAdminHref("pages_content", "list", "&systemid=" . $this->getSystemid()) . "\">" . class_adminskin_helper::getAdminImage("icon_page") . $this->getLang("contentToolbar_content") . "</a>"; $arrToolbarEntries[2] = "<a href=\"" . class_link::getLinkPortalHref($objPage->getStrName(), "", "", "&preview=1", "", $this->getLanguageToWorkOn()) . "\" target=\"_blank\">" . class_adminskin_helper::getAdminImage("icon_lens") . $this->getLang("contentToolbar_preview") . "</a>"; if ($objPage->getIntType() != class_module_pages_page::$INT_TYPE_ALIAS) { $strReturn .= $this->objToolkit->getContentToolbar($arrToolbarEntries, 1); } $arrInfoRows = array(array($this->getLang("template"), $objPage->getStrTemplate()), array($this->getLang("lastuserTitle"), $objPage->getLastEditUser()), array($this->getLang("lasteditTitle"), timeToString($objPage->getIntLmTime()))); $strReturn .= $this->objToolkit->dataTable(null, $arrInfoRows); $strReturn .= $this->objToolkit->divider(); //try to load template, otherwise abort $strTemplateID = null; try { $strTemplateID = $this->objTemplate->readTemplate("/module_pages/" . $objPage->getStrTemplate(), "", false, true); } catch (class_exception $objException) { $strReturn .= $this->getLang("templateNotLoaded") . "<br />"; } //Load elements on template, master-page special case! if ($objPage->getStrName() == "master") { $arrElementsOnTemplate = $this->objTemplate->getElements($strTemplateID, 1); } else { $arrElementsOnTemplate = $this->objTemplate->getElements($strTemplateID, 0); } //Language-dependant loading of elements, if installed $arrElementsOnPage = class_module_pages_pageelement::getElementsOnPage($this->getSystemid(), false, $this->getLanguageToWorkOn()); //save a copy of the array to be able to check against all values later on $arrElementsOnPageCopy = $arrElementsOnPage; //Loading all Elements installed on the system ("RAW"-Elements) $arrElementsInSystem = class_module_pages_element::getObjectList(); //So, loop through the placeholders and check, if there's any element already belonging to this one $intI = 0; if (is_array($arrElementsOnTemplate) && count($arrElementsOnTemplate) > 0) { //Iterate over every single placeholder provided by the template foreach ($arrElementsOnTemplate as $arrOneElementOnTemplate) { $strOutputAtPlaceholder = ""; //Do we have one or more elements already in db at this placeholder? $bitHit = false; //Iterate over every single element-type provided by the placeholder foreach ($arrElementsOnPage as $intArrElementsOnPageKey => $objOneElementOnPage) { //Check, if its the same placeholder $bitSamePlaceholder = false; if ($arrOneElementOnTemplate["placeholder"] == $objOneElementOnPage->getStrPlaceholder()) { $bitSamePlaceholder = true; } if ($bitSamePlaceholder) { $bitHit = true; //try to unlock the record $objOneElementOnPage->getLockManager()->unlockRecord(); $strActions = $this->getActionIcons($objOneElementOnPage); //Put all Output together $strOutputAtPlaceholder .= $this->objToolkit->simpleAdminList($objOneElementOnPage, $strActions, $intI++); //remove the element from the array unset($arrElementsOnPage[$intArrElementsOnPageKey]); } } //Check, if one of the elements in the placeholder is allowed to be used multiple times foreach ($arrOneElementOnTemplate["elementlist"] as $arrSingleElementOnTemplateplaceholder) { /** @var class_module_pages_element $objOneElementInSystem */ foreach ($arrElementsInSystem as $objOneElementInSystem) { if ($objOneElementInSystem->getStrName() == $arrSingleElementOnTemplateplaceholder["element"]) { if ($objOneElementInSystem->getIntRepeat() == 1 || $bitHit === false) { //So, the Row for a new element: element is repeatable or not yet created $strActions = $this->objToolkit->listButton(class_link::getLinkAdmin("pages_content", "new", "&placeholder=" . $arrOneElementOnTemplate["placeholder"] . "&element=" . $arrSingleElementOnTemplateplaceholder["element"] . "&systemid=" . $this->getSystemid(), "", $this->getLang("element_anlegen"), "icon_new")); $strOutputAtPlaceholder .= $this->objToolkit->genericAdminList("", $objOneElementInSystem->getStrDisplayName(), "", $strActions, $intI++); } else { //element not repeatable. //Is there already one element installed? if not, then it IS allowed to create a new one $bitOneInstalled = false; foreach ($arrElementsOnPageCopy as $objOneElementToCheck) { if ($arrOneElementOnTemplate["placeholder"] == $objOneElementToCheck->getStrPlaceholder() && $arrSingleElementOnTemplateplaceholder["element"] == $objOneElementToCheck->getStrElement()) { $bitOneInstalled = true; } } if (!$bitOneInstalled) { //So, the Row for a new element $strActions = $this->objToolkit->listButton(class_link::getLinkAdmin("pages_content", "new", "&placeholder=" . $arrOneElementOnTemplate["placeholder"] . "&element=" . $arrSingleElementOnTemplateplaceholder["element"] . "&systemid=" . $this->getSystemid(), "", $this->getLang("element_anlegen"), "icon_new")); $strOutputAtPlaceholder .= $this->objToolkit->genericAdminList("", $objOneElementInSystem->getStrDisplayName(), "", $strActions, $intI++); } } } } } if ((int) uniStrlen($strOutputAtPlaceholder) > 0) { $arrSinglePlaceholder = explode("_", $arrOneElementOnTemplate["placeholder"]); if (count($arrSinglePlaceholder) == 2) { $strOutputAtPlaceholder .= $this->objToolkit->formHeadline($arrSinglePlaceholder[0]); } $strListId = generateSystemid(); $strReturn .= $this->objToolkit->dragableListHeader($strListId, true); $strReturn .= $strOutputAtPlaceholder; $strReturn .= $this->objToolkit->dragableListFooter($strListId); } } } else { $strReturn .= $this->getLang("element_liste_leer"); } //if there are any page-elements remaining, print a warning and print the elements row if (count($arrElementsOnPage) > 0) { $strReturn .= $this->objToolkit->divider(); $strReturn .= $this->objToolkit->warningBox($this->getLang("warning_elementsremaining")); $strReturn .= $this->objToolkit->listHeader(); //minimized actions now, plz. this ain't being a real element anymore! foreach ($arrElementsOnPage as $objOneElement) { $strActions = ""; $strActions .= $this->objToolkit->listDeleteButton($objOneElement->getStrDisplayName(), $this->getLang("element_loeschen_frage"), class_link::getLinkAdminHref("pages_content", "deleteElementFinal", "&systemid=" . $objOneElement->getSystemid() . ($this->getParam("pe") == "" ? "" : "&peClose=" . $this->getParam("pe")))); //Put all Output together $strReturn .= $this->objToolkit->genericAdminList("", $objOneElement->getStrDisplayName() . $this->getLang("placeholder") . $objOneElement->getStrPlaceholder(), "", $strActions, $intI++); } $strReturn .= $this->objToolkit->listFooter(); } $strReturn .= $this->objToolkit->getTableOfContents("h2"); return $strReturn; }
/** * Unicode-safe string trimmer * * @param string $strString string to wrap * @param int $intLength * @param string $strAdd string to add after wrapped string * * @return string */ function uniStrTrim($strString, $intLength, $strAdd = "…") { if ($intLength > 0 && uniStrlen($strString) > $intLength) { return trim(uniSubstr($strString, 0, $intLength)) . $strAdd; } else { return $strString; } }
/** * Builds a string of concatenated systemids. Those ids are the systemids of the page-points * being active. The delimiter is the ','-char. * Ths ids are sorted top to bottom. So the first one is current active one, * the last one is the last parent being active, so in most cases the node on the * first level of the navigation * * @param class_module_navigation_point $objActivePoint * * @return string */ private function getActiveIdStack($objActivePoint) { //Loading the points above $objTemp = $objActivePoint; if ($objTemp == null) { //Special case: no active point found --> load the first level inactive return $this->arrElementData["navigation_id"]; } $arrStacks = array(); foreach ($this->arrTempNodes[$this->arrElementData["navigation_id"]]["subnodes"] as $arrOneNode) { $strStack = $this->createActiveIdStackHelper($objActivePoint, $arrOneNode); if ($strStack != null) { $arrStacks[] = $strStack . "," . $this->arrElementData["navigation_id"]; } } $strStack = ""; //search the deepest stack foreach ($arrStacks as $strOneStack) { if (uniStrlen($strOneStack) > uniStrlen($strStack)) { $strStack = $strOneStack; } } return $strStack; }
/** * @param string $strRecordComment * @return void */ public function setStrRecordComment($strRecordComment) { if (uniStrlen($strRecordComment) > 254) { $strRecordComment = uniStrTrim($strRecordComment, 250); } $this->strRecordComment = $strRecordComment; }
/** * Validates the form data provided by the user * * @return bool */ private function validateForm() { $bitReturn = true; $strTemplateId = $this->objTemplate->readTemplate("/module_postacomment/" . $this->arrElementData["char1"], "validation_error_row"); if (uniStrlen($this->getParam("comment_name")) < 2) { $bitReturn = false; $this->strErrors .= $this->objTemplate->fillTemplate(array("error" => $this->getLang("validation_name")), $strTemplateId); } if (uniStrlen($this->getParam("comment_message")) < 2) { $bitReturn = false; $this->strErrors .= $this->objTemplate->fillTemplate(array("error" => $this->getLang("validation_message")), $strTemplateId); } if ($this->objSession->getCaptchaCode() != $this->getParam("form_captcha") || $this->getParam("form_captcha") == "") { $bitReturn = false; $this->strErrors .= $this->objTemplate->fillTemplate(array("error" => $this->getLang("validation_code")), $strTemplateId); } return $bitReturn; }
/** * Validates the submitted data * * @return bool */ private function validateData() { $bitReturn = true; //Check captachcode if ($this->getParam("gb_post_captcha") != $this->objSession->getCaptchaCode() || $this->getParam("gb_post_captcha") == "") { $bitReturn = false; } //Check mailaddress $objMailValidator = new class_email_validator(); if (!$objMailValidator->validate($this->getParam("gb_post_email"))) { $this->arrErrors[] = $this->getLang("insert_error_email"); $bitReturn = false; } if (uniStrlen($this->getParam("gb_post_name")) == 0) { $this->arrErrors[] = $this->getLang("insert_error_name"); $bitReturn = false; } if (uniStrlen($this->getParam("gb_post_text")) == 0) { $this->arrErrors[] = $this->getLang("insert_error_post"); $bitReturn = false; } //if there ain't any errors, update texts if ($bitReturn) { $this->setParam("gb_post_name", htmlToString($this->getParam("gb_post_name"))); $this->setParam("gb_post_email", htmlToString($this->getParam("gb_post_email"))); $this->setParam("gb_post_text", htmlToString($this->getParam("gb_post_text"))); } return $bitReturn; }
public function stringToPlaceholder($strText) { $strReturn = ""; $strLastChar = ""; for ($i = 0; $i < uniStrlen($strText); $i++) { $strChar = uniSubstr($strText, $i, 1); $strCharLower = uniStrtolower($strChar); if ($i > 0 && $strChar != $strCharLower && $strLastChar != "_") { $strReturn .= "_" . $strCharLower; } else { $strReturn .= $strCharLower; } $strLastChar = $strChar; } return $strReturn; }
/** * Crreates an object of type '$strClassType'. * Only properties which are annotated with @var will be considered * * @param string $strClassType - the name of the class as a string * @param string $strParentId - the parent id of the object to be created * @param array $arrExcludeFillProperty - array of poperty names which will not be set * @param array $arrPropertyValues - assoziative array which has as key the property name and as value the to be set for the property * @param boolean $bitAutofillProperties - if true all properties which have annotation @tablecolumn will be filled with random values * * @return class_model */ protected function createObject($strClassType, $strParentId, array $arrExcludeFillProperty = array(), array $arrPropertyValues = array(), $bitAutofillProperties = true) { //get properties with an tablecolumn annotation $objObject = new $strClassType(); $objReflection = new class_reflection($strClassType); $arrProperties = $objReflection->getPropertiesWithAnnotation(class_orm_base::STR_ANNOTATION_TABLECOLUMN); $arrProperties = array_merge($objReflection->getPropertiesWithAnnotation(class_orm_base::STR_ANNOTATION_OBJECTLIST), $arrProperties); //exclude class_root properties $objRootReflection = new class_reflection("class_root"); $arrExcludeFillProperty = array_merge($arrExcludeFillProperty, array_keys($objRootReflection->getPropertiesWithAnnotation(class_orm_base::STR_ANNOTATION_TABLECOLUMN))); foreach ($arrProperties as $strPropName => $strValue) { //Exclude properties to be set if (in_array($strPropName, $arrExcludeFillProperty)) { continue; } //Set properties from array $arrPropertyValues if (array_key_exists($strPropName, $arrPropertyValues)) { $strSetterMethod = $objReflection->getSetter($strPropName); if ($strSetterMethod !== null) { $objValue = $arrPropertyValues[$strPropName]; $objObject->{$strSetterMethod}($objValue); continue; } } //check if the property is annotated with @tablecolumn if ($bitAutofillProperties) { if ($objReflection->hasPropertyAnnotation($strPropName, class_orm_base::STR_ANNOTATION_TABLECOLUMN)) { $strSetterMethod = $objReflection->getSetter($strPropName); if ($strSetterMethod !== null) { //determine the field type $strDataType = $objReflection->getAnnotationValueForProperty($strPropName, "@var"); $strFieldType = $objReflection->getAnnotationValueForProperty($strPropName, "@fieldType"); $objMethodValue = null; if ($strDataType == "string") { if ($strFieldType == "text" || $strFieldType == "textarea") { $objMethodValue = $strPropName . "_" . $objObject->getStrSystemid(); if (uniStrlen($objMethodValue) > 10) { $objMethodValue = uniStrTrim($objMethodValue, 10, ""); } } } else { if ($strDataType == "int" || $strDataType == "numeric") { if ($strFieldType != "dropdown") { $objMethodValue = 1; } } else { if ($strDataType == "class_date") { $objMethodValue = new class_date(); } else { if ($strDataType == "bool") { $objMethodValue = false; } else { continue; //continue with foreach } } } } $objObject->{$strSetterMethod}($objMethodValue); } } } } //save it $objObject->updateObjectToDb($strParentId); return $objObject; }