Merge branch 'laravel' into 'master'

Changed framework to Laravel

Re-write to use Laravel  5.2

See merge request !1
This commit is contained in:
Deon George 2016-06-30 06:05:21 +00:00
commit f089c33b8b
125 changed files with 8165 additions and 1196 deletions

27
.env.example Normal file
View File

@ -0,0 +1,27 @@
APP_ENV=local
APP_KEY=SomeRandomString
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

3
.gitattributes vendored Normal file
View File

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

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
/vendor
/node_modules
/public/storage
Homestead.yaml
Homestead.json
.env

View File

@ -0,0 +1,223 @@
<?php
namespace App\Console\Commands;
use Log;
use Illuminate\Console\Command;
use App\Model\Person;
use App\Model\PhotoPerson;
use App\Model\Photo;
use App\Model\PhotoTag;
use App\Model\Tag;
class Import extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'photo:import
{--dir= : Directory to Parse}
{--file= : File to import}
{--ignoredupe : Ignore duplicate files}
{--deletedupe : Delete duplicate files}
{--people= : People to reference in photo}
{--tags= : Add tag to photo}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Import photos into the database';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
// Make sure we got a directory or a file to import
if (is_null($this->option('file')) AND is_null($this->option('dir')))
abort(500,'Missing filename, please use --file= OR --dir=');
Log::info('Processing: '.($this->option('file') ? $this->option('file') : $this->option('dir')));
$files = [];
if ($this->option('dir'))
{
// Remove our trailing slash from the directory.
$dir = preg_replace('/\/$/','',$this->option('dir'));
// Exclude . & .. from the path.
$files = array_diff(scandir($dir),array('.','..'));
}
elseif ($this->option('file'))
{
$dir = dirname($this->option('file'));
$files = array(basename($this->option('file')));
}
// Determine if our dir is releative to where we store data
$dir = Photo::path($dir);
// Add our path
if ($dir)
array_walk($files,function(&$value,$key,$path='') {
if ($path) {
$value = sprintf('%s/%s',$path,$value);
}
},$dir);
// Show a progress bar
$bar = $this->output->createProgressBar(count($files));
$bar->setFormat("%current%/%max% [%bar%] %percent:3s%% (%memory%) (%remaining%) ");
$tags = NULL;
$t = $p = array();
// Tags
if ($this->option('tags'))
{
$tags = explode(',',$this->option('tags'));
$t = Tag::whereIn('tag',$tags)->get();
}
// People
if ($this->option('people'))
{
$tags = explode(',',$this->option('people'));
$p = Person::whereIn('tag',$tags)->get();
}
$c = 0;
foreach ($files as $file)
{
$bar->advance();
if (preg_match('/@__thumb/',$file) OR preg_match('/\/._/',$file))
{
$this->warn(sprintf('Ignoring file [%s]',$file));
continue;
}
if (! in_array(strtolower(pathinfo($file,PATHINFO_EXTENSION)),config('photo.import.accepted')))
{
$this->warn(sprintf('Ignoring [%s]',$file));
continue;
}
if ($this->option('verbose'))
$this->info(sprintf('Processing file [%s]',$file));
$c++;
$po = Photo::where('filename',$file)->first();
if (is_null($po))
{
$po = new Photo;
$po->filename = $file;
}
$po->date_taken = strtotime($po->property('exif:DateTime'));
$po->subsectime = $po->property('exif:SubSecTimeOriginal');
$po->signature = $po->property('signature');
$po->make = $po->property('exif:Make');
$po->model = $po->property('exif:Model');
$po->height = $po->property('height');
$po->width = $po->property('width');
$po->orientation = $po->property('orientation');
$po->gps_lat = Photo::latlon(preg_split('/,\s?/',$po->property('exif:GPSLatitude')),$po->property('exif:GPSLatitudeRef'));
$po->gps_lon = Photo::latlon(preg_split('/,\s?/',$po->property('exif:GPSLongitude')),$po->property('exif:GPSLongitudeRef'));
try {
$po->thumbnail = exif_thumbnail($po->file_path());
} catch (\Exception $e) {
// @todo Couldnt get the thumbnail, so we should create one.
}
// If this is a duplicate
$x = Photo::whereIN('id',$po->list_duplicate())->get();
if (count($x)) {
$skip = FALSE;
foreach ($x as $o) {
// We'll only ignore based on the same signature.
if ($po->signature != $o->signature AND ! $po->exists)
continue;
if ($this->option('ignoredupe'))
{
$skip = TRUE;
$this->warn(sprintf("Ignoring file [%s], it's the same as [%s] with id %s",$po->file_path(),$o->filename,$o->id));
break;
}
elseif ($this->option('deletedupe') AND ($po->filename != $o->filename))
{
$skip = TRUE;
$this->error(sprintf("Deleting file [%s], it's the same as [%s] with id %s and signature [%s]\n",$po->file_path(),$o->filename,$o->id,$po->signature));
unlink($po->file_path());
}
}
if ($skip)
continue;
$po->duplicate = '1';
$this->warn(sprintf('Image [%s] marked as a duplicate',$file));
}
if ($po->exists)
$this->warn(sprintf('Image [%s] already in DB: %s',$file,$po->id));
$po->save();
if ($po->wasRecentlyCreated)
$this->info(sprintf('Image [%s] stored in DB: %s',$file,$po->id));
// Record our tags
foreach ($t as $o)
if (! (new PhotoTag)->where('tag_id','=',$o->id)->where('photo_id','=',$po->id)->count())
{
$x = new PhotoTag;
$x->tag_id = $o->id;
$x->photo_id = $po->id;
$x->save();
}
// Record our people
foreach ($p as $o)
if (! (new PhotoPerson)->where('people_id','=',$o->id)->where('photo_id','=',$po->id)->count())
{
$x = new PhotoPerson;
$x->people_id = $o->id;
$x->photo_id = $po->id;
$x->save();
}
}
$bar->finish();
return $this->info(sprintf('Images processed: %s',$c));
}
}

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);
}
}

View File

@ -0,0 +1,99 @@
<?php
namespace App\Console\Commands;
use DB;
use Log;
use Illuminate\Console\Command;
use App\Model\Photo;
class Move extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'photo:move
{--file= : Photo File}
{--id= : Photo ID}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Moves Photos to their new location';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
if ($this->option('file'))
{
$po = Photo::notRemove()->notDuplicate()->where('filename',Photo::path($this->option('file')));
}
elseif ($this->option('id'))
{
$po = Photo::notRemove()->notDuplicate()->where('id',Photo::path($this->option('id')));
}
else
{
$po = Photo::notRemove()->notDuplicate();
}
// Show a progress bar
$bar = $this->output->createProgressBar($po->count());
$bar->setFormat("%current%/%max% [%bar%] %percent:3s%% (%memory%) (%remaining%) ");
$bar->setRedrawFrequency(100);
$po->chunk(1,function($photo) use ($bar) {
while ($po = $photo->shift())
{
if (($x = $po->moveable()) === TRUE) {
Log::info(sprintf('Moving: (%s)[%s]',$po->id,$po->filename));
if (rename($po->file_path(),$po->file_path(FALSE,TRUE)))
{
// Convert the path to a relative one.
$po->filename = $po->file_path(TRUE,TRUE);
// @todo If the DB update failed, move it back.
if (! $po->save()) # AND ! rename($path,$po->file_path()))
{
$this->error(sprintf('Save after rename failed for (%s)',$po->id));
continue;
}
}
else
{
$this->error(sprintf('Rename failed for (%s)',$po->id));
continue;
}
chmod($po->file_path(),0444);
}
else
{
if ($x > 0)
$this->warn(sprintf('Unable to move (%s) [%s] to [%s], moveable returned (%s)',$po->id,$po->file_path(),$po->file_path(FALSE,TRUE),$x));
}
}
$bar->advance();
});
}
}

31
app/Console/Kernel.php Normal file
View File

@ -0,0 +1,31 @@
<?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 = [
Commands\Import::class,
Commands\Move::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,50 @@
<?php
namespace App\Exceptions;
use Exception;
use Illuminate\Validation\ValidationException;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
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 = [
AuthorizationException::class,
HttpException::class,
ModelNotFoundException::class,
ValidationException::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)
{
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,72 @@
<?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;
/**
* Where to redirect users after login / registration.
*
* @var string
*/
protected $redirectTo = '/';
/**
* Create a new authentication controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware($this->guestMiddleware(), ['except' => 'logout']);
}
/**
* 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|min:6|confirmed',
]);
}
/**
* 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($this->guestMiddleware());
}
}

View File

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

View File

@ -0,0 +1,107 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Response;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Model\Photo;
use App\Jobs\PhotoDelete;
class PhotoController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
public function delete($id)
{
$po = Photo::notRemove()->findOrFail($id);
if ($po)
{
$po->remove = TRUE;
$po->save();
}
return redirect()->action('PhotoController@info',[$id]);
}
public function deletes()
{
return view('photo.deletereview',['photos'=>Photo::where('remove',1)->paginate(2)]);
}
public function deletesUpdate(Request $request)
{
foreach ($request->input('photo') as $id)
{
$photo = Photo::findOrFail($id);
if ($photo->remove AND $request->input('remove.'.$id))
$this->dispatch((new PhotoDelete($photo))->onQueue('delete'));
}
return $request->input('pagenext') ? redirect()->action('PhotoController@deletes','?page='.$request->input('pagenext')) : redirect('/');
}
public function duplicates($id=NULL)
{
return view('photo.duplicates',['photos'=>is_null($id) ? Photo::notRemove()->where('duplicate',1)->paginate(1) : Photo::where('id',$id)->paginate(1)]);
}
public function duplicatesUpdate(Request $request)
{
foreach ($request->input('photo') as $id)
{
$po = Photo::findOrFail($id);
// Set if duplicate
$po->duplicate = $request->input('duplicate.'.$id) ? 1 : NULL;
// Set if flag
$po->flag = $request->input('flag.'.$id) ? 1 : NULL;
// Set if delete
$po->remove = $request->input('remove.'.$id) ? 1 : NULL;
$po->isDirty() AND $po->save();
}
return redirect()->action('PhotoController@duplicates','?page='.$request->input('page'));
}
public function info($id)
{
return view('photo.view', ['photo'=> Photo::findOrFail($id)]);
}
public function thumbnail($id)
{
return response(Photo::findOrFail($id)->thumbnail(TRUE))->header('Content-Type','image/jpeg');
}
public function undelete($id)
{
$po = Photo::findOrFail($id);
if ($po)
{
$po->remove = NULL;
$po->save();
}
return redirect()->action('PhotoController@info',[$id]);
}
public function view($id)
{
return response(Photo::findOrFail($id)->image())->header('Content-Type','image/jpeg');
}
}

53
app/Http/Kernel.php Normal file
View File

@ -0,0 +1,53 @@
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* These middleware are run during every request to your application.
*
* @var array
*/
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
];
/**
* The application's route middleware groups.
*
* @var array
*/
protected $middlewareGroups = [
'web' => [
\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,
],
'api' => [
'throttle:60,1',
],
];
/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'can' => \Illuminate\Foundation\Http\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
];
}

