aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_compatibility.php
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-10-28 00:34:51 +0100
committerJoas Schilling <nickvergessen@gmx.de>2014-10-28 00:34:51 +0100
commit6380aea647c2d611a4c3aaf5d0fe4046782340dd (patch)
tree78b8ee8de13b1d6827593c5f13a2b57756420dab /phpBB/includes/functions_compatibility.php
parent0cdd071230120b8d502e6869c17f5b748d9182a0 (diff)
downloadforums-6380aea647c2d611a4c3aaf5d0fe4046782340dd.tar
forums-6380aea647c2d611a4c3aaf5d0fe4046782340dd.tar.gz
forums-6380aea647c2d611a4c3aaf5d0fe4046782340dd.tar.bz2
forums-6380aea647c2d611a4c3aaf5d0fe4046782340dd.tar.xz
forums-6380aea647c2d611a4c3aaf5d0fe4046782340dd.zip
[ticket/13232] Fix more issues with TTL and global cache file
PHPBB3-13232
Diffstat (limited to 'phpBB/includes/functions_compatibility.php')
0 files changed, 0 insertions, 0 deletions
7'>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 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034
#!/usr/bin/perl
#
# Copyright (C) 2004 by Mandrakesoft aginies _ateuh_ mandrakesoft.com
#
# 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, 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.

# Quick configuration of PXE menu parameters
# use with care developement release....
# thx R1 for test and some debug

my $version = "0.9";

use lib qw(/usr/lib/libDrakX);
use standalone;
use strict;
use common;
use MDK::Common;
use ugtk2 qw(:ask :helpers :wrappers :create :dialogs);
use interactive;

# i18n: IMPORTANT: to get correct namespace (drakconf instead of libDrakX)
BEGIN { unshift @::textdomains, 'drakpxelinux' }

use constant FALSE => 0;
use constant TRUE => 1;

# ie of entry menu in PXE:
#label linux
#        KERNEL images/vmlinuz
#        APPEND initrd=images/all.rdz automatic=method:http,interface:eth0,network:dhcp,server:10.0.1.33,directory:/install/ ramdisk_size=64000 root=/dev/ram3 rw vga=788 display=:0

# default VAR
my $conf = "/var/lib/tftpboot/X86PC/linux/pxelinux.cfg/default";
#my $conf = "/tmp/tr";
my $HOSTNAME = chomp_(`hostname`);
my $TFTPDIR = "/var/lib/tftpboot";
my $CLIENTPATH = '/X86PC/linux';
my $X86 = $TFTPDIR . $CLIENTPATH;
my $IMGPATH = $X86 . '/images';
my $PXEHELP = $X86 . '/help.txt';
my $PXEMESSAGE = $X86 . '/messages';
my $pxeconf = '/etc/pxe.conf';
my $SYSLINUXPATH = '/usr/lib/syslinux/';
my $MEMDISK = $SYSLINUXPATH . '/memdisk';
my $XINETDDIR = "/etc/xinetd.d";

my $interface = 'eth0';
my ($IPSERVER) = `/sbin/ip addr show dev $interface` =~ /^\s*inet\s+(\d+\.\d+\.\d+\.\d+)/m;
my $DOMAINNAME = chomp_(`dnsdomainname`);

my $help = "" .
N("PXE Label: the name displayed in PXE menu (a word/number)") . "\n" .
N("Server: IP address of server, which contains installation directory") . "\n" . 
N("Kernel: memdisk or vmlinuz") . "\n" . 
N("Initrd: network boot image (network.img ) or all.rdz") . "\n" . 
N("Interface: network interface used for the installation process") . "\n" . 
N("Network: DHCP or an IP address") . "\n" . 
N("Directory: full path to MDK install server directory") . "\n" . 
N("Method: installation method: choose NFS or HTTP") . "\n" . 
N("Ramsize: ramsize parameter on boot disk") . "\n" . 
N("Display: export display on another computer (ie: 10.0.1.33:0)") . "\n" . 
N("VGA: if you encounter any problem with VGA, please adjust") . "\n" . 
"";


