예제 #1
0
/**
 * Function to create the page title to be used within the html <head> <title></title> element.
 * Usefull if you use one header.php for the header of all theme pages instead of individual ones on the theme pages
 * It returns the title and site name in reversed breadcrumb order:
 * <title of current page> | <parent item if present> | <gallery title>
 * It supports standard gallery pages as well a custom and Zenpage news articles, categories and pages.
 *
 * @param string $separator How you wish the parts to be separated
 * @param bool $listparentalbums If the parent albums should be printed in reversed order before the current
 * @param bool $listparentpage If the parent Zenpage pages should be printed in reversed order before the current page
 */
function getHeadTitle($separator = ' | ', $listparentalbums = true, $listparentpages = true)
{
    global $_zp_gallery, $_zp_current_album, $_zp_current_image, $_zp_current_zenpage_news, $_zp_current_zenpage_page, $_zp_gallery_page, $_zp_current_category, $_zp_page, $_myFavorites;
    $mainsitetitle = html_encode(getBare(getMainSiteName()));
    $separator = html_encode($separator);
    if ($mainsitetitle) {
        $mainsitetitle = $separator . $mainsitetitle;
    }
    $gallerytitle = html_encode(getBareGalleryTitle());
    if ($_zp_page > 1) {
        $pagenumber = ' (' . $_zp_page . ')';
    } else {
        $pagenumber = '';
    }
    switch ($_zp_gallery_page) {
        case 'index.php':
            return $gallerytitle . $mainsitetitle . $pagenumber;
            break;
        case 'album.php':
        case 'image.php':
            if ($listparentalbums) {
                $parents = getParentAlbums();
                $parentalbums = '';
                if (count($parents) != 0) {
                    $parents = array_reverse($parents);
                    foreach ($parents as $parent) {
                        $parentalbums .= html_encode(getBare($parent->getTitle())) . $separator;
                    }
                }
            } else {
                $parentalbums = '';
            }
            $albumtitle = html_encode(getBareAlbumTitle()) . $pagenumber . $separator . $parentalbums . $gallerytitle . $mainsitetitle;
            switch ($_zp_gallery_page) {
                case 'album.php':
                    return $albumtitle;
                    break;
                case 'image.php':
                    return html_encode(getBareImageTitle()) . $separator . $albumtitle;
                    break;
            }
            break;
        case 'news.php':
            if (function_exists("is_NewsArticle")) {
                if (is_NewsArticle()) {
                    return html_encode(getBareNewsTitle()) . $pagenumber . $separator . gettext('News') . $separator . $gallerytitle . $mainsitetitle;
                } else {
                    if (is_NewsCategory()) {
                        return html_encode(getBare($_zp_current_category->getTitle())) . $pagenumber . $separator . gettext('News') . $separator . $gallerytitle . $mainsitetitle;
                    } else {
                        return gettext('News') . $pagenumber . $separator . $gallerytitle . $mainsitetitle;
                    }
                }
            }
            break;
        case 'pages.php':
            if ($listparentpages) {
                $parents = $_zp_current_zenpage_page->getParents();
                $parentpages = '';
                if (count($parents) != 0) {
                    $parents = array_reverse($parents);
                    foreach ($parents as $parent) {
                        $obj = new ZenpagePage($parent);
                        $parentpages .= html_encode(getBare($obj->getTitle())) . $separator;
                    }
                }
            } else {
                $parentpages = '';
            }
            return html_encode(getBarePageTitle()) . $pagenumber . $separator . $parentpages . $gallerytitle . $mainsitetitle;
            break;
        case '404.php':
            return gettext('Object not found') . $separator . $gallerytitle . $mainsitetitle;
            break;
        default:
            // for all other possible static custom pages
            $custompage = stripSuffix($_zp_gallery_page);
            $standard = array('contact' => gettext('Contact'), 'register' => gettext('Register'), 'search' => gettext('Search'), 'archive' => gettext('Archive view'), 'password' => gettext('Password required'));
            if (is_object($_myFavorites)) {
                $standard['favorites'] = gettext('My favorites');
            }
            if (array_key_exists($custompage, $standard)) {
                return $standard[$custompage] . $pagenumber . $separator . $gallerytitle . $mainsitetitle;
            } else {
                return $custompage . $pagenumber . $separator . $gallerytitle . $mainsitetitle;
            }
            break;
    }
}
/**
 * Prints the nested list for pages and categories
 *
 * @param string $listtype 'cats-checkboxlist' for a fake nested checkbock list of categories for the news article edit/add page
 * 												'cats-sortablelist' for a sortable nested list of categories for the admin categories page
 * 												'pages-sortablelist' for a sortable nested list of pages for the admin pages page
 * @param int $articleid Only for $listtype = 'cats-checkboxlist': For ID of the news article if the categories an existing articles is assigned to shall be shown, empty if this is a new article to be added.
 * @param string $option Only for $listtype = 'cats-checkboxlist': "all" to show all categories if creating a new article without categories assigned, empty if editing an existing article that already has categories assigned.
 * @return string | bool
 */
