Skip to content

Commit

Permalink
Move public accessible code into a separate directory (#2504)
Browse files Browse the repository at this point in the history
  • Loading branch information
usox committed Aug 16, 2020
1 parent 5c1c77e commit 63343b9
Show file tree
Hide file tree
Showing 627 changed files with 226 additions and 186 deletions.
15 changes: 8 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,29 @@
/play/.htaccess
/rest/.htaccess
/tmp/
/src/public/lib/components
bootstrap/
components/
core/
cs_fixer_tmp_*
develop/
master/
node_modules/
php-cs-fixer.phar
public/
resources/
robots.txt
storage/
vendor/
.settings/
.vscode/
.idea/
cs_fixer_tmp_*
.buildpath
.env
.pc
.php_cs.cache
.project
.settings/
.vscode/
.idea/
php-cs-fixer.phar
composer.phar
robots.txt
web.config
phpcbf*
phpcs*
Expand All @@ -45,4 +47,3 @@ phpcs*
*.swp
*.v11.suo
*~
composer.phar
13 changes: 11 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"config":
{
"vendor-dir": "lib/vendor",
"component-dir": "lib/components",
"component-dir": "src/public/lib/components",
"platform": {
"ext-curl": "1.0",
"ext-gd": "1.0",
Expand Down Expand Up @@ -57,7 +57,7 @@
"maennchen/zipstream-php": "0.4.*",
"mikealmond/musicbrainz": "dev-master",
"needim/noty": "2.4.*",
"oomphinc/composer-installers-extender": "^1.1",
"oomphinc/composer-installers-extender": "^2.0",
"openid/php-openid": "2.*",
"phpmailer/phpmailer": "6.1.*",
"pklauzinski/jscroll": "2.*",
Expand Down Expand Up @@ -329,6 +329,15 @@
"recurse": false,
"replace": false,
"merge-extra": false
},
"sort-packages": true,
"installer-types": ["component", "library"],
"installer-paths": {
"src/public/lib/components/noty/": ["needim/noty"],
"src/public/lib/components/jquery-file-upload/": ["blueimp/jquery-file-upload"],
"src/public/lib/components/happyworm-jplayer/": ["happyworm/jplayer"],
"src/public/lib/components/{$name}/": ["type:component"],
"lib/vendor/{$vendor}/{$name}": ["type:library"]
}
},
"autoload": {
Expand Down
47 changes: 32 additions & 15 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions lib/class/session.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,10 @@ public static function _auto_init()
return true;
}

public static function gc() {

}

/**
* create_cookie
*
Expand Down
7 changes: 5 additions & 2 deletions lib/class/ui.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,18 @@ public function __construct()
* @param string $template
* @return string
*/
public static function find_template($template)
public static function find_template($template, bool $extern = false)
{
$path = AmpConfig::get('theme_path') . '/templates/' . $template;
$realpath = AmpConfig::get('prefix') . $path;
$extension = strtolower(pathinfo($path, PATHINFO_EXTENSION));
if (($extension != 'php' || AmpConfig::get('allow_php_themes')) && file_exists($realpath) && is_file($realpath)) {
return $path;
} else {
return '/templates/' . $template;
if ($extern === true) {
return '/templates/' . $template;
}
return '/src/public/templates/' . $template;
}
}

Expand Down
3 changes: 2 additions & 1 deletion lib/init-tiny.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
throw new RuntimeException(T_("Ampache requires PHP version >= 7.1"));
}

error_reporting(E_ERROR); // Only show fatal errors in production
//error_reporting(E_ERROR); // Only show fatal errors in production

$load_time_begin = microtime(true);

Expand All @@ -50,6 +50,7 @@

// Define some base level config options
AmpConfig::set('prefix', $prefix);
AmpConfig::set('prefix-public', $prefix.'/src/public');

