Пример #1
0
/**
* Recursivly deletes all albums and child albums
*
* @param    int     album_id    album id to delete
* @return   int     true for success or false for failure
*
*/
function MG_deleteChildAlbums($album_id)
{
    global $MG_albums, $_CONF, $_MG_CONF, $_TABLES, $_USER;
    $sql = "SELECT * FROM {$_TABLES['mg_albums']} WHERE album_parent=" . $album_id;
    $aResult = DB_query($sql);
    $rowCount = DB_numRows($aResult);
    for ($z = 0; $z < $rowCount; $z++) {
        $row = DB_fetchArray($aResult);
        MG_deleteChildAlbums($row['album_id']);
    }
    $sql = "SELECT ma.media_id, m.media_filename, m.media_mime_ext\r\n            FROM " . $_TABLES['mg_media_albums'] . " as ma LEFT JOIN " . $_TABLES['mg_media'] . " as m ON ma.media_id=m.media_id\r\n            WHERE ma.album_id = " . $album_id;
    $result = DB_query($sql);
    $nRows = DB_numRows($result);
    $mediarow = array();
    for ($i = 0; $i < $nRows; $i++) {
        $row = DB_fetchArray($result);
        $mediarow[] = $row;
    }
    if (count($mediarow) != 0) {
        for ($i = 0; $i < count($mediarow); $i++) {
            $sql = "SELECT COUNT(media_id) AS count FROM " . $_TABLES['mg_media_albums'] . "  WHERE media_id = '" . $mediarow[$i]['media_id'] . "'";
            $result = DB_query($sql);
            $row = DB_fetchArray($result);
            if ($row['count'] <= 1) {
                foreach ($_MG_CONF['validExtensions'] as $ext) {
                    @unlink($_MG_CONF['path_mediaobjects'] . 'tn/' . $mediarow[$i]['media_filename'][0] . '/' . $mediarow[$i]['media_filename'] . $ext);
                    @unlink($_MG_CONF['path_mediaobjects'] . 'disp/' . $mediarow[$i]['media_filename'][0] . '/' . $mediarow[$i]['media_filename'] . $ext);
                }
                @unlink($_MG_CONF['path_mediaobjects'] . 'orig/' . $mediarow[$i]['media_filename'][0] . '/' . $mediarow[$i]['media_filename'] . '.' . $mediarow[$i]['media_mime_ext']);
                $sql = "DELETE FROM " . $_TABLES['mg_media'] . "  WHERE media_id = '" . $mediarow[$i]['media_id'] . "'";
                DB_query($sql);
                DB_delete($_TABLES['comments'], 'sid', $mediarow[$i]['media_id']);
                DB_delete($_TABLES['mg_playback_options'], 'media_id', $mediarow[$i]['media_id']);
                PLG_itemDeleted($mediarow[$i]['media_id'], 'mediagallery');
            }
        }
    }
    $sql = "DELETE FROM " . $_TABLES['mg_media_albums'] . " WHERE album_id = " . $album_id;
    DB_query($sql);
    $sql = "DELETE FROM " . $_TABLES['mg_albums'] . " WHERE album_id = " . $album_id;
    DB_query($sql);
    $feedname = sprintf($_MG_CONF['rss_feed_name'] . "%06d", $album_id);
    $feedpath = MG_getFeedPath();
    @unlink($feedpath . '/' . $feedname . '.rss');
}
Пример #2
0
/**
* Recursivly deletes all albums and child albums
*
* @param    int     album_id    album id to delete
* @return   int     true for success or false for failure
*
*/
function MG_deleteChildAlbums($album_id)
{
    global $_MG_CONF, $_TABLES;
    $sql = "SELECT album_id " . "FROM {$_TABLES['mg_albums']} " . "WHERE album_parent=" . intval($album_id);
    $result = DB_query($sql);
    while ($row = DB_fetchArray($result)) {
        MG_deleteChildAlbums($row['album_id']);
    }
    $sql = "SELECT media_id " . "FROM {$_TABLES['mg_media_albums']} " . "WHERE album_id = " . intval($album_id);
    $result = DB_query($sql);
    while ($row = DB_fetchArray($result)) {
        MG_deleteMedia($row['media_id']);
    }
    DB_delete($_TABLES['mg_media_albums'], 'album_id', intval($album_id));
    DB_delete($_TABLES['mg_albums'], 'album_id', intval($album_id));
    $feedname = sprintf($_MG_CONF['rss_feed_name'] . "%06d", $album_id);
    $feedpath = MG_getFeedPath();
    @unlink($feedpath . '/' . $feedname . '.rss');
}
Пример #3
0
function MG_buildFullRSS()
{
    global $LANG_CHARSET, $MG_albums, $_MG_CONF, $_CONF, $_TABLES;
    $feedpath = MG_getFeedPath();
    if ($_MG_CONF['rss_full_enabled'] != 1) {
        @unlink($feedpath . '/' . $_MG_CONF['rss_feed_name'] . '.rss');
        return;
    }
    $rss = new UniversalFeedCreator();
    $rss->title = $_CONF['site_name'] . ' Media Gallery RSS Feed';
    $rss->description = $_CONF['site_slogan'];
    $rss->descriptionTruncSize = 500;
    $rss->descriptionHtmlSyndicated = true;
    $rss->encoding = strtoupper($_CONF['default_charset']);
    $rss->link = $_CONF['site_url'];
    $feedurl = SYND_getFeedUrl();
    $rss->syndicationURL = $feedurl . $_MG_CONF['rss_feed_name'] . '.rss';
    MG_parseAlbumsRSS($rss, 0);
    $rss->saveFeed($_MG_CONF['rss_feed_type'], $feedpath . "/" . $_MG_CONF['rss_feed_name'] . '.rss', 0);
    @chmod($feedpath . '/' . $_MG_CONF['rss_feed_name'] . '.rss', 0664);
    return;
}
Пример #4
0
function MG_buildFullRSS()
{
    global $_MG_CONF, $_CONF, $_TABLES;
    $feedpath = MG_getFeedPath();
    if ($_MG_CONF['rss_full_enabled'] != 1) {
        @unlink($feedpath . $_MG_CONF['rss_feed_name'] . '.rss');
        return;
    }
    $rss = new UniversalFeedCreator();
    $rss->title = $_CONF['site_name'] . ' Media Gallery RSS Feed';
    $rss->description = $_CONF['site_slogan'];
    $rss->descriptionTruncSize = 500;
    $rss->descriptionHtmlSyndicated = true;
    $rss->encoding = strtoupper($_CONF['default_charset']);
    $rss->link = $_CONF['site_url'];
    $rss->syndicationURL = $_CONF['site_url'] . $_SERVER["PHP_SELF"];
    // あやしい。
    MG_parseAlbumsRSS($rss, 0);
    // valid format strings are: RSS0.91, RSS1.0, RSS2.0, PIE0.1 (deprecated),
    // MBOX, OPML, ATOM, ATOM0.3, HTML, JS
    $rss->saveFeed($_MG_CONF['rss_feed_type'], $feedpath . $_MG_CONF['rss_feed_name'] . '.rss', 0);
    @chmod($feedpath . $_MG_CONF['rss_feed_name'] . '.rss', 0664);
    return;
}