function printNestedItemsList($listtype = 'cats-sortablelist', $articleid = '', $option = '')
{
    global $_zp_zenpage;
    switch ($listtype) {
        case 'cats-checkboxlist':
        default:
            $ulclass = "";
            break;
        case 'cats-sortablelist':
        case 'pages-sortablelist':
            $ulclass = " class=\"page-list\"";
            break;
    }
    switch ($listtype) {
        case 'cats-checkboxlist':
        case 'cats-sortablelist':
            $items = $_zp_zenpage->getAllCategories(false);
            break;
        case 'pages-sortablelist':
            $items = $_zp_zenpage->getPages(false);
            break;
        default:
            $items = array();
            break;
    }
    $indent = 1;
    $open = array(1 => 0);
    $rslt = false;
    foreach ($items as $item) {
        switch ($listtype) {
            case 'cats-checkboxlist':
            case 'cats-sortablelist':
                $itemobj = new ZenpageCategory($item['titlelink']);
                $ismypage = $itemobj->isMyItem(ZENPAGE_NEWS_RIGHTS);
                break;
            case 'pages-sortablelist':
                $itemobj = new ZenpagePage($item['titlelink']);
                $ismypage = $itemobj->isMyItem(ZENPAGE_PAGES_RIGHTS);
                break;
        }
        $itemsortorder = $itemobj->getSortOrder();
        $itemid = $itemobj->getID();
        if ($ismypage) {
            $order = explode('-', $itemsortorder);
            $level = max(1, count($order));
            if ($toodeep = $level > 1 && $order[$level - 1] === '') {
                $rslt = true;
            }
            if ($level > $indent) {
                echo "\n" . str_pad("\t", $indent, "\t") . "<ul" . $ulclass . ">\n";
                $indent++;
                $open[$indent] = 0;
            } else {
                if ($level < $indent) {
                    while ($indent > $level) {
                        $open[$indent]--;
                        $indent--;
                        echo "</li>\n" . str_pad("\t", $indent, "\t") . "</ul>\n";
                    }
                } else {
                    // indent == level
                    if ($open[$indent]) {
                        echo str_pad("\t", $indent, "\t") . "</li>\n";
                        $open[$indent]--;
                    } else {
                        echo "\n";
                    }
                }
            }
            if ($open[$indent]) {
                echo str_pad("\t", $indent, "\t") . "</li>\n";
                $open[$indent]--;
            }
            switch ($listtype) {
                case 'cats-checkboxlist':
                    echo "<li>\n";
                    printCategoryCheckboxListEntry($itemobj, $articleid, $option);
                    break;
                case 'cats-sortablelist':
                    echo str_pad("\t", $indent - 1, "\t") . "<li id=\"id_" . $itemid . "\" class=\"clear-element page-item1 left\">";
                    printCategoryListSortableTable($itemobj, $toodeep);
                    break;
                case 'pages-sortablelist':
                    echo str_pad("\t", $indent - 1, "\t") . "<li id=\"id_" . $itemid . "\">";
                    printPagesListTable($itemobj, $toodeep);
                    break;
            }
            $open[$indent]++;
        }
    }
    while ($indent > 1) {
        echo "</li>\n";
        $open[$indent]--;
        $indent--;
        echo str_pad("\t", $indent, "\t") . "</ul>";
    }
    if ($open[$indent]) {
        echo "</li>\n";
    } else {
        echo "\n";
    }
    return $rslt;
}
예제 #3
0
/**
 * 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&amp;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&amp;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;
    }
}
 /**
  * Checks if user is allowed to access the page
  * @param $hint
  * @param $show
  */
 function checkforGuest(&$hint = NULL, &$show = NULL)
 {
     if (!parent::checkForGuest()) {
         return false;
     }
     $pageobj = $this;
     $hash = $pageobj->getPassword();
     while (empty($hash) && !is_null($pageobj)) {
         $parentID = $pageobj->getParentID();
         if (empty($parentID)) {
             $pageobj = NULL;
         } else {
             $sql = 'SELECT `titlelink` FROM ' . prefix('pages') . ' WHERE `id`=' . $parentID;
             $result = query_single_row($sql);
             $pageobj = new ZenpagePage($result['titlelink']);
             $hash = $pageobj->getPassword();
         }
     }
     if (empty($hash)) {
         // no password required
         return 'zp_public_access';
     } else {
         $authType = "zp_page_auth_" . $pageobj->get('id');
         $saved_auth = zp_getCookie($authType);
         if ($saved_auth == $hash) {
             return $authType;
         } else {
             $user = $pageobj->getUser();
             $show = !empty($user);
             $hint = $pageobj->getPasswordHint();
             return false;
         }
     }
 }
