/**
 * @deprecated
 */
function zenpageHitcounter($option = 'pages', $viewonly = false, $id = NULL)
{
    deprecated_function_notify(gettext('Use getHitcounter().'));
    global $_zp_current_zenpage_page, $_zp_current_zenpage_news;
    switch ($option) {
        case "pages":
            if (is_null($id)) {
                $id = getPageID();
            }
            $dbtable = prefix('pages');
            $doUpdate = true;
            break;
        case "category":
            if (is_null($id)) {
                $id = getCurrentNewsCategoryID();
            }
            $dbtable = prefix('news_categories');
            $doUpdate = getCurrentNewsPage() == 1;
            // only count initial page for a hit on an album
            break;
        case "news":
            if (is_null($id)) {
                $id = getNewsID();
            }
            $dbtable = prefix('news');
            $doUpdate = true;
            break;
    }
    if ($option == "pages" and is_Pages() or $option == "news" and is_NewsArticle() or $option == "category" and is_NewsCategory()) {
        if (zp_loggedin(ZENPAGE_PAGES_RIGHTS | ZENPAGE_NEWS_RIGHTS) || $viewonly) {
            $doUpdate = false;
        }
        $hitcounter = "hitcounter";
        $whereID = " WHERE `id` = {$id}";
        $sql = "SELECT `" . $hitcounter . "` FROM {$dbtable} {$whereID}";
        if ($doUpdate) {
            $sql .= " FOR UPDATE";
        }
        $result = query_single_row($sql);
        $resultupdate = $result['hitcounter'];
        if ($doUpdate) {
            $resultupdate++;
            query("UPDATE {$dbtable} SET `" . $hitcounter . "`= {$resultupdate} {$whereID}");
        }
        return $resultupdate;
    }
}
/**
 * Prints the id of a page
 *
 * @return string
 */
