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
|
<?php
/**
* $Horde: ingo/script.php,v 1.33.6.7 2009/01/06 15:24:34 jan Exp $
*
* Copyright 2002-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (ASL). If you
* did not receive this file, see http://www.horde.org/licenses/asl.php.
*
* @author Mike Cochrane <mike@graftonhall.co.nz>
*/
@define('INGO_BASE', dirname(__FILE__));
require_once INGO_BASE . '/lib/base.php';
/* Redirect if script updating is not available. */
if (!$_SESSION['ingo']['script_generate']) {
header('Location: ' . Horde::applicationUrl('filters.php', true));
exit;
}
$script = '';
/* Get the Ingo_Script:: backend. */
$scriptor = Ingo::loadIngoScript();
if ($scriptor) {
/* Generate the script. */
$script = $scriptor->generate();
}
/* Activate/deactivate script if requested.
activateScript() does its own $notification->push() on error. */
$actionID = Util::getFormData('actionID');
switch ($actionID) {
case 'action_activate':
if (!empty($script)) {
Ingo::activateScript($script);
}
break;
case 'action_deactivate':
Ingo::activateScript('', true);
break;
case 'show_active':
$script = Ingo::getScript();
if (is_a($script, 'PEAR_Error')) {
$notification->push($script, 'horde.error');
$script = '';
}
break;
}
$title = _("Filter Script Display");
require INGO_TEMPLATES . '/common-header.inc';
require INGO_TEMPLATES . '/menu.inc';
require INGO_TEMPLATES . '/script/header.inc';
if (!empty($script)) {
require INGO_TEMPLATES . '/script/activate.inc';
}
require INGO_TEMPLATES . '/script/script.inc';
if (!empty($script)) {
$lines = preg_split('(\r\n|\n|\r)', $script);
$i = 0;
foreach ($lines as $line) {
printf("%3d: %s\n", ++$i, htmlspecialchars($line));
}
} else {
echo '[' . _("No script generated.") . ']';
}
require INGO_TEMPLATES . '/script/footer.inc';
require $registry->get('templates', 'horde') . '/common-footer.inc';
|