php

How can I detect and survive being "Slashdotted"?

What's a good way to survive abnormally high traffic spikes? My thought is that at some trigger, my website should temporarily switch into a "low bandwidth" mode: switch to basic HTML pages, minimal graphics, disable widgets that might put unnecessary load on the database, and so-on. My thoughts are: Monitor CPU usage Monitor bandwid...

FogBugz, WebSVN & Cygwin - Diffs Not Being Generated

Hey Guys, I can appreciate what I'm about to ask is a bit specific and a small niche but if you could provide some help you might actually let me keep some of my hair! I originally posted the query over on the FogBugz technical support page, but haven't had much joy. Basically I am using webSVN as a repository browser to provider log ...

Locking NFS files in PHP

Part of my latest webapp needs to write to file a fair amount as part of its logging. One problem I've noticed is that if there are a few concurrent users, the writes can overwrite each other (instead of appending to file). I assume this is because of the destination file can be open in a number of places at the same time. flock(...) is...

How do I display mysql data in row span using PHP?

I have data from MySQL showing all organisations a customer got, with all details of employess in each organisation. I want to list each organisation name only once i.e. in a single cell ( row span) and all employees in that organisation against this name like: Org1 Emp1 Name, Emp1 Phone, Emp1 Address Emp2 Name, Emp2 Phone,...

new DOMDocument() in php 4

Hello, I've make an application in php that uses DOMDocument() in php 5. The problem is that my server uses php4 and DOM object is not recognized. What can I do? Can I download any kind of software and put it in my server and use include? wich one? Thanks a lot. ...

php/mysql login works on one server (php 5.0.2) but does not work on the other (php 5.1.6)

Here is a stripped down version of what I use to authenticate users, it works fine on my php v5.0.2/mysql 4.0.21 server, but fails on my php v5.1.6/mysql v5.0.45 server. In the code below, should I be aware of anything that might not be supported by the newer version of php & mysql? Global variables have been enabled. <?php if(!isset...

How to resize all images in a block of HTML to a specific width and cache the results

I'm writing a mobile content adaptation plugin for a bespoke CMS in PHP. The CMS contains links to images with absolute URLs which are all 400 pixels wide and vary in height. I'd like to parse the HTML (which is stored in MySQL) and re-scale each image to a new width - this will vary according to the device. I'd also like to cache the i...

Generating unique codes in PHP/MySQL?

I'm working with a client that needs to generate millions of the alphanumeric codes used in magazine scratch-off cards, bottlecap prizes, and so on. They have to be short enough to print on a cap, they want to make sure that ambiguous characters like 1 and I, 0 and O, etc. are not included, and they have to be explicitly stored for futur...

Using PHP to Access a User's Webcam

I'd like to allow users to record videos directly from their webcam. I haven't done much work with PHP but am stuck with it for this project. We currently have a system in place for video uploading and encoding, but nothing to actually access a user's webcam. How would you recommend I proceed? ...

WordPress: I got rid of the second "home" page, but it's not good enough

I have a WordPress site (2.6.2) in which I have set the Home page to a static page instead of the normal posts page. The ID of this page is 2, so in the WordPress template I have changed the wp_list_pages to look like this: <?php wp_list_pages('exclude=2&title_li=&depth=1' ); ?> this works fine, but now the Home page doesn't get "lit ...

PHP - Sessions - Security

How secure are php Sessions? I am planning to use the native PHP sessions to authenticate users. Can users modify session data like they can $_POST and $_GET data? ...

How can I encrypt password data in a database using PHP?

I am connecting to a MySQL database with PHP and the CodeIgniter Framework. I want to store my passwords encrypted in the database and would like to know the best way to do this. ...

Parsing A Data Feed

I'm not the best at PHP and would be extremely grateful if somebody could help. Basically I need to parse each line of a datafeed and just get each bit of information between each "|" - then I can add it to a database. I think I can handle getting the information from between the "|"'s by using explode but I need a bit of help with parsi...

What is the best library to create an AJAX auto-suggest textbox in a web form?

I'm creating a web application for work where the user has to enter the name of the person that requested the job. I'd like to create a simple AJAX auto-suggest dropdown so they don't need to type the entire name. On the backend, the database will provide suggestions based on previous entries. The website is built using CakePHP 1.1. ...

What is the easiest to use ORM framework for PHP?

I'm looking for Ruby's Active record for PHP. Something that is so simple that I just define my fields, extend the base ORM class, and I get ACID operations for free. I should get default getters and setters without writing any code, but overriding a default getter or setter is as easy as declaring get$fieldName or set$fieldName function...

Best Way to Organize PHP Class Heirarchy

I've got a somewhat primitive framework I've been using for most of my projects, but a general design issue came to mind that I haven't been able to work out yet. For a given application, should I separate the application-specific class structure from the framework's structure, or is buliding on top of the framework not such a bad thing?...

Access control for multiple users in a web application

I'am working on a PHP + MySQL Social Networking application, now i need to setup different access control (read,create,edit,delete) for global (all items) and/or self items (item which created by themselves) for each module to group or specific user. Does anyone has suggestions in doing this (table structures, etc)? ...

How do I filter a php array with a MySQL table?

Say I have an array of strings in a php array called $foo with a few hundred entries, and I have a MySQL table 'people' that has a field named 'name' with a few thousand entries. What is an efficient way to find out which strings in $foo aren't a 'name' in an entry in 'people' without submitting a query for every string in $foo? So I...

Magic quotes in PHP

According to the PHP manual, in order to make code more portable, they recommend using something like the following for escaping data: if (!get_magic_quotes_gpc()) { $lastname = addslashes($_POST['lastname']); } else { $lastname = $_POST['lastname']; } I have other validation checks that I will be performing, but how secure is...

As a C# developer who wants to do some PHP work, what [book/online articles] should I [buy/read] to introduce myself to PHP?

I've got the bare minimum to handle the Linux/MySQL parts of the stack, but I want to have a basic grasp of PHP before I dive in. I'll be working on WordPress plugins, in case there's anything specifically interesting for that. PS - any recommendations regarding recommended source control/IDEs would also be great, but I guess that's a ...