예제 #5
0
                     $as = trim(sanitize($_POST['copy_object_as']));
                     if (empty($as)) {
                         $as = sprintf(gettext('copy of %s'), $result->getTitle());
                     }
                     $as = seoFriendly($as);
                     $result->copy($as);
                     $result = new ZenpagePage($as);
                     $_GET['titlelink'] = $as;
                     break;
                 case 'delete':
                     $reports[] = deletePage($result);
                     break;
             }
         }
     } else {
         $result = new ZenpagePage('');
         $result->setPermalink(1);
         $result->setDateTime(date('Y-m-d H:i:s'));
     }
 }
 if (isset($_GET['save'])) {
     XSRFdefender('save');
     $result = updatePage($reports, true);
 }
 if (isset($_GET['delete'])) {
     XSRFdefender('delete');
     $msg = deletePage(sanitize($_GET['delete']));
     if (!empty($msg)) {
         $reports[] = $msg;
     }
 }
/**
 * 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);
}
예제 #7
0
/**
 * Gets all tags used by either all Zenpage news articles or pages.
 * @param string $mode "news" for Zenpage news article tags, "pages" for Zenpage pages tags
 *
 */
function getAllTagsFromZenpage($mode = 'news')
{
    global $_zp_gallery, $_zp_zenpage;
    if (!getOption('zp_plugin_zenpage')) {
        return FALSE;
    }
    $passwordcheck = '';
    $ids = array();
    $where = '';
    $tagWhere = "";
    switch ($mode) {
        case 'news':
            if (zp_loggedin(ZENPAGE_NEWS_RIGHTS)) {
                $published = 'all';
            } else {
                $published = 'published';
            }
            $type = 'news';
            $items = $_zp_zenpage->getNewsArticles('', $published);
            foreach ($items as $item) {
                $obj = new ZenpageNews($item['titlelink']);
                if ($obj->checkAccess($hint, $show)) {
                    $ids[] = $obj->getID();
                }
            }
            break;
        case 'pages':
            if (zp_loggedin(ZENPAGE_NEWS_RIGHTS)) {
                $published = 'all';
            } else {
                $published = 'published';
            }
            $type = 'pages';
            $items = $_zp_zenpage->getPages('', '', $published);
            foreach ($items as $item) {
                $obj = new ZenpagePage($item['titlelink']);
                if ($obj->checkAccess($hint, $show)) {
                    $ids[] = $obj->getID();
                }
            }
            break;
    }
    $count = '';
    if (count($ids) == 0) {
        return FALSE;
    } else {
        $tagWhere = " WHERE ";
        foreach ($ids as $id) {
            $count++;
            $tagWhere .= '(o.objectid =' . $id . " AND o.tagid = t.id AND o.type = '" . $type . "')";
            if ($count != count($ids)) {
                $tagWhere .= " OR ";
            }
        }
    }
    if (empty($tagWhere)) {
        return FALSE;
    } else {
        $tags = query_full_array("SELECT DISTINCT t.name, t.id, (SELECT DISTINCT COUNT(*) FROM " . prefix('obj_to_tag') . " WHERE tagid = t.id AND o.type = '" . $type . "') AS count FROM " . prefix('obj_to_tag') . " AS o," . prefix('tags') . " AS t" . $tagWhere . " ORDER BY t.name");
    }
    return $tags;
}
예제 #8
0
/**
 * Prints all available pages or categories in Zenpage
 *
 * @return string
 */
