This file is indexed.

/usr/sbin/update-gosa is in gosa 2.7.2-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
#!/usr/bin/php
<?php
/*
 * This code is part of GOsa (http://www.gosa-project.org)
 * Copyright (C) 2003-2010 GONICUS GmbH
 *
 * ID: $$Id: main.php 9254 2008-03-03 15:57:49Z cajus $$
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

define ("GOSA_HOME", "/usr/share/gosa");
define ("LOCALE_DIR", GOSA_HOME."/locale");
define ("PLUGSTATE_DIR", GOSA_HOME."/state");

function print_usage()
{
	?>
update-gosa - class cache updated and plugin manager for GOsa
Usage: update-gosa install dsc     Install the plugin using the dsc information
                                   placed in the plugin source directory.

       update-gosa remove plugin   Remove the plugin named "plugin" from
                                   the current configuration.

       update-gosa list           Lists installed plugins

       update-gosa rescan-i18n     Rebuilds the translations

       update-gosa rescan-images   Rebuilds the themes master image

       update-gosa rescan-classes  Rebuilds the class list
       
       update-gosa                 Shortcut for rescan-classes and rescan-i18n
<?php
	exit (1);
}


function rmdirRecursive($path, $followLinks=false) {
  $dir= opendir($path);
  while($entry= readdir($dir)) {
    if(is_file($path."/".$entry) || ((!$followLinks) && is_link($path."/".$entry))) {
      unlink($path."/".$entry);
    } elseif (is_dir($path."/".$entry) && $entry!='.' && $entry!='..') {
      rmdirRecursive($path."/".$entry);
    }
  }
  closedir($dir);
  return rmdir($path);
}


function get_themes()
{
  $themes= array();
  $d = dir(GOSA_HOME."/html/themes");
  while (false !== ($entry = $d->read())) {
    if ($entry[0] != '.') {
      $themes[]= basename($entry);
    }
  }
  $d->close();

  return $themes;
}

/* Function to include all class_ files starting at a given directory base */
function get_classes($folder= ".")
{
  static $base_dir= "";
  static $result= array();

  if ($base_dir == ""){
    if ($folder == "."){
      $base_dir= getcwd();
    } else {
      $base_dir= $folder;
    }
  }

  $currdir=getcwd();
  if ($folder){
    chdir("$folder");
  }

  $dh = opendir(".");
  while(is_resource($dh) && false !== ($file = readdir($dh))){

    if (preg_match("/.*\.svn.*/", $file) ||
        preg_match("/.*smarty.*/i",$file) ||
        preg_match("/.*\.tpl.*/",$file) ||
        ($file==".") ||($file =="..")){
      continue;
    }

    /* Recurse through all "common" directories */
    if (is_dir($file) && !file_exists("{$file}/excludeFromAutoLoad")){
      get_classes($file);
      continue;
    }

    /* Only take care about .inc and .php files... */
    if (!(preg_match('/\.php$/', $file) || preg_match('/\.inc$/', $file))){
      continue;
    }

    /* Include existing class_ files */
    $contents= file($file);
    foreach($contents as $line){
      $line= chop($line);
      if (preg_match('/^\s*class\s*\w.*$/', $line)){
        $class= preg_replace('/^\s*class\s*(\w+).*$/', '\1', $line);
        $result[$class]= preg_replace("%$base_dir/%", "", "$currdir/$folder/$file");
      }
    }
  }

  @closedir($dh);
  chdir($currdir);

  return ($result);
}


function rescan_classes()
{
	echo "Updating class cache...\n";
	$class_mapping= get_classes("/usr/share/gosa");
	$filename= "/var/cache/gosa/class.cache";

	/* Sanity checks */
	if (!file_exists($filename) || is_writable($filename)) {

	    if (!$handle= fopen($filename, 'w')) {
		 echo "Cannot open file \"$filename\" - aborted\n";
		 exit (1);
	    }

	} else {
	    echo "File \"$filename\" is not writable - aborted\n";
	    exit (2);
	}

	fwrite ($handle, "<?php\n\$class_mapping= array(\n");
	foreach ($class_mapping as $key => $value){
	  fwrite ($handle, "                \"$key\" => \"$value\",\n");
	}
	fwrite ($handle, " );\n");

	fclose($handle);
}


