PageRenderTime 29ms CodeModel.GetById 14ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/system/bootstrap.inc.php

https://bitbucket.org/sundeeppeswani/tell-a-friend-www
PHP | 84 lines | 71 code | 13 blank | 0 comment | 16 complexity | b90c5b13cb5af61b2dee28477bfb8a6d MD5 | raw file
 1<?php defined( 'VALID_INCLUSION' ) or die();
 2
 3require_once './configuration.php';
 4require_once './system/lib/exceptions.inc.php';
 5require_once './system/lib/classes/class.database.php';
 6
 7function __( &$object ) {
 8	echo '<pre>'; print_r( $object ); echo '</pre>';
 9}
10
11function site_link( $params ) {
12	if ( USE_CLEAN_URLS == false ) {
13		return SITE_URL . 'index.php' . ( empty( $params ) ? '' : '?' . http_build_query( $array ) );
14	}
15
16	$format = '%s' . join( '/', array_fill( 0, count( $params ), '%s' ) );
17	$values = array_values( $params );
18	array_unshift( $values, SITE_URL );
19	return vsprintf( $format, $values );
20}
21
22function get_ip() {
23	if ( function_exists( 'get_env' ) ) {
24		if ( getenv( 'HTTP_CLIENT_IP' ) )
25			return getenv( 'HTTP_CLIENT_IP' );
26		if ( getenv( 'HTTP_X_FORWARDED_FOR' ) )
27			return getenv( 'HTTP_X_FORWARDED_FOR' );
28		if ( getenv( 'HTTP_X_FORWARDED' ) )
29			return getenv( 'HTTP_X_FORWARDED' );
30		if ( getenv( 'HTTP_FORWARDED_FOR' ) )
31			return getenv( 'HTTP_FORWARDED_FOR' );
32		if ( getenv( 'HTTP_FORWARDED' ) )
33			return getenv( 'HTTP_FORWARDED' );
34	}
35	return $_SERVER['REMOTE_ADDR'];
36}
37
38function log_error( $class, $exception ) {
39	static $logfile = NULL;
40	$logfile = realpath( '.' ) . '/system/logs/error_' . gmdate( 'Ymd' ) . '.log';
41	echo $logfile;
42	exit;
43
44	$message = $exception;
45	if ( is_a( $exception, 'Exception' ) ) {
46		$message = $exception->getMessage();
47	}
48
49	error_log( "$class: $message\n", 3, $logfile );
50}
51
52function post_exists( $key, $type = null, $keys = null ) {
53	if ( empty( $_POST ) ) {
54		return false;
55	}
56
57	if ( empty( $_POST[ $key ] ) ) {
58		return false;
59	}
60
61	switch( $type ) {
62		case 'array':
63			if ( is_array( $_POST[ $key ] ) == false ) {
64				return false;
65			}
66			if ( isset( $keys ) ) {
67				foreach ( $keys as $k ) {
68					if ( empty( $_POST[ $key ][ $k ] ) ) {
69						return false;
70					}
71				}
72			}
73			return true;
74		case 'double':	return is_numeric( $_POST[ $key ] ) && is_double( floatval( $_POST[ $key ] ) );
75		case 'integer':	return is_numeric( $_POST[ $key ] );
76		case 'string':	return is_string( $_POST[ $key ] );
77		default:	return false;
78	}
79}
80
81function shutdown() {
82}
83
84register_shutdown_function( 'shutdown' );