View File

@ -0,0 +1,30 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
class Authenticate
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->guest()) {
if ($request->ajax() || $request->wantsJson()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('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,26 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect('/');
}
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
{
//
}

30
app/Http/routes.php Normal file
View File

@ -0,0 +1,30 @@
<?php
use Illuminate\Http\Request;
/*
|--------------------------------------------------------------------------
| 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');
});
Route::auth();
Route::get('/deletes/{id?}', 'PhotoController@deletes')->where('id', '[0-9]+');;
Route::get('/duplicates/{id?}', 'PhotoController@duplicates')->where('id', '[0-9]+');;
Route::get('/info/{id}', 'PhotoController@info')->where('id', '[0-9]+');;
Route::get('/thumbnail/{id}', 'PhotoController@thumbnail')->where('id', '[0-9]+');;
Route::get('/view/{id}', 'PhotoController@view')->where('id', '[0-9]+');;
Route::post('/delete/{id}', 'PhotoController@delete')->where('id', '[0-9]+');;
Route::post('/duplicates', 'PhotoController@duplicatesUpdate');
Route::post('/deletes', 'PhotoController@deletesUpdate');
Route::post('/undelete/{id}', 'PhotoController@undelete')->where('id', '[0-9]+');;

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 "onQueue" and "delay" queue helper methods.
|
*/
use Queueable;
}

58
app/Jobs/PhotoDelete.php Normal file
View File

@ -0,0 +1,58 @@
<?php
namespace App\Jobs;
use Log;
use App\Jobs\Job;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\Model\Photo;
class PhotoDelete extends Job implements ShouldQueue
{
use InteractsWithQueue, SerializesModels;
private $photo;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(Photo $photo)
{
$this->photo = $photo;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
if (! $this->photo->remove)
{
Log::warning(__METHOD__.' NOT Deleting: '.$this->photo->file_path().', not marked for deletion');
exit;
}
// Remove tags;
// @todo
// Remove People;
// @todo
// Make sure our parent is writable
if (! is_writable(dirname($this->photo->file_path())))
Log::warning(__METHOD__.' NOT Deleting: '.$this->photo->file_path().', parent directory not writable');
// Perform delete
if (file_exists($this->photo->file_path()))
unlink($this->photo->file_path());
Log::info(sprintf('%s: Deleted (%s): %s',__METHOD__,$this->photo->id,$this->photo->file_path()));
$this->photo->delete();
}
}

39
app/Jobs/PhotoMove.php Normal file
View File

@ -0,0 +1,39 @@
<?php
namespace App\Jobs;
use Log;
use App\Jobs\Job;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\Model\Photo;
use Artisan;
class PhotoMove extends Job implements ShouldQueue
{
use InteractsWithQueue, SerializesModels;
private $photo;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(Photo $photo)
{
$this->photo = $photo;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
Log::info(__METHOD__.' Moving: '.$this->photo->id);
Artisan::call('photo:move',['--id' => $this->photo->id]);
}
}

1
app/Listeners/.gitkeep Normal file
View File

@ -0,0 +1 @@

9
app/Model/Person.php Normal file
View File

@ -0,0 +1,9 @@
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class Person extends Model
{
}

369
app/Model/Photo.php Normal file
View File

@ -0,0 +1,369 @@
<?php
namespace App\Model;
use DB;
use Illuminate\Database\Eloquent\Model;
class Photo extends Model
{
protected $table = 'photo';
// Imagick Object
private $_io;
// How should the image be rotated, based on the value of orientation
private $_rotate = [
3=>180,
6=>90,
8=>-90,
];
/**
* Photo's NOT pending removal.
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeNotRemove($query)
{
return $query->where(function($query)
{
$query->where('remove','!=',TRUE)
->orWhere('remove','=',NULL);
});
}
/**
* Photo's NOT duplicate.
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeNotDuplicate($query)
{
return $query->where(function($query)
{
$query->where('duplicate','!=',TRUE)
->orWhere('duplicate','=',NULL);
});
}
public function date_taken()
{
return $this->date_taken ? (date('Y-m-d H:i:s',$this->date_taken).($this->subsectime ? '.'.$this->subsectime : '')) : 'UNKNOWN';
}
/**
* Return the date of the file
*/
public function file_date($type,$format=FALSE)
{
if (! is_readable($this->file_path()))
return NULL;
switch ($type)
{
case 'a': $t = fileatime($this->file_path());
break;
case 'c': $t = filectime($this->file_path());
break;
case 'm': $t = filemtime($this->file_path());
break;
}
return $format ? date('d-m-Y H:i:s',$t) : $t;
}
/**
* Determine the new name for the image
*/
public function file_path($short=FALSE,$new=FALSE)
{
$file = $this->filename;
if ($new)
$file = sprintf('%s.%s',((is_null($this->date_taken) OR ! $this->date_taken)
? sprintf('UNKNOWN/%07s',$this->file_path_id())
: sprintf('%s_%03s',date('Y/m/d-His',$this->date_taken),$this->subsectime).($this->subsectime ? '' : sprintf('-%05s',$this->id))),$this->type());
return (($short OR preg_match('/^\//',$file)) ? '' : config('photo.dir').DIRECTORY_SEPARATOR).$file;
}
/**
* Calculate a file path ID based on the id of the file
*/
public function file_path_id($sep=3,$depth=9)
{
return trim(chunk_split(sprintf("%0{$depth}s",$this->id),$sep,'/'),'/');
}
/**
* Return the photo size
*/
public function file_size()
{
return (! is_readable($this->file_path())) ? NULL : filesize($this->file_path());
}
/**
* Display the GPS coordinates
*/
public function gps()
{
return ($this->gps_lat AND $this->gps_lon) ? sprintf('%s/%s',$this->gps_lat,$this->gps_lon) : 'UNKNOWN';
}
/**
* Return the image, rotated, minus exif data
*/
public function image()
{
$imo = $this->io();
if (array_key_exists('exif',$imo->getImageProfiles()))
$imo->removeImageProfile('exif');
$this->rotate($imo);
return $imo->getImageBlob();
}
/**
* Return an Imagick object or attribute
*
*/
protected function io($attr=NULL)
{
if (is_null($this->_io))
$this->_io = new \Imagick($this->file_path());
return is_null($attr) ? $this->_io : $this->_io->getImageProperty($attr);
}
/**
* Calculate the GPS coordinates
*/
public static function latlon(array $coordinate,$hemisphere)
{
if (! $coordinate OR ! $hemisphere)
return NULL;
for ($i=0; $i<3; $i++)
{
$part = explode('/', $coordinate[$i]);
if (count($part) == 1)
$coordinate[$i] = $part[0];
elseif (count($part) == 2)
$coordinate[$i] = floatval($part[0])/floatval($part[1]);
else
$coordinate[$i] = 0;
}
list($degrees, $minutes, $seconds) = $coordinate;
$sign = ($hemisphere == 'W' || $hemisphere == 'S') ? -1 : 1;
return round($sign*($degrees+$minutes/60+$seconds/3600),$degrees > 100 ? 3 : 4);
}
/**
* Determine if a file is moveable
*
* useID boolean Determine if the path is based on the the ID or date
*/
public function moveable()
{
// If the source and target are the same, we dont need to move it
if ($this->file_path() == $this->file_path(FALSE,TRUE))
return FALSE;
// If there is already a file in the target.
// @todo If the target file is to be deleted, we could move this file
if (file_exists($this->file_path(FALSE,TRUE)))
return 1;
// Test if the source is readable
if (! is_readable($this->file_path()))
return 2;
// Test if the dir is writable (so we can remove the file)
if (! is_writable(dirname($this->file_path())))
return 3;
// Test if the target dir is writable
// @todo The target dir may not exist yet, so we should check that a parent exists and is writable.
if (! is_writable(dirname($this->file_path(FALSE,TRUE))))
return 4;
return TRUE;
}
/**
* Get the id of the previous photo
*/
public function next()
{
$po = DB::table('photo');
$po->where('id','>',$this->id);
$po->orderby('id','ASC');
return $po->first();
}
/**
* Display the orientation of a photo
*/
public function orientation() {
switch ($this->orientation) {
case 1: return 'None!';
case 3: return 'Upside Down';
case 6: return 'Rotate Right';
case 8: return 'Rotate Left';
default:
return 'unknown?';
}
}
/**
* Rotate the image
*
*/
private function rotate(\Imagick $imo)
{
if (array_key_exists($this->orientation,$this->_rotate))
$imo->rotateImage(new \ImagickPixel('none'),$this->_rotate[$this->orientation]);
return $imo->getImageBlob();
}
public static function path($path)
{
return preg_replace('/^\//','',str_replace(config('photo.dir'),'',$path));
}
/**
* Get the id of the previous photo
*/
public function previous()
{
$po = DB::table('photo');
$po->where('id','<',$this->id);
$po->orderby('id','DEC');
return $po->first();
}
public function property($property)
{
if (! $this->io())
return NULL;
switch ($property)
{
case 'height': return $this->_io->getImageHeight(); break;
case 'orientation': return $this->_io->getImageOrientation(); break;
case 'signature': return $this->_io->getImageSignature(); break;
case 'width': return $this->_io->getImageWidth(); break;
default:
return $this->_io->getImageProperty($property);
}
}
public function properties()
{
return $this->io() ? $this->_io->getImageProperties() : [];
}
/**
* Display the photo signature
*/
public function signature($short=FALSE)
{
return $short ? static::signaturetrim($this->signature) : $this->signature;
}
public static function signaturetrim($signature,$chars=6)
{
return sprintf('%s...%s',substr($signature,0,$chars),substr($signature,-1*$chars));
}
/**
* Determine if the image should be moved
*/
public function shouldMove()
{
return ($this->filename != $this->file_path(TRUE,TRUE));
}
/**
* Return the image's thumbnail
*
*/
public function thumbnail($rotate=TRUE)
{
if (! $this->thumbnail)
{
return $this->io()->thumbnailimage(200,200,true,true) ? $this->_io->getImageBlob() : NULL;
}
if (! $rotate OR ! array_key_exists($this->orientation,$this->_rotate) OR ! extension_loaded('imagick'))
return $this->thumbnail;
$imo = new \Imagick();
$imo->readImageBlob($this->thumbnail);
return $this->rotate($imo);
}
/**
* Return the extension of the image
*/
public function type($mime=FALSE)
{
return strtolower($mime ? File::mime_by_ext(pathinfo($this->filename,PATHINFO_EXTENSION)) : pathinfo($this->filename,PATHINFO_EXTENSION));
}
/**
* Find duplicate images based on some attributes of the current image
*/
public function list_duplicate($includeme=FALSE)
{
$po = DB::table('photo');
if ($this->id AND ! $includeme)
$po->where('id','!=',$this->id);
// Ignore photo's pending removal.
if (! $includeme)
$po->where(function($query)
{
$query->where('remove','!=',TRUE)
->orWhere('remove','=',NULL);
});
// Where the signature is the same
$po->where(function($query)
{
$query->where('signature','=',$this->signature);
// Or they have the same time taken with the same camera
if ($this->date_taken AND ($this->model OR $this->make))
{
$query->orWhere(function($query)
{
$query->where('date_taken','=',$this->date_taken ? $this->date_taken : NULL);
$query->where('subsectime','=',$this->subsectime ? $this->subsectime : NULL);
if (! is_null($this->model))
$query->where('model','=',$this->model);
if (! is_null($this->make))
$query->where('make','=',$this->make);
});
}
});
return $po->pluck('id');
}
}

View File

@ -0,0 +1,9 @@
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class PhotoPerson extends Model
{
}

15
app/Model/PhotoTag.php Normal file
View File

@ -0,0 +1,15 @@
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class PhotoTag extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'photo_tag';
}

