<?php
/* this script acts like a proxy to rewrite url before OsClass loading, see .htaccess */
/* example: https://dev1.usato.it/annunci/milano/motori/?alimentazione=benzina+metano&cilindrata=1000 */

/* NB: we made a change to Osclass code to disable meta "generator" in oc-load.php */

require_once 'config.php';      // needed to retrieve db info
require_once 'superadmin/OscHelper.php';   // a custom OsClass API

$osc = new OscHelper(
  DB_HOST,
  DB_USER,
  DB_PASSWORD,
  DB_NAME,
  DB_TABLE_PREFIX
);

/* send the same cookies with requests to all subdomains */
ini_set('session.cookie_domain', ".$osc->osc_subdomain_host" );

/* TODO(steborsatto):  check if our plugin is enabled */

$url = $_SERVER['REQUEST_URI'];

if ($osc->isCustomSearchUrl($url)) {
  $osc->setUpEnv($url);
} else if ($osc->shouldRedirect($url)) {
  //$osc->redirect($url);
  die();
}

/* run Osclass */
include_once 'index.php';
