Project

General

Profile

« Previous | Next » 

Revision 2a0e6517

Added by Colin Smith about 20 years ago

  • Add eval_once, which checks the md5s of code to eval() against already eval'ed blocks.
  • eval -> eval_once when using package global functions.

Tickets #160, #158

View differences:

etc/inc/pkg-utils.inc
449 449
	update_output_window($static_output);
450 450
}
451 451

  
452
function eval_once($toeval) {
453
	global $evaled;
454
	$evalmd5 = md5($toeval);
455
	if(!in_array($evalmd5, $evaled)) {
456
		eval($toeval);
457
		$evaled[] = $evalmd5;
458
	}
459
	return;
460
}
461
	
462

  
452 463
function install_package_xml($pkg) {
453 464
	global $g, $config, $fd_log, $static_output;
454 465
	if(($pkgid = get_pkg_id($pkg)) == -1) {
......
540 551
			$static_output .= "\tCustom commands... ";
541 552
			update_output_window($static_output);
542 553
			if($pkg_config['custom_php_global_functions'] <> "") {
543
				eval($pkg_config['custom_php_global_functions']);
554
				eval_once($pkg_config['custom_php_global_functions']);
544 555
			}
545 556
			fwrite($fd_log, "Executing post install commands...\n");
546
			eval($pkg_config['custom_php_install_command']);
557
			eval_once($pkg_config['custom_php_install_command']);
547 558
			$static_output .= "done.\n";
548 559
			update_output_window($static_output);
549 560
		}
550 561
		/* call our before form property since we may be declaring functions
551 562
		   in it that are called later */
552 563
		if($pkg_config['custom_php_command_before_form'] <> "") {
553
			eval($pkg_config['custom_php_command_before_form']);
564
			eval_once($pkg_config['custom_php_command_before_form']);
554 565
		}
555 566
		/* call our resync function */
556 567
		if($pkg_config['custom_php_resync_config_command'] <> "") {
557
			eval($pkg_config['custom_php_resync_config_command']);
568
			eval_once($pkg_config['custom_php_resync_config_command']);
558 569
		}
559 570
	} else {
560 571
		$static_output .= "Loading package configuration... failed!\n\nInstallation aborted.";
......
636 647
		}
637 648
		/* evalate this package's global functions and pre deinstall commands */
638 649
		if($pkg_config['custom_php_global_functions'] <> "")
639
			eval($pkg_config['custom_php_global_functions']);
650
			eval_once($pkg_config['custom_php_global_functions']);
640 651
		if($pkg_config['custom_php_pre_deinstall_command'] <> "") 
641
			eval($pkg_config['custom_php_pre_deinstall_command']);
652
			eval_once($pkg_config['custom_php_pre_deinstall_command']);
642 653
		/* remove all additional files */
643 654
		if($pkg_config['additional_files_needed'] <> "") {
644 655
			$static_output .= "\tAuxiliary files... ";
......
679 690
		if($pkg_config['custom_php_deinstall_command'] <> "") {
680 691
			$static_output .= "\tDeinstall commands... ";
681 692
			update_output_window($static_output);
682
			eval($pkg_config['custom_php_deinstall_command']);
693
			eval_once($pkg_config['custom_php_deinstall_command']);
683 694
			$static_output .= "done.\n";
684 695
			update_output_window($static_output);
685 696
		}

Also available in: Unified diff