php

How do I make sure a file path is within a given subdirectory?

I want to make sure a file path set via query string does not go outside of the desired subdirectory. Right now, I am checking that: The path does not start with "/", to prevent the user from giving an absolute path. The path does not contain "..", to prevent the user from giving a path that is outside of the desired subdirectory. The...

using Live HTTP Headers

On a website, I enter some parameters in a form, click on search and then get a page with a message "retrieving your results". After the search is complete, I get another page with my results displayed. I am trying to recreate this programatically and I used Live HTTP Headers to get a peek of what is going on behind i.e the url, form ...

jQuery: print_r() display equivalent?

Hi All, I am getting a bit tired of looking at unformatted json blobs in FireBug. Does anyone know an equivalent to PHP's print_r() for jQuery? Something that would recursively make a display string from an object or array, that I could display on the page for quick debugging? Thanks! ...

PHP refresh

Hi, I want to detect whether the browser is refreshed or not using PHP, and if the browser is refreshed, what particular PHP code should execute. Please help me. Any code snippet is very helpful. Thanks in advance, regards Naveen ...

Understanding input escaping in PHP

Hi, One thing that's always confused me is input escaping and whether or not you're protected from attacks like SQL injection. Say I have a form which sends data using HTTP POST to a PHP file. I type the following in an input field and submit the form: "Hello", said Jimmy O'Toole. If you print/echo the input on the PHP page that rec...

How to deny foreign alphabets in utf-8 in PHP 5.x (symfony)?

I have to disable chinese, japanese, cyrillic (and so on) alphabets to be entered by users in my website, at validation time (only server side validation). At the same time I want all latin accented characters to be allowed. I use symfony 1.1 and PHP 5.2, using utf-8, of course. Any hint? ...

How do I remove a specific node using its attribute value in PHP XML Dom?

My question is best phrase as: http://stackoverflow.com/questions/262351/remove-a-child-with-a-specific-attribute-in-simplexml-for-php except I'm not using simpleXML. I'm new to XML for PHP so I may not be doing the best way I have a xml created using the $dom->save($xml) for each individual user. (not placing all in one xml due to un...

Logical Operators: is AND better than OR?

Sorry if this is a comp-sci 101 question. I'm just unsure if I'm missing something obvious. So let's say some user input throws an error, and I want to catch it and return some feedback. The error will be a number, 0 - 8. 0 means "No Error". I want to give the user very specific feedback if the error is 3 (No numbers allowed, let's say)...

PHP MySql Where Field = <4 Words

I need to use a query which will pull data from a field when it is less then 4 words, is this possible and if so could you give some pointers? I suppose if not possible it could cycle through the results until it found one which was 3 words and then end the while statement when it has found one. ...

MVC with PHP CodeIgniter: user authentication

I am writing a web-app PHP. I want to use MVC pattern for this, and decided to go with CodeIgniter. My application will have some pages which will require authentication, some pages wont. I want to design this in a very generic way, so that there should be no code duplication. Can any one point to some good "design/class structure" fo...

what is the best method to build "multilingual" script in php?

Hello guys, I am building a website and it need to be in 7 languages? I was wondering if there is a good practice can be applied to get multilingual php script? Easy for me Easy for the translators Also what do you think , should I Store it in DB , XML or in PHP file? ...

Organization of many forms on many pages

I have a web app I'm building that has about 50 forms. I have a very nice form-building class that handles the creation and submission of these forms very nicely and it's wrapped with error handlers, etc. No help needed there. However, the forms are scattered through 120 pages. I could really use some weigh in from you guys about the...

What options do I have for reading Excel files and evaluating formulas in C#, Java and PHP?

I've seen various means of reading (and writing) Excel spreadsheets. For example: In .Net as an ADO.Net source (as per Reading Excel files from C#); In Java with either JExcelAPI ("jxl") or Apache POI; In PHP with the Excel Spreadsheet Writer (as per Format text in Excel file via PHP and PHP:Writing to excel file using PEAR). But I'...

Best way to recognize a filetype in php

What's the best way to discover a file's filetype within php? I heard that the browser may be tricked, so what's a better way of doing this? ...

php server-to-server post?

Hello, I'd like to have one server make an http post request to another server. Can I do this with a basic php install (Dreamhost in my case)? If so, please point me in the right direction! thanks, -Morgan ...

Best way to implement shopping cart using PHP/MySQL

I'm working on a customer's website, and they've asked for a shopping cart. They need to use securetrading.net for the payment, so I don't need to ask for any credit card details. All I need to do is keep track of the items in their cart. I've read about using PHP sessions, but I'm concerned about security there. Is this not a problem i...

Handling input with the Zend Framework (Post,get,etc)

Hi, im re-factoring php on zend code and all the code is full of $_GET["this"] and $_POST["that"]. I have always used the more phpish $this->_request->getPost('this') and $this->_request->getQuery('that') (this one being not so much logical with the getquery insteado of getGet). So i was wondering if my method was safer/better/easier t...

Zend_Db_Table Relationships and Zend_Paginator

Hi, is there a way, hot to apply paginator limit on select, which I send to findDependentRowset function? for example: $select = $row->select(); $select->order('item_name'); $row->findDependentRowset($table, null, $select) thank's ...

Have XML results in plaintext, want to loop through them in PHP

So I am working with an API that returns results in XML. Let's just say for argument sake I am returned the following: <?xml version="1.0" encoding="UTF-8"?> <Properties> <Property> <Name>Joes Crab Shack</Name> <Address>111 Shack Street</Address> </Property> <Property> <Name>Johns Shoe Store</Name> ...

PHP sessions with HTML

I have a website which uses PHP and HTML pages, I want to create a session which stores a username from the login page. But the login pages are php and the next pages are html. Is this a problem or can I just add a small statement of php into the html page saying <?PHP session_start(); $_session['loginid']=$_post['username']; ?> Or ...