exec_SELECTgetRows('uid, tx_semantic_category', 'tt_content', sprintf("pid = %d && tx_semantic_category != 0", $GLOBALS["TSFE"]->id)); if($rows){ $showCategories = tx_semantic_brain::getCategories4Output(false); $neutralElements; $semElement; $hasSemanticContent = false; $semCategory = array(); $semElements = array(); if($showCategories){ foreach($showCategories as $key => $value){ $semCategory[] = $key; } } if(count($semCategory) == 0) $semCategory[0] = -1; $GLOBALS['TSFE']->register['semanticid'] = $semCategory[0]; foreach ($rows as $row) { if($row["tx_semantic_category"]){ $hasSemanticContent = true; if($row["tx_semantic_category"] == -1) $neutralElements[] = $row; else if($row["tx_semantic_category"] == $semCategory[0]) $semElement = $row; else{ $semElements[] = $row['uid']; } } } if($semElement){ if($neutralElements){ foreach($neutralElements as $neutralElement){ $semElements[] = $neutralElement['uid']; } } } if($hasSemanticContent){ $GLOBALS['TSFE']->register['semantic'] = count($semElements) ? ' uid NOT IN ('.implode(",", $semElements).')' : 'true'; } } //$statistik = self::getStatistik($userData); try{ mcrypt_generic_deinit($this->td); mcrypt_module_close($this->td); }catch(\Exception $e){} //return $statistik; } function getUserData(){ if($_COOKIE["dpsmtc"]){ if(strpos($_COOKIE["dpsmtc"], "%") !== false){ $_COOKIE["dpsmtc"] = urldecode($_COOKIE["dpsmtc"]); } if(strpos($_COOKIE["dpsmtc"], ":") !== false){ $userData = unserialize($_COOKIE["dpsmtc"]); }else{ $userData = unserialize($this->decrypt($_COOKIE["dpsmtc"])); } } else $userData = array(); return $userData; } function saveUserData($data){ $dataCrypt = $this->encrypt(serialize($data)); @setcookie("dpsmtc", $dataCrypt, intval(time()+631138519), '/'); } function getCurrentPageCat(){ for($i = count($GLOBALS["TSFE"]->rootLine)-1; $i >= 0; $i--){ $currentRow = $GLOBALS["TSFE"]->rootLine[$i]; $semanticCat = $currentRow["tx_semantic_category"]; if($semanticCat){ return $semanticCat; } } } function getCategoryData($id, $field="", $all=false, $orderby=""){ if($all == false){ $where = 'uid = "'.$id.'"'; }else{ $where = ""; } $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*','tx_dpsemanticsystem_domain_model_semanticcategory', $where, '', $orderby); if($all){ $returnArray = array(); if(mysqli_num_rows($res)){ while($row = mysqli_fetch_assoc($res)){ $returnArray[] = $row; } } return $returnArray; } $row = mysqli_fetch_assoc($res); if($field) return $row[$field]; return $row; } function saveTempDataToBrain($data){ if($data["temp"]["data"]){ $newData = self::calculateBrain($data["brain"], $data["temp"]); $data["brain"]["data"] = $newData; unset($data["temp"]["data"]); } return $data; } function calculateBrain($brainData, $tempData){ $newData = array(); $categoryData = self::getCategoryData(0, "", true); if(!$tempData["data"]) { return $brainData["data"]; } $tempData["data"] = self::calculatePercent($tempData["data"], false); if(!$brainData["data"]){ return self::fillArrayWithCategory($tempData["data"]); } $multiplikator = ($tempData["date"]-$brainData["date"])/8640000; if($multiplikator < 0.1) $multiplikator = 0.1; if($multiplikator > 3.65) $multiplikator = 3.65; $divisor = 1+$multiplikator; foreach ($categoryData as $value){ $key = intval($value["uid"]); if($tempData["data"][$key]){ $newData[$key] = $brainData["data"][$key] + ($tempData["data"][$key]*$multiplikator); }else if($brainData["data"][$key]){ $newData[$key] = $brainData["data"][$key]; }else{ $newData[$key] = 0; } } foreach ($newData as $key => $value){ $newData[$key] = $newData[$key] / $divisor; } return $newData; } function calculatePercent($data, $round=true){ $allClicks = array_sum($data); foreach ($data as $key => $value){ $percent = ($value/$allClicks * 100); if($round) $returnArray[$key] = round($percent , 2); else $returnArray[$key] = $percent; } return $returnArray; } function fillArrayWithCategory($data){ $categoryData = self::getCategoryData(0, "", true, "rand()"); foreach ($categoryData as $value){ $key = intval($value["uid"]); if(!$data[$key]) $data[$key] = 0; } return $data; } /* AUSGABE */ function getCategories4Output($shuffle=true){ $userData = self::getUserData(); $brainData = $userData["brain"]; $tempData = $userData["temp"]; $data = self::calculateBrain($brainData, $tempData); if(count($data)){ arsort($data); $returnArray = $data; }else if($shuffle){ $categoryData = self::getCategoryData(0, "", true); shuffle($categoryData); foreach ($categoryData as $value){ $returnArray[$value["uid"]] = 0; } } return $returnArray; } function getStatistik(){ $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['dp_semanticsystem']); if(!$extConf["debug"]) return; if(!$GLOBALS['TSFE']->beUserLogin) return; if($GLOBALS["BE_USER"]->user["username"] != "dp") return; $data = self::getUserData(); $output = " "; $hilightColor = "A7C414"; $output .= '
'; $output .= 'Semantic Debugausgabe anzeigen/verstecken'; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $categoryArray = self::getCategories4Output(); if($categoryArray && ($data["brain"]["data"] || $data["temp"]["data"])){ $output .= ''; $output .= ''; $output .= ''; $count = 0; foreach ($categoryArray as $key => $value){ if($count < 7) $dataXMLEntries .= ""; $count++; } $output .= ''; $output .= ''; $output .= ''; } $output .= ''; $output .= ''; if($data["brain"]["date"]) $output .= ''; else $output .= ''; $output .= ''; if($data["brain"]["data"]){ arsort($data["brain"]["data"]); foreach ($data["brain"]["data"] as $key => $value){ $output .= ''; $output .= ''; $output .= ''; $output .= ''; } }else{ $output .= ''; $output .= ''; $output .= ''; } $output .= ''; $output .= ''; if($data["temp"]["date"]) $output .= ''; else $output .= ''; $output .= ''; if($data["temp"]["data"]){ arsort($data["temp"]["data"]); foreach ($data["temp"]["data"] as $key => $value){ $output .= ''; $output .= ''; $output .= ''; $output .= ''; } }else{ $output .= ''; $output .= ''; $output .= ''; } $output .= ''; $output .= ''; $output .= '
'; /* FLASH CHART */ $dataXML = "$dataXMLEntries"; $xmlFile = fopen("typo3conf/ext/dp_semanticsystem/res/flashchart.xml", "w"); fwrite($xmlFile, $dataXML); fclose($xmlFile); $GLOBALS['TSFE']->additionalHeaderData[$this->prefixId] .= ''; $GLOBALS['TSFE']->additionalHeaderData[$this->prefixId] .= ''; return $output; } /** * Generates a hex string of $src * @param $src string String to be encrypted * @return void */ function encrypt($src) { $this->initCrypt(); srand(( double) microtime() * 1000000); $this->iv = mcrypt_create_iv($this->ks, MCRYPT_RAND); mcrypt_generic_init($this->td, $this->salt, $this->iv); $tmpStr = mcrypt_generic($this->td, $src); return bin2hex($this->iv.$tmpStr); } /** * Decrypts a hex string * @param $src string String to be decrypted * @return void */ function decrypt($src) { $this->initCrypt(); $corrected = preg_replace("[^0-9a-fA-F]", "", $src); $binenc = pack("H".strlen($corrected), $corrected); $this->iv = substr($binenc, 0, $this->ks); $binstr = substr($binenc, $this->ks); mcrypt_generic_init($this->td, $this->salt, $this->iv); $decrypted = mdecrypt_generic($this->td, $binstr); return trim($decrypted); } function initCrypt(){ if($this->td) return; $this->td = mcrypt_module_open('rijndael-256', '', 'ofb', ''); $this->ks = mcrypt_enc_get_key_size($this->td); $this->salt = substr(md5("!Doppelpack:66:Semantic!"), 0, $this->ks); } } ?>exec_SELECTgetRows('uid, tx_semantic_category', 'tt_content', sprintf("pid = %d && tx_semantic_category != 0", $GLOBALS["TSFE"]->id)); if($rows){ $showCategories = tx_semantic_brain::getCategories4Output(false); $neutralElements; $semElement; $hasSemanticContent = false; $semCategory = array(); $semElements = array(); if($showCategories){ foreach($showCategories as $key => $value){ $semCategory[] = $key; } } if(count($semCategory) == 0) $semCategory[0] = -1; $GLOBALS['TSFE']->register['semanticid'] = $semCategory[0]; foreach ($rows as $row) { if($row["tx_semantic_category"]){ $hasSemanticContent = true; if($row["tx_semantic_category"] == -1) $neutralElements[] = $row; else if($row["tx_semantic_category"] == $semCategory[0]) $semElement = $row; else{ $semElements[] = $row['uid']; } } } if($semElement){ if($neutralElements){ foreach($neutralElements as $neutralElement){ $semElements[] = $neutralElement['uid']; } } } if($hasSemanticContent){ $GLOBALS['TSFE']->register['semantic'] = count($semElements) ? ' uid NOT IN ('.implode(",", $semElements).')' : 'true'; } } //$statistik = self::getStatistik($userData); try{ mcrypt_generic_deinit($this->td); mcrypt_module_close($this->td); }catch(\Exception $e){} //return $statistik; } function getUserData(){ if($_COOKIE["dpsmtc"]){ if(strpos($_COOKIE["dpsmtc"], "%") !== false){ $_COOKIE["dpsmtc"] = urldecode($_COOKIE["dpsmtc"]); } if(strpos($_COOKIE["dpsmtc"], ":") !== false){ $userData = unserialize($_COOKIE["dpsmtc"]); }else{ $userData = unserialize($this->decrypt($_COOKIE["dpsmtc"])); } } else $userData = array(); return $userData; } function saveUserData($data){ $dataCrypt = $this->encrypt(serialize($data)); @setcookie("dpsmtc", $dataCrypt, intval(time()+631138519), '/'); } function getCurrentPageCat(){ for($i = count($GLOBALS["TSFE"]->rootLine)-1; $i >= 0; $i--){ $currentRow = $GLOBALS["TSFE"]->rootLine[$i]; $semanticCat = $currentRow["tx_semantic_category"]; if($semanticCat){ return $semanticCat; } } } function getCategoryData($id, $field="", $all=false, $orderby=""){ if($all == false){ $where = 'uid = "'.$id.'"'; }else{ $where = ""; } $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*','tx_dpsemanticsystem_domain_model_semanticcategory', $where, '', $orderby); if($all){ $returnArray = array(); if(mysqli_num_rows($res)){ while($row = mysqli_fetch_assoc($res)){ $returnArray[] = $row; } } return $returnArray; } $row = mysqli_fetch_assoc($res); if($field) return $row[$field]; return $row; } function saveTempDataToBrain($data){ if($data["temp"]["data"]){ $newData = self::calculateBrain($data["brain"], $data["temp"]); $data["brain"]["data"] = $newData; unset($data["temp"]["data"]); } return $data; } function calculateBrain($brainData, $tempData){ $newData = array(); $categoryData = self::getCategoryData(0, "", true); if(!$tempData["data"]) { return $brainData["data"]; } $tempData["data"] = self::calculatePercent($tempData["data"], false); if(!$brainData["data"]){ return self::fillArrayWithCategory($tempData["data"]); } $multiplikator = ($tempData["date"]-$brainData["date"])/8640000; if($multiplikator < 0.1) $multiplikator = 0.1; if($multiplikator > 3.65) $multiplikator = 3.65; $divisor = 1+$multiplikator; foreach ($categoryData as $value){ $key = intval($value["uid"]); if($tempData["data"][$key]){ $newData[$key] = $brainData["data"][$key] + ($tempData["data"][$key]*$multiplikator); }else if($brainData["data"][$key]){ $newData[$key] = $brainData["data"][$key]; }else{ $newData[$key] = 0; } } foreach ($newData as $key => $value){ $newData[$key] = $newData[$key] / $divisor; } return $newData; } function calculatePercent($data, $round=true){ $allClicks = array_sum($data); foreach ($data as $key => $value){ $percent = ($value/$allClicks * 100); if($round) $returnArray[$key] = round($percent , 2); else $returnArray[$key] = $percent; } return $returnArray; } function fillArrayWithCategory($data){ $categoryData = self::getCategoryData(0, "", true, "rand()"); foreach ($categoryData as $value){ $key = intval($value["uid"]); if(!$data[$key]) $data[$key] = 0; } return $data; } /* AUSGABE */ function getCategories4Output($shuffle=true){ $userData = self::getUserData(); $brainData = $userData["brain"]; $tempData = $userData["temp"]; $data = self::calculateBrain($brainData, $tempData); if(count($data)){ arsort($data); $returnArray = $data; }else if($shuffle){ $categoryData = self::getCategoryData(0, "", true); shuffle($categoryData); foreach ($categoryData as $value){ $returnArray[$value["uid"]] = 0; } } return $returnArray; } function getStatistik(){ $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['dp_semanticsystem']); if(!$extConf["debug"]) return; if(!$GLOBALS['TSFE']->beUserLogin) return; if($GLOBALS["BE_USER"]->user["username"] != "dp") return; $data = self::getUserData(); $output = " "; $hilightColor = "A7C414"; $output .= '
'; $output .= 'Semantic Debugausgabe anzeigen/verstecken'; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $categoryArray = self::getCategories4Output(); if($categoryArray && ($data["brain"]["data"] || $data["temp"]["data"])){ $output .= ''; $output .= ''; $output .= ''; $count = 0; foreach ($categoryArray as $key => $value){ if($count < 7) $dataXMLEntries .= ""; $count++; } $output .= ''; $output .= ''; $output .= ''; } $output .= ''; $output .= ''; if($data["brain"]["date"]) $output .= ''; else $output .= ''; $output .= ''; if($data["brain"]["data"]){ arsort($data["brain"]["data"]); foreach ($data["brain"]["data"] as $key => $value){ $output .= ''; $output .= ''; $output .= ''; $output .= ''; } }else{ $output .= ''; $output .= ''; $output .= ''; } $output .= ''; $output .= ''; if($data["temp"]["date"]) $output .= ''; else $output .= ''; $output .= ''; if($data["temp"]["data"]){ arsort($data["temp"]["data"]); foreach ($data["temp"]["data"] as $key => $value){ $output .= ''; $output .= ''; $output .= ''; $output .= ''; } }else{ $output .= ''; $output .= ''; $output .= ''; } $output .= ''; $output .= ''; $output .= '
'; /* FLASH CHART */ $dataXML = "$dataXMLEntries"; $xmlFile = fopen("typo3conf/ext/dp_semanticsystem/res/flashchart.xml", "w"); fwrite($xmlFile, $dataXML); fclose($xmlFile); $GLOBALS['TSFE']->additionalHeaderData[$this->prefixId] .= ''; $GLOBALS['TSFE']->additionalHeaderData[$this->prefixId] .= ''; return $output; } /** * Generates a hex string of $src * @param $src string String to be encrypted * @return void */ function encrypt($src) { $this->initCrypt(); srand(( double) microtime() * 1000000); $this->iv = mcrypt_create_iv($this->ks, MCRYPT_RAND); mcrypt_generic_init($this->td, $this->salt, $this->iv); $tmpStr = mcrypt_generic($this->td, $src); return bin2hex($this->iv.$tmpStr); } /** * Decrypts a hex string * @param $src string String to be decrypted * @return void */ function decrypt($src) { $this->initCrypt(); $corrected = preg_replace("[^0-9a-fA-F]", "", $src); $binenc = pack("H".strlen($corrected), $corrected); $this->iv = substr($binenc, 0, $this->ks); $binstr = substr($binenc, $this->ks); mcrypt_generic_init($this->td, $this->salt, $this->iv); $decrypted = mdecrypt_generic($this->td, $binstr); return trim($decrypted); } function initCrypt(){ if($this->td) return; $this->td = mcrypt_module_open('rijndael-256', '', 'ofb', ''); $this->ks = mcrypt_enc_get_key_size($this->td); $this->salt = substr(md5("!Doppelpack:66:Semantic!"), 0, $this->ks); } } ?> Anmeldung Botschafter Club
  • Italiano
  • English
  • Deutsch

Herzlich Willkommen im Botschafter Club!

Bitte geben Sie Ihre VIP-Card Nummer ein, um zu den aktuellen Botschafterangeboten zu kommen.
Online Buchen
Anfragen