my %help = (
	    'initrd' => N("network boot image (network.img ) or all.rdz"),
	    'kernel' => N("memdisk in case of network.img, or vmlinuz"),
	    'vga' => N("if you encounter any problem with VGA, please adjust"),
	    'interface' => N("network interface used for the installation process"),
	    'info' => N("the name displayed in PXE menu (a word/number)"),
	    'network' => N("dhcp or an IP address"),
	    'directory' => N("full path to MDK install server directory"),
	    'automatic' => N("installation method: choose NFS or HTTP"),
	    'ramsize' => N("ramsize parameter on boot disk"),
	    'display' => N("export display on another computer (ie: 10.0.1.33:0)"),
	    'option' => N("apic nolapic acpi=off initrd=/bin/shell"),
	    'server' => N("IP address of server, which contains installation directory"),
	    'labels' => N("list all PXE entry, selected one is the default boot"),
	    'wizardsrv' => N("Launch a wizard to setup a PXE server"),
	    'editb' => N("Edit the PXE entry selected with a dialog box"),
	    'removepxe' => N("Remove the PXE entry selected"),
	    'addpxe' => N("Launch a Wizard to add a PXE entry "),
	    'helponline' => N("get help from Online documentation"),
	   );

sub set_help_tip {
  my ($entry, $key) = @_;
  gtkset_tip(new Gtk2::Tooltips, $entry, formatAlaTeX($help{$key}));
}

if (!-f $conf) {
  err_dialog(N("Error!"), N("missing %s\n\nPlease install pxe package.",$conf)) and !$::testing && die;
} else {
  save_config($conf);
}

my @listpxe;
my @list_method = qw(nfs http); push @list_method, "";
my @list_ram = qw(32000 48000 64000 96000 1280000); push @list_ram, "";
my @list_vga = qw(normal 785 788 791 794 text); push @list_vga, "";
my @list_eth = qw(eth0 eth1 eth2); push @list_eth, "";

use constant COLUMN_LABEL => 0;
use constant COLUMN_INFO => 1;
use constant COLUMN_KERNEL => 2;
use constant COLUMN_INITRD => 3;
use constant COLUMN_AUTOMATIC => 4;
use constant COLUMN_INTERFACE => 5;
use constant COLUMN_NETWORK => 6;
use constant COLUMN_SERVER => 7;
use constant COLUMN_DIRECTORY => 8;
use constant COLUMN_RAMDISK => 9;
use constant COLUMN_VGA => 10;
use constant COLUMN_DISPLAY => 11;
use constant COLUMN_OPTION => 12;
use constant NUM_COLUMNS => 13;

