Initial L5.1 commit

This commit is contained in:
Kelvin Zhang 2015-08-30 12:22:00 +01:00
parent 03df4d1ec9
commit 292d476210
614 changed files with 5233 additions and 120002 deletions

19
.env.example Normal file
View file

@ -0,0 +1,19 @@
APP_ENV=local
APP_DEBUG=true
APP_KEY=SomeRandomString
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

2
.gitattributes vendored
View file

@ -1 +1,3 @@
* text=auto
*.css linguist-vendored
*.less linguist-vendored

53
.gitignore vendored
View file

@ -1,50 +1,5 @@
.vagrant
# Numerous always-ignore extensions
*.diff
*.err
*.orig
*.log
*.rej
*.swo
*.swp
*.vi
*~
*.sass-cache
# OS or Editor folders
.DS_Store
Thumbs.db
.cache
.project
.settings
.tmproj
*.esproj
nbproject
*.iml
# Dreamweaver added files
_notes
dwsync.xml
# Komodo
*.komodoproject
.komodotools
# Folders to ignore
.hg
.svn
.CVS
intermediate
publish
.idea
node_modules
/public/build/
/bootstrap/compiled.php
/vendor
/app/config/production
composer.phar
composer.lock
atlassian-ide-plugin.xml
_ide_helper.php
/node_modules
Homestead.yaml
.env
.vagrant

View file

@ -1,3 +0,0 @@
# Contribution Guidelines
Please submit all issues and pull requests to the [laravel/framework](http://github.com/laravel/framework) repository!

View file

@ -0,0 +1,33 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Foundation\Inspiring;
class Inspire extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'inspire';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Display an inspiring quote';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
}
}

30
app/Console/Kernel.php Normal file
View file

@ -0,0 +1,30 @@
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
\App\Console\Commands\Inspire::class,
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('inspire')
->hourly();
}
}

8
app/Events/Event.php Normal file
View file

@ -0,0 +1,8 @@
<?php
namespace App\Events;
abstract class Event
{
//
}

View file

@ -0,0 +1,44 @@
<?php
namespace App\Exceptions;
use Exception;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that should not be reported.
*
* @var array
*/
protected $dontReport = [
HttpException::class,
];
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
* @return void
*/
public function report(Exception $e)
{
return parent::report($e);
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
return parent::render($request, $e);
}
}

View file

@ -0,0 +1,65 @@
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
class AuthController extends Controller
{
/*
|--------------------------------------------------------------------------
| Registration & Login Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users, as well as the
| authentication of existing users. By default, this controller uses
| a simple trait to add these behaviors. Why don't you explore it?
|
*/
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
/**
* Create a new authentication controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest', ['except' => 'getLogout']);
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|confirmed|min:6',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
}

View file

@ -0,0 +1,32 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;
class PasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset requests
| and uses a simple trait to include this behavior. You're free to
| explore this trait and override any methods you wish to tweak.
|
*/
use ResetsPasswords;
/**
* Create a new password controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
}

View file

@ -0,0 +1,12 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
abstract class Controller extends BaseController
{
use DispatchesJobs, ValidatesRequests;
}

33
app/Http/Kernel.php Normal file
View file

@ -0,0 +1,33 @@
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* @var array
*/
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
];
/**
* The application's route middleware.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
];
}

View file

@ -0,0 +1,47 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Auth\Guard;
class Authenticate
{
/**
* The Guard implementation.
*
* @var Guard
*/
protected $auth;
/**
* Create a new filter instance.
*
* @param Guard $auth
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('auth/login');
}
}
return $next($request);
}
}

View file

@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Cookie\Middleware\EncryptCookies as BaseEncrypter;
class EncryptCookies extends BaseEncrypter
{
/**
* The names of the cookies that should not be encrypted.
*
* @var array
*/
protected $except = [
//
];
}

View file

@ -0,0 +1,43 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Auth\Guard;
class RedirectIfAuthenticated
{
/**
* The Guard implementation.
*
* @var Guard
*/
protected $auth;
/**
* Create a new filter instance.
*
* @param Guard $auth
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->check()) {
return redirect('/home');
}
return $next($request);
}
}

View file

@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
class VerifyCsrfToken extends BaseVerifier
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
//
];
}

View file

@ -0,0 +1,10 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
abstract class Request extends FormRequest
{
//
}

16
app/Http/routes.php Normal file
View file

@ -0,0 +1,16 @@
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
return view('welcome');
});

21
app/Jobs/Job.php Normal file
View file

@ -0,0 +1,21 @@
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
abstract class Job
{
/*
|--------------------------------------------------------------------------
| Queueable Jobs
|--------------------------------------------------------------------------
|
| This job base class provides a central location to place any logic that
| is shared across all of your jobs. The trait included with the class
| provides access to the "queueOn" and "delay" queue helper methods.
|
*/
use Queueable;
}

View file

@ -0,0 +1,28 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}

View file

@ -0,0 +1,33 @@
<?php
namespace App\Providers;
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
'App\Events\SomeEvent' => [
'App\Listeners\EventListener',
],
];
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
//
}
}

View file