function printAllNestedList()
{
    global $_zp_zenpage, $host;
    if (isset($_GET['zenpage']) && ($_GET['zenpage'] == "pages" || $_GET['zenpage'] == "categories")) {
        $mode = sanitize($_GET['zenpage']);
        switch ($mode) {
            case 'pages':
                $items = $_zp_zenpage->getPages(false);
                $listtitle = gettext('Pages');
                break;
            case 'categories':
                $items = $_zp_zenpage->getAllCategories(false);
                $listtitle = gettext('Categories');
                break;
        }
        echo "<h3>Zenpage: <em>" . html_encode($listtitle) . "</em> <small> " . gettext("(Click on article title to include a link)") . "</small></h3>";
        echo "<ul class='tinynesteditems'>";
        $indent = 1;
        $open = array(1 => 0);
        $rslt = false;
        foreach ($items as $key => $item) {
            switch ($mode) {
                case 'pages':
                    $obj = new ZenpagePage($item['titlelink']);
                    $itemcontent = truncate_string(getBare($obj->getContent()), 300);
                    $zenpagepage = _PAGES_ . '/' . $item['titlelink'];
                    $unpublished = unpublishedZenpageItemCheck($obj);
                    $counter = '';
                    break;
                case 'categories':
                    $obj = new ZenpageCategory($item['titlelink']);
                    $itemcontent = $obj->getTitle();
                    $zenpagepage = "news/category/" . $item['titlelink'];
                    $unpublished = unpublishedZenpageItemCheck($obj);
                    $counter = ' (' . count($obj->getArticles()) . ') ';
                    break;
            }
            $itemsortorder = $obj->getSortOrder();
            $itemtitlelink = $obj->getTitlelink();
            $itemtitle = $obj->getTitle();
            $itemid = $obj->getID();
            $order = explode('-', $itemsortorder);
            $level = max(1, count($order));
            if ($toodeep = $level > 1 && $order[$level - 1] === '') {
                $rslt = true;
            }
            if ($level > $indent) {
                echo "\n" . str_pad("\t", $indent, "\t") . "<ul>\n";
                $indent++;
                $open[$indent] = 0;
            } else {
                if ($level < $indent) {
                    while ($indent > $level) {
                        $open[$indent]--;
                        $indent--;
                        echo "</li>\n" . str_pad("\t", $indent, "\t") . "</ul>\n";
                    }
                } else {
                    // indent == level
                    if ($open[$indent]) {
                        echo str_pad("\t", $indent, "\t") . "</li>\n";
                        $open[$indent]--;
                    } else {
                        echo "\n";
                    }
                }
            }
            if ($open[$indent]) {
                echo str_pad("\t", $indent, "\t") . "</li>\n";
                $open[$indent]--;
            }
            echo "<li id='" . $itemid . "' class='itemborder'>";
            echo "<a href=\"javascript:ZenpageDialog.insert('','" . $zenpagepage . "','','','" . $itemtitlelink . "','" . js_encode($itemtitle) . "','','','" . $mode . "','','','','');\" title='" . html_encode($itemcontent) . "'>" . html_encode($itemtitle) . $unpublished . $counter . "</a> <small><em>" . $obj->getDatetime() . "</em></small>";
            if ($mode == 'pages') {
                echo " <a href='zoom.php?pages=" . urlencode($itemtitlelink) . "' title='Zoom' class='colorbox' style='outline: none;'><img src='img/magnify.png' alt='' style='border: 0' /></a>";
            }
            $open[$indent]++;
        }
        while ($indent > 1) {
            echo "</li>\n";
            $open[$indent]--;
            $indent--;
            echo str_pad("\t", $indent, "\t") . "</ul>";
        }
        if ($open[$indent]) {
            echo "</li>\n";
        } else {
            echo "\n";
        }
        echo "</ul>\n";
    }
}
예제 #9
0
 /**
  * Gets the feed item data in a Zenpage news feed
  *
  * @param array $item Titlelink a Zenpage article or filename of an image if a combined feed
  * @return array
  */
 protected function getitemPages($item, $len)
 {
     $obj = new ZenpagePage($item['titlelink']);
     $feeditem['title'] = $feeditem['title'] = get_language_string($obj->getTitle('all'), $this->locale);
     $feeditem['link'] = $obj->getLink();
     $desc = $obj->getContent($this->locale);
     $desc = str_replace('//<![CDATA[', '', $desc);
     $desc = str_replace('//]]>', '', $desc);
     $feeditem['desc'] = shortenContent($desc, $len, '...');
     $feeditem['enclosure'] = '';
     $feeditem['category'] = '';
     $feeditem['media_content'] = '';
     $feeditem['media_thumbnail'] = '';
     $feeditem['pubdate'] = date("r", strtotime($obj->getDatetime()));
     return $feeditem;
 }
예제 #10
0
/**
 * 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;
}
예제 #11
0
/**
 * Creates a "REWRITE" url given the query parameters that represent the link
 *
 * @param type $query
 * @return string
 */
