<?php
$module_dir = "im_cinemas";
$module_css_path = ($line_domain['theme'] != "" && $line_domain['theme'] != "default") ? ($path . ('assets/themes/' . $line_domain['theme'] . '/')) : $path;
$admin_view = false;
if(isset($_SESSION['user_id']) && intval($_SESSION['user_id']) > 0) {
    $admin_view = true;
}

$include_www = "https://www.cypruswebsites.com";
//$admin_view = false;

require_once(dirname(__FILE__) . "/config.php");
require_once(dirname(__FILE__) . "/im_functions.php");
require_once(dirname(__FILE__) . "/../../imCinemaAdmin/classes/Str.php");

if(file_exists(dirname(__FILE__) . "/im_cinemas_init.php")) {
    include(dirname(__FILE__) . "/im_cinemas_init.php");
}
else {
    echo "<br/><b>".dirname(__FILE__) . "/im_cinemas_init.php does not exist</b>";
}


if(isset($_POST['media_ajax'])) {
    require_once(dirname(__FILE__) . "/media_ajax.php");
}

if(isset($module_params)) {
    $def_ads = isset($module_params['def_ads']) ? $module_params['def_ads'] : 'no';
    $def_ad_id = isset($module_params['ws_ad_unit_id']) ? $module_params['ws_ad_unit_id'] : '';
}
else {
    $default_module_params = [];
    $q = "SELECT l.* FROM left_content l, module m WHERE l.module_id=m.module_id AND m.url='im_cinemas' AND l.catdom_id='$domain_id';";
    $r = @mysql_query($q);
    if($r && mysql_num_rows($r) > 0) {
        $row = mysql_fetch_assoc($r);
        $default_module_params = unserialize(base64_decode($row['module_params']));
    }

    $def_ads = isset($default_module_params['def_ads']) ? $default_module_params['def_ads'] : 'no';
    $def_ad_id = isset($default_module_params['ws_ad_unit_id']) ? $default_module_params['ws_ad_unit_id'] : '';

    $module_params = [
        'ws_ad_unit_id' => $def_ad_id,
        'def_ads' => $def_ads
    ];
}


if(isset($_REQUEST['movie_slug'])) {

    require_once(dirname(__FILE__) . "/im_movie.php");
}

$show_default = true;

if(isset($module_params['module_mode']) && $module_params['module_mode'] != "null") {
    $module_mode_file = dirname(__FILE__) . "/im_" . $module_params['module_mode'] . ".php";
    if(file_exists($module_mode_file)) {
        require_once($module_mode_file);
        $show_default = false;
    }
}


if($show_default && file_exists(dirname(__FILE__) . "/im_cinemas_default.php")) {
    include(dirname(__FILE__) . "/im_cinemas_default.php");
}