Use Case:Working on a project where user can create his own site and publish it to internet.(Something similar to this or this). The user can create and later edit his website.When the user wants to publish we create a domain of his choice(a subdomain at first.Can be a different domain later).
Issue:What we want to do is,have the images stored directly on the domain created for the user(The domain initially would be created as a subdomain).For example,our site is at www.xyz.com,then the subdomain can be ABC.xyz.com.This will help to maintain a single copy of images for both the publish and the edit domain.We don't want to store the same image at two different locations.
Research:
Two possibilities that I found could be used:
1) Have a php upload script(upload.php) on each domain created that would be called when user uploads any image.-->Not sure how efficient it would be
2) Use FTP to transfer images from a domain to another.(Some cross domain mechanism)-->Not sure about the security issues here
Do I need to have any kind of cross domain script to be written?Please,help me with how to go about the issue.I don't want the entire code but the logic that would take me in the right direction.Suggestions,if my approach is wrong are welcome.Thank you for your time.
Note: I am still figuring out other alternatives.If I get my code in some shape,will update it.
Related
I have a web app built using Laravel and MySQL. It's currently running on my www.domain.com
I would like to know how to "duplicate" the web app to a subdomain with a separated database?
The web app has login and signup features. There's also email notification sent to clients if they sign up, make changes, etc.
The reason I'm doing this is because I have two types of clients, local and overseas clients. Therefore I have to separate them since they use different currencies and languages. So, when my team login to the subdomain, they'll know they have to speak in our local language, but when they login to the www.domain.com, they'll know they have to speak English.
Thanks very much, will appreciate any help
UPDATE The database has been successfully copied to a new database, however the sign up and login pages of the subdomain are linked to the main domain.
You could look up https://hyn.readme.io which does pretty much exactly what you want. It lets you setup new tenants which are assigned a subdomain and creates a separate database while at the same time sharing your actual application between them all.
If needed you can add tenant-specific overrides of the default apps views and whatnot by adding them to the tenants own folders.
According to your comment earlier, you are getting error in phpMyAdmin when trying to upload database. Why not just copy the database in phpMyAdmin? Go to database you want click on Operations then under Copy Database type name of new database and select copy structure and data. That should solve your issue.
So we have been developing a content management system on laravel and everything is finished. Our plan was to ship it as downloadable solution for customers but now things have changed and we have decided that we will provide it as a SAAS. As it will be used by multiple customers and they will be either using their own domain or our subdomain, I figured out the following solution.
Detect the domain or sub domain and query it against the database
Get the relevant id from a table storing the domains
Set the id in a session or a global variable
Get the settings of the site using that key
For all the subsequent queries to database, add a default where('domain_id',$idOfDomain) so that to avoid mixing up of the data by users of different clients
I don't know if that's the best approach but currently i feel like it's the solution. Now the problem is that I don't know
How to load the domain id and settings from database before code in controller is executed. Just like the configuration file in laravel
I tried to set a default key on models but it was not much successful and I want to know how to set and retrieve domain id in all models as editing all the codes in controller will be too much time consuming
Besides if someone has better and secure solution then the above one then please share it.
Thanks :)
Have a look at the package delatbabel / site-config, it sounds like it does most of what you want. Search on packagist or github. It will pre populate the laravel config data based on database contents, depending on what domain The browser is pointing to.
I need to build a strategy or plan for implementation of a site
the situation is the following:
i have a site for people which belong to a community say xyz.
now i need to provide an account for the individuals of such communities on my site
when they logs into my site, there will be a feature to build a portal for themselves with some functionalities
like wise when n no of people logs in they might create n no of portal for themselves with some functionalities
the people will also create or use a n no of domain name respectively for the portal.
my problem or questions is:
How can i plan to create such a website?
Do i have to create separate code base files for each individual portal? or my current website portal code base can serve for each individual created portals?
How can i setup the site at domain automatically?
Update 1
I think the main website will already have a domain name for it
The other portals created through the main website will also have domain name for themselves as they are for some users
but the question is i have my main website domain name already using the code base which is serving the main website, now can i create domain names through my main website for the users and also ask the newly created domain names to use the same code base of my main website?
Actually i am planning to create domains through my application(please guide how can i create domain from my application) than after creating the domain can i ask the newly created domain to use the code base of my website which created the domain.
than there in the code base i do a domain name check as suggested in few other forums i guess, and load the content for the portal in the newly created domin
is this possible? if yes also can you guide me how can i:
create domains from my application? and than
during domain creation process through my application, how can i configure the new domain being created to my application code base?
is this the right way of implementing it?
1) How can i plan to create such a website?
Think about what exactly it is that the user requires. They have made an account, and want a portal to their own personal domain on the server. A domain on a server is just a file, so when they create that new portal, you might want to simply add a new HTML file under a logical directory, and populate it with some standard HTML.
2)Do I have to create separate code base files for each individual portal? or my current website portal code base can serve for each individual created portals?
I guess you can make the difference specified by a query string in the URL. For example, add database values for each user, and do something like this:
www.mywebsite.com/portal.php?id=40395
Your page will then use that id value, and take values from the database to populate the page with. That way you only have one file, portal.php, but it serves for any number of people.
3)How can i setup the site at domain automatically?
Like I said, the domain is just a file on the server. For example:
www.mywebsite.com/files/directory/hello.php
is just referring to the structure of files on the server. Namely:
www.mywebsite.com
files
directory
hello.php
If you place a file, goodbye.php in the same place, you can access it in a similar way.
www.mywebsite.com/files/directory/goodbye.php
PLEASE NOTE : You have provided no code, so I don't feel obliged to provide any in return. If you haven't took a swing at the problem of implementing the solution, then I guess I won't either.
Use Case: I am working on an application where user can build his own html template and publish it to his domain by selecting one. He can use different components to do this.
Issue: I want to transfer the pages build by the user from my domain to his created domain. Something similar to what is done here. Now currently in the prototye, what I do is write the content to a file (a .html file using ajax request) then make an FTP connection to the users domain (possible beacuse domains are created dynamically by the application) and transfer the files to his domain.
This, I believe, cannot be the right way and I would like to build it around a REST service which would make it flexible and also secure.
Research: I went through the web and found some website handle this very well (like the one mentioned above) and believe they have built it as a service. Am I on the ?
I would like suggestions and the possibilities so I can move forward. I am using PHP on the server side and javascript on the client side.
I can see some possible features to add safety to your services :
Check the source IP from the request, and only allow your servers to make the REST calls.
add header('Access-Control-Allow-Origin: *'); with the list of the possible domains to make the calls, instead of the *.
add security tokens related to the caller machine IP address, that would work as a password for the machine.
send all the data using post instead of get.
To update the page, I would go this way :
keep the data in the database, on server 1
add a page that reads from the database the content of the page based on a domain parameter
on the domain page call server 1 with the domain parameter to get the contents
It has been a while since I've been thinking over this feature that some websites are implementing and it looks to be very successful.
Websites like tumblr.com, blogger.com, wordpress.com allow users to register new sub-domain names from within the website by using a simple HTML/PHP form. With my current knowledge of PHP I couldn't figure out myself how this is done. I've read some posts on this and still can't build a clear idea about this.
So, how do I create a script that allows users to register their own sub-domains on my website (www.username.mydomain.com) and more than that, how do I allow them to use a different website template (as wordpress.com does). Is this possible to be done on a shared server or a dedicated server is needed?
These subdomain issues are brought down to the level of nice URLs, friendly URLs etcetera, as this feature has various names.
Basically what you do is that you set up a redirection so that if someone enters foobar.example.org, the server will serve example.org/user.php?name=foobar or example.org/foobar. After this, it's only a matter of how you put together your PHP script so that user.php or the contents of /foobar is parsed properly. The "registration" part is statically done in the .htaccess file in your DocumentRoot.
Of course this will need some sort of proper error handling for a nonexistant "subdomain".
I can tell you a simple approach.
First you have to enable subdomains in your domain. You can search for 'wildcard-dns and sub domains'. Next all is programming logic.
While registering you can ask for a unique subdomain name. After login, redirect it to the registered subdomain.
It's easy to create the wildcard subdomains. Check my post for create the wildcard subdomains dynamically in Create subdomains on the fly with .htaccess (PHP) .
How to Create Dynamic Subdomain with the help of PHP and Htaccess
We can create dynamic sub domain like top websites who provides us sub domain access with the help of username, I will try to give the best solution for the programmers. I am going to explain how to use htaccess with PHP to create dynamic sub domains, using this you can easily host multiple sub domains on single server.
Process to create dynamic subdomain
Add zone record in domain name setting
Open the setting of your Domain name provider and go to your domain DNS(Domain Name Settings), click add zone record.
Create A record and Point to IP
Now you need to create a custom A record for all your subdomains.
Select A record, HOST * POINTS TO: Your IP Address
Example : 102.30.138.121
Create a record and point to ip prashantabhishek.com
Repeat the same for host #.
Create dynamic subdomain by Prashantabhishek.com
Add CNAME record
HOST www points to # (this refers towards your IP address. )
dynamic sub domain c name record
Save the setting and enjoy the code effect.
Read more at : https://www.prashantabhishek.com/blog/view-post/how-to-create-dynamic-subdomain-with-the-help-of-php-and-htaccess/