Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
10-25-2016, 03:55 AM | #1 |
Confirmed User
Join Date: Apr 2010
Posts: 272
|
Learning PHP
I am trying to learn php/mysql and have completed a couple of courses so far on udemy. Still a lot to learn, but my goal is to code my own cms system that I could use on a network of high traffic sites. But while working through online course some questions don't seem to be answered or discussed much yet.
1. How to make script secure? A lot of courses so far are fairly brief on this, are there any good sources for information or books to study? 2. Caching? What caching should I be learning about to help run high traffic sites. I have experience with sites running memcache/smarty template cache. |
10-25-2016, 04:33 AM | #2 |
So fuckin' bored
Industry Role:
Join Date: Jun 2003
Posts: 32,378
|
1. No answer here. It's like if you ask "how to make my home secure?" There could be a ton of recommendations, but no universal solution.
2. When PHP engine generates a page, it usually does a lot of things. Performs SQL queries, access various files and simple executes the code. Caching is a method do avoid it. Once the page was generated, it's saved as a simple HTML file. So next time when someone will try to open it, he will see the previously generated static version - the PHP code will not be executed, SQL queries will not be performed etc.
__________________
Obey the Cowgod |
10-25-2016, 04:43 AM | #3 | |
Industry Role:
Join Date: Aug 2006
Location: Little Vienna
Posts: 32,234
|
Quote:
Basically you need to check your script against any kind of injections, regardless is it mysql or any other kind. But sometime even trivial solutions can block most of injections, for example command htmlentities which turns characters which are required to execute injection into html code. 2. I am using memcached and it do the fine job, page loads fast once is runned for first time, and it stil loads fast even if you make a change on page. There are additional caching engines, like Opcache and Ioncube which you can use as well with it, but also pay attention to your queries - a lot of optimization can be done by simply using either better queries or better data structure. For example, you can organize data by dividing tables to frequently used data and settings data. |
|
10-25-2016, 05:11 AM | #4 |
It's 42
Industry Role:
Join Date: Jun 2010
Location: Global
Posts: 18,083
|
1. Limit user input to scripts to the expected input.
2. Set the correct (lowest permissions necessary) for all files and directories. By only allowing only the expected, the dangerous unexpected user input will be rejected. Google is your friend: https://www.google.com/search?q=secure+PHP Lots of opinions and ideas here ^ |
10-25-2016, 08:30 AM | #5 |
Too lazy to set a custom title
Industry Role:
Join Date: Sep 2005
Location: Springfield
Posts: 13,826
|
best advice I can give you is to use a php framework... If you're a beginner to PHP a CodeIgniter is a good start. Using a framework you'll have to worry less about security and these regular PHP stuff and you'll focus more on what are you trying to build.
__________________
Make a bank with Chaturbate - the best selling webcam program Ads that can't be block with AdBlockers !!! /// Best paying popup program (Bitcoin payouts) !!! PHP, MySql, Smarty, CodeIgniter, Laravel, WordPress, NATS... fixing stuff, server migrations & optimizations... My ICQ: 27429884 | Email: |
10-25-2016, 10:29 AM | #6 |
Confirmed User
Industry Role:
Join Date: Oct 2015
Posts: 560
|
A lot of this is running validation routines on data that can be passed into the script, e.g. from form fields or querystrings, so that rogue instructions can't be included with that data.
|
10-25-2016, 12:37 PM | #7 |
Bollocks
Industry Role:
Join Date: Jun 2007
Location: Bollocks
Posts: 2,792
|
One basic way to do caching is use the output buffering.
Put ob_start(); at the start of your script, before you write any HTML. At the end, after you've written all the HTML, put ob_end_flush(); That sends the contents of the buffer to the client with headers. To cache the page instead of sending it, you can make use of ob_get_contents(); and save the result as a file. Then the next time that page is requested, serve that file instead of rebuilding the page. After the file is a certain age, delete it and rebuild the page. That's a basic way of doing caching. The problems arise when you want to dynamically add a value in the HTML which is different for each visitor, say if you're dynamically writing JS. Then it gets a bit more tricky....
__________________
Interserver unmanaged AMD Ryzen servers from $73.00 |
10-25-2016, 10:10 PM | #8 |
Confirmed User
Industry Role:
Join Date: Sep 2015
Posts: 1,045
|
never truss user input.
htmlspecialchar is good php function. Looks at parameterized sql statements to avoids sqlinjection. Much old information for sql still on web shows old ways of things. that is dangerous.
__________________
|
10-26-2016, 04:00 AM | #9 |
Confirmed User
Industry Role:
Join Date: Aug 2016
Posts: 353
|
When it comes to secure, it is all individual, there are a lot of solutions you can find.
__________________
Skype: daniel.bongacash | E-Mail: [email protected] | ICQ: 706111038 Kind Regards, Daniel Affiliate Manager |
10-29-2016, 11:37 AM | #10 |
Too lazy to set a custom title
Industry Role:
Join Date: Aug 2002
Posts: 54,932
|
|
10-29-2016, 11:42 AM | #11 |
♦ Web Developer ♦
Industry Role:
Join Date: May 2005
Location: Full-Stack Developer
Posts: 12,467
|
If I'd pick a framework, I'd go with Laravel
|
10-30-2016, 04:43 AM | #12 |
Confirmed User
Industry Role:
Join Date: Sep 2015
Posts: 1,045
|
also, when i say don't trust user input. do input validation on the back-end. Even Post data can be manipulated using a proxy tool like Burp suite.
You can validate using javascript on the front end, just to save user time. But make sure security validation is done on the back-end.
__________________
|
10-30-2016, 05:01 AM | #13 |
Judge Jury and Executioner
Industry Role:
Join Date: Jan 2005
Location: South-America
Posts: 8,939
|
Heard more people using that, must try myself.
__________________
everything is fake |
10-30-2016, 05:25 AM | #14 |
Confirmed User
Join Date: Apr 2010
Posts: 272
|
Thanks for all advice. I'm getting a better understanding of what is required. So far have coded blog type script, with uploads, admin area, tags, search and a basic shopping cart while following video tutorials.
In general terms I guess the stages could be broken down as such: -code secure script -optimize db queries -implement memcache Is memcache the only caching solution I need to use? With current scripts I see they use memcache and template cache, but I guess the template cache is because it uses smarty? |