CPG 1.3.2 - Upload files and edit them all at once CPG 1.3.2 - Upload files and edit them all at once
 

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]

Main Menu

CPG 1.3.2 - Upload files and edit them all at once

Started by mstralka, August 27, 2004, 06:15:05 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

mstralka

If your users upload more than one photo at a time, they probably don't like having to:
Select the album each photo should go to
Edit the description
Click Next
Repeat process for each picture they uploaded.

This mod will simplify this process by letting users see alll of the uploaded photos on one page, move them to different albums accordingly (or to the same album with 1 click), set descriptions, keywords, etc (SEE SCREENSHOT BELOW)

EDIT 8/28: Updated the MOD to be easier to follow, and included Admin option.  See my posts below for the complete mod
GO IRISH

Joachim Müller

looks good - we need to discuss on the dev board if this should go into the core code (my vote is yes, as an admin settable option).

Joachim

P.S. As you're a dev team member now, you should be able to post your mods directly on the mods board, or move a thread to it. Please post if this doesn't work for you. Moved your posting accordingly.

mstralka

Quote from: GauGau on August 27, 2004, 09:39:02 PM
looks good - we need to discuss on the dev board if this should go into the core code (my vote is yes, as an admin settable option).

I'll make it an Admin settable option
GO IRISH

kegobeer

It would be nice for the admin to have this functionality in the batch add process also.
Do not send me a private message unless I ask for one.  Make your post public so everyone can benefit.

There are no stupid questions
But there are a LOT of inquisitive idiots

DefenceTalk.com

Great mod. Tried making it work but fouled up somewhere. Maybe because I have modded upload.php even though i was able to find all of these. I wish instructions were easier/simplar(like phpbb mods) (same with juploads mod) had trouble figuring out the last find replace. :)


thanks
(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.defencetalk.com%2Fpictures%2Fsignature_cpg.php&hash=c0098ed5314d39beb9e8799c7c8787a9a0353b45)

Joachim Müller

Quote from: DefenceTalk.com on August 28, 2004, 05:25:54 AM
I wish instructions were easier/simplar(like phpbb mods)
phpBB uses the same syntax for their mods, they use [OPEN] filename,  [FIND] expression, [BEFORE,ADD] expression, [AFTER,ADD]expression etc.
Does it make a great difference for you if the syntax is [ADD] instead of [AFTER,ADD] ? The way this mod is written, most mods for similar web projects are, so this is sort of a standard. Other projects use Lunix diffs (which is far less readable for humans, as it was designed to be computer-readable) - I doubt this would make you happier ;).

Joachim

mstralka

Quote from: DefenceTalk.com on August 28, 2004, 05:25:54 AM
I wish instructions were easier/simplar(like phpbb mods) (same with juploads mod) had trouble figuring out the last find replace. :)

If you can figure out where you think I made a mistake and correct it, please let me know.  The upload.php code is not easy to mod, much less document it.  Feel free to mod the code yourself or rewrite my mod.
GO IRISH

DefenceTalk.com

Gaugua, it was just a suggestion. And no it doesn't follow the same syntax not to the same degree and maybe because phpbb and cpg are two different scripts and we shouldnt mix them together..

mstralka, by no means am i trying to criticise as I really would like to install this mod as well! As i am not a programmer and looking at this from a USER perspective rather than a developer perspective. For those of us who are not programmers, its VERY easy to get lost but for you guys its much easier to find which function to replace and where the replacement goes exactly. It was just a suggestion so that USERS (people who download cpg script and install it for other people/users) are able to actually mod the file without having to ask questions. It would be much better, easier and professional if we could have something like following of this template for better mods and understanding of them FOR THOSE who are not developers.

http://www.phpbb.com/kb/article.php?article_id=38

http://www.phpbb.com/kb/article.php?article_id=39

Not all of us are blessed with know how and expertise of the programming. It may not make my life easier or happier but it would certainly make someone else's cpg experience much better to see some type of consistency and ease of usage when it comes to adding mods.  :-\\

I hope you guys understand, sorry to drift from the topic.
thanks
(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.defencetalk.com%2Fpictures%2Fsignature_cpg.php&hash=c0098ed5314d39beb9e8799c7c8787a9a0353b45)

mstralka

This mod is split over 2 posts, please follow both

Defence, I apologize for my tone.  I write the instructions as I am doing a mod, so they probably aren't as neat as they should be.  I have, however, completed an improved version of this mod that will let the Admin decide whether users can edit all of the upload pictures at once, or separately (CPG default).  Thanks for the phpBB template.  I've never seen their templates but I will definitely start using it now.  See below:

## MOD Title: Multi-File Uploader
## MOD Author: mstralka < email > (Mark Stralka) http://www.photo-junky.com
## MOD Description: This mod will simplify the upload process by
## letting users see alll of the uploaded photos on one page,
## move them to different albums accordingly (or to the same
## album with 1 click), set descriptions, keywords, etc, instead
## of one image per page.
## Administrator can determine whether users will edit all
## uploaded photos at once, or individually.
## MOD Version: 2.0.0
## Built on CPG 1.3.2 - may work with 1.3.1
##
## Installation Level: Easy
## Installation Time: 10 minutes
## Files To Edit:   lang/english.php
##               upload.php
## Included Files: (screenshot)
##############################################################
## Author Notes:
## These steps are in order from top to bottom.  You have to
## be careful modding upload.php because a lot of the code is
## duplicated in different sections.

## This mod incorporates Frogfoot's fancy album dropdown MOD.
## You must install it first (takes 5 minutes)

