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
|
<?php
// File udfs.inc.php / ibWebAdmin
// Purpose functions working with exceptions, included from accessories.php
// Author Lutz Brueckner <irie@gmx.de>
// Copyright (c) 2000, 2001, 2002, 2003, 2004 by Lutz Brueckner,
// published under the terms of the GNU General Public Licence v.2,
// see file LICENCE for details
// Created <04/03/06 16:14:550 lb>
//
// $Id: exceptions.inc.php,v 1.3 2004/03/31 20:04:47 lbrueckner Exp $
//
// return an array with the properties of the exceptions defined in the database
//
function get_exceptions($order=1, $dir='ASC') {
global $dbhandle;
$sql = 'SELECT E.RDB$EXCEPTION_NAME AS ENAME,'
.' E.RDB$MESSAGE AS MSG'
.' FROM RDB$EXCEPTIONS E'
.' ORDER BY '.$order.' '.$dir;
$res = ibase_query($dbhandle, $sql) or ib_error(__FILE__, __LINE__, $sql);
$exceptions = array();
while ($obj = ibase_fetch_object($res)) {
$exceptions[trim($obj->ENAME)] = trim($obj->MSG);
}
return $exceptions;
}
//
// return the html displaying the user defined functions in a table
//
function get_exceptions_table($exceptions, $order, $dir) {
global $HTTP_SERVER_VARS, $acc_strings;
$heads = array('Name', 'Message');
$html = "<table cellpadding=\"0\" cellspacing=\"0\" border>\n"
." <tr align=\"left\">\n";
foreach ($heads as $idx => $head) {
$url = url_session($HTTP_SERVER_VARS['PHP_SELF'].'?excorder=1&order='.($idx +1));
$title = $acc_strings[$head];
if ($order == $idx +1) {
$title = $dir == 'ASC' ? '* '.$title : $title.' *';
}
$html .= ' <th class="detail"><a href="'.$url.'">'.$title."</a></th>\n";
}
$html .= " </tr>\n";
foreach ($exceptions as $ename => $msg) {
$html .= " <tr>\n"
.' <td class="detail">'.$ename."</td>\n"
.' <td class="detail">'.$msg."</td>\n"
." </tr>\n";
}
$html .= "</table>\n";
return $html;
}
//
// return the html for a exception selectlist
//
function get_exception_select($name, $sel=NULL, $empty=TRUE, $tags=array()) {
global $s_exceptions;
$enames = array_keys($s_exceptions);
sort($enames);
return get_selectlist($name, $enames, $sel, $empty, $tags);
}
//
// create an exception from the definitions in $exception_defs
//
function create_exception($exception_defs) {
global $dbhandle, $ib_error, $lsql;
$lsql = 'CREATE EXCEPTION '.$exception_defs['name']." '".str_replace("'", "''", $exception_defs['msg'])."'";
if (DEBUG) add_debug('lsql', __FILE__, __LINE__);
if (!@ibase_query($dbhandle, $lsql)) {
$ib_error = ibase_errmsg();
}
return empty($ib_error);
}
//
// create an exception from the definitions in $exception_defs
//
function modify_exception($exception_defs) {
global $dbhandle, $ib_error, $lsql;
$lsql = 'ALTER EXCEPTION '.$exception_defs['name']." '".str_replace("'", "''", $exception_defs['msg'])."'";
if (DEBUG) add_debug('lsql', __FILE__, __LINE__);
if (!@ibase_query($dbhandle, $lsql)) {
$ib_error = ibase_errmsg();
}
return empty($ib_error);
}
//
// drop the user defined function $name off the database
//
function drop_exception($name) {
global $s_exceptions, $dbhandle;
global $ib_error, $lsql;
$lsql = 'DROP EXCEPTION '.$name;
if (DEBUG) add_debug('lsql', __FILE__, __LINE__);
if (!@ibase_query($dbhandle, $lsql)) {
$ib_error = ibase_errmsg();
return FALSE;
}
else {
unset($s_exceptions[$name]);
return TRUE;
}
}
?>
|