@ -0,0 +1,44 @@
<?php
namespace App\Providers;
use Illuminate\Routing\Router;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to the controller routes in your routes file.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
//
parent::boot($router);
}
/**
* Define the routes for the application.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function map(Router $router)
{
$router->group(['namespace' => $this->namespace], function ($router) {
require app_path('Http/routes.php');
});
}
}

35
app/User.php Normal file
View file

@ -0,0 +1,35 @@
<?php
namespace App;
use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
class User extends Model implements AuthenticatableContract, CanResetPasswordContract
{
use Authenticatable, CanResetPassword;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'users';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['name', 'email', 'password'];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = ['password', 'remember_token'];
}

View file

@ -1,354 +0,0 @@
<?php
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
class MigrateOldData extends Command {
protected $name = 'migrate-old-data';
protected $description = 'Migrates data from the old pfm site.';
public function __construct()
{
parent::__construct();
}
public function fire() {
DB::connection()->disableQueryLog();
$oldDb = DB::connection('old');
$this->call('migrate:refresh');
$oldUsers = $oldDb->table('users')->get();
$this->info('Syncing Users');
foreach ($oldUsers as $user) {
$displayName = $user->display_name;
if (!$displayName)
$displayName = $user->username;
if (!$displayName)
$displayName = $user->mlpforums_name;
if (!$displayName)
continue;
DB::table('users')->insert([
'id' => $user->id,
'display_name' => $displayName,
'email' => $user->email,
'created_at' => $user->created_at,
'updated_at' => $user->updated_at,
'slug' => $user->slug,
'bio' => $user->bio,
'sync_names' => $user->sync_names,
'can_see_explicit_content' => $user->can_see_explicit_content,
'mlpforums_name' => $user->mlpforums_name,
'uses_gravatar' => $user->uses_gravatar,
'gravatar' => $user->gravatar,
'avatar_id' => null
]);
$coverId = null;
if (!$user->uses_gravatar) {
try {
$coverFile = $this->getIdDirectory('users', $user->id) . '/' . $user->id . '_.png';
$coverId = \Entities\Image::upload(new Symfony\Component\HttpFoundation\File\UploadedFile($coverFile, $user->id . '_.png'), $user->id)->id;
DB::table('users')->where('id', $user->id)->update(['avatar_id' => $coverId]);
} catch (\Exception $e) {
$this->error('Could copy user avatar ' . $user->id . ' because ' . $e->getMessage());
DB::table('users')->where('id', $user->id)->update(['uses_gravatar' => true]);
}
}
}
$this->info('Syncing Genres');
$oldGenres = $oldDb->table('genres')->get();
foreach ($oldGenres as $genre) {
DB::table('genres')->insert([
'id' => $genre->id,
'name' => $genre->title,
'slug' => $genre->slug
]);
}
$this->info('Syncing Albums');
$oldAlbums = $oldDb->table('albums')->get();
foreach ($oldAlbums as $playlist) {
$logViews = $oldDb->table('album_log_views')->whereAlbumId($playlist->id)->get();
$logDownload = $oldDb->table('album_log_downloads')->whereAlbumId($playlist->id)->get();
DB::table('albums')->insert([
'title' => $playlist->title,
'description' => $playlist->description,
'created_at' => $playlist->created_at,
'updated_at' => $playlist->updated_at,
'deleted_at' => $playlist->deleted_at,
'slug' => $playlist->slug,
'id' => $playlist->id,
'user_id' => $playlist->user_id,
'view_count' => 0,
'download_count' => 0
]);
foreach ($logViews as $logItem) {
try {
DB::table('resource_log_items')->insert([
'user_id' => $logItem->user_id,
'log_type' => \Entities\ResourceLogItem::VIEW,
'album_id' => $logItem->album_id,
'created_at' => $logItem->created_at,
'ip_address' => $logItem->ip_address,
]);
} catch (\Exception $e) {
$this->error('Could insert log item for album ' . $playlist->id . ' because ' . $e->getMessage());
}
}
foreach ($logDownload as $logItem) {
try {
DB::table('resource_log_items')->insert([
'user_id' => $logItem->user_id,
'log_type' => \Entities\ResourceLogItem::DOWNLOAD,
'album_id' => $logItem->album_id,
'created_at' => $logItem->created_at,
'ip_address' => $logItem->ip_address,
'track_format_id' => $logItem->track_file_format_id - 1
]);
} catch (\Exception $e) {
$this->error('Could insert log item for album ' . $playlist->id . ' because ' . $e->getMessage());
}
}
}
$this->info('Syncing Tracks');
$oldTracks = $oldDb->table('tracks')->get();
foreach ($oldTracks as $track) {
$coverId = null;
if ($track->cover) {
try {
$coverFile = $this->getIdDirectory('tracks', $track->id) . '/' . $track->id . '_' . $track->cover . '.png';
$coverId = \Entities\Image::upload(new Symfony\Component\HttpFoundation\File\UploadedFile($coverFile, $track->id . '_' . $track->cover . '.png'), $track->user_id)->id;
} catch (\Exception $e) {
$this->error('Could copy track cover ' . $track->id . ' because ' . $e->getMessage());
}
}
$trackLogViews = $oldDb->table('track_log_views')->whereTrackId($track->id)->get();
$trackLogPlays = $oldDb->table('track_log_plays')->whereTrackId($track->id)->get();
$trackLogDownload = $oldDb->table('track_log_downloads')->whereTrackId($track->id)->get();
DB::table('tracks')->insert([
'id' => $track->id,
'title' => $track->title,
'slug' => $track->slug,
'description' => $track->description,
'lyrics' => $track->lyrics,
'created_at' => $track->created_at,
'deleted_at' => $track->deleted_at,
'updated_at' => $track->updated_at,
'released_at' => $track->released_at,
'published_at' => $track->published_at,
'genre_id' => $track->genre_id,
'is_explicit' => $track->explicit,
'is_downloadable' => $track->downloadable,
'is_vocal' => $track->is_vocal,
'track_type_id' => $track->track_type_id,
'track_number' => $track->track_number,
'user_id' => $track->user_id,
'album_id' => $track->album_id,
'cover_id' => $coverId,
'license_id' => $track->license_id,
'duration' => $track->duration,
'view_count' => 0,
'play_count' => 0,
'download_count' => 0
]);
foreach ($trackLogViews as $logItem) {
try {
DB::table('resource_log_items')->insert([
'user_id' => $logItem->user_id,
'log_type' => \Entities\ResourceLogItem::VIEW,
'track_id' => $logItem->track_id,
'created_at' => $logItem->created_at,
'ip_address' => $logItem->ip_address
]);
} catch (\Exception $e) {
$this->error('Could insert log item for track ' . $track->id . ' because ' . $e->getMessage());
}
}
foreach ($trackLogPlays as $logItem) {
try {
DB::table('resource_log_items')->insert([
'user_id' => $logItem->user_id,
'log_type' => \Entities\ResourceLogItem::PLAY,
'track_id' => $logItem->track_id,
'created_at' => $logItem->created_at,
'ip_address' => $logItem->ip_address
]);
} catch (\Exception $e) {
$this->error('Could insert log item for track ' . $track->id . ' because ' . $e->getMessage());
}
}
foreach ($trackLogDownload as $logItem) {
try {
DB::table('resource_log_items')->insert([
'user_id' => $logItem->user_id,
'log_type' => \Entities\ResourceLogItem::DOWNLOAD,
'track_id' => $logItem->track_id,
'created_at' => $logItem->created_at,
'ip_address' => $logItem->ip_address,
'track_format_id' => $logItem->track_file_format_id - 1
]);
} catch (\Exception $e) {
$this->error('Could insert log item for track ' . $track->id . ' because ' . $e->getMessage());
}
}
}
$oldShowSongs = $oldDb->table('song_track')->get();
foreach ($oldShowSongs as $song) {
try {
DB::table('show_song_track')->insert([
'id' => $song->id,
'show_song_id' => $song->song_id,
'track_id' => $song->track_id
]);
} catch (\Exception $e) {
$this->error('Could insert show track item for ' . $song->track_id . ' because ' . $e->getMessage());
}
}
$this->info('Syncing Playlists');
$oldPlaylists = $oldDb->table('playlists')->get();
foreach ($oldPlaylists as $playlist) {
$logViews = $oldDb->table('playlist_log_views')->wherePlaylistId($playlist->id)->get();
$logDownload = $oldDb->table('playlist_log_downloads')->wherePlaylistId($playlist->id)->get();
DB::table('playlists')->insert([
'title' => $playlist->title,
'description' => $playlist->description,
'created_at' => $playlist->created_at,
'updated_at' => $playlist->updated_at,
'deleted_at' => $playlist->deleted_at,
'slug' => $playlist->slug,
'id' => $playlist->id,
'user_id' => $playlist->user_id,
'is_public' => true,
'view_count' => 0,
'download_count' => 0,
]);
foreach ($logViews as $logItem) {
try {
DB::table('resource_log_items')->insert([
'user_id' => $logItem->user_id,
'log_type' => \Entities\ResourceLogItem::VIEW,
'playlist_id' => $logItem->playlist_id,
'created_at' => $logItem->created_at,
'ip_address' => $logItem->ip_address,
]);
} catch (\Exception $e) {
$this->error('Could insert log item for playlist ' . $playlist->id . ' because ' . $e->getMessage());
}
}
foreach ($logDownload as $logItem) {
try {
DB::table('resource_log_items')->insert([
'user_id' => $logItem->user_id,
'log_type' => \Entities\ResourceLogItem::DOWNLOAD,
'playlist_id' => $logItem->playlist_id,
'created_at' => $logItem->created_at,
'ip_address' => $logItem->ip_address,
'track_format_id' => $logItem->track_file_format_id - 1
]);
} catch (\Exception $e) {
$this->error('Could insert log item for playlist ' . $playlist->id . ' because ' . $e->getMessage());
}
}
}
$this->info('Syncing Playlist Tracks');
$oldPlaylistTracks = $oldDb->table('playlist_track')->get();
foreach ($oldPlaylistTracks as $playlistTrack) {
DB::table('playlist_track')->insert([
'id' => $playlistTrack->id,
'created_at' => $playlistTrack->created_at,
'updated_at' => $playlistTrack->updated_at,
'position' => $playlistTrack->position,
'playlist_id' => $playlistTrack->playlist_id,
'track_id' => $playlistTrack->track_id
]);
}
$this->info('Syncing Comments');
$oldComments = $oldDb->table('comments')->get();
foreach ($oldComments as $comment) {
try {
DB::table('comments')->insert([
'id' => $comment->id,
'user_id' => $comment->user_id,
'created_at' => $comment->created_at,
'deleted_at' => $comment->deleted_at,
'updated_at' => $comment->updated_at,
'content' => $comment->content,
'track_id' => $comment->track_id,
'album_id' => $comment->album_id,
'playlist_id' => $comment->playlist_id,
'profile_id' => $comment->profile_id
]);
} catch (Exception $e) {
$this->error('Could not sync comment ' . $comment->id . ' because ' . $e->getMessage());
}
}
$this->info('Syncing Favourites');
$oldFavs = $oldDb->table('favourites')->get();
foreach ($oldFavs as $fav) {
try {
DB::table('favourites')->insert([
'id' => $fav->id,
'user_id' => $fav->user_id,
'created_at' => $fav->created_at,
'track_id' => $fav->track_id,
'album_id' => $fav->album_id,
'playlist_id' => $fav->playlist_id,
]);
} catch (Exception $e) {
$this->error('Could not sync favourite ' . $fav->id . ' because ' . $e->getMessage());
}
}
$this->info('Syncing Followers');
$oldFollowers = $oldDb->table('user_follower')->get();
foreach ($oldFollowers as $follower) {
try {
DB::table('followers')->insert([
'id' => $follower->id,
'user_id' => $follower->follower_id,
'artist_id' => $follower->user_id,
'created_at' => $follower->created_at,
]);
} catch (Exception $e) {
$this->error('Could not sync follower ' . $follower->id . ' because ' . $e->getMessage());
}
}
}
private function getIdDirectory($type, $id) {
$dir = (string) ( floor( $id / 100 ) * 100 );
return \Config::get('app.files_directory') . '/' . $type . '/' . $dir;
}
protected function getArguments() {
return [];
}
protected function getOptions() {
return [];
}
}

View file

@ -1,202 +0,0 @@
<?php
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
class RefreshCache extends Command {
protected $name = 'refresh-cache';
protected $description = 'Refreshes cache tables for views and downloads';
public function __construct() {
parent::__construct();
}
public function fire() {
DB::connection()->disableQueryLog();
DB::table('tracks')->update(['comment_count' => DB::raw('(SELECT COUNT(id) FROM comments WHERE comments.track_id = tracks.id AND deleted_at IS NULL)')]);
DB::table('albums')->update([
'comment_count' => DB::raw('(SELECT COUNT(id) FROM comments WHERE comments.album_id = albums.id AND deleted_at IS NULL)'),
'track_count' => DB::raw('(SELECT COUNT(id) FROM tracks WHERE album_id = albums.id)')
]);
DB::table('playlists')->update([
'comment_count' => DB::raw('(SELECT COUNT(id) FROM comments WHERE comments.playlist_id = playlists.id AND deleted_at IS NULL)'),
'track_count' => DB::raw('(SELECT COUNT(id) FROM playlist_track WHERE playlist_id = playlists.id)')
]);
DB::table('users')->update([
'comment_count' => DB::raw('(SELECT COUNT(id) FROM comments WHERE comments.profile_id = users.id AND deleted_at IS NULL)'),
'track_count' => DB::raw('(SELECT COUNT(id) FROM tracks WHERE deleted_at IS NULL AND published_at IS NOT NULL AND user_id = users.id)')
]);
$users = DB::table('users')->get();
$cacheItems = [];
$resources = [
'album' => [],
'playlist' => [],
'track' => []
];
foreach ($users as $user) {
$cacheItems[$user->id] = [
'album' => [],
'playlist' => [],
'track' => [],
];
}
$logItems = DB::table('resource_log_items')->get();
foreach ($logItems as $item) {
$type = '';
$id = 0;
if ($item->album_id) {
$type = 'album';
$id = $item->album_id;
}
else if ($item->playlist_id) {
$type = 'playlist';
$id = $item->playlist_id;
}
else if ($item->track_id) {
$type = 'track';
$id = $item->track_id;
}
$resource = $this->getCacheItem($resources, $type, $id);
if ($item->user_id != null) {
$userResource = $this->getUserCacheItem($cacheItems, $item->user_id, $type, $id);
if ($item->log_type == \Entities\ResourceLogItem::DOWNLOAD) {
$userResource['download_count']++;
}
else if ($item->log_type == \Entities\ResourceLogItem::VIEW) {
$userResource['view_count']++;
}
else if ($item->log_type == \Entities\ResourceLogItem::PLAY) {
$userResource['play_count']++;
}
$cacheItems[$item->user_id][$type][$id] = $userResource;
}
if ($item->log_type == \Entities\ResourceLogItem::DOWNLOAD) {
$resource['download_count']++;
}
else if ($item->log_type == \Entities\ResourceLogItem::VIEW) {
$resource['view_count']++;
}
else if ($item->log_type == \Entities\ResourceLogItem::PLAY) {
$resource['play_count']++;
}
$resources[$type][$id] = $resource;
}
$pins = DB::table('pinned_playlists')->get();
foreach ($pins as $pin) {
$userResource = $this->getUserCacheItem($cacheItems, $pin->user_id, 'playlist', $pin->playlist_id);
$userResource['is_pinned'] = true;
$cacheItems[$pin->user_id]['playlist'][$pin->playlist_id] = $userResource;
}
$favs = DB::table('favourites')->get();
foreach ($favs as $fav) {
$type = '';
$id = 0;
if ($fav->album_id) {
$type = 'album';
$id = $fav->album_id;
}
else if ($fav->playlist_id) {
$type = 'playlist';
$id = $fav->playlist_id;
}
else if ($fav->track_id) {
$type = 'track';
$id = $fav->track_id;
}
$userResource = $this->getUserCacheItem($cacheItems, $fav->user_id, $type, $id);
$userResource['is_favourited'] = true;
$cacheItems[$fav->user_id][$type][$id] = $userResource;
$resource = $this->getCacheItem($resources, $type, $id);
$resource['favourite_count']++;
$resources[$type][$id] = $resource;
}
foreach (DB::table('followers')->get() as $follower) {
$userResource = $this->getUserCacheItem($cacheItems, $follower->user_id, 'artist', $follower->artist_id);
$userResource['is_followed'] = true;
$cacheItems[$follower->user_id]['artist'][$follower->artist_id] = $userResource;
}
foreach ($resources as $name => $resourceArray) {
foreach ($resourceArray as $id => $resource) {
DB::table($name . 's')->whereId($id)->update($resource);
}
}
DB::table('resource_users')->delete();
foreach ($cacheItems as $cacheItem) {
foreach ($cacheItem as $resources) {
foreach ($resources as $resource) {
DB::table('resource_users')->insert($resource);
}
}
}
}
private function getCacheItem(&$resources, $type, $id) {
if (!isset($resources[$type][$id])) {
$item = [
'view_count' => 0,
'download_count' => 0,
'favourite_count' => 0,
];
if ($type == 'track')
$item['play_count'] = 0;
$resources[$type][$id] = $item;
return $item;
}
return $resources[$type][$id];
}
private function getUserCacheItem(&$items, $userId, $type, $id) {
if (!isset($items[$userId][$type][$id])) {
$item = [
'is_followed' => false,
'is_favourited' => false,
'is_pinned' => false,
'view_count' => 0,
'play_count' => 0,
'download_count' => 0,
'user_id' => $userId
];
$item[$type . '_id'] = $id;
$items[$userId][$type][$id] = $item;
return $item;
}
return $items[$userId][$type][$id];
}
protected function getArguments() {
return [];
}
protected function getOptions() {
return [];
}
}

View file

@ -1,190 +0,0 @@
<?php
return array(
'sendfile' => false,
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => false,
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| your application so that it is used when running Artisan tasks.
|
*/
'url' => 'http://pony.fm',
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/
'timezone' => 'UTC',
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/
'locale' => 'en',
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is used by the Illuminate encrypter service and should be set
| to a random, long string, otherwise these encrypted values will not
| be safe. Make sure to change it before deploying any application!
|
*/
'key' => 'AQUSDTDK5xA04yb9eO9iwlm72NpC8e90',
/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers
|--------------------------------------------------------------------------
|
| The service providers listed here will be automatically loaded on the
| request to your application. Feel free to add your own services to
| this array to grant expanded functionality to your applications.
|
*/
'providers' => array(
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
'Illuminate\Auth\AuthServiceProvider',
'Illuminate\Cache\CacheServiceProvider',
'Illuminate\Foundation\Providers\CommandCreatorServiceProvider',
'Illuminate\Session\CommandsServiceProvider',
'Illuminate\Foundation\Providers\ComposerServiceProvider',
'Illuminate\Routing\ControllerServiceProvider',
'Illuminate\Cookie\CookieServiceProvider',
'Illuminate\Database\DatabaseServiceProvider',
'Illuminate\Encryption\EncryptionServiceProvider',
'Illuminate\Filesystem\FilesystemServiceProvider',
'Illuminate\Hashing\HashServiceProvider',
'Illuminate\Html\HtmlServiceProvider',
'Illuminate\Foundation\Providers\KeyGeneratorServiceProvider',
'Illuminate\Log\LogServiceProvider',
'Illuminate\Mail\MailServiceProvider',
'Illuminate\Foundation\Providers\MaintenanceServiceProvider',
'Illuminate\Database\MigrationServiceProvider',
'Illuminate\Foundation\Providers\OptimizeServiceProvider',
'Illuminate\Pagination\PaginationServiceProvider',
'Illuminate\Foundation\Providers\PublisherServiceProvider',
'Illuminate\Queue\QueueServiceProvider',
'Illuminate\Redis\RedisServiceProvider',
'Illuminate\Auth\Reminders\ReminderServiceProvider',
'Illuminate\Foundation\Providers\RouteListServiceProvider',
'Illuminate\Database\SeedServiceProvider',
'Illuminate\Foundation\Providers\ServerServiceProvider',
'Illuminate\Session\SessionServiceProvider',
'Illuminate\Foundation\Providers\TinkerServiceProvider',
'Illuminate\Translation\TranslationServiceProvider',
'Illuminate\Validation\ValidationServiceProvider',
'Illuminate\View\ViewServiceProvider',
'Illuminate\Workbench\WorkbenchServiceProvider',
'Intouch\LaravelNewrelic\LaravelNewrelicServiceProvider',
),
/*
|--------------------------------------------------------------------------
| Service Provider Manifest
|--------------------------------------------------------------------------
|
| The service provider manifest is used by Laravel to lazy load service
| providers which are not needed for each request, as well to keep a
| list of all of the services. Here, you may set its storage spot.
|
*/
'manifest' => storage_path().'/meta',
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/
'aliases' => array(
'App' => 'Illuminate\Support\Facades\App',
'Artisan' => 'Illuminate\Support\Facades\Artisan',
'Auth' => 'Illuminate\Support\Facades\Auth',
'Blade' => 'Illuminate\Support\Facades\Blade',
'Cache' => 'Illuminate\Support\Facades\Cache',
'ClassLoader' => 'Illuminate\Support\ClassLoader',
'Config' => 'Illuminate\Support\Facades\Config',
'Controller' => 'Illuminate\Routing\Controllers\Controller',
'Cookie' => 'Illuminate\Support\Facades\Cookie',
'Crypt' => 'Illuminate\Support\Facades\Crypt',
'DB' => 'Illuminate\Support\Facades\DB',
'Eloquent' => 'Illuminate\Database\Eloquent\Model',
'Event' => 'Illuminate\Support\Facades\Event',
// 'File' => 'Illuminate\Support\Facades\File',
'Form' => 'Illuminate\Support\Facades\Form',
'Hash' => 'Illuminate\Support\Facades\Hash',
'HTML' => 'Illuminate\Support\Facades\HTML',
'Input' => 'Illuminate\Support\Facades\Input',
'Lang' => 'Illuminate\Support\Facades\Lang',
'Log' => 'Illuminate\Support\Facades\Log',
'Mail' => 'Illuminate\Support\Facades\Mail',
'Paginator' => 'Illuminate\Support\Facades\Paginator',
'Password' => 'Illuminate\Support\Facades\Password',
'Queue' => 'Illuminate\Support\Facades\Queue',
'Redirect' => 'Illuminate\Support\Facades\Redirect',
'Redis' => 'Illuminate\Support\Facades\Redis',
'Request' => 'Illuminate\Support\Facades\Request',
'Response' => 'Illuminate\Support\Facades\Response',
'Route' => 'Illuminate\Support\Facades\Route',
'Schema' => 'Illuminate\Support\Facades\Schema',
'Seeder' => 'Illuminate\Database\Seeder',
'Session' => 'Illuminate\Support\Facades\Session',
'Str' => 'Illuminate\Support\Str',
'URL' => 'Illuminate\Support\Facades\URL',
'Validator' => 'Illuminate\Support\Facades\Validator',
'View' => 'Illuminate\Support\Facades\View',
'Newrelic' => 'Intouch\LaravelNewrelic\Facades\Newrelic',
),
);

View file

