sparqapi/api/application/helpers/external_dir_check_helper.php

65 lines
1.4 KiB
PHP

<?php
class EXTERNAL_DIR_CHECK
{
// Create the logger
public static function checkExternalDirectory($pd_id = null) //$msg,$data,$log_type
{
//echo 'EXTERNAL_DIR_CHECK called';
$path = $_SERVER['DOCUMENT_ROOT'].'/ssa_external_data';
if(!file_exists($path))
{
mkdir($path,0761);
}
$path .='/'.ENVIRONMENT;
if(!file_exists($path))
{
mkdir($path,0761);
}
$array = array($path.'/ci_logs',$path.'/api_request_logs',$path.'/app_logs',$path.'/pd_reports',$path.'/sales_pd',$path.'/sales_pd_logs');
foreach ($array as $key => $value)
{
if(!file_exists($value))
{
mkdir($value,0761);
}
}
if($pd_id != null)
{
$pd_folder = $array[3].'/'.$pd_id;
if(!file_exists($pd_folder))
{
mkdir($pd_folder,0777);
}
}
// $fp = fopen($path.'/ci_logs/sample.html','a');
// $data = '<h1>WELCOME</h1>';
// fwrite($fp, $data);
// $data = '<h2>DSKFHLKSDFNSLDKN</h2>';
// fwrite($fp, $data);
// fclose($fp);
// $str = file_get_contents($path.'/ci_logs/sample.html');
// echo $str;
// $log = MYLOG::logFunction2($path.'/ci_logs');
// $log->info('EXTERNAL LOG IINFO',array(1,2));
// $log->error('EXTERNAL LOG ERROR',array(3,4));
// $CI =& get_instance();
// echo $CI->config->item('log_path');
// log_message('error','Hi this');
// $CI->config->set_item('log_path', $path.'/api_request_logs');
// echo $CI->config->item('log_path');
// log_message('error','Hi this');
}
}
?>