<?php

	$extra = null;

	if(login_control()) {
        $status = $db->from("settings")->where("id",1)->first();
        $status = json_decode($status['childpanel'],1);
        if($status['status'] == 1){
		$child = $db->from('child_panels')->where('user_id', session('user_id'))->first();

		if($child){
			$childadmin = json_decode($child['panel_detail']);
		}

		$title = "Child Panel";
		$integration = "";

		foreach($plugins as $plugin){

			if ($plugin['app_id'] !== 1 && $plugin['app_id'] !== 2 && $plugin['app_id'] !== 3 && $plugin['app_id'] !== 4 && $plugin['app_id'] !== 5) {

				@$data = json_decode($plugin['app_data'], true);

				if(@$data['visibility'] == 0){ // Tüm Sayfalar
					@$integration .= $data['code'];
				}elseif($data['visibility'] == 1){ // Giriş Yapanlar
					@$integration .= $data['code'];
				}

			}

		}

		require view("child");

		$extra = [
			"{INTEGRATIONS}" => $integration
		];

	} else {

		require controller("404");

	}
	    
	}else {

		require controller("404");

	}

	$output = ob_get_clean();
	echo replace($output, $extra);