@ -1,63 +0,0 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Default Authentication Driver
|--------------------------------------------------------------------------
|
| This option controls the authentication driver that will be utilized.
| This drivers manages the retrieval and authentication of the users
| attempting to get access to protected areas of your application.
|
| Supported: "database", "eloquent"
|
*/
'driver' => 'pfm',
/*
|--------------------------------------------------------------------------
| Authentication Model
|--------------------------------------------------------------------------
|
| When using the "Eloquent" authentication driver, we need to know which
| Eloquent model should be used to retrieve your users. Of course, it
| is often just the "User" model but you may use whatever you like.
|
*/
'model' => 'User',
/*
|--------------------------------------------------------------------------
| Authentication Table
|--------------------------------------------------------------------------
|
| When using the "Database" authentication driver, we need to know which
| table should be used to retrieve your users. We have chosen a basic
| default value but you may easily change it to any table you like.
|
*/
'table' => 'users',
/*
|--------------------------------------------------------------------------
| Password Reminder Settings
|--------------------------------------------------------------------------
|
| Here you may set the settings for password reminders, including a view
| that should be used as your password reminder e-mail. You will also
| be able to set the name of the table that holds the reset tokens.
|
*/
'reminder' => array(
'email' => 'emails.auth.reminder', 'table' => 'password_reminders',
),
);

View file

@ -1,89 +0,0 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Default Cache Driver
|--------------------------------------------------------------------------
|
| This option controls the default cache "driver" that will be used when
| using the Caching library. Of course, you may use other drivers any
| time you wish. This is the default when another is not specified.
|
| Supported: "file", "database", "apc", "memcached", "redis", "array"
|
*/
'driver' => 'file',
/*
|--------------------------------------------------------------------------
| File Cache Location
|--------------------------------------------------------------------------
|
| When using the "file" cache driver, we need a location where the cache
| files may be stored. A sensible default has been specified, but you
| are free to change it to any other place on disk that you desire.
|
*/
'path' => storage_path().'/cache',
/*
|--------------------------------------------------------------------------
| Database Cache Connection
|--------------------------------------------------------------------------
|
| When using the "database" cache driver you may specify the connection
| that should be used to store the cached items. When this option is
| null the default database connection will be utilized for cache.
|
*/
'connection' => null,
/*
|--------------------------------------------------------------------------
| Database Cache Table
|--------------------------------------------------------------------------
|
| When using the "database" cache driver we need to know the table that
| should be used to store the cached items. A default table name has
| been provided but you're free to change it however you deem fit.
|
*/
'table' => 'cache',
/*
|--------------------------------------------------------------------------
| Memcached Servers
|--------------------------------------------------------------------------
|
| Now you may specify an array of your Memcached servers that should be
| used when utilizing the Memcached cache driver. All of the servers
| should contain a value for "host", "port", and "weight" options.
|
*/
'memcached' => array(
array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 100),
),
/*
|--------------------------------------------------------------------------
| Cache Key Prefix
|--------------------------------------------------------------------------
|
| When utilizing a RAM based store such as APC or Memcached, there might
| be other applications utilizing the same cache. So, we'll specify a
| value to get prefixed to all our keys so we can avoid collisions.
|
*/
'prefix' => 'laravel',
);

View file

@ -1,18 +0,0 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Additional Compiled Classes
|--------------------------------------------------------------------------
|
| Here you may specify additional classes to include in the compiled file
| generated by the `artisan optimize` command. These should be classes
| that are included on basically every request into the application.
|
*/
);

View file

@ -1,124 +0,0 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| PDO Fetch Style
|--------------------------------------------------------------------------
|
| By default, database results will be returned as instances of the PHP
| stdClass object; however, you may desire to retrieve records in an
| array format for simplicity. Here you can tweak the fetch style.
|
*/
'fetch' => PDO::FETCH_CLASS,
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for all database work. Of course
| you may use many connections at once using the Database library.
|
*/
'default' => 'mysql',
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Here are each of the database connections setup for your application.
| Of course, examples of configuring each database platform that is
| supported by Laravel is shown below to make development simple.
|
|
| All database work in Laravel is done through the PHP PDO facilities
| so make sure you have the driver for your particular database of
| choice installed on your machine before you begin development.
|
*/
'connections' => array(
'sqlite' => array(
'driver' => 'sqlite',
'database' => __DIR__.'/../database/production.sqlite',
'prefix' => '',
),
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'database',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
'pgsql' => array(
'driver' => 'pgsql',
'host' => 'localhost',
'database' => 'database',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
),
'sqlsrv' => array(
'driver' => 'sqlsrv',
'host' => 'localhost',
'database' => 'database',
'username' => 'root',
'password' => '',
'prefix' => '',
),
),
/*
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk have not actually be run in the databases.
|
*/
'migrations' => 'migrations',
/*
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer set of commands than a typical key-value systems
| such as APC or Memcached. Laravel makes it easy to dig right in.
|
*/
'redis' => array(
'cluster' => true,
'default' => array(
'host' => '127.0.0.1',
'port' => 6379,
'database' => 0,
),
),
);

View file

@ -1,111 +0,0 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Mail Driver
|--------------------------------------------------------------------------
|
| Laravel supports both SMTP and PHP's "mail" function as drivers for the
| sending of e-mail. You may specify which one you're using throughout
| your application here. By default, Laravel is setup for SMTP mail.
|
| Supported: "smtp", "mail", "sendmail"
|
*/
'driver' => 'smtp',
/*
|--------------------------------------------------------------------------
| SMTP Host Address
|--------------------------------------------------------------------------
|
| Here you may provide the host address of the SMTP server used by your
| applications. A default option is provided that is compatible with
| the Postmark mail service, which will provide reliable delivery.
|
*/
'host' => 'smtp.mailgun.org',
/*
|--------------------------------------------------------------------------
| SMTP Host Port
|--------------------------------------------------------------------------
|
| This is the SMTP port used by your application to delivery e-mails to
| users of your application. Like the host we have set this value to
| stay compatible with the Postmark e-mail application by default.
|
*/
'port' => 587,
/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all e-mails sent by your application to be sent from
| the same address. Here, you may specify a name and address that is
| used globally for all e-mails that are sent by your application.
|
*/
'from' => array('address' => null, 'name' => null),
/*
|--------------------------------------------------------------------------
| E-Mail Encryption Protocol
|--------------------------------------------------------------------------
|
| Here you may specify the encryption protocol that should be used when
| the application send e-mail messages. A sensible default using the
| transport layer security protocol should provide great security.
|
*/
'encryption' => 'tls',
/*
|--------------------------------------------------------------------------
| SMTP Server Username
|--------------------------------------------------------------------------
|
| If your SMTP server requires a username for authentication, you should
| set it here. This will get used to authenticate with your server on
| connection. You may also set the "password" value below this one.
|
*/
'username' => null,
/*
|--------------------------------------------------------------------------
| SMTP Server Password
|--------------------------------------------------------------------------
|
| Here you may set the password required by your SMTP server to send out
| messages from your application. This will be given to the server on
| connection so that the application will be able to send messages.
|
*/
'password' => null,
/*
|--------------------------------------------------------------------------
| Sendmail System Path
|--------------------------------------------------------------------------
|
| When using the "sendmail" driver to send e-mails, we will need to know
| the path to where Sendmail lives on this server. A default path has
| been provided here, which will work well on most of your systems.
|
*/
'sendmail' => '/usr/sbin/sendmail -bs',
);

View file

@ -1,11 +0,0 @@
<?php
return [
'version' => 1,
'urls' => [
'api' => '',
'auth' => '',
'token' => ''
],
'client_id' => 0,
'secret' => ''
];

View file

@ -1,60 +0,0 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Default Queue Driver
|--------------------------------------------------------------------------
|
| The Laravel queue API supports a variety of back-ends via an unified
| API, giving you convenient access to each back-end using the same
| syntax for each one. Here you may set the default queue driver.
|
| Supported: "sync", "beanstalkd", "sqs", "iron"
|
*/
'default' => 'sync',
/*
|--------------------------------------------------------------------------
| Queue Connections
|--------------------------------------------------------------------------
|
| Here you may configure the connection information for each server that
| is used by your application. A default configuration has been added
| for each back-end shipped with Laravel. You are free to add more.
|
*/
'connections' => array(
'sync' => array(
'driver' => 'sync',
),
'beanstalkd' => array(
'driver' => 'beanstalkd',
'host' => 'localhost',
'queue' => 'default',
),
'sqs' => array(
'driver' => 'sqs',
'key' => 'your-public-key',
'secret' => 'your-secret-key',
'queue' => 'your-queue-url',
'region' => 'us-east-1',
),
'iron' => array(
'driver' => 'iron',
'project' => 'your-project-id',
'token' => 'your-token',
'queue' => 'your-queue-name',
),
),
);

View file

@ -1,125 +0,0 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Default Session Driver
|--------------------------------------------------------------------------
|
| This option controls the default session "driver" that will be used on
| requests. By default, we will use the lightweight native driver but
| you may specify any of the other wonderful drivers provided here.
|
| Supported: "native", "cookie", "database", "apc",
| "memcached", "redis", "array"
|
*/
'driver' => 'native',
/*
|--------------------------------------------------------------------------
| Session Lifetime
|--------------------------------------------------------------------------
|
| Here you may specify the number of minutes that you wish the session
| to be allowed to remain idle for it is expired. If you want them
| to immediately expire when the browser closes, set it to zero.
|
*/
'lifetime' => 120,
/*
|--------------------------------------------------------------------------
| Session File Location
|--------------------------------------------------------------------------
|
| When using the native session driver, we need a location where session
| files may be stored. A default has been set for you but a different
| location may be specified. This is only needed for file sessions.
|
*/
'files' => storage_path().'/sessions',
/*
|--------------------------------------------------------------------------
| Session Database Connection
|--------------------------------------------------------------------------
|
| When using the "database" session driver, you may specify the database
| connection that should be used to manage your sessions. This should
| correspond to a connection in your "database" configuration file.
|
*/
'connection' => null,
/*
|--------------------------------------------------------------------------
| Session Database Table
|--------------------------------------------------------------------------
|
| When using the "database" session driver, you may specify the table we
| should use to manage the sessions. Of course, a sensible default is
| provided for you; however, you are free to change this as needed.
|
*/
'table' => 'sessions',
/*
|--------------------------------------------------------------------------
| Session Sweeping Lottery
|--------------------------------------------------------------------------
|
| Some session drivers must manually sweep their storage location to get
| rid of old sessions from storage. Here are the chances that it will
| happen on a given request. By default, the odds are 2 out of 100.
|
*/
'lottery' => array(2, 100),
/*
|--------------------------------------------------------------------------
| Session Cookie Name
|--------------------------------------------------------------------------
|
| Here you may change the name of the cookie used to identify a session
| instance by ID. The name specified here will get used every time a
| new session cookie is created by the framework for every driver.
|
*/
'cookie' => 'laravel_session',
/*
|--------------------------------------------------------------------------
| Session Cookie Path
|--------------------------------------------------------------------------
|
| The session cookie path determines the path for which the cookie will
| be regarded as available. Typically, this will be the root path of
| your application but you are free to change this when necessary.
|
*/
'path' => '/',
/*
|--------------------------------------------------------------------------
| Session Cookie Domain
|--------------------------------------------------------------------------
|
| Here you may change the domain of the cookie used to identify a session
| in your application. This will determine which domains the cookie is
| available to in your application. A sensible default has been set.
|
*/
'domain' => null,
);

View file

@ -1,20 +0,0 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Default Cache Driver
|--------------------------------------------------------------------------
|
| This option controls the default cache "driver" that will be used when
| using the Caching library. Of course, you may use other drivers any
| time you wish. This is the default when another is not specified.
|
| Supported: "file", "database", "apc", "memcached", "redis", "array"
|
*/
'driver' => 'array',
);

View file

@ -1,21 +0,0 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Default Session Driver
|--------------------------------------------------------------------------
|
| This option controls the default session "driver" that will be used on
| requests. By default, we will use the lightweight native driver but
| you may specify any of the other wonderful drivers provided here.
|
| Supported: "native", "cookie", "database", "apc",
| "memcached", "redis", "array"
|
*/
'driver' => 'array',
);

View file

@ -1,31 +0,0 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| View Storage Paths
|--------------------------------------------------------------------------
|
| Most templating systems load templates from disk. Here you may specify
| an array of paths that should be checked for your views. Of course
| the usual Laravel view path has already been registered for you.
|
*/
'paths' => array(__DIR__.'/../views'),
/*
|--------------------------------------------------------------------------
| Pagination View
|--------------------------------------------------------------------------
|
| This view will be used to render the pagination link output, and can
| be easily customized here to show any view you like. A clean view
| compatible with Twitter's Bootstrap is given to you by default.
|
*/
'pagination' => 'pagination::slider',
);

View file

@ -1,31 +0,0 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Workbench Author Name
|--------------------------------------------------------------------------
|
| When you create new packages via the Artisan "workbench" command your
| name is needed to generate the composer.json file for your package.
| You may specify it now so it is used for all of your workbenches.
|
*/
'name' => '',
/*
|--------------------------------------------------------------------------
| Workbench Author E-Mail Address
|--------------------------------------------------------------------------
|
| Like the option above, your e-mail address is used when generating new
| workbench packages. The e-mail is placed in your composer.json file
| automatically after the package is created by the workbench tool.
|
*/
'email' => '',
);

View file

@ -1,14 +0,0 @@
<?php
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Redirect;
class AccountController extends Controller {
public function getIndex() {
return View::make('shared.null');
}
public function getRegister() {
return Redirect::to(Config::get('poniverse.urls')['register']);
}
}

View file

