<?php
  /**
   * Copyright 2011 Zazavi - http://www.zazavi.com
   * Zazavi is free software released under the terms of the GNU General Public License.
   * You should have received a copy of the license.  If not, see <http://www.gnu.org/licenses/>.
   */
  if (!defined("_VALID_PHP"))
      die('Direct access to this location is not allowed.');
?>
<?php error_reporting(E_ALL);

  // Magic Quotes Fix
  if (ini_get('magic_quotes_gpc')) {
      function clean($data)
      {
          if (is_array($data)) {
              foreach ($data as $key => $value) {
                  $data[clean($key)] = clean($value);
              }
          } else {
              $data = stripslashes($data);
          }
          
          return $data;
      }
      
      $_GET = clean($_GET);
      $_POST = clean($_POST);
      $_COOKIE = clean($_COOKIE);
  }
  
  $ZAZAVILITE = str_replace("init.php", "", realpath(__FILE__));
  define("ZAZAVILITE", $ZAZAVILITE);
  
  $configFile = ZAZAVILITE . "lib/config.ini.php";
  if (file_exists($configFile)) {
      require_once($configFile);
  } else {
      header("Location: setup/");
  }

  require_once(ZAZAVILITE . "lib/class_db.php");
  $db = new Database(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE);
  $db->connect();
  
  include(ZAZAVILITE . "lib/headerRefresh.php");
  require_once(ZAZAVILITE . "lib/class_filter.php");
  $request = new Filter();

  //Include Functions
  require_once(ZAZAVILITE . "lib/functions.php");
  require_once(ZAZAVILITE . "lib/fn_seo.php");
  
  //StartUser Class 
  require_once(ZAZAVILITE . "lib/class_user.php");
  $user = new Users();

  //Start Core Class 
  require_once(ZAZAVILITE . "lib/class_core.php");
  $core = new Core();

  //Load Content Class
  require_once(ZAZAVILITE . "lib/class_content.php");
  $content = new Content();

  //Load Membership Class
  require_once(ZAZAVILITE . "lib/class_membership.php");
  $member = new Membership();

  //Load Security Class
  require_once(ZAZAVILITE . "lib/class_security.php");
  $zazavisec = new Security($core->attempt, $core->flood);
  
  define("SITEURL", $core->site_url);
  define("ADMINURL", $core->site_url."/admin");
  define("UPLOADS", ZAZAVILITE."uploads/");
  define("MODDIR", ZAZAVILITE."modules/");
  define("THEMEURL", SITEURL."/theme/".$core->theme);
  define("THEMEDIR", ZAZAVILITE."theme/".$core->theme);
?>