<? 



// Copyright by Mateusz Rusin C 2005 // 1.38
ini_set ('max_execution_time', 9999);
ini_set ('register_globals', 'Off');
require ('class.php');
require ('simple_db_edit.class.php');
$admin = new Page ();
if (empty ($_SESSION ['user']) || ($_SESSION ['user'] -> user_category != 'admin' && $_SESSION ['user'] -> user_category != 'editor')) 
{
	header('Location: ./login.htm'); 
	die ();
//	die ('<body onLoad="javascript: window.close()">');
}
$id = !empty ($_GET ['id']) ? $_GET ['id'] : false;
$order = !empty ($_GET ['order']) ? $_GET ['order'] : false;
$form =& new simple_db_edit ($admin -> db, $admin -> ini, $admin -> language);
/*$admin -> text .= '
<!-- TinyMCE -->
<script language="javascript" type="text/javascript" src="/tiny_mce/tiny_mce_src.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
	mode : "textareas",
	language : "' . $admin -> language . '",
	theme : "advanced",
	theme_advanced_toolbar_location : "top",
	entity_encoding : "raw"
});
</script>
<!-- /TinyMCE -->
';*/
switch ($admin -> page_id)
{
	case 'admin_menu':
		if ($_SESSION ['user'] -> user_category == 'admin' || $_SESSION ['user'] -> user_category == 'editor')
			$form -> set_delete ();		
		$form -> update ('menu', 'menu_id');
		$form -> set_order_menu ($order);
		$condition = !empty ($form -> insert_id) 
			? '`menu_id` = ' . $form -> insert_id 
			: 
				(
					isset ($_GET ['id']) && $_GET ['id'] != 'all' 
						? '`menu_id` = ' . (int) $_GET ['id']
						: ''
				);
		if ($_SESSION ['user'] -> user_category != 'admin')
			$condition .= $condition ? " and `rights` like '%{$admin -> user_category}%'" : "`rights` like '%{$admin -> user_category}%'";
		$form -> set_result 
		(
			$form -> db -> select 
			(
				'menu', 
				$condition, 
				'*', 
				($order ? $order : 'parent_id, position, menu_id, page_id'),
				'desc'
			)
		);
//		$result = $form -> db -> select ('menu', "`rights` like '%{$admin -> user_category}%'" . ($id ? " and `menu_id` = $id" : ''), '*', (!$id && $order ? $order : 'parent_id, position, menu_id'));
//		$form -> set_result ($result);
		if ($id)
			$form -> set_default_value ('parent_id', $id);
		$menu_menu [] = array ('value' => 0, 'name' => '&mdash; root &mdash;');
		$menu_result = $form -> db -> select ('menu', "`rights` like '%{$admin -> user_category}%'", '*', 'parent_id, position, menu_id');
		while ($menu_element = $form -> db -> fetch_object ($menu_result))
			$menu_menu [] = array ('value' => $menu_element -> menu_id, 'name' => $menu_element -> menu_id . ' &ndash; ' . $menu_element -> {'legend_' . $admin -> language} . (!empty ($menu_element -> page_id ) ? ' (' . $menu_element -> page_id  . ')' : ''));
		$form -> set_select_menu ('parent_id', $menu_menu, 1);
		$form -> set_default_value ('position', 0);
		for ($i = -16; $i < 16; $i ++)
			$position_menu [] = array ('value' => $i, 'name' => $i);
		$form -> set_select_menu ('position', $position_menu, 1);
		$pages_result = $form -> db -> select ('pages', "`rights` like '%{$admin -> user_category}%'");
		$form -> set_default_value ('page_id', !empty ($_SESSION ['default_page_id']) ? $_SESSION ['default_page_id'] : $form -> ini -> get ('default_page_id'));
		while ($page_data = $form -> db -> fetch_object ($pages_result))
			$pages_menu [] = array ('value' => $page_data -> page_id, 'name' => $page_data -> page_id . (!empty ($page_data -> {'title_' . $admin -> language}) ? ' (' . $page_data -> {'title_' . $admin -> language} . ')' : ''));
		$form -> set_select_menu ('page_id', $pages_menu, 1);
		$form -> set_select_menu ('rights', array (array ('value' => 'admin', 'name' => 'admin'), array ('value' => 'editor', 'name' => 'editor'), array ('value' => 'author', 'name' => 'author'), array ('value' => 'press', 'name' => 'press'), array ('value' => 'guest', 'name' => 'guest')));
		$form -> unset_fields (array ('title_en', 'title_de', 'title_fr', 'text_en', 'text_de', 'text_fr', 'legend_en', 'legend_de', 'legend_fr'));
//editor
		if ($_SESSION ['user'] -> user_category != 'admin')
		{
			$form -> unset_fields (array ('modyfication_date', 'rights', 'news_set_id', 'template_variant'));
		}
		$admin -> text .= $form -> get ();
	break;
	case 'admin_pages':
		if ($_SESSION ['user'] -> user_category == 'admin' || $_SESSION ['user'] -> user_category == 'editor')
			$form -> set_delete ();		
		$form -> update ('pages', 'page_id');
//		$form -> set_result ($form -> db -> query ("select * from pages left join pages_photos using (page_id) where `rights` like '%{$admin -> user_category}%'" . ($id ? " and `pages`.`page_id` = '$id'" : '')));
		unset ($id);
		$id = !empty ($form -> insert_id) 
			? $form -> insert_id 
			: 
				(
					isset ($_GET ['id']) && $_GET ['id'] != 'all' 
						? $_GET ['id'] 
						: null
				);
		$condition = isset ($id) ? "`page_id` = '$id'" : '';
		$_SESSION ['default_page_id'] = $id;
		if ($_SESSION ['user'] -> user_category != 'admin')
			$condition .= $condition ? " and `rights` like '%{$admin -> user_category}%'" : "`rights` like '%{$admin -> user_category}%'";
		$form -> set_result 
		(
			$form -> db -> select 
			(
				'pages', 
				$condition, 
				'*', 
				($order ? $order : 'modyfication_date'),
				'desc'
			)
		);
//		$form -> set_result ($form -> db -> select ('pages', "`rights` like '%{$admin -> user_category}%'" . ($id ? " and `page_id` = '$id'" : '')));
		$form -> set_default_value ('user_id', $_SESSION ['user'] -> user_id);
		$users_menu [] = array ('value' => null, 'name' => '&mdash;');
		$users_result = $form -> db -> select ('users');
		while ($user_data = $form -> db -> fetch_object ($users_result))
			$users_menu [] = array ('value' => $user_data -> user_id, 'name' => $user_data -> user_id . (!empty ($user_data -> signature) ? ' (' . $user_data -> signature . ')' : ''));
		$form -> set_select_menu ('user_id', $users_menu, 1);
		$templates_result = $form -> db -> select ('templates');
		while ($template_data = $form -> db -> fetch_object ($templates_result))
			$templates_menu [] = array ('value' => $template_data -> template_id, 'name' => $template_data -> template_id . (!empty ($template_data -> {'title_' . $admin -> language}) ? ' (' . $template_data -> {'title_' . $admin -> language} . ')' : ''));
		$form -> set_select_menu ('template_variant', $templates_menu, 1);
/*		$photos_menu [] = array ('value' => 0, 'name' => '&mdash;');
		$photos_result = $form -> db -> select ('photos');
		while ($photo_data = $form -> db -> fetch_object ($photos_result))
			$photos_menu [] = array ('value' => $photo_data -> photo_id, 'name' => (!empty ($photo_data -> {'title_' . $admin -> language}) ? $photo_data -> {'title_' . $admin -> language} : '') . ' (' . $photo_data -> photo_id . ')');
		$form -> set_select_menu ('photo_id', $photos_menu, 1);
*/		$form -> set_select_menu ('rights', array (array ('value' => 'admin', 'name' => 'admin'), array ('value' => 'editor', 'name' => 'editor'), array ('value' => 'author', 'name' => 'author'), array ('value' => 'press', 'name' => 'press'), array ('value' => 'guest', 'name' => 'guest')));
		$news_sets_menu [] = array ('value' => null, 'name' => '&mdash;');
		$news_sets_result = $form -> db -> select ('news_sets');
		while ($news_set_data = $form -> db -> fetch_object ($news_sets_result))
			$news_sets_menu [] = array ('value' => $news_set_data -> news_set_id, 'name' => $news_set_data -> news_set_id . (!empty ($news_set_data -> news_set) ? ' (' . $news_set_data -> news_set . ')' : ''));
		$form -> set_select_menu ('news_set_id', $news_sets_menu, 1);
		$form -> set_datetime ('publication_date');
		$form -> set_select_menu 
			(
				'nl2br', 
				array 
					(
						array ('value' => 1, 'name' => 'on'),
						array ('value' => 0, 'name' => 'off'), 
					), 
				1
			);
		$form -> set_default_value ('nl2br', 1); 
//		$form -> set_checkbox ('nl2br');
		$form -> set_primary_key ('page_id');
		$form -> disable_field ('open_count');
		$form -> disable_field ('modyfication_date');
		$form -> unset_fields (array (/*'open_count', */'crawler_open_count'));
		$form -> unset_fields (array ('title_en', 'title_de', 'title_fr', 'text_en', 'text_de', 'text_fr', 'keywords_en', 'keywords_de', 'keywords_fr', 'abstract_en', 'abstract_de', 'abstract_fr' ));
//editor
		if ($_SESSION ['user'] -> user_category != 'admin')
		{
//			$form -> hide ('user_id');
			$form -> unset_fields (array ('modyfication_date', 'rights', 'news_set_id', 'template_variant'));
		}

		$admin -> text .= $form -> get ();
	break;
	case 'admin_photos':
		if ($_SESSION ['user'] -> user_category == 'admin' || $_SESSION ['user'] -> user_category == 'editor')
			$form -> set_delete ();		
		ini_set('memory_limit', '256M');
		$form -> update ('photos', 'photo_id');
		$form -> set_result ($form -> db -> select ('photos', !empty ($form -> insert_id) ? '`photo_id` = ' . $form -> insert_id : ($form -> db -> insert_id () ? '`photo_id` = ' . $form -> db -> insert_id () : (isset ($_GET ['id']) && $_GET ['id'] != 'all' ? '`photo_id` = ' . (int) $_GET ['id'] : '')), '*', (!$id && $order ? $order : 'photo_id')));
//		$form -> set_result ($form -> db -> select ('photos'));
		$form -> set_select_menu ('type', array (array ('value' => 'image/jpeg', 'name' => 'JPEG'), array ('value' => 'image/gif', 'name' => 'GIF')), 1);
		$form -> set_file_type ('type', 'photo');
		$form -> set_file_name ('title', 'photo');
//		$form -> set_photo ('photo', 'photo/?id=');
		$form -> set_photo ('photo', 'photo/?id=', false, array ('photo' => array ($form -> ini -> get ('photo_width'), $form -> ini -> get ('photo_height'))));
		$pages_result = $form -> db -> select ('pages', "`rights` like '%{$admin -> user_category}%'");
		$pages_menu [] = array ('value' => null, 'name' => '&mdash;');
		while ($page_data = $form -> db -> fetch_object ($pages_result))
			$pages_menu [] = array ('value' => $page_data -> page_id, 'name' => $page_data -> page_id . (!empty ($page_data -> {'title_' . $admin -> language}) ? ' (' . $page_data -> {'title_' . $admin -> language} . ')' : ''));
		$form -> set_select_menu ('page_id', $pages_menu, 1);
		$form -> ignore ('page_id');

		foreach ($form -> ignored as $id => $fields)
		{
			if ($id == 'add')
				$id = !empty ($form -> insert_id) ? $form -> insert_id : null;
			if (!empty ($fields ['page_id']))
			{
				$img_tag = '<img src="gfx/?id=' . $id . '" />';
				$form -> db -> query ("update `pages` set  
															`text_pl` = concat(`text_pl`, '\n$img_tag'),
															`text_en` = concat(`text_en`, '\n$img_tag'),
															`text_de` = concat(`text_de`, '\n$img_tag'),
															`text_fr` = concat(`text_fr`, '\n$img_tag')
															where `page_id` = '{$fields ['page_id']}'");
			}
		}
		$admin -> text .= $form -> get ();
	break;
	case 'admin_news':	
//editor
		if ($_SESSION ['user'] -> user_category != 'admin')
			$news_set_id = 1;
		if ($_SESSION ['user'] -> user_category == 'admin' || $_SESSION ['user'] -> user_category == 'editor')
			$form -> set_delete ();		
		$form -> update ('news', 'news_id');//echo'IS!<pre>'; var_dump ($_FILES);echo'WAS!</pre>'; 
		$condition = !empty ($form -> insert_id) 
			? '`news_id` = ' . $form -> insert_id 
			: 
				(
					isset ($_GET ['id']) && $_GET ['id'] != 'all' 
						? '`news_id` = ' . (int) $_GET ['id'] 
						: ''
				);
		if (!empty ($news_set_id))
			$condition .= $condition ? ' and `news_set_id` = ' . $news_set_id : '`news_set_id` = ' . $news_set_id;
		$form -> set_result 
		(
			$form -> db -> select 
			(
				'news', 
				$condition, 
				'*', 
				($order ? $order : 'publication_date'),
				'desc'
			)
		);
//		$form -> set_result ($form -> db -> select ('news', ($news_set_id ? array ('news_set_id' => $news_set_id) : ''), '*', 'news_set_id, publication_date desc'));
		$form -> set_select_menu 
			(
				'nl2br', 
				array 
					(
						array ('value' => 1, 'name' => 'on'),
						array ('value' => 0, 'name' => 'off'), 
					), 
				1
			);
		$form -> set_default_value ('nl2br', 1); 
		$form -> set_default_value ('user_id', $_SESSION ['user'] -> user_id);
		$users_menu [] = array ('value' => null, 'name' => '&mdash;');
		$users_result = $form -> db -> select ('users');
		while ($user_data = $form -> db -> fetch_object ($users_result))
			$users_menu [] = array ('value' => $user_data -> user_id, 'name' => $user_data -> user_id . (!empty ($user_data -> signature) ? ' (' . $user_data -> signature . ')' : ''));
		$form -> set_select_menu ('user_id', $users_menu, 1);
		$form -> set_file ('thumb', true);
		$form -> set_file ('full', true);
		$form -> set_file_type ('type', array ('thumb', 'full'));
		$form -> set_photo ('photo', 'news_photo/?id=', 'news_photo/?size=full&amp;id=', array ('thumb' => array ($form -> ini -> get ('news_photo_width'), $form -> ini -> get ('news_photo_heigh')), 'full' => array ($form -> ini -> get ('news_full_width'), $form -> ini -> get ('news_full_height'))));
		$form -> set_datetime ('publication_date');
		if (!empty ($news_set_id))
			$form -> set_default_value ('news_set_id', $news_set_id);
		else
			$form -> set_default_value ('news_set_id', 1);
//editor
		if ($_SESSION ['user'] -> user_category != 'admin')
		{
			$form -> hide ('news_set_id');
//			$form -> hide ('user_id');
			$form -> unset_fields (array ('thumb', 'full'));
		}
		else
		{
			$news_sets_menu [] = array ('value' => null, 'name' => '&mdash;');
			$news_sets_result = $form -> db -> select ('news_sets');
			while ($news_set_data = $form -> db -> fetch_object ($news_sets_result))
				$news_sets_menu [] = array ('value' => $news_set_data -> news_set_id, 'name' => $news_set_data -> news_set_id . (!empty ($news_set_data -> news_set) ? ' (' . $news_set_data -> news_set . ')' : ''));
			$form -> set_select_menu ('news_set_id', $news_sets_menu, 1);
		}

		$form -> unset_fields (array ('thumb', 'full', 'link_pl', 'link_en', 'link_de', 'link_fr', 'modyfication_date', 'open_count', 'crawler_open_count'));
		$form -> unset_fields (array ('title_en', 'title_de', 'title_fr', 'text_en', 'text_de', 'text_fr'));
		$admin -> text .= $form -> get (false, isset ($_GET ['id']) && $_GET ['id'] == 'all' ? false : true);
	break;
	case 'admin_promo':	
//editor
		$news_set_id = 2;
		if ($_SESSION ['user'] -> user_category == 'admin' || $_SESSION ['user'] -> user_category == 'editor')
			$form -> set_delete ();		
		$form -> update ('news', 'news_id');//echo'IS!<pre>'; var_dump ($_FILES);echo'WAS!</pre>'; 
		$condition = !empty ($form -> insert_id) 
			? '`news_id` = ' . $form -> insert_id 
			: 
				(
					isset ($_GET ['id']) && $_GET ['id'] != 'all' 
						? '`news_id` = ' . (int) $_GET ['id'] 
						: ''
				);
		if (!empty ($news_set_id))
			$condition .= $condition ? ' and `news_set_id` = ' . $news_set_id : '`news_set_id` = ' . $news_set_id;
		$form -> set_result 
		(
			$form -> db -> select 
			(
				'news', 
				$condition, 
				'*', 
				($order ? $order : 'publication_date'),
				'desc'
			)
		);
//		$form -> set_result ($form -> db -> select ('news', ($news_set_id ? array ('news_set_id' => $news_set_id) : ''), '*', 'news_set_id, publication_date desc'));
		$form -> set_select_menu 
			(
				'nl2br', 
				array 
					(
						array ('value' => 1, 'name' => 'on'),
						array ('value' => 0, 'name' => 'off'), 
					), 
				1
			);
		$form -> set_default_value ('nl2br', 1); 
		$form -> set_default_value ('user_id', $_SESSION ['user'] -> user_id);
		$users_menu [] = array ('value' => null, 'name' => '&mdash;');
		$users_result = $form -> db -> select ('users');
		while ($user_data = $form -> db -> fetch_object ($users_result))
			$users_menu [] = array ('value' => $user_data -> user_id, 'name' => $user_data -> user_id . (!empty ($user_data -> signature) ? ' (' . $user_data -> signature . ')' : ''));
		$form -> set_select_menu ('user_id', $users_menu, 1);
		$form -> set_file ('thumb', true);
		$form -> set_file ('full', true);
		$form -> set_file_type ('type', array ('thumb', 'full'));
		$form -> set_photo ('photo', 'news_photo/?id=', 'news_photo/?size=full&amp;id=', array ('thumb' => array ($form -> ini -> get ('news_photo_width'), $form -> ini -> get ('news_photo_heigh')), 'full' => array ($form -> ini -> get ('news_full_width'), $form -> ini -> get ('news_full_height'))));
		$form -> set_datetime ('publication_date');
		if (!empty ($news_set_id))
			$form -> set_default_value ('news_set_id', $news_set_id);
		else
			$form -> set_default_value ('news_set_id', 1);
//editor
		if ($_SESSION ['user'] -> user_category != 'admin')
		{
			$form -> hide ('news_set_id');
//			$form -> hide ('user_id');
			$form -> unset_fields (array ('thumb', 'full'));
		}
		else
		{
			$news_sets_menu [] = array ('value' => null, 'name' => '&mdash;');
			$news_sets_result = $form -> db -> select ('news_sets');
			while ($news_set_data = $form -> db -> fetch_object ($news_sets_result))
				$news_sets_menu [] = array ('value' => $news_set_data -> news_set_id, 'name' => $news_set_data -> news_set_id . (!empty ($news_set_data -> news_set) ? ' (' . $news_set_data -> news_set . ')' : ''));
			$form -> set_select_menu ('news_set_id', $news_sets_menu, 1);
		}

		$form -> unset_fields (array ('link_pl', 'link_en', 'link_de', 'link_fr', 'modyfication_date', 'open_count', 'crawler_open_count'));
		$form -> unset_fields (array ('title_en', 'title_de', 'title_fr', 'text_en', 'text_de', 'text_fr'));
		$admin -> text .= $form -> get (false, isset ($_GET ['id']) && $_GET ['id'] == 'all' ? false : true);
	break;
	case 'admin_skins':
		if ($_SESSION ['user'] -> user_category == 'admin')
			$form -> set_delete ();		
		$form -> update ('skins', 'skin_id');
		$form -> set_result ($form -> db -> select ('skins'));
		$css_menu [] = array ('value' => null, 'name' => '&mdash;');
		$css_result = $form -> db -> select ('css');
		while ($css = $form -> db -> fetch_object ($css_result))
			if ($css -> css_id != 1)
				$css_menu [] = array ('value' => $css -> css_id, 'name' => $css -> css_id);
		$form -> set_select_menu ('css_id', $css_menu, 1);
		$form -> set_select_menu ('css_gecko_id', $css_menu, 1);
		$form -> set_select_menu ('css_opera_id', $css_menu, 1);
		$form -> set_select_menu ('css_msie_id', $css_menu, 1);
		$templates_result = $form -> db -> select ('templates');
		while ($template = $form -> db -> fetch_object ($templates_result))
			$templates_menu [] = array ('value' => $template -> template_id, 'name' => $template -> template_id);
		$form -> set_select_menu ('template_id', $templates_menu, 1);
		$admin -> text .= $form -> get ();
	break;
	case 'admin_sets':
		if ($_SESSION ['user'] -> user_category == 'admin')
			$form -> set_delete ();		
		$form -> update ('news_sets', 'news_set_id');
		$form -> set_result ($form -> db -> select ('news_sets'));
		$form -> set_name ('news_set', 'class');
		$admin -> text .= $form -> get ();
	break;
	case 'admin_templates':
		if ($_SESSION ['user'] -> user_category == 'admin')
			$form -> set_delete ();		
		$form -> update ('templates', 'template_id');
		$form -> set_result ($form -> db -> select ('templates'));
		//$form -> set_file ('template');
		$admin -> text .= $form -> get ();
	break;
	case 'admin_css':
		if ($_SESSION ['user'] -> user_category == 'admin')
			$form -> set_delete ();		
		$form -> update ('css', 'css_id');
		$form -> set_result ($form -> db -> select ('css'));
		$admin -> text .= $form -> get ();
	break;
	case 'admin_ini':
		if ($_SESSION ['user'] -> user_category == 'admin')
			$form -> set_delete ();		
		$form -> update ('ini', 'key');
		$form -> set_result ($form -> db -> select ('ini'));
		$admin -> text .= $form -> get ();
	break;
	case 'admin_extensions':
		if ($_SESSION ['user'] -> user_category == 'admin')
			$form -> set_delete ();		
		$form -> update ('extensions', 'extension');
		$form -> set_result ($form -> db -> select ('extensions'));
		$admin -> text .= $form -> get ();
	break;
	case 'admin_users':
//		$admin -> text .= '<h2 class="top_frame">user accounts admin</h2><div class="form_frame">';
		if ($_SESSION ['user'] -> user_category == 'admin')
			$form -> set_delete ();		
		$form -> update ('users', 'user_id');
		$form -> set_result 
		(
			$form -> db -> select 
			(
				'users', 
				(!empty ($_POST ['add'] ['user_id']) ? "`user_id` = '" . $_POST ['add'] ['user_id'] . "'" : (isset ($_GET ['id']) && $_GET ['id'] != 'all' ? "`user_id` = '" . $_GET ['id'] . "'" : '')), 
				'*', 
				($order ? $order : 'user_id'),
				'asc'
			)
		);
//		$form -> set_result ($form -> db -> select ('users', isset ($_GET ['id']) && $_GET ['id'] != 'all' ? "`user_id` = '" . $_GET ['id'] . "'" : ''), '*', (!$id && $order ? $order : 'publication_date'));
		$form -> set_default_value ('user_category',  $form -> ini -> get ('default_user_cat'));
		$form -> set_select_menu ('user_category', array (array ('value' => 'admin', 'name' => 'admin'), array ('value' => 'editor', 'name' => 'editor'), array ('value' => 'author', 'name' => 'author'), array ('value' => 'press', 'name' => 'press'), array ('value' => 'guest', 'name' => 'guest')), 1);
		$form -> set_md5 ('password');
		$form -> set_name ('user_id', 'login');
		$form -> unset_fields (array ('profile_id'));
		$admin -> text .= $form -> get (false, isset ($_GET ['id']) && $_GET ['id'] == 'all' ? false : true);
	break;
	break;
	case 'news':
	default:
/*	if ($admin -> news_set -> news_set_id)
		$admin -> text .= '<br /><a class="button" href="admin.php?page=admin_news&id=' . $admin -> news_set -> news_set_id . '">dodanie i edycja njusów</a>';*/
	$menu_id_result = $form -> db -> select ('menu', "`rights` like '%{$admin -> user_category}%' and `page_id` = '{$admin -> page_id}'", 'menu_id');
	$menu_id = $form -> db -> fetch_object ($menu_id_result);
	$admin -> text .= '<div class="admin-buttons">'
					. '<a class="button" href="admin.php?' . $admin -> ini -> get ('page_id_key') . '=admin_pages&amp;id=' . $admin -> page_id . '#' . $admin -> page_id . '">edycja tekstu</a>'
					. '<a class="button" href="admin.php?' . $admin -> ini -> get ('page_id_key') . '=admin_pages&amp;id=">dodanie tekstu</a>'
/*					. '<a class="button" href="admin.php?' . $admin -> ini -> get ('page_id_key') . '=admin_menu&amp;id=' . $menu_id -> menu_id . '#' . $menu_id -> menu_id . '">edycja menu</a>'
					. '<a class="button" href="admin.php?' . $admin -> ini -> get ('page_id_key') . '=admin_menu&amp;id=">dodanie menu</a>'
*/					. '<a class="button" href="admin.php?' . $admin -> ini -> get ('page_id_key') . '=admin_news&amp;id=all">edycja njusów</a>'
					. '<a class="button" href="admin.php?' . $admin -> ini -> get ('page_id_key') . '=admin_news&amp;id=">dodanie njusa</a>'
					. '<a class="button" href="admin.php?' . $admin -> ini -> get ('page_id_key') . '=admin_promo&amp;id=all">edycja promocji</a>'
					. '<a class="button" href="admin.php?' . $admin -> ini -> get ('page_id_key') . '=admin_promo&amp;id=">dodanie promocji</a>'
					/*
					. '<br /><a class="button" href="correct.php?type=1&amp;id=' . $admin -> page_id . '" title="korekcja po wprowadzeniu danych na Macu" target="faf_correct">korekcja polskich znaków 1</a>'
					. '<br /><a class="button" href="correct.php?type=2&amp;id=' . $admin -> page_id . '" title="korekcja po edycji danych na Macu" target="faf_correct">korekcja polskich znaków 2</a>'*/
					. '</div>';
}
$admin -> show ();

function update_photo (&$form, $phtoto_fields) // Copyright by Mateusz Rusin C 2005 // 1.01
{
	foreach ($phtoto_fields as $phtoto_field)
	{
		if (!empty ($_FILES ['add'] ['tmp_name'] [$phtoto_field]))
			$photo_tmp_name = $_FILES ['add'] ['tmp_name'] [$phtoto_field];
		if (!empty ($photo_tmp_name) && is_uploaded_file ($photo_tmp_name))
		{
			$photo_content = file_get_contents ($photo_tmp_name);
			include_once ('resampling.php');
			//$photo_content = scale ($photo_tmp_name, $admin -> ini -> get ('news_photo_width'), $admin -> ini -> get ('news_photo_heigh'));
			if ($form -> db -> insert_id ())
				$form -> db -> update ('news', array ('news_id' => $form -> db -> insert_id ()), array ($phtoto_field => $photo_content));
			else
				$form -> db -> insert ('news', array ($phtoto_field => $photo_content));
		}
		else
			$photo_content = '';
		unset ($photo_content, $photo_tmp_name);
		if (!empty ($_FILES))
			foreach ($_FILES as $id => $fields)
				if (substr ($id, 0, 3) == 'id_')
				{
					$id = substr ($id, 3);
					if (empty ($_POST ['delete'] [$id]) && !empty ($_FILES ['id_' . $id] ['tmp_name'] [$phtoto_field]))
						$photo_tmp_name = $_FILES ['id_' . $id] ['tmp_name'] [$phtoto_field];
					if (!empty ($photo_tmp_name) && is_uploaded_file ($photo_tmp_name))
					{
						$photo_content = file_get_contents ($photo_tmp_name);
						include_once ('resampling.php');
						//$photo_content = scale ($photo_tmp_name, $admin -> ini -> get ('news_photo_width'), $admin -> ini -> get ('news_photo_heigh'));
						$form -> db -> update ('news', array ('news_id' => $id), array ($phtoto_field => $photo_content));
					}
					else
						$photo_content = '';
					unset ($photo_content, $photo_tmp_name);
				}
	}
}

//<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
?>