function zpRewriteURL($query)
{
    $redirectURL = '';
    if (isset($query['p'])) {
        sanitize($query);
        switch ($query['p']) {
            case 'news':
                $redirectURL = _NEWS_;
                if (isset($query['category'])) {
                    $obj = new ZenpageCategory($query['category'], false);
                    if (!$obj->loaded) {
                        return '';
                    }
                    $redirectURL = $obj->getLink();
                    unset($query['category']);
                } else {
                    if (isset($query['date'])) {
                        $redirectURL = _NEWS_ARCHIVE_ . '/' . $query['date'];
                        unset($query['date']);
                    }
                }
                if (isset($query['title'])) {
                    $obj = new ZenpageNews($query['title'], false);
                    if (!$obj->loaded) {
                        return '';
                    }
                    $redirectURL = $obj->getLink();
                    unset($query['title']);
                }
                break;
            case 'pages':
                $redirectURL = _PAGES_;
                if (isset($query['title'])) {
                    $obj = new ZenpagePage($query['title'], false);
                    if (!$obj->loaded) {
                        return '';
                    }
                    $redirectURL = $obj->getLink();
                    unset($query['title']);
                }
                break;
            case 'search':
                $redirectURL = _SEARCH_;
                if (isset($query['date'])) {
                    $redirectURL = _ARCHIVE_ . '/' . $query['date'];
                    unset($query['date']);
                } else {
                    if (isset($query['searchfields']) && $query['searchfields'] == 'tags') {
                        $redirectURL = _TAGS_;
                        unset($query['searchfields']);
                    }
                }
                if (isset($query['words'])) {
                    $redirectURL .= '/' . $query['words'];
                    unset($query['words']);
                }
                break;
            default:
                $redirectURL = getCustomPageURL($query['p']);
                break;
        }
        unset($query['p']);
        $redirectURL = preg_replace('~^' . WEBPATH . '/~', '', $redirectURL);
        if (isset($query['page'])) {
            $redirectURL .= '/' . $query['page'];
            unset($query['page']);
        }
        $q = http_build_query($query);
        if ($q) {
            $redirectURL .= '?' . $q;
        }
    } else {
        if (isset($query['album'])) {
            if (isset($query['image'])) {
                $obj = newImage(NULL, array('folder' => $query['album'], 'filename' => $query['image']), true);
                unset($query['image']);
            } else {
                $obj = newAlbum($query['album'], NULL, true);
            }
            unset($query['album']);
            if (!$obj->exists) {
                return '';
            }
            $redirectURL = preg_replace('~^' . WEBPATH . '/~', '', $obj->getLink());
            $q = http_build_query($query);
            if ($q) {
                $redirectURL .= '?' . $q;
            }
        }
    }
    return $redirectURL;
}
예제 #12
0
    zenpagePublish($obj, sanitize_numeric($_GET['publish']));
}
if (isset($_GET['skipscheduling'])) {
    XSRFdefender('update');
    $obj = new ZenpagePage($result['titlelink']);
    skipScheduledPublishing($obj);
}
if (isset($_GET['commentson'])) {
    XSRFdefender('update');
    $obj = new ZenpagePage(sanitize($_GET['titlelink']));
    $obj->setCommentsAllowed(sanitize_numeric($_GET['commentson']));
    $obj->save();
}
if (isset($_GET['hitcounter'])) {
    XSRFdefender('hitcounter');
    $obj = new ZenpagePage(sanitize($_GET['titlelink']));
    $obj->set('hitcounter', 0);
    $obj->save();
    $reports[] = '<p class="messagebox fade-message">' . gettext("Hitcounter reset") . '</p>';
}
printAdminHeader('pages');
printSortableHead();
zenpageJSCSS();
?>
<script type="text/javascript">
	//<!-- <![CDATA[
	var deleteArticle = "<?php 
echo gettext("Are you sure you want to delete this article? THIS CANNOT BE UNDONE!");
?>
";
	var deletePage = "<?php 
예제 #13
0
/**
 * Prints the x related articles based on a tag search
 *
 * @param int $number Number of items to get
 * @param string $type 'albums', 'images','news','pages', "all" for all combined.
 * @param string $specific If $type = 'albums' or 'images' name of album
 * @param bool $excerpt If a text excerpt (gallery items: description; Zenpage items: content) should be shown. NULL for none or number of length
 * @param bool $thumb For $type = 'albums' or 'images' if a thumb should be shown (default size as set on the options)
 */