## http://forum.coppermine-gallery.net/index.php?topic=8861.0
## Thanks to DefenceTalk for the MOD Instruction Template
##############################################################
## MOD History:
##
##   2004-08-27 - Version 1.0.0
##      - Original version, was not in line-by-line order,
##      - no Admin option
##
##############################################################
## Before Adding This MOD To Your Site, You Should Back Up All Files
## Related To This MOD

Database query (use phpMyAdmin):

INSERT INTO `cpg132_config` ( `name` , `value` )
VALUES (
'allow_assign_multiple_photos', '0'
);


Adding this code will create a Yes/No option on the CONFIG page, under User Settings.  The default value
is No, which means uploads will work just like they do now.  Setting it to Yes will turn on the mod.
lang/english.php
FIND:

  'User settings',
  array('Allow new user registrations', 'allow_user_registration', 1),
  array('User registration requires email verification', 'reg_requires_valid_email', 1),

ADD to end of User Settings section:

  array('Allow users to assign uploaded photos at once (instead of one-at-a-time)','allow_assign_multiple_photos',1), //Mark Stralka cpg1.3.2


upload.php:
FIND:

// The function to create the album list drop down.
function form_alb_list_box($text, $name) {
//Vodovnik.com modified this code to allow display of Categories besides album names

    // Pull the $CONFIG array and the GET array into the function.
    global $CONFIG, $HTTP_GET_VARS;

    // Also pull the album lists into the function.
    global $user_albums_list, $public_albums_list;

    // Check to see if an album has been preselected by URL addition. If so, make $sel_album the album number. Otherwise, make $sel_album 0.
    $sel_album = isset($HTTP_GET_VARS['album']) ? $HTTP_GET_VARS['album'] : 0;

    // Create the opening of the drop down box.
    echo <<<EOT
    <tr>
        <td class="tableb">
            $text
        </td>
        <td class="tableb" valign="top">
            <select name="$name" class="listbox">

EOT;

    //Cylce through the User albums.
    foreach($user_albums_list as $album) {

        // Set $album_id to the actual album ID.
        $album_id = $album['aid'];

        //Query the database to determine the category the album belongs to.
        $vQuery = "SELECT category FROM " . $CONFIG['TABLE_ALBUMS'] . " WHERE aid='" . $album_id . "'";
        $vRes = mysql_query($vQuery);
        $vRes = mysql_fetch_array($vRes);

        // Query the database to get the category name.
        $vQuery = "SELECT name FROM " . $CONFIG['TABLE_CATEGORIES'] . " WHERE cid='" . $vRes['category'] . "'";
        $vRes = mysql_query($vQuery);
        $vRes = mysql_fetch_array($vRes);

        // Create the option for the drop down list.
        echo '                <option value="' . $album['aid'] . '"' . ($album['aid'] == $sel_album ? ' selected' : '') . '>' . (($vRes['name']) ? '(' . $vRes['name'] . ') ' : '') . $album['title'] . "</option>\n";
    }

    //Cycle through the public albums.
    foreach($public_albums_list as $album) {

        // Set $album_id to the actual album ID.
        $album_id = $album['aid'];

        //Query the database to determine the category the album belongs to.
        $vQuery = "SELECT category FROM " . $CONFIG['TABLE_ALBUMS'] . " WHERE aid='" . $album_id . "'";
        $vRes = mysql_query($vQuery);
        $vRes = mysql_fetch_array($vRes);

        // Query the database to get the category name.
        $vQuery = "SELECT name FROM " . $CONFIG['TABLE_CATEGORIES'] . " WHERE cid='" . $vRes['category'] . "'";
        $vRes = mysql_query($vQuery);
        $vRes = mysql_fetch_array($vRes);

        // Create the option for the drop down list.
        echo '                <option value="' . $album['aid'] . '"' . ($album['aid'] == $sel_album ? ' selected' : '') . '>' . (($vRes['name']) ? '(' . $vRes['name'] . ') ' : '') . $album['title'] . "</option>\n";
    }

    // Close the drop down.
    echo <<<EOT
            </select>
        </td>
    </tr>

EOT;
}

Replace with:

