Example #1
0
$admins = $_zp_authority->getAdministrators('all');
foreach ($admins as $key => $user) {
    if ($user['valid'] && !($user['rights'] & ADMIN_RIGHTS)) {
        if ($subscription) {
            $admins[$key]['expires'] = strtotime($user['date']) + $subscription;
        } else {
            $admins[$key]['expires'] = 0;
        }
    } else {
        unset($admins[$key]);
    }
}
if ($subscription) {
    $admins = sortMultiArray($admins, array('expires'), false);
} else {
    $admins = sortMultiArray($admins, array('lastlogon'), true);
}
$adminordered = array();
foreach ($admins as $user) {
    $adminordered[] = $user;
}
$msg = NULL;
if (isset($_GET['action'])) {
    $action = sanitize($_GET['action']);
    XSRFdefender($action);
    if ($action == 'expiry') {
        foreach ($_POST as $key => $action) {
            if (strpos($key, 'r_') === 0) {
                $userobj = $_zp_authority->getAnAdmin(array('`id`=' => sanitize(postIndexDecode(str_replace('r_', '', $key)))));
                if ($userobj) {
                    switch ($action) {
Example #2
0
 /**
  * Gets the feed items
  *
  * @return array
  */
 public function getitems()
 {
     global $_zp_CMS;
     switch ($this->feedtype) {
         case 'gallery':
             if ($this->mode == "albums") {
                 $items = getAlbumStatistic($this->itemnumber, $this->sortorder, $this->albumfolder, 0, $this->sortdirection);
             } else {
                 $items = getImageStatistic($this->itemnumber, $this->sortorder, $this->albumfolder, $this->collection, 0, $this->sortdirection);
             }
             break;
         case 'news':
             switch ($this->newsoption) {
                 case "category":
                     if ($this->sortorder) {
                         $items = getZenpageStatistic($this->itemnumber, 'categories', $this->sortorder, $this->sortdirection);
                     } else {
                         $items = getLatestNews($this->itemnumber, $this->catlink, false, $this->sortdirection);
                     }
                     break;
                 default:
                 case "news":
                     if ($this->sortorder) {
                         $items = getZenpageStatistic($this->itemnumber, 'news', $this->sortorder, $this->sortdirection);
                     } else {
                         // Needed baceause type variable "news" is used by the feed item method and not set by the class method getArticles!
                         $items = getLatestNews($this->itemnumber, '', false, $this->sortdirection);
                     }
                     break;
             }
             break;
         case "pages":
             if ($this->sortorder) {
                 $items = getZenpageStatistic($this->itemnumber, 'pages', $this->sortorder, $this->sortdirection);
             } else {
                 $items = $_zp_CMS->getPages(NULL, false, $this->itemnumber);
             }
             break;
         case 'comments':
             switch ($type = $this->commentfeedtype) {
                 case 'gallery':
                     $items = getLatestComments($this->itemnumber, 'all');
                     break;
                 case 'album':
                     $items = getLatestComments($this->itemnumber, 'album', $this->id);
                     break;
                 case 'image':
                     $items = getLatestComments($this->itemnumber, 'image', $this->id);
                     break;
                 case 'zenpage':
                     $type = 'all';
                 case 'news':
                 case 'page':
                     if (function_exists('getLatestZenpageComments')) {
                         $items = getLatestZenpageComments($this->itemnumber, $type, $this->id);
                     }
                     break;
                 case 'allcomments':
                     $items = getLatestComments($this->itemnumber, 'all');
                     $items_zenpage = array();
                     if (function_exists('getLatestZenpageComments')) {
                         $items_zenpage = getLatestZenpageComments($this->itemnumber, 'all', $this->id);
                         $items = array_merge($items, $items_zenpage);
                         $items = sortMultiArray($items, 'date', true);
                         $items = array_slice($items, 0, $this->itemnumber);
                     }
                     break;
             }
             break;
     }
     if (isset($items)) {
         return $items;
     }
     if (TEST_RELEASE) {
         zp_error(gettext('Bad ' . $this->feed . ' feed:' . $this->feedtype), E_USER_WARNING);
     }
     return NULL;
 }
/**
 * Gets the statistic for pages, news articles or categories as an unordered list
 *
 * @param int $number The number of news items to get
 * @param string $option "all" pages, articles  and categories
 * 											 "news" for news articles
 * 											 "categories" for news categories
 * 											 "pages" for pages
 * @param string $mode "popular" most viewed for pages, news articles and categories
 * 										 "mostrated" for news articles and pages
 * 										 "toprated" for news articles and pages
 * 										 "random" for pages and news articles
 * @param string $sortdirection "asc" for ascending otherwise descending (default)
 * @return array
 */
function getZenpageStatistic($number = 10, $option = "all", $mode = "popular", $sortdirection = 'desc')
{
    global $_zp_zenpage, $_zp_current_zenpage_news, $_zp_current_zenpage_pages;
    $sortdir = strtolower($sortdirection) != 'asc';
    $statsarticles = array();
    $statscats = array();
    $statspages = array();
    if ($option == "all" || $option == "news") {
        $articles = $_zp_zenpage->getArticles($number, NULL, true, $mode, $sortdir, false);
        $counter = "";
        $statsarticles = array();
        foreach ($articles as $article) {
            $counter++;
            $obj = new ZenpageNews($article['titlelink']);
            $statsarticles[$counter] = array("id" => $obj->getID(), "title" => $obj->getTitle(), "titlelink" => $article['titlelink'], "hitcounter" => $obj->getHitcounter(), "total_votes" => $obj->getTotal_votes(), "rating" => $obj->getRating(), "content" => $obj->getContent(), "date" => $obj->getDateTime(), "type" => "News");
        }
        $stats = $statsarticles;
    }
    if (($option == "all" || $option == "categories") && $mode != "mostrated" && $mode != "toprated") {
        $categories = $_zp_zenpage->getAllCategories(true, $mode, $sortdir);
        $counter = "";
        $statscats = array();
        foreach ($categories as $cat) {
            $counter++;
            $statscats[$counter] = array("id" => $cat['id'], "title" => html_encode(get_language_string($cat['title'])), "titlelink" => getNewsCategoryURL($cat['titlelink']), "hitcounter" => $cat['hitcounter'], "total_votes" => "", "rating" => "", "content" => '', "date" => '', "type" => "Category");
        }
        $stats = $statscats;
    }
    if ($option == "all" || $option == "pages") {
        $pages = $_zp_zenpage->getPages(NULL, false, $number, $mode, $sortdir);
        $counter = "";
        $statspages = array();
        foreach ($pages as $page) {
            $counter++;
            $pageobj = new ZenpagePage($page['titlelink']);
            $statspages[$counter] = array("id" => $pageobj->getID(), "title" => $pageobj->getTitle(), "titlelink" => $page['titlelink'], "hitcounter" => $pageobj->getHitcounter(), "total_votes" => $pageobj->get('total_votes'), "rating" => $pageobj->get('rating'), "content" => $pageobj->getContent(), "date" => $pageobj->getDateTime(), "type" => "Page");
        }
        $stats = $statspages;
    }
    if ($option == "all") {
        $stats = array_merge($statsarticles, $statscats, $statspages);
        if ($mode == 'random') {
            shuffle($stats);
        } else {
            switch ($sortdir) {
                case 'asc':
                    $desc = false;
                    break;
                case 'desc':
                    $desc = true;
                    break;
            }
            $stats = sortMultiArray($stats, $mode, $desc);
        }
    }
    return $stats;
}
Example #4
0
 /**
  * Gets news articles and images of a gallery to show them together on the news section
  *
  * NOTE: This function does not exclude articles that are password protected via a category
  *
  * @param int $articles_per_page The number of articles to get
  * @param string $mode 	"latestimages-thumbnail"
  * 											"latestimages-thumbnail-customcrop"
  * 											"latestimages-sizedimage"
  * 											"latestalbums-thumbnail"
  * 		 									"latestalbums-thumbnail-customcrop"
  * 		 									"latestalbums-sizedimage"
  * 		 									"latestimagesbyalbum-thumbnail"
  * 		 									"latestimagesbyalbum-thumbnail-customcrop"
  * 		 									"latestimagesbyalbum-sizedimage"
  * 		 									"latestupdatedalbums-thumbnail" (for RSS and getLatestNews() used only)
  * 		 									"latestupdatedalbums-thumbnail-customcrop" (for RSS and getLatestNews() used only)
  * 		 									"latestupdatedalbums-sizedimage" (for RSS and getLatestNews() used only)
  * 	NOTE: The "latestupdatedalbums" variants do NOT support pagination as required on the news loop!
  *
  * @param string $published "published" for published articles,
  * 													"unpublished" for un-published articles,
  * 													"all" for all articles
  * @param string $sortorder 	id, date or mtime, only for latestimages-... modes
  * @param bool $sticky set to true to place "sticky" articles at the front of the list.
  * @param string $direction 	"desc" or "asc"
  * @return array
  * @deprecated since version 1.4.6
  */
 function getOldCombiNews($articles_per_page = '', $mode = '', $published = NULL, $sortorder = NULL, $sticky = true, $sortdirection = 'desc')
 {
     global $_zp_combiNews_cache, $_zp_gallery;
     if (is_null($published)) {
         if (zp_loggedin(ZENPAGE_NEWS_RIGHTS | ALL_NEWS_RIGHTS)) {
             $published = "all";
         } else {
             $published = "published";
         }
     }
     if (empty($mode)) {
         $mode = getOption('zenpage_combinews_mode');
     }
     if (isset($_zp_combiNews_cache[$published . $mode . $sticky . $sortorder . $sortdirection])) {
         return $_zp_combiNews_cache[$published . $mode . $sticky . $sortorder . $sortdirection];
     }
     if ($published == "published") {
         $show = " WHERE `show` = 1 AND date <= '" . date('Y-m-d H:i:s') . "'";
         $imagesshow = " AND images.show = 1 ";
     } else {
         $show = "";
         $imagesshow = "";
     }
     self::getAllAccessibleAlbums($_zp_gallery, $albumlist);
     if (empty($albumlist)) {
         $albumWhere = 'albums.`id` is NULL';
     } else {
         $albumWhere = 'albums.`id` in (' . implode(',', $albumlist) . ')';
     }
     if ($articles_per_page) {
         $offset = self::getOffset($articles_per_page);
     } else {
         $offset = 0;
     }
     if (empty($sortorder)) {
         $combinews_sortorder = getOption("zenpage_combinews_sortorder");
     } else {
         $combinews_sortorder = $sortorder;
     }
     $stickyorder = '';
     if ($sticky) {
         $stickyorder = 'sticky DESC,';
     }
     switch (strtolower($sortdirection)) {
         case false:
         case 'asc':
             $sortdir = 'ASC';
             break;
         case 'desc':
         default:
             $sortdir = 'DESC';
             break;
     }
     $type3 = query("SET @type3:='0'");
     switch ($mode) {
         case "latestimages-thumbnail":
         case "latestimages-thumbnail-customcrop":
         case "latestimages-sizedimage":
         case "latestimages-sizedimage-maxspace":
         case "latestimages-fullimage":
             $albumWhere = ' AND ' . $albumWhere;
             $sortorder = $combinews_sortorder;
             $type1 = query("SET @type1:='news'");
             $type2 = query("SET @type2:='images'");
             switch ($combinews_sortorder) {
                 case 'id':
                 case 'date':
                     $imagequery = "(SELECT albums.folder, images.filename, images.date, @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
                     break;
                 case 'publishdate':
                     $imagequery = "(SELECT albums.folder, images.filename, IFNULL(images.publishdate,images.date), @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
                 case 'mtime':
                     $imagequery = "(SELECT albums.folder, images.filename, FROM_UNIXTIME(images.mtime), @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
                     break;
             }
             $result = $this->siftResults("(SELECT title as albumname, titlelink, date, @type1 as type, sticky FROM " . prefix('news') . " " . $show . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . $imagequery . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY {$stickyorder} date " . $sortdir, $offset, $articles_per_page);
             break;
         case "latestalbums-thumbnail":
         case "latestalbums-thumbnail-customcrop":
         case "latestalbums-sizedimage":
         case "latestalbums-sizedimage-maxspace":
         case "latestalbums-fullimage":
         default:
             if (empty($show)) {
                 $albumWhere = ' WHERE ' . $albumWhere;
             } else {
                 $albumWhere = ' AND ' . $albumWhere;
             }
             $sortorder = $combinews_sortorder;
             $type1 = query("SET @type1:='news'");
             $type2 = query("SET @type2:='albums'");
             switch ($combinews_sortorder) {
                 case 'id':
                 case 'date':
                     $albumquery = "(SELECT albums.folder, albums.title, albums.date, @type2, @type3 as sticky FROM " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t" . $show . $albumWhere . ")";
                     break;
                 case 'publishdate':
                     $albumquery = "(SELECT albums.folder, albums.title, IFNULL(albums.publishdate,albums.date), @type2, @type3 as sticky FROM " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t\t\t\t\t\t\t" . $show . $albumWhere . ")";
                     break;
                 case 'mtime':
                 default:
                     $albumquery = "(SELECT albums.folder, albums.title, FROM_UNIXTIME(albums.mtime), @type2, @type3 as sticky FROM " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t" . $show . $albumWhere . ")";
                     break;
             }
             $result = $this->siftResults("(SELECT title as albumname, titlelink, date, @type1 as type, sticky FROM " . prefix('news') . " " . $show . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . $albumquery . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY {$stickyorder} date " . $sortdir, $offset, $articles_per_page);
             break;
         case "latestimagesbyalbum-thumbnail":
         case "latestimagesbyalbum-thumbnail-customcrop":
         case "latestimagesbyalbum-sizedimage":
         case "latestimagesbyalbum-sizedimage-maxspace":
         case "latestimagesbyalbum-fullimage":
             $albumWhere = ' AND ' . $albumWhere;
             $type1 = query("SET @type1:='news'");
             $type2 = query("SET @type2:='albums'");
             if (empty($combinews_sortorder) || $combinews_sortorder != "date" || $combinews_sortorder != "mtime" || $combinews_sortorder != "publishdate") {
                 $combinews_sortorder = "date";
             }
             $sortorder = "images." . $combinews_sortorder;
             switch ($combinews_sortorder) {
                 case "date":
                     $imagequery = "(SELECT DISTINCT DATE_FORMAT(" . $sortorder . ",'%Y-%m-%d'), albums.folder, DATE_FORMAT(images.date,'%Y-%m-%d'), @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
                     break;
                 case "mtime":
                     $imagequery = "(SELECT DISTINCT FROM_UNIXTIME(" . $sortorder . ",'%Y-%m-%d'), albums.folder, DATE_FORMAT(images.mtime,'%Y-%m-%d'), @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
                 case "publishdate":
                     $imagequery = "(SELECT DISTINCT FROM_UNIXTIME(" . $sortorder . ",'%Y-%m-%d'), albums.folder, DATE_FORMAT(images.publishdate,'%Y-%m-%d'), @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
                     break;
             }
             $result = $this->siftResults("(SELECT title as albumname, titlelink, date, @type1 as type, sticky FROM " . prefix('news') . " " . $show . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . $imagequery . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER By {$stickyorder} date " . $sortdir, $offset, $articles_per_page);
             break;
         case "latestupdatedalbums-thumbnail":
         case "latestupdatedalbums-thumbnail-customcrop":
         case "latestupdatedalbums-sizedimage":
         case "latestupdatedalbums-sizedimage-maxspace":
         case "latestupdatedalbums-fullimage":
             $latest = $this->getArticles($articles_per_page, NULL, true, 'date', $sortdirection);
             $counter = '';
             foreach ($latest as $news) {
                 $article = new Article($news['titlelink']);
                 if ($article->checkAccess()) {
                     $counter++;
                     $latestnews[$counter] = array("albumname" => $article->getTitle(), "titlelink" => $article->getTitlelink(), "date" => $article->getDateTime(), "type" => "news");
                 }
             }
             $albums = getAlbumStatistic($articles_per_page, "latestupdated", false, 0, $sortdirection);
             $latestalbums = array();
             $counter = "";
             foreach ($albums as $tempalbum) {
                 $counter++;
                 $tempalbumthumb = $tempalbum->getAlbumThumbImage();
                 $timestamp = $tempalbum->get('mtime');
                 if ($timestamp == 0) {
                     $albumdate = $tempalbum->getDateTime();
                 } else {
                     $albumdate = strftime('%Y-%m-%d %H:%M:%S', $timestamp);
                 }
                 $latestalbums[$counter] = array("albumname" => $tempalbum->getFileName(), "titlelink" => $tempalbum->getTitle(), "date" => $albumdate, "type" => 'albums');
             }
             //$latestalbums = array_merge($latestalbums, $item);
             $latest = array_merge($latestnews, $latestalbums);
             $result = sortMultiArray($latest, "date", $sortdirection != 'asc');
             if (count($result) > $articles_per_page) {
                 $result = array_slice($result, 0, $articles_per_page);
             }
             break;
     }
     $_zp_combiNews_cache[$published . $mode . $sticky . $sortorder . $sortdirection] = $result;
     return $result;
 }
Example #5
0
/**
 * sorts the found albums (images) by the required key(s)
 *
 * NB: this sort is sensitive to the key(s) chosen and makes
 * the appropriate sorts based on same. Some multi-key sorts
 * will not make any sense and will give unexpected results.
 * Most notably any that contain the keys "title" or "desc"
 * as these require multi-lingual sorts.
 *
 * @param array $results
 * @param string $sortkey
 * @param string $order
 */
function sortByKey($results, $sortkey, $order)
{
    $sortkey = str_replace('`', '', $sortkey);
    switch ($sortkey) {
        case 'title':
        case 'desc':
            return sortByMultilingual($results, $sortkey, $order);
        case 'RAND()':
            shuffle($results);
            return $results;
        default:
            if (preg_match('`[\\/\\(\\)\\*\\+\\-!\\^\\%\\<\\>\\=\\&\\|]`', $sortkey)) {
                return $results;
                //	We cannot deal with expressions
            }
    }
    $indicies = explode(',', $sortkey);
    foreach ($indicies as $key => $index) {
        $indicies[$key] = trim($index);
    }
    $results = sortMultiArray($results, $indicies, $order, true, false, true);
    return $results;
}
Example #6
0
            $button_enable = true;
            $button_XSRFTag = '';
            $utilityStream = file_get_contents($utility);
            eval(isolate('$button_text', $utilityStream));
            eval(isolate('$button_hint', $utilityStream));
            eval(isolate('$button_icon', $utilityStream));
            eval(isolate('$button_rights', $utilityStream));
            eval(isolate('$button_alt', $utilityStream));
            eval(isolate('$button_hidden', $utilityStream));
            eval(isolate('$button_action', $utilityStream));
            eval(isolate('$button_enable', $utilityStream));
            eval(isolate('$button_XSRFTag', $utilityStream));
            $buttonlist[] = array('XSRFTag' => $button_XSRFTag, 'enable' => $button_enable, 'button_text' => $button_text, 'formname' => $utility, 'action' => $button_action, 'icon' => $button_icon, 'title' => $button_hint, 'alt' => $button_alt, 'hidden' => $button_hidden, 'rights' => $button_rights | ADMIN_RIGHTS);
        }
        $buttonlist = zp_apply_filter('admin_utilities_buttons', $buttonlist);
        $buttonlist = sortMultiArray($buttonlist, 'button_text', false);
        $count = 0;
        foreach ($buttonlist as $key => $button) {
            if (zp_loggedin($button['rights'])) {
                $count++;
            } else {
                unset($buttonlist[$key]);
            }
        }
        $count = round($count / 2);
        ?>
	<div class="box" id="overview-utility">
	<h2 class="h2_bordered"><?php 
        echo gettext("Utility functions");
        ?>
</h2>
/**
 * Gets news articles and images of a gallery to show them together on the news section
 *
 * NOTE: This function does not exclude articles that are password protected via a category
 *
 * @param int $articles_per_page The number of articles to get
 * @param string $mode 	"latestimages-thumbnail"
 *											"latestimages-thumbnail-customcrop"
 *											"latestimages-sizedimage"
 *											"latestalbums-thumbnail"
 *		 									"latestalbums-thumbnail-customcrop"
 *		 									"latestalbums-sizedimage"
 *		 									"latestimagesbyalbum-thumbnail"
 *		 									"latestimagesbyalbum-thumbnail-customcrop"
 *		 									"latestimagesbyalbum-sizedimage"
 *		 									"latestupdatedalbums-thumbnail" (for RSS and getLatestNews() used only)
 *		 									"latestupdatedalbums-thumbnail-customcrop" (for RSS and getLatestNews() used only)
 *		 									"latestupdatedalbums-sizedimage" (for RSS and getLatestNews() used only)
 *	NOTE: The "latestupdatedalbums" variants do NOT support pagination as required on the news loop!
 *
 * @param string $published "published" for published articles,
 * 													"unpublished" for un-published articles,
 * 													"all" for all articles
 * @param string $sortorder 	id, date or mtime, only for latestimages-... modes
 * @param bool $sticky set to true to place "sticky" articles at the front of the list.
 * @return array
 */
function getCombiNews($articles_per_page = '', $mode = '', $published = NULL, $sortorder = '', $sticky = true)
{
    deprecated_function_notify(gettext('Use the Zenpage class method instead.'));
    global $_zp_gallery, $_zp_flash_player;
    processExpired('news');
    if (is_null($published)) {
        if (zp_loggedin(ZENPAGE_NEWS_RIGHTS)) {
            $published = "all";
        } else {
            $published = "published";
        }
    }
    if (empty($mode)) {
        $mode = getOption("zenpage_combinews_mode");
    }
    if ($published == "published") {
        $show = " WHERE `show` = 1 AND date <= '" . date('Y-m-d H:i:s') . "'";
        $imagesshow = " AND images.show = 1 ";
    } else {
        $show = "";
        $imagesshow = "";
    }
    $passwordcheck = "";
    if (zp_loggedin(ZENPAGE_NEWS_RIGHTS)) {
        $albumWhere = "";
        $passwordcheck = "";
    } else {
        $albumscheck = query_full_array("SELECT * FROM " . prefix('albums') . " ORDER BY title");
        foreach ($albumscheck as $albumcheck) {
            if (!checkAlbumPassword($albumcheck['folder'])) {
                $albumpasswordcheck = " AND albums.id != " . $albumcheck['id'];
                $passwordcheck = $passwordcheck . $albumpasswordcheck;
            }
        }
        $albumWhere = "AND albums.show=1" . $passwordcheck;
    }
    $limit = getLimitAndOffset($articles_per_page);
    if (empty($sortorder)) {
        $combinews_sortorder = getOption("zenpage_combinews_sortorder");
    } else {
        $combinews_sortorder = $sortorder;
    }
    $stickyorder = '';
    if ($sticky) {
        $stickyorder = 'sticky DESC,';
    }
    $type3 = query("SET @type3:='0'");
    switch ($mode) {
        case "latestimages-thumbnail":
        case "latestimages-thumbnail-customcrop":
        case "latestimages-sizedimage":
            $sortorder = "images." . $combinews_sortorder;
            $type1 = query("SET @type1:='news'");
            $type2 = query("SET @type2:='images'");
            switch ($combinews_sortorder) {
                case 'id':
                case 'date':
                    $imagequery = "(SELECT albums.folder, images.filename, images.date, @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
                    break;
                case 'mtime':
                    $imagequery = "(SELECT albums.folder, images.filename, FROM_UNIXTIME(images.mtime), @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
                    break;
            }
            $result = query_full_array("(SELECT title as albumname, titlelink, date, @type1 as type, sticky FROM " . prefix('news') . " " . $show . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . $imagequery . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY {$stickyorder} date DESC {$limit}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
            break;
        case "latestalbums-thumbnail":
        case "latestalbums-thumbnail-customcrop":
        case "latestalbums-sizedimage":
            $sortorder = $combinews_sortorder;
            $type1 = query("SET @type1:='news'");
            $type2 = query("SET @type2:='albums'");
            switch ($combinews_sortorder) {
                case 'id':
                case 'date':
                    $albumquery = "(SELECT albums.folder, albums.title, albums.date, @type2, @type3 as sticky FROM " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t" . $show . $albumWhere . ")";
                    break;
                case 'mtime':
                    $albumquery = "(SELECT albums.folder, albums.title, FROM_UNIXTIME(albums.mtime), @type2, @type3 as sticky FROM " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t" . $show . $albumWhere . ")";
                    break;
            }
            $result = query_full_array("(SELECT title as albumname, titlelink, date, @type1 as type, sticky FROM " . prefix('news') . " " . $show . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . $albumquery . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY {$stickyorder} date DESC {$limit}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
            break;
        case "latestimagesbyalbum-thumbnail":
        case "latestimagesbyalbum-thumbnail-customcrop":
        case "latestimagesbyalbum-sizedimage":
            $type1 = query("SET @type1:='news'");
            $type2 = query("SET @type2:='albums'");
            if (empty($combinews_sortorder) || $combinews_sortorder != "date" || $combinews_sortorder != "mtime") {
                $combinews_sortorder = "date";
            }
            $combinews_sortorder = "date";
            $sortorder = "images." . $combinews_sortorder;
            switch ($combinews_sortorder) {
                case "date":
                    $imagequery = "(SELECT DISTINCT DATE_FORMAT(" . $sortorder . ",'%Y-%m-%d'), albums.folder, DATE_FORMAT(images.`date`,'%Y-%m-%d'), @type2 FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
                    break;
                case "mtime":
                    $imagequery = "(SELECT DISTINCT FROM_UNIXTIME(" . $sortorder . ",'%Y-%m-%d'), albums.folder, DATE_FORMAT(images.`mtime`,'%Y-%m-%d'), @type2 FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
                    break;
            }
            $result = query_full_array("(SELECT title as albumname, titlelink, date, @type1 as type FROM " . prefix('news') . " " . $show . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . $imagequery . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER By date DESC {$limit}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
            //echo "<pre>"; print_r($result); echo "</pre>";
            //$result = "";
            break;
        case "latestupdatedalbums-thumbnail":
        case "latestupdatedalbums-thumbnail-customcrop":
        case "latestupdatedalbums-sizedimage":
            $latest = getNewsArticles($articles_per_page, '', NULL, true);
            $counter = '';
            foreach ($latest as $news) {
                $article = new ZenpageNews($news['titlelink']);
                if ($article->checkAccess($hint, $show)) {
                    $counter++;
                    $latestnews[$counter] = array("albumname" => $article->getTitle(), "titlelink" => $article->getTitlelink(), "date" => $article->getDateTime(), "type" => "news");
                }
            }
            $albums = getAlbumStatistic($articles_per_page, "latestupdated");
            $latestalbums = array();
            $counter = "";
            foreach ($albums as $album) {
                $counter++;
                $tempalbum = new Album($_zp_gallery, $album['folder']);
                $tempalbumthumb = $tempalbum->getAlbumThumbImage();
                $timestamp = $tempalbum->get('mtime');
                if ($timestamp == 0) {
                    $albumdate = $tempalbum->getDateTime();
                } else {
                    $albumdate = strftime('%Y-%m-%d %H:%M:%S', $timestamp);
                }
                $latestalbums[$counter] = array("albumname" => $tempalbum->getFolder(), "titlelink" => $tempalbum->getTitle(), "date" => $albumdate, "type" => 'albums');
            }
            //$latestalbums = array_merge($latestalbums, $item);
            $latest = array_merge($latestnews, $latestalbums);
            $result = sortMultiArray($latest, "date", true);
            if (count($result) > $articles_per_page) {
                $result = array_slice($result, 0, 10);
            }
            break;
    }
    //$result = "";
    return $result;
}
Example #8
0
    static function groupList($userobj, $i, $background, $current, $template)
    {
        global $_zp_authority, $_zp_zenpage, $_zp_gallery;
        $group = $userobj->getGroup();
        $admins = $_zp_authority->getAdministrators('groups');
        $groups = array();
        $hisgroups = explode(',', $userobj->getGroup());
        $admins = sortMultiArray($admins, 'user');
        foreach ($admins as $user) {
            if ($template || $user['name'] != 'template') {
                $groups[] = $user;
            }
        }
        if (empty($groups)) {
            return gettext('no groups established');
        }
        // no groups setup yet
        $grouppart = '
		<script type="text/javascript">
			// <!-- <![CDATA[
			function groupchange' . $i . '(type) {
				switch (type) {
				case 0:	//	none
					$(\'.user-' . $i . '\').prop(\'disabled\',false);
					$(\'.templatelist' . $i . '\').prop(\'checked\',false);
					$(\'.grouplist' . $i . '\').prop(\'checked\',false);
					break;
				case 1:	//	group
					$(\'.user-' . $i . '\').prop(\'disabled\',true);
					$(\'.user-' . $i . '\').prop(\'checked\',false);
					$(\'#noGroup_' . $i . '\').prop(\'checked\',false);
					$(\'.templatelist' . $i . '\').prop(\'checked\',false);
					break;
				case 2:	//	template
					$(\'.user-' . $i . '\').prop(\'disabled\',false);
					$(\'#noGroup_' . $i . '\').prop(\'checked\',false);
					$(\'.grouplist' . $i . '\').prop(\'checked\',false);
					break;
			}
		}
		//]]> -->
	</script>' . "\n";
        $grouppart .= '<ul class="customchecklist">' . "\n";
        $grouppart .= '<label title="' . gettext('*no group affiliation') . '"><input type="checkbox" id="noGroup_' . $i . '" name="' . $i . 'group[]" value="" onclick="groupchange' . $i . '(0);" />' . gettext('*no group selected') . '</label>' . "\n";
        foreach ($groups as $key => $user) {
            if ($user['name'] == 'template') {
                $type = gettext(' (Template)');
                $highlight = ' class="grouphighlight"';
                $class = 'templatelist' . $i;
                $case = 2;
            } else {
                $type = $highlight = '';
                $class = 'grouplist' . $i;
                $case = 1;
            }
            if (in_array($user['user'], $hisgroups)) {
                $checked = ' checked="checked"';
            } else {
                $checked = '';
            }
            $grouppart .= '<label title="' . html_encode($user['custom_data']) . $type . '"' . $highlight . '><input type="checkbox" class="' . $class . '" name="' . $i . 'group[]" value="' . $user['user'] . '" onclick="groupchange' . $i . '(' . $case . ');"' . $checked . ' />' . html_encode($user['user']) . '</label>' . "\n";
        }
        $grouppart .= "</ul>\n";
        return $grouppart;
    }
Example #9
0
 /**
  * initializes the $_zp_exifvars array display state
  *
  * @author Stephen Billard
  * @Copyright 2015 by Stephen L Billard for use in {@link https://github.com/ZenPhoto20/ZenPhoto20 ZenPhoto20}
  */
 static function exifvars($default = false)
 {
     global $_zp_images_classes;
     /*
      * Note: If fields are added or deleted, setup should be run or the new data won't be stored
      * (but existing fields will still work; nothing breaks).
      *
      * This array should be ordered by logical associations as it will be the order that EXIF information
      * is displayed
      */
     $exifvars = array();
     $handlers = array_unique($_zp_images_classes);
     $handlers[] = 'xmpMetadata';
     foreach ($handlers as $handler) {
         if (class_exists($handler)) {
             $exifvars = array_merge($exifvars, $handler::getMetadataFields());
         }
     }
     $exifvars = sortMultiArray($exifvars, 2, false, true, false, true);
     if ($default) {
         return $exifvars;
     }
     foreach ($exifvars as $key => $item) {
         if (!is_null($disable = getOption($key . '-disabled'))) {
             $exifvars[$key][5] = !($disable & true);
         }
         if (!is_null($display = getOption($key . '-display'))) {
             $exifvars[$key][3] = $display;
         }
     }
     return $exifvars;
 }
Example #10
0
function getRelatedItems($type = 'news', $album = NULL)
{
    global $_zp_gallery, $_zp_current_album, $_zp_current_image, $_zp_current_zenpage_page, $_zp_current_zenpage_news, $_zp_gallery_page;
    $tags = getTags();
    if (!empty($tags)) {
        // if there are tags at all
        $searchstring = '';
        $count = '';
        foreach ($tags as $tag) {
            $count++;
            if ($count == 1) {
                $bool = '';
            } else {
                $bool = '|';
                // connect tags by OR to get a wide range
            }
            $searchstring .= $bool . $tag;
        }
        $paramstr = urlencode('words') . '=' . $searchstring . '&searchfields=tags';
        if (!is_null($album)) {
            $paramstr = '&albumname=' . urlencode($album);
        }
        $search = new SearchEngine();
        switch ($type) {
            case 'albums':
                $paramstr .= '&inalbums=1';
                break;
            case 'images':
                $paramstr .= '&inimages=1';
                break;
            case 'news':
                $paramstr .= '&innews=1';
                break;
            case 'pages':
                $paramstr .= '&inpages=1';
                break;
            case 'all':
                $paramstr .= '&inalbums=1&inimages=1&innews=1&inpages=1';
                break;
        }
        $search->setSearchParams($paramstr);
        // get the results
        switch ($type) {
            case 'albums':
                $albumresult = $search->getAlbums(0, "date", "desc");
                $result = createRelatedItemsResultArray($albumresult, $type);
                break;
            case 'images':
                $imageresult = $search->getImages(0, 0, 'date', 'desc');
                $result = createRelatedItemsResultArray($imageresult, $type);
                break;
            case 'news':
                $newsresult = $search->getArticles(0, NULL, true, "date", "desc");
                $result = createRelatedItemsResultArray($newsresult, $type);
                break;
            case 'pages':
                $pageresult = $search->getPages();
                $result = createRelatedItemsResultArray($pageresult, $type);
                break;
            case 'all':
                $albumresult = $search->getAlbums(0, "date", "desc");
                $imageresult = $search->getImages(0, 0, 'date', 'desc');
                $newsresult = $search->getArticles(0, NULL, true, "date", "desc");
                $pageresult = $search->getPages();
                $result1 = createRelatedItemsResultArray($albumresult, 'albums');
                $result2 = createRelatedItemsResultArray($imageresult, 'images');
                $result3 = createRelatedItemsResultArray($newsresult, 'news');
                $result4 = createRelatedItemsResultArray($pageresult, 'pages');
                $result = array_merge($result1, $result2, $result3, $result4);
                $result = sortMultiArray($result, 'weight', true, true, false, false);
                // sort by search result weight
                break;
        }
        return $result;
    }
    return array();
}
Example #11
0
        if (!zp_apply_filter('admin_managed_albums_access', false, $return)) {
            header('Location: ' . FULLWEBPATH . '/' . ZENFOLDER . '/admin.php');
            exitZP();
        }
    }
} else {
    $object = '<em>' . gettext('Gallery') . '</em>';
    $zenphoto_tabs['overview']['subtabs'] = array(gettext('Cache images') => PLUGIN_FOLDER . '/cacheManager/cacheImages.php?page = overview&tab=images', gettext('Cache stored images') => PLUGIN_FOLDER . '/cacheManager/cacheDBImages.php?page=overview&tab=DB&XSRFToken=' . getXSRFToken('cacheDBImages'));
}
$custom = array();
$result = query('SELECT * FROM ' . prefix('plugin_storage') . ' WHERE `type` = "cacheManager" ORDER BY `aux`');
while ($row = db_fetch_assoc($result)) {
    $row = getSerializedArray($row['data']);
    $custom[] = $row;
}
$custom = sortMultiArray($custom, array('theme', 'thumb', 'image_size', 'image_width', 'image_height'));
if (isset($_GET['select'])) {
    XSRFdefender('cacheImages');
    $enabled = @$_POST['enable'];
} else {
    $enabled = false;
}
printAdminHeader('overview', 'images');
echo "\n</head>";
echo "\n<body>";
printLogoAndLinks();
echo "\n" . '<div id = "main">';
printTabs();
echo "\n" . '<div id = "content">';
printSubtabs();
?>
/**
 * Prints a table with a bar graph of the values.
 *
 * @param string $sortorder "popular", "mostrated","toprated","mostcommented" or - only if $type = "albums"! - "mostimages" 
 * @param string_type $type "albums" or "images"
 * @param int $limit Number of entries to show
 */
function printBarGraph($sortorder = "mostimages", $type = "albums", $from_number = 0, $to_number = 10)
{
    global $gallery, $webpath;
    $limit = $from_number . "," . $to_number;
    $bargraphmaxsize = 400;
    switch ($type) {
        case "albums":
            $typename = gettext("Albums");
            $dbquery = "SELECT id, title, folder, hitcounter, total_votes, total_value, `show` FROM " . prefix('albums');
            break;
        case "images":
            $typename = gettext("Images");
            $dbquery = "SELECT id, title, filename, albumid, hitcounter, total_votes, total_value, `show` FROM " . prefix('images');
            break;
    }
    switch ($sortorder) {
        case "popular":
            $itemssorted = query_full_array($dbquery . " ORDER BY hitcounter DESC LIMIT " . $limit);
            if (empty($itemssorted)) {
                $maxvalue = 0;
            } else {
                $maxvalue = $itemssorted[0]['hitcounter'];
            }
            $headline = $typename . " - " . gettext("most viewed");
            break;
        case "mostrated":
            $itemssorted = query_full_array($dbquery . " ORDER BY total_votes DESC LIMIT " . $limit);
            if (empty($itemssorted)) {
                $maxvalue = 0;
            } else {
                $maxvalue = $itemssorted[0]['total_votes'];
            }
            $headline = $typename . " - " . gettext("most rated");
            break;
        case "toprated":
            switch ($type) {
                case "albums":
                    $itemssorted = query_full_array("SELECT * FROM " . prefix('albums') . " ORDER BY (total_value/total_votes) DESC LIMIT {$limit}");
                    break;
                case "images":
                    $itemssorted = query_full_array("SELECT * FROM " . prefix('images') . " ORDER BY (total_value/total_votes) DESC LIMIT {$limit}");
                    break;
            }
            if (empty($itemssorted)) {
                $maxvalue = 0;
            } else {
                if ($itemssorted[0]['total_votes'] != 0) {
                    $maxvalue = $itemssorted[0]['total_value'] / $itemssorted[0]['total_votes'];
                } else {
                    $maxvalue = 0;
                }
            }
            $headline = $typename . " - " . gettext("top rated");
            break;
        case "mostcommented":
            switch ($type) {
                case "albums":
                    $itemssorted = query_full_array("SELECT comments.ownerid, count(*) as commentcount, albums.* FROM " . prefix('comments') . " AS comments, " . prefix('albums') . " AS albums WHERE albums.id=comments.ownerid AND type = 'albums' GROUP BY comments.ownerid ORDER BY commentcount DESC LIMIT " . $limit);
                    break;
                case "images":
                    $itemssorted = query_full_array("SELECT comments.ownerid, count(*) as commentcount, images.* FROM " . prefix('comments') . " AS comments, " . prefix('images') . " AS images WHERE images.id=comments.ownerid AND type = 'images' GROUP BY comments.ownerid ORDER BY commentcount DESC LIMIT " . $limit);
                    break;
            }
            if (empty($itemssorted)) {
                $maxvalue = 0;
            } else {
                $maxvalue = $itemssorted[0]['commentcount'];
            }
            $headline = $typename . " - " . gettext("most commented");
            break;
        case "mostimages":
            $itemssorted = query_full_array("SELECT images.albumid, count(*) as imagenumber, albums.* FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums WHERE albums.id=images.albumid GROUP BY images.albumid ORDER BY imagenumber DESC LIMIT " . $limit);
            if (empty($itemssorted)) {
                $maxvalue = 0;
            } else {
                $maxvalue = $itemssorted[0]['imagenumber'];
            }
            $headline = $typename . " - " . gettext("most images");
            break;
        case "latest":
            switch ($type) {
                case "albums":
                    $allalbums = query_full_array($dbquery . " ORDER BY id DESC LIMIT " . $limit);
                    $albums = array();
                    foreach ($allalbums as $album) {
                        $albumobj = new Album($gallery, $album['folder']);
                        $albumentry = array("id" => $albumobj->get('id'), "title" => $albumobj->getTitle(), "folder" => $albumobj->name, "imagenumber" => $albumobj->getNumImages(), "show" => $albumobj->get("show"));
                        array_unshift($albums, $albumentry);
                    }
                    $maxvalue = 0;
                    if (empty($albums)) {
                        $itemssorted = array();
                    } else {
                        foreach ($albums as $entry) {
                            if (array_key_exists('imagenumber', $entry)) {
                                $v = $entry['imagenumber'];
                                if ($v > $maxvalue) {
                                    $maxvalue = $v;
                                }
                            }
                        }
                        $itemssorted = $albums;
                        // The items are originally sorted by id;
                    }
                    $headline = $typename . " - " . gettext("latest");
                    break;
                case "images":
                    $itemssorted = query_full_array($dbquery . " ORDER BY id DESC LIMIT " . $limit);
                    $barsize = 0;
                    $maxvalue = 1;
                    $headline = $typename . " - " . gettext("latest");
                    break;
            }
            break;
        case "latestupdated":
            // part taken from the image_albums_statistics - could probably be optimized regarding queries...
            // get all albums
            $allalbums = query_full_array("SELECT id, title, folder, `show` FROM " . prefix('albums'));
            $albums = array();
            $latestimages = array();
            foreach ($allalbums as $album) {
                $albumobj = new Album($gallery, $album['folder']);
                $albumentry = array("id" => $albumobj->get('id'), "title" => $albumobj->getTitle(), "folder" => $albumobj->name, "imagenumber" => $albumobj->getNumImages(), "show" => $albumobj->get("show"));
                array_unshift($albums, $albumentry);
            }
            // get latest images of each album
            $count = 0;
            foreach ($albums as $album) {
                $count++;
                $image = query_single_row("SELECT id, albumid, mtime FROM " . prefix('images') . " WHERE albumid = " . $album['id'] . " ORDER BY id DESC LIMIT 1");
                if (is_array($image)) {
                    array_push($latestimages, $image);
                }
                if ($count === $to_number) {
                    break;
                }
            }
            // sort latest image by mtime
            $latestimages = sortMultiArray($latestimages, "mtime", "desc", false, false);
            //echo "<pre>"; print_r($albums); echo "</pre>";
            $itemssorted = array();
            $count = 0;
            foreach ($latestimages as $latestimage) {
                $count++;
                foreach ($allalbums as $album) {
                    if ($album['id'] === $latestimage['albumid']) {
                        array_push($albums, $album);
                    }
                }
                if ($count === $to_number) {
                    break;
                }
            }
            if ($to_number < 1) {
                $stopelement = 1;
            } else {
                $stopelement = $to_number;
            }
            $albums = array_slice($albums, 0, $stopelement);
            // clear unnessesary items fron array
            $maxvalue = 0;
            if (empty($albums)) {
                $itemssorted = array();
            } else {
                foreach ($albums as $key => $entry) {
                    if (array_key_exists('imagenumber', $entry)) {
                        $v = $entry['imagenumber'];
                        if ($v > $maxvalue) {
                            $maxvalue = $v;
                        }
                    } else {
                        unset($albums[$key]);
                        // if it has no imagenumber it must not be a valid entry!
                    }
                }
                $itemssorted = $albums;
                // The items are originally sorted by id;
            }
            $headline = $typename . " - " . gettext("latest updated");
            //echo "<pre>"; print_r($albums); echo "</pre>";
            break;
    }
    if ($maxvalue == 0 or empty($itemssorted)) {
        $maxvalue = 1;
        $no_statistic_message = "<tr><td><em>" . gettext("No statistic available") . "</em></td><td></td><td></td><td></td></tr>";
    } else {
        $no_statistic_message = "";
    }
    if ($from_number <= 1) {
        $count = 1;
    } else {
        $count = $from_number;
    }
    $countlines = 0;
    echo "<table class='bordered'>";
    echo "<tr><th colspan='4'><strong>" . $headline . "</strong>";
    if (isset($_GET['stats'])) {
        echo "<a href='gallery_statistics.php'> | " . gettext("Back to the top 10 lists") . "</a>";
    } else {
        if (empty($no_statistic_message)) {
            echo "<a href='gallery_statistics.php?stats=" . $sortorder . "&amp;type=" . $type . "'> | " . gettext("View more") . "</a>";
        }
        echo "<a href='#top'> | " . gettext("top") . "</a>";
    }
    echo "</th></tr>";
    echo $no_statistic_message;
    foreach ($itemssorted as $item) {
        if (array_key_exists("filename", $item)) {
            $name = $item['filename'];
        } else {
            if (array_key_exists("folder", $item)) {
                $name = $item['folder'];
            }
        }
        switch ($sortorder) {
            case "popular":
                $barsize = round($item['hitcounter'] / $maxvalue * $bargraphmaxsize);
                $value = $item['hitcounter'];
                break;
            case "mostrated":
                if ($item['total_votes'] != 0) {
                    $barsize = round($item['total_votes'] / $maxvalue * $bargraphmaxsize);
                } else {
                    $barsize = 0;
                }
                $value = $item['total_votes'];
                break;
            case "toprated":
                if ($item['total_votes'] != 0) {
                    $barsize = round($item['total_value'] / $item['total_votes'] / $maxvalue * $bargraphmaxsize);
                    $value = round($item['total_value'] / $item['total_votes']);
                } else {
                    $barsize = 0;
                    $value = 0;
                }
                break;
            case "mostcommented":
                if ($maxvalue != 0) {
                    $barsize = round($item['commentcount'] / $maxvalue * $bargraphmaxsize);
                } else {
                    $barsize = 0;
                }
                $value = $item['commentcount'];
                break;
            case "mostimages":
                $barsize = round($item['imagenumber'] / $maxvalue * $bargraphmaxsize);
                $value = $item['imagenumber'];
                break;
            case "latest":
                switch ($type) {
                    case "albums":
                        $barsize = 0;
                        //round($item['imagenumber'] / $maxvalue * $bargraphmaxsize);
                        $value = sprintf(gettext("%s images"), $item['imagenumber']);
                        break;
                    case "images":
                        $barsize = 0;
                        $value = "";
                        break;
                }
                break;
            case "latestupdated":
                $barsize = 0;
                //round($item['imagenumber'] / $maxvalue * $bargraphmaxsize);
                $value = sprintf(gettext("%s images"), $item['imagenumber']);
                break;
        }
        // counter to have a gray background of every second line
        if ($countlines === 1) {
            $style = "style='background-color: #f4f4f4'";
            // a little ugly but the already attached class for the table is so easiest overriden...
            $countlines = 0;
        } else {
            $style = "";
            $countlines++;
        }
        switch ($type) {
            case "albums":
                $editurl = $webpath . "/admin.php?page=edit&amp;album=" . $name;
                $viewurl = WEBPATH . "/index.php?album=" . $name;
                break;
            case "images":
                $getalbumfolder = query_single_row("SELECT title, folder, `show` from " . prefix("albums") . " WHERE id = " . $item['albumid']);
                if ($sortorder === "latest") {
                    $value = "<span";
                    if ($getalbumfolder['show'] != "1") {
                        $value = $value . " class='unpublished_item'";
                    }
                    $value = $value . ">" . get_language_string($getalbumfolder['title']) . "</span> (" . $getalbumfolder['folder'] . ")";
                }
                $editurl = $webpath . "/admin.php?page=edit&amp;album=" . $getalbumfolder['folder'] . "&amp;image=" . $item['filename'] . "&amp;tab=imageinfo#IT";
                $viewurl = WEBPATH . "/index.php?album=" . $getalbumfolder['folder'] . "&amp;image=" . $name;
                break;
        }
        if ($item['show'] != "1") {
            $show = " class='unpublished_item'";
        } else {
            $show = "";
        }
        if ($value != 0 or $sortorder === "latest") {
            ?>
		<tr class="statistic_wrapper">
		<td class="statistic_counter" <?php 
            echo $style;
            ?>
><?php 
            echo $count;
            ?>
</td>
		<td class="statistic_title" <?php 
            echo $style;
            ?>
><strong<?php 
            echo $show;
            ?>
><?php 
            echo get_language_string($item['title']);
            ?>
</strong> (<?php 
            echo $name;
            ?>
)</td>
		<td class="statistic_graphwrap" <?php 
            echo $style;
            ?>
><div class="statistic_bargraph" style="width: <?php 
            echo $barsize;
            ?>
px"></div><div class="statistic_value"><?php 
            echo $value;
            ?>
</div></td>
		<td class="statistic_link" <?php 
            echo $style;
            ?>
>
		<?php 
            echo "<a href='" . $editurl . "' title='" . $name . "'>" . gettext("Edit") . "</a> | <a href='" . $viewurl . "' title='" . $name . "'>" . gettext("View") . "</a></td";
            echo "</tr>";
            $count++;
            if ($count === $limit) {
                break;
            }
        }
    }
    // foreach end
    echo "</table>";
}
Example #13
0
 static function handleOptionSave($themename, $themealbum)
 {
     if (!class_exists('user_groups')) {
         $saved_rights = NO_RIGHTS;
         $rightslist = sortMultiArray(Zenphoto_Authority::getRights(), array('set', 'value'));
         foreach ($rightslist as $rightselement => $right) {
             if (isset($_POST['register_user-' . $rightselement])) {
                 $saved_rights = $saved_rights | $_POST['register_user-' . $rightselement];
             }
         }
         setOption('register_user_user_rights', $saved_rights);
     }
     return false;
 }
Example #14
0
 /**
  * Returns a list of News Titlelinks found in the search
  *
  * @param string $sorttype field to sort on
  * @param string $sortdirection sort order
  *
  * @return array
  */
 private function getSearchArticles($sorttype, $sortdirection)
 {
     if (!extensionEnabled('zenpage') || getOption('search_no_news') || $this->search_no_news) {
         return array();
     }
     list($sorttype, $sortdirection) = $this->sortKey($sorttype, $sortdirection, 'title', 'news');
     $searchstring = $this->getSearchString();
     $searchdate = $this->dates;
     if (empty($searchstring) && empty($searchdate)) {
         return array();
     }
     // nothing to find
     $criteria = $this->getCacheTag('news', serialize($searchstring), $sorttype . ' ' . $sortdirection);
     if ($this->articles && $criteria == $this->searches['news']) {
         return $this->articles;
     }
     $result = $this->getCachedSearch($criteria);
     if (is_null($result)) {
         $result = array();
         if (empty($searchdate)) {
             list($search_query, $weights) = $this->searchFieldsAndTags($searchstring, 'news', $sorttype, $sortdirection);
         } else {
             $search_query = $this->searchDate($searchstring, $searchdate, 'news', $sorttype, $sortdirection, $this->whichdates);
         }
         if (empty($search_query)) {
             $search_result = false;
         } else {
             $search_result = query($search_query);
         }
         zp_apply_filter('search_statistics', $searchstring, 'news', !empty($search_result), false, $this->iteration++);
         if ($search_result) {
             while ($row = db_fetch_assoc($search_result)) {
                 $data = array('titlelink' => $row['titlelink']);
                 if (isset($weights)) {
                     $data['weight'] = $weights[$row['id']];
                 }
                 $result[] = $data;
             }
             db_free_result($search_result);
         }
         if (isset($weights)) {
             $result = sortMultiArray($result, 'weight', true, true, false, false, array('weight'));
         }
         $this->cacheSearch($criteria, $result);
     }
     $this->articles = $result;
     $this->searches['news'] = $criteria;
     return $this->articles;
 }
Example #15
0
                 unset($recentIP[$ip]['accessed'][$key]);
             }
         }
         if ($__count > 1) {
             $__interval = $__interval / $__count;
         } else {
             $__interval = 0;
         }
         $recentIP[$ip]['interval'] = $__interval;
         if ($__count > 10 && $__interval < $__config['accessThreshold_THRESHOLD']) {
             $recentIP[$ip]['blocked'] = 2;
         }
     }
     if (count($recentIP) - 1 > $__config['accessThreshold_IP_RETENTION']) {
         unset($recentIP['config']);
         $recentIP = sortMultiArray($recentIP, array('lastAccessed'), true, true, false, true);
         $recentIP = array_slice($recentIP, 0, $__config['accessThreshold_IP_RETENTION']);
         $recentIP['config'] = $__config;
     }
     file_put_contents(SERVERPATH . '/' . DATA_FOLDER . '/recentIP', serialize($recentIP));
     $mu->unlock();
     unset($ip);
     unset($full_ip);
     unset($recentIP);
     unset($__config);
     unset($__time);
     unset($__interval);
     unset($__previous);
     unset($__count);
     unset($__locale);
 }
/**
 * Gets the statistic for pages, news articles or categories as an unordered list
 *
 * @param int $number The number of news items to get
 * @param string $option "all" pages, articles  and categories
 * 											 "news" for news articles
 * 											 "categories" for news categories
 * 											 "pages" for pages
 * @param string $mode "popular" most viewed for pages, news articles and categories
 * 										 "mostrated" for news articles and pages
 * 										 "toprated" for news articles and pages
 * @return array
 */
function getZenpageStatistic($number = 10, $option = "all", $mode = "popular")
{
    global $_zp_current_zenpage_news, $_zp_current_zenpage_pages;
    $statsarticles = array();
    $statscats = array();
    $statspages = array();
    switch ($mode) {
        case "popular":
            $sortorder = "hitcounter";
            break;
        case "mostrated":
            $sortorder = "total_votes";
            break;
        case "toprated":
            $sortorder = "rating";
            break;
    }
    if ($option == "all" or $option == "news") {
        $articles = query_full_array("SELECT titlelink FROM " . prefix('news') . " ORDER BY {$sortorder} DESC LIMIT {$number}");
        $counter = "";
        $statsarticles = array();
        foreach ($articles as $article) {
            $counter++;
            $obj = new ZenpageNews($article['titlelink']);
            $statsarticles[$counter] = array("id" => $obj->getID(), "title" => $obj->getTitle(), "titlelink" => $article['titlelink'], "hitcounter" => $obj->getHitcounter(), "total_votes" => $obj->get('total_votes'), "rating" => $obj->get('rating'), "content" => $obj->getContent(), "date" => $obj->getDateTime(), "type" => "News");
        }
        $stats = $statsarticles;
    }
    if (($option == "all" or $option == "categories") && $mode != "mostrated" && $mode != "toprated") {
        $categories = query_full_array("SELECT id, titlelink as title, title as titlelink, hitcounter FROM " . prefix('news_categories') . " ORDER BY {$sortorder} DESC LIMIT {$number}");
        $counter = "";
        $statscats = array();
        foreach ($categories as $cat) {
            $counter++;
            $statscats[$counter] = array("id" => $cat['id'], "title" => html_encode(get_language_string($cat['title'])), "titlelink" => getNewsCategoryURL($cat['titlelink']), "hitcounter" => $cat['hitcounter'], "total_votes" => "", "rating" => "", "content" => '', "date" => '', "type" => "Category");
        }
        $stats = $statscats;
    }
    if ($option == "all" or $option == "pages") {
        $pages = query_full_array("SELECT titlelink FROM " . prefix('pages') . " ORDER BY {$sortorder} DESC LIMIT {$number}");
        $counter = "";
        $statspages = array();
        foreach ($pages as $page) {
            $counter++;
            $pageobj = new ZenpagePage($page['titlelink']);
            $statspages[$counter] = array("id" => $pageobj->getID(), "title" => $pageobj->getTitle(), "titlelink" => $page['titlelink'], "hitcounter" => $pageobj->getHitcounter(), "total_votes" => $pageobj->get('total_votes'), "rating" => $pageobj->get('rating'), "content" => $pageobj->getContent(), "date" => $pageobj->getDateTime(), "type" => "Page");
        }
        $stats = $statspages;
    }
    if ($option == "all") {
        $stats = array_merge($statsarticles, $statscats, $statspages);
    }
    $stats = sortMultiArray($stats, $sortorder, true);
    return $stats;
}
Example #17
0
    /**
     *
     * custom option handler
     * @param string $option
     * @param mixed $currentValue
     */
    function handleOption($option, $currentValue)
    {
        global $_zp_gallery;
        $currenttheme = $_zp_gallery->getCurrentTheme();
        $custom = array();
        $result = query('SELECT * FROM ' . prefix('plugin_storage') . ' WHERE `type`="cacheManager" ORDER BY `aux`');
        $key = 0;
        while ($row = db_fetch_assoc($result)) {
            $theme = $row['aux'];
            $data = getSerializedArray($row['data']);
            $custom[$theme][] = $data;
        }
        ksort($custom, SORT_LOCALE_STRING);
        $custom[''] = array(array());
        $c = 0;
        ?>
		<script type="text/javascript">
			//<!-- <![CDATA[
			function showTheme(theme) {
				html = $('#' + theme + '_arrow').html();
				if (html.match(/down/)) {
					html = html.replace(/_down/, '_up');
					html = html.replace(/title="<?php 
        echo gettext('Show');
        ?>
/, 'title="<?php 
        echo gettext('Hide');
        ?>
"');
					$('#' + theme + '_list').show();
				} else {
					html = html.replace(/_up/, '_down');
					html = html.replace(/title="<?php 
        echo gettext('Hide');
        ?>
/, 'title="<?php 
        echo gettext('Show');
        ?>
"');
					$('#' + theme + '_list').hide();
				}
				$('#' + theme + '_arrow').html(html);
			}
			//]]> -->
		</script>
		<?php 
        foreach ($custom as $theme => $themedata) {
            $themedata = sortMultiArray($themedata, array('thumb', 'image_size', 'image_width', 'image_height'));
            ?>
			<span class="icons" id="<?php 
            echo $theme;
            ?>
_arrow">
				<?php 
            if ($theme) {
                $inputclass = 'hidden';
                echo '<em>' . $theme . '</em> (' . count($themedata), ')';
            } else {
                $inputclass = 'textbox';
                echo '<br />' . gettext('add');
            }
            ?>
				<a href="javascript:showTheme('<?php 
            echo $theme;
            ?>
');" title="<?php 
            echo gettext('Show');
            ?>
">
					<img class="icon-position-top4" src="<?php 
            echo WEBPATH . '/' . ZENFOLDER . '/images/arrow_down.png';
            ?>
" alt="" />
				</a>
			</span>
			<br />
			<div id="<?php 
            echo $theme;
            ?>
_list" style="display:none">
				<br />
				<?php 
            foreach ($themedata as $cache) {
                $key++;
                if ($c % 2) {
                    $class = 'boxb';
                } else {
                    $class = 'box';
                }
                ?>
					<div>
						<?php 
                $c++;
                if (isset($cache['enable']) && $cache['enable']) {
                    $allow = ' checked="checked"';
                } else {
                    $allow = '';
                }
                ?>
						<div class="<?php 
                echo $class;
                ?>
">
							<input type="<?php 
                echo $inputclass;
                ?>
" size="25" name="cacheManager_theme_<?php 
                echo $key;
                ?>
" value="<?php 
                echo $theme;
                ?>
" />
							<?php 
                if ($theme) {
                    ?>
								<span class="displayinlineright"><?php 
                    echo gettext('Delete');
                    ?>
 <input type="checkbox" name="cacheManager_delete_<?php 
                    echo $key;
                    ?>
" value="1" /></span>
								<input type="hidden" name="cacheManager_valid_<?php 
                    echo $key;
                    ?>
" value="1" />
								<?php 
                }
                ?>
							<br />
							<?php 
                foreach (array('image_size' => gettext('Size'), 'image_width' => gettext('Width'), 'image_height' => gettext('Height'), 'crop_width' => gettext('Crop width'), 'crop_height' => gettext('Crop height'), 'crop_x' => gettext('Crop X axis'), 'crop_y' => gettext('Crop Y axis')) as $what => $display) {
                    if (isset($cache[$what])) {
                        $v = $cache[$what];
                    } else {
                        $v = '';
                    }
                    ?>
								<span class="nowrap"><?php 
                    echo $display;
                    ?>
 <input type="textbox" size="2" name="cacheManager_<?php 
                    echo $what;
                    ?>
_<?php 
                    echo $key;
                    ?>
" value="<?php 
                    echo $v;
                    ?>
" /></span>
								<?php 
                }
                if (isset($cache['wmk'])) {
                    $wmk = $cache['wmk'];
                } else {
                    $wmk = '';
                }
                ?>
							<span class="nowrap"><?php 
                echo gettext('Watermark');
                ?>
 <input type="textbox" size="20" name="cacheManager_wmk_<?php 
                echo $key;
                ?>
" value="<?php 
                echo $wmk;
                ?>
" /></span>
							<br />
							<span class="nowrap"><?php 
                echo gettext('MaxSpace');
                ?>
<input type="checkbox"  name="cacheManager_maxspace_<?php 
                echo $key;
                ?>
" value="1"<?php 
                if (isset($cache['maxspace']) && $cache['maxspace']) {
                    echo ' checked="checked"';
                }
                ?>
 /></span>
							<span class="nowrap"><?php 
                echo gettext('Thumbnail');
                ?>
<input type="checkbox"  name="cacheManager_thumb_<?php 
                echo $key;
                ?>
" value="1"<?php 
                if (isset($cache['thumb']) && $cache['thumb']) {
                    echo ' checked="checked"';
                }
                ?>
 /></span>
							<span class="nowrap"><?php 
                echo gettext('Grayscale');
                ?>
<input type="checkbox"  name="cacheManager_gray_<?php 
                echo $key;
                ?>
" value="gray"<?php 
                if (isset($cache['gray']) && $cache['gray']) {
                    echo ' checked="checked"';
                }
                ?>
 /></span>
						</div>
						<br />
					</div>
					<?php 
            }
            ?>
			</div><!-- <?php 
            echo $theme;
            ?>
_list -->
			<?php 
        }
    }
Example #18
0
/**
 * Prints a table with a bar graph of the values.
 */
function printBarGraph()
{
    //$limit = $from_number.",".$to_number;
    $bargraphmaxsize = 90;
    $maxvalue = 0;
    $items = query_full_array("SELECT `aux`,`data` FROM " . prefix('plugin_storage') . " WHERE `type` = 'downloadList' AND `data` != 0 ORDER BY `data` DESC");
    $items = sortMultiArray($items, 'data', true, true, false, false);
    if ($items) {
        $maxvalue = $items[0]['data'];
        $no_statistic_message = "";
    } else {
        $no_statistic_message = "<tr><td><em>" . gettext("No statistic available") . "</em></td><td></td><td></td><td></td></tr>";
    }
    $countlines = 0;
    echo "<table class='bordered'>";
    echo "<tr><th colspan='4'><strong>" . gettext("Most downloaded files") . "</strong>";
    echo "</th></tr>";
    $count = '';
    echo $no_statistic_message;
    foreach ($items as $item) {
        if ($item['data'] != 0) {
            $count++;
            $barsize = round($item['data'] / $maxvalue * $bargraphmaxsize);
            $value = $item['data'];
            // counter to have a gray background of every second line
            if ($countlines === 1) {
                $style = " style='background-color: #f4f4f4'";
                // a little ugly but the already attached class for the table is so easiest overriden...
                $countlines = 0;
            } else {
                $style = "";
                $countlines++;
            }
            $outdated = '';
            if (!file_exists(internalToFilesystem($item['aux']))) {
                $outdated = ' class="unpublished_item"';
            }
            ?>
			<tr class="statistic_wrapper">
				<td class="statistic_counter" <?php 
            echo $style;
            ?>
>
					<?php 
            echo $count;
            ?>
				</td>
				<td class="statistic_title" <?php 
            echo $style;
            ?>
>
					<strong<?php 
            echo $outdated;
            ?>
>
						<?php 
            echo html_encode($item['aux']);
            ?>
					</strong>
				</td>
				<td class="statistic_graphwrap" <?php 
            echo $style;
            ?>
>
					<div class="statistic_bargraph" style="width: <?php 
            echo $barsize;
            ?>
%"></div>
					<div class="statistic_value"><?php 
            echo $value;
            ?>
</div>
				</td>
			</tr>
			<?php 
        }
        // if value != 0
    }
    // foreach end
    ?>
	</table>
	<?php 
}
/**
 * Prints a table with a bar graph of the values.
 *
 * @param string $sortorder "popular", "mostrated","toprated","mostcommented" or - only if $type = "albums"! - "mostimages"
 * @param string_type $type "albums", "images", "pages", "news", "tags"
 * @param int $limit Number of entries to show
 */
function printBarGraph($sortorder = "mostimages", $type = "albums", $from_number = 0, $to_number = 10)
{
    global $gallery, $webpath;
    $limit = $from_number . "," . $to_number;
    $bargraphmaxsize = 400;
    switch ($type) {
        case "albums":
            $typename = gettext("Albums");
            $dbquery = "SELECT * FROM " . prefix('albums');
            break;
        case "images":
            $typename = gettext("Images");
            $dbquery = "SELECT * FROM " . prefix('images');
            break;
        case "pages":
            $typename = gettext("Pages");
            $dbquery = "SELECT * FROM " . prefix('pages');
            break;
        case "news":
            $typename = gettext("News Articles");
            $dbquery = "SELECT * FROM " . prefix('news');
            break;
        case "newscategories":
            $typename = gettext("News Categories");
            $dbquery = "SELECT * FROM " . prefix('news_categories');
            break;
        case "tags":
            $typename = gettext("Tags");
            break;
        case "rss":
            $typename = gettext("rss");
            break;
    }
    switch ($sortorder) {
        case "mostused":
            switch ($type) {
                case "tags":
                    $itemssorted = query_full_array("SELECT tagobj.tagid, count(*) as tagcount, tags.* FROM " . prefix('obj_to_tag') . " AS tagobj, " . prefix('tags') . " AS tags WHERE tags.id=tagobj.tagid GROUP BY tags.id ORDER BY tagcount DESC LIMIT " . $limit);
                    if (empty($itemssorted)) {
                        $maxvalue = 0;
                    } else {
                        $maxvalue = $itemssorted[0]['tagcount'];
                    }
                    break;
                case "newscategories":
                    $itemssorted = query_full_array("SELECT news2cat.cat_id, count(*) as catcount, cats.* FROM " . prefix('news2cat') . " AS news2cat, " . prefix('news_categories') . " AS cats WHERE cats.id=news2cat.cat_id GROUP BY news2cat.cat_id ORDER BY catcount DESC LIMIT " . $limit);
                    if (empty($itemssorted)) {
                        $maxvalue = 0;
                    } else {
                        $maxvalue = $itemssorted[0]['catcount'];
                    }
                    break;
            }
            $headline = $typename . " - " . gettext("most used");
            break;
        case "popular":
            switch ($type) {
                case 'rss':
                    $itemssorted = query_full_array("SELECT `type`,`aux`, `data` FROM " . prefix('plugin_storage') . " WHERE `type` = 'rsshitcounter' ORDER BY CONVERT(data,UNSIGNED) DESC LIMIT " . $limit);
                    if (empty($itemssorted)) {
                        $maxvalue = 0;
                    } else {
                        $maxvalue = $itemssorted[0]['data'];
                    }
                    break;
                default:
                    $itemssorted = query_full_array($dbquery . " ORDER BY hitcounter DESC LIMIT " . $limit);
                    if (empty($itemssorted)) {
                        $maxvalue = 0;
                    } else {
                        $maxvalue = $itemssorted[0]['hitcounter'];
                    }
                    break;
            }
            $headline = $typename . " - " . gettext("most viewed");
            break;
        case "mostrated":
            $itemssorted = query_full_array($dbquery . " ORDER BY total_votes DESC LIMIT " . $limit);
            if (empty($itemssorted)) {
                $maxvalue = 0;
            } else {
                $maxvalue = $itemssorted[0]['total_votes'];
            }
            $headline = $typename . " - " . gettext("most rated");
            break;
        case "toprated":
            $itemssorted = query_full_array($dbquery . " ORDER BY (total_value/total_votes) DESC LIMIT {$limit}");
            if (empty($itemssorted)) {
                $maxvalue = 0;
            } else {
                if ($itemssorted[0]['total_votes'] != 0) {
                    $maxvalue = $itemssorted[0]['total_value'] / $itemssorted[0]['total_votes'];
                } else {
                    $maxvalue = 0;
                }
            }
            $headline = $typename . " - " . gettext("top rated");
            break;
        case "mostcommented":
            switch ($type) {
                case "albums":
                    $itemssorted = query_full_array("SELECT comments.ownerid, count(*) as commentcount, albums.* FROM " . prefix('comments') . " AS comments, " . prefix('albums') . " AS albums WHERE albums.id=comments.ownerid AND type = 'albums' GROUP BY comments.ownerid ORDER BY commentcount DESC LIMIT " . $limit);
                    break;
                case "images":
                    $itemssorted = query_full_array("SELECT comments.ownerid, count(*) as commentcount, images.* FROM " . prefix('comments') . " AS comments, " . prefix('images') . " AS images WHERE images.id=comments.ownerid AND type = 'images' GROUP BY comments.ownerid ORDER BY commentcount DESC LIMIT " . $limit);
                    break;
                case "pages":
                    $itemssorted = query_full_array("SELECT comments.ownerid, count(*) as commentcount, pages.* FROM " . prefix('comments') . " AS comments, " . prefix('pages') . " AS pages WHERE pages.id=comments.ownerid AND type = 'page' GROUP BY comments.ownerid ORDER BY commentcount DESC LIMIT " . $limit);
                    break;
                case "news":
                    $itemssorted = query_full_array("SELECT comments.ownerid, count(*) as commentcount, news.* FROM " . prefix('comments') . " AS comments, " . prefix('news') . " AS news WHERE news.id=comments.ownerid AND type = 'news' GROUP BY comments.ownerid ORDER BY commentcount DESC LIMIT " . $limit);
                    break;
            }
            if (empty($itemssorted)) {
                $maxvalue = 0;
            } else {
                $maxvalue = $itemssorted[0]['commentcount'];
            }
            $headline = $typename . " - " . gettext("most commented");
            break;
        case "mostimages":
            $itemssorted = query_full_array("SELECT images.albumid, count(*) as imagenumber, albums.* FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums WHERE albums.id=images.albumid GROUP BY images.albumid ORDER BY imagenumber DESC LIMIT " . $limit);
            if (empty($itemssorted)) {
                $maxvalue = 0;
            } else {
                $maxvalue = $itemssorted[0]['imagenumber'];
            }
            $headline = $typename . " - " . gettext("most images");
            break;
        case "latest":
            switch ($type) {
                case "albums":
                    $allalbums = query_full_array($dbquery . " ORDER BY id DESC LIMIT " . $limit);
                    $albums = array();
                    foreach ($allalbums as $album) {
                        $albumobj = new Album($gallery, $album['folder']);
                        $albumentry = array("id" => $albumobj->get('id'), "title" => $albumobj->getTitle(), "folder" => $albumobj->name, "imagenumber" => $albumobj->getNumImages(), "show" => $albumobj->get("show"));
                        array_unshift($albums, $albumentry);
                    }
                    $maxvalue = 1;
                    $itemssorted = sortMultiArray($albums, 'id', true, true);
                    // The items are originally sorted by id;
                    $headline = $typename . " - " . gettext("latest");
                    break;
                case "images":
                    $itemssorted = query_full_array($dbquery . " ORDER BY id DESC LIMIT " . $limit);
                    $barsize = 0;
                    $maxvalue = 1;
                    $headline = $typename . " - " . gettext("latest");
                    break;
            }
            break;
        case "latestupdated":
            $albums = getAlbumStatistic($to_number, 'latestupdated', '');
            $maxvalue = 1;
            if (!empty($albums)) {
                foreach ($albums as $key => $album) {
                    $albumobj = new Album($gallery, $album['folder']);
                    $albums[$key]['imagenumber'] = $albumobj->getNumImages();
                }
            }
            $itemssorted = $albums;
            $headline = $typename . " - " . gettext("latest updated");
            break;
    }
    if ($maxvalue == 0 || empty($itemssorted)) {
        $maxvalue = 1;
        $no_hitcount_enabled_msg = '';
        if ($sortorder == 'popular' && $type != 'rss' && !getOption('zp_plugin_hitcounter')) {
            $no_hitcount_enabled_msg = gettext("(The hitcounter plugin is not enabled.)");
        }
        $no_statistic_message = "<tr><td><em>" . gettext("No statistic available.") . $no_hitcount_enabled_msg . "</em></td><td></td><td></td><td></td></tr>";
    } else {
        $no_statistic_message = "";
        if ($sortorder == 'popular' && $type != 'rss' && !getOption('zp_plugin_hitcounter')) {
            $no_statistic_message = "<tr><td colspan='4'><em>" . gettext("Note: The hitcounter plugin is not enabled, therefore any existing values will not get updated.") . "</em></td><td></td><td></td><td></td></tr>";
        }
    }
    if ($from_number <= 1) {
        $count = 1;
    } else {
        $count = $from_number;
    }
    $countlines = 0;
    echo "<table class='bordered'>";
    echo "<tr><th colspan='4'><strong>" . $headline . "</strong>";
    if (isset($_GET['stats'])) {
        echo "<a href='gallery_statistics.php'> | " . gettext("Back to the top 10 lists") . "</a>";
    } else {
        if (empty($no_statistic_message)) {
            echo "<a href='gallery_statistics.php?stats=" . $sortorder . "&amp;type=" . $type . "'> | " . gettext("View more") . "</a>";
        }
        echo "<a href='#top'> | " . gettext("top") . "</a>";
    }
    echo "</th></tr>";
    echo $no_statistic_message;
    foreach ($itemssorted as $item) {
        if (array_key_exists("filename", $item)) {
            $name = $item['filename'];
        } else {
            if (array_key_exists("folder", $item)) {
                $name = $item['folder'];
            } else {
                if ($type === "pages" or $type === "news") {
                    $name = $item['titlelink'];
                } else {
                    if ($type === "newscategories") {
                        $name = $item['title'];
                    } else {
                        if ($type === "tags") {
                            $name = "";
                        }
                    }
                }
            }
        }
        switch ($sortorder) {
            case "popular":
                switch ($type) {
                    case 'rss':
                        $barsize = round($item['data'] / $maxvalue * $bargraphmaxsize);
                        $value = $item['data'];
                        break;
                    default:
                        $barsize = round($item['hitcounter'] / $maxvalue * $bargraphmaxsize);
                        $value = $item['hitcounter'];
                        break;
                }
                break;
            case "mostrated":
                if ($item['total_votes'] != 0) {
                    $barsize = round($item['total_votes'] / $maxvalue * $bargraphmaxsize);
                } else {
                    $barsize = 0;
                }
                $value = $item['total_votes'];
                break;
            case "toprated":
                if ($item['total_votes'] != 0) {
                    $barsize = round($item['total_value'] / $item['total_votes'] / $maxvalue * $bargraphmaxsize);
                    $value = round($item['total_value'] / $item['total_votes']);
                } else {
                    $barsize = 0;
                    $value = 0;
                }
                break;
            case "mostcommented":
                if ($maxvalue != 0) {
                    $barsize = round($item['commentcount'] / $maxvalue * $bargraphmaxsize);
                } else {
                    $barsize = 0;
                }
                $value = $item['commentcount'];
                break;
            case "mostimages":
                $barsize = round($item['imagenumber'] / $maxvalue * $bargraphmaxsize);
                $value = $item['imagenumber'];
                break;
            case "latest":
                switch ($type) {
                    case "albums":
                        $barsize = 0;
                        //round($item['imagenumber'] / $maxvalue * $bargraphmaxsize);
                        $value = sprintf(gettext("%s images"), $item['imagenumber']);
                        break;
                    case "images":
                        $barsize = 0;
                        $value = "";
                        break;
                }
                break;
            case "latestupdated":
                $barsize = 0;
                //round($item['imagenumber'] / $maxvalue * $bargraphmaxsize);
                $value = sprintf(gettext("%s images"), $item['imagenumber']);
                break;
            case "mostused":
                switch ($type) {
                    case "tags":
                        if ($maxvalue != 0) {
                            $barsize = round($item['tagcount'] / $maxvalue * $bargraphmaxsize);
                        } else {
                            $barsize = 0;
                        }
                        $value = $item['tagcount'];
                        break;
                    case "newscategories":
                        if ($maxvalue != 0) {
                            $barsize = round($item['catcount'] / $maxvalue * $bargraphmaxsize);
                        } else {
                            $barsize = 0;
                        }
                        $value = $item['catcount'];
                        break;
                }
                break;
        }
        // counter to have a gray background of every second line
        if ($countlines === 1) {
            $style = " style='background-color: #f4f4f4'";
            // a little ugly but the already attached class for the table is so easiest overriden...
            $countlines = 0;
        } else {
            $style = "";
            $countlines++;
        }
        switch ($type) {
            case "albums":
                $editurl = $webpath . "/admin-edit.php?page=edit&amp;album=" . $name;
                $viewurl = WEBPATH . "/index.php?album=" . $name;
                $title = get_language_string($item['title']);
                break;
            case "images":
                $getalbumfolder = query_single_row("SELECT title, folder, `show` from " . prefix("albums") . " WHERE id = " . $item['albumid']);
                if ($sortorder === "latest") {
                    $value = "<span";
                    if ($getalbumfolder['show'] != "1") {
                        $value = $value . " class='unpublished_item'";
                    }
                    $value = $value . ">" . get_language_string($getalbumfolder['title']) . "</span> (" . $getalbumfolder['folder'] . ")";
                }
                $editurl = $webpath . "/admin-edit.php?page=edit&amp;album=" . $getalbumfolder['folder'] . "&amp;image=" . $item['filename'] . "&amp;tab=imageinfo#IT";
                $viewurl = WEBPATH . "/index.php?album=" . $getalbumfolder['folder'] . "&amp;image=" . $name;
                $title = get_language_string($item['title']);
                break;
            case "pages":
                $editurl = $webpath . '/' . PLUGIN_FOLDER . "/zenpage/admin-edit.php?page&amp;titlelink=" . $name;
                $viewurl = WEBPATH . "/index.php?p=pages&amp;title=" . $name;
                $title = get_language_string($item['title']);
                break;
            case "news":
                $editurl = $webpath . '/' . PLUGIN_FOLDER . "/zenpage/admin-edit.php?news&amp;titlelink=" . $name;
                $viewurl = WEBPATH . "/index.php?p=news&amp;title=" . $name;
                $title = get_language_string($item['title']);
                break;
            case "newscategories":
                $editurl = $webpath . '/' . PLUGIN_FOLDER . "/zenpage/admin-categories.php?edit&amp;id=" . $item['id'];
                $viewurl = WEBPATH . "/index.php?p=news&amp;category=" . $name;
                $title = get_language_string($item['titlelink']);
                break;
            case "tags":
                $editurl = $webpath . "/admin-tags.php";
                $viewurl = WEBPATH . "/index.php?p=search&amp;searchfields=tags&amp;words=" . $item['name'];
                $title = get_language_string($item['name']);
                break;
            case "rss":
                $editurl = '';
                $viewurl = WEBPATH . "/index.php?" . html_encode(strrchr($item['aux'], 'rss'));
                $title = html_encode(strrchr($item['aux'], 'rss'));
                break;
        }
        if (isset($item['show'])) {
            if ($item['show'] != "1") {
                $show = " class='unpublished_item'";
            } else {
                $show = "";
            }
        } else {
            $show = "";
        }
        if ($value != 0 or $sortorder === "latest") {
            if (empty($name)) {
                $name = "";
            } else {
                $name = "(" . $name . ")";
            }
            ?>
		<tr class="statistic_wrapper">
		<td class="statistic_counter" <?php 
            echo $style;
            ?>
>
		<?php 
            echo $count;
            ?>
		</td>
		<td class="statistic_title" <?php 
            echo $style;
            ?>
>
		<strong<?php 
            echo $show;
            ?>
><?php 
            echo $title;
            ?>
</strong> <?php 
            echo $name;
            ?>
		</td>
		<td class="statistic_graphwrap" <?php 
            echo $style;
            ?>
>
		<div class="statistic_bargraph" style="width: <?php 
            echo $barsize;
            ?>
px"></div>
		<div class="statistic_value"><?php 
            echo $value;
            ?>
</div>
		</td>
		<td class="statistic_link" <?php 
            echo $style;
            ?>
>
		<?php 
            switch ($type) {
                case 'rss':
                    echo "<a href='" . $viewurl . "' title='" . $name . "'>" . gettext("View") . "</a></td>";
                    break;
                default:
                    echo "<a href='" . $editurl . "' title='" . $name . "'>" . gettext("Edit") . "</a> | <a href='" . $viewurl . "' title='" . $name . "'>" . gettext("View") . "</a></td>";
                    break;
            }
            echo "</tr>";
            $count++;
            if ($count === $limit) {
                break;
            }
        }
    }
    // foreach end
    echo "</table>";
}
Example #20
0
</li>
													<?php 
                }
            }
            ?>
										</ul>
									</p>
									<?php 
        }
        if (!empty($buttonlist) || !empty($albumbuttons) || !empty($imagebuttons)) {
            ?>
									<hr />
									<?php 
        }
        if (!empty($buttonlist)) {
            $buttonlist = sortMultiArray($buttonlist, array('category', 'button_text'), false);
            ?>
									<div class="box" id="overview-utility">
										<h2 class="h2_bordered">Utility functions</h2>
										<?php 
            $category = '';
            foreach ($buttonlist as $button) {
                $button_category = @$button['category'];
                $button_icon = @$button['icon'];
                if ($category != $button_category) {
                    if ($category) {
                        ?>
													</fieldset>
													<?php 
                    }
                    $category = $button_category;
Example #21
0
/**
 * Outputs the rights checkbox table for admin
 *
 * @param $id int record id for the save
 * @param string $background background color
 * @param string $alterrights are the items changable
 * @param bit $rights rights of the admin
 */
function printAdminRightsTable($id, $background, $alterrights, $rights)
{
    $rightslist = sortMultiArray(Zenphoto_Authority::getRights(), array('set', 'value'));
    ?>
		<div class="box-rights">
			<strong><?php 
    echo gettext("Rights:");
    ?>
</strong>
			<?php 
    $element = 3;
    $activeset = false;
    ?>
			<input type="checkbox" name="<?php 
    echo $id;
    ?>
-rightsenabled" class="user-<?php 
    echo $id;
    ?>
" value="1" checked="checked" <?php 
    echo $alterrights;
    ?>
 style="display:none" />
			<?php 
    foreach ($rightslist as $rightselement => $right) {
        if ($right['display']) {
            if ($right['set'] != gettext('Pages') && $right['set'] != gettext('News') || extensionEnabled('zenpage')) {
                if ($activeset != $right['set']) {
                    if ($activeset) {
                        ?>
							</fieldset>
							<?php 
                    }
                    $activeset = $right['set'];
                    ?>
						<fieldset><legend><?php 
                    echo $activeset;
                    ?>
</legend>
							<?php 
                }
                ?>
						<label title="<?php 
                echo html_encode(get_language_string($right['hint']));
                ?>
">
							<input type="checkbox" name="<?php 
                echo $id . '-' . $rightselement;
                ?>
" id="<?php 
                echo $rightselement . '-' . $id;
                ?>
" class="user-<?php 
                echo $id;
                ?>
" value="<?php 
                echo $right['value'];
                ?>
"<?php 
                if ($rights & $right['value']) {
                    echo ' checked="checked"';
                }
                echo $alterrights;
                ?>
 /> <?php 
                echo $right['name'];
                ?>
						</label>
						<?php 
            } else {
                ?>
						<input type="hidden" name="<?php 
                echo $id . '-' . $rightselement;
                ?>
" id="<?php 
                echo $rightselement . '-' . $id;
                ?>
" value="<?php 
                echo $right['value'];
                ?>
" />
						<?php 
            }
        }
    }
    ?>
		</fieldset>
	</div>
	<?php 
}
Example #22
0
/**
 * Sort the album array based on either according to the sort key.
 * Default is to sort on the `sort_order` field.
 *
 * Returns an array with the albums in the desired sort order
 *
 * @param  array $albums array of album names
 * @param  string $sortkey the sorting scheme
 * @return array
 *
 * @author Todd Papaioannou (lucky@luckyspin.org)
 * @since  1.0.0
 */
function sortAlbumArray($parentalbum, $albums, $sortkey = '`sort_order`')
{
    global $_zp_gallery;
    if (count($albums) == 0) {
        return array();
    }
    if (is_null($parentalbum)) {
        $albumid = ' IS NULL';
    } else {
        $albumid = '="' . $parentalbum->id . '"';
    }
    $sql = 'SELECT `folder`, `sort_order`, `title`, `show`, `dynamic`, `search_params` FROM ' . prefix("albums") . ' WHERE `parentid`' . $albumid . ' ORDER BY ' . $sortkey;
    $loop = 0;
    do {
        $result = query($sql);
        $hidden = array();
        $results = array();
        while ($row = mysql_fetch_assoc($result)) {
            $results[] = $row;
        }
        if (strpos($sortkey, 'title') !== false) {
            $results = sortByMultilingual($results, 'title', strpos($sortkey, 'DESC') !== false);
        } else {
            if (strpos($sortkey, 'folder') !== false) {
                if (strpos($sortkey, 'DESC') !== false) {
                    $order = 'dsc';
                } else {
                    $order = 'asc';
                }
                $results = sortMultiArray($results, 'folder', $order, true, false);
            }
        }
        $i = 0;
        $albums_r = array_flip($albums);
        $albums_touched = array();
        foreach ($results as $row) {
            $folder = $row['folder'];
            $mine = isMyALbum($folder, ALL_RIGHTS);
            if (array_key_exists($folder, $albums_r)) {
                $albums_r[$folder] = $i;
                $albums_touched[] = $folder;
                if (!($row['show'] || $mine)) {
                    // you can see only your own unpublished content.
                    $hidden[] = $folder;
                }
            }
            $i++;
        }
        $albums_untouched = array_diff($albums, $albums_touched);
        if (count($albums_untouched) > 0) {
            //found new albums
            $loop++;
            foreach ($albums_untouched as $alb) {
                $albobj = new Album($_zp_gallery, $alb);
                // force load to DB
                $albums_r[$alb] = -$i;
                // place them in the front of the list
                $i++;
            }
        } else {
            $loop = 0;
        }
    } while ($loop == 1);
    foreach ($hidden as $alb) {
        unset($albums_r[$alb]);
    }
    $albums = array_flip($albums_r);
    ksort($albums);
    $albums_ordered = array();
    foreach ($albums as $album) {
        $albums_ordered[] = $album;
    }
    return $albums_ordered;
}
Example #23
0
function action_getPlaylist()
{
    doPrint("got json playlist request");
    //doPrint($_REQUEST);
    global $config;
    $data = getData();
    if (isset($_REQUEST["move"]) and is_array($_REQUEST["move"])) {
        doPrint("reorderd playlist");
        $newPlaylist = array();
        foreach ($_REQUEST['move'] as $key) {
            $track = $data['playlist'][$key];
            unset($data['playlist'][$key]);
            $newPlaylist[$key] = $track;
        }
        #add not moved ones to the end
        foreach ($data['playlist'] as $key => $track) {
            $newPlaylist[$key] = $track;
        }
        $data["playlist"] = $newPlaylist;
        storeData($data);
    }
    if (isset($_REQUEST["add"]) and is_array($_REQUEST["add"])) {
        if (!isset($_REQUEST["aktPath"])) {
            $_REQUEST["aktPath"] = "";
        }
        $aktPath = strip_tags($_REQUEST["aktPath"]);
        $aktPath = stripslashes($_REQUEST["aktPath"]);
        foreach ($_REQUEST["add"] as $file) {
            $file = stripslashes($file);
            $file = trim($file);
            $allowed = getAccess($aktPath . "/" . $file);
            if (!$allowed) {
                doPrint("ip is not allowed to add " . $aktPath . "/" . $file);
            } elseif (file_exists($config["searchPath"] . $aktPath . "/" . $file)) {
                doPrint("added file " . $aktPath . "/" . $file);
                $data["playlist"] = playlistAdd($data["playlist"], $config["searchPath"] . $aktPath . "/" . $file);
            } elseif (strpos($file, "http://") === 0) {
                doPrint("added stream " . $file);
                $data["playlist"] = playlistAdd($data["playlist"], $file);
            } else {
                doPrint("action_getPlaylist(): dont know what to do with: " . $config["searchPath"] . $aktPath . "/" . $file);
            }
        }
        $data = recalcTotalPlaytime($data);
        storeData($data);
    }
    if (isset($_REQUEST["remove"]) and is_array($_REQUEST["remove"])) {
        foreach ($_REQUEST["remove"] as $token) {
            if (isset($data["playlist"][$token])) {
                doPrint("removed file " . $data["playlist"][$token]['title']);
                unset($data["playlist"][$token]);
            }
        }
        $data = recalcTotalPlaytime($data);
        storeData($data);
    }
    if (isset($_REQUEST["clear"])) {
        doPrint("pressed clear");
        $data["playlist"] = array();
        $data["totalTime"] = "0";
        $data["cachedPic"] = "";
        $data["playingPic"] = "";
        $data["curTrack"] = "";
        storeData($data);
    }
    if (isset($_REQUEST["shuffle"])) {
        doPrint("pressed shuffle");
        shuffle($data["playlist"]);
        $newData = array();
        foreach ($data["playlist"] as $blah) {
            $newData[$blah["token"]] = $blah;
        }
        $data["playlist"] = $newData;
        storeData($data);
    }
    if (isset($_REQUEST["sort"])) {
        doPrint("pressed sort");
        $tmp = sortMultiArray($data["playlist"], "filename");
        $newData = array();
        foreach ($tmp as $blah) {
            $newData[$blah["token"]] = $blah;
        }
        $data["playlist"] = $newData;
        storeData($data);
    }
    if (isset($_REQUEST["loadPlaylist"]) and is_file($config["plDir"] . $_REQUEST["loadPlaylist"])) {
        doPrint("loading playlist: " . $_REQUEST["loadPlaylist"]);
        if (!preg_match("/\\w+ - .*\\.playlist/", $_REQUEST["loadPlaylist"])) {
            doPrint("invalid playlist: " . $_REQUEST["loadPlaylist"]);
            exit;
        }
        $files = file($config["plDir"] . $_REQUEST["loadPlaylist"]);
        $playlist = array();
        foreach ($files as $file) {
            $file = trim($file);
            if (substr($file, 0, 8) == "STREAM::") {
                $playlist = playlistAdd($playlist, substr($file, 8));
            } else {
                $playlist = playlistAdd($playlist, $config["searchPath"] . $file);
            }
        }
        $data["playlist"] = $playlist;
        storeData($data);
    }
    $playlist = array();
    foreach ($data['playlist'] as $key => $entry) {
        if (empty($key) or !isset($entry["filename"])) {
            continue;
        }
        $playlist[] = array("tracknum" => $entry['tracknum'], "artist" => utf8_encode($entry['artist']), "album" => utf8_encode($entry['album']), "title" => utf8_encode($entry['title']), "length" => $entry['length'], "token" => $entry['token'], "file" => utf8_encode($entry['filename']));
    }
    if (count($playlist) > 0) {
        $data = json_encode($playlist);
        echo '({"total":"' . count($playlist) . '","results":' . $data . '})';
    } else {
        echo '({"total":"0", "results":""})';
    }
}
Example #24
0
/**
 * Gets the parent menu items of the current menu item. Returns the array of the items or false.
 * @param string $menuset current menu set
 * @return array|false
 */
function getParentMenuItems($menuset = 'default')
{
    $sortorder = getCurrentMenuItem($menuset);
    $items = getMenuItems($menuset, getMenuVisibility());
    if (count($items) > 0) {
        if ($sortorder) {
            $parents = array();
            $order = explode('-', $sortorder);
            array_pop($order);
            $look = array();
            while (count($order) > 0) {
                $look = implode('-', $order);
                array_pop($order);
                if (array_key_exists($look, $items)) {
                    array_unshift($parents, $items[$look]);
                }
            }
            if (!empty($parents)) {
                return sortMultiArray($parents, 'sort_order', $descending = false, $natsort = false, $case_sensitive = false);
            }
        }
    }
    return false;
}
Example #25
0
                        break;
                    case '$':
                        if (!empty($user['group'])) {
                            unset($admins[$key]);
                        }
                        break;
                    default:
                        $hisgroups = explode(',', $user['group']);
                        if (!in_array($showgroup, $hisgroups)) {
                            unset($admins[$key]);
                        }
                        break;
                }
            }
        }
        $admins = sortMultiArray($admins, 'user');
        $rights = DEFAULT_RIGHTS;
        $groupname = 'default';
        $list = array();
        foreach ($admins as $admin) {
            $list[] = $admin['user'];
        }
        $rangeset = getPageSelector($list, USERS_PER_PAGE);
    }
    $newuser = array('id' => -1, 'user' => '', 'pass' => '', 'name' => '', 'email' => '', 'rights' => $rights, 'custom_data' => NULL, 'valid' => 1, 'group' => $groupname);
    $alterrights = '';
} else {
    $alterrights = ' disabled="disabled"';
    $rangeset = array();
    if ($_zp_current_admin_obj) {
        $admins = array($_zp_current_admin_obj->getUser() => array('id' => $_zp_current_admin_obj->getID(), 'user' => $_zp_current_admin_obj->getUser(), 'pass' => $_zp_current_admin_obj->getPass(), 'name' => $_zp_current_admin_obj->getName(), 'email' => $_zp_current_admin_obj->getEmail(), 'rights' => $_zp_current_admin_obj->getRights(), 'custom_data' => $_zp_current_admin_obj->getCustomData(), 'valid' => 1, 'group' => $_zp_current_admin_obj->getGroup()));
Example #26
0
 /**
  * Returns an array of the rights definitions for $version (default returns current version rights)
  *
  * @param $version
  */
 static function getRights($version = NULL)
 {
     if (empty($version)) {
         $v = self::getVersion();
     } else {
         $v = $version;
     }
     switch ($v) {
         case 1:
             $rightsset = array('NO_RIGHTS' => array('value' => 2, 'name' => gettext('No rights'), 'set' => '', 'display' => false, 'hint' => ''), 'OVERVIEW_RIGHTS' => array('value' => 4, 'name' => gettext('Overview'), 'set' => '', 'display' => true, 'hint' => ''), 'VIEW_ALL_RIGHTS' => array('value' => 8, 'name' => gettext('View all'), 'set' => '', 'display' => true, 'hint' => ''), 'UPLOAD_RIGHTS' => array('value' => 16, 'name' => gettext('Upload'), 'set' => '', 'display' => true, 'hint' => ''), 'POST_COMMENT_RIGHTS' => array('value' => 32, 'name' => gettext('Post comments'), 'set' => '', 'display' => true, 'hint' => ''), 'COMMENT_RIGHTS' => array('value' => 64, 'name' => gettext('Comments'), 'set' => '', 'display' => true, 'hint' => ''), 'ALBUM_RIGHTS' => array('value' => 256, 'name' => gettext('Album'), 'set' => '', 'display' => true, 'hint' => ''), 'MANAGE_ALL_ALBUM_RIGHTS' => array('value' => 512, 'name' => gettext('Manage all albums'), 'set' => '', 'display' => true, 'hint' => ''), 'THEMES_RIGHTS' => array('value' => 1024, 'name' => gettext('Themes'), 'set' => '', 'display' => true, 'hint' => ''), 'ZENPAGE_RIGHTS' => array('value' => 2049, 'name' => gettext('Zenpage'), 'set' => '', 'display' => true, 'hint' => ''), 'TAGS_RIGHTS' => array('value' => 4096, 'name' => gettext('Tags'), 'set' => '', 'display' => true, 'hint' => ''), 'OPTIONS_RIGHTS' => array('value' => 8192, 'name' => gettext('Options'), 'set' => '', 'display' => true, 'hint' => ''), 'ADMIN_RIGHTS' => array('value' => 65536, 'name' => gettext('Admin'), 'set' => '', 'display' => true, 'hint' => ''));
             break;
         case 2:
             $rightsset = array('NO_RIGHTS' => array('value' => 1, 'name' => gettext('No rights'), 'set' => '', 'display' => false, 'hint' => ''), 'OVERVIEW_RIGHTS' => array('value' => pow(2, 2), 'name' => gettext('Overview'), 'set' => gettext('Gallery'), 'display' => true, 'hint' => gettext('Users with this right may view the admin overview page.')), 'VIEW_ALL_RIGHTS' => array('value' => pow(2, 4), 'name' => gettext('View all'), 'set' => gettext('Gallery'), 'display' => true, 'hint' => gettext('Users with this right may view all of the gallery regardless of protection of the page. Without this right, the user can view only public ones and those checked in his managed object lists or as granted by View Search or View Gallery.')), 'UPLOAD_RIGHTS' => array('value' => pow(2, 6), 'name' => gettext('Upload'), 'set' => gettext('Gallery'), 'display' => true, 'hint' => gettext('Users with this right may upload to the albums for which they have management rights.')), 'POST_COMMENT_RIGHTS' => array('value' => pow(2, 8), 'name' => gettext('Post comments'), 'set' => gettext('Gallery'), 'display' => true, 'hint' => gettext('When the comment_form plugin is used for comments and its "Only members can comment" option is set, only users with this right may post comments.')), 'COMMENT_RIGHTS' => array('value' => pow(2, 10), 'name' => gettext('Comments'), 'set' => gettext('Gallery'), 'display' => true, 'hint' => gettext('Users with this right may make comments tab changes.')), 'ALBUM_RIGHTS' => array('value' => pow(2, 12), 'name' => gettext('Albums'), 'set' => gettext('Albums'), 'display' => true, 'hint' => gettext('Users with this right may access the “albums” tab to make changes.')), 'ZENPAGE_PAGES_RIGHTS' => array('value' => pow(2, 14), 'name' => gettext('Pages'), 'set' => gettext('Pages'), 'display' => true, 'hint' => gettext('Users with this right may edit and manage Zenpage pages.')), 'ZENPAGE_NEWS_RIGHTS' => array('value' => pow(2, 16), 'name' => gettext('News'), 'set' => gettext('News'), 'display' => true, 'hint' => gettext('Users with this right may edit and manage Zenpage articles and categories.')), 'FILES_RIGHTS' => array('value' => pow(2, 18), 'name' => gettext('Files'), 'set' => gettext('Gallery'), 'display' => true, 'hint' => gettext('Allows the user access to the “filemanager” located on the upload: files sub-tab.')), 'MANAGE_ALL_PAGES_RIGHTS' => array('value' => pow(2, 20), 'name' => gettext('Manage all pages'), 'set' => gettext('Pages'), 'display' => true, 'hint' => gettext('Users who do not have “Admin” rights normally are restricted to manage only objects to which they have been assigned. This right allows them to manage any Zenpage page.')), 'MANAGE_ALL_NEWS_RIGHTS' => array('value' => pow(2, 22), 'name' => gettext('Manage all news'), 'set' => gettext('News'), 'display' => true, 'hint' => gettext('Users who do not have “Admin” rights normally are restricted to manage only objects to which they have been assigned. This right allows them to manage any Zenpage news article or category.')), 'MANAGE_ALL_ALBUM_RIGHTS' => array('value' => pow(2, 24), 'name' => gettext('Manage all albums'), 'set' => gettext('Albums'), 'display' => true, 'hint' => gettext('Users who do not have “Admin” rights normally are restricted to manage only objects to which they have been assigned. This right allows them to manage any album in the gallery.')), 'THEMES_RIGHTS' => array('value' => pow(2, 26), 'name' => gettext('Themes'), 'set' => gettext('Gallery'), 'display' => true, 'hint' => gettext('Users with this right may make themes related changes. These are limited to the themes associated with albums checked in their managed albums list.')), 'TAGS_RIGHTS' => array('value' => pow(2, 28), 'name' => gettext('Tags'), 'set' => gettext('General'), 'display' => true, 'hint' => gettext('Users with this right may make additions and changes to the set of tags.')), 'OPTIONS_RIGHTS' => array('value' => pow(2, 29), 'name' => gettext('Options'), 'set' => gettext('General'), 'display' => true, 'hint' => gettext('Users with this right may make changes on the options tabs.')), 'ADMIN_RIGHTS' => array('value' => pow(2, 30), 'name' => gettext('Admin'), 'set' => gettext('General'), 'display' => true, 'hint' => gettext('The master privilege. A user with "Admin" can do anything. (No matter what his other rights might indicate!)')));
             break;
         case 3:
             $rightsset = array('NO_RIGHTS' => array('value' => 1, 'name' => gettext('No rights'), 'set' => '', 'display' => false, 'hint' => ''), 'OVERVIEW_RIGHTS' => array('value' => pow(2, 2), 'name' => gettext('Overview'), 'set' => gettext('General'), 'display' => true, 'hint' => gettext('Users with this right may view the admin overview page.')), 'VIEW_GALLERY_RIGHTS' => array('value' => pow(2, 4), 'name' => gettext('View gallery'), 'set' => gettext('Gallery'), 'display' => true, 'hint' => gettext('Users with this right may view otherwise protected generic gallery pages.')), 'VIEW_SEARCH_RIGHTS' => array('value' => pow(2, 5), 'name' => gettext('View search'), 'set' => gettext('Gallery'), 'display' => true, 'hint' => gettext('Users with this right may view search pages even if password protected.')), 'VIEW_FULLIMAGE_RIGHTS' => array('value' => pow(2, 6), 'name' => gettext('View fullimage'), 'set' => gettext('Albums'), 'display' => true, 'hint' => gettext('Users with this right may view all full sized (raw) images.')), 'ALL_NEWS_RIGHTS' => array('value' => pow(2, 7), 'name' => gettext('Access all'), 'set' => gettext('News'), 'display' => true, 'hint' => gettext('Users with this right have access to all zenpage news articles.')), 'ALL_PAGES_RIGHTS' => array('value' => pow(2, 8), 'name' => gettext('Access all'), 'set' => gettext('Pages'), 'display' => true, 'hint' => gettext('Users with this right have access to all zenpage pages.')), 'ALL_ALBUMS_RIGHTS' => array('value' => pow(2, 9), 'name' => gettext('Access all'), 'set' => gettext('Albums'), 'display' => true, 'hint' => gettext('Users with this right have access to all albums.')), 'VIEW_UNPUBLISHED_RIGHTS' => array('value' => pow(2, 10), 'name' => gettext('View unpublished'), 'set' => gettext('Albums'), 'display' => true, 'hint' => gettext('Users with this right will see all unpublished items.')), 'POST_COMMENT_RIGHTS' => array('value' => pow(2, 11), 'name' => gettext('Post comments'), 'set' => gettext('Gallery'), 'display' => true, 'hint' => gettext('When the comment_form plugin is used for comments and its "Only members can comment" option is set, only users with this right may post comments.')), 'COMMENT_RIGHTS' => array('value' => pow(2, 12), 'name' => gettext('Comments'), 'set' => gettext('Gallery'), 'display' => true, 'hint' => gettext('Users with this right may make comments tab changes.')), 'UPLOAD_RIGHTS' => array('value' => pow(2, 13), 'name' => gettext('Upload'), 'set' => gettext('Albums'), 'display' => true, 'hint' => gettext('Users with this right may upload to the albums for which they have management rights.')), 'ZENPAGE_NEWS_RIGHTS' => array('value' => pow(2, 15), 'name' => gettext('News'), 'set' => gettext('News'), 'display' => false, 'hint' => gettext('Users with this right may edit and manage Zenpage articles and categories.')), 'ZENPAGE_PAGES_RIGHTS' => array('value' => pow(2, 16), 'name' => gettext('Pages'), 'set' => gettext('Pages'), 'display' => false, 'hint' => gettext('Users with this right may edit and manage Zenpage pages.')), 'FILES_RIGHTS' => array('value' => pow(2, 17), 'name' => gettext('Files'), 'set' => gettext('Gallery'), 'display' => true, 'hint' => gettext('Allows the user access to the “filemanager” located on the upload: files sub-tab.')), 'ALBUM_RIGHTS' => array('value' => pow(2, 18), 'name' => gettext('Albums'), 'set' => gettext('Albums'), 'display' => false, 'hint' => gettext('Users with this right may access the “albums” tab to make changes.')), 'MANAGE_ALL_NEWS_RIGHTS' => array('value' => pow(2, 21), 'name' => gettext('Manage all'), 'set' => gettext('News'), 'display' => true, 'hint' => gettext('Users who do not have “Admin” rights normally are restricted to manage only objects to which they have been assigned. This right allows them to manage any Zenpage news article or category.')), 'MANAGE_ALL_PAGES_RIGHTS' => array('value' => pow(2, 22), 'name' => gettext('Manage all'), 'set' => gettext('Pages'), 'display' => true, 'hint' => gettext('Users who do not have “Admin” rights normally are restricted to manage only objects to which they have been assigned. This right allows them to manage any Zenpage page.')), 'MANAGE_ALL_ALBUM_RIGHTS' => array('value' => pow(2, 23), 'name' => gettext('Manage all'), 'set' => gettext('Albums'), 'display' => true, 'hint' => gettext('Users who do not have “Admin” rights normally are restricted to manage only objects to which they have been assigned. This right allows them to manage any album in the gallery.')), 'THEMES_RIGHTS' => array('value' => pow(2, 26), 'name' => gettext('Themes'), 'set' => gettext('Gallery'), 'display' => true, 'hint' => gettext('Users with this right may make themes related changes. These are limited to the themes associated with albums checked in their managed albums list.')), 'TAGS_RIGHTS' => array('value' => pow(2, 28), 'name' => gettext('Tags'), 'set' => gettext('Gallery'), 'display' => true, 'hint' => gettext('Users with this right may make additions and changes to the set of tags.')), 'OPTIONS_RIGHTS' => array('value' => pow(2, 29), 'name' => gettext('Options'), 'set' => gettext('General'), 'display' => true, 'hint' => gettext('Users with this right may make changes on the options tabs.')), 'ADMIN_RIGHTS' => array('value' => pow(2, 30), 'name' => gettext('Admin'), 'set' => gettext('General'), 'display' => true, 'hint' => gettext('The master privilege. A user with "Admin" can do anything. (No matter what his other rights might indicate!)')));
             break;
         case 4:
             $rightsset = array('NO_RIGHTS' => array('value' => 1, 'name' => gettext('No rights'), 'set' => '', 'display' => false, 'hint' => ''), 'OVERVIEW_RIGHTS' => array('value' => pow(2, 2), 'name' => gettext('Overview'), 'set' => gettext('General'), 'display' => true, 'hint' => gettext('Users with this right may view the admin overview page.')), 'USER_RIGHTS' => array('value' => pow(2, 3), 'name' => gettext('User'), 'set' => gettext('General'), 'display' => true, 'hint' => gettext('Users must have this right to change their credentials.')), 'DEBUG_RIGHTS' => array('value' => pow(2, 4), 'name' => gettext('Debug'), 'set' => gettext('General'), 'display' => true, 'hint' => gettext('Allows viewing of the debug tab items.')), 'VIEW_GALLERY_RIGHTS' => array('value' => pow(2, 5), 'name' => gettext('View gallery'), 'set' => gettext('Gallery'), 'display' => true, 'hint' => gettext('Users with this right may view otherwise protected generic gallery pages.')), 'VIEW_SEARCH_RIGHTS' => array('value' => pow(2, 6), 'name' => gettext('View search'), 'set' => gettext('Gallery'), 'display' => true, 'hint' => gettext('Users with this right may view search pages even if password protected.')), 'VIEW_FULLIMAGE_RIGHTS' => array('value' => pow(2, 7), 'name' => gettext('View fullimage'), 'set' => gettext('Albums'), 'display' => true, 'hint' => gettext('Users with this right may view all full sized (raw) images.')), 'ALL_NEWS_RIGHTS' => array('value' => pow(2, 8), 'name' => gettext('Access all'), 'set' => gettext('News'), 'display' => true, 'hint' => gettext('Users with this right have access to all zenpage news articles.')), 'ALL_PAGES_RIGHTS' => array('value' => pow(2, 9), 'name' => gettext('Access all'), 'set' => gettext('Pages'), 'display' => true, 'hint' => gettext('Users with this right have access to all zenpage pages.')), 'ALL_ALBUMS_RIGHTS' => array('value' => pow(2, 10), 'name' => gettext('Access all'), 'set' => gettext('Albums'), 'display' => true, 'hint' => gettext('Users with this right have access to all albums.')), 'VIEW_UNPUBLISHED_RIGHTS' => array('value' => pow(2, 11), 'name' => gettext('View unpublished'), 'set' => gettext('Albums'), 'display' => true, 'hint' => gettext('Users with this right will see all unpublished items.')), 'VIEW_UNPUBLISHED_NEWS_RIGHTS' => array('value' => pow(2, 12), 'name' => gettext('View unpublished'), 'set' => gettext('News'), 'display' => true, 'hint' => gettext('Users with this right will see all unpublished items.')), 'POST_COMMENT_RIGHTS' => array('value' => pow(2, 13), 'name' => gettext('Post comments'), 'set' => gettext('Gallery'), 'display' => true, 'hint' => gettext('When the comment_form plugin is used for comments and its "Only members can comment" option is set, only users with this right may post comments.')), 'COMMENT_RIGHTS' => array('value' => pow(2, 14), 'name' => gettext('Comments'), 'set' => gettext('Gallery'), 'display' => true, 'hint' => gettext('Users with this right may make comments tab changes.')), 'UPLOAD_RIGHTS' => array('value' => pow(2, 15), 'name' => gettext('Upload'), 'set' => gettext('Albums'), 'display' => true, 'hint' => gettext('Users with this right may upload to the albums for which they have management rights.')), 'VIEW_UNPUBLISHED_PAGE_RIGHTS' => array('value' => pow(2, 16), 'name' => gettext('View unpublished'), 'set' => gettext('Pages'), 'display' => true, 'hint' => gettext('Users with this right will see all unpublished items.')), 'ZENPAGE_NEWS_RIGHTS' => array('value' => pow(2, 17), 'name' => gettext('News'), 'set' => gettext('News'), 'display' => false, 'hint' => gettext('Users with this right may edit and manage Zenpage articles and categories.')), 'ZENPAGE_PAGES_RIGHTS' => array('value' => pow(2, 18), 'name' => gettext('Pages'), 'set' => gettext('Pages'), 'display' => false, 'hint' => gettext('Users with this right may edit and manage Zenpage pages.')), 'FILES_RIGHTS' => array('value' => pow(2, 19), 'name' => gettext('Files'), 'set' => gettext('Gallery'), 'display' => true, 'hint' => gettext('Allows the user access to the “filemanager” located on the upload: files sub-tab.')), 'ALBUM_RIGHTS' => array('value' => pow(2, 20), 'name' => gettext('Albums'), 'set' => gettext('Albums'), 'display' => false, 'hint' => gettext('Users with this right may access the “albums” tab to make changes.')), 'MANAGE_ALL_NEWS_RIGHTS' => array('value' => pow(2, 21), 'name' => gettext('Manage all'), 'set' => gettext('News'), 'display' => true, 'hint' => gettext('Users who do not have “Admin” rights normally are restricted to manage only objects to which they have been assigned. This right allows them to manage any Zenpage news article or category.')), 'MANAGE_ALL_PAGES_RIGHTS' => array('value' => pow(2, 22), 'name' => gettext('Manage all'), 'set' => gettext('Pages'), 'display' => true, 'hint' => gettext('Users who do not have “Admin” rights normally are restricted to manage only objects to which they have been assigned. This right allows them to manage any Zenpage page.')), 'MANAGE_ALL_ALBUM_RIGHTS' => array('value' => pow(2, 23), 'name' => gettext('Manage all'), 'set' => gettext('Albums'), 'display' => true, 'hint' => gettext('Users who do not have “Admin” rights normally are restricted to manage only objects to which they have been assigned. This right allows them to manage any album in the gallery.')), 'CODEBLOCK_RIGHTS' => array('value' => pow(2, 25), 'name' => gettext('Codeblock'), 'set' => gettext('General'), 'display' => true, 'hint' => gettext('Users with this right may edit Codeblocks.')), 'THEMES_RIGHTS' => array('value' => pow(2, 26), 'name' => gettext('Themes'), 'set' => gettext('Gallery'), 'display' => true, 'hint' => gettext('Users with this right may make themes related changes. These are limited to the themes associated with albums checked in their managed albums list.')), 'TAGS_RIGHTS' => array('value' => pow(2, 28), 'name' => gettext('Tags'), 'set' => gettext('Gallery'), 'display' => true, 'hint' => gettext('Users with this right may make additions and changes to the set of tags.')), 'OPTIONS_RIGHTS' => array('value' => pow(2, 29), 'name' => gettext('Options'), 'set' => gettext('General'), 'display' => true, 'hint' => gettext('Users with this right may make changes on the options tabs.')), 'ADMIN_RIGHTS' => array('value' => pow(2, 30), 'name' => gettext('Admin'), 'set' => gettext('General'), 'display' => true, 'hint' => gettext('The master privilege. A user with "Admin" can do anything. (No matter what his other rights might indicate!)')));
             break;
     }
     $allrights = 0;
     foreach ($rightsset as $key => $right) {
         $allrights = $allrights | $right['value'];
     }
     $rightsset['ALL_RIGHTS'] = array('value' => $allrights, 'name' => gettext('All rights'), 'display' => false);
     $rightsset['DEFAULT_RIGHTS'] = array('value' => $rightsset['OVERVIEW_RIGHTS']['value'] + $rightsset['POST_COMMENT_RIGHTS']['value'], 'name' => gettext('Default rights'), 'display' => false);
     if (isset($rightsset['VIEW_ALL_RIGHTS']['value'])) {
         $rightsset['DEFAULT_RIGHTS']['value'] = $rightsset['DEFAULT_RIGHTS']['value'] | $rightsset['VIEW_ALL_RIGHTS']['value'];
     } else {
         $rightsset['DEFAULT_RIGHTS']['value'] = $rightsset['DEFAULT_RIGHTS'] | $rightsset['ALL_ALBUMS_RIGHTS']['value'] | $rightsset['ALL_PAGES_RIGHTS']['value'] | $rightsset['ALL_NEWS_RIGHTS']['value'] | $rightsset['VIEW_SEARCH_RIGHTS']['value'] | $rightsset['VIEW_GALLERY_RIGHTS']['value'];
     }
     $rightsset = sortMultiArray($rightsset, 'value', false, true, false, true);
     return $rightsset;
 }
Example #27
0
																													minWidth: 350, minHeight: 120,
																													resize: function(event, ui) {
																													$('#metadatalist').height($('#resizable').height());
																													}
																									});
																									});</script>
								<tr>
									<td><?php 
    echo gettext("Metadata");
    ?>
</td>
									<td>
										<div id="resizable">
											<ul id="metadatalist" class="searchchecklist">
												<?php 
    $exifstuff = sortMultiArray($_zp_exifvars, 2, false);
    foreach ($exifstuff as $key => $item) {
        $checked_show = $checked_hide = $checked_disabled = '';
        if (!$item[5]) {
            $checked_disabled = ' checked="checked"';
        } else {
            if ($item[3]) {
                $checked_show = ' checked="checked"';
            } else {
                $checked_hide = ' checked="checked"';
            }
        }
        if (!$item[4]) {
            $checked_show = ' disabled="disabled"';
        }
        ?>
Example #28
0
function processFilters()
{
    require_once SERVERPATH . '/' . ZENFOLDER . '/setup/setup-functions.php';
    global $_zp_resident_files;
    $classes = $subclasses = $oldfilterlist = array();
    $htmlfile = SERVERPATH . '/' . USER_PLUGIN_FOLDER . '/filterDoc/filter list.html';
    $prolog = $epilog = '';
    if (file_exists($htmlfile)) {
        $oldhtml = file_get_contents($htmlfile);
        $i = strpos($oldhtml, '<!-- Begin filter descriptions -->');
        if ($i !== false) {
            $prolog = substr($oldhtml, 0, $i);
        }
        $i = strpos($oldhtml, '<!-- End filter descriptions -->');
        if ($i !== false) {
            $epilog = trim(substr($oldhtml, $i + 32));
        }
        preg_match_all('|<!-- description(.+?)-(.+?) -->(.+?)<!--e-->|', $oldhtml, $matches);
        foreach ($matches[2] as $key => $filter) {
            $oldfilterlist[$filter]['desc'] = $matches[3][$key];
            $class = explode('.', trim($matches[1][$key], '()'));
            $oldfilterlist[$filter]['class'] = $class[0];
            $oldfilterlist[$filter]['subclass'] = $class[1];
        }
        preg_match_all('|<!-- classhead (.+?) -->(.+?)<!--e-->|', $oldhtml, $classheads);
        foreach ($classheads[1] as $key => $head) {
            $classes[$head] = $classheads[2][$key];
        }
        preg_match_all('|<!-- subclasshead (.+?) -->(.+?)<!--e-->|', $oldhtml, $subclassheads);
        foreach ($subclassheads[1] as $key => $head) {
            $subclasses[$head] = $subclassheads[2][$key];
        }
    }
    $filterDescriptions = array();
    $filterdesc = SERVERPATH . '/' . USER_PLUGIN_FOLDER . '/filterDoc/filter descriptions.txt';
    if (file_exists($filterdesc)) {
        $t = file_get_contents($filterdesc);
        $t = explode("\n", $t);
        foreach ($t as $d) {
            $d = trim($d);
            if (!empty($d)) {
                $f = explode(':=', $d);
                $filterDescriptions[$f[0]] = trim($f[1]);
            }
        }
    }
    getResidentZPFiles(SERVERPATH . '/' . ZENFOLDER);
    getResidentZPFiles(SERVERPATH . '/' . THEMEFOLDER);
    $key = array_search(SERVERPATH . '/' . ZENFOLDER . '/functions-filter.php', $_zp_resident_files);
    unset($_zp_resident_files[$key]);
    $key = array_search(SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/deprecated-functions.php', $_zp_resident_files);
    unset($_zp_resident_files[$key]);
    $filterlist = array();
    $useagelist = array();
    foreach ($_zp_resident_files as $file) {
        if (getSuffix($file) == 'php') {
            $size = filesize($file);
            $text = file_get_contents($file);
            $script = str_replace(SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/', '<em>plugin</em>/', $file);
            $script = str_replace(SERVERPATH . '/' . ZENFOLDER . '/', '<!--sort first-->/', $script);
            $script = str_replace(SERVERPATH . '/' . THEMEFOLDER . '/', '<em>theme</em>/', $script);
            preg_match_all('|zp_apply_filter\\s*\\((.+?)\\).?|', $text, $matches);
            foreach ($matches[1] as $paramsstr) {
                $filter = explode(',', $paramsstr);
                foreach ($filter as $key => $element) {
                    $filter[$key] = unQuote(trim($element));
                }
                $filtername = array_shift($filter);
                if (array_key_exists($filtername, $filterlist)) {
                    $filterlist[$filtername][0][] = $script;
                } else {
                    array_unshift($filter, array($script));
                    $filterlist[$filtername] = $filter;
                }
            }
            preg_match_all('|zp_register_filter\\s*\\((.+?)\\).?|', $text, $matches);
            foreach ($matches[1] as $paramsstr) {
                $filter = explode(',', $paramsstr);
                $filtername = unQuote(array_shift($filter));
                $useagelist[] = array('filter' => $filtername, 'script' => $script, 'scriptsize' => $size);
            }
        }
    }
    $useagelist = sortMultiArray($useagelist, 'scriptsize', false, false, false);
    $filterCategories = array();
    $newfilterlist = array();
    foreach ($filterlist as $key => $params) {
        if (count($params[0])) {
            sort($params[0]);
            $calls = array();
            $class = '';
            $subclass = '';
            $lastscript = $params[0][0];
            $count = 0;
            foreach ($params[0] as $script) {
                if (!$class) {
                    $basename = basename($script);
                    if (strpos($script, '<em>theme</em>') !== false) {
                        $class = 'Theme';
                        $subclass = 'Script';
                    } else {
                        if (strpos($basename, 'user') !== false || strpos($basename, 'auth') !== false || strpos($basename, 'logon') !== false || strpos($key, 'login') !== false) {
                            $class = 'User_management';
                            $subclass = 'Miscellaneous';
                        } else {
                            if (strpos($key, 'upload') !== false) {
                                $class = 'Upload';
                                $subclass = 'Miscellaneous';
                            } else {
                                if (strpos($key, 'texteditor') !== false) {
                                    $class = 'Miscellaneous';
                                    $subclass = 'Miscellaneous';
                                } else {
                                    if (strpos($basename, 'class') !== false) {
                                        $class = 'Object';
                                        if (strpos($basename, 'zenpage') !== false) {
                                            $class = 'Object';
                                            $subclass = 'Zenpage';
                                        } else {
                                            if (!$subclass) {
                                                switch ($basename) {
                                                    case 'classes.php':
                                                        $subclass = 'Root_class';
                                                        break;
                                                    case 'class-load.php':
                                                    case 'class-gallery.php':
                                                        $subclass = 'Miscellaneous';
                                                        break;
                                                    case 'class-album.php':
                                                    case 'class-image.php':
                                                    case 'class-transientimage.php':
                                                    case 'class-textobject.php':
                                                    case 'class-textobject_core.php':
                                                    case 'class-Anyfile.php':
                                                    case 'class-video.php':
                                                    case 'Class-WEBdocs.php':
                                                        $subclass = 'Media';
                                                        break;
                                                    case 'class-comment.php':
                                                        $subclass = 'Comments';
                                                        break;
                                                    case 'class-search.php':
                                                        $subclass = 'Search';
                                                        break;
                                                }
                                                if (strpos($key, 'image') !== false || strpos($key, 'album') !== false) {
                                                    $subclass = 'Media';
                                                }
                                            }
                                        }
                                    } else {
                                        if (strpos($script, 'admin') !== false) {
                                            $class = 'Admin';
                                            if (strpos($script, 'zenpage') !== false) {
                                                $subclass = 'Zenpage';
                                            } else {
                                                if (strpos($basename, 'comment') !== false || strpos($key, 'comment')) {
                                                    $subclass = 'Comment';
                                                } else {
                                                    if (strpos($basename, 'edit') !== false || strpos($key, 'album') !== false || strpos($key, 'image') !== false) {
                                                        $subclass = 'Media';
                                                    }
                                                }
                                            }
                                        } else {
                                            if (strpos($script, 'template') !== false) {
                                                $class = 'Template';
                                            } else {
                                                if (strpos($basename, 'zenpage') !== false) {
                                                    $class = 'Zenpage';
                                                } else {
                                                    $class = 'Miscellaneous';
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (!$subclass) {
                        $subclass = 'Miscellaneous';
                    }
                    if (array_key_exists($key, $oldfilterlist)) {
                        if ($class != $oldfilterlist[$key]['class'] || $subclass != $oldfilterlist[$key]['subclass']) {
                            $class = $oldfilterlist[$key]['class'];
                            $subclass = $oldfilterlist[$key]['subclass'];
                        }
                    }
                    if (!array_key_exists($class, $filterCategories)) {
                        $filterCategories[$class] = array('class' => $class, 'subclass' => '', 'count' => 0);
                    }
                    if (!array_key_exists($class . '_' . $subclass, $filterCategories)) {
                        $filterCategories[$class . '_' . $subclass] = array('class' => $class, 'subclass' => $subclass, 'count' => $filterCategories[$class]['count']++);
                    }
                    if (!array_key_exists('*' . $class, $filterDescriptions)) {
                        $filterDescriptions['*' . $class] = '';
                    }
                    if (!array_key_exists('*' . $class . '.' . $subclass, $filterDescriptions)) {
                        $filterDescriptions['*' . $class . '.' . $subclass] = '';
                    }
                }
                if ($script == $lastscript) {
                    $count++;
                } else {
                    if ($count > 1) {
                        $count .= " ({$count})";
                    } else {
                        $count = '';
                    }
                    $calls[] = $lastscript . $count;
                    $count = 0;
                    $lastscript = $script;
                }
            }
            if ($count > 0) {
                if ($count > 1) {
                    $count .= " ({$count})";
                } else {
                    $count = '';
                }
                $calls[] = $lastscript . $count;
            }
        }
        array_shift($params);
        $newparms = array();
        foreach ($params as $param) {
            switch ($param) {
                case 'true':
                case 'false':
                    $newparms[] = 'bool';
                    break;
                case '$this':
                    $newparms[] = 'object';
                    break;
                default:
                    if (substr($param, 0, 1) == '$') {
                        $newparms[] = trim($param, '$');
                    } else {
                        $newparms[] = 'string';
                    }
                    break;
            }
        }
        $newfilterlist[$key] = array('filter' => $key, 'calls' => $calls, 'users' => array(), 'params' => $newparms, 'desc' => '*Edit Description*', 'class' => $class, 'subclass' => $subclass);
        if (!array_key_exists($key, $filterDescriptions)) {
            $filterDescriptions[$key] = '';
        }
    }
    foreach ($useagelist as $use) {
        if (array_key_exists($use['filter'], $newfilterlist)) {
            $newfilterlist[$use['filter']]['users'][] = $use['script'];
        }
    }
    $newfilterlist = sortMultiArray($newfilterlist, array('class', 'subclass', 'filter'), false, false);
    $f = fopen($htmlfile, 'w');
    $class = $subclass = NULL;
    if ($prolog) {
        fwrite($f, $prolog);
    }
    fwrite($f, "<!-- Begin filter descriptions -->\n");
    $ulopen = false;
    foreach ($newfilterlist as $filter) {
        if ($class !== $filter['class']) {
            $class = $filter['class'];
            if (array_key_exists('*' . $class, $filterDescriptions)) {
                $classhead = '<p>' . $filterDescriptions['*' . $class] . '</p>';
            } else {
                $classhead = '';
            }
            if ($subclass) {
                fwrite($f, "\t\t\t</ul><!-- filterdetail -->\n");
            }
            fwrite($f, "\t" . '<h5><a name="' . $class . '"></a>' . $class . " filters</h5>\n");
            fwrite($f, "\t" . '<!-- classhead ' . $class . ' -->' . $classhead . "<!--e-->\n");
            $subclass = NULL;
        }
        if ($subclass !== $filter['subclass']) {
            // new subclass
            if (!is_null($subclass)) {
                fwrite($f, "\t\t\t</ul><!-- filterdetail -->\n");
            }
            $subclass = $filter['subclass'];
            if (array_key_exists('*' . $class . '.' . $subclass, $filterDescriptions)) {
                $subclasshead = '<p>' . $filterDescriptions['*' . $class . '.' . $subclass] . '</p>';
            } else {
                $subclasshead = '';
            }
            if ($subclass && $filterCategories[$class]['count'] > 1) {
                //	Class doc is adequate.
                fwrite($f, "\t\t\t" . '<h6 class="filter"><a name="' . $class . '_' . $subclass . '"></a>' . $subclass . "</h6>\n");
                fwrite($f, "\t\t\t" . '<!-- subclasshead ' . $class . '.' . $subclass . ' -->' . $subclasshead . "<!--e-->\n");
            }
            fwrite($f, "\t\t\t" . '<ul class="filterdetail">' . "\n");
        }
        fwrite($f, "\t\t\t\t" . '<li class="filterdetail">' . "\n");
        fwrite($f, "\t\t\t\t\t" . '<p class="filterdef"><tt><strong>' . $filter['filter'] . '</strong></tt>(<em>' . implode(', ', $filter['params']) . "</em>)</p>\n");
        if (array_key_exists($filter['filter'], $filterDescriptions)) {
            $filter['desc'] = '<p>' . $filterDescriptions[$filter['filter']] . '</p>';
        }
        fwrite($f, "\t\t\t\t\t" . '<!-- description(' . $class . '.' . $subclass . ')-' . $filter['filter'] . ' -->' . $filter['desc'] . "<!--e-->\n");
        $user = array_shift($filter['users']);
        if (!empty($user)) {
            fwrite($f, "\t\t\t\t\t" . '<p class="handlers">For example see ' . mytrim($user) . '</p>' . "\n");
        }
        fwrite($f, "\t\t\t\t\t" . '<p class="calls">Invoked from:' . "</p>\n");
        fwrite($f, "\t\t\t\t\t<ul><!-- calls -->\n");
        $calls = $filter['calls'];
        $limit = 4;
        foreach ($calls as $call) {
            $limit--;
            if ($limit > 0) {
                fwrite($f, "\t\t\t\t\t\t" . '<li class="call_list">' . mytrim($call) . "</li>\n");
            } else {
                fwrite($f, "\t\t\t\t\t\t<li>...</li>\n");
                break;
            }
        }
        fwrite($f, "\t\t\t\t\t" . "</ul><!-- calls -->\n");
        fwrite($f, "\t\t\t\t" . '</li><!-- filterdetail -->' . "\n");
    }
    fwrite($f, "\t\t\t" . '</ul><!-- filterdetail -->' . "\n");
    fwrite($f, "<!-- End filter descriptions -->\n");
    if ($epilog) {
        fwrite($f, $epilog);
    }
    fclose($f);
    $filterCategories = sortMultiArray($filterCategories, array('class', 'subclass', 'text'), false, false);
    $indexfile = SERVERPATH . '/' . USER_PLUGIN_FOLDER . '/filterDoc/filter list_index.html';
    $f = fopen($indexfile, 'w');
    fwrite($f, '<li>' . "\t\n");
    fwrite($f, "\t" . '<a href="#filters">List of Zenphoto filters</a>' . "\n");
    fwrite($f, "\t<ul>\n");
    $ulopen = false;
    foreach ($filterCategories as $element) {
        $class = $element['class'];
        $subclass = $element['subclass'];
        if ($subclass == '') {
            // this is a new class element
            $count = $element['count'];
            if ($ulopen) {
                fwrite($f, "\t\t</ul>\n");
                $ulopen = false;
            }
            fwrite($f, "\t\t" . '<li><a title="' . $class . ' filters" href="#' . $class . '">' . $class . " filters</a></li>\n");
        } else {
            if ($class != $subclass) {
                if ($count > 1) {
                    if (!$ulopen) {
                        fwrite($f, "\t\t<ul>\n");
                        $ulopen = true;
                    }
                    fwrite($f, "\t\t\t\t" . '<li><a title="' . $subclass . ' ' . $class . ' filters" href="#' . $class . '_' . $subclass . '">' . $subclass . ' ' . str_replace('_', ' ', strtolower($class)) . " filters</a></li>\n");
                } else {
                    unset($filterDescriptions['*' . $class . '.' . $subclass]);
                }
            }
        }
    }
    if ($ulopen) {
        fwrite($f, "\t\t</ul>\n");
    }
    fwrite($f, "\t</ul>\n");
    fwrite($f, "</li>\n");
    fclose($f);
    $f = fopen($filterdesc, 'w');
    asort($filterDescriptions);
    foreach ($filterDescriptions as $filter => $desc) {
        fwrite($f, $filter . ':=' . $desc . "\n");
    }
    fclose($f);
}
Example #29
0
 /**
  * Gets all categories
  * @param bool $visible TRUE for published and unprotected
  * @param string $sorttype NULL for the standard order as sorted on the backend, "title", "id", "popular", "random"
  * @param bool $sortdirection TRUE for ascending or FALSE for descending order
  * @return array
  */
 function getAllCategories($visible = true, $sorttype = NULL, $sortdirection = NULL)
 {
     $structure = $this->getCategoryStructure();
     if (is_null($sortdirection)) {
         $sortdirection = $this->sortdirection;
     }
     switch ($sorttype) {
         case "id":
             $sortorder = "id";
             break;
         case "title":
             $sortorder = "title";
             break;
         case "popular":
             $sortorder = 'hitcounter';
             break;
         case "random":
             $sortorder = 'random';
             break;
         default:
             $sortorder = "sort_order";
             break;
     }
     if ($visible) {
         foreach ($structure as $key => $cat) {
             $catobj = new ZenpageCategory($cat['titlelink']);
             if ($catobj->getShow() || $catobj->isMyItem(LIST_RIGHTS)) {
                 $structure[$key]['show'] = 1;
             } else {
                 unset($structure[$key]);
             }
         }
     }
     if (!is_null($sorttype) || !is_null($sortdirection)) {
         if ($sorttype == 'random') {
             shuffle($structure);
         } else {
             //sortMultiArray descending = true
             if ($sortdirection) {
                 $sortdir = false;
             } else {
                 $sortdir = true;
             }
             $structure = sortMultiArray($structure, $sortorder, $sortdir, true, false, false);
         }
     }
     return $structure;
 }
Example #30
0
 /**
  * Prints a list of users/instances watching the object
  * NOTE: the caller must enclose the list with the appropraite UL, OL, or DL html
  * @param type $obj
  * @param type $list_type if NULL, use li tags. otherwise the array will have the start, middle, and end tags.
  */
 static function listWatchers($obj, $list_type = NULL)
 {
     $watchers = self::getWatchers($obj);
     if (!empty($watchers)) {
         if (is_null($list_type)) {
             $start = '<li>';
             $separate = '';
             $end = '</li>';
         } else {
             list($start, $separate, $end) = $list_type;
         }
         foreach ($watchers as $key => $aux) {
             $watchers[$key] = getSerializedArray($aux);
         }
         $watchers = sortMultiArray($watchers, array(1, 2));
         foreach ($watchers as $aux) {
             $watchee = $aux[0];
             if (isset($aux[1])) {
                 $instance = $aux[1];
                 if (is_null($list_type)) {
                     $instance = '[' . $instance . ']';
                 }
             } else {
                 $instance = '';
             }
             echo $start . html_encode($watchee) . $separate . html_encode($instance) . $end;
         }
     }
 }