function rescan_i18n()
{
	echo "Updating internationalization...\n";
	$languages= array();
	$size= strlen(LOCALE_DIR);

	/* Get all available messages.po files, sort them for languages */
	$dir= new RecursiveDirectoryIterator(LOCALE_DIR);
	$all= new RecursiveIteratorIterator($dir);
	foreach ( $all as $element ){
		if ($element->isFile() && preg_match('/\/LC_MESSAGES\/messages.po$/', $element->getPathname())){
			$lang= preg_replace('/^.*\/([^\/]+)\/LC_MESSAGES\/.*$/', '\1', $element);
			if (!isset($languages[$lang])){
				$languages[$lang]= array();
			}
			$languages[$lang][]= substr($element->getPathName(), $size+1);
		}
	}

	/* For each language, merge the target .mo to the compiled directory. */
	foreach ($languages as $language => $po_files){
		if (!is_dir("/var/cache/gosa/locale/${language}/LC_MESSAGES")){
			if (!mkdir ("/var/cache/gosa/locale/${language}/LC_MESSAGES", 0755, TRUE)){
				echo "Failed to create '/var/cache/gosa/locale/${language}/LC_MESSAGES'- aborted";
				exit (3);
			}
		}

		/* Cat all these po files into one single file */
		system ("(cd ".LOCALE_DIR." && msgcat --use-first ".implode(" ", $po_files)." > /var/cache/gosa/locale/${language}/LC_MESSAGES/messages.po)", $val);
		if ($val != 0){
			echo "Merging of message files failed - aborted";
			exit (4);
		}
		system ("(cd /var/cache/gosa/locale/${language}/LC_MESSAGES && msgfmt -o messages.mo messages.po && rm messages.po)", $val);
		if ($val != 0){
			echo "Compiling of message files failed - aborted";
			exit (5);
		}
	}

	echo "! Warning: you may need to reload your webservice!\n";
}


function parse_ini($file)
{
	global $description, $provides, $depends, $versions, $conflicts;

	$res= "";
	if (file_exists($file)){
		$tmp= parse_ini_file($file, TRUE);

		if (isset($tmp['gosa-plugin'])){
			$plugin= &$tmp['gosa-plugin'];
			if (isset($plugin['name'])&& isset($plugin['description'])){
				$res= $plugin['name'];
				$description[$res]= $plugin['description'];
				$versions[$res]= $plugin['version'];
				$provides[$res]= $res;
				if (isset($plugin['depends'])){
					$depends[$res]= explode(',', preg_replace('/\s+/', '', $plugin['depends']));
				}
				if (isset($plugin['conflicts'])){
					$conflicts[$res]= explode(',', preg_replace('/\s+/', '', $plugin['conflicts']));
				}
			}
		}
	}

	return $res;
}


function dependency_check()
{
	global $description, $provides, $depends;

	foreach ($depends as $name => $pl_depends){
		foreach ($pl_depends as $pl){
			if (!in_array($pl, $provides)){
				echo "! Error: plugin '$name' depends on '$pl' which is not provided by any plugin\n\n";
				exit (1);
			}
		}
	}
}


function load_plugins()
{
	if (!is_dir(PLUGSTATE_DIR)){
		if (!mkdir (PLUGSTATE_DIR, 0755, TRUE)){
			echo "Cannot create plugstate dir '".PLUGSTATE_DIR."' - aborted\n";
			exit (2);
		}
	}
	$dir= new DirectoryIterator(PLUGSTATE_DIR);
	foreach ($dir as $entry){
		if ($dir->isDir() && !preg_match('/^\./', $dir->__toString())){
			$file= $dir->getPathName()."/plugin.dsc";
			if (parse_ini($file) == ""){
				echo "! Warning: plugin ".$dir->getPathName()." is missing declarations\n";
			}
		}
	}
}


function list_plugins()
{
	global $description, $versions;
	$count= 0;

	/* Load plugin list */
	load_plugins();

	/* Show plugins */
	foreach ($description as $name => $dsc){
		if ($count == 0){
			echo "Plugin\t\t|Version |Description\n";
			echo "----------------------------------------------------------------------------\n";
		}
		$ver= $versions[$name];
		echo "$name\t\t|$ver\t |$dsc\n";
		$count++;
	}

	/* Yell about non existing plugins... */
	if ($count == 0){
		echo "No plugins found...\n\n";
	} else {
		# Check for dependencies
		dependency_check();
		echo "\n";
	}
}


