php

Passing a variable by reference into a PHP extension

I'm writing a PHP extension that takes a reference to a value and alters it. Example PHP: $someVal = "input value"; TestPassRef($someVal); // value now changed What's the right approach? ...

Constant Contact - PHP wrapper for REST API?

Anyone written or know of a decent PHP helper class written for Constant Contact's new REST API? I've looked at their sample application... has a bunch of inline examples... helpful, but I'm thinking I want to either find or write a helper class to fully encapsulate the API so that all one has to do is interact with the PHP object. ...

Is it possible to display an RTF file inside a web page using PHP?

I have an RTF file that I want to display inside a web page after tags have been replaced with user input. I would like to be able to display the RTF file without having to convert it to something before displaying it. Every time I try it now it gives me the popup open/save box even though I am telling it to display it inline with:...

How Does a Login system generally work with OOP?

Sorry if this is a badly formed question, but I'm trying to make my web applications (using PHP) more OO. *EDIT* I'm developing the Framework myself */EDIT* Everything is great so far, I've made a Front Controller system that taps into a MVC system. The FC figures out what page you want, loads the specific page Controller (*EDIT* which e...

Lightweight PHP library alternative to common MVC frameworks

Hi hi, I'm looking for a easy to learn php library to use for my coming web app project. I've recently finished a web app with fully handwritten raw php code and it's absolutely hard to be done again for another project. even though I have the recent project code snippets to be used again, but due to their non-structural arrangement (not...

imap_header, recent = N, unseen = ""... but I haven't read it yet!

Using PHP 5.2.0-8+etch13 on a LeaseWeb server, I have code that process a file emailed to a certain address by picking up the email via imap. I call imap_open (checking for errors and not finding any), get the number of messages via imap_num_msg, and look over then calling imap_header on each. All runs without errors. I then check if ('...

Write to Directory using PHP: Is this a permissions problem?

Hi My PHP script writes to a file so that it can create a jpg image. fwrite($handle, $GLOBALS['HTTP_RAW_POST_DATA']); fclose($handle); print $newfile.'.jpg'; I have put this script on a new server however the image never gets saved. The permission of the folder it saves to is 755 but it does not own it. Last time, I think I fixed...

What payment processing frameworks, like ActiveMerchant, are available for other languages?

Rails has frameworks such as ActiveMerchant and Freemium (which uses ActiveMerchant) to simplify dealing with payment processing. What other frameworks are there for other programming languages such as PHP or Python? ...

How do I run a custom function/bit of code when PHP has a parse error

I'm looking to run a bit of custom error handling for PHP's parse errors - the type when the syntax is wrong, and you get those white screens of death. (To be clear, the type that would result when running malformed code as so: <?php if () { ?> ) I had a look at setting a custom error handler, but couldn't get anything to happen. ...

php fopen doesn't open the file, it permission to read is not given to the world/public?

the php fopen fails to open a file for reading, if the file permission is 440. I don't want to give 444 permission to the file, so that it can't be accessed directly through a URL. ...

GET vs. POST Best Practices

For my web application (PHP/MYSQL), I show a list of items and a link on each row to delete the item. Right now, the link is <a href='item.php?id=3&action=delete'>Delete Item</a> If I wanted to use POST instead... how would I do it (this is a dynamically generated list)? Can I send POST data without the use of a form? Or, for every...

Prevent browser from re-sending form information

Does anyone know of a way to prevent the browser from asking the user to resend form information. I know you can redirect the browser with: <php header("location http://example.com"); ?> But this seems so inefficient and takes 2 request. Hope you can help. duplicate of: http://stackoverflow.com/questions/665399/how-do-i-stop-t...

Seemingly Random Script Failure with XML Implications, Why?

I am receiving this XML error: Only one top level element is allowed in an XML document. Error processing resource... Accompanied with this PHP error: Warning: file_get_contents(...) It seems straight forward, except it's not reproducible in any way and it's happens 100% on our clients computers (more than 6). Initially I thoug...

Find Number of Open Sessions

I'm looking for an easy (no database) method of listing how many users are active on a website. The easiest way I can come up with is by counting the number of open sessions. This code should work: $number_of_users = count(scandir(ini_get("session.save_path"))); Of course it won't because of the security constraints on that director...

Passing POST data from one web page to another with PHP

Searching did not find a similar question, so: How can POST data used by PHP to generate one page be passed from that page to another PHP generated page? I have: A form on page 1 which sends data to a PHP script via POST. Page 2 is generated by that script and shows one or more graphs generated by an external program using the entrie...

Limiting user login attempts in PHP

Hi there, I'm seeing web apps implementing limitations for user login attempts. Is it a security necessity and, if so, why? For example: you had three failed login attempts, let's try again in 10 minutes!! thanks :) ...

Redirect within Ajax call

I need to redirect an Ajax call without letting the client know. getPage.php is an application which returns html etc. for a given query. getPage.php?hash=interesting-article-title and getPage.php?page=3 returns the same. To avoid the client from having to cache both of these I would like getPage.php?hash=interesting-article-title to ...

Can I make PHPUnit fail if the code throws a notice?

It doesn't appear to do it by default, and I don't see any switch for it either. This is PHPUnit 2.3.5, and PHP 5.2.0-8. ...

Devising a test for a Web Developer

I need to devise a test for web developers. This test should screen both good grasp of the DOM and manipulating it and Good skills in designing scalable and efficient DB and server side code, And to salt it a bit with web specific problems (like translating from one encoding to another, clean input-security). And best of all, cram it int...

CakePHP Tables without an 'id' field

How does CakePHP deal with tables that don't have an id column? I'm trying to save some relationship data, but Cake wants to "SELECT LAST_INSERT_ID()", however the table that it's trying to save to does not have the id column so the id is for a different table. Specifically, I've got tables for "Games" and "Players", and a relationship...