<?

/* ------------------------------------------------------------------- */
/*

*************************************************
*			UWAGA! SKRYPT NIE JEST DARMOWY.			*
*		DALSZE ROZPOWSZECHNIANIE BEZ ZGODY 			*
*			FIRMY ArtGlobal JEST ZABRONIONE.			*
*************************************************

*************************************************
*	WWW.ArtGlobal.PL		PRODUCENT OPROGRAMOWANIA	*
*	NAZWA SKRYPTU:		NIERUCHOMOSCI 6.0			*
*	WERSJA FINALNA:	04.10.2010						*
*	KONTAKT:				kontakt@artglobal.pl			*
*************************************************

Copyright (c) 2010 ArtGlobal. Wszelkie prawa zastrzeżone.

*/
/* ------------------------------------------------------------------- */

$smarty -> assign('ob', '');

$url = $_SERVER['REQUEST_URI'];
$smarty -> assign('url', $url);

if ( $_GET['act'] == 'accept' )
{
        $id = $_GET['id'];
        $sql = "UPDATE `object` SET `obConfirm` = '1' WHERE obId = '$id'";
        mysql_query( $sql );
        $smarty -> assign('success', 'Poprawnie zatwierdzono obiekt!');
}

if ( $_GET['act'] == 'delete' )
{
        $id = $_GET['id'];
        $sql = "SELECT photoUrl FROM photos WHERE photoObjectId = '$id'";
        $q = mysql_query( $sql );
        
        while ( $db = mysql_fetch_array( $q  ) )
        {
                @unlink('../files/photo/mini/' . $db[0]);
                @unlink('../files/photo/big/' . $db[0]);

				@unlink('../files/photo/sre/'  . $db[0]);
				@unlink('../files/photo/duz/'  . $db[0]);
				@unlink('../files/photo/top/'  . $db[0]);
        }
        
        $sql = "DELETE FROM photos WHERE photoObjectId = '$id'";
        mysql_query( $sql );
        
        $sql = "DELETE FROM object WHERE obId = '$id'";
        mysql_query( $sql );
        
        $smarty -> assign('success', 'Poprawnie usunięto obiekt!');
}

$n = '30';
$sql = "SELECT a.*, b.*, c.*, d.userName FROM object AS a, type AS b, state AS c, users AS d WHERE a.obTypeId = b.typeId AND a.obStateId = c.stateId AND a.obUserId = d.userId";
$q = mysql_query( $sql );
$num = mysql_num_rows( $q );
$smarty -> assign('num', $num);
$p = new Pager('kat', $num, $n, '100');
$p -> setVar("html_link", "<a href=\"administrator.php?mod=object&site={^link}\">{^name}</a>\n");
$p -> Render();
$start = $p -> startRecord();

$sql = "SELECT a.*, b.*, c.*, d.userName FROM object AS a, type AS b, state AS c, users AS d WHERE a.obTypeId = b.typeId AND a.obStateId = c.stateId AND a.obUserId = d.userId ORDER by a.obId DESC LIMIT $start, $n";
$q = mysql_query( $sql );
$object = array();

while ( $db = mysql_fetch_array( $q ) )
{
        $object[] = $db;
}
$smarty -> assign('object', $object);

$str = $p -> getVar("html_out");
$smarty->assign('str', $str);
?>