function install_plugin($file)
{
	global $description, $provides, $depends, $conflicts;

	/* Load plugin list */
	load_plugins();

	/* Load .dsc file */
	if (file_exists($file)){
		$tmp= parse_ini_file($file, TRUE);

		if (isset($tmp['gosa-plugin'])){
			$plugin= &$tmp['gosa-plugin'];
			if (isset($plugin['name'])&& isset($plugin['description'])){
				$name= $plugin['name'];
				$description= $plugin['description'];
				$depends= array();
				if (isset($plugin['depends'])){
					$depends= explode(',', preg_replace('/\s+/', '', $plugin['depends']));
				}

				/* Already installed? */
				if (isset($provides[$name])){
					echo "! Error: plugin already installed\n\n";
					exit (3);
				}

				/* Check if dependencies are fullfilled */
				foreach ($depends as $dep){
					$found= false;
					foreach ($provides as $provide => $dummy){
						if ($dep == $provide){
							$found= true;
							break;
						}
					}
					if (!$found){
						echo "! Error: plugin depends on '$dep', but this is not installed\n\n";
						exit (3);
					}
				}

				/* Check for conflicts */
				foreach ($conflicts as $conf){
					if (!in_array($conf, $provides)){
						echo "! Warning: plugin conflicts with '$conf'\n\n";
					}
				}

				/* Create plugstate directory and touch plugin.lst */
				if (!mkdir (PLUGSTATE_DIR."/$name", 0755, TRUE)){
					echo "Failed to create '".PLUGSTATE_DIR."/$name - aborted";
					exit (3);
				}
				if (!$handle= fopen(PLUGSTATE_DIR."/$name/plugin.lst", 'w')) {
					echo "Cannot open file '$filename' - aborted\n";
					exit (1);
				}

				echo "Installing plugin '$name'...\n";

				/* Copy and fill plugin.lst */
				$path= dirname($file);
				$dir= new RecursiveDirectoryIterator($path);
				$all= new RecursiveIteratorIterator($dir);
				foreach ( $all as $entry ){
					$source= $path."/".substr($entry->getPathName(), strlen($path) + 1);

					/* Skip description - it belongs to the state dir */
					if (preg_match('/\/plugin.dsc$/', $source)){
						copy ($source, PLUGSTATE_DIR."/$name/plugin.dsc");
						continue;
					}

					/* Skip well known directories */
					if (preg_match('/^\.+$/', $source) || preg_match('/\/\.svn\//', $source)) {
						continue;
					}

					/* Calculate destination */
					if (preg_match("%^.*locale/%", $source)){
						$dest= GOSA_HOME."/locale/plugins/$name/".preg_replace("%^.*locale/%", "", $source);
					} elseif (preg_match("%^.*help/%", $source)) {
						$dest= GOSA_HOME."/doc/plugins/$name/".preg_replace("%^.*help/%", "", $source);
					} elseif (preg_match("%^.*html/%", $source)) {
						$dest= GOSA_HOME."/html/plugins/$name/".preg_replace("%^.*html/%", "", $source);
					} else {
						$dest= GOSA_HOME."/plugins/".substr($entry->getPathName(), strlen($path) + 1);
					}

					/* Destination exists in case of directories? */
					if ($entry->isDir()){
						if (!is_dir($dest)){
							mkdir($dest, 0755, TRUE);
							fwrite ($handle, "$dest\n");
						}
					} else {
						if (!is_dir(dirname($dest))){
							mkdir(dirname($dest), 0755, TRUE);
							fwrite ($handle, dirname($dest)."\n");
						}
					}

					/* Copy files */
					if ($entry->isFile()){
						copy ($source, $dest);
					}

					/* Note what we did... */
					fwrite ($handle, "$dest\n");
				}

				fclose($handle);
			}
		}
	}
	
	/* Update caches */
	rescan_classes();
	rescan_i18n();
}


function remove_plugin($name)
{
	global $description, $depends;

	/* Load plugin list */
	load_plugins();

	/* Present? */
	if (!isset($description[$name])){
		echo "! Error: cannot find a plugin named '$name'\n\n";
		exit (1);
	}

	/* Depends? */
	foreach ($depends as $sname => $pl_depends){
		if (in_array($name, $pl_depends)){
			echo "! Error: plugin '$sname' depends on '$name' - cannot remove it\n\n";
			exit (1);
		}
	}

	/* Load information */
	if (!file_exists(PLUGSTATE_DIR."/$name/plugin.lst")){
		echo "! Error: cannot remove plugin '$name' - no install history found\n\n";
		exit (1);
	}

	echo "Removing plugin '$name'...\n";
	$contents= file(PLUGSTATE_DIR."/$name/plugin.lst");
	$cnv= array();
	foreach($contents as $line){
		$entry= chop($line);
		$cnv[strlen($entry).":$entry"]= $entry;
	}
	krsort($cnv);

	/* Remove files first */
	clearstatcache();
	foreach ($cnv as $entry){
		if (is_dir($entry)){
			rmdir($entry);
			continue;
		}
		if (file_exists($entry)){
			unlink($entry);
		}
	}

	/* Remove state directory for plugin */
	rmdirRecursive(PLUGSTATE_DIR."/$name");

	/* Update caches */
	rescan_classes();
	rescan_i18n();
}