// Register autoloaders
spl_autoload_register(array('Core', 'autoload'), true, true);
Expand Down
8 changes: 4 additions & 4 deletions lib/themes.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
function get_themes()
{
/* Open the themes dir and start reading it */
$handle = opendir(AmpConfig::get('prefix') . '/themes');
$handle = opendir(AmpConfig::get('prefix-public') . '/themes');

if (!is_resource($handle)) {
debug_event('themes', 'Failed to open /themes directory', 2);
Expand Down Expand Up @@ -75,7 +75,7 @@ function get_theme($name)
return $_mapcache[$name];
}

$config_file = AmpConfig::get('prefix') . "/themes/" . $name . "/theme.cfg.php";
$config_file = AmpConfig::get('prefix-public') . "/themes/" . $name . "/theme.cfg.php";
if (file_exists($config_file)) {
$results = parse_ini_file($config_file);
$results['path'] = $name;
Expand All @@ -101,7 +101,7 @@ function get_theme($name)
*/
function get_theme_author($theme_name)
{
$theme_path = AmpConfig::get('prefix') . '/themes/' . $theme_name . '/theme.cfg.php';
$theme_path = AmpConfig::get('prefix-public') . '/themes/' . $theme_name . '/theme.cfg.php';
$results = read_config($theme_path);

return $results['author'];
Expand All @@ -115,7 +115,7 @@ function get_theme_author($theme_name)
*/
function theme_exists($theme_name)
{
$theme_path = AmpConfig::get('prefix') . '/themes/' . $theme_name . '/theme.cfg.php';
$theme_path = AmpConfig::get('prefix-public') . '/themes/' . $theme_name . '/theme.cfg.php';

if (!file_exists($theme_path)) {
return false;
Expand Down
Binary file removed php-cs-fixer
Binary file not shown.
2 changes: 1 addition & 1 deletion admin/access.php → src/public/admin/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
*/

require_once '../lib/init.php';
require_once __DIR__.'/../../../lib/init.php';

if (!Access::check('interface', 100)) {
UI::access_denied();
Expand Down
2 changes: 1 addition & 1 deletion admin/catalog.php → src/public/admin/catalog.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
*/

require_once '../lib/init.php';
require_once __DIR__.'/../../../lib/init.php';
require_once AmpConfig::get('prefix') . '/modules/catalog/local/local.catalog.php';

if (!Access::check('interface', 75)) {
Expand Down
2 changes: 1 addition & 1 deletion admin/duplicates.php → src/public/admin/duplicates.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
*/

require_once '../lib/init.php';
require_once __DIR__.'/../../../lib/init.php';

if (!Access::check('interface', 75)) {
UI::access_denied();
Expand Down
2 changes: 1 addition & 1 deletion admin/export.php → src/public/admin/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
*/

require_once '../lib/init.php';
require_once __DIR__.'/../../../lib/init.php';

if (!Access::check('interface', 75)) {
UI::access_denied();
Expand Down
2 changes: 1 addition & 1 deletion admin/index.php → src/public/admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
*/

require_once '../lib/init.php';
require_once __DIR__.'/../../../lib/init.php';

if (!Access::check('interface', 75)) {
UI::access_denied();
Expand Down
2 changes: 1 addition & 1 deletion admin/license.php → src/public/admin/license.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
*/

require_once '../lib/init.php';
require_once __DIR__.'/../../../lib/init.php';

if (!Access::check('interface', 75)) {
UI::access_denied();
Expand Down
2 changes: 1 addition & 1 deletion admin/mail.php → src/public/admin/mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
*/

require_once '../lib/init.php';
require_once __DIR__.'/../../../lib/init.php';

if (!Access::check('interface', 75)) {
UI::access_denied();
Expand Down
2 changes: 1 addition & 1 deletion admin/modules.php → src/public/admin/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
*/

require_once '../lib/init.php';
require_once __DIR__.'/../../../lib/init.php';

if (!Core::get_global('user')->has_access(100)) {
UI::access_denied();
Expand Down
2 changes: 1 addition & 1 deletion admin/shout.php → src/public/admin/shout.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
*/

require_once '../lib/init.php';
require_once __DIR__.'/../../../lib/init.php';

if (!Access::check('interface', 100)) {
UI::access_denied();
Expand Down
2 changes: 1 addition & 1 deletion admin/system.php → src/public/admin/system.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
*/

require_once '../lib/init.php';
require_once __DIR__.'/../../../lib/init.php';

if (!Access::check('interface', 100) || AmpConfig::get('demo_mode')) {
UI::access_denied();
Expand Down
2 changes: 1 addition & 1 deletion admin/users.php → src/public/admin/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
*/

require_once '../lib/init.php';
require_once __DIR__.'/../../../lib/init.php';

if (!Access::check('interface', 100)) {
UI::access_denied();
Expand Down
2 changes: 1 addition & 1 deletion albums.php → src/public/albums.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
*/

require_once 'lib/init.php';
require_once __DIR__.'/../../lib/init.php';

require_once AmpConfig::get('prefix') . UI::find_template('header.inc.php');

Expand Down
2 changes: 1 addition & 1 deletion artists.php → src/public/artists.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
*/

require_once 'lib/init.php';
require_once __DIR__ . '/../../lib/init.php';

UI::show_header();

Expand Down
Loading

0 comments on commit 63343b9

Please sign in to comment.