/** * Gets links to all Zenpage pages * * @return string */ function getSitemapZenpagePages() { global $_zp_zenpage, $sitemap_number; //not splitted into several sitemaps yet if ($sitemap_number == 1) { $data = ''; $limit = sitemap_getDBLimit(2); $sitemap_locales = generateLanguageList(); $changefreq = getOption('sitemap_changefreq_pages'); $pages = $_zp_zenpage->getPages(true); if ($pages) { $data .= sitemap_echonl('<?xml version="1.0" encoding="UTF-8"?>'); $data .= sitemap_echonl('<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'); foreach ($pages as $page) { $pageobj = new ZenpagePage($page['titlelink']); $date = substr($pageobj->getDatetime(), 0, 10); $lastchange = ''; if (!is_null($pageobj->getLastchange())) { $lastchange = substr($pageobj->getLastchange(), 0, 10); } if ($date > $lastchange && !empty($lastchangedate)) { $date = $lastchange; } if (!$pageobj->isProtected()) { switch (SITEMAP_LOCALE_TYPE) { case 1: foreach ($sitemap_locales as $locale) { $url = seo_locale::localePath(true, $locale) . '/' . _PAGES_ . '/' . urlencode($page['titlelink']); $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>"); } break; case 2: foreach ($sitemap_locales as $locale) { $url = rewrite_path(_PAGES_ . '/' . urlencode($page['titlelink']), '?p=pages&title=' . urlencode($page['titlelink']), dynamic_locale::fullHostPath($locale)); $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>"); } break; default: $url = rewrite_path(_PAGES_ . '/' . urlencode($page['titlelink']), '?p=pages&title=' . urlencode($page['titlelink']), FULLWEBPATH); $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>"); break; } } } $data .= sitemap_echonl('</urlset>'); // End off the <urlset> tag } return $data; } }
/** * Gets latest comments for news articles and pages * * @param int $number how many comments you want. * @param string $type "all" for all latest comments for all news articles and all pages * "news" for the lastest comments of one specific news article * "page" for the lastest comments of one specific page * @param int $itemID the ID of the element to get the comments for if $type != "all" */ function getLatestZenpageComments($number, $type = "all", $itemID = "") { $itemID = sanitize_numeric($itemID); $number = sanitize_numeric($number); $checkauth = zp_loggedin(); if ($type == 'all' || $type == 'news') { $newspasswordcheck = ""; if (zp_loggedin(MANAGE_ALL_NEWS_RIGHTS)) { $newsshow = ''; } else { $newsshow = 'news.show=1 AND'; $newscheck = query_full_array("SELECT * FROM " . prefix('news') . " ORDER BY date"); foreach ($newscheck as $articlecheck) { $obj = new ZenpageNews($articlecheck['titlelink']); if ($obj->inProtectedCategory()) { if ($checkauth && $obj->isMyItem(LIST_RIGHTS)) { $newsshow = ''; } else { $excludenews = " AND id != " . $articlecheck['id']; $newspasswordcheck = $newspasswordcheck . $excludenews; } } } } } if ($type == 'all' || $type == 'page') { $pagepasswordcheck = ""; if (zp_loggedin(MANAGE_ALL_PAGES_RIGHTS)) { $pagesshow = ''; } else { $pagesshow = 'pages.show=1 AND'; $pagescheck = query_full_array("SELECT * FROM " . prefix('pages') . " ORDER BY date"); foreach ($pagescheck as $pagecheck) { $obj = new ZenpagePage($pagecheck['titlelink']); if ($obj->isProtected()) { if ($checkauth && $obj->isMyItem(LIST_RIGHTS)) { $pagesshow = ''; } else { $excludepages = " AND pages.id != " . $pagecheck['id']; $pagepasswordcheck = $pagepasswordcheck . $excludepages; } } } } } switch ($type) { case "news": $whereNews = " WHERE {$newsshow} news.id = " . $itemID . " AND c.ownerid = news.id AND c.type = 'news' AND c.private = 0 AND c.inmoderation = 0" . $newspasswordcheck; break; case "page": $wherePages = " WHERE {$pagesshow} pages.id = " . $itemID . " AND c.ownerid = pages.id AND c.type = 'pages' AND c.private = 0 AND c.inmoderation = 0" . $pagepasswordcheck; break; case "all": $whereNews = " WHERE {$newsshow} c.ownerid = news.id AND c.type = 'news' AND c.private = 0 AND c.inmoderation = 0" . $newspasswordcheck; $wherePages = " WHERE {$pagesshow} c.ownerid = pages.id AND c.type = 'pages' AND c.private = 0 AND c.inmoderation = 0" . $pagepasswordcheck; break; } $comments_news = array(); $comments_pages = array(); if ($type == "all" or $type == "news") { $comments_news = query_full_array("SELECT c.id, c.name, c.type, c.website," . " c.date, c.anon, c.comment, news.title, news.titlelink FROM " . prefix('comments') . " AS c, " . prefix('news') . " AS news " . $whereNews . " ORDER BY c.id DESC LIMIT {$number}"); } if ($type == "all" or $type == "page") { $comments_pages = query_full_array($sql = "SELECT c.id, c.name, c.type, c.website," . " c.date, c.anon, c.comment, pages.title, pages.titlelink FROM " . prefix('comments') . " AS c, " . prefix('pages') . " AS pages " . $wherePages . " ORDER BY c.id DESC LIMIT {$number}"); } $comments = array(); foreach ($comments_news as $comment) { $comments[$comment['id']] = $comment; } foreach ($comments_pages as $comment) { $comments[$comment['id']] = $comment; } krsort($comments); return array_slice($comments, 0, $number); }
/** * Gets the title, url and name of a menu item * * @return array */ function getItemTitleAndURL($item) { global $_zp_gallery; $themename = $_zp_gallery->getCurrentTheme(); $array = array("title" => '', "url" => '', "name" => '', 'protected' => false, 'theme' => $themename); $valid = true; $title = get_language_string($item['title']); switch ($item['type']) { case "galleryindex": $array = array("title" => get_language_string($item['title']), "url" => WEBPATH, "name" => WEBPATH, 'protected' => false, 'theme' => $themename); break; case "album": $folderFS = internalToFilesystem($item['link']); $localpath = ALBUM_FOLDER_SERVERPATH . $folderFS; $dynamic = hasDynamicAlbumSuffix($folderFS) && !is_dir($folderFS); $valid = file_exists($localpath) && ($dynamic || is_dir($localpath)); if (!$valid || strpos($localpath, '..') !== false) { $valid = false; $url = ''; $protected = 0; } else { $obj = newAlbum($item['link']); $url = $obj->getLink(0); $protected = $obj->isProtected(); $title = $obj->getTitle(); } $array = array("title" => $title, "url" => $url, "name" => $item['link'], 'protected' => $protected, 'theme' => $themename); break; case "zenpagepage": if (class_exists('zenpage')) { $sql = 'SELECT * FROM ' . prefix('pages') . ' WHERE `titlelink`="' . $item['link'] . '"'; $result = query_single_row($sql); if (is_array($result)) { $obj = new ZenpagePage($item['link']); $url = $obj->getLink(0); $protected = $obj->isProtected(); $title = $obj->getTitle(); } else { $valid = false; $url = ''; $protected = 0; } $array = array("title" => $title, "url" => $url, "name" => $item['link'], 'protected' => $protected, 'theme' => $themename); } break; case "zenpagenewsindex": if (class_exists('zenpage')) { $url = getNewsIndexURL(); $array = array("title" => get_language_string($item['title']), "url" => $url, "name" => $url, 'protected' => false); } break; case "zenpagecategory": if (class_exists('zenpage')) { $sql = "SELECT title FROM " . prefix('news_categories') . " WHERE titlelink = '" . $item['link'] . "'"; $obj = query_single_row($sql, false); if ($obj) { $obj = new ZenpageCategory($item['link']); $title = $obj->getTitle(); $protected = $obj->isProtected(); $url = $obj->getLink(0); } else { $valid = false; $url = ''; $protected = 0; } $array = array("title" => $title, "url" => $url, "name" => $item['link'], 'protected' => $protected, 'theme' => $themename); } break; case "custompage": $root = SERVERPATH . '/' . THEMEFOLDER . '/' . $themename . '/'; if (file_exists($root . $item['link'] . '.php')) { $url = zp_apply_filter('getLink', rewrite_path(_PAGE_ . '/' . $item['link'], "/index.php?p=" . $item['link']), $item['link'] . '.php', NULL); } else { $valid = false; $url = ''; } $array = array("title" => $title, "url" => $url, "name" => $item['link'], 'protected' => false, 'theme' => $themename); break; case "customlink": $array = array("title" => get_language_string($item['title']), "url" => $item['link'], "name" => $item['link'], 'protected' => false, 'theme' => $themename); break; case 'menulabel': $array = array("title" => get_language_string($item['title']), "url" => NULL, 'name' => $item['title'], 'protected' => false, 'theme' => $themename); break; default: $array = array("title" => get_language_string($item['title']), "url" => $item['link'], "name" => $item['link'], 'protected' => false, 'theme' => $themename); break; } $limit = MENU_TRUNCATE_STRING; $array['valid'] = $valid; if ($limit) { $array['title'] = shortenContent($array['title'], $limit, MENU_TRUNCATE_INDICATOR); } return $array; }