@ -1,54 +0,0 @@
<?php
use Entities\Album;
use Entities\ResourceLogItem;
use Entities\Track;
class AlbumsController extends Controller {
public function getIndex() {
return View::make('albums.index');
}
public function getShow($id, $slug) {
$album = Album::find($id);
if (!$album)
App::abort(404);
if ($album->slug != $slug)
return Redirect::action('AlbumsController@getAlbum', [$id, $album->slug]);
return View::make('albums.show');
}
public function getShortlink($id) {
$album = Album::find($id);
if (!$album)
App::abort(404);
return Redirect::action('AlbumsController@getTrack', [$id, $album->slug]);
}
public function getDownload($id, $extension) {
$album = Album::with('tracks', 'user')->find($id);
if (!$album)
App::abort(404);
$format = null;
$formatName = null;
foreach (Track::$Formats as $name => $item) {
if ($item['extension'] == $extension) {
$format = $item;
$formatName = $name;
break;
}
}
if ($format == null)
App::abort(404);
ResourceLogItem::logItem('album', $id, ResourceLogItem::DOWNLOAD, $format['index']);
$downloader = new AlbumDownloader($album, $formatName);
$downloader->download();
}
}

View file

@ -1,40 +0,0 @@
<?php namespace Api\Mobile;
use Entities\Track;
class TracksController extends Controller
{
public function latest()
{
$tracks = Track::summary()
->userDetails()
->listed()
->explicitFilter()
->published()
->with('user', 'genre', 'cover', 'album', 'album.user')->take(10);
$json = [
'total_tracks' => $tracks->count(),
'tracks' => $tracks->toArray()
];
return Response::json($json, 200);
}
public function popular()
{
$tracks = Track::popular(10)
->userDetails()
->listed()
->explicitFilter()
->published()
->with('user', 'genre', 'cover', 'album', 'album.user')->take(10);
$json = [
'total_tracks' => $tracks->count(),
'tracks' => $tracks->toArray()
];
return Response::json($json, 200);
}
}

View file

@ -1,94 +0,0 @@
<?php
namespace Api\V1;
use Commands\DeleteTrackCommand;
use Commands\EditTrackCommand;
use Commands\UploadTrackCommand;
use Cover;
use Entities\Favourite;
use Entities\Image;
use Entities\ResourceLogItem;
use Entities\ResourceUser;
use Entities\Track;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Response;
class TracksController extends \ApiControllerBase {
public function getTrackRadioDetails($hash) {
$track = Track
::with('user', 'album', 'user.avatar', 'cover', 'comments', 'genre')
->published()
->whereHash($hash)->first();
if (!$track)
return Response::json(['message' => 'Track not found.'], 403);
$comments = [];
foreach ($track->comments as $comment) {
$comments[] = [
'id' => $comment->id,
'created_at' => $comment->created_at,
'content' => $comment->content,
'user' => [
'name' => $comment->user->display_name,
'id' => $comment->user->id,
'url' => $comment->user->url,
'avatars' => [
'normal' => $comment->user->getAvatarUrl(Image::NORMAL),
'thumbnail' => $comment->user->getAvatarUrl(Image::THUMBNAIL),
'small' => $comment->user->getAvatarUrl(Image::SMALL),
]
]
];
}
return Response::json([
'id' => $track->id,
'title' => $track->title,
'description' => $track->description,
'lyrics' => $track->lyrics,
'user' => [
'id' => $track->user->id,
'name' => $track->user->display_name,
'url' => $track->user->url,
'avatars' => [
'thumbnail' => $track->user->getAvatarUrl(Image::THUMBNAIL),
'small' => $track->user->getAvatarUrl(Image::SMALL),
'normal' => $track->user->getAvatarUrl(Image::NORMAL)
]
],
'stats' => [
'views' => $track->view_count,
'plays' => $track->play_count,
'downloads' => $track->download_count,
'comments' => $track->comment_count,
'favourites' => $track->favourite_count
],
'url' => $track->url,
'is_vocal' => !!$track->is_vocal,
'is_explicit' => !!$track->is_explicit,
'is_downloadable' => !!$track->is_downloadable,
'published_at' => $track->published_at,
'duration' => $track->duration,
'genre' => $track->genre != null
?
[
'id' => $track->genre->id,
'name' => $track->genre->name
] : null,
'type' => [
'id' => $track->track_type->id,
'name' => $track->track_type->title
],
'covers' => [
'thumbnail' => $track->getCoverUrl(Image::THUMBNAIL),
'small' => $track->getCoverUrl(Image::SMALL),
'normal' => $track->getCoverUrl(Image::NORMAL)
],
'comments' => $comments
], 200);
}
}

View file

@ -1,38 +0,0 @@
<?php
namespace Api\Web;
use Commands\CreateAlbumCommand;
use Commands\DeleteAlbumCommand;
use Commands\DeleteTrackCommand;
use Commands\EditAlbumCommand;
use Commands\EditTrackCommand;
use Commands\SaveAccountSettingsCommand;
use Cover;
use Entities\Album;
use Entities\Image;
use Entities\Track;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Response;
class AccountController extends \ApiControllerBase {
public function getSettings() {
$user = Auth::user();
return Response::json([
'bio' => $user->bio,
'can_see_explicit_content' => $user->can_see_explicit_content == 1,
'display_name' => $user->display_name,
'sync_names' => $user->sync_names == 1,
'mlpforums_name' => $user->mlpforums_name,
'gravatar' => $user->gravatar ? $user->gravatar : $user->email,
'avatar_url' => !$user->uses_gravatar ? $user->getAvatarUrl() : null,
'uses_gravatar' => $user->uses_gravatar == 1
], 200);
}
public function postSave() {
return $this->execute(new SaveAccountSettingsCommand(Input::all()));
}
}

View file

@ -1,131 +0,0 @@
<?php
namespace Api\Web;
use Commands\CreateAlbumCommand;
use Commands\DeleteAlbumCommand;
use Commands\EditAlbumCommand;
use Entities\Album;
use Entities\Comment;
use Entities\Image;
use Entities\ResourceLogItem;
use Entities\Track;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Response;
class AlbumsController extends \ApiControllerBase {
public function postCreate() {
return $this->execute(new CreateAlbumCommand(Input::all()));
}
public function postEdit($id) {
return $this->execute(new EditAlbumCommand($id, Input::all()));
}
public function postDelete($id) {
return $this->execute(new DeleteAlbumCommand($id));
}
public function getShow($id) {
$album = Album::with([
'tracks' => function($query) { $query->userDetails(); },
'tracks.cover',
'tracks.genre',
'tracks.user',
'user',
'comments',
'comments.user'])
->userDetails()
->find($id);
if (!$album)
App::abort(404);
if (Input::get('log')) {
ResourceLogItem::logItem('album', $id, ResourceLogItem::VIEW);
$album->view_count++;
}
$returned_album = Album::mapPublicAlbumShow($album);
if($returned_album['is_downloadable'] == 0) {
unset($returned_album['formats']);
}
return Response::json([
'album' => $returned_album
], 200);
}
public function getIndex() {
$page = 1;
if (Input::has('page'))
$page = Input::get('page');
$query = Album::summary()
->with('user', 'user.avatar', 'cover')
->userDetails()
->orderBy('created_at', 'desc')
->where('track_count', '>', 0);
$count = $query->count();
$perPage = 40;
$query->skip(($page - 1) * $perPage)->take($perPage);
$albums = [];
foreach ($query->get() as $album) {
$albums[] = Album::mapPublicAlbumSummary($album);
}
return Response::json(["albums" => $albums, "current_page" => $page, "total_pages" => ceil($count / $perPage)], 200);
}
public function getOwned() {
$query = Album::summary()->where('user_id', \Auth::user()->id)->orderBy('created_at', 'desc')->get();
$albums = [];
foreach ($query as $album) {
$albums[] = [
'id' => $album->id,
'title' => $album->title,
'slug' => $album->slug,
'created_at' => $album->created_at,
'covers' => [
'small' => $album->getCoverUrl(Image::SMALL),
'normal' => $album->getCoverUrl(Image::NORMAL)
]
];
}
return Response::json($albums, 200);
}
public function getEdit($id) {
$album = Album::with('tracks')->find($id);
if (!$album)
return $this->notFound('Album ' . $id . ' not found!');
if ($album->user_id != Auth::user()->id)
return $this->notAuthorized();
$tracks = [];
foreach ($album->tracks as $track) {
$tracks[] = [
'id' => $track->id,
'title' => $track->title
];
}
return Response::json([
'id' => $album->id,
'title' => $album->title,
'user_id' => $album->user_id,
'slug' => $album->slug,
'created_at' => $album->created_at,
'published_at' => $album->published_at,
'description' => $album->description,
'cover_url' => $album->hasCover() ? $album->getCoverUrl(Image::NORMAL) : null,
'real_cover_url' => $album->getCoverUrl(Image::NORMAL),
'tracks' => $tracks
], 200);
}
}

View file

@ -1,180 +0,0 @@
<?php
namespace Api\Web;
use Commands\CreateAlbumCommand;
use Commands\DeleteAlbumCommand;
use Commands\DeleteTrackCommand;
use Commands\EditAlbumCommand;
use Commands\EditTrackCommand;
use Cover;
use Entities\Album;
use Entities\Comment;
use Entities\Favourite;
use Entities\Image;
use Entities\Track;
use Entities\User;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Response;
class ArtistsController extends \ApiControllerBase {
public function getFavourites($slug) {
$user = User::whereSlug($slug)->first();
if (!$user)
App::abort(404);
$favs = Favourite::whereUserId($user->id)->with([
'track.genre',
'track.cover',
'track.user',
'album.cover',
'album.user',
'track' => function($query) { $query->userDetails(); },
'album' => function($query) { $query->userDetails(); }])->get();
$tracks = [];
$albums = [];
foreach ($favs as $fav) {
if ($fav->type == 'Entities\Track') {
$tracks[] = Track::mapPublicTrackSummary($fav->track);
}
else if ($fav->type == 'Entities\Album') {
$albums[] = Album::mapPublicAlbumSummary($fav->album);
}
}
return Response::json([
'tracks' => $tracks,
'albums' => $albums
], 200);
}
public function getContent($slug) {
$user = User::whereSlug($slug)->first();
if (!$user)
App::abort(404);
$query = Track::summary()->published()->listed()->explicitFilter()->with('genre', 'cover', 'user')->userDetails()->whereUserId($user->id)->whereNotNull('published_at');
$tracks = [];
$singles = [];
foreach ($query->get() as $track) {
if ($track->album_id != null)
$tracks[] = Track::mapPublicTrackSummary($track);
else
$singles[] = Track::mapPublicTrackSummary($track);
}
$query = Album::summary()
->with('user')
->orderBy('created_at', 'desc')
->where('track_count', '>', 0)
->whereUserId($user->id);
$albums = [];
foreach ($query->get() as $album) {
$albums[] = Album::mapPublicAlbumSummary($album);
}
return Response::json(['singles' => $singles, 'albumTracks' => $tracks, 'albums' => $albums], 200);
}
public function getShow($slug) {
$user = User::whereSlug($slug)
->userDetails()
->with(['comments' => function ($query) { $query->with('user'); }])
->first();
if (!$user)
App::abort(404);
$trackQuery = Track::summary()
->published()
->explicitFilter()
->listed()
->with('genre', 'cover', 'user')
->userDetails()
->whereUserId($user->id)
->whereNotNull('published_at')
->orderBy('created_at', 'desc')
->take(20);
$latestTracks = [];
foreach ($trackQuery->get() as $track) {
$latestTracks[] = Track::mapPublicTrackSummary($track);
}
$comments = [];
foreach ($user->comments as $comment) {
$comments[] = Comment::mapPublic($comment);
}
$userData = [
'is_following' => false
];
if ($user->users->count()) {
$userRow = $user->users[0];
$userData = [
'is_following' => $userRow->is_followed
];
}
return Response::json([
'artist' => [
'id' => $user->id,
'name' => $user->display_name,
'slug' => $user->slug,
'is_archived' => $user->is_archived,
'avatars' => [
'small' => $user->getAvatarUrl(Image::SMALL),
'normal' => $user->getAvatarUrl(Image::NORMAL)
],
'created_at' => $user->created_at,
'followers' => [],
'following' => [],
'latest_tracks' => $latestTracks,
'comments' => $comments,
'bio' => $user->bio,
'mlpforums_username' => $user->mlpforums_name,
'message_url' => $user->message_url,
'user_data' => $userData
]
], 200);
}
public function getIndex() {
$page = 1;
if (Input::has('page'))
$page = Input::get('page');
$query = User::orderBy('created_at', 'desc')
->where('track_count', '>', 0);
$count = $query->count();
$perPage = 40;
$query->skip(($page - 1) * $perPage)->take($perPage);
$users = [];
foreach ($query->get() as $user) {
$users[] = [
'id' => $user->id,
'name' => $user->display_name,
'slug' => $user->slug,
'url' => $user->url,
'is_archived' => $user->is_archived,
'avatars' => [
'small' => $user->getAvatarUrl(Image::SMALL),
'normal' => $user->getAvatarUrl(Image::NORMAL)
],
'created_at' => $user->created_at
];
}
return Response::json(["artists" => $users, "current_page" => $page, "total_pages" => ceil($count / $perPage)], 200);
}
}

View file

@ -1,11 +0,0 @@
<?php
namespace Api\Web;
use Commands\RegisterUserCommand;
class AuthController extends \Controller {
public function postLogout() {
\Auth::logout();
}
}

View file

@ -1,42 +0,0 @@
<?php
namespace Api\Web;
use Commands\CreateCommentCommand;
use Entities\Album;
use Entities\Comment;
use Entities\Image;
use Entities\Playlist;
use Entities\Track;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Response;
class CommentsController extends \ApiControllerBase {
public function postCreate($type, $id) {
return $this->execute(new CreateCommentCommand($type, $id, Input::all()));
}
public function getIndex($type, $id) {
$column = '';
if ($type == 'track')
$column = 'track_id';
else if ($type == 'user')
$column = 'profile_id';
else if ($type == 'album')
$column = 'album_id';
else if ($type == 'playlist')
$column = 'playlist_id';
else
App::abort(500);
$query = Comment::where($column, '=', $id)->orderBy('created_at', 'desc')->with('user');
$comments = [];
foreach ($query->get() as $comment) {
$comments[] = Comment::mapPublic($comment);
}
return Response::json(['list' => $comments, 'count' => count($comments)]);
}
}

View file

