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: album/file does not exist error when add to favorite  (Read 3396 times)

0 Members and 1 Guest are viewing this topic.

zac

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 153
album/file does not exist error when add to favorite
« on: May 09, 2007, 06:27:32 am »

I have been trying to get an answer to this by bumping a couple of threads marked solved.. so thought I would make this its own topic.

I added an add to favorites link in my nav bar as explained in this thread: http://forum.coppermine-gallery.net/index.php?topic=26315.20

It does work in adding the image to the favorites however the page reloads to an error that the selected album/file does not exist.  I found a few posts about this topic, all marked solved and all offering the same mod of addfav.php:

Code: [Select]
$header_location = (@preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE'))) ? 'Refresh: 0; URL=' : 'Location: ';
// MOD BEGIN
$ref .= '&cat='.$_GET['cat'].'&pos='.$_GET['pos'];
// MOD END
header($header_location . $ref);

For reference those posts are:  http://forum.coppermine-gallery.net/index.php?topic=32079.0 and http://forum.coppermine-gallery.net/index.php?topic=31124.0

This did not fix it for me.  I am running 1.4.9 with the album_fav_boxes plugin.  I did get some advice from Nibbler but not really clear to me ???

Quote
You need to add a redirect parameter to the link, look at the built-in link to see how this works. It was added as a bugfix since this mod was posted.

I do have a test setup at http://www.folkphotography.com/prints/

username and password :  test

thanks to anyone that has any advice on how to fix this or if someone can explain it a bit more detail which built in link I should be looking at to understand how to add a redirect parameter.

« Last Edit: May 10, 2007, 08:02:12 am by GauGau »
Logged

zac

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 153
Re: album/file does not exist error when add to favorite
« Reply #1 on: May 09, 2007, 07:35:35 am »

Just to further clarify.. the part of the code I think I need to fix is this:

Code: [Select]
if (USER_ID) {
if (!in_array($CURRENT_PIC_DATA['pid'], $FAVPICS)) {
             $favorite = '<a href=addfav.php?pid=' . $CURRENT_PIC_DATA['pid'] . ' ><img src="http://www.folkphotography.com/prints/images/addlight.gif" align="middle" border="0" alt="" title="'. $lang_picinfo['addFav'] . '" /></a>';
       } else {
             $favorite = '<a href=addfav.php?pid=' . $CURRENT_PIC_DATA['pid'] . ' ><img src="images/remlight.gif" align="middle" border="0" alt="" title="'. $lang_picinfo['remFav'] . '" /></a>';
       }
} else {
       $favorite = '';
}

I found this in my displayimage.php:

Code: [Select]
$ref = $REFERER ? "&amp;ref=$REFERER" : '';

    if (!in_array($CURRENT_PIC_DATA['pid'], $FAVPICS)) {

        $info[$lang_picinfo['addFavPhrase']] = "<a href=\"addfav.php?pid=" . $CURRENT_PIC_DATA['pid'] . $ref . "\" >" . $lang_picinfo['addFav'] . '</a>';

    } else {

        $info[$lang_picinfo['addFavPhrase']] = "<a href=\"addfav.php?pid=" . $CURRENT_PIC_DATA['pid']  . $ref . "\" >" . $lang_picinfo['remFav'] . '</a>';

    }

is this the "built-in" link I should be replicating? 
Logged

zac

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 153
Re: album/file does not exist error when add to favorite
« Reply #2 on: May 10, 2007, 04:46:52 am »

.. you can mark this as solved.  After some more digging around I found the solution spread out in a few different threads.  In case anyone cares.. the correct code to move the add button to the nav is actually

Code: [Select]
function theme_html_img_nav_menu()
{
    global $CONFIG, $HTTP_SERVER_VARS, $HTTP_GET_VARS, $CURRENT_PIC_DATA, $PHP_SELF, $FAVPICS, $REFERER;
    global $album, $cat, $pos, $pic_count, $lang_img_nav_bar, $lang_picinfo, $lang_text_dir, $template_img_navbar;

    $cat_link = is_numeric($album) ? '' : '&amp;cat=' . $cat;

    $human_pos = $pos + 1;
    $page = ceil(($pos + 1) / ($CONFIG['thumbrows'] * $CONFIG['thumbcols']));
    $pid = $CURRENT_PIC_DATA['pid'];

    $start = 0;
        $start_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&amp;pos=$start";
        $start_title = $lang_img_nav_bar['go_album_start'];
        $meta_nav .= "<link rel=\"start\" href=\"$start_tgt\" title=\"$start_title\" />
        ";
        $end = $pic_count - 1;
        $end_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&amp;pos=$end";
        $end_title = $lang_img_nav_bar['go_album_end'];
        $meta_nav .= "<link rel=\"last\" href=\"$end_tgt\" title=\"$end_title\" />
        ";

    if ($pos > 0) {
        $prev = $pos - 1;
        $prev_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&amp;pos=$prev";
        $prev_title = $lang_img_nav_bar['prev_title'];
                                $meta_nav .= "<link rel=\"prev\" href=\"$prev_tgt\" title=\"$prev_title\" />
                                ";
    } else {
        $prev_tgt = "javascript:;";
        $prev_title = "";
    }

    if ($pos < ($pic_count -1)) {
        $next = $pos + 1;
        $next_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&amp;pos=$next";
        $next_title = $lang_img_nav_bar['next_title'];
                                $meta_nav .= "<link rel=\"next\" href=\"$next_tgt\" title=\"$next_title\"/>
                                ";
    } else {
        $next_tgt = "javascript:;";
        $next_title = "";
    }

    if (USER_CAN_SEND_ECARDS) {
        $ecard_tgt = "ecard.php?album=$album$cat_link&amp;pid=$pid&amp;pos=$pos";
        $ecard_title = $lang_img_nav_bar['ecard_title'];
    } else {
        template_extract_block($template_img_navbar, 'ecard_button'); // added to remove button if cannot send ecard
        /*$ecard_tgt = "javascript:alert('" . addslashes($lang_img_nav_bar['ecard_disabled_msg']) . "');";
        $ecard_title = $lang_img_nav_bar['ecard_disabled'];*/
    }

$ref = $REFERER ? "&amp;ref=$REFERER" : '';
if (!in_array($CURRENT_PIC_DATA['pid'], $FAVPICS)) {
        $favorite = '<a href=addfav.php?pid=' . $CURRENT_PIC_DATA['pid'] . $ref . ' ><img src="images/addlight.jpg" align="middle" border="0" alt="" title="'. $lang_picinfo['addFav'] . '" /></a>';
    } else {
        $favorite = '<a href=addfav.php?pid=' . $CURRENT_PIC_DATA['pid'] . $ref . ' ><img src="images/remlight.jpg" align="middle" border="0" alt="" title="'. $lang_picinfo['remFav'] . '" /></a>';
    }

with this fix for a know bug in addfav.php

Code: [Select]
$header_location = (@preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE'))) ? 'Refresh: 0; URL=' : 'Location: ';
// MOD BEGIN
echo "HEADER LOCATION: $header_location<br />";
echo "REF: $ref<br />";
ob_end_flush();
exit();
// MOD END
Logged
Pages: [1]   Go Up
 

Page created in 0.017 seconds with 19 queries.