[HELP] write downloader's IP in FLAC tag

Post Reply
forart
User
Posts: 2
Joined: Sat Apr 04, 2015 6:03 pm
Are you a spambot?: no

[HELP] write downloader's IP in FLAC tag

Post by forart » Mon Apr 06, 2015 8:16 am

Hi there, we're an EU noprofit organization devoted to spread emerging artists' works through internet.

We're going to publish our affiliated artists' productions in FLAC format for free, but we want to "watermark" downloaded files with downloader's IP and download date as tags.

We tried with this code:

Code: Select all

require_once('../classes/getid3/getid3.php');
require_once('../classes/getid3/write.php');
require_once('../classes/getid3/write.metaflac.php');

$getID3 = new getID3;
$getID3->setOption(array('encoding'=>$TaggingFormat));
	
$tagwriter = new getid3_writetags;

$tagwriter->filename = $filename;
$tagwriter->tagformats = array('metaflac');

$tagwriter->overwrite_tags = false;
$tagwriter->tag_encoding = $TaggingFormat;
$tagwriter->remove_other_tags = false;

// write IP as tag
if(isset($_SERVER["REMOTE_ADDR"]) ) {
	$TagData['downloader'][] = $_SERVER["REMOTE_ADDR"];
}
else if(isset($_SERVER["HTTP_X_FORWARDED_FOR"]) ) {
	$TagData['downloader'][] = $_SERVER["HTTP_X_FORWARDED_FOR"];
}
else if(isset($_SERVER["HTTP_CLIENT_IP"]) ) {
	$TagData['downloader'][] = $_SERVER["HTTP_CLIENT_IP"];
} 
else {};

$TagData['downdate'][] = date('Y/m/d');
	
$tagwriter->tag_data = $TagData;
}
The script runs without errors, but it don't writes anything inside the file(s).

Can you please tell us where we're wrong ?

Note that the tags "downloader" and "downdate" are not present in server's FLAC file(s): do we have to create it before upload ?

James Heinrich
getID3() v1 developer
Posts: 1477
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: [HELP] write downloader's IP in FLAC tag

Post by James Heinrich » Mon Apr 06, 2015 12:46 pm

The first thing that jumps out at me is that you're preparing the tag data, but I don't see you actually writing it anywhere. Continuing from /demos/demo.write.php, this code should follow what you have above:

Code: Select all

if ($tagwriter->WriteTags()) {
	echo 'Successfully wrote tags<br>';
	if (!empty($tagwriter->warnings)) {
		echo 'There were some warnings:<ul><li>'.implode('</li><li>', $tagwriter->warnings).'</li></ul>';
	}
} else {
	echo 'Failed to write tags!<ul><li>'.implode('</li><li>', $tagwriter->errors).'</li></ul>';
}

forart
User
Posts: 2
Joined: Sat Apr 04, 2015 6:03 pm
Are you a spambot?: no

Re: [HELP] write downloader's IP in FLAC tag

Post by forart » Tue Apr 07, 2015 5:26 am

Done.

Now gives me another error (and don't write tags into to files):
Warning: shell_exec() has been disabled for security reasons in /web/htdocs/www.forart.it/home/classes/getid3/write.metaflac.php on line 85
So this means that I can't use it on my webspace ?

James Heinrich
getID3() v1 developer
Posts: 1477
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: [HELP] write downloader's IP in FLAC tag

Post by James Heinrich » Wed Apr 08, 2015 5:40 pm

If you can't call metaflac for writing tags, you can't write tags, sorry.

Post Reply