visible vanilla dashboard to only one ip-address (admin) - vanilla-forums

http://fidm.in/vanilla/
I want to restrict these two urls
[1]: http://fidm.in/vanilla/dashboard/settings , http://fidm.in/vanilla/settings outside my ip-address.
I have tried through .htacess but no success.

If .htaccess not work.you try php custom code $_SERVER['REMOTE_ADDR'].
Go to applications/dashboard/views/settings folder
and use custom coding in index.php
if($_SERVER['REMOTE_ADDR'] != '00.00.00.00'){
header('Location: http://www.rediect-domain.com/');
exit;
}

Related

Laravel - Catch specific public folder route

Sorry if this sounds so basic.
I've encoutered a scenario where I need to add certain checks when user access certain file in public folder.
With default setting, you can access specific file in public directory directly by typing its url in the browser: Sorry this is misleading.
You can access an image with:
localhost/img/banner.jpg
But I can't catch it with:
Route::get('/img/banner.jpg', function(){
//checks goes here
});
How it should be done?
You should create controller for serve images(files) and disallow direct access if you need control. On example:
Route::get('/file/{name}', function ($name) {
// Your check and return file with correct response headers
}
Or best way to create controller for that.
https://laravel.com/docs/5.6/filesystem . Check laravel Docs to see how manage multiple file storages.
I just found another way without using filesystem.
In .htaccess inside public folder, add these:
RewriteCond \banner.jpg$ !-d
RewriteRule ^ index.php [L]
Which will let laravel handle the route then I can catch it with:
Route::get('/img/banner.jpg', function(){
//checks goes here
});

Laravel. Add port to home url

Site use port 8080 on new server.
I need "site.com" => "site.com:8080"
How change base url in laravel for correct including css/js and redirects?
Ok, we tried many things.
It seems it's a bug or something. They have it since Laravel 4 and do not want to fix it:
https://github.com/laravel/framework/issues/1833
The only solutions I see here are:
1. To use standard port.
2. To generate URLs manually. For example:
// in controller
$baseUrl = 'http://'.$_SERVER['HTTP_HOST'].'/';
// in template
<link hre="{{ $baseUrl.'css/myStyleSheet.css' }}" ....>
Or you could set this variable in your top layout, so all inherited views have it.
I ended up adding the following line to boot() function of AppServiceProvider.php :
URL::forceRootUrl(env('APP_URL'));
You can also hardcode it there, but this way it uses the settings from .env file.
Warning: if the APP_URL is https, then I also needed to add the following line, or otherwise it would alter it to http (weird):
URL::forceScheme('https');

Laravel 5 maintenance mode turn on without artisan

Is there any possibility to turn on and turn off Laravel 5 maintenance without php artisan up and down commands when my website is being hosted ?
What I've done:
Route::get('site/shutdown', function(){
return Artisan::call('down');
});
Route::get('site/live', function(){
return Artisan::call('up');
});
The first route is working fine. But when I call site/live the site still is shuted down. What can cause this problem ?
If your project is already down, you cannot call another function.
What happens after you run php artisan down is that it creates a file named down inside storage/framework. After running php artisan up the file is removed.
You can create the file manually inside storage/framework. It will down your project. When you want to take your project live again, just remove the file.
I think the right answer is missing here..
You could add your route to app/http/middleware/CheckForMaintenanceMode.php
protected $except = [
//here
];
So It never would be off.
when you run artisan down. site is not available so when try to call up, your IP can't access site.
you must call down with your IP exception.
php artisan down --allow=127.0.0.1 --allow=192.168.0.0/16
or add ::1 to local.
to make that in route without command
try to save this command in specific one and call it.
Laravel 8 introduced secret in maintenance mode, in which you can bypass the maintenance mode by providing a secret, then your Artisan::call would work.
You could add your routes to the $except var in CheckForMaintenanceMode middleware to bypass the check. Then your site/live route would work just fine.
In order to make your site live again using an url, you can create a live.php file which you put in laravel's public folder and then visit http://your.domain/live.php .
In the live.php file you need something like this: (check your projects directory structure if you don't use the default public folder!)
<?php
unlink(dirname(__FILE__) . "/../storage/framework/down");
header("Location: your.domain");
die;
just put
Artisan::call('up');
without route function.

Unable to run the app on hosted server

I have just installed Ci framework and tried on my local some basics according to the tutorial.
http://ellislab.com/codeigniter/user-guide/tutorial/static_pages.html
On local machine, everything was OK and page was displayed.
Than I upload project to the server (I am using wedos web hosting where I already have som web which is working correctly) but this is not working for the application which I copied it here. When I type the URL I got 404 error.
On my webhosting service I have www folder where i put my index.html file. Than when i type www.mydomain.eu I get this index.html file. Than I have subfolder www/folder/index.html Than when i type www.mydomain.eu/folder i get this page so it is ok.
Than i have www/folder2/here i unzip CodeIgniter framework and when i type www.mydomain.eu/folder2, 404 Page Not Found appears. The error is not general error from browser but generated from the CI framework.
I have created my own controler in application/controllers/mycontroller.php
<?php
class Mycontroller extends CI_Controller {
public function view($page = ‘enter_form’)
{
$data[‘title’] = ucfirst($page); // Capitalize the first letter
$this->load->view(‘templates/header’, $data);
$this->load->view(‘pages/’.$page, $data);
$this->load->view(‘templates/footer’, $data);
}
}
And I have following structure of views:
views/pages/enter_form.php
views/templates/header.php and footer.php
And the following settings:
1) $config[‘base_url’] = ‘’; but I have tried ‘http://mydomain.eu/’ and ‘http://mydomain.eu/www/’ or ‘http://mydomain.eu/www/folder2/’
2) $route[‘default_controller’] = ‘mycontroller/view’;
$route[’(:any)’] = ‘mycontroller/view/$1’;
Thank you for any help
Sounds to me like there is either a configuration issue or a rewrite issue going on. Do you have a .htaccess file in your CI root folder where your index.php file lives? Seeing that you are depending on the CI to pick up any uri and reroute it to a specific route, this might be the issue. I've ran into issues with this before on different hosts. Make sure mod rewrite is enabled and make sure your .htaccess is something similar to this:
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|assets|uploads)
RewriteRule ^(.*)$ /index.php/$1 [L]
Ok, so it seems like the typo somewhere, because when I used the default CI welcome pages, it works. So I will try to find the typo myself and i will see...

