Codeigniter Manage URL With Routes - codeigniter

I'm just starting a new saas project alone and I'm stuck in Codeigniter's URI configuration.
I'm using xampp, and so far I have a folder with my site in it with it's own database.
If a client register to my product a new subfolder will be generated also new database will be generated related to this client.
The main URL is as ex: (http://localhost/gms/admin) but how to manage urls from clients like this : (http://localhost/gms/client1/admin) .... etc and after client log with his new specific url it SHOULD load the related database.
I Took time to solve it. Please need it necessary.

in routes.php
$route['gms/(:any)/admin'] = 'gms/admin';
in gms controller
public function admin(){
$client = $this->uri->segment(2);
echo $client;
}

Related

How to control access to files at another server in Laravel

I have a host for my Laravel website and another (non-laravel) for stored files. Direct access to my files are blocked completely by default and I want to control access to them by creating temporary links in my Laravel site. I know how to code, just want to know the idea of how to do it (not details).
From the Laravel docs
Temporary URLs For files stored using the s3 or rackspace driver, you
may create a temporary URL to a given file using the temporaryUrl
method. This methods accepts a path and a DateTime instance specifying
when the URL should expire:
$url = Storage::temporaryUrl(
'file.jpg', now()->addMinutes(5)
);
You could also make your own solution by directing all image request through your own server and making sure the file visibility is set to private.
Here is an example of how a controller could return image from your storage
public function get($path)
{
$file = Storage::disk('s3')->get($path);
// Do your temp link solution here
return response($file, 200)->header('Content-Type', 'image/png');
}
What i am using right now is Flysystem provided in laravel.Laravel Flysystem integration use simple drivers for working with local filesystems, Amazon S3 and other some space provide also. So for this doesn't matter whether is a server is laravel server or not.
Even better, it's very simple in this to switch between server by just changing server configuration in API.
As far as I know we can create temporary Url for s3 and rackspace in this also by calling temporaryUrl method. Caching is already in this.
That's the thing.
If your files are uploaded on an AWS S3 server
then,
use Storage;
$file_path = "4/1563454594.mp4";
if( Storage::disk('s3')->exists($file_path) ) {
// link expiration time
$urlExpires = Carbon::now()->addMinutes(1);
try {
$tempUrl = Storage::disk('s3')->temporaryUrl($file_path, $urlExpires);
} catch ( \Exception $e ) {
// Unable to test temporaryUrl, its giving driver dont support it issue.
return response($e->getMessage());
}
}
Your temporary URL will be generated, After given expiration time (1 minute). It will expire.

Route::resource clean /public from URL

I am making a system using the Laravel 5.6
I uploaded to a server that I have and access this externally
You used the software when a route uses resouce, for example::
Route::resource('materiais', 'MaterialController');
Because the routes you create using Route::get, Route::post, Route::patch, etc.., work correctly
For example, if I'm in
http://192.168.0.23/sisobras/public/neworder
and I go to open a new order he goes to the address
http://192.168.0.23/sisobras/public/serviceorder/2/create?
running correctly, a route looks like this:
Route::get('serviceorder/{id}/create', 'ServiceOrderController#create');
but if I'm in
http://192.168.0.23/sisobras/public/materials
and you can register new material the url looks like this:
http://192.168.0.23/materials/create
The view is called on the controller so
public function create()
{
$units = Units::all();
return view('materials/create', compact('units'));
}
and the lack of sisobras/public/ a Not Found error
When used with the php artisan serve works correctly

Codeigniter Issue route issue

I want the following to happen
The url something.com/why-us to go to content controller
The url something.com/nepal to go to location controller
How to manage the above in CI routes
Apply the below coding in routes.php in config folder
$route['why-us'] = "content_controller";
$route['nepal'] = "location_controller";
use your desire controller

Disable caching of the config details in Symfony2

We have several sites, each site has its own database and url.
All sites are using an API written by Symfony2. The database configuration in Symfony is in parameter.php file, which set the database parameters according to the current site.
As a result, every request to Symfony can be from different database, which means, the configuration should be loaded every time.
The question is how to disable the caching of the config parameters.
Or, if there is other idea, how to keep caching and to find a way to create caching per site, I would be happy to hear.
Thanks.
I ended up creating a separate cache directory for each site. This way the configuration parameters are saved in the cache per site.
Here is how to override the cache directory:
http://symfony.com/doc/2.1/cookbook/configuration/override_dir_structure.html
I just added the following to the AppKernel.php file:
public function getCacheDir()
{
$request = Request::createFromGlobals();
return $this->rootDir . '/cache/'. $this->environment .'/' . $request->getHost();
}

passing values from ASP.NET to php

I am working on a project which is coded in ASP.NET now I need to add some PHP pages to it. But I have to pass the email address from ASP.NET to PHP page. I know its possible by using URL transfer method but its not secured as users can modify it. I need session transfer method to pass these values. Is there any direct way to do that or indirectly is it possible by using JavaScripts or jQuery or any other method?
Is your information being passed over http or https? It makes a big difference. You can do something such as the following without getting too complicated:
ASP.NET > update the web.config to:
cookieRequireSSL=”true”
In your asp page:
HttpCookie cookie = new HttpCookie(‘name’);
cookie.Secure = True;
cookie.Value = ‘joe#example.com’;
It's also possible to do a separate session id for http (could be md5(securesessid)) and make the association in server level; Just remember not to trust an insecure sess if going back and forth.
In your php page:
<?php
session_start();
$_COOKIE['ASP.NET_SessionId'];
$cookies = getCookies();
$sessionId = $cookies['ASP.NET_SessionId'];
?>
another way is via php/soap:
var_dump($client->_cookies);
echo "cookie is ".$client->_cookies["ASP.NET_SessionId"][0];

Resources