function printRelatedItems($number = 5, $type = 'news', $specific = NULL, $excerpt = NULL, $thumb = false, $date = false)
{
    global $_zp_gallery, $_zp_current_album, $_zp_current_image, $_zp_current_zenpage_page, $_zp_current_zenpage_news;
    $label = array('albums' => gettext('Albums'), 'images' => gettext('Images'), 'news' => gettext('News'), 'pages' => gettext('Pages'));
    $result = getRelatedItems($type, $specific);
    $resultcount = count($result);
    if ($resultcount != 0) {
        ?>
		<h3 class="relateditems">
			<?php 
        printf(gettext('Related %s'), $type);
        ?>
		</h3>
		<ul id="relateditems">
			<?php 
        $count = 0;
        foreach ($result as $item) {
            $count++;
            ?>
				<li class="<?php 
            echo $item['type'];
            ?>
">
					<?php 
            $category = '';
            switch ($item['type']) {
                case 'albums':
                    $obj = newAlbum($item['name']);
                    $url = $obj->getLink();
                    $text = $obj->getDesc();
                    $category = gettext('Album');
                    break;
                case 'images':
                    $alb = newAlbum($item['album']);
                    $obj = newImage($alb, $item['name']);
                    $url = $obj->getLink();
                    $text = $obj->getDesc();
                    $category = gettext('Image');
                    break;
                case 'news':
                    $obj = new ZenpageNews($item['name']);
                    $url = $obj->getLink();
                    $text = $obj->getContent();
                    $category = gettext('News');
                    break;
                case 'pages':
                    $obj = new ZenpagePage($item['name']);
                    $url = $obj->getLink();
                    $text = $obj->getContent();
                    $category = gettext('Page');
                    break;
            }
            ?>
					<?php 
            if ($thumb) {
                $thumburl = false;
                switch ($item['type']) {
                    case 'albums':
                        $thumburl = $obj->getThumb();
                        break;
                    case 'images':
                        $thumburl = $obj->getThumb();
                        break;
                }
                if ($thumburl) {
                    ?>
							<a href="<?php 
                    echo html_encode(pathurlencode($url));
                    ?>
" title="<?php 
                    echo html_encode($obj->getTitle());
                    ?>
" class="relateditems_thumb">
								<img src="<?php 
                    echo html_encode(pathurlencode($thumburl));
                    ?>
" alt="<?php 
                    echo html_encode($obj->getTitle());
                    ?>
" />
							</a>
							<?php 
                }
            }
            ?>
					<h4><a href="<?php 
            echo html_encode(pathurlencode($url));
            ?>
" title="<?php 
            echo html_encode($obj->getTitle());
            ?>
"><?php 
            echo html_encode($obj->getTitle());
            ?>
</a>
						<?php 
            if ($date) {
                switch ($item['type']) {
                    case 'albums':
                    case 'images':
                        $d = $obj->getDateTime();
                        break;
                    case 'news':
                    case 'pages':
                        $d = $obj->getDateTime();
                        break;
                }
                ?>
							<span class="relateditems_date">
								<?php 
                echo zpFormattedDate(DATE_FORMAT, strtotime($d));
                ?>
							</span>
							<?php 
            }
            ?>
						<?php 
            if ($type == 'all') {
                ?>
 (<small><?php 
                echo $category;
                ?>
</small>)<?php 
            }
            ?>

					</h4>
					<?php 
            if ($excerpt) {
                echo shortenContent($text, $excerpt, '...', true);
            }
            ?>
				</li>
				<?php 
            if ($count == $number) {
                break;
            }
        }
        // foreach
        if ($count) {
            ?>
			</ul>
			<?php 
        }
    }
}
예제 #14
0
파일: pages.php 프로젝트: rb26/zenphoto
</a> <?php 
        printZenpageItemsBreadcrumb('', '  ');
        printPageTitle('');
        ?>
