php

Quick top level server language question.

Right, so if you have to decide on a server-side language for a distributed Linux-based server backend, would you choose: PHP Mono ASP.net Java Python (I've just added this because Google use it) As a C++ programmer, I'm thinking Java+Tomcat, but I'd love to hear experienced thoughts here, especially relating to debugging and IDE (li...

.net equivalent for php preg_replace

What is the c#.net equivalent for php's preg_replace function? php code is like this: const ALLOW_VALUES = '[^a-z0-9àáâäèéêëìíîïòóôöùûŵýÿyÁÂÄÈÉÊËÌÎÏÒÓÔÖÙÛÜŴYÝ]'; public function streetTownHash($data, $hashCheck = false, $updateRecord = false) { foreach($data as $key=>$value){ try{ $value = mb_conve...

function not printing out anything

I have the following function below: public function setupHead($title){ $displayHead .='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; ch...

PHP Soap strange handling of complex type

Hi all, I'm running a php5 based web service which contains the following complex type among others: <xsd:complexType name="FrequencyList"> <xsd:sequence> <xsd:element name="F" type="xsd:float" minOccurs="0" maxOccurs="unbounded" /> </xsd:sequence> </xsd:complexType> Note: F reads Frequencies, I've just chopped it for readability...

What's the simplest way to create a Zend_Form tabular display with each row having a radio button?

I've seen simple examples of rendering a Zend_Form using decorators, but I'm not sure they are able to handle the issue I'm facing very well. I query the database and get an array of user objects. I want to display these users as a form, with a radio button next to each of them and a submit button at the bottom of the page. Here's rou...

Batch folder of images into grayscale using php

Can anyone spot where I'm going wrong here. It should be creating grayscale copies of images in one folder and saving them in another folder. Could it be to do with the way im referencing the file locations. Folder permissions on both folders are 777. Script is running without visible error but no images are being created. function gra...

Application Code Redesign to reduce no. of Database Hits from Performance Perspective

Scenario I want to parse a large CSV file and inserts data into the database, csv file has approximately 100K rows of data. Currently I am using fgetcsv to parse through the file row by row and insert data into Database and so right now I am hitting database for each line of data present in csv file so currently database hit count is ...

How to make extension-less url for a PHP based site?

Do I have to put every file in a different folder? like: about-us/about-us.php profile/profile.php etc. or is there any other automatic solution. I want to convert http://sitename.com/about-us/about-us.php to http://sitename.com/about-us ...

Preventing spam bots on site?

We're having an issue on one of our fairly large websites with spam bots. It appears the bots are creating user accounts and then posting journal entries which lead to various spam links. It appears they are bypassing our captcha somehow -- either it's been cracked or they're using another method to create accounts. We're looking ...

Submitting a multidimensional array via POST with php

I have a php form that has a known number of columns (ex. top diameter, bottom diameter, fabric, colour, quantity), but has an unknown number of rows, as users can add rows as they need. I've discovered how to take each of the fields(columns) and place them into an array of their own. <input name="topdiameter['+current+']" type="text"...

check if a URI exists?

How do I check if a URI exists with PHP? I guess it will return an error code and I can check it before I use file_get_contents, because if I use file_get_contents on a link that doesn't exist, it gives me an error. ...

Keeping Track of Dependent Third-party Library Releases

I am building a web application that is dependent upon several third-party libraries. What is a good strategy for making sure that you're always using the most fully patched versions? A simple method would be to keep the versions written down and visit the websites at regular intervals, but I am looking for some way to get the informat...

how to create a TCP client to send commands to a server using PHP

Hi guys I need to create a TCP client using PHP to send commands to a server with an IP and a port. greetings ...

php - track down premature headers leak

I'm using set_cookie() on a site. After adding some functionality, I'm getting Warning: Cannot modify header information - headers already sent by... error. The line number it references as to where the headers initiated from is the very line where set_cookie() is! And I checked, it's not being called twice. How can I track down these p...

Suggest encoding which removes slashes which I can use as the format for REST-style URL-paramteters

Given a path to a REST style URL: http://site.com/rest/customer/foo/robot/bar/1 When you GET it, it returns a PDF to the foo-customer containing page 1 of the bar-URL. While foo is the name of the customer bar is an URL. The URL usually contains slashes and might look something like this: http://anothersite.com/interestingarticle.ht...

CURL + $GLOBALS["HTTP_RAW_POST_DATA"] in PHP

I'm using CURL to upload files to a service. currently I'm getting the file content with $GLOBALS["HTTP_RAW_POST_DATA"] then save it on my server. after that, I'm using CURLOPT_POSTFIELDS with the file's full path. Is there a way to send the file content directly, without saving it on my server, as if I saved it? Or is there a way to ...

What does the two parameters mean for WScript here?

$WshShell = new COM("WScript.Shell"); $oExec = $WshShell->Run($cmd, 0, false); I don't seem to find the document for this... EDIT Does it need some settings to enable it?I found the above script is not working whether setting the second parameter to true or false ...

WADL from PHP source

I have the PHP source of a RESTful service. Are there any solutions for auto-generating a WADL from this? ...

APC caching and atomic operations

Hi all, I am thinking of integrating some caching logic in my app. Mainly, it will cache objects and objects lists to APC. I will implement a way for them to be automatically invalidated, once the object is updated/removed. However, what about atomicity? How can I make sure that operations are atomic? Thanks ...

MySQL only returning one result. Im Baffled.

Here is te code: <?php //Starting session session_start(); //Includes mass includes containing all the files needed to execute the full script //Also shows homepage elements without customs require_once ('includes/mass.php'); $username = $_SESSION['username']; if (isset($username)) { //Query database for the users networths ...