php

How can I access request headers that don't appear in $_SERVER?

I am attempting to create a REST API in PHP and I'd like to implement an authentication scheme similar to Amazon's S3 approach. This involves setting a custom 'Authorization' header in the request. I had thought I would be able to access the header with $_SERVER['HTTP_AUTHORIZATION'], but it's nowhere to be found in var_dump($_SERVER). ...

Call to undefined method in facebook call to publishUserAction

I'm getting the following using the PHP client on my server (connecting via FBML). I've included the appropriate php files (facebook etc..) Fatal error: Call to undefined method FacebookRestClient::feed_publishUserAction() in ..../index.php on line 50 I'm trying to use the example given. Any ideas? ...

What is the current state of the PHP community?

PHP 5 came out back in 2004. PHP 5.2 hit the net in late 2006. Since then, there's been nothing but incremental bug releases and beta releases of PHP 5.3. It's been two and half years since then, and even though PHP 5.3 does contain some new interesting features they're not that revolutionary. I've used PHP for seven years now, but late...

Is there an advantage to using parse_str for optional function parameters vs an array?

I happened to be making some changes to a WordPress blog and noticed that they use parse_str (http://php.net/parse_str) for parsing and setting their optional parameters to a function. I'm wondering if there is an advantage to this over sending an array? Examples: With array: $blahOptions = array( 'option_1' => true, ); BlahArra...

How can I call Perl from my PHP page on apache?

Hi, my friend and I are creating a log parser for a series of games. We have written the frontend (web) in PHP/MySQL and the parser in Perl (also using MySQL, of course). Now we are having problems getting these two to communicate. All we wan't to do is this: one administration page online where you have the button "parse". When you cli...

Can I find which user the web server is being run as in PHP?

I'm writing a simple web app in PHP that needs to have write access to a directory on the server, if the directory isn't writable I want to display an error message explaining to set the owner of the directory to whoever the webserver is being run as (eg. www-data, nobody) but as most people don't know this it would be nice to be able to...

Allowed memory size of * bytes exhausted, in php

I'm getting the 'out of memory' error in php. I know it can be fixed with the likes of ini_set("memory_limit","64M"), but I don't want to, because that much memory for a script is abnormal. I have a few reports that are so huge that I pretty much need that memory, but normally don't. The problem is: I don't even know which script is con...

In Kohana, can you trigger a 404 error?

I have a controller called articles, which creates the articles model which gets the relevant data from the database. I want to, if the method I call returns false, to trigger a 404 error. This is what I have so far. $articleName = $this->uri->segment('articles'); $article = new Articles_Model(); $data = $article->getArticleUsing...

Can anybody suggest a true MVC framework for building a PHP application from scratch?

There are several questions on SO about MVC and PHP. I already know the mvc frameworks that are out there like CodeIgniter, Cake PHP, Zend PHP, Agavi, etc., I played with most of them and feel that they are bit of hack but nevertheless good implementations of presentation abstractions. I need some advice from PHP experts and veterans on ...

PHP Script that inserts URL variables into a mysql db?

Hi All I'm looking for a simple and secure script to insert rows into a mysql table from a php script. by calling http://www.myserver.com/addtosometable.php?1=asdf&2=asdf.... I'm not asking how specifically, rather I thought this might be a good platform to build a example script and keep it up to date with best practices... Chee...

Strategies for authenticating users one time without pre-shared identifier.

I am creating a script that takes a list of names and email addresses and sends an email inviting them to register for our department's secure website. The list of names and emails are available on a public facing page on the same site. I need a way to give them a unique token that will identify them when they follow a link in the emai...

how to move already written codeigniter code to kohana?

Hi, All I'm already using codeigniter for some time, and i liked it but it looks like i need to move to kohana, because my other team member need our code to fully use PHP5 feature. the problem is, we have already code half of the code in CodeIgniter. my question is: Did anyone here have done it before? Is it possible to do? how muc...

Regex question to find a trailing space in a whole folder

Hi, I have a folder pulled from a wordpress installation, >1000 files. Some php code is throwing an error due to trailing spaces on the very last line (I cleaned up an iframe injection on some final lines of pages, and did find/replace with a space, but didn't know that that would throw off all my code). What's the most efficient way t...

passing session id via url

I'm trying to get my script to use url session id instead of cookies. The following page is not picking up the variable in the url as the session id. I must be missing something. First page http://www.website.com/start.php ini_set("session.use_cookies",0); ini_set("session.use_trans_sid",1); session_start(); $session_id = session_id();...

PHP AJAX File Uploader

Does anyone know of a good PHP based file uploader using AJAX? The demo below look promising, but it's for ASP.Net http://mattberseth2.com/demo/Default.aspx?Name=ASP.NET+File+Upload+with+Real-Time+Progress+Bar&Filter=All ...

Levenshtein distance: how to better handle words swapping positions?

I've had some success comparing strings using the PHP levenshtein function. However, for two strings which contain substrings that have swapped positions, the algorithm counts those as whole new substrings. For example: levenshtein("The quick brown fox", "brown quick The fox"); // 10 differences are treated as having less in common ...

PHP Framework that integrates with dojo

I am looking for the simplest php framework that comes integrated with dojo. I do not need MVC or to learn a giant framework all over again. Does anyone have suggestions or examples? ...

How can I get a date after 15 days/1 month in PHP?

In my PHP code I have a date in my variable "$postedDate". Now I want to get the date after 7 days, 15 days, one month and 2 months have elapsed. Which date function should I use? Output date format should be in US format. ...

How to replace a variable within a string with PHP?

So I have some PHP code that looks like: $message = 'Here is the result: %s'; I just used %s as an example. It's basically a placeholder for whatever will go there. Then I pass the string to a function and I want that function to replace the %s with the value. What do I need to do to achieve this? Do I need to do some regex, and use ...

PHP get all arguments as array?

Hey, I was working with a PHP function that takes multiple arguments and formats them. Currently, I'm working with something like this: function foo($a1 = null, $a2 = null, $a3 = null, $a4 = null){ if ($a1 !== null) doSomethingWith($a1, 1); if ($a2 !== null) doSomethingWith($a2, 2); if ($a3 !== null) doSomethingWith($a3, 3)...