</strong></h2>

							<?php 
        printPageContent();
        printCodeblock(1);
        $subpages = $_zp_current_zenpage_page->getPages();
        if ($subpages) {
            ?>
								<ul data-role="listview" data-inset="true" data-theme="a" class="ui-listview ui-group-theme-a">
									<?php 
            foreach ($subpages as $subpage) {
                $obj = new ZenpagePage($subpage['titlelink']);
                ?>
										<li><a href="<?php 
                echo html_encode($obj->getLink());
                ?>
" title="<?php 
                echo html_encode($obj->getTitle());
                ?>
"><?php 
                echo html_encode($obj->getTitle());
                ?>
</a></li>
										<?php 
            }
            ?>
								</ul>
예제 #15
0
/**
 * checks password posting
 *
 * @param string $authType override of athorization type
 */
function zp_handle_password($authType = NULL, $check_auth = NULL, $check_user = NULL)
{
    global $_zp_loggedin, $_zp_login_error, $_zp_current_album, $_zp_current_zenpage_page, $_zp_gallery;
    if (empty($authType)) {
        // not supplied by caller
        $check_auth = '';
        if (isset($_GET['z']) && @$_GET['p'] == 'full-image' || isset($_GET['p']) && $_GET['p'] == '*full-image') {
            $authType = 'zp_image_auth';
            $check_auth = getOption('protected_image_password');
            $check_user = getOption('protected_image_user');
        } else {
            if (in_context(ZP_SEARCH)) {
                // search page
                $authType = 'zp_search_auth';
                $check_auth = getOption('search_password');
                $check_user = getOption('search_user');
            } else {
                if (in_context(ZP_ALBUM)) {
                    // album page
                    $authType = "zp_album_auth_" . $_zp_current_album->getID();
                    $check_auth = $_zp_current_album->getPassword();
                    $check_user = $_zp_current_album->getUser();
                    if (empty($check_auth)) {
                        $parent = $_zp_current_album->getParent();
                        while (!is_null($parent)) {
                            $check_auth = $parent->getPassword();
                            $check_user = $parent->getUser();
                            $authType = "zp_album_auth_" . $parent->getID();
                            if (!empty($check_auth)) {
                                break;
                            }
                            $parent = $parent->getParent();
                        }
                    }
                } else {
                    if (in_context(ZP_ZENPAGE_PAGE)) {
                        $authType = "zp_page_auth_" . $_zp_current_zenpage_page->getID();
                        $check_auth = $_zp_current_zenpage_page->getPassword();
                        $check_user = $_zp_current_zenpage_page->getUser();
                        if (empty($check_auth)) {
                            $pageobj = $_zp_current_zenpage_page;
                            while (empty($check_auth)) {
                                $parentID = $pageobj->getParentID();
                                if ($parentID == 0) {
                                    break;
                                }
                                $sql = 'SELECT `titlelink` FROM ' . prefix('pages') . ' WHERE `id`=' . $parentID;
                                $result = query_single_row($sql);
                                $pageobj = new ZenpagePage($result['titlelink']);
                                $authType = "zp_page_auth_" . $pageobj->getID();
                                $check_auth = $pageobj->getPassword();
                                $check_user = $pageobj->getUser();
                            }
                        }
                    }
                }
            }
        }
        if (empty($check_auth)) {
            // anything else is controlled by the gallery credentials
            $authType = 'zp_gallery_auth';
            $check_auth = $_zp_gallery->getPassword();
            $check_user = $_zp_gallery->getUser();
        }
    }
    // Handle the login form.
    if (DEBUG_LOGIN) {
        debugLog("zp_handle_password: \$authType={$authType}; \$check_auth={$check_auth}; \$check_user={$check_user}; ");
    }
    if (isset($_POST['password']) && isset($_POST['pass'])) {
        // process login form
        if (isset($_POST['user'])) {
            $post_user = sanitize($_POST['user']);
        } else {
            $post_user = '';
        }
        $post_pass = $_POST['pass'];
        // We should not sanitize the password
        foreach (Zenphoto_Authority::$hashList as $hash => $hi) {
            $auth = Zenphoto_Authority::passwordHash($post_user, $post_pass, $hi);
            $success = $auth == $check_auth && $post_user == $check_user;
            if (DEBUG_LOGIN) {
                debugLog("zp_handle_password({$success}): \$post_user={$post_user}; \$post_pass={$post_pass}; \$check_auth={$check_auth}; \$auth={$auth}; \$hash={$hash};");
            }
            if ($success) {
                break;
            }
        }
        $success = zp_apply_filter('guest_login_attempt', $success, $post_user, $post_pass, $authType);
        if ($success) {
            // Correct auth info. Set the cookie.
            if (DEBUG_LOGIN) {
                debugLog("zp_handle_password: valid credentials");
            }
            zp_setCookie($authType, $auth);
            if (isset($_POST['redirect'])) {
                $redirect_to = sanitizeRedirect($_POST['redirect'], true);
                if (!empty($redirect_to)) {
                    header("Location: " . $redirect_to);
                    exitZP();
                }
            }
        } else {
            // Clear the cookie, just in case
            if (DEBUG_LOGIN) {
                debugLog("zp_handle_password: invalid credentials");
            }
            zp_clearCookie($authType);
            $_zp_login_error = true;
        }
        return;
    }
    if (empty($check_auth)) {
        //no password on record or admin logged in
        return;
    }
    if (($saved_auth = zp_getCookie($authType)) != '') {
        if ($saved_auth == $check_auth) {
            if (DEBUG_LOGIN) {
                debugLog("zp_handle_password: valid cookie");
            }
            return;
        } else {
            // Clear the cookie
            if (DEBUG_LOGIN) {
                debugLog("zp_handle_password: invalid cookie");
            }
            zp_clearCookie($authType);
        }
    }
}
/**
 * Prints all available pages in Zenpage
 *
 * @param string $current set to the page selected (if any)
 *
 * @return string
 */
function printZenpagePagesSelector($current)
{
    global $_zp_gallery, $_zp_zenpage;
    ?>
	<select id="pageselector" name="pageselect">
		<?php 
    $pages = $_zp_zenpage->getPages(false);
    foreach ($pages as $key => $page) {
        if ($page['titlelink'] == $current) {
            $selected = ' selected= "selected

			"';
        } else {
            $selected = '';
        }
        $pageobj = new ZenpagePage($page['titlelink']);
        $level = substr_count($pageobj->getSortOrder(), "-");
        $arrow = "";
        for ($count = 1; $count <= $level; $count++) {
            $arrow .= "» ";
        }
        echo "<option value = '" . html_encode($pageobj->getTitlelink()) . "'" . $selected . '>';
        echo $arrow . $pageobj->getTitle() . unpublishedZenphotoItemCheck($pageobj) . "</option>";
    }
    ?>
	</select>
	<?php 
}
예제 #17
0
									</div>
									<br class="clearall" />
							</div>
							<?php 
    } else {
        echo gettext('No unpublished articles');
    }
    ?>
					</fieldset>
					<?php 
    $visible = $report == 'pages';
    $items = $_zp_zenpage->getPages(false);
    $output = '';
    $c = 0;
    foreach ($items as $key => $item) {
        $itemobj = new ZenpagePage($item['titlelink']);
        if (!$itemobj->getShow()) {
            $c++;
            $output .= '<li><label><input type="checkbox" name="' . $item['titlelink'] . '" value="' . $item['titlelink'] . '" class="pagecheck" />' . $itemobj->getTitle() . '</label><a href="' . html_encode($itemobj->getLink()) . '" title="' . html_encode($itemobj->getTitle()) . '"> (' . gettext('View') . ')</a></li>';
        }
    }
    ?>
					<br class="clearall" />
					<fieldset class="smallbox">
						<legend><?php 
    reveal('pagebox', $visible);
    echo gettext('Pages not published');
    ?>