9
app/Model/Tag.php Normal file
View File

@ -0,0 +1,9 @@
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class Tag extends Model
{
}

1
app/Policies/.gitkeep Normal file
View File

@ -0,0 +1 @@

View File

@ -0,0 +1,41 @@
<?php
namespace App\Providers;
use Log;
use Illuminate\Support\ServiceProvider;
use App\Model\Photo;
use App\Jobs\PhotoMove;
use Illuminate\Foundation\Bus\DispatchesJobs;
class AppServiceProvider extends ServiceProvider
{
use DispatchesJobs;
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
// Any photo saved, queue it to be moved.
Photo::saved(function($photo) {
if (! $photo->duplicate AND ($x=$photo->moveable()) === TRUE)
{
Log::info(__METHOD__.': Need to Move: '.$photo->id.'|'.serialize($x));
$this->dispatch((new PhotoMove($photo))->onQueue('move'));
}
});
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace App\Providers;
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* @var array
*/
protected $policies = [
'App\Model' => 'App\Policies\ModelPolicy',
];
/**
* Register any application authentication / authorization services.
*
* @param \Illuminate\Contracts\Auth\Access\Gate $gate
* @return void
*/
public function boot(GateContract $gate)
{
$this->registerPolicies($gate);
//
}
}

View File

@ -0,0 +1,30 @@
<?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 = [
];
/**
* 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,61 @@
<?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 your controller routes.
*
* 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)
{
$this->mapWebRoutes($router);
//
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
protected function mapWebRoutes(Router $router)
{
$router->group([
'namespace' => $this->namespace, 'middleware' => 'web',
], function ($router) {
require app_path('Http/routes.php');
});
}
}

26
app/User.php Normal file
View File

@ -0,0 +1,26 @@
<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}

View File

@ -1,180 +0,0 @@
<?php defined('SYSPATH') or die('No direct script access.');
// -- Environment setup --------------------------------------------------------
$SERVER_NAMES = array(
'xphoto.leenooks.vpn',
);
// Load the core Kohana class
require SYSPATH.'classes/Kohana/Core'.EXT;
if (is_file(APPPATH.'classes/Kohana'.EXT))
{
// Application extends the core
require APPPATH.'classes/Kohana'.EXT;
}
else
{
// Load empty core extension
require SYSPATH.'classes/Kohana'.EXT;
}
/**
* Set the default time zone.
*
* @link http://kohanaframework.org/guide/using.configuration
* @link http://www.php.net/manual/timezones
*/
date_default_timezone_set('Australia/Melbourne');
/**
* Set the default locale.
*
* @link http://kohanaframework.org/guide/using.configuration
* @link http://www.php.net/manual/function.setlocale
*/
setlocale(LC_ALL, 'en_US.utf-8');
/**
* Enable the Kohana auto-loader.
*
* @link http://kohanaframework.org/guide/using.autoloading
* @link http://www.php.net/manual/function.spl-autoload-register
*/
spl_autoload_register(array('Kohana', 'auto_load'));
/**
* Optionally, you can enable a compatibility auto-loader for use with
* older modules that have not been updated for PSR-0.
*
* It is recommended to not enable this unless absolutely necessary.
*/
//spl_autoload_register(array('Kohana', 'auto_load_lowercase'));
/**
* Enable the Kohana auto-loader for unserialization.
*
* @link http://www.php.net/manual/function.spl-autoload-call
* @link http://www.php.net/manual/var.configuration#unserialize-callback-func
*/
ini_set('unserialize_callback_func', 'spl_autoload_call');
// -- Configuration and initialization -----------------------------------------
/**
* Set the default language
*/
I18n::lang('en-us');
/**
* Set Kohana::$environment if a 'KOHANA_ENV' environment variable has been supplied.
*
* Note: If you supply an invalid environment name, a PHP warning will be thrown
* saying "Couldn't find constant Kohana::<INVALID_ENV_NAME>"
*/
/**
* Set the environment status by the domain.
*/
Kohana::$environment = (! isset($_SERVER['SERVER_NAME']) OR in_array($_SERVER['SERVER_NAME'],$SERVER_NAMES)) ? Kohana::PRODUCTION : Kohana::DEVELOPMENT;
if (isset($_SERVER['KOHANA_ENV']))
{
Kohana::$environment = constant('Kohana::'.strtoupper($_SERVER['KOHANA_ENV']));
}
/**
* Initialize Kohana, setting the default options.
*
* The following options are available:
*
* - string base_url path, and optionally domain, of your application NULL
* - string index_file name of your index file, usually "index.php" index.php
* - string charset internal character set used for input and output utf-8
* - string cache_dir set the internal cache directory APPPATH/cache
* - integer cache_life lifetime, in seconds, of items cached 60
* - boolean errors enable or disable error handling TRUE
* - boolean profile enable or disable internal profiling TRUE
* - boolean caching enable or disable internal caching FALSE
* - boolean expose set the X-Powered-By header FALSE
*/
Kohana::init(array(
'base_url' => Kohana::$environment === Kohana::PRODUCTION ? '/' : '/',
'caching' => Kohana::$environment === Kohana::PRODUCTION,
'profile' => Kohana::$environment !== Kohana::PRODUCTION,
'index_file' => FALSE,
));
/**
* Attach the file write to logging. Multiple writers are supported.
*/
Kohana::$log->attach(new Log_File(APPPATH.'logs'));
/**
* Attach a file reader to config. Multiple readers are supported.
*/
Kohana::$config->attach(new Config_File);
/**
* Enable modules. Modules are referenced by a relative or absolute path.
*/
Kohana::modules(array(
'lnapp' => MODPATH.'lnapp', // lnApp Base Application Tools
// 'oauth' => MODPATH.'oauth', // OAuth Module for External Authentication
// 'auth' => SMDPATH.'auth', // Basic authentication
// 'cache' => SMDPATH.'cache', // Caching with multiple backends
// 'cron' => SMDPATH.'cron', // Kohana Cron Module
// 'codebench' => SMDPATH.'codebench', // Benchmarking tool
'database' => SMDPATH.'database', // Database access
// 'gchart' => MODPATH.'gchart', // Google Chart Module
// 'highchart' => MODPATH.'highchart', // Highcharts Chart Module
// 'image' => SMDPATH.'image', // Image manipulation
// 'khemail' => SMDPATH.'khemail', // Email module for Kohana 3 PHP Framework
'minion' => SMDPATH.'minion', // CLI Tasks
'orm' => SMDPATH.'orm', // Object Relationship Mapping
// 'pagination' => SMDPATH.'pagination', // Kohana Pagination module for Kohana 3 PHP Framework
// 'unittest' => SMDPATH.'unittest', // Unit testing
// 'userguide' => SMDPATH.'userguide', // User guide and API documentation
// 'xml' => SMDPATH.'xml', // XML module for Kohana 3 PHP Framework
));
/**
* Enable specalised interfaces
*/
Route::set('sections', '<directory>/<controller>(/<action>(/<id>(/<sid>)))',
array(
'directory' => '('.implode('|',array_values(URL::$method_directory)).')'
))
->defaults(array(
'action' => 'index',
));
// Static file serving (CSS, JS, images)
Route::set('default/media', 'media(/<file>)', array('file' => '.+'))
->defaults(array(
'controller' => 'media',
'action' => 'get',
));
/**
* Set the routes. Each route must have a minimum of a name, a URI and a set of
* defaults for the URI.
*/
Route::set('default', '(<controller>(/<action>(/<id>)))', array('id'=>'[a-zA-Z0-9_.-]+'))
->defaults(array(
'controller' => 'welcome',
'action' => 'index',
));
/**
* If APC is enabled, and we need to clear the cache
*/
if (file_exists(APPPATH.'cache/CLEAR_APC_CACHE') AND function_exists('apc_clear_cache') AND (PHP_SAPI !== 'cli')) {
if (! apc_clear_cache() OR ! unlink(APPPATH.'cache/CLEAR_APC_CACHE'))
throw new Kohana_Exception('Unable to clear the APC cache.');
}
// If we are a CLI, set our session dir
if (PHP_SAPI === 'cli')
session_save_path('tmp/');
?>