// The function to create the album list drop down.
function form_alb_list_box($text, $name,$onChange='') {
// frogfoot re-wrote this function to present the list in categorized, sorted and nicely formatted order

    // Pull the $CONFIG array and the GET array into the function
    global $CONFIG, $HTTP_GET_VARS, $lang_upload_php;

    // Also pull the album lists into the function
    global $user_albums_list, $public_albums_list;

    // Check to see if an album has been preselected by URL addition. If so, make $sel_album the album number. Otherwise, make $sel_album 0.
    $sel_album = isset($HTTP_GET_VARS['album']) ? $HTTP_GET_VARS['album'] : 0;

if (!empty($onChange)) {
$onChange = " onChange=\"$onChange\" ";
}
    // Create the opening of the drop down box
    echo <<<EOT
    <tr>
        <td class="tableb">
            $text
        </td>
        <td class="tableb" valign="top">
            <select name="$name" class="listbox" $onChange>

EOT;

    // Reset counter
    $list_count = 0;

    // Cycle through the User albums
    foreach($user_albums_list as $album) {

        // Add to multi-dim array for later sorting
        $listArray[$list_count][cat] = $lang_upload_php['personal_albums'];
        $listArray[$list_count][aid] = $album['aid'];
        $listArray[$list_count][title] = $album['title'];
        $list_count++;
    }

    // Cycle through the public albums
    foreach($public_albums_list as $album) {

        // Set $album_id to the actual album ID
        $album_id = $album['aid'];

        // Get the category name
        $vQuery = "SELECT cat.name FROM " . $CONFIG['TABLE_CATEGORIES'] . " cat, " . $CONFIG['TABLE_ALBUMS'] . " alb WHERE alb.aid='" . $album_id . "' AND cat.cid=alb.category";
        $vRes = mysql_query($vQuery);
        $vRes = mysql_fetch_array($vRes);

        // Add to multi-dim array for sorting later
        if ($vRes['name']) {
            $listArray[$list_count][cat] = $vRes['name'];
        } else {
            $listArray[$list_count][cat] = $lang_upload_php['albums_no_category'];
        }
        $listArray[$list_count][aid] = $album['aid'];
        $listArray[$list_count][title] = $album['title'];
        $list_count++;
    }

    // Sort the pulldown options by category and album name
    $listArray = array_csort($listArray,'cat','title');

    // Finally, print out the nicely sorted and formatted drop down list
    $alb_cat = '';
    echo '                <option value="">' . $lang_upload_php['select_album'] . "</option>\n";
    foreach ($listArray as $val) {
        if ($val[cat] != $alb_cat) {
if ($alb_cat) echo "                </optgroup>\n";
            echo '                <optgroup label="' . $val[cat] . '">' . "\n";
            $alb_cat = $val[cat];
        }
        echo '                <option value="' . $val[aid] . '"' . ($val[aid] == $sel_album ? ' selected' : '') . '>   ' . $val[title] . "</option>\n";
    }
    if ($alb_cat) echo "                </optgroup>\n";

    // Close the drop down
    echo <<<EOT
            </select>
        </td>
    </tr>

EOT;
}


FIND:

// The open_form function creates the Javascript verification code and the opening form tags.
// $path hold the form action path.
function open_form($path) {

    echo <<<EOT
    <script language="JavaScript">
    function textCounter(field, maxlimit) {
            if (field.value.length > maxlimit) // if too long...trim it!
            field.value = field.value.substring(0, maxlimit);
    }
    </script>
    <form method="post" action="$path" ENCTYPE="multipart/form-data">
    </td>
EOT;
}

Replace with:

// The open_form function creates the Javascript verification code and the opening form tags.
// $path hold the form action path.
function open_form($path,$formName = "") {
if (!empty($formName)) $fn = "name=\"$formName\"";
    echo <<<EOT
    <script language="JavaScript" type="text/javascript">
    function textCounter(field, maxlimit) {
            if (field.value.length > maxlimit) // if too long...trim it!
            field.value = field.value.substring(0, maxlimit);
    }
    </script>
    <form method="post" action="$path" $fn ENCTYPE="multipart/form-data">
    </td>
EOT;
}


FIND:

        // Create array index.
        $index = count($escrow_array) - 1;

Add this below:

$start = 0;
if ((int)$CONFIG['allow_assign_multiple_photos'] == 1) {
$iCnt = count($_POST["album"]);
} else {
$iCnt = $index + 1;
$start = $index;
}

