I am somehow confused to analyse a project. Client says "I need an admin panel using PHP that create subdomain on wizard", i.e like he wants www.domain.com/sub1, www.domain.com/sub2, www.domain.com/sub3 etc. each sub domain may contain different header, menu, content, footer etc. I am really confused in "How do I make PHP admin panel that creates a directory and files for each subdomain?". I hope you got it, otherwise I am ready to discuss it more.
Thanks.
Hope you have something on this:
http://php.net/manual/en/function.mkdir.php
http://php.net/manual/en/function.fwrite.php
Why making a directory for each "domain"? You can use .htaccess and a database.
Related
Is it possible to update the content of a website (add Item, remove Item, update Infos, etc...) directly from the webpage?
For example, you have a webpage and you make a new page in it, that only the admin can access. That page should contain some options that allow the admin to change/update contents on the actual website(what people can see) easily.
(Without the admin having to write new HTML or PHP code...)
I heard something about Joomla or Wordpress but I don't really know how they work.
Thank you.
Basicaly, joomla has some fonctionnalities to edit content by the frontoffice. Of course, the user need to be logged and access levels need to be well managed. You should to try it with a basic installation and see if it's coherent with respect to that you looking for.
I'm new to web development but i know some php basic stuff. Using ftp, i create directories then create simple php scripts there, simple as echoing a string. Which can be accessed like,
www.sampledomain.com/folder1/subfolder2/hello.php
After some time, my friend introduced me to wordpress which is what they described as CMS. I tried to visit her site www.majaflores.com then i click on some stuff there and i noticed the url changed to http://majaflores.com/project/if-i-let-you-in-please-dont-break-anything/
At first, its pretty normal for me because its just a link where there is a folder named "project" and inside it another folder named "if-i-let-you-in-please-dont-break-anything". But when she showed me the ftp folders directory, i didnt see any folder named "project" under main folder of the domain. How did wordpress manage to do this? and how can i implement this manually?
Just wanted to say that like most server-side code environments, PHP also let you parse URLs "manually" and decide what to do accordingly, be it return a file or generate some content.
You can find more information about how PHP is parsing URLs in here:
http://php.net/manual/en/function.parse-url.php
and some discussion regarding it in here:
URL handling – PHP vs Apache Rewrite
This is they way WordPress stores data. U can further see the setting under Permalink.
Under Permalink, u can have options to render ulr as page id, category names and more. You can also use your own format over there.
Just a note, WordPress stored data in database not as a content on FTP directory.
Can I get a list of files on any page?
For example on page
www.90minut.pl/
Every news on page is in folder "news" eg.
www.90minut.pl/news/238/news2387307-Deniz-Yilmaz-nie-zagra-z-Legia.html
I would like to see all files on
www.90minut.pl/news/
Is it possible in PHP?
No.
Unless the site provides you with links, there is no way to tell what resources it is hosting.
of course you can, but, you have to pay attention if the structure from the website/system is using structure like MVC or it's using friendly urls, and the server's permission it's setted as read mode or read/write.
I am asking if is it possible do the following thing using Joomla
I have 2 different URL, something like: www.stupidname.com and www.seriousname.com
If the user open stupidname.com by his browser will open the website having a stupid template
If the user open seriusname.com by his browser will open the website having a serious template
The website and the content are the same...should only change the template according to the url open in the browser
Do you have some ideas about how to do this thing?
Thanks
Andrea
I've done this before making elements of a template conditional based on the domain name, and that can work well. I suppose you could extend the same logic to change the template.
Perhaps you could add a conditional to both template's index.php to change the template. Perhaps something like...
if ( substr_count( $_SERVER['HTTP_HOST'], "silly") ) {
$GLOBALS["mainframe"]->setTemplate = "silly_template_name";
} else {
$GLOBALS["mainframe"]->setTemplate = "serious_template_name";
}
...I've not tested this, but I think in principle it should work fine, though it might depend on which Joomla version you have.
There are, as saji89 pointed out, plenty of good multi-site extensions and that'd be an ok solution too.
From my personal experience with Joomla I can advise you to use the component Virtual Domains (http://extensions.joomla.org/extensions/core-enhancements/multiple-sites/7557) you can add the domains which you redirect to the main site where Joomla is installed and it this component you assign them the template you want.
I can confirm the functionality on Joomla 2.5 latest update with usage of around 5+ different Virtual Domains on one Joomla installation.
Some possible downsides i want to mention:
SEO links can get sometimes messy, you need to play with some SEO component and its settings
its better to use same structure and components for boths side its easier because otherwise the administration gets messy but its possible
the user which register on one website has automatically account on all of them because its one Joomla
I have a revision website, it has stuff for multiple school subjects. I am starting to develop subject pages, these will have stuff only for that subject. e.g. a physics page
Anyway, what I am trying to do is let people type in www.myWebsite.com/history or www.myWebsite.com/ict - or what ever. And them get redirected to the appropriate page.
From that it sounds really simple, I would just put a file called history.php in my public_html home directory, right?
But my home directory is super organised, with everything in nice sub folders. I want to but all the subject pages in a sub folder called 'subjects' (imaginative name :p ).
How can I put these pages in the sub folder, yet still let the user access them from the URL examples above?
A great way to do this is to use a Front Controller. You can re-route all requests to one file (typically index.php) via htaccess and then from there grab the URI (the /itc, /history etc.) and use it to direct the request to the appropriate script.
Check this out, should get you started.
http://www.technotaste.com/blog/simple-php-front-controller/
Once you figure that out, you will want to compare the differences between dynamic and static invocation. Cheers.
you've got to do a url rewrite for the same. google out mod_rewrite and you'll get the examples.
If you are running under Apache, mod_rewrite is probably the most direct approach to accomplishing this.
http://httpd.apache.org/docs/current/mod/mod_rewrite.html
Basically create a .htaccess file in the root that maps the URI segment to the appropriate php file in your 'subjects' directory.
I think this is a case where you could use mod_rewrite, so the web server you're using will redirect the user to the appropiate directory. You can either keep the rewrite list manually or dynamically using regexes.