| | |
How to store files for a Content Management System (CMS)
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Feb 2008
Posts: 83
Reputation:
Solved Threads: 4
I'm building a Content Management System on my own in PHP & MySql. I thought it's a good idea that all CMS files to be stored secure on the server "before" www folder so that it can't be accesed from the browser (all cms files in one folder). In www folder it's only the TEMPLATE cause I want to separate template from CMS, separate folders. I can include *.php files from folder above but I can't include the JavaScript files and other files that are linked from forms. For example at login: my login form actions on "login.php" which is in folder above root so it can't be accessed.
My question are:
- it is a good idea to store all CMS files in folder above 'www' folder? If so, how can I include the files correctly? If not, what's the best option to place my CMS folder? (remember I must separate the template from CMS. The template only calls 3,4 functions from CMS to show menu, content, etc. so that I can change the template without changing the content)
Thanks. Hope somebody helps
My question are:
- it is a good idea to store all CMS files in folder above 'www' folder? If so, how can I include the files correctly? If not, what's the best option to place my CMS folder? (remember I must separate the template from CMS. The template only calls 3,4 functions from CMS to show menu, content, etc. so that I can change the template without changing the content)
Thanks. Hope somebody helps
•
•
Join Date: May 2008
Posts: 231
Reputation:
Solved Threads: 19
0
#2 26 Days Ago
Storing files as, well, files is never a good idea, if stored as PHP files and then include/require(ed) the scripts could contain malicious code. There are two options;
1,
Save the file as .htm, .html, .txt (or some other plain text format)
Include the file with
This will get the contents of the text file and echo it to the browser without executing any code inside.
2,
BLOB!
There is a field type in MySQL called BLOB (Binary Large Object) which I use for storing my files, it can hold a large amount of data, all you have to do is output it as you would with any other MySQL field
1,
Save the file as .htm, .html, .txt (or some other plain text format)
Include the file with
php Syntax (Toggle Plain Text)
<?php echo file_get_contents($FileToGet); ?>
2,
BLOB!
There is a field type in MySQL called BLOB (Binary Large Object) which I use for storing my files, it can hold a large amount of data, all you have to do is output it as you would with any other MySQL field
My Blog, Life and everything that matters to me - SamRudge.co.uk
2x Macbook Pro's, 1x Mac Pro, 1x iMac, 2x Macbook's running Fedora linux - In conclusion, I hate windows =)
2x Macbook Pro's, 1x Mac Pro, 1x iMac, 2x Macbook's running Fedora linux - In conclusion, I hate windows =)
•
•
Join Date: May 2008
Posts: 231
Reputation:
Solved Threads: 19
0
#3 26 Days Ago
Storing files as, well, files is never a good idea, if stored as PHP files and then include/require(ed) the scripts could contain malicious code. There are two options;
1,
Save the file as .htm, .html, .txt (or some other plain text format)
Include the file with
This will get the contents of the text file and echo it to the browser without executing any code inside.
2,
BLOB!
There is a field type in MySQL called BLOB (Binary Large Object) which I use for storing my files, it can hold a large amount of data, all you have to do is output it as you would with any other MySQL field
1,
Save the file as .htm, .html, .txt (or some other plain text format)
Include the file with
php Syntax (Toggle Plain Text)
<?php echo file_get_contents($FileToGet); ?>
2,
BLOB!
There is a field type in MySQL called BLOB (Binary Large Object) which I use for storing my files, it can hold a large amount of data, all you have to do is output it as you would with any other MySQL field
My Blog, Life and everything that matters to me - SamRudge.co.uk
2x Macbook Pro's, 1x Mac Pro, 1x iMac, 2x Macbook's running Fedora linux - In conclusion, I hate windows =)
2x Macbook Pro's, 1x Mac Pro, 1x iMac, 2x Macbook's running Fedora linux - In conclusion, I hate windows =)
•
•
Join Date: Feb 2008
Posts: 83
Reputation:
Solved Threads: 4
0
#6 26 Days Ago
Unfortunately I don't use any MVC yet cause I don't know
. But I have 2 questions for *samarudge*:
1. I would have this link echo(ed) in the template header:
2. I have a form:
The file "login.php" is in the folder above too (if I use your first option). What can I do in this situation? cause the browser can't find it in the root folder of the website.
Hope I did not missunderstood something from you
. Now I must leave and get back in an 1-2 hours or so. Thanks for your interest in my problem!
. But I have 2 questions for *samarudge*:1. I would have this link echo(ed) in the template header:
PHP Syntax (Toggle Plain Text)
<script type="text/javascript" src="indexScript.js"></script> //but I don't want to echo in the source my script which is in the folder above. How can I do it?
PHP Syntax (Toggle Plain Text)
<form name="login_form" action="login.php" method="POST"> <td colspan="8" valign="middle" align="center" style="height:30px; width:500px;"> <span style="font-weight:bold; font:16px">Password:</span> <input type="password" name="upass" /> <input type="submit" value="Login" style="width:60px; height:25px;" /></td> </form>
Hope I did not missunderstood something from you
. Now I must leave and get back in an 1-2 hours or so. Thanks for your interest in my problem! •
•
Join Date: Feb 2008
Posts: 83
Reputation:
Solved Threads: 4
0
#7 26 Days Ago
Unfortunately I don't use any MVC yet cause I don't know
. But I have 2 questions for *samarudge*:
1. I would have this link echo(ed) in the template header:
2. I have a form:
The file "login.php" is in the folder above too (if I use your first option). What can I do in this situation? cause the browser can't find it in the root folder of the website.
Hope I did not missunderstood something from you
. Now I must leave and get back in an 1-2 hours or so. Thanks for your interest in my problem!
. But I have 2 questions for *samarudge*:1. I would have this link echo(ed) in the template header:
PHP Syntax (Toggle Plain Text)
<script type="text/javascript" src="indexScript.js"></script> //but I don't want to echo in the source my script which is in the folder above. How can I do it?
PHP Syntax (Toggle Plain Text)
<form name="login_form" action="login.php" method="POST"> <td colspan="8" valign="middle" align="center" style="height:30px; width:500px;"> <span style="font-weight:bold; font:16px">Password:</span> <input type="password" name="upass" /> <input type="submit" value="Login" style="width:60px; height:25px;" /></td> </form>
Hope I did not missunderstood something from you
. Now I must leave and get back in an 1-2 hours or so. Thanks for your interest in my problem! •
•
Join Date: May 2008
Posts: 231
Reputation:
Solved Threads: 19
0
#8 20 Days Ago
Not 100% sure what you mean but if you are in the file
/var/www/html/page/index.php (Local/On server)
and you are trying to access a file
/var/www/html/include/page.php (Local)
you can use the "Double Dot" syntax in PHP
would include the file
Is this what you meant?
/var/www/html/page/index.php (Local/On server)
and you are trying to access a file
/var/www/html/include/page.php (Local)
you can use the "Double Dot" syntax in PHP
php Syntax (Toggle Plain Text)
include('../include/page.php');
Is this what you meant?
My Blog, Life and everything that matters to me - SamRudge.co.uk
2x Macbook Pro's, 1x Mac Pro, 1x iMac, 2x Macbook's running Fedora linux - In conclusion, I hate windows =)
2x Macbook Pro's, 1x Mac Pro, 1x iMac, 2x Macbook's running Fedora linux - In conclusion, I hate windows =)
•
•
Join Date: Feb 2008
Posts: 83
Reputation:
Solved Threads: 4
0
#9 20 Days Ago
No, I mean if I have files like *.js and css in a folder like "/var/CMS/script.js" and the www is in the same folder as CMS, how can I make a link from html (which is in 'www' folder) to 'script.js' which is in 'CMS' folder? I gues I cannot...
So, link '/var/CMS/script.js' file in '/var/www/index.html'. What I was trying to do is to make the CMS folder unaccesible from the browser. (secure folder). Thanks for reply.
So, link '/var/CMS/script.js' file in '/var/www/index.html'. What I was trying to do is to make the CMS folder unaccesible from the browser. (secure folder). Thanks for reply.
![]() |
Similar Threads
- CMS (Site Layout and Usability)
- Best Free Content Management System (IT Professionals' Lounge)
- PHP Content Management System from scratch (PHP)
- Which content management system (CMS) should I choose? (Existing Scripts)
- Content management system (Site Layout and Usability)
- Bluo Content Management System (Websites for Sale)
- Content Management System (PHP)
Other Threads in the PHP Forum
- Previous Thread: mysql_num_rows(): error needs to work in 24 hrs mac :S thanks in advance
- Next Thread: How To Print Directly to Printer
| Thread Tools | Search this Thread |
adobe air ajax ajaxhelp api array autosuggest basic beginner beneath checkbox class cms code command console curl database display dojofoundation duplicates dynamic email execution files flash folder form forms forum gaming gentoo head hosting href html httppost ibm if...loop iframe image include insert javascript jobs jquery link links linux login mail memmory menu mimic multiple mysql object oop open password paypal persist php post products projectmanager prompt protocol query recursiveloop registry root script search security select server servers sms snippet sorting spam sql system tag tutorial tweaks up-to-date upload user video virus website window windows wpf xslt yahoo youtube zend