@ -1,45 +0,0 @@
<?php
namespace Api\Web;
use Commands\DeleteTrackCommand;
use Commands\EditTrackCommand;
use Commands\UploadTrackCommand;
use Cover;
use Entities\Image;
use Entities\News;
use Entities\Track;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Response;
class DashboardController extends \ApiControllerBase {
public function getIndex() {
$recentQuery = Track::summary()
->with(['genre', 'user', 'cover', 'user.avatar'])
->whereIsLatest(true)
->listed()
->userDetails()
->explicitFilter()
->published()
->orderBy('published_at', 'desc')
->take(30);
$recentTracks = [];
foreach ($recentQuery->get() as $track) {
$recentTracks[] = Track::mapPublicTrackSummary($track);
}
return Response::json([
'recent_tracks' => $recentTracks,
'popular_tracks' => Track::popular(30, Auth::check() && Auth::user()->can_see_explicit_content),
'news' => News::getNews(0, 10)], 200);
}
public function postReadNews() {
News::markPostAsRead(Input::get('url'));
return Response::json([
]);
}
}

View file

@ -1,98 +0,0 @@
<?php
namespace Api\Web;
use Commands\ToggleFavouriteCommand;
use Entities\Album;
use Entities\Favourite;
use Entities\Playlist;
use Entities\Track;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Response;
class FavouritesController extends \ApiControllerBase {
public function postToggle() {
return $this->execute(new ToggleFavouriteCommand(Input::get('type'), Input::get('id')));
}
public function getTracks() {
$query = Favourite
::whereUserId(Auth::user()->id)
->whereNotNull('track_id')
->with([
'track' => function($query) {
$query
->userDetails()
->published();
},
'track.user',
'track.genre',
'track.cover',
'track.album',
'track.album.user'
]);
$tracks = [];
foreach ($query->get() as $fav) {
if ($fav->track == null) // deleted track
continue;
$tracks[] = Track::mapPublicTrackSummary($fav->track);
}
return Response::json(["tracks" => $tracks], 200);
}
public function getAlbums() {
$query = Favourite
::whereUserId(Auth::user()->id)
->whereNotNull('album_id')
->with([
'album' => function($query) {
$query->userDetails();
},
'album.user',
'album.user.avatar',
'album.cover'
]);
$albums = [];
foreach ($query->get() as $fav) {
if ($fav->album == null) // deleted album
continue;
$albums[] = Album::mapPublicAlbumSummary($fav->album);
}
return Response::json(["albums" => $albums], 200);
}
public function getPlaylists() {
$query = Favourite
::whereUserId(Auth::user()->id)
->whereNotNull('playlist_id')
->with([
'playlist' => function($query) {
$query->userDetails();
},
'playlist.user',
'playlist.user.avatar',
'playlist.tracks',
'playlist.tracks.cover'
]);
$playlists = [];
foreach ($query->get() as $fav) {
if ($fav->playlist == null) // deleted playlist
continue;
$playlists[] = Playlist::mapPublicPlaylistSummary($fav->playlist);
}
return Response::json(["playlists" => $playlists], 200);
}
}

View file

@ -1,13 +0,0 @@
<?php
namespace Api\Web;
use Commands\ToggleFavouriteCommand;
use Commands\ToggleFollowingCommand;
use Illuminate\Support\Facades\Input;
class FollowController extends \ApiControllerBase {
public function postToggle() {
return $this->execute(new ToggleFollowingCommand(Input::get('type'), Input::get('id')));
}
}

View file

@ -1,34 +0,0 @@
<?php
namespace Api\Web;
use Commands\DeleteTrackCommand;
use Commands\EditTrackCommand;
use Commands\UploadTrackCommand;
use Cover;
use Entities\Image;
use Entities\Track;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Response;
class ImagesController extends \ApiControllerBase {
public function getOwned() {
$query = Image::where('uploaded_by', \Auth::user()->id);
$images = [];
foreach ($query->get() as $image) {
$images[] = [
'id' => $image->id,
'urls' => [
'small' => $image->getUrl(Image::SMALL),
'normal' => $image->getUrl(Image::NORMAL),
'thumbnail' => $image->getUrl(Image::THUMBNAIL),
'original' => $image->getUrl(Image::ORIGINAL)
],
'filename' => $image->filename
];
}
return Response::json($images, 200);
}
}

View file

@ -1,118 +0,0 @@
<?php
namespace Api\Web;
use Commands\AddTrackToPlaylistCommand;
use Commands\CreatePlaylistCommand;
use Commands\DeletePlaylistCommand;
use Commands\EditPlaylistCommand;
use Entities\Album;
use Entities\Comment;
use Entities\Image;
use Entities\Playlist;
use Entities\ResourceLogItem;
use Entities\Track;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Response;
class PlaylistsController extends \ApiControllerBase {
public function postCreate() {
return $this->execute(new CreatePlaylistCommand(Input::all()));
}
public function postEdit($id) {
return $this->execute(new EditPlaylistCommand($id, Input::all()));
}
public function postDelete($id) {
return $this->execute(new DeletePlaylistCommand($id, Input::all()));
}
public function postAddTrack($id) {
return $this->execute(new AddTrackToPlaylistCommand($id, Input::get('track_id')));
}
public function getIndex() {
$page = 1;
if (Input::has('page'))
$page = Input::get('page');
$query = Playlist::summary()
->with('user', 'user.avatar', 'tracks', 'tracks.cover', 'tracks.user', 'tracks.album', 'tracks.album.user')
->userDetails()
->orderBy('created_at', 'desc')
->where('track_count', '>', 0)
->whereIsPublic(true);
$count = $query->count();
$perPage = 40;
$query->skip(($page - 1) * $perPage)->take($perPage);
$playlists = [];
foreach ($query->get() as $playlist) {
$playlists[] = Playlist::mapPublicPlaylistSummary($playlist);
}
return Response::json(["playlists" => $playlists, "current_page" => $page, "total_pages" => ceil($count / $perPage)], 200);
}
public function getShow($id) {
$playlist = Playlist::with(['tracks.user', 'tracks.genre', 'tracks.cover', 'tracks.album', 'tracks' => function($query) { $query->userDetails(); }, 'comments', 'comments.user'])->userDetails()->find($id);
if (!$playlist || !$playlist->canView(Auth::user()))
App::abort('404');
if (Input::get('log')) {
ResourceLogItem::logItem('playlist', $id, ResourceLogItem::VIEW);
$playlist->view_count++;
}
return Response::json(Playlist::mapPublicPlaylistShow($playlist), 200);
}
public function getPinned() {
$query = Playlist
::userDetails()
->with('tracks', 'tracks.cover', 'tracks.user', 'user')
->join('pinned_playlists', function($join) {
$join->on('playlist_id', '=', 'playlists.id');
})
->where('pinned_playlists.user_id', '=', Auth::user()->id)
->orderBy('title', 'asc')
->select('playlists.*')
->get();
$playlists = [];
foreach ($query as $playlist) {
$mapped = Playlist::mapPublicPlaylistSummary($playlist);
$mapped['description'] = $playlist->description;
$mapped['is_pinned'] = true;
$playlists[] = $mapped;
}
return Response::json($playlists, 200);
}
public function getOwned() {
$query = Playlist::summary()->with('pins', 'tracks', 'tracks.cover')->where('user_id', \Auth::user()->id)->orderBy('title', 'asc')->get();
$playlists = [];
foreach ($query as $playlist) {
$playlists[] = [
'id' => $playlist->id,
'title' => $playlist->title,
'slug' => $playlist->slug,
'created_at' => $playlist->created_at,
'description' => $playlist->description,
'url' => $playlist->url,
'covers' => [
'small' => $playlist->getCoverUrl(Image::SMALL),
'normal' => $playlist->getCoverUrl(Image::NORMAL)
],
'is_pinned' => $playlist->hasPinFor(Auth::user()->id),
'is_public' => $playlist->is_public == 1
];
}
return Response::json($playlists, 200);
}
}

View file

@ -1,24 +0,0 @@
<?php
namespace Api\Web;
use Entities\ProfileRequest;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Response;
class ProfilerController extends \Controller {
public function getRequest($id) {
if (!Config::get('app.debug'))
return;
$key = 'profiler-request-' . $id;
$request = Cache::get($key);
if (!$request)
exit();
Cache::forget($key);
return Response::json(['request' => ProfileRequest::load($request)->toArray()], 200);
}
}

View file

@ -1,20 +0,0 @@
<?php
namespace Api\Web;
use Entities\Genre;
use Entities\License;
use Entities\ShowSong;
use Entities\TrackType;
use Illuminate\Support\Facades\DB;
class TaxonomiesController extends \ApiControllerBase {
public function getAll() {
return \Response::json([
'licenses' => License::all()->toArray(),
'genres' => Genre::select('genres.*', DB::raw('(SELECT COUNT(id) FROM tracks WHERE tracks.genre_id = genres.id AND tracks.published_at IS NOT NULL) AS track_count'))->orderBy('name')->get()->toArray(),
'track_types' => TrackType::select('track_types.*', DB::raw('(SELECT COUNT(id) FROM tracks WHERE tracks.track_type_id = track_types.id AND tracks.published_at IS NOT NULL) AS track_count'))->get()->toArray(),
'show_songs' => ShowSong::select('title', 'id', 'slug', DB::raw('(SELECT COUNT(tracks.id) FROM show_song_track INNER JOIN tracks ON tracks.id = show_song_track.track_id WHERE show_song_track.show_song_id = show_songs.id AND tracks.published_at IS NOT NULL) AS track_count'))->get()->toArray()
], 200);
}
}

View file

@ -1,139 +0,0 @@
<?php
namespace Api\Web;
use Commands\DeleteTrackCommand;
use Commands\EditTrackCommand;
use Commands\UploadTrackCommand;
use Cover;
use Entities\Favourite;
use Entities\Image;
use Entities\ResourceLogItem;
use Entities\ResourceUser;
use Entities\Track;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Response;
class TracksController extends \ApiControllerBase {
public function postUpload() {
session_write_close();
return $this->execute(new UploadTrackCommand());
}
public function postDelete($id) {
return $this->execute(new DeleteTrackCommand($id));
}
public function postEdit($id) {
return $this->execute(new EditTrackCommand($id, Input::all()));
}
public function getShow($id) {
$track = Track::userDetails()->withComments()->find($id);
if (!$track || !$track->canView(Auth::user()))
return $this->notFound('Track not found!');
if (Input::get('log')) {
ResourceLogItem::logItem('track', $id, ResourceLogItem::VIEW);
$track->view_count++;
}
$returned_track = Track::mapPublicTrackShow($track);
if ($returned_track['is_downloadable'] != 1) {
unset($returned_track['formats']);
}
return Response::json(['track' => $returned_track], 200);
}
public function getIndex() {
$page = 1;
$perPage = 45;
if (Input::has('page'))
$page = Input::get('page');
$query = Track::summary()
->userDetails()
->listed()
->explicitFilter()
->published()
->with('user', 'genre', 'cover', 'album', 'album.user');
$this->applyFilters($query);
$totalCount = $query->count();
$query->take($perPage)->skip($perPage * ($page - 1));
$tracks = [];
$ids = [];
foreach ($query->get(['tracks.*']) as $track) {
$tracks[] = Track::mapPublicTrackSummary($track);
$ids[] = $track->id;
}
return Response::json(["tracks" => $tracks, "current_page" => $page, "total_pages" => ceil($totalCount / $perPage)], 200);
}
public function getOwned() {
$query = Track::summary()->where('user_id', \Auth::user()->id)->orderBy('created_at', 'desc');
$tracks = [];
foreach ($query->get() as $track)
$tracks[] = Track::mapPrivateTrackSummary($track);
return Response::json($tracks, 200);
}
public function getEdit($id) {
$track = Track::with('showSongs')->find($id);
if (!$track)
return $this->notFound('Track ' . $id . ' not found!');
if ($track->user_id != Auth::user()->id)
return $this->notAuthorized();
return Response::json(Track::mapPrivateTrackShow($track), 200);
}
private function applyFilters($query) {
if (Input::has('order')) {
$order = \Input::get('order');
$parts = explode(',', $order);
$query->orderBy($parts[0], $parts[1]);
}
if (Input::has('is_vocal')) {
$isVocal = \Input::get('is_vocal');
if ($isVocal == 'true')
$query->whereIsVocal(true);
else
$query->whereIsVocal(false);
}
if (Input::has('in_album')) {
if (Input::get('in_album') == 'true')
$query->whereNotNull('album_id');
else
$query->whereNull('album_id');
}
if (Input::has('genres'))
$query->whereIn('genre_id', Input::get('genres'));
if (Input::has('types'))
$query->whereIn('track_type_id', Input::get('types'));
if (Input::has('songs')) {
$query->join('show_song_track', function($join) {
$join->on('tracks.id', '=', 'show_song_track.track_id');
});
$query->whereIn('show_song_track.show_song_id', Input::get('songs'));
}
return $query;
}
}

View file

@ -1,23 +0,0 @@
<?php
abstract class ApiControllerBase extends Controller {
protected function execute($command) {
if (!$command->authorize())
return $this->notAuthorized();
$result = $command->execute();
if ($result->didFail()) {
return Response::json(['message' => 'Validation failed', 'errors' => $result->getValidator()->messages()->getMessages()], 400);
}
return Response::json($result->getResponse(), 200);
}
public function notAuthorized() {
return Response::json(['message' => 'You may not do this!'], 403);
}
public function notFound($message) {
return Response::json(['message' => $message], 403);
}
}

View file

@ -1,25 +0,0 @@
<?php
use Entities\User;
class ArtistsController extends Controller {
public function getIndex() {
return View::make('artists.index');
}
public function getProfile($slug) {
$user = User::whereSlug($slug)->first();
if (!$user)
App::abort('404');
return View::make('artists.profile');
}
public function getShortlink($id) {
$user = User::find($id);
if (!$user)
App::abort('404');
return Redirect::action('ArtistsController@getProfile', [$id]);
}
}

View file

