<?php
    header('Access-Control-Allow-Origin: *');
    header('Access-Control-Allow-Methods: GET, POST');
    header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");
    include '../../../config/index.php';
    $data = file_get_contents( 'php://input' );
    $obj = json_decode( $data, true );

    $db_description = 'descriptions/'.time();
    $dv_file = '/home/sendusco/app/descriptions/'.time();

    $file = fopen( $dv_file, 'w' ) or die( 'Unable to open file!' );

    fwrite( $file, $_POST[ 'EditConceptValue' ] );

    fclose( $file );

    $sql = "UPDATE course_lesson_structure_concepts SET
                concept_name='".$_GET["EditConceptName"]."',
                concept_time='".$_GET["EditConceptTime"]."',
                concept='".$db_description."'
            WHERE course_lesson_structure_concepts_id='".$_GET["course_lesson_structure_concepts_id"]."'
        ";

    if (mysqli_query($conn, $sql)) {
        $curl_post_data = array(
            'Success' => 'true',
            'Reason' => 'You Have Succesfully Added A Main Concept',
            'course_desired_outcomes_id' => $_GET["course_desired_outcomes_id"],
        );
        echo json_encode($curl_post_data);
    } else {
        $curl_post_data = array(
            'Success' => 'false',
            'Reason' => 'You Were Unsuccesfull in adding a Main COncept',
            'course_desired_outcomes_id' => $_GET["course_desired_outcomes_id"],
        );
        echo json_encode($curl_post_data);
    }
    function RemoveSpecialChar($str) {

        $res = str_replace( array( '\'', '"', ',' ,':' , '.' , ' ', ';', '<', '>' ), '_', $str);
    
        // Returning the result 
        return $res;
    }

  
?>