/** * Return the configuration array of a configuration file * * @param string $path the configuration file path or false to let the function load the global configuration * * @return array the configuration array or null if file is invalid or if configuration file does not exist */ function get_config_file($path = false) { if ($path === false) { $path = get_config_file_path(); } if (is_null($path)) { return null; } if (strtolower(substr($path, -3, 3)) === 'php') { ob_start(); require $path; $string = ob_get_clean(); } else { $string = @file_get_contents($path); } return json_decode($string, true); }
/* |-------------------------------------------------------------------------- | Logs 1. Check if $config_file already exists |-------------------------------------------------------------------------- | */ /* |-------------------------------------------------------------------------- | Logs 1. Check if $config_file already exists |-------------------------------------------------------------------------- | */ case 'exist': $config_file_name = get_config_file_name(); if (!is_null($config_file_name)) { $return['notice'] = __('Please remove it manually if you want me to create it:') . '<br/><br/>' . '<div class="row">' . ' <div class="col-md-9"><pre class="clipboardcontent">' . 'rm \'' . get_config_file_path() . '\'</pre></div>' . ' <div class="col-md-3"><a class="btn btn-primary clipboard">' . __('Copy to clipboard') . '</a><script>clipboard_enable("a.clipboard","pre.clipboardcontent" , "top" , "' . __('Command copied!') . '");</script></div>' . '</div>'; throw new Exception(sprintf(__('File <code>%s</code> already exists.'), $config_file_name)); } break; /* |-------------------------------------------------------------------------- | Logs 2. Try to touch $config_file_temp |-------------------------------------------------------------------------- | */ /* |-------------------------------------------------------------------------- | Logs 2. Try to touch $config_file_temp |-------------------------------------------------------------------------- | */
} else { echo json_indent(json_encode($logs)); } ?> </pre></div></div></div><div class="panel panel-default"><div class="panel-heading"><h4 class="panel-title"><a data-toggle="collapse" data-parent="#accordion2" href="#collapseFour2"><?php _e('Rights'); ?> </a></h4></div><div id="collapseFour2" class="panel-collapse collapse"><div class="panel-body"><pre><?php if (function_exists('posix_getpwuid')) { var_dump(@posix_getpwuid(posix_geteuid())); } else { _e('No POSIX functions...'); } ?> </pre><?php $paths = array('config' => get_config_file_path()); if (is_array(@$files)) { foreach ($files as $fileid => $file) { $paths['--> ' . $fileid] = @$file['path']; $dir_name = realpath($file['path']); if (file_exists($dir_name)) { while ($dir_name != dirname($dir_name)) { $dir_name = dirname($dir_name); $paths[$dir_name] = $dir_name; } } } } echo '<div class="table-responsive"><table>'; echo '<thead><tr><th>' . __('Read') . '</th><th>' . __('Write') . '</th><th>ID</th><th>' . __('Path') . '</th><th>' . __('Real path') . '</th></tr></thead>'; echo '<tbody>';