php

How to delete a file whenever user leaves page?

I have a form with action set to a php-file (verify.php). In the form, I have made a pretty nice picture upload section. After submitting the form, the verify.php is opened to verify the form filled in by the user. The form values are all placed inside another form on the verify.php page. Only the image is uploaded to a folder on the se...

How to determine file age using PHP ?

Any way to determine file age of an image in a folder using PHP? I want to delete older files than 2 hours, is this possible without adding timestamp-names to their filenames on upload to the folder? If so, please give me an example! thanks ...

Calling bash with PHP's shell_exec -- slow.

Hi, I'm using PHP's shell_exec function to call a bash script on my server. shell_exec("bash -x /tesladata/isetools/0-extractbytickerforweb.bash $ticker $isedate > /t24alv2/iseoutput/$ticker-$isedate-$thistime.log &"); Now, I previously had the command running from a CGI script ("bash -x...") and it was much faster (instantaneous). N...

Architecture of very complex php applications ?

I want to know which php architecture strategies developers use in complex php applications . So far , i know the mvc structure which consists of models, views and controller (and controller plugins which handle with common tasks such as user access controller ). I know some good php frameworks which makes some common stuffs easier .But...

PHP - UTF8 problem with German characters.

Hello, I'm at my wits end with this one, then I remember stack overflow. I have a site, http://bridgeserver3.co.uk/disklavier/de/ , the language is stored in a simple PHP file which looks like.. $translations["welcome_text_3"]="Zum Lieferumfang eines jeden Disklaviers gehšren bereits zahlreiche Lieder und das Angebot lŠsst sich jederz...

Is there a PHP library to create ASP.Net datasets for use with ASP.Net webservices?

I need to consume a ASP.Net webserice from PHP. So far reading data hasn't been to difficult. I have been able to pars the XML and find the information that I need. The problem I am running into is sending data back to the webservice. It is looking for the XML representation of a dataset. Is there anything out there that can generate the...

PHP - How to set full directory path in Content-Disposition?

I am passing a filename to a download page. ie somefile.xls The download page adds back in the full directory path onto the filename. ie c:\temp\somefile.xls The problem is that now setting the 'Content-Disposition' of the header doesn't work. The filename it wants to download is the full directory-filename path. ie c_tem...

PHP specific - clean code, naming conventions and documentation

What are some of the best practices for clean code, naming conventions and documentation for PHP? I see users/people saying this is a bad practice, Example: // Create an array to hold x values $arr_x = array(); That this is a unnecessary comment cause the syntax alone explains the functionality. That is should be more of a header com...

Best practice for HTML escaping user-supplied data with PHP (and ZF)

Note: I'm using Zend Framework, but I think most of this applies to PHP coding in general. I'm trying to choose a strategy for writing views scripts, possibly with the help of a templating engine. Motivations: clarity and security. I'm just not happy with writing .phtml scripts. This syntax is awfully verbose to do the most often needed...

Specifying CSS class of a Zend_Navigation li element

Hi, I can't seem to find where to specify the CSS class of the list items for rendering a Zend_Navigation object. I know you can set the class of the ul tag via the navigation menu view helper and the class of the anchor via a page attribute...but not the li tag containing the anchor. Can anyone point me in the right direction? ...

Cleaner way to translate index into specified string?

Could I achieve this in a more cleaner way? Would be really appricated. switch($vocation) { case 1: $vocation = "Sorcerer"; break; case 2: $vocation = "Druid"; break; case 3: $vocation = "Paladin"; break; case 4: $vocation = "Knight"; break; case 5: $vocation = "Master Sorcere...

Check a phrase is not in an <a> (or other) element

A friend is writing an advertisement script that puts links around select phrases in HTML code. Naturally if the phrase is already inside an <a> element (or another element that doesn't allow it - like if the phrase is found in the attribute of an element), he doesn't want the script to write out a link as it would break validation. H...

php find some text in a string (if it's there)

Hi All, I have a MYSQL database of photo galleries; each row contains a field with the list of images included in that gallery, eg: 1,5,134,13,5 these are the IDs of the photos. The same image_id could be included in other galleries. When I delete a photo, I need to remove the corresponding id from the galleries that contain it. Wha...

Current common practices in web application architecture

Here's a very broad question: I've been building a small MVC framework in PHP, mostly for the sake of learning better practices in my coding (and so I have a system to manage my home finances). In reading up, I've discovered a lot on VOs and DAOs, which were new to me, at least in a formalized way. This made me realize that even thoug...

What's the best way to include custom HTML in a Symfony form?

I'm working with a Symfony generated admin and need to include some custom HTML into a form. This HTML (a label, img tag, and link) should only appear when the action is 'edit'. What's the best way to do this? It seems like I should just be able to include a partial, but I don't know where to include it from. Thanks. ...

How do I get SSL working in fsockopen?

I'm running PHP 5.2.6 on Windows, I have extension=php_curl.dll and extension=php_openssl.dll uncommented in php.ini; as such I can see the following in phpinfo: curl cURL support enabled cURL Information libcurl/7.16.0 OpenSSL/0.9.8g zlib/1.2.3 openssl OpenSSL support enabled OpenSSL Version OpenSSL 0.9.8g 19 Oct 200...

What's the Difference Between Extension and zend_extension in php.ini?

When I installed Xdebug through pecl, it added the following line to my php.ini file. extension="xdebug.so" and everything I used worked. Until today. Today I was having trouble setting up Xdebug for interactive debugging. I couldn't get anythign working until I changed the above to zend_extension="/usr/local/lib/php/extensions/xd...

Php: How can I prevent attacks from url links written by users?

When a user enters a web url in a comment, that url becomes a link. How do I prevent attacks from those links? any measures I can take? thanx ...

Regular Expressions and php

I have a form where users enter a URL. I need a regular expression to skip the part 'http://' if present. For example, if the user insert into the form: http://youtube.com I need to save only youtube.com. I don't know regular expressions. Could you help me? Thanks! ...

Regex Proxy Server

I control access via a proxy server and run some regex on every request. For prototype I have used curl, regex and php. Obviously this won't put up with any serious load. Can anyone suggest and proxy servers that would be suitable? ...