# get all values from default PXE file
sub get_items() {
  my $info; my $label; my $kernel; my $initrd;
  foreach (cat_($conf)) {
    if (any { /^label/ } cat_($conf)) {
      if (/^label/) { ($label) = /^label\s(.*)/ }
      if (/KERNEL/) { ($kernel) = /KERNEL\s(.*)/ }
      my ($initrd, $automatic, $interface, $network, $server, $directory, $ramdisk, $vga, $display) = m!\s*APPEND\sinitrd=(.*?rdz)\s\bautomatic=method\b:(nfs|http),interface:(eth0|eth1|eth2),network:(dhcp|10.0.1.33),server:(.*?),directory:(.*?)\s\bramdisk_size\b=(.*?)\sroot=/dev/ram3\srw\svga=(.*?)\sdisplay=(.*?)\s!;
      # in case of parameter not on this order (previous pxe default file)
      $initrd or my ($init) = m!\s*APPEND\s\binitrd\b=(.*?)\s!;
      $ramdisk or my ($ramdis) = m!\bramdisk_size\b=(\d+)\s!;
      $automatic or my ($automati) = m!\bautomatic\b=method:(nfs|http)!;
      $vga or my ($vg) = m!\bvga\b=(.*?)\s!;
      $display or my ($displa) = m!\bdisplay\b=(.*?)\s!;
      $interface or my ($interfac) = m!\binterface\b:(eth0|eth1|eth2)!;
      $network or my ($networ) = m!\bnetwork\b:(dhcp|10.0.1.33)!;
      $server or my ($serve) = m!\bserver\b:(.*?),!;
      $directory or my ($director) = m!\bdirectory\b:(.*?)\s!;
      my $initall; my $ramdiskall; my $autoall; my $vgaall; my $displayall; my $interfaceall; my $networkall; my $serverall; my $directoryall;
      if ($initrd) { $initall = $initrd } else { $initall = $init }
      if ($ramdisk) { $ramdiskall = $ramdisk } else { $ramdiskall = $ramdis }
      if ($automatic) { $autoall = $automatic } else { $autoall = $automati }
      if ($vga) { $vgaall = $vga } else { $vgaall = $vg }
      if ($display) { $displayall = $display } else { $displayall = $displa }
      if ($interface) { $interfaceall = $interface } else { $interfaceall = $interfac }
      if ($network) { $networkall = $network } else { $networkall = $networ }
      if ($server) { $serverall = $server } else { $serverall = $serve }
      if ($directory) { $directoryall = $directory } else { $directoryall = $director }
      my ($allopt) = m!\s*APPEND\s(.*)!;
      my ($autocomp) = m!\bautomatic\b=(.*?)\s!;
      my ($devram) = m!root=/dev/ram3\srw!;
      my $optionsall = join(' ', grep { ! /$devram/ && ! /initrd=$initall/ && !/display=$displayall/ && ! /ramdisk_size=$ramdiskall/ && ! /automatic=$autocomp/ && !/vga=$vgaall/ } split(' ', $allopt));
      if ($label && $kernel && $initall) {
	my $information = get_information($label);
	# now push data in @
	push @listpxe, {
			label => $label,
			info => $information,
			kernel => $kernel,
			initrd => $initall,
			automatic => $autoall,
			interface => $interfaceall,
			network => $networkall,
			server => $serverall,
			directory => $directoryall,
			ramdisk => $ramdiskall,
			vga => $vgaall,
			display => $displayall,
			option => $optionsall,
		       },;
      }
    }
  }
}


# get info from help.txt
sub get_information {
  my ($label) = @_;
  my $line = cat_($PXEHELP);
  my ($information) = $line =~ /\b$label\b\s: (.*)/;
  $information and return $information;
}

sub list_label_pxe() {
  my @labels;
  foreach (cat_($conf)) {
    my ($label) = /label\s(.*)/;
    $label and push @labels, $label;
  }
  @labels;
}

# set new default boot PXE
sub set_new_default {
  my ($default) = @_;
  substInFile {
    s/^DEFAULT.*/DEFAULT $default/;
  } $conf;
}

sub get_default_pxe {
  my ($defaultpxe) = cat_($conf) =~ /DEFAULT\s+(\S+)/;
  return $defaultpxe;
}

sub get_default_prompt() {
  my $line = cat_($conf);
  my ($prompt) = $line =~ /^PROMPT\s(\d+)/;
  $prompt and return $prompt;
}

sub get_default_timeout() {
  my ($time) = cat_($conf) =~ /^TIMEOUT\s(\d+)/;
  return $time;
}

