HEX
Server: Apache
System: Linux wyse1.wyseservers.com 4.18.0-553.124.4.el8_10.x86_64 #1 SMP Fri May 15 04:14:14 EDT 2026 x86_64
User: kochikidswysewor (1061)
PHP: 8.3.33
Disabled: NONE
Upload Files
File: /home/kochikidswysewor/public_html/wp-content/themes/children-charity-child/case-submission.php
<?php 
 include '../../../wp-load.php';
    if($_REQUEST['action']===""){
           	echo "<script>alert('Invalid data!');window.location.href='".get_site_url()."'</script>";
           }
    if ( $_REQUEST['action']=="add-cause" ){ 
        $cause_title=$_POST['cause_title'];
        $agency_name=$_POST['agency_name']; 
        // $agency_location=$_POST['agency_location'];
        $cause_description=$_POST['cause_description'];
        if($_POST['cause_title'] && $_POST['agency_name']){
            $term = term_exists( $cause_title, 'children_categories' ); 
            if ( $term !== 0 && $term !== null ) {
               echo "0";
            }
            else {
               $add_cat = wp_insert_term( $cause_title, 'children_categories', $args = array('description' => $cause_description,) );
               // my_acf_pre_save_post($post_id);
               // echo $agency_name;exit;
                   update_field( 'field_63ce1eed09949', $agency_name, 'children_categories_'.$add_cat['term_id']);
                   // update_field( 'field_63ce1f020994a', $agency_location, $add_cat['term_id']);
              
               echo "1"; 
            }
            
        }
    }
    if ( $_REQUEST['action']=="add-case" ){ 
        $current_user = wp_get_current_user();
        $agency = $current_user->ID;
        $select_cause=$_POST['select_cause'];
        $case_title=$_POST['case_title'];
        $case_date=$_POST['case_date'];
        $case_description=$_POST['case_description'];
        // $birthday=$_POST['birthday'];
        // $age=$_POST['age'];
        // $hobbies=$_POST['hobbies'];
        $file_upload=$_FILES['profile_pic'];
        $url = '';
        if($_POST['select_cause'] && $_POST['case_title']){
              $post_id = wp_insert_post( array(
                  'post_type' => 'children',
                  'post_title'    => $_POST['case_title'],
                  'post_content'  => $_POST['case_description'],
                  // 'post_category' => $_POST['select_cause'],
                  'post_status'   => 'publish',
                  'post_status'   => 'publish',
              ) );
              wp_set_post_terms( $post_id,$_POST['select_cause'], 'children_categories' );
         
              // my_acf_pre_save_post($post_id);
              if( ! ( wp_is_post_revision( $post_id ) || wp_is_post_autosave( $post_id ) ) ) {
                  update_field( 'field_63ca95356c7b6', $case_date, $post_id );
                  update_field( 'field_63ca57c302e25', $agency, $post_id );
                  // update_field( 'field_5e204aa60da1b', $hobbies, $post_id );
                  // update_field( 'field_5e204a810da1a', $birthday, $post_id );
                  // update_field( 'field_5e2044ee0da19', $age, $post_id );
                  // update_field( 'field_63ca95016c7b4', $branch_name, $post_id );
                  // update_field( 'field_63ca950d6c7b5', $ifsc_code, $post_id );
              }

              $url = '';
              if (isset($file_upload))
              {
                 
                  $uploadedfile = $file_upload['name'];
                  $upload_name = $file_upload['name'];
                  $uploads = wp_upload_dir();
                  if (!function_exists('wp_handle_upload'))
                  {
                         require_once( ABSPATH . 'wp-admin/includes/file.php' );
                  }

                  // require_once ('../../../wp-admin/includes/image.php');

                  $upload_overrides = array(
                  'test_form' => false
                  );  

                  $movefile = wp_handle_upload($file_upload, $upload_overrides); 
                  if ($movefile && !isset($movefile['error']))
                  {
                      $file = $movefile['file'];
                      $url = $movefile['url'];
                      $type = $movefile['type'];

                      // media_handle_upload( $file_handler, 0 );

                      $attachment = array(
                      'post_mime_type' => $type,
                      'post_title' => $upload_name,
                      'post_parent' => $post_id
                      //'post_parent' => 0 //IF DONT WANT TO ATTACH POST ID
                      );
                      $attach_id = wp_insert_attachment($attachment, $file, $post_id);
                      // update_field( 'field_640eb2a117ae7', $attach_id, $post_id );
                      set_post_thumbnail( $post_id, $attach_id );

                      }

              }
              echo "Case Added Successfully";
          }



    }
?>