File: _functions_errors.php

package info (click to toggle)
b2evolution 0.9.2-3
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 12,976 kB
  • ctags: 5,460
  • sloc: php: 58,989; sh: 298; makefile: 36
file content (69 lines) | stat: -rw-r--r-- 1,279 bytes parent folder | download | duplicates (2)
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
<?php
/**
 * Error handling
 * 
 * b2evolution - {@link http://b2evolution.net/}
 * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
 * @copyright (c)2003-2005 by Francois PLANQUE - {@link http://fplanque.net/}
 *
 * @package evocore
 */
if( !defined('DB_USER') ) die( 'Please, do not access this page directly.' );

if( !isset( $errors ) )
{
	$errors = array();
}

/**
 * add error to list
 */
function errors_add( $string )
{
	global $errors;
	// echo 'error:'.$string;
	$errors[] = $string;
}

function errors()
{
	global $errors;
	return count( $errors );
}

function errors_display( $head, $foot, $display = true )
{
	global $errors;
	if( ! count( $errors ) )
	{
		// echo 'NO ERROR';
		return false;
	}

	$disp = '<div class="error"><p class="error">'.$head.'</p><ul class="error">';
	foreach( $errors as $error )
	{
		$disp .= '<li class="error">'.$error.'</li>';
	}		
	$disp .= '</ul><p class="error">'.$foot.'</p></div>';
	
	if( $display )
	{
		echo $disp;
		return true;
	}

	return $disp;
}

function errors_string( $head, $foot )
{
	global $errors;
	if( ! count( $errors ) )
	{
		return false;
	}
	return strip_tags($head.' '.implode(', ',$errors).' '.$foot);
}

?>