</legend>
						<?php 
    if ($report == 'pages') {
예제 #18
0
        $item = sanitize($_GET['news']);
        $obj = new ZenpageNews($item);
        $cats = $obj->getCategories();
        $categories = gettext('Categories: ');
        $count = '';
        if ($cats) {
            foreach ($cats as $cat) {
                $count++;
                $catobj = new ZenpageCategory($cat['titlelink']);
                if ($count != 1) {
                    $categories .= ', ';
                }
                $categories .= $catobj->getTitle();
            }
        }
    } elseif (isset($_GET['pages'])) {
        $item = sanitize($_GET['pages']);
        $obj = new ZenpagePage($item);
        $categories = '';
    }
    echo '<h3>' . $obj->getTitle() . '</h3>';
    echo '<p><small>' . $obj->getDatetime() . '</small></p>';
    echo $obj->getContent();
    echo $categories;
    echo '</div>';
}
?>
</div><!-- main div -->
</body>
</html>
예제 #19
0
 /**
  * Gets all pages or published ones.
  *
  * NOTE: Since this function only returns titlelinks for use with the object model it does not exclude pages that are password protected
  *
  * @param bool $published TRUE for published or FALSE for all pages including un-published
  * @param bool $toplevel TRUE for only the toplevel pages
  * @param int $number number of pages to get (NULL by default for all)
  * @param string $sorttype NULL for the standard order as sorted on the backend, "title", "date", "id", "popular", "mostrated", "toprated", "random"
  * @param string $sortdirection false for ascenting, true for descending
  * @return array
  */
 function getPages($published = NULL, $toplevel = false, $number = NULL, $sorttype = NULL, $sortdirection = NULL)
 {
     global $_zp_loggedin;
     if (is_null($sortdirection)) {
         $sortdirection = $this->getSortDirection('pages');
     }
     if (is_null($sorttype)) {
         $sorttype = $this->getSortType('pages');
     }
     if (is_null($published)) {
         $published = !zp_loggedin();
         $all = zp_loggedin(MANAGE_ALL_PAGES_RIGHTS);
     } else {
         $all = !$published;
     }
     $gettop = '';
     if ($published) {
         if ($toplevel) {
             $gettop = " AND parentid IS NULL";
         }
         $show = " WHERE `show` = 1 AND date <= '" . date('Y-m-d H:i:s') . "'" . $gettop;
     } else {
         if ($toplevel) {
             $gettop = " WHERE parentid IS NULL";
         }
         $show = $gettop;
     }
     if ($sortdirection) {
         $sortdir = ' DESC';
     } else {
         $sortdir = ' ASC';
     }
     switch ($sorttype) {
         default:
         case 'date':
             $sortorder = 'date';
             break;
         case 'lastchange':
             $sortorder = 'lastchange';
             break;
         case 'title':
             $sortorder = 'title';
             break;
         case 'id':
             $sortorder = 'id';
             break;
         case 'popular':
             $sortorder = 'hitcounter';
             break;
         case 'mostrated':
             $sortorder = 'total_votes';
             break;
         case 'toprated':
             if (empty($sortdir)) {
                 $sortdir = ' DESC';
             }
             $sortorder = '(total_value/total_votes) ' . $sortdir . ', total_value';
             break;
         case 'random':
             $sortorder = 'RAND()';
             $sortdir = '';
             break;
         default:
             $sortorder = 'sort_order';
             $sortdir = '';
             break;
     }
     $all_pages = array();
     // Disabled cache var for now because it does not return un-publishded and published if logged on index.php somehow if logged in.
     $result = query('SELECT * FROM ' . prefix('pages') . $show . ' ORDER by `' . $sortorder . '`' . $sortdir);
     if ($result) {
         while ($row = db_fetch_assoc($result)) {
             if ($all || $row['show']) {
                 $all_pages[] = $row;
             } else {
                 if ($_zp_loggedin) {
                     $page = new ZenpagePage($row['titlelink']);
                     if ($page->isMyItem(LIST_RIGHTS)) {
                         $all_pages[] = $row;
                         if ($number && count($result) >= $number) {
                             break;
                         }
                     }
                 }
             }
         }
         db_free_result($result);
     }
     return $all_pages;
 }
예제 #20
0
/**
 * @deprecated
 * @since 1.4.6
 */
function getPageLinkPath($titlelink)
{
    deprecated_functions::notify(gettext('Create an object and use the object getLink'));
    $obj = new ZenpagePage($titlelink);
    return $obj->getLink();
}