View File

@ -1,50 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class extends the core Kohana class by adding some core application
* specific functions, and configuration.
*
* @package Photo
* @category Helpers
* @author Deon George
* @copyright (c) 2014 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Config extends Kohana_Config {
/**
* Some early initialisation
*
* At this point, KH hasnt been fully initialised either, so we cant rely on
* too many KH functions yet.
*
* NOTE: Kohana doesnt provide a parent construct for the Kohana_Config class.
*/
public function __construct() {
}
/**
* Get the singleton instance of Config.
*
* $config = Config::instance();
*
* @return Config
* @compat Restore KH 3.1 functionality
*/
public static function instance() {
if (Config::$_instance === NULL)
// Create a new instance
Config::$_instance = new Config;
return Config::$_instance;
}
public static function Copywrite() {
return '(c) 2014 Deon George';
}
public static function version() {
// @todo Work out our versioning
return 'TBA';
}
}
?>

View File

@ -1,290 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* Mark all accounts that have no outstanding invoices and active services as disabled.
*
* @package Photo
* @category Controllers
* @author Deon George
* @copyright (c) 2014 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Controller_Photo extends Controller_TemplateDefault {
public function action_index() {
}
public function action_delete() {
$output = '';
// Update the current posted photos.
if ($this->request->post())
foreach ($this->request->post('process') as $pid) {
$po = ORM::factory('Photo',$pid);
$po->remove = Arr::get($this->request->post('remove'),$pid);
$po->save();
// If the photo is not marked as remove, or flagged, dont do it.
if (! $po->loaded() OR $po->flag OR ! $po->remove)
continue;
if (! is_writable(dirname($po->file_path())))
$output .= sprintf('Dont have write permissions on %s',dirname($po->file_path()));
$output .= sprintf('Removing %s (%s)',$po->id,$po->file_path());
// Delete it
$po->delete();
}
$p = ORM::factory('Photo');
// Review a specific photo, or the next one marked remove
if ($x=$this->request->param('id'))
$p->where('id','=',$x);
else
$p->where('remove','=',TRUE)
->where_open()
->where('flag','!=',TRUE)
->or_where('flag','is',NULL)
->where_close();
$output .= Form::open(sprintf('%s/%s',strtolower($this->request->controller()),$this->request->action()));
foreach ($p->find_all() as $po) {
$dp = $po->list_duplicate()->find_all();
$output .= Form::hidden('process[]',$po->id);
foreach ($dp as $dpo)
$output .= Form::hidden('process[]',$dpo->id);
$output .= '<table class="table table-striped table-condensed table-hover">';
foreach (array(
'ID'=>array('key'=>'id','value'=>HTML::anchor('/photo/details/%VALUE%','%VALUE%')),
'Thumbnail'=>array('key'=>'id','value'=>HTML::anchor('/photo/view/%VALUE%',HTML::image('photo/thumbnail/%VALUE%'))),
'Signature'=>array('key'=>'signature'),
'Date Taken'=>array('key'=>'date_taken()'),
'File Modified'=>array('key'=>'date_file("m",TRUE)'),
'File Created'=>array('key'=>'date_file("c",TRUE)'),
'Filename'=>array('key'=>'file_path(TRUE,FALSE)'),
'Filesize'=>array('key'=>'file_size()'),
'Width'=>array('key'=>'width'),
'Height'=>array('key'=>'height'),
'Orientation'=>array('key'=>'orientation'),
'Orientate'=>array('key'=>'rotation()'),
'Make'=>array('key'=>'make'),
'Model'=>array('key'=>'model'),
) as $k=>$v)
$output .= $this->table_duplicate_details($dp,$po,$v['key'],$k,Arr::get($v,'value','%VALUE%'));
foreach (array(
'Delete'=>array('key'=>'id','value'=>'remove'),
) as $k=>$v)
$output .= $this->table_duplicate_checkbox($dp,$po,$v['key'],$k,Arr::get($v,'value','%VALUE%'));
$output .= '</table>';
break;
}
$output .= '<div class="row">';
$output .= '<div class="col-md-offset-2">';
$output .= '<button type="submit" class="btn btn-primary">Save changes</button>';
$output .= '<button type="button" class="btn">Cancel</button>';
$output .= '</div>';
$output .= '</div>';
$output .= Form::close();
Block::factory()
->title('Delete Photo:'.$po->id)
->title_icon('icon-delete')
->body($output);
}
public function action_details() {
$po = ORM::factory('Photo',$this->request->param('id'));
if (! $po->loaded())
HTTP::redirect('index');
Block::factory()
->title('Details for Photo:'.$po->id)
->body(Debug::vars($po->info()));
}
public function action_duplicate() {
$output = '';
// Update the current posted photos.
if ($this->request->post())
foreach ($this->request->post('process') as $pid) {
$po = ORM::factory('Photo',$pid);
$po->duplicate = Arr::get($this->request->post('duplicate'),$pid);
$po->remove = Arr::get($this->request->post('remove'),$pid);
$po->flag = Arr::get($this->request->post('flag'),$pid);
if ($po->changed())
$output .= HTML::anchor(URL::link('','photo/duplicate/'.$po->id),$po->id).' updated.<br/>';
$po->save();
}
$p = ORM::factory('Photo');
// Review a specific photo, or the next one marked duplicate
if ($x=$this->request->param('id'))
$p->where('id','=',$x);
else
$p->where('duplicate','=',TRUE)
->where_open()
->where('remove','!=',TRUE)
->or_where('remove','is',NULL)
->where_close();
$output .= Form::open(sprintf('%s/%s',strtolower($this->request->controller()),$this->request->action()));
foreach ($p->find_all() as $po) {
$dp = $po->list_duplicate()->find_all();
// Check that there are still duplicates
if ($dp->count() == 0) {
$po->duplicate = NULL;
$po->save();
continue;
}
$output .= Form::hidden('process[]',$po->id);
foreach ($dp as $dpo)
$output .= Form::hidden('process[]',$dpo->id);
$output .= '<table class="table table-striped table-condensed table-hover">';
foreach (array(
'ID'=>array('key'=>'id','value'=>HTML::anchor('/photo/details/%VALUE%','%VALUE%')),
'Thumbnail'=>array('key'=>'id','value'=>HTML::anchor('/photo/view/%VALUE%',HTML::image('photo/thumbnail/%VALUE%'))),
'ThumbSig'=>array('key'=>'thumbnail_sig()'),
'Signature'=>array('key'=>'signature'),
'Date Taken'=>array('key'=>'date_taken()'),
'File Modified'=>array('key'=>'date_file("m",TRUE)'),
'File Created'=>array('key'=>'date_file("c",TRUE)'),
'Filename'=>array('key'=>'file_path(TRUE,FALSE)'),
'Filesize'=>array('key'=>'file_size()'),
'Width'=>array('key'=>'width'),
'Height'=>array('key'=>'height'),
'Orientation'=>array('key'=>'orientation'),
'Orientate'=>array('key'=>'rotation()'),
'Make'=>array('key'=>'make'),
'Model'=>array('key'=>'model'),
'Exif Diff'=>array('key'=>"propertydiff({$po->id})"),
) as $k=>$v)
$output .= $this->table_duplicate_details($dp,$po,$v['key'],$k,Arr::get($v,'value','%VALUE%'));
foreach (array(
'Flag'=>array('key'=>'id','value'=>'flag'),
'Duplicate'=>array('key'=>'id','value'=>'duplicate'),
'Delete'=>array('key'=>'id','value'=>'remove'),
) as $k=>$v)
$output .= $this->table_duplicate_checkbox($dp,$po,$v['key'],$k,Arr::get($v,'value','%VALUE%'));
$output .= '</table>';
break;
}
$output .= '<div class="row">';
$output .= '<div class="col-md-offset-2">';
$output .= '<button type="submit" class="btn btn-primary">Save changes</button>';
$output .= '<button type="button" class="btn">Cancel</button>';
$output .= '</div>';
$output .= '</div>';
$output .= Form::close();
Block::factory()
->title('Duplicate Photo:'.$po->id)
->title_icon('icon-edit')
->body($output);
}
public function action_thumbnail() {
// Get the file path from the request
$po = ORM::factory('Photo',$this->request->param('id'));
return $this->image($po->thumbnail(),$po->date_taken,$po->type(TRUE));
}
public function action_view() {
$po = ORM::factory('Photo',$this->request->param('id'));
return $this->image($po->image(),$po->date_taken,$po->type(TRUE));
}
private function image($content,$modified,$type) {
// Send the file content as the response
if ($content)
$this->response->body($content);
// Return a 404 status
else
$this->response->status(404);
// Generate and check the ETag for this file
if (Kohana::$environment < Kohana::TESTING OR Kohana::$config->load('debug')->etag)
$this->check_cache(sha1($this->response->body()));
// Set the proper headers to allow caching
$this->response->headers('Content-Type',$type);
$this->response->headers('Content-Length',(string)$this->response->content_length());
$this->response->headers('Last-Modified',date('r',$modified));
$this->auto_render = FALSE;
}
private function table_duplicate_checkbox(Database_MySQL_Result $dp,Model_Photo $po,$param,$title,$condition) {
$output = '<tr>';
$output .= sprintf('<th>%s</th>',$title);
$output .= '<td>'.Form::checkbox($condition.'['.$po->{$param}.']',TRUE,$po->{$condition} ? TRUE : FALSE).'</td>';
foreach ($dp as $dpo)
$output .= '<td>'.Form::checkbox($condition.'['.$dpo->{$param}.']',TRUE,$dpo->{$condition} ? TRUE : FALSE).'</td>';
$output .= '</tr>';
return $output;
}
private function evaluate(Model $o,$param) {
$result = NULL;
if (preg_match('/\(/',$param) OR preg_match('/-\>/',$param))
eval("\$result = \$o->$param;");
else
$result = $o->display($param);
return $result;
}
private function table_duplicate_details(Database_MySQL_Result $dp,Model_Photo $po,$param,$title='',$content='') {
$output = '<tr>';
$v = $this->evaluate($po,$param);
$output .= sprintf('<th>%s</th>',$title);
$output .= sprintf('<td>%s</td>',$content ? str_replace('%VALUE%',$v,$content) : $v);
foreach ($dp as $dpo) {
$d = $this->evaluate($dpo,$param);
$output .= sprintf('<td class="%s">%s</td>',($d==$v ? 'success' : 'warning'),$content ? str_replace('%VALUE%',$d,$content) : $d);
}
$output .= '</tr>';
return $output;
}
}
?>

