<?php
/**
 * phpaga
 *
 * This is phpaga's internal configuration file. There should be no
 * need to modify anything in here. All local configuration settings
 * are done in config.local.php
 *
 * @author Florian Lanthaler <florian@phpaga.net>
 * @version $Id: config.php 878 2007-10-31 22:11:00Z florian $
 *
 * Copyright (c) 2002, 2003 Florian Lanthaler <florian@phpaga.net>
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 *    * Redistributions of source code must retain the above copyright
 *      notice, this list of conditions and the following disclaimer.
 *
 *    * Redistributions in binary form must reproduce the above copyright
 *      notice, this list of conditions and the following disclaimer in
 *      the documentation and/or other materials provided with the
 *      distribution.
 *
 *    * Neither the name of Florian Lanthaler nor the names of his
 *      contributors may be used to endorse or promote products derived
 *      from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/* Include local configuration settings */
include_once("config.local.php");

if (!defined('PHPAGA_ERR_VERBOSE'))
    define("PHPAGA_ERR_VERBOSE", false);

/* Compress output if the option is not disabled and the browser
 * supports gzip encoding */

if ((!defined('PHPAGA_COMPRESSOUT_DISABLED') || !PHPAGA_COMPRESSOUT_DISABLED)
    && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
    ob_start("gzencode");
    header("Content-Encoding: gzip");
}

/* Set error reporting */
if (defined("PHPAGA_ERR_VERBOSE") && (PHPAGA_ERR_VERBOSE == true))
    error_reporting(E_ALL);

/* DSN */
define("PHPAGA_DSN", sprintf("%s://%s:%s@%s/%s",
                             PHPAGA_DB_SYSTEM,
                             PHPAGA_DB_LOGIN,
                             PHPAGA_DB_PASSWD,
                             PHPAGA_DB_HOST,
                             PHPAGA_DB_NAME));

/* Include local configuration settings */
include_once("languages.php");

/* Set include paths */
define("PHPAGA_ETCPATH", PHPAGA_BASEPATH."etc/");
define("PHPAGA_EXTPATH", PHPAGA_BASEPATH."ext/");
define("PHPAGA_DOCPATH", PHPAGA_BASEPATH."htdocs/");
define("PHPAGA_LIBPATH", PHPAGA_BASEPATH."lib/");
define("PHPAGA_LNGPATH", PHPAGA_BASEPATH."locale/");
define("PHPAGA_FILEPATH", PHPAGA_BASEPATH."files/");
define("PHPAGA_PICTUREPATH", PHPAGA_BASEPATH."pictures/");
define("PHPAGA_LOGOPATH", PHPAGA_BASEPATH."logos/");
define("PHPAGA_BMTPATH", PHPAGA_LIBPATH."bill/");
define("PHPAGA_BASETPLPATH", PHPAGA_BASEPATH."templates/");

/* Configure ezcomponents directory */
if (!defined("EZC_BASE"))
    define("EZC_BASE", PHPAGA_EXTPATH."ezcomponents/Base/src/base.php");

/* Include eZ Components */
require_once EZC_BASE;

/**
 * Autoload ezc classes
 *
 * @param string $className
 */
function __autoload( $className ) {
    ezcBase::autoload( $className );
}

/* Include internal primary libraries */
include_once(PHPAGA_LIBPATH."errors.php");
include_once(PHPAGA_LIBPATH."db.php");
include_once(PHPAGA_LIBPATH."config.php");
include_once(PHPAGA_ETCPATH."globals.php");
include_once(PHPAGA_LIBPATH."users.php");
include_once(PHPAGA_LIBPATH."misc.php");
include_once(PHPAGA_ETCPATH."errors.php");
include_once(PHPAGA_LIBPATH."persons.php");

/* Fill $_REQUEST if necessary ($_REQUEST works with php 4.1 and later) */