//Instead of doing one photo at a time, show one page with all of the photos that are being uploaded - this makes it much easier for the users.
for ($index = $start; $index < $iCnt; $index++) {


FIND:

        // We have incoming placement data. Let's capture it.

Add this below:

$x = $index;
if ((int)$CONFIG['allow_assign_multiple_photos'] == 0) {
$x = 0;
} else {
$x = $index;
}


FIND:

$album = (int)$HTTP_POST_VARS['album'];
$title = addslashes($HTTP_POST_VARS['title']);
$caption = addslashes($HTTP_POST_VARS['caption']);
$keywords = addslashes($HTTP_POST_VARS['keywords']);
$user1 = addslashes($HTTP_POST_VARS['user1']);
$user2 = addslashes($HTTP_POST_VARS['user2']);
$user3 = addslashes($HTTP_POST_VARS['user3']);
$user4 = addslashes($HTTP_POST_VARS['user4']);

Replace with:

$album = (int)$HTTP_POST_VARS['album'][$x];
$title = addslashes($HTTP_POST_VARS['title'][$x]);
$caption = addslashes($HTTP_POST_VARS['caption'][$x]);
$keywords = addslashes($HTTP_POST_VARS['keywords'][$x]);
$user1 = addslashes($HTTP_POST_VARS['user1'][$x]);
$user2 = addslashes($HTTP_POST_VARS['user2'][$x]);
$user3 = addslashes($HTTP_POST_VARS['user3'][$x]);
$user4 = addslashes($HTTP_POST_VARS['user4'][$x]);


FIND:

        // Check to see if this is the last one.
        if(count($escrow_array) == '0') {

            // Create the final message.
            if ($PIC_NEED_APPROVAL) {

                if ($file_placement == 'no') {

                    $final_message = ''.$lang_upload_php['no_place'].'<br /><br />'.$lang_db_input_php['upload_success'];

                } else {

                    $final_message = ''.$lang_upload_php['yes_place'].'<br /><br />'.$lang_db_input_php['upload_success'];

                }

            } else {

                if ($file_placement == 'no') {

                    $final_message = ''.$lang_upload_php['no_place'].'<br /><br />'.$lang_upload_php['process_complete'];

                } else {

                    $final_message = ''.$lang_upload_php['yes_place'].'<br /><br />'.$lang_upload_php['process_complete'];

                }

            }

            // Delete the temporary data file.
            delete_record($_POST['unique_ID']);

            // Send e-mail notification to the admin if requested (added by gaugau: 03-11-09).
            if (($CONFIG['upl_notify_admin_email']) and ($PIC_NEED_APPROVAL)) {
                // Encapsulate so included lang file doesn't interfere with global one
                function cpg_send_upload_notification() {
                    global $CONFIG;
                    $lang_db_input_php = cpg_get_default_lang_var('lang_db_input_php');
                    // Get the mail files.
                    include_once('include/mailer.inc.php');

                    // Send the message.
                    cpg_mail($CONFIG['gallery_admin_email'], sprintf($lang_db_input_php['notify_admin_email_subject'], $CONFIG['gallery_name']), sprintf($lang_db_input_php['notify_admin_email_body'], USER_NAME,  $CONFIG['ecards_more_pic_target'].'editpics.php?mode=upload_approval' ));
                }
                cpg_send_upload_notification();
            }

            // That was the last one. Create a redirect box.
            pageheader($lang_info);
            msg_box($lang_info, $final_message, $lang_continue, 'index.php', "100%");
            pagefooter();

            // Exit the script.
            exit;

        }

Replace with:

// Check to see if this is the last one.
if(count($escrow_array) == '0') {

// Create the final message.
if ($PIC_NEED_APPROVAL) {

if ($file_placement == 'no') {

$final_message = ''.$lang_upload_php['no_place'].'<br /><br />'.$lang_db_input_php['upload_success'];

} else {

$final_message = ''.$lang_upload_php['yes_place'].'<br /><br />'.$lang_db_input_php['upload_success'];

}

} else {

if ($file_placement == 'no') {

$final_message = ''.$lang_upload_php['no_place'].'<br /><br />'.$lang_upload_php['process_complete'];

} else {

$final_message = ''.$lang_upload_php['yes_place'].'<br /><br />'.$lang_upload_php['process_complete'];

}

}

if ((int)$CONFIG['allow_assign_multiple_photos'] == 0) {
// Delete the temporary data file.
delete_record($_POST['unique_ID']);

// Send e-mail notification to the admin if requested (added by gaugau: 03-11-09).
if (($CONFIG['upl_notify_admin_email']) and ($PIC_NEED_APPROVAL)) {
// Encapsulate so included lang file doesn't interfere with global one
function cpg_send_upload_notification() {
global $CONFIG;
$lang_db_input_php = cpg_get_default_lang_var('lang_db_input_php');
// Get the mail files.
include_once('include/mailer.inc.php');

// Send the message.
cpg_mail($CONFIG['gallery_admin_email'], sprintf($lang_db_input_php['notify_admin_email_subject'], $CONFIG['gallery_name']), sprintf($lang_db_input_php['notify_admin_email_body'], USER_NAME,  $CONFIG['ecards_more_pic_target'].'editpics.php?mode=upload_approval' ));
}
cpg_send_upload_notification();
}

// That was the last one. Create a redirect box.
pageheader($lang_info);
msg_box($lang_info, $final_message, $lang_continue, 'index.php', "100%");
pagefooter();

// Exit the script.
exit;
}
} //end for loop

            if ((int)$CONFIG['allow_assign_multiple_photos'] == 1) {
// Delete the temporary data file.
delete_record($_POST['unique_ID']);

// Send e-mail notification to the admin if requested (added by gaugau: 03-11-09).
if (($CONFIG['upl_notify_admin_email']) and ($PIC_NEED_APPROVAL)) {
// Encapsulate so included lang file doesn't interfere with global one
function cpg_send_upload_notification() {
global $CONFIG;
$lang_db_input_php = cpg_get_default_lang_var('lang_db_input_php');
// Get the mail files.
include_once('include/mailer.inc.php');

// Send the message.
cpg_mail($CONFIG['gallery_admin_email'], sprintf($lang_db_input_php['notify_admin_email_subject'], $CONFIG['gallery_name']), sprintf($lang_db_input_php['notify_admin_email_body'], USER_NAME,  $CONFIG['ecards_more_pic_target'].'editpics.php?mode=upload_approval' ));
}
cpg_send_upload_notification();
}

// That was the last one. Create a redirect box.
pageheader($lang_info);
msg_box($lang_info, $final_message, $lang_continue, 'index.php', "100%");
pagefooter();

// Exit the script.
exit;
}
}


FIND:

    // Create array index.
    $index = count($escrow_array) - 1;

ADD:


$start = 0;
if ((int)$CONFIG['allow_assign_multiple_photos'] == 1) {
$iCnt = count($escrow_array);
} else {
$iCnt = $index + 1;
$start = $index;
}

// Create upload form headers.
    pageheader($lang_upload_php['title']);
echo <<<EOT
<script type="text/javascript">
function moveAllTo(d,box) {
var f = document.editForm;
for (i = 0; i < f.length; i++) {
if (f[i].type == "select-one" && f[i].name.indexOf(box) >= 0) {
f[i].value = d
}
}
}
</script>
EOT;
    // Open the form table.
    starttable("100%", $lang_upload_php['title'], 2);
echo <<<EOT
<tr>
<td class="tableh2">
All Photos:
</td>
<td class="tableh2">

EOT;
//MOVE TO ALL MOD
form_alb_list_box("Move all photos to:","moveAllTo","moveAllTo(this.value,'album');");
echo <<<EOT
</td>
</tr>
EOT;
    // Direct the request to this script.
    open_form($_SERVER['PHP_SELF'],'editForm');