View File

@ -1,10 +0,0 @@
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Welcome extends Controller {
public function action_index()
{
HTTP::redirect('photo');
}
} // End Welcome

View File

@ -1,15 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class overrides Kohana's Cookie
*
* @package Photo
* @category Modifications
* @author Deon George
* @copyright (c) 2014 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Cookie extends Kohana_Cookie {
public static $salt = 'Photo';
}
?>

View File

@ -1,24 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class extends the core Kohana class by adding some core application
* specific functions, and configuration.
*
* @package Photo
* @category Helpers
* @author Deon George
* @copyright (c) 2014 Deon George
* @license http://dev.leenooks.net/license.html
*/
class File extends Kohana_File {
public static function ParentDirExist($path,$create=FALSE) {
$isDir = is_dir($path);
if ($isDir OR ! $create)
return $isDir;
if (File::ParentDirExist(dirname($path),$create))
return mkdir($path);
}
}
?>

View File

@ -1,14 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports Albums.
*
* @package Photo
* @category Models
* @author Deon George
* @copyright (c) 2014 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Model_Album extends ORM {
}
?>

View File

@ -1,272 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports Photos.
*
* @package Photo
* @category Models
* @author Deon George
* @copyright (c) 2014 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Model_Photo extends ORM {
private $_path = '/mnt/net/qnap/Multimedia/Photos';
private $_io = NULL;
protected $_has_many = array(
'album'=>array('through'=>'album_photo'),
'people'=>array('through'=>'photo_people','far_key'=>'people_id'),
'tags'=>array('through'=>'photo_tag','far_key'=>'tag_id'),
'photo_tag'=>array('far_key'=>'id'),
'photo_people'=>array('far_key'=>'id'),
);
/**
* Filters used to format the display of values into friendlier values
*/
protected $_display_filters = array(
'date_orig'=>array(
array('Site::Datetime',array(':value')),
),
'date_taken'=>array(
array('Site::Datetime',array(':value')),
),
'signature'=>array(
array('Model_Photo::Signaturetrim',array(':value')),
),
);
public function date_file($type,$format=FALSE) {
switch ($type) {
case 'a': $t = fileatime($this->file_path());
break;
case 'c': $t = filectime($this->file_path());
break;
case 'm': $t = filemtime($this->file_path());
break;
}
return $format ? Site::Datetime($t) : $t;
}
public function date_taken() {
return $this->display('date_taken').($this->subsectime ? '.'.$this->subsectime : '');
}
public function file_path($short=FALSE,$new=FALSE) {
$file = $this->filename;
if ($new)
$file = sprintf('%s.%s',((is_null($this->date_taken) OR ! $this->date_taken)
? sprintf('UNKNOWN/%07s',$this->file_path_id())
: sprintf('%s_%03s',date('Y/m/d-His',$this->date_taken),$this->subsectime).($this->subsectime ? '' : sprintf('-%05s',$this->id))),$this->type());
return (($short OR preg_match('/^\//',$file)) ? '' : $this->_path.DIRECTORY_SEPARATOR).$file;
}
public function file_path_id($sep=3,$depth=9) {
return trim(chunk_split(sprintf("%0{$depth}s",$this->id),$sep,'/'),'/');
}
public function file_path_short($path) {
return preg_replace(":^{$this->_path}".DIRECTORY_SEPARATOR.":",'',$path);
}
public function delete() {
if (unlink($this->file_path())) {
// Remove any tags
foreach ($this->photo_tag->find_all() as $o)
$o->delete();
// Remove any people
foreach ($this->photo_people->find_all() as $o)
$o->delete();
return parent::delete();
}
// If unlink failed...
return FALSE;
}
public function file_size() {
return filesize($this->file_path());
}
public function gps(array $coordinate,$hemisphere) {
if (! $coordinate OR ! $hemisphere)
return NULL;
for ($i=0; $i<3; $i++) {
$part = explode('/', $coordinate[$i]);
if (count($part) == 1)
$coordinate[$i] = $part[0];
elseif (count($part) == 2)
$coordinate[$i] = floatval($part[0])/floatval($part[1]);
else
$coordinate[$i] = 0;
}
list($degrees, $minutes, $seconds) = $coordinate;
$sign = ($hemisphere == 'W' || $hemisphere == 'S') ? -1 : 1;
return round($sign*($degrees+$minutes/60+$seconds/3600),$degrees > 100 ? 3 : 4);
}
public function image() {
$imo = $this->io();
if (array_key_exists('exif',$imo->getImageProfiles()))
$imo->removeImageProfile('exif');
$this->rotate($imo);
return $imo->getImageBlob();
}
public function info() {
$imo = $this->io();
return $imo->getImageProperties();
}
public function io($attr=NULL) {
if (is_nulL($this->_io))
$this->_io = new Imagick($this->file_path());
return is_null($attr) ? $this->_io : $this->_io->getImageProperty($attr);
}
public function move($path='') {
if (! $path)
$path = $this->file_path(FALSE,TRUE);
// Check if there is already a phoot here - and if it is pending delete.
$po = ORM::factory('Photo',array('filename'=>$this->file_path_short($path)));
// @todo Move any tags if we are replacing an existing photo.
if ($po->loaded() AND (! $po->remove OR ($po->remove AND ! $po->delete())))
return FALSE;
unset($po);
// If the file already exists, or we cant create the dir structure, we'll ignore the move
if (file_exists($path) OR ! File::ParentDirExist(dirname($path),TRUE))
return FALSE;
if (rename($this->file_path(),$path)) {
// Convert the path to a relative one.
$this->filename = $this->file_path_short($path);
// If the DB update failed, move it back.
if (! $this->save() AND ! rename($path,$this->file_path()))
throw new Kohana_Exception('Error: Unable to move file, ID: :id, OLD: :oldname, NEW: :newname',
array(':id'=>$this->id,':oldname'=>$this->file_path(),':newname'=>$path));
chmod($this->file_path(),0444);
return TRUE;
}
}
public function propertydiff($id) {
if ($id == $this->id)
return;
$po = ORM::factory($this->_object_name,$id);
if (! $po->loaded())
return;
$result = array_diff_assoc($this->info(),$po->info());
return join('|',array_keys($result));
}
private function rotate(Imagick $imo) {
switch ($this->orientation) {
case 3: $imo->rotateImage(new ImagickPixel('none'),180);
break;
case 6: $imo->rotateImage(new ImagickPixel('none'),90);
break;
case 8: $imo->rotateImage(new ImagickPixel('none'),-90);
break;
}
}
public function rotation() {
switch ($this->orientation) {
case 1: return 'None!';
case 3: return 'Upside Down';
case 6: return 'Rotate Right';
case 8: return 'Rotate Left';
default:
return 'unknown?';
}
}
public static function SignatureTrim($signature,$chars=6) {
return sprintf('%s...%s',substr($signature,0,$chars),substr($signature,-1*$chars));
}
public function thumbnail($rotate=TRUE) {
if (! $this->thumbnail)
return NULL;
$imo = new Imagick();
$imo->readImageBlob($this->thumbnail);
if ($rotate)
$this->rotate($imo);
return $imo->getImageBlob();
}
public function thumbnail_sig() {
return md5($this->thumbnail()).':'.strlen($this->thumbnail());
}
public function type($mime=FALSE) {
return strtolower($mime ? File::mime_by_ext(pathinfo($this->filename,PATHINFO_EXTENSION)) : pathinfo($this->filename,PATHINFO_EXTENSION));
}
public function list_duplicate() {
$po = ORM::factory($this->_object_name);
if ($this->loaded())
$po->where('id','!=',$this->id);
// Ignore photo's pending removal.
$po->where_open();
$po->where('remove','!=',TRUE);
$po->or_where('remove','is',NULL);
$po->where_close();
// Where the signature is the same
$po->where_open();
$po->where('signature','=',$this->signature);
// Or they have the same time taken with the same camera
if ($this->date_taken AND ($this->model OR $this->make)) {
$po->or_where_open();
$po->where('date_taken','=',$this->date_taken);
$po->where('subsectime','=',$this->subsectime);
if (! is_null($this->model))
$po->and_where('model','=',$this->model);
if (! is_null($this->make))
$po->and_where('make','=',$this->make);
$po->where_close();
}
$po->where_close();
return $po;
}
}
?>

View File

@ -1,14 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports Tags.
*
* @package Photo
* @category Models
* @author Deon George
* @copyright (c) 2014 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Model_Photo_People extends ORM {
}
?>

View File

@ -1,14 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports Tags.
*
* @package Photo
* @category Models
* @author Deon George
* @copyright (c) 2014 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Model_Photo_Tag extends ORM {
}
?>

View File

@ -1,14 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports Tags.
*
* @package Photo
* @category Models
* @author Deon George
* @copyright (c) 2014 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Model_Tags extends ORM {
}
?>

