Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Visitor upload not working  (Read 18074 times)

0 Members and 1 Guest are viewing this topic.

The German

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Visitor upload not working
« on: January 20, 2013, 05:29:22 pm »

So, I spent several hours on this and can't find a solution :-(
- I allowed the "Guests" group Public album upload without approval
- There is no way to assign a "Guests"  group to a category
- In the album "Visitor can upload files" is activated.

Result
- The album is being displayed to visitors
- There is no album that can be selected for uploading a file

This drives me crazy and was wondering if there is a solution to this....
Logged

phill104

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4885
    • Windsurf.me
Re: Visitor upload not working
« Reply #1 on: January 20, 2013, 05:44:01 pm »

Logged
It is a mistake to think you can solve any major problems just with potatoes.

The German

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Visitor upload not working
« Reply #2 on: January 20, 2013, 05:49:33 pm »

Yes, the link that is missing is that "Guests" do not have any album assigned, nor can they pick it when trying to upload.
Also, this is a brand new, out of the box installation without any modifications or plugins.
Logged

phill104

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4885
    • Windsurf.me
Re: Visitor upload not working
« Reply #3 on: January 20, 2013, 06:40:21 pm »

Is it working now? If not please provide all the details from the "troubleshooting the upload process" from the docs.
Logged
It is a mistake to think you can solve any major problems just with potatoes.

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Visitor upload not working
« Reply #4 on: January 21, 2013, 11:03:28 am »

This is maybe related to a recent change in cpg1.5.22:
Unified album drop-down boxes (thread)
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Visitor upload not working
« Reply #5 on: January 21, 2013, 11:09:28 am »

