<?php
error_reporting(0);
include 'connect.php';
include 'functions.php';
include 'config.php';
$p=@$_GET['p'];
$p=valid_number($p);
$res=mysql_query("SELECT *
FROM `category`
WHERE `id`='$p'
LIMIT 1");
$arr = mysql_fetch_assoc($res);
$dec=urldecode($arr['array']);
$dec=unserialize($dec);
$f=$_GET['f'];
$f=valid_number($f);
$theme = $dec[$f];
include 'tar.php';
$size = 100;
$archive = new Archive_Tar($theme);
if(!$deskside_file=$archive -> extractInString ('Theme.xml'))
{
$list = $archive->listContent();
$all = sizeof($list);
for($i=0; $i<$all; ++$i)
{
if(pathinfo($list[$i]['filename'],PATHINFO_EXTENSION) == 'xml')
{ $deskside_file=$archive -> extractInString($list[$i]['filename']);
break;
}
}
}
$image_puth = simplexml_load_string($deskside_file)-> Standby_image['Source'] or
simplexml_load_string($deskside_file)-> Desktop_image['Source'];
$image_string = $archive -> extractInString($image_puth);
$resource = imagecreatefromstring($image_string);
if ($resource){
$width = imageSX($resource);
$height = imageSY($resource);
$image = imagecreatetruecolor($size,$size);
if ( $width > $height )
{imagecopyresampled( $image, $resource, 0, 0, round( ( max( $width, $height ) - min( $width, $height ) ) / 2 ), 0, $size, $size, min( $width, $height ), min( $width, $height ) );}
if ( $width < $height )
{imagecopyresampled( $image, $resource, 0, 0, 0, 0, $size, $size, min( $width, $height ), min( $width, $height ) );}
if ( $width == $height )
{imagecopyresampled( $image, $resource, 0, 0, 0, 0, $size, $size, $width, $width );}
header("Content-type:image/jpeg");
imagejpeg($image);
imagedestroy( $image );
}
?>