<?php /* * Describe what it does to show you're not that dumb! * **/ /** @var $ctrl \bbn\mvc\controller */ if (isset($ctrl->post['ref'])) { $path = BBN_USER_PATH . 'tmp/' . $ctrl->post['ref']; $files = \bbn\file\dir::get_files($path); $ctrl->post['files'] = $files; } $ctrl->obj = $ctrl->get_object_model($ctrl->post);
function tree($path, $ver_path, $c = false, $ext = false) { $res = []; foreach (\bbn\file\dir::get_files($path, 1) as $p) { if (empty($ext) || !empty($ext) && (\bbn\str::file_ext($p) === $ext || \bbn\str::file_ext($p) === '')) { $pa = substr($p, strlen($ver_path), strlen($p)); $r = ['text' => basename($p), 'path' => strpos($pa, '/') === 0 ? substr($pa, 1, strlen($pa)) : $pa]; if (!empty($c) && in_array($r['path'], $c)) { $r['checked'] = 1; } if (is_dir($p)) { $r['items'] = tree($p, $ver_path, $c, $ext); } if (!is_dir($p) || is_dir($p) && !empty($r['items'])) { array_push($res, $r); } } } return $res; }
<?php /** @var $model \bbn\mvc\model */ //die(\bbn\file\dir::get_files(BBN_LOG_PATH)); $log_files = array_filter(\bbn\file\dir::get_files(BBN_DATA_PATH . 'logs'), function ($a) { return substr($a, -3) === 'log'; }); if (($log_file = ini_get('error_log')) && strpos($log_file, BBN_DATA_PATH . 'logs') === false) { array_unshift($log_files, $log_file); } $res = []; foreach ($log_files as $lf) { $res[basename($lf)] = $lf; } ksort($res); if (isset($model->data['log'])) { $output = []; if ($model->data['clear']) { file_put_contents($res[$model->data['log']], ''); } else { $file = escapeshellarg($res[$model->data['log']]); // for the security concious (should be everyone!) $num_lines = isset($model->data['num_lines']) && \bbn\str::is_integer($model->data['num_lines']) && $model->data['num_lines'] > 0 && $model->data['num_lines'] <= 1000 ? $model->data['num_lines'] : 100; $line = "tail -n {$num_lines} {$file}"; exec($line, $output); $res = []; $pid = 0; } return ['content' => implode("\n", $output)]; } else { $data = ['logs' => []];
} } } } } else { // Get files and folders $path = $path . (empty($model->data['path']) ? '' : $model->data['path']); $ff = \bbn\file\dir::get_files($path, 1); foreach ($ff as $f) { if (is_dir($f)) { // Folder name $fn = basename($f); // Add folder to array $folders[$fn] = ['path' => (empty($model->data['path']) ? '' : $model->data['path'] . '/') . $fn, 'name' => $fn, 'has_index' => \bbn\file\dir::has_file($f, 'index.php', 'index.html', 'index.htm') ? 1 : false, 'dir' => $current, 'parenthood' => true, 'is_svg' => false, 'is_viewable' => false, 'is_image' => false, 'default' => false, 'icon' => "folder-icon", 'bcolor' => $dir['bcolor'], 'type' => "dir"]; if (empty($model->data['onlydir'])) { $folders[$fn]['is_parent'] = count(\bbn\file\dir::get_files($f, 1)) > 0; } else { $folders[$fn]['is_parent'] = count(\bbn\file\dir::get_dirs($f)) > 0; } } else { if (empty($model->data['onlydir']) && !in_array(\bbn\str::file_ext($f), $excluded)) { // File extension $ext = \bbn\str::file_ext($f); // Filename $fn = \bbn\str::file_ext($f, 1)[0]; // Add file $files[$f] = ['path' => (empty($model->data['path']) ? '' : $model->data['path'] . '/') . basename($f), 'name' => $fn, 'has_index' => false, 'is_parent' => false, 'parenthood' => false, 'dir' => $current, 'is_svg' => $ext === 'svg', 'is_viewable' => in_array($ext, $file_check['viewables']) && $ext !== 'svg' ? true : false, 'is_image' => in_array($ext, $file_check['images']), 'default' => false, 'ext' => in_array($ext, $ext_icons) ? $ext : 'default', 'bcolor' => $dir['bcolor'], 'type' => "file"]; $files[$f]['default'] = !$files[$f]['is_svg'] && !$files[$f]['is_viewable'] && !$files[$f]['is_image'] ? true : false; } } }
<?php /* * Describe what it does to show you're not that dumb! * **/ /** @var $ctrl \bbn\mvc\controller */ if (isset($ctrl->arguments[0]) && is_array($o = $ctrl->inc->options->get_cfg($ctrl->arguments[0]))) { $ctrl->add_data($o, ['id' => $ctrl->arguments[0], 'values' => $ctrl->inc->options->text_value_options($ctrl->arguments[0]), 'controllers' => array_map(function ($a) { $len = strlen(BBN_APP_PATH . 'mvc/private/'); $tmp = $len + strlen('_options/'); return ['text' => substr($a, $tmp, -4), 'value' => substr($a, $len, -4)]; }, array_filter(\bbn\file\dir::get_files(BBN_APP_PATH . 'mvc/private/_options'), function ($b) { return substr($b, -4) === '.php'; }))])->combo("Configuration", $ctrl->data); }