1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ampache_ynh.git synced 2024-09-03 18:15:55 +02:00

update ampache to 3.8.2 and do yunohost 2.4 compatibility

This commit is contained in:
aymhce 2016-06-04 21:19:05 +02:00
parent 9fc961558c
commit dbe010e230
2480 changed files with 89257 additions and 402259 deletions

View file

@ -12,6 +12,9 @@
"email": "beudbeud@beudibox.fr"
},
"multi_instance": "true",
"requirements": {
"yunohost": ">> 2.3.12.1"
},
"services" : [
"nginx",
"php5-fpm",

View file

@ -1,14 +1,18 @@
#!/bin/bash
# Retrieve arguments
app=$YNH_APP_INSTANCE_NAME
domain=$1
path=$2
admin_ampache=$3
debianversionname=$(lsb_release -a | grep Codename | awk -F' ' '{print $2}')
# Source YunoHost helpers
. /usr/share/yunohost/helpers
#debianversionname=$(lsb_release -a | grep Codename | awk -F' ' '{print $2}')
# Check domain/path availability
sudo yunohost app checkurl $domain$path -a ampache
sudo yunohost app checkurl $domain$path -a $app
if [[ ! $? -eq 0 ]]; then
exit 1
fi
@ -26,14 +30,16 @@ sudo yunohost app setting ampache admin -v $admin_ampache
db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p')
# Use 'ampache' as database name and user
db_user=ampache
db_user=$app
# Initialize database and store mysql password for upgrade
sudo yunohost app initdb $db_user -p $db_pwd -s $(readlink -e ../sources/sql/ampache.sql)
sudo yunohost app setting ampache mysqlpwd -v $db_pwd
#sudo yunohost app initdb $db_user -p $db_pwd -s $(readlink -e ../sources/sql/ampache.sql)
sudo yunohost app setting $app mysqlpwd -v $db_pwd
ynh_mysql_create_db "$app" "$db_user" "$db_pwd"
ynh_mysql_connect_as "$db_user" "$db_pwd" "$app" < "../sources/sql/ampache.sql"
# Copy files to the right place
final_path=/var/www/ampache
final_path=/var/www/$app
sudo mkdir -p $final_path/log
sudo cp -a ../sources/* $final_path
sudo cp ../conf/ampache.cfg.php $final_path/config/ampache.cfg.php
@ -55,29 +61,32 @@ sudo chown -R www-data: $final_path
# Modify Nginx configuration file and copy it to Nginx conf directory
sed -i "s@PATHTOCHANGE@${path%/}@g" ../conf/nginx.conf*
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf*
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/ampache.conf
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
# Reload Nginx and regenerate SSOwat conf
sudo service nginx reload
sudo yunohost app setting ampache skipped_uris -v "/"
sudo yunohost app setting $app skipped_uris -v "/"
sudo yunohost app ssowatconf
# Install dependency
sudo apt-get install ffmpeg -y
sudo apt-get install libav-tools -y
# Ampache installation
cd /var/www/$app
sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
sudo php composer-setup.php
sudo php composer.phar install --prefer-source --no-interaction
echo "127.0.0.1 $domain #yunoampache" | sudo tee -a /etc/hosts
sleep 1
curl -kL -X POST http://$domain${path%/}/update.php?action=update > /dev/null 2>&1
sleep 5
[ "$debianversionname" == "wheezy" ] && \
sudo sed -i 's/;transcode_cmd = "ffmpeg"/transcode_cmd = "ffmpeg"/g' /var/www/ampache/config/ampache.cfg.php && \
sudo sed -i 's/^transcode_cmd = "avconv"/;transcode_cmd = "avconv"/g' /var/www/ampache/config/ampache.cfg.php
sudo yunohost app setting ampache skipped_uris -d
sudo yunohost app setting ampache skipped_uris -v "/rest"
sudo yunohost app setting $app skipped_uris -d
sudo yunohost app setting $app skipped_uris -v "/rest"
sudo yunohost app ssowatconf
sudo sed '/yunoampache/d' /etc/hosts > /tmp/hosts.tmp
sudo cp /tmp/hosts.tmp /etc/hosts ; sudo rm -f /tmp/hosts.tmp
mysql -u $db_user -p$db_pwd $db_user < /tmp/admin.sql
ynh_mysql_connect_as "$db_user" "$db_pwd" "$app" < /tmp/admin.sql
sudo rm /tmp/admin.sql

View file

@ -1,16 +1,17 @@
#!/bin/bash
db_user=ampache
db_name=ampache
app=$YNH_APP_INSTANCE_NAME
db_user=$app
db_name=$app
root_pwd=$(sudo cat /etc/yunohost/mysql)
domain=$(sudo yunohost app setting ampache domain)
domain=$(sudo yunohost app setting $app domain)
# Drop MySQL database
mysql -u root -p$root_pwd -e "DROP DATABASE $db_name ; DROP USER $db_user@localhost ;"
# Remove sources
sudo rm -rf /var/www/ampache
sudo rm -rf /var/www/$app
# Remove Nginx configuration and reload Nginx conf
sudo rm -f /etc/nginx/conf.d/$domain.d/ampache.conf
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
sudo service nginx reload

View file

@ -1,20 +1,18 @@
#!/bin/bash
debianversionname=$(lsb_release -a | grep Codename | awk -F' ' '{print $2}')
# Retrieve arguments
domain=$(sudo yunohost app setting ampache domain)
path=$(sudo yunohost app setting ampache path)
db_user=ampache
db_pwd=$(sudo yunohost app setting ampache mysqlpwd)
admin_ampache=$(sudo yunohost app setting ampache admin)
app=$YNH_APP_INSTANCE_NAME
domain=$(sudo yunohost app setting $app domain)
path=$(sudo yunohost app setting $app path)
db_user=$app
db_pwd=$(sudo yunohost app setting $app mysqlpwd)
admin_ampache=$(sudo yunohost app setting $app admin)
# first make a copy of the db
# mysqldump -u $db_user -p$db_pwd --add-drop-table --allow-keywords ampache > $final_path/ampache-db-backup.sql
# mysqldump -u $db_user -p$db_pwd --add-drop-table --allow-keywords $app > $final_path/ampache-db-backup.sql
# Copy files to the right place
final_path=/var/www/ampache
final_path=/var/www/$app
sudo cp -a ../sources/* $final_path
sudo cp ../conf/ampache.cfg.php $final_path/config/ampache.cfg.php
@ -32,12 +30,12 @@ sudo chown -R www-data: $final_path
# Modify Nginx configuration file and copy it to Nginx conf directory
sed -i "s@PATHTOCHANGE@${path%/}@g" ../conf/nginx.conf*
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf*
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/ampache.conf
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
# Reload Nginx and regenerate SSOwat conf
sudo service nginx reload
sudo yunohost app setting ampache skipped_uris -v "/"
sudo yunohost app setting $app skipped_uris -v "/"
sudo yunohost app ssowatconf
# Ampache installation
@ -45,11 +43,9 @@ echo "127.0.0.1 $domain #yunoampache" | sudo tee -a /etc/hosts
sleep 1
curl -kL -X POST http://$domain${path%/}/update.php?action=update > /dev/null 2>&1
sleep 5
[ "$debianversionname" == "wheezy" ] && \
sudo sed -i 's/;transcode_cmd = "ffmpeg"/transcode_cmd = "ffmpeg"/g' /var/www/ampache/config/ampache.cfg.php && \
sudo sed -i 's/^transcode_cmd = "avconv"/;transcode_cmd = "avconv"/g' /var/www/ampache/config/ampache.cfg.php
sudo yunohost app setting ampache skipped_uris -d
sudo yunohost app setting ampache skipped_uris -v "/rest"
sudo yunohost app setting $app skipped_uris -d
sudo yunohost app setting $app skipped_uris -v "/rest"
sudo yunohost app ssowatconf
sudo sed '/yunoampache/d' /etc/hosts > /tmp/hosts.tmp
sudo cp /tmp/hosts.tmp /etc/hosts ; sudo rm -f /tmp/hosts.tmp

24
sources/.gitignore vendored
View file

@ -1,12 +1,24 @@
config/ampache.cfg.php
config/ampache-doped.cfg.php
rest/.htaccess
play/.htaccess
/config/ampache.cfg.php
/config/ampache-doped.cfg.php
/rest/.htaccess
/play/.htaccess
/channel/.htaccess
*.phpproj
*.sln
*.v11.suo
*.suo
logs
/logs/
/log/
/nbproject/private/
.pc
/tmp
/tmp/
*~
*#
*.log
/lib/vendor/
/lib/components/
web.config
/config/motd.php
/config/registration_agreement.php
/.maintenance
/modules/plugins/ampache-*

View file

@ -3,12 +3,14 @@
use Symfony\CS\FixerInterface;
$finder = Symfony\CS\Finder\DefaultFinder::create()
->exclude('lib/components')
->exclude('lib/vendor')
->exclude('modules')
->exclude('nbproject')
->in(__DIR__)
->in(__DIR__ . '/modules/localplay')
->in(__DIR__ . '/modules/catalog')
->in(__DIR__ . '/modules/ampacheapi')
->in(__DIR__ . '/modules/plugins')
;
return Symfony\CS\Config\Config::create()

View file

@ -1,5 +1,7 @@
filter:
excluded_paths:
- 'lib/components/*'
- 'lib/vendor/*'
- 'modules/*'
paths: { }
@ -8,6 +10,8 @@ tools:
enabled: true
filter:
excluded_paths:
- 'lib/components/*'
- 'lib/vendor/*'
- 'modules/*'
- 'themes/*'
paths: { }
@ -21,6 +25,8 @@ tools:
excluded_dirs: { }
filter:
excluded_paths:
- 'lib/components/*'
- 'lib/vendor/*'
- 'modules/*'
paths: { }
php_analyzer:
@ -28,9 +34,13 @@ tools:
extensions:
- php
dependency_paths:
- 'lib/components/*'
- 'lib/vendor/*'
- 'modules/*'
filter:
excluded_paths:
- 'lib/components/*'
- 'lib/vendor/*'
- 'modules/*'
- 'themes/*'
paths: { }
@ -44,16 +54,22 @@ tools:
- '\bimplement(?:s|ed)?\b'
filter:
excluded_paths:
- 'lib/components/*'
- 'lib/vendor/*'
- 'modules/*'
paths: { }
php_loc:
enabled: true
excluded_dirs:
- 'lib/components/*'
- 'lib/vendor/*'
- 'modules/*'
php_cpd:
enabled: true
excluded_dirs: { }
filter:
excluded_paths:
- 'lib/components/*'
- 'lib/vendor/*'
- 'modules/*'
paths: { }

View file

@ -4,9 +4,10 @@ php:
- 5.4
- 5.5
- 5.6
- 7.0
before_install:
- wget http://cs.sensiolabs.org/get/php-cs-fixer.phar
- wget http://get.sensiolabs.org/php-cs-fixer.phar
before_script:
- chmod +x scripts/tests/syntax.sh

View file

@ -1 +0,0 @@
ampache.org

78
sources/README.md Executable file → Normal file
View file

@ -1,6 +1,6 @@
Ampache
![Logo](http://ampache.org/img/logo/ampache-logo_x64.png) Ampache
=======
[www.ampache.org](http://www.ampache.org) |
[www.ampache.org](http://ampache.org/) |
[ampache.github.io](http://ampache.github.io)
Basics
@ -11,7 +11,7 @@ manager allowing you to access your music & videos from anywhere,
using almost any internet enabled device.
Ampache's usefulness is heavily dependent on being able to extract
correct metadata from embedded tags in your files and/or the filename.
correct metadata from embedded tags in your files and/or the file name.
Ampache is not a media organiser; it is meant to be a tool which
presents an already organised collection in a useful way. It assumes
that you know best how to manage your files and are capable of
@ -20,15 +20,14 @@ choosing a suitable method for doing so.
Recommended Version
-------------------
Currently, the recommended version is [git HEAD](https://github.com/ampache/ampache/archive/master.tar.gz).
The recommended and most stable version is [git HEAD](https://github.com/ampache/ampache/archive/master.tar.gz).
[![Build Status](https://api.travis-ci.org/ampache/ampache.png?branch=master)](https://travis-ci.org/ampache/ampache)
Latest changes but unstable is [develop branch](https://github.com/ampache/ampache/archive/develop.tar.gz).
You get the latest version with recent changes and fixes but maybe in an unstable state from our [develop branch](https://github.com/ampache/ampache/archive/develop.tar.gz).
[![Build Status](https://api.travis-ci.org/ampache/ampache.png?branch=develop)](https://travis-ci.org/ampache/ampache)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/ampache/ampache/badges/quality-score.png?b=develop)](https://scrutinizer-ci.com/g/ampache/ampache/?branch=develop)
[![Codacy Badge](https://www.codacy.com/project/badge/b28cdb9e9ee2431c7cb9c23d5438cb80)](https://www.codacy.com/app/afterster_2222/ampache)
[![Codacy Badge](https://api.codacy.com/project/badge/b28cdb9e9ee2431c7cb9c23d5438cb80)](https://www.codacy.com/app/afterster_2222/ampache)
[![Code Climate](https://codeclimate.com/github/ampache/ampache/badges/gpa.svg)](https://codeclimate.com/github/ampache/ampache)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/ee067d0e-3432-4062-a969-01b4ee037f48/mini.png)](https://insight.sensiolabs.com/projects/ee067d0e-3432-4062-a969-01b4ee037f48)
Requirements
------------
@ -48,7 +47,7 @@ receives the most testing:
* hash
* session
* json
* simplexml (This is not strictly necessary, but may result in a better experience.)
* simplexml (This is not strictly necessary, but may result in a better experience.)
* curl (This is not strictly necessary, but may result in a better experience.)
* MySQL 5.x
@ -63,34 +62,33 @@ Upgrading
If you are upgrading from an older version of Ampache we recommend
moving the old directory out of the way, extracting the new copy in
its place and then copying the old config/ampache.cfg.php, /rest/.htaccess,
its place and then copying the old /config/ampache.cfg.php, /rest/.htaccess,
and /play/.htaccess files if any. All database updates will be handled by Ampache.
License
-------
Ampache is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License v2
modify it under the terms of the GNU Affero General Public License v3 (AGPLv3)
as published by the Free Software Foundation.
Ampache includes some external modules that carry their own licensing.
* [getID3](http://getid3.sourceforge.net): GPL v2
* [Horde_Browser](http://www.horde.org): LGPL v2.1
* [PHP-gettext](https://launchpad.net/php-gettext): GPL v2
* [Gettext](https://github.com/oscarotero/Gettext): MIT
* [MusicBrainz](https://github.com/mikealmond/MusicBrainz): MIT
* PHP MPD interface: GPL v2
* [PHPMailer](https://github.com/PHPMailer/PHPMailer): LGPL v2.1
* [jQuery](http://jquery.org): MIT
* [jQuery](https://jquery.org/): MIT
* [Requests](http://requests.ryanmccue.info): ISC Licensed
* [Whatever:hover](http://www.xs4all.nl/~peterned): LGPL v2.1
* [xbmc-php-rpc](https://github.com/karlrixon/xbmc-php-rpc): GPL v3
* [xbmc-php-rpc](https://github.com/krixon/xbmc-php-rpc): GPL v3
* [Dropbox SDK](https://github.com/dropbox/dropbox-sdk-php): MIT
* [jPlayer](http://jplayer.org): MIT
* [prettyPhoto](http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone): GPL v2
* [Tag-it!] (http://aehlke.github.io/tag-it): MIT
* [PHP Echo Nest API] (https://github.com/bshaffer/php-echonest-api): MIT
* [Noty] (http://ned.im/noty): MIT
* [Noty] (http://ned.im/noty/): MIT
* [jScroll] (https://github.com/pklauzinski/jscroll): MIT
* [jquery.qrcode] (http://jeromeetienne.github.io/jquery-qrcode): MIT
* [PHP OpenID] (https://github.com/openid/php-openid): Apache License
@ -99,14 +97,14 @@ Ampache includes some external modules that carry their own licensing.
* [Guzzle] (https://github.com/guzzle/guzzle): MIT
* [Symfony Components] (https://github.com/symfony): MIT
* [Evenement] (https://github.com/igorw/evenement): MIT
* [RhinoSlider] (http://rhinoslider.com): MIT
* [RhinoSlider] (http://www.rhinoslider.com/): MIT
* [MediaTable] (https://github.com/edenspiekermann/MediaTable): MIT
* [Responsive Elements] (https://github.com/kumailht/responsive-elements): MIT
* [Bootstrap] (http://getbootstrap.com): MIT
* [jQuery Knob] (https://github.com/aterrien/jQuery-Knob): MIT
* [jQuery File Upload] (https://github.com/blueimp/jQuery-File-Upload): MIT
* [jsTree] (http://www.jstree.com): MIT
* [php-tmdb-api] (https://github.com/wtfzdotnet/php-tmdb-api) : MIT
* [jsTree] (https://www.jstree.com/): MIT
* [php-tmdb-api] (https://github.com/php-tmdb/api) : MIT
* [TvDb] (https://github.com/Moinax/TvDb) : MIT
* [jQuery DateTimePicker] (https://github.com/xdan/datetimepicker) : MIT
* [pChart] (http://www.pchart.net) : GPL v3
@ -119,27 +117,13 @@ Translations
Ampache is currently translated (at least partially) into the
following languages. If you are interested in updating an existing
translation or adding a new one please see /locale/base/TRANSLATIONS
translation, simply visit us on [Transifex](https://www.transifex.com/ampache/ampache).
If you prefer it old school or want to work offline, take a look at [/locale/base/TRANSLATIONS](https://github.com/ampache/ampache/blob/develop/locale/base/TRANSLATIONS.md)
for more instructions.
* English (en_US)
* Arabic (ar_SA)
* Catalan (ca_ES)
* Catalan (ca_ES)
* Czech (cs_CZ)
* Dutch (nl_NL)
* French (fr_FR)
* German (de_DE)
* Greek (el_GR)
* Italian (it_IT)
* Japanese (ja_JP)
* Norwegian (nb_NO)
* Persian (fa_IR)
* Polish (pl_PL)
* Russian (ru_RU)
* Spanish (es_ES)
* Swedish (sv_SE)
* UK English (en_GB)
Translation progress so far:
[![Transifex](https://www.transifex.com/projects/p/ampache/resource/messagespot/chart/image_png)](https://www.transifex.com/projects/p/ampache/)
Credits
-------
@ -150,12 +134,18 @@ Thanks to all those who have helped make Ampache awesome: [Credits](docs/ACKNOWL
Contact Us
----------
Hate it? Love it? Let us know. Also let us know if you think of any
more features, encounter bugs, etc.
Hate it? Love it? Let us know! Dozens of people send ideas for amazing new features, report bugs and further develop Ampache actively. Be a part of Ampache with it's more than 10 years long history and get in touch with an awesome and friendly community!
* [Public Repository](http://github.com/ampache)
* IRC: chat.freenode.net #ampache
* [Forum](https://groups.google.com/forum/#!forum/ampache)
* [Issue Tracker](https://github.com/ampache/ampache/issues)
* [Documentation](https://github.com/ampache/ampache/wiki)
* For Live discussions, visit us on our IRC Channel at chat.freenode.net #ampache or alternative via a [web based chat client](https://webchat.freenode.net)
* For harder cases or general discussion about Ampache take a look at our [Google Groups Forum](https://groups.google.com/forum/#!forum/ampache)
* Found a bug or Ampache isn't working as expected? Head over to our [Issue Tracker](https://github.com/ampache/ampache/issues)
Further Information and basic Help
----------------------------------
* Everything related to the Ampache Project can be found on our [Public Repository](https://github.com/ampache)
* Want to know, how to get Apache to work or learn more about the functions? See our [Documentation](https://github.com/ampache/ampache/wiki)
We hope to see you soon and that you have fun with this Project!
[Team Ampache](docs/ACKNOWLEDGEMENTS)

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -40,7 +40,9 @@ switch ($_REQUEST['action']) {
show_confirmation(T_('Deleted'), T_('Your Access List Entry has been removed'),$url);
break;
case 'show_delete_record':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
$access = new Access($_GET['access_id']);
show_confirmation(T_('Deletion Request'), T_('Are you sure you want to permanently delete') . ' ' . $access->name,
'admin/access.php?action=delete_record&amp;access_id=' . $access->id,1,'delete_access');
@ -67,12 +69,12 @@ switch ($_REQUEST['action']) {
Access::create($_POST);
}
if (!Error::occurred()) {
if (!AmpError::occurred()) {
$url = AmpConfig::get('web_path') . '/admin/access.php';
show_confirmation(T_('Added'), T_('Your new Access Control List(s) have been created'),$url);
} else {
$action = 'show_add_' . $_POST['type'];
require_once AmpConfig::get('prefix') . '/templates/show_add_access.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_add_access.inc.php');
}
break;
case 'update_record':
@ -82,11 +84,11 @@ switch ($_REQUEST['action']) {
}
$access = new Access($_REQUEST['access_id']);
$access->update($_POST);
if (!Error::occurred()) {
show_confirmation(T_('Updated'), T_('Access List Entry updated'), AmpConfig::get('web_path').'/admin/access.php');
if (!AmpError::occurred()) {
show_confirmation(T_('Updated'), T_('Access List Entry updated'), AmpConfig::get('web_path') . '/admin/access.php');
} else {
$access->format();
require_once AmpConfig::get('prefix') . '/templates/show_edit_access.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_edit_access.inc.php');
}
break;
case 'show_add_current':
@ -94,17 +96,17 @@ switch ($_REQUEST['action']) {
case 'show_add_local':
case 'show_add_advanced':
$action = $_REQUEST['action'];
require_once AmpConfig::get('prefix') . '/templates/show_add_access.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_add_access.inc.php');
break;
case 'show_edit_record':
$access = new Access($_REQUEST['access_id']);
$access->format();
require_once AmpConfig::get('prefix') . '/templates/show_edit_access.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_edit_access.inc.php');
break;
default:
$list = array();
$list = Access::get_access_lists();
require_once AmpConfig::get('prefix') .'/templates/show_access_list.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_access_list.inc.php');
break;
} // end switch on action
UI::show_footer();

View file

@ -2,26 +2,26 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
require_once '../lib/init.php';
require_once AmpConfig::get('prefix') . '/modules/catalog/local.catalog.php';
require_once AmpConfig::get('prefix') . '/modules/catalog/local/local.catalog.php';
if (!Access::check('interface','100')) {
UI::access_denied();
@ -45,43 +45,47 @@ if (is_array($catalogs) && count($catalogs) == 1 && $_REQUEST['action'] !== 'del
}
}
}
$sse_catalogs = urlencode(serialize($catalogs));
/* Big switch statement to handle various actions */
switch ($_REQUEST['action']) {
case 'add_to_all_catalogs':
$sse_url = AmpConfig::get('web_path') . "/server/sse.server.php?worker=catalog&action=add_to_all_catalogs";
sse_worker($sse_url);
catalog_worker('add_to_all_catalogs');
show_confirmation(T_('Catalog Update started...'), '', AmpConfig::get('web_path') . '/admin/catalog.php', 0, 'confirmation', false);
break;
case 'add_to_catalog':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
$sse_url = AmpConfig::get('web_path') . "/server/sse.server.php?worker=catalog&action=add_to_catalog&catalogs=" . $sse_catalogs;
sse_worker($sse_url);
catalog_worker('add_to_catalog', $catalogs);
show_confirmation(T_('Catalog Update started...'), '', AmpConfig::get('web_path') . '/admin/catalog.php', 0, 'confirmation', false);
break;
case 'update_all_catalogs':
$sse_url = AmpConfig::get('web_path') . "/server/sse.server.php?worker=catalog&action=update_all_catalogs";
sse_worker($sse_url);
catalog_worker('update_all_catalogs');
show_confirmation(T_('Catalog Update started...'), '', AmpConfig::get('web_path') . '/admin/catalog.php', 0, 'confirmation', false);
break;
case 'update_catalog':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
$sse_url = AmpConfig::get('web_path') . "/server/sse.server.php?worker=catalog&action=update_catalog&catalogs=" . $sse_catalogs;
sse_worker($sse_url);
catalog_worker('update_catalog', $catalogs);
show_confirmation(T_('Catalog Update started...'), '', AmpConfig::get('web_path') . '/admin/catalog.php', 0, 'confirmation', false);
break;
case 'full_service':
if (AmpConfig::get('demo_mode')) { UI::access_denied(); break; }
if (AmpConfig::get('demo_mode')) {
UI::access_denied();
break;
}
$sse_url = AmpConfig::get('web_path') . "/server/sse.server.php?worker=catalog&action=full_service&catalogs=" . $sse_catalogs;
sse_worker($sse_url);
catalog_worker('full_service', $catalogs);
show_confirmation(T_('Catalog Update started...'), '', AmpConfig::get('web_path') . '/admin/catalog.php', 0, 'confirmation', false);
break;
case 'delete_catalog':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
if (!Core::form_verify('delete_catalog')) {
UI::access_denied();
@ -92,7 +96,9 @@ switch ($_REQUEST['action']) {
/* Delete the sucker, we don't need to check perms as thats done above */
foreach ($catalogs as $catalog_id) {
$deleted = Catalog::delete($catalog_id);
if (!$deleted) break;
if (!$deleted) {
break;
}
}
$next_url = AmpConfig::get('web_path') . '/admin/catalog.php';
if ($deleted) {
@ -106,7 +112,9 @@ switch ($_REQUEST['action']) {
show_confirmation(T_('Catalog Delete'), T_('Confirm Deletion Request'),$next_url,1,'delete_catalog');
break;
case 'enable_disabled':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
$songs = $_REQUEST['song'];
@ -118,51 +126,54 @@ switch ($_REQUEST['action']) {
} else {
$body = T_('No Disabled Songs selected');
}
$url = AmpConfig::get('web_path') . '/admin/catalog.php';
$url = AmpConfig::get('web_path') . '/admin/catalog.php';
$title = count($songs) . ngettext(' Disabled Song Processed', ' Disabled Songs Processed', count($songs));
show_confirmation($title,$body,$url);
break;
case 'clean_all_catalogs':
$sse_url = AmpConfig::get('web_path') . "/server/sse.server.php?worker=catalog&action=clean_all_catalogs";
sse_worker($sse_url);
catalog_worker('clean_all_catalogs');
show_confirmation(T_('Catalog Clean started...'), '', AmpConfig::get('web_path') . '/admin/catalog.php', 0, 'confirmation', false);
break;
case 'clean_catalog':
$sse_url = AmpConfig::get('web_path') . "/server/sse.server.php?worker=catalog&action=clean_catalog&catalogs=" . $sse_catalogs;
sse_worker($sse_url);
catalog_worker('clean_catalog', $catalogs);
show_confirmation(T_('Catalog Clean started...'), '', AmpConfig::get('web_path') . '/admin/catalog.php', 0, 'confirmation', false);
break;
case 'update_catalog_settings':
/* No Demo Here! */
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
/* Update the catalog */
Catalog::update_settings($_POST);
$url = AmpConfig::get('web_path') . '/admin/catalog.php';
$url = AmpConfig::get('web_path') . '/admin/catalog.php';
$title = T_('Catalog Updated');
$body = '';
$body = '';
show_confirmation($title,$body,$url);
break;
case 'update_from':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
$sse_url = AmpConfig::get('web_path') . "/server/sse.server.php?worker=catalog&action=update_from&add_path=" . scrub_in($_POST['add_path']) . "&update_path=" . $_POST['update_path'];
sse_worker($sse_url);
catalog_worker('update_from', null, $_POST);
show_confirmation(T_('Subdirectory update started...'), '', AmpConfig::get('web_path') . '/admin/catalog.php', 0, 'confirmation', false);
break;
case 'add_catalog':
/* Wah Demo! */
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
ob_end_flush();
if (!strlen($_POST['type']) || $_POST['type'] == 'none') {
Error::add('general', T_('Error: Please select a catalog type'));
AmpError::add('general', T_('Error: Please select a catalog type'));
}
if (!strlen($_POST['name'])) {
Error::add('general', T_('Error: Name not specified'));
AmpError::add('general', T_('Error: Name not specified'));
}
if (!Core::form_verify('add_catalog','post')) {
@ -171,53 +182,62 @@ switch ($_REQUEST['action']) {
}
// If an error hasn't occured
if (!Error::occurred()) {
if (!AmpError::occurred()) {
$catalog_id = Catalog::create($_POST);
if (!$catalog_id) {
require AmpConfig::get('prefix') . '/templates/show_add_catalog.inc.php';
require AmpConfig::get('prefix') . UI::find_template('show_add_catalog.inc.php');
break;
}
$sse_url = AmpConfig::get('web_path') . "/server/sse.server.php?worker=catalog&action=add_catalog&catalog_id=" . $catalog_id . "&options=" . urlencode(serialize($_POST));
sse_worker($sse_url);
$catalogs[] = $catalog_id;
catalog_worker('add_to_catalog', $catalogs, $_POST);
show_confirmation(T_('Catalog Creation started...'), '', AmpConfig::get('web_path') . '/admin/catalog.php', 0, 'confirmation', false);
} else {
require AmpConfig::get('prefix') . '/templates/show_add_catalog.inc.php';
require AmpConfig::get('prefix') . UI::find_template('show_add_catalog.inc.php');
}
break;
case 'clear_stats':
if (AmpConfig::get('demo_mode')) { UI::access_denied(); break; }
if (AmpConfig::get('demo_mode')) {
UI::access_denied();
break;
}
Stats::clear();
$url = AmpConfig::get('web_path') . '/admin/catalog.php';
$url = AmpConfig::get('web_path') . '/admin/catalog.php';
$title = T_('Catalog statistics cleared');
$body = '';
$body = '';
show_confirmation($title, $body, $url);
break;
case 'show_add_catalog':
require AmpConfig::get('prefix') . '/templates/show_add_catalog.inc.php';
require AmpConfig::get('prefix') . UI::find_template('show_add_catalog.inc.php');
break;
case 'clear_now_playing':
if (AmpConfig::get('demo_mode')) { UI::access_denied(); break; }
if (AmpConfig::get('demo_mode')) {
UI::access_denied();
break;
}
Stream::clear_now_playing();
show_confirmation(T_('Now Playing Cleared'), T_('All now playing data has been cleared'),AmpConfig::get('web_path') . '/admin/catalog.php');
break;
case 'show_disabled':
/* Stop the demo hippies */
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
$songs = Song::get_disabled();
if (count($songs)) {
require AmpConfig::get('prefix') . '/templates/show_disabled_songs.inc.php';
require AmpConfig::get('prefix') . UI::find_template('show_disabled_songs.inc.php');
} else {
echo "<div class=\"error\" align=\"center\">" . T_('No Disabled songs found') . "</div>";
}
break;
case 'show_delete_catalog':
/* Stop the demo hippies */
if (AmpConfig::get('demo_mode')) { UI::access_denied(); break; }
if (AmpConfig::get('demo_mode')) {
UI::access_denied();
break;
}
$catalog = Catalog::create_from_id($_REQUEST['catalog_id']);
$nexturl = AmpConfig::get('web_path') . '/admin/catalog.php?action=delete_catalog&amp;catalog_id=' . scrub_out($_REQUEST['catalog_id']);
@ -226,16 +246,15 @@ switch ($_REQUEST['action']) {
case 'show_customize_catalog':
$catalog = Catalog::create_from_id($_REQUEST['catalog_id']);
$catalog->format();
require_once AmpConfig::get('prefix') . '/templates/show_edit_catalog.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_edit_catalog.inc.php');
break;
case 'gather_media_art':
$sse_url = AmpConfig::get('web_path') . "/server/sse.server.php?worker=catalog&action=gather_media_art&catalogs=" . $sse_catalogs;
sse_worker($sse_url);
catalog_worker('gather_media_art', $catalogs);
show_confirmation(T_('Media Art Search started...'), '', AmpConfig::get('web_path') . '/admin/catalog.php', 0, 'confirmation', false);
break;
case 'show_catalogs':
default:
require_once AmpConfig::get('prefix') . '/templates/show_manage_catalogs.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_manage_catalogs.inc.php');
break;
} // end switch

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -33,12 +33,12 @@ UI::show_header();
switch ($_REQUEST['action']) {
case 'find_duplicates':
$search_type = $_REQUEST['search_type'];
$duplicates = Song::find_duplicates($search_type);
require_once AmpConfig::get('prefix') . '/templates/show_duplicate.inc.php';
require_once AmpConfig::get('prefix') . '/templates/show_duplicates.inc.php';
$duplicates = Song::find_duplicates($search_type);
require_once AmpConfig::get('prefix') . UI::find_template('show_duplicate.inc.php');
require_once AmpConfig::get('prefix') . UI::find_template('show_duplicates.inc.php');
break;
default:
require_once AmpConfig::get('prefix') . '/templates/show_duplicate.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_duplicate.inc.php');
break;
} // end switch on action

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -65,7 +65,7 @@ switch ($_REQUEST['action']) {
// We don't want the footer so we're done here
exit;
default:
require_once AmpConfig::get('prefix') . '/templates/show_export.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_export.inc.php');
break;
} // end switch on action

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -33,7 +33,7 @@ switch ($_REQUEST['action']) {
default:
// Show Catalogs
$catalog_ids = Catalog::get_catalogs();
$browse = new Browse();
$browse = new Browse();
$browse->set_type('catalog');
$browse->set_static_content(true);
$browse->save_objects($catalog_ids);

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -41,16 +41,16 @@ switch ($_REQUEST['action']) {
License::create($_POST);
$text = T_('License Created');
}
show_confirmation($text,'',AmpConfig::get('web_path').'/admin/license.php');
show_confirmation($text,'',AmpConfig::get('web_path') . '/admin/license.php');
break;
case 'show_edit':
$license = new License($_REQUEST['license_id']);
case 'show_create':
require_once AmpConfig::get('prefix') . '/templates/show_edit_license.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_edit_license.inc.php');
break;
case 'delete':
License::delete($_REQUEST['license_id']);
show_confirmation(T_('License Deleted'),'',AmpConfig::get('web_path').'/admin/license.php');
show_confirmation(T_('License Deleted'),'',AmpConfig::get('web_path') . '/admin/license.php');
break;
default:
$browse = new Browse();

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -55,7 +55,7 @@ switch ($_REQUEST['action']) {
if ($_REQUEST['from'] == 'system') {
$mailer->set_default_sender();
} else {
$mailer->sender = $GLOBALS['user']->email;
$mailer->sender = $GLOBALS['user']->email;
$mailer->sender_name = $GLOBALS['user']->fullname;
}
@ -64,14 +64,14 @@ switch ($_REQUEST['action']) {
$body = T_('Your E-mail was successfully sent.');
} else {
$title = T_('E-mail Not Sent');
$body = T_('Your E-mail was not sent.');
$body = T_('Your E-mail was not sent.');
}
$url = AmpConfig::get('web_path') . '/admin/mail.php';
show_confirmation($title,$body,$url);
break;
default:
require_once AmpConfig::get('prefix') . '/templates/show_mail_users.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_mail_users.inc.php');
break;
} // end switch

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -35,8 +35,8 @@ switch ($_REQUEST['action']) {
case 'install_localplay':
$localplay = new Localplay($_REQUEST['type']);
if (!$localplay->player_loaded()) {
Error::add('general', T_('Install Failed, Controller Error'));
Error::display('general');
AmpError::add('general', T_('Install Failed, Controller Error'));
AmpError::display('general');
break;
}
// Install it!
@ -55,11 +55,11 @@ switch ($_REQUEST['action']) {
show_confirmation($title ,$body, $url);
break;
case 'install_catalog_type':
$type = (string) scrub_in($_REQUEST['type']);
$type = (string) scrub_in($_REQUEST['type']);
$catalog = Catalog::create_catalog_type($type);
if ($catalog == null) {
Error::add('general', T_('Install Failed, Catalog Error'));
Error::display('general');
AmpError::add('general', T_('Install Failed, Catalog Error'));
AmpError::display('general');
break;
}
@ -72,17 +72,17 @@ switch ($_REQUEST['action']) {
show_confirmation($title ,$body, $url);
break;
case 'confirm_uninstall_localplay':
$type = (string) scrub_in($_REQUEST['type']);
$url = AmpConfig::get('web_path') . '/admin/modules.php?action=uninstall_localplay&amp;type=' . $type;
$type = (string) scrub_in($_REQUEST['type']);
$url = AmpConfig::get('web_path') . '/admin/modules.php?action=uninstall_localplay&amp;type=' . $type;
$title = T_('Are you sure you want to remove this plugin?');
$body = '';
$body = '';
show_confirmation($title,$body,$url,1);
break;
case 'confirm_uninstall_catalog_type':
$type = (string) scrub_in($_REQUEST['type']);
$url = AmpConfig::get('web_path') . '/admin/modules.php?action=uninstall_catalog_type&amp;type=' . $type;
$type = (string) scrub_in($_REQUEST['type']);
$url = AmpConfig::get('web_path') . '/admin/modules.php?action=uninstall_catalog_type&amp;type=' . $type;
$title = T_('Are you sure you want to remove this plugin?');
$body = '';
$body = '';
show_confirmation($title,$body,$url,1);
break;
case 'uninstall_localplay':
@ -102,8 +102,8 @@ switch ($_REQUEST['action']) {
$catalog = Catalog::create_catalog_type($type);
if ($catalog == null) {
Error::add('general', T_('Uninstall Failed, Catalog Error'));
Error::display('general');
AmpError::add('general', T_('Uninstall Failed, Catalog Error'));
AmpError::display('general');
break;
}
$catalog->uninstall();
@ -125,8 +125,8 @@ switch ($_REQUEST['action']) {
if (!$plugin->install()) {
debug_event('plugins','Error: Plugin Install Failed, ' . $_REQUEST['plugin'],'1');
$url = AmpConfig::get('web_path') . '/admin/modules.php?action=show_plugins';
$title = T_('Unable to Install Plugin');
$body = '';
$title = T_('Unable to Install Plugin');
$body = '';
show_confirmation($title,$body,$url);
break;
}
@ -135,16 +135,16 @@ switch ($_REQUEST['action']) {
User::rebuild_all_preferences();
/* Show Confirmation */
$url = AmpConfig::get('web_path') . '/admin/modules.php?action=show_plugins';
$url = AmpConfig::get('web_path') . '/admin/modules.php?action=show_plugins';
$title = T_('Plugin Activated');
$body = '';
$body = '';
show_confirmation($title,$body,$url);
break;
case 'confirm_uninstall_plugin':
$plugin = scrub_in($_REQUEST['plugin']);
$url = AmpConfig::get('web_path') . '/admin/modules.php?action=uninstall_plugin&amp;plugin=' . $plugin;
$plugin = scrub_in($_REQUEST['plugin']);
$url = AmpConfig::get('web_path') . '/admin/modules.php?action=uninstall_plugin&amp;plugin=' . $plugin;
$title = T_('Are you sure you want to remove this plugin?');
$body = '';
$body = '';
show_confirmation($title,$body,$url,1);
break;
case 'uninstall_plugin':
@ -184,19 +184,19 @@ switch ($_REQUEST['action']) {
case 'show_plugins':
$plugins = Plugin::get_plugins();
UI::show_box_top(T_('Plugins'), 'box box_localplay_plugins');
require_once AmpConfig::get('prefix') . '/templates/show_plugins.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_plugins.inc.php');
UI::show_box_bottom();
break;
case 'show_localplay':
$controllers = Localplay::get_controllers();
UI::show_box_top(T_('Localplay Controllers'), 'box box_localplay_controllers');
require_once AmpConfig::get('prefix') . '/templates/show_localplay_controllers.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_localplay_controllers.inc.php');
UI::show_box_bottom();
break;
case 'show_catalog_types':
$catalogs = Catalog::get_catalog_types();
UI::show_box_top(T_('Catalog Types'), 'box box_catalog_types');
require_once AmpConfig::get('prefix') . '/templates/show_catalog_types.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_catalog_types.inc.php');
UI::show_box_bottom();
break;
default:

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -36,19 +36,19 @@ switch ($_REQUEST['action']) {
if ($shout->id) {
$shout->update($_POST);
}
show_confirmation(T_('Shoutbox Post Updated'),'',AmpConfig::get('web_path').'/admin/shout.php');
show_confirmation(T_('Shoutbox Post Updated'),'',AmpConfig::get('web_path') . '/admin/shout.php');
break;
case 'show_edit':
$shout = new Shoutbox($_REQUEST['shout_id']);
$shout = new Shoutbox($_REQUEST['shout_id']);
$object = Shoutbox::get_object($shout->object_type,$shout->object_id);
$object->format();
$client = new User($shout->user);
$client->format();
require_once AmpConfig::get('prefix') . '/templates/show_edit_shout.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_edit_shout.inc.php');
break;
case 'delete':
Shoutbox::delete($_REQUEST['shout_id']);
show_confirmation(T_('Shoutbox Post Deleted'),'',AmpConfig::get('web_path').'/admin/shout.php');
show_confirmation(T_('Shoutbox Post Deleted'),'',AmpConfig::get('web_path') . '/admin/shout.php');
break;
default:
$browse = new Browse();

View file

@ -2,27 +2,27 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
require_once '../lib/init.php';
if (!Access::check('interface',100) OR AmpConfig::get('demo_mode')) {
if (!Access::check('interface',100) or AmpConfig::get('demo_mode')) {
UI::access_denied();
exit();
}
@ -37,25 +37,25 @@ switch ($_REQUEST['action']) {
case 'generate_config':
ob_end_clean();
$current = parse_ini_file(AmpConfig::get('prefix') . '/config/ampache.cfg.php');
$final = generate_config($current);
$final = generate_config($current);
$browser = new Horde_Browser();
$browser->downloadHeaders('ampache.cfg.php', 'text/plain',false,filesize(AmpConfig::get('prefix') . '/config/ampache.cfg.php.dist'));
echo $final;
exit;
case 'write_config':
write_config(AmpConfig::get('prefix') . '/config/ampache.cfg.php');
header('Location: '. AmpConfig::get('web_path') . '/index.php');
header('Location: ' . AmpConfig::get('web_path') . '/index.php');
exit;
case 'reset_db_charset':
Dba::reset_db_charset();
show_confirmation(T_('Database Charset Updated'), T_('Your Database and associated tables have been updated to match your currently configured charset'), AmpConfig::get('web_path').'/admin/system.php?action=show_debug');
show_confirmation(T_('Database Charset Updated'), T_('Your Database and associated tables have been updated to match your currently configured charset'), AmpConfig::get('web_path') . '/admin/system.php?action=show_debug');
break;
case 'show_debug':
$configuration = AmpConfig::get_all();
if ($_REQUEST['autoupdate'] == 'force') {
$version = AutoUpdate::get_latest_version(true);
}
require_once AmpConfig::get('prefix') . '/templates/show_debug.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_debug.inc.php');
break;
case 'clear_cache':
switch ($_REQUEST['type']) {
@ -63,7 +63,7 @@ switch ($_REQUEST['action']) {
case 'artist' : Artist::clear_cache(); break;
case 'album' : Album::clear_cache(); break;
}
show_confirmation(T_('Cache cleared'), T_('Your cache has been cleared successfully.'), AmpConfig::get('web_path').'/admin/system.php?action=show_debug');
show_confirmation(T_('Cache cleared'), T_('Your cache has been cleared successfully.'), AmpConfig::get('web_path') . '/admin/system.php?action=show_debug');
break;
default:
// Rien a faire

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -32,7 +32,9 @@ UI::show_header();
// Switch on the actions
switch ($_REQUEST['action']) {
case 'update_user':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
if (!Core::form_verify('edit_user','post')) {
UI::access_denied();
@ -40,16 +42,16 @@ switch ($_REQUEST['action']) {
}
/* Clean up the variables */
$user_id = intval($_POST['user_id']);
$username = scrub_in($_POST['username']);
$fullname = scrub_in($_POST['fullname']);
$email = scrub_in($_POST['email']);
$website = scrub_in($_POST['website']);
$access = scrub_in($_POST['access']);
$pass1 = $_POST['password_1'];
$pass2 = $_POST['password_2'];
$state = scrub_in($_POST['state']);
$city = scrub_in($_POST['city']);
$user_id = intval($_POST['user_id']);
$username = scrub_in($_POST['username']);
$fullname = scrub_in($_POST['fullname']);
$email = scrub_in($_POST['email']);
$website = scrub_in($_POST['website']);
$access = scrub_in($_POST['access']);
$pass1 = $_POST['password_1'];
$pass2 = $_POST['password_2'];
$state = scrub_in($_POST['state']);
$city = scrub_in($_POST['city']);
$fullname_public = isset($_POST['fullname_public']);
/* Setup the temp user */
@ -57,26 +59,26 @@ switch ($_REQUEST['action']) {
/* Verify Input */
if (empty($username)) {
Error::add('username', T_("Error Username Required"));
AmpError::add('username', T_("Error Username Required"));
} else {
if ($username != $client->username) {
if (!User::check_username($username)) {
Error::add('username', T_("Error Username already exists"));
AmpError::add('username', T_("Error Username already exists"));
}
}
}
if ($pass1 !== $pass2 && !empty($pass1)) {
Error::add('password', T_("Error Passwords don't match"));
AmpError::add('password', T_("Error Passwords don't match"));
}
// Check the mail for correct address formation.
if (!Mailer::validate_address($email)) {
Error::add('email', T_('Invalid email address'));
AmpError::add('email', T_('Invalid email address'));
}
/* If we've got an error then show edit form! */
if (Error::occurred()) {
require_once AmpConfig::get('prefix') . '/templates/show_edit_user.inc.php';
if (AmpError::occurred()) {
require_once AmpConfig::get('prefix') . UI::find_template('show_edit_user.inc.php');
break;
}
@ -109,10 +111,12 @@ switch ($_REQUEST['action']) {
}
$client->upload_avatar();
show_confirmation(T_('User Updated'), $client->fullname . "(" . $client->username . ")" . T_('updated'), AmpConfig::get('web_path'). '/admin/users.php');
show_confirmation(T_('User Updated'), $client->fullname . "(" . $client->username . ")" . T_('updated'), AmpConfig::get('web_path') . '/admin/users.php');
break;
case 'add_user':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
if (!Core::form_verify('add_user','post')) {
UI::access_denied();
@ -130,41 +134,47 @@ switch ($_REQUEST['action']) {
$city = (string) scrub_in($_POST['city']);
if ($pass1 !== $pass2 || !strlen($pass1)) {
Error::add('password', T_("Error Passwords don't match"));
AmpError::add('password', T_("Error Passwords don't match"));
}
if (empty($username)) {
Error::add('username', T_('Error Username Required'));
AmpError::add('username', T_('Error Username Required'));
}
/* make sure the username doesn't already exist */
if (!User::check_username($username)) {
Error::add('username', T_('Error Username already exists'));
AmpError::add('username', T_('Error Username already exists'));
}
// Check the mail for correct address formation.
if (!Mailer::validate_address($email)) {
Error::add('email', T_('Invalid email address'));
AmpError::add('email', T_('Invalid email address'));
}
/* If we've got an error then show add form! */
if (Error::occurred()) {
require_once AmpConfig::get('prefix') . '/templates/show_add_user.inc.php';
if (AmpError::occurred()) {
require_once AmpConfig::get('prefix') . UI::find_template('show_add_user.inc.php');
break;
}
/* Attempt to create the user */
$user_id = User::create($username, $fullname, $email, $website, $pass1, $access, $state, $city);
if (!$user_id) {
Error::add('general', T_("Error: Insert Failed"));
AmpError::add('general', T_("Error: Insert Failed"));
}
$user = new User($user_id);
$user->upload_avatar();
if ($access == 5) { $access = T_('Guest');} elseif ($access == 25) { $access = T_('User');} elseif ($access == 100) { $access = T_('Admin');}
if ($access == 5) {
$access = T_('Guest');
} elseif ($access == 25) {
$access = T_('User');
} elseif ($access == 100) {
$access = T_('Admin');
}
/* HINT: %1 Username, %2 Access num */
show_confirmation(T_('New User Added'),sprintf(T_('%1$s has been created with an access level of %2$s'), $username, $access), AmpConfig::get('web_path').'/admin/users.php');
show_confirmation(T_('New User Added'),sprintf(T_('%1$s has been created with an access level of %2$s'), $username, $access), AmpConfig::get('web_path') . '/admin/users.php');
break;
case 'enable':
$client = new User($_REQUEST['user_id']);
@ -172,40 +182,46 @@ switch ($_REQUEST['action']) {
if (!AmpConfig::get('user_no_email_confirm')) {
Registration::send_account_enabled($client->username, $client->fullname, $client->email);
}
show_confirmation(T_('User Enabled'),$client->fullname . ' (' . $client->username . ')', AmpConfig::get('web_path'). '/admin/users.php');
show_confirmation(T_('User Enabled'),$client->fullname . ' (' . $client->username . ')', AmpConfig::get('web_path') . '/admin/users.php');
break;
case 'disable':
$client = new User($_REQUEST['user_id']);
if ($client->disable()) {
show_confirmation(T_('User Disabled'),$client->fullname . ' (' . $client->username . ')', AmpConfig::get('web_path'). '/admin/users.php');
show_confirmation(T_('User Disabled'),$client->fullname . ' (' . $client->username . ')', AmpConfig::get('web_path') . '/admin/users.php');
} else {
show_confirmation(T_('Error'), T_('Unable to Disabled last Administrator'), AmpConfig::get('web_path').'/admin/users.php');
show_confirmation(T_('Error'), T_('Unable to Disabled last Administrator'), AmpConfig::get('web_path') . '/admin/users.php');
}
break;
case 'show_edit':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
$client = new User($_REQUEST['user_id']);
require_once AmpConfig::get('prefix') . '/templates/show_edit_user.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_edit_user.inc.php');
break;
case 'confirm_delete':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
if (!Core::form_verify('delete_user')) {
UI::access_denied();
exit;
}
$client = new User($_REQUEST['user_id']);
if ($client->delete()) {
show_confirmation(T_('User Deleted'), sprintf(T_('%s has been Deleted'), $client->username), AmpConfig::get('web_path'). "/admin/users.php");
show_confirmation(T_('User Deleted'), sprintf(T_('%s has been Deleted'), $client->username), AmpConfig::get('web_path') . "/admin/users.php");
} else {
show_confirmation(T_('Delete Error'), T_("Unable to delete last Admin User"), AmpConfig::get('web_path')."/admin/users.php");
show_confirmation(T_('Delete Error'), T_("Unable to delete last Admin User"), AmpConfig::get('web_path') . "/admin/users.php");
}
break;
case 'delete':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
$client = new User($_REQUEST['user_id']);
show_confirmation(T_('Deletion Request'),
sprintf(T_('Are you sure you want to permanently delete %s?'), $client->fullname),
AmpConfig::get('web_path')."/admin/users.php?action=confirm_delete&amp;user_id=" . $_REQUEST['user_id'],1,'delete_user');
AmpConfig::get('web_path') . "/admin/users.php?action=confirm_delete&amp;user_id=" . $_REQUEST['user_id'],1,'delete_user');
break;
case 'show_delete_avatar':
$user_id = $_REQUEST['user_id'];
@ -214,7 +230,9 @@ switch ($_REQUEST['action']) {
show_confirmation(T_('User Avatar Delete'), T_('Confirm Deletion Request'), $next_url, 1, 'delete_avatar');
break;
case 'delete_avatar':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
if (!Core::form_verify('delete_avatar','post')) {
UI::access_denied();
@ -225,7 +243,7 @@ switch ($_REQUEST['action']) {
$client->delete_avatar();
$next_url = AmpConfig::get('web_path') . '/admin/users.php';
show_confirmation(T_('User Avater Deleted'), T_('User Avatar has been deleted'), $next_url);
show_confirmation(T_('User Avatar Deleted'), T_('User Avatar has been deleted'), $next_url);
break;
case 'show_generate_apikey':
$user_id = $_REQUEST['user_id'];
@ -234,7 +252,9 @@ switch ($_REQUEST['action']) {
show_confirmation(T_('Generate new API Key'), T_('Confirm API Key Generation'), $next_url, 1, 'generate_apikey');
break;
case 'generate_apikey':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
if (!Core::form_verify('generate_apikey','post')) {
UI::access_denied();
@ -257,16 +277,18 @@ switch ($_REQUEST['action']) {
} else {
$history = $working_user->get_ip_history();
}
require AmpConfig::get('prefix') . '/templates/show_ip_history.inc.php';
require AmpConfig::get('prefix') . UI::find_template('show_ip_history.inc.php');
break;
case 'show_add_user':
if (AmpConfig::get('demo_mode')) { break; }
require_once AmpConfig::get('prefix') . '/templates/show_add_user.inc.php';
if (AmpConfig::get('demo_mode')) {
break;
}
require_once AmpConfig::get('prefix') . UI::find_template('show_add_user.inc.php');
break;
case 'show_preferences':
$client = new User($_REQUEST['user_id']);
$client = new User($_REQUEST['user_id']);
$preferences = Preference::get_all($client->id);
require_once AmpConfig::get('prefix') . '/templates/show_user_preferences.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_user_preferences.inc.php');
break;
default:
$browse = new Browse();

View file

@ -2,44 +2,48 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
require_once 'lib/init.php';
require_once AmpConfig::get('prefix') . '/templates/header.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('header.inc.php');
/* Switch on Action */
switch ($_REQUEST['action']) {
case 'delete':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
$album_id = scrub_in($_REQUEST['album_id']);
show_confirmation(
T_('Album Deletion'),
T_('Are you sure you want to permanently delete this album?'),
AmpConfig::get('web_path')."/albums.php?action=confirm_delete&album_id=" . $album_id,
AmpConfig::get('web_path') . "/albums.php?action=confirm_delete&album_id=" . $album_id,
1,
'delete_album'
);
break;
case 'confirm_delete':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
$album = new Album($_REQUEST['album_id']);
if (!Catalog::can_remove($album)) {
@ -61,10 +65,10 @@ switch ($_REQUEST['action']) {
exit;
}
$type = 'album';
$type = 'album';
$object_id = intval($_REQUEST['album_id']);
$target_url = AmpConfig::get('web_path') . '/albums.php?action=show&amp;album=' . $object_id;
require_once AmpConfig::get('prefix') . '/templates/show_update_items.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_update_items.inc.php');
break;
case 'set_track_numbers':
debug_event('albums', 'Set track numbers called.', '5');
@ -77,7 +81,7 @@ switch ($_REQUEST['action']) {
// Retrieving final song order from url
foreach ($_GET as $key => $data) {
$_GET[$key] = unhtmlentities(scrub_in($data));
debug_event('albums', $key.'='.$_GET[$key], '5');
debug_event('albums', $key . '=' . $_GET[$key], '5');
}
if (isset($_GET['order'])) {
@ -93,14 +97,14 @@ switch ($_REQUEST['action']) {
break;
case 'show_missing':
set_time_limit(600);
$mbid = $_REQUEST['mbid'];
$mbid = $_REQUEST['mbid'];
$walbum = new Wanted(Wanted::get_wanted($mbid));
if (!$walbum->id) {
$walbum->mbid = $mbid;
if (isset($_REQUEST['artist'])) {
$artist = new Artist($_REQUEST['artist']);
$walbum->artist = $artist->id;
$artist = new Artist($_REQUEST['artist']);
$walbum->artist = $artist->id;
$walbum->artist_mbid = $artist->mbid;
} elseif (isset($_REQUEST['artist_mbid'])) {
$walbum->artist_mbid = $_REQUEST['artist_mbid'];
@ -108,7 +112,7 @@ switch ($_REQUEST['action']) {
}
$walbum->load_all();
$walbum->format();
require AmpConfig::get('prefix') . '/templates/show_missing_album.inc.php';
require AmpConfig::get('prefix') . UI::find_template('show_missing_album.inc.php');
break;
// Browse by Album
case 'show':
@ -117,9 +121,9 @@ switch ($_REQUEST['action']) {
$album->format();
if (!count($album->album_suite)) {
require AmpConfig::get('prefix') . '/templates/show_album.inc.php';
require AmpConfig::get('prefix') . UI::find_template('show_album.inc.php');
} else {
require AmpConfig::get('prefix') . '/templates/show_album_group_disks.inc.php';
require AmpConfig::get('prefix') . UI::find_template('show_album_group_disks.inc.php');
}
break;

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -29,19 +29,23 @@ UI::show_header();
*/
switch ($_REQUEST['action']) {
case 'delete':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
$artist_id = scrub_in($_REQUEST['artist_id']);
show_confirmation(
T_('Artist Deletion'),
T_('Are you sure you want to permanently delete this artist?'),
AmpConfig::get('web_path')."/artists.php?action=confirm_delete&artist_id=" . $artist_id,
AmpConfig::get('web_path') . "/artists.php?action=confirm_delete&artist_id=" . $artist_id,
1,
'delete_artist'
);
break;
case 'confirm_delete':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
$artist = new Artist($_REQUEST['artist_id']);
if (!Catalog::can_remove($artist)) {
@ -65,30 +69,34 @@ switch ($_REQUEST['action']) {
$object_ids = $artist->get_albums($_REQUEST['catalog']);
}
$object_type = 'album';
require_once AmpConfig::get('prefix') . '/templates/show_artist.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_artist.inc.php');
break;
case 'show_all_songs':
$artist = new Artist($_REQUEST['artist']);
$artist->format();
$object_type = 'song';
$object_ids = $artist->get_songs();
require_once AmpConfig::get('prefix') . '/templates/show_artist.inc.php';
$object_ids = $artist->get_songs();
require_once AmpConfig::get('prefix') . UI::find_template('show_artist.inc.php');
break;
case 'update_from_tags':
$type = 'artist';
$object_id = intval($_REQUEST['artist']);
$type = 'artist';
$object_id = intval($_REQUEST['artist']);
$target_url = AmpConfig::get('web_path') . "/artists.php?action=show&amp;artist=" . $object_id;
require_once AmpConfig::get('prefix') . '/templates/show_update_items.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_update_items.inc.php');
break;
case 'match':
case 'Match':
$match = scrub_in($_REQUEST['match']);
if ($match == "Browse" || $match == "Show_all") { $chr = ""; } else { $chr = $match; }
if ($match == "Browse" || $match == "Show_all") {
$chr = "";
} else {
$chr = $match;
}
/* Enclose this in the purty box! */
require AmpConfig::get('prefix') . '/templates/show_box_top.inc.php';
require AmpConfig::get('prefix') . UI::find_template('show_box_top.inc.php');
show_alphabet_list('artists','artists.php',$match);
show_alphabet_form($chr, T_('Show Artists starting with'),"artists.php?action=match");
require AmpConfig::get('prefix') . '/templates/show_box_bottom.inc.php';
require AmpConfig::get('prefix') . UI::find_template('show_box_bottom.inc.php');
if ($match === "Browse") {
show_artists();
@ -105,10 +113,10 @@ switch ($_REQUEST['action']) {
break;
case 'show_missing':
set_time_limit(600);
$mbid = $_REQUEST['mbid'];
$mbid = $_REQUEST['mbid'];
$wartist = Wanted::get_missing_artist($mbid);
require AmpConfig::get('prefix') . '/templates/show_missing_artist.inc.php';
require AmpConfig::get('prefix') . UI::find_template('show_missing_artist.inc.php');
break;
} // end switch

View file

@ -2,31 +2,34 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
require_once 'lib/init.php';
require_once AmpConfig::get('prefix') . '/templates/header.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('header.inc.php');
$object_type = $_GET['object_type'];
$object_id = $_GET['object_id'];
if (!Core::is_library_item($object_type)) { UI::access_denied(); exit; }
$object_id = $_GET['object_id'];
if (!Core::is_library_item($object_type)) {
UI::access_denied();
exit;
}
$burl = '';
if (isset($_GET['burl'])) {
$burl = base64_decode($_GET['burl']);
@ -34,7 +37,10 @@ if (isset($_GET['burl'])) {
$item = new $object_type($object_id);
// If not a content manager user then kick em out
if (!Access::check('interface', 50) && (!Access::check('interface', 25) || $item->get_user_owner() != $GLOBALS['user']->id)) { UI::access_denied(); exit; }
if (!Access::check('interface', 50) && (!Access::check('interface', 25) || $item->get_user_owner() != $GLOBALS['user']->id)) {
UI::access_denied();
exit;
}
/* Switch on Action */
switch ($_REQUEST['action']) {
@ -52,7 +58,7 @@ switch ($_REQUEST['action']) {
}
// Pull the image information
$data = array('file'=>$_FILES['file']['tmp_name']);
$data = array('file'=>$_FILES['file']['tmp_name']);
$image_data = Art::get_from_source($data, $object_type);
// If we got something back insert it
@ -72,29 +78,27 @@ switch ($_REQUEST['action']) {
set_time_limit(0);
$item->format();
$art = new Art($object_id, $object_type);
$images = array();
$art = new Art($object_id, $object_type);
$images = array();
$cover_url = array();
// If we've got an upload ignore the rest and just insert it
if (!empty($_FILES['file']['tmp_name'])) {
$path_info = pathinfo($_FILES['file']['name']);
$path_info = pathinfo($_FILES['file']['name']);
$upload['file'] = $_FILES['file']['tmp_name'];
$upload['mime'] = 'image/' . $path_info['extension'];
$image_data = Art::get_from_source($upload, $object_type);
$image_data = Art::get_from_source($upload, $object_type);
if ($image_data) {
$art->insert($image_data,$upload['0']['mime']);
show_confirmation(T_('Art Inserted'), '', $burl);
break;
} // if image data
} // if it's an upload
$keywords = $item->get_keywords();
$keyword = '';
$options = array();
$keyword = '';
$options = array();
foreach ($keywords as $key => $word) {
if (isset($_REQUEST['option_' . $key])) {
$word['value'] = $_REQUEST['option_' . $key];
@ -112,8 +116,8 @@ switch ($_REQUEST['action']) {
$images = $art->gather($options);
if (!empty($_REQUEST['cover'])) {
$path_info = pathinfo($_REQUEST['cover']);
$cover_url[0]['url'] = scrub_in($_REQUEST['cover']);
$path_info = pathinfo($_REQUEST['cover']);
$cover_url[0]['url'] = scrub_in($_REQUEST['cover']);
$cover_url[0]['mime'] = 'image/' . $path_info['extension'];
}
$images = array_merge($cover_url, $images);
@ -128,14 +132,14 @@ switch ($_REQUEST['action']) {
} // end foreach
// Store the results for further use
$_SESSION['form']['images'] = $images;
require_once AmpConfig::get('prefix') . '/templates/show_arts.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_arts.inc.php');
}
// Else nothing
else {
show_confirmation(T_('Art Not Located'), T_('Art could not be located at this time. This may be due to write access error, or the file is not received correctly.'), $burl);
}
require_once AmpConfig::get('prefix') . '/templates/show_get_art.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_get_art.inc.php');
break;
case 'select_art':
@ -147,11 +151,11 @@ switch ($_REQUEST['action']) {
set_time_limit(0);
$image = Art::get_from_source($_SESSION['form']['images'][$image_id], 'album');
$mime = $_SESSION['form']['images'][$image_id]['mime'];
$mime = $_SESSION['form']['images'][$image_id]['mime'];
// Special case for albums, I'm not sure if we should keep it, remove it or find a generic way
if ($object_type == 'album') {
$album = new $object_type($object_id);
$album = new $object_type($object_id);
$album_groups = $album->get_group_disks_ids();
foreach ($album_groups as $a_id) {
$art = new Art($a_id, $object_type);

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -43,10 +43,10 @@ if (!defined('NO_SESSION') && !Access::check_function('batch_download')) {
/* Drop the normal Time limit constraints, this can take a while */
set_time_limit(0);
$media_ids = array();
$media_ids = array();
$default_name = "Unknown.zip";
$object_type = scrub_in($_REQUEST['action']);
$name = $default_name;
$object_type = scrub_in($_REQUEST['action']);
$name = $default_name;
if ($object_type == 'browse') {
$object_type = $_REQUEST['type'];
@ -68,7 +68,7 @@ if (Core::is_playable_item($_REQUEST['action'])) {
$libitem = new $object_type($i);
if ($libitem->id) {
$libitem->format();
$name = $libitem->get_fullname();
$name = $libitem->get_fullname();
$media_ids = array_merge($media_ids, $libitem->get_medias());
}
}
@ -76,16 +76,16 @@ if (Core::is_playable_item($_REQUEST['action'])) {
switch ($_REQUEST['action']) {
case 'tmp_playlist':
$media_ids = $GLOBALS['user']->playlist->get_items();
$name = $GLOBALS['user']->username . ' - Playlist';
$name = $GLOBALS['user']->username . ' - Playlist';
break;
case 'browse':
$id = intval(scrub_in($_REQUEST['browse_id']));
$browse = new Browse($id);
$id = intval(scrub_in($_REQUEST['browse_id']));
$browse = new Browse($id);
$browse_media_ids = $browse->get_saved();
foreach ($browse_media_ids as $media_id) {
switch ($object_type) {
case 'album':
$album = new Album($media_id);
$album = new Album($media_id);
$media_ids = array_merge($media_ids, $album->get_songs());
break;
case 'song':

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -28,12 +28,18 @@ require_once $prefix . '/lib/init.php';
// Turn off output buffering we don't need it for a command line script
ob_end_clean();
$sql = "SELECT `image`,`id` FROM `image`";
$inDisk = AmpConfig::get('album_art_store_disk');
$sql = "SELECT `image`,`id`,object_id,object_type,size FROM `image`";
$db_results = Dba::read($sql);
$results = array();
while ($row = Dba::fetch_assoc($db_results)) {
$source = $row['image'];
if ($inDisk)
$source = Art::get_from_source(array('file' => Art::get_dir_on_disk($row['object_type'], $row['object_id'], 'default').'art-'.$row['size'].'.jpg'), $row['object_type']);
else
$source = $row['image'];
$id = $row['id'];
$dimensions = Core::image_dimensions($source);
if ($dimensions) {

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

View file

@ -0,0 +1,5 @@
start dns-sd -R Ampache _http._tcp local 3689
start dns-sd -R Ampache _daap._tcp local 3689 txtvers=1 "Machine ID"=AC630E6FB504 "iTSh Version"=196619 "Media Kinds Shared"=1 dmv=131082 Version=196620 "Machine Name"=Ampache Password=0 OSsi=0x10313 "Database ID"=416D7061636865 MID=0xAD12C5B9B9D839F2
start dns-sd -R Ampache _dacp._tcp local 3689
start dns-sd -R Ampache _touch-able._tcp local 3689 txtvers=1 OSsi=0x10313 CtlN=Ampache Ver=131073 DvSv=2305 DvTy=iTunes DbId=416D7061636865
start dns-sd -R Ampache _rsp._tcp local 3689

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -87,7 +87,7 @@ AmpConfig::set_by_array(array(
// Install the database
if (!install_insert_db($new_db_user, $new_db_pass, true, $force, true)) {
echo T_('Database creation failed'), "\n";
echo Error::get('general'), "\n\n";
echo AmpError::get('general'), "\n\n";
exit(1);
}
@ -99,7 +99,7 @@ AmpConfig::set_by_array(array(
// Write the config file
if (!install_create_config()) {
echo T_('Config file creation failed'), "\n";
echo Error::get('general') . "\n\n";
echo AmpError::get('general') . "\n\n";
exit(1);
}

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

View file

@ -2,35 +2,37 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/*
* Use with caution, this hasn't been heavily tested!!!
*/
define('NO_SESSION','1');
require_once '../lib/init.php';
$valid_exts = array ('m3u', 'xspf', 'pls');
if (!$GLOBALS['argv']['1'] || $GLOBALS['argv']['1'] == '-h') { usage(); }
else {
$dirname = $GLOBALS['argv']['1'];
$type = $GLOBALS['argv']['2'];
$type = $GLOBALS['argv']['2'];
$ext = $GLOBALS['argv']['3'];
if (!$ext || !in_array($ext, $valid_exts)) {
$ext = 'm3u';
}
}
// Make sure the output dir is valid and writeable
@ -42,35 +44,68 @@ if (!is_writeable($dirname)) {
// Switch on the type of playlist dump we want to do
// here
switch ($type) {
case 'playlists':
case 'albums':
$ids = Catalog::get_albums();
$items = array();
foreach ($ids as $id) {
$items[] = new Album($id);
}
break;
case 'artist':
case 'artists':
$items = Catalog::get_artists();
break;
default:
$ids = Playlist::get_playlists(false, -1);
$items = array();
foreach ($ids as $id) {
$items[] = new Playlist($id);
}
break;
} // end type switch
foreach ($items as $item) {
$item->format();
$name = $item->get_fullname();
// We don't know about file system encoding / specificity
// For now, we only keep simple characters to be sure it will work everywhere
$name = preg_replace('/[:]/', '.', $name);
$name = preg_replace('/[^a-zA-Z0-9. -]/', '', $name);
$filename = $dirname . DIRECTORY_SEPARATOR . $item->id . '. ' . $name . '.' . $ext;
$medias = $item->get_medias();
$pl = new Stream_Playlist(-1);
$pl->title = $item->get_fullname();
foreach ($medias as $media) {
$pl->urls[] = Stream_Playlist::media_to_url($media, $dirname, 'file');
}
$plstr = $pl->{'get_' . $ext . '_string'}();
if (file_put_contents($filename, $plstr) === false) {
echo "Error: cannot write playlist file `" . $filename . "`.\n";
} else {
echo "Playlist file `" . $filename . "` created.\n";
}
}
echo "Playlist export completed.\n";
/* FUNCTIONS */
function usage() {
$desc1 = T_("This will dump a collection of playlists files based on type");
$desc2 = T_("Types:");
$desc3 = T_("Dumps all of your Playlists");
$desc4 = T_("Dumps all Albums as individual playlists");
$desc5 = T_("Dumps all Artists as individual playlists");
$desc6 = T_("Extensions: m3u (default), xspf, pls");
$desc1 = T_("This will dump a collection of m3u playlists based on type");
$desc2 = T_("Types:");
$desc3 = T_("Dumps all Albums as individual playlists");
$desc4 = T_("Dumps all of your Playlists as m3u's");
$desc5 = T_("Dumps all Artists as individual playlists");
$string = "write_playlists.php.inc [-h] <DIRNAME> <TYPE> [<EXT>]
$string = "write_playlists.php.inc [-h] <DIRNAME> <TYPE>
$desc1
$desc2
default $desc3
albums $desc4
artists $desc5
$desc6\n\n";
$desc1
$desc2
default $desc3
playlists $desc4
artist $desc5\n\n";
exit($string);
} // useage
exit($string);
} // usage
?>

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -44,7 +44,7 @@ switch ($_REQUEST['action']) {
exit;
}
$id = $_REQUEST['id'];
$id = $_REQUEST['id'];
$broadcast = new Broadcast($id);
if ($broadcast->delete()) {
$next_url = AmpConfig::get('web_path') . '/browse.php?action=broadcast';

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -57,6 +57,8 @@ switch ($_REQUEST['action']) {
case 'personal_video':
case 'label':
case 'pvmsg':
case 'podcast':
case 'podcast_episode':
$browse->set_type($_REQUEST['action']);
$browse->set_simple_browse(true);
break;
@ -83,20 +85,20 @@ switch ($_REQUEST['action']) {
//FIXME: This whole thing is ugly, even though it works.
$browse->set_sort('count','ASC');
// This one's a doozy
$browse_type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'song';
$browse_type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'artist';
$browse->set_simple_browse(false);
$browse->save_objects(Tag::get_tags($browse_type, 0, 'name')); // Should add a pager?
$object_ids = $browse->get_saved();
$keys = array_keys($object_ids);
$keys = array_keys($object_ids);
Tag::build_cache($keys);
UI::show_box_top(T_('Tag Cloud'), 'box box_tag_cloud');
$browse2 = new Browse();
$browse2->set_type($browse_type);
$browse2->store();
require_once AmpConfig::get('prefix') . '/templates/show_tagcloud.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_tagcloud.inc.php');
UI::show_box_bottom();
$type = $browse2->get_type();
require_once AmpConfig::get('prefix') . '/templates/browse_content.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('browse_content.inc.php');
break;
case 'artist':
$browse->set_filter('catalog',$_SESSION['catalog']);
@ -202,8 +204,23 @@ switch ($_REQUEST['action']) {
$browse->update_browse_from_session();
$browse->show_objects();
break;
case 'podcast':
if (AmpConfig::get('catalog_disable')) {
$browse->set_filter('catalog_enabled', '1');
}
$browse->set_sort('title','ASC');
$browse->update_browse_from_session();
$browse->show_objects();
break;
case 'podcast_episode':
if (AmpConfig::get('catalog_disable')) {
$browse->set_filter('catalog_enabled', '1');
}
$browse->set_sort('pubdate','DESC');
$browse->update_browse_from_session();
$browse->show_objects();
break;
default:
break;
} // end Switch $action

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -37,7 +37,7 @@ switch ($_REQUEST['action']) {
$object = new $type($_REQUEST['id']);
if ($object->id) {
$object->format();
require_once AmpConfig::get('prefix') . '/templates/show_add_channel.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_add_channel.inc.php');
}
}
UI::show_footer();
@ -56,7 +56,7 @@ switch ($_REQUEST['action']) {
$created = Channel::create($_REQUEST['name'], $_REQUEST['description'], $_REQUEST['url'], $_REQUEST['type'], $_REQUEST['id'], $_REQUEST['interface'], $_REQUEST['port'], $_REQUEST['admin_password'], $_REQUEST['private'] ?: 0, $_REQUEST['max_listeners'], $_REQUEST['random'] ?: 0, $_REQUEST['loop'] ?: 0, $_REQUEST['stream_type'], $_REQUEST['bitrate']);
if (!$created) {
require_once AmpConfig::get('prefix') . '/templates/show_add_channel.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_add_channel.inc.php');
} else {
$title = T_('Channel Created');
show_confirmation($title, $body, AmpConfig::get('web_path') . '/browse.php?action=channel');
@ -76,7 +76,7 @@ switch ($_REQUEST['action']) {
exit;
}
$id = $_REQUEST['id'];
$id = $_REQUEST['id'];
$channel = new Channel($id);
if ($channel->delete()) {
$next_url = AmpConfig::get('web_path') . '/browse.php?action=channel';

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -53,13 +53,13 @@ if ($channel->is_private) {
$auth = Auth::login($htusername, $htpassword);
if ($auth['success']) {
$username = $auth['username'];
$username = $auth['username'];
$GLOBALS['user'] = new User($username);
$is_auth = true;
$is_auth = true;
Preference::init();
if (AmpConfig::get('access_control')) {
if (!Access::check_network('stream',$GLOBALS['user']->id,'25') AND
if (!Access::check_network('stream',$GLOBALS['user']->id,'25') and
!Access::check_network('network',$GLOBALS['user']->id,'25')) {
debug_event('UI::access_denied', "Streaming Access Denied: " . $_SERVER['REMOTE_ADDR'] . " does not have stream level access",'3');
UI::access_denied();
@ -79,9 +79,9 @@ if ($channel->is_private) {
$url = 'http://' . $channel->interface . ':' . $channel->port . '/' . $_REQUEST['target'];
// Redirect request to the real channel server
$headers = getallheaders();
$headers = getallheaders();
$headers['Host'] = $channel->interface;
$reqheaders = array();
$reqheaders = array();
foreach ($headers as $key => $value) {
$reqheaders[] = $key . ': ' . $value;
}

330
sources/composer.json Normal file
View file

@ -0,0 +1,330 @@
{
"name": "ampache/ampache",
"description": "A web based audio/video streaming application and file manager allowing you to access your music & videos from anywhere, using almost any internet enabled device.",
"homepage": "http://ampache.org",
"keywords": ["php", "music", "video", "player", "stream"],
"type": "project",
"license": "AGPL-3.0",
"config":
{
"vendor-dir": "lib/vendor",
"component-dir": "lib/components",
"platform": {
"ext-curl": "1.0",
"ext-gd": "1.0",
"ext-gmp": "1.0",
"ext-dom": "1.0",
"ext-pcre": "1.0",
"ext-spl": "1.0",
"ext-simplexml": "1.0",
"ext-ctype": "1.0",
"ext-date": "1.0",
"ext-iconv": "1.0",
"ext-libxml": "1.0",
"ext-mbstring": "1.0",
"ext-xmlwriter": "1.0",
"ext-xmlreader": "1.0",
"lib-libxml": "2.6.20"
}
},
"require": {
"php": ">=5.4.0",
"symfony/process": "~2.1",
"wikimedia/composer-merge-plugin": "1.*",
"doctrine/cache": "1.5.4",
"gettext/gettext": "3.5.*",
"james-heinrich/getid3": "1.9.*",
"mikealmond/musicbrainz": "dev-master",
"phpmailer/phpmailer": "5.2.*",
"rmccue/requests": "1.6.*",
"react/react": "0.4.*",
"cboden/ratchet": "0.3.*",
"symfony/event-dispatcher": "2.7.*",
"symfony/routing": "2.7.*",
"symfony/http-foundation": "2.7.*",
"szymach/c-pchart": "1.*",
"evenement/evenement": "2.*",
"happyworm/jplayer": "2.*",
"needim/noty": "2.3.*",
"openid/php-openid": "2.*",
"sabre/dav": "3.0.5",
"maennchen/zipstream-php": "0.*",
"Afterster/php-echonest-api": "dev-master",
"components/jquery": "2.0.*",
"components/jqueryui": "1.*",
"vakata/jstree": "3.*",
"components/bootstrap": "3.*",
"aehlke/tag-it": "2.*",
"scaron/prettyphoto": "3.*",
"jeromeetienne/jquery-qrcode": "dev-master",
"carhartl/jquery-cookie": "1.*",
"xdan/datetimepicker": "2.*",
"blueimp/jQuery-File-Upload": "9.*",
"aterrien/jQuery-Knob": "1.2.*",
"pklauzinski/jscroll": "2.*",
"kumailht/responsive-elements": "dev-master"
},
"repositories":
[
{
"type": "package",
"package": {
"name": "Afterster/php-echonest-api",
"version": "dev-master",
"source": {
"url": "https://github.com/Afterster/php-echonest-api.git",
"type": "git",
"reference": "master"
}
}
},
{
"type": "package",
"package": {
"name": "jeromeetienne/jquery-qrcode",
"type": "component",
"version": "dev-master",
"source": {
"url": "https://github.com/jeromeetienne/jquery-qrcode.git",
"type": "git",
"reference": "master"
},
"extra": {
"component": {
"scripts": [
"src/jquery.qrcode.js",
"src/qrcode.js"
]
}
},
"require": {
"robloach/component-installer": "*"
}
}
},
{
"type": "package",
"package": {
"name": "carhartl/jquery-cookie",
"type": "component",
"version": "1.4.1",
"source": {
"url": "https://github.com/carhartl/jquery-cookie.git",
"type": "git",
"reference": "v1.4.1"
},
"extra": {
"component": {
"scripts": [
"jquery.cookie.js"
]
}
},
"require": {
"robloach/component-installer": "*"
}
}
},
{
"type": "package",
"package": {
"name": "aehlke/tag-it",
"type": "component",
"version": "2.0",
"source": {
"url": "https://github.com/aehlke/tag-it.git",
"type": "git",
"reference": "v2.0"
},
"extra": {
"component": {
"scripts": [
"js/tag-it.js"
],
"styles": [
"css/jquery.tagit.css"
],
"files": [
"js/tag-it.min.js"
]
}
},
"require": {
"robloach/component-installer": "*"
}
}
},
{
"type": "package",
"package": {
"name": "scaron/prettyphoto",
"type": "component",
"version": "3.1.6",
"source": {
"url": "https://github.com/scaron/prettyphoto.git",
"type": "git",
"reference": "3.1.6"
},
"extra": {
"component": {
"scripts": [
"js/jquery.prettyPhoto.js"
],
"styles": [
"css/prettyPhoto.css"
]
}
},
"require": {
"robloach/component-installer": "*"
}
}
},
{
"type": "package",
"package": {
"name": "xdan/datetimepicker",
"type": "component",
"version": "2.4.5",
"source": {
"url": "https://github.com/xdan/datetimepicker.git",
"type": "git",
"reference": "2.4.5"
},
"extra": {
"component": {
"scripts": [
"jquery.datetimepicker.js"
],
"styles": [
"jquery.datetimepicker.css"
]
}
},
"require": {
"robloach/component-installer": "*"
}
}
},
{
"type": "package",
"package": {
"name": "blueimp/jQuery-File-Upload",
"type": "component",
"version": "9.11.2",
"source": {
"url": "https://github.com/blueimp/jQuery-File-Upload.git",
"type": "git",
"reference": "9.11.2"
},
"extra": {
"component": {
"scripts": [
"js/jquery.fileupload.js",
"js/jquery.iframe-transport.js"
]
}
},
"require": {
"robloach/component-installer": "*"
}
}
},
{
"type": "package",
"package": {
"name": "aterrien/jQuery-Knob",
"type": "component",
"version": "1.2.11",
"source": {
"url": "https://github.com/aterrien/jQuery-Knob.git",
"type": "git",
"reference": "1.2.11"
},
"extra": {
"component": {
"scripts": [
"js/jquery.knob.js"
]
}
},
"require": {
"robloach/component-installer": "*"
}
}
},
{
"type": "package",
"package": {
"name": "pklauzinski/jscroll",
"type": "component",
"version": "2.3.4",
"source": {
"url": "https://github.com/pklauzinski/jscroll.git",
"type": "git",
"reference": "v2.3.4"
},
"extra": {
"component": {
"scripts": [
"jquery.jscroll.js"
],
"files": [
"jquery.jscroll.min.js"
]
}
},
"require": {
"robloach/component-installer": "*"
}
}
},
{
"type": "package",
"package": {
"name": "kumailht/responsive-elements",
"type": "component",
"version": "dev-master",
"source": {
"url": "https://github.com/kumailht/responsive-elements.git",
"type": "git",
"reference": "master"
},
"extra": {
"component": {
"scripts": [
"responsive-elements.js"
]
}
},
"require": {
"robloach/component-installer": "*"
}
}
}
],
"extra": {
"merge-plugin": {
"include": [
"modules/catalog/*/composer.module.json",
"modules/localplay/*/composer.module.json",
"modules/plugins/*/composer.module.json"
],
"recurse": false,
"replace": false,
"merge-extra": false
}
},
"autoload": {
"psr-4": {
"Lib\\": "lib/class"
}
}
}

3406
sources/composer.lock generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,17 +1,17 @@
;#<?php exit(); ?>##
;###################
; General Config #
;###################
;#########################################################
; General Config #
;#########################################################
; This value is used to detect quickly
; if this config file is up to date
; this is compared against a value hard-coded
; into the init script
config_version = 29
config_version = 33
;###################
; Path Vars #
;###################
;#########################################################
; Path Vars #
;#########################################################
; The public http host of your server.
; If not set, retrieved automatically from client request.
@ -19,6 +19,11 @@ config_version = 29
; DEFAULT: ""
;http_host = "localhost"
; The public http port of your server.
; If not set, retrieved automatically from client request.
; DEFAULT:
;http_port = 80
; The public path to your ampache install
; Do not put a trailing / on this path
; For example if your site is located at http://localhost
@ -33,9 +38,10 @@ config_version = 29
; DEFAULT: ""
;local_web_path = "http://localhost/ampache"
;##############################
; Session and Login Variables #
;##############################
;#########################################################
; Database #
;#########################################################
; Hostname of your database
; For socket authentication, set the path to socket file (e.g. /var/run/mysqld/mysqld.sock)
@ -60,6 +66,11 @@ database_username = username
; DEFAULT: ""
database_password = password
;#########################################################
; Session and Security #
;#########################################################
; Cryptographic secret
; This MUST BE changed with your own secret key. Ampache-specific, just pick any random string you want.
secret_key = "abcdefghijklmnoprqstuvwyz0123456"
@ -95,7 +106,7 @@ session_cookielife = 0
; Is the cookie a "secure" cookie? This should only be set to 1 (true) if you are
; running a secure site (HTTPS).
; DEFAULT: 0
session_cookiesecure = 0
session_cookiesecure = 0
; Auth Methods
; This defines which auth methods Auth will attempt to use and in which order.
@ -122,43 +133,6 @@ auth_methods = "mysql"
; we want to redirect to an SSO provider instead.
; logout_redirect = "http://sso.example.com/logout"
;#####################
; Program Settings #
;#####################
; File Pattern
; This defines which file types Ampache will attempt to catalog
; You can specify any file extension you want in here separating them
; with a |
; DEFAULT: mp3|mpc|m4p|m4a|aac|ogg|oga|wav|aif|aiff|rm|wma|asf|flac|opus|spx|ra|ape|shn|wv
catalog_file_pattern = "mp3|mpc|m4p|m4a|aac|ogg|oga|wav|aif|aiff|rm|wma|asf|flac|opus|spx|ra|ape|shn|wv"
; Video Pattern
; This defines which video file types Ampache will attempt to catalog
; You can specify any file extension you want in here seperating them with
; a | but ampache may not be able to parse them
; DEAFULT: avi|mpg|mpeg|flv|m4v|mp4|webm|mkv|wmv|ogv|mov|divx|m2ts
catalog_video_pattern = "avi|mpg|mpeg|flv|m4v|mp4|webm|mkv|wmv|ogv|mov|divx|m2ts"
; Playlist Pattern
; This defines which playlist types Ampache will attempt to catalog
; You can specify any file extension you want in here seperating them with
; a | but ampache may not be able to parse them
; DEFAULT: m3u|pls|asx|xspf
catalog_playlist_pattern = "m3u|pls|asx|xspf"
; Prefix Pattern
; This defines which prefix Ampache will ignore when importing tags from
; your music. You may add any prefix you want seperating them with a |
; DEFAULT: The|An|A|Die|Das|Ein|Eine|Les|Le|La
catalog_prefix_pattern = "The|An|A|Die|Das|Ein|Eine|Les|Le|La"
; Catalog disable
; This defines if catalog can be disabled without removing database entries
; WARNING: this increase sensibly sql requests and slow down Ampache a lot
; DEFAULT: false
;catalog_disable = "false"
; Use Access List
; Toggle this on if you want ampache to pay attention to the access list
; and only allow streaming/downloading/api-rpc from known hosts api-rpc
@ -189,6 +163,115 @@ require_localnet_session = "true"
; DEFAULT: false
;prevent_multiple_logins = "false"
;#########################################################
; Metadata #
;#########################################################
; This determines the tag order for all cataloged
; music. If none of the listed tags are found then
; ampache will randomly use whatever was found.
; POSSIBLE VALUES: ape asf avi id3v1 id3v2 lyrics3 matroska mpeg quicktime riff
; vorbiscomment
; DEFAULT: id3v2 id3v1 vorbiscomment quicktime matroska ape asf avi mpeg riff
getid3_tag_order = "id3v2,id3v1,vorbiscomment,quicktime,matroska,ape,asf,avi,mpeg,riff"
; Determines whether we try to autodetect the encoding for id3v2 tags.
; May break valid tags.
; DEFAULT: false
;getid3_detect_id3v2_encoding = "false"
; This determines if file metadata should be write back to files
; as id3 metadata when updated.
; DEFAULT: false
;write_id3 = "false"
; This determines if album art should be write back to files
; as id3 metadata when updated.
; DEFAULT: false
;write_id3_art = "false"
; This determines the order in which metadata sources are used (and in the
; case of plugins, checked)
; POSSIBLE VALUES (builtins): filename and getID3
; POSSIBLE VALUES (plugins): MusicBrainz,TheAudioDb, plus any others you've installed.
; DEFAULT: getID3 filename
metadata_order = "getID3,filename"
; This determines the order in which metadata sources are used (and in the
; case of plugins, checked) for video files
; POSSIBLE VALUES (builtins): filename and getID3
; POSSIBLE VALUES (plugins): Tvdb,Tmdb,Omdb, plus any others you've installed.
; DEFAULT: filename getID3
metadata_order_video = "filename,getID3"
; This determines if extended metadata grabbed from external services should be deferred.
; If enabled, extended metadata is retrieved when browsing the library item.
; If disabled, extended metadata is retrieved at catalog update.
; Today, only Artist information (summary, place formed, ...) can be deferred.
; DEFAULT: true
deferred_ext_metadata = "true"
; Some taggers use delimiters other than \0 for fields
; This list specifies possible delimiters additional to \0
; This setting takes a regex pattern.
; DEFAULT: // / \ | , ;
additional_genre_delimiters = "[/]{2}|[/|\\\\|\|,|;]"
; Enable importing custom metadata from files.
; This will need a bit of time during the import. So you may want to disable this
; if you have troubles with huge databases.
; DEFAULT: false
;enable_custom_metadata = "false"
;#########################################################
; Catalog #
;#########################################################
; File Pattern
; This defines which file types Ampache will attempt to catalog
; You can specify any file extension you want in here separating them
; with a |
; DEFAULT: mp3|mpc|m4p|m4a|aac|ogg|oga|wav|aif|aiff|rm|wma|asf|flac|opus|spx|ra|ape|shn|wv
catalog_file_pattern = "mp3|mpc|m4p|m4a|aac|ogg|oga|wav|aif|aiff|rm|wma|asf|flac|opus|spx|ra|ape|shn|wv"
; Video Pattern
; This defines which video file types Ampache will attempt to catalog
; You can specify any file extension you want in here separating them with
; a | but ampache may not be able to parse them
; DEAFULT: avi|mpg|mpeg|flv|m4v|mp4|webm|mkv|wmv|ogv|mov|divx|m2ts
catalog_video_pattern = "avi|mpg|mpeg|flv|m4v|mp4|webm|mkv|wmv|ogv|mov|divx|m2ts"
; Playlist Pattern
; This defines which playlist types Ampache will attempt to catalog
; You can specify any file extension you want in here separating them with
; a | but ampache may not be able to parse them
; DEFAULT: m3u|m3u8|pls|asx|xspf
catalog_playlist_pattern = "m3u|m3u8|pls|asx|xspf"
; Prefix Pattern
; This defines which prefix Ampache will ignore when importing tags from
; your music. You may add any prefix you want separating them with a |
; DEFAULT: The|An|A|Die|Das|Ein|Eine|Les|Le|La
catalog_prefix_pattern = "The|An|A|Die|Das|Ein|Eine|Les|Le|La"
; Catalog disable
; This defines if catalog can be disabled without removing database entries
; WARNING: this increase sensibly sql requests and slow down Ampache a lot
; DEFAULT: false
;catalog_disable = "false"
; Delete from disk
; This determines if catalog manager users can delete medias from disk.
; DEFAULT: false
;delete_from_disk = "false"
;#########################################################
; Program Settings #
;#########################################################
; Downsample Remote
; If this is set to true and access control is on any users who are not
; coming from a defined 'network' ACL will be automatically downsampled
@ -259,60 +342,6 @@ Allow Zip Types
; VALUES: any whole number (in bytes per second)
;throttle_download = 10
; This determines the tag order for all cataloged
; music. If none of the listed tags are found then
; ampache will randomly use whatever was found.
; POSSIBLE VALUES: ape asf avi id3v1 id3v2 lyrics3 matroska mpeg quicktime riff
; vorbiscomment
; DEFAULT: id3v2 id3v1 vorbiscomment quicktime matroska ape asf avi mpeg riff
getid3_tag_order = "id3v2,id3v1,vorbiscomment,quicktime,matroska,ape,asf,avi,mpeg,riff"
; Determines whether we try to autodetect the encoding for id3v2 tags.
; May break valid tags.
; DEFAULT: false
;getid3_detect_id3v2_encoding = "false"
; This determines if file metadata should be write back to files
; as id3 metadata when updated.
; DEFAULT: false
;write_id3 = "false"
; This determines if album art should be write back to files
; as id3 metadata when updated.
; DEFAULT: false
;write_id3_art = "false"
; This determines if catalog manager users can delete medias from disk.
; DEFAULT: false
;delete_from_disk = "false"
; This determines the order in which metadata sources are used (and in the
; case of plugins, checked)
; POSSIBLE VALUES (builtins): filename and getID3
; POSSIBLE VALUES (plugins): MusicBrainz,TheAudioDb, plus any others you've installed.
; DEFAULT: getID3 filename
metadata_order = "getID3,filename"
; This determines the order in which metadata sources are used (and in the
; case of plugins, checked) for video files
; POSSIBLE VALUES (builtins): filename and getID3
; POSSIBLE VALUES (plugins): Tvdb,Tmdb,Omdb, plus any others you've installed.
; DEFAULT: filename getID3
metadata_order_video = "filename,getID3"
; This determines if extended metadata grabbed from external services should be deferred.
; If enabled, extended metadata is retrieved when browsing the library item.
; If disabled, extended metadata is retrieved at catalog update.
; Today, only Artist information (summary, place formed, ...) can be deferred.
; DEFAULT: true
deferred_ext_metadata = "true"
; Some taggers use delimiters other than \0 for fields
; This list specifies possible delimiters additional to \0
; This setting takes a regex pattern.
; DEFAULT: // / \ | , ;
additional_genre_delimiters = "[/]{2}|[/|\\\\|\|,|;]"
; This determines if a preview image should be retrieved from video files
; It requires encode_get_image transcode settings.
; DEFAULT: false
@ -477,6 +506,11 @@ art_order = "db,tags,folder,musicbrainz,lastfm,google"
; recommendations and metadata.
lastfm_api_key = "d5df942424c71b754e54ce1832505ae2"
; Last.FM API secret
; Set this to your Last.FM api secret to actually use Last.FM for
; scrobbling.
lastfm_api_secret = ""
; Wanted
; Set this to true to enable display missing albums and the
; possibility for users to mark it as wanted.
@ -520,11 +554,48 @@ channel = "true"
; DEFAULT: true
live_stream = "true"
; Podcasts
; Set this to true to enable podcasts and the
; possibility for admins to subscribe to new podcasts.
; DEFAULT: false
;podcast = "false"
; Web Socket address
; Declare the web socket server address
; DEFAULT: determined automatically
;websocket_address = "ws://localhost:8100"
; Refresh Limit
; This defines the default refresh limit in seconds for
; pages with dynamic content, such as now playing
; DEFAULT: 60
; Possible Values: Int > 5
refresh_limit = "60"
; Footer Statistics
; This defines whether statistics (Queries, Cache Hits, Load Time)
; are shown in the page footer.
; DEFAULT: true
; Possible values: true, false
show_footer_statistics = "true"
; RSS Feeds
; Set this to true to enable rss feeds.
; (latest albums, shouts, albums of artist, ...)
; use_rss = false (values true | false)
;DEFAULT: use_rss = false
;use_rss = "false"
; This setting allows themes to overwrite PHP template files. This can be really
; dangerous. Do this only if you trust every theme in your themes/ directory.
; DEFAULT: false
;allow_php_themes = "false"
;#########################################################
; Debugging #
;#########################################################
; Debug
; If this is enabled Ampache will write debugging information to the log file
; DEFAULT: false
@ -548,15 +619,20 @@ debug_level = 5
; include trailing slash. You will need to make sure that
; the specified directory exists and your HTTP server has
; write access.
; DEFAULT: NULL
; DEFAULT: none
;log_path = "/var/log/ampache"
; Log filename pattern
; This defines where the log file name pattern.
; This defines where the log file name pattern
; %name.%Y%m%d.log will create a different log file every day.
; DEFAULT: %name.%Y%m%d.log
log_filename = "%name.%Y%m%d.log"
;#########################################################
; Encoding Settings #
;#########################################################
; Charset of generated HTML pages
; Default of UTF-8 should work for most people
; DEFAULT: UTF-8
@ -570,19 +646,13 @@ site_charset = UTF-8
; DEFAULT: ISO8859-1
;lc_charset = "ISO8859-1"
; Refresh Limit
; This defines the default refresh limit in seconds for
; pages with dynamic content, such as now playing
; DEFAULT: 60
; Possible Values: Int > 5
refresh_limit = "60"
; Multibyte
; See http://php.net/manual/mbstring.supported-encodings.php
; If you want ID3v1 encoding detection to work, you should uncomment this line
; so that the ordering is sane.
; DEFAULT: auto
;mb_detect_order = "ASCII,UTF-8,EUC-JP,ISO-2022-JP,SJIS,JIS"
; Footer Statistics
; This defines whether statistics (Queries, Cache Hits, Load Time)
; are shown in the page footer.
; DEFAULT: true
; Possible values: true, false
show_footer_statistics = "true"
;#########################################################
; Custom actions (optional) #
@ -605,6 +675,7 @@ show_footer_statistics = "true"
;custom_play_action_icon_0 = "microphone"
;custom_play_action_run_0 = "sox \"%f\" -p oops | ffmpeg -i pipe:0 -f %c pipe:1"
;#########################################################
; LDAP login info (optional) #
;#########################################################
@ -612,7 +683,7 @@ show_footer_statistics = "true"
; LDAP filter string to use (required)
; For OpenLDAP use "uid"
; For Microsoft Active Directory (MAD) use "sAMAccountName"
; DEFAULT: null
; DEFAULT: none
;ldap_filter = "(sAMAccountName=%v)"
; LDAP objectclass (required)
@ -622,38 +693,40 @@ show_footer_statistics = "true"
;ldap_objectclass = "organizationalPerson"
; Initial credentials to bind with for searching (optional)
; DEFAULT: null
; DEFAULT: none
;ldap_username = ""
;ldap_password = ""
; Require that the user is in a specific group (optional)
; DEFAULT: null
; DEFAULT: none
;ldap_require_group = "cn=yourgroup,ou=yourorg,dc=yoursubdomain,dc=yourdomain,dc=yourtld"
; This is the search dn used to find users (required)
; DEFAULT: null
; DEFAULT: none
;ldap_search_dn = "ou=People,dc=yoursubdomain,dc=yourdomain,dc=yourtld"
; This is the address of your ldap server (required)
; DEFAULT: null
; DEFAULT: none
;ldap_url = ""
; Attributes where additional user information is stored (optional)
; OpenLDAP ldap_name_field = "cn"
; MAD ldap_name_field = "displayname"
; DEFAULT: null
; DEFAULT: none
;ldap_email_field = "mail"
;ldap_name_field = "cn"
;#########################################################
; OpenID login info (optional) #
;#########################################################
; Requires specific OpenID Provider Authentication Policy
; DEFAULT: null
; DEFAULT: none
; VALUES: PAPE_AUTH_MULTI_FACTOR_PHYSICAL,PAPE_AUTH_MULTI_FACTOR,PAPE_AUTH_PHISHING_RESISTANT
;openid_required_pape = ""
;#########################################################
; Public Registration settings, defaults to disabled #
;#########################################################
@ -725,6 +798,7 @@ registration_display_fields = "fullname,website"
; DEFAULT: fullname
registration_mandatory_fields = "fullname"
;########################################################
; These options control the dynamic downsampling based #
; on current usage #
@ -823,7 +897,7 @@ transcode_player_customize = "true"
; Command configuration. Substitutions will be made as follows:
; %FILE% => filename
; %SAMPLE% => target sample rate
; %BITRATE% => target bit rate
; You can do fancy things like VBR, but consider whether the consequences are
; acceptable in your environment.
@ -852,11 +926,11 @@ transcode_input = "-i %FILE%"
; For each output format, you should provide the necessary arguments for
; your transcode_cmd.
; encode_args_TYPE = TRANSCODE_CMD_ARGS
encode_args_mp3 = "-vn -b:a %SAMPLE%K -c:a libmp3lame -f mp3 pipe:1"
encode_args_ogg = "-vn -b:a %SAMPLE%K -c:a libvorbis -f ogg pipe:1"
encode_args_m4a = "-vn -b:a %SAMPLE%K -c:a libfdk_aac -f adts pipe:1"
encode_args_wav = "-vn -b:a %SAMPLE%K -c:a pcm_s16le -f wav pipe:1"
encode_args_flv = "-b:a %SAMPLE%K -ar 44100 -ac 2 -v 0 -f flv -c:v libx264 -preset superfast -threads 0 pipe:1"
encode_args_mp3 = "-vn -b:a %BITRATE%K -c:a libmp3lame -f mp3 pipe:1"
encode_args_ogg = "-vn -b:a %BITRATE%K -c:a libvorbis -f ogg pipe:1"
encode_args_m4a = "-vn -b:a %BITRATE%K -c:a libfdk_aac -f adts pipe:1"
encode_args_wav = "-vn -b:a %BITRATE%K -c:a pcm_s16le -f wav pipe:1"
encode_args_flv = "-b:a %BITRATE%K -ar 44100 -ac 2 -v 0 -f flv -c:v libx264 -preset superfast -threads 0 pipe:1"
encode_args_webm = "-q %QUALITY% -f webm -c:v libvpx -maxrate %MAXBITRATE%k -preset superfast -threads 0 pipe:1"
encode_args_ts = "-q %QUALITY% -s %RESOLUTION% -f mpegts -c:v libx264 -c:a libmp3lame -maxrate %MAXBITRATE%k -preset superfast -threads 0 pipe:1"
@ -873,18 +947,10 @@ encode_ss_frame = "-ss %TIME%"
encode_ss_duration = "-t %DURATION%"
;######################################################
; these options allow you to configure your rss-feed
; layout. rss exists of two parts, main and song main is the information about the feed
; song is the information in the feed. can be multiple items.
; use_rss = false (values true | false)
;DEFAULT: use_rss = false
;use_rss = "false"
;#####################################################
;#########################################################
; Proxy Settings (optional) #
;#########################################################
;#############################
; Proxy Settings (optional) #
;#############################
; If Ampache is behind an http proxy, specifiy the hostname or IP address
; port, proxyusername, and proxypassword here.
;DEFAULT: not in use
@ -897,9 +963,10 @@ encode_ss_duration = "-t %DURATION%"
;Default: false
;force_ssl = "true"
;#############################
; Mail Settings #
;#############################
;#########################################################
; Mail Settings #
;#########################################################
;Method used to send mail
;POSSIBLE VALUES: smtp sendmail php
@ -928,16 +995,17 @@ encode_ss_duration = "-t %DURATION%"
;mail_check = "strict"
;############################
; sendmail Settings #
;############################
;#########################################################
; sendmail Settings #
;#########################################################
;DEFAULT: /usr/sbin/sendmail
;sendmail_path = "/usr/sbin/sendmail"
;#############################
; SMTP Settings #
;#############################
;#########################################################
; SMTP Settings #
;#########################################################
;Mail server (hostname or IP address)
;DEFAULT: localhost
@ -965,10 +1033,8 @@ encode_ss_duration = "-t %DURATION%"
;mail_auth_pass = ""
;#############################
; Multibyte Settings #
; Abbreviation Filter #
;#############################
; See http://php.net/manual/mbstring.supported-encodings.php
; If you want ID3v1 encoding detection to work, you should uncomment this line
; so that the ordering is sane.
; DEFAULT: auto
;mb_detect_order = "ASCII,UTF-8,EUC-JP,ISO-2022-JP,SJIS,JIS"
; For file name parsing. Any unecessary abbreviations in file names can be removed during parsing
; by adding them to the list below so that they will be removed during the parsing process.
common_abbr = "divx,xvid,dvdrip,hdtv,lol,axxo,repack,xor,pdtv,real,vtv,caph,2hd,proper,fqm,uncut,topaz,tvt,notv,fpn,fov,orenji,0tv,omicron,dsr,ws,sys,crimson,wat,hiqt,internal,brrip,boheme,vost,vostfr,fastsub,addiction,x264,LOL,720p,1080p,YIFY,evolve,fihtv,first,bokutox,bluray,tvboom,info"

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -24,6 +24,6 @@ require_once 'lib/init.php';
UI::show_header();
require_once AmpConfig::get('prefix') . '/templates/cookie_disclaimer.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('cookie_disclaimer.inc.php');
UI::show_footer();

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -34,7 +34,7 @@ $headers = apache_request_headers();
//$daapAccessIndex = $headers['Client-DAAP-Access-Index'];
//$daapVersion = $headers['Client-DAAP-Version'];
//$daapValidation = $headers['Client-DAAP-Validation']; // That's header hash, we don't care about it (only required by iTunes >= 7.0)
debug_event('daap', 'Request headers: '. print_r($headers, true), '5');
debug_event('daap', 'Request headers: ' . print_r($headers, true), '5');
// Get the list of possible methods for the Plex API
$methods = get_class_methods('daap_api');
@ -50,7 +50,9 @@ if (count($params) > 0) {
$act = strtolower(implode('_', array_slice($params, 0, $i)));
$act = str_replace("-", "_", $act);
foreach ($methods as $method) {
if (in_array($method, $internal_functions)) { continue; }
if (in_array($method, $internal_functions)) {
continue;
}
// If the method is the same as the action being called
// Then let's call this function!
@ -59,7 +61,6 @@ if (count($params) > 0) {
// We only allow a single function to be called, and we assume it's cleaned up!
exit();
}
} // end foreach methods in API
}
}

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -43,7 +43,7 @@ switch ($_REQUEST['action']) {
}
// Show the create page
require_once AmpConfig::get('prefix') . '/templates/show_create_democratic.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_create_democratic.inc.php');
break;
case 'delete':
if (!Access::check('interface','75')) {
@ -54,8 +54,8 @@ switch ($_REQUEST['action']) {
Democratic::delete($_REQUEST['democratic_id']);
$title = '';
$text = T_('The Requested Playlist has been deleted.');
$url = AmpConfig::get('web_path') . '/democratic.php?action=manage_playlists';
$text = T_('The Requested Playlist has been deleted.');
$url = AmpConfig::get('web_path') . '/democratic.php?action=manage_playlists';
show_confirmation($title,$text,$url);
break;
case 'create':
@ -96,20 +96,20 @@ switch ($_REQUEST['action']) {
// Get all of the non-user playlists
$playlists = Democratic::get_playlists();
require_once AmpConfig::get('prefix') . '/templates/show_manage_democratic.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_manage_democratic.inc.php');
break;
case 'show_playlist':
default:
$democratic = Democratic::get_current_playlist();
if (!$democratic->id) {
require_once AmpConfig::get('prefix') . '/templates/show_democratic.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_democratic.inc.php');
break;
}
$democratic->set_parent();
$democratic->format();
require_once AmpConfig::get('prefix') . '/templates/show_democratic.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_democratic.inc.php');
$objects = $democratic->get_items();
Song::build_cache($democratic->object_ids);
Democratic::build_vote_cache($democratic->vote_ids);

View file

@ -1,5 +1,5 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
@ -7,17 +7,15 @@
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
@ -26,44 +24,34 @@ them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
@ -72,7 +60,7 @@ modification follow.
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
@ -549,35 +537,45 @@ to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
@ -635,40 +633,29 @@ the "copyright" line and a pointer to where the full notice is found.
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GNU Affero General Public License for more details.
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View file

@ -1,6 +1,98 @@
CHANGELOG
=========
3.8.2
----------
- Fixed potential security vulnerability on smartplaylist search rule and catalog management actions (thanks Roman Ammann)
- Fixed song comparison issue on arrays (genre ...) when updating from tag
- Fixed song insertion issue if track year is out of range
- Fixed unexpected artist summary autoupdate
- Improved generated playlist filename (thanks yam655)
- Fixed user avatar upload (thanks vader083)
- Fixed waveform temporary file deletion issue if GD library is unavailable
- Fixed max number of items returned from Subsonic getStarred.view (thanks zerodogg)
- Fixed video update from tags (thanks stebe)
- Reverted PHP 5.5.9 dependency to PHP 5.4
- Added video playlist support (thanks SurvivalHive)
- Added preference subcategory
- Added prompt for new playlist name
- Fixed page refresh when canceling album art change (thanks EvilLivesHere)
- Added /play htaccess rewrite rule to avoid default max limit redirection
- Fixed Subsonic artist/album/song name JSON parsing if the name is numeric only
- Added ignored articles and cover art to Subsonic getArtists.view function
- Fixed MySQL requests to support ONLY_FULL_GROUP_BY mode
- Fixed Ajax art refresh after changing it (thanks gnujeremie)
- Fixed playlist creation from smartplaylist (thanks stebe)
- Added SQL unique constraint on tag map
- Fixed Subsonic genres with JSON format
- Added Bookmarks feature on Subsonic API
- Fixed thumb art regeneration if entry found in database without data (thanks s4astliv)
- Added Podcast feature
- Added large view / grid view option on artist and albums collection
- Moved from php-gettext to oscarotero/Gettext
- Added `Access-Control-Allow-Origin: *` header on Subsonic images & streams
- Fixed Subsonic item identifier parsing
- Added logic for external plugin directories (ampache-*)
- Added Discogs metadata plugin
3.8.1
----------
- Fixed PHP7 Error class conflict (thanks trampi)
- Fixed user password with special characters at install time (thanks jagerman)
- Moved Ampache project license from GPLv2 to AGPLv3
- Added Ampache specific information on Subsonic API getAlbum using a new `ampache` parameter (thanks nicklan)
- Added 'album tag' option in song search (thanks DanielMaly)
- Added Message of the Day plugin to display MOTD at home page
- Moved AmpacheApi class to a separate ampacheapi-php git repository
- Added timeline / friends timeline feature
- Fixed disabled song display to regular users (thanks shangril)
- Fixed random albums art size (thanks Bidules079)
- Moved tag cloud to artist browsing by default
- Fixed utf8 BOM empty string on song comparison
- Improved recently played and user stats queries performance (thanks thinca)
- Renamed SAMPLE_RATE to TRANSCODE_BITRATE on transcoding
- Fixed tag deletion sql error (thanks stebe)
- Moved to PNG default blank image instead of JPG (thanks Psy-Virus)
- Fixed temporary playlist initial position when scrolling down (thanks RobertoCarlo)
- Added Radio stations to UPnP backend
- Fixed Subsonic API art to use album art if song doesn't have a custom art (thanks hypfvieh)
- Fixed Subsonic API search when object count parameter is 0 (thanks hypfvieh)
- Fixed UPnP UUID to be based on host information
- Moved to Composer for dependencies management
- Fixed catalog action when not using Ajax page loading (thanks Razrael)
- Fixed unrated song default value (thanks Combustible)
- Added custom metadata support from files (thanks Razrael)
- Improved Subsonic API getArtists performance (thanks nicklan)
- Fixed theme color setting behavior
- Moved audioscrobbler API to v2
- Added m3u8 playlist import
- Fixed utf8 id3v2 comments support
- Added write_playlists script to export playlists to file
- Fixed Tvdb and Tmdb plugins (thanks wagnered)
- Improved Video filename parsing (thanks wagnered)
- Fixed non scalar settings value printing on debug page
- Improved Subsonic API getAlbumList error handling
- Fixed user login with browser used during the installation
- Fixed iTunes 12 browsing when using DAAP (thanks Chattaway83)
- Moved http_port user preference to ampache.cfg.php
- Upgraded last.fm and libre.fm scrobbling to latest API version (thanks nioc)
- Added missing space between track and album in localplay playlist (thanks arnaudbey)
- Added check fo mbstring.func_overload support before using id3 write functionality (thanks anonymous2ch)
- Fixed file size calculation when using id3v2 tag (thanks hypfvieh)
- Added rating from id3 tag (thanks nioc)
- Added track number on streaming playlist (thanks Fondor1)
- Fixed catalog export (thanks shellshocker)
- Fixed file change detection
- Improved XML API with more information and new functions (advanced_search, toggle_follow, last_shouts, rate, timeline, friends_timeline)
- Fixed 'Next' button when browsing start offset is aligned to offset limit (thanks wagnered)
- Fixed stream kill OS detection (thanks nan4k7)
- Fixed calculate_art_size script to support storage on disk (thanks nan4k7)
- Fixed sql script semicolon typo (thanks jack)
- Added support for .opus files (thanks mrpi)
- Fixed podcast owner xml information
- Fixed ldap filter parameter check (thanks ChrGeiss)
- Fixed 'Add to existing playlist' link for regular users (thanks Niols)
3.8.0
----------
- Added Portuguese (Brasil) language (thanks Ione Souza Junior)

View file

@ -1,280 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
^L
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS

View file

@ -1,9 +1,9 @@
-------------------------------------------------------------------------------
----------------- PLUGINS - Ampache v.3.6 ----------------------
----------------- PLUGINS - Ampache v.3.8.1 ----------------------
-------------------------------------------------------------------------------
Plugins are placed in modules/plugins; the name of the file must be
<Name>.plugin.php, e.g. Dummy.plugin.php. The file must declare a
<Name>/<Name>.plugin.php, e.g. Dummay/Dummy.plugin.php. The file must declare a
corresponding class and the name of the class must be prefixed with
Ampache, e.g. AmpacheDummy.

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -38,17 +38,17 @@ if (!AmpConfig::get('statistical_graphs')) {
$type = $_REQUEST['type'];
$user_id = intval($_REQUEST['user_id']);
$user_id = intval($_REQUEST['user_id']);
$object_type = (string) scrub_in($_REQUEST['object_type']);
if (!Core::is_library_item($object_type)) {
$object_type = null;
}
$object_id = intval($_REQUEST['object_id']);
$object_id = intval($_REQUEST['object_id']);
$start_date = scrub_in($_REQUEST['start_date']);
$end_date = scrub_in($_REQUEST['end_date']);
$zoom = (string) scrub_in($_REQUEST['zoom']);
$end_date = scrub_in($_REQUEST['end_date']);
$zoom = (string) scrub_in($_REQUEST['zoom']);
$width = intval($_REQUEST['width']);
$width = intval($_REQUEST['width']);
$height = intval($_REQUEST['height']);
$graph = new Graph();

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -41,7 +41,9 @@ if (AmpConfig::get('use_auth') && AmpConfig::get('require_session')) {
}
// If we aren't resizing just trash thumb
if (!AmpConfig::get('resize_images')) { $_GET['thumb'] = null; }
if (!AmpConfig::get('resize_images')) {
$_GET['thumb'] = null;
}
// FIXME: Legacy stuff - should be removed after a version or so
if (!isset($_GET['object_type'])) {
@ -49,36 +51,37 @@ if (!isset($_GET['object_type'])) {
}
$type = $_GET['object_type'];
if (!Core::is_library_item($type))
if (!Art::is_valid_type($type)) {
exit;
}
/* Decide what size this image is */
$size = Art::get_thumb_size($_GET['thumb']);
$kind = isset($_GET['kind']) ? $_GET['kind'] : 'default';
$image = '';
$mime = '';
$filename = '';
$etag = '';
$image = '';
$mime = '';
$filename = '';
$etag = '';
$typeManaged = false;
if (isset($_GET['type'])) {
switch ($_GET['type']) {
case 'popup':
$typeManaged = true;
require_once AmpConfig::get('prefix') . '/templates/show_big_art.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_big_art.inc.php');
break;
case 'session':
// If we need to pull the data out of the session
Session::check();
$filename = scrub_in($_REQUEST['image_index']);
$image = Art::get_from_source($_SESSION['form']['images'][$filename], 'album');
$mime = $_SESSION['form']['images'][$filename]['mime'];
$filename = scrub_in($_REQUEST['image_index']);
$image = Art::get_from_source($_SESSION['form']['images'][$filename], 'album');
$mime = $_SESSION['form']['images'][$filename]['mime'];
$typeManaged = true;
break;
}
}
if (!$typeManaged) {
$item = new $type($_GET['object_id']);
$item = new $type($_GET['object_id']);
$filename = $item->name ?: $item->title;
$art = new Art($item->id, $type, $kind);
@ -91,7 +94,7 @@ if (!$typeManaged) {
$ccontrol = $reqheaders['Cache-Control'];
if ($ccontrol != 'no-cache') {
$cetagf = explode('-', $reqheaders['If-None-Match']);
$cetag = $cetagf[0];
$cetag = $cetagf[0];
// Same image than the cached one? Use the cache.
if ($cetag == $etag) {
header('HTTP/1.1 304 Not Modified');
@ -110,8 +113,8 @@ if (!$typeManaged) {
$defaultimg .= "blankmovie.png";
break;
default:
$mime = 'image/jpeg';
$defaultimg .= "blankalbum.jpg";
$mime = 'image/png';
$defaultimg .= "blankalbum.png";
break;
}
$image = file_get_contents($defaultimg);
@ -121,22 +124,23 @@ if (!$typeManaged) {
$etag .= '-' . $_GET['thumb'];
}
$mime = isset($thumb_data['thumb_mime']) ? $thumb_data['thumb_mime'] : $art->raw_mime;
$mime = isset($thumb_data['thumb_mime']) ? $thumb_data['thumb_mime'] : $art->raw_mime;
$image = isset($thumb_data['thumb']) ? $thumb_data['thumb'] : $art->raw;
}
}
if (!empty($image)) {
$extension = Art::extension($mime);
$filename = scrub_out($filename . '.' . $extension);
$filename = scrub_out($filename . '.' . $extension);
// Send the headers and output the image
$browser = new Horde_Browser();
if (!empty($etag)) {
header('ETag: ' . $etag);
header('Cache-Control: private');
header('Last-Modified: '.gmdate('D, d M Y H:i:s \G\M\T', time()));
header('Last-Modified: ' . gmdate('D, d M Y H:i:s \G\M\T', time()));
}
header("Access-Control-Allow-Origin: *");
$browser->downloadHeaders($filename, $mime, true);
echo $image;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -38,10 +38,10 @@ $_SESSION['catalog'] = 0;
*/
if (AmpConfig::get('refresh_limit') > 5 && AmpConfig::get('home_now_playing')) {
$refresh_limit = AmpConfig::get('refresh_limit');
$ajax_url = '?page=index&action=reloadnp';
require_once AmpConfig::get('prefix') . '/templates/javascript_refresh.inc.php';
$ajax_url = '?page=index&action=reloadnp';
require_once AmpConfig::get('prefix') . UI::find_template('javascript_refresh.inc.php');
}
require_once AmpConfig::get('prefix') . '/templates/show_index.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_index.inc.php');
UI::show_footer();

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -29,23 +29,23 @@ set_error_handler('ampache_error_handler');
// Redirect if installation is already complete.
if (!install_check_status($configfile)) {
$redirect_url = 'login.php';
require_once AmpConfig::get('prefix') . '/templates/error_page.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('error_page.inc.php');
exit;
}
define('INSTALL', 1);
$htaccess_play_file = AmpConfig::get('prefix') . '/play/.htaccess';
$htaccess_rest_file = AmpConfig::get('prefix') . '/rest/.htaccess';
$htaccess_play_file = AmpConfig::get('prefix') . '/play/.htaccess';
$htaccess_rest_file = AmpConfig::get('prefix') . '/rest/.htaccess';
$htaccess_channel_file = AmpConfig::get('prefix') . '/channel/.htaccess';
// Clean up incoming variables
$web_path = scrub_in($_REQUEST['web_path']);
$username = scrub_in($_REQUEST['local_username']);
$password = $_REQUEST['local_pass'];
$hostname = scrub_in($_REQUEST['local_host']);
$database = scrub_in($_REQUEST['local_db']);
$port = scrub_in($_REQUEST['local_port']);
$web_path = scrub_in($_REQUEST['web_path']);
$username = scrub_in($_REQUEST['local_username']);
$password = $_REQUEST['local_pass'];
$hostname = scrub_in($_REQUEST['local_host']);
$database = scrub_in($_REQUEST['local_db']);
$port = scrub_in($_REQUEST['local_port']);
$skip_admin = isset($_REQUEST['skip_admin']);
AmpConfig::set_by_array(array(
@ -91,9 +91,9 @@ if (!$htmllang) {
$lang = 'en_US';
}
if (strpos($lang, '.')) {
$langtmp = explode('.', $lang);
$langtmp = explode('.', $lang);
$htmllang = $langtmp[0];
$charset = $langtmp[1];
$charset = $langtmp[1];
} else {
$htmllang = $lang;
}
@ -119,7 +119,7 @@ switch ($_REQUEST['action']) {
$new_pass = $_POST['db_password'];
if (!strlen($new_user) || !strlen($new_pass)) {
Error::add('general', T_('Error: Ampache SQL Username or Password missing'));
AmpError::add('general', T_('Error: Ampache SQL Username or Password missing'));
require_once 'templates/show_install.inc.php';
break;
}
@ -138,17 +138,17 @@ switch ($_REQUEST['action']) {
require_once 'templates/show_install_config.inc.php';
break;
case 'create_config':
$all = (isset($_POST['create_all']));
$all = (isset($_POST['create_all']));
$skip = (isset($_POST['skip_config']));
if (!$skip) {
$write = (isset($_POST['write']));
$download = (isset($_POST['download']));
$write = (isset($_POST['write']));
$download = (isset($_POST['download']));
$download_htaccess_channel = (isset($_POST['download_htaccess_channel']));
$download_htaccess_rest = (isset($_POST['download_htaccess_rest']));
$download_htaccess_play = (isset($_POST['download_htaccess_play']));
$write_htaccess_channel = (isset($_POST['write_htaccess_channel']));
$write_htaccess_rest = (isset($_POST['write_htaccess_rest']));
$write_htaccess_play = (isset($_POST['write_htaccess_play']));
$download_htaccess_rest = (isset($_POST['download_htaccess_rest']));
$download_htaccess_play = (isset($_POST['download_htaccess_play']));
$write_htaccess_channel = (isset($_POST['write_htaccess_channel']));
$write_htaccess_rest = (isset($_POST['write_htaccess_rest']));
$write_htaccess_play = (isset($_POST['write_htaccess_play']));
$created_config = true;
if ($write_htaccess_channel || $download_htaccess_channel || $all) {
@ -166,18 +166,20 @@ switch ($_REQUEST['action']) {
}
case 'show_create_account':
$results = parse_ini_file($configfile);
if (!isset($created_config)) $created_config = true;
if (!isset($created_config)) {
$created_config = true;
}
/* Make sure we've got a valid config file */
if (!check_config_values($results) || !$created_config) {
Error::add('general', T_('Error: Config files not found or unreadable'));
require_once AmpConfig::get('prefix') . '/templates/show_install_config.inc.php';
AmpError::add('general', T_('Error: Config files not found or unreadable'));
require_once AmpConfig::get('prefix') . UI::find_template('show_install_config.inc.php');
break;
}
// Don't try to add administrator user on existing database
if (install_check_status($configfile)) {
require_once AmpConfig::get('prefix') . '/templates/show_install_account.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_install_account.inc.php');
} else {
header ("Location: " . $web_path . '/login.php');
}
@ -186,19 +188,13 @@ switch ($_REQUEST['action']) {
$results = parse_ini_file($configfile);
AmpConfig::set_by_array($results, true);
$password2 = scrub_in($_REQUEST['local_pass2']);
$password2 = $_REQUEST['local_pass2'];
if (!install_create_account($username, $password, $password2)) {
require_once AmpConfig::get('prefix') . '/templates/show_install_account.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_install_account.inc.php');
break;
}
// Automatically log-in the newly created user
Session::create_cookie();
Session::create(array('type' => 'mysql', 'username' => $username));
$_SESSION['userdata']['username'] = $username;
Session::check();
header ("Location: " . $web_path . '/index.php');
break;
case 'init':
@ -212,3 +208,4 @@ switch ($_REQUEST['action']) {
require_once 'templates/show_install_lang.inc.php';
break;
} // end action switch

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -27,19 +27,23 @@ UI::show_header();
// Switch on the incomming action
switch ($_REQUEST['action']) {
case 'delete':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
$label_id = scrub_in($_REQUEST['label_id']);
show_confirmation(
T_('Label Deletion'),
T_('Are you sure you want to permanently delete this label?'),
AmpConfig::get('web_path')."/labels.php?action=confirm_delete&label_id=" . $label_id,
AmpConfig::get('web_path') . "/labels.php?action=confirm_delete&label_id=" . $label_id,
1,
'delete_label'
);
break;
case 'confirm_delete':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
$label = new Label($_REQUEST['label_id']);
if (!Catalog::can_remove($label)) {
@ -76,9 +80,9 @@ switch ($_REQUEST['action']) {
$label_id = Label::create($_POST);
if (!$label_id) {
require_once AmpConfig::get('prefix') . '/templates/show_add_label.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_add_label.inc.php');
} else {
$body = T_('Label Added');
$body = T_('Label Added');
$title = '';
show_confirmation($title, $body, AmpConfig::get('web_path') . '/browse.php?action=label');
}
@ -93,15 +97,15 @@ switch ($_REQUEST['action']) {
if ($label_id > 0) {
$label = new Label($label_id);
$label->format();
$object_ids = $label->get_artists();
$object_ids = $label->get_artists();
$object_type = 'artist';
require_once AmpConfig::get('prefix') . '/templates/show_label.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_label.inc.php');
UI::show_footer();
exit;
}
case 'show_add_label':
if (Access::check('interface','50') || AmpConfig::get('upload_allow_edit')) {
require_once AmpConfig::get('prefix') . '/templates/show_add_label.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_add_label.inc.php');
} else {
echo T_('Label cannot be found.');
}

View file

@ -1,10 +1,16 @@
# Apache 2.4
<IfModule mod_authz_core.c>
Require all denied
<FilesMatch "\.css$|\.js$|\.png$|\.gif$|\.jpg$|\.swf$|\.ttf$|\.json$|\.xml$|\.htc$|\.map$|\.woff$">
Require all granted
</FilesMatch>
</IfModule>
# Apache 2.2
<IfModule mod_access.c>
Order deny,allow
Deny from all
<Files ~ "\.css$|\.js$|\.png$|\.gif$|\.jpg$|\.swf$|\.ttf$|\.json$|\.xml$|\.htc$|\.map$|\.woff$">
Allow from all
</Files>
</IfModule>

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -36,10 +36,10 @@ function get_media_files($media_ids)
if (is_array($element)) {
if (isset($element['object_type'])) {
$type = $element['object_type'];
$id = $element['object_id'];
$id = $element['object_id'];
} else {
$type = array_shift($element);
$id = array_shift($element);
$id = array_shift($element);
}
$media = new $type($id);
} else {
@ -49,7 +49,7 @@ function get_media_files($media_ids)
$media->format();
$total_size += sprintf("%.2f",($media->size/1048576));
$dirname = '';
$parent = $media->get_parent();
$parent = $media->get_parent();
if ($parent != null) {
$pobj = new $parent['object_type']($parent['object_id']);
$pobj->format();
@ -77,8 +77,11 @@ function get_media_files($media_ids)
function send_zip($name, $media_files)
{
/* Require needed library */
require_once AmpConfig::get('prefix') . '/modules/ZipStream/ZipStream.php';
$arc = new ZipStream\ZipStream($name . ".zip" );
if (!@include_once(AmpConfig::get('prefix') . '/lib/vendor/maennchen/zipstream-php/src/ZipStream.php')) {
throw new Exception('Missing ZipStream dependency.');
}
$arc = new ZipStream\ZipStream($name . ".zip" );
$options = array(
'comment' => AmpConfig::get('file_zip_comment'),
);
@ -103,7 +106,7 @@ function check_can_zip($object_type)
{
$allowed = true;
if (AmpConfig::get('allow_zip_types')) {
$allowed = false;
$allowed = false;
$allowed_types = explode(',', AmpConfig::get('allow_zip_types'));
foreach ($allowed_types as $atype) {
if (trim($atype) == $object_type) {

View file

@ -0,0 +1,117 @@
<?php
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace Lib;
/**
* Description of Model
*
* @author raziel
*/
abstract class DatabaseObject
{
protected $id;
//private $originalData;
/**
*
* @var array Stores relation between SQL field name and class name so we
* can initialize objects the right way
*/
protected $fieldClassRelations = array();
public function __construct()
{
$this->remapCamelcase();
$this->initializeChildObjects();
//$this->originalData = get_object_vars($this);
}
public function getId()
{
return $this->id;
}
protected function isPropertyDirty($property)
{
return $this->originalData->$property !== $this->$property;
}
public function isDirty()
{
return true;
}
/**
* Get all changed properties
* TODO: we get all properties for now...need more logic here...
* @return array
*/
public function getDirtyProperties()
{
$properties = get_object_vars($this);
unset($properties['id']);
unset($properties['fieldClassRelations']);
return $this->fromCamelCase($properties);
}
/**
* Convert the object properties to camelCase.
* This works in constructor because the properties are here from
* fetch_object before the constructor get called.
*/
protected function remapCamelcase()
{
foreach (get_object_vars($this) as $key => $val) {
if (strpos($key, '_') !== false) {
$camelCaseKey = lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $key))));
$this->$camelCaseKey = $val;
unset($this->$key);
}
}
}
protected function fromCamelCase($properties)
{
$data = array();
foreach ($properties as $propertie => $value) {
$newPropertyKey = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $propertie));
$data[$newPropertyKey] = $value;
}
return $data;
}
/**
* Adds child Objects based of the Model Information
* TODO: Someday we might need lazy loading, but for now it should be ok.
*/
public function initializeChildObjects()
{
foreach ($this->fieldClassRelations as $field => $repositoryName) {
if (class_exists($repositoryName)) {
/* @var $repository Repository */
$repository = new $repositoryName;
$this->$field = $repository->findById($this->$field);
}
}
}
}

View file

@ -0,0 +1,37 @@
<?php
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace Lib\Interfaces;
/**
* Description of Model
*
* @author raziel
*/
interface Model
{
/**
* Get ID of Database Object
*/
public function getId();
}

View file

@ -0,0 +1,176 @@
<?php
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace Lib\Metadata;
/**
* Description of metadata
*
* @author raziel
*/
trait Metadata
{
/**
*
* @var Repository\Metadata
*/
protected $metadataRepository;
/**
*
* @var Repository\MetadataField
*/
protected $metadataFieldRepository;
/**
* Determines if the functionality is enabled or not.
* @var boolean
*/
protected $enableCustomMetadata;
/**
* Cache variable for disabled metadata field names
* @var array
*/
protected $disabledMetadataFields = array();
/**
* Initialize the repository variables. Needs to be called first if the trait should do something.
*/
protected function initializeMetadata()
{
$this->metadataRepository = new \Lib\Metadata\Repository\Metadata();
$this->metadataFieldRepository = new \Lib\Metadata\Repository\MetadataField();
}
/**
*
* @return Model\Metadata
*/
public function getMetadata()
{
return $this->metadataRepository->findByObjectIdAndType($this->id, get_class($this));
}
/**
*
* @param Model\Metadata $metadata
*/
public function deleteMetadata(Model\Metadata $metadata)
{
$this->metadataRepository->remove($metadata);
}
/**
*
* @param \Lib\Metadata\Model\MetadataField $field
* @param type $data
*/
public function addMetadata(\Lib\Metadata\Model\MetadataField $field, $data)
{
$metadata = new \Lib\Metadata\Model\Metadata();
$metadata->setField($field);
$metadata->setObjectId($this->id);
$metadata->setType(get_class($this));
$metadata->setData($data);
$this->metadataRepository->add($metadata);
}
public function updateOrInsertMetadata(\Lib\Metadata\Model\MetadataField $field, $data)
{
/* @var $metadata Model\Metadata */
$metadata = $this->metadataRepository->findByObjectIdAndFieldAndType($this->id, $field, get_class($this));
if ($metadata) {
$object = reset($metadata);
$object->setData($data);
$this->metadataRepository->update($object);
} else {
$this->addMetadata($field, $data);
}
}
/**
*
* @param type $name
* @param type $public
* @return \Lib\Metadata\Model\MetadataField
*/
protected function createField($name, $public)
{
$field = new \Lib\Metadata\Model\MetadataField();
$field->setName($name);
if (!$public) {
$field->hide();
}
$this->metadataFieldRepository->add($field);
return $field;
}
/**
*
* @param string $propertie
* @param boolean $public
* @return Model\MetadataField
*/
public function getField($propertie, $public = true)
{
$fields = $this->metadataFieldRepository->findByName($propertie);
if (count($fields)) {
$field = reset($fields);
} else {
$field = $this->createField($propertie, $public);
}
return $field;
}
/**
*
* @return boolean
*/
public static function isCustomMetadataEnabled()
{
return (boolean) \AmpConfig::get('enable_custom_metadata');
}
/**
* Get all disabled Metadata field names
* @return array
*/
public function getDisabledMetadataFields()
{
if (!$this->disabledMetadataFields) {
$fields = array();
$ids = explode(',', \AmpConfig::get('disabled_custom_metadata_fields'));
foreach ($ids as $id) {
$field = $this->metadataFieldRepository->findById($id);
if ($field) {
$fields[] = $field->getName();
}
}
$this->disabledMetadataFields = array_merge(
$fields, explode(',', \AmpConfig::get('disabled_custom_metadata_fields_input'))
);
}
return $this->disabledMetadataFields;
}
}

View file

@ -0,0 +1,142 @@
<?php
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace Lib\Metadata\Model;
/**
* Description of metadata
*
* @author raziel
*/
class Metadata extends \Lib\DatabaseObject implements \Lib\Interfaces\Model
{
/**
* Database ID
* @var integer
*/
protected $id;
/**
* A library item like song or video
* @var \library_item
*/
protected $objectId;
/**
* Tag Field
* @var MetadataField
*/
protected $field;
/**
* Tag Data
* @var string
*/
protected $data;
/**
*
* @var string
*/
protected $type;
/**
*
* @var array Stores relation between SQL field name and repository class name so we
* can initialize objects the right way
*/
protected $fieldClassRelations = array(
'field' => '\Lib\Metadata\Repository\MetadataField'
);
/**
*
* @return \library_item
*/
public function getObjectId()
{
return $this->objectId;
}
/**
*
* @return MetadataField
*/
public function getField()
{
return $this->field;
}
/**
*
* @return string
*/
public function getData()
{
return $this->data;
}
/**
*
* @param integer $object
*/
public function setObjectId($object)
{
$this->objectId = $object;
}
/**
*
* @param MetadataField $field
*/
public function setField(MetadataField $field)
{
$this->field = $field;
}
/**
*
* @param string $data
*/
public function setData($data)
{
$this->data = $data;
}
/**
*
* @return string
*/
public function getType()
{
return $this->type;
}
/**
*
* @param string $type
*/
public function setType($type)
{
$this->type = $type;
}
}

View file

@ -0,0 +1,102 @@
<?php
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace Lib\Metadata\Model;
/**
* Description of metadata_field
*
* @author raziel
*/
class MetadataField extends \Lib\DatabaseObject implements \Lib\Interfaces\Model
{
/**
* Database ID
* @var integer
*/
protected $id;
/**
* Tag name
* @var string
*/
protected $name;
/**
* Is the Tag public?
* @var boolean
*/
protected $public = true;
/**
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
*
* @return string
*/
public function getFormattedName()
{
return ucwords(str_replace("_", " ", $this->name));
}
/**
*
* @param string $name
*/
public function setName($name)
{
$this->name = $name;
}
/**
*
* @return boolean
*/
public function isPublic()
{
return $this->public;
}
/**
* Set public to false
*/
public function hide()
{
$this->public = false;
}
}

View file

@ -0,0 +1,40 @@
<?php
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace Lib\Metadata\Repository;
/**
* Description of Metadata
*
* @author raziel
*/
class Metadata extends \Lib\Repository
{
protected $modelClassName = '\Lib\Metadata\Model\Metadata';
public static function gc()
{
\Dba::write('DELETE FROM `metadata` USING `metadata` LEFT JOIN `song` ON `song`.`id` = `metadata`.`object_id` WHERE `song`.`id` IS NULL');
}
//put your code here
}

View file

@ -0,0 +1,38 @@
<?php
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace Lib\Metadata\Repository;
/**
* Description of Metadata_field
*
* @author raziel
*/
class MetadataField extends \Lib\Repository
{
protected $modelClassName = '\Lib\Metadata\Model\MetadataField';
public static function gc()
{
\Dba::write('DELETE FROM `metadata_field` USING `metadata_field` LEFT JOIN `metadata` ON `metadata`.`field` = `metadata_field`.`id` WHERE `metadata`.`id` IS NULL');
}
}

View file

@ -0,0 +1,230 @@
<?php
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace Lib;
use Lib\Interfaces\Model;
/**
* Description of Repository
*
* @author raziel
*/
class Repository
{
protected $modelClassName;
/**
*
* @var array Stores relation between SQL field name and class name so we
* can initialize objects the right way
*/
protected $fieldClassRelations = array();
protected function findBy($fields, $values)
{
$table = $this->getTableName();
return $this->getRecords($table, $fields, $values);
}
/**
*
* @return DatabaseObject[]
*/
public function findAll()
{
$table = $this->getTableName();
return $this->getRecords($table);
}
/**
*
* @param type $id
* @return DatabaseObject
*/
public function findById($id)
{
$rows = $this->findBy(array('id'), array($id));
return count($rows) ? reset($rows) : null;
}
private function getRecords($table, $field = null, $value = null)
{
$data = array();
$sql = $this->assembleQuery($table, $field);
$statement = \Dba::read($sql, is_array($value) ? $value : array($value));
while ($object = \Dba::fetch_object($statement, $this->modelClassName)) {
$data[$object->getId()] = $object;
}
return $data;
}
/**
*
* @param string $name
* @param array $arguments
* @return DatabaseObject
*/
public function __call($name, $arguments)
{
if (preg_match('/^findBy(.*)$/', $name, $matches)) {
$parts = explode('And', $matches[1]);
return $this->findBy(
$parts,
$this->resolveObjects($arguments)
);
}
}
private function getTableName()
{
$className = get_called_class();
$nameParts = explode('\\', $className);
$tableName = preg_replace_callback(
'/(?<=.)([A-Z])/',
function($m) {
return '_' . strtolower($m[0]);
}, end($nameParts));
return lcfirst($tableName);
}
public function add(DatabaseObject $object)
{
$properties = $object->getDirtyProperties();
$this->setPrivateProperty(
$object,
'id',
$this->insertRecord($properties)
);
}
public function update(DatabaseObject $object)
{
if ($object->isDirty()) {
$properties = $object->getDirtyProperties();
$this->updateRecord($object->getId(), $properties);
}
}
public function remove(DatabaseObject $object)
{
$id = $object->getId();
$this->deleteRecord($id);
}
protected function insertRecord($properties)
{
$sql = 'INSERT INTO ' . $this->getTableName() . ' (' . implode(',', array_keys($properties)) . ')'
. ' VALUES(' . implode(',', array_fill(0, count($properties), '?')) . ')';
//print_r($properties);
\Dba::write(
$sql,
array_values($this->resolveObjects($properties))
);
return \Dba::insert_id();
}
protected function updateRecord($id, $properties)
{
$sql = 'UPDATE ' . $this->getTableName()
. ' SET ' . implode(',', $this->getKeyValuePairs($properties))
. ' WHERE id = ?';
$properties[] = $id;
\Dba::write(
$sql,
array_values($this->resolveObjects($properties))
);
}
protected function deleteRecord($id)
{
$sql = 'DELETE FROM ' . $this->getTableName()
. ' WHERE id = ?';
\Dba::write($sql, array($id));
}
protected function getKeyValuePairs($properties)
{
$pairs = array();
foreach ($properties as $property => $value) {
$pairs[] = $property . '= ?';
}
return $pairs;
}
/**
* Set a private or protected variable.
* Only used in case where a property should not publicly writable
* @param Object $object
* @param string $property
* @param mixed $value
*/
protected function setPrivateProperty(Model $object, $property, $value)
{
$reflectionClass = new \ReflectionClass(get_class($object));
$ReflectionProperty = $reflectionClass->getProperty($property);
$ReflectionProperty->setAccessible(true);
$ReflectionProperty->setValue($object, $value);
}
/**
* Resolve all objects into id's
* @param array $properties
* @return array
*/
protected function resolveObjects(array $properties)
{
foreach ($properties as $property => $value) {
if (is_object($value)) {
$properties[$property] = $value->getId();
}
}
return $properties;
}
/**
* Create query for one or multiple fields
* @param string $table
* @param array $fields
* @return string
*/
public function assembleQuery($table, $fields)
{
$sql = 'SELECT * FROM ' . $table;
if ($fields) {
$sql .= ' WHERE ';
$sqlParts = array();
foreach ($fields as $field) {
$sqlParts[] = '`' . $this->camelCaseToUnderscore($field) . '` = ?';
}
$sql .= implode(' and ', $sqlParts);
}
return $sql;
}
public function camelCaseToUnderscore($string)
{
return strtolower(preg_replace('/(?<=\\w)(?=[A-Z])/','_$1', $string));
}
}

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -93,7 +93,9 @@ class Access
*/
public function __construct($access_id = null)
{
if (!$access_id) { return false; }
if (!$access_id) {
return false;
}
/* Assign id for use in get_info() */
$this->id = intval($access_id);
@ -114,7 +116,7 @@ class Access
*/
private function _get_info()
{
$sql = 'SELECT * FROM `access_list` WHERE `id` = ?';
$sql = 'SELECT * FROM `access_list` WHERE `id` = ?';
$db_results = Dba::read($sql, array($this->id));
$results = Dba::fetch_assoc($db_results);
@ -131,11 +133,11 @@ class Access
public function format()
{
$this->f_start = inet_ntop($this->start);
$this->f_end = inet_ntop($this->end);
$this->f_end = inet_ntop($this->end);
$this->f_user = $this->get_user_name();
$this->f_user = $this->get_user_name();
$this->f_level = $this->get_level_name();
$this->f_type = $this->get_type_name();
$this->f_type = $this->get_type_name();
}
/**
@ -149,19 +151,19 @@ class Access
private static function _verify_range($startp, $endp)
{
$startn = @inet_pton($startp);
$endn = @inet_pton($endp);
$endn = @inet_pton($endp);
if (!$startn && $startp != '0.0.0.0' && $startp != '::') {
Error::add('start', T_('Invalid IPv4 / IPv6 Address Entered'));
AmpError::add('start', T_('Invalid IPv4 / IPv6 Address Entered'));
return false;
}
if (!$endn) {
Error::add('end', T_('Invalid IPv4 / IPv6 Address Entered'));
AmpError::add('end', T_('Invalid IPv4 / IPv6 Address Entered'));
}
if (strlen(bin2hex($startn)) != strlen(bin2hex($endn))) {
Error::add('start', T_('IP Address Version Mismatch'));
Error::add('end', T_('IP Address Version Mismatch'));
AmpError::add('start', T_('IP Address Version Mismatch'));
AmpError::add('end', T_('IP Address Version Mismatch'));
return false;
}
@ -182,12 +184,12 @@ class Access
return false;
}
$start = @inet_pton($data['start']);
$end = @inet_pton($data['end']);
$name = $data['name'];
$type = self::validate_type($data['type']);
$level = intval($data['level']);
$user = $data['user'] ?: '-1';
$start = @inet_pton($data['start']);
$end = @inet_pton($data['end']);
$name = $data['name'];
$type = self::validate_type($data['type']);
$level = intval($data['level']);
$user = $data['user'] ?: '-1';
$enabled = make_bool($data['enabled']) ? 1 : 0;
$sql = 'UPDATE `access_list` SET `start` = ?, `end` = ?, `level` = ?, ' .
@ -215,16 +217,16 @@ class Access
// Check existing ACLs to make sure we're not duplicating values here
if (self::exists($data)) {
debug_event('ACL Create', 'Error: An ACL equal to the created one already exists. Not adding another one: ' . $data['start'] . ' - ' . $data['end'], 1);
Error::add('general', T_('Duplicate ACL defined'));
AmpError::add('general', T_('Duplicate ACL defined'));
return false;
}
$start = @inet_pton($data['start']);
$end = @inet_pton($data['end']);
$name = $data['name'];
$user = $data['user'] ?: '-1';
$level = intval($data['level']);
$type = self::validate_type($data['type']);
$start = @inet_pton($data['start']);
$end = @inet_pton($data['end']);
$name = $data['name'];
$user = $data['user'] ?: '-1';
$level = intval($data['level']);
$type = self::validate_type($data['type']);
$enabled = make_bool($data['enabled']) ? 1 : 0;
$sql = 'INSERT INTO `access_list` (`name`, `level`, `start`, `end`, ' .
@ -232,7 +234,6 @@ class Access
Dba::write($sql, array($name, $level, $start, $end, $user, $type, $enabled));
return true;
}
/**
@ -246,9 +247,9 @@ class Access
public static function exists(array $data)
{
$start = inet_pton($data['start']);
$end = inet_pton($data['end']);
$type = self::validate_type($data['type']);
$user = $data['user'] ?: '-1';
$end = inet_pton($data['end']);
$type = self::validate_type($data['type']);
$user = $data['user'] ?: '-1';
$sql = 'SELECT * FROM `access_list` WHERE `start` = ? AND `end` = ? ' .
'AND `type` = ? AND `user` = ?';
@ -289,7 +290,7 @@ class Access
debug_event('access', 'ZLIB extension not loaded, batch download disabled', 3);
return false;
}
if (AmpConfig::get('allow_zip_download') AND $GLOBALS['user']->has_access('5')) {
if (AmpConfig::get('allow_zip_download') and $GLOBALS['user']->has_access('5')) {
return make_bool(AmpConfig::get('download'));
}
break;
@ -433,7 +434,7 @@ class Access
*/
public static function get_access_lists()
{
$sql = 'SELECT `id` FROM `access_list`';
$sql = 'SELECT `id` FROM `access_list`';
$db_results = Dba::read($sql);
$results = array();
@ -476,7 +477,9 @@ class Access
*/
public function get_user_name()
{
if ($this->user == '-1') { return T_('All'); }
if ($this->user == '-1') {
return T_('All');
}
$user = new User($this->user);
return $user->fullname . " (" . $user->username . ")";

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -40,7 +40,6 @@ class Ajax
public function __construct()
{
// Rien a faire
} // constructor
/**
@ -63,22 +62,21 @@ class Ajax
$source_txt = "'#$source'";
}
$observe = "<script type=\"text/javascript\">";
$observe = "<script type=\"text/javascript\">";
$methodact = (($method == 'click') ? "update_action();" : "");
if (AmpConfig::get('ajax_load') && $method == 'load') {
$source_txt = "$( document ).ready(";
} else {
$source_txt = "$(".$source_txt.").on('".$method."', ";
$source_txt = "$(" . $source_txt . ").on('" . $method . "', ";
}
if (!empty($confirm)) {
$observe .= $source_txt . "function(){ ".$methodact." if (confirm(\"".$confirm."\")) { ".$action." }});";
$observe .= $source_txt . "function(){ " . $methodact . " if (confirm(\"" . $confirm . "\")) { " . $action . " }});";
} else {
$observe .= $source_txt . "function(){ ".$methodact." ".$action.";});";
$observe .= $source_txt . "function(){ " . $methodact . " " . $action . ";});";
}
$observe .= "</script>";
return $observe;
} // observe
/**
@ -120,7 +118,6 @@ class Ajax
}
return $ajax_string;
} // action
/**
@ -143,7 +140,7 @@ class Ajax
// If they passed a span class
if ($class) {
$class = ' class="'.$class.'"';
$class = ' class="' . $class . '"';
}
$string = UI::get_icon($icon, $alt);
@ -151,12 +148,11 @@ class Ajax
// Generate an <a> so that it's more compliant with older
// browsers (ie :hover actions) and also to unify linkbuttons
// (w/o ajax) display
$string = "<a href=\"javascript:void(0);\" id=\"$source\" $class>".$string."</a>\n";
$string = "<a href=\"javascript:void(0);\" id=\"$source\" $class>" . $string . "</a>\n";
$string .= self::observe($source, 'click', $ajax_string, $confirm);
return $string;
} // button
/**
@ -193,7 +189,6 @@ class Ajax
}
return $string;
} // text
/**
@ -206,7 +201,6 @@ class Ajax
echo "<script type=\"text/javascript\"><!--\n";
echo "$action";
echo "\n--></script>";
} // run
/**
@ -218,7 +212,6 @@ class Ajax
public static function set_include_override($value)
{
self::$include_override = make_bool($value);
} // set_include_override
/**
@ -230,14 +223,15 @@ class Ajax
*/
public static function start_container($name, $class = '')
{
if (defined('AJAX_INCLUDE') && !self::$include_override) { return true; }
if (defined('AJAX_INCLUDE') && !self::$include_override) {
return true;
}
echo '<div id="' . scrub_out($name) . '"';
if (!empty($class)) {
echo ' class="' . scrub_out($class) . '"';
}
echo '>';
} // start_container
/**
@ -246,12 +240,13 @@ class Ajax
*/
public static function end_container()
{
if (defined('AJAX_INCLUDE') && !self::$include_override) { return true; }
if (defined('AJAX_INCLUDE') && !self::$include_override) {
return true;
}
echo "</div>";
self::$include_override = false;
} // end_container
} // end Ajax class

View file

@ -2,22 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -187,7 +186,9 @@ class Album extends database_object implements library_item
*/
public function __construct($id=null)
{
if (!$id) { return false; }
if (!$id) {
return false;
}
/* Get the information from the db */
$info = $this->get_info($id);
@ -206,7 +207,6 @@ class Album extends database_object implements library_item
}
return true;
} // constructor
/**
@ -226,7 +226,6 @@ class Album extends database_object implements library_item
$album->_fake = true; // Make sure that we tell em it's fake
return $album;
} // construct_from_array
/**
@ -249,13 +248,13 @@ class Album extends database_object implements library_item
public static function build_cache(array $ids)
{
// Nothing to do if they pass us nothing
if (!is_array($ids) OR !count($ids)) {
if (!is_array($ids) or !count($ids)) {
return false;
}
$idlist = '(' . implode(',', $ids) . ')';
$sql = "SELECT * FROM `album` WHERE `id` IN $idlist";
$sql = "SELECT * FROM `album` WHERE `id` IN $idlist";
$db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) {
@ -263,7 +262,6 @@ class Album extends database_object implements library_item
}
return true;
} // build_cache
/**
@ -282,19 +280,16 @@ class Album extends database_object implements library_item
return parent::get_from_cache('album_extra', $this->id);
}
// Calculation
$sql = "SELECT " .
"COUNT(DISTINCT(`song`.`artist`)) AS `artist_count`, " .
"COUNT(`song`.`id`) AS `song_count`, " .
"SUM(`song`.`time`) as `total_duration`," .
"`song`.`catalog` as `catalog_id`,".
"`artist`.`name` AS `artist_name`, " .
"`artist`.`prefix` AS `artist_prefix`, " .
"`artist`.`id` AS `artist_id` " .
"FROM `song` INNER JOIN `artist` " .
"ON `artist`.`id`=`song`.`artist` ";
"SUM(`song`.`time`) as `total_duration` " .
"FROM `song` ";
$sqlj = '';
if (AmpConfig::get('catalog_disable')) {
$sql .= "LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` ";
$sqlj = "LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` ";
}
$suite_array = array();
@ -306,24 +301,38 @@ class Album extends database_object implements library_item
}
$idlist = '(' . implode(',', $suite_array) . ')';
$sql .= "WHERE `song`.`album` IN $idlist ";
$sqlw = "WHERE `song`.`album` IN $idlist ";
if (AmpConfig::get('catalog_disable')) {
$sql .= "AND `catalog`.`enabled` = '1' ";
$sqlw .= "AND `catalog`.`enabled` = '1' ";
}
$sql .= $sqlj . $sqlw;
if (!count($this->album_suite)) {
$sql .= "GROUP BY `song`.`album`";
$sql .= "GROUP BY `song`.`album` ";
} else {
$sql .= "GROUP BY `song`.`artist`";
$sql .= "GROUP BY `song`.`artist` ";
}
$db_results = Dba::read($sql);
$results = Dba::fetch_assoc($db_results);
$results = Dba::fetch_assoc($db_results);
// Get associated information from first song only
$sql = "SELECT " .
"`song`.`catalog` as `catalog_id`," .
"`artist`.`name` AS `artist_name`, " .
"`artist`.`prefix` AS `artist_prefix`, " .
"`artist`.`id` AS `artist_id` " .
"FROM `song` INNER JOIN `artist` " .
"ON `artist`.`id`=`song`.`artist` ";
$sql .= $sqlj . $sqlw . "LIMIT 1";
$db_results = Dba::read($sql);
$results = array_merge($results, Dba::fetch_assoc($db_results));
$art = new Art($this->id, 'album');
$art->get_db();
$results['has_art'] = make_bool($art->raw);
$results['has_art'] = make_bool($art->raw);
$results['has_thumb'] = make_bool($art->thumb);
if (AmpConfig::get('show_played_times')) {
@ -333,7 +342,6 @@ class Album extends database_object implements library_item
parent::add_to_cache('album_extra', $this->id, $results);
return $results;
} // _get_extra_info
public function can_edit($user = null)
@ -342,20 +350,25 @@ class Album extends database_object implements library_item
$user = $GLOBALS['user']->id;
}
if (!$user)
if (!$user) {
return false;
}
if ($this->user !== null && $user == $this->user)
if ($this->user !== null && $user == $this->user) {
return true;
}
if (Access::check('interface', 50, $user))
if (Access::check('interface', 50, $user)) {
return true;
}
if (!$this->album_artist)
if (!$this->album_artist) {
return false;
}
if (!AmpConfig::get('upload_allow_edit'))
if (!AmpConfig::get('upload_allow_edit')) {
return false;
}
$owner = $this->get_user_owner();
return ($owner && $owner === $user);
@ -377,30 +390,30 @@ class Album extends database_object implements library_item
*/
public static function check($name, $year = 0, $disk = 0, $mbid = null, $mbid_group = null, $album_artist = null, $release_type = null, $readonly = false)
{
$trimmed = Catalog::trim_prefix(trim($name));
$name = $trimmed['string'];
$prefix = $trimmed['prefix'];
$trimmed = Catalog::trim_prefix(trim($name));
$name = $trimmed['string'];
$prefix = $trimmed['prefix'];
$album_artist = intval($album_artist);
$album_artist = ($album_artist <= 0) ? null : $album_artist;
$mbid = empty($mbid) ? null : $mbid;
$mbid_group = empty($mbid_group) ? null : $mbid_group;
$mbid = empty($mbid) ? null : $mbid;
$mbid_group = empty($mbid_group) ? null : $mbid_group;
$release_type = empty($release_type) ? null : $release_type;
// Not even sure if these can be negative, but better safe than llama.
$year = abs(intval($year));
$year = Catalog::normalize_year($year);
$disk = abs(intval($disk));
if (!$name) {
$name = T_('Unknown (Orphaned)');
$year = 0;
$disk = 0;
$name = T_('Unknown (Orphaned)');
$year = 0;
$disk = 0;
$album_artist = null;
}
if (isset(self::$_mapcache[$name][$disk][$mbid][$album_artist])) {
return self::$_mapcache[$name][$disk][$mbid][$album_artist];
}
$sql = 'SELECT `album`.`id` FROM `album` WHERE `album`.`name` = ? AND `album`.`disk` = ? ';
$sql = 'SELECT `album`.`id` FROM `album` WHERE `album`.`name` = ? AND `album`.`disk` = ? ';
$params = array($name, $disk);
if ($mbid) {
@ -410,8 +423,8 @@ class Album extends database_object implements library_item
$sql .= 'AND `album`.`mbid` IS NULL ';
}
if ($prefix) {
$sql .= 'AND `album`.`prefix` = ? ';
$params[] = $prefix;
$sql .= 'AND `album`.`prefix` = ? ';
$params[] = $prefix;
}
if ($album_artist) {
@ -422,7 +435,7 @@ class Album extends database_object implements library_item
$db_results = Dba::read($sql, $params);
if ($row = Dba::fetch_assoc($db_results)) {
$id = $row['id'];
$id = $row['id'];
self::$_mapcache[$name][$disk][$mbid][$album_artist] = $id;
return $id;
}
@ -490,7 +503,6 @@ class Album extends database_object implements library_item
}
return $results;
} // get_songs
/**
@ -536,7 +548,7 @@ class Album extends database_object implements library_item
$results = array();
$catalog_where = "";
$catalog_join = "LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog`";
$catalog_join = "LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog`";
if ($catalog) {
$catalog_where .= " AND `catalog`.`id` = '$catalog'";
}
@ -544,7 +556,7 @@ class Album extends database_object implements library_item
$catalog_where .= " AND `catalog`.`enabled` = '1'";
}
$sql = "SELECT DISTINCT `album`.`id` FROM album LEFT JOIN `song` ON `song`.`album`=`album`.`id` $catalog_join " .
$sql = "SELECT DISTINCT `album`.`id`, `album`.`disk` FROM album LEFT JOIN `song` ON `song`.`album`=`album`.`id` $catalog_join " .
"WHERE `album`.`mbid`='$this->mbid' $catalog_where ORDER BY `album`.`disk` ASC";
$db_results = Dba::read($sql);
@ -554,7 +566,6 @@ class Album extends database_object implements library_item
}
return $results;
} // get_album_suite
/**
@ -565,13 +576,12 @@ class Album extends database_object implements library_item
*/
public function has_track($title)
{
$sql = "SELECT `id` FROM `song` WHERE `album` = ? AND `title` = ?";
$sql = "SELECT `id` FROM `song` WHERE `album` = ? AND `title` = ?";
$db_results = Dba::read($sql, array($this->id, $title));
$data = Dba::fetch_assoc($db_results);
return $data;
} // has_track
/**
@ -583,7 +593,7 @@ class Album extends database_object implements library_item
{
$time = 0;
$sql = "SELECT MIN(`addition_time`) FROM `song` WHERE `album` = ?";
$sql = "SELECT MIN(`addition_time`) FROM `song` WHERE `album` = ?";
$db_results = Dba::read($sql, array($this->id));
if ($data = Dba::fetch_row($db_results)) {
$time = $data[0];
@ -605,24 +615,26 @@ class Album extends database_object implements library_item
if ($details) {
/* Pull the advanced information */
$data = $this->_get_extra_info($limit_threshold);
foreach ($data as $key=>$value) { $this->$key = $value; }
foreach ($data as $key=>$value) {
$this->$key = $value;
}
if ($this->album_artist) {
$Album_artist = new Artist($this->album_artist);
$Album_artist->format();
$this->album_artist_name = $Album_artist->name;
$this->album_artist_name = $Album_artist->name;
$this->f_album_artist_name = $Album_artist->f_name;
$this->f_album_artist_link = "<a href=\"" . $web_path . "/artists.php?action=show&artist=" . $this->album_artist . "\" title=\"" . scrub_out($this->album_artist_name) . "\">" . $this->f_album_artist_name . "</a>";
}
$this->tags = Tag::get_top_tags('album', $this->id);
$this->tags = Tag::get_top_tags('album', $this->id);
$this->f_tags = Tag::get_display($this->tags, true, 'album');
}
/* Truncate the string if it's to long */
$this->f_name = $this->full_name;
$this->link = $web_path . '/albums.php?action=show&album=' . scrub_out($this->id);
$this->link = $web_path . '/albums.php?action=show&album=' . scrub_out($this->id);
$this->f_link = "<a href=\"" . $this->link . "\" title=\"" . scrub_out($this->full_name) . "\">" . scrub_out($this->f_name);
// Looking if we need to combine or display disks
@ -634,13 +646,13 @@ class Album extends database_object implements library_item
$this->f_title = $this->full_name;
if ($this->artist_count == '1') {
$artist = trim(trim($this->artist_prefix) . ' ' . trim($this->artist_name));
$artist = trim(trim($this->artist_prefix) . ' ' . trim($this->artist_name));
$this->f_artist_name = $artist;
$this->f_artist_link = "<a href=\"$web_path/artists.php?action=show&artist=" . $this->artist_id . "\" title=\"" . scrub_out($this->artist_name) . "\">" . $artist . "</a>";
$this->f_artist = $artist;
$this->f_artist = $artist;
} else {
$this->f_artist_link = "<span title=\"$this->artist_count " . T_('Artists') . "\">" . T_('Various') . "</span>";
$this->f_artist = T_('Various');
$this->f_artist = T_('Various');
$this->f_artist_name = $this->f_artist;
}
@ -649,7 +661,6 @@ class Album extends database_object implements library_item
}
$this->f_release_type = ucwords($this->release_type);
} // format
/**
@ -658,7 +669,7 @@ class Album extends database_object implements library_item
*/
public function get_keywords()
{
$keywords = array();
$keywords = array();
$keywords['mb_albumid'] = array('important' => false,
'label' => T_('Album MusicBrainzID'),
'value' => $this->mbid);
@ -713,17 +724,17 @@ class Album extends database_object implements library_item
*/
public function search_childrens($name)
{
$search['type'] = "song";
$search['rule_0_input'] = $name;
$search['type'] = "song";
$search['rule_0_input'] = $name;
$search['rule_0_operator'] = 4;
$search['rule_0'] = "title";
$search['rule_1_input'] = $this->name;
$search['rule_0'] = "title";
$search['rule_1_input'] = $this->name;
$search['rule_1_operator'] = 4;
$search['rule_1'] = "album";
$search['rule_2_input'] = $this->album_artist_name;
$search['rule_1'] = "album";
$search['rule_2_input'] = $this->album_artist_name;
$search['rule_2_operator'] = 4;
$search['rule_2'] = "artist";
$songs = Search::run($search);
$search['rule_2'] = "artist";
$songs = Search::run($search);
$childrens = array();
foreach ($songs as $song) {
@ -773,8 +784,9 @@ class Album extends database_object implements library_item
*/
public function get_user_owner()
{
if (!$this->album_artist)
if (!$this->album_artist) {
return null;
}
$artist = new Artist($this->album_artist);
return $artist->get_user_owner();
@ -798,15 +810,17 @@ class Album extends database_object implements library_item
public function display_art($thumb = 2)
{
$id = null;
$id = null;
$type = null;
if (Art::has_db($this->id, 'album')) {
$id = $this->id;
$id = $this->id;
$type = 'album';
} else if (Art::has_db($this->artist_id, 'artist')) {
$id = $this->artist_id;
$type = 'artist';
} else {
if (Art::has_db($this->artist_id, 'artist')) {
$id = $this->artist_id;
$type = 'artist';
}
}
if ($id !== null && $type !== null) {
@ -838,7 +852,6 @@ class Album extends database_object implements library_item
}
return $results;
} // get_random_songs
/**
@ -850,25 +863,20 @@ class Album extends database_object implements library_item
*/
public function update(array $data)
{
$year = isset($data['year']) ? $data['year'] : $this->year;
$artist = isset($data['artist']) ? intval($data['artist']) : $this->artist_id;
$year = isset($data['year']) ? $data['year'] : $this->year;
$artist = isset($data['artist']) ? intval($data['artist']) : $this->artist_id;
$album_artist = isset($data['album_artist']) ? intval($data['album_artist']) : $this->album_artist;
$name = isset($data['name']) ? $data['name'] : $this->name;
$disk = isset($data['disk']) ? $data['disk']: $this->disk;
$mbid = isset($data['mbid']) ? $data['mbid'] : $this->mbid;
$mbid_group = isset($data['mbid_group']) ? $data['mbid_group'] : $this->mbid_group;
$name = isset($data['name']) ? $data['name'] : $this->name;
$disk = isset($data['disk']) ? $data['disk']: $this->disk;
$mbid = isset($data['mbid']) ? $data['mbid'] : $this->mbid;
$mbid_group = isset($data['mbid_group']) ? $data['mbid_group'] : $this->mbid_group;
$release_type = isset($data['release_type']) ? $data['release_type'] : $this->release_type;
$current_id = $this->id;
if (!empty($data['album_artist_name'])) {
// Need to create new artist according the name
$album_artist = Artist::check($data['album_artist_name']);
}
$updated = false;
$songs = null;
if ($artist != $this->artist_id AND $artist) {
$songs = null;
if ($artist != $this->artist_id && $artist) {
// Update every song
$songs = $this->get_songs();
foreach ($songs as $song_id) {
@ -878,16 +886,23 @@ class Album extends database_object implements library_item
Artist::gc();
}
if (!empty($data['album_artist_name'])) {
// Need to create new artist according the name
$album_artist = Artist::check($data['album_artist_name']);
}
$album_id = self::check($name, $year, $disk, $mbid, $mbid_group, $album_artist, $release_type);
if ($album_id != $this->id) {
if (!is_array($songs)) { $songs = $this->get_songs(); }
if (!is_array($songs)) {
$songs = $this->get_songs();
}
foreach ($songs as $song_id) {
Song::update_album($album_id,$song_id);
Song::update_year($year,$song_id);
Song::write_id3_for_song($song_id);
}
$current_id = $album_id;
$updated = true;
$updated = true;
Stats::migrate('album', $this->id, $album_id);
Art::migrate('album', $this->id, $album_id);
self::gc();
@ -896,12 +911,12 @@ class Album extends database_object implements library_item
Album::update_mbid_group($mbid_group, $album_id);
Album::update_release_type($release_type, $album_id);
}
$this->year = $year;
$this->mbid_group = $mbid_group;
$this->year = $year;
$this->mbid_group = $mbid_group;
$this->release_type = $release_type;
$this->name = $name;
$this->disk = $disk;
$this->mbid = $mbid;
$this->name = $name;
$this->disk = $disk;
$this->mbid = $mbid;
$this->album_artist = $album_artist;
if ($updated && is_array($songs)) {
@ -911,6 +926,7 @@ class Album extends database_object implements library_item
Stats::gc();
Rating::gc();
Userflag::gc();
Useractivity::gc();
} // if updated
$override_childs = false;
@ -928,7 +944,6 @@ class Album extends database_object implements library_item
}
return $current_id;
} // update
/**
@ -959,25 +974,26 @@ class Album extends database_object implements library_item
public function remove_from_disk()
{
$deleted = true;
$deleted = true;
$song_ids = $this->get_songs();
foreach ($song_ids as $id) {
$song = new Song($id);
$song = new Song($id);
$deleted = $song->remove_from_disk();
if (!$deleted) {
debug_event('album', 'Error when deleting the song `' . $id .'`.', 1);
debug_event('album', 'Error when deleting the song `' . $id . '`.', 1);
break;
}
}
if ($deleted) {
$sql = "DELETE FROM `album` WHERE `id` = ?";
$sql = "DELETE FROM `album` WHERE `id` = ?";
$deleted = Dba::write($sql, array($this->id));
if ($deleted) {
Art::gc('album', $this->id);
Userflag::gc('album', $this->id);
Rating::gc('album', $this->id);
Shoutbox::gc('album', $this->id);
Useractivity::gc('album', $this->id);
}
}
@ -1067,5 +1083,5 @@ class Album extends database_object implements library_item
return $results;
}
} //end of album class

View file

@ -2,22 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; version 2
* of the License.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -40,7 +39,6 @@ class Ampache_RSS
public function __construct($type)
{
$this->type = self::validate_type($type);
} // constructor
/**
@ -54,7 +52,7 @@ class Ampache_RSS
if ($this->type === "podcast") {
if ($params != null && is_array($params)) {
$object_type = $params['object_type'];
$object_id = $params['object_id'];
$object_id = $params['object_id'];
if (Core::is_library_item($object_type)) {
$libitem = new $object_type($object_id);
if ($libitem->id) {
@ -65,10 +63,10 @@ class Ampache_RSS
}
} else {
// Function call name
$data_function = 'load_' . $this->type;
$data_function = 'load_' . $this->type;
$pub_date_function = 'pubdate_' . $this->type;
$data = call_user_func(array('Ampache_RSS',$data_function));
$data = call_user_func(array('Ampache_RSS',$data_function));
$pub_date = null;
if (method_exists('Ampache_RSS', $data_function)) {
$pub_date = call_user_func(array('Ampache_RSS',$pub_date_function));
@ -81,7 +79,6 @@ class Ampache_RSS
}
return null;
} // get_xml
/**
@ -99,7 +96,6 @@ class Ampache_RSS
);
return scrub_out(AmpConfig::get('site_title')) . ' - ' . $titles[$this->type];
} // get_title
/**
@ -111,7 +107,6 @@ class Ampache_RSS
{
//FIXME: For now don't do any kind of translating
return 'Ampache RSS Feeds';
} // get_description
/**
@ -129,7 +124,6 @@ class Ampache_RSS
}
return $type;
} // validate_type
/**
@ -159,7 +153,6 @@ class Ampache_RSS
$string .= '</a>';
return $string;
} // get_display
// type specific functions below, these are called semi-dynamically based on the current type //
@ -174,22 +167,22 @@ class Ampache_RSS
{
$data = Stream::get_now_playing();
$results = array();
$format = AmpConfig::get('rss_format') ?: '%t - %a - %A';
$results = array();
$format = AmpConfig::get('rss_format') ?: '%t - %a - %A';
$string_map = array(
'%t' => 'title',
'%a' => 'artist',
'%A' => 'album'
);
foreach ($data as $element) {
$song = $element['media'];
$client = $element['user'];
$title = $format;
$song = $element['media'];
$client = $element['user'];
$title = $format;
$description = $format;
foreach ($string_map as $search => $replace) {
$trep = 'f_' . $replace;
$drep = 'f_' . $replace . '_full';
$title = str_replace($search, $song->$trep, $title);
$trep = 'f_' . $replace;
$drep = 'f_' . $replace . '_full';
$title = str_replace($search, $song->$trep, $title);
$description = str_replace($search, $song->$drep, $description);
}
$xml_array = array(
@ -203,7 +196,6 @@ class Ampache_RSS
} // end foreach
return $results;
} // load_now_playing
/**
@ -220,7 +212,6 @@ class Ampache_RSS
$element = array_shift($data);
return $element['expire'];
} // pubdate_now_playing
/**
@ -233,54 +224,54 @@ class Ampache_RSS
//FIXME: The time stuff should be centralized, it's currently in two places, lame
$time_unit = array('', T_('seconds ago'), T_('minutes ago'), T_('hours ago'), T_('days ago'), T_('weeks ago'), T_('months ago'), T_('years ago'));
$data = Song::get_recently_played();
$data = Song::get_recently_played();
$results = array();
foreach ($data as $item) {
$client = new User($item['user']);
$song = new Song($item['object_id']);
$song->format();
$amount = intval(time() - $item['date']+2);
$final = '0';
$time_place = '0';
while ($amount >= 1) {
$final = $amount;
$time_place++;
if ($time_place <= 2) {
$amount = floor($amount/60);
}
if ($time_place == '3') {
$amount = floor($amount/24);
}
if ($time_place == '4') {
$amount = floor($amount/7);
}
if ($time_place == '5') {
$amount = floor($amount/4);
}
if ($time_place == '6') {
$amount = floor ($amount/12);
}
if ($time_place > '6') {
$final = $amount . '+';
break;
}
} // end while
$song = new Song($item['object_id']);
if ($song->enabled) {
$song->format();
$amount = intval(time() - $item['date']+2);
$final = '0';
$time_place = '0';
while ($amount >= 1) {
$final = $amount;
$time_place++;
if ($time_place <= 2) {
$amount = floor($amount/60);
}
if ($time_place == '3') {
$amount = floor($amount/24);
}
if ($time_place == '4') {
$amount = floor($amount/7);
}
if ($time_place == '5') {
$amount = floor($amount/4);
}
if ($time_place == '6') {
$amount = floor ($amount/12);
}
if ($time_place > '6') {
$final = $amount . '+';
break;
}
} // end while
$time_string = $final . ' ' . $time_unit[$time_place];
$xml_array = array('title'=>$song->f_title . ' - ' . $song->f_artist . ' - ' . $song->f_album,
'link'=>str_replace('&amp;', '&', $song->link),
'description'=>$song->title . ' - ' . $song->f_artist_full . ' - ' . $song->f_album_full . ' - ' . $time_string,
'comments'=>$client->username,
'pubDate'=>date("r",$item['date']));
$results[] = $xml_array;
$time_string = $final . ' ' . $time_unit[$time_place];
$xml_array = array('title'=>$song->f_title . ' - ' . $song->f_artist . ' - ' . $song->f_album,
'link'=>str_replace('&amp;', '&', $song->link),
'description'=>$song->title . ' - ' . $song->f_artist_full . ' - ' . $song->f_album_full . ' - ' . $time_string,
'comments'=>$client->username,
'pubDate'=>date("r",$item['date']));
$results[] = $xml_array;
}
} // end foreach
return $results;
} // load_recently_played
/**
@ -306,11 +297,9 @@ class Ampache_RSS
'pubDate' => date("c", $album->get_addtime_first_song())
);
$results[] = $xml_array;
} // end foreach
return $results;
} // load_latest_album
/**
@ -336,11 +325,9 @@ class Ampache_RSS
'pubDate' => ''
);
$results[] = $xml_array;
} // end foreach
return $results;
} // load_latest_artist
/**
@ -358,23 +345,23 @@ class Ampache_RSS
$shout = new Shoutbox($id);
$shout->format();
$object = Shoutbox::get_object($shout->object_type, $shout->object_id);
$object->format();
$user = new User($shout->user);
$user->format();
$xml_array = array('title' => $user->username . ' ' . T_('on') . ' ' . $object->get_fullname(),
'link' => $object->link,
'description' => $shout->text,
'image' => Art::url($shout->object_id, $shout->object_type, null, 2),
'comments' => '',
'pubDate' => date("c", $shout->date)
);
$results[] = $xml_array;
if ($object !== null) {
$object->format();
$user = new User($shout->user);
$user->format();
$xml_array = array('title' => $user->username . ' ' . T_('on') . ' ' . $object->get_fullname(),
'link' => $object->link,
'description' => $shout->text,
'image' => Art::url($shout->object_id, $shout->object_type, null, 2),
'comments' => '',
'pubDate' => date("c", $shout->date)
);
$results[] = $xml_array;
}
} // end foreach
return $results;
} // load_latest_shout
/**
@ -389,7 +376,6 @@ class Ampache_RSS
$element = array_shift($data);
return $element['date'];
} // pubdate_recently_played
} // end Ampache_RSS class

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -82,7 +82,7 @@ class AmpConfig
{
if (isset(self::$_global[$name]) && !$clobber) {
debug_event('Config', "Tried to overwrite existing key $name without setting clobber", 5);
Error::add('Config Global', sprintf(T_('Trying to clobber \'%s\' without setting clobber'), $name));
AmpError::add('Config Global', sprintf(T_('Trying to clobber \'%s\' without setting clobber'), $name));
return false;
}

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANT ABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -27,9 +27,9 @@
* hello static functions and variables
*
*/
class Error
class AmpError
{
private static $state = false; // set to one when an error occurs
private static $state = false; // set to one when an error occurs
private static $errors = array(); // Errors array key'd array with errors that have occured
/**
@ -39,7 +39,6 @@ class Error
private function __construct()
{
// Rien a faire
} // __construct
/**
@ -51,7 +50,6 @@ class Error
foreach (self::$errors as $key=>$error) {
$_SESSION['errors'][$key] = $error;
}
} // __destruct
/**
@ -62,21 +60,21 @@ class Error
public static function add($name,$message,$clobber=0)
{
// Make sure its set first
if (!isset(Error::$errors[$name])) {
Error::$errors[$name] = $message;
Error::$state = true;
$_SESSION['errors'][$name] = $message;
if (!isset(AmpError::$errors[$name])) {
AmpError::$errors[$name] = $message;
AmpError::$state = true;
$_SESSION['errors'][$name] = $message;
}
// They want us to clobber it
elseif ($clobber) {
Error::$state = true;
Error::$errors[$name] = $message;
$_SESSION['errors'][$name] = $message;
AmpError::$state = true;
AmpError::$errors[$name] = $message;
$_SESSION['errors'][$name] = $message;
}
// They want us to append the error, add a BR\n and then the message
else {
Error::$state = true;
Error::$errors[$name] .= "<br />\n" . $message;
AmpError::$state = true;
AmpError::$errors[$name] .= "<br />\n" . $message;
$_SESSION['errors'][$name] .= "<br />\n" . $message;
}
@ -86,7 +84,6 @@ class Error
ob_flush();
flush();
}
} // add
/**
@ -95,10 +92,11 @@ class Error
*/
public static function occurred()
{
if (self::$state == '1') { return true; }
if (self::$state == '1') {
return true;
}
return false;
} // occurred
/**
@ -107,10 +105,11 @@ class Error
*/
public static function get($name)
{
if (!isset(Error::$errors[$name])) { return ''; }
return Error::$errors[$name];
if (!isset(AmpError::$errors[$name])) {
return '';
}
return AmpError::$errors[$name];
} // get
/**
@ -121,10 +120,11 @@ class Error
public static function display($name)
{
// Be smart about this, if no error don't print
if (!isset(Error::$errors[$name])) { return ''; }
echo '<p class="alert alert-danger">' . T_(Error::$errors[$name]) . '</p>';
if (!isset(AmpError::$errors[$name])) {
return '';
}
echo '<p class="alert alert-danger">' . T_(AmpError::$errors[$name]) . '</p>';
} // display
/**
@ -133,13 +133,14 @@ class Error
*/
public static function auto_init()
{
if (!is_array($_SESSION['errors'])) { return false; }
if (!is_array($_SESSION['errors'])) {
return false;
}
// Re-insert them
foreach ($_SESSION['errors'] as $key=>$error) {
self::add($key,$error);
}
} // auto_init
} // Error

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -51,7 +51,6 @@ class Api
private function __construct()
{
// Rien a faire
} // constructor
/**
@ -77,7 +76,9 @@ class Api
*/
public static function set_filter($filter,$value)
{
if (!strlen($value)) { return false; }
if (!strlen($value)) {
return false;
}
switch ($filter) {
case 'add':
@ -112,7 +113,6 @@ class Api
} // end filter
return true;
} // set_filter
/**
@ -125,14 +125,14 @@ class Api
*/
public static function handshake($input)
{
$timestamp = preg_replace('/[^0-9]/', '', $input['timestamp']);
$timestamp = preg_replace('/[^0-9]/', '', $input['timestamp']);
$passphrase = $input['auth'];
if (empty($passphrase)) {
$passphrase = $_POST['auth'];
}
$username = trim($input['user']);
$ip = $_SERVER['REMOTE_ADDR'];
$version = $input['version'];
$ip = $_SERVER['REMOTE_ADDR'];
$version = $input['version'];
// Log the attempt
debug_event('API', "Handshake Attempt, IP:$ip User:$username Version:$version", 5);
@ -140,7 +140,7 @@ class Api
// Version check shouldn't be soo restrictive... only check with initial version to not break clients compatibility
if (intval($version) < self::$auth_version) {
debug_event('API', 'Login Failed: version too old', 1);
Error::add('api', T_('Login Failed: version too old'));
AmpError::add('api', T_('Login Failed: version too old'));
return false;
}
@ -152,7 +152,7 @@ class Api
$user_id = $client->id;
}
} else {
$client = User::get_from_username($username);
$client = User::get_from_username($username);
$user_id = $client->id;
}
@ -168,7 +168,7 @@ class Api
if (($timestamp < (time() - 1800)) ||
($timestamp > (time() + 1800))) {
debug_event('API', 'Login Failed: timestamp out of range ' . $timestamp . '/' . time(), 1);
Error::add('api', T_('Login Failed: timestamp out of range'));
AmpError::add('api', T_('Login Failed: timestamp out of range'));
echo XML_Data::error('401', T_('Error Invalid Handshake - ') . T_('Login Failed: timestamp out of range'));
return false;
}
@ -180,7 +180,7 @@ class Api
if (!$realpwd) {
debug_event('API', 'Unable to find user with userid of ' . $user_id, 1);
Error::add('api', T_('Invalid Username/Password'));
AmpError::add('api', T_('Invalid Username/Password'));
echo XML_Data::error('401', T_('Error Invalid Handshake - ') . T_('Invalid Username/Password'));
return false;
}
@ -196,10 +196,10 @@ class Api
if ($client) {
// Create the session
$data = array();
$data = array();
$data['username'] = $client->username;
$data['type'] = 'api';
$data['value'] = $timestamp;
$data['type'] = 'api';
$data['value'] = $timestamp;
if (isset($input['client'])) {
$data['agent'] = $input['client'];
}
@ -218,30 +218,30 @@ class Api
// We need to also get the 'last update' of the
// catalog information in an RFC 2822 Format
$sql = 'SELECT MAX(`last_update`) AS `update`, MAX(`last_add`) AS `add`, MAX(`last_clean`) AS `clean` FROM `catalog`';
$sql = 'SELECT MAX(`last_update`) AS `update`, MAX(`last_add`) AS `add`, MAX(`last_clean`) AS `clean` FROM `catalog`';
$db_results = Dba::read($sql);
$row = Dba::fetch_assoc($db_results);
$row = Dba::fetch_assoc($db_results);
// Now we need to quickly get the song totals
$sql = 'SELECT COUNT(`id`) AS `song`, ' .
'COUNT(DISTINCT(`album`)) AS `album`, '.
'COUNT(DISTINCT(`album`)) AS `album`, ' .
'COUNT(DISTINCT(`artist`)) AS `artist` ' .
'FROM `song`';
$db_results = Dba::read($sql);
$counts = Dba::fetch_assoc($db_results);
$counts = Dba::fetch_assoc($db_results);
// Next the video counts
$sql = "SELECT COUNT(`id`) AS `video` FROM `video`";
$sql = "SELECT COUNT(`id`) AS `video` FROM `video`";
$db_results = Dba::read($sql);
$vcounts = Dba::fetch_assoc($db_results);
$vcounts = Dba::fetch_assoc($db_results);
$sql = "SELECT COUNT(`id`) AS `playlist` FROM `playlist`";
$sql = "SELECT COUNT(`id`) AS `playlist` FROM `playlist`";
$db_results = Dba::read($sql);
$playlist = Dba::fetch_assoc($db_results);
$playlist = Dba::fetch_assoc($db_results);
$sql = "SELECT COUNT(`id`) AS `catalog` FROM `catalog` WHERE `catalog_type`='local'";
$sql = "SELECT COUNT(`id`) AS `catalog` FROM `catalog` WHERE `catalog_type`='local'";
$db_results = Dba::read($sql);
$catalog = Dba::fetch_assoc($db_results);
$catalog = Dba::fetch_assoc($db_results);
echo XML_Data::keyed_array(array('auth'=>$token,
'api'=>self::$version,
@ -257,7 +257,6 @@ class Api
'catalogs'=>$catalog['catalog']));
return true;
} // match
} // end while
debug_event('API','Login Failed, unable to match passphrase','1');
@ -286,7 +285,6 @@ class Api
ob_end_clean();
echo XML_Data::keyed_array($xmldata);
} // ping
/**
@ -315,7 +313,6 @@ class Api
// echo out the resulting xml document
ob_end_clean();
echo XML_Data::artists($artists);
} // artists
/**
@ -328,7 +325,6 @@ class Api
{
$uid = scrub_in($input['filter']);
echo XML_Data::artists(array($uid));
} // artist
/**
@ -347,7 +343,6 @@ class Api
XML_Data::set_limit($input['limit']);
ob_end_clean();
echo XML_Data::albums($albums);
} // artist_albums
/**
@ -358,14 +353,13 @@ class Api
public static function artist_songs($input)
{
$artist = new Artist($input['filter']);
$songs = $artist->get_songs();
$songs = $artist->get_songs();
// Set the offset
XML_Data::set_offset($input['offset']);
XML_Data::set_limit($input['limit']);
ob_end_clean();
echo XML_Data::songs($songs);
} // artist_songs
/**
@ -390,7 +384,6 @@ class Api
XML_Data::set_limit($input['limit']);
ob_end_clean();
echo XML_Data::albums($albums);
} // albums
/**
@ -402,7 +395,6 @@ class Api
{
$uid = scrub_in($input['filter']);
echo XML_Data::albums(array($uid));
} // album
/**
@ -421,7 +413,6 @@ class Api
ob_end_clean();
echo XML_Data::songs($songs);
} // album_songs
/**
@ -445,7 +436,6 @@ class Api
ob_end_clean();
echo XML_Data::tags($tags);
} // tags
/**
@ -458,7 +448,6 @@ class Api
$uid = scrub_in($input['filter']);
ob_end_clean();
echo XML_Data::tags(array($uid));
} // tag
/**
@ -476,7 +465,6 @@ class Api
ob_end_clean();
echo XML_Data::artists($artists);
}
} // tag_artists
/**
@ -494,7 +482,6 @@ class Api
ob_end_clean();
echo XML_Data::albums($albums);
}
} // tag_albums
/**
@ -511,7 +498,6 @@ class Api
ob_end_clean();
echo XML_Data::songs($songs);
} // tag_songs
/**
@ -538,7 +524,6 @@ class Api
ob_end_clean();
echo XML_Data::songs($songs);
} // songs
/**
@ -552,7 +537,6 @@ class Api
ob_end_clean();
echo XML_Data::songs(array($uid));
} // song
/**
@ -590,7 +574,6 @@ class Api
ob_end_clean();
echo XML_Data::playlists($playlist_ids);
} // playlists
/**
@ -604,7 +587,6 @@ class Api
ob_end_clean();
echo XML_Data::playlists(array($uid));
} // playlist
/**
@ -615,7 +597,7 @@ class Api
public static function playlist_songs($input)
{
$playlist = new Playlist($input['filter']);
$items = $playlist->get_items();
$items = $playlist->get_items();
$songs = array();
foreach ($items as $object) {
@ -628,7 +610,6 @@ class Api
XML_Data::set_limit($input['limit']);
ob_end_clean();
echo XML_Data::songs($songs,$items);
} // playlist_songs
/**
@ -674,14 +655,13 @@ class Api
{
ob_end_clean();
$playlist = new Playlist($input['filter']);
$song = $input['song'];
$song = $input['song'];
if (!$playlist->has_access()) {
echo XML_Data::error('401', T_('Access denied to this playlist.'));
} else {
$playlist->add_songs(array($song));
echo XML_Data::single_string('success');
}
} // playlist_add_song
/**
@ -693,14 +673,13 @@ class Api
{
ob_end_clean();
$playlist = new Playlist($input['filter']);
$track = scrub_in($input['track']);
$track = scrub_in($input['track']);
if (!$playlist->has_access()) {
echo XML_Data::error('401', T_('Access denied to this playlist.'));
} else {
$playlist->delete_track_number($track);
echo XML_Data::single_string('success');
}
} // playlist_remove_song
/**
@ -710,10 +689,10 @@ class Api
*/
public static function search_songs($input)
{
$array = array();
$array['type'] = 'song';
$array['rule_1'] = 'anywhere';
$array['rule_1_input'] = $input['filter'];
$array = array();
$array['type'] = 'song';
$array['rule_1'] = 'anywhere';
$array['rule_1_input'] = $input['filter'];
$array['rule_1_operator'] = 0;
ob_end_clean();
@ -724,9 +703,40 @@ class Api
$results = Search::run($array);
echo XML_Data::songs($results);
} // search_songs
/**
* advanced_search
* Perform an advanced search given passed rules
* @param array $input
*/
public static function advanced_search($input)
{
ob_end_clean();
XML_Data::set_offset($input['offset']);
XML_Data::set_limit($input['limit']);
$results = Search::run($input);
$type = 'song';
if (isset($input['type'])) {
$type = $input['type'];
}
switch ($type) {
case 'artist':
echo XML_Data::artists($results);
break;
case 'album':
echo XML_Data::albums($results);
break;
default:
echo XML_Data::songs($results);
break;
}
} // advanced_search
/**
* videos
* This returns video objects!
@ -747,7 +757,6 @@ class Api
XML_Data::set_limit($input['limit']);
echo XML_Data::videos($video_ids);
} // videos
/**
@ -760,8 +769,6 @@ class Api
$video_id = scrub_in($input['filter']);
echo XML_Data::videos(array($video_id));
} // video
/**
@ -781,7 +788,7 @@ class Api
case 'play':
case 'stop':
$result_status = $localplay->$input['command']();
$xml_array = array('localplay'=>array('command'=>array($input['command']=>make_bool($result_status))));
$xml_array = array('localplay'=>array('command'=>array($input['command']=>make_bool($result_status))));
echo XML_Data::keyed_array($xml_array);
break;
default:
@ -789,7 +796,6 @@ class Api
echo XML_Data::error('405', T_('Invalid Request'));
break;
} // end switch on command
} // localplay
/**
@ -805,7 +811,7 @@ class Api
switch ($input['method']) {
case 'vote':
$type = 'song';
$type = 'song';
$media = new $type($input['oid']);
if (!$media->id) {
echo XML_Data::error('400', T_('Media Object Invalid or Not Specified'));
@ -823,7 +829,7 @@ class Api
echo XML_Data::keyed_array($xml_array);
break;
case 'devote':
$type = 'song';
$type = 'song';
$media = new $type($input['oid']);
if (!$media->id) {
echo XML_Data::error('400', T_('Media Object Invalid or Not Specified'));
@ -843,7 +849,7 @@ class Api
echo XML_Data::democratic($objects);
break;
case 'play':
$url = $democratic->play_url();
$url = $democratic->play_url();
$xml_array = array('url'=>$url);
echo XML_Data::keyed_array($xml_array);
break;
@ -851,7 +857,6 @@ class Api
echo XML_Data::error('405', T_('Invalid Request'));
break;
} // switch on method
} // democratic
/**
@ -860,36 +865,44 @@ class Api
*/
public static function stats($input)
{
$type = $input['type'];
$offset = $input['offset'];
$limit = $input['limit'];
$type = $input['type'];
$offset = $input['offset'];
$limit = $input['limit'];
$username = $input['username'];
$albums = null;
if ($type == "newest") {
$albums = Stats::get_newest("album", $limit, $offset);
} else if ($type == "highest") {
$albums = Rating::get_highest("album", $limit, $offset);
} else if ($type == "frequent") {
$albums = Stats::get_top("album", $limit, '', $offset);
} else if ($type == "recent") {
if (!empty($username)) {
$user = User::get_from_username($username);
if ($user !== null) {
$albums = $user->get_recently_played($limit, 'album');
} else {
debug_event('api', 'User `' . $username . '` cannot be found.', 1);
}
} else {
$albums = Stats::get_recent("album", $limit, $offset);
}
} else if ($type == "flagged") {
$albums = Userflag::get_latest('album');
} else {
if (!$limit) {
$limit = AmpConfig::get('popular_threshold');
if ($type == "highest") {
$albums = Rating::get_highest("album", $limit, $offset);
} else {
if ($type == "frequent") {
$albums = Stats::get_top("album", $limit, '', $offset);
} else {
if ($type == "recent") {
if (!empty($username)) {
$user = User::get_from_username($username);
if ($user !== null) {
$albums = $user->get_recently_played($limit, 'album');
} else {
debug_event('api', 'User `' . $username . '` cannot be found.', 1);
}
} else {
$albums = Stats::get_recent("album", $limit, $offset);
}
} else {
if ($type == "flagged") {
$albums = Userflag::get_latest('album');
} else {
if (!$limit) {
$limit = AmpConfig::get('popular_threshold');
}
$albums = Album::get_random($limit);
}
}
}
}
$albums = Album::get_random($limit);
}
if ($albums !== null) {
@ -971,6 +984,30 @@ class Api
}
} // following
/**
* toggle_follow
* This follow/unfollow an user
* @param array $input
*/
public static function toggle_follow($input)
{
if (AmpConfig::get('sociable')) {
$username = $input['username'];
if (!empty($username)) {
$user = User::get_from_username($username);
if ($user !== null) {
$GLOBALS['user']->toggle_follow($user->id);
ob_end_clean();
echo XML_Data::single_string('success');
}
} else {
debug_event('api', 'Username to toggle required on follow function call.', 1);
}
} else {
debug_event('api', 'Sociable feature is not enabled.', 3);
}
} // toggle_follow
/**
* last_shouts
* This get the latest posted shouts
@ -997,4 +1034,80 @@ class Api
}
} // last_shouts
/**
* rate
* This rate a library item
* @param array $input
*/
public static function rate($input)
{
ob_end_clean();
$type = $input['type'];
$id = $input['id'];
$rating = $input['rating'];
if (!Core::is_library_item($type) || !$id) {
echo XML_Data::error('401', T_('Wrong library item type.'));
} else {
$item = new $type($id);
if (!$item->id) {
echo XML_Data::error('404', T_('Library item not found.'));
} else {
$r = new Rating($id, $type);
$r->set_rating($rating);
echo XML_Data::single_string('success');
}
}
} // rate
/**
* timeline
* This get an user timeline
* @param array $input
*/
public static function timeline($input)
{
if (AmpConfig::get('sociable')) {
$username = $input['username'];
$limit = intval($input['limit']);
$since = intval($input['since']);
if (!empty($username)) {
$user = User::get_from_username($username);
if ($user !== null) {
if (Preference::get_by_user($user->id, 'allow_personal_info_recent')) {
$activities = Useractivity::get_activities($user->id, $limit, $since);
ob_end_clean();
echo XML_Data::timeline($activities);
}
}
} else {
debug_event('api', 'Username required on timeline function call.', 1);
}
} else {
debug_event('api', 'Sociable feature is not enabled.', 3);
}
} // timeline
/**
* timeline
* This get current user friends timeline
* @param array $input
*/
public static function friends_timeline($input)
{
if (AmpConfig::get('sociable')) {
$limit = intval($input['limit']);
$since = intval($input['since']);
if ($GLOBALS['user']->id > 0) {
$activities = Useractivity::get_friends_activities($GLOBALS['user']->id, $limit, $since);
ob_end_clean();
echo XML_Data::timeline($activities);
}
} else {
debug_event('api', 'Sociable feature is not enabled.', 3);
}
} // friends_timeline
} // API class

View file

@ -2,26 +2,26 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
use MusicBrainz\MusicBrainz;
use MusicBrainz\Clients\RequestsMbClient;
use MusicBrainz\HttpAdapters\RequestsHttpAdapter;
/**
* Art Class
@ -81,14 +81,19 @@ class Art extends database_object
*/
public function __construct($uid, $type = 'album', $kind = 'default')
{
if (!Core::is_library_item($type))
if (!Art::is_valid_type($type)) {
return false;
}
$this->type = $type;
$this->uid = intval($uid);
$this->uid = intval($uid);
$this->kind = $kind;
} // constructor
public static function is_valid_type($type)
{
return (Core::is_library_item($type) || $type == 'user');
}
/**
* build_cache
* This attempts to reduce # of queries by asking for everything in the
@ -99,9 +104,11 @@ class Art extends database_object
*/
public static function build_cache($object_ids)
{
if (!is_array($object_ids) || !count($object_ids)) { return false; }
$uidlist = '(' . implode(',', $object_ids) . ')';
$sql = "SELECT `object_type`, `object_id`, `mime`, `size` FROM `image` WHERE `object_id` IN $uidlist";
if (!is_array($object_ids) || !count($object_ids)) {
return false;
}
$uidlist = '(' . implode(',', $object_ids) . ')';
$sql = "SELECT `object_type`, `object_id`, `mime`, `size` FROM `image` WHERE `object_id` IN $uidlist";
$db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) {
@ -110,7 +117,6 @@ class Art extends database_object
}
return true;
} // build_cache
/**
@ -170,13 +176,14 @@ class Art extends database_object
*/
public static function extension($mime)
{
$data = explode("/", $mime);
$data = explode("/", $mime);
$extension = $data['1'];
if ($extension == 'jpeg') { $extension = 'jpg'; }
if ($extension == 'jpeg') {
$extension = 'jpg';
}
return $extension;
} // extension
/**
@ -202,8 +209,8 @@ class Art extends database_object
// Check to make sure PHP:GD exists. If so, we can sanity check
// the image.
if (function_exists('ImageCreateFromString')) {
$image = ImageCreateFromString($source);
if (!$image || imagesx($image) < 5 || imagesy($image) < 5) {
$image = @ImageCreateFromString($source);
if (!$image || imagesx($image) < 5 || imagesy($image) < 5) {
debug_event('Art', 'Image failed PHP-GD test',1);
$test = false;
}
@ -234,7 +241,6 @@ class Art extends database_object
} else {
return $this->thumb;
}
} // get
@ -247,7 +253,7 @@ class Art extends database_object
*/
public function get_db()
{
$sql = "SELECT `id`, `image`, `mime`, `size` FROM `image` WHERE `object_type` = ? AND `object_id` = ? AND `kind` = ?";
$sql = "SELECT `id`, `image`, `mime`, `size` FROM `image` WHERE `object_type` = ? AND `object_id` = ? AND `kind` = ?";
$db_results = Dba::read($sql, array($this->type, $this->uid, $this->kind));
while ($results = Dba::fetch_assoc($db_results)) {
@ -258,18 +264,22 @@ class Art extends database_object
$this->raw = $results['image'];
}
$this->raw_mime = $results['mime'];
} else if (AmpConfig::get('resize_images') && $results['size'] == '275x275') {
if (AmpConfig::get('album_art_store_disk')) {
$this->thumb = self::read_from_dir($results['size'], $this->type, $this->uid, $this->kind);
} else {
$this->thumb = $results['image'];
} else {
if (AmpConfig::get('resize_images') && $results['size'] == '275x275') {
if (AmpConfig::get('album_art_store_disk')) {
$this->thumb = self::read_from_dir($results['size'], $this->type, $this->uid, $this->kind);
} else {
$this->thumb = $results['image'];
}
$this->raw_mime = $results['mime'];
}
$this->raw_mime = $results['mime'];
}
$this->id = $results['id'];
}
// If we get nothing return false
if (!$this->raw) { return false; }
if (!$this->raw) {
return false;
}
// If there is no thumb and we want thumbs
if (!$this->thumb && AmpConfig::get('resize_images')) {
@ -278,7 +288,7 @@ class Art extends database_object
// If it works save it!
if ($data) {
$this->save_thumb($data['thumb'], $data['thumb_mime'], $size);
$this->thumb = $data['thumb'];
$this->thumb = $data['thumb'];
$this->thumb_mime = $data['thumb_mime'];
} else {
debug_event('Art','Unable to retrieve or generate thumbnail for ' . $this->type . '::' . $this->id,1);
@ -286,7 +296,6 @@ class Art extends database_object
} // if no thumb, but art and we want to resize
return true;
} // get_db
/**
@ -298,9 +307,9 @@ class Art extends database_object
*/
public static function has_db($object_id, $object_type, $kind = 'default')
{
$sql = "SELECT COUNT(`id`) AS `nb_img` FROM `image` WHERE `object_type` = ? AND `object_id` = ? AND `kind` = ?";
$sql = "SELECT COUNT(`id`) AS `nb_img` FROM `image` WHERE `object_type` = ? AND `object_id` = ? AND `kind` = ?";
$db_results = Dba::read($sql, array($object_type, $object_id, $kind));
$nb_img = 0;
$nb_img = 0;
if ($results = Dba::fetch_assoc($db_results)) {
$nb_img = $results['nb_img'];
}
@ -316,8 +325,8 @@ class Art extends database_object
{
debug_event('art', 'Insert art from url ' . $url, '5');
$image = Art::get_from_source(array('url' => $url), $this->type);
$rurl = pathinfo($url);
$mime = "image/" . $rurl['extension'];
$rurl = pathinfo($url);
$mime = "image/" . $rurl['extension'];
$this->insert($image, $mime);
}
@ -330,7 +339,7 @@ class Art extends database_object
debug_event('art', 'Insert art from file on disk ' . $filepath, '5');
$image = Art::get_from_source(array('file' => $filepath), $this->type);
$rfile = pathinfo($filepath);
$mime = "image/" . $rfile['extension'];
$mime = "image/" . $rfile['extension'];
$this->insert($image, $mime);
}
@ -345,7 +354,9 @@ class Art extends database_object
public function insert($source, $mime = '')
{
// Disabled in demo mode cause people suck and upload porn
if (AmpConfig::get('demo_mode')) { return false; }
if (AmpConfig::get('demo_mode')) {
return false;
}
// Check to make sure we like this image
if (!self::test_image($source)) {
@ -366,7 +377,7 @@ class Art extends database_object
foreach ($songs as $song_id) {
$song = new Song($song_id);
$song->format();
$id3 = new vainfo($song->file);
$id3 = new vainfo($song->file);
$data = $id3->read_id3();
if (isset($data['tags']['id3v2'])) {
$image_from_tag = '';
@ -374,11 +385,12 @@ class Art extends database_object
$image_from_tag = $data['id3v2']['APIC'][0]['data'];
}
if ($image_from_tag != $source) {
$ndata = array();
$ndata = array();
$ndata['APIC']['data'] = $source;
$ndata['APIC']['mime'] = $mime;
$ndata = array_merge($ndata, $song->get_metadata());
$ndata = array_merge($ndata, $song->get_metadata());
$id3->write_id3($ndata);
Catalog::update_media_from_tags($song);
}
}
}
@ -386,9 +398,9 @@ class Art extends database_object
}
$dimensions = Core::image_dimensions($source);
$width = intval($dimensions['width']);
$height = intval($dimensions['height']);
$sizetext = 'original';
$width = intval($dimensions['width']);
$height = intval($dimensions['height']);
$sizetext = 'original';
if (!self::check_dimensions($dimensions)) {
return false;
@ -404,7 +416,6 @@ class Art extends database_object
Dba::write($sql, array($source, $mime, $sizetext, $width, $height, $this->type, $this->uid, $this->kind));
return true;
} // insert
public static function check_dimensions($dimensions)
@ -432,7 +443,7 @@ class Art extends database_object
return true;
}
private static function get_dir_on_disk($type, $uid, $kind = '', $autocreate = false)
public static function get_dir_on_disk($type, $uid, $kind = '', $autocreate = false)
{
$path = AmpConfig::get('local_metadata_dir');
if (!$path) {
@ -498,7 +509,7 @@ class Art extends database_object
}
$image = '';
$fp = fopen($path, "rb");
$fp = fopen($path, "rb");
do {
$image .= fread($fp, 2048);
} while (!feof($fp));
@ -521,9 +532,13 @@ class Art extends database_object
if (Core::is_readable($path)) {
foreach (scandir($path) as $file) {
if ('.' === $file || '..' === $file) continue;
elseif (is_dir($path . '/' . $file)) self::delete_rec_dir($path . '/' . $file);
else unlink($path . '/' . $file);
if ('.' === $file || '..' === $file) {
continue;
} elseif (is_dir($path . '/' . $file)) {
self::delete_rec_dir($path . '/' . $file);
} else {
unlink($path . '/' . $file);
}
}
rmdir($path);
}
@ -557,8 +572,8 @@ class Art extends database_object
return false;
}
$width = intval($size['width']);
$height = intval($size['height']);
$width = intval($size['width']);
$height = intval($size['height']);
$sizetext = $width . 'x' . $height;
$sql = "DELETE FROM `image` WHERE `object_id` = ? AND `object_type` = ? AND `size` = ? AND `kind` = ?";
@ -581,15 +596,26 @@ class Art extends database_object
*/
public function get_thumb($size)
{
$sizetext = $size['width'] . 'x' . $size['height'];
$sql = "SELECT `image`, `mime` FROM `image` WHERE `size` = ? AND `object_type` = ? AND `object_id` = ? AND `kind` = ?";
$sizetext = $size['width'] . 'x' . $size['height'];
$sql = "SELECT `image`, `mime` FROM `image` WHERE `size` = ? AND `object_type` = ? AND `object_id` = ? AND `kind` = ?";
$db_results = Dba::read($sql, array($sizetext, $this->type, $this->uid, $this->kind));
$results = Dba::fetch_assoc($db_results);
if (count($results)) {
return array(
'thumb' => (AmpConfig::get('album_art_store_disk')) ? self::read_from_dir($sizetext, $this->type, $this->uid, $this->kind) : $results['image'],
'thumb_mime' => $results['mime']);
$image = null;
if (AmpConfig::get('album_art_store_disk')) {
$image = self::read_from_dir($sizetext, $this->type, $this->uid, $this->kind);
} else {
$image = $results['image'];
}
if ($image != null) {
return array(
'thumb' => (AmpConfig::get('album_art_store_disk')) ? self::read_from_dir($sizetext, $this->type, $this->uid, $this->kind) : $results['image'],
'thumb_mime' => $results['mime']);
} else {
debug_event('art', 'Thumb entry found in database but associated data cannot be found.', 3);
}
}
// If we didn't get a result
@ -599,7 +625,6 @@ class Art extends database_object
}
return $results;
} // get_thumb
/**
@ -628,19 +653,19 @@ class Art extends database_object
}
// Check and make sure we can resize what you've asked us to
if (($type == 'jpg' OR $type == 'jpeg') AND !(imagetypes() & IMG_JPG)) {
if (($type == 'jpg' or $type == 'jpeg') and !(imagetypes() & IMG_JPG)) {
debug_event('Art','PHP-GD Does not support JPGs - unable to resize',1);
return false;
}
if ($type == 'png' AND !imagetypes() & IMG_PNG) {
if ($type == 'png' and !imagetypes() & IMG_PNG) {
debug_event('Art','PHP-GD Does not support PNGs - unable to resize',1);
return false;
}
if ($type == 'gif' AND !imagetypes() & IMG_GIF) {
if ($type == 'gif' and !imagetypes() & IMG_GIF) {
debug_event('Art','PHP-GD Does not support GIFs - unable to resize',1);
return false;
}
if ($type == 'bmp' AND !imagetypes() & IMG_WBMP) {
if ($type == 'bmp' and !imagetypes() & IMG_WBMP) {
debug_event('Art','PHP-GD Does not support BMPs - unable to resize',1);
return false;
}
@ -702,7 +727,6 @@ class Art extends database_object
}
return array('thumb' => $data, 'thumb_mime' => $mime_type);
} // generate_thumb
/**
@ -726,9 +750,9 @@ class Art extends database_object
// If it came from the database
if (isset($data['db'])) {
$sql = "SELECT * FROM `image` WHERE `object_type` = ? AND `object_id` =? AND `size`='original'";
$sql = "SELECT * FROM `image` WHERE `object_type` = ? AND `object_id` =? AND `size`='original'";
$db_results = Dba::read($sql, array($type, $data['db']));
$row = Dba::fetch_assoc($db_results);
$row = Dba::fetch_assoc($db_results);
return $row['art'];
} // came from the db
@ -737,8 +761,8 @@ class Art extends database_object
$options = array();
try {
$options['timeout'] = 3;
$request = Requests::get($data['url'], array(), Core::requests_options($options));
$raw = $request->body;
$request = Requests::get($data['url'], array(), Core::requests_options($options));
$raw = $request->body;
} catch (Exception $e) {
debug_event('Art', 'Error getting art: ' . $e->getMessage(), '1');
$raw = null;
@ -749,7 +773,7 @@ class Art extends database_object
// Check to see if it's a FILE
if (isset($data['file'])) {
$handle = fopen($data['file'],'rb');
$handle = fopen($data['file'],'rb');
$image_data = fread($handle,Core::get_filesize($data['file']));
fclose($handle);
return $image_data;
@ -759,7 +783,7 @@ class Art extends database_object
if (isset($data['song'])) {
// If we find a good one, stop looking
$getID3 = new getID3();
$id3 = $getID3->analyze($data['song']);
$id3 = $getID3->analyze($data['song']);
if ($id3['format_name'] == "WMA") {
return $id3['asf']['extended_content_description_object']['content_descriptors']['13']['data'];
@ -772,7 +796,6 @@ class Art extends database_object
} // if data song
return null;
} // get_from_source
/**
@ -786,8 +809,9 @@ class Art extends database_object
*/
public static function url($uid,$type,$sid=null,$thumb=null)
{
if (!Core::is_library_item($type))
if (!self::is_valid_type($type)) {
return null;
}
if (AmpConfig::get('use_auth') && AmpConfig::get('require_session')) {
$sid = $sid ? scrub_out($sid) : scrub_out(session_id());
@ -801,28 +825,30 @@ class Art extends database_object
$key = $type . $uid;
if (parent::is_cached('art', $key . '275x275') && AmpConfig::get('resize_images')) {
$row = parent::get_from_cache('art', $key . '275x275');
$row = parent::get_from_cache('art', $key . '275x275');
$mime = $row['mime'];
}
if (parent::is_cached('art', $key . 'original')) {
$row = parent::get_from_cache('art', $key . 'original');
$row = parent::get_from_cache('art', $key . 'original');
$thumb_mime = $row['mime'];
}
if (!isset($mime) && !isset($thumb_mime)) {
$sql = "SELECT `object_type`, `object_id`, `mime`, `size` FROM `image` WHERE `object_type` = ? AND `object_id` = ?";
$sql = "SELECT `object_type`, `object_id`, `mime`, `size` FROM `image` WHERE `object_type` = ? AND `object_id` = ?";
$db_results = Dba::read($sql, array($type, $uid));
while ($row = Dba::fetch_assoc($db_results)) {
parent::add_to_cache('art', $key . $row['size'], $row);
if ($row['size'] == 'original') {
$mime = $row['mime'];
} else if ($row['size'] == '275x275' && AmpConfig::get('resize_images')) {
$thumb_mime = $row['mime'];
} else {
if ($row['size'] == '275x275' && AmpConfig::get('resize_images')) {
$thumb_mime = $row['mime'];
}
}
}
}
$mime = isset($thumb_mime) ? $thumb_mime : (isset($mime) ? $mime : null);
$mime = isset($thumb_mime) ? $thumb_mime : (isset($mime) ? $mime : null);
$extension = self::extension($mime);
if (AmpConfig::get('stream_beautiful_url')) {
@ -846,7 +872,6 @@ class Art extends database_object
}
return $url;
} // url
/**
@ -912,7 +937,7 @@ class Art extends database_object
public static function duplicate($object_type, $old_object_id, $new_object_id)
{
if (AmpConfig::get('album_art_store_disk')) {
$sql = "SELECT `size`, `kind` FROM `image` WHERE `object_type` = ? AND `object_id` = ?";
$sql = "SELECT `size`, `kind` FROM `image` WHERE `object_type` = ? AND `object_id` = ?";
$db_results = Dba::read($sql, array($object_type, $old_object_id));
while ($row = Dba::fetch_assoc($db_results)) {
$image = self::read_from_dir($row['size'], $object_type, $old_object_id, $row['kind']);
@ -937,7 +962,7 @@ class Art extends database_object
{
// Define vars
$results = array();
$type = $this->type;
$type = $this->type;
if (isset($options['type'])) {
$type = $options['type'];
}
@ -946,7 +971,7 @@ class Art extends database_object
debug_event('Art', 'No options for art search, skipped.', 3);
return array();
}
$config = AmpConfig::get('art_order');
$config = AmpConfig::get('art_order');
$methods = get_class_methods('Art');
/* If it's not set */
@ -966,15 +991,16 @@ class Art extends database_object
$data = array();
if (in_array($method, $plugin_names)) {
$plugin = new Plugin($method);
$plugin = new Plugin($method);
$installed_version = Plugin::get_plugin_version($plugin->_plugin->name);
if ($installed_version) {
if ($plugin->load($GLOBALS['user'])) {
$data = $plugin->_plugin->gather_arts($type, $options, $limit);
}
}
} else if (in_array($method_name, $methods)) {
debug_event('Art', "Method used: $method_name", 3);
} else {
if (in_array($method_name, $methods)) {
debug_event('Art', "Method used: $method_name", 3);
// Some of these take options!
switch ($method_name) {
case 'gather_lastfm':
@ -987,8 +1013,9 @@ class Art extends database_object
$data = $this->{$method_name}($limit);
break;
}
} else {
debug_event("Art", $method_name . " not defined", 1);
} else {
debug_event("Art", $method_name . " not defined", 1);
}
}
// Add the results we got to the current set
@ -997,11 +1024,9 @@ class Art extends database_object
if ($limit && count($results) >= $limit) {
return array_slice($results, 0, $limit);
}
} // end foreach
return $results;
} // gather
///////////////////////////////////////////////////////////////////////
@ -1047,7 +1072,7 @@ class Art extends database_object
return $images;
}
$mb = new MusicBrainz(new RequestsMbClient());
$mb = new MusicBrainz(new RequestsHttpAdapter());
$includes = array(
'url-rels'
);
@ -1057,7 +1082,7 @@ class Art extends database_object
return $images;
}
$asin = $release['asin'];
$asin = $release->asin;
if ($asin) {
debug_event('mbz-gatherart', "Found ASIN: " . $asin, '5');
@ -1091,7 +1116,7 @@ class Art extends database_object
// that displays cover art.
// I'm leaving in the releaseuri info for the moment, though
// it's not going to be used.
$coverartsites = array();
$coverartsites = array();
$coverartsites[] = array(
'name' => "CD Baby",
'domain' => "cdbaby.com",
@ -1173,7 +1198,6 @@ class Art extends database_object
} // end foreach
return $images;
} // gather_musicbrainz
/**
@ -1190,7 +1214,7 @@ class Art extends database_object
$limit = 5;
}
$results = array();
$results = array();
$preferred = false;
// For storing which directories we've already done
$processed = array();
@ -1213,12 +1237,14 @@ class Art extends database_object
$media = new Album($this->uid);
$songs = $media->get_songs();
foreach ($songs as $song_id) {
$song = new Song($song_id);
$song = new Song($song_id);
$dirs[] = Core::conv_lc_file( dirname($song->file) );
}
} else if ($this->type == 'video') {
$media = new Video($this->uid);
$dirs[] = Core::conv_lc_file( dirname($media->file) );
} else {
if ($this->type == 'video') {
$media = new Video($this->uid);
$dirs[] = Core::conv_lc_file( dirname($media->file) );
}
}
foreach ($dirs as $dir) {
@ -1232,7 +1258,7 @@ class Art extends database_object
$handle = opendir($dir);
if (!$handle) {
Error::add('general', T_('Error: Unable to open') . ' ' . $dir);
AmpError::add('general', T_('Error: Unable to open') . ' ' . $dir);
debug_event('folder_art', "Error: Unable to open $dir for album art read", 2);
continue;
}
@ -1284,10 +1310,8 @@ class Art extends database_object
'mime' => 'image/' . $extension,
'title' => 'Folder'
);
} // end while reading dir
closedir($handle);
} // end foreach dirs
if (is_array($preferred)) {
@ -1302,7 +1326,6 @@ class Art extends database_object
}
return array_values($results);
} // gather_folder
/**
@ -1351,7 +1374,7 @@ class Art extends database_object
// grab the songs and define our results
$songs = $album->get_songs();
$data = array();
$data = array();
// Foreach songs in this album
foreach ($songs as $song_id) {
@ -1373,15 +1396,17 @@ class Art extends database_object
*/
protected function gather_media_tags($media)
{
$mtype = strtolower(get_class($media));
$data = array();
$mtype = strtolower(get_class($media));
$data = array();
$getID3 = new getID3();
try { $id3 = $getID3->analyze($media->file); } catch (Exception $error) {
try {
$id3 = $getID3->analyze($media->file);
} catch (Exception $error) {
debug_event('getid3', $error->getMessage(), 1);
}
if (isset($id3['asf']['extended_content_description_object']['content_descriptors']['13'])) {
$image = $id3['asf']['extended_content_description_object']['content_descriptors']['13'];
$image = $id3['asf']['extended_content_description_object']['content_descriptors']['13'];
$data[] = array(
$mtype => $media->file,
'raw' => $image['data'],
@ -1401,7 +1426,7 @@ class Art extends database_object
}
if (isset($id3['comments']['picture']['0'])) {
$image = $id3['comments']['picture']['0'];
$image = $id3['comments']['picture']['0'];
$data[] = array(
$mtype => $media->file,
'raw' => $image['data'],
@ -1411,7 +1436,6 @@ class Art extends database_object
}
return $data;
}
/**
@ -1431,7 +1455,7 @@ class Art extends database_object
$images = array();
$search = rawurlencode($data['keyword']);
$size = '&imgsz=m'; // Medium
$size = '&imgsz=m'; // Medium
$url = "http://images.google.com/images?source=hp&q=" . $search . "&oq=&um=1&ie=UTF-8&sa=N&tab=wi&start=0&tbo=1" . $size;
debug_event('Art', 'Search url: ' . $url, '5');
@ -1442,18 +1466,19 @@ class Art extends database_object
'User-Agent' => 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11',
);
$query = Requests::get($url, $headers, Core::requests_options());
$html = $query->body;
$html = $query->body;
if (preg_match_all("|imgres\?imgurl\=(http.+?)&|", $html, $matches, PREG_PATTERN_ORDER)) {
foreach ($matches[1] as $match) {
$match = rawurldecode($match);
debug_event('Art', 'Found image at: ' . $match, '5');
$results = pathinfo($match);
$mime = 'image/' . $results['extension'];
$mime = 'image/' . $results['extension'];
$images[] = array('url' => $match, 'mime' => $mime, 'title' => 'Google');
if ($limit > 0 && count($images) >= $limit)
if ($limit > 0 && count($images) >= $limit) {
break;
}
}
}
} catch (Exception $e) {
@ -1461,7 +1486,6 @@ class Art extends database_object
}
return $images;
} // gather_google
/**
@ -1487,22 +1511,31 @@ class Art extends database_object
try {
$xmldata = Recommendation::album_search($data['artist'], $data['album']);
if (!count($xmldata)) { return array(); }
if (!count($xmldata)) {
return array();
}
$coverart = (array) $xmldata->coverart;
if (!$coverart) { return array(); }
$xalbum = $xmldata->album;
if (!$xalbum) {
return array();
}
$coverart = (array) $xalbum->image;
if (!$coverart) {
return array();
}
ksort($coverart);
foreach ($coverart as $url) {
// We need to check the URL for the /noimage/ stuff
if (strpos($url, '/noimage/') !== false) {
if (is_array($url) || strpos($url, '/noimage/') !== false) {
debug_event('LastFM', 'Detected as noimage, skipped ' . $url, 3);
continue;
}
// HACK: we shouldn't rely on the extension to determine file type
$results = pathinfo($url);
$mime = 'image/' . $results['extension'];
$results = pathinfo($url);
$mime = 'image/' . $results['extension'];
$images[] = array('url' => $url, 'mime' => $mime, 'title' => 'LastFM');
if ($limit && count($images) >= $limit) {
return $images;
@ -1513,7 +1546,6 @@ class Art extends database_object
}
return $images;
} // gather_lastfm
/**
@ -1524,60 +1556,60 @@ class Art extends database_object
*/
public static function gather_metadata_plugin($plugin, $type, $options)
{
$gtypes = array();
$gtypes = array();
$media_info = array();
switch ($type) {
case 'tvshow':
case 'tvshow_season':
case 'tvshow_episode':
$gtypes[] = 'tvshow';
$media_info['tvshow'] = $options['tvshow'];
$media_info['tvshow_season'] = $options['tvshow_season'];
$gtypes[] = 'tvshow';
$media_info['tvshow'] = $options['tvshow'];
$media_info['tvshow_season'] = $options['tvshow_season'];
$media_info['tvshow_episode'] = $options['tvshow_episode'];
break;
case 'song':
$media_info['mb_trackid'] = $options['mb_trackid'];
$media_info['title'] = $options['title'];
$media_info['artist'] = $options['artist'];
$media_info['album'] = $options['album'];
$gtypes[] = 'song';
$media_info['title'] = $options['title'];
$media_info['artist'] = $options['artist'];
$media_info['album'] = $options['album'];
$gtypes[] = 'song';
break;
case 'album':
$media_info['mb_albumid'] = $options['mb_albumid'];
$media_info['mb_albumid'] = $options['mb_albumid'];
$media_info['mb_albumid_group'] = $options['mb_albumid_group'];
$media_info['artist'] = $options['artist'];
$media_info['title'] = $options['album'];
$gtypes[] = 'music';
$gtypes[] = 'album';
$media_info['artist'] = $options['artist'];
$media_info['title'] = $options['album'];
$gtypes[] = 'music';
$gtypes[] = 'album';
break;
case 'artist':
$media_info['mb_artistid'] = $options['mb_artistid'];
$media_info['title'] = $options['artist'];
$gtypes[] = 'music';
$gtypes[] = 'artist';
$media_info['title'] = $options['artist'];
$gtypes[] = 'music';
$gtypes[] = 'artist';
break;
case 'movie':
$gtypes[] = 'movie';
$gtypes[] = 'movie';
$media_info['title'] = $options['keyword'];
break;
}
$meta = $plugin->get_metadata($gtypes, $media_info);
$meta = $plugin->get_metadata($gtypes, $media_info);
$images = array();
if ($meta['art']) {
$url = $meta['art'];
$ures = pathinfo($url);
$url = $meta['art'];
$ures = pathinfo($url);
$images[] = array('url' => $url, 'mime' => 'image/' . $ures['extension'], 'title' => $plugin->name);
}
if ($meta['tvshow_season_art']) {
$url = $meta['tvshow_season_art'];
$ures = pathinfo($url);
$url = $meta['tvshow_season_art'];
$ures = pathinfo($url);
$images[] = array('url' => $url, 'mime' => 'image/' . $ures['extension'], 'title' => $plugin->name);
}
if ($meta['tvshow_art']) {
$url = $meta['tvshow_art'];
$ures = pathinfo($url);
$url = $meta['tvshow_art'];
$ures = pathinfo($url);
$images[] = array('url' => $url, 'mime' => 'image/' . $ures['extension'], 'title' => $plugin->name);
}
@ -1596,56 +1628,55 @@ class Art extends database_object
switch ($thumb) {
case 1:
/* This is used by the now_playing / browse stuff */
$size['height'] = 100;
$size['height'] = 100;
$size['width'] = 100;
break;
case 2:
$size['height'] = 128;
$size['width'] = 128;
$size['width'] = 128;
break;
case 3:
/* This is used by the embedded web player */
$size['height'] = 80;
$size['width'] = 80;
break;
case 4:
/* Web Player size */
$size['height'] = 200;
$size['width'] = 200; // 200px width, set via CSS
$size['width'] = 80;
break;
case 5:
/* Web Player size */
$size['height'] = 32;
$size['width'] = 32;
$size['width'] = 32;
break;
case 6:
/* Video browsing size */
$size['height'] = 150;
$size['width'] = 100;
$size['width'] = 100;
break;
case 7:
/* Video page size */
$size['height'] = 300;
$size['width'] = 200;
$size['width'] = 200;
break;
case 8:
/* Video preview size */
$size['height'] = 200;
$size['width'] = 470;
$size['width'] = 470;
break;
case 9:
/* Video preview size */
$size['height'] = 100;
$size['width'] = 235;
$size['width'] = 235;
break;
case 10:
/* Search preview size */
$size['height'] = 24;
$size['width'] = 24;
$size['width'] = 24;
break;
case 4:
/* Popup Web Player size */
case 11:
/* Large view browse size */
default:
$size['height'] = 275;
$size['width'] = 275;
$size['height'] = 200;
$size['width'] = 200;
break;
}
@ -1661,7 +1692,7 @@ class Art extends database_object
*/
public static function display_item($item, $thumb, $link = null)
{
return self::display($item->type, $item->id, $item->get_fullname(), $thumb, $link);
return self::display($item->type ?: strtolower(get_class($item)), $item->id, $item->get_fullname(), $thumb, $link);
}
/**
@ -1677,8 +1708,9 @@ class Art extends database_object
*/
public static function display($object_type, $object_id, $name, $thumb, $link = null, $show_default = true, $kind = 'default')
{
if (!Core::is_library_item($object_type))
if (!self::is_valid_type($object_type)) {
return false;
}
if (!$show_default) {
// Don't show any image if not available
@ -1686,7 +1718,7 @@ class Art extends database_object
return false;
}
}
$size = self::get_thumb_size($thumb);
$size = self::get_thumb_size($thumb);
$prettyPhoto = ($link == null);
if ($link == null) {
$link = AmpConfig::get('web_path') . "/image.php?object_id=" . $object_id . "&object_type=" . $object_type;
@ -1707,14 +1739,22 @@ class Art extends database_object
if ($kind != 'default') {
$imgurl .= '&kind=' . $kind;
}
echo "<img src=\"" . $imgurl . "\" alt=\"" . $name . "\" height=\"" . $size['height'] . "\" width=\"" . $size['width'] . "\" />";
if ($prettyPhoto) {
if ($size['width'] >= 150) {
echo "<div class=\"item_art_play\">";
echo Ajax::text('?page=stream&action=directplay&object_type=' . $object_type . '&object_id=' . $object_id . '\' + getPagePlaySettings() + \'', '<span class="item_art_play_icon" title="' . T_('Play') . '" />', 'directplay_art_' . $object_type . '_' .$object_id);
echo "</div>";
// This to keep browser cache feature but force a refresh in case image just changed
if (Art::has_db($object_id, $object_type)) {
$art = new Art($object_id, $object_type);
if ($art->get_db()) {
$imgurl .= '&fooid=' . $art->id;
}
}
echo "<img src=\"" . $imgurl . "\" alt=\"" . $name . "\" height=\"" . $size['height'] . "\" width=\"" . $size['width'] . "\" />";
if ($size['height'] > 150) {
echo "<div class=\"item_art_play\">";
echo Ajax::text('?page=stream&action=directplay&object_type=' . $object_type . '&object_id=' . $object_id . '\' + getPagePlaySettings() + \'', '<span class="item_art_play_icon" title="' . T_('Play') . '" />', 'directplay_art_' . $object_type . '_' . $object_id);
echo "</div>";
}
if ($prettyPhoto) {
$libitem = new $object_type($object_id);
echo "<div class=\"item_art_actions\">";
if ($GLOBALS['user']->has_access(50) || ($GLOBALS['user']->has_access(25) && $GLOBALS['user']->id == $libitem->get_user_owner())) {
@ -1728,10 +1768,11 @@ class Art extends database_object
}
echo"</div>";
}
echo "</a>\n";
echo "</div>";
return true;
}
} // Art

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -76,6 +76,10 @@ class Artist extends database_object implements library_item
* @var int $user
*/
public $user;
/**
* @var boolean $manual_update
*/
public $manual_update;
/**
* @var array $tags
@ -139,7 +143,9 @@ class Artist extends database_object implements library_item
public function __construct($id=null,$catalog_init=0)
{
/* If they failed to pass in an id, just run for it */
if (!$id) { return false; }
if (!$id) {
return false;
}
$this->catalog_id = $catalog_init;
/* Get the information from the db */
@ -150,7 +156,6 @@ class Artist extends database_object implements library_item
} // foreach info
return true;
} //constructor
/**
@ -171,7 +176,6 @@ class Artist extends database_object implements library_item
$artist->_fake = true;
return $artist;
} // construct_from_array
/**
@ -196,15 +200,17 @@ class Artist extends database_object implements library_item
*/
public static function build_cache($ids, $extra=false, $limit_threshold = '')
{
if (!is_array($ids) OR !count($ids)) { return false; }
if (!is_array($ids) or !count($ids)) {
return false;
}
$idlist = '(' . implode(',', $ids) . ')';
$sql = "SELECT * FROM `artist` WHERE `id` IN $idlist";
$sql = "SELECT * FROM `artist` WHERE `id` IN $idlist";
$db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) {
parent::add_to_cache('artist',$row['id'],$row);
while ($row = Dba::fetch_assoc($db_results)) {
parent::add_to_cache('artist',$row['id'],$row);
}
// If we need to also pull the extra information, this is normally only used when we are doing the human display
@ -220,11 +226,9 @@ class Artist extends database_object implements library_item
}
parent::add_to_cache('artist_extra',$row['artist'],$row);
}
} // end if extra
return true;
} // build_cache
/**
@ -235,7 +239,7 @@ class Artist extends database_object implements library_item
*/
public static function get_from_name($name)
{
$sql = "SELECT `id` FROM `artist` WHERE `name` = ?'";
$sql = "SELECT `id` FROM `artist` WHERE `name` = ?'";
$db_results = Dba::read($sql, array($name));
$row = Dba::fetch_assoc($db_results);
@ -243,7 +247,6 @@ class Artist extends database_object implements library_item
$object = new Artist($row['id']);
return $object;
} // get_from_name
/**
@ -258,7 +261,7 @@ class Artist extends database_object implements library_item
public function get_albums($catalog = null, $ignoreAlbumGroups = false, $group_release_type = false)
{
$catalog_where = "";
$catalog_join = "LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog`";
$catalog_join = "LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog`";
if ($catalog) {
$catalog_where .= " AND `catalog`.`id` = '" . $catalog . "'";
}
@ -269,7 +272,7 @@ class Artist extends database_object implements library_item
$results = array();
$sort_type = AmpConfig::get('album_sort');
$sql_sort = '`album`.`name`,`album`.`disk`,`album`.`year`';
$sql_sort = '`album`.`name`,`album`.`disk`,`album`.`year`';
if ($sort_type == 'year_asc') {
$sql_sort = '`album`.`year` ASC';
} elseif ($sort_type == 'year_desc') {
@ -280,48 +283,50 @@ class Artist extends database_object implements library_item
$sql_sort = '`album`.`name` DESC';
}
$sql_group_type = '`album`.`id`';
if (!$ignoreAlbumGroups && AmpConfig::get('album_group')) {
$sql_group_type = '`album`.`mbid`';
if (!$ignoreAlbumGroups) {
$ignoreAlbumGroups = !AmpConfig::get('album_group');
}
$sql_group = "COALESCE($sql_group_type, `album`.`id`)";
$sql = "SELECT `album`.`id`, `album`.`release_type` FROM album LEFT JOIN `song` ON `song`.`album`=`album`.`id` $catalog_join " .
"WHERE (`song`.`artist`='$this->id' OR `album`.`album_artist`='$this->id') $catalog_where GROUP BY $sql_group ORDER BY $sql_sort";
$sql = "SELECT `album`.`id`, `album`.`release_type`,`album`.`mbid` FROM album LEFT JOIN `song` ON `song`.`album`=`album`.`id` $catalog_join " .
"WHERE (`song`.`artist`='$this->id' OR `album`.`album_artist`='$this->id') $catalog_where GROUP BY `album`.`id`, `album`.`release_type`,`album`.`mbid` ORDER BY $sql_sort";
debug_event("Artist", "$sql", "6");
$db_results = Dba::read($sql);
$mbids = array();
while ($r = Dba::fetch_assoc($db_results)) {
if ($group_release_type) {
// We assume undefined release type is album
$rtype = $r['release_type'] ?: 'album';
if (!isset($results[$rtype])) {
$results[$rtype] = array();
}
$results[$rtype][] = $r['id'];
$sort = AmpConfig::get('album_release_type_sort');
if ($sort) {
$results_sort = array();
$asort = explode(',', $sort);
foreach ($asort as $rtype) {
if (array_key_exists($rtype, $results)) {
$results_sort[$rtype] = $results[$rtype];
unset($results[$rtype]);
}
if ($ignoreAlbumGroups || empty($r['mbid']) || !in_array($r['mbid'], $mbids)) {
if ($group_release_type) {
// We assume undefined release type is album
$rtype = $r['release_type'] ?: 'album';
if (!isset($results[$rtype])) {
$results[$rtype] = array();
}
$results[$rtype][] = $r['id'];
$results = array_merge($results_sort, $results);
$sort = AmpConfig::get('album_release_type_sort');
if ($sort) {
$results_sort = array();
$asort = explode(',', $sort);
foreach ($asort as $rtype) {
if (array_key_exists($rtype, $results)) {
$results_sort[$rtype] = $results[$rtype];
unset($results[$rtype]);
}
}
$results = array_merge($results_sort, $results);
}
} else {
$results[] = $r['id'];
}
if (!empty($r['mbid'])) {
$mbids[] = $r['mbid'];
}
} else {
$results[] = $r['id'];
}
}
return $results;
} // get_albums
/**
@ -348,7 +353,6 @@ class Artist extends database_object implements library_item
}
return $results;
} // get_songs
/**
@ -376,7 +380,6 @@ class Artist extends database_object implements library_item
}
return $results;
} // get_random_songs
/**
@ -391,20 +394,30 @@ class Artist extends database_object implements library_item
if (parent::is_cached('artist_extra',$this->id) ) {
$row = parent::get_from_cache('artist_extra',$this->id);
} else {
$uid = Dba::escape($this->id);
$sql = "SELECT `song`.`artist`,COUNT(DISTINCT `song`.`id`) AS `song_count`, COUNT(DISTINCT `song`.`album`) AS `album_count`, SUM(`song`.`time`) AS `time`, `song`.`catalog` as `catalog_id` FROM `song` LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` " .
"WHERE `song`.`artist`='$uid' ";
$params = array($this->id);
// Calculation
$sql = "SELECT COUNT(DISTINCT `song`.`id`) AS `song_count`, COUNT(DISTINCT `song`.`album`) AS `album_count`, SUM(`song`.`time`) AS `time` FROM `song` LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` ";
$sqlw = "WHERE `song`.`artist` = ? ";
if ($catalog) {
$sql .= "AND (`song`.`catalog` = '$catalog') ";
$params[] = $catalog;
$sqlw .= "AND (`song`.`catalog` = ?) ";
}
if (AmpConfig::get('catalog_disable')) {
$sql .= " AND `catalog`.`enabled` = '1'";
$sqlw .= " AND `catalog`.`enabled` = '1' ";
}
$sql .= $sqlw . "GROUP BY `song`.`artist`";
$sql .= "GROUP BY `song`.`artist`";
$db_results = Dba::read($sql, $params);
$row = Dba::fetch_assoc($db_results);
// Get associated information from first song only
$sql = "SELECT `song`.`artist`, `song`.`catalog` as `catalog_id` FROM `song` LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog` ";
$sql .= $sqlw . "LIMIT 1";
$db_results = Dba::read($sql, $params);
$row = array_merge($row, Dba::fetch_assoc($db_results));
$db_results = Dba::read($sql);
$row = Dba::fetch_assoc($db_results);
if (AmpConfig::get('show_played_times')) {
$row['object_cnt'] = Stats::get_object_count('artist', $row['artist'], $limit_threshold);
}
@ -412,13 +425,12 @@ class Artist extends database_object implements library_item
}
/* Set Object Vars */
$this->songs = $row['song_count'];
$this->albums = $row['album_count'];
$this->time = $row['time'];
$this->songs = $row['song_count'];
$this->albums = $row['album_count'];
$this->time = $row['time'];
$this->catalog_id = $row['catalog_id'];
return $row;
} // _get_extra_info
/**
@ -432,18 +444,20 @@ class Artist extends database_object implements library_item
public function format($details = true, $limit_threshold = '')
{
/* Combine prefix and name, trim then add ... if needed */
$name = trim($this->prefix . " " . $this->name);
$this->f_name = $name;
$name = trim($this->prefix . " " . $this->name);
$this->f_name = $name;
$this->f_full_name = trim(trim($this->prefix) . ' ' . trim($this->name));
// If this is a memory-only object, we're done here
if (!$this->id) { return true; }
if (!$this->id) {
return true;
}
if ($this->catalog_id) {
$this->link = AmpConfig::get('web_path') . '/artists.php?action=show&catalog=' . $this->catalog_id . '&artist=' . $this->id;
$this->link = AmpConfig::get('web_path') . '/artists.php?action=show&catalog=' . $this->catalog_id . '&artist=' . $this->id;
$this->f_link = "<a href=\"" . $this->link . "\" title=\"" . $this->f_full_name . "\">" . $name . "</a>";
} else {
$this->link = AmpConfig::get('web_path') . '/artists.php?action=show&artist=' . $this->id;
$this->link = AmpConfig::get('web_path') . '/artists.php?action=show&artist=' . $this->id;
$this->f_link = "<a href=\"" . $this->link . "\" title=\"" . $this->f_full_name . "\">" . $name . "</a>";
}
@ -454,16 +468,16 @@ class Artist extends database_object implements library_item
//Format the new time thingy that we just got
$min = sprintf("%02d",(floor($extra_info['time']/60)%60));
$sec = sprintf("%02d",($extra_info['time']%60));
$sec = sprintf("%02d",($extra_info['time']%60));
$hours = floor($extra_info['time']/3600);
$this->f_time = ltrim($hours . ':' . $min . ':' . $sec,'0:');
$this->tags = Tag::get_top_tags('artist', $this->id);
$this->tags = Tag::get_top_tags('artist', $this->id);
$this->f_tags = Tag::get_display($this->tags, true, 'artist');
if (AmpConfig::get('label')) {
$this->labels = Label::get_labels($this->id);
$this->labels = Label::get_labels($this->id);
$this->f_labels = Label::get_display($this->labels, true);
}
@ -471,7 +485,6 @@ class Artist extends database_object implements library_item
}
return true;
} // format
/**
@ -480,7 +493,7 @@ class Artist extends database_object implements library_item
*/
public function get_keywords()
{
$keywords = array();
$keywords = array();
$keywords['mb_artistid'] = array('important' => false,
'label' => T_('Artist MusicBrainzID'),
'value' => $this->mbid);
@ -533,14 +546,14 @@ class Artist extends database_object implements library_item
*/
public function search_childrens($name)
{
$search['type'] = "album";
$search['rule_0_input'] = $name;
$search['type'] = "album";
$search['rule_0_input'] = $name;
$search['rule_0_operator'] = 4;
$search['rule_0'] = "title";
$search['rule_1_input'] = $this->name;
$search['rule_0'] = "title";
$search['rule_1_input'] = $this->name;
$search['rule_1_operator'] = 4;
$search['rule_1'] = "artist";
$albums = Search::run($search);
$search['rule_1'] = "artist";
$albums = Search::run($search);
$childrens = array();
foreach ($albums as $album) {
@ -608,11 +621,11 @@ class Artist extends database_object implements library_item
public function display_art($thumb = 2)
{
$id = null;
$id = null;
$type = null;
if (Art::has_db($this->id, 'artist')) {
$id = $this->id;
$id = $this->id;
$type = 'artist';
}
@ -627,12 +640,14 @@ class Artist extends database_object implements library_item
$user = $GLOBALS['user']->id;
}
if (!$user)
if (!$user) {
return false;
}
if (AmpConfig::get('upload_allow_edit')) {
if ($this->user !== null && $user == $this->user)
if ($this->user !== null && $user == $this->user) {
return true;
}
}
return Access::check('interface', 50, $user);
@ -650,13 +665,18 @@ class Artist extends database_object implements library_item
public static function check($name, $mbid = null, $readonly = false)
{
$trimmed = Catalog::trim_prefix(trim($name));
$name = $trimmed['string'];
$prefix = $trimmed['prefix'];
$name = $trimmed['string'];
$prefix = $trimmed['prefix'];
// If Ampache support multiple artists per song one day, we should also handle other artists here
$trimmed = Catalog::trim_featuring($name);
$name = $trimmed[0];
if ($mbid == '') $mbid = null;
if ($mbid == '') {
$mbid = null;
}
if (!$name) {
$name = T_('Unknown (Orphaned)');
$name = T_('Unknown (Orphaned)');
$prefix = null;
}
@ -664,26 +684,26 @@ class Artist extends database_object implements library_item
return self::$_mapcache[$name][$mbid];
}
$id = 0;
$id = 0;
$exists = false;
if ($mbid) {
$sql = 'SELECT `id` FROM `artist` WHERE `mbid` = ?';
$sql = 'SELECT `id` FROM `artist` WHERE `mbid` = ?';
$db_results = Dba::read($sql, array($mbid));
if ($row = Dba::fetch_assoc($db_results)) {
$id = $row['id'];
$id = $row['id'];
$exists = true;
}
}
if (!$exists) {
$sql = 'SELECT `id`, `mbid` FROM `artist` WHERE `name` LIKE ?';
$sql = 'SELECT `id`, `mbid` FROM `artist` WHERE `name` LIKE ?';
$db_results = Dba::read($sql, array($name));
$id_array = array();
while ($row = Dba::fetch_assoc($db_results)) {
$key = $row['mbid'] ?: 'null';
$key = $row['mbid'] ?: 'null';
$id_array[$key] = $row['id'];
}
@ -694,12 +714,12 @@ class Artist extends database_object implements library_item
Dba::write($sql, array($mbid, $id_array['null']));
}
if (isset($id_array['null'])) {
$id = $id_array['null'];
$id = $id_array['null'];
$exists = true;
}
} else {
// Pick one at random
$id = array_shift($id_array);
$id = array_shift($id_array);
$exists = true;
}
}
@ -725,7 +745,6 @@ class Artist extends database_object implements library_item
self::$_mapcache[$name][$mbid] = $id;
return $id;
}
/**
@ -737,11 +756,11 @@ class Artist extends database_object implements library_item
public function update(array $data)
{
// Save our current ID
$name = isset($data['name']) ? $data['name'] : $this->name;
$mbid = isset($data['mbid']) ? $data['mbid'] : $this->mbid;
$summary = isset($data['summary']) ? $data['summary'] : $this->summary;
$name = isset($data['name']) ? $data['name'] : $this->name;
$mbid = isset($data['mbid']) ? $data['mbid'] : $this->mbid;
$summary = isset($data['summary']) ? $data['summary'] : $this->summary;
$placeformed = isset($data['placeformed']) ? $data['placeformed'] : $this->placeformed;
$yearformed = isset($data['yearformed']) ? $data['yearformed'] : $this->yearformed;
$yearformed = isset($data['yearformed']) ? $data['yearformed'] : $this->yearformed;
$current_id = $this->id;
@ -750,7 +769,7 @@ class Artist extends database_object implements library_item
$artist_id = self::check($name, $mbid, true);
$updated = false;
$songs = array();
$songs = array();
// If it's changed we need to update
if ($artist_id != null && $artist_id != $this->id) {
@ -758,7 +777,7 @@ class Artist extends database_object implements library_item
foreach ($songs as $song_id) {
Song::update_artist($artist_id,$song_id);
}
$updated = true;
$updated = true;
$current_id = $artist_id;
Stats::migrate('artist', $this->id, $artist_id);
Art::migrate('artist', $this->id, $artist_id);
@ -772,21 +791,24 @@ class Artist extends database_object implements library_item
Stats::gc();
Rating::gc();
Userflag::gc();
Useractivity::gc();
} // if updated
} else if ($this->mbid != $mbid) {
$sql = 'UPDATE `artist` SET `mbid` = ? WHERE `id` = ?';
Dba::write($sql, array($mbid, $current_id));
} else {
if ($this->mbid != $mbid) {
$sql = 'UPDATE `artist` SET `mbid` = ? WHERE `id` = ?';
Dba::write($sql, array($mbid, $current_id));
}
}
// Update artist name (if we don't want to use the MusicBrainz name)
$trimmed = Catalog::trim_prefix(trim($name));
$name = $trimmed['string'];
$name = $trimmed['string'];
if ($name != '' && $name != $this->name) {
$sql = 'UPDATE `artist` SET `name` = ? WHERE `id` = ?';
Dba::write($sql, array($name, $current_id));
}
$this->update_artist_info($summary, $placeformed, $yearformed);
$this->update_artist_info($summary, $placeformed, $yearformed, true);
$this->name = $name;
$this->mbid = $mbid;
@ -810,7 +832,6 @@ class Artist extends database_object implements library_item
}
return $current_id;
} // update
/**
@ -845,14 +866,14 @@ class Artist extends database_object implements library_item
* @param int $yearformed
* @return boolean
*/
public function update_artist_info($summary, $placeformed, $yearformed)
public function update_artist_info($summary, $placeformed, $yearformed, $manual = false)
{
$sql = "UPDATE `artist` SET `summary` = ?, `placeformed` = ?, `yearformed` = ?, `last_update` = ? WHERE `id` = ?";
$sqlret = Dba::write($sql, array($summary, $placeformed, $yearformed, time(), $this->id));
$sql = "UPDATE `artist` SET `summary` = ?, `placeformed` = ?, `yearformed` = ?, `last_update` = ?, `manual_update` = ? WHERE `id` = ?";
$sqlret = Dba::write($sql, array($summary, $placeformed, Catalog::normalize_year($yearformed), time(), $manual ? 1 : 0, $this->id));
$this->summary = $summary;
$this->summary = $summary;
$this->placeformed = $placeformed;
$this->yearformed = $yearformed;
$this->yearformed = $yearformed;
return $sqlret;
}
@ -870,29 +891,30 @@ class Artist extends database_object implements library_item
public function remove_from_disk()
{
$deleted = true;
$deleted = true;
$album_ids = $this->get_albums();
foreach ($album_ids as $id) {
$album = new Album($id);
$album = new Album($id);
$deleted = $album->remove_from_disk();
if (!$deleted) {
debug_event('artist', 'Error when deleting the album `' . $id .'`.', 1);
debug_event('artist', 'Error when deleting the album `' . $id . '`.', 1);
break;
}
}
if ($deleted) {
$sql = "DELETE FROM `artist` WHERE `id` = ?";
$sql = "DELETE FROM `artist` WHERE `id` = ?";
$deleted = Dba::write($sql, array($this->id));
if ($deleted) {
Art::gc('artist', $this->id);
Userflag::gc('artist', $this->id);
Rating::gc('artist', $this->id);
Shoutbox::gc('artist', $this->id);
Useractivity::gc('artist', $this->id);
}
}
return $deleted;
}
} // end of artist class

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -85,5 +85,5 @@ class Artist_Event
return false;
}
} // end of recommendation class

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -68,7 +68,7 @@ class Auth
xoutput_headers();
$results = array();
$results = array();
$results['rfc3514'] = '<script type="text/javascript">reloadRedirect("' . $target . '")</script>';
echo xoutput_from_array($results);
} else {
@ -100,7 +100,9 @@ class Auth
}
$results = self::$function_name($username, $password);
if ($results['success'] || ($allow_ui && !empty($results['ui_required']))) { break; }
if ($results['success'] || ($allow_ui && !empty($results['ui_required']))) {
break;
}
}
return $results;
@ -137,7 +139,7 @@ class Auth
private static function mysql_auth($username, $password)
{
if (strlen($password) && strlen($username)) {
$sql = 'SELECT `password` FROM `user` WHERE `username` = ?';
$sql = 'SELECT `password` FROM `user` WHERE `username` = ?';
$db_results = Dba::read($sql, array($username));
if ($row = Dba::fetch_assoc($db_results)) {
@ -146,7 +148,7 @@ class Auth
// variations of the password. Increases collision chances, but
// doesn't break things.
// FIXME: Break things in the future.
$hashed_password = array();
$hashed_password = array();
$hashed_password[] = hash('sha256', $password);
$hashed_password[] = hash('sha256',
Dba::escape(stripslashes(htmlspecialchars(strip_tags($password)))));
@ -188,19 +190,19 @@ class Auth
$results = array();
if (!function_exists('pam_auth')) {
$results['success'] = false;
$results['error'] = 'The PAM PHP module is not installed';
$results['error'] = 'The PAM PHP module is not installed';
return $results;
}
$password = scrub_in($password);
if (pam_auth($username, $password)) {
$results['success'] = true;
$results['type'] = 'pam';
$results['success'] = true;
$results['type'] = 'pam';
$results['username'] = $username;
} else {
$results['success'] = false;
$results['error'] = 'PAM login attempt failed';
$results['error'] = 'PAM login attempt failed';
}
return $results;
@ -234,7 +236,7 @@ class Auth
), $pipes);
if (is_resource($proc)) {
fwrite($pipes[0], $username."\n".$password."\n");
fwrite($pipes[0], $username . "\n" . $password . "\n");
fclose($pipes[0]);
fclose($pipes[1]);
if ($stderr = fread($pipes[2], 8192)) {
@ -301,18 +303,18 @@ class Auth
if (!($ldap_dn && $ldap_url && $ldap_filter && $ldap_class)) {
debug_event('ldap_auth', 'Required config value missing', 1);
$results['success'] = false;
$results['error'] = 'Incomplete LDAP config';
$results['error'] = 'Incomplete LDAP config';
return $results;
}
if (strpos($ldap_filter, "%v") >= 0) {
if (strpos($ldap_filter, "%v") !== false) {
$ldap_filter = str_replace("%v", $username, $ldap_filter);
} else {
// This to support previous configuration where only the fieldname was set
$ldap_filter = "($ldap_filter=$username)";
}
$ldap_name_field = AmpConfig::get('ldap_name_field');
$ldap_name_field = AmpConfig::get('ldap_name_field');
$ldap_email_field = AmpConfig::get('ldap_email_field');
if ($ldap_link = ldap_connect($ldap_url) ) {
@ -323,13 +325,13 @@ class Auth
// bind using our auth if we need to for initial search
if (!ldap_bind($ldap_link, $ldap_username, $ldap_password)) {
$results['success'] = false;
$results['error'] = 'Could not bind to LDAP server.';
$results['error'] = 'Could not bind to LDAP server.';
return $results;
} // If bind fails
$searchstr = "(&(objectclass=$ldap_class)$ldap_filter)";
debug_event('ldap_auth', 'ldap_search: ' . $searchstr, 5);
$sr = ldap_search($ldap_link, $ldap_dn, $searchstr);
$sr = ldap_search($ldap_link, $ldap_dn, $searchstr);
$info = ldap_get_entries($ldap_link, $sr);
if ($info["count"] == 1) {
@ -348,7 +350,7 @@ class Auth
if (!$group_result) {
debug_event('ldap_auth', "Failure reading $require_group", 1);
$results['success'] = false;
$results['error'] = 'The LDAP group could not be read';
$results['error'] = 'The LDAP group could not be read';
return $results;
}
@ -357,7 +359,7 @@ class Auth
if ($group_info['count'] < 1) {
debug_event('ldap_auth', "No members found in $require_group", 1);
$results['success'] = false;
$results['error'] = 'Empty LDAP group';
$results['error'] = 'Empty LDAP group';
return $results;
}
@ -365,7 +367,7 @@ class Auth
if (!$group_match) {
debug_event('ldap_auth', "$user_dn is not a member of $require_group",1);
$results['success'] = false;
$results['error'] = 'LDAP login attempt failed';
$results['error'] = 'LDAP login attempt failed';
return $results;
}
}
@ -377,11 +379,8 @@ class Auth
$results['email'] = $info[0][$ldap_email_field][0];
return $results;
} // if we get something good back
} // if something was sent back
} // if failed connect
/* Default to bad news */
@ -389,7 +388,6 @@ class Auth
$results['error'] = 'LDAP login attempt failed';
return $results;
} // ldap_auth
/**
@ -406,11 +404,11 @@ class Auth
$results = array();
if (($_SERVER['REMOTE_USER'] == $username) ||
($_SERVER['HTTP_REMOTE_USER'] == $username)) {
$results['success'] = true;
$results['type'] = 'http';
$results['success'] = true;
$results['type'] = 'http';
$results['username'] = $username;
$results['name'] = $username;
$results['email'] = '';
$results['name'] = $username;
$results['email'] = '';
} else {
$results['success'] = false;
$results['error'] = 'HTTP auth login attempt failed';
@ -468,7 +466,7 @@ class Auth
}
} else {
// Generate form markup and render it.
$form_id = 'openid_message';
$form_id = 'openid_message';
$form_html = $auth_request->htmlMarkup(AmpConfig::get('web_path'), Openid::get_return_url(), false, array('id' => $form_id));
if (Auth_OpenID::isFailure($form_html)) {
@ -477,15 +475,15 @@ class Auth
} else {
debug_event('auth', 'OpenID 2: javascript redirection code to OpenID form.', '5');
// First step is a success, UI interaction required.
$results['success'] = false;
$results['success'] = false;
$results['ui_required'] = $form_html;
}
}
} else {
} else {
debug_event('auth', $website . ' is not a valid OpenID.', '3');
$results['success'] = false;
$results['error'] = 'Not a valid OpenID.';
}
}
} else {
debug_event('auth', 'Cannot initialize OpenID resources.', '3');
$results['success'] = false;
@ -507,62 +505,66 @@ class Auth
*/
private static function openid_auth_2()
{
$results = array();
$results = array();
$results['type'] = 'openid';
$consumer = Openid::get_consumer();
$consumer = Openid::get_consumer();
if ($consumer) {
$response = $consumer->complete(Openid::get_return_url());
if ($response->status == Auth_OpenID_CANCEL) {
$results['success'] = false;
$results['error'] = 'OpenID verification cancelled.';
} else if ($response->status == Auth_OpenID_FAILURE) {
$results['success'] = false;
$results['error'] = 'OpenID authentication failed: ' . $response->message;
} else if ($response->status == Auth_OpenID_SUCCESS) {
// Extract the identity URL and Simple Registration data (if it was returned).
$sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
$sreg = $sreg_resp->contents();
} else {
if ($response->status == Auth_OpenID_FAILURE) {
$results['success'] = false;
$results['error'] = 'OpenID authentication failed: ' . $response->message;
} else {
if ($response->status == Auth_OpenID_SUCCESS) {
// Extract the identity URL and Simple Registration data (if it was returned).
$sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
$sreg = $sreg_resp->contents();
$results['website'] = $response->getDisplayIdentifier();
if (@$sreg['email']) {
$results['email'] = $sreg['email'];
}
$results['website'] = $response->getDisplayIdentifier();
if (@$sreg['email']) {
$results['email'] = $sreg['email'];
}
if (@$sreg['nickname']) {
$results['username'] = $sreg['nickname'];
}
if (@$sreg['nickname']) {
$results['username'] = $sreg['nickname'];
}
if (@$sreg['fullname']) {
$results['name'] = $sreg['fullname'];
}
if (@$sreg['fullname']) {
$results['name'] = $sreg['fullname'];
}
$users = User::get_from_website($results['website']);
if (count($users) > 0) {
if (count($users) == 1) {
$user = new User($users[0]);
$results['success'] = true;
$results['username'] = $user->username;
} else {
// Several users for the same website/openid? Allowed but stupid, try to get a match on username.
$users = User::get_from_website($results['website']);
if (count($users) > 0) {
if (count($users) == 1) {
$user = new User($users[0]);
$results['success'] = true;
$results['username'] = $user->username;
} else {
// Several users for the same website/openid? Allowed but stupid, try to get a match on username.
// Should we make website field unique?
foreach ($users as $id) {
$user = new User($id);
if ($user->username == $results['username']) {
$results['success'] = true;
$results['success'] = true;
$results['username'] = $user->username;
}
}
}
} else {
// Don't return success if an user already exists for this username but don't have this openid identity as website
}
} else {
// Don't return success if an user already exists for this username but don't have this openid identity as website
$user = User::get_from_username($results['username']);
if ($user->id) {
$results['success'] = false;
$results['error'] = 'No user associated to this OpenID and username already taken.';
} else {
$results['success'] = true;
$results['error'] = 'No user associated to this OpenID.';
if ($user->id) {
$results['success'] = false;
$results['error'] = 'No user associated to this OpenID and username already taken.';
} else {
$results['success'] = true;
$results['error'] = 'No user associated to this OpenID.';
}
}
}
}
}

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -45,7 +45,7 @@ class AutoUpdate
protected static function is_develop()
{
$version = AmpConfig::get('version');
$vspart = explode('-', $version);
$vspart = explode('-', $version);
return ($vspart[count($vspart) - 1] == 'develop');
}
@ -77,7 +77,7 @@ class AutoUpdate
{
try {
// https is mandatory
$url = "https://api.github.com/repos/ampache/ampache" . $action;
$url = "https://api.github.com/repos/ampache/ampache" . $action;
$request = Requests::get($url, array(), Core::requests_options());
// Not connected / API rate limit exceeded: just ignore, it will pass next time
@ -195,8 +195,8 @@ class AutoUpdate
debug_event('autoupdate', 'Checking latest version online...', '5');
$available = false;
$current = self::get_current_version();
$latest = self::get_latest_version();
$current = self::get_current_version();
$latest = self::get_latest_version();
if ($current != $latest && !empty($current)) {
if (self::is_develop()) {
@ -243,12 +243,27 @@ class AutoUpdate
*/
public static function update_files()
{
echo T_('Updating Ampache sources with `git pull` ...') . '<br />';
$cmd = 'git pull https://github.com/ampache/ampache.git';
echo T_('Updating Ampache sources with `' . $cmd . '` ...') . '<br />';
ob_flush();
chdir(AmpConfig::get('prefix'));
exec('git pull https://github.com/ampache/ampache.git');
exec($cmd);
echo T_('Done') . '<br />';
ob_flush();
self::get_latest_version(true);
}
/**
* Update project dependencies.
*/
public static function update_dependencies()
{
$cmd = 'composer install --prefer-source --no-interaction';
echo T_('Updating dependencies with `' . $cmd . '` ...') . '<br />';
ob_flush();
chdir(AmpConfig::get('prefix'));
exec($cmd);
echo T_('Done') . '<br />';
ob_flush();
}
}

View file

@ -0,0 +1,156 @@
<?php
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Bookmark class
*
* This manage bookmark on playable items
*
*/
class Bookmark extends database_object
{
// Public variables
public $id;
public $user;
public $object_id;
public $object_type;
public $position;
public $comment;
public $creation_date;
public $update_date;
public $f_user;
/**
* Constructor
* This is run every time a new object is created, and requires
* the id and type of object that we need to pull for
*/
public function __construct ($object_id, $object_type = null, $user_id = null)
{
if (!$object_id) {
return false;
}
if (!$object_type) {
$info = $this->get_info($object_id);
} else {
if ($user_id == null) {
$user_id = $GLOBALS['user']->id;
}
$sql = "SELECT * FROM `bookmark` WHERE `object_type` = ? AND `object_id` = ? AND `user` = ?";
$db_results = Dba::read($sql, array($object_type, $object_id, $user_id));
if (!$db_results) {
return false;
}
$info = Dba::fetch_assoc($db_results);
}
// Foreach what we've got
foreach ($info as $key=>$value) {
$this->$key = $value;
}
return true;
}
/**
* gc
*
* Remove bookmark for items that no longer exist.
*/
public static function gc($object_type = null, $object_id = null)
{
$types = array('song', 'video', 'podcast_episode');
if ($object_type != null) {
if (in_array($object_type, $types)) {
$sql = "DELETE FROM `bookmark` WHERE `object_type` = ? AND `object_id` = ?";
Dba::write($sql, array($object_type, $object_id));
} else {
debug_event('bookmark', 'Garbage collect on type `' . $object_type . '` is not supported.', 1);
}
} else {
foreach ($types as $type) {
Dba::write("DELETE FROM `bookmark` USING `bookmark` LEFT JOIN `$type` ON `$type`.`id` = `bookmark`.`object_id` WHERE `bookmark`.`object_type` = '$type' AND `$type`.`id` IS NULL");
}
}
}
public static function get_bookmarks_ids($user = null)
{
$ids = array();
if ($user == null) {
$user = $GLOBALS['user'];
}
$sql = "SELECT `id` FROM `bookmark` WHERE `user` = ?";
$db_results = Dba::read($sql, array($user->id));
while ($results = Dba::fetch_assoc($db_results)) {
$ids[] = $results['id'];
}
return $ids;
}
public static function get_bookmarks($user = null)
{
$bookmarks = array();
$ids = self::get_bookmarks_ids($user);
foreach ($ids as $id) {
$bookmarks[] = new Bookmark($id);
}
return $bookmarks;
}
public static function create(array $data)
{
$user = $data['user'] ?: $GLOBALS['user']->id;
$position = $data['position'] ?: 0;
$comment = scrub_in($data['comment']);
$sql = "INSERT INTO `bookmark` (`user`, `position`, `comment`, `object_type`, `object_id`, `creation_date`, `update_date`) VALUES (?, ?, ?, ?, ?, ?, ?)";
return Dba::write($sql, array($user, $position, $comment, $data['object_type'], $data['object_id'], time(), time()));
}
public function update($position)
{
$sql = "UPDATE `bookmark` SET `position` = ?, `update_date` = ? WHERE `id` = ?";
return Dba::write($sql, array($position, time(), $this->id));
}
public function remove()
{
$sql = "DELETE FROM `bookmark` WHERE `id` = ?";
return Dba::write($sql, array($this->id));
}
public function format()
{
$user = new User($this->user);
$f_user = $user->username;
}
} //end bookmark class

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -78,7 +78,9 @@ class Broadcast extends database_object implements library_item
*/
public function __construct($id=0)
{
if (!$id) { return true; }
if (!$id) {
return true;
}
/* Get the information from the db */
$info = $this->get_info($id);
@ -125,7 +127,7 @@ class Broadcast extends database_object implements library_item
$sql = "UPDATE `broadcast` SET `song` = ? " .
"WHERE `id` = ?";
Dba::write($sql, array($song_id, $this->id));
$this->song = $song_id;
$this->song = $song_id;
$this->song_position = 0;
}
@ -148,7 +150,7 @@ class Broadcast extends database_object implements library_item
public static function create($name, $description='')
{
if (!empty($name)) {
$sql = "INSERT INTO `broadcast` (`user`, `name`, `description`, `is_private`) VALUES (?, ?, ?, '1')";
$sql = "INSERT INTO `broadcast` (`user`, `name`, `description`, `is_private`) VALUES (?, ?, ?, '1')";
$params = array($GLOBALS['user']->id, $name, $description);
Dba::write($sql, $params);
return Dba::insert_id();
@ -181,7 +183,7 @@ class Broadcast extends database_object implements library_item
$this->f_name = $this->name;
$this->f_link = '<a href="' . AmpConfig::get('web_path') . '/broadcast.php?id=' . $this->id . '">' . scrub_out($this->f_name) . '</a>';
if ($details) {
$this->tags = Tag::get_top_tags('broadcast', $this->id);
$this->tags = Tag::get_top_tags('broadcast', $this->id);
$this->f_tags = Tag::get_display($this->tags, true, 'broadcast');
}
}
@ -308,9 +310,9 @@ class Broadcast extends database_object implements library_item
*/
public static function get_broadcast_list()
{
$sql = self::get_broadcast_list_sql();
$sql = self::get_broadcast_list_sql();
$db_results = Dba::read($sql);
$results = array();
$results = array();
while ($row = Dba::fetch_assoc($db_results)) {
$results[] = $row['id'];
@ -336,7 +338,7 @@ class Broadcast extends database_object implements library_item
*/
public static function get_broadcast($key)
{
$sql = "SELECT `id` FROM `broadcast` WHERE `key` = ?";
$sql = "SELECT `id` FROM `broadcast` WHERE `key` = ?";
$db_results = Dba::read($sql, array($key));
if ($results = Dba::fetch_assoc($db_results)) {
@ -354,7 +356,7 @@ class Broadcast extends database_object implements library_item
if ($this->id) {
if ($GLOBALS['user']->has_access('75')) {
echo "<a id=\"edit_broadcast_ " . $this->id . "\" onclick=\"showEditDialog('broadcast_row', '" . $this->id . "', 'edit_broadcast_" . $this->id . "', '" . T_('Broadcast edit') . "', 'broadcast_row_')\">" . UI::get_icon('edit', T_('Edit')) . "</a>";
echo " <a href=\"" . AmpConfig::get('web_path') . "/broadcast.php?action=show_delete&id=" . $this->id ."\">" . UI::get_icon('delete', T_('Delete')) . "</a>";
echo " <a href=\"" . AmpConfig::get('web_path') . "/broadcast.php?action=show_delete&id=" . $this->id . "\">" . UI::get_icon('delete', T_('Delete')) . "</a>";
}
}
}
@ -392,7 +394,7 @@ class Broadcast extends database_object implements library_item
*/
public static function get_broadcasts($user_id)
{
$sql = "SELECT `id` FROM `broadcast` WHERE `user` = ?";
$sql = "SELECT `id` FROM `broadcast` WHERE `user` = ?";
$db_results = Dba::read($sql, array($user_id));
$broadcasts = array();
@ -404,7 +406,6 @@ class Broadcast extends database_object implements library_item
public static function gc()
{
}
/*
@ -421,5 +422,5 @@ class Broadcast extends database_object implements library_item
{
return $oid;
}
} // end of broadcast class

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -25,15 +25,15 @@ use Ratchet\ConnectionInterface;
class Broadcast_Server implements MessageComponentInterface
{
const BROADCAST_SONG = "SONG";
const BROADCAST_SONG_POSITION = "SONG_POSITION";
const BROADCAST_PLAYER_PLAY = "PLAYER_PLAY";
const BROADCAST_SONG = "SONG";
const BROADCAST_SONG_POSITION = "SONG_POSITION";
const BROADCAST_PLAYER_PLAY = "PLAYER_PLAY";
const BROADCAST_REGISTER_BROADCAST = "REGISTER_BROADCAST";
const BROADCAST_REGISTER_LISTENER = "REGISTER_LISTENER";
const BROADCAST_ENDED = "ENDED";
const BROADCAST_INFO = "INFO";
const BROADCAST_NB_LISTENERS = "NB_LISTENERS";
const BROADCAST_AUTH_SID = "AUTH_SID";
const BROADCAST_REGISTER_LISTENER = "REGISTER_LISTENER";
const BROADCAST_ENDED = "ENDED";
const BROADCAST_INFO = "INFO";
const BROADCAST_NB_LISTENERS = "NB_LISTENERS";
const BROADCAST_AUTH_SID = "AUTH_SID";
public $verbose;
/**
@ -55,10 +55,10 @@ class Broadcast_Server implements MessageComponentInterface
public function __construct()
{
$this->verbose = false;
$this->clients = array();
$this->sids = array();
$this->listeners = array();
$this->verbose = false;
$this->clients = array();
$this->sids = array();
$this->listeners = array();
$this->broadcasters = array();
}
@ -109,13 +109,13 @@ class Broadcast_Server implements MessageComponentInterface
break;
default:
if ($this->verbose) {
echo "[" . time() ."][warning]Unknown message code." . "\r\n";
echo "[" . time() . "][warning]Unknown message code." . "\r\n";
}
break;
}
} else {
if ($this->verbose) {
echo "[" . time() ."][error]Wrong message format (" . $command . ")." . "\r\n";
echo "[" . time() . "][error]Wrong message format (" . $command . ")." . "\r\n";
}
}
}
@ -129,7 +129,7 @@ class Broadcast_Server implements MessageComponentInterface
*/
protected function getSongJS($song_id)
{
$media = array();
$media = array();
$media[] = array(
'object_type' => 'song',
'object_id' => $song_id
@ -148,7 +148,7 @@ class Broadcast_Server implements MessageComponentInterface
{
if ($this->isBroadcaster($from)) {
$broadcast = $this->broadcasters[$from->resourceId];
$clients = $this->getListeners($broadcast);
$clients = $this->getListeners($broadcast);
Session::extend(Stream::get_session(), 'stream');
@ -156,7 +156,7 @@ class Broadcast_Server implements MessageComponentInterface
$this->broadcastMessage($clients, self::BROADCAST_SONG, base64_encode($this->getSongJS($song_id)));
if ($this->verbose) {
echo "[" . time() ."][info]Broadcast " . $broadcast->id . " now playing song " . $song_id . "." . "\r\n";
echo "[" . time() . "][info]Broadcast " . $broadcast->id . " now playing song " . $song_id . "." . "\r\n";
}
} else {
debug_event('broadcast', 'Action unauthorized.', '3');
@ -172,7 +172,7 @@ class Broadcast_Server implements MessageComponentInterface
{
if ($this->isBroadcaster($from)) {
$broadcast = $this->broadcasters[$from->resourceId];
$seekdiff = $broadcast->song_position - $song_position;
$seekdiff = $broadcast->song_position - $song_position;
if ($seekdiff > 2 || $seekdiff < -2) {
$clients = $this->getListeners($broadcast);
$this->broadcastMessage($clients, self::BROADCAST_SONG_POSITION, $song_position);
@ -180,7 +180,7 @@ class Broadcast_Server implements MessageComponentInterface
$broadcast->song_position = $song_position;
if ($this->verbose) {
echo "[" . time() ."][info]Broadcast " . $broadcast->id . " has song position to " . $song_position . "." . "\r\n";
echo "[" . time() . "][info]Broadcast " . $broadcast->id . " has song position to " . $song_position . "." . "\r\n";
}
} else {
debug_event('broadcast', 'Action unauthorized.', '3');
@ -196,11 +196,11 @@ class Broadcast_Server implements MessageComponentInterface
{
if ($this->isBroadcaster($from)) {
$broadcast = $this->broadcasters[$from->resourceId];
$clients = $this->getListeners($broadcast);
$clients = $this->getListeners($broadcast);
$this->broadcastMessage($clients, self::BROADCAST_PLAYER_PLAY, $play ? 'true' : 'false');
if ($this->verbose) {
echo "[" . time() ."][info]Broadcast " . $broadcast->id . " player state: " . $play . "." . "\r\n";
echo "[" . time() . "][info]Broadcast " . $broadcast->id . " player state: " . $play . "." . "\r\n";
}
} else {
debug_event('broadcast', 'Action unauthorized.', '3');
@ -215,11 +215,11 @@ class Broadcast_Server implements MessageComponentInterface
{
if ($this->isBroadcaster($from)) {
$broadcast = $this->broadcasters[$from->resourceId];
$clients = $this->getListeners($broadcast);
$clients = $this->getListeners($broadcast);
$this->broadcastMessage($clients, self::BROADCAST_ENDED);
if ($this->verbose) {
echo "[" . time() ."][info]Broadcast " . $broadcast->id . " ended." . "\r\n";
echo "[" . time() . "][info]Broadcast " . $broadcast->id . " ended." . "\r\n";
}
} else {
debug_event('broadcast', 'Action unauthorized.', '3');
@ -236,7 +236,7 @@ class Broadcast_Server implements MessageComponentInterface
$broadcast = Broadcast::get_broadcast($broadcast_key);
if ($broadcast) {
$this->broadcasters[$from->resourceId] = $broadcast;
$this->listeners[$broadcast->id] = array();
$this->listeners[$broadcast->id] = array();
if ($this->verbose) {
echo "[info]Broadcast " . $broadcast->id . " registered." . "\r\n";
@ -251,7 +251,7 @@ class Broadcast_Server implements MessageComponentInterface
protected function unregisterBroadcast(ConnectionInterface $conn)
{
$broadcast = $this->broadcasters[$conn->resourceId];
$clients = $this->getListeners($broadcast);
$clients = $this->getListeners($broadcast);
$this->broadcastMessage($clients, self::BROADCAST_ENDED);
$broadcast->update_state(false);
@ -259,7 +259,7 @@ class Broadcast_Server implements MessageComponentInterface
unset($this->broadcasters[$conn->resourceId]);
if ($this->verbose) {
echo "[" . time() ."][info]Broadcast " . $broadcast->id . " unregistered." . "\r\n";
echo "[" . time() . "][info]Broadcast " . $broadcast->id . " unregistered." . "\r\n";
}
}
@ -353,8 +353,8 @@ class Broadcast_Server implements MessageComponentInterface
{
$broadcaster_id = array_search($broadcast, $this->broadcasters);
if ($broadcaster_id) {
$clients = $this->listeners[$broadcast->id];
$clients[] = $this->clients[$broadcaster_id];
$clients = $this->listeners[$broadcast->id];
$clients[] = $this->clients[$broadcaster_id];
$nb_listeners = count($this->listeners[$broadcast->id]);
$broadcast->update_listeners($nb_listeners);
$this->broadcastMessage($clients, self::BROADCAST_NB_LISTENERS, $nb_listeners);
@ -433,10 +433,10 @@ class Broadcast_Server implements MessageComponentInterface
{
$websocket_address = AmpConfig::get('websocket_address');
if (empty($websocket_address)) {
$websocket_address = 'ws://' . $_SERVER['HTTP_HOST'] . ':8100';
$websocket_address = 'ws://' . $_SERVER['SERVER_NAME'] . ':8100';
}
return $websocket_address . '/broadcast';
}
} // end of broadcast_server class

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -49,6 +49,7 @@ class Browse extends Query
if (!$id) {
$this->set_use_pages(true);
$this->set_use_alpha(false);
$this->set_grid_view(true);
}
$this->show_header = true;
}
@ -63,7 +64,6 @@ class Browse extends Query
public function set_simple_browse($value)
{
$this->set_is_simple($value);
} // set_simple_browse
/**
@ -78,7 +78,6 @@ class Browse extends Query
$_SESSION['browse']['supplemental'][$this->id][$class] = intval($uid);
return true;
} // add_supplemental_object
/**
@ -97,7 +96,6 @@ class Browse extends Query
}
return $objects;
} // get_supplemental_objects
/**
@ -113,7 +111,6 @@ class Browse extends Query
// Checking if value is suitable
$start = $_SESSION[$name]['start'];
if ($this->get_offset() > 0) {
$set_page = floor($start / $this->get_offset());
if ($this->get_total() > $this->get_offset()) {
$total_pages = ceil($this->get_total() / $this->get_offset());
@ -155,13 +152,15 @@ class Browse extends Query
$this->get_offset(),
true
);
} else if (!count($object_ids)) {
$this->set_total(0);
} else {
if (!count($object_ids)) {
$this->set_total(0);
}
}
// Load any additional object we need for this
$extra_objects = $this->get_supplemental_objects();
$browse = $this;
$browse = $this;
foreach ($extra_objects as $class_name => $id) {
${$class_name} = new $class_name($id);
@ -180,7 +179,7 @@ class Browse extends Query
} elseif ($filter_value = $this->get_filter('catalog')) {
// Get the catalog title
$catalog = Catalog::create_from_id(intval($filter_value));
$match = ' (' . $catalog->name . ')';
$match = ' (' . $catalog->name . ')';
}
$type = $this->get_type();
@ -195,7 +194,7 @@ class Browse extends Query
$argument_param = ($argument ? '&argument=' . scrub_in($argument) : '');
debug_event('browse', 'Show objects called for type {'.$type.'}', '5');
debug_event('browse', 'Show objects called for type {' . $type . '}', '5');
$limit_threshold = $this->get_threshold();
@ -204,7 +203,7 @@ class Browse extends Query
case 'song':
$box_title = T_('Songs') . $match;
Song::build_cache($object_ids, $limit_threshold);
$box_req = AmpConfig::get('prefix') . '/templates/show_songs.inc.php';
$box_req = AmpConfig::get('prefix') . UI::find_template('show_songs.inc.php');
break;
case 'album':
Album::build_cache($object_ids);
@ -217,122 +216,130 @@ class Browse extends Query
} else {
$allow_group_disks = false;
}
$box_req = AmpConfig::get('prefix') . '/templates/show_albums.inc.php';
$box_req = AmpConfig::get('prefix') . UI::find_template('show_albums.inc.php');
break;
case 'user':
$box_title = T_('Users') . $match;
$box_req = AmpConfig::get('prefix') . '/templates/show_users.inc.php';
$box_req = AmpConfig::get('prefix') . UI::find_template('show_users.inc.php');
break;
case 'artist':
$box_title = T_('Artists') . $match;
Artist::build_cache($object_ids, true, $limit_threshold);
$box_req = AmpConfig::get('prefix') . '/templates/show_artists.inc.php';
$box_req = AmpConfig::get('prefix') . UI::find_template('show_artists.inc.php');
break;
case 'live_stream':
require_once AmpConfig::get('prefix') . '/templates/show_live_stream.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_live_stream.inc.php');
$box_title = T_('Radio Stations') . $match;
$box_req = AmpConfig::get('prefix') . '/templates/show_live_streams.inc.php';
$box_req = AmpConfig::get('prefix') . UI::find_template('show_live_streams.inc.php');
break;
case 'playlist':
Playlist::build_cache($object_ids);
$box_title = T_('Playlists') . $match;
$box_req = AmpConfig::get('prefix') . '/templates/show_playlists.inc.php';
$box_req = AmpConfig::get('prefix') . UI::find_template('show_playlists.inc.php');
break;
case 'playlist_song':
$box_title = T_('Playlist Songs') . $match;
$box_req = AmpConfig::get('prefix') . '/templates/show_playlist_songs.inc.php';
case 'playlist_media':
$box_title = T_('Playlist Medias') . $match;
$box_req = AmpConfig::get('prefix') . UI::find_template('show_playlist_medias.inc.php');
break;
case 'playlist_localplay':
$box_title = T_('Current Playlist');
$box_req = AmpConfig::get('prefix') . '/templates/show_localplay_playlist.inc.php';
$box_req = AmpConfig::get('prefix') . UI::find_template('show_localplay_playlist.inc.php');
UI::show_box_bottom();
break;
case 'smartplaylist':
$box_title = T_('Smart Playlists') . $match;
$box_req = AmpConfig::get('prefix') . '/templates/show_searches.inc.php';
$box_req = AmpConfig::get('prefix') . UI::find_template('show_searches.inc.php');
break;
case 'catalog':
$box_title = T_('Catalogs');
$box_req = AmpConfig::get('prefix') . '/templates/show_catalogs.inc.php';
$box_req = AmpConfig::get('prefix') . UI::find_template('show_catalogs.inc.php');
break;
case 'shoutbox':
$box_title = T_('Shoutbox Records');
$box_req = AmpConfig::get('prefix') . '/templates/show_manage_shoutbox.inc.php';
$box_req = AmpConfig::get('prefix') . UI::find_template('show_manage_shoutbox.inc.php');
break;
case 'tag':
Tag::build_cache($object_ids);
$box_title = T_('Tag Cloud');
$box_req = AmpConfig::get('prefix') . '/templates/show_tagcloud.inc.php';
$box_req = AmpConfig::get('prefix') . UI::find_template('show_tagcloud.inc.php');
break;
case 'video':
Video::build_cache($object_ids);
$video_type = 'video';
$box_title = T_('Videos');
$box_req = AmpConfig::get('prefix') . '/templates/show_videos.inc.php';
$box_title = T_('Videos');
$box_req = AmpConfig::get('prefix') . UI::find_template('show_videos.inc.php');
break;
case 'democratic':
$box_title = T_('Democratic Playlist');
$box_req = AmpConfig::get('prefix') . '/templates/show_democratic_playlist.inc.php';
$box_req = AmpConfig::get('prefix') . UI::find_template('show_democratic_playlist.inc.php');
break;
case 'wanted':
$box_title = T_('Wanted Albums');
$box_req = AmpConfig::get('prefix') . '/templates/show_wanted_albums.inc.php';
$box_req = AmpConfig::get('prefix') . UI::find_template('show_wanted_albums.inc.php');
break;
case 'share':
$box_title = T_('Shared Objects');
$box_req = AmpConfig::get('prefix') . '/templates/show_shared_objects.inc.php';
$box_req = AmpConfig::get('prefix') . UI::find_template('show_shared_objects.inc.php');
break;
case 'song_preview':
$box_title = T_('Songs');
$box_req = AmpConfig::get('prefix') . '/templates/show_song_previews.inc.php';
$box_req = AmpConfig::get('prefix') . UI::find_template('show_song_previews.inc.php');
break;
case 'channel':
$box_title = T_('Channels');
$box_req = AmpConfig::get('prefix') . '/templates/show_channels.inc.php';
$box_req = AmpConfig::get('prefix') . UI::find_template('show_channels.inc.php');
break;
case 'broadcast':
$box_title = T_('Broadcasts');
$box_req = AmpConfig::get('prefix') . '/templates/show_broadcasts.inc.php';
$box_req = AmpConfig::get('prefix') . UI::find_template('show_broadcasts.inc.php');
break;
case 'license':
$box_title = T_('Media Licenses');
$box_req = AmpConfig::get('prefix') . '/templates/show_manage_license.inc.php';
$box_req = AmpConfig::get('prefix') . UI::find_template('show_manage_license.inc.php');
break;
case 'tvshow':
$box_title = T_('TV Shows');
$box_req = AmpConfig::get('prefix') . '/templates/show_tvshows.inc.php';
$box_req = AmpConfig::get('prefix') . UI::find_template('show_tvshows.inc.php');
break;
case 'tvshow_season':
$box_title = T_('Seasons');
$box_req = AmpConfig::get('prefix') . '/templates/show_tvshow_seasons.inc.php';
$box_req = AmpConfig::get('prefix') . UI::find_template('show_tvshow_seasons.inc.php');
break;
case 'tvshow_episode':
$box_title = T_('Episodes');
$box_title = T_('Episodes');
$video_type = $type;
$box_req = AmpConfig::get('prefix') . '/templates/show_videos.inc.php';
$box_req = AmpConfig::get('prefix') . UI::find_template('show_videos.inc.php');
break;
case 'movie':
$box_title = T_('Movies');
$box_title = T_('Movies');
$video_type = $type;
$box_req = AmpConfig::get('prefix') . '/templates/show_videos.inc.php';
$box_req = AmpConfig::get('prefix') . UI::find_template('show_videos.inc.php');
break;
case 'clip':
$box_title = T_('Clips');
$box_title = T_('Clips');
$video_type = $type;
$box_req = AmpConfig::get('prefix') . '/templates/show_videos.inc.php';
$box_req = AmpConfig::get('prefix') . UI::find_template('show_videos.inc.php');
break;
case 'personal_video':
$box_title = T_('Personal Videos');
$box_title = T_('Personal Videos');
$video_type = $type;
$box_req = AmpConfig::get('prefix') . '/templates/show_videos.inc.php';
$box_req = AmpConfig::get('prefix') . UI::find_template('show_videos.inc.php');
break;
case 'label':
$box_title = T_('Labels');
$box_req = AmpConfig::get('prefix') . '/templates/show_labels.inc.php';
$box_req = AmpConfig::get('prefix') . UI::find_template('show_labels.inc.php');
break;
case 'pvmsg':
$box_title = T_('Private Messages');
$box_req = AmpConfig::get('prefix') . '/templates/show_pvmsgs.inc.php';
$box_req = AmpConfig::get('prefix') . UI::find_template('show_pvmsgs.inc.php');
break;
case 'podcast':
$box_title = T_('Podcasts');
$box_req = AmpConfig::get('prefix') . UI::find_template('show_podcasts.inc.php');
break;
case 'podcast_episode':
$box_title = T_('Podcast Episodes');
$box_req = AmpConfig::get('prefix') . UI::find_template('show_podcast_episodes.inc.php');
break;
default:
// Rien a faire
@ -363,17 +370,16 @@ class Browse extends Query
}
}
Ajax::end_container();
} // show_object
public function show_next_link($argument = null)
{
$limit = $this->get_offset();
$start = $this->get_start();
$total = $this->get_total();
$limit = $this->get_offset();
$start = $this->get_start();
$total = $this->get_total();
$next_offset = $start + $limit;
if ($next_offset <= $total) {
echo '<a class="jscroll-next" href="' . AmpConfig::get('ajax_url') . '?page=browse&action=page&browse_id=' . $this->id . '&start=' . $next_offset . '&xoutput=raw&xoutputnode='. $this->get_content_div() . '&show_header=false' . $argument . '">' . T_('More') . '</a>';
echo '<a class="jscroll-next" href="' . AmpConfig::get('ajax_url') . '?page=browse&action=page&browse_id=' . $this->id . '&start=' . $next_offset . '&xoutput=raw&xoutputnode=' . $this->get_content_div() . '&show_header=false' . $argument . '">' . T_('More') . '</a>';
}
}
@ -387,7 +393,7 @@ class Browse extends Query
foreach ($request as $key => $value) {
//reinterpret v as a list of int
$list = explode(',', $value);
$ok = true;
$ok = true;
foreach ($list as $item) {
if (!is_numeric($item)) {
$ok = false;
@ -426,6 +432,10 @@ class Browse extends Query
$this->set_filter('regex_not_match', '');
}
}
$cn = 'browse_' . $type . '_grid_view';
if (isset($_COOKIE[$cn])) {
$this->set_grid_view($_COOKIE[$cn] == 'true');
}
parent::set_type($type, $custom_base);
}
@ -461,6 +471,25 @@ class Browse extends Query
return $this->_state['use_pages'];
}
/**
*
* @param boolean $grid_view
*/
public function set_grid_view($grid_view)
{
$this->save_cookie_params('grid_view', $grid_view ? 'true' : 'false');
$this->_state['grid_view'] = $grid_view;
}
/**
*
* @return boolean
*/
public function get_grid_view()
{
return $this->_state['grid_view'];
}
/**
*
* @param boolean $use_alpha
@ -534,4 +563,17 @@ class Browse extends Query
return $this->_state['threshold'];
}
/**
*
* @return string
*/
public function get_css_class()
{
$css = '';
if (!$this->_state['grid_view']) {
$css = 'disablegv';
}
return $css;
}
} // browse

File diff suppressed because it is too large Load diff

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -40,7 +40,7 @@ class Channel extends database_object implements media, library_item
public $description;
public $header_chunk;
public $chunk_size = 4096;
public $chunk_size = 4096;
private $header_chunk_remainder = 0;
public $tags;
@ -59,7 +59,9 @@ class Channel extends database_object implements media, library_item
*/
public function __construct($id=0)
{
if (!$id) { return true; }
if (!$id) {
return true;
}
/* Get the information from the db */
$info = $this->get_info($id);
@ -78,15 +80,15 @@ class Channel extends database_object implements media, library_item
Dba::write($sql, array($start_date, $address, $port, $pid, $this->id));
$this->start_date = $start_date;
$this->interface = $address;
$this->port = $port;
$this->pid = $pid;
$this->interface = $address;
$this->port = $port;
$this->pid = $pid;
}
public function update_listeners($listeners, $addition=false)
{
$sql = "UPDATE `channel` SET `listeners` = ? ";
$params = array($listeners);
$sql = "UPDATE `channel` SET `listeners` = ? ";
$params = array($listeners);
$this->listeners = $listeners;
if ($listeners > $this->peak_listeners) {
$this->peak_listeners = $listeners;
@ -103,7 +105,7 @@ class Channel extends database_object implements media, library_item
public function get_genre()
{
$tags = Tag::get_object_tags('channel', $this->id);
$tags = Tag::get_object_tags('channel', $this->id);
$genre = "";
if ($tags) {
foreach ($tags as $tag) {
@ -123,8 +125,8 @@ class Channel extends database_object implements media, library_item
public static function get_next_port()
{
$port = 8200;
$sql = "SELECT MAX(`port`) AS `max_port` FROM `channel`";
$port = 8200;
$sql = "SELECT MAX(`port`) AS `max_port` FROM `channel`";
$db_results = Dba::read($sql);
if ($results = Dba::fetch_assoc($db_results)) {
@ -139,7 +141,7 @@ class Channel extends database_object implements media, library_item
public static function create($name, $description, $url, $object_type, $object_id, $interface, $port, $admin_password, $private, $max_listeners, $random, $loop, $stream_type, $bitrate)
{
if (!empty($name)) {
$sql = "INSERT INTO `channel` (`name`, `description`, `url`, `object_type`, `object_id`, `interface`, `port`, `fixed_endpoint`, `admin_password`, `is_private`, `max_listeners`, `random`, `loop`, `stream_type`, `bitrate`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$sql = "INSERT INTO `channel` (`name`, `description`, `url`, `object_type`, `object_id`, `interface`, `port`, `fixed_endpoint`, `admin_password`, `is_private`, `max_listeners`, `random`, `loop`, `stream_type`, `bitrate`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$params = array($name, $description, $url, $object_type, $object_id, $interface, $port, (!empty($interface) && !empty($port)), $admin_password, !empty($private), $max_listeners, $random, $loop, $stream_type, $bitrate);
return Dba::write($sql, $params);
}
@ -182,7 +184,7 @@ class Channel extends database_object implements media, library_item
echo Ajax::button('?page=index&action=start_channel&id=' . $this->id,'run', T_('Start Channel'),'channel_start_' . $this->id);
echo " " . Ajax::button('?page=index&action=stop_channel&id=' . $this->id,'stop', T_('Stop Channel'),'channel_stop_' . $this->id);
echo " <a id=\"edit_channel_ " . $this->id . "\" onclick=\"showEditDialog('channel_row', '" . $this->id . "', 'edit_channel_" . $this->id . "', '" . T_('Channel edit') . "', 'channel_row_', 'refresh_channel')\">" . UI::get_icon('edit', T_('Edit')) . "</a>";
echo " <a href=\"" . AmpConfig::get('web_path') . "/channel.php?action=show_delete&id=" . $this->id ."\">" . UI::get_icon('delete', T_('Delete')) . "</a>";
echo " <a href=\"" . AmpConfig::get('web_path') . "/channel.php?action=show_delete&id=" . $this->id . "\">" . UI::get_icon('delete', T_('Delete')) . "</a>";
}
}
}
@ -190,7 +192,7 @@ class Channel extends database_object implements media, library_item
public function format($details = true)
{
if ($details) {
$this->tags = Tag::get_top_tags('channel', $this->id);
$this->tags = Tag::get_top_tags('channel', $this->id);
$this->f_tags = Tag::get_display($this->tags, true, 'channel');
}
}
@ -284,9 +286,9 @@ class Channel extends database_object implements media, library_item
public static function get_channel_list()
{
$sql = self::get_channel_list_sql();
$sql = self::get_channel_list_sql();
$db_results = Dba::read($sql);
$results = array();
$results = array();
while ($row = Dba::fetch_assoc($db_results)) {
$results[] = $row['id'];
@ -343,7 +345,7 @@ class Channel extends database_object implements media, library_item
protected function init_channel_songs()
{
$this->song_pos = 0;
$this->songs = array();
$this->songs = array();
$this->playlist = $this->get_target_object();
if ($this->playlist) {
if (!$this->random) {
@ -365,7 +367,7 @@ class Channel extends database_object implements media, library_item
// Move to next song
while ($this->media == null && ($this->random || $this->song_pos < count($this->songs))) {
if ($this->random) {
$randsongs = $this->playlist->get_random_items(1);
$randsongs = $this->playlist->get_random_items(1);
$this->media = new Song($randsongs[0]['object_id']);
} else {
$this->media = new Song($this->songs[$this->song_pos]);
@ -418,13 +420,14 @@ class Channel extends database_object implements media, library_item
$options = array(
'bitrate' => $this->bitrate
);
$this->transcoder = Stream::start_transcode($this->media, $this->stream_type, null, $options);
$this->transcoder = Stream::start_transcode($this->media, $this->stream_type, null, $options);
$this->media_bytes_streamed = 0;
}
if (is_resource($this->transcoder['handle'])) {
if (ftell($this->transcoder['handle']) == 0)
if (ftell($this->transcoder['handle']) == 0) {
$this->header_chunk = '';
}
$chunk = fread($this->transcoder['handle'], $this->chunk_size);
$this->media_bytes_streamed += strlen($chunk);
@ -435,16 +438,16 @@ class Channel extends database_object implements media, library_item
if ($this->header_chunk_remainder) {
$this->header_chunk .= substr($clchunk, 0, $this->header_chunk_remainder);
if (strlen($clchunk) >= $this->header_chunk_remainder) {
$clchunk = substr($clchunk, $this->header_chunk_remainder);
$clchunk = substr($clchunk, $this->header_chunk_remainder);
$this->header_chunk_remainder = 0;
} else {
$this->header_chunk_remainder = $this->header_chunk_remainder - strlen($clchunk);
$clchunk = '';
$clchunk = '';
}
}
// see bin/channel_run.inc for explanation what's happening here
while ($this->strtohex(substr($clchunk, 0, 4)) == "4F676753") {
$hex = $this->strtohex(substr($clchunk, 0, 27));
$hex = $this->strtohex(substr($clchunk, 0, 27));
$ogg_nr_of_segments = hexdec(substr($hex, 26*2, 2));
if ((substr($clchunk, 27 + $ogg_nr_of_segments + 1, 6) == "vorbis") || (substr($clchunk, 27 + $ogg_nr_of_segments, 4) == "Opus")) {
$hex .= $this->strtohex(substr($clchunk, 27, $ogg_nr_of_segments));
@ -453,11 +456,13 @@ class Channel extends database_object implements media, library_item
$ogg_sum_segm_laces += hexdec(substr($hex, 27*2 + $segm*2, 2));
}
$this->header_chunk .= substr($clchunk, 0, 27 + $ogg_nr_of_segments + $ogg_sum_segm_laces);
if (strlen($clchunk) < (27 + $ogg_nr_of_segments + $ogg_sum_segm_laces))
if (strlen($clchunk) < (27 + $ogg_nr_of_segments + $ogg_sum_segm_laces)) {
$this->header_chunk_remainder = (int) (27 + $ogg_nr_of_segments + $ogg_sum_segm_laces - strlen($clchunk));
}
$clchunk = substr($clchunk, 27 + $ogg_nr_of_segments + $ogg_sum_segm_laces);
} else //no more interesting headers
} else { //no more interesting headers
$clchunk = '';
}
}
}
//debug_event('channel', 'File handle pointer: ' . ftell($this->transcoder['handle']) ,'5');
@ -474,11 +479,11 @@ class Channel extends database_object implements media, library_item
fclose($this->transcoder['handle']);
Stream::kill_process($this->transcoder);
$this->media = null;
$this->media = null;
$this->transcoder = null;
}
} else {
$this->media = null;
$this->media = null;
$this->transcoder = null;
}
@ -531,15 +536,15 @@ class Channel extends database_object implements media, library_item
public static function gc()
{
}
private function strtohex($x)
{
$s='';
foreach(str_split($x) as $c) $s.=sprintf("%02X",ord($c));
foreach (str_split($x) as $c) {
$s.=sprintf("%02X",ord($c));
}
return($s);
}
} // end of channel class

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -44,7 +44,6 @@ class Clip extends Video
}
return true;
} // Constructor
/**
@ -70,7 +69,6 @@ class Clip extends Video
Dba::write($sql, array($data['id'], $data['artist'], $data['song']));
return $data['id'];
} // create
/**
@ -83,7 +81,6 @@ class Clip extends Video
Dba::write($sql, array($data['artist'], $data['song'], $this->id));
return $this->id;
} // update
/**
@ -110,7 +107,6 @@ class Clip extends Video
}
return true;
} //format
/**
@ -137,5 +133,5 @@ class Clip extends Video
return null;
}
} // Clip class

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -36,7 +36,6 @@ class Core
private function __construct()
{
return false;
} // construction
/**
@ -48,41 +47,81 @@ class Core
*/
public static function autoload($class)
{
$possiblePaths = array();
if (strpos($class, '\\') === false) {
$file = AmpConfig::get('prefix') . '/lib/class/' .
strtolower($class) . '.class.php';
$possiblePaths = self::getNonNamespacedPaths($class);
} else {
$possiblePaths = self::getNamespacedPaths($class);
}
if (Core::is_readable($file)) {
require_once $file;
// Call _auto_init if it exists
$autocall = array($class, '_auto_init');
if (is_callable($autocall)) {
call_user_func($autocall);
}
foreach ($possiblePaths as $path) {
if (is_file($path) && Core::is_readable($path)) {
require_once($path);
self::executeAutoCall($class);
} else {
debug_event('autoload', "'$class' not found!", 1);
}
} else {
// Class with namespace are not used by Ampache but probably by modules
$split = explode('\\', $class);
$path = AmpConfig::get('prefix') . '/modules';
for ($i = 0; $i < count($split); ++$i) {
$path .= '/' . $split[$i];
if ($i != count($split)-1) {
if (!is_dir($path)) {
break;
}
} else {
$path .= '.php';
if (Core::is_readable($path)) {
require_once $path;
}
}
}
}
}
/**
* Execute _auto_init if availlable
* @param string $class
*/
private static function executeAutoCall($class)
{
$autocall = array($class, '_auto_init');
if (is_callable($autocall)) {
call_user_func($autocall);
}
}
/**
* Place a new key on a specific position in array
* @param array $array
* @param integer $position
* @param array $add
* @return array
*/
private static function insertInArray(array $array, $position, array $add)
{
return array_slice($array, 0, $position, true) +
$add +
array_slice($array, $position, null, true);
}
/**
* Get possible filepaths of namespaced classes
* @param string $class
* @return string
*/
private static function getNamespacedPaths($class)
{
$possiblePaths = array();
$namespaceParts = explode('\\', $class);
$possiblePaths[] = AmpConfig::get('prefix') . '/modules/' . implode('/', $namespaceParts) . '.php';
$classedPath = array('path' => AmpConfig::get('prefix')) +
self::insertInArray($namespaceParts, 1, array('add' => 'class'));
$possiblePaths[] = implode('/', $classedPath) . '.php';
return $possiblePaths;
}
/**
* Get possible filepaths of non namespaced classes
* @param string $class
* @return string
*/
private static function getNonNamespacedPaths($class)
{
$possiblePaths = array();
$possiblePaths[] = AmpConfig::get('prefix') . '/lib/class/' .
strtolower($class) . '.class.php';
return $possiblePaths;
}
/**
* form_register
* This registers a form with a SID, inserts it into the session
@ -91,7 +130,7 @@ class Core
public static function form_register($name, $type = 'post')
{
// Make ourselves a nice little sid
$sid = md5(uniqid(rand(), true));
$sid = md5(uniqid(rand(), true));
$window = AmpConfig::get('session_length');
$expire = time() + $window;
@ -110,7 +149,6 @@ class Core
} // end switch on type
return $string;
} // form_register
/**
@ -160,7 +198,6 @@ class Core
// OMG HAX0RZ
debug_event('Core', "$type form $sid failed consistency check, rejecting request", 2);
return false;
} // form_verify
/**
@ -171,19 +208,24 @@ class Core
*/
public static function image_dimensions($image_data)
{
if (!function_exists('ImageCreateFromString')) { return false; }
if (!function_exists('ImageCreateFromString')) {
return false;
}
$image = ImageCreateFromString($image_data);
if (!$image) { return false; }
if (!$image) {
return false;
}
$width = imagesx($image);
$width = imagesx($image);
$height = imagesy($image);
if (!$width || !$height) { return false; }
if (!$width || !$height) {
return false;
}
return array('width'=>$width,'height'=>$height);
} // image_dimensions
/*
@ -224,7 +266,7 @@ class Core
return false;
}
$offset = PHP_INT_MAX - 1;
$size = (float) $offset;
$size = (float) $offset;
if (!fseek($fp, $offset)) {
return false;
}
@ -246,9 +288,9 @@ class Core
*/
public static function conv_lc_file($filename)
{
$lc_filename = $filename;
$lc_filename = $filename;
$site_charset = AmpConfig::get('site_charset');
$lc_charset = AmpConfig::get('lc_charset');
$lc_charset = AmpConfig::get('lc_charset');
if ($lc_charset && $lc_charset != $site_charset) {
if (function_exists('iconv')) {
$lc_filename = iconv($site_charset, $lc_charset, $filename);
@ -312,7 +354,7 @@ class Core
if (!isset($options['proxy'])) {
if (AmpConfig::get('proxy_host') && AmpConfig::get('proxy_port')) {
$proxy = array();
$proxy = array();
$proxy[] = AmpConfig::get('proxy_host') . ':' . AmpConfig::get('proxy_port');
if (AmpConfig::get('proxy_user')) {
$proxy[] = AmpConfig::get('proxy_user');
@ -326,3 +368,4 @@ class Core
return $options;
}
} // Core

View file

@ -1,23 +1,23 @@
<?php
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; version 2
* of the License.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -26,11 +26,47 @@
*
* This class wrap Ampache to DAAP API functions. See https://github.com/andytinycat/daapdocs/blob/master/daapdocs.txt
* These are all static calls.
*
*/
class Daap_Api
{
const AMPACHEID_SMARTPL = 400000000;
const BASE_LIBRARY = 0;
public static $metas = array(
'dmap.itemid',
'dmap.itemname',
'dmap.itemkind',
'dmap.persistentid',
'daap.songalbum',
'daap.songartist',
'daap.songbitrate',
'daap.songbeatsperminute',
'daap.songcomment',
'daap.songcompilation',
'daap.songcomposer',
'daap.songdateadded',
'daap.songdatemodified',
'daap.songdisccount',
'daap.songdiscnumber',
'daap.songdisabled',
'daap.songeqpreset',
'daap.songformat',
'daap.songgenre',
'daap.songdescription',
'daap.songrelativevolume',
'daap.songsamplerate',
'daap.songsize',
'daap.songstarttime',
'daap.songstoptime',
'daap.songtime',
'daap.songtrackcount',
'daap.songtracknumber',
'daap.songuserrating',
'daap.songyear',
'daap.songdatakind',
'daap.songdataurl',
'com.apple.itunes.norm-volume'
);
public static $tags = array();
@ -48,8 +84,8 @@ class Daap_Api
ob_end_clean();
if (function_exists('curl_version')) {
$headers = apache_request_headers();
$reqheaders = array();
$headers = apache_request_headers();
$reqheaders = array();
$reqheaders[] = "User-Agent: " . $headers['User-Agent'];
if (isset($headers['Range'])) {
$reqheaders[] = "Range: " . $headers['Range'];
@ -61,8 +97,14 @@ class Daap_Api
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => false,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_WRITEFUNCTION => array('Daap_Api', 'output_body'),
CURLOPT_HEADERFUNCTION => array('Daap_Api', 'output_header'),
CURLOPT_WRITEFUNCTION => array(
'Daap_Api',
'output_body'
),
CURLOPT_HEADERFUNCTION => array(
'Daap_Api',
'output_header'
),
// Ignore invalid certificate
// Default trusted chain is crap anyway and currently no custom CA option
CURLOPT_SSL_VERIFYPEER => false,
@ -88,8 +130,8 @@ class Daap_Api
public static function output_header($ch, $header)
{
$rheader = trim($header);
$rhpart = explode(':', $rheader);
if (!empty($rheader) && count($rhpart) > 1) {
$rhpart = explode(':', $rheader);
if (! empty($rheader) && count($rhpart) > 1) {
if ($rhpart[0] != "Transfer-Encoding") {
header($rheader);
}
@ -99,7 +141,6 @@ class Daap_Api
/**
* server_info
*
*/
public static function server_info($input)
{
@ -115,7 +156,7 @@ class Daap_Api
$o .= self::tlv('dmap.supportsquery', 0);
$o .= self::tlv('dmap.itemname', 'Ampache');
$o .= self::tlv('dmap.supportsbrowse', 0);
$o .= self::tlv('dmap.protocolversion', '0.2.0.0');
$o .= self::tlv('dmap.protocolversion', '0.2.0.0');
$o .= self::tlv('dmap.databasescount', 1);
$o = self::tlv('dmap.serverinforesponse', $o);
@ -124,7 +165,6 @@ class Daap_Api
/**
* content_codes
*
*/
public static function content_codes($input)
{
@ -132,7 +172,7 @@ class Daap_Api
foreach (self::$tags as $name => $tag) {
$entry = self::tlv('dmap.contentcodesname', $name);
$pcode = str_split($tag['code']);
$icode = (ord($pcode[0])<<24) + (ord($pcode[1])<<16) + (ord($pcode[2])<<8) + ord($pcode[3]);
$icode = (ord($pcode[0]) << 24) + (ord($pcode[1]) << 16) + (ord($pcode[2]) << 8) + ord($pcode[3]);
$entry .= self::tlv('dmap.contentcodesnumber', $icode);
$entry .= self::tlv('dmap.contentcodestype', self::get_type_id($tag['type']));
$o .= self::tlv('dmap.dictionary', $entry);
@ -144,7 +184,6 @@ class Daap_Api
/**
* login
*
*/
public static function login($input)
{
@ -152,7 +191,9 @@ class Daap_Api
// Create a new daap session
$sql = "INSERT INTO `daap_session` (`creationdate`) VALUES (?)";
Dba::write($sql, array(time()));
Dba::write($sql, array(
time()
));
$sid = Dba::insert_id();
$o = self::tlv('dmap.status', 200);
@ -166,16 +207,19 @@ class Daap_Api
{
// Purge expired sessions
$sql = "DELETE FROM `daap_session` WHERE `creationdate` < ?";
Dba::write($sql, array(time() - 1800));
Dba::write($sql, array(
time() - 1800
));
self::check_auth($code);
if (!isset($_GET['session-id'])) {
if (! isset($_GET['session-id'])) {
debug_event('daap', 'Missing session id.', '');
} else {
$sql = "SELECT * FROM `daap_session` WHERE `id` = ?";
$db_results = Dba::read($sql, array($_GET['session-id']));
$sql = "SELECT * FROM `daap_session` WHERE `id` = ?";
$db_results = Dba::read($sql, array(
$_GET['session-id']
));
if (Dba::num_rows($db_results) == 0) {
debug_event('daap', 'Unknown session id `' . $_GET['session-id'] . '`.', '4');
@ -186,13 +230,13 @@ class Daap_Api
private static function check_auth($code = '')
{
$authenticated = false;
$pass = AmpConfig::get('daap_pass');
$pass = AmpConfig::get('daap_pass');
// DAAP password specified, need to authenticate the client
if (!empty($pass)) {
if (! empty($pass)) {
$headers = apache_request_headers();
$auth = $headers['Authorization'];
$auth = $headers['Authorization'];
if (strpos(strtolower($auth), 'basic') === 0) {
$decauth = base64_decode(substr($auth, 6));
$decauth = base64_decode(substr($auth, 6));
$userpass = split(':', $decauth);
if (count($userpass) == 2) {
if ($userpass[1] == $pass) {
@ -204,9 +248,9 @@ class Daap_Api
$authenticated = true;
}
if (!$authenticated) {
if (! $authenticated) {
debug_event('daap', 'Authentication failed. Wrong DAAP password?', '5');
if (!empty($code)) {
if (! empty($code)) {
self::createApiError($code, 403);
}
}
@ -214,14 +258,15 @@ class Daap_Api
/**
* logout
*
*/
public static function logout($input)
{
self::check_auth();
$sql = "DELETE FROM `daap_session` WHERE `id` = ?";
Dba::write($sql, array($input['session-id']));
Dba::write($sql, array(
$input['session-id']
));
self::setHeaders();
header("HTTP/1.0 204 Logout Successful", true, 204);
@ -229,7 +274,6 @@ class Daap_Api
/**
* update
*
*/
public static function update($input)
{
@ -242,14 +286,33 @@ class Daap_Api
self::apiOutput($o);
}
private static function catalog_songs()
{
// $type = $_GET['type'];
$meta = explode(',', strtolower($_GET['meta']));
$o = self::tlv('dmap.status', 200);
$o .= self::tlv('dmap.updatetype', 0);
$songs = array();
$catalogs = Catalog::get_catalogs();
foreach ($catalogs as $catalog_id) {
$catalog = Catalog::create_from_id($catalog_id);
$songs = array_merge($songs, $catalog->get_songs());
}
$o .= self::tlv('dmap.specifiedtotalcount', count($songs));
$o .= self::tlv('dmap.returnedcount', count($songs));
$o .= self::tlv('dmap.listing', self::tlv_songs($songs, $meta));
return $o;
}
/**
* update
*
* databases
*/
public static function databases($input)
{
//$revision = $_GET['revision-number'];
// $revision = $_GET['revision-number'];
$o = '';
// Database list
if (count($input) == 0) {
@ -261,6 +324,7 @@ class Daap_Api
$o .= self::tlv('dmap.returnedcount', 1);
$r = self::tlv('dmap.itemid', 1);
$r .= self::tlv('dmap.persistentid', 1);
$r .= self::tlv('dmap.itemname', 'Ampache');
$counts = Catalog::count_medias();
$r .= self::tlv('dmap.itemcount', $counts['songs']);
@ -272,25 +336,10 @@ class Daap_Api
} elseif (count($input) == 2) {
if ($input[1] == 'items') {
// Songs list
self::check_session('daap.playlistsongs');
self::check_session('daap.databasesongs');
//$type = $_GET['type'];
$meta = explode(',', strtolower($_GET['meta']));
$o = self::tlv('dmap.status', 200);
$o .= self::tlv('dmap.updatetype', 0);
$songs = array();
$catalogs = Catalog::get_catalogs();
foreach ($catalogs as $catalog_id) {
$catalog = Catalog::create_from_id($catalog_id);
$songs = array_merge($songs, $catalog->get_songs());
}
$o .= self::tlv('dmap.specifiedtotalcount', count($songs));
$o .= self::tlv('dmap.returnedcount', count($songs));
$o .= self::tlv('dmap.listing', self::tlv_songs($songs, $meta));
$o = self::tlv('daap.playlistsongs', $o);
$o = self::catalog_songs();
$o = self::tlv('daap.databasesongs', $o);
} elseif ($input[1] == 'containers') {
// Playlist list
self::check_session('daap.databaseplaylists');
@ -299,11 +348,11 @@ class Daap_Api
$o .= self::tlv('dmap.updatetype', 0);
$playlists = Playlist::get_playlists();
$searches = Search::get_searches();
$o .= self::tlv('dmap.specifiedtotalcount', count($playlists) + count($searches));
$o .= self::tlv('dmap.returnedcount', count($playlists) + count($searches));
$searches = Search::get_searches();
$o .= self::tlv('dmap.specifiedtotalcount', count($playlists) + count($searches) + 1);
$o .= self::tlv('dmap.returnedcount', count($playlists) + count($searches) + 1);
$l = '';
$l = self::base_library();
foreach ($playlists as $playlist_id) {
$playlist = new Playlist($playlist_id);
$playlist->format();
@ -323,19 +372,19 @@ class Daap_Api
if ($input[1] == 'items') {
$finfo = explode('.', $input[2]);
if (count($finfo) == 2) {
$id = intval($finfo[0]);
$id = intval($finfo[0]);
$type = $finfo[1];
$params = '';
$params = '';
$headers = apache_request_headers();
$client = $headers['User-Agent'];
if (!empty($client)) {
$client = $headers['User-Agent'];
if (! empty($client)) {
$params .= '&client=' . $client;
}
$params .= '&transcode_to=' . $type;
$url = Song::play_url($id, $params, 'api', true);
self::follow_stream($url);
exit;
exit();
}
}
} elseif (count($input) == 4) {
@ -345,38 +394,43 @@ class Daap_Api
self::check_session('daap.playlistsongs');
if ($id > Daap_Api::AMPACHEID_SMARTPL) {
$id -= Daap_Api::AMPACHEID_SMARTPL;
$playlist = new Search($id, 'song');
if ($id == Daap_Api::BASE_LIBRARY) {
$o = self::catalog_songs();
$o = self::tlv('daap.playlistsongs', $o);
} else {
$playlist = new Playlist($id);
}
if ($id > Daap_Api::AMPACHEID_SMARTPL) {
$id -= Daap_Api::AMPACHEID_SMARTPL;
$playlist = new Search($id, 'song');
} else {
$playlist = new Playlist($id);
}
if ($playlist->id) {
$meta = explode(',', strtolower($_GET['meta']));
$o = self::tlv('dmap.status', 200);
$o .= self::tlv('dmap.updatetype', 0);
$items = $playlist->get_items();
$song_ids = array();
foreach ($items as $item) {
if ($item['object_type'] == 'song') {
$song_ids[] = $item['object_id'];
if ($playlist->id) {
$meta = explode(',', strtolower($_GET['meta']));
$o = self::tlv('dmap.status', 200);
$o .= self::tlv('dmap.updatetype', 0);
$items = $playlist->get_items();
$song_ids = array();
foreach ($items as $item) {
if ($item['object_type'] == 'song') {
$song_ids[] = $item['object_id'];
}
}
}
if (AmpConfig::get('memory_cache')) {
Song::build_cache($song_ids);
}
$songs = array();
foreach ($song_ids as $song_id) {
$songs[] = new Song($song_id);
}
$o .= self::tlv('dmap.specifiedtotalcount', count($songs));
$o .= self::tlv('dmap.returnedcount', count($songs));
$o .= self::tlv('dmap.listing', self::tlv_songs($songs, $meta));
if (AmpConfig::get('memory_cache')) {
Song::build_cache($song_ids);
}
$songs = array();
foreach ($song_ids as $song_id) {
$songs[] = new Song($song_id);
}
$o .= self::tlv('dmap.specifiedtotalcount', count($songs));
$o .= self::tlv('dmap.returnedcount', count($songs));
$o .= self::tlv('dmap.listing', self::tlv_songs($songs, $meta));
$o = self::tlv('daap.databaseplaylists', $o);
} else {
self::createApiError('daap.playlistsongs', 500, 'Invalid playlist id: ' . $id);
$o = self::tlv('daap.playlistsongs', $o);
} else {
self::createApiError('daap.playlistsongs', 500, 'Invalid playlist id: ' . $id);
}
}
}
}
@ -386,6 +440,9 @@ class Daap_Api
private static function tlv_songs($songs, $meta)
{
if (array_search('all', $meta) > - 1) {
$meta = self::$metas;
}
$lo = '';
foreach ($songs as $song) {
$song->format();
@ -396,60 +453,61 @@ class Daap_Api
switch ($m) {
case 'dmap.itemname':
$o .= self::tlv($m, $song->f_title);
break;
/*case 'dmap.persistentid':
break;
case 'dmap.containeritemid':
/* case 'dmap.persistentid': */
$o .= self::tlv($m, $song->id);
break;*/
break;
case 'daap.songalbum':
$o .= self::tlv($m, $song->f_album);
break;
break;
case 'daap.songartist':
$o .= self::tlv($m, $song->f_artist);
break;
break;
case 'daap.songbitrate':
$o .= self::tlv($m, intval($song->bitrate / 1000));
break;
break;
case 'daap.songcomment':
$o .= self::tlv($m, $song->comment);
break;
break;
case 'daap.songdateadded':
$o .= self::tlv($m, $song->addition_time);
break;
break;
case 'daap.songdatemodified':
if ($song->update_time) {
$o .= self::tlv($m, $song->update_time);
}
break;
break;
case 'daap.songdiscnumber':
$album = new Album($song->album);
$o .= self::tlv($m, $album->disk);
break;
break;
case 'daap.songformat':
$o .= self::tlv($m, $song->type);
break;
break;
case 'daap.songgenre':
$o .= self::tlv($m, Tag::get_display($song->tags, false, 'song'));
break;
break;
case 'daap.songsamplerate':
$o .= self::tlv($m, $song->rate);
break;
break;
case 'daap.songsize':
$o .= self::tlv($m, $song->size);
break;
break;
case 'daap.songtime':
$o .= self::tlv($m, $song->time * 1000);
break;
break;
case 'daap.songtracknumber':
$o .= self::tlv($m, $song->track);
break;
break;
case 'daap.songuserrating':
$rating = new Rating($song->id, "song");
$rating = new Rating($song->id, "song");
$rating_value = $rating->get_average_rating();
$o .= self::tlv($m, $rating_value);
break;
break;
case 'daap.songyear':
$o .= self::tlv($m, $song->year);
break;
break;
}
}
$lo .= self::tlv('dmap.listingitem', $o);
@ -458,13 +516,26 @@ class Daap_Api
return $lo;
}
public static function base_library()
{
$p = self::tlv('dmap.itemid', Daap_Api::BASE_LIBRARY);
$p .= self::tlv('dmap.persistentid', Daap_Api::BASE_LIBRARY);
$p .= self::tlv('dmap.itemname', 'Music');
$p .= self::tlv('daap.baseplaylist', 1);
$stats = Catalog::count_medias();
$p .= self::tlv('dmap.itemcount', $stats['songs']);
return self::tlv('dmap.listingitem', $p);
}
public static function tlv_playlist($playlist)
{
$isSmart = false;
if (strtolower(get_class($playlist)) == 'search') {
$isSmart = true;
}
$p = self::tlv('dmap.itemid', (($isSmart) ? Daap_Api::AMPACHEID_SMARTPL : 0) + $playlist->id);
$id = (($isSmart) ? Daap_Api::AMPACHEID_SMARTPL : 0) + $playlist->id;
$p = self::tlv('dmap.itemid', $id);
$p .= self::tlv('dmap.persistentid', $id);
$p .= self::tlv('dmap.itemname', $playlist->f_name);
$p .= self::tlv('dmap.itemcount', count($playlist->get_items()));
if ($isSmart) {
@ -516,32 +587,32 @@ class Daap_Api
// Really?! PHP...
// Need to split value into two 32-bit integer because php pack function doesn't support 64-bit integer...
$highMap = 0xffffffff00000000;
$lowMap = 0x00000000ffffffff;
$higher = ($value & $highMap) >>32;
$lower = $value & $lowMap;
return $tag . "\0\0\0\8" . pack("NN", $higher, $lower);
$lowMap = 0x00000000ffffffff;
$higher = ($value & $highMap) >> 32;
$lower = $value & $lowMap;
return $tag . "\x00\x00\x00\x08" . pack("NN", $higher, $lower);
}
private static function tlv_int($tag, $value)
{
return $tag . "\0\0\0\4" . pack("N", $value);
return $tag . "\x00\x00\x00\x04" . pack("N", $value);
}
private static function tlv_short($tag, $value)
{
return $tag . "\0\0\0\2" . pack("n", $value);
return $tag . "\x00\x00\x00\x02" . pack("n", $value);
}
private static function tlv_byte($tag, $value)
{
return $tag . "\0\0\0\1" . pack("C", $value);
return $tag . "\x00\x00\x00\x01" . pack("C", $value);
}
private static function tlv_version($tag, $value)
{
$v = explode('.', $value);
if (count($v) == 4) {
return $tag . "\0\0\0\4" . pack("C", $v[0]) . pack("C", $v[1]) . pack("C", $v[2]) . pack("C", $v[3]);
return $tag . "\x00\x00\x00\x04" . pack("C", $v[0]) . pack("C", $v[1]) . pack("C", $v[2]) . pack("C", $v[3]);
} else {
debug_event('daap', 'Malformed `' . $tag . '` version `' . $value . '`.', '5');
}
@ -561,25 +632,25 @@ class Daap_Api
public static function create_dictionary()
{
self::add_dict('mdcl', 'list', 'dmap.dictionary'); // a dictionary entry
self::add_dict('mstt', 'int', 'dmap.status'); // the response status code, these appear to be http status codes
self::add_dict('miid', 'int', 'dmap.itemid'); // an item's id
self::add_dict('minm', 'string', 'dmap.itemname'); // an items name
self::add_dict('mikd', 'byte', 'dmap.itemkind'); // the kind of item. So far, only '2' has been seen, an audio file?
self::add_dict('mper', 'long', 'dmap.persistentid'); // a persistent id
self::add_dict('mcon', 'list', 'dmap.container'); // an arbitrary container
self::add_dict('mcti', 'int', 'dmap.containeritemid'); // the id of an item in its container
self::add_dict('mdcl', 'list', 'dmap.dictionary'); // a dictionary entry
self::add_dict('mstt', 'int', 'dmap.status'); // the response status code, these appear to be http status codes
self::add_dict('miid', 'int', 'dmap.itemid'); // an item's id
self::add_dict('minm', 'string', 'dmap.itemname'); // an items name
self::add_dict('mikd', 'byte', 'dmap.itemkind'); // the kind of item. So far, only '2' has been seen, an audio file?
self::add_dict('mper', 'long', 'dmap.persistentid'); // a persistent id
self::add_dict('mcon', 'list', 'dmap.container'); // an arbitrary container
self::add_dict('mcti', 'int', 'dmap.containeritemid'); // the id of an item in its container
self::add_dict('mpco', 'int', 'dmap.parentcontainerid');
self::add_dict('msts', 'string', 'dmap.statusstring');
self::add_dict('mimc', 'int', 'dmap.itemcount'); // number of items in a container
self::add_dict('mrco', 'int', 'dmap.returnedcount'); // number of items returned in a request
self::add_dict('mtco', 'int', 'dmap.specifiedtotalcount'); // number of items in response to a request
self::add_dict('mimc', 'int', 'dmap.itemcount'); // number of items in a container
self::add_dict('mrco', 'int', 'dmap.returnedcount'); // number of items returned in a request
self::add_dict('mtco', 'int', 'dmap.specifiedtotalcount'); // number of items in response to a request
self::add_dict('mctc', 'int', 'dmap.containercount');
self::add_dict('mlcl', 'list', 'dmap.listing'); // a list
self::add_dict('mlit', 'list', 'dmap.listingitem'); // a single item in said list
self::add_dict('mlcl', 'list', 'dmap.listing'); // a list
self::add_dict('mlit', 'list', 'dmap.listingitem'); // a single item in said list
self::add_dict('mbcl', 'list', 'dmap.bag');
self::add_dict('mdcl', 'list', 'dmap.dictionary');
self::add_dict('msrv', 'list', 'dmap.serverinforesponse'); // response to a /server-info
self::add_dict('msrv', 'list', 'dmap.serverinforesponse'); // response to a /server-info
self::add_dict('msau', 'byte', 'dmap.authenticationmethod');
self::add_dict('mslr', 'byte', 'dmap.loginrequired');
self::add_dict('mpro', 'version', 'dmap.protocolversion');
@ -594,23 +665,23 @@ class Daap_Api
self::add_dict('msrs', 'byte', 'dmap.supportsresolve');
self::add_dict('mstm', 'int', 'dmap.timeoutinterval');
self::add_dict('msdc', 'int', 'dmap.databasescount');
self::add_dict('mccr', 'list', 'dmap.contentcodesresponse'); // response to a /content-codes
self::add_dict('mcnm', 'int', 'dmap.contentcodesnumber'); // the four letter code
self::add_dict('mcna', 'string', 'dmap.contentcodesname'); // the full name of the code
self::add_dict('mcty', 'short', 'dmap.contentcodestype'); // the type of the code
self::add_dict('mlog', 'list', 'dmap.loginresponse'); // response to a /login
self::add_dict('mlid', 'int', 'dmap.sessionid'); // the session id for the login session
self::add_dict('mupd', 'list', 'dmap.updateresponse'); // response to a /update
self::add_dict('musr', 'int', 'dmap.serverrevision'); // revision to use for requests
self::add_dict('mccr', 'list', 'dmap.contentcodesresponse'); // response to a /content-codes
self::add_dict('mcnm', 'int', 'dmap.contentcodesnumber'); // the four letter code
self::add_dict('mcna', 'string', 'dmap.contentcodesname'); // the full name of the code
self::add_dict('mcty', 'short', 'dmap.contentcodestype'); // the type of the code
self::add_dict('mlog', 'list', 'dmap.loginresponse'); // response to a /login
self::add_dict('mlid', 'int', 'dmap.sessionid'); // the session id for the login session
self::add_dict('mupd', 'list', 'dmap.updateresponse'); // response to a /update
self::add_dict('musr', 'int', 'dmap.serverrevision'); // revision to use for requests
self::add_dict('muty', 'byte', 'dmap.updatetype');
self::add_dict('mudl', 'list', 'dmap.deletedidlisting'); // used in updates?
self::add_dict('avdb', 'list', 'daap.serverdatabases'); // response to a /databases
self::add_dict('mudl', 'list', 'dmap.deletedidlisting'); // used in updates?
self::add_dict('avdb', 'list', 'daap.serverdatabases'); // response to a /databases
self::add_dict('abpro', 'list', 'daap.databasebrowse');
self::add_dict('abal', 'list', 'daap.browsealbumlisting');
self::add_dict('abar', 'list', 'daap.browseartistlisting');
self::add_dict('abcp', 'list', 'daap.browsecomposerlisting');
self::add_dict('abgn', 'list', 'daap.browsegenrelisting');
self::add_dict('adbs', 'list', 'daap.databasesongs'); // response to a /databases/id/items
self::add_dict('adbs', 'list', 'daap.databasesongs'); // response to a /databases/id/items
self::add_dict('asal', 'string', 'daap.songalbum');
self::add_dict('asar', 'string', 'daap.songartist');
self::add_dict('asbt', 'short', 'daap.songsbeatsperminute');
@ -629,18 +700,18 @@ class Daap_Api
self::add_dict('asrv', 'byte', 'daap.songrelativevolume');
self::add_dict('assr', 'int', 'daap.songsamplerate');
self::add_dict('assz', 'int', 'daap.songsize');
self::add_dict('asst', 'int', 'daap.songstarttime'); // in milliseconds
self::add_dict('assp', 'int', 'daap.songstoptime'); // in milliseconds
self::add_dict('astm', 'int', 'daap.songtime'); // in milliseconds
self::add_dict('asst', 'int', 'daap.songstarttime'); // in milliseconds
self::add_dict('assp', 'int', 'daap.songstoptime'); // in milliseconds
self::add_dict('astm', 'int', 'daap.songtime'); // in milliseconds
self::add_dict('astc', 'short', 'daap.songtrackcount');
self::add_dict('astn', 'short', 'daap.songtracknumber');
self::add_dict('asur', 'byte', 'daap.songuserrating');
self::add_dict('asyr', 'short', 'daap.songyear');
self::add_dict('asdk', 'byte', 'daap.songdatakind');
self::add_dict('asul', 'string', 'daap.songdataurl');
self::add_dict('aply', 'list', 'daap.databaseplaylists'); // response to a /databases/id/containers
self::add_dict('aply', 'list', 'daap.databaseplaylists'); // response to a /databases/id/containers
self::add_dict('abpl', 'byte', 'daap.baseplaylist');
self::add_dict('apso', 'list', 'daap.playlistsongs'); // response to a /databases/id/containers/id/items
self::add_dict('apso', 'list', 'daap.playlistsongs'); // response to a /databases/id/containers/id/items
self::add_dict('prsv', 'list', 'daap.resolve');
self::add_dict('arif', 'list', 'daap.resolveinfo');
self::add_dict('aeNV', 'int', 'com.apple.itunes.norm-volume');
@ -649,7 +720,8 @@ class Daap_Api
private static function add_dict($code, $type, $name)
{
self::$tags[$name] = array('type' => $type,
self::$tags[$name] = array(
'type' => $type,
'code' => $code
);
}
@ -675,7 +747,7 @@ class Daap_Api
return 8;
case 'string':
return 9;
case 'date': // represented as a 4 byte integer
case 'date': // represented as a 4 byte integer
return 10;
case 'version': // represented as a 4 singles bytes, e.g. 0.1.0.0 or as two shorts, e.g. 1.0
return 11;
@ -721,17 +793,17 @@ class Daap_Api
break;
}
header("Content-type: text/html", true);
header("HTTP/1.0 ". $code . " " . $error, true, $code);
header("HTTP/1.0 " . $code . " " . $error, true, $code);
$html = "<html><head><title>" . $error . "</title></head><body><h1>" . $code . " " . $error . "</h1></body></html>";
self::apiOutput($html);
exit();
}
public static function createApiError($tag, $code, $msg='')
public static function createApiError($tag, $code, $msg = '')
{
$o = self::tlv('dmap.status', $code);
if (!empty($msg)) {
if (! empty($msg)) {
$o .= self::tlv('dmap.statusstring', $msg);
}
$o = self::tlv($tag, $o);

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -45,23 +45,26 @@ abstract class database_object
$table_name = $table_name ? Dba::escape($table_name) : Dba::escape(strtolower(get_class($this)));
// Make sure we've got a real id
if (!is_numeric($id)) { return array(); }
if (!is_numeric($id)) {
return array();
}
if (self::is_cached($table_name,$id)) {
return self::get_from_cache($table_name,$id);
}
$sql = "SELECT * FROM `$table_name` WHERE `id`='$id'";
$sql = "SELECT * FROM `$table_name` WHERE `id`='$id'";
$db_results = Dba::read($sql);
if (!$db_results) { return array(); }
if (!$db_results) {
return array();
}
$row = Dba::fetch_assoc($db_results);
self::add_to_cache($table_name,$id,$row);
return $row;
} // get_info
/**
@ -79,10 +82,11 @@ abstract class database_object
public static function is_cached($index, $id)
{
// Make sure we've got some parents here before we dive below
if (!isset(self::$object_cache[$index])) { return false; }
if (!isset(self::$object_cache[$index])) {
return false;
}
return isset(self::$object_cache[$index][$id]);
} // is_cached
/**
@ -98,7 +102,6 @@ abstract class database_object
}
return false;
} // get_from_cache
/**
@ -107,11 +110,12 @@ abstract class database_object
*/
public static function add_to_cache($index, $id, $data)
{
if (!self::$_enabled) { return false; }
if (!self::$_enabled) {
return false;
}
$value = is_null($data) ? false : $data;
$value = is_null($data) ? false : $data;
self::$object_cache[$index][$id] = $value;
} // add_to_cache
/**
@ -124,7 +128,6 @@ abstract class database_object
if (isset(self::$object_cache[$index]) && isset(self::$object_cache[$index][$id])) {
unset(self::$object_cache[$index][$id]);
}
} // remove_from_cache
/**
@ -134,7 +137,6 @@ abstract class database_object
public static function _auto_init()
{
self::$_enabled = AmpConfig::get('memory_cache');
} // _auto_init
} // end database_object

View file

@ -2,26 +2,28 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* Make sure they aren't directly accessing it */
if (!defined('INIT_LOADED') || INIT_LOADED != '1') { exit; }
if (!defined('INIT_LOADED') || INIT_LOADED != '1') {
exit;
}
/**
* Dba Class
@ -48,7 +50,6 @@ class Dba
private function __construct()
{
// Rien a faire
} // construct
/**
@ -93,12 +94,14 @@ class Dba
self::$_error = json_encode($dbh->errorInfo());
debug_event('Dba', 'Error: ' . json_encode($dbh->errorInfo()), 1);
self::disconnect();
} else if ($stmt->errorCode() && $stmt->errorCode() != '00000') {
self::$_error = json_encode($stmt->errorInfo());
debug_event('Dba', 'Error: ' . json_encode($stmt->errorInfo()), 1);
self::finish($stmt);
self::disconnect();
return false;
} else {
if ($stmt->errorCode() && $stmt->errorCode() != '00000') {
self::$_error = json_encode($stmt->errorInfo());
debug_event('Dba', 'Error: ' . json_encode($stmt->errorInfo()), 1);
self::finish($stmt);
self::disconnect();
return false;
}
}
return $stmt;
@ -185,6 +188,24 @@ class Dba
return $result;
}
public static function fetch_object($resource, $class = 'stdClass', $finish = true)
{
if (!$resource) {
return array();
}
$result = $resource->fetchObject($class);
if (!$result) {
if ($finish) {
self::finish($resource);
}
return array();
}
return $result;
}
/**
* num_rows
*
@ -243,7 +264,7 @@ class Dba
$username = AmpConfig::get('database_username');
$hostname = AmpConfig::get('database_hostname');
$password = AmpConfig::get('database_password');
$port = AmpConfig::get('database_port');
$port = AmpConfig::get('database_port');
// Build the data source name
if (strpos($hostname, '/') === 0) {
@ -318,7 +339,7 @@ class Dba
*/
public static function check_database_inserted()
{
$sql = "DESCRIBE session";
$sql = "DESCRIBE session";
$db_results = Dba::read($sql);
if (!$db_results) {
@ -428,39 +449,39 @@ class Dba
switch (strtoupper($charset)) {
case 'CP1250':
case 'WINDOWS-1250':
$target_charset = 'cp1250';
$target_charset = 'cp1250';
$target_collation = 'cp1250_general_ci';
break;
case 'ISO-8859':
case 'ISO-8859-2':
$target_charset = 'latin2';
$target_charset = 'latin2';
$target_collation = 'latin2_general_ci';
break;
case 'ISO-8859-1':
case 'CP1252':
case 'WINDOWS-1252':
$target_charset = 'latin1';
$target_charset = 'latin1';
$target_collation = 'latin1_general_ci';
break;
case 'EUC-KR':
$target_charset = 'euckr';
$target_charset = 'euckr';
$target_collation = 'euckr_korean_ci';
break;
case 'CP932':
$target_charset = 'sjis';
$target_charset = 'sjis';
$target_collation = 'sjis_japanese_ci';
break;
case 'KOI8-U':
$target_charset = 'koi8u';
$target_charset = 'koi8u';
$target_collation = 'koi8u_general_ci';
break;
case 'KOI8-R':
$target_charset = 'koi8r';
$target_charset = 'koi8r';
$target_collation = 'koi8r_general_ci';
break;
case 'UTF-8':
default:
$target_charset = 'utf8';
$target_charset = 'utf8';
$target_collation = 'utf8_unicode_ci';
break;
}
@ -482,19 +503,19 @@ class Dba
public static function reset_db_charset()
{
$translated_charset = self::translate_to_mysqlcharset(AmpConfig::get('site_charset'));
$target_charset = $translated_charset['charset'];
$target_collation = $translated_charset['collation'];
$target_charset = $translated_charset['charset'];
$target_collation = $translated_charset['collation'];
// Alter the charset for the entire database
$sql = "ALTER DATABASE `" . AmpConfig::get('database_name') . "` DEFAULT CHARACTER SET $target_charset COLLATE $target_collation";
Dba::write($sql);
$sql = "SHOW TABLES";
$sql = "SHOW TABLES";
$db_results = Dba::read($sql);
// Go through the tables!
while ($row = Dba::fetch_row($db_results)) {
$sql = "DESCRIBE `" . $row['0'] . "`";
$sql = "DESCRIBE `" . $row['0'] . "`";
$describe_results = Dba::read($sql);
// Change the tables default charset and colliation
@ -507,7 +528,7 @@ class Dba
(strpos($table['Type'], 'varchar') !== false) ||
(strpos($table['Type'], 'enum') !== false) ||
(strpos($table['Table'],'text') !== false)) {
$sql = "ALTER TABLE `" . $row['0'] . "` MODIFY `" . $table['Field'] . "` " . $table['Type'] . " CHARACTER SET " . $target_charset;
$sql = "ALTER TABLE `" . $row['0'] . "` MODIFY `" . $table['Field'] . "` " . $table['Type'] . " CHARACTER SET " . $target_charset;
$charset_results = Dba::write($sql);
if (!$charset_results) {
debug_event('CHARSET','Unable to update the charset of ' . $table['Field'] . '.' . $table['Type'] . ' to ' . $target_charset,'3');
@ -528,7 +549,7 @@ class Dba
*/
public static function optimize_tables()
{
$sql = "SHOW TABLES";
$sql = "SHOW TABLES";
$db_results = Dba::read($sql);
while ($row = Dba::fetch_row($db_results)) {

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -43,7 +43,7 @@ class Democratic extends Tmp_Playlist
// Build local, buy local
public $tmp_playlist;
public $object_ids = array();
public $vote_ids = array();
public $vote_ids = array();
public $user_votes = array();
/**
@ -52,14 +52,15 @@ class Democratic extends Tmp_Playlist
*/
public function __construct($id='')
{
if (!$id) { return false; }
if (!$id) {
return false;
}
$info = $this->get_info($id);
foreach ($info as $key=>$value) {
$this->$key = $value;
}
} // constructor
/**
@ -68,7 +69,9 @@ class Democratic extends Tmp_Playlist
*/
public static function build_vote_cache($ids)
{
if (!is_array($ids) || !count($ids)) { return false; }
if (!is_array($ids) || !count($ids)) {
return false;
}
$idlist = '(' . implode(',', $ids) . ')';
@ -83,7 +86,6 @@ class Democratic extends Tmp_Playlist
}
return true;
} // build_vote_cache
/**
@ -93,10 +95,11 @@ class Democratic extends Tmp_Playlist
*/
public function is_enabled()
{
if ($this->tmp_playlist) { return true; }
if ($this->tmp_playlist) {
return true;
}
return false;
} // is_enabled
/**
@ -107,14 +110,12 @@ class Democratic extends Tmp_Playlist
{
$demo_id = Dba::escape($this->id);
$sql = "SELECT * FROM `tmp_playlist` WHERE `session`='$demo_id'";
$sql = "SELECT * FROM `tmp_playlist` WHERE `session`='$demo_id'";
$db_results = Dba::read($sql);
$row = Dba::fetch_assoc($db_results);
$this->tmp_playlist = $row['id'];
} // set_parent
/**
@ -141,7 +142,6 @@ class Democratic extends Tmp_Playlist
Preference::update_all($play_method,'clear');
return true;
} // set_user_preferences
/**
@ -151,7 +151,7 @@ class Democratic extends Tmp_Playlist
public function format($details = true)
{
$this->f_cooldown = $this->cooldown . ' ' . T_('minutes');
$this->f_primary = $this->primary ? T_('Primary') : '';
$this->f_primary = $this->primary ? T_('Primary') : '';
switch ($this->level) {
case '5':
@ -170,7 +170,6 @@ class Democratic extends Tmp_Playlist
$this->f_level = T_('Admin');
break;
}
} // format
/**
@ -180,7 +179,7 @@ class Democratic extends Tmp_Playlist
*/
public static function get_playlists()
{
$sql = "SELECT `id` FROM `democratic` ORDER BY `name`";
$sql = "SELECT `id` FROM `democratic` ORDER BY `name`";
$db_results = Dba::read($sql);
$results = array();
@ -190,7 +189,6 @@ class Democratic extends Tmp_Playlist
}
return $results;
} // get_playlists
/**
@ -204,17 +202,16 @@ class Democratic extends Tmp_Playlist
if (!$democratic_id) {
$level = Dba::escape($GLOBALS['user']->access);
$sql = "SELECT `id` FROM `democratic` WHERE `level` <= '$level' " .
$sql = "SELECT `id` FROM `democratic` WHERE `level` <= '$level' " .
" ORDER BY `level` DESC,`primary` DESC";
$db_results = Dba::read($sql);
$row = Dba::fetch_assoc($db_results);
$db_results = Dba::read($sql);
$row = Dba::fetch_assoc($db_results);
$democratic_id = $row['id'];
}
$object = new Democratic($democratic_id);
return $object;
} // get_current_playlist
/**
@ -259,7 +256,6 @@ class Democratic extends Tmp_Playlist
}
return $results;
} // get_items
/**
@ -271,7 +267,6 @@ class Democratic extends Tmp_Playlist
$link = Stream::get_base_url() . 'uid=' . scrub_out($GLOBALS['user']->id) . '&demo_id=' . scrub_out($this->id);
return Stream_URL::format($link);
} // play_url
/**
@ -298,15 +293,14 @@ class Democratic extends Tmp_Playlist
// from base_playlist
if ($this->base_playlist) {
$base_playlist = new Playlist($this->base_playlist);
$data = $base_playlist->get_random_items(1);
$data = $base_playlist->get_random_items(1);
return $data[0]['object_id'];
} else {
$sql = "SELECT `id` FROM `song` WHERE `enabled`='1' ORDER BY RAND() LIMIT 1";
$sql = "SELECT `id` FROM `song` WHERE `enabled`='1' ORDER BY RAND() LIMIT 1";
$db_results = Dba::read($sql);
$results = Dba::fetch_assoc($db_results);
$results = Dba::fetch_assoc($db_results);
return $results['id'];
}
} // get_next_object
/**
@ -315,9 +309,9 @@ class Democratic extends Tmp_Playlist
*/
public function get_uid_from_object_id($object_id, $object_type = 'song')
{
$object_id = Dba::escape($object_id);
$object_id = Dba::escape($object_id);
$object_type = Dba::escape($object_type);
$tmp_id = Dba::escape($this->tmp_playlist);
$tmp_id = Dba::escape($this->tmp_playlist);
$sql = 'SELECT `id` FROM `tmp_playlist_data` ' .
"WHERE `object_type`='$object_type' AND " .
@ -327,7 +321,6 @@ class Democratic extends Tmp_Playlist
$row = Dba::fetch_assoc($db_results);
return $row['id'];
} // get_uid_from_object_id
/**
@ -343,7 +336,6 @@ class Democratic extends Tmp_Playlist
$song_ids = Stats::get_object_history($GLOBALS['user']->id, $cool_time);
return $song_ids;
} // get_cool_songs
/**
@ -357,13 +349,12 @@ class Democratic extends Tmp_Playlist
{
/* Iterate through the objects if no vote, add to playlist and vote */
foreach ($items as $element) {
$type = array_shift($element);
$type = array_shift($element);
$object_id = array_shift($element);
if (!$this->has_vote($object_id, $type)) {
$this->_add_vote($object_id, $type);
}
} // end foreach
} // vote
/**
@ -396,7 +387,6 @@ class Democratic extends Tmp_Playlist
}
return false;
} // has_vote
/**
@ -427,7 +417,7 @@ class Democratic extends Tmp_Playlist
/* Vote! */
$time = time();
$sql = "INSERT INTO user_vote (`user`,`object_id`,`date`,`sid`) " .
$sql = "INSERT INTO user_vote (`user`,`object_id`,`date`,`sid`) " .
"VALUES (?, ?, ?, ?)";
Dba::write($sql, array($GLOBALS['user']->id, $results['id'], $time, session_id()));
@ -442,7 +432,7 @@ class Democratic extends Tmp_Playlist
*/
public function remove_vote($row_id)
{
$sql = "DELETE FROM `user_vote` WHERE `object_id` = ? ";
$sql = "DELETE FROM `user_vote` WHERE `object_id` = ? ";
$params = array($row_id);
if ($GLOBALS['user']->id > 0) {
$sql .= "AND `user` = ?";
@ -457,7 +447,6 @@ class Democratic extends Tmp_Playlist
self::prune_tracks();
return true;
} // remove_vote
/**
@ -475,7 +464,6 @@ class Democratic extends Tmp_Playlist
Dba::write($sql);
return true;
} // delete_votes
/**
@ -488,10 +476,11 @@ class Democratic extends Tmp_Playlist
if ($row_id) {
debug_event('Democratic','Removing Votes for ' . $oid . ' of type ' . $object_type,'5');
$this->delete_votes($row_id);
} else { debug_event('Democratic','Unable to find Votes for ' . $oid . ' of type ' . $object_type,'3'); }
} else {
debug_event('Democratic','Unable to find Votes for ' . $oid . ' of type ' . $object_type,'3');
}
return true;
} // delete_from_oid
/**
@ -511,7 +500,6 @@ class Democratic extends Tmp_Playlist
self::prune_tracks();
return true;
} // delete
/**
@ -520,18 +508,17 @@ class Democratic extends Tmp_Playlist
*/
public function update(array $data)
{
$name = Dba::escape($data['name']);
$base = Dba::escape($data['democratic']);
$cool = Dba::escape($data['cooldown']);
$name = Dba::escape($data['name']);
$base = Dba::escape($data['democratic']);
$cool = Dba::escape($data['cooldown']);
$level = Dba::escape($data['level']);
$default = Dba::escape($data['make_default']);
$id = Dba::escape($this->id);
$default = Dba::escape($data['make_default']);
$id = Dba::escape($this->id);
$sql = "UPDATE `democratic` SET `name` = ?, `base_playlist` = ?,`cooldown` = ?, `primary` = ?, `level` = ? WHERE `id` = ?";
Dba::write($sql, array($name, $base, $cool, $default, $level, $id));
return true;
} // update
/**
@ -543,10 +530,10 @@ class Democratic extends Tmp_Playlist
// Clean up the input
$name = Dba::escape($data['name']);
$base = Dba::escape($data['democratic']);
$cool = Dba::escape($data['cooldown']);
$cool = Dba::escape($data['cooldown']);
$level = Dba::escape($data['level']);
$default = Dba::escape($data['make_default']);
$user = Dba::escape($GLOBALS['user']->id);
$default = Dba::escape($data['make_default']);
$user = Dba::escape($GLOBALS['user']->id);
$sql = "INSERT INTO `democratic` (`name`,`base_playlist`,`cooldown`,`level`,`user`,`primary`) " .
"VALUES ('$name','$base','$cool','$level','$user','$default')";
@ -562,7 +549,6 @@ class Democratic extends Tmp_Playlist
}
return $db_results;
} // create
/**
@ -580,7 +566,6 @@ class Democratic extends Tmp_Playlist
Dba::write($sql);
return true;
} // prune_tracks
/**
@ -607,7 +592,6 @@ class Democratic extends Tmp_Playlist
self::clear_votes();
return true;
} // clear_playlist
/**
@ -622,7 +606,6 @@ class Democratic extends Tmp_Playlist
Dba::write($sql);
return true;
} // clear_votes
/**
@ -642,7 +625,6 @@ class Democratic extends Tmp_Playlist
$results = Dba::fetch_assoc($db_results);
parent::add_to_cache('democratic_vote', $id, $results['count']);
return $results['count'];
} // get_vote
/**
@ -656,7 +638,7 @@ class Democratic extends Tmp_Playlist
return parent::get_from_cache('democratic_voters', $object_id);
}
$sql = "SELECT `user` FROM `user_vote` WHERE `object_id` = ?";
$sql = "SELECT `user` FROM `user_vote` WHERE `object_id` = ?";
$db_results = Dba::read($sql, array($object_id));
$voters = array();
@ -666,6 +648,5 @@ class Democratic extends Tmp_Playlist
parent::add_to_cache('democratic_vote', $object_id, $voters);
return $voters;
} // get_voters
} // Democratic class

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -24,10 +24,9 @@ class Graph
{
public function __construct()
{
require_once AmpConfig::get('prefix') . '/modules/pChart/pData.class.php';
require_once AmpConfig::get('prefix') . '/modules/pChart/pDraw.class.php';
require_once AmpConfig::get('prefix') . '/modules/pChart/pImage.class.php';
require_once AmpConfig::get('prefix') . '/lib/vendor/szymach/c-pchart/src/Classes/pData.php';
require_once AmpConfig::get('prefix') . '/lib/vendor/szymach/c-pchart/src/Classes/pDraw.php';
require_once AmpConfig::get('prefix') . '/lib/vendor/szymach/c-pchart/src/Classes/pImage.php';
return true;
}
@ -35,7 +34,7 @@ class Graph
{
switch ($zoom) {
case 'hour':
$df = "DATE_FORMAT(FROM_UNIXTIME(" . $field ."), '%Y-%m-%d %H:00:00')";
$df = "DATE_FORMAT(FROM_UNIXTIME(" . $field . "), '%Y-%m-%d %H:00:00')";
break;
case 'year':
$df = "DATE_FORMAT(FROM_UNIXTIME(" . $field . "), '%Y-01-01')";
@ -132,7 +131,7 @@ class Graph
return $values;
}
protected function get_all_pts($fct, pData $MyData, $id = 0, $object_type = null, $object_id = 0, $start_date = null, $end_date = null, $zoom = 'day', $show_total = true)
protected function get_all_pts($fct, CpChart\Classes\pData $MyData, $id = 0, $object_type = null, $object_id = 0, $start_date = null, $end_date = null, $zoom = 'day', $show_total = true)
{
$values = $this->get_all_type_pts($fct, $id, $object_type, $object_id, $start_date, $end_date, $zoom);
foreach ($values as $date => $value) {
@ -144,7 +143,7 @@ class Graph
return $values;
}
protected function get_user_all_pts($fct, pData $MyData, $user = 0, $object_type = null, $object_id = 0, $start_date = null, $end_date = null, $zoom = 'day')
protected function get_user_all_pts($fct, CpChart\Classes\pData $MyData, $user = 0, $object_type = null, $object_id = 0, $start_date = null, $end_date = null, $zoom = 'day')
{
$values = $this->get_all_pts($fct, $MyData, $user, $object_type, $object_id, $start_date, $end_date, $zoom);
@ -153,7 +152,7 @@ class Graph
if (!$user && $ustats['users'] < 10) {
$user_ids = User::get_valid_users();
foreach ($user_ids as $user_id) {
$u = new User($user_id);
$u = new User($user_id);
$user_values = $this->get_all_type_pts($fct, $user_id, $object_type, $object_id, $start_date, $end_date, $zoom);
foreach ($values as $date => $value) {
if (array_key_exists($date, $user_values)) {
@ -167,7 +166,7 @@ class Graph
}
}
protected function get_catalog_all_pts($fct, pData $MyData, $catalog = 0, $object_type = null, $object_id = 0, $start_date = null, $end_date = null, $zoom = 'day')
protected function get_catalog_all_pts($fct, CpChart\Classes\pData $MyData, $catalog = 0, $object_type = null, $object_id = 0, $start_date = null, $end_date = null, $zoom = 'day')
{
$values = $this->get_all_pts($fct, $MyData, $catalog, $object_type, $object_id, $start_date, $end_date, $zoom, false);
@ -175,13 +174,13 @@ class Graph
if (!$catalog) {
$catalog_ids = Catalog::get_catalogs();
foreach ($catalog_ids as $catalog_id) {
$c = Catalog::create_from_id($catalog_id);
$c = Catalog::create_from_id($catalog_id);
$catalog_values = $this->get_all_type_pts($fct, $catalog_id, $object_type, $object_id, $start_date, $end_date, $zoom);
$pv = 0;
$pv = 0;
foreach ($values as $date => $value) {
if (array_key_exists($date, $catalog_values)) {
$value = $catalog_values[$date];
$pv = $value;
$pv = $value;
} else {
$value = $pv;
}
@ -193,9 +192,9 @@ class Graph
protected function get_user_hits_pts($user = 0, $object_type = 'song', $object_id = 0, $start_date = null, $end_date = null, $zoom = 'day')
{
$df = $this->get_sql_date_format("`object_count`.`date`", $zoom);
$df = $this->get_sql_date_format("`object_count`.`date`", $zoom);
$where = $this->get_user_sql_where($user, $object_type, $object_id, $start_date, $end_date);
$sql = "SELECT " . $df . " AS `zoom_date`, COUNT(`object_count`.`id`) AS `hits` FROM `object_count` " . $where .
$sql = "SELECT " . $df . " AS `zoom_date`, COUNT(`object_count`.`id`) AS `hits` FROM `object_count` " . $where .
" GROUP BY " . $df;
$db_results = Dba::read($sql);
@ -208,9 +207,9 @@ class Graph
protected function get_user_object_count_pts($user = 0, $object_type = 'song', $object_id = 0, $start_date = null, $end_date = null, $zoom = 'day', $column = 'size')
{
$df = $this->get_sql_date_format("`object_count`.`date`", $zoom);
$df = $this->get_sql_date_format("`object_count`.`date`", $zoom);
$where = $this->get_user_sql_where($user, $object_type, $object_id, $start_date, $end_date);
$sql = "SELECT " . $df . " AS `zoom_date`, SUM(`" . $object_type . "`.`" . $column . "`) AS `total` FROM `object_count` " .
$sql = "SELECT " . $df . " AS `zoom_date`, SUM(`" . $object_type . "`.`" . $column . "`) AS `total` FROM `object_count` " .
" JOIN `" . $object_type . "` ON `" . $object_type . "`.`id` = `object_count`.`object_id` " . $where .
" GROUP BY " . $df;
$db_results = Dba::read($sql);
@ -235,9 +234,9 @@ class Graph
protected function get_catalog_files_pts($catalog = 0, $object_type = 'song', $object_id = 0, $start_date = null, $end_date = null, $zoom = 'day')
{
$start_date = $start_date ?: ($end_date ?: time()) - 864000;
$df = $this->get_sql_date_format("`" . $object_type . "`.`addition_time`", $zoom);
$where = $this->get_catalog_sql_where($object_type, $object_id, $catalog, $start_date, $end_date);
$sql = "SELECT " . $df . " AS `zoom_date`, ((SELECT COUNT(`t2`.`id`) FROM `" . $object_type . "` `t2` WHERE `t2`.`addition_time` < `zoom_date`) + COUNT(`" . $object_type . "`.`id`)) AS `files` FROM `" . $object_type . "` " . $where .
$df = $this->get_sql_date_format("`" . $object_type . "`.`addition_time`", $zoom);
$where = $this->get_catalog_sql_where($object_type, $object_id, $catalog, $start_date, $end_date);
$sql = "SELECT " . $df . " AS `zoom_date`, ((SELECT COUNT(`t2`.`id`) FROM `" . $object_type . "` `t2` WHERE `t2`.`addition_time` < `zoom_date`) + COUNT(`" . $object_type . "`.`id`)) AS `files` FROM `" . $object_type . "` " . $where .
" GROUP BY " . $df;
$db_results = Dba::read($sql);
@ -251,9 +250,9 @@ class Graph
protected function get_catalog_size_pts($catalog = 0, $object_type = 'song', $object_id = 0, $start_date = null, $end_date = null, $zoom = 'day')
{
$start_date = $start_date ?: ($end_date ?: time()) - 864000;
$df = $this->get_sql_date_format("`" . $object_type . "`.`addition_time`", $zoom);
$where = $this->get_catalog_sql_where($object_type, $object_id, $catalog, $start_date, $end_date);
$sql = "SELECT " . $df . " AS `zoom_date`, ((SELECT SUM(`t2`.`size`) FROM `" . $object_type . "` `t2` WHERE `t2`.`addition_time` < `zoom_date`) + SUM(`" . $object_type . "`.`size`)) AS `storage` FROM `" . $object_type . "` " . $where .
$df = $this->get_sql_date_format("`" . $object_type . "`.`addition_time`", $zoom);
$where = $this->get_catalog_sql_where($object_type, $object_id, $catalog, $start_date, $end_date);
$sql = "SELECT " . $df . " AS `zoom_date`, ((SELECT SUM(`t2`.`size`) FROM `" . $object_type . "` `t2` WHERE `t2`.`addition_time` < `zoom_date`) + SUM(`" . $object_type . "`.`size`)) AS `storage` FROM `" . $object_type . "` " . $where .
" GROUP BY " . $df;
$db_results = Dba::read($sql);
@ -289,7 +288,7 @@ class Graph
return $pts;
}
protected function render_graph($title, pData $MyData, $zoom, $width = 0, $height = 0)
protected function render_graph($title, CpChart\Classes\pData $MyData, $zoom, $width = 0, $height = 0)
{
// Check graph size sanity
$width = intval($width);
@ -319,10 +318,10 @@ class Graph
}
/* Create the pChart object */
$myPicture = new pImage($width,$height,$MyData);
$myPicture = new CpChart\Classes\pImage($width,$height,$MyData);
/* Turn of Antialiasing */
$myPicture->Antialias = FALSE;
$myPicture->Antialias = false;
/* Draw a background */
$Settings = array("R"=>90, "G"=>90, "B"=>90, "Dash"=>1, "DashR"=>120, "DashG"=>120, "DashB"=>120);
@ -336,25 +335,26 @@ class Graph
/* Add a border to the picture */
$myPicture->drawRectangle(0,0,$width-1,$height-1,array("R"=>0,"G"=>0,"B"=>0));
$font_path = AmpConfig::get('prefix') . "/lib/vendor/szymach/c-pchart/src/Resources/fonts";
/* Write the chart title */
$myPicture->setFontProperties(array("FontName"=>AmpConfig::get('prefix')."/modules/pChart/fonts/Forgotte.ttf","FontSize"=>11));
$myPicture->setFontProperties(array("FontName"=>$font_path . "/Forgotte.ttf","FontSize"=>11));
$myPicture->drawText(150,35,$title,array("FontSize"=>20,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
/* Set the default font */
$myPicture->setFontProperties(array("FontName"=>AmpConfig::get('prefix')."/modules/pChart/fonts/pf_arma_five.ttf","FontSize"=>6));
$myPicture->setFontProperties(array("FontName"=>$font_path . "/pf_arma_five.ttf","FontSize"=>6));
/* Define the chart area */
$myPicture->setGraphArea(60,40,$width-20,$height-50);
/* Draw the scale */
$scaleSettings = array("XMargin"=>10,"YMargin"=>10,"Floating"=>TRUE,"GridR"=>200,"GridG"=>200,"GridB"=>200,"RemoveSkippedAxis"=>TRUE,"DrawSubTicks"=>FALSE,"Mode"=>SCALE_MODE_START0,"LabelRotation"=>45,"LabelingMethod"=>LABELING_DIFFERENT);
$scaleSettings = array("XMargin"=>10,"YMargin"=>10,"Floating"=>true,"GridR"=>200,"GridG"=>200,"GridB"=>200,"RemoveSkippedAxis"=>true,"DrawSubTicks"=>false,"Mode"=>SCALE_MODE_START0,"LabelRotation"=>45,"LabelingMethod"=>LABELING_DIFFERENT);
$myPicture->drawScale($scaleSettings);
/* Turn on Antialiasing */
$myPicture->Antialias = TRUE;
$myPicture->Antialias = true;
/* Draw the line chart */
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
$myPicture->setShadow(true,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
$myPicture->drawLineChart();
/* Write a label over the chart */
@ -370,7 +370,7 @@ class Graph
public function render_user_hits($user = 0, $object_type, $object_id, $start_date = null, $end_date = null, $zoom = 'day', $width = 0, $height = 0)
{
$MyData = new pData();
$MyData = new CpChart\Classes\pData();
$this->get_user_all_pts('get_user_hits_pts', $MyData, $user, $object_type, $object_id, $start_date, $end_date, $zoom);
$MyData->setAxisName(0, "Hits");
@ -381,7 +381,7 @@ class Graph
public function render_user_bandwidth($user = 0, $object_type = null, $object_id = 0, $start_date = null, $end_date = null, $zoom = 'day', $width = 0, $height = 0)
{
$MyData = new pData();
$MyData = new CpChart\Classes\pData();
$this->get_user_all_pts('get_user_bandwidth_pts', $MyData, $user, $object_type, $object_id, $start_date, $end_date, $zoom);
$MyData->setAxisName(0, "Bandwidth");
@ -392,7 +392,7 @@ class Graph
public function get_total_bandwidth($user = 0, $start_date = null, $end_date = null)
{
$total = 0;
$total = 0;
$values = $this->get_all_type_pts('get_user_bandwidth_pts', $user, null, 0, $start_date, $end_date, 'month');
foreach ($values as $date => $value) {
$total += $value;
@ -403,7 +403,7 @@ class Graph
public function get_total_time($user = 0, $start_date = null, $end_date = null)
{
$total = 0;
$total = 0;
$values = $this->get_all_type_pts('get_user_time_pts', $user, null, 0, $start_date, $end_date, 'month');
foreach ($values as $date => $value) {
$total += $value;
@ -414,7 +414,7 @@ class Graph
public function get_total_hits($user = 0, $start_date = null, $end_date = null)
{
$total = 0;
$total = 0;
$values = $this->get_all_type_pts('get_user_hits_pts', $user, null, 0, $start_date, $end_date, 'month');
foreach ($values as $date => $value) {
$total += $value;
@ -425,7 +425,7 @@ class Graph
public function render_catalog_files($catalog = 0, $object_type = null, $object_id = 0, $start_date = null, $end_date = null, $zoom = 'day', $width = 0, $height = 0)
{
$MyData = new pData();
$MyData = new CpChart\Classes\pData();
$this->get_catalog_all_pts('get_catalog_files_pts', $MyData, $catalog, $object_type, $object_id, $start_date, $end_date, $zoom);
$MyData->setAxisName(0, "Files");
@ -436,7 +436,7 @@ class Graph
public function render_catalog_size($catalog = 0, $object_type = null, $object_id = 0, $start_date = null, $end_date = null, $zoom = 'day', $width = 0, $height = 0)
{
$MyData = new pData();
$MyData = new CpChart\Classes\pData();
$this->get_catalog_all_pts('get_catalog_size_pts', $MyData, $catalog, $object_type, $object_id, $start_date, $end_date, $zoom);
$MyData->setAxisName(0, "Size");
@ -462,19 +462,29 @@ class Graph
public static function display_from_request()
{
if (!Access::check('interface','50')) {
$object_type = $_REQUEST['object_type'];
$object_id = $_REQUEST['object_id'];
$libitem = null;
$owner_id = 0;
if ($object_id) {
if (Core::is_library_item($object_type)) {
$libitem = new $object_type($object_id);
$owner_id = $libitem->get_user_owner();
}
}
if (($owner_id <= 0 || $owner_id != $GLOBALS['user']->id) && !Access::check('interface','50')) {
UI::access_denied();
} else {
$user_id = $_REQUEST['user_id'];
$object_type = $_REQUEST['object_type'];
$object_id = $_REQUEST['object_id'];
$end_date = $_REQUEST['end_date'] ? strtotime($_REQUEST['end_date']) : time();
$f_end_date = date("Y-m-d H:i", $end_date);
$start_date = $_REQUEST['start_date'] ? strtotime($_REQUEST['start_date']) : ($end_date - 864000);
$user_id = $_REQUEST['user_id'];
$end_date = $_REQUEST['end_date'] ? strtotime($_REQUEST['end_date']) : time();
$f_end_date = date("Y-m-d H:i", $end_date);
$start_date = $_REQUEST['start_date'] ? strtotime($_REQUEST['start_date']) : ($end_date - 864000);
$f_start_date = date("Y-m-d H:i", $start_date);
$zoom = $_REQUEST['zoom'] ?: 'day';
$zoom = $_REQUEST['zoom'] ?: 'day';
$gtypes = array();
$gtypes = array();
$gtypes[] = 'user_hits';
if ($object_type == null || $object_type == 'song' || $object_type == 'video') {
$gtypes[] = 'user_bandwidth';
@ -485,21 +495,20 @@ class Graph
}
$blink = '';
if ($object_id) {
if (Core::is_library_item($object_type)) {
$libitem = new $object_type($object_id);
$libitem->format();
if (isset($libitem->f_link)) {
$blink = $libitem->f_link;
}
if ($libitem !== null) {
$libitem->format();
if (isset($libitem->f_link)) {
$blink = $libitem->f_link;
}
} else {
if ($user_id) {
$u = new User($user_id);
$u->format();
$blink = $u->f_link;
}
} else if ($user_id) {
$u = new User($user_id);
$u->format();
$blink = $u->f_link;
}
require_once AmpConfig::get('prefix') . '/templates/show_graphs.inc.php';
require_once AmpConfig::get('prefix') . UI::find_template('show_graphs.inc.php');
}
}
}

View file

@ -2,21 +2,21 @@
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2015 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -85,7 +85,9 @@ class Label extends database_object implements library_item
*/
public function __construct($id=null)
{
if (!$id) { return false; }
if (!$id) {
return false;
}
$info = $this->get_info($id);
foreach ($info as $key=>$value) {
@ -117,7 +119,7 @@ class Label extends database_object implements library_item
public function get_childrens()
{
$medias = array();
$medias = array();
$artists = $this->get_artists();
foreach ($artists as $artist_id) {
$medias[] = array(
@ -145,7 +147,7 @@ class Label extends database_object implements library_item
public function get_keywords()
{
$keywords = array();
$keywords = array();
$keywords['label'] = array('important' => true,
'label' => T_('Label'),
'value' => $this->f_name);
@ -179,11 +181,11 @@ class Label extends database_object implements library_item
public function search_childrens($name)
{
$search['type'] = "artist";
$search['rule_0_input'] = $name;
$search['type'] = "artist";
$search['rule_0_input'] = $name;
$search['rule_0_operator'] = 4;
$search['rule_0'] = "title";
$artists = Search::run($search);
$search['rule_0'] = "title";
$artists = Search::run($search);
$childrens = array();
foreach ($artists as $artist) {
@ -201,12 +203,14 @@ class Label extends database_object implements library_item
$user = $GLOBALS['user']->id;
}
if (!$user)
if (!$user) {
return false;
}
if (AmpConfig::get('upload_allow_edit')) {
if ($this->user !== null && $user == $this->user)
if ($this->user !== null && $user == $this->user) {
return true;
}
}
return Access::check('interface', 50, $user);
@ -218,22 +222,22 @@ class Label extends database_object implements library_item
return false;
}
$name = isset($data['name']) ? $data['name'] : $this->name;
$name = isset($data['name']) ? $data['name'] : $this->name;
$category = isset($data['category']) ? $data['category'] : $this->category;
$summary = isset($data['summary']) ? $data['summary'] : $this->summary;
$address = isset($data['address']) ? $data['address'] : $this->address;
$email = isset($data['email']) ? $data['email'] : $this->email;
$website = isset($data['website']) ? $data['website'] : $this->website;
$summary = isset($data['summary']) ? $data['summary'] : $this->summary;
$address = isset($data['address']) ? $data['address'] : $this->address;
$email = isset($data['email']) ? $data['email'] : $this->email;
$website = isset($data['website']) ? $data['website'] : $this->website;
$sql = "UPDATE `label` SET `name` = ?, `category` = ?, `summary` = ?, `address` = ?, `email` = ?, `website` = ? WHERE `id` = ?";
Dba::write($sql, array($name, $category, $summary, $address, $email, $website, $this->id));
$this->name = $name;
$this->name = $name;
$this->category = $category;
$this->summary = $summary;
$this->address = $address;
$this->email = $email;
$this->website = $website;
$this->summary = $summary;
$this->address = $address;
$this->email = $email;
$this->website = $website;
return $this->id;
}
@ -244,13 +248,13 @@ class Label extends database_object implements library_item
return false;
}
$name = $data['name'];
$category = $data['category'];
$summary = $data['summary'];
$address = $data['address'];
$email = $data['email'];
$website = $data['website'];
$user = $data['user'] ?: $GLOBALS['user']->id;
$name = $data['name'];
$category = $data['category'];
$summary = $data['summary'];
$address = $data['address'];
$email = $data['email'];
$website = $data['website'];
$user = $data['user'] ?: $GLOBALS['user']->id;
$creation_date = $data['creation_date'] ?: time();
$sql = "INSERT INTO `label` (`name`, `category`, `summary`, `address`, `email`, `website`, `user`, `creation_date`) " .
@ -263,11 +267,11 @@ class Label extends database_object implements library_item
public static function lookup(array $data, $id = 0)
{
$ret = -1;
$ret = -1;
$name = trim($data['name']);
if (!empty($name)) {
$ret = 0;
$sql = "SELECT `id` FROM `label` WHERE `name` = ?";
$ret = 0;
$sql = "SELECT `id` FROM `label` WHERE `name` = ?";
$params = array($name);
if ($id > 0) {
$sql .= " AND `id` != ?";
@ -289,9 +293,9 @@ class Label extends database_object implements library_item
public function get_artists()
{
$sql = "SELECT `artist` FROM `label_asso` WHERE `label` = ?";
$sql = "SELECT `artist` FROM `label_asso` WHERE `label` = ?";
$db_results = Dba::read($sql, array($this->id));
$results = array();
$results = array();
while ($row = Dba::fetch_assoc($db_results)) {
$results[] = $row['artist'];
}
@ -336,18 +340,18 @@ class Label extends database_object implements library_item
}
return $results;
} // get_songs
public function remove()
{
$sql = "DELETE FROM `label` WHERE `id` = ?";
$sql = "DELETE FROM `label` WHERE `id` = ?";
$deleted = Dba::write($sql, array($this->id));
if ($deleted) {
Art::gc('label', $this->id);
Userflag::gc('label', $this->id);
Rating::gc('label', $this->id);
Shoutbox::gc('label', $this->id);
Useractivity::gc('label', $this->id);
}
return $deleted;
@ -355,9 +359,9 @@ class Label extends database_object implements library_item
public static function get_all_labels()
{
$sql = "SELECT `id`, `name` FROM `label`";
$sql = "SELECT `id`, `name` FROM `label`";
$db_results = Dba::read($sql);
$results = array();
$results = array();
while ($row = Dba::fetch_assoc($db_results)) {
$results[$row['id']] = $row['name'];
}
@ -370,7 +374,7 @@ class Label extends database_object implements library_item
"LEFT JOIN `label_asso` ON `label_asso`.`label` = `label`.`id` " .
"WHERE `label_asso`.`artist` = ?";
$db_results = Dba::read($sql, array($artist_id));
$results = array();
$results = array();
while ($row = Dba::fetch_assoc($db_results)) {
$results[$row['id']] = $row['name'];
}
@ -383,7 +387,9 @@ class Label extends database_object implements library_item
*/
public static function get_display($labels, $link=false)
{
if (!is_array($labels)) { return ''; }
if (!is_array($labels)) {
return '';
}
$results = '';
@ -402,7 +408,6 @@ class Label extends database_object implements library_item
$results = rtrim($results, ', ');
return $results;
} // get_display
/**
@ -411,16 +416,16 @@ class Label extends database_object implements library_item
*/
public static function update_label_list($labels_comma, $artist_id, $overwrite)
{
debug_event('label.class', 'Updating labels for values {'.$labels_comma.'} artist {'.$artist_id.'}', '5');
debug_event('label.class', 'Updating labels for values {' . $labels_comma . '} artist {' . $artist_id . '}', '5');
$clabels = Label::get_labels($artist_id);
$clabels = Label::get_labels($artist_id);
$editedLabels = explode(",", $labels_comma);
if (is_array($clabels)) {
foreach ($clabels as $clid => $clv) {
if ($clid) {
$clabel = new Label($clid);
debug_event('label.class', 'Processing label {'.$clabel->name.'}...', '5');
debug_event('label.class', 'Processing label {' . $clabel->name . '}...', '5');
$found = false;
foreach ($editedLabels as $lk => $lv) {
@ -433,9 +438,11 @@ class Label extends database_object implements library_item
if ($found) {
debug_event('label.class', 'Already found. Do nothing.', '5');
unset($editedLabels[$lk]);
} else if ($overwrite) {
debug_event('label.class', 'Not found in the new list. Delete it.', '5');
$clabel->remove_artist_assoc($artist_id);
} else {
if ($overwrite) {
debug_event('label.class', 'Not found in the new list. Delete it.', '5');
$clabel->remove_artist_assoc($artist_id);
}
}
}
}
@ -444,7 +451,7 @@ class Label extends database_object implements library_item
// Look if we need to add some new labels
foreach ($editedLabels as $lk => $lv) {
if ($lv != '') {
debug_event('label.class', 'Adding new label {'.$lv.'}', '5');
debug_event('label.class', 'Adding new label {' . $lv . '}', '5');
$label_id = Label::lookup(array('name' => $lv));
if ($label_id === 0) {
debug_event('label.class', 'Creating a label directly from artist editing is not allowed.', '5');

Some files were not shown because too many files have changed in this diff Show more