Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: Will coppermine ........  (Read 4189 times)

0 Members and 1 Guest are viewing this topic.

dfstrottersfan

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Will coppermine ........
« on: December 23, 2004, 08:00:05 pm »

I have an application which really looks suited to Coppermine.

I want to load an image gallery  -  myself but allow only recognised users to access the gallery and read i.e. download the images.

Can anyone tell me if this is possible - I had a quick look at the documentation and it was not obvious to me if this was possible.

I didn't want to invest a lot of time if it was not possible

Thanks in advance
Logged

Nibbler

  • Guest
Re: Will coppermine ........
« Reply #1 on: December 23, 2004, 08:01:57 pm »

How can I let unregistered users see the thumbnails only, but not the actual pictures?

There is a variation on this posted on the boards to make it even more restrictive, or you could use album viewing rights to control access.
Logged

bit bit spears

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 240
    • TangibleBrit.com
Re: Will coppermine ........
« Reply #2 on: December 28, 2004, 10:55:29 pm »

ok here's what we do:) this is VERY possible. although you must be willing to code ALL of this and to not hold me responsible if anything happans that shouldn't. (back up all the files that will be modifed)

First off, let's create a file called "images.php".

Place this code in it:

Code: [Select]
<?php 
// ------------------------------------------------------------------------- // 
// Coppermine Photo Gallery 1.2.1                                            // 
// ------------------------------------------------------------------------- // 
// Copyright (C) 2002,2003 Gregory DEMAR                                     // 
// http://www.chezgreg.net/coppermine/                                       // 
// ------------------------------------------------------------------------- // 
// Updated by the Coppermine Dev Team                                        // 
// (http://coppermine.sf.net/team/)                                          // 
// see /docs/credits.html for details                                        // 
// ------------------------------------------------------------------------- // 
// This program is free software; you can redistribute it and/or modify      // 
// it under the terms of the GNU General Public License as published by      // 
// the Free Software Foundation; either version 2 of the License, or         // 
// (at your option) any later version.                                       // 
// ------------------------------------------------------------------------- // 


// Code by:     Christopher Brown-Floyd 
// Date:        January 13, 2004 

// Modifed by: Matt H. @ TangibleBrit.com
// Date: December 28, 2004

define('IN_COPPERMINE'true); 
define('GETFILE_PHP'true); 

global 
$CONFIG
include(
'include/init.inc.php');
include(
'include/config.inc.php');
$CONFIG['TABLE_CONFIG'] = $CONFIG['TABLE_PREFIX'] . "config"
$CONFIG['TABLE_PICTURES'] = $CONFIG['TABLE_PREFIX'] . "pictures"
    
error_reporting (0); 
// Begin Authenticate User

if(!USER_ID){

header("Location: index.php");
exit;
}
//End Atuhenticate User
db_connect($db); 
$results mysql_query("SELECT * FROM {$CONFIG['TABLE_CONFIG']}");
while (
$row mysql_fetch_array($results)) { 
    
$CONFIG[$row['name']] = $row['value']; 
// while 
mysql_free_result($results); 
// Set error logging level 
if ($CONFIG['debug_mode']) { 
    
error_reporting (0); 
} else { 
    
error_reporting (0); 

mysql_close(); 

if (!
function_exists('mime_content_type')) 

    function 
mime_content_type($path) { 
        
$image_params getimagesize($path); 
        if (
is_null($image_params)) 
            return 
null
        else 
            return 
$image_params['mime']; 
    } 


$pic_prefix = array( 
        
'thumb' => $CONFIG['thumb_pfx'], 
        
'normal' => $CONFIG['normal_pfx'], 
        
'fullsize' => ''
); 

$pid = (int) $_GET['pid']; 
$size htmlspecialchars($_GET['size']);

db_connect($db); 

$result mysql_query("select filepath,filename from {$CONFIG['TABLE_PREFIX']}pictures where pid=$pid;"); 
$result mysql_fetch_assoc($result); 
mysql_close(); 
$filename $result['filename'];
$cfilepath $CONFIG['fullpath'].$result['filepath'].$pic_prefix[$size].$result['filename']; 
header('Content-type: '.mime_content_type($cfilepath)); 
header('Content-disposition: inline; filename="' $filename '.jpg"');
    
error_reporting (0); 
$fp fopen($cfilepath,'rb'); 
echo 
fread($fp,filesize($cfilepath)); 
fclose(); 

function 
db_connect(&$db

        global 
$CONFIG
        
$db mysql_connect($CONFIG['dbserver'],$CONFIG['dbuser'],$CONFIG['dbpass']); 
        
mysql_select_db($CONFIG['dbname']); 

?>


Note: That file has already been coded to NOT show images to users who are not logged in; therefore, your images are protected from that point.

Next, let's open up the file "functions.inc.php" in the /include folder.

Replace:

Code: [Select]
return $url_prefix[$pic_row['url_prefix']]. path2url($pic_row['filepath']. $pic_prefix[$mode]. $pic_row['filename']);
With:

Code: [Select]
       if (is_null($pic_row['pid']) || !isset($CONFIG['url_mode']) || $CONFIG['url_mode']!='hide')
       return $url_prefix[$pic_row['url_prefix']]. path2url($pic_row['filepath']. $pic_prefix[$mode]. $pic_row['filename']);
return 'get_file.php?pid='.$pic_row['pid'].'&size='.$mode;

Next, open up "config.inc.php" in the /include folder

Add this line to the code:

Code: [Select]
$CONFIG['url_mode'] = 'hide';
Okay, this will make all of the images in your gallery appear as: images.php?pid=(whatever it is)&size=(the size) instead of http://yousite.com/yourcpgdir/albums/whatever.jpg.

Next, open up the following files: index.php, displayimage.php, and thumbnails.php

To each file, add this code after "define('IN_COPPERMINE', true);"

Code: [Select]

include("include/init.inc.php");

if(!USER_ID){
header("Location: login.php?referer=$PHP_SELF");
exit;
}

There you go! It should work fine if you do it right, if you have any problems, post back!
Logged

omniscientdeveloper

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 901
Re: Will coppermine ........
« Reply #3 on: December 30, 2004, 01:56:35 pm »

Seems to me that all he'll need to do is make a custom bridge file. He didn't say he had cpg already installed.
Logged
Pages: [1]   Go Up
 

Page created in 0.019 seconds with 19 queries.