//Display all of the photos at once for editing
for ($index = $start; $index < $iCnt; $index++) {



FIND and Delete or comment out:

    // Create upload form headers.
    pageheader($lang_upload_php['title']);

    // Open the form table.
    starttable("100%", $lang_upload_php['title'], 2);

    // Direct the request to this script.
    open_form($_SERVER['PHP_SELF']);
GO IRISH

mstralka

#9
FIND:

$form_array = array(
array($lang_upload_php['album'], 'album[]', 2),
array($lang_upload_php['pic_title'], 'title[]', 0, 255, 1),
array($captionLabel, 'caption', 3, $CONFIG['max_img_desc_length']),
array($lang_upload_php['keywords'], 'keywords[]', 0, 255, 1));

// Check for user defined fields.
if(!empty($CONFIG['user_field1_name'])) {
$form_array[] = array($CONFIG['user_field1_name'], 'user1', 0, 255, 1);
}

if(!empty($CONFIG['user_field2_name'])) {
$form_array[] = array($CONFIG['user_field2_name'], 'user2', 0, 255, 1);
}

if(!empty($CONFIG['user_field3_name'])) {
$form_array[] = array($CONFIG['user_field3_name'], 'user3', 0, 255, 1);
}

if(!empty($CONFIG['user_field4_name'])) {
$form_array[] = array($CONFIG['user_field4_name'], 'user4', 0, 255, 1);
}

Replace with:

$form_array = array(
array($lang_upload_php['album'], 'album[]', 2),
array($lang_upload_php['pic_title'], 'title[]', 0, 255, 1),
array($captionLabel, 'caption', 3, $CONFIG['max_img_desc_length']),
array($lang_upload_php['keywords'], 'keywords[]', 0, 255, 1));
if ((int)$CONFIG['allow_assign_multiple_photos'] == 0) {
$form_array[] = array('control', 'phase_2', 4);
$form_array[] = array('unique_ID', $_POST['unique_ID'], 4);
}

// Check for user defined fields.
if(!empty($CONFIG['user_field1_name[]'])) {
$form_array[] = array($CONFIG['user_field1_name[]'], 'user1', 0, 255, 1);
}

if(!empty($CONFIG['user_field2_name'])) {
$form_array[] = array($CONFIG['user_field2_name[]'], 'user2', 0, 255, 1);
}

if(!empty($CONFIG['user_field3_name'])) {
$form_array[] = array($CONFIG['user_field3_name[]'], 'user3', 0, 255, 1);
}

if(!empty($CONFIG['user_field4_name'])) {
$form_array[] = array($CONFIG['user_field4_name[]'], 'user4', 0, 255, 1);
}


FIND:

    // Create the form and echo more instructions.
create_form($form_array);

ADD:

}//end loop over pictures


FIND:

    // More instructions.
    if(count($escrow_array) > '1') {

        form_statement($lang_upload_php['place_instr_2']);

    }

ADD:

if ((int)$CONFIG['allow_assign_multiple_photos'] == 1) {
$form_array = array(
array('control', 'phase_2', 4),
array('unique_ID', $_REQUEST['unique_ID'], 4),
);
create_form($form_array);
}
GO IRISH

DefenceTalk.com

Thank You.

:)

I did edit text of your other mod cross platform uploading, etc. Took away bbcodes, spaces between FINDs, replaces, etc. so I can clearly see them. Its a long mod you know. ;)
(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.defencetalk.com%2Fpictures%2Fsignature_cpg.php&hash=c0098ed5314d39beb9e8799c7c8787a9a0353b45)

foulu

i do but after add some pics, the final message show nothing and only one pics was uploaded. i don't think i make something wrong. I check it 1.5 hours.

foulu

FIND:

Code:
      $form_array = array(
      array($lang_upload_php['album'], 'album[]', 2),
      array($lang_upload_php['pic_title'], 'title[]', 0, 255, 1),
      array($captionLabel, 'caption', 3, $CONFIG['max_img_desc_length']),
      array($lang_upload_php['keywords'], 'keywords[]', 0, 255, 1));
      if ((int)$CONFIG['allow_assign_multiple_photos'] == 0) {
         $form_array[] = array('control', 'phase_2', 4);
         $form_array[] = array('unique_ID', $_POST['unique_ID'], 4);
      }

      // Check for user defined fields.
      if(!empty($CONFIG['user_field1_name'])) {
         $form_array[] = array($CONFIG['user_field1_name'], 'user1', 0, 255, 1);
      }

      if(!empty($CONFIG['user_field2_name'])) {
         $form_array[] = array($CONFIG['user_field2_name'], 'user2', 0, 255, 1);
      }

      if(!empty($CONFIG['user_field3_name'])) {
         $form_array[] = array($CONFIG['user_field3_name'], 'user3', 0, 255, 1);
      }

      if(!empty($CONFIG['user_field4_name'])) {
         $form_array[] = array($CONFIG['user_field4_name'], 'user4', 0, 255, 1);
      }
Replace with:

Code:
      $form_array = array(
      array($lang_upload_php['album'], 'album[]', 2),
      array($lang_upload_php['pic_title'], 'title[]', 0, 255, 1),
      array($captionLabel, 'caption', 3, $CONFIG['max_img_desc_length']),
      array($lang_upload_php['keywords'], 'keywords[]', 0, 255, 1));
      if ((int)$CONFIG['allow_assign_multiple_photos'] == 0) {
         $form_array[] = array('control', 'phase_2', 4);
         $form_array[] = array('unique_ID', $_POST['unique_ID'], 4);
      }

      // Check for user defined fields.
      if(!empty($CONFIG['user_field1_name[]'])) {
         $form_array[] = array($CONFIG['user_field1_name[]'], 'user1', 0, 255, 1);
      }

      if(!empty($CONFIG['user_field2_name'])) {
         $form_array[] = array($CONFIG['user_field2_name[]'], 'user2', 0, 255, 1);
      }

      if(!empty($CONFIG['user_field3_name'])) {
         $form_array[] = array($CONFIG['user_field3_name[]'], 'user3', 0, 255, 1);
      }

      if(!empty($CONFIG['user_field4_name'])) {
         $form_array[] = array($CONFIG['user_field4_name[]'], 'user4', 0, 255, 1);
      }

