Пример #1
0
 function __construct()
 {
     $blocks = query_single_row("SELECT id, `aux`, `data` FROM " . prefix('plugin_storage') . " WHERE `type` = 'defaultCodeblocks'");
     if ($blocks) {
         $this->codeblocks = $blocks['data'];
     } else {
         $this->codeblocks = serialize(array());
         $sql = 'INSERT INTO ' . prefix('plugin_storage') . ' (`type`,`aux`,`data`) VALUES ("defaultCodeblocks","",' . db_quote($this->codeblocks) . ')';
         query($sql);
     }
 }
Пример #2
0
 static function setCurrentNewsPage()
 {
     global $_zp_current_zenpage_news, $_zp_page;
     if (isset($_zp_current_zenpage_news)) {
         $table = prefix('zenpage_news');
         $id = $_zp_current_zenpage_news->getID();
         $query = "SELECT count(id) ct FROM {$table} where id >= {$id} AND `show`=1";
         $result = query_single_row($query);
         $count = $result['ct'];
         $pageNumber = ceil($count / max(1, getOption("zenpage_articles_per_page")));
         $_GET["page"] = $pageNumber;
         $_zp_page = $pageNumber;
     }
 }
Пример #3
0
function getTitle($table, $row)
{
    switch ($table) {
        case 'images':
            $album = query_single_row('SELECT `folder` FROM ' . prefix('albums') . ' WHERE `id`=' . $row[albumid]);
            $title = sprintf(gettext('%1$s: image %2$s'), $album['folder'], $row[$filename]);
            break;
        case 'albums':
            $title = sprintf(gettext('album %s'), $row[$folder]);
            break;
        case 'news':
        case 'pages':
            $title = sprintf(gettext('%1$s: %2$s'), $table, $row['titlelink']);
            break;
    }
    return $title;
}
/**
* Returns true if the IP has voted
*
* @param string $ip the IP address to check
* @param int $id the record ID of the image
* @param string $option 'image' or 'album' depending on the requestor
* @return bool
*/
function checkForIp($ip, $id, $option)
{
    global $_rating_current_IPlist;
    switch ($option) {
        case "image":
            $dbtable = prefix('images');
            break;
        case "album":
            $dbtable = prefix('albums');
            break;
    }
    $IPlist = query_single_row("SELECT used_ips FROM {$dbtable} WHERE id= {$id}");
    if (is_array($IPlist)) {
        if (empty($IPlist['used_ips'])) {
            $_rating_current_IPlist = array();
            return false;
        }
        $_rating_current_IPlist = unserialize($IPlist['used_ips']);
        return in_array($ip, $_rating_current_IPlist);
    } else {
        $_rating_current_IPlist = array();
        return false;
    }
}
Пример #5
0
 /**
  * Prints the slideshow using the {@link http://http://www.malsup.com/jquery/cycle/  jQuery plugin Cycle}
  *
  * Two ways to use:
  * a) Use on your theme's slideshow.php page and called via printSlideShowLink():
  * If called from image.php it starts with that image, called from album.php it starts with the first image (jQuery only)
  * To be used on slideshow.php only and called from album.php or image.php.
  *
  * b) Calling directly via printSlideShow() function (jQuery mode)
  * Place the printSlideShow() function where you want the slideshow to appear and set create an album object for $albumobj and if needed an image object for $imageobj.
  * The controls are disabled automatically.
  *
  * NOTE: The jQuery mode does not support movie and audio files anymore. If you need to show them please use the Flash mode.
  * Also note that this function is not used for the Colorbox mode!
  *
  * @param bool $heading set to true (default) to emit the slideshow breadcrumbs in flash mode
  * @param bool $speedctl controls whether an option box for controlling transition speed is displayed
  * @param obj $albumobj The object of the album to show the slideshow of. If set this overrides the POST data of the printSlideShowLink()
  * @param obj $imageobj The object of the image to start the slideshow with. If set this overrides the POST data of the printSlideShowLink(). If not set the slideshow starts with the first image of the album.
  * @param int $width The width of the images (jQuery mode). If set this overrides the size the slideshow_width plugin option that otherwise is used.
  * @param int $height The heigth of the images (jQuery mode). If set this overrides the size the slideshow_height plugin option that otherwise is used.
  * @param bool $crop Set to true if you want images cropped width x height (jQuery mode only)
  * @param bool $shuffle Set to true if you want random (shuffled) order
  * @param bool $linkslides Set to true if you want the slides to be linked to their image pages (jQuery mode only)
  * @param bool $controls Set to true (default) if you want the slideshow controls to be shown (might require theme CSS changes if calling outside the slideshow.php page) (jQuery mode only)
  *
  */
 function printSlideShow($heading = true, $speedctl = false, $albumobj = NULL, $imageobj = NULL, $width = NULL, $height = NULL, $crop = false, $shuffle = false, $linkslides = false, $controls = true)
 {
     global $_myFavorites, $_zp_conf_vars;
     if (!isset($_POST['albumid']) and !is_object($albumobj)) {
         return '<div class="errorbox" id="message"><h2>' . gettext('Invalid linking to the slideshow page.') . '</h2></div>';
     }
     //getting the image to start with
     if (!empty($_POST['imagenumber']) and !is_object($imageobj)) {
         $imagenumber = sanitize_numeric($_POST['imagenumber']) - 1;
         // slideshows starts with 0, but zp with 1.
     } elseif (is_object($imageobj)) {
         $imagenumber = $imageobj->getIndex();
     } else {
         $imagenumber = 0;
     }
     // set pagenumber to 0 if not called via POST link
     if (isset($_POST['pagenr'])) {
         $pagenumber = sanitize_numeric($_POST['pagenr']);
     } else {
         $pagenumber = 1;
     }
     // getting the number of images
     if (!empty($_POST['numberofimages'])) {
         $numberofimages = sanitize_numeric($_POST['numberofimages']);
     } elseif (is_object($albumobj)) {
         $numberofimages = $albumobj->getNumImages();
     } else {
         $numberofimages = 0;
     }
     if ($imagenumber < 2 || $imagenumber > $numberofimages) {
         $imagenumber = 0;
     }
     //getting the album to show
     if (!empty($_POST['albumid']) && !is_object($albumobj)) {
         $albumid = sanitize_numeric($_POST['albumid']);
     } elseif (is_object($albumobj)) {
         $albumid = $albumobj->getID();
     } else {
         $albumid = 0;
     }
     if (isset($_POST['preserve_search_params'])) {
         // search page
         $search = new SearchEngine();
         $params = sanitize($_POST['preserve_search_params']);
         $search->setSearchParams($params);
         $searchwords = $search->getSearchWords();
         $searchdate = $search->getSearchDate();
         $searchfields = $search->getSearchFields(true);
         $page = $search->page;
         $returnpath = getSearchURL($searchwords, $searchdate, $searchfields, $page);
         $albumobj = new AlbumBase(NULL, false);
         $albumobj->setTitle(gettext('Search'));
         $albumobj->images = $search->getImages(0);
     } else {
         if (isset($_POST['favorites_page'])) {
             $albumobj = $_myFavorites;
             $returnpath = $_myFavorites->getLink($pagenumber);
         } else {
             $albumq = query_single_row("SELECT title, folder FROM " . prefix('albums') . " WHERE id = " . $albumid);
             $albumobj = newAlbum($albumq['folder']);
             if (empty($_POST['imagenumber'])) {
                 $returnpath = $albumobj->getLink($pagenumber);
             } else {
                 $image = newImage($albumobj, sanitize($_POST['imagefile']));
                 $returnpath = $image->getLink();
             }
         }
     }
     echo slideshow::getShow($heading, $speedctl, $albumobj, $imageobj, $width, $height, $crop, $shuffle, $linkslides, $controls, $returnpath, $imagenumber);
 }
