diff --git a/conlite/external/frontend/data/config/.gitignore b/conlite/external/frontend/data/config/.gitignore new file mode 100644 index 0000000..5493b99 --- /dev/null +++ b/conlite/external/frontend/data/config/.gitignore @@ -0,0 +1,2 @@ +/local +/localhost diff --git a/conlite/external/frontend/data/config/production/.keep b/conlite/external/frontend/data/config/production/.keep new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/conlite/external/frontend/data/config/production/.keep @@ -0,0 +1 @@ + diff --git a/conlite/external/frontend/data/config/production/config.php b/conlite/external/frontend/data/config/production/config.php new file mode 100644 index 0000000..f987795 --- /dev/null +++ b/conlite/external/frontend/data/config/production/config.php @@ -0,0 +1,52 @@ + + * @license http://www.contenido.org/license/LIZENZ.txt + * @link http://www.4fb.de + * @link http://www.contenido.org + * + * + * + * {@internal + * created unknown + * modified 2008-07-03, bilal arslan, added security fix + * + * $Id$: + * }} + * + */ + +if(!defined('CON_FRAMEWORK')) { + die('Illegal call'); +} + + +// Relative path to contenido directory, for all inclusions, in most cases: "../contenido/" +$contenido_path = "../conlite/"; + +// If language isn't specified, set this client and language (ID) +$load_lang = "1"; +$load_client = "1"; + +/* Various debugging options */ +$frontend_debug["container_display"] = false; +$frontend_debug["module_display"] = false; +$frontend_debug["module_timing"] = false; +$frontend_debug["module_timing_summary"]= false; + +/* Set to 1 to brute-force module regeneration */ +$force = 0; +?> diff --git a/conlite/external/frontend/environment.php b/conlite/external/frontend/environment.php new file mode 100644 index 0000000..180842c --- /dev/null +++ b/conlite/external/frontend/environment.php @@ -0,0 +1,19 @@ + + * + * $Id$ + */ + +class Contenido_NavMain_Util { + /** + * Recursive Loop over all (sub)categories. + * Each level will be assigned a css class navmainStandardLevel_x + * + * @param Contenido_Category $oCategory + * @param Contenido_FrontendNavigation $oFrontendNavigation + * @param Template $oTpl + * @param string $sUrlStyle + * @param array $aCfg + * @param int $iLang + * @param array $aLevelInfo Information for marking active cat per levels + * @param array $aDepthInfo Info on level depth / where to stop. Format: array(iCurrentLoopCount, iMaxLoopCount) + * @return void + */ + public static function loopCats(Contenido_Category $oCategory, Contenido_FrontendNavigation $oFrontendNavigation, Template $oTpl, array $aCfg, $iLang, array $aLevelInfo, $iCurrentPageIdcat, array $aDepthInfo = array()) { + $aDepthInfo[0] = isset($aDepthInfo[0]) ? $aDepthInfo[0] + 1 : 1; + $aDepthInfo[1] = isset($aDepthInfo[1]) ? $aDepthInfo[1] : 1; + // display current item + $iItemLevel = $oFrontendNavigation->getLevel($oCategory->getIdCat()); + if (!isset($aLevelInfo[$oCategory->getIdCat()])) { + $aLevelInfo[$oCategory->getIdCat()] = array(); + } + $oCurrentSubcategories = $oFrontendNavigation->getSubCategories($oCategory->getIdCat()); + $aLevelInfo[$oCategory->getIdCat()]['has_children'] = $oCurrentSubcategories->count() > 0; + $aLevelInfo[$oCategory->getIdCat()]['first_child_item'] = -1; + $aLevelInfo[$oCategory->getIdCat()]['last_child_item'] = -1; + $bMarkActive = $oCategory->getIdCat() == $iCurrentPageIdcat || $oFrontendNavigation->isInPathToRoot($oCategory->getIdCat(), $iCurrentPageIdcat); + if ($oCurrentSubcategories->count() > 0) { + $aLevelInfo[$oCategory->getIdCat()]['first_child_item'] = $oCurrentSubcategories[0]->getIdCat(); + $aLevelInfo[$oCategory->getIdCat()]['last_child_item'] = $oCurrentSubcategories[$oCurrentSubcategories->count()-1]->getIdCat(); + } + // this is just for sample client - modify to your needs! + if (($aCfg['url_builder']['name'] == 'front_content') || ($aCfg['url_builder']['name'] == 'MR')) { + $aParams = array('lang' => $iLang, 'idcat' => $oCategory->getIdCat()); + } else { + $aParams = array('a' => $oCategory->getIdCat(), + 'idcat' => $oCategory->getIdCat(), // needed to build category path + 'lang' => $iLang, // needed to build category path + 'level' => 1); // needed to build category path + } + // fill template with values + $oTpl->set('d', 'name', $oCategory->getCategoryLanguage()->getName()); + $oTpl->set('d', 'css_level', $iItemLevel); + $oTpl->set('d', 'css_first_item', ($aLevelInfo[$oCategory->getIdParent()]['first_child_item'] == $oCategory->getIdCat() ? ' first' : '')); + $oTpl->set('d', 'css_last_item', ($aLevelInfo[$oCategory->getIdParent()]['last_child_item'] == $oCategory->getIdCat() ? ' last' : '')); + $oTpl->set('d', 'css_active_item', ($bMarkActive === true ? ' active' : '')); + try { + $oTpl->set('d', 'url', Contenido_Url::getInstance()->build($aParams)); + } catch (InvalidArgumentException $e) { + $oTpl->set('d', 'url', '#'); + } + $oTpl->next(); + // continue until max level depth + if ($aDepthInfo[1] > $aDepthInfo[0]) { + // check if current item has sub-items to be displayed + $bShowFollowUps = ($oCategory->getIdCat() == $iCurrentPageIdcat || $oFrontendNavigation->isInPathToRoot($oCategory->getIdCat(), $iCurrentPageIdcat)) + ? true : false; + if ($bShowFollowUps === true && $oCurrentSubcategories->count() > 0) { + $oSubCategories = $oCurrentSubcategories; + foreach ($oSubCategories as $oSubCategory) { + self::loopCats($oSubCategory, $oFrontendNavigation, $oTpl, $aCfg, $iLang, $aLevelInfo, $iCurrentPageIdcat, $aDepthInfo); + } + } + } + } +} +?> \ No newline at end of file diff --git a/conlite/external/frontend/includes/Util/Modules/Contenido_Sitemap_Util.class.php b/conlite/external/frontend/includes/Util/Modules/Contenido_Sitemap_Util.class.php new file mode 100644 index 0000000..f04de2b --- /dev/null +++ b/conlite/external/frontend/includes/Util/Modules/Contenido_Sitemap_Util.class.php @@ -0,0 +1,66 @@ + + * + * $Id$ + */ +class Contenido_Sitemap_Util { + /** + * Recursive Loop over all (sub)categories. + * Each level will be assigned a css class sitemapStandardLevel_x + * + * @param Contenido_Category $oCategory + * @param Contenido_FrontendNavigation $oFrontendNavigation + * @param Template $oTpl + * @param string $sUrlStyle + * @param array $aCfg + * @param int $iLang + * @param array $aDepthInfo Info on level depth / where to stop. Format: array(iCurrentLoopCount, iMaxLoopCount) + * @return void + */ + public static function loopCats(Contenido_Category $oCategory, Contenido_FrontendNavigation $oFrontendNavigation, Template $oTpl, $sUrlStyle, array $aCfg, $iLang, array $aDepthInfo = array()) { + $aDepthInfo[0] = isset($aDepthInfo[0]) ? $aDepthInfo[0] + 1 : 1; + $aDepthInfo[1] = isset($aDepthInfo[1]) ? $aDepthInfo[1] : 1; + // display current item + $iItemLevel = $oFrontendNavigation->getLevel($oCategory->getIdCat()); + // this is just for sample client - modify to your needs! + if (($aCfg['url_builder']['name'] == 'front_content') || ($aCfg['url_builder']['name'] == 'MR')) { + $aParams = array('lang' => $iLang, 'idcat' => $oCategory->getIdCat()); + } else { + $aParams = array('a' => $oCategory->getIdCat(), + 'idcat' => $oCategory->getIdCat(), // needed to build category path + 'lang' => $iLang, // needed to build category path + 'level' => 1); // needed to build category path + } + // fill template with values + $oTpl->set('d', 'name', $oCategory->getCategoryLanguage()->getName()); + $oTpl->set('d', 'css_level', $iItemLevel); + try { + $oTpl->set('d', 'url', Contenido_Url::getInstance()->build($aParams)); + } catch (InvalidArgumentException $e) { + $oTpl->set('d', 'url', '#'); + } + $oTpl->next(); + // continue until max level depth + if ($aDepthInfo[1] > $aDepthInfo[0]) { + // check if current item has sub-items + $oSubCategories = $oFrontendNavigation->getSubCategories($oCategory->getIdCat()); + if ($oSubCategories->count() > 0) { + foreach ($oSubCategories as $oSubCategory) { + self::loopCats($oSubCategory, $oFrontendNavigation, $oTpl, $sUrlStyle, $aCfg, $iLang, $aDepthInfo); + } + } + } + } +} +?> \ No newline at end of file diff --git a/conlite/external/frontend/includes/functions.include.php b/conlite/external/frontend/includes/functions.include.php new file mode 100644 index 0000000..f611b9c --- /dev/null +++ b/conlite/external/frontend/includes/functions.include.php @@ -0,0 +1,40 @@ + + * @license http://www.contenido.org/license/LIZENZ.txt + * @link http://www.4fb.de + * @link http://www.contenido.org + * + * $Id$: + */ + +if(!defined('CON_FRAMEWORK')) { + die('Illegal call'); +} + +function getTeaserImage ($text,$return = 'path') { + $regEx = "/]*?>.*?/i"; + $match = array(); + preg_match($regEx, $text, $match); + + $regEx = "/(src)(=)(['\"]?)([^\"']*)(['\"]?)/i"; + $img = array(); + preg_match($regEx, $match[0], $img); + + if ($return == 'path') { + return $img[4]; + } else { + return $match[0]; + } +} +?> \ No newline at end of file diff --git a/conlite/external/frontend/includes/functions.navigation.php b/conlite/external/frontend/includes/functions.navigation.php new file mode 100644 index 0000000..066a31d --- /dev/null +++ b/conlite/external/frontend/includes/functions.navigation.php @@ -0,0 +1,521 @@ + + * @license http://www.contenido.org/license/LIZENZ.txt + * @link http://www.4fb.de + * @link http://www.contenido.org + * + * $Id$: + */ +if (!defined('CON_FRAMEWORK')) { + die('Illegal call'); +} + +// create Navigation array for one level +function createNavigationArray($start_id, $db) { + global $user, $cfg, $client, $lang, $auth; + + $navigation = array(); + $FrontendPermissionCollection = new FrontendPermissionCollection; + +// SECURITY-FIX + $sql = "SELECT + A.idcat, + C.name, + C.public, + C.idcatlang + FROM + " . $cfg["tab"]["cat_tree"] . " AS A, + " . $cfg["tab"]["cat"] . " AS B, + " . $cfg["tab"]["cat_lang"] . " AS C + WHERE + A.idcat = B.idcat AND + B.idcat = C.idcat AND + B.idclient = '" . Contenido_Security::escapeDB($client, $db) . "' AND + C.idlang = '" . Contenido_Security::escapeDB($lang, $db) . "' AND + C.visible = '1' AND + B.parentid = '" . Contenido_Security::escapeDB($start_id, $db) . "' + ORDER BY + A.idtree"; + $db->query($sql); + + while ($db->next_record()) { + $cat_id = $db->f("idcat"); + $cat_idlang = $db->f("idcatlang"); + $visible = false; + if ($db->f("public") != 0) { + $visible = true; + } elseif (($auth->auth['uid'] != '') && ($auth->auth['uid'] != 'nobody')) { + $FrontendGroupMemberCollection = new FrontendGroupMemberCollection; + + $FrontendGroupMemberCollection->setWhere("idfrontenduser", $auth->auth['uid']); + $FrontendGroupMemberCollection->query(); + $groups = array(); + while ($member = $FrontendGroupMemberCollection->next()) { + $groups[] = $member->get("idfrontendgroup"); + } + } + if (count($groups) > 0) { + for ($i = 0; $i < count($groups); $i++) { + if ($FrontendPermissionCollection->checkPerm($groups[$i], 'category', 'access', $cat_idlang, true)) { + $visible = true; + } + } + } + if ($visible) { + $navigation[$cat_id] = array("idcat" => $cat_id, + "name" => $db->f("name"), + "target" => '_self', # you can not call getTarget($cat_id, &$db) at this point with the same db instance! + "public" => $db->f("public")); + } + } // end while + + $db->free(); + + return $navigation; +} + +/** + * Return target of a given category id + * + * @deprecated + */ +function getTarget($cat_id, $db) { + global $cfg, $client, $lang; + +// SECURITY-FIX + $sql = "SELECT + a.external_redirect AS ext + FROM + " . $cfg["tab"]["art_lang"] . " AS a, + " . $cfg["tab"]["cat_art"] . " AS b, + " . $cfg["tab"]["cat"] . " AS c + WHERE + b.idcat = '" . Contenido_Security::escapeDB($cat_id, $db) . "' AND + c.idclient = '" . Contenido_Security::escapeDB($client, $db) . "' AND + c.idcat = b.idcat AND + a.idart = b.idart AND + a.idlang = '" . Contenido_Security::escapeDB($lang, $db) . "'"; + + $db->query($sql); + $db->next_record(); + + $target = ( $db->f('ext') == 0 ) ? '_self' : '_blank'; + + $db->free(); + return $target; +} + +/** + * Return true if $parentid is parent of $catid + */ +function isParent($parentid, $catid, $db) { + + + global $cfg, $client, $lang; + // SECURITY-FIX + $sql = "SELECT + a.parentid + FROM + " . $cfg["tab"]["cat"] . " AS a, + " . $cfg["tab"]["cat_lang"] . " AS b + WHERE + a.idclient = '" . Contenido_Security::escapeDB($client, $db) . "' AND + b.idlang = '" . Contenido_Security::escapeDB($lang, $db) . "' AND + a.idcat = b.idcat AND + a.idcat = '" . Contenido_Security::escapeDB($catid, $db) . "'"; + + $db->query($sql); + $db->next_record(); + + $pre = $db->f("parentid"); + + if ($parentid == $pre) { + return true; + } else { + return false; + } +} + +function getParent($preid, &$db) { + + global $cfg, $client, $lang; + +// SECURITY-FIX + $sql = "SELECT + a.parentid + FROM + " . $cfg["tab"]["cat"] . " AS a, + " . $cfg["tab"]["cat_lang"] . " AS b + WHERE + a.idclient = '" . Contenido_Security::escapeDB($client, $db) . "' AND + b.idlang = '" . Contenido_Security::escapeDB($lang, $db) . "' AND + a.idcat = b.idcat AND + a.idcat = '" . Contenido_Security::escapeDB($preid, $db) . "'"; + + $db->query($sql); + + if ($db->next_record()) { + return $db->f("parentid"); + } else { + return false; + } +} + +function getLevel($catid, &$db) { + global $cfg, $client, $lang; + +// SECURITY-FIX + $sql = "SELECT + level + FROM + " . $cfg["tab"]["cat_tree"] . " + WHERE + idcat = '" . Contenido_Security::escapeDB($catid, $db) . "' "; + + $db->query($sql); + + if ($db->next_record()) { + return $db->f("level"); + } else { + return false; + } +} + +/** + * Return path of a given category up to a certain level + */ +function getCategoryPath($cat_id, $level, $reverse = true, &$db) { + $root_path = array(); + + array_push($root_path, $cat_id); + + $parent_id = $cat_id; + + while (getLevel($parent_id, $db) != false AND getLevel($parent_id, $db) > $level AND getLevel($parent_id, $db) >= 0) { + + $parent_id = getParent($parent_id, $db); + if ($parent_id != false) { + array_push($root_path, $parent_id); + } + } + + if ($reverse == true) { + $root_path = array_reverse($root_path); + } + + return $root_path; +} + +/** + * Return location string of a given category + */ +function getLocationString($iStartCat, $level, $seperator, $sLinkStyleClass, $sTextStyleClass, $fullweblink = false, $reverse = true, $mod_rewrite = true, $db) { + global $sess, $cfgClient, $client; + + $aCatPath = getCategoryPath($iStartCat, $level, $reverse, $db); + + if (is_array($aCatPath) AND count($aCatPath) > 0) { + $aLocation = array(); + foreach ($aCatPath as $value) { + if (!$fullweblink) { + if ($mod_rewrite == true) { + $linkUrl = $sess->url("index-a-$value.html"); + } else { + $linkUrl = $sess->url("front_content.php?idcat=$value"); + } + } else { + if ($mod_rewrite == true) { + $linkUrl = $sess->url($cfgClient[$client]["path"]["htmlpath"] . "index-a-$value.html"); + } else { + $linkUrl = $sess->url($cfgClient[$client]["path"]["htmlpath"] . "front_content.php?idcat=$value"); + } + } + $name = getCategoryName($value, $db); + $aLocation[] = '' . $name . ''; + } + } + + $sLocation = implode($seperator, $aLocation); + $sLocation = '' . $sLocation . ''; + + + return $sLocation; +} + +/** + * + * get subtree by a given id + * + * @param int $idcat Id of category + * @return array Array with all deeper categories + * + * @copyright four for business AG + */ +function getSubTree($idcat_start, $db) { + global $client, $cfg; + + // SECURITY-FIX + $sql = "SELECT + B.idcat, A.level + FROM + " . $cfg["tab"]["cat_tree"] . " AS A, + " . $cfg["tab"]["cat"] . " AS B + WHERE + A.idcat = B.idcat AND + idclient = '" . Contenido_Security::escapeDB($client, $db) . "' + ORDER BY + idtree"; + + $db->query($sql); + + $subCats = false; + $curLevel = 0; + while ($db->next_record()) { + if ($db->f("idcat") == $idcat_start) { + $curLevel = $db->f("level"); + $subCats = true; + } else if ($db->f("level") <= $curLevel) { // ending part of tree + $subCats = false; + } + + if ($subCats == true) { //echo "true"; echo $db->f("idcat"); echo "
"; + $deeper_cats[] = $db->f("idcat"); + } + } + return $deeper_cats; +} + +function getTeaserDeeperCategories($iIdcat, $db) { + global $client, $cfg, $lang; + + // SECURITY-FIX + $sql = "SELECT + B.parentid, B.idcat + FROM + " . $cfg["tab"]["cat_tree"] . " AS A, + " . $cfg["tab"]["cat"] . " AS B, + " . $cfg["tab"]["cat_lang"] . " AS C + WHERE + A.idcat = B.idcat AND + B.idcat = C.idcat AND + C.idlang = '" . Contenido_Security::escapeDB($lang, $db) . "' AND + C.visible = '1' AND + B.idclient = '" . Contenido_Security::escapeDB($client, $db) . "' + ORDER BY + idtree"; + $db->query($sql); + + $subCats = false; + $curLevel = 0; + while ($db->next_record()) { + if ($db->f("idcat") == $iIdcat) { + $curLevel = $db->f("level"); + $subCats = true; + } else if ($curLevel == $db->f("level")) { // ending part of tree + $subCats = false; + } + + if ($subCats == true) { + $deeper_cats[] = $db->f("idcat"); + } + } + return $deeper_cats; +} + +/** + * + * get subtree by a given id, without protected and invisible categories + * + * @param int $idcat Id of category + * @return array Array with all deeper categories + * + * @copyright four for business AG + */ +function getProtectedSubTree($idcat_start, $db) { + global $client, $cfg, $lang; + + // SECURITY-FIX + $sql = "SELECT + B.parentid, B.idcat + FROM + " . $cfg["tab"]["cat_tree"] . " AS A, + " . $cfg["tab"]["cat"] . " AS B, + " . $cfg["tab"]["cat_lang"] . " AS C + WHERE + A.idcat = B.idcat AND + B.idcat = C.idcat AND + C.idlang = '" . Contenido_Security::escapeDB($lang, $db) . "' AND + C.visible = '1' AND + C.public = '1' AND + B.idclient = '" . Contenido_Security::escapeDB($client, $db) . "' + ORDER BY + idtree"; + + $db->query($sql); + + $subCats = false; + $curLevel = 0; + while ($db->next_record()) { + if ($db->f("idcat") == $idcat_start) { + $curLevel = $db->f("level"); + $subCats = true; + } else if ($curLevel == $db->f("level")) { // ending part of tree + $subCats = false; + } + + if ($subCats == true) { //echo "true"; echo $db->f("idcat"); echo "
"; + $deeper_cats[] = $db->f("idcat"); + } + } + return $deeper_cats; +} + +/** + * Return category name + */ +function getCategoryName($cat_id, &$db) { + + global $cfg, $client, $lang; + + // SECURITY-FIX + $sql = "SELECT + * + FROM + " . $cfg["tab"]["cat"] . " AS A, + " . $cfg["tab"]["cat_lang"] . " AS B + WHERE + A.idcat = B.idcat AND + A.idcat = '" . Contenido_Security::escapeDB($cat_id, $db) . "' AND + A.idclient = '" . Contenido_Security::escapeDB($client, $db) . "' AND + B.idlang = '" . Contenido_Security::escapeDB($lang, $db) . "' + "; + + $db->query($sql); + + if ($db->next_record()) { + $cat_name = $db->f("name"); + return $cat_name; + } else { + return ''; + } +} + +// end function + +// get direct subcategories of a given category +function getSubCategories($parent_id, $db) { + + $subcategories = array(); + + global $cfg, $client, $lang; + +// SECURITY-FIX + $sql = "SELECT + A.idcat + FROM + " . $cfg["tab"]["cat_tree"] . " AS A, + " . $cfg["tab"]["cat"] . " AS B, + " . $cfg["tab"]["cat_lang"] . " AS C + WHERE + A.idcat = B.idcat AND + B.idcat = C.idcat AND + B.idclient = '" . Contenido_Security::escapeDB($client, $db) . "' AND + C.idlang = '" . Contenido_Security::escapeDB($lang, $db) . "' AND + C.visible = '1' AND + C.public = '1' AND + B.parentid = '" . Contenido_Security::escapeDB($parent_id, $db) . "' + ORDER BY + A.idtree"; + + $db->query($sql); + + while ($db->next_record()) { + + $subcategories[] = $db->f("idcat"); + } // end while + + return $subcategories; +} + +// end function + +// get direct subcategories with protected categories +function getProtectedSubCategories($parent_id, $db) { + + $subcategories = array(); + unset($subcategories); + + global $cfg, $client, $lang; + +// SECURITY-FIX + $sql = "SELECT + A.idcat + FROM + " . $cfg["tab"]["cat_tree"] . " AS A, + " . $cfg["tab"]["cat"] . " AS B, + " . $cfg["tab"]["cat_lang"] . " AS C + WHERE + A.idcat = B.idcat AND + B.idcat = C.idcat AND + B.idclient = '" . Contenido_Security::escapeDB($client, $db) . "' AND + C.idlang = '" . Contenido_Security::escapeDB($lang, $db) . "' AND + B.parentid = '" . Contenido_Security::escapeDB($parent_id, $db) . "' + ORDER BY + A.idtree"; + + $db->query($sql); + + while ($db->next_record()) { + + $subcategories[] = $db->f("idcat"); + } // end while + + return $subcategories; +} + +// end function + +function checkCatPermission($idcatlang, $public) { + #Check if current user has permissions to access cat + + global $auth; + + $oDB = new DB_ConLite(); + + $FrontendPermissionCollection = new FrontendPermissionCollection; + $visible = false; + + if ($public != 0) { + $visible = true; + $groups = array(); + } elseif (($auth->auth['uid'] != '') && ($auth->auth['uid'] != 'nobody')) { + $FrontendGroupMemberCollection = new FrontendGroupMemberCollection; + $FrontendGroupMemberCollection->setWhere("idfrontenduser", $auth->auth['uid']); + $FrontendGroupMemberCollection->query(); + $groups = array(); + while ($member = $FrontendGroupMemberCollection->next()) { + $groups[] = $member->get("idfrontendgroup"); + } + } + if (count($groups) > 0) { + for ($i = 0; $i < count($groups); $i++) { + if ($FrontendPermissionCollection->checkPerm($groups[$i], 'category', 'access', $idcatlang, true)) { + $visible = true; + } + } + } + + return $visible; +} \ No newline at end of file diff --git a/conlite/external/frontend/includes/rss.inc.php b/conlite/external/frontend/includes/rss.inc.php new file mode 100644 index 0000000..2202b9e --- /dev/null +++ b/conlite/external/frontend/includes/rss.inc.php @@ -0,0 +1,59 @@ + \ No newline at end of file diff --git a/conlite/external/frontend/includes/rss_php.php b/conlite/external/frontend/includes/rss_php.php new file mode 100644 index 0000000..1456313 --- /dev/null +++ b/conlite/external/frontend/includes/rss_php.php @@ -0,0 +1,160 @@ + + Published: 200801 :: blacknet :: via rssphp.net + + RSS_PHP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. + + Usage: + See the documentation at http://rssphp.net/documentation + Examples: + Can be found online at http://rssphp.net/examples +*/ + +class rss_php { + + public $document; + public $channel; + public $items; + +/**************************** + public load methods +***/ + # load RSS by URL + public function load($url=false, $unblock=true) { + if($url) { + if($unblock) { + $this->loadParser(file_get_contents($url, false, $this->randomContext())); + } else { + $this->loadParser(file_get_contents($url)); + } + } + } + # load raw RSS data + public function loadRSS($rawxml=false) { + if($rawxml) { + $this->loadParser($rawxml); + } + } + +/**************************** + public load methods + @param $includeAttributes BOOLEAN + return array; +***/ + # return full rss array + public function getRSS($includeAttributes=false) { + if($includeAttributes) { + return $this->document; + } + return $this->valueReturner(); + } + # return channel data + public function getChannel($includeAttributes=false) { + if($includeAttributes) { + return $this->channel; + } + return $this->valueReturner($this->channel); + } + # return rss items + public function getItems($includeAttributes=false) { + if($includeAttributes) { + return $this->items; + } + return $this->valueReturner($this->items); + } + +/**************************** + internal methods +***/ + private function loadParser($rss=false) { + if($rss) { + $this->document = array(); + $this->channel = array(); + $this->items = array(); + $DOMDocument = new DOMDocument; + $DOMDocument->strictErrorChecking = false; + $DOMDocument->loadXML($rss); + $this->document = $this->extractDOM($DOMDocument->childNodes); + } + } + + private function valueReturner($valueBlock=false) { + if(!$valueBlock) { + $valueBlock = $this->document; + } + foreach($valueBlock as $valueName => $values) { + if(isset($values['value'])) { + $values = $values['value']; + } + if(is_array($values)) { + $valueBlock[$valueName] = $this->valueReturner($values); + } else { + $valueBlock[$valueName] = $values; + } + } + return $valueBlock; + } + + private function extractDOM($nodeList,$parentNodeName=false) { + $itemCounter = 0; + foreach($nodeList as $values) { + if(substr($values->nodeName,0,1) != '#') { + if($values->nodeName == 'item') { + $nodeName = $values->nodeName.':'.$itemCounter; + $itemCounter++; + } else { + $nodeName = $values->nodeName; + } + $tempNode[$nodeName] = array(); + if($values->attributes) { + for($i=0;$values->attributes->item($i);$i++) { + $tempNode[$nodeName]['properties'][$values->attributes->item($i)->nodeName] = $values->attributes->item($i)->nodeValue; + } + } + if(!$values->firstChild) { + $tempNode[$nodeName]['value'] = $values->textContent; + } else { + $tempNode[$nodeName]['value'] = $this->extractDOM($values->childNodes, $values->nodeName); + } + if(in_array($parentNodeName, array('channel','rdf:RDF'))) { + if($values->nodeName == 'item') { + $this->items[] = $tempNode[$nodeName]['value']; + } elseif(!in_array($values->nodeName, array('rss','channel'))) { + $this->channel[$values->nodeName] = $tempNode[$nodeName]; + } + } + } elseif(substr($values->nodeName,1) == 'text') { + $tempValue = trim(preg_replace('/\s\s+/',' ',str_replace("\n",' ', $values->textContent))); + if($tempValue) { + $tempNode = $tempValue; + } + } elseif(substr($values->nodeName,1) == 'cdata-section'){ + $tempNode = $values->textContent; + } + } + return $tempNode; + } + + private function randomContext() { + $headerstrings = array(); + $headerstrings['User-Agent'] = 'Mozilla/5.0 (Windows; U; Windows NT 5.'.rand(0,2).'; en-US; rv:1.'.rand(2,9).'.'.rand(0,4).'.'.rand(1,9).') Gecko/2007'.rand(10,12).rand(10,30).' Firefox/2.0.'.rand(0,1).'.'.rand(1,9); + $headerstrings['Accept-Charset'] = rand(0,1) ? 'en-gb,en;q=0.'.rand(3,8) : 'en-us,en;q=0.'.rand(3,8); + $headerstrings['Accept-Language'] = 'en-us,en;q=0.'.rand(4,6); + $setHeaders = 'Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5'."\r\n". + 'Accept-Charset: '.$headerstrings['Accept-Charset']."\r\n". + 'Accept-Language: '.$headerstrings['Accept-Language']."\r\n". + 'User-Agent: '.$headerstrings['User-Agent']."\r\n"; + $contextOptions = array( + 'http'=>array( + 'method'=>"GET", + 'header'=>$setHeaders + ) + ); + return stream_context_create($contextOptions); + } + +} + +?> \ No newline at end of file diff --git a/conlite/external/frontend/logs/deprecated.txt b/conlite/external/frontend/logs/deprecated.txt new file mode 100644 index 0000000..0e406df --- /dev/null +++ b/conlite/external/frontend/logs/deprecated.txt @@ -0,0 +1,2 @@ +This folder is marked as deprecated and will be deleted in next versions of ConLite. +Please use folders in data-directory instead! \ No newline at end of file