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/www/wp-content/themes/children-charity-child/user_login.php=old
<?php 
 include '../../../wp-load.php';

           if($_REQUEST['action']===""){

           	echo "<script>alert('Invalid data!');window.location.href='".get_site_url()."'</script>";

           }

         function user_login_custom($username,$password,$remember){
            if($remember==""){ 
            	$remember=false;
            }

            $creds = array();
			$creds['user_login'] = $username;
			$creds['user_password'] = $password;
			$creds['remember'] =$remember;
			$user = wp_signon( $creds, false ); 
			if(is_wp_error($user)===false){
					if(in_array("sponser",$user->caps) ){ 
		            if ( is_wp_error($user) )
					{

					    return false;
					}
					else
					{

					    return true;
					}
	            }else{
	            	return "#500";
	            }
			}else{
				return false;
			}
            
			


         }
       

       function check_custom_logged_in(){

         
         if ( is_user_logged_in() ) {
         
           global $current_user;

				if( in_array( "subscriber" , $current_user->roles ) ){

				   return true;

				}else{
				   return false;

				}

           }else{

				   return false;

				}
		
		}
        
        function isValidEmail($email){ 
		    return filter_var($email, FILTER_VALIDATE_EMAIL) !== false;
		}


        function password_reset_by_email($email){
             
             //php mailer variables
        	   $admin_email = get_option('admin_email');  //admin email fetch
				   $user = get_user_by('email', $email);    //getting user information by email
                   $user_id=$user->ID;                    //getting user ID
                   if($user_id){                           
                   	$random_password = wp_generate_password( $length=12, $include_standard_special_chars=false );
                   
                   }else{
                   	 return false;
                   }
				   
				  
                   if($user){
                         $body_="New password:".$random_password;
    $body='<table width="700px" cellpadding="0" cellspacing="0" style="width:700px;
	border-left:1px solid #171717; 
	border-top:1px solid #171717;
	font-family:Arial, Helvetica, sans-serif;
	font-size:13px;
	color:#000;
	margin:0 auto;">
  <tbody><tr style="background:#fff;">
    <td colspan="2" style="padding:0px !important;border-right:1px solid #171717;
	border-bottom:0px solid #171717;
	">
	
	<a href="http://kochikids.org/" title="Kochi Kids" style="font-family:Arial, Helvetica, sans-serif;
	font-size:13px;
	color:#000;
	text-decoration:underline;">
	<img src="http://kochikids.org/wp-content/themes/children-charity/img/mail-template.jpg" alt="Kochi Kids"></a>
</td>
  </tr>
 <tr>
    <td colspan="2" style="border-right:1px solid #171717;
	border-bottom:1px solid #171717;
	padding:5px;">    
     
     Hi, 
     <br>
      <br>
      Your password has been successfully been reset and following is your new password.<br>
    '.$body_.'  <br> <br>
   </td>
  </tr>  <tr>
		<td colspan="2" class="footer-template" style="background:#d13777;
	text-align:center;border-right:1px solid #171717;
	border-bottom:1px solid #171717;
	padding:5px;"><a href="http://kochikids.org/" target="_blank" title="Kochi Kids" style="color:#fff ; 
	text-align:center;
	text-decoration:none !important;">Kochi Kids</a></td>
	  </tr>
	</tbody></table>';
                   	    
                   	    $subject = "Kochi Kids - Password Reset";						
						$headers = "MIME-Version: 1.0\r\n";
						$headers.="Content-Type: text/html;\n\tcharset=\"iso-8859-1\"\n";
						// $headers.= "From:".$this->admin_mailto."\r\n";
						$headers.= "From: Kochi Kids <".$admin_email."> \r\n";
						 $send=wp_mail($email,$subject,$body,$headers);
						if($send){
						  wp_update_user(array('ID' =>$user_id, 'user_pass' => $random_password));
						  	return true;
						}
                   }


                 	
        }
        

         /* if(check_custom_logged_in()){
          	echo "logged in";
          }*/
   
         // var_dump(add_new_subscriber("testt","albert.techintll@gmail.com","@#$%23425345"));
           
           /*$_REQUEST['action']="reset";
           $_POST['user_name']="test";
           $_POST['user_email']="albert.techintl@gmail.com";
           $_POST['user_pass']="6vp552zXV374";*/
          // print_r($_POST);
          if ( $_REQUEST['action']=="add" ){ 
            //print_r($_POST);
           
            $user_email=$_POST['user_email'];
            // $user_name=$_POST['user_email']; echo $user_name;
            $user_name=$_POST['user_name']; 
            $user_pass=$_POST['user_pass'];
            $user_phone=$_POST['user_phone'];
            // $user_department=$_POST['user_department'];
            $array =array();
            $array = $_POST;
            unset($array['user_name']);
            unset($array['user_pass']);
            unset($array['user_email']);
            if($user_name!="" && $user_email!="" && $user_pass!=""){

            	if(isValidEmail($user_email)){
            		$userdata = array(
					'user_login' =>  $user_name,
					'user_email'   =>  $user_email,
					'user_pass'  =>  $user_pass,
					'role' =>'sponser'
					);

					$user_id = wp_insert_user( $userdata ) ;
					// echo "user_phone====".$user_phone; echo "user_iddd===".$user_id;
					update_field( 'field_5e21529193bda', $user_phone, $user_id );
	             // $result=add_new_subscriber($user_name,$user_email,$user_pass);
	             // print_r($user_id);

	             	if($user_id){
	             		foreach ($array as $key => $value) {
	             			update_user_meta( $user_id, $key, $value);
	             		}
	             		// update_user_meta( $user_id, $key, $value);
	             		// update_user_meta( $user_id, 'user_department', $user_department);
	             	   //do_action( 'personal_options_update', 'save_custom_userprofile_fields',$user_phone,$user_id);
	                   echo "1" ;
	                 }
	                 else{
	                   echo 0;
	                 }

                }	

            }
              

          }else if($_REQUEST['action']=="reset"){
  
              $user_email=$_POST['reset_user_email'];
              
              if($user_email!=""){

	            	if(isValidEmail($user_email)){
		                
		                if(password_reset_by_email($user_email)==true){
		                	echo "1" ;
		                }else{
		                	echo "Email address not found!";
		                }
		                
	 
	                 }	

               }else{
               	   echo "Enter email address";
               }

          } else if($_REQUEST['action']=="login"){
// print_r($_POST); exit;
          	$user_name=$_POST['user_name']; 
          	$user_pass=$_POST['user_pass'];
          	$remember=$_POST['remember'];
           
           if($user_name!="" && $user_pass!=""){

	             $result=user_login_custom($user_name,$user_pass,$remember);
	             	if($result===true){
	                   echo "1" ;
	                 }
	                 else if($result=="#500"){
	                 	echo "#500";
	                 }
	                 else{
	                   echo "0" ;
	                 }

                	
            }

          }else if($_REQUEST['action']=="logout"){
          	wp_logout();
          	header("location:http://kochikids.org");
          }