function rescan_images($path, $theme)
{
  $widths= array();
  $heights= array();
  $paths= array();
  $posX= array();
  $posY= array();
  $baseLength= strlen($path);
  $heightStats= array();
  $warnings= array();
  $checksums= array();
  $styles= array();
  $duplicates= array();

  echo "Updating master image for theme '$theme'...";

  // Check for image magick convert
  if (!function_exists("imageFilter")){
    exec("which convert", $res, $ret);
    if ($ret != 0) {
      die("Your system has no bundled gd support for imageFilter function. Please install imagemagick in order to use an external command.\n");
    }
  }
  
  // Scan for images in the given path
  flush();
  foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)) as $fileInfo) {
  
      // We're only interested in png files
      $indexPath= substr($fileInfo->getPathname(), $baseLength + 1);
      $path= $fileInfo->getPathname();
      if (preg_match('/\.png$/', $indexPath) && !preg_match('/\.svn/', $path) && !preg_match('/themes\/[^\/]+\/images\/img.png$/', $path)){
  
         // Grey image if it is not already one
         if (preg_match('/grey/', $indexPath)) {
           echo "!";
           $warnings[]= "! Warning: skipped possible *grey* image $path";
           flush();
           continue;
         }

         // New image if it is not already one
         if (preg_match('/new/', $indexPath) && !preg_match('/new\.png$/', $indexPath)) {
           echo "!";
           $warnings[]= "! Warning: skipped possible *new* image $path";
           flush();
           continue;
         }

         // Catch available themes
         if (preg_match('/themes\//', $indexPath) && !preg_match('/themes\/'.$theme.'\//', $indexPath)) {
           continue;
         }

         // Load image
         $img= imageCreateFromPng($path);
         $width= imageSX($img);
         $height= imageSY($img);
         imageDestroy($img);
         $greyIndexPath= preg_replace('/\.png$/', '-grey.png', $indexPath);

         // Is this image already there?
         $checksum= md5_file($path);
         if (in_array($checksum, $checksums)) {
           $warnings[]= "! Warning: images $indexPath seems to be a duplicate of ".array_search($checksum, $checksums);
           $duplicates[$indexPath]= array_search($checksum, $checksums);
           $duplicates[$greyIndexPath]= preg_replace('/\.png$/', '-grey.png', array_search($checksum, $checksums));
           continue;
         } else {
           $checksums[$indexPath]= $checksum;
         }

         // Ordinary image
         $widths[$indexPath]= $width;
         $heights[$indexPath]= $height;
         $paths[$indexPath]= $path;

         // Grey image
         $widths[$greyIndexPath]= $width;
         $heights[$greyIndexPath]= $height;
         $paths[$greyIndexPath]= $path;

         // Feed height statistics
         if (!isset($heightStats[$height])) {
           $heightStats[$height]= 1;
         } else {
           $heightStats[$height]++;
         }
      }
  
    echo ".";
    flush();
  }
  echo "\n";

  // Do some stupid height calculation
  arsort($heightStats, SORT_NUMERIC);
  reset($heightStats);
  $popular= current($heightStats);

  krsort($heightStats);
  reset($heightStats);
  $max= current($heightStats);

  $maxHeight= (floor($max / $popular) + 1) * $popular * 6;
  
  // Sort to get biggest values
  arsort($widths, SORT_NUMERIC);
  reset($widths);
  echo "Calculating master image dimensions: ";
  flush();
  
  // Build container image
  $cursorX= 0;
  $cursorY= 0;
  $colWidth= 0;
  $rowHeight= 0;
  $colX= 0;
  $colY= 0;
  $maxY= 0;
  $maxX= 0;

  // Walk thru width sorted images
  foreach ($widths as $imagePath => $imageWidth) {
    $imageHeight= $heights[$imagePath];

    // First element in this column
    if ($colWidth == 0) {
      $colWidth= $imageWidth;
    }

    // First element in this row
    if ($rowHeight < $imageHeight) {
      $rowHeight= $imageHeight;
    }

    // Does the image match here?
    if ($cursorX + $imageWidth > $colX + $colWidth) {

      if ($cursorY + $imageHeight >= $maxHeight) {

        // Reached max height, move to the next column
        $colX+= $colWidth;
        $cursorX= $colX;
        $colWidth= $imageWidth;
        $rowHeight= $imageHeight;
        $colY= $cursorY= 0;

      } else {

        // Next row
        $colY+= $rowHeight;
        $cursorY= $colY;
        $cursorX= $colX;
        $rowHeight= $imageHeight;
      }

      $maxY=($colY + $imageHeight > $maxY)?$colY+$imageHeight:$maxY;
    }

    // Save calculated position
    $posX[$imagePath]= $cursorX;
    $posY[$imagePath]= $cursorY;

    // Move X cursor to the next position
    $cursorX+= $imageWidth;

    $maxX=($colX+$imageWidth > $maxX)?$colX+$imageWidth:$maxX;
  }
  
  // Print maximum dimensions
  echo $maxY."x".$maxX."\n";
  echo "Processing";
  flush();

  // Create result image
  $dst= imageCreateTrueColor($maxX, $maxY);
  imageAlphaBlending($dst, true);
  $transparent = imagecolorallocatealpha($dst, 0, 0, 0, 127);
  imageFill($dst, 0, 0, $transparent);
  imageSaveAlpha($dst, true);

  // Finally assemble picture
  foreach ($heights as $imagePath => $imageHeight) {
    $imageWidth= $widths[$imagePath];
    $x= $posX[$imagePath];
    $y= $posY[$imagePath];

    // Insert source image...

    // Eventually convert it to grey before
    if (preg_match('/-grey\.png$/', $imagePath)) {
      if (!function_exists("imageFilter")){
        exec("convert ".$paths[$imagePath]." -colorspace Gray /tmp/grey-converted.png");
        $src= imageCreateFromPng("/tmp/grey-converted.png");
      } else {
        $src= imageCreateFromPng($paths[$imagePath]);
        imageFilter($src, IMG_FILTER_GRAYSCALE);
      }
    } else {
      $src= imageCreateFromPng($paths[$imagePath]);
    }

    // Merge image
    imageCopyResampled($dst, $src, $x, $y, 0, 0, $imageWidth, $imageHeight, $imageWidth, $imageHeight);
    imageDestroy($src);

    // Store style
    $styles[$imagePath]= "background-position:-".$x."px -".$y."px;width:".$imageWidth."px;height:".$imageHeight."px";

    echo ".";
    flush();
  }

  /* Add duplicates */
  foreach ($duplicates as $imagePath => $realPath) {
    $styles[$imagePath]= $styles[$realPath];
  }

  imagePNG($dst, GOSA_HOME."/html/themes/$theme/images/img.png", 9);
  imageDestroy($dst);

  // Show warnings images
  foreach ($warnings as $warn) {
    echo "$warn\n";
  }

  // Write styles
  echo "Writing styles...";
  $fp = fopen(GOSA_HOME."/ihtml/themes/$theme/img.styles", 'w');
  fwrite($fp, serialize($styles));
  fclose($fp);

  echo "\n";
}


/* Fill global values */
$description= $provides= $depends= $versions= $conflicts= array();

/* Action specified? */
if ($argc < 2){
	rescan_classes();
	rescan_i18n();
    foreach (get_themes() as $theme) {
      rescan_images(GOSA_HOME."/html", $theme);
    }
    exit (0);
}

switch ($argv[1]){
        case 'install':
                if (isset($argv[2])){
			install_plugin($argv[2]);
		} else {
			echo "Usage: update-gosa install dsc-file\n\n";
			exit (1);
		}
                break;
        case 'list':
                list_plugins();
                break;
        case 'remove':
                if (isset($argv[2])){
			remove_plugin($argv[2]);
		} else {
			echo "Usage: update-gosa remove plugin-name\n\n";
			exit (1);
		}
                break;
        case 'rescan-i18n':
                rescan_i18n();
                break;
        case 'rescan-classes':
                rescan_classes();
                break;
        case 'rescan-images':
                foreach (get_themes() as $theme) {
                  rescan_images("html", $theme);
                }
                break;
        default:
                echo "Error: Supplied command not known\n\n";
                print_usage();
                break;
}


?>