they all the same

mstralka

You're right.  This section did not exist in the original code - it needs to be added for this mod:

      if ((int)$CONFIG['allow_assign_multiple_photos'] == 0) {
         $form_array[] = array('control', 'phase_2', 4);
         $form_array[] = array('unique_ID', $_POST['unique_ID'], 4);
      }
GO IRISH

foulu

#14
When use debug mode i receiver some note:

Upload file

Notice: Undefined variable: fn in c:\inetpub\wwwroot\gallery\uploadER.php on line 350

Notice: Undefined offset: 2 in c:\inetpub\wwwroot\gallery\uploadER.php on line 290

Notice: Undefined offset: 3 in c:\inetpub\wwwroot\gallery\uploadER.php on line 296

Notice: Undefined offset: 4 in c:\inetpub\wwwroot\gallery\uploadER.php on line 296
 
and

Notice: Undefined index: URI_array in c:\inetpub\wwwroot\gallery\uploadER.php on line 1302

Notice: Undefined variable: file_failure_array in c:\inetpub\wwwroot\gallery\uploadER.php on line 1980

Notice: Undefined variable: URI_failure_array in c:\inetpub\wwwroot\gallery\uploadER.php on line 1981

Notice: Undefined variable: zip_failure_array in c:\inetpub\wwwroot\gallery\uploadER.php on line 1982

do you think it is normal.

Joachim Müller

disable display of notices (coppermin config, at the very bottom) - they are only meant for developers who know what they mean, they usually won't affect anything.

Joachim

foulu

#16
thanks, i always scare about it. But i think
Quote
// Check to see if this is the last one.
         if(count($escrow_array) == '0') {
            
            // Create the final message.
            if ($PIC_NEED_APPROVAL) {

               if ($file_placement == 'no') {

                  $final_message = ''.$lang_upload_php['no_place'].'<br /><br />'.$lang_db_input_php['upload_success'];

               } else {

                  $final_message = ''.$lang_upload_php['yes_place'].'<br /><br />'.$lang_db_input_php['upload_success'];

               }

            } else {

               if ($file_placement == 'no') {

                  $final_message = ''.$lang_upload_php['no_place'].'<br /><br />'.$lang_upload_php['process_complete'];

               } else {

                  $final_message = ''.$lang_upload_php['yes_place'].'<br /><br />'.$lang_upload_php['process_complete'];

               }

            }

            if ((int)$CONFIG['allow_assign_multiple_photos'] == 0) {
               // Delete the temporary data file.
               delete_record($_POST['unique_ID']);

               // Send e-mail notification to the admin if requested (added by gaugau: 03-11-09).
               if (($CONFIG['upl_notify_admin_email']) and ($PIC_NEED_APPROVAL)) {
                  // Encapsulate so included lang file doesn't interfere with global one
                  function cpg_send_upload_notification() {
                     global $CONFIG;
                     $lang_db_input_php = cpg_get_default_lang_var('lang_db_input_php');
                     // Get the mail files.
                     include_once('include/mailer.inc.php');

                     // Send the message.
                     cpg_mail($CONFIG['gallery_admin_email'], sprintf($lang_db_input_php['notify_admin_email_subject'], $CONFIG['gallery_name']), sprintf($lang_db_input_php['notify_admin_email_body'], USER_NAME,  $CONFIG['ecards_more_pic_target'].'editpics.php?mode=upload_approval' ));
                  }
                  cpg_send_upload_notification();
               }

               // That was the last one. Create a redirect box.
               pageheader($lang_info);
               msg_box($lang_info, $final_message, $lang_continue, 'index.php', "100%");
               pagefooter();

               // Exit the script.
               exit;
            }
         } //end for loop

            if ((int)$CONFIG['allow_assign_multiple_photos'] == 1) {
            // Delete the temporary data file.
            delete_record($_POST['unique_ID']);

            // Send e-mail notification to the admin if requested (added by gaugau: 03-11-09).
            if (($CONFIG['upl_notify_admin_email']) and ($PIC_NEED_APPROVAL)) {
               // Encapsulate so included lang file doesn't interfere with global one
               function cpg_send_upload_notification() {
                  global $CONFIG;
                  $lang_db_input_php = cpg_get_default_lang_var('lang_db_input_php');
                  // Get the mail files.
                  include_once('include/mailer.inc.php');

                  // Send the message.
                  cpg_mail($CONFIG['gallery_admin_email'], sprintf($lang_db_input_php['notify_admin_email_subject'], $CONFIG['gallery_name']), sprintf($lang_db_input_php['notify_admin_email_body'], USER_NAME,  $CONFIG['ecards_more_pic_target'].'editpics.php?mode=upload_approval' ));
               }
               cpg_send_upload_notification();
            }

            // That was the last one. Create a redirect box.
            pageheader($lang_info);
            msg_box($lang_info, $final_message, $lang_continue, 'index.php', "100%");
            pagefooter();

            // Exit the script.
            exit;
         }
      }