@ -1,94 +0,0 @@
<?php
use Entities\User;
class AuthController extends Controller {
protected $poniverse;
public function __construct() {
$this->poniverse = new Poniverse(Config::get('poniverse.client_id'), Config::get('poniverse.secret'));
$this->poniverse->setRedirectUri(URL::to('/auth/oauth'));
}
public function getLogin() {
if (Auth::guest())
return Redirect::to($this->poniverse->getAuthenticationUrl('login'));
return Redirect::to('/');
}
public function postLogout() {
Auth::logout();
return Redirect::to('/');
}
public function getOAuth() {
$code = $this->poniverse->getClient()->getAccessToken(
Config::get('poniverse.urls')['token'],
'authorization_code',
[
'code' => Input::query('code'),
'redirect_uri' => URL::to('/auth/oauth')
]);
if($code['code'] != 200) {
if($code['code'] == 400 && $code['result']['error_description'] == 'The authorization code has expired' && !isset($this->request['login_attempt'])) {
return Redirect::to($this->poniverse->getAuthenticationUrl('login_attempt'));
}
return Redirect::to('/')->with('message', 'Unfortunately we are having problems attempting to log you in at the moment. Please try again at a later time.' );
}
$this->poniverse->setAccessToken($code['result']['access_token']);
$poniverseUser = $this->poniverse->getUser();
$token = DB::table('oauth2_tokens')->where('external_user_id', '=', $poniverseUser['id'])->where('service', '=', 'poniverse')->first();
$setData = [
'access_token' => $code['result']['access_token'],
'expires' => date( 'Y-m-d H:i:s', strtotime("+".$code['result']['expires_in']." Seconds", time())),
'type' => $code['result']['token_type'],
];
if(isset($code['result']['refresh_token']) && !empty($code['result']['refresh_token'])) {
$setData['refresh_token'] = $code['result']['refresh_token'];
}
if($token) {
//User already exists, update access token and refresh token if provided.
DB::table('oauth2_tokens')->where('id', '=', $token->id)->update($setData);
return $this->loginRedirect(User::find($token->user_id));
}
//Check by email to see if they already have an account
$localMember = User::where('email', '=', $poniverseUser['email'])->first();
if ($localMember) {
return $this->loginRedirect($localMember);
}
$user = new User;
$user->mlpforums_name = $poniverseUser['username'];
$user->display_name = $poniverseUser['display_name'];
$user->email = $poniverseUser['email'];
$user->created_at = gmdate("Y-m-d H:i:s", time());
$user->uses_gravatar = 1;
$user->save();
//We need to insert a new token row :O
$setData['user_id'] = $user->id;
$setData['external_user_id'] = $poniverseUser['id'];
$setData['service'] = 'poniverse';
DB::table('oauth2_tokens')->insert($setData);
return $this->loginRedirect($user);
}
protected function loginRedirect($user, $rememberMe = true) {
Auth::login($user, $rememberMe);
return Redirect::to('/');
}
}

View file

@ -1,15 +0,0 @@
<?php
class ContentController extends Controller {
public function getTracks() {
return View::make('shared.null');
}
public function getAlbums() {
return View::make('shared.null');
}
public function getPlaylists() {
return View::make('shared.null');
}
}

View file

@ -1,15 +0,0 @@
<?php
class FavouritesController extends Controller {
public function getTracks() {
return View::make('shared.null');
}
public function getAlbums() {
return View::make('shared.null');
}
public function getPlaylists() {
return View::make('shared.null');
}
}

View file

@ -1,9 +0,0 @@
<?php
use Entities\Track;
class HomeController extends Controller {
public function getIndex() {
return View::make('home.index');
}
}

View file

@ -1,43 +0,0 @@
<?php
use Entities\Image;
use Entities\Track;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Redirect;
class ImagesController extends Controller {
public function getImage($id, $type) {
$coverType = Image::getImageTypeFromName($type);
if ($coverType == null)
App::abort(404);
$image = Image::find($id);
if (!$image)
App::abort(404);
$response = Response::make('', 200);
$filename = $image->getFile($coverType['id']);
if (!is_file($filename)) {
$redirect = URL::to('/images/icons/profile_' . Image::$ImageTypes[$coverType['id']]['name'] . '.png');
return Redirect::to($redirect);
}
if (Config::get('app.sendfile')) {
$response->header('X-Sendfile', $filename);
} else {
$response->header('X-Accel-Redirect', $filename);
}
$response->header('Content-Disposition', 'filename="' . $filename . '"');
$response->header('Content-Type', 'image/png');
$lastModified = filemtime($filename);
$response->header('Last-Modified', $lastModified);
$response->header('Cache-Control', 'max-age=' . (60 * 60 * 24 * 7));
return $response;
}
}

View file

@ -1,55 +0,0 @@
<?php
use Entities\Playlist;
use Entities\ResourceLogItem;
use Entities\Track;
use Illuminate\Support\Facades\Redirect;
class PlaylistsController extends Controller {
public function getIndex() {
return View::make('playlists.index');
}
public function getPlaylist($id, $slug) {
$playlist = Playlist::find($id);
if (!$playlist || !$playlist->canView(Auth::user()))
App::abort(404);
if ($playlist->slug != $slug)
return Redirect::action('PlaylistsController@getPlaylist', [$id, $playlist->slug]);
return View::make('playlists.show');
}
public function getShortlink($id) {
$playlist = Playlist::find($id);
if (!$playlist || !$playlist->canView(Auth::user()))
App::abort(404);
return Redirect::action('PlaylistsController@getPlaylist', [$id, $playlist->slug]);
}
public function getDownload($id, $extension) {
$playlist = Playlist::with('tracks', 'user', 'tracks.album')->find($id);
if (!$playlist || !$playlist->is_public)
App::abort(404);
$format = null;
$formatName = null;
foreach (Track::$Formats as $name => $item) {
if ($item['extension'] == $extension) {
$format = $item;
$formatName = $name;
break;
}
}
if ($format == null)
App::abort(404);
ResourceLogItem::logItem('playlist', $id, ResourceLogItem::DOWNLOAD, $format['index']);
$downloader = new PlaylistDownloader($playlist, $formatName);
$downloader->download();
}
}

View file

@ -1,131 +0,0 @@
<?php
use Entities\ResourceLogItem;
use Entities\Track;
use Entities\TrackFile;
use Illuminate\Support\Facades\App;
class TracksController extends Controller {
public function getIndex() {
return View::make('tracks.index');
}
public function getEmbed($id) {
$track = Track
::whereId($id)
->published()
->userDetails()
->with(
'user',
'user.avatar',
'genre'
)->first();
if (!$track || !$track->canView(Auth::user()))
App::abort(404);
$userData = [
'stats' => [
'views' => 0,
'plays' => 0,
'downloads' => 0
],
'is_favourited' => false
];
if ($track->users->count()) {
$userRow = $track->users[0];
$userData = [
'stats' => [
'views' => $userRow->view_count,
'plays' => $userRow->play_count,
'downloads' => $userRow->download_count,
],
'is_favourited' => $userRow->is_favourited
];
}
return View::make('tracks.embed', ['track' => $track, 'user' => $userData]);
}
public function getTrack($id, $slug) {
$track = Track::find($id);
if (!$track || !$track->canView(Auth::user()))
App::abort(404);
if ($track->slug != $slug)
return Redirect::action('TracksController@getTrack', [$id, $track->slug]);
return View::make('tracks.show');
}
public function getShortlink($id) {
$track = Track::find($id);
if (!$track || !$track->canView(Auth::user()))
App::abort(404);
return Redirect::action('TracksController@getTrack', [$id, $track->slug]);
}
public function getStream($id, $extension) {
$track = Track::find($id);
if (!$track || !$track->canView(Auth::user()))
App::abort(404);
$trackFile = TrackFile::findOrFailByExtension($track->id, $extension);
ResourceLogItem::logItem('track', $id, ResourceLogItem::PLAY, $trackFile->getFormat()['index']);
$response = Response::make('', 200);
$filename = $trackFile->getFile();
if (Config::get('app.sendfile')) {
$response->header('X-Sendfile', $filename);
} else {
$response->header('X-Accel-Redirect', $filename);
}
$time = gmdate(filemtime($filename));
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $time == $_SERVER['HTTP_IF_MODIFIED_SINCE']) {
header('HTTP/1.0 304 Not Modified');
exit();
}
$response->header('Last-Modified', $time);
$response->header('Content-Type', $trackFile->getFormat()['mime_type']);
return $response;
}
public function getDownload($id, $extension) {
$track = Track::find($id);
if (!$track || !$track->canView(Auth::user()))
App::abort(404);
$trackFile = TrackFile::findOrFailByExtension($track->id, $extension);
ResourceLogItem::logItem('track', $id, ResourceLogItem::DOWNLOAD, $trackFile->getFormat()['index']);
$response = Response::make('', 200);
$filename = $trackFile->getFile();
if (Config::get('app.sendfile')) {
$response->header('X-Sendfile', $filename);
$response->header('Content-Disposition', 'attachment; filename="' . $trackFile->getDownloadFilename() . '"');
} else {
$response->header('X-Accel-Redirect', $filename);
$response->header('Content-Disposition', 'attachment; filename="' . $trackFile->getDownloadFilename() . '"');
}
$time = gmdate(filemtime($filename));
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $time == $_SERVER['HTTP_IF_MODIFIED_SINCE']) {
header('HTTP/1.0 304 Not Modified');
exit();
}
$response->header('Last-Modified', $time);
$response->header('Content-Type', $trackFile->getFormat()['mime_type']);
return $response;
}
}

View file

@ -1,7 +0,0 @@
<?php
class UploaderController extends Controller {
public function getIndex() {
return View::make('shared.null');
}
}

View file

@ -1,19 +0,0 @@
<?php
use Entities\Track;
use Illuminate\Support\Facades\App;
class UsersController extends Controller {
public function getAvatar($id, $type) {
$coverType = Cover::getCoverFromName($type);
if ($coverType == null)
App::abort(404);
$user = User::find($id);
if (!$user)
App::abort(404);
return File::inline($user->getAvatarFile($coverType['id']), 'image/png', 'cover.png');
}
}

View file

@ -1,57 +0,0 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration {
public function up() {
Schema::create('users', function(Blueprint $table) {
$table->increments('id');
$table->string('display_name', 255);
$table->string('mlpforums_name')->nullable();
$table->boolean('sync_names')->default(true);
$table->string('email', 150)->indexed();
$table->string('gravatar')->nullable();
$table->string('slug');
$table->boolean('uses_gravatar')->default(true);
$table->boolean('can_see_explicit_content');
$table->text('bio');
$table->integer('track_count')->unsigned();
$table->integer('comment_count')->unsigned();
$table->timestamps();
});
Schema::create('roles', function($table){
$table->increments('id');
$table->string('name');
});
Schema::create('role_user', function($table){
$table->increments('id');
$table->integer('user_id')->unsigned()->index();
$table->integer('role_id')->unsigned()->index();
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('role_id')->references('id')->on('roles');
});
Schema::create('cache', function($table){
$table->string('key')->index();
$table->text('value');
$table->integer('expiration')->unsigned()->index();
});
DB::table('roles')->insert(['name' => 'super_admin']);
DB::table('roles')->insert(['name' => 'admin']);
DB::table('roles')->insert(['name' => 'moderator']);
DB::table('roles')->insert(['name' => 'user']);
}
public function down() {
Schema::drop('cache');
Schema::drop('role_user');
Schema::drop('roles');
Schema::drop('users');
}
}

View file

@ -1,128 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
class CreateTracksTable extends Migration {
public function up() {
Schema::create('licenses', function($table){
$table->increments('id');
$table->string('title', 100);
$table->text('description');
$table->boolean('affiliate_distribution');
$table->boolean('open_distribution');
$table->boolean('remix');
});
Schema::create('genres', function($table){
$table->increments('id');
$table->string('name')->unique();
$table->string('slug', 200)->index();
});
Schema::create('track_types', function($table){
$table->increments('id');
$table->string('title');
$table->string('editor_title');
});
Schema::create('tracks', function($table){
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->integer('license_id')->unsigned()->nullable()->default(NULL);
$table->integer('genre_id')->unsigned()->nullable()->index()->default(NULL);
$table->integer('track_type_id')->unsigned()->nullable()->default(NULL);
$table->string('title', 100)->index();
$table->string('slug', 200)->index();
$table->text('description')->nullable();
$table->text('lyrics')->nullable();
$table->boolean('is_vocal');
$table->boolean('is_explicit');
$table->integer('cover_id')->unsigned()->nullable();
$table->boolean('is_downloadable');
$table->float('duration')->unsigned();
$table->integer('play_count')->unsigned();
$table->integer('view_count')->unsigned();
$table->integer('download_count')->unsigned();
$table->integer('favourite_count')->unsigned();
$table->integer('comment_count')->unsigned();
$table->timestamps();
$table->timestamp('deleted_at')->nullable()->index();
$table->timestamp('published_at')->nullable()->index();
$table->timestamp('released_at')->nullable();
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('license_id')->references('id')->on('licenses');
$table->foreign('genre_id')->references('id')->on('genres')->on_update('cascade');
$table->foreign('track_type_id')->references('id')->on('track_types')->on_update('cascade');
});
DB::table('licenses')->insert([
'title' => 'Personal',
'description' => 'Only you and Pony.fm are allowed to distribute and broadcast the track.',
'affiliate_distribution' => 0,
'open_distribution' => 0,
'remix' => 0
]);
DB::table('licenses')->insert([
'title' => 'Broadcast',
'description' => 'You, Pony.fm, and its affiliates may distribute and broadcast the track.',
'affiliate_distribution' => 1,
'open_distribution' => 0,
'remix' => 0
]);
DB::table('licenses')->insert([
'title' => 'Open',
'description' => 'Anyone is permitted to broadcast and distribute the song in its original form, with attribution to you.',
'affiliate_distribution' => 1,
'open_distribution' => 1,
'remix' => 0
]);
DB::table('licenses')->insert([
'title' => 'Remix',
'description' => 'Anyone is permitted to broadcast and distribute the song in any form, or create derivative works based on it for any purpose, with attribution to you.',
'affiliate_distribution' => 1,
'open_distribution' => 1,
'remix' => 1
]);
DB::table('track_types')->insert([
'title' => 'Original Song',
'editor_title' => 'an original song'
]);
DB::table('track_types')->insert([
'title' => 'Official Song Remix',
'editor_title' => 'a remix of an official song'
]);
DB::table('track_types')->insert([
'title' => 'Fan Song Remix',
'editor_title' => 'a remix of a fan song'
]);
DB::table('track_types')->insert([
'title' => 'Ponified Song',
'editor_title' => 'a non-pony song, turned pony'
]);
DB::table('track_types')->insert([
'title' => 'Official Show Audio Remix',
'editor_title' => 'a remix of official show audio'
]);
}
public function down() {
Schema::drop('tracks');
Schema::drop('licenses');
Schema::drop('track_types');
Schema::drop('genres');
}
}

