<?php require_once __DIR__."/../includes/functions.php"; require_admin(); $pageTitle="Upload Check"; include __DIR__."/_header.php"; ?>
<div class="content-header"><div class="container-fluid"><h1 class="m-0">Upload Folder Check</h1></div></div>
<section class="content"><div class="container-fluid">
<div class="card"><div class="card-body">
<?php
$folders=['listings','companies','users','documents','payment-proof','deals','services'];
echo '<table class="table table-bordered table-striped"><thead><tr><th>Folder</th><th>Path</th><th>Exists</th><th>Writable</th><th>Action</th></tr></thead><tbody>';
foreach($folders as $folder){
  $path=realpath(__DIR__.'/../assets') ?: (__DIR__.'/../assets');
  $path.='/uploads/'.$folder;
  if(!is_dir($path)){ @mkdir($path,0775,true); }
  if(is_dir($path) && !is_writable($path)){ @chmod($path,0775); }
  echo '<tr><td>'.e($folder).'</td><td><code>'.e($path).'</code></td><td>'.(is_dir($path)?'<span class="badge badge-success">Yes</span>':'<span class="badge badge-danger">No</span>').'</td><td>'.(is_writable($path)?'<span class="badge badge-success">Yes</span>':'<span class="badge badge-danger">No</span>').'</td><td>';
  if(!is_writable($path)) echo 'Set permission 755/775'; else echo 'OK';
  echo '</td></tr>';
}
echo '</tbody></table>';
echo '<p><b>PHP file_uploads:</b> '.(ini_get('file_uploads')?'On':'Off').'</p>';
echo '<p><b>upload_max_filesize:</b> '.e(ini_get('upload_max_filesize')).'</p>';
echo '<p><b>post_max_size:</b> '.e(ini_get('post_max_size')).'</p>';
echo '<p><b>upload_tmp_dir:</b> '.e(ini_get('upload_tmp_dir') ?: sys_get_temp_dir()).'</p>';
?>
</div></div></div></section>
<?php include __DIR__."/_footer.php"; ?>