CodeIgniter redirect not working on a real Server

I'm having a problem with CI 2.1.3 redirect function.
Everytime I call redirect, it shows a white-blank page. In fact, it works well on my localhost, the problem just occurs on my real server (with CentOS 5 installed).
This is how I call the redirects :
redirect('frontend/article/index');
or
redirect(base_url('articles.html'));
I did add a route in config/routes.php
$route['articles.html'] = 'frontend/article/index';
with : frontend is module, article is controller, and index is action (I'm using wiredesignz's HMVC module extension)
How could I fix it? And what is the problem here?
Thanks in advance!
UPDATE
I replaced CI redirect function by calling :
header("Location: http://example.com");
but it didn't work too.
So I created a file named info.php and uploaded it to my server. Here's the content:
<?php
phpinfo();
?>
When I type in the address bar : http://example.com/info.php, it shows like in the image.
Why was there a ">" character? Was it the problem causing redirect not working?
Firstly, make sure error reporting is enabled, or try placing the following at the top of your index.php.
error_reporting(E_ALL | E_WARNING | E_NOTICE);
ini_set('display_errors', TRUE);
If this doesn't point you in the right direction make sure you don't have any output echo, print_r, print, dump, etc before your call to redirect() method.
Another common cause or problems when moving to a new environment is white space. Check that your files don't have any whitespace at the bottom of them.
if you are defining .html in the config.php as the file ext. you do not need to postfix the route with it.
$route['articles'] //instead of $route['articles.html']
Also you need to remove the base_url() from the redirect cos that is not needed.
redirect('articles'); //should sort it
Hope this sorts ur problems.
EDIT
If this is still not working after attempting these changes, it will most likely be a problem in the controllers. If this is the case you may need to turn on error reporting in your index.php file to find out exactly where the problem is occurring.

Resources