if (!isset($_REQUEST))
    $_REQUEST = $HTTP_POST_VARS + $HTTP_GET_VARS + $HTTP_COOKIE_VARS;

/* Remove slashes from request paramters if magic_quotes_gpc is On. */

if (get_magic_quotes_gpc() == 1)
{
    $_REQUEST = phpaga_stripslashesArray($_REQUEST);
    $_GET = phpaga_stripslashesArray($_GET);
    $_POST = phpaga_stripslashesArray($_POST);
}

if ((!defined("PHPAGA_INSTALL") || !PHPAGA_INSTALL) && (!defined("PHPAGA_FROMCRON") || !PHPAGA_FROMCRON)) {
    /* check session and load user config settings */
    include_once(PHPAGA_LIBPATH."sessions.php");
} else {
    /* load default config settings */
    phpaga_config_read();
}

if (defined("PHPAGA_INSTALL") && PHPAGA_INSTALL)
{
    if (!defined("PHPAGA_TEMPLATESET")) {
        define("PHPAGA_TEMPLATESET", "phpaga");
    }

    if (!defined("PHPAGA_DEFAULT_SKIN")) {
        define("PHPAGA_DEFAULT_SKIN", "phpaga");
    }
}

/* Uploads are enabled unless defined otherwise in config.local.php */

if (!defined("PHPAGA_UPLOADS_DISABLED"))
    define("PHPAGA_UPLOADS_DISABLED", false);

/* Include internal secondary libraries */

include_once(PHPAGA_LIBPATH."auth.php");
include_once(PHPAGA_LIBPATH."bills.php");
include_once(PHPAGA_LIBPATH."companies.php");
include_once(PHPAGA_LIBPATH."countries.php");
include_once(PHPAGA_LIBPATH."currencies.php");
include_once(PHPAGA_LIBPATH."expenses.php");
include_once(PHPAGA_LIBPATH."files.php");
include_once(PHPAGA_LIBPATH."finances.php");
include_once(PHPAGA_LIBPATH."materials.php");
include_once(PHPAGA_LIBPATH."operations.php");
include_once(PHPAGA_LIBPATH."products.php");
include_once(PHPAGA_LIBPATH."projects.php");
include_once(PHPAGA_LIBPATH."quotations.php");
include_once(PHPAGA_LIBPATH."language.php");
include_once(PHPAGA_ETCPATH."permissions.php");

define("PHPAGA_TPLPATH", PHPAGA_BASETPLPATH.PHPAGA_TEMPLATESET."/");

/* Let PHP handle the temporary directory if it is not specified
 * already */
if (!defined('PHPAGA_TMPDIR'))
    define('PHPAGA_TMPDIR', '');

/* Configure smarty-gettext directory */
if (!defined("SMARTYGETTEXT_DIR"))
    define("SMARTYGETTEXT_DIR", PHPAGA_EXTPATH."/smarty-gettext/");

/* Configure and include Smarty */
if (!defined("SMARTY_DIR")) {
    define("SMARTY_DIR", PHPAGA_EXTPATH."smarty/libs/");
}

include_once(PHPAGA_LIBPATH."smarty.php");

if (!defined("TTF_DIR")) {
    define("TTF_DIR", PHPAGA_BASEPATH."fonts/");
}

/* Configure PDF class */
if (!defined("PDFCLASS_DIR")) {
    define("PDFCLASS_DIR", PHPAGA_EXTPATH."pdfclass/");
}

/* File thumbnails */

if (!defined("PHPAGA_FILES_PREVIEW"))
    define("PHPAGA_FILES_PREVIEW", true);

if (!defined("PHPAGA_BIN_CONVERT"))
    define("PHPAGA_BIN_CONVERT", "/usr/bin/convert");

if (!defined("PHPAGA_BIN_DOT"))
    define("PHPAGA_BIN_DOT", "dot");

define("PHPAGA_SELF", basename($_SERVER["PHP_SELF"]));

?>