function printPageID()
{
    echo getPageID();
}
Beispiel #3
0
function printDisqusCommentForm()
{
    global $_zp_gallery_page, $_zp_current_image, $_zp_current_album, $_zp_current_zenpage_news, $_zp_current_zenpage_page;
    $zpdisqus_shortname = getOption('zpbase_disqus_shortname');
    $comments_open = false;
    switch ($_zp_gallery_page) {
        case 'image.php':
            if (!getOption('zpbase_disqus_comment_form_images')) {
                return;
            }
            $comments_open = $_zp_current_image->getCommentsAllowed();
            $zpdisqus_id = 'image' . $_zp_current_image->getID();
            $zpdisqus_title = $_zp_current_image->getTitle();
            break;
        case 'album.php':
            if (!getOption('zpbase_disqus_comment_form_albums')) {
                return;
            }
            $comments_open = $_zp_current_album->getCommentsAllowed();
            $zpdisqus_id = 'album' . $_zp_current_album->getID();
            $zpdisqus_title = $_zp_current_album->getTitle();
            break;
        case 'news.php':
            if (!getOption('zpbase_disqus_comment_form_articles')) {
                return;
            }
            $comments_open = $_zp_current_zenpage_news->getCommentsAllowed();
            $zpdisqus_id = 'news' . getNewsID();
            $zpdisqus_title = $_zp_current_zenpage_news->getTitle();
            break;
        case 'pages.php':
            if (!getOption('zpbase_disqus_comment_form_pages')) {
                return;
            }
            $comments_open = $_zp_current_zenpage_page->getCommentsAllowed();
            $zpdisqus_id = 'page' . getPageID();
            $zpdisqus_title = $_zp_current_zenpage_page->getTitle();
            break;
    }
    if ($zpdisqus_shortname != '' && $comments_open) {
        ?>

	<div id="disqus_thread"></div>
	<script type="text/javascript">
		var disqus_shortname = '<?php 
        echo $zpdisqus_shortname;
        ?>
';
		var disqus_identifier = '<?php 
        echo $zpdisqus_id;
        ?>
';
		var disqus_title = '<?php 
        echo $zpdisqus_title;
        ?>
';
		(function() {
			var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
			dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
			(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
		})();
	</script>
	<?php 
    } elseif ($zpdisqus_shortname == '') {
        echo '<h3>' . gettext('Disqus shortname is not being provided...please contact the admin of this site') . '</h3>';
    }
}
Beispiel #4
0
/**
 * Prints a RSS link for if (class_exists('RSS')) printRSSLink() and if (class_exists('RSS')) printRSSHeaderLink()
 *
 * @param string $option type of RSS: "Gallery" feed for latest images of the whole gallery
 * 																		"Album" for latest images only of the album it is called from
 * 																		"Collection" for latest images of the album it is called from and all of its subalbums
 * 																		"Comments" for all comments of all albums and images
 * 																		"Comments-image" for latest comments of only the image it is called from
 * 																		"Comments-album" for latest comments of only the album it is called from
 * 																		"AlbumsRSS" for latest albums
 * 																		"AlbumsRSScollection" only for latest subalbums with the album it is called from
 * 															or
 * 																		"News" feed for all news articles
 * 																		"Category" for only the news articles of the category that is currently selected
 * 																		"NewsWithImages" for all news articles and latest images
 * 																		"Comments" for all news articles and pages
 * 																		"Comments-news" for comments of only the news article it is called from
 * 																		"Comments-page" for comments of only the page it is called from
 * 																		"Comments-all" for comments from all albums, images, news articels and pages
 * 																		"Pages" feed for all pages
 * @param string $lang optional to display a feed link for a specific language. Enter the locale like "de_DE" (the locale must be installed on your Zenphoto to work of course). If empty the locale set in the admin option or the language selector (getOption('locale') is used.
 * @param string $addl provided additional data for feeds (e.g. album object for album feeds, $categorylink for zenpage categories
 */
function getRSSLink($option, $lang = NULL, $addl = NULL)
{
    global $_zp_current_album, $_zp_current_image, $_zp_current_admin_obj, $_zp_current_category;
    if (strtolower($option) == 'newswithimages') {
        RSS_internal_deprecations::getRSSLink($option);
    }
    if (empty($lang)) {
        $lang = zpFunctions::getLanguageText(getOption('locale'));
    }
    $link = NULL;
    switch (strtolower($option)) {
        case 'gallery':
            if (getOption('RSS_album_image')) {
                $link = array('rss' => 'gallery');
            }
            break;
        case 'album':
            if (getOption('RSS_album_image')) {
                if (is_object($addl)) {
                    $album = $addl;
                } else {
                    $album = $_zp_current_album;
                }
                $link = array('rss' => 'gallery', 'albumname' => $album->getFileName());
                break;
            }
        case 'collection':
            if (getOption('RSS_album_image')) {
                if (is_object($addl)) {
                    $album = $addl;
                } else {
                    $album = $_zp_current_album;
                }
                $link = array('rss' => 'gallery', 'folder' => $album->getFileName());
            }
            break;
        case 'comments':
            if (getOption('RSS_comments')) {
                $link = array('rss' => 'comments', 'type' => 'gallery');
            }
            break;
        case 'comments-image':
            if (getOption('RSS_comments')) {
                $link = array('rss' => 'comments', 'id' => (string) $_zp_current_image->getID(), 'type' => 'image');
            }
            break;
        case 'comments-album':
            if (getOption('RSS_comments')) {
                $link = array('rss' => 'comments', 'id' => (string) $_zp_current_album->getID(), 'type' => 'album');
            }
            break;
        case 'albumsrss':
            if (getOption('RSS_album_image')) {
                $link = array('rss' => 'gallery', 'albumsmode' => '');
            }
            break;
        case 'albumsrsscollection':
            if (getOption('RSS_album_image')) {
                $link = array('rss' => 'gallery', 'folder' => $_zp_current_album->getFileName(), 'albumsmode' => '');
            }
            break;
        case 'pages':
            if (getOption('RSS_pages')) {
                $link = array('rss' => 'pages');
            }
            break;
        case 'news':
            if (getOption('RSS_articles')) {
                $link = array('rss' => 'news');
            }
            break;
        case 'category':
            if (getOption('RSS_articles')) {
                if (empty($addl) && !is_null($_zp_current_category)) {
                    $addl = $_zp_current_category->getTitlelink();
                }
                if (empty($addl)) {
                    $link = array('rss' => 'news');
                } else {
                    $link = array('rss' => 'news', 'category' => $addl);
                }
            }
            break;
        case 'newswithimages':
            if (getOption('RSS_articles')) {
                $link = array('rss' => 'news', 'withimages' => '');
            }
            break;
        case 'comments':
            if (getOption('RSS_article_comments')) {
                $link = array('comments' => 1, 'type' => 'zenpage');
            }
            break;
        case 'comments-news':
            if (getOption('RSS_article_comments')) {
                $link = array('rss' => 'comments', 'id' => (string) getNewsID(), 'type' => 'news');
            }
            break;
        case 'comments-page':
            if (getOption('RSS_article_comments')) {
                $link = array('rss' => 'comments', 'id' => (string) getPageID(), 'type' => 'page');
            }
            break;
        case 'comments-all':
            if (getOption('RSS_article_comments')) {
                $link = array('rss' => 'comments', 'type' => 'allcomments');
            }
            break;
    }
    if (is_array($link)) {
        $link['lang'] = $lang;
        if (zp_loggedin() && getOption('RSS_portable_link')) {
            $link['user'] = (string) $_zp_current_admin_obj->getID();
            $link['token'] = Zenphoto_Authority::passwordHash(serialize($link), '');
        }
        $uri = WEBPATH . '/index.php?' . str_replace('=&', '&', http_build_query($link));
        return $uri;
    }
    return NULL;
}
/**
 * Prints a RSS link
 *
 * @param string $option type of RSS: "News" feed for all news articles
 * 																		"Category" for only the news articles of the category that is currently selected
 * 																		"NewsWithImages" for all news articles and latest images
 * 																		"Comments" for all news articles and pages
 * 																		"Comments-news" for comments of only the news article it is called from
 * 																		"Comments-page" for comments of only the page it is called from
 * 																		"Comments-all" for comments from all albums, images, news articels and pages
 * @param string $categorylink The specific category you want a RSS feed from (only 'Category' mode)
 * @param string $prev text to before before the link
 * @param string $linktext title of the link
 * @param string $next text to appear after the link
 * @param bool $printIcon print an RSS icon beside it? if true, the icon is zp-core/images/rss.png
 * @param string $class css class
 * @param string $lang optional to display a feed link for a specific language (currently works for latest images only). Enter the locale like "de_DE" (the locale must be installed on your Zenphoto to work of course). If empty the locale set in the admin option or the language selector (getOption('locale') is used.
 */
function printZenpageRSSLink($option = 'News', $categorylink = '', $prev = '', $linktext = '', $next = '', $printIcon = true, $class = null, $lang = NULL)
{
    global $_zp_current_category;
    if ($printIcon) {
        $icon = ' <img src="' . FULLWEBPATH . '/' . ZENFOLDER . '/images/rss.png" alt="RSS Feed" />';
    } else {
        $icon = '';
    }
    if (!is_null($class)) {
        $class = 'class="' . $class . '"';
    }
    if (empty($lang)) {
        $lang = getOption("locale");
    }
    if ($option == 'Category') {
        if (!is_null($categorylink)) {
            $categorylink = '&amp;category=' . sanitize($categorylink);
        } elseif (empty($categorylink) and !is_null($_zp_current_category)) {
            $categorylink = '&amp;category=' . $_zp_current_category->getTitlelink();
        } else {
            $categorylink = '';
        }
    }
    $linktext = html_encode($linktext);
    switch ($option) {
        case "News":
            if (getOption('RSS_articles')) {
                echo $prev . "<a {$class} href=\"" . WEBPATH . "/index.php?rss-news&amp;lang=" . $lang . "\" title=\"" . gettext("News RSS") . "\" rel=\"nofollow\">" . $linktext . "{$icon}</a>" . $next;
            }
            break;
        case "Category":
            if (getOption('RSS_articles')) {
                echo $prev . "<a {$class} href=\"" . WEBPATH . "/index.php?rss-news&amp;lang=" . $lang . $categorylink . "\" title=\"" . gettext("News Category RSS") . "\" rel=\"nofollow\">" . $linktext . "{$icon}</a>" . $next;
            }
            break;
        case "NewsWithImages":
            if (getOption('RSS_articles')) {
                echo $prev . "<a {$class} href=\"" . WEBPATH . "/index.php?rss-news&amp;withimages&amp;lang=" . $lang . "\" title=\"" . gettext("News and Gallery RSS") . "\"  rel=\"nofollow\">" . $linktext . "{$icon}</a>" . $next;
            }
            break;
        case "Comments":
            if (getOption('RSS_article_comments')) {
                echo $prev . "<a {$class} href=\"" . WEBPATH . "/index.php?rss-comments&amp;type=zenpage&amp;lang=" . $lang . "\" title=\"" . gettext("Zenpage Comments RSS") . "\"  rel=\"nofollow\">" . $linktext . "{$icon}</a>" . $next;
            }
            break;
        case "Comments-news":
            if (getOption('RSS_article_comments')) {
                echo $prev . "<a {$class} href=\"" . WEBPATH . "/index.php?rss-comments&amp;id=" . getNewsID() . "&amp;title=" . urlencode(getNewsTitle()) . "&amp;type=news&amp;lang=" . $lang . "\" title=\"" . gettext("News article comments RSS") . "\"  rel=\"nofollow\">" . $linktext . "{$icon}</a>" . $next;
            }
            break;
        case "Comments-page":
            if (getOption('RSS_article_comments')) {
                echo $prev . "<a {$class} href=\"" . WEBPATH . "/index.php?rss-comments&amp;id=" . getPageID() . "&amp;title=" . urlencode(getPageTitle()) . "&amp;type=page&amp;lang=" . $lang . "\" title=\"" . gettext("Page Comments RSS") . "\"  rel=\"nofollow\">" . $linktext . "{$icon}</a>" . $next;
            }
            break;
        case "Comments-all":
            if (getOption('RSS_article_comments')) {
                echo $prev . "<a {$class} href=\"" . WEBPATH . "/index.php?rss-comments&amp;type=allcomments&amp;lang=" . $lang . "\" title=\"" . gettext("Page Comments RSS") . "\"  rel=\"nofollow\">" . $linktext . "{$icon}</a>" . $next;
            }
            break;
    }
}
Beispiel #6
0
 if ($xmlStatusResponse) {
     do {
         $xmlStatusResponse = simplexml_load_file($checkStatusURL);
         $completed = checkTestComplete($xmlStatusResponse);
         if (!$completed) {
             sleep(20);
         }
     } while (!$completed);
     //echo "status text >>>>".$xmlStatusResponse->data->statusText; exit;
     if ($completed) {
         $resultsURL = "http://www.webpagetest.org/xmlResult/" . $value['test_id'] . "/";
         //echo "<br/>".$resultsURL;
         $xmlResultsResponse = simplexml_load_file($resultsURL);
         if ($xmlStatusResponse) {
             //echo $xmlResultsResponse;exit;
             $pageID = getPageID($xmlResultsResponse->data->testUrl);
             $collection = $db->parameterdata_counters;
             $user_collection = $db->parameterdata;
             /*$document = array( 
             			"_id" => getNextSequence("parameterdataid"),
             			"datasource_id" => 2,
             			"parameter_id" => 1,
             			"page_id" => $pageID,
             			"value" => "",
             			"data" => $xmlResultsResponse->data,
             			"updated_time" => new MongoDate()
             		);*/
             $pageScore = (int) 78;
             //echo "PageScore".$pageScore;
             $loadTime = (int) $xmlResultsResponse->data->average->firstView->loadTime / 1000;
             $ttfb = (int) $xmlResultsResponse->data->average->firstView->TTFB / 1000;
Beispiel #7
0
function addpage($pagedef, $menu_id)
{
    $ret = null;
    $parent = $pagedef['parent'];
    $parentid = 0;
    $test = get_page_by_path($parent);
    if (!empty($test)) {
        $parentid = $test->ID;
    }
    // try to find if this page already exists
    $pid = getPageID($parent, $pagedef['url'], $pagedef['title']);
    // create the post
    $post = array();
    $post['ID'] = $pid;
    $post['menu_order'] = $pagedef['order'];
    $post['post_name'] = $pagedef['url'];
    if (empty($post['post_name'])) {
        $post['post_name'] = null;
    }
    $post['post_title'] = $pagedef['title'];
    $post['post_status'] = 'publish';
    $post['post_parent'] = $parentid;
    $post['comment_status'] = 'closed';
    // set the default content
    $content = $pagedef['content'];
    if ($content != '') {
        /* we check if the content is pointing to a local file */
        if (strpos($content, '/') === 0) {
            $cpath = get_local(plugins_url($content, __FILE__));
            $t = file_get_contents($cpath);
            $m = new Mustache_Engine();
            /* we need to call this function so the $bapi_all_options gets populated */
            bapi_wp_site_options();
            $wrapper = getbapisolutiondata();
            $string = $m->render($t, $wrapper);
        } else {
            /* if not is pointing to a json object */
            $jsonContent = file_get_contents($content);
            if ($jsonContent != FALSE) {
                $jsonObjContent = json_decode($jsonContent);
                $string = $jsonObjContent->result[0]->DocText;
            } else {
                $string = '';
            }
        }
        $string = str_replace("\t", '', $string);
        // remove tabs
        $string = str_replace("\n", '', $string);
        // remove new lines
        $string = str_replace("\r", '', $string);
        // remove carriage returns
        $post['post_content'] = $string;
        //utf8_encode($string);
    } else {
        $post['post_content'] = '';
    }
    $post['post_type'] = 'page';
    $action = "Added";
    if ($pid == 0) {
        $pid = wp_insert_post($post, $error);
    } else {
        $action = "Edited";
        wp_update_post($post);
    }
    add_post_meta($pid, 'bapi_page_id', $pagedef['intid'], true);
    update_post_meta($pid, "_wp_page_template", $pagedef['template']);
    $miid = 0;
    $addtomenu = $pagedef['addtomenu'] == 'true';
    if ($addtomenu && !doesNavMenuExist($pid)) {
        $miid = addtonav($pid, $menu_id, $post, $parent, $ret);
    }
    if ($post['post_title'] == 'Home') {
        update_option('page_on_front', $pid);
        update_option('show_on_front', 'page');
    }
    if ($post['post_title'] == 'Blog') {
        update_option('page_for_posts', $pid);
    }
    return array('action' => $action, 'post_title' => $post['post_title'], 'post_id' => $pid, 'miid' => $miid, 'menu_id' => $menu_id, 'add_to_nav' => $ret);
}
Beispiel #8
0
    static function admin_toolbox_pages($redirect, $zf)
    {
        global $_zp_CMS;
        if (zp_loggedin(ZENPAGE_PAGES_RIGHTS) && $_zp_CMS && $_zp_CMS->pages_enabled) {
            // page is zenpage page--provide edit, delete, and add links
            echo "<li><a href=\"" . $zf . '/' . PLUGIN_FOLDER . "/zenpage/admin-edit.php?page&amp;edit&amp;titlelink=" . urlencode(getPageTitlelink()) . "&amp;subpage=object\">" . gettext("Edit Page") . "</a></li>";
            if (GALLERY_SESSION) {
                // XSRF defense requires sessions
                ?>
				<li><a href="javascript:confirmDelete('<?php 
                echo $zf . '/' . PLUGIN_FOLDER;
                ?>
/zenpage/page-admin.php?del=<?php 
                echo getPageID();
                ?>
&amp;XSRFToken=<?php 
                echo getXSRFToken('delete');
                ?>
',deletePage)"
							 title="<?php 
                echo gettext("Delete page");
                ?>
"><?php 
                echo gettext("Delete Page");
                ?>
					</a></li>
				<?php 
            }
            echo "<li><a href=\"" . FULLWEBPATH . "/" . ZENFOLDER . '/' . PLUGIN_FOLDER . "/zenpage/admin-edit.php?page&amp;add\">" . gettext("Add Page") . "</a></li>";
        }
        return $redirect . '&amp;title=' . urlencode(getPageTitlelink());
    }
Beispiel #9
0
 }
 print "" . $progress[$j % 4];
 $j++;
 $user = $parts[4] == 'Anonymous' ? '' : $parts[4];
 $ipall = '';
 if (($p = strpos($addr, ',')) !== false) {
     $ip = substr($addr, 0, $p);
     $ipall = $addr;
 } else {
     $ip = $addr;
 }
 $ip2long = sprintf("%u", ip2long($ip));
 $page_id = 0;
 $pagename = $DBInfo->keyToPagename($page_key);
 if ($db) {
     if (($id = getPageID($pagename, $db)) !== false) {
         $page_id = $id;
     } else {
         $page_id = addPage($pagename, $curid, $db, $mtime);
         // page creation time
         if ($page_id < 0) {
             echo "FATAL: Unable to add page!\n";
             exit;
         }
         // page added successfully
         if ($page_id == $curid) {
             $curid++;
         }
     }
 } else {
     if (file_exists($pages_dir . '/' . $page_key)) {
Beispiel #10
0
<?
	include("includes.inc.php");
	ob_start();
	initSession();
	$menu=makeMenu();
		
	showPage(getPageID());
?>
Beispiel #11
0
function getPageTitleValue()
{
    switch (getPageID()) {
        case '1':
            return "Sobre Nós";
        case '2':
            return "Planos";
        case '3':
            return "Cases";
        case '4':
            return "Contato";
        case '6':
        case '7':
            return "Blog";
        case '8':
            return "Clientes";
        default:
            return "KMS";
    }
}
/**
 * Prints the clickable drop down toolbox on any theme page with generic admin helpers
 * @param string $id the html/css theming id
 */
function printAdminToolbox($id = 'admin')
{
    global $_zp_current_album, $_zp_current_image, $_zp_current_search, $_zp_gallery_page, $_zp_gallery;
    if (zp_loggedin()) {
        $protocol = SERVER_PROTOCOL;
        if ($protocol == 'https_admin') {
            $protocol = 'https';
        }
        $zf = $protocol . '://' . $_SERVER['HTTP_HOST'] . WEBPATH . "/" . ZENFOLDER;
        $dataid = $id . '_data';
        $page = getCurrentPage();
        $redirect = '';
        ?>
		<script type="text/javascript">
			// <!-- <![CDATA[
			function newAlbum(folder,albumtab) {
				var album = prompt('<?php 
        echo gettext('New album name?');
        ?>
', '<?php 
        echo gettext('new album');
        ?>
');
				if (album) {
					launchScript('<?php 
        echo $zf;
        ?>
/admin-edit.php',['action=newalbum','album='+encodeURIComponent(folder),'name='+encodeURIComponent(album),'albumtab='+albumtab,'XSRFToken=<?php 
        echo getXSRFToken('newalbum');
        ?>
']);
				}
			}
			// ]]> -->
		</script>
		<?php 
        echo '<div id="' . $id . '">' . "\n" . '<h3><a href="javascript:toggle(' . "'" . $dataid . "'" . ');">' . gettext('Admin Toolbox') . '</a></h3>' . "\n" . "\n</div>";
        echo '<div id="' . $dataid . '" style="display: none;">' . "\n";
        // open the list--all links go between here and the close of the list below
        echo "<ul style='list-style-type: none;'>";
        // generic link to Admin.php
        echo "<li>";
        printLink($zf . '/admin.php', gettext("Admin"), NULL, NULL, NULL);
        echo "</li>\n";
        // setup for return links
        if (isset($_GET['p'])) {
            $redirect = "&amp;p=" . urlencode(sanitize($_GET['p']));
        }
        if ($page > 1) {
            $redirect .= "&amp;page={$page}";
        }
        if (zp_loggedin(OPTIONS_RIGHTS)) {
            // options link for all admins with options rights
            echo "<li>";
            printLink($zf . '/admin-options.php?tab=general', gettext("Options"), NULL, NULL, NULL);
            echo "</li>\n";
        }
        zp_apply_filter('admin_toolbox_global');
        $gal = getOption('custom_index_page');
        if (empty($gal) || !file_exists(SERVERPATH . '/' . THEMEFOLDER . '/' . $_zp_gallery->getCurrentTheme() . '/' . internalToFilesystem($gal) . '.php')) {
            $gal = 'index.php';
        } else {
            $gal .= '.php';
        }
        if ($_zp_gallery_page === $gal) {
            // script is either index.php or the gallery index page
            if (zp_loggedin(ALBUM_RIGHTS)) {
                // admin has edit rights so he can sort the gallery (at least those albums he is assigned)
                ?>
				<li><?php 
                printLink($zf . '/admin-edit.php?page=edit', gettext("Sort Gallery"), NULL, NULL, NULL);
                ?>
				</li>
				<?php 
            }
            if (zp_loggedin(UPLOAD_RIGHTS)) {
                // admin has upload rights, provide an upload link for a new album
                if (GALLERY_SESSION) {
                    // XSRF defense requires sessions
                    ?>
					<li><a href="javascript:newAlbum('',true);"><?php 
                    echo gettext("New Album");
                    ?>
</a></li>
					<?php 
                }
            }
            zp_apply_filter('admin_toolbox_gallery');
        } else {
            if ($_zp_gallery_page === 'album.php') {
                // script is album.php
                $albumname = $_zp_current_album->name;
                if ($_zp_current_album->isMyItem(ALBUM_RIGHTS)) {
                    // admin is empowered to edit this album--show an edit link
                    echo "<li>";
                    printLink($zf . '/admin-edit.php?page=edit&album=' . pathurlencode($_zp_current_album->name), gettext('Edit album'), NULL, NULL, NULL);
                    echo "</li>\n";
                    if (!$_zp_current_album->isDynamic()) {
                        if ($_zp_current_album->getNumAlbums()) {
                            ?>
						<li><?php 
                            printLink($zf . '/admin-edit.php?page=edit&album=' . pathurlencode($albumname) . '&tab=subalbuminfo', gettext("Sort subalbums"), NULL, NULL, NULL);
                            ?>
						</li>
						<?php 
                        }
                        if ($_zp_current_album->getNumImages() > 0) {
                            ?>
						<li><?php 
                            printLink($zf . '/admin-albumsort.php?page=edit&album=' . pathurlencode($albumname) . '&tab=sort', gettext("Sort album images"), NULL, NULL, NULL);
                            ?>
						</li>
						<?php 
                        }
                    }
                    // and a delete link
                    if (GALLERY_SESSION) {
                        // XSRF defense requires sessions
                        ?>
					<li><a
						href="javascript:confirmDeleteAlbum('<?php 
                        echo $zf;
                        ?>
/admin-edit.php?page=edit&amp;action=deletealbum&amp;album=<?php 
                        echo urlencode(pathurlencode($albumname));
                        ?>
&amp;XSRFToken=<?php 
                        echo getXSRFToken('delete');
                        ?>
');"
						title="<?php 
                        echo gettext('Delete the album');
                        ?>
"><?php 
                        echo gettext('Delete album');
                        ?>
</a>
					</li>
					<?php 
                    }
                }
                if ($_zp_current_album->isMyItem(UPLOAD_RIGHTS) && !$_zp_current_album->isDynamic()) {
                    // provide an album upload link if the admin has upload rights for this album and it is not a dynamic album
                    ?>
				<li><?php 
                    printLink($zf . '/admin-upload.php?album=' . pathurlencode($albumname), gettext("Upload Here"), NULL, NULL, NULL);
                    ?>
				</li>
				<?php 
                    if (GALLERY_SESSION) {
                        // XSRF defense requires sessions
                        ?>
					<li><a
						href="javascript:newAlbum('<?php 
                        echo pathurlencode($albumname);
                        ?>
',true);"><?php 
                        echo gettext("New Album Here");
                        ?>
</a>
					</li>
					<?php 
                    }
                }
                // set the return to this album/page
                zp_apply_filter('admin_toolbox_album', $albumname);
                $redirect = "&amp;album=" . pathurlencode($albumname);
                if ($page > 1) {
                    $redirect .= "&amp;page={$page}";
                }
            } else {
                if ($_zp_gallery_page === 'image.php') {
                    // script is image.php
                    if (!$_zp_current_album->isDynamic()) {
                        // don't provide links when it is a dynamic album
                        $albumname = $_zp_current_album->name;
                        $imagename = $_zp_current_image->filename;
                        if ($_zp_current_album->isMyItem(ALBUM_RIGHTS)) {
                            // if admin has edit rights on this album, provide a delete link for the image.
                            if (GALLERY_SESSION) {
                                // XSRF defense requires sessions
                                ?>
						<li><a href="javascript:confirmDelete('<?php 
                                echo $zf;
                                ?>
/admin-edit.php?page=edit&amp;action=deleteimage&amp;album=<?php 
                                echo urlencode(pathurlencode($albumname));
                                ?>
&amp;image=<?php 
                                echo urlencode($imagename);
                                ?>
&amp;XSRFToken=<?php 
                                echo getXSRFToken('delete');
                                ?>
',deleteImage);"
										title="<?php 
                                echo gettext("Delete the image");
                                ?>
"><?php 
                                echo gettext("Delete image");
                                ?>
</a></li>
						<?php 
                            }
                            ?>
					<li><a href="<?php 
                            echo $zf;
                            ?>
/admin-edit.php?page=edit&amp;album=<?php 
                            echo pathurlencode($albumname);
                            ?>
&amp;image=<?php 
                            echo urlencode($imagename);
                            ?>
&amp;tab=imageinfo#IT"
						title="<?php 
                            echo gettext('Edit this image');
                            ?>
"><?php 
                            echo gettext('Edit image');
                            ?>
</a></li>
					<?php 
                        }
                        // set return to this image page
                        zp_apply_filter('admin_toolbox_image', $albumname, $imagename);
                        $redirect = "&amp;album=" . pathurlencode($albumname) . "&amp;image=" . urlencode($imagename);
                    }
                } else {
                    if ($_zp_gallery_page === 'search.php' && !empty($_zp_current_search->words)) {
                        // script is search.php with a search string
                        if (zp_loggedin(UPLOAD_RIGHTS)) {
                            // if admin has edit rights allow him to create a dynamic album from the search
                            echo "<li><a href=\"" . $zf . "/admin-dynamic-album.php\" title=\"" . gettext("Create an album from the search") . "\">" . gettext("Create Album") . "</a></li>";
                        }
                        zp_apply_filter('admin_toolbox_search');
                        $redirect = "&amp;p=search" . $_zp_current_search->getSearchParams() . "&amp;page={$page}";
                    }
                }
            }
        }
        // zenpage script pages
        if (function_exists('is_NewsArticle')) {
            if (is_NewsArticle()) {
                // page is a NewsArticle--provide zenpage edit, delete, and Add links
                $titlelink = getNewsTitlelink();
                $redirect .= '&amp;title=' . urlencode($titlelink);
            }
            if (is_Pages()) {
                // page is zenpage page--provide edit, delete, and add links
                $titlelink = getPageTitlelink();
                $redirect .= '&amp;title=' . urlencode($titlelink);
            }
            if (zp_loggedin(ZENPAGE_NEWS_RIGHTS)) {
                // admin has zenpage rights, provide link to the Zenpage admin tab
                echo "<li><a href=\"" . $zf . '/' . PLUGIN_FOLDER . "/zenpage/admin-news-articles.php\">" . gettext("News") . "</a></li>";
                if (is_NewsArticle()) {
                    // page is a NewsArticle--provide zenpage edit, delete, and Add links
                    echo "<li><a href=\"" . $zf . '/' . PLUGIN_FOLDER . "/zenpage/admin-edit.php?newsarticle&amp;edit&amp;titlelink=" . urlencode($titlelink) . "\">" . gettext("Edit Article") . "</a></li>";
                    if (GALLERY_SESSION) {
                        // XSRF defense requires sessions
                        ?>
						<li><a href="javascript:confirmDelete('<?php 
                        echo $zf . '/' . PLUGIN_FOLDER;
                        ?>
/zenpage/admin-news-articles.php?del=<?php 
                        echo getNewsID();
                        ?>
&amp;XSRFToken=<?php 
                        echo getXSRFToken('delete');
                        ?>
',deleteArticle)"
							title="<?php 
                        echo gettext("Delete article");
                        ?>
"><?php 
                        echo gettext("Delete Article");
                        ?>
</a></li>
						<?php 
                    }
                    echo "<li><a href=\"" . $zf . '/' . PLUGIN_FOLDER . "/zenpage/admin-edit.php?newsarticle&amp;add\">" . gettext("Add Article") . "</a></li>";
                    zp_apply_filter('admin_toolbox_news', $titlelink);
                }
            }
            if (zp_loggedin(ZENPAGE_PAGES_RIGHTS)) {
                echo "<li><a href=\"" . $zf . '/' . PLUGIN_FOLDER . "/zenpage/admin-pages.php\">" . gettext("Pages") . "</a></li>";
                if (is_Pages()) {
                    // page is zenpage page--provide edit, delete, and add links
                    echo "<li><a href=\"" . $zf . '/' . PLUGIN_FOLDER . "/zenpage/admin-edit.php?page&amp;edit&amp;titlelink=" . urlencode($titlelink) . "\">" . gettext("Edit Page") . "</a></li>";
                    if (GALLERY_SESSION) {
                        // XSRF defense requires sessions
                        ?>
						<li><a href="javascript:confirmDelete('<?php 
                        echo $zf . '/' . PLUGIN_FOLDER;
                        ?>
/zenpage/page-admin.php?del=<?php 
                        echo getPageID();
                        ?>
&amp;XSRFToken=<?php 
                        echo getXSRFToken('delete');
                        ?>
',deletePage)"
							title="<?php 
                        echo gettext("Delete page");
                        ?>
"><?php 
                        echo gettext("Delete Page");
                        ?>
</a></li>
						<?php 
                    }
                    echo "<li><a href=\"" . FULLWEBPATH . "/" . ZENFOLDER . '/' . PLUGIN_FOLDER . "/zenpage/admin-edit.php?page&amp;add\">" . gettext("Add Page") . "</a></li>";
                    zp_apply_filter('admin_toolbox_page', $titlelink);
                }
            }
        }
        // logout link
        $sec = (int) (SERVER_PROTOCOL == 'https' & true);
        $link = FULLWEBPATH . '/index.php?logout=' . $sec . $redirect;
        ?>
		<li><a href="<?php 
        echo $link;
        ?>
"><?php 
        echo gettext("Logout");
        ?>
</a></li>
		<?php 
        // close the list
        echo "</ul>\n";
        echo "</div>\n";
    }
}
/**
 * Prints the clickable drop down toolbox on any theme page with generic admin helpers
 * @param string $id the html/css theming id
 */
function printAdminToolbox($id = 'admin')
{
    global $_zp_current_album, $_zp_current_image, $_zp_current_search, $_zp_loggedin, $_zp_gallery_page;
    if (zp_loggedin()) {
        echo '<script type="text/javascript" src="' . WEBPATH . '/' . ZENFOLDER . '/js/admin.js"></script>';
        $zf = WEBPATH . "/" . ZENFOLDER;
        $dataid = $id . '_data';
        $page = getCurrentPage();
        $redirect = '';
        echo '<div id="' . $id . '">' . "\n" . '<h3><a href="javascript: toggle(' . "'" . $dataid . "'" . ');">' . gettext('Admin Toolbox') . '</a></h3>' . "\n" . "\n</div>";
        echo '<div id="' . $dataid . '" style="display: none;">' . "\n";
        // open the list--all links go between here and the close of the list below
        echo "<ul style='list-style-type: none;'>";
        // generic link to Admin.php
        echo "<li>";
        printAdminLink(gettext('Admin'), '', "</li>\n");
        // setup for return links
        if (isset($_GET['p'])) {
            $redirect = "&amp;p=" . $_GET['p'];
        }
        if ($page > 1) {
            $redirect .= "&amp;page={$page}";
        }
        if ($_zp_loggedin & (ADMIN_RIGHTS | OPTIONS_RIGHTS)) {
            // options link for all admins with options rights
            echo "<li>";
            printLink($zf . '/admin-options.php', gettext("Options"), NULL, NULL, NULL);
            echo "</li>\n";
        }
        apply_filter('admin_toolbox_global');
        $gal = getOption('custom_index_page');
        if (empty($gal) || !file_exists(SERVERPATH . '/' . THEMEFOLDER . '/' . getOption('current_theme') . '/' . UTF8ToFilesystem($gal) . '.php')) {
            $gal = 'index.php';
        } else {
            $gal .= '.php';
        }
        if ($_zp_gallery_page === $gal) {
            // script is either index.php or the gallery index page
            if ($_zp_loggedin & (ADMIN_RIGHTS | EDIT_RIGHTS)) {
                // admin has edit rights so he can sort the gallery (at least those albums he is assigned)
                echo "<li>";
                printSortableGalleryLink(gettext('Sort gallery'), gettext('Manual sorting'));
                echo "</li>\n";
            }
            if ($_zp_loggedin & (ADMIN_RIGHTS | UPLOAD_RIGHTS)) {
                // admin has upload rights, provide an upload link for a new album
                echo "<li>";
                printLink($zf . '/admin-upload.php', gettext("New album"), NULL, NULL, NULL);
                echo "</li>\n";
            }
            apply_filter('admin_toolbox_gallery');
        } else {
            if ($_zp_gallery_page === 'album.php') {
                // script is album.php
                $albumname = $_zp_current_album->name;
                if (isMyAlbum($albumname, EDIT_RIGHTS)) {
                    // admin is empowered to edit this album--show an edit link
                    echo "<li>";
                    printSubalbumAdmin(gettext('Edit album'), '', "</li>\n");
                    if (!$_zp_current_album->isDynamic()) {
                        echo "<li>";
                        printSortableAlbumLink(gettext('Sort album'), gettext('Manual sorting'));
                        echo "</li>\n";
                    }
                    // and a delete link
                    echo "<li><a href=\"javascript: confirmDeleteAlbum('" . $zf . "/admin-edit.php?page=edit&amp;action=deletealbum&amp;album=" . urlencode(urlencode($albumname)) . "','" . js_encode(gettext("Are you sure you want to delete this entire album?")) . "','" . js_encode(gettext("Are you Absolutely Positively sure you want to delete the album? THIS CANNOT BE UNDONE!")) . "');\" title=\"" . gettext("Delete the album") . "\">" . gettext("Delete album") . "</a></li>\n";
                }
                if (isMyAlbum($albumname, UPLOAD_RIGHTS) && !$_zp_current_album->isDynamic()) {
                    // provide an album upload link if the admin has upload rights for this album and it is not a dynamic album
                    echo "<li>";
                    printLink($zf . '/admin-upload.php?album=' . urlencode($albumname), gettext("Upload Here"), NULL, NULL, NULL);
                    echo "</li>\n";
                    echo "<li>";
                    printLink($zf . '/admin-upload.php?new&album=' . urlencode($albumname), gettext("New Album Here"), NULL, NULL, NULL);
                    echo "</li>\n";
                }
                // set the return to this album/page
                apply_filter('admin_toolbox_album');
                $redirect = "&amp;album=" . urlencode($albumname) . "&amp;page={$page}";
            } else {
                if ($_zp_gallery_page === 'image.php') {
                    // script is image.php
                    $albumname = $_zp_current_album->name;
                    $imagename = urlencode($_zp_current_image->filename);
                    if (isMyAlbum($albumname, EDIT_RIGHTS)) {
                        // if admin has edit rights on this album, provide a delete link for the image.
                        echo "<li><a href=\"javascript: confirmDeleteImage('" . $zf . "/admin-edit.php?page=edit&amp;action=deleteimage&amp;album=" . urlencode(urlencode($albumname)) . "&amp;image=" . urlencode($imagename) . "','" . js_encode(gettext("Are you sure you want to delete the image? THIS CANNOT BE UNDONE!")) . "');\" title=\"" . gettext("Delete the image") . "\">" . gettext("Delete image") . "</a>";
                        echo "</li>\n";
                        echo '<li><a href="' . $zf . '/admin-edit.php?page=edit&amp;album=' . urlencode($albumname) . '&amp;image=' . urlencode($imagename) . '&amp;tab=imageinfo#IT" title="' . gettext('Edit this image') . '">' . gettext('Edit image') . '</a></li>' . "\n";
                    }
                    // set return to this image page
                    apply_filter('admin_toolbox_image');
                    $redirect = "&amp;album=" . urlencode($albumname) . "&amp;image={$imagename}";
                } else {
                    if ($_zp_gallery_page === 'search.php' && !empty($_zp_current_search->words)) {
                        // script is search.php with a search string
                        if ($_zp_loggedin & (ADMIN_RIGHTS | UPLOAD_RIGHTS)) {
                            // if admin has edit rights allow him to create a dynamic album from the search
                            echo "<li><a href=\"" . $zf . "/admin-dynamic-album.php\" title=\"" . gettext("Create an album from the search") . "\">" . gettext("Create Album") . "</a></li>";
                        }
                        apply_filter('admin_toolbox_search');
                        $redirect = "&amp;p=search" . $_zp_current_search->getSearchParams() . "&amp;page={$page}";
                    }
                }
            }
        }
        // zenpage script pages
        if (function_exists('is_NewsArticle')) {
            if ($_zp_loggedin & (ADMIN_RIGHTS | ZENPAGE_RIGHTS)) {
                // admin has zenpage rights, provide link to the zenpage admin tab
                echo "<li><a href=\"" . $zf . "/plugins/zenpage/\">" . gettext("Zenpage") . "</a></li>";
                if (is_NewsArticle()) {
                    // page is a NewsArticle--provide zenpage edit, delete, and Add links
                    echo "<li><a href=\"" . $zf . "/plugins/zenpage/admin-edit.php?newsarticle&amp;edit&amp;titlelink=" . urlencode(getNewsTitlelink()) . "\">" . gettext("Edit Article") . "</li>";
                    ?>
 
					<li><a href="javascript: confirmDeleteImage('<?php 
                    echo $zf;
                    ?>
/plugins/zenpage/news-article-admin.php?del=<?php 
                    echo getNewsID();
                    ?>
','<?php 
                    echo js_encode(gettext("Are you sure you want to delete this article? THIS CANNOT BE UNDONE!"));
                    ?>
')" title="<?php 
                    echo gettext("Delete article");
                    ?>
"><?php 
                    echo gettext("Delete Article");
                    ?>
</a></li>
					<?php 
                    echo "<li><a href=\"" . $zf . "/plugins/zenpage/admin-edit.php?newsarticle&amp;add\">" . gettext("Add Article") . "</li>";
                }
                if (is_Pages()) {
                    // page is zenpage page--provide edit, delete, and add links
                    echo "<li><a href=\"" . $zf . "/plugins/zenpage/admin-edit.php?page&amp;edit&amp;titlelink=" . urlencode(getPageTitlelink()) . "\">" . gettext("Edit Page") . "</li>";
                    ?>
 
					<li><a href="javascript: confirmDeleteImage('<?php 
                    echo $zf;
                    ?>
/plugins/zenpage/page-admin.php?del=<?php 
                    echo getPageID();
                    ?>
','<?php 
                    echo js_encode(gettext("Are you sure you want to delete this page? THIS CANNOT BE UNDONE!"));
                    ?>
')" title="<?php 
                    echo gettext("Delete page");
                    ?>
"><?php 
                    echo gettext("Delete Page");
                    ?>
</a></li>
					<?php 
                    echo "<li><a href=\"" . FULLWEBPATH . "/" . ZENFOLDER . "/plugins/zenpage/admin-edit.php?page&amp;add\">" . gettext("Add Page") . "</li>";
                }
            }
            apply_filter('admin_toolbox_news');
        }
        // logout link
        echo "<li><a href=\"" . $zf . "/admin.php?logout{$redirect}\">" . gettext("Logout") . "</a></li>\n";
        // close the list
        echo "</ul>\n";
        echo "</div>\n";
    }
}