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 2 3 [4] 5 6 7 8   Go Down

Author Topic: Flikr style image annotations  (Read 202130 times)

0 Members and 1 Guest are viewing this topic.

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Flikr style image annotations
« Reply #60 on: July 25, 2008, 05:54:05 pm »

You have to comment out just the line 'if (USER_ID){' and the appropriate '}'

I changed your posted code to my idea. Try:
Code: [Select]
<?php
/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2007 Coppermine Dev Team
  v1.1 originally written by Gregory DEMAR

  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.
**********************************************/

if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');

if (
defined('DISPLAYIMAGE_PHP')) {
$thisplugin->add_filter('page_meta','annotate_meta');
$thisplugin->add_filter('file_data','annotate_file_data');
}

$thisplugin->add_action('plugin_install','annotate_install');
$thisplugin->add_action('plugin_uninstall','annotate_uninstall');
$thisplugin->add_action('plugin_cleanup','annotate_cleanup');

function 
annotate_meta(){

$meta  "\n" '<script src="plugins/annotate/lib/httpreq.js" type="text/javascript"></script>';
$meta .= "\n" '<script src="plugins/annotate/lib/photonotes.js" type="text/javascript"></script>';
$meta .= "\n" '<link rel="stylesheet" href="plugins/annotate/lib/photonotes.css" type="text/css" />';
$meta .= "\n";

return $meta;
}

function 
annotate_file_data($CURRENT_PIC_DATA){

global $CONFIG;

if (is_image($CURRENT_PIC_DATA['filename'])){

$sql "SELECT * FROM {$CONFIG['TABLE_PREFIX']}notes WHERE pid = {$CURRENT_PIC_DATA['pid']}";
$result cpg_db_query($sql);

$notes = array();

while ($row mysql_fetch_assoc($result)) $notes[] = $row;

mysql_free_result($result);

$jsarray arrayToJS4($notes'annotations');

$html =& $CURRENT_PIC_DATA['html'];

$html '<div class="Photo fn-container" id="PhotoContainer">' $html '</div>';

// if (USER_ID){

$html .= <<< EOT

<div style="clear: both; padding-top: 20px">
<form action="" method="post">
<input type="submit" class="button" name="addname" value="Annotate" onclick="return addnote()" />
</form>
</div>

EOT;

// }


$user_id  USER_ID;
$admin GALLERY_ADMIN_MODE 'true' 'false';

$html .= <<< EOT

<script type="text/javascript">

var 
$jsarray

/* create the Photo Note Container */
var container = document.getElementById('PhotoContainer');

var notes = new PhotoNoteContainer(container);

for (var n = 0; n < annotations.length; n++){

/* create a note */
var size = new PhotoNoteRect(annotations[n].posx, annotations[n].posy, annotations[n].width, annotations[n].height);
var note = new PhotoNote(annotations[n].note,'note' + n, size);

/* implement the save/delete functions */
note.onsave = function (note) { return ajax_save(note); };
note.ondelete = function (note) { return ajax_delete(note); };

/* assign the note id number */
note.nid = annotations[n].nid;

/* if (!
$admin && note.user_id != $user_id) note.editable = false; */

/* add it to the container */
notes.AddNote(note);
}

notes.HideAllNotes();

addEvent(container, 'mouseover', function() {
         notes.ShowAllNotes();
    });
    
 addEvent(container, 'mouseout', function() {
         notes.HideAllNotes();
    });

function addnote(){

var newNote = new PhotoNote('','note' + n,new PhotoNoteRect(10,10,50,50));
newNote.onsave = function (note) { return ajax_save(note); };
newNote.ondelete = function (note) { return ajax_delete(note); };
notes.AddNote(newNote);
newNote.Select();
newNote.nid = 0;

return false;
}

function ajax_save(note){

var data = 'add=' + 
{$CURRENT_PIC_DATA['pid']} + '&nid=' + note.nid + '&posx=' + note.rect.left + '&posy=' + note.rect.top + '&width=' + note.rect.width + '&height=' + note.rect.height + '&note=' + escape(note.text);

annotate_request(data, note);

return true;
}

function ajax_delete(note){

var data = 'remove=' + note.nid;

annotate_request(data, note);

return true;
}

</script>


EOT;

}

return $CURRENT_PIC_DATA;
}