# write conf in default file
sub write_conf_pxe {
  my $default = get_default_pxe;
  my $prompt = get_default_prompt;
  my $time = get_default_timeout;
  output($conf, <<EOF);
# DO NOT EDIT auto_generated by drakpxelinux.pl
PROMPT 10
DEFAULT $default
DISPLAY messages
TIMEOUT 50
F1 help.txt

label local
    LOCALBOOT 0
EOF

  foreach my $a (@listpxe) {
    if ($a->{interface} && !$a->{display}) {
      append_to_file($conf, "
label $a->{label}
      KERNEL $a->{kernel}
      APPEND initrd=$a->{initrd} automatic=method:$a->{automatic},interface:$a->{interface},network:$a->{network},server:$a->{server},directory:$a->{directory} ramdisk_size=$a->{ramdisk} root=/dev/ram3 rw vga=$a->{vga}
");
    } elsif ($a->{interface} && $a->{display}) {
      append_to_file($conf, "
label $a->{label}
     KERNEL $a->{kernel}
     APPEND initrd=$a->{initrd} automatic=method:$a->{automatic},interface:$a->{interface},network:$a->{network},server:$a->{server},directory:$a->{directory} ramdisk_size=$a->{ramdisk} root=/dev/ram3 rw vga=$a->{vga} display=$a->{display}
");
      # case of .img image
    } else {
      append_to_file($conf, "
label $a->{label}
      KERNEL $a->{kernel}
      APPEND initrd=$a->{initrd}
");
    }
  }
}

sub create_model {
  get_items();
  my $model = Gtk2::ListStore->new(("Glib::String") x13);
  foreach my $a (@listpxe) {
    my $iter = $model->append;
    $model->set($iter,
		 COLUMN_LABEL, $a->{label},
		 COLUMN_INFO, $a->{info},
		 COLUMN_KERNEL, $a->{kernel},
		 COLUMN_INITRD, $a->{initrd},
		 COLUMN_AUTOMATIC, $a->{automatic},
		 COLUMN_INTERFACE, $a->{interface},
		 COLUMN_NETWORK, $a->{network},
		 COLUMN_SERVER, $a->{server},
		 COLUMN_DIRECTORY, $a->{directory},
		 COLUMN_RAMDISK, $a->{ramdisk},
		 COLUMN_VGA, $a->{vga},
		 COLUMN_DISPLAY, $a->{display},
		 COLUMN_OPTION, $a->{option},
		),
	      }
  return $model;
}

# wizard to add an entry in PXE menu
sub wizard_add_entry {
  my ($widget, $treeview) = @_;
  my $model = $treeview->get_model;

  local $::isEmbedded = 0;
  my $in = 'interactive'->vnew('su');
  undef $::WizardTable;
  undef $::WizardWindow;
  $::isWizard = 1;
  use wizards;
  my $WPXENAME = "Mandrakeclustering";
  my $WINFO = "install Mandrakeclustering";
#  my $WALLRDZ = "/home/nis/install/clic/isolinux/alt0/all.rdz";
  my $WALLRDZ = "/mnt/ken/dis/10.0/i586/isolinux/alt0/all.rdz";
#  my $WVMLINUZ = "/home/nis/install/clic/isolinux/alt0/vmlinuz";
  my $WVMLINUZ = "/mnt/ken/dis/10.0/i586/isolinux/alt0/vmlinuz";
  my $w = wizards->new;
  my $wiz = {
	     name => N("Add PXE entry"),
	     pages => {
		       welcome => {
				   name => N("Add an all.rdz boot image") . "\n" . N("To boot through network, network computer need a boot image. Morever we need to name this image, so each boot image is related to a name in PXE menu. So user can choose wich image he wants to boot through PXE.") . "\n\n" . N("For technical reason, in case of multiple boot image, it's more simple to boot network computer through a kernel (vmlinuz), and provide one file with all drivers needed (in our case all.rdz).") ,
				   next => 'addimg',
				  },
		       addimg => {
				  name => N("At the end of this wizard, the all.rdz image and kernel vmlinuz will be copied into \n%s.\n\nPXE menu list will be updated with this new entry", $IMGPATH),
				  data => [
					   { label => N("PXE label:"), val => \$WPXENAME,
					     help => N("name displayed in PXE menu (please provide a word or a number, with no space)") },
					   { label => N("PXE information:"), val => \$WINFO,
					     help => N("PXE information is used to explain the rule of the boot image,\nie:\nMandrake 10 rescue disk\nMandrake cooker install via http") },
					   { label => N("Full path to all.rdz image source:"), val => \$WALLRDZ,
					     help => N("Provide the full path to all.rdz image source") },
					   { label => N("Full path to vmlinuz source:"), val => \$WVMLINUZ,
					     help => N("Provide the full path to vmlinuz kernel source") },
					  ],
				  complete => sub {
				    if (any { /^$WPXENAME :/ } cat_($PXEHELP)) {
				      err_dialog(N("Error!"), N("Found a similar entry in PXE list labeled : %s.\nChoose another label please", $WPXENAME)) and return 'addimg';
				    }
				    if ($WPXENAME != /^\d+$/) {
				      err_dialog(N("Error!"), N("PXE label should be a name/number without space. Please adjust"));
                          return 'addimg';
				    }
				  },
				  next => 'endadd',
				  post => sub {
				    my $w = $in->wait_message(N("add a PXE entry"), N("ad a PXE entry in your PXE server configuration..."));
				    add_in_help($WPXENAME, $WINFO);
				    my $vmlinuzpxe = basename($WVMLINUZ) . "-$WPXENAME";
				    cp_af($WVMLINUZ, "$IMGPATH/$vmlinuzpxe");
				    cp_af($WALLRDZ, "$IMGPATH/$WPXENAME.rdz");
				    push @listpxe, {
					      label => $WPXENAME,
					      info => $WINFO,
					      kernel => "images/$vmlinuzpxe",
					      initrd => "images/$WPXENAME.rdz",
					      automatic => "",
					      interface => "",
					      network => "",
					      server => "",
					      directory => "",
					      ramdisk => "128000",
					      vga => "",
					      display => "",
					      option => "",
					     };
				    my $iter = $model->append;
				    $model->set($iter,
						COLUMN_LABEL, $listpxe[-1]{label},
						COLUMN_INFO, $listpxe[-1]{info},
						COLUMN_KERNEL, $listpxe[-1]{kernel},
						COLUMN_INITRD, $listpxe[-1]{initrd},
						COLUMN_AUTOMATIC, $listpxe[-1]{automatic},
						COLUMN_INTERFACE, $listpxe[-1]{interface},
						COLUMN_NETWORK, $listpxe[-1]{network},
						COLUMN_SERVER, $listpxe[-1]{server},
						COLUMN_DIRECTORY, $listpxe[-1]{directory},
						COLUMN_RAMDISK, $listpxe[-1]{ramdisk},
						COLUMN_VGA, $listpxe[-1]{vga},
						COLUMN_DISPLAY, $listpxe[-1]{display},
						COLUMN_OPTION, $listpxe[-1]{option},
					       );
				    write_conf_pxe();
				    undef $w;
				    return;
				  },
				  no_back => 1,
				 },
		       endadd => {
				  name => N("Congratulations"),
				  data => [ { label => N("The wizard successfully added the PXE boot image.") } ],
				  post => sub { list_label_pxe() },
				  no_back => 1,
				  end => 1,
				  next => 0,
				 },
		      }
	    };
  $w->process($wiz, $in);
  $::isWizard = 0;
}

# remove an entry in PXE menu
sub remove_item {
  my ($widget, $treeview) = @_;
  $::isWizard = 0;
  my $model = $treeview->get_model;
  my $selection = $treeview->get_selection;
  my $iter = $selection->get_selected;
  if ($iter) {
      my $path = $model->get_path($iter);
      my $i = ($path->get_indices)[0];
      ask_okcancel("Remove $listpxe[$i]{label} PXE entry ?") or return;
      remove_in_help($listpxe[$i]{label});
      my $ke = "$X86/$listpxe[$i]{kernel}";
      my $initrdf = "$X86/$listpxe[$i]{initrd}";
      if (basename($listpxe[$i]{kernel} ne "$X86/memdisk")) {
	print "k: $ke\n";
	print "initrd: $initrdf\n";
	system("rm -vf $ke");
	system("rm -vf $initrdf");
      } else {
	print "initrd: $initrdf\n";
	system("rm -vf $initrdf");
      }
      $model->remove($iter);
      splice @listpxe, $i, 1;
      write_conf_pxe;
    }
}

sub test_similar_label {
  my ($newlabel, $oldlabel) = @_;
#  if ($newlabel eq $oldlabel) {
#    err_dialog(N("hmm.."), N("You should provide a new label name.")) and return 0;
#  } els
  if (any { /^label\s$newlabel$/ } cat_($conf)) {
    err_dialog(N("Error!"), N("Found a similar entry in PXE list labeled: %s.\nChoose another label please", $newlabel)) and return 0;
  } else { return 1 };
}

# dialog box to edit a PXE entry
sub edit_box_item {
  my ($widget, $treeview) = @_;
  $::isWizard = 0;
  my $model = $treeview->get_model;
  my $selection = $treeview->get_selection;

  my $iter = $selection->get_selected;
  if ($iter) {
    my $path = $model->get_path($iter);
    my $i = ($path->get_indices)[0];

    my $dialog = new Gtk2::Dialog();
    $dialog->set_modal(1);
    $dialog->set_resizable(FALSE);

#    my $label = Gtk2::Entry->new;
    my $label = Gtk2::Label->new($listpxe[$i]{label});
#   $label->set_text($listpxe[$i]{label});
#    my $oldlabel = $label;

    my $info = Gtk2::Entry->new;
    $info->set_text($listpxe[$i]{info});
    set_help_tip($info, 'info');

    # create file dialog widget, with file or directory selection
    my $fdwidget = sub {
      my ($data, $test) = @_;
      my $fd = new Gtk2::FileSelection(N("Selection"));
      $fd->set_modal(TRUE);
      $fd->signal_connect("destroy", sub { $fd->hide });
      $fd->ok_button->signal_connect(clicked => sub {
						 my $file = $fd->get_filename;
						 if ($test eq "dir") {
						   -d $file or err_dialog(N("Error!"), N("Should be a directory.")) and return;
						 } else {
						   -f $file or err_dialog(N("Error!"), N("Should be a file")) and return;
						   $file = "images/" . basename($file);
						 }
						 $data->set_text($file);
						 $fd->hide;
                                             }, $fd);
      $fd->cancel_button->signal_connect(clicked => sub { $fd->hide });
      return $fd;
    };


    my $kernel = Gtk2::Entry->new;
    $kernel->set_text($listpxe[$i]{kernel});
    set_help_tip($kernel, 'kernel');

    my $file_dialogk = $fdwidget->($kernel, "");
    # button kernel
    my $buttonkernel = Gtk2::Button->new(N("Select kernel"));
    $buttonkernel->signal_connect(clicked => sub { $file_dialogk->show });

    my $initrd = Gtk2::Entry->new;
    $initrd->set_text($listpxe[$i]{initrd});
    set_help_tip($initrd, 'initrd');

    my $file_dialog = $fdwidget->($initrd, "");
    my $buttoninitrd = Gtk2::Button->new(N("Select initrd"));
    $buttoninitrd->signal_connect(clicked => sub { $file_dialog->show });

    # combo box to pop down automatic installation
    my $automatic = Gtk2::OptionMenu->new;
    $automatic->set_popdown_strings(@list_method);
    $automatic->entry->set_text($listpxe[$i]{automatic});
    set_help_tip($automatic, 'automatic');

    # combo box to pop down list of network interface
    my $interface = new Gtk2::OptionMenu();
    $interface->set_popdown_strings(@list_eth);
    $interface->entry->set_text($listpxe[$i]{interface});
    set_help_tip($interface, 'interface');

    my $network = Gtk2::Entry->new;
    $network->set_text($listpxe[$i]{network});
    set_help_tip($network, 'network');

    my $server = Gtk2::Entry->new;
    $server->set_text($listpxe[$i]{server});
    set_help_tip($server, 'server');

    my $directory = Gtk2::Entry->new;
    $directory->set_text($listpxe[$i]{directory});
    set_help_tip($directory, 'directory');

    my $file_dialogd = $fdwidget->($directory, "dir");