php

Escaping file name when uploading with Zend_File_Transfer_Adapter_Http

Hi, Is there the functionality to escape the filename before uploading with Zend_File_Transfer_Adapter_Http. For example file names such as 'tes file$"f.gif' will cause problems. Thanks ...

received HTTP headers incorrect/unexpected for XSL file type

I'm using PHP+curl to retrieve an XSL file, but first I want to do some minimum validation that the file is really a XSL file. I make sure the file exists, has status code 200 OK, and that it has the correct file extension, but then I want to check the header for the Content-Type. I do this using curl_getinfo() function. All fine. But...

How to prevent code injection attacks in PHP?

I am abot confusing, there are so many functions in PHP, and some using this, some using that. Some people use: htmlspecialchars(), htmlentities(), strip_tags() etc Which is the correct one and what do you guys usually use? Is this correct (advise me a better one, if any): $var = mysql_real_escape_string(htmlentities($_POST['username'...

Iterating through a PHP array in jQuery?

How do I iterate through a PHP array in jQuery? I have an array in php named $viewfields. How do I iterate through each element of this array using jQuery? EDIT 1 <?php foreach ($viewfields as $view): ?> if(<?=$view['Attribute']['type'];?>=='text'||<?=$view['Attribute']['type'];?>=='number') { $("<input id=input<?=$v...

Generate string with apostrophe after each letter of original string in turn.

How can I iteratively create a variant of "Murrays" that has an apostrophe after each letter? The end-result should be: "m'rrays,mu'rrays,mur'rays,murr'ays,murra'ys,murray's" ...

What does PHP keyword 'var' do?

This is probably a very trivial question, but I haven't been able to find the answer neither through web search engines, nor on php.net. Please just direct me to where I can read about this, if you haven't got time to explain. What does the 'var' keyword mean in PHP? Are there any differences between PHP4 and PHP5? ...

PHP/MySQL: Best way to fetch new entries?

We've got some kind of groups at our site where group members could put messages. I want to notice the members of each group when there's new entries. What's the best way to do this? ...

Creating messages (ie drafts) in Gmail with IMAP/SMTP?

I've done quite a bit of inbox manipulation with Gmail via IMAP functions in PHP, but one thing I haven't found is a way to create messages. I'm not sure if IMAP or SMTP is required, but I would like to use PHP to create a new message (specifically a draft) that is stored in my inbox with everything ready to hit send at a later date. How...

How do you use memcache with PHP

I finally got memcache running on my home pc so I can start developing with it at last! I am not off to a good start though I am trying to use the code on php.net @ memcache-set I am unable to get either example code to work that they post I tried this: <?php /* procedural API */ $memcache_obj = memcache_connect('memcache_host', 112...

exec() not working as expected in PHP

Hi, I'm new to this forum. I have a PHP script in which I need to execute a shell script 'add_article.sh' which reads a parameter file and adds the news article contents to a search index (Lemur/Indri). Executing the 'add_article.sh' script on its own (from the shell) works perfectly, but running it from within the php script I get thi...

Stacking Algorithm - Stack 3d objects in smallest area possible

I'm trying to solve the problem of stacking objects into the most convenient size for postage. The size and shape of objects will be varied. Length, width and height of all objects is known. For example a customer may order a (length x width x height) 200x100x10cm object (wide, long and flat) along with 2 50x50x50cm objects (cubes). If ...

how to store images in the file system dynamically??

we are creating a website for hotel booking. we need to store a large number of images. we think it would be a better option to store images in the filesystem and store the path in the database. But do we have to manually save them? We are using web services from another website to get the images. is there a way to save the images dynami...

Problem With PHP/HTML Dropdown Box Code (selected value)

Hey everyone, I wrote some PHP code that will allow me to create an html dropdown box, and then choose what should be the selected value. The code is: $role_drop = "<select name='role'>"; $role_drop .= "\r\n<option value='Resident Assistant'>Resident Assistant</option>"; $role_drop .= "\r\n<option value='Community Assistant'>Commu...

output xml fragment without headers

I have a feeling I'm being thick, but here's my problem: I'm creating dynamic XML trees using PHP. These trees describe employee hierarchies, file directories, etc. They comprise small sections of content on a webpage. The rest of the webpage is glued together from various other sources that may be SQL based, or static text or some s...

PHP GD: How to get imagedata as binary string?

I'm using a solution for assembling image files to a zip and streaming it to browser/Flex application. (ZipStream by Paul Duncan, http://pablotron.org/software/zipstream-php/). Just loading the image files and compressing them works fine. Here's the core for compressing a file: // Reading the file and converting to string data $stringd...

PHP Most Efficient Way Of Communicating Between Servers

Soon I'm going to have 3 identical scripts on 3 different VPS's and I want to have a fourth VPS which will control them all.. So for the sake of this question what I need to do is insert SQL rows and create files on the sub-servers, and the sub-servers also need to send statistical data back to the mother server. What is the most effici...

hash_hmac() functionality

I'm tying out a new moodle module, which provides integration with Windows Live. When using the live authentication I get a blank page. Switch on PHP error logging and get: Fatal error: Call to undefined function hash_hmac() in /srv/www/htdocs/moodle/auth/liveid/windowslivelogin.php on line 1293 Line 1293 is: return hash_hmac("sha25...

How do I create a separate directory for each video in a database and pull its ID from the URL?

For example - on vimeo.com, each video has an id number. To view that video, you simply navigate to vimeo.com/2847535 or whatever. Let's say I have a similar site where every time a user adds a video, it is assigned a unique id. How do I create a directory with that ID number after I add the video to the database? Also, once the video...

Which Operating System is the best for PHP development or Development in General?

Which Operating System is the best for PHP development or Development in General? 1) Linux Mint? 2) Ubuntu? 3) Windows 7? 4) OS? ...

How to output the reason for a PHP file open failure

I'm trying to debug a huge, antiquated (circa 2001) PHP web service and I'm encountering file open failures. The fopen call is in an included module, the caller is logging that the file could not be opened but no reason is being logged. The code that actually does the open is: // Read the file if (!($fp = @fopen($fileName, 'rb')))...