This seems to fix the issue in my testbed. Please open include/functions.inc.php and replace the whole function album_selection_options with
Code: [Select]
function album_selection_options($selected = 0)
{
    global $CONFIG, $lang_common, $cpg_udb, $LINEBREAK;
    // html string of options to be returned
    $options = '';
    $albums = array();
    // load all albums

    $uploads_yes = defined('EDITPICS_PHP') || defined('UPLOAD_PHP') ? ' OR uploads = "YES"' : '';

    if (GALLERY_ADMIN_MODE) {
        $result = cpg_db_query("SELECT aid, title, category FROM {$CONFIG['TABLE_ALBUMS']} ORDER BY pos");
    } elseif (USER_ID) {
        $result = cpg_db_query("SELECT aid, title, category FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = " . (FIRST_USER_CAT + USER_ID) . " OR owner = " . USER_ID . $uploads_yes . " ORDER BY pos");
    } else {
        $result = cpg_db_query("SELECT aid, title, category FROM {$CONFIG['TABLE_ALBUMS']} WHERE 0 " . $uploads_yes . " ORDER BY pos");
    }

    while ( ($row = mysql_fetch_assoc($result)) ) {
        $albums[$row['category']][$row['aid']] = $row['title'];
    }
    if (!empty($albums[0])) {
        // Albums in no category
        $options .= '<optgroup label="' . $lang_common['albums_no_category'] . '">';
        foreach ($albums[0] as $aid => $title) {
            $options .= sprintf('<option value="%d"%s>%s</option>'.$LINEBREAK, $aid, $aid == $selected ? ' selected="selected"' : '', $title);
        }
        $options .= '</optgroup>';
    }
    // Load all categories
    if (GALLERY_ADMIN_MODE) {
        $result = cpg_db_query("SELECT cid, rgt, name FROM {$CONFIG['TABLE_CATEGORIES']} ORDER BY lft");
    } elseif (USER_ID) {
        $result = cpg_db_query("SELECT DISTINCT c.cid, c.rgt, c.name FROM {$CONFIG['TABLE_ALBUMS']} AS a RIGHT JOIN {$CONFIG['TABLE_CATEGORIES']} AS c ON a.category = c.cid WHERE c.cid = " . USER_GAL_CAT . " OR a.owner = ". USER_ID . $uploads_yes . " ORDER BY lft");
    } else {
        $result = cpg_db_query("SELECT DISTINCT c.cid, c.rgt, c.name FROM {$CONFIG['TABLE_ALBUMS']} AS a RIGHT JOIN {$CONFIG['TABLE_CATEGORIES']} AS c ON a.category = c.cid WHERE 0 " . $uploads_yes . " ORDER BY lft");
    }

    $cats = array();
    // Loop through all categories
    while ( ($row = mysql_fetch_assoc($result))) {
        // Determine category hierarchy
        if (count($cats)) {
            while ($cats && $cats[count($cats)-1]['rgt'] < $row['rgt']) {
                array_pop($cats);
            }
        }
        $cats[] = $row;
        // Add this category to the hierarchy
        if ($row['cid'] == USER_GAL_CAT) {
            // User galleries
            $options .= '<optgroup label="' . $lang_common['personal_albums'] . '">' . $LINEBREAK;

            if (GALLERY_ADMIN_MODE) {
                $result2 = cpg_db_query("SELECT {$cpg_udb->field['user_id']} AS user_id, {$cpg_udb->field['username']} AS user_name "
                    . "FROM {$cpg_udb->usertable} ORDER BY {$cpg_udb->field['username']}", $cpg_udb->link_id);
                $users = cpg_db_fetch_rowset($result2);
                mysql_free_result($result2);
            } else {
                $users = array(array('user_id' => USER_ID, 'user_name' => USER_NAME));
            }

            foreach ($users as $user) {
                if (!empty($albums[$user['user_id'] + FIRST_USER_CAT])) {
                    $options .= '<optgroup label="&nbsp;&nbsp;&nbsp;&nbsp;' . $user['user_name'] . '">' . $LINEBREAK;
                    foreach ($albums[$user['user_id'] + FIRST_USER_CAT] as $aid => $title) {
                        $options .= sprintf('<option value="%d"%s>%s</option>' . $LINEBREAK, $aid, $aid == $selected ? ' selected="selected"' : '', '&nbsp;&nbsp;&nbsp;&nbsp;'.$title);
                    }
                    $options .= '</optgroup>';
                }
            }
            $options .= '</optgroup>';
            unset($users);
            continue;
        }
        // calculate indent for this level
        $indent = str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', (count($cats) - 1));
        // albums in the category
        if (!empty($albums[$row['cid']])) {
            // category header
            $options .= '<optgroup label="' . $indent . $row['name'] . '">' . $LINEBREAK;

            foreach ($albums[$row['cid']] as $aid => $title) {
                $options .= sprintf('<option value="%d"%s>%s</option>' . $LINEBREAK, $aid, $aid == $selected ? ' selected="selected"' : '', $indent . $title);
            }

            $options .= '</optgroup>';
        }
    }
    mysql_free_result($result);

    return $options;
}
« Last Edit: January 21, 2013, 11:16:32 am by Αndré »
Logged

The German

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Problems uploading pictures.
« Reply #6 on: January 22, 2013, 03:10:18 am »

Must be really hard to even read the e-mail before pushing out the standard "RTFM" thing hmm? Read my message again... It is the ANONYMOUS / GUEST that does not need to log on as described in your troubleshooting guide. Registered users can upload just fine.

Well, you know what, simply delete my account here, I already wasted way too much time for something that should work out of the box and does not. There are other solutions that are being tested before released.

Regards,
Thomas
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Visitor upload not working
« Reply #7 on: January 22, 2013, 09:29:01 am »

Thomas, it's not always obvious how some config options may affect other parts. However, I already provided a fix and ask you to confirm if it also works for you (actually this worked since cpg1.5.20 and have crept in while optimizing something different in cpg1.5.22). If you still want your account to be deleted, let me know.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Visitor upload not working
« Reply #8 on: January 25, 2013, 02:48:51 pm »

Fix confirmed:
Changed code now working

Added to SVN repository in revision 8539.
Logged

mculver

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
Re: Visitor upload not working
« Reply #9 on: April 08, 2013, 02:23:57 am »

I had the same issue -- the fix posted here works like a charm.

Thanks!
Logged
Pages: [1]   Go Up
 

Page created in 0.023 seconds with 20 queries.