move   } //end for loop   to end to make this mod work !!!

djbabytroja

This Hack have bugs... i think so....

but... the idea is good...

because i try to add it... but wenn i take all pics to one album and press next cpg says no folder exist.... !!!!! ?????


Greetiings

DefenceTalk.com

i am getting this after updating the files:

(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.defencetalk.com%2Fpictures%2Fsignature_cpg.php&hash=c0098ed5314d39beb9e8799c7c8787a9a0353b45)

djbabytroja

Hi...

Read this...

Quote
##############################################################
## Author Notes:
## These steps are in order from top to bottom.  You have to
## be careful modding upload.php because a lot of the code is
## duplicated in different sections.
## This mod incorporates Frogfoot's fancy album dropdown MOD.
## You must install it first (takes 5 minutes)
## http://forum.coppermine-gallery.net/index.php?topic=8861.0
## Thanks to DefenceTalk for the MOD Instruction Template
##############################################################

I forgott this as first... and i had the same problem like you...
after installing the Frogfoot hack it works...

But this Hack is buggy... because after installing the Frogfoot hack and installing this hack... he shows me... after uploading the files... this abum not exist.. i know why...

because mstralka says...

FIND:
// The function to create the album list drop down.
function form_alb_list_box($text, $name) {
//Vodovnik.com modified this code to allow display of Categories besides album names

    // Pull the $CONFIG array and the GET array into the function.
    global $CONFIG, $HTTP_GET_VARS;

    // Also pull the album lists into the function.
    global $user_albums_list, $public_albums_list;

    // Check to see if an album has been preselected by URL addition. If so, make $sel_album the album number. Otherwise, make $sel_album 0.
    $sel_album = isset($HTTP_GET_VARS['album']) ? $HTTP_GET_VARS['album'] : 0;

    // Create the opening of the drop down box.
    echo <<<EOT
    <tr>
        <td class="tableb">
            $text
        </td>
        <td class="tableb" valign="top">
            <select name="$name" class="listbox">

EOT;

    //Cylce through the User albums.
    foreach($user_albums_list as $album) {

        // Set $album_id to the actual album ID.
        $album_id = $album['aid'];

        //Query the database to determine the category the album belongs to.
        $vQuery = "SELECT category FROM " . $CONFIG['TABLE_ALBUMS'] . " WHERE aid='" . $album_id . "'";
        $vRes = mysql_query($vQuery);
        $vRes = mysql_fetch_array($vRes);

        // Query the database to get the category name.
        $vQuery = "SELECT name FROM " . $CONFIG['TABLE_CATEGORIES'] . " WHERE cid='" . $vRes['category'] . "'";
        $vRes = mysql_query($vQuery);
        $vRes = mysql_fetch_array($vRes);

        // Create the option for the drop down list.
        echo '                <option value="' . $album['aid'] . '"' . ($album['aid'] == $sel_album ? ' selected' : '') . '>' . (($vRes['name']) ? '(' . $vRes['name'] . ') ' : '') . $album['title'] . "</option>\n";
    }

    //Cycle through the public albums.
    foreach($public_albums_list as $album) {

        // Set $album_id to the actual album ID.
        $album_id = $album['aid'];

        //Query the database to determine the category the album belongs to.
        $vQuery = "SELECT category FROM " . $CONFIG['TABLE_ALBUMS'] . " WHERE aid='" . $album_id . "'";
        $vRes = mysql_query($vQuery);
        $vRes = mysql_fetch_array($vRes);

        // Query the database to get the category name.
        $vQuery = "SELECT name FROM " . $CONFIG['TABLE_CATEGORIES'] . " WHERE cid='" . $vRes['category'] . "'";
        $vRes = mysql_query($vQuery);
        $vRes = mysql_fetch_array($vRes);

        // Create the option for the drop down list.
        echo '                <option value="' . $album['aid'] . '"' . ($album['aid'] == $sel_album ? ' selected' : '') . '>' . (($vRes['name']) ? '(' . $vRes['name'] . ') ' : '') . $album['title'] . "</option>\n";
    }

    // Close the drop down.
    echo <<<EOT
            </select>
        </td>
    </tr>

EOT;
}


