<?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 = 'الملف غير موجود';
break;
case 'Product id is empty !':
$return = 'رقم المنتج فارغ';
break;
case 'Product id must be numeric !':
$return = 'يجب أن يكون رقم المنتج مكونا من أرقام فقط';
break;
case 'Selected product not found !':
$return = 'المنتج المحدد غير موجود';
break;
endswitch;
return $return;
}
function EnLastError()
{
return $this->error;
}
}
?>