View File

@ -1,186 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* Import photo to the database
*
* @package Photo
* @category Tasks
* @author Deon George
* @copyright (c) 2014 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Task_Photo_Import extends Minion_Task {
private $_log = '/tmp/photo_import.txt';
private $_accepted = array(
'jpg',
);
protected $_options = array(
'dir'=>NULL, // Directory of Photos to Import
'file'=>NULL, // Photo File to Import
'tags'=>NULL,
'people'=>NULL,
'ignoredupe'=>FALSE, // Skip duplicate photos
'deletedupe'=>FALSE, // Skip duplicate photos
'verbose'=>FALSE, // Photo File to Import
);
private function _adddir(&$value,$key,$path='') {
if ($path)
$value = sprintf('%s/%s',$path,$value);
}
protected function _execute(array $params) {
$tags = NULL;
$t = $p = array();
if (is_null($params['file']) AND is_null($params['dir']) OR ($params['file'] AND $params['dir']))
throw new Kohana_Exception('Missing filename, please use --file= OR --dir=');
if ($params['dir']) {
$files = array_diff(scandir($params['dir']),array('.','..'));
array_walk($files,'static::_adddir',$params['dir']);
} else
$files = array($params['file']);
// Tags
if ($params['tags']) {
$tags = explode(',',$params['tags']);
$t = ORM::factory('Tags')->where('tag','IN',$tags)->find_all();
}
// People
if ($params['people']) {
$tags = explode(',',$params['people']);
$p = ORM::factory('People')->where('tag','IN',$tags)->find_all();
}
$c = 0;
foreach ($files as $file) {
if ($params['verbose'])
printf("Processing file [%s]\n",$file);
if (preg_match('/@__thumb/',$file) OR preg_match('/\/._/',$file)) {
$this->writelog(sprintf("Ignoring file [%s]\n",$file));
continue;
}
if (! in_array(strtolower(pathinfo($file,PATHINFO_EXTENSION)),$this->_accepted)) {
$this->writelog(sprintf("Ignoring file [%s]\n",$file));
continue;
}
$c++;
$po = ORM::factory('Photo',array('filename'=>$file));
if (! $po->loaded())
$po->filename = realpath($file);
$po->date_taken = $this->dbcol(strtotime($po->io('exif:DateTime')));
$po->signature = $this->dbcol($po->io()->getImageSignature());
$po->make = $this->dbcol($po->io('exif:Make'));
$po->model = $this->dbcol($po->io('exif:Model'));
$po->height = $this->dbcol($po->io()->getImageheight());
$po->width = $this->dbcol($po->io()->getImageWidth());
$po->orientation = $this->dbcol($po->io()->getImageOrientation());
$po->subsectime = $this->dbcol($po->io('exif:SubSecTimeOriginal'));
$po->gps_lat = $this->dbcol($po->gps(preg_split('/,\s?/',$po->io()->getImageProperty('exif:GPSLatitude')),$po->io()->getImageProperty('exif:GPSLatitudeRef')));
$po->gps_lon = $this->dbcol($po->gps(preg_split('/,\s?/',$po->io()->getImageProperty('exif:GPSLongitude')),$po->io()->getImageProperty('exif:GPSLongitudeRef')));
try {
$po->thumbnail = $this->dbcol(exif_thumbnail($po->filename));
} catch (Exception $e) {
}
switch ($params['verbose']) {
case 1:
print_r($po->what_changed());
break;
case 2:
print_r($po->io()->getImageProperties());
break;
}
$x = $po->list_duplicate()->find_all();
if (count($x)) {
$skip = FALSE;
foreach ($x as $o) {
# We'll only ignore based on the same signature.
if ($params['ignoredupe'] AND ($po->signature == $o->signature)) {
$skip = TRUE;
$this->writelog(sprintf("Ignore file [%s], it's the same as [%s (%s)]\n",$po->filename,$o->id,$o->file_path()));
break;
} elseif ($params['deletedupe'] AND ($po->signature == $o->signature) AND ($po->filename != $o->filename)) {
$skip = TRUE;
$this->writelog(sprintf("Delete file [%s], it's the same as [%s (%s)] with signature [%s]\n",$po->filename,$o->id,$o->file_path(),$po->signature));
unlink($file);
}
}
unset($x);
if ($skip)
continue;
else
$po->duplicate = '1';
}
if (! $po->changed())
$this->writelog(sprintf("Image [%s] already in DB: %s\n",$file,$po->id));
$po->save();
if ($po->saved())
$this->writelog(sprintf("Image [%s] stored in DB: %s\n",$file,$po->id));
// Record our tags
foreach ($t as $o) {
$x = ORM::factory('Photo_Tag')->where('tag_id','=',$o->id)->where('photo_id','=',$po->id)->find();
$x->tag_id = $o->id;
$x->photo_id = $po->id;
$x->save();
}
// Record our people
foreach ($p as $o) {
$x = ORM::factory('Photo_People',array('people_id'=>$o->id,'photo_id'=>$po->id));
$x->people_id = $o->id;
$x->photo_id = $po->id;
$x->save();
}
unset($po);
unset($x);
unset($o);
}
if ($c > 1)
return sprintf("Images processed: %s\n",$c);
}
// Force the return of a string or NULL
private function dbcol($val,$noval=NULL) {
return $val ? (string)$val : $noval;
}
private function writelog($msg) {
if (! $this->_log)
return;
static $fh = NULL;
if (is_null($fh))
$fh = fopen($this->_log,'a+');
fwrite($fh,$msg);
}
}
?>

View File

@ -1,58 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* Mark all accounts that have no outstanding invoices and active services as disabled.
*
* @package Photo
* @category Tasks
* @author Deon George
* @copyright (c) 2014 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Task_Photo_Move extends Minion_Task {
protected $_options = array(
'file'=>NULL, // Photo File to Move
'batch'=>NULL, // Number of photos to move in a batch
'useid'=>TRUE, // If date not in photo use ID
'verbose'=>FALSE, // Show some debuggig
);
protected function _execute(array $params) {
if ($params['file']) {
$po = ORM::factory('Photo',array('filename'=>$params['file']));
} else {
$p = ORM::factory('Photo')
->where_open()
->where('remove','!=',TRUE)
->or_where('remove','is',NULL)
->where_close()
->where_open()
->where('duplicate','!=',TRUE)
->or_where('duplicate','is',NULL)
->where_close();
}
$c = 0;
foreach ($p->find_all() as $po) {
if ($po->file_path() == $po->file_path(FALSE,($params['useid'] OR $po->date_taken) ? TRUE : FALSE))
continue;
if ($params['verbose'])
printf("Processing [%s], file [%s] - newpath [%s]\n",$po->id,$po->file_path(),$po->file_path(FALSE,($params['useid'] OR $po->date_taken) ? TRUE : FALSE));
if ($po->move())
printf("Photo [%s] moved to %s.\n",$po->id,$po->file_path());
else
printf("Photo [%s] NOT moved to %s.\n",$po->id,$po->file_path(FALSE,TRUE));
$c++;
if (! is_null($params['batch']) AND $c >= $params['batch'])
break;
}
return sprintf("Images processed [%s]\n",$c);
}
}
?>

View File

@ -1,6 +0,0 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
return array
(
'appname' => 'Photo',
);

View File

@ -1,31 +0,0 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
return array
(
'default' => array
(
'type' => 'MySQL',
'connection' => array(
/**
* The following options are available for MySQL:
*
* string hostname server hostname, or socket
* string database database name
* string username database username
* string password database password
* boolean persistent use persistent connections?
* array variables system variables as "key => value" pairs
*
* Ports and sockets may be appended to the hostname.
*/
'hostname' => 'mysql.leenooks.vpn',
'database' => 'weblnphoto',
'username' => 'ln-photo',
'password' => 'Ph0T0!',
'persistent' => TRUE,
),
'table_prefix' => '',
'charset' => 'utf8',
'caching' => FALSE,
),
);

View File

@ -1,16 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* Photo system default configurable items.
*
* @package Photo
* @category Configuration
* @author Deon George
* @copyright (c) 2010-2013 Deon George
* @license http://dev.leenooks.net/license.html
*/
return array(
'Duplicates' => array('icon'=>'icon-edit','url'=>URL::site('photo/duplicate')),
);
?>

51
artisan Normal file
View File

@ -0,0 +1,51 @@
#!/usr/bin/env php
<?php
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/
require __DIR__.'/bootstrap/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Artisan Application
|--------------------------------------------------------------------------
|
| When we run the console application, the current CLI command will be
| executed in this console and the response sent back to a terminal
| or another output device for the developers. Here goes nothing!
|
*/
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$status = $kernel->handle(
$input = new Symfony\Component\Console\Input\ArgvInput,
new Symfony\Component\Console\Output\ConsoleOutput
);
/*
|--------------------------------------------------------------------------
| Shutdown The Application
|--------------------------------------------------------------------------
|
| Once Artisan has finished running. We will fire off the shutdown events
| so that any final work may be done by the application before we shut
| down the process. This is the last thing to happen to the request.
|
*/
$kernel->terminate($input, $status);
exit($status);

55
bootstrap/app.php Normal file
View File

@ -0,0 +1,55 @@
<?php
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
|
*/
$app = new Illuminate\Foundation\Application(
realpath(__DIR__.'/../')
);
/*
|--------------------------------------------------------------------------
| Bind Important Interfaces
|--------------------------------------------------------------------------
|
| Next, we need to bind some important interfaces into the container so
| we will be able to resolve them when needed. The kernels serve the
| incoming requests to this application from both the web and CLI.
|
*/
$app->singleton(
Illuminate\Contracts\Http\Kernel::class,
App\Http\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Console\Kernel::class,
App\Console\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
App\Exceptions\Handler::class
);
/*
|--------------------------------------------------------------------------
| Return The Application
|--------------------------------------------------------------------------
|
| This script returns the application instance. The instance is given to
| the calling script so we can separate the building of the instances
| from the actual running of the application and sending responses.
|
*/
return $app;

34
bootstrap/autoload.php Normal file
View File

