#! /usr/local/bin/php -f
<?php
	// 
	// IE6 wird nicht mehr berücksichtig!
	//

	define("cfg_shell",1);
        $_SERVER['DOCUMENT_ROOT'] = $DOCUMENT_ROOT = "/www/shoe.org/doc";
        require_once( $_SERVER['DOCUMENT_ROOT']."/includes/config.inc");

	$default_template = '
.icon_%s{
	background-position:%s %s;
        %s
}
	';



	$autogenerated = '/* ------------------------  AUTO GENERATED CONTENT ---------------------- */
/* -------------------- by /includes/css/_generate.css.sh  --------------- */
';

	$default_content = file_get_contents(SHOE_WEB_DIR .'/includes/css/icons.css.template') . $autogenerated;


	$default_handle = fopen(SHOE_WEB_DIR ."/includes/css/icons.css", "w+");
	$mobile_handle = fopen(SHOE_MOB_WEB_DIR ."/includes/css/icons.css", "w+");

	$icons = SH_sql_array("SELECT * FROM ".SHOE_DB.".site_icons");
	foreach ($icons AS $arr) {
                $default_content .= sprintf($default_template, 
                        $arr['name'],
                        $arr['pos_left'],
                        $arr['pos_top'],
                        ( ($arr['url'] == 'icons.png') ? '':'background-image: url('.SHOE_IMAGES_URI.'/icons/'.$arr['url'].') !important;')
                );
	}
	 fwrite($default_handle, utf8_encode($default_content) );
	 fwrite($mobile_handle, utf8_encode($default_content) );

	 fclose($default_handle);
	 fclose($mobile_handle);

	echo "# all done!";
?>