AND REPLACE WITH:
// The function to create the album list drop down.
function form_alb_list_box($text, $name,$onChange='') {
// frogfoot re-wrote this function to present the list in categorized, sorted and nicely formatted order

    // Pull the $CONFIG array and the GET array into the function
    global $CONFIG, $HTTP_GET_VARS, $lang_upload_php;

    // Also pull the album lists into the function
    global $user_albums_list, $public_albums_list;

    // Check to see if an album has been preselected by URL addition. If so, make $sel_album the album number. Otherwise, make $sel_album 0.
    $sel_album = isset($HTTP_GET_VARS['album']) ? $HTTP_GET_VARS['album'] : 0;

if (!empty($onChange)) {
$onChange = " onChange=\"$onChange\" ";
}
    // Create the opening of the drop down box
    echo <<<EOT
    <tr>
        <td class="tableb">
            $text
        </td>
        <td class="tableb" valign="top">
            <select name="$name" class="listbox" $onChange>

EOT;

    // Reset counter
    $list_count = 0;

    // Cycle through the User albums
    foreach($user_albums_list as $album) {

        // Add to multi-dim array for later sorting
        $listArray[$list_count][cat] = $lang_upload_php['personal_albums'];
        $listArray[$list_count][aid] = $album['aid'];
        $listArray[$list_count][title] = $album['title'];
        $list_count++;
    }

    // Cycle through the public albums
    foreach($public_albums_list as $album) {

        // Set $album_id to the actual album ID
        $album_id = $album['aid'];

        // Get the category name
        $vQuery = "SELECT cat.name FROM " . $CONFIG['TABLE_CATEGORIES'] . " cat, " . $CONFIG['TABLE_ALBUMS'] . " alb WHERE alb.aid='" . $album_id . "' AND cat.cid=alb.category";
        $vRes = mysql_query($vQuery);
        $vRes = mysql_fetch_array($vRes);

        // Add to multi-dim array for sorting later
        if ($vRes['name']) {
            $listArray[$list_count][cat] = $vRes['name'];
        } else {
            $listArray[$list_count][cat] = $lang_upload_php['albums_no_category'];
        }
        $listArray[$list_count][aid] = $album['aid'];
        $listArray[$list_count][title] = $album['title'];
        $list_count++;
    }

    // Sort the pulldown options by category and album name
    $listArray = array_csort($listArray,'cat','title');

    // Finally, print out the nicely sorted and formatted drop down list
    $alb_cat = '';
    echo '                <option value="">' . $lang_upload_php['select_album'] . "</option>\n";
    foreach ($listArray as $val) {
        if ($val[cat] != $alb_cat) {
if ($alb_cat) echo "                </optgroup>\n";
            echo '                <optgroup label="' . $val[cat] . '">' . "\n";
            $alb_cat = $val[cat];
        }
        echo '                <option value="' . $val[aid] . '"' . ($val[aid] == $sel_album ? ' selected' : '') . '>   ' . $val[title] . "</option>\n";
    }
    if ($alb_cat) echo "                </optgroup>\n";

    // Close the drop down
    echo <<<EOT
            </select>
        </td>
    </tr>

EOT;
}


AND frogfoot have this CODE:
// The function to create the album list drop down.
function form_alb_list_box($text, $name) {
// frogfoot re-wrote this function to present the list in categorized, sorted and nicely formatted order

    // Pull the $CONFIG array and the GET array into the function
    global $CONFIG, $HTTP_GET_VARS, $lang_upload_php;

    // Also pull the album lists into the function
    global $user_albums_list, $public_albums_list;

    // Check to see if an album has been preselected by URL addition. If so, make $sel_album the album number. Otherwise, make $sel_album 0.
    $sel_album = isset($HTTP_GET_VARS['album']) ? $HTTP_GET_VARS['album'] : 0;

    // Create the opening of the drop down box
    echo <<<EOT
    <tr>
        <td class="tableb">
            $text
        </td>
        <td class="tableb" valign="top">
            <select name="$name" class="listbox">

EOT;

    // Reset counter
    $list_count = 0;

    // Cycle through the User albums
    foreach($user_albums_list as $album) {

        // Add to multi-dim array for later sorting
        $listArray[$list_count][cat] = $lang_upload_php['personal_albums'];
        $listArray[$list_count][aid] = $album['aid'];
        $listArray[$list_count][title] = $album['title'];
        $list_count++;
    }

    // Cycle through the public albums
    foreach($public_albums_list as $album) {

        // Set $album_id to the actual album ID
        $album_id = $album['aid'];

        // Get the category name
        $vQuery = "SELECT cat.name FROM " . $CONFIG['TABLE_CATEGORIES'] . " cat, " . $CONFIG['TABLE_ALBUMS'] . " alb WHERE alb.aid='" . $album_id . "' AND cat.cid=alb.category";
        $vRes = mysql_query($vQuery);
        $vRes = mysql_fetch_array($vRes);

        // Add to multi-dim array for sorting later
        if ($vRes['name']) {
            $listArray[$list_count][cat] = $vRes['name'];
        } else {
            $listArray[$list_count][cat] = $lang_upload_php['albums_no_category'];
        }
        $listArray[$list_count][aid] = $album['aid'];
        $listArray[$list_count][title] = $album['title'];
        $list_count++;
    }

    // Sort the pulldown options by category and album name
    $listArray = array_csort($listArray,'cat','title');

    // Finally, print out the nicely sorted and formatted drop down list
    $alb_cat = '';
    echo '                <option value="">' . $lang_upload_php['select_album'] . "</option>\n";
    foreach ($listArray as $val) {
        if ($val[cat] != $alb_cat) {
if ($alb_cat) echo "                </optgroup>\n";
            echo '                <optgroup label="' . $val[cat] . '">' . "\n";
            $alb_cat = $val[cat];
        }
        echo '                <option value="' . $val[aid] . '"' . ($val[aid] == $sel_album ? ' selected' : '') . '>   ' . $val[title] . "</option>\n";
    }
    if ($alb_cat) echo "                </optgroup>\n";

    // Close the drop down
    echo <<<EOT
            </select>
        </td>
    </tr>

EOT;
}

// Multi-dim array sort, with ability to sort by two and more dimensions
// Coded by Ichier2003, available at php.net
// syntax:
// $array = array_csort($array [, 'col1' [, SORT_FLAG [, SORT_FLAG]]]...);
function array_csort() {
   $args = func_get_args();
   $marray = array_shift($args);

   $msortline = "return(array_multisort(";
   foreach ($args as $arg) {
       $i++;
       if (is_string($arg)) {
           foreach ($marray as $row) {
               $sortarr[$i][] = $row[$arg];
           }
       } else {
           $sortarr[$i] = $arg;
       }
       $msortline .= "\$sortarr[".$i."],";
   }
   $msortline .= "\$marray));";

   eval($msortline);
   return $marray;
}


What is to do???

Greetings