sparqapi/api/application/helpers/external_dir_check_helper.php
2020-10-27 00:58:28 +05:30

72 lines
1.5 KiB
PHP

<?php
class EXTERNAL_DIR_CHECK
{
// Create the logger
public static function checkExternalDirectory($pd_id = null,$path_to_check = null)
{
//echo 'EXTERNAL_DIR_CHECK called';
if($path_to_check == null)
{
$path = XLPATH;
}
else
{
$path = $path_to_check;
}
if(!file_exists($path))
{
mkdir($path,0777);
}
// $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',$path.'/tmp');
foreach ($array as $key => $value)
{
if(!file_exists($value))
{
mkdir($value,0777);
}
}
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');
}
}
?>