@ -0,0 +1,34 @@
<?php
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register The Composer Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/
require __DIR__.'/../vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Include The Compiled Class File
|--------------------------------------------------------------------------
|
| To dramatically increase your application's performance, you may use a
| compiled class file which contains all of the classes commonly used
| by a request. The Artisan "optimize" is used to create this file.
|
*/
$compiledPath = __DIR__.'/cache/compiled.php';
if (file_exists($compiledPath)) {
require $compiledPath;
}

2
bootstrap/cache/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

58
composer.json Normal file
View File

@ -0,0 +1,58 @@
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"symfony/css-selector": "2.8.*|3.0.*",
"symfony/dom-crawler": "2.8.*|3.0.*",
"xethron/migrations-generator": "dev-l5",
"way/generators": "dev-feature/laravel-five-stable"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist"
},
"repositories": {
"repo-name": {
"type": "git",
"url": "git@github.com:jamisonvalenta/Laravel-4-Generators.git"
}
}
}

3659
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

211
config/app.php Normal file
View File

@ -0,0 +1,211 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services your application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| 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' => env('APP_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' => env('APP_URL', 'http://localhost'),
/*
|--------------------------------------------------------------------------
| 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' => 'Australia/Melbourne',
/*
|--------------------------------------------------------------------------
| 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',
/*
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
*/
'fallback_locale' => 'en',
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is used by the Illuminate encrypter service and should be set
| to a random, 32 character string, otherwise these encrypted strings
| will not be safe. Please do this before deploying an application!
|
*/
'key' => env('APP_KEY'),
'cipher' => 'AES-256-CBC',
/*
|--------------------------------------------------------------------------
| Logging Configuration
|--------------------------------------------------------------------------
|
| Here you may configure the log settings for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Settings: "single", "daily", "syslog", "errorlog"
|
*/
'log' => env('APP_LOG', 'single'),
'log_level' => env('APP_LOG_LEVEL', 'debug'),
/*
|--------------------------------------------------------------------------
| 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' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
Way\Generators\GeneratorsServiceProvider::class,
Xethron\MigrationsGenerator\MigrationsGeneratorServiceProvider::class,
],
/*
|--------------------------------------------------------------------------
| 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' => [
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
'Blade' => Illuminate\Support\Facades\Blade::class,
'Cache' => Illuminate\Support\Facades\Cache::class,
'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class,
'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class,
'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class,
'Password' => Illuminate\Support\Facades\Password::class,
'Queue' => Illuminate\Support\Facades\Queue::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class,
'Redis' => Illuminate\Support\Facades\Redis::class,
'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class,
'Schema' => Illuminate\Support\Facades\Schema::class,
'Session' => Illuminate\Support\Facades\Session::class,
'Storage' => Illuminate\Support\Facades\Storage::class,
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
],
];

107
config/auth.php Normal file
View File

@ -0,0 +1,107 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option controls the default authentication "guard" and password
| reset options for your application. You may change these defaults
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| here which uses session storage and the Eloquent user provider.
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| Supported: "session", "token"
|
*/
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
],
],
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| Here you may set the options for resetting passwords including the view
| that is your password reset e-mail. You may also set the name of the
| table that maintains all of the reset tokens for your application.
|
| You may specify multiple password reset configurations if you have more
| than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types.
|
| The expire time is the number of minutes that the reset token should be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
*/
'passwords' => [
'users' => [
'provider' => 'users',
'email' => 'auth.emails.password',
'table' => 'password_resets',
'expire' => 60,
],
],
];

54
config/broadcasting.php Normal file
View File

@ -0,0 +1,54 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Broadcaster
|--------------------------------------------------------------------------
|
| This option controls the default broadcaster that will be used by the
| framework when an event needs to be broadcast. You may set this to
| any of the connections defined in the "connections" array below.
|
| Supported: "pusher", "redis", "log"
|
*/
'default' => env('BROADCAST_DRIVER', 'pusher'),
/*
|--------------------------------------------------------------------------
| Broadcast Connections
|--------------------------------------------------------------------------
|
| Here you may define all of the broadcast connections that will be used
| to broadcast events to other systems or over websockets. Samples of
| each available type of connection are provided inside this array.
|
*/
'connections' => [
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_KEY'),
'secret' => env('PUSHER_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
//
],
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
],
'log' => [
'driver' => 'log',
],
],
];

83
config/cache.php Normal file
View File

@ -0,0 +1,83 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache connection that gets used while
| using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function.
|
| Supported: "apc", "array", "database", "file", "memcached", "redis"
|
*/
'default' => env('CACHE_DRIVER', 'file'),
/*
|--------------------------------------------------------------------------
| Cache Stores
|--------------------------------------------------------------------------
|
| Here you may define all of the cache "stores" for your application as
| well as their drivers. You may even define multiple stores for the
| same cache driver to group types of items stored in your caches.
|
*/
'stores' => [
'apc' => [
'driver' => 'apc',
],
'array' => [
'driver' => 'array',
],
'database' => [
'driver' => 'database',
'table' => 'cache',
'connection' => null,
],
'file' => [
'driver' => 'file',
'path' => storage_path('framework/cache'),
],
'memcached' => [
'driver' => 'memcached',
'servers' => [
[
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
'port' => env('MEMCACHED_PORT', 11211),
'weight' => 100,
],
],
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
],
],
/*
|--------------------------------------------------------------------------
| 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',
];

35
config/compile.php Normal file
View File

@ -0,0 +1,35 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| 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.
|
*/
'files' => [
//
],
/*
|--------------------------------------------------------------------------
| Compiled File Providers
|--------------------------------------------------------------------------
|
| Here you may list service providers which define a "compiles" function
| that returns additional files that should be compiled, providing an
| easy way to get common files from any packages you are utilizing.
|
*/
'providers' => [
//
],
];

120
config/database.php Normal file
View File

@ -0,0 +1,120 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| 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' => env('DB_CONNECTION', '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' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
],
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
],
],
/*
|--------------------------------------------------------------------------
| 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 haven't actually been run in the database.
|
*/
'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' => [
'cluster' => false,
'default' => [
'host' => env('REDIS_HOST', 'localhost'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
],
];

67
config/filesystems.php Normal file
View File

@ -0,0 +1,67 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
| by the framework. A "local" driver, as well as a variety of cloud
| based drivers are available for your choosing. Just store away!
|
| Supported: "local", "ftp", "s3", "rackspace"
|
*/
'default' => 'local',
/*
|--------------------------------------------------------------------------
| Default Cloud Filesystem Disk
|--------------------------------------------------------------------------
|
| Many applications store files both locally and in the cloud. For this
| reason, you may specify a default "cloud" driver here. This driver
| will be bound as the Cloud disk implementation in the container.
|
*/
'cloud' => 's3',
/*
|--------------------------------------------------------------------------
| Filesystem Disks
|--------------------------------------------------------------------------
|
| Here you may configure as many filesystem "disks" as you wish, and you
| may even configure multiple disks of the same driver. Defaults have
| been setup for each driver as an example of the required options.
|
*/
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => 'your-key',
'secret' => 'your-secret',
'region' => 'your-region',
'bucket' => 'your-bucket',
],
],
];

112
config/mail.php Normal file
View File

@ -0,0 +1,112 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| 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", "mailgun", "mandrill",
| "ses", "sparkpost", "log"
|
*/
'driver' => env('MAIL_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 Mailgun mail service which will provide reliable deliveries.
|
*/
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
/*
|--------------------------------------------------------------------------
| SMTP Host Port
|--------------------------------------------------------------------------
|
| This is the SMTP port used by your application to deliver e-mails to
| users of the application. Like the host we have set this value to
| stay compatible with the Mailgun e-mail application by default.
|
*/
'port' => env('MAIL_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' => ['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' => env('MAIL_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' => env('MAIL_USERNAME'),
/*
|--------------------------------------------------------------------------
| 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' => env('MAIL_PASSWORD'),
/*
|--------------------------------------------------------------------------
| 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',
];

9
config/photo.php Normal file
View File

@ -0,0 +1,9 @@
<?php
return [
'dir'=>'/var/www/sites/co.dlcm.p/store',
'import'=>[
'accepted'=>['jpg'],
'log'=>'/tmp/import.log',
],
];

85
config/queue.php Normal file
View File

@ -0,0 +1,85 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| 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: "null", "sync", "database", "beanstalkd", "sqs", "redis"
|
*/
'default' => env('QUEUE_DRIVER', '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' => [
'sync' => [
'driver' => 'sync',
],
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'expire' => 60,
],
'beanstalkd' => [
'driver' => 'beanstalkd',
'host' => 'localhost',
'queue' => 'default',
'ttr' => 60,
],
'sqs' => [
'driver' => 'sqs',
'key' => 'your-public-key',
'secret' => 'your-secret-key',
'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id',
'queue' => 'your-queue-name',
'region' => 'us-east-1',
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
'queue' => 'default',
'expire' => 60,
],
],
/*
|--------------------------------------------------------------------------
| Failed Queue Jobs
|--------------------------------------------------------------------------
|
| These options configure the behavior of failed queue job logging so you
| can control which database and table are used to store the jobs that
| have failed. You may change them to any database / table you wish.
|
*/
'failed' => [
'database' => env('DB_CONNECTION', 'mysql'),
'table' => 'failed_jobs',
],
];

42
config/services.php Normal file
View File

@ -0,0 +1,42 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Third Party Services
|--------------------------------------------------------------------------
|
| This file is for storing the credentials for third party services such
| as Stripe, Mailgun, Mandrill, and others. This file provides a sane
| default location for this type of information, allowing packages
| to have a conventional place to find your various credentials.
|
*/
'mailgun' => [
'domain' => env('MAILGUN_DOMAIN'),
'secret' => env('MAILGUN_SECRET'),
],
'mandrill' => [
'secret' => env('MANDRILL_SECRET'),
],
'ses' => [
'key' => env('SES_KEY'),
'secret' => env('SES_SECRET'),
'region' => 'us-east-1',
],
'sparkpost' => [
'secret' => env('SPARKPOST_SECRET'),
],
'stripe' => [
'model' => App\User::class,
'key' => env('STRIPE_KEY'),
'secret' => env('STRIPE_SECRET'),
],
];

166
config/session.php Normal file
View File

@ -0,0 +1,166 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| 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: "file", "cookie", "database", "apc",
| "memcached", "redis", "array"
|
*/
'driver' => env('SESSION_DRIVER', 'file'),
/*
|--------------------------------------------------------------------------
| Session Lifetime
|--------------------------------------------------------------------------
|
| Here you may specify the number of minutes that you wish the session
| to be allowed to remain idle before it expires. If you want them
| to immediately expire on the browser closing, set that option.
|
*/
'lifetime' => 120,
'expire_on_close' => false,
/*
|--------------------------------------------------------------------------
| Session Encryption
|--------------------------------------------------------------------------
|
| This option allows you to easily specify that all of your session data
| should be encrypted before it is stored. All encryption will be run
| automatically by Laravel and you can use the Session like normal.
|
*/
'encrypt' => false,
/*
|--------------------------------------------------------------------------
| 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('framework/sessions'),
/*
|--------------------------------------------------------------------------
| Session Database Connection
|--------------------------------------------------------------------------
|
| When using the "database" or "redis" session drivers, you may specify a
| connection that should be used to manage these sessions. This should
| correspond to a connection in your database configuration options.
|
*/
'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' => [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,
/*
|--------------------------------------------------------------------------
| HTTPS Only Cookies
|--------------------------------------------------------------------------
|
| By setting this option to true, session cookies will only be sent back
| to the server if the browser has a HTTPS connection. This will keep
| the cookie from being sent to you if it can not be done securely.
|
*/
'secure' => false,
/*
|--------------------------------------------------------------------------
| HTTP Access Only
|--------------------------------------------------------------------------
|
| Setting this value to true will prevent JavaScript from accessing the
| value of the cookie and the cookie will only be accessible through
| the HTTP protocol. You are free to modify this option if needed.
|
*/
'http_only' => true,
];

33
config/view.php Normal file
View File

@ -0,0 +1,33 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| 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' => [
realpath(base_path('resources/views')),
],
/*
|--------------------------------------------------------------------------
| Compiled View Path
|--------------------------------------------------------------------------
|
| This option determines where all the compiled Blade templates will be
| stored for your application. Typically, this is within the storage
| directory. However, as usual, you are free to change this value.
|
*/
'compiled' => realpath(storage_path('framework/views')),
];

