HEX
Server: Apache/2.4.41 (Amazon) OpenSSL/1.0.2k-fips PHP/5.6.40
System: Linux ip-172-31-40-18 4.14.146-93.123.amzn1.x86_64 #1 SMP Tue Sep 24 00:45:23 UTC 2019 x86_64
User: apache (48)
PHP: 5.6.40
Disabled: NONE
Upload Files
File: /var/www/html/pmw24/pmw_live_testing/app/application/helpers/common_helper.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

if ( ! function_exists('test_method'))
{
    function registration_mail($params){
       $params['config']=email_settings();
       sendmail($params);
       return 1;
    } 
    function forgotpassword_mail($params){
       $params['config']=email_settings();
       sendmail($params);
       return 1; 
    } 
    function email_settings(){
        $config['protocol']    = 'smtp';
        $config['smtp_host']    = 'mail.pmw24.com.au'; 
        $config['smtp_port']    = '587';        
        $config['smtp_user']    = 'info@pmw24.com.au';
        $config['smtp_pass']    = 'Info123@';
        $config['charset']    = 'utf-8';
        $config['newline']    = "\r\n";
        $config['mailtype'] = 'html'; // or html
        $config['validation'] = TRUE; // bool whether to validate email or not     
        return $config;  
       /* $config['protocol']    = 'smtp';
        $config['smtp_host']    = 'mail.met-technologies.com';
        $config['smtp_port']    = '25';        
        $config['smtp_user']    = 'developer.net@met-technologies.com';
        $config['smtp_pass']    = 'Dot123@#$%';
        $config['charset']    = 'utf-8';
        $config['newline']    = "\r\n";
        $config['mailtype'] = 'html'; // or html
        $config['validation'] = TRUE; // bool whether to validate email or not     
        return $config; */
    } 
    function sendmail($params){
        $obj =get_object();
        $obj->load->library('email');
        $obj->email->initialize($params['config']);
        $obj->email->from('info@pmw24.com.au',$params['name']); 
        $obj->email->to($params['to']); 
        $obj->email->subject($params['subject']);
        $obj->email->message($params['message']);
        $obj->email->set_crlf( "\r\n" ); 
        $obj->email->send(); 
        return $obj->email->send();
        //echo $obj->email->print_debugger();die;
    }
    function get_user_role_type(){
      $user_role=get_object()->session->userdata('user_role');
      return $user_role;
    } 
    function get_object(){
      $obj =& get_instance();
      return $obj;
    }
    function array_to_csv($array, $download = "")
    {

        $n = 0;  
        //$handle = fopen("$download","w");
        $output_file_path = 'public/reports/'.$download; 

        $handle = fopen($output_file_path, 'w');
        foreach ($array as $line)
        {
            $n++;
            fputcsv($handle, $line);
        }
        fclose($handle);   
    }
    function query_to_csv($query, $headers = TRUE, $download = "")
    {

        if ( ! is_object($query) OR ! method_exists($query, 'list_fields'))
        {
            show_error('invalid query');
        }
        
        $array = array();
        
        if ($headers)
        {
            $line = array();
            foreach ($query->list_fields() as $name)
            {
                $line[] = $name;
            }
            $array[] = $line;
        }
        
        foreach ($query->result_array() as $row)
        {
            $line = array();
            foreach ($row as $item)
            {
                $line[] = $item;
            }
            $array[] = $line;
        }
         //print_r($array); die;
         array_to_csv($array, $download);
    }
  
}