View file

@ -1,44 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
class CreateImagesTable extends Migration {
public function up() {
Schema::create('images', function($table) {
$table->increments('id');
$table->string('filename', 256);
$table->string('mime', 100);
$table->string('extension', 32);
$table->integer('size');
$table->string('hash', 32);
$table->integer('uploaded_by')->unsigned();
$table->timestamps();
$table->foreign('uploaded_by')->references('id')->on('users');
});
Schema::table('users', function($table) {
$table->integer('avatar_id')->unsigned()->nullable();
$table->foreign('avatar_id')->references('id')->on('images');
});
DB::table('tracks')->update(['cover_id' => null]);
Schema::table('tracks', function($table) {
$table->foreign('cover_id')->references('id')->on('images');
});
}
public function down() {
Schema::table('tracks', function($table) {
$table->dropForeign('tracks_cover_id_foreign');
});
Schema::table('users', function($table) {
$table->dropForeign('users_avatar_id_foreign');
$table->dropColumn('avatar_id');
});
Schema::drop('images');
}
}

View file

@ -1,45 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
class CreateAlbums extends Migration {
public function up() {
Schema::create('albums', function($table) {
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->string('title')->index();
$table->string('slug')->index();
$table->text('description');
$table->integer('cover_id')->unsigned()->nullable();
$table->integer('track_count')->unsigned();
$table->integer('view_count')->unsigned();
$table->integer('download_count')->unsigned();
$table->integer('favourite_count')->unsigned();
$table->integer('comment_count')->unsigned();
$table->timestamps();
$table->timestamp('deleted_at')->nullable()->index();
$table->foreign('cover_id')->references('id')->on('images');
$table->foreign('user_id')->references('id')->on('users');
});
Schema::table('tracks', function($table) {
$table->integer('album_id')->unsigned()->nullable();
$table->integer('track_number')->unsigned()->nullable();
$table->foreign('album_id')->references('id')->on('albums');
});
}
public function down() {
Schema::table('tracks', function($table) {
$table->dropForeign('tracks_album_id_foreign');
$table->dropColumn('album_id');
$table->dropColumn('track_number');
});
Schema::drop('albums');
}
}

View file

@ -1,67 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
class CreatePlaylists extends Migration {
public function up() {
Schema::create('playlists', function($table) {
$table->increments('id');
$table->integer('user_id')->unsigned()->index();
$table->string('title');
$table->string('slug');
$table->text('description');
$table->boolean('is_public');
$table->integer('track_count')->unsigned();
$table->integer('view_count')->unsigned();
$table->integer('download_count')->unsigned();
$table->integer('favourite_count')->unsigned();
$table->integer('follow_count')->unsigned();
$table->integer('comment_count')->unsigned();
$table->timestamps();
$table->date('deleted_at')->nullable()->index();
$table->foreign('user_id')->references('id')->on('users')->on_update('cascade');
});
Schema::create('playlist_track', function($table){
$table->increments('id');
$table->timestamps();
$table->integer('playlist_id')->unsigned()->index();
$table->integer('track_id')->unsigned()->index();
$table->integer('position')->unsigned();
$table->foreign('playlist_id')->references('id')->on('playlists')->on_update('cascade')->on_delete('cascade');
$table->foreign('track_id')->references('id')->on('tracks')->on_update('cascade');
});
Schema::create('pinned_playlists', function($table) {
$table->increments('id');
$table->integer('user_id')->unsigned()->index();
$table->integer('playlist_id')->unsigned()->index();
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users')->on_update('cascade');
$table->foreign('playlist_id')->references('id')->on('playlists')->on_update('cascade');
});
}
public function down() {
Schema::table('playlist_track', function($table){
$table->dropForeign('playlist_track_playlist_id_foreign');
$table->dropForeign('playlist_track_track_id_foreign');
});
Schema::drop('playlist_track');
Schema::drop('pinned_playlists');
Schema::table('playlists', function($table){
$table->dropForeign('playlists_user_id_foreign');
});
Schema::drop('playlists');
}
}

View file

@ -1,38 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
class CreateComments extends Migration {
public function up() {
Schema::create('comments', function($table){
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->string('ip_address', 46);
$table->text('content');
$table->timestamps();
$table->timestamp('deleted_at')->nullable()->index();
$table->integer('profile_id')->unsigned()->nullable()->index();
$table->integer('track_id')->unsigned()->nullable()->index();
$table->integer('album_id')->unsigned()->nullable()->index();
$table->integer('playlist_id')->unsigned()->nullable()->index();
$table->foreign('profile_id')->references('id')->on('users');
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('track_id')->references('id')->on('tracks');
$table->foreign('album_id')->references('id')->on('albums');
$table->foreign('playlist_id')->references('id')->on('playlists');
});
}
public function down() {
Schema::table('comments', function($table){
$table->dropForeign('comments_user_id_foreign');
$table->dropForeign('comments_track_id_foreign');
$table->dropForeign('comments_album_id_foreign');
$table->dropForeign('comments_playlist_id_foreign');
});
Schema::drop('comments');
}
}

View file

@ -1,57 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
class CreateUserTables extends Migration {
public function up() {
Schema::create('resource_users', function($table){
$table->increments('id');
$table->integer('user_id')->unsigned()->index();
$table->integer('track_id')->unsigned()->nullable()->index();
$table->integer('album_id')->unsigned()->nullable()->index();
$table->integer('playlist_id')->unsigned()->nullable()->index();
$table->integer('artist_id')->unsigned()->nullable()->index();
$table->boolean('is_followed');
$table->boolean('is_favourited');
$table->boolean('is_pinned');
$table->integer('view_count');
$table->integer('play_count');
$table->integer('download_count');
$table->foreign('artist_id')->references('id')->on('users')->on_delete('cascade');
$table->foreign('user_id')->references('id')->on('users')->on_delete('cascade');
$table->foreign('track_id')->references('id')->on('tracks')->on_delete('cascade');;
$table->foreign('album_id')->references('id')->on('albums')->on_delete('cascade');;
$table->foreign('playlist_id')->references('id')->on('playlists')->on_delete('cascade');;
$table->unique(['user_id', 'track_id', 'album_id', 'playlist_id', 'artist_id'], 'resource_unique');
});
Schema::create('resource_log_items', function($table){
$table->increments('id');
$table->integer('user_id')->unsigned()->nullable()->index();
$table->integer('log_type')->unsigned();
$table->string('ip_address', 46)->index();
$table->integer('track_format_id')->unsigned()->nullable();
$table->integer('track_id')->unsigned()->nullable()->index();
$table->integer('album_id')->unsigned()->nullable()->index();
$table->integer('playlist_id')->unsigned()->nullable()->index();
$table->timestamp('created_at');
$table->foreign('user_id')->references('id')->on('users')->on_delete('cascade');
$table->foreign('track_id')->references('id')->on('tracks');
$table->foreign('album_id')->references('id')->on('albums');
$table->foreign('playlist_id')->references('id')->on('playlists');
});
}
public function down() {
Schema::drop('resource_users');
Schema::drop('resource_log_items');
}
}

View file

@ -1,34 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
class CreateFavourites extends Migration {
public function up() {
Schema::create('favourites', function($table){
$table->increments('id');
$table->integer('user_id')->unsigned()->index();
$table->integer('track_id')->unsigned()->nullable()->index();
$table->integer('album_id')->unsigned()->nullable()->index();
$table->integer('playlist_id')->unsigned()->nullable()->index();
$table->timestamp('created_at');
$table->foreign('user_id')->references('id')->on('users')->on_delete('cascade');
$table->foreign('track_id')->references('id')->on('tracks');
$table->foreign('album_id')->references('id')->on('albums');
$table->foreign('playlist_id')->references('id')->on('playlists');
});
}
public function down() {
Schema::table('favourites', function($table){
$table->dropForeign('favourites_user_id_foreign');
$table->dropForeign('favourites_track_id_foreign');
$table->dropForeign('favourites_album_id_foreign');
$table->dropForeign('favourites_playlist_id_foreign');
});
Schema::drop('favourites');
}
}

View file

@ -1,25 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
class CreateFollowers extends Migration {
public function up() {
Schema::create('followers', function($table){
$table->increments('id');
$table->integer('user_id')->unsigned()->index();
$table->integer('artist_id')->unsigned()->nullable()->index();
$table->integer('playlist_id')->unsigned()->nullable()->index();
$table->timestamp('created_at');
$table->foreign('user_id')->references('id')->on('users')->on_delete('cascade');
$table->foreign('artist_id')->references('id')->on('users')->on_delete('cascade');
$table->foreign('playlist_id')->references('id')->on('playlists');
});
}
public function down() {
Schema::drop('followers');
}
}

View file

@ -1,22 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
class Oauth extends Migration {
public function up() {
Schema::create('oauth2_tokens', function($table) {
$table->increments('id');
$table->integer('user_id');
$table->integer('external_user_id');
$table->text('access_token');
$table->timestamp('expires');
$table->text('refresh_token');
$table->string('type');
$table->string('service');
});
}
public function down() {
Schema::drop('oauth2_tokens');
}
}

View file

@ -1,21 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
class CreateNewsTable extends Migration {
public function up() {
Schema::create('news', function($table){
$table->increments('id');
$table->integer('user_id')->unsigned()->index();
$table->string('post_hash', 32)->index();
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
}
public function down() {
Schema::drop('news');
}
}

View file

@ -1,37 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
class CreateLatestColumn extends Migration {
public function up() {
Schema::table('tracks', function($table) {
$table->boolean('is_latest')->notNullable()->indexed();
});
DB::update('
UPDATE
tracks
SET
is_latest = true
WHERE
(
SELECT
t2.id
FROM
(SELECT id, user_id FROM tracks WHERE published_at IS NOT NULL AND deleted_at IS NULL) AS t2
WHERE
t2.user_id = tracks.user_id
ORDER BY
created_at DESC
LIMIT 1
) = tracks.id
AND
published_at IS NOT NULL');
}
public function down() {
Schema::table('tracks', function($table) {
$table->dropColumn('is_latest');
});
}
}

View file

@ -1,23 +0,0 @@
<?php
use Entities\Track;
use Illuminate\Database\Migrations\Migration;
class CreateTrackHashes extends Migration {
public function up() {
Schema::table('tracks', function($table) {
$table->string('hash', 32)->notNullable()->indexed();
});
foreach (Track::with('user')->get() as $track) {
$track->updateHash();
$track->save();
}
}
public function down() {
Schema::table('tracks', function($table) {
$table->dropColumn('hash');
});
}
}

View file

@ -1,23 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
class TrackIsListed extends Migration {
public function up() {
Schema::table('tracks', function($table) {
$table->boolean('is_listed')->notNullable()->indexed();
});
DB::update('
UPDATE
tracks
SET
is_listed = true');
}
public function down() {
Schema::table('tracks', function($table) {
$table->dropColumn('is_listed');
});
}
}

View file

@ -1,16 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Entities\Track;
class UpdateTrackHash extends Migration {
public function up() {
foreach (Track::with('user')->get() as $track) {
$track->updateHash();
$track->save();
}
}
public function down() {
}
}

View file

@ -1,17 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
class AddRememberMeField extends Migration {
public function up() {
Schema::table('users', function($table) {
$table->string('remember_token', 100)->nullable()->indexed();
});
}
public function down() {
Schema::table('users', function($table) {
$table->dropColumn('remember_token');
});
}
}

View file

@ -1,31 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
class AddArchivedProfileField extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function ( $table ) {
$table->boolean( 'is_archived' )->default(false);
} );
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table( 'users', function ( $table ) {
$table->dropColumn( 'is_archived' );
} );
}
}

View file

@ -1,54 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Entities\Track;
use Entities\TrackFile;
class CreateTrackFilesTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// Fill in the table
DB::transaction(function(){
Schema::create('track_files', function($table){
$table->increments('id');
$table->integer('track_id')->unsigned()->indexed();
$table->boolean('is_master')->default(false)->indexed();
$table->string('format')->indexed();
$table->foreign('track_id')->references('id')->on('tracks');
$table->timestamps();
});
foreach (Track::all() as $track){
foreach (Track::$Formats as $name => $item) {
DB::table('track_files')->insert(
[
'track_id' => $track->id,
'is_master' => $name === 'FLAC' ? true : false,
'format' => $name,
'created_at'=> $track->created_at,
'updated_at'=> Carbon\Carbon::now()
]
);
}
}
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('track_files');
}
}

View file

@ -1,17 +0,0 @@
<?php
class DatabaseSeeder extends Seeder {
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Eloquent::unguard();
// $this->call('UserTableSeeder');
}
}

View file

@ -1,106 +0,0 @@
<?php
/*
|--------------------------------------------------------------------------
| Application & Route Filters
|--------------------------------------------------------------------------
|
| Below you will find the "before" and "after" events for the application
| which may be used to do any work before or after a request into your
| application. Here you may also register your custom route filters.
|
*/
use Illuminate\Support\Facades\DB;
if (Config::get('app.debug')) {
$profiler = \Entities\ProfileRequest::create();
function processResponse($profiler, $request, $response) {
$profiler->after($request, $response);
Cache::put('profiler-request-' . $profiler->getId(), $profiler->toString(), 2);
header('X-Request-Id: ' . $profiler->getId());
}
App::error(function($exception) use ($profiler) {
$profiler->log('error', $exception->__toString(), []);
processResponse($profiler, null, null);
});
App::after(function($request, $response) use ($profiler) {
if ($response->headers->get('content-type') != 'application/json')
return;
processResponse($profiler, $request, $response);
});
Log::listen(function($level, $message, $context) use ($profiler) {
$profiler->log($level, $message, $context);
});
App::error(function($exception) {
// return Response::view('errors.500', array(), 404);
});
}
App::missing(function($exception) {
return Response::view('errors.404', array(), 404);
});
/*
|--------------------------------------------------------------------------
| Authentication Filters
|--------------------------------------------------------------------------
|
| The following filters are used to verify that the user of the current
| session is logged into this application. The "basic" filter easily
| integrates HTTP Basic authentication for quick, simple checking.
|
*/
Route::filter('auth', function()
{
if (Auth::guest()) return Redirect::guest('login');
});
Route::filter('auth.basic', function()
{
return Auth::basic();
});
/*
|--------------------------------------------------------------------------
| Guest Filter
|--------------------------------------------------------------------------
|
| The "guest" filter is the counterpart of the authentication filters as
| it simply checks that the current user is not logged in. A redirect
| response will be issued if they are, which you may freely change.
|
*/
Route::filter('guest', function()
{
if (Auth::check()) return Redirect::to('/');
});
/*
|--------------------------------------------------------------------------
| CSRF Protection Filter
|--------------------------------------------------------------------------
|
| The CSRF filter is responsible for protecting your application against
| cross-site request forgery attacks. If this special token in a user
| session does not match the one given in this request, we'll bail.
|
*/
Route::filter('csrf', function()
{
if (Session::token() != Input::get('_token') && Session::token() != Request::header('X-Token')) {
throw new Illuminate\Session\TokenMismatchException;
}
});

