Wrox Programmer Forums
|
BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9
This is the forum to discuss the Wrox book PHP and MySQL: Create-Modify-Reuse by Timothy Boronczyk, Martin E. Psinas; ISBN: 9780470192429
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 12th, 2010, 03:57 PM
Authorized User
 
Join Date: Jul 2009
Posts: 77
Thanks: 4
Thanked 6 Times in 6 Posts
Default Chap 12 - Security, Path Traversal

On page 320, at the top of the page there is a
gray box section containing code,

The variable $target is not defined (line 10);
I think this should be $template.
I think the idea is that you want
TEMPLATE_DIR to be completely contained within $template;
and start at the 0th position of $template.

The strpos test is a good test for this, but I would
change the conditional test into two test. One test to see if
TEMPLATE_DIR is contained within $template
PHP Code:
strpos($templateTEMPLATE_DIR ) !== false 
and another test to test that TEMPLATE_DIR starts
at template's string position 0.
PHP Code:
strpos($templateTEMPLATE_DIR ) == 
The whole conditional would now look like this.
PHP Code:
if (isset($template) &&
   
strpos($templateTEMPLATE_DIR ) !== false &&
   
strpos($templateTEMPLATE_DIR ) == &&
   
file_exists($template))
   { 
I think I understand what they were trying to do
with
PHP Code:
strpos($templateTEMPLATE_DIR ) !== 
but when I tried it, it did not work for me. It did not return
0, it returned false. The online documentation for Php,
strpos, has a warning saying basically that it can return
false, 0, or ""; so this can be tricky. I choose
what was working for me on my system. Your system may be
different. I think the best thing to do is experiment and
see how it works for you.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Graph Traversal (Keep track of visited path) Mr.Fine XSLT 0 August 12th, 2009 06:03 AM
chap 12 exer 2 harper BOOK: Beginning JavaScript 3rd Ed. ISBN: 978-0-470-05151-1 0 January 31st, 2008 10:19 AM
Chap 12 connection to a dbase jardbf BOOK: Beginning ASP 3.0 1 May 25th, 2006 11:01 AM
chap. 12 -cmstables.php niy BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 3 January 12th, 2005 02:36 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.