Index: /extensions/hotblocker/admin/hb_admin.php
===================================================================
--- /extensions/hotblocker/admin/hb_admin.php	(revision 3699)
+++ /extensions/hotblocker/admin/hb_admin.php	(revision 3699)
@@ -0,0 +1,31 @@
+<?php
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+$me = get_plugin_data($plugin_id);
+$me->list_path_of_real_cat();
+$me->init('./galleries/');
+global $template;
+
+$template->set_filenames( array('plugin_admin_content' => dirname(__FILE__).'/hb_admin.tpl') );
+$template->assign( 'HB_VERSION' , HB_VERSION );
+
+if ( isset($_POST['submit']) )
+{
+	if ((isset($_POST['HB_active']))&&($_POST['HB_active']="on"))
+	{
+		$template->assign('HB_ACTIVE','checked');
+		$me->hotblock_dir('./galleries/',0);
+	}
+	else
+	{
+		$me->hotfree_dir('./galleries/',0);
+	}
+}
+else
+{
+	if ($me->etat == "on") {
+		$template->assign('HB_ACTIVE','checked');
+	}
+}
+load_language('plugin.lang', HB_PATH);
+$template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content');
+?>
Index: /extensions/hotblocker/admin/hb_admin.tpl
===================================================================
--- /extensions/hotblocker/admin/hb_admin.tpl	(revision 3699)
+++ /extensions/hotblocker/admin/hb_admin.tpl	(revision 3699)
@@ -0,0 +1,18 @@
+<div class="titrePage"><h2>HotBlocker<br />{$HB_VERSION}</h2></div>
+<p>{'hb_description'|@translate}<br /><img src="{$ROOT_URL}plugins/hotblocker/img/bloked.gif"><br />{'hb_description2'|@translate}</p>
+<p><i>{'hb_aide'|@translate}</i></p>
+
+<form method="post" action="" class="properties">
+<fieldset>
+	
+	<ul align="center">
+		<li>
+			<span class="property">
+				<label>{'hb_protect'|@translate}</label>
+			</span>
+			<input type="checkbox" {$HB_ACTIVE} name="HB_active"/>
+		</li>
+	</ul>
+	<div align="center"><input class="submit" type="submit" value="{'hb_submit'|@translate}" name="submit" /></div>
+</fieldset>
+</form>
Index: /extensions/hotblocker/admin/index.php
===================================================================
--- /extensions/hotblocker/admin/index.php	(revision 3699)
+++ /extensions/hotblocker/admin/index.php	(revision 3699)
@@ -0,0 +1,33 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery                           |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
+// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
+// | last modifier : $Author: rub $
+// | revision      : $Revision: 1912 $
+// +-----------------------------------------------------------------------+
+// | 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                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /extensions/hotblocker/img/index.php
===================================================================
--- /extensions/hotblocker/img/index.php	(revision 3699)
+++ /extensions/hotblocker/img/index.php	(revision 3699)
@@ -0,0 +1,33 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery                           |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
+// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
+// | last modifier : $Author: rub $
+// | revision      : $Revision: 1912 $
+// +-----------------------------------------------------------------------+
+// | 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                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /extensions/hotblocker/index.php
===================================================================
--- /extensions/hotblocker/index.php	(revision 3699)
+++ /extensions/hotblocker/index.php	(revision 3699)
@@ -0,0 +1,33 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery                           |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
+// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
+// | last modifier : $Author: rub $
+// | revision      : $Revision: 1912 $
+// +-----------------------------------------------------------------------+
+// | 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                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /extensions/hotblocker/language/en_UK/index.php
===================================================================
--- /extensions/hotblocker/language/en_UK/index.php	(revision 3699)
+++ /extensions/hotblocker/language/en_UK/index.php	(revision 3699)
@@ -0,0 +1,30 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery                                  |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008      Piwigo Team                  http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | 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                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /extensions/hotblocker/language/en_UK/plugin.lang.php
===================================================================
--- /extensions/hotblocker/language/en_UK/plugin.lang.php	(revision 3699)
+++ /extensions/hotblocker/language/en_UK/plugin.lang.php	(revision 3699)
@@ -0,0 +1,30 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery                                  |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008      Piwigo Team                  http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | 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                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+$lang['hb_description'] = 'Create an ".htaccess" file in "galleries" directory to block "hot linking" : <br />Protected pics will be replaced by :';
+$lang['hb_description2']= 'But allow hotlink for thumbnails by creating an ".htaccess" file in each "thumbnail" directory';
+$lang['hb_submit'] 		= 'Save';
+$lang['hb_aide'] 		= 'Info :<br />Delete or deactivate the plugin won\'t erase the ".htaccess" files<br />when creating a new real category, you need to protect your gallery again.<br />';
+$lang['hb_protect'] 	= 'Protect';
+
+?>
Index: /extensions/hotblocker/language/fr_FR/index.php
===================================================================
--- /extensions/hotblocker/language/fr_FR/index.php	(revision 3699)
+++ /extensions/hotblocker/language/fr_FR/index.php	(revision 3699)
@@ -0,0 +1,30 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery                                  |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008      Piwigo Team                  http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | 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                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /extensions/hotblocker/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/hotblocker/language/fr_FR/plugin.lang.php	(revision 3699)
+++ /extensions/hotblocker/language/fr_FR/plugin.lang.php	(revision 3699)
@@ -0,0 +1,30 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery                                  |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008      Piwigo Team                  http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | 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                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+$lang['hb_description'] = 'Créer un fichier ".htaccess" dans le repertoire gallerie pour empêcher le "hot linking" : <br />Les photos protégées seront remplacées par :';
+$lang['hb_description2']= 'Mais autorise le hotlink des miniatures en créant un fichier ".htaccess" dans chaque repertoire "thumbnail"';
+$lang['hb_submit'] 		= 'Enregistrer';
+$lang['hb_aide'] 		= 'Note :<br />Supprimer le plugin sans déprotéger les répertoires ne supprime pas les fichiers ".htaccess".<br />Après l\'ajout de categorie physique, il faudra reprotéger la galerie.<br />';
+$lang['hb_protect'] 	= 'Protéger';
+
+?>
Index: /extensions/hotblocker/language/index.php
===================================================================
--- /extensions/hotblocker/language/index.php	(revision 3699)
+++ /extensions/hotblocker/language/index.php	(revision 3699)
@@ -0,0 +1,30 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery                                  |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008      Piwigo Team                  http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | 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                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /extensions/hotblocker/main.inc.php
===================================================================
--- /extensions/hotblocker/main.inc.php	(revision 3699)
+++ /extensions/hotblocker/main.inc.php	(revision 3699)
@@ -0,0 +1,99 @@
+<?php
+/*
+Plugin Name: HotBloker
+Version: 2.0
+Description: this plugin creates .htaccess files in your './galleries/' directory to disallow "hotlink" to your pics, BUT not for your thumbnails (so rss feed still works !!) :
+Plugin URI: http://piwigo.org/ext/extension_view.php?eid=291
+Author: repie38
+Author URI: http://www.pierre-b.com
+*/
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+DEFINE('HB_VERSION','v2.0');
+define('HB_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
+
+class HB
+{
+	var $etat;
+	var $real_cat;
+    function init($dir) {
+    	if (file_exists($dir.'/.htaccess')) {
+    		$this->etat="on";
+    		 foreach ($this->real_cat as $cat) {
+		    	$this->etat = ((file_exists($cat.'/thumbnail/.htaccess')) and ( $this->etat=="on" )) ? "on" : "off" ;
+		    }
+    	}
+    	else {
+    		$this->etat="off";
+    	}
+    }
+
+	function hotblock_dir($dir,$tn)
+	{
+		$htaccess_content ="RewriteEngine on \n";
+		$htaccess_content.="RewriteCond %{HTTP_REFERER} !^$ \n";
+		$htaccess_content.="RewriteCond %{HTTP_REFERER} !^"."http://".$_SERVER["HTTP_HOST"]."/".".*$ [NC] \n";
+		$htaccess_content.="RewriteRule .*\.*$ " . get_absolute_root_url(1) . "plugins/hotbloker/img/bloked.gif [NC] \n";
+
+		if ($tn) {
+			$htaccess_content = "RewriteEngine on \n";
+			$htaccess_content.= "RewriteRule ^.*$ -";
+		}
+	    $file = fopen( $dir.'/.htaccess', 'w' );
+
+	    fwrite($file, $htaccess_content );
+	    fclose( $file );
+	    if (!$tn) {
+		    foreach ($this->real_cat as $cat) {
+		    	//hotfree_dir($cat);
+		    	if (file_exists($cat.'/thumbnail')) $this->hotblock_dir($cat.'/thumbnail',1);
+		    }
+	    }
+    }
+
+	function hotfree_dir($dir,$tn)
+	{
+		if (file_exists($dir.'/.htaccess'))
+		{
+			unlink($dir.'/.htaccess');
+		}
+		if (!$tn) {
+			foreach ($this->real_cat as $cat) {
+		   		$this->hotfree_dir($cat.'/thumbnail',1);
+			}
+		}
+    }
+
+
+    function plugin_admin_menu($menu)
+    {
+        array_push($menu,
+            array(
+                'NAME' => 'HotBlocker',
+                'URL' => get_admin_plugin_menu_link(dirname(__FILE__).'/admin/hb_admin.php')
+            )
+        );
+        return $menu;
+    }
+
+    function list_path_of_real_cat()
+	{
+	  $list="";$real_cat=array();
+	  $query = 'SELECT `id` FROM '.CATEGORIES_TABLE.' WHERE `dir` != \'NULL\';';
+	  $cat = pwg_query($query);
+	  if (empty($cat))
+	    return null;
+
+	  while ($row=mysql_fetch_row($cat)) {
+	  	array_push($real_cat,$row[0]);
+	  }
+	  $this->real_cat = get_fulldirs($real_cat);
+	}
+}
+
+
+$obj = new HB();
+add_event_handler('get_admin_plugin_menu_links', array(&$obj, 'plugin_admin_menu') );
+set_plugin_data($plugin['id'], $obj)
+
+?>
