$count = isset($HTTP_GET_VARS['count']) ? (int) $HTTP_GET_VARS['count'] : 25;
$next_target = $PHP_SELF . '?album=' . $album_id . '&start=' . ($start + $count) . '&count=' . $count . (UPLOAD_APPROVAL_MODE == 1 ? "&mode=upload_approval" : "");
$prev_target = $PHP_SELF . '?album=' . $album_id . '&start=' . max(0, $start - $count) . '&count=' . $count . (UPLOAD_APPROVAL_MODE == 1 ? "&mode=upload_approval" : "");
$s50 = $count == 50 ? 'selected' : '';
$s75 = $count == 75 ? 'selected' : '';
$s100 = $count == 100 ? 'selected' : '';
if (UPLOAD_APPROVAL_MODE) {
    $result = db_query("SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'NO'");
    $nbEnr = mysql_fetch_array($result);
    $pic_count = $nbEnr[0];
    // Update user names for pictures
    $sql = "SELECT pid, owner_id FROM {$CONFIG['TABLE_PICTURES']} WHERE owner_id != 0 AND owner_name = ''";
    $result = db_query($sql);
    while ($row = mysql_fetch_array($result)) {
        if (defined('UDB_INTEGRATION')) {
            $owner_name = udb_get_user_name($row['owner_id']);
        } else {
            $result2 = db_query("SELECT user_name FROM {$CONFIG['TABLE_USERS']} WHERE user_id = '" . $row['owner_id'] . "'");
            if (mysql_num_rows($result2)) {
                $row2 = mysql_fetch_array($result2);
                mysql_free_result($result2);
                $owner_name = $row2['user_name'];
            } else {
                $owner_name = '';
            }
        }
        if ($owner_name) {
            db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET owner_name = '{$owner_name}' WHERE pid = {$row['pid']} LIMIT 1");
        } else {
            db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET owner_id = 0 WHERE pid = {$row['pid']} LIMIT 1");
        }
function get_username($uid)
{
    global $CONFIG;
    $uid = (int) $uid;
    if (!$uid) {
        return 'Anonymous';
    } elseif (defined('UDB_INTEGRATION')) {
        return udb_get_user_name($uid);
    } else {
        $result = db_query("SELECT user_name FROM {$CONFIG['TABLE_USERS']} WHERE user_id = '" . $uid . "'");
        if (mysql_num_rows($result) == 0) {
            return '';
        }
        $row = mysql_fetch_array($result);
        mysql_free_result($result);
        return $row['user_name'];
    }
}
function form_visibility($text, $name)
{
    global $CONFIG, $USER_DATA, $ALBUM_DATA, $lang_modifyalb_php;
    if (!$CONFIG['allow_private_albums']) {
        echo '        <input type="hidden" name="' . $name . '" value="0">' . "\n";
        return;
    }
    if (GALLERY_ADMIN_MODE) {
        $options = array(0 => $lang_modifyalb_php['public_alb'], FIRST_USER_CAT + USER_ID => $lang_modifyalb_php['me_only']);
        if ($ALBUM_DATA['category'] > FIRST_USER_CAT) {
            if (defined('UDB_INTEGRATION')) {
                $owner_name = udb_get_user_name($ALBUM_DATA['category'] - FIRST_USER_CAT);
            } else {
                $result = db_query("SELECT user_name FROM {$CONFIG['TABLE_USERS']} WHERE user_id='" . ($ALBUM_DATA['category'] - FIRST_USER_CAT) . "'");
                if (mysql_num_rows($result)) {
                    $user = mysql_fetch_array($result);
                    $owner_name = $user['user_name'];
                }
            }
            $options[$ALBUM_DATA['category']] = sprintf($lang_modifyalb_php['owner_only'], $owner_name);
        }
        $result = db_query("SELECT group_id, group_name FROM {$CONFIG['TABLE_USERGROUPS']} WHERE 1");
        while ($group = mysql_fetch_array($result)) {
            $options[$group['group_id']] = sprintf($lang_modifyalb_php['groupp_only'], $group['group_name']);
        }
        // while
    } else {
        $options = array(0 => $lang_modifyalb_php['public_alb'], FIRST_USER_CAT + USER_ID => $lang_modifyalb_php['me_only']);
        $result = db_query("SELECT group_id, group_name FROM {$CONFIG['TABLE_USERGROUPS']} WHERE group_id IN " . USER_GROUP_SET);
        while ($group = mysql_fetch_array($result)) {
            $options[$group['group_id']] = sprintf($lang_modifyalb_php['groupp_only'], $group['group_name']);
        }
        // while
    }
    echo <<<EOT
        <tr>
                <td class="tableb">
                        {$text}
                </td>
                <td class="tableb" valign="top">
                        <select name="{$name}" class="listbox">

EOT;
    foreach ($options as $value => $caption) {
        echo '                                <option value ="' . $value . '"' . ($ALBUM_DATA['visibility'] == $value ? ' selected' : '') . '>' . $caption . "</option>\n";
    }
    echo <<<EOT
                        </select>
                </td>
        </tr>

EOT;
}