Location: PHPKode > scripts > Simple Hook and Plug-ins System (XML) > hook.php
<?php

/*

Hook & Plugins class
programming By Mohammed Cherkaoui
Duhok-hide@address.com

*/

ob_start();
@mysql_connect('localhost', 'root', '') or die(mysql_error());
@mysql_select_db('hacks') or die(mysql_error());

class products
{



var $File_Patch = '';

var $error;

var $product_table = 'products';

var $plugin_table = 'plugins';

var $export_productid;

var $xml_encoding = 'windows-1256';

	function products($File_Patch = '')
	{
	$this->File_Patch = $File_Patch;
	}

	
	function Import()
	{
	if(! file_exists($this->File_Patch))
	{
	$this->error = 'File not found !';
	return false;
	} else
	{
	$Xml = simplexml_load_file($this->File_Patch);
	// Insert The Product
	@mysql_query("insert into ".$this->product_table." set
	title = '".$Xml->setting[0]->title."',
	version = '".$Xml->setting[0]->version."',
	url = '".$Xml->setting[0]->version."',
	description = '".$Xml->setting[0]->description."',
	installcode = '".addslashes($Xml->setting[0]->installcode)."',
	unistallcode = '".addslashes($Xml->setting[0]->unistallcode)."'
	") or die(mysql_error());
	eval($Xml->setting[0]->installcode);
	// Get The product id
	$sql = @mysql_query("select productid from ".$this->product_table." order by productid desc limit 1") or die(mysql_error());
	$Productinfo = @mysql_fetch_array($sql);
	// Insert the plugins
	
	
	for($i = 0;$i < count($Xml->plugin);++$i):
	@mysql_query("insert into ".$this->plugin_table." set
	productid = '".intval($Productinfo['productid'])."',
	place = '".$Xml->plugin[$i]->place."',
	title = '".$Xml->plugin[$i]->title."',
	phpcode = '".addslashes($Xml->plugin[$i]->phpcode)."',
	status = '".intval($Xml->plugin[$i]->status)."'
	") or die(mysql_error());
	endfor;
	
	return true;
	}
	}

	function SetProductId($Productid)
	{
	$this->export_productid = $Productid;
	}
	
	function Export()
	{
	if(empty($this->export_productid))
	{
	$this->error = 'Product id is empty !';
	return false;
	} elseif(! empty($this->export_productid))
	{
	if(! is_numeric($this->export_productid))
	{
	$this->error = 'Product id must be numeric !';
	return false;
	} elseif(is_numeric($this->export_productid) == true)
	{
	$sql = @mysql_query("select * from ".$this->product_table." 
			where productid = '".intval($this->export_productid)."'") or die(mysql_error());
	if(mysql_num_rows($sql) == 0)
	{
	$this->error = 'Selected product not found !';
	return false;
	} else
	{
	$Productinfo = mysql_fetch_array($sql);
	@mysql_free_result($sql);
	$Output = '<?xml version="1.0" encoding="'.$this->xml_encoding.'"?>';
	$Output .= '
<product>

<setting>
<title>'.$Productinfo['title'].'</title>
<description>'.$Productinfo['description'].'</description>
<version>'.$Productinfo['version'].'</version>
<url>'.$Productinfo['url'].'</url>
<installcode>
<![CDATA['.stripslashes($Productinfo['installcode']).']]>
</installcode>
<unistallcode>
<![CDATA['.$Productinfo['unistallcode'].']]>
</unistallcode>
</setting>
';
	$sql_plugins = @mysql_query("select * from ".$this->plugin_table." where
															productid = '".intval($this->export_productid)."'
																			") or die(mysql_error());
if(mysql_num_rows($sql_plugins) > 0)
{
$Plugininfo = @mysql_fetch_array($sql_plugins);
$Output .= '
<plugin>
<title>'.$Plugininfo['title'].'</title>
<place>'.$Plugininfo['place'].'</place>
<phpcode><![CDATA['.stripslashes($Plugininfo['phpcode']).']]></phpcode>
<status>'.$Plguininfo['status'].'</status>
</plugin>
';
}		
		$Output .= '
		
		</product>';
		$this->DownloadXml($Output, $Productinfo['title']);
		unset($Output, $Productinfo, $Plguininfo);
	}
	}
	}
	}
	
	function DownloadXml($Output, $filename = 'unknown')
	{
	$filename = @iconv('utf-8', 'windows-1256', $filename);
	$Output = @iconv('utf-8', 'windows-1256', $Output);
	header('Content-Type: text/xml'); 
	header("Content-length: ".strlen($Output));
	header("Content-Disposition: attachment; filename=$filename.xml");
	echo $Output;
	exit;
	}
	
	// the next function mean delete
	function Unistall($ProductId)
	{
	@mysql_query("delete from ".$this->product_table." where productid = '".intval($ProductId)."'");
	@mysql_query("delete from ".$this->plugin_table." where productid = '".intval($ProductId)."'");
	}
	
	function eval_plugins($Place)
	{
	$sql = @mysql_query("select * from ".$this->plugin_table." where place = '$Place' and status = '1'") or die(mysql_error());
	if(mysql_num_rows($sql) == 0)
	{
	return '';
	} else
	{
		while($Plugin = mysql_fetch_array($sql)):
		eval(stripslashes($Plugin['phpcode']));
		endwhile;
		@mysql_free_result($sql);
	}
	}
	
	function ArLastError()
	{
	switch($this->error):
	case 'File not found !':
	$return = '&#1575;&#1604;&#1605;&#1604;&#1601; &#1594;&#1610;&#1585; &#1605;&#1608;&#1580;&#1608;&#1583;';
	break;
	case 'Product id is empty !':
	$return = '&#1585;&#1602;&#1605; &#1575;&#1604;&#1605;&#1606;&#1578;&#1580; &#1601;&#1575;&#1585;&#1594;';
	break;
	case 'Product id must be numeric !':
	$return = '&#1610;&#1580;&#1576; &#1571;&#1606; &#1610;&#1603;&#1608;&#1606; &#1585;&#1602;&#1605; &#1575;&#1604;&#1605;&#1606;&#1578;&#1580; &#1605;&#1603;&#1608;&#1606;&#1575; &#1605;&#1606; &#1571;&#1585;&#1602;&#1575;&#1605; &#1601;&#1602;&#1591;';
	break;
	case 'Selected product not found !':
	$return = '&#1575;&#1604;&#1605;&#1606;&#1578;&#1580; &#1575;&#1604;&#1605;&#1581;&#1583;&#1583; &#1594;&#1610;&#1585; &#1605;&#1608;&#1580;&#1608;&#1583;';
	break;
	endswitch;
	return $return;
	}
	
	function EnLastError()
	{
	return $this->error;
	}
	
	
	
}


?>
Return current item: Simple Hook and Plug-ins System (XML)