mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-09-19 16:01:34 +02:00
Fixing Dependancies, re-organising files
Only a little progress. Still heaps to do
This commit is contained in:
parent
2c696666df
commit
77922893d2
20
.env.example
20
.env.example
@ -1,18 +1,2 @@
|
||||
APP_ENV=local
|
||||
APP_DEBUG=true
|
||||
APP_KEY=SomeRandomString
|
||||
|
||||
DB_HOST=localhost
|
||||
DB_DATABASE=homestead
|
||||
DB_USERNAME=homestead
|
||||
DB_PASSWORD=secret
|
||||
|
||||
CACHE_DRIVER=file
|
||||
SESSION_DRIVER=file
|
||||
QUEUE_DRIVER=sync
|
||||
|
||||
MAIL_DRIVER=smtp
|
||||
MAIL_HOST=mailtrap.io
|
||||
MAIL_PORT=2525
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
APP_ENV=development
|
||||
APP_DEBUG=true
|
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,3 +1,9 @@
|
||||
/vendor
|
||||
/node_modules
|
||||
.env
|
||||
/.DS_Store
|
||||
/Thumbs.db
|
||||
.env.development.php
|
||||
.env.php
|
||||
.idea
|
||||
.project
|
@ -1,4 +1,4 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
<?php namespace InvoiceNinja\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Foundation\Inspiring;
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php namespace App\Providers;
|
||||
|
||||
use App;
|
||||
use Illuminate\Routing\Router;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
@ -27,263 +27,6 @@ class RouteServiceProvider extends ServiceProvider {
|
||||
|
||||
|
||||
|
||||
App::before(function($request)
|
||||
{
|
||||
// Ensure all request are over HTTPS in production
|
||||
if (App::environment() == ENV_PRODUCTION)
|
||||
{
|
||||
if (!Request::secure())
|
||||
{
|
||||
return Redirect::secure(Request::getRequestUri());
|
||||
}
|
||||
}
|
||||
|
||||
// If the database doens't yet exist we'll skip the rest
|
||||
if (!Utils::isNinja() && !Utils::isDatabaseSetup())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// check the application is up to date and for any news feed messages
|
||||
if (Auth::check())
|
||||
{
|
||||
$count = Session::get(SESSION_COUNTER, 0);
|
||||
Session::put(SESSION_COUNTER, ++$count);
|
||||
|
||||
if (!Utils::startsWith($_SERVER['REQUEST_URI'], '/news_feed') && !Session::has('news_feed_id')) {
|
||||
$data = false;
|
||||
if (Utils::isNinja()) {
|
||||
$data = Utils::getNewsFeedResponse();
|
||||
} else {
|
||||
$file = @file_get_contents(NINJA_APP_URL . '/news_feed/' . Utils::getUserType() . '/' . NINJA_VERSION);
|
||||
$data = @json_decode($file);
|
||||
}
|
||||
if ($data) {
|
||||
if ($data->version != NINJA_VERSION) {
|
||||
$params = [
|
||||
'user_version' => NINJA_VERSION,
|
||||
'latest_version'=> $data->version,
|
||||
'releases_link' => link_to(RELEASES_URL, 'Invoice Ninja', ['target' => '_blank'])
|
||||
];
|
||||
Session::put('news_feed_id', NEW_VERSION_AVAILABLE);
|
||||
Session::put('news_feed_message', trans('texts.new_version_available', $params));
|
||||
} else {
|
||||
Session::put('news_feed_id', $data->id);
|
||||
if ($data->message && $data->id > Auth::user()->news_feed_id) {
|
||||
Session::put('news_feed_message', $data->message);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Session::put('news_feed_id', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we're requesting to change the account's language
|
||||
if (Input::has('lang'))
|
||||
{
|
||||
$locale = Input::get('lang');
|
||||
App::setLocale($locale);
|
||||
Session::set(SESSION_LOCALE, $locale);
|
||||
|
||||
if (Auth::check())
|
||||
{
|
||||
if ($language = Language::whereLocale($locale)->first())
|
||||
{
|
||||
$account = Auth::user()->account;
|
||||
$account->language_id = $language->id;
|
||||
$account->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Auth::check())
|
||||
{
|
||||
$locale = Session::get(SESSION_LOCALE, DEFAULT_LOCALE);
|
||||
App::setLocale($locale);
|
||||
}
|
||||
|
||||
// Make sure the account/user localization settings are in the session
|
||||
if (Auth::check() && !Session::has(SESSION_TIMEZONE))
|
||||
{
|
||||
Event::fire('user.refresh');
|
||||
}
|
||||
|
||||
// Check if the user is claiming a license (ie, additional invoices, white label, etc.)
|
||||
$claimingLicense = Utils::startsWith($_SERVER['REQUEST_URI'], '/claim_license');
|
||||
if (!$claimingLicense && Input::has('license_key') && Input::has('product_id'))
|
||||
{
|
||||
$licenseKey = Input::get('license_key');
|
||||
$productId = Input::get('product_id');
|
||||
|
||||
$data = trim(file_get_contents((Utils::isNinjaDev() ? 'http://ninja.dev' : NINJA_APP_URL) . "/claim_license?license_key={$licenseKey}&product_id={$productId}"));
|
||||
|
||||
if ($productId == PRODUCT_INVOICE_DESIGNS)
|
||||
{
|
||||
if ($data = json_decode($data))
|
||||
{
|
||||
foreach ($data as $item)
|
||||
{
|
||||
$design = new InvoiceDesign();
|
||||
$design->id = $item->id;
|
||||
$design->name = $item->name;
|
||||
$design->javascript = $item->javascript;
|
||||
$design->save();
|
||||
}
|
||||
|
||||
if (!Utils::isNinjaProd()) {
|
||||
Cache::forget('invoice_designs_cache_' . Auth::user()->maxInvoiceDesignId());
|
||||
}
|
||||
|
||||
Session::flash('message', trans('texts.bought_designs'));
|
||||
}
|
||||
}
|
||||
else if ($productId == PRODUCT_WHITE_LABEL)
|
||||
{
|
||||
if ($data == 'valid')
|
||||
{
|
||||
$account = Auth::user()->account;
|
||||
$account->pro_plan_paid = NINJA_DATE;
|
||||
$account->save();
|
||||
|
||||
Session::flash('message', trans('texts.bought_white_label'));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Filters
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following filters are used to verify that the user of the current
|
||||
| session is logged into this application. The "basic" filter easily
|
||||
| integrates HTTP Basic authentication for quick, simple checking.
|
||||
|
|
||||
*/
|
||||
|
||||
$router->filter('auth', function()
|
||||
{
|
||||
if (Auth::guest())
|
||||
{
|
||||
if (Utils::isNinja() || Account::count() == 0)
|
||||
{
|
||||
return Redirect::guest('/');
|
||||
}
|
||||
else
|
||||
{
|
||||
return Redirect::guest('/login');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$router->filter('auth.basic', function()
|
||||
{
|
||||
return Auth::basic();
|
||||
});
|
||||
|
||||
$router->filter('api.access', function()
|
||||
{
|
||||
$headers = Utils::getApiHeaders();
|
||||
|
||||
// check for a valid token
|
||||
$token = AccountToken::where('token', '=', Request::header('X-Ninja-Token'))->first(['id', 'user_id']);
|
||||
|
||||
if ($token) {
|
||||
Auth::loginUsingId($token->user_id);
|
||||
Session::set('token_id', $token->id);
|
||||
} else {
|
||||
sleep(3);
|
||||
return Response::make('Invalid token', 403, $headers);
|
||||
}
|
||||
|
||||
if (!Utils::isNinja()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!Utils::isPro()) {
|
||||
return Response::make('API requires pro plan', 403, $headers);
|
||||
} else {
|
||||
$accountId = Auth::user()->account->id;
|
||||
|
||||
// http://stackoverflow.com/questions/1375501/how-do-i-throttle-my-sites-api-users
|
||||
$hour = 60 * 60;
|
||||
$hour_limit = 100; # users are limited to 100 requests/hour
|
||||
$hour_throttle = Cache::get("hour_throttle:{$accountId}", null);
|
||||
$last_api_request = Cache::get("last_api_request:{$accountId}", 0);
|
||||
$last_api_diff = time() - $last_api_request;
|
||||
|
||||
if (is_null($hour_throttle)) {
|
||||
$new_hour_throttle = 0;
|
||||
} else {
|
||||
$new_hour_throttle = $hour_throttle - $last_api_diff;
|
||||
$new_hour_throttle = $new_hour_throttle < 0 ? 0 : $new_hour_throttle;
|
||||
$new_hour_throttle += $hour / $hour_limit;
|
||||
$hour_hits_remaining = floor(( $hour - $new_hour_throttle ) * $hour_limit / $hour);
|
||||
$hour_hits_remaining = $hour_hits_remaining >= 0 ? $hour_hits_remaining : 0;
|
||||
}
|
||||
|
||||
if ($new_hour_throttle > $hour) {
|
||||
$wait = ceil($new_hour_throttle - $hour);
|
||||
sleep(1);
|
||||
return Response::make("Please wait {$wait} second(s)", 403, $headers);
|
||||
}
|
||||
|
||||
Cache::put("hour_throttle:{$accountId}", $new_hour_throttle, 10);
|
||||
Cache::put("last_api_request:{$accountId}", time(), 10);
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Guest Filter
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The "guest" filter is the counterpart of the authentication filters as
|
||||
| it simply checks that the current user is not logged in. A redirect
|
||||
| response will be issued if they are, which you may freely change.
|
||||
|
|
||||
*/
|
||||
|
||||
$router->filter('guest', function()
|
||||
{
|
||||
if (Auth::check()) return Redirect::to('/');
|
||||
});
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| CSRF Protection Filter
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The CSRF filter is responsible for protecting your application against
|
||||
| cross-site request forgery attacks. If this special token in a user
|
||||
| session does not match the one given in this request, we'll bail.
|
||||
|
|
||||
*/
|
||||
|
||||
$router->filter('csrf', function()
|
||||
{
|
||||
if ($_SERVER['REQUEST_URI'] != '/signup/register')
|
||||
{
|
||||
$token = Request::ajax() ? Request::header('X-CSRF-Token') : Input::get('_token');
|
||||
|
||||
if (Session::token() != $token)
|
||||
{
|
||||
Session::flash('warning', trans('texts.session_expired'));
|
||||
|
||||
return Redirect::to('/');
|
||||
//throw new Illuminate\Session\TokenMismatchException;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,18 +1,40 @@
|
||||
{
|
||||
"name": "laravel/laravel",
|
||||
"description": "The Laravel Framework.",
|
||||
"keywords": ["framework", "laravel"],
|
||||
"license": "MIT",
|
||||
"type": "project",
|
||||
"name": "hillelcoren/invoice-ninja",
|
||||
"description": "An open-source invoicing site built with Laravel",
|
||||
"keywords": ["invoice", "laravel"],
|
||||
"license": "Attribution Assurance License",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Hillel Coren",
|
||||
"email": "hillelcoren@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Jeramy Simpson",
|
||||
"email": "jeramy.n.simpson@gmail.com"
|
||||
}
|
||||
],
|
||||
"repositories": [
|
||||
{
|
||||
"type": "package",
|
||||
"package": {
|
||||
"name": "calvinfroedge/PHP-Payments",
|
||||
"version": "dev-master",
|
||||
"source": {
|
||||
"url": "https://github.com/calvinfroedge/PHP-Payments",
|
||||
"type": "git",
|
||||
"reference": "origin/master"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"laravel/framework": "5.0.*",
|
||||
"patricktalmadge/bootstrapper": "5.5.x",
|
||||
"zizaco/confide": "4.2.x",
|
||||
"anahkiasen/former": "4.0.*@dev",
|
||||
"barryvdh/laravel-debugbar": "~2.0.2",
|
||||
"chumper/datatable": "dev-master",
|
||||
"chumper/datatable": "dev-develop",
|
||||
"omnipay/omnipay": "2.3.x",
|
||||
"intervention/image": "2.1.x",
|
||||
"intervention/image": "dev-master",
|
||||
"webpatser/laravel-countries": "dev-master",
|
||||
"barryvdh/laravel-ide-helper": "2.0.x",
|
||||
"doctrine/dbal": "2.5.x",
|
||||
@ -24,8 +46,9 @@
|
||||
"coatesap/omnipay-paymentsense": "~2.0",
|
||||
"coatesap/omnipay-realex": "~2.0",
|
||||
"fruitcakestudio/omnipay-sisow": "~2.0",
|
||||
"alfaproject/omnipay-skrill": "dev-master"
|
||||
|
||||
"alfaproject/omnipay-skrill": "dev-master",
|
||||
"illuminate/html": "5.*",
|
||||
"calvinfroedge/PHP-Payments": "dev-master"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0",
|
||||
@ -33,6 +56,12 @@
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"app/Console/Commands",
|
||||
"app/Http/Controllers",
|
||||
"app/Models",
|
||||
"app/libraries",
|
||||
"app/ninja",
|
||||
"vendor/calvinfroedge/PHP-Payments/lib",
|
||||
"database"
|
||||
],
|
||||
"psr-4": {
|
||||
|
@ -26,7 +26,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'url' => 'http://localhost',
|
||||
'url' => 'http://ninja5.boldplatform.com',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@ -39,7 +39,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'timezone' => 'UTC',
|
||||
'timezone' => 'Australia/Brisbane',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@ -78,7 +78,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'key' => env('APP_KEY', 'SomeRandomString'),
|
||||
'key' => env('APP_KEY', 'p118gfK&rlbAb22CB&8!5SKiPkcZpzGG'),
|
||||
|
||||
'cipher' => MCRYPT_RIJNDAEL_128,
|
||||
|
||||
@ -145,6 +145,17 @@ return [
|
||||
'App\Providers\EventServiceProvider',
|
||||
'App\Providers\RouteServiceProvider',
|
||||
|
||||
/*
|
||||
* Additional Providers
|
||||
*/
|
||||
'Bootstrapper\BootstrapperL5ServiceProvider',
|
||||
'Former\FormerServiceProvider',
|
||||
'Barryvdh\Debugbar\ServiceProvider',
|
||||
'Chumper\Datatable\DatatableServiceProvider',
|
||||
'Intervention\Image\ImageServiceProvider',
|
||||
'Webpatser\Countries\CountriesServiceProvider',
|
||||
'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider',
|
||||
'Illuminate\Html\HtmlServiceProvider',
|
||||
],
|
||||
|
||||
/*
|
||||
@ -193,6 +204,42 @@ return [
|
||||
'Validator' => 'Illuminate\Support\Facades\Validator',
|
||||
'View' => 'Illuminate\Support\Facades\View',
|
||||
|
||||
// Added Class Aliases
|
||||
|
||||
'Form' => 'Illuminate\Html\FormFacade',
|
||||
'HTML' => 'Illuminate\Html\HtmlFacade',
|
||||
'SSH' => 'Illuminate\Support\Facades\SSH',
|
||||
'Alert' => 'Bootstrapper\Alert',
|
||||
'Badge' => 'Bootstrapper\Badge',
|
||||
'Breadcrumb' => 'Bootstrapper\Breadcrumb',
|
||||
'Button' => 'Bootstrapper\Button',
|
||||
'ButtonGroup' => 'Bootstrapper\ButtonGroup',
|
||||
'ButtonToolbar' => 'Bootstrapper\ButtonToolbar',
|
||||
'Carousel' => 'Bootstrapper\Carousel',
|
||||
'DropdownButton' => 'Bootstrapper\DropdownButton',
|
||||
'Form' => 'Bootstrapper\Form',
|
||||
'Helpers' => 'Bootstrapper\Helpers',
|
||||
'Icon' => 'Bootstrapper\Icon',
|
||||
//'Image' => 'Bootstrapper\Image',
|
||||
'Label' => 'Bootstrapper\Label',
|
||||
'MediaObject' => 'Bootstrapper\MediaObject',
|
||||
'Navbar' => 'Bootstrapper\Navbar',
|
||||
'Navigation' => 'Bootstrapper\Navigation',
|
||||
'Paginator' => 'Bootstrapper\Paginator',
|
||||
'Progress' => 'Bootstrapper\Progress',
|
||||
'Tabbable' => 'Bootstrapper\Tabbable',
|
||||
'Table' => 'Bootstrapper\Table',
|
||||
'Thumbnail' => 'Bootstrapper\Thumbnail',
|
||||
'Typeahead' => 'Bootstrapper\Typeahead',
|
||||
'Typography' => 'Bootstrapper\Typography',
|
||||
'Former' => 'Former\Facades\Former',
|
||||
'Datatable' => 'Chumper\Datatable\Facades\DatatableFacade',
|
||||
'Omnipay' => 'Omnipay\Omnipay',
|
||||
'CreditCard' => 'Omnipay\Common\CreditCard',
|
||||
'Image' => 'Intervention\Image\Facades\Image',
|
||||
'Countries' => 'Webpatser\Countries\CountriesFacade',
|
||||
'Carbon' => 'Carbon\Carbon',
|
||||
'Rocketeer' => 'Rocketeer\Facades\Rocketeer',
|
||||
],
|
||||
|
||||
];
|
||||
|
@ -54,7 +54,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'from' => ['address' => null, 'name' => null],
|
||||
'from' => ['address' => 'contact@invoiceninja.com', 'name' => 'Invoice Ninja'],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
@ -13,7 +13,4 @@
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^ index.php [L]
|
||||
|
||||
# cp from invoice ninja
|
||||
RewriteCond %{HTTP:Authorization} .
|
||||
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
|
||||
</IfModule>
|
||||
|
Loading…
Reference in New Issue
Block a user