View file

@ -1,20 +0,0 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Pagination Language Lines
|--------------------------------------------------------------------------
|
| The following language lines are used by the paginator library to build
| the simple pagination links. You are free to change them to anything
| you want to customize your views to better match your application.
|
*/
'previous' => '&laquo; Previous',
'next' => 'Next &raquo;',
);

View file

@ -1,22 +0,0 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Password Reminder Language Lines
|--------------------------------------------------------------------------
|
| The following language lines are the default lines which match reasons
| that are given by the password broker for a password update attempt
| has failed, such as for an invalid token or invalid new password.
|
*/
"password" => "Passwords must be six characters and match the confirmation.",
"user" => "We can't find a user with that e-mail address.",
"token" => "This password reset token is invalid.",
);

View file

@ -1,104 +0,0 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Validation Language Lines
|--------------------------------------------------------------------------
|
| The following language lines contain the default error messages used by
| the validator class. Some of these rules have multiple versions such
| such as the size rules. Feel free to tweak each of these messages.
|
*/
"accepted" => "The :attribute must be accepted.",
"active_url" => "The :attribute is not a valid URL.",
"after" => "The :attribute must be a date after :date.",
"alpha" => "The :attribute may only contain letters.",
"alpha_dash" => "The :attribute may only contain letters, numbers, and dashes.",
"alpha_num" => "The :attribute may only contain letters and numbers.",
"before" => "The :attribute must be a date before :date.",
"between" => array(
"numeric" => "The :attribute must be between :min - :max.",
"file" => "The :attribute must be between :min - :max kilobytes.",
"string" => "The :attribute must be between :min - :max characters.",
),
"confirmed" => "The :attribute confirmation does not match.",
"date" => "The :attribute is not a valid date.",
"date_format" => "The :attribute does not match the format :format.",
"different" => "The :attribute and :other must be different.",
"digits" => "The :attribute must be :digits digits.",
"digits_between" => "The :attribute must be between :min and :max digits.",
"email" => "The :attribute format is invalid.",
"exists" => "The selected :attribute is invalid.",
"image" => "The :attribute must be an image.",
"in" => "The selected :attribute is invalid.",
"integer" => "The :attribute must be an integer.",
"ip" => "The :attribute must be a valid IP address.",
"max" => array(
"numeric" => "The :attribute may not be greater than :max.",
"file" => "The :attribute may not be greater than :max kilobytes.",
"string" => "The :attribute may not be greater than :max characters.",
),
"mimes" => "The :attribute must be a file of type: :values.",
"min" => array(
"numeric" => "The :attribute must be at least :min.",
"file" => "The :attribute must be at least :min kilobytes.",
"string" => "The :attribute must be at least :min characters.",
),
"not_in" => "The selected :attribute is invalid.",
"numeric" => "The :attribute must be a number.",
"regex" => "The :attribute format is invalid.",
"required" => "The :attribute field is required.",
"required_if" => "The :attribute field is required when :other is :value.",
"required_with" => "The :attribute field is required when :values is present.",
"required_without" => "The :attribute field is required when :values is not present.",
"same" => "The :attribute and :other must match.",
"size" => array(
"numeric" => "The :attribute must be :size.",
"file" => "The :attribute must be :size kilobytes.",
"string" => "The :attribute must be :size characters.",
),
"unique" => "The :attribute has already been taken.",
"url" => "The :attribute format is invalid.",
/*
|--------------------------------------------------------------------------
| Custom Validation Language Lines
|--------------------------------------------------------------------------
|
| Here you may specify custom validation messages for attributes using the
| convention "attribute.rule" to name the lines. This makes it quick to
| specify a specific custom language line for a given attribute rule.
|
*/
'custom' => array(),
//=== CUSTOM VALIDATION MESSAGES ===//
"audio" => "The :attribute must be an audio file.",
"audio_channels" => "The :attribute contains an invalid number of channels.",
"audio_format" => "The :attribute does not contain audio in a valid format.",
"required_when" => "The :attribute field cannot be left blank.",
"sample_rate" => "The :attribute has an invalid sample rate.",
"min_width" => "The :attribute is not wide enough.",
"min_height" => "The :attribute is not tall enough.",
"textarea_length" => "The :attribute must be less than 250 characters long.", // @TODO: Figure out how to retrieve the parameter from the validation rule
/*
|--------------------------------------------------------------------------
| Custom Validation Attributes
|--------------------------------------------------------------------------
|
| The following language lines are used to swap attribute place-holders
| with something more reader friendly such as E-Mail Address instead
| of "email". This simply helps us make messages a little cleaner.
|
*/
'attributes' => array(),
);

View file

@ -1,107 +0,0 @@
<?php
use Assetic\Asset\AssetCollection;
use Assetic\Asset\FileAsset;
use Assetic\Asset\GlobAsset;
use Assetic\Filter\CoffeeScriptFilter;
class Assets {
public static function scriptIncludes($area = 'app') {
if (!Config::get("app.debug"))
return '<script src="/build/scripts/' . $area . '.js?' . filemtime("./build/scripts/" . $area . ".js") . '"></script>';
$scripts = self::mergeGlobs(self::getScriptsForArea($area));
$retVal = "";
foreach ($scripts as $script) {
$filename = self::replaceExtensionWith($script, ".coffee", ".js");
$retVal .= "<script src='/build/$filename?" . filemtime('./build/' . $filename) . "'></script>";
}
return $retVal;
}
public static function styleIncludes($area = 'app') {
if (!Config::get("app.debug"))
return '<script>document.write(\'<link rel="stylesheet" href="build/styles/' . $area . '.css?' . filemtime("build/styles/" . $area . ".css") . '" />\');</script>';
$styles = self::mergeGlobs(self::getStylesForArea($area));
$retVal = "";
foreach ($styles as $style) {
$filename = self::replaceExtensionWith($style, ".less", ".css");
$retVal .= "<link rel='stylesheet' href='/build/$filename?" . filemtime('./build/' . $filename) . "' />";
}
return $retVal;
}
private static function replaceExtensionWith($filename, $fromExtension, $toExtension) {
$fromLength = strlen($fromExtension);
return substr($filename, -$fromLength) == $fromExtension
? substr($filename, 0, strlen($filename) - $fromLength) . $toExtension
: $filename;
}
/** Merges an array of paths that are passed into "glob" into a list of unique filenames.
* Note that this method assumes the globs should be relative to the "app" folder of this project */
private static function mergeGlobs($globs) {
$files = [];
$filesFound = [];
foreach ($globs as $glob) {
foreach (glob("../app/" . $glob, GLOB_BRACE) as $file) {
if (isset($filesFound[$file]))
continue;
$filesFound[$file] = true;
$files[] = substr($file, 7); // chop off ../app/
}
}
return $files;
}
private static function getScriptsForArea($area) {
if ($area == 'app') {
return [
"scripts/base/jquery-2.0.2.js",
"scripts/base/angular.js",
"scripts/base/*.{coffee,js}",
"scripts/shared/*.{coffee,js}",
"scripts/app/*.{coffee,js}",
"scripts/app/services/*.{coffee,js}",
"scripts/app/filters/*.{coffee,js}",
"scripts/app/directives/*.{coffee,js}",
"scripts/app/controllers/*.{coffee,js}",
"scripts/**/*.{coffee,js}"
];
} else if ($area == 'embed') {
return [
"scripts/base/jquery-2.0.2.js",
"scripts/base/jquery.viewport.js",
"scripts/base/underscore.js",
"scripts/base/moment.js",
"scripts/base/jquery.timeago.js",
"scripts/base/soundmanager2-nodebug.js",
"scripts/embed/*.coffee"];
}
throw new Exception();
}
private static function getStylesForArea($area) {
if ($area == 'app') {
return [
"styles/base/jquery-ui.css",
"styles/base/colorbox.css",
"styles/app.less",
"styles/profiler.less"
];
} else if ($area == 'embed') {
return [
"styles/embed.less"
];
}
throw new Exception();
}
}

View file

@ -1,16 +0,0 @@
<?php
class AudioCache {
private static $_movieCache = array();
/**
* @param $filename
* @return FFmpegMovie
*/
public static function get($filename) {
if (isset(self::$_movieCache[$filename]))
return self::$_movieCache[$filename];
return self::$_movieCache[$filename] = new FFmpegMovie($filename);
}
}

View file

@ -1,32 +0,0 @@
<?php
use Assetic\Asset\BaseAsset;
use Assetic\Filter\FilterInterface;
/**
* Class CacheBusterAsset
* OH GOD IT BUUUUUUURNS
*
* Well, I may as well tell you why this awful class exists. So... Assetic doesn't quite support less's import
* directive. I mean; it supports it insofar as Less itself supports it - but it doesn't take into account the
* last modified time for imported assets. Since we only have one less file that imports everything else... well
* you can see where this is going. This asset will let us override the last modified time for an entire collection
* which allows me to write a custom mechanism for cache busting.
*/
class CacheBusterAsset extends BaseAsset {
private $_lastModified;
/**
* @param int $lastModified
*/
public function __construct($lastModified) {
$this->_lastModified = $lastModified;
parent::__construct([], '', '', []);
}
public function load(FilterInterface $additionalFilter = null) {
}
public function getLastModified() {
return $this->_lastModified;
}
}

View file

@ -1,14 +0,0 @@
<?php
use Illuminate\Support\Facades\Log;
class External {
public static function execute($command) {
$output = [];
$error = exec($command, $output);
if ($error != null) {
Log::error('"' . $command . '" failed with "' . $error . '"');
}
}
}

View file

@ -1,32 +0,0 @@
<?php
/**
* File
*
* Note: Remember to remove the "File" alias in APP_DIR/config/application.php
*
* @author Phill Sparks <me@phills.me.uk>
*/
class File extends \Illuminate\Support\Facades\File
{
public static function inline($path, $mime, $name = null)
{
if (is_null($name))
{
$name = basename($path);
}
$response = Response::make(static::get($path));
$response->header('Content-Type', $mime);
$response->header('Content-Disposition', 'inline; filename="'.$name.'"');
$response->header('Content-Transfer-Encoding', 'binary');
$response->header('Expires', 0);
$response->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
$response->header('Pragma', 'public');
$response->header('Content-Length', filesize($path));
return $response;
}
}

View file

@ -1,26 +0,0 @@
<?php
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\URL;
class Gravatar {
public static function getUrl($email, $size = 80, $default = null, $rating = 'g') {
$url = 'https://www.gravatar.com/avatar/';
$url .= md5( strtolower( trim( $email ) ) );
$url .= "?s=$size&r=$rating";
if ($default != null)
$url .= "&d=" . $default;
else {
$size = 'normal';
if ($size == 50)
$size = 'thumbnail';
else if ($size == 100)
$size = 'small';
$url .= "&d=" . urlencode(URL::to('/images/icons/profile_' . $size . '.png'));
}
return $url;
}
}

View file

@ -1,51 +0,0 @@
<?php
class Helpers {
/**
* Removes whitespace and special characters from a string
* and sets all characters to lower case.
*/
public static function sanitizeInputForHashing($value) {
$value = preg_replace('/[^A-Za-z0-9]/', '', $value);
return strtolower($value);
}
public static function template($template) {
echo file_get_contents('templates/' . $template);
}
public static function angular($expression) {
return '{{' . $expression . '}}';
}
public static function formatBytes($bytes, $precision = 2) {
if ($bytes == 0)
return '0 MB';
$units = array('B', 'KB', 'MB', 'GB', 'TB');
$bytes = max($bytes, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
$pow = min($pow, count($units) - 1);
$bytes /= pow(1024, $pow);
return round($bytes, $precision) . ' ' . $units[$pow];
}
/**
* timeago-style timestamp generator macro.
*
* @param string $timestamp A timestamp in SQL DATETIME syntax
* @return string
*/
public static function timestamp( $timestamp ) {
if(gettype($timestamp) !== 'string' && get_class($timestamp) === 'DateTime'){
$timestamp = $timestamp->format('c');
}
$title = date('c', strtotime($timestamp));
$content = date('F d, o \@ g:i:s a', strtotime($timestamp));
return '<abbr class="timeago" title="'.$title.'">'.$content.'</abbr>';
}
}

View file

@ -1,29 +0,0 @@
<?php
use Illuminate\Hashing\HasherInterface;
class IpsHasher implements HasherInterface {
public function make($value, array $options = array()) {
return md5(md5($options['salt']) . md5(static::ips_sanitize($value)));
}
public function check($value, $hashedValue, array $options = array()) {
return static::make($value, ['salt' => $options['salt']]) === $hashedValue;
}
public function needsRehash($hashedValue, array $options = array()) {
return false;
}
static public function ips_sanitize( $value ) {
$value = str_replace('&', '&amp;', $value);
$value = str_replace('\\', '&#092;', $value);
$value = str_replace('!', '&#33;', $value);
$value = str_replace('$', '&#036;', $value);
$value = str_replace('"', '&quot;', $value);
$value = str_replace('<', '&lt;', $value);
$value = str_replace('>', '&gt;', $value);
$value = str_replace('\'', '&#39;', $value);
return $value;
}
}

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