Пример #6
0
 static function passwordAllowed($msg, $pwd, $user)
 {
     if ($id = $user->getID() > 0) {
         $store = query_single_row('SELECT * FROM ' . prefix('plugin_storage') . ' WHERE `type`=' . db_quote('user_expiry_usedPasswords') . ' AND `aux`=' . $id);
         if ($store) {
             $used = getSerializedArray($store['data']);
             if (in_array($pwd, $used)) {
                 if (zp_loggedin(ADMIN_RIGHTS)) {
                     // persons with ADMIN_RIGHTS get to override this so they can reset a passwrod for a user
                     unset($used[$pwd]);
                 } else {
                     return gettext('You have used that password recently. Please choose a different password.');
                 }
             }
             if (count($used) > 9) {
                 $used = array_slice($used, 1);
             }
         } else {
             $used = array();
         }
         array_push($used, $pwd);
         if ($store) {
             query('UPDATE ' . prefix('plugin_storage') . 'SET `data`=' . db_quote(serialize($used)) . ' WHERE `type`=' . db_quote('user_expiry_usedPasswords') . ' AND `aux`=' . $id);
         } else {
             query('INSERT INTO ' . prefix('plugin_storage') . ' (`type`, `aux`, `data`) VALUES (' . db_quote('user_expiry_usedPasswords') . ',' . $id . ',' . db_quote(serialize($used)) . ')');
         }
     }
     return $msg;
 }
            $ret = '&amp;return=' . $ret;
        }
        $metaURL = $redirecturl = '?' . $type . 'refresh=continue&amp;id=' . $imageid . $albumparm . $ret . '&XSRFToken=' . getXSRFToken('refresh');
    }
} else {
    if ($type !== 'prune&amp;') {
        if (!empty($folder)) {
            $album = newAlbum($folder);
            if (!$album->isMyItem(ALBUM_RIGHTS)) {
                if (!zp_apply_filter('admin_managed_albums_access', false, $return)) {
                    header('Location: ' . FULLWEBPATH . '/' . ZENFOLDER . '/admin.php');
                    exitZP();
                }
            }
            $sql = "SELECT `id` FROM " . prefix('albums') . " WHERE `folder`=" . db_quote($folder);
            $row = query_single_row($sql);
            $id = $row['id'];
        }
        if (!empty($id)) {
            $imagewhere = "WHERE `albumid`={$id}";
            $r = " {$folder}";
            $albumwhere = "WHERE `parentid`={$id}";
        }
    }
    if (isset($_REQUEST['return'])) {
        $ret = sanitize($_REQUEST['return']);
    }
    if (!empty($ret)) {
        $ret = '&amp;return=' . $ret;
    }
    $metaURL = $starturl = '?' . $type . 'refresh=start' . $albumparm . '&amp;XSRFToken=' . getXSRFToken('refresh') . $ret;
Пример #8
0
function RSShitcounter()
{
    if (!zp_loggedin() && getOption('feed_hitcounter')) {
        $rssuri = getRSSCacheFilename();
        $type = 'rsshitcounter';
        $checkitem = query_single_row("SELECT `data` FROM " . prefix('plugin_storage') . " WHERE `aux` = " . db_quote($rssuri) . " AND `type` = '" . $type . "'", true);
        if ($checkitem) {
            $hitcount = $checkitem['data'] + 1;
            query("UPDATE " . prefix('plugin_storage') . " SET `data` = " . $hitcount . " WHERE `aux` = " . db_quote($rssuri) . " AND `type` = '" . $type . "'", true);
        } else {
            query("INSERT INTO " . prefix('plugin_storage') . " (`type`,`aux`,`data`) VALUES ('" . $type . "'," . db_quote($rssuri) . ",1)", true);
        }
    }
}
Пример #9
0
 switch ($action) {
     case 'albums':
         unset($_POST['checkAllAuto']);
         foreach ($_POST as $key => $albumid) {
             $album = newAlbum(postIndexDecode($key));
             $album->setShow(1);
             $album->save();
         }
         $report = 'albums';
         break;
     case 'images':
         foreach ($_POST as $action) {
             $i = strrpos($action, '_');
             $imageid = sanitize_numeric(substr($action, $i + 1));
             $rowi = query_single_row('SELECT * FROM ' . prefix('images') . ' WHERE `id`=' . $imageid);
             $rowa = query_single_row('SELECT * FROM ' . prefix('albums') . ' WHERE `id`=' . $rowi['albumid']);
             $album = newAlbum($rowa['folder']);
             $image = newImage($album, $rowi['filename']);
             switch (substr($action, 0, $i)) {
                 case 'pub':
                     $image->setShow(1);
                     $image->save();
                     break;
                 case 'del':
                     $image->remove();
                     break;
             }
         }
         $report = 'images';
         break;
     case 'categories':
Пример #10
0
<?php

/**
 * xspf playlist for flv player
 * 
 * @author Malte Müller (acrylian), Stephen Billard (sbillard)
 * @version 1.0.5
 * @package plugins 
 */
header("content-type:text/xml;charset=utf-8");
require_once "../../zp-core/template-functions.php";
$albumid = sanitize_numeric($_GET["albumid"]);
$albumresult = query_single_row("SELECT folder from " . prefix('albums') . " WHERE id = " . $albumid);
$album = new Album(new Gallery(), $albumresult['folder']);
$playlist = $album->getImages();
echo "<playlist version='1' xmlns='http://xspf.org/ns/0/'>\n";
echo "<title>Sample XSPF Playlist</title>";
echo "<info>http://www.what.de</info>";
echo "<annotation>An example of a playlist with commercial</annotation>";
echo "<trackList>\n";
$imgextensions = array(".jpg", ".jpeg", ".gif", ".png");
foreach ($playlist as $item) {
    $image = newImage($album, $item);
    $ext = strtolower(strrchr($item, "."));
    if ($ext == ".flv" || $ext == ".mp3" || $ext == ".mp4") {
        $videoThumb = $image->objectsThumb;
        if (!empty($videoThumb)) {
            $videoThumb = '../../' . getAlbumFolder('') . $album->name . "/" . $videoThumb;
        }
        echo "\t<track>\n";
        echo "\t\t<title>" . $image->getTitle() . " (" . $ext . ")</title>\n";
Пример #11
0
/**
 * 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>";
}
/**
 * Prints the checkboxes to select and/or show the category of an news article on the edit or add page
 *
 * @param int $id ID of the news article if the categories an existing articles is assigned to shall be shown, empty if this is a new article to be added.
 * @param string $option "all" to show all categories if creating a new article without categories assigned, empty if editing an existing article that already has categories assigned.
 */
function printCategoryCheckboxListEntry($cat, $articleid, $option)
{
    $selected = '';
    if ($option != "all" && !$cat->transient && !empty($articleid)) {
        $cat2news = query_single_row("SELECT cat_id FROM " . prefix('news2cat') . " WHERE news_id = " . $articleid . " AND cat_id = " . $cat->getID());
        if ($cat2news['cat_id'] != "") {
            $selected = "checked ='checked'";
        } else {
            $selected = "";
        }
    }
    $catname = $cat->getTitle();
    $catlink = $cat->getTitlelink();
    if ($cat->isProtected() && GALLERY_SECURITY != 'private') {
        $protected = '<img src="' . WEBPATH . '/' . ZENFOLDER . '/images/lock.png" alt="' . gettext('password protected') . '" />';
    } else {
        $protected = '';
    }
    $catid = $cat->getID();
    echo "<label for='cat" . $catid . "'><input name='cat" . $catid . "' id='cat" . $catid . "' type='checkbox' value='" . $catid . "' " . $selected . " />" . $catname . " " . $protected . "</label>\n";
}
Пример #13
0
 static function albumbutton($html, $object, $prefix)
 {
     $html .= '<hr />';
     if (query_single_row('SELECT * FROM ' . prefix('plugin_storage') . ' WHERE `type`="cacheManager" LIMIT 1')) {
         $disable = '';
         $title = gettext('Finds images that have not been cached and creates the cached versions.');
     } else {
         $disable = ' disabled="disabled"';
         $title = gettext("You must first set the plugin options for cached image parameters.");
     }
     $html .= '<div class="button buttons tooltip" title="' . $title . '"><a href="' . WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/cacheManager/cacheImages.php?album=' . html_encode($object->name) . '&amp;XSRFToken=' . getXSRFToken('cacheImages') . '"' . $disable . '><img src="images/cache.png" />' . gettext('Cache album images') . '</a><br class="clearall" /></div>';
     return $html;
 }
Пример #14
0
echo "\n" . '<div id="content">';
if ($page == "editcomment" && isset($_GET['id'])) {
    ?>
	<h1><?php 
    echo gettext("edit comment");
    ?>
</h1>
	<?php 
    zp_apply_filter('admin_note', 'comments', 'edit');
    ?>

	<div id="container">
		<div class="box" style="padding: 10px">
			<?php 
    $id = sanitize_numeric($_GET['id']);
    $commentarr = query_single_row("SELECT * FROM " . prefix('comments') . " WHERE id = {$id} LIMIT 1");
    if ($commentarr) {
        extract($commentarr);
        $commentarr = array_merge($commentarr, getSerializedArray($commentarr['custom_data']));
        ?>
				<form class="dirtylistening" onReset="setClean('form_editcomment');" id="form_editcomment" action="?action=savecomment" method="post" autocomplete="off">
					<?php 
        XSRFToken('savecomment');
        ?>
					<input	type="hidden" name="id" value="<?php 
        echo $id;
        ?>
" />
					<span class="buttons">
						<p class="buttons">
							<a href="javascript:if(confirm('<?php 
Пример #15
0
 /**
  * Gets the id of a download item from the database for the download link. For internal use.
  * @param string $path Path of the download item (without WEBPATH)
  * @return bool|string
  */
 static function getItemID($path)
 {
     $downloaditem = query_single_row("SELECT id, `aux`, `data` FROM " . prefix('plugin_storage') . " WHERE `type` = 'downloadList' AND `aux` = " . db_quote($path));
     if ($downloaditem) {
         return $downloaditem['id'];
     } else {
         return false;
     }
 }
Пример #16
0
     $comment['comment_author_email'] = $comment['comment_author_email'];
     $comment['comment_author_url'] = $comment['comment_author_url'];
     $comment['comment_date'] = $comment['comment_date'];
     $comment['comment_content'] = nl2br($_zp_UTF8->convert($comment['comment_content']));
     if (getcheckboxState('convertlinefeeds')) {
         $comment['comment_content'] = nl2br($comment['comment_content']);
     }
     $comment_approved = sanitize_numeric($comment['comment_approved']);
     if ($comment_approved == 1) {
         // in WP 1 means approved, with ZP the opposite!
         $comment_approved = 0;
     } else {
         $comment_approved = 1;
     }
     //echo "commentstatus:".$comment['comment_approved'];
     if (query_single_row("SELECT * from " . prefix('comments') . " WHERE ownerid =" . $newarticleid . " AND name=" . db_quote($comment['comment_author']) . " AND email =" . db_quote($comment['comment_author_email']) . " AND website =" . db_quote($comment['comment_author_url']) . " AND date =" . db_quote($comment['comment_date']) . " AND comment =" . db_quote($comment['comment_content']) . " AND inmoderation =" . $comment_approved . " AND type='" . $ctype . "'", false)) {
         $commentexists_count++;
     } else {
         if (query("INSERT INTO " . prefix('comments') . " (ownerid,name,email,website,date,comment,inmoderation,type) VALUES (" . $newarticleid . "," . db_quote($comment['comment_author']) . "," . db_quote($comment['comment_author_email']) . "," . db_quote($comment['comment_author_url']) . "," . db_quote($comment['comment_date']) . "," . db_quote($comment['comment_content']) . "," . $comment_approved . ",'" . $ctype . "')", true)) {
             $commentcount++;
         } else {
             $postinfo .= '<li class="import-error">' . gettext('Comment could not be assigned!') . '</li>';
         }
     }
 }
 if ($commentexists_count != 0) {
     $postinfo .= '<li class="import-exists">' . sprintf(ngettext('%1$u comment already exists.', '%1$u comments already exist.', $commentexists_count), $commentexists_count) . '</li>';
 }
 if ($commentcount != 0) {
     $postinfo .= '<li class="import-success">' . sprintf(ngettext('%1$u comment imported.', '%1$u comments imported.', $commentcount), $commentcount) . '</li>';
 }
Пример #17
0
/**
 * Gets an item object by id
 *
 * @param string $table database table to search
 * @param int $id id of the item to get
 * @return mixed
 */
function getItemByID($table, $id)
{
    if ($result = query_single_row('SELECT * FROM ' . prefix($table) . ' WHERE id =' . (int) $id)) {
        switch ($table) {
            case 'images':
                if ($alb = getItemByID('albums', $result['albumid'])) {
                    return newImage($alb, $result['filename'], true);
                }
                break;
            case 'albums':
                return newAlbum($result['folder'], false, true);
            case 'news':
                return new ZenpageNews($result['titlelink']);
            case 'pages':
                return new ZenpagePage($result['titlelink']);
            case 'news_categories':
                return new ZenpageCategory($result['titlelink']);
        }
    }
    return NULL;
}
Пример #18
0
 /**
  * Load the data array from the database, using the unique id set to get the unique record.
  *
  * @param bool $allowCreate set to true to enable new object creation.
  * @return false if the record already exists, true if a new record was created.
  */
 private function load($allowCreate)
 {
     $new = $entry = null;
     // Set up the SQL query in case we need it...
     $sql = 'SELECT * FROM ' . prefix($this->table) . getWhereClause($this->unique_set) . ' LIMIT 1;';
     // But first, try the cache.
     if ($this->use_cache) {
         $entry = $this->getFromCache();
     }
     // Check the database if: 1) not using cache, or 2) didn't get a hit.
     if (empty($entry)) {
         $entry = query_single_row($sql, false);
         // Save this entry into the cache so we get a hit next time.
         if ($entry) {
             $this->addToCache($entry);
         }
     }
     // If we don't have an entry yet, this is a new record. Create it.
     if (empty($entry)) {
         if ($this->transient) {
             // no don't save it in the DB!
             $entry = array_merge($this->unique_set, $this->updates, $this->tempdata);
             $entry['id'] = 0;
         } else {
             if (!$allowCreate) {
                 return NULL;
                 // does not exist and we are not allowed to create it
             } else {
                 $new = true;
                 $this->save();
                 $entry = query_single_row($sql);
                 // If we still don't have an entry, something went wrong...
                 if (!$entry) {
                     return null;
                 }
                 // Save this new entry into the cache so we get a hit next time.
                 $this->addToCache($entry);
             }
         }
     }
     $this->data = $entry;
     $this->id = (int) $entry['id'];
     $this->loaded = true;
     return $new;
 }
Пример #19
0
function printTotalComments()
{
    $commentsArray = query_single_row("SELECT count(*) FROM " . prefix('comments') . " WHERE inmoderation = 0");
    $commentsNumber = array_shift($commentsArray);
    echo $commentsNumber;
}
/**
 * @deprecated
 */
function zenpageHitcounter($option = 'pages', $viewonly = false, $id = NULL)
{
    deprecated_function_notify(gettext('Use getHitcounter().'));
    global $_zp_current_zenpage_page, $_zp_current_zenpage_news;
    switch ($option) {
        case "pages":
            if (is_null($id)) {
                $id = getPageID();
            }
            $dbtable = prefix('pages');
            $doUpdate = true;
            break;
        case "category":
            if (is_null($id)) {
                $id = getCurrentNewsCategoryID();
            }
            $dbtable = prefix('news_categories');
            $doUpdate = getCurrentNewsPage() == 1;
            // only count initial page for a hit on an album
            break;
        case "news":
            if (is_null($id)) {
                $id = getNewsID();
            }
            $dbtable = prefix('news');
            $doUpdate = true;
            break;
    }
    if ($option == "pages" and is_Pages() or $option == "news" and is_NewsArticle() or $option == "category" and is_NewsCategory()) {
        if (zp_loggedin(ZENPAGE_PAGES_RIGHTS | ZENPAGE_NEWS_RIGHTS) || $viewonly) {
            $doUpdate = false;
        }
        $hitcounter = "hitcounter";
        $whereID = " WHERE `id` = {$id}";
        $sql = "SELECT `" . $hitcounter . "` FROM {$dbtable} {$whereID}";
        if ($doUpdate) {
            $sql .= " FOR UPDATE";
        }
        $result = query_single_row($sql);
        $resultupdate = $result['hitcounter'];
        if ($doUpdate) {
            $resultupdate++;
            query("UPDATE {$dbtable} SET `" . $hitcounter . "`= {$resultupdate} {$whereID}");
        }
        return $resultupdate;
    }
}
Пример #21
0
    static function printSlideShow($heading = true, $speedctl = false, $albumobj = "", $imageobj = "", $width = "", $height = "")
    {
        if (!isset($_POST['albumid']) and !is_object($albumobj)) {
            echo "<div class=\"errorbox\" id=\"message\"><h2>" . gettext("Invalid linking to the slideshow page.") . "</h2></div>";
            echo "</div></body></html>";
            exit;
        }
        global $_zp_flash_player, $_zp_current_image, $_zp_current_album, $_zp_gallery;
        //getting the image to start with
        if (!empty($_POST['imagenumber']) and !is_object($imageobj)) {
            $imagenumber = $_POST['imagenumber'] - 1;
            // slideshows starts with 0, but zp with 1.
        } elseif (is_object($imageobj)) {
            makeImageCurrent($imageobj);
            $imagenumber = imageNumber() - 1;
        } else {
            $imagenumber = 0;
        }
        // set pagenumber to 0 if not called via POST link
        if (isset($_POST['pagenr'])) {
            $pagenumber = sanitize_numeric($_POST['pagenr']);
        } else {
            $pagenumber = 0;
        }
        // getting the number of images
        if (!empty($_POST['numberofimages'])) {
            $numberofimages = sanitize_numeric($_POST['numberofimages']);
        } elseif (is_object($albumobj)) {
            $numberofimages = $albumobj->getNumImages();
        }
        //getting the album to show
        if (!empty($_POST['albumid']) and !is_object($albumobj)) {
            $albumid = sanitize_numeric($_POST['albumid']);
        } elseif (is_object($albumobj)) {
            $albumid = $albumobj->id;
        } else {
            $albumid = -1;
        }
        // setting the image size
        if (!empty($width) and !empty($height)) {
            $width = sanitize_numeric($width);
            $height = sanitize_numeric($height);
        } else {
            $width = getOption("slideshow_width");
            $height = getOption("slideshow_height");
        }
        $option = getOption("slideshow_mode");
        // jQuery Cycle slideshow config
        // get slideshow data
        $gallery = new Gallery();
        if ($albumid <= 0) {
            // search page
            $dynamic = 2;
            $search = new SearchEngine();
            $params = $_POST['preserve_search_params'];
            $search->setSearchParams($params);
            $images = $search->getImages(0);
            $searchwords = $search->words;
            $searchdate = $search->dates;
            $searchfields = $search->fields;
            $page = $search->page;
            if (empty($_POST['imagenumber'])) {
                $albumq = query_single_row("SELECT title, folder FROM " . prefix('albums') . " WHERE id = " . abs($albumid));
                $album = new Album($gallery, $albumq['folder']);
                $returnpath = getSearchURL($searchwords, $searchdate, $searchfields, $page);
                //$returnpath = rewrite_path('/'.pathurlencode($album->name).'/page/'.$pagenumber,'/index.php?album='.urlencode($album->name).'&page='.$pagenumber);
            } else {
                $returnpath = getSearchURL($searchwords, $searchdate, $searchfields, $page);
            }
            $albumtitle = gettext('Search');
        } else {
            $albumq = query_single_row("SELECT title, folder FROM " . prefix('albums') . " WHERE id = " . $albumid);
            $album = new Album($gallery, $albumq['folder']);
            $albumtitle = $album->getTitle();
            if (!checkAlbumPassword($albumq['folder'], $hint)) {
                echo gettext("This album is password protected!");
                exit;
            }
            $dynamic = $album->isDynamic();
            $images = $album->getImages(0);
            // return path to get back to the page we called the slideshow from
            if (empty($_POST['imagenumber'])) {
                $returnpath = rewrite_path('/' . pathurlencode($album->name) . '/page/' . $pagenumber, '/index.php?album=' . urlencode($album->name) . '&page=' . $pagenumber);
            } else {
                $returnpath = rewrite_path('/' . pathurlencode($album->name) . '/' . rawurlencode($_POST['imagefile']) . getOption('mod_rewrite_image_suffix'), '/index.php?album=' . urlencode($album->name) . '&image=' . urlencode($_POST['imagefile']));
            }
        }
        // slideshow display section
        switch ($option) {
            case "jQuery":
                $validtypes = array('jpg', 'jpeg', 'gif', 'png', 'mov', '3gp');
                ?>
					<script type="text/javascript">
						$(document).ready(function(){
							$(function() {
								var ThisGallery = '<?php 
                echo html_encode($albumtitle);
                ?>
';
								var ImageList = new Array();
								var TitleList = new Array();
								var DescList = new Array();
								var ImageNameList = new Array();
								var DynTime=(<?php 
                echo getOption("slideshow_timeout");
                ?>
) * 1.0;	// force numeric
								<?php 
                for ($imgnr = 0, $cntr = 0, $idx = $imagenumber; $imgnr < $numberofimages; $imgnr++, $idx++) {
                    if ($dynamic) {
                        $filename = $images[$idx]['filename'];
                        $album = new Album($gallery, $images[$idx]['folder']);
                        $image = newImage($album, $filename);
                    } else {
                        $filename = $images[$idx];
                        $image = newImage($album, $filename);
                    }
                    $ext = is_valid($filename, $validtypes);
                    if ($ext) {
                        makeImageCurrent($image);
                        $img = getCustomSizedImageMaxSpace($width, $height);
                        //$img = WEBPATH . '/' . ZENFOLDER . '/i.php?a=' . pathurlencode($image->album->name) . '&i=' . urlencode($filename) . '&s=' . $imagesize;
                        echo 'ImageList[' . $cntr . '] = "' . $img . '";' . "\n";
                        echo 'TitleList[' . $cntr . '] = "' . js_encode($image->getTitle()) . '";' . "\n";
                        if (getOption("slideshow_showdesc")) {
                            $desc = $image->getDesc();
                            $desc = str_replace("\r\n", '<br />', $desc);
                            $desc = str_replace("\r", '<br />', $desc);
                            echo 'DescList[' . $cntr . '] = "' . js_encode($desc) . '";' . "\n";
                        } else {
                            echo 'DescList[' . $cntr . '] = "";' . "\n";
                        }
                        if ($idx == $numberofimages - 1) {
                            $idx = -1;
                        }
                        echo 'ImageNameList[' . $cntr . '] = "' . urlencode($filename) . '";' . "\n";
                        $cntr++;
                    }
                }
                echo "\n";
                $numberofimages = $cntr;
                ?>
								var countOffset = <?php 
                echo $imagenumber;
                ?>
;
								var totalSlideCount = <?php 
                echo $numberofimages;
                ?>
;
								var currentslide = 2;
			
								function onBefore(curr, next, opts) {
									//$(next).parent().animate({opacity: 0});

									if (opts.timeout != DynTime) {
										opts.timeout = DynTime;
									}
									if (!opts.addSlide)
										return;
							
									var currentImageNum = currentslide;
									currentslide++;
									if (currentImageNum == totalSlideCount) {
										opts.addSlide = null;
										return;
									}
									var relativeSlot = (currentslide + countOffset) % totalSlideCount;
									if (relativeSlot == 0) {relativeSlot = totalSlideCount;}
									var htmlblock = "<span class='slideimage'><h4><strong>" + ThisGallery + ":</strong> ";
									htmlblock += TitleList[currentImageNum]  + " (" + relativeSlot + "/" + totalSlideCount + ")</h4>";
									htmlblock += "<img src='" + ImageList[currentImageNum] + "'/>";
									htmlblock += "<p class='imgdesc'>" + DescList[currentImageNum] + "</p></span>";
									opts.addSlide(htmlblock);

								}
			
								function onAfter(curr, next, opts){
									<?php 
                if (!isMyALbum($album->name, ALL_RIGHTS)) {
                    ?>
									//Only register at hit count the first time the image is viewed.
									if ($(next).attr( 'viewed') != 1) {
										$.get("<?php 
                    echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER;
                    ?>
/slideshow/slideshow-counter.php?album=<?php 
                    echo pathurlencode($album->name);
                    ?>
&img="+ImageNameList[opts.currSlide]);
										$(next).attr( 'viewed', 1 );
									}
									<?php 
                }
                ?>

									//THE MISSING LINE
									$(next).parent().height(
										$(next).find('img').height() + $(next).find('p').height() + $(next).find('h4').height() + 40
									); //.animate({opacity: 1}, 'normal', 'linear');
									//getOption('slideshow_onafter'); //make it generic
									//END MISSING LINE
								}
			
								$('#slides').cycle({
										fx:     '<?php 
                echo getOption("slideshow_effect");
                ?>
',
										speed:   <?php 
                echo getOption("slideshow_speed");
                ?>
,
										timeout: DynTime,
										next:   '#next',
										prev:   '#prev',
										cleartype: 1,
										before: onBefore,
										after: onAfter
								});
			
								$('#speed').change(function () {
									DynTime = this.value;
									return false;
								});
			
								$('#pause').click(function() { $('#slides').cycle('pause'); return false; });
								$('#play').click(function() { $('#slides').cycle('resume'); return false; });
							});
			
						});	// Documentready()
			
						</script>
						<div id="slideshow" align="center">
						<?php 
                // 7/21/08dp
                if ($speedctl) {
                    echo '<div id="speedcontrol">';
                    // just to keep it away from controls for sake of this demo
                    $minto = getOption("slideshow_speed");
                    while ($minto % 500 != 0) {
                        $minto += 100;
                        if ($minto > 10000) {
                            break;
                        }
                        // emergency bailout!
                    }
                    $dflttimeout = getOption("slideshow_timeout");
                    /* don't let min timeout = speed */
                    $thistimeout = $minto == getOption("slideshow_speed") ? $minto + 250 : $minto;
                    echo 'Select Speed: <select id="speed" name="speed">';
                    while ($thistimeout <= 60000) {
                        // "around" 1 minute :)
                        echo "<option value={$thistimeout} " . ($thistimeout == $dflttimeout ? " selected='selected'>" : ">") . round($thistimeout / 1000, 1) . " sec</option>";
                        /* put back timeout to even increments of .5 */
                        if ($thistimeout % 500 != 0) {
                            $thistimeout -= 250;
                        }
                        $thistimeout += $thistimeout < 1000 ? 500 : ($thistimeout < 10000 ? 1000 : 5000);
                    }
                    echo "</select> </div>";
                }
                if (!is_object($albumobj)) {
                    // disable controls if calling the slideshow directly on homepage for example
                    ?>
						<div id="controls">
						<div><span><a href="#" id="prev"
							title="<?php 
                    echo gettext("Previous");
                    ?>
"></a></span> <a
							href="<?php 
                    echo $returnpath;
                    ?>
" id="stop"
							title="<?php 
                    echo gettext("Stop and return to album or image page");
                    ?>
"></a>
						<a href="#" id="pause"
							title="<?php 
                    echo gettext("Pause (to stop the slideshow without returning)");
                    ?>
"></a>
						<a href="#" id="play" title="<?php 
                    echo gettext("Play");
                    ?>
"></a> <a
							href="#" id="next" title="<?php 
                    echo gettext("Next");
                    ?>
"></a>
						</div>
						</div>
						<?php 
                }
                ?>
						<div id="slides" class="pics">
						<?php 
                if ($cntr > 1) {
                    $cntr = 1;
                }
                for ($imgnr = 0, $idx = $imagenumber; $imgnr <= $cntr; $idx++) {
                    if ($idx >= $numberofimages) {
                        $idx = 0;
                    }
                    if ($dynamic) {
                        $folder = $images[$idx]['folder'];
                        $dalbum = new Album($gallery, $folder);
                        $filename = $images[$idx]['filename'];
                        $image = newImage($dalbum, $filename);
                        $imagepath = FULLWEBPATH . getAlbumFolder('') . pathurlencode($folder) . "/" . urlencode($filename);
                    } else {
                        $folder = $album->name;
                        $filename = $images[$idx];
                        //$filename = $animage;
                        $image = newImage($album, $filename);
                        $imagepath = FULLWEBPATH . getAlbumFolder('') . pathurlencode($folder) . "/" . urlencode($filename);
                    }
                    $ext = is_valid($filename, $validtypes);
                    if ($ext) {
                        $imgnr++;
                        echo "<span class='slideimage'><h4><strong>" . $albumtitle . gettext(":") . "</strong> " . $image->getTitle() . " (" . ($idx + 1) . "/" . $numberofimages . ")</h4>";
                        if ($ext == "3gp") {
                            echo '</a>
												<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="352" height="304" codebase="http://www.apple.com/qtactivex/qtplugin.cab">
												<param name="src" value="' . $imagepath . '"/>
												<param name="autoplay" value="false" />
												<param name="type" value="video/quicktime" />
												<param name="controller" value="true" />
												<embed src="' . $imagepath . '" width="352" height="304" autoplay="false" controller"true" type="video/quicktime"
												pluginspage="http://www.apple.com/quicktime/download/" cache="true"></embed>
												</object>
												<a>';
                        } elseif ($ext == "mov") {
                            echo '</a>
									 			<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="640" height="496" codebase="http://www.apple.com/qtactivex/qtplugin.cab">
										 		<param name="src" value="' . $imagepath . '"/>
										 		<param name="autoplay" value="false" />
										 		<param name="type" value="video/quicktime" />
										 		<param name="controller" value="true" />
										 		<embed src="' . $imagepath . '" width="640" height="496" autoplay="false" controller"true" type="video/quicktime"
										 		pluginspage="http://www.apple.com/quicktime/download/" cache="true"></embed>
												</object>
												<a>';
                        } else {
                            makeImageCurrent($image);
                            printCustomSizedImageMaxSpace($alt = '', $width, $height, NULL, NULL, false);
                            //echo "<img src='".WEBPATH."/".ZENFOLDER."/i.php?a=".urlencode($folder)."&i=".urlencode($filename)."&s=".$imagesize."' alt='".html_encode($image->getTitle())."' title='".html_encode($image->getTitle())."' />\n";
                        }
                        if (getOption("slideshow_showdesc")) {
                            $desc = $image->getDesc();
                            $desc = str_replace("\r\n", '<br />', $desc);
                            $desc = str_replace("\r", '<br />', $desc);
                            echo "<p class='imgdesc'>" . $desc . "</p>";
                        }
                        echo "</span>";
                    }
                }
                break;
            case "flash":
                if ($heading) {
                    echo "<span class='slideimage'><h4><strong>" . $albumtitle . "</strong> (" . $numberofimages . " images) | <a style='color: white' href='" . $returnpath . "' title='" . gettext("back") . "'>" . gettext("back") . "</a></h4>";
                }
                echo "<span id='slideshow'></span>";
                ?>
 
					<script type="text/javascript">
					$("#slideshow").flashembed({
						  src:'<?php 
                echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER;
                ?>
/flowplayer/FlowPlayerLight.swf',
						  width:<?php 
                echo getOption("slideshow_flow_player_width");
                ?>
,
						  height:<?php 
                echo getOption("slideshow_flow_player_height");
                ?>
						},
						{config: {
						  autoPlay: true,
						  useNativeFullScreen: true,
						  playList: [
													<?php 
                echo "\n";
                $count = 0;
                foreach ($images as $animage) {
                    if ($dynamic) {
                        $folder = $animage['folder'];
                        $filename = $animage['filename'];
                        $salbum = new Album($_zp_gallery, $folder);
                        $image = newImage($salbum, $filename);
                        $imagepath = FULLWEBPATH . getAlbumFolder('') . pathurlencode($salbum->name) . "/" . urlencode($filename);
                    } else {
                        $folder = $album->name;
                        $filename = $animage;
                        $image = newImage($album, $filename);
                        $imagepath = FULLWEBPATH . getAlbumFolder('') . pathurlencode($folder) . "/" . pathurlencode($filename);
                    }
                    $ext = is_valid($filename, array('jpg', 'jpeg', 'gif', 'png', 'flv', 'mp3', 'mp4'));
                    if ($ext) {
                        if ($ext == "flv" || $ext == "mp3" || $ext == "mp4") {
                            $duration = "";
                        } else {
                            $duration = ", duration: " . getOption("slideshow_speed") / 10;
                        }
                        if ($count > 0) {
                            echo ",\n";
                        }
                        echo "{ url: '" . FULLWEBPATH . getAlbumFolder('') . pathurlencode($folder) . "/" . urlencode($filename) . "'" . $duration . " }";
                        $count++;
                    }
                }
                echo "\n";
                ?>
												],
						  showPlayListButtons: true,
						  showStopButton: true,
						  controlBarBackgroundColor: 0,
						 	showPlayListButtons: true,
						 	controlsOverVideo: 'ease',
						 	controlBarBackgroundColor: '<?php 
                echo getOption('flow_player_controlbarbackgroundcolor');
                ?>
',
						  controlsAreaBorderColor: '<?php 
                echo getOption('flow_player_controlsareabordercolor');
                ?>
'
						}}
				  );
					</script> 
					<?php 
                echo "</span>";
                echo "<p>";
                printf(gettext("Click on %s on the right in the player control bar to view full size."), "<img style='position: relative; top: 4px; border: 1px solid gray' src='" . WEBPATH . "/" . ZENFOLDER . '/' . PLUGIN_FOLDER . "/slideshow/flowplayerfullsizeicon.png' />");
                echo "</p>";
                break;
        }
        ?>
			</div>
		</div>
			<?php 
    }
Пример #22
0
function processPlugins()
{
    global $_zp_current_admin_obj;
    $curdir = getcwd();
    $basepath = SERVERPATH . "/" . ZENFOLDER . '/' . PLUGIN_FOLDER . '/';
    chdir($basepath);
    $filelist = safe_glob('*.php');
    foreach ($filelist as $file) {
        $titlelink = stripSuffix(filesystemToInternal($file));
        $author = stripSuffix(basename(__FILE__));
        $sql = 'SELECT `id` FROM ' . prefix('news') . ' WHERE `titlelink`=' . db_quote($titlelink);
        $result = query_single_row($sql);
        if (empty($result)) {
            $plugin_news = new ZenpageNews($titlelink);
            $fp = fopen($basepath . $file, 'r');
            $empty = true;
            $desc = '<p>';
            $tags = array($titlelink);
            $incomment = false;
            while ($line = fgets($fp)) {
                if (strpos($line, '/*') !== false) {
                    $incomment = true;
                }
                if ($incomment) {
                    if (strpos($line, '*/') !== false) {
                        break;
                    }
                    $i = strpos($line, '*');
                    $line = trim(trim(substr($line, $i + 1), '*'));
                    if (empty($line)) {
                        if (!$empty) {
                            $desc .= '<p>';
                        }
                        $empty = true;
                    } else {
                        if (strpos($line, '@') === 0) {
                            $line = trim($line, '@');
                            $i = strpos($line, ' ');
                            $mod = substr($line, 0, $i);
                            $line = trim(substr($line, $i + 1));
                            switch ($mod) {
                                case 'author':
                                    $desc .= 'Author: ' . html_encode($line) . ' ';
                                    $empty = false;
                                    preg_match_all('|\\((.+?)\\)|', $line, $matches);
                                    $tags = array_merge($tags, $matches[1]);
                                    $author = array_shift($matches[1]);
                                    break;
                                case 'package':
                                case 'subpackage':
                                    $tags[] = $line;
                                    break;
                                case 'tags':
                                    $pluginTags = explode(',', $line);
                                    foreach ($pluginTags as $tag) {
                                        $tags[] = trim(unQuote($tag));
                                    }
                                    break;
                            }
                        } else {
                            $desc .= html_encode($line) . ' ';
                            $empty = false;
                        }
                    }
                }
            }
            $desc .= '</p>';
            fclose($fp);
            $plugin_news->setShow(0);
            $plugin_news->setDateTime(date('Y-m-d H:i:s'), filemtime($file));
            $plugin_news->setAuthor($author);
            $plugin_news->setTitle($titlelink);
            $plugin_news->setContent($desc);
            $plugin_news->setTags($tags);
            $plugin_news->setCategories(array('officially-supported', 'extensions'));
            $plugin_news->setCustomData("http://www.zenphoto.org/documentation/plugins/_" . PLUGIN_FOLDER . "---" . $titlelink . ".html");
            $plugin_news->save();
        }
    }
    chdir($curdir);
}
Пример #23
0
 /**
  * Gets the feed item data in a gallery feed
  *
  * @param object $item Object of an image or album
  * @return array
  */
 protected function getItemGallery($item)
 {
     if ($this->mode == "albums") {
         $albumobj = newAlbum($item['folder']);
         $totalimages = $albumobj->getNumImages();
         $itemlink = $this->host . pathurlencode($albumobj->getLink());
         $thumb = $albumobj->getAlbumThumbImage();
         $title = $albumobj->getTitle($this->locale);
         $filechangedate = filectime(ALBUM_FOLDER_SERVERPATH . internalToFilesystem($albumobj->name));
         $latestimage = query_single_row("SELECT mtime FROM " . prefix('images') . " WHERE albumid = " . $albumobj->getID() . " AND `show` = 1 ORDER BY id DESC");
         if ($latestimage && $this->sortorder == 'latestupdated') {
             $count = db_count('images', "WHERE albumid = " . $albumobj->getID() . " AND mtime = " . $latestimage['mtime']);
         } else {
             $count = $totalimages;
         }
         if ($count != 0) {
             $imagenumber = sprintf(ngettext('%s (%u image)', '%s (%u images)', $count), $title, $count);
         } else {
             $imagenumber = $title;
         }
         $feeditem['desc'] = $albumobj->getDesc($this->locale);
         $feeditem['title'] = $imagenumber;
         $feeditem['pubdate'] = date("r", strtotime($albumobj->getDateTime()));
     } else {
         if (isAlbumClass($item)) {
             $albumobj = $item;
             $thumb = $albumobj->getAlbumThumbImage();
         } else {
             $albumobj = $item->getAlbum();
             $thumb = $item;
         }
         $itemlink = $this->host . $item->getLink();
         $title = $item->getTitle($this->locale);
         $feeditem['desc'] = $item->getDesc($this->locale);
         $feeditem['title'] = sprintf('%1$s (%2$s)', $item->getTitle($this->locale), $albumobj->getTitle($this->locale));
         $feeditem['pubdate'] = date("r", strtotime($item->getDateTime()));
     }
     //link
     $feeditem['link'] = $itemlink;
     //category
     $feeditem['category'] = html_encode($albumobj->getTitle($this->locale));
     //media content
     $feeditem['media_content'] = '<image url="' . PROTOCOL . '://' . html_encode($thumb->getCustomImage($this->imagesize, NULL, NULL, NULL, NULL, NULL, NULL, TRUE)) . '" />';
     $feeditem['media_thumbnail'] = '<thumbnail url="' . PROTOCOL . '://' . html_encode($thumb->getThumb()) . '" />';
     return $feeditem;
 }
Пример #24
0
/**
 * Prints the Galleria slideshow for albums or search results.
 *
 * Two ways to use (see readme/documentation):
 * a) Used on the included theme slideshow.php page and called via printSlideShowLink() from the core slideshow plugin:
 * b) Calling directly via printGslideshow() function in a template file or codeblock.
 *
 * @param obj $albumobj The object of the album to show the slideshow of. Not needed if calling slideshow from album, image, or search.
 * @param obj $imageobj The object of the image to start the slideshow with. If not set the slideshow starts with the first image of the album, or current image if called from image.php. Not needed if calling slideshow from album, image, or search.
 * @param bool $linkslides Set to true if you want the slides to be linked to their image pages
 * @param mixed $autoplay true to autoplay slideshow with interval set in options, false to start with slideshow stopped.  Set integer in milliseconds to autoplay at that interval (Ex. 4000), overriding plugin option set.
 * @param bool $shuffle Set to true if you want random (shuffled) order of the slides
 *
 * */
function printGslideshow($albumobj = null, $imageobj = null, $linkslides = true, $autoplay = true, $forceheight = false, $shuffle = false)
{
    $data = 'data';
    // no POST data from slidehow link and $albumobj provided is not valid, exit
    if (!isset($_POST['albumid']) and !is_object($albumobj)) {
        echo "<div class=\"errorbox\" id=\"message\"><h2>" . gettext("Invalid linking to the slideshow page.") . "</h2></div>";
        echo "</div></body></html>";
        exitZP();
    }
    global $_zp_current_image, $_zp_current_album, $_zp_gallery, $_myFavorites, $_zp_conf_vars;
    $imagenumber = 0;
    //getting the image to start with
    if (!empty($_POST['imagenumber']) and !is_object($imageobj)) {
        $imagenumber = sanitize_numeric($_POST['imagenumber']) - 1;
        // slideshows starts with 0, but zp with 1.
    } elseif (is_object($imageobj)) {
        makeImageCurrent($imageobj);
        $imagenumber = imageNumber() - 1;
    }
    // set pagenumber to 0 if not called via POST link
    if (isset($_POST['pagenr'])) {
        $pagenumber = sanitize_numeric($_POST['pagenr']);
    } else {
        $pagenumber = 1;
    }
    // getting the number of images
    if (!empty($_POST['numberofimages'])) {
        $numberofimages = sanitize_numeric($_POST['numberofimages']);
    } elseif (is_object($albumobj)) {
        $numberofimages = $albumobj->getNumImages();
    } else {
        $numberofimages = 0;
    }
    if ($imagenumber < 2 || $imagenumber > $numberofimages) {
        $imagenumber = 0;
    }
    //getting the album to show
    if (!empty($_POST['albumid']) && !is_object($albumobj)) {
        $albumid = sanitize_numeric($_POST['albumid']);
        $embedded = false;
    } elseif (is_object($albumobj)) {
        $albumid = $albumobj->getID();
        $embedded = true;
    } else {
        $albumid = 0;
        $embedded = false;
    }
    if ($numberofimages == 0) {
        return NULL;
    }
    // get slideshow data
    if (isset($_POST['preserve_search_params'])) {
        // search page
        $search = new SearchEngine();
        $params = sanitize($_POST['preserve_search_params']);
        $search->setSearchParams($params);
        $images = $search->getImages(0);
        $searchwords = $search->getSearchWords();
        $searchdate = $search->getSearchDate();
        $searchfields = $search->getSearchFields(true);
        $page = $search->page;
        $returnpath = getSearchURL($searchwords, $searchdate, $searchfields, $page);
        $albumtitle = gettext('Search');
    } else {
        if (isset($_POST['favorites_page'])) {
            $album = $_myFavorites;
            $albumtitle = gettext('My Favorites');
            $images = $album->getImages(0);
            $returnpath = rewrite_path(favorites::getFavorites_link() . '/' . $pagenumber, FULLWEBPATH . '/index.php?p=favorites' . '&page=' . $pagenumber);
        } else {
            $albumq = query_single_row("SELECT title, folder FROM " . prefix('albums') . " WHERE id = " . $albumid);
            $album = newAlbum($albumq['folder']);
            $albumtitle = $album->getTitle();
            if (!$album->isMyItem(LIST_RIGHTS) && !checkAlbumPassword($albumq['folder'])) {
                echo gettext("This album is password protected!");
                exitZP();
            }
            $dynamic = $album->isDynamic();
            $images = $album->getImages(0);
            // return path to get back to the page we called the slideshow from
            if (empty($_POST['imagenumber'])) {
                $returnpath = rewrite_path('/' . pathurlencode($album->name) . '/page/' . $pagenumber, '/index.php?album=' . urlencode($album->name) . '&page=' . $pagenumber);
            } else {
                $returnpath = rewrite_path('/' . pathurlencode($album->name) . '/' . rawurlencode(sanitize($_POST['imagefile'])) . getOption('mod_rewrite_image_suffix'), '/index.php?album=' . urlencode($album->name) . '&image=' . urlencode($_POST['imagefile']));
            }
        }
    }
    if ($shuffle) {
        shuffle($images);
    }
    // slideshow display section
    ?>

			<script>
				var data = [
				<?php 
    for ($imgnr = 0, $cntr = 0, $idx = 0; $imgnr < $numberofimages; $imgnr++, $idx++) {
        if (is_array($images[$idx])) {
            $filename = $images[$idx]['filename'];
            $album = newAlbum($images[$idx]['folder']);
            $image = newImage($album, $filename);
        } else {
            $filename = $images[$idx];
            $image = newImage($album, $filename);
        }
        $ext = isImagePhoto($image);
        if ($ext) {
            makeImageCurrent($image);
            echo '{' . "\n";
            echo 'thumb: \'' . getCustomSizedImageMaxSpace(getOption('gslideshow_thumbsize'), getOption('gslideshow_thumbsize')) . '\',' . "\n";
            echo 'image: \'' . getCustomSizedImageMaxSpace(getOption('gslideshow_mediumsize'), getOption('gslideshow_mediumsize')) . '\',' . "\n";
            echo 'big: \'' . getCustomSizedImageMaxSpace(getOption('gslideshow_bigsize'), getOption('gslideshow_bigsize')) . '\',' . "\n";
            echo 'title: \'' . js_encode($image->getTitle()) . '\',' . "\n";
            $desc = $image->getDesc();
            $desc = str_replace("\r\n", '<br />', $desc);
            $desc = str_replace("\r", '<br />', $desc);
            echo 'description: \'' . js_encode($desc) . '\',' . "\n";
            if ($linkslides) {
                echo 'link: \'' . html_encode($image->getLink()) . '\'' . "\n";
            }
            if ($imgnr == $numberofimages - 1) {
                echo '}' . "\n";
            } else {
                echo '},' . "\n";
            }
        }
    }
    echo "\n";
    ?>
				];
			</script>
			<?php 
    printGalleriaRun($data, $linkslides, $autoplay, $embedded, $forceheight, $imagenumber, $albumtitle, $returnpath);
    //restore_context(); // needed if the slideshow is for example called directly via album object before the next_album loop on index.php
}
Пример #25
0
function db_count($table, $clause = NULL, $field = "*")
{
    $sql = 'SELECT COUNT(' . $field . ') FROM ' . prefix($table) . ' ' . $clause;
    $result = query_single_row($sql);
    if ($result) {
        return array_shift($result);
    } else {
        return 0;
    }
}
Пример #26
0
 /**
  * Returns an array of image names found in the search
  *
  * @param string $sorttype what to sort on
  * @param string $sortdirection what direction
  * @param bool $mine set true/false to overried ownership
  * @return array
  */
 function getSearchImages($sorttype, $sortdirection, $mine = NULL)
 {
     if (getOption('search_no_images') || $this->search_no_images) {
         return array();
     }
     $hint = '';
     $images = array();
     $searchstring = $this->getSearchString();
     $searchdate = $this->dates;
     if (empty($searchstring) && empty($searchdate)) {
         return $images;
     }
     // nothing to find
     if (empty($searchdate)) {
         $search_results = $this->searchFieldsAndTags($searchstring, 'images', $sorttype, $sortdirection);
     } else {
         $search_results = $this->SearchDate($searchstring, $searchdate, 'images', $sorttype, $sortdirection);
     }
     if (isset($search_results) && is_array($search_results)) {
         foreach ($search_results as $row) {
             $albumid = $row['albumid'];
             $query = "SELECT id, title, folder,`show` FROM " . prefix('albums') . " WHERE id = {$albumid}";
             $row2 = query_single_row($query);
             // id is unique
             $albumname = $row2['folder'];
             if (file_exists(ALBUM_FOLDER_SERVERPATH . internalToFilesystem($albumname) . '/' . internalToFilesystem($row['filename']))) {
                 $album = new Album(new gallery(), $albumname);
                 if ($mine || is_null($mine) && ($album->isMyItem(LIST_RIGHTS) || checkAlbumPassword($albumname) && $row2['show'])) {
                     if (empty($this->album_list) || in_array($albumname, $this->album_list)) {
                         $images[] = array('filename' => $row['filename'], 'folder' => $albumname);
                     }
                 }
             }
         }
     }
     if (empty($searchdate)) {
         zp_apply_filter('search_statistics', $searchstring, 'images', !empty($images), $this->dynalbumname, $this->iteration++);
     }
     return $images;
 }
Пример #27
0
/**
 *
 * Enter description here ...
 * @param $allow
 * @param $obj
 */
function copyLayoutSelection($newid, $obj)
{
    $type = 'multiple_layouts_' . $obj->table;
    if (getOption($type)) {
        $result = query_single_row('SELECT * FROM ' . prefix('plugin_storage') . ' WHERE `aux` = ' . $obj->getID() . ' AND type = "' . $type . '"', false);
        if ($result) {
            $query = query('INSERT INTO ' . prefix('plugin_storage') . ' (type,aux,data) VALUES ("' . $result['type'] . '", ' . $newid . ', ' . db_quote($result['data']) . ')');
        }
        if (isAlbumClass($obj)) {
            $result = query_single_row('SELECT * FROM ' . prefix('plugin_storage') . ' WHERE `aux` = ' . $obj->getID() . ' AND type = "multiple_layouts_albums_images"', false);
            if ($result) {
                $query = query('INSERT INTO ' . prefix('plugin_storage') . ' (type,aux,data) VALUES ("multiple_layouts_albums_images", ' . $newid . ', ' . db_quote($result['data']) . ')');
            }
        }
    }
    return $newid;
}
Пример #28
0
/**
 * POST handler for album tree sorts
 *
 * @param int $parentid id of owning album
 *
 */
function postAlbumSort($parentid)
{
    if (isset($_POST['order']) && !empty($_POST['order'])) {
        $order = processOrder(sanitize($_POST['order']));
        $sortToID = array();
        foreach ($order as $id => $orderlist) {
            $id = str_replace('id_', '', $id);
            $sortToID[implode('-', $orderlist)] = $id;
        }
        foreach ($order as $item => $orderlist) {
            $item = str_replace('id_', '', $item);
            $currentalbum = query_single_row('SELECT * FROM ' . prefix('albums') . ' WHERE `id`=' . $item);
            $sortorder = array_pop($orderlist);
            if (count($orderlist) > 0) {
                $newparent = $sortToID[implode('-', $orderlist)];
            } else {
                $newparent = $parentid;
            }
            if ($newparent == $currentalbum['parentid']) {
                $sql = 'UPDATE ' . prefix('albums') . ' SET `sort_order`=' . db_quote(sprintf('%03u', $sortorder)) . ' WHERE `id`=' . $item;
                query($sql);
            } else {
                // have to do a move
                $albumname = $currentalbum['folder'];
                $album = newAlbum($albumname);
                if (strpos($albumname, '/') !== false) {
                    $albumname = basename($albumname);
                }
                if (is_null($newparent)) {
                    $dest = $albumname;
                } else {
                    $parent = query_single_row('SELECT * FROM ' . prefix('albums') . ' WHERE `id`=' . $newparent);
                    if ($parent['dynamic']) {
                        return "&mcrerr=5";
                    } else {
                        $dest = $parent['folder'] . '/' . $albumname;
                    }
                }
                if ($e = $album->move($dest)) {
                    return "&mcrerr=" . $e;
                } else {
                    $album->setSortOrder(sprintf('%03u', $sortorder));
                    $album->save();
                }
            }
        }
        return true;
    }
    return false;
}
Пример #29
0
function printFooter($page)
{
    global $_zp_themeroot;
    ?>
	<!-- Footer -->
	<div class="footlinks">
		<?php 
    switch ($page) {
        case 'image':
        case 'album':
            $h = getHitcounter();
            if ($h == 1) {
                echo "<p>" . sprintf(gettext('1 hit on this %s'), $page) . "</p>";
            } else {
                echo "<p>" . sprintf(gettext('%1$u hits on this %2$s'), $h, $page) . "</p>";
            }
            break;
        case 'gallery':
            ?>
			<small>
				<p><?php 
            $albumNumber = getNumAlbums();
            echo sprintf(gettext("Albums: %u"), $albumNumber);
            ?>
 &middot;
					<?php 
            echo sprintf(gettext("Subalbums: %u"), get_subalbum_count());
            ?>
 &middot;
					<?php 
            $photosArray = query_single_row("SELECT count(*) FROM " . prefix('images'));
            $photosNumber = array_shift($photosArray);
            echo sprintf(gettext("Images: %u"), $photosNumber);
            ?>
					<?php 
            if (getOption('Allow_comments')) {
                ?>
						&middot;
						<?php 
                $commentsArray = query_single_row("SELECT count(*) FROM " . prefix('comments') . " WHERE inmoderation = 0");
                $commentsNumber = array_shift($commentsArray);
                echo sprintf(gettext("Comments: %u"), $commentsNumber);
                ?>
					<?php 
            }
            ?>
				</p>
			</small>
			<?php 
            break;
    }
    ?>
		<small><?php 
    printThemeInfo();
    ?>
</small>
		<?php 
    printZenphotoLink();
    ?>
		<?php 
    if ($page == 'gallery') {
        echo '<br />';
        printRSSLink('Gallery', '', 'Gallery RSS', '');
    }
    ?>
		<?php 
    if (function_exists('printUserLogout')) {
        printUserLogout('<br />', '', true);
    }
    ?>
		<?php 
    if (function_exists('printContactForm')) {
        printCustomPageURL(gettext('Contact us'), 'contact', '', '<br />');
    }
    ?>
		<?php 
    if (!zp_loggedin() && function_exists('printRegistrationForm')) {
        printCustomPageURL(gettext('Register for this site'), 'request', '', '<br />');
    }
    ?>
		<?php 
    if (function_exists('printLanguageSelector')) {
        printLanguageSelector();
    }
    ?>
	</div>
	<!-- Administration Toolbox -->
	<?php 
    printAdminToolbox();
}
Пример #30
0
             }
             break;
     }
 }
 // tag action
 if (isset($_GET['rename'])) {
     XSRFdefender('tag_rename');
     unset($_POST['XSRFToken']);
     foreach ($_POST as $key => $newName) {
         if (!empty($newName)) {
             $newName = sanitize($newName, 3);
             $key = substr($key, 2);
             // strip off the 'R_'
             $key = postIndexDecode(sanitize($key));
             $newtag = query_single_row('SELECT `id` FROM ' . prefix('tags') . ' WHERE `name`=' . db_quote($newName));
             $oldtag = query_single_row('SELECT `id` FROM ' . prefix('tags') . ' WHERE `name`=' . db_quote($key));
             if (is_array($newtag)) {
                 // there is an existing tag of the same name
                 $existing = $newtag['id'] != $oldtag['id'];
                 // but maybe it is actually the original in a different case.
             } else {
                 $existing = false;
             }
             if ($existing) {
                 query('DELETE FROM ' . prefix('tags') . ' WHERE `id`=' . $oldtag['id']);
                 query('UPDATE ' . prefix('obj_to_tag') . ' SET `tagid`=' . $newtag['id'] . ' WHERE `tagid`=' . $oldtag['id']);
             } else {
                 query('UPDATE ' . prefix('tags') . ' SET `name`=' . db_quote($newName) . ' WHERE `id`=' . $oldtag['id']);
             }
         }
     }