1
database/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.sqlite

View File

@ -0,0 +1,21 @@
<?php
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
$factory->define(App\User::class, function (Faker\Generator $faker) {
return [
'name' => $faker->name,
'email' => $faker->safeEmail,
'password' => bcrypt(str_random(10)),
'remember_token' => str_random(10),
];
});

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('users');
}
}

View File

@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePasswordResetsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token')->index();
$table->timestamp('created_at');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('password_resets');
}
}

View File

@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreatePhotoTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('photo', function(Blueprint $table)
{
$table->bigInteger('id', true);
$table->timestamps();
$table->integer('date_taken')->nullable();
$table->smallInteger('subsectime')->nullable();
$table->string('filename', 128);
$table->string('signature', 64)->nullable();
$table->string('make', 32)->nullable();
$table->string('model', 32)->nullable();
$table->integer('height')->nullable();
$table->integer('width')->nullable();
$table->integer('orientation')->nullable();
$table->float('gps_lat', 10, 0)->nullable();
$table->float('gps_lon', 10, 0)->nullable();
$table->binary('thumbnail', 65535)->nullable();
$table->boolean('duplicate')->nullable();
$table->boolean('remove')->nullable();
$table->boolean('flag')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('photo');
}
}

View File

@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreatePeopleTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('people', function(Blueprint $table)
{
$table->integer('id', true);
$table->string('tag', 16)->unique('tag_UNIQUE');
$table->string('name', 64)->nullable();
$table->integer('date_birth')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('people');
}
}

View File

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreatePhotoPeopleTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('photo_people', function(Blueprint $table)
{
$table->bigInteger('id', true);
$table->timestamps();
$table->integer('people_id');
$table->bigInteger('photo_id')->index('fk_pp_ph_idx');
$table->unique(['people_id','photo_id'], 'UNIQUE');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('photo_people');
}
}

View File

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreatePhotoTagTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('photo_tag', function(Blueprint $table)
{
$table->bigInteger('id', true);
$table->timestamps();
$table->bigInteger('photo_id');
$table->bigInteger('tag_id')->index('pt_t_idx');
$table->unique(['photo_id','tag_id'], 'UNIQUE');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('photo_tag');
}
}

View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateTagsTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tags', function(Blueprint $table)
{
$table->bigInteger('id', true);
$table->string('tag', 16)->unique('tag_UNIQUE');
$table->string('description', 45)->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('tags');
}
}

View File

@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddForeignKeysToPhotoPeopleTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('photo_people', function(Blueprint $table)
{
$table->foreign('people_id', 'fk_pp_p')->references('id')->on('people')->onUpdate('NO ACTION')->onDelete('NO ACTION');
$table->foreign('photo_id', 'fk_pp_ph')->references('id')->on('photo')->onUpdate('NO ACTION')->onDelete('NO ACTION');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('photo_people', function(Blueprint $table)
{
$table->dropForeign('fk_pp_p');
$table->dropForeign('fk_pp_ph');
});
}
}

View File

@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddForeignKeysToPhotoTagTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('photo_tag', function(Blueprint $table)
{
$table->foreign('photo_id', 'fk_pt_p')->references('id')->on('photo')->onUpdate('NO ACTION')->onDelete('NO ACTION');
$table->foreign('tag_id', 'fk_pt_t')->references('id')->on('tags')->onUpdate('NO ACTION')->onDelete('NO ACTION');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('photo_tag', function(Blueprint $table)
{
$table->dropForeign('fk_pt_p');
$table->dropForeign('fk_pt_t');
});
}
}

View File

@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateJobsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('jobs', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('queue');
$table->longText('payload');
$table->tinyInteger('attempts')->unsigned();
$table->tinyInteger('reserved')->unsigned();
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
$table->index(['queue', 'reserved', 'reserved_at']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('jobs');
}
}

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateFailedJobsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('failed_jobs', function (Blueprint $table) {
$table->increments('id');
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('failed_jobs');
}
}

1
database/seeds/.gitkeep Normal file
View File

@ -0,0 +1 @@

View File

@ -0,0 +1,16 @@
<?php
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// $this->call(UsersTableSeeder::class);
}
}

16
gulpfile.js Normal file
View File

@ -0,0 +1,16 @@
var elixir = require('laravel-elixir');
/*
|--------------------------------------------------------------------------
| Elixir Asset Management
|--------------------------------------------------------------------------
|
| Elixir provides a clean, fluent API for defining some basic Gulp tasks
| for your Laravel application. By default, we are compiling the Sass
| file for our application, as well as publishing vendor resources.
|
*/
elixir(function(mix) {
mix.sass('app.scss');
});

@ -1 +0,0 @@
Subproject commit 5ffa395307a3b26f901dde5f3064c48a15979f0d

@ -1 +0,0 @@
Subproject commit 9a41635025206453cf05a092b5f3b981d5635d7a

12
package.json Normal file
View File

@ -0,0 +1,12 @@
{
"private": true,
"scripts": {
"prod": "gulp --production",
"dev": "gulp watch"
},
"devDependencies": {
"gulp": "^3.9.1",
"laravel-elixir": "^5.0.0",
"bootstrap-sass": "^3.3.0"
}
}

30
phpunit.xml Normal file
View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="bootstrap/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Application Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
<exclude>
<file>./app/Http/routes.php</file>
</exclude>
</whitelist>
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
</php>
</phpunit>

20
public/.htaccess Normal file
View File

@ -0,0 +1,20 @@
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

0
public/favicon.ico Normal file
View File

58
public/index.php Normal file
View File

@ -0,0 +1,58 @@
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <taylorotwell@gmail.com>
*/
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels nice to relax.
|
*/
require __DIR__.'/../bootstrap/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__.'/../bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);

2
public/robots.txt Normal file
View File

@ -0,0 +1,2 @@
User-agent: *
Disallow:

23
public/web.config Normal file
View File

@ -0,0 +1,23 @@
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)/$" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="/{R:1}" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
<match url="^" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

27
readme.md Normal file
View File

@ -0,0 +1,27 @@
# Laravel PHP Framework
[![Build Status](https://travis-ci.org/laravel/framework.svg)](https://travis-ci.org/laravel/framework)
[![Total Downloads](https://poser.pugx.org/laravel/framework/d/total.svg)](https://packagist.org/packages/laravel/framework)
[![Latest Stable Version](https://poser.pugx.org/laravel/framework/v/stable.svg)](https://packagist.org/packages/laravel/framework)
[![Latest Unstable Version](https://poser.pugx.org/laravel/framework/v/unstable.svg)](https://packagist.org/packages/laravel/framework)
[![License](https://poser.pugx.org/laravel/framework/license.svg)](https://packagist.org/packages/laravel/framework)
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as authentication, routing, sessions, queueing, and caching.
Laravel is accessible, yet powerful, providing tools needed for large, robust applications. A superb inversion of control container, expressive migration system, and tightly integrated unit testing support give you the tools you need to build any application with which you are tasked.
## Official Documentation
Documentation for the framework can be found on the [Laravel website](http://laravel.com/docs).
## Contributing
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](http://laravel.com/docs/contributions).
## Security Vulnerabilities
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed.
## License
The Laravel framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).

2
resources/assets/sass/app.scss vendored Normal file
View File

@ -0,0 +1,2 @@
// @import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap";

View File

@ -0,0 +1,19 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Language Lines
|--------------------------------------------------------------------------
|
| The following language lines are used during authentication for various
| messages that we need to display to the user. You are free to modify
| these language lines according to your application's requirements.
|
*/
'failed' => 'These credentials do not match our records.',
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
];

View File

@ -0,0 +1,19 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| 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;',
];

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