// Based on code by Rob Williams
//Convert a PHP array to a JavaScript one (rev. 4)
function arrayToJS4($array$baseName) {

$return '';

   
//Write out the initial array definition
   
$return .= ($baseName " = new Array(); \r\n ");    

   
//Reset the array loop pointer
   
reset ($array);

   
//Use list() and each() to loop over each key/value
   //pair of the array
   
while (list($key$value) = each($array)) {
      if (
is_numeric($key)) {
         
//A numeric key, so output as usual
         
$outKey "[" $key "]";
      } else {
         
//A string key, so output as a string
         
$outKey "['" $key "']";
      }
      
      if (
is_array($value)) {
         
//The value is another array, so simply call
         //another instance of this function to handle it
         
$return .= arrayToJS4($value$baseName $outKey);
      } else {

         
//Output the key declaration
         
$return .= ($baseName $outKey " = ");      

         
//Now output the value
         
if (is_numeric($value)){
         
$return .= ($value "; \r\n ");
         } else if (
is_string($value)) {
            
//Output as a string, as we did before       
            
$return .= ("'" $value "'; \r\n ");
         } else if (
$value === false) {
            
//Explicitly output false
            
$return .= ("false; \r\n ");
         } else if (
$value === NULL) {
            
//Explicitly output null
            
$return .= ("null; \r\n ");
         } else if (
$value === true) {
            
//Explicitly output true
            
$return .= ("true; \r\n ");
         } else {
            
//Output the value directly otherwise
            
$return .= ($value "; \r\n ");
         }
      }
   }
   
   return 
$return;
}


function 
annotate_install() {
    global 
$thisplugin$CONFIG;

$sql "DROP TABLE IF EXISTS `{$CONFIG['TABLE_PREFIX']}notes`";
cpg_db_query($sql);

$sql = <<< EOT

CREATE TABLE IF NOT EXISTS `
{$CONFIG['TABLE_PREFIX']}notes` (
  `nid` smallint(5) unsigned NOT NULL auto_increment,
  `pid` mediumint(8) unsigned NOT NULL,
  `posx` smallint(5) unsigned NOT NULL,
  `posy` smallint(5) unsigned NOT NULL,
  `width` smallint(5) unsigned NOT NULL,
  `height` smallint(5) unsigned NOT NULL,
  `note` text NOT NULL,
  `user_id` smallint(5) unsigned NOT NULL,
  PRIMARY KEY  (`nid`),
  KEY `pid` (`pid`)
) TYPE=MyISAM ;

EOT;

return cpg_db_query($sql);
 }
Logged

LnQ

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 38
Re: Flikr style image annotations
« Reply #61 on: July 25, 2008, 11:42:12 pm »

Thanks it works...

Now I just need some security....could it be posible to add some admin info for abuse...
when people tag theirs ip adresse get logged... or some capture code to be verified before someone can tag...

abuse from bots and stuff if they exits...

but thanks for the plugin too it awsome
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Flikr style image annotations
« Reply #62 on: July 26, 2008, 08:27:31 am »

when people tag theirs ip adresse get logged
Just make an 'ALTER TABLE foo ADD bar' in your database and change the sql query, where the annotations are added to the database.

some capture code to be verified before someone can tag
You could customize the captcha plugin for this purpose.
Logged

Gephri

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 235
Re: Flikr style image annotations
« Reply #63 on: July 26, 2008, 04:53:31 pm »

eenemeenemuu:

I see that you are offering help to prevent an abuse using this mod.  Can you help me with the following request?

Quote
how to add the dirty word filter from the language file ($lang_bad_words) to this plug-in?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Flikr style image annotations
« Reply #64 on: July 26, 2008, 10:03:26 pm »

I don't know how $lang_bad_words is constructed, but i suppose it's an array.

You have to insert somewhere something like
Code: [Select]
if (in_array($lang_bad_words))
  cpg_die(ERROR, 'Don't use bad words.', __FILE__, __LINE__);
or check it via javascript.


I'll think about that soon ;)
Logged

Gephri

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 235
Re: Flikr style image annotations
« Reply #65 on: July 27, 2008, 01:22:29 am »

Thanks
Here's 2 places where dirty word functions are in place in cpg:
db_input.php
Code: [Select]
function check_comment(&$str)
{
    global $CONFIG, $lang_bad_words, $queries;

    if ($CONFIG['filter_bad_words']) {
        $ercp = array();
        foreach($lang_bad_words as $word) {
            $ercp[] = '/' . ($word[0] == '*' ? '': '\b') . str_replace('*', '', $word) . ($word[(strlen($word)-1)] == '*' ? '': '\b') . '/i';
        }
        $str = preg_replace($ercp, '(...)', $str);
    }

    $com_words=explode(' ',strip_tags(bb_decode($str)));
    $replacements=array();
    foreach($com_words as $key => $word) {
       if (utf_strlen($word) > $CONFIG['max_com_wlength'] ) {
          $replacements[] = $word;
       }
    }
    $str=str_replace($replacements,'(...)',$str);
}

and
include/functions.inc
Code: [Select]
/**
 * filter_content()
 *
 * Replace strings that match badwords with tokens indicating it has been filtered.
 *
 * @param string or array $str
 * @return string or array
 **/
function filter_content($str)
{
    global $lang_bad_words, $CONFIG, $ercp;
    if ($CONFIG['filter_bad_words']) {
        static $ercp=array();
        if (!count($ercp)) foreach($lang_bad_words as $word) {
            $ercp[] = '/' . ($word[0] == '*' ? '': '\b') . str_replace('*', '', $word) . ($word[(strlen($word)-1)] == '*' ? '': '\b') . '/i';
        }
        if (is_array($str)) {
            $new_str=array();
            foreach ($str as $key=>$element) {
                $new_str[$key]=filter_content($element);
            }
            $str=$new_str;
        } else {
        $stripped_str = strip_tags($str);
        $str = preg_replace($ercp, '(...)', $stripped_str);
        }
    }
return $str;
}

Beyond that - I'm not sure what to do...
Logged

lemm85

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: Flikr style image annotations
« Reply #66 on: September 04, 2008, 09:22:19 pm »

hi anyone,

nobody an idea why firefox and IE7 set different marks like this:

marked with firefox3.0.1:
[Edit GauGau] Replaced hotlinked images with attachment [/Edit]

viewed in IE7:
[Edit GauGau] Replaced hotlinked images with attachment [/Edit]

could any other approve this problem?

thx
« Last Edit: September 05, 2008, 07:43:45 pm by Joachim Müller »
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Flikr style image annotations
« Reply #67 on: September 04, 2008, 09:33:30 pm »

could any other approve this problem?

No. In my gallery the annotations are at the same place in IE 7 and FF 3.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Flikr style image annotations
« Reply #68 on: September 05, 2008, 07:44:26 pm »

Posting a link instead of just a screenshot might help... ::)
Logged

Fabricio Ferrero

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 1996
  • From San Juan, Argentina, to the World!
    • http://fabricioferrero.com/
Re: Flikr style image annotations
« Reply #69 on: September 13, 2008, 09:31:27 pm »

Hi,

Some user of spanish sub forum is using this plugin but he can't put the 'ñ'. He is right. Maybe some of you have modified the code to work under UTF-8 and could share an updated version of the plugin.
Logged
Read Docs and Search the Forum before posting. - Soporte en español
--*--
Fabricio Ferrero's Website

Catching up! :)

davieb

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 48
Re: Flikr style image annotations
« Reply #70 on: September 22, 2008, 10:01:19 pm »

My users used to like this feature when we ran a flickr gallery so I reckon it would be a good addition to our coppermine one, however I have the same problem that others had early on, and that is the annotate button appears but when it's clicked the screen just refreshes but nothing appears to add a note anywhere. Can someone explain what I've done wrong or what I need to do to resolve this problem please.
Logged

chrislam101

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: Flikr style image annotations
« Reply #71 on: October 01, 2008, 04:11:15 pm »

I have one problem on using that, Can it support UT8 or chinese BIG5 ? many thanks !
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Flikr style image annotations
« Reply #72 on: October 01, 2008, 05:31:27 pm »

Nibbler already said that he would be updating the plugin with utf-8 support if he got the time:
I will update the plugin soon with your css change and I'll try to fix the apostrophe and utf-8 issues too.
So far, he hasn't updated it. You're welcome to look into this if you're ready.
Logged

chrislam101

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: Flikr style image annotations
« Reply #73 on: October 02, 2008, 12:35:43 pm »

Oh thanks ! and waiting for new update  ;D
Logged

jManuel

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 46
    • Comunidad de fotografos aficionados
Re: Flikr style image annotations
« Reply #74 on: October 07, 2008, 09:43:45 pm »

hi,

I have one problem on using that, Can it support UT8 or chinese BIG5 ? many thanks !
Try this,

view this topic in spanish sub-board:

http://forum.coppermine-gallery.net/index.php/topic,55068.0.html

waiting for update.

Logged
jManuel - Comunidad de fotografos aficionados

jharvie

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Flikr style image annotations
« Reply #75 on: October 19, 2008, 03:01:51 pm »

absolutely grand!
Is there a way to give permissions to use annotate feature only to some user group? I have made a few tests on my gallery and noticed every registered user can annotate any pic, but I would rather prefere giving this privilege only to some groups.

PS. ah, forgot to mention: Thanks!!!

Yeah, Is there any way to make it so that only certain groups can use the annotate feature or even so that only admin can use it? I don't really want any registered user to be able to annotate my pictures.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Flikr style image annotations
« Reply #76 on: October 19, 2008, 06:48:17 pm »

Yeah, Is there any way to make it so that only certain groups can use the annotate feature or even so that only admin can use it? I don't really want any registered user to be able to annotate my pictures.

In codebase.php, change the line
Code: [Select]
if (USER_ID){to your needs.
Logged

jharvie

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Flikr style image annotations
« Reply #77 on: October 19, 2008, 09:05:44 pm »

In codebase.php, change the line
Code: [Select]
if (USER_ID){to your needs.

So if I want to allow the "administrators" group or the username "Admin", what would I change this to?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Flikr style image annotations
« Reply #78 on: October 20, 2008, 06:56:07 pm »

So if I want to allow the "administrators" group or the username "Admin", what would I change this to?

Simple way to give only the user "Admin" (with user id "1") access, replace it with:
Code: [Select]
if (USER_ID == "1"){

To give groups access, replace it with:
Code: [Select]
$group = mysql_result(cpg_db_query("
  SELECT g.group_name FROM {$CONFIG['TABLE_USERS']} u
  INNER JOIN {$CONFIG['TABLE_USERGROUPS']} g
  ON u.user_group = g.group_id
  WHERE u.user_id = ".USER_ID
),0);
if ($group == "Administrators" || $group == "other groups"){
Logged

ksawery

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 21
Re: Flikr style image annotations
« Reply #79 on: October 23, 2008, 01:17:53 pm »

Is in progress a new version with updates?
Logged
Pages: 1 2 3 [4] 5 6 7 8   Go Up
 

Page created in 0.06 seconds with 21 queries.