php

PHP best practices for naming conventions

I recently started these naming conventions.. all functions & variables = camelCase constants with define() = ALL_CAPS_AND_UNDERSCORES Now I see a lot of other people mix up camelCase and underscores and they seem to have some sort of convention to it... What do you use and what is best? I've heard that public and private functions sh...

XML/Parser.php installation

I recently signed up to shared web hosting with godaddy using Linux and PHP 5. I want to work with multiple RSS feeds. I previously had this all functioning under Apache, however, the host supplied the PEAR installation. Now I have to do this myself and I am in unfamiliar territory.I installed PEAR PHP and managed to get rss.php in the...

Optimize feed fetching

Hello I'm working on a site now that have to fetch users feeds. But how can I best optimize fetching if I have a database with, lets say, 300 feeds. I'm going to set up a cron-job to which fetches the feeds, but should I do it like 5 every second minute or something? Any ideas on how to do this the best way in PHP? ...

Build Tar file from directory in PHP without exec/passthru

So I have a client who's current host does not allow me to use tar via exec()/passthru()/ect and I need to backup the site periodicly and programmaticly so is there a solution? This is a linux server. ...

Is there a good pre-existing class for dealing with URLs in PHP?

Is there a widely accepted class for dealing with URLs in PHP? Things like: getting/changing parts of an existing URL (e.g. path, scheme, etc), resolving relative paths from a base URL. Kind of like a two-way parse_url(), encapsulated with a bunch of handy functions. Does something like this exist? ...

What web application framework should I use for a web gallery?

Hey guys, I need to create a photo gallery for a website running IIS 4.0 or IIS 5.0 (im not sure which). It needs to display a low resolution version of the gallery to anyone, and it must show both the low and high resolution images for "priviledged" users. So I need access priviledges, photo albums and once the site is complete, the pe...

How to build a tree view with PHP / SQL?

What's the best way to: Get the data from the db using a single query Loop through the results building e.g. a nested unordered list My table has id, name and parent_id columns. ...

php mysql date/time question

I've built a small application which has User Management, a frontend console to enter data and a backend console to control parts of the frontend. The frontend adds rows to a MySQL database which are timestamped. The backend needs to be able to select rows from the database between X and Y dates. Everything works so far, except the date...

Using Zend Lucene to search PDF files

Is there a way to use Zend_Search_Lucene to search/index PDF documents? ...

What's best way to secure a database connection string?

I am writing a set of database-driven applications in PHP. These applications will run on a Linux server as its own user. Other users will likely be on the system at times, but have very controlled access. Other servers they will not have access to at all. I will also expose a limit stored procedure API to developers who need to writ...

PHP Script to execute multiple URLs?

Is there a sort of php script which will run a series of URLs and then direct the user to the final destination? the use of this is: creating a checkout cart on a site that doesn't have a robust "wishlist" feature. The script runs a series of "add item to cart" urls, and then the final destination takes the user to their cart of produc...

Best Open Source MVC PHP project to study

Hello, Do you know some good Open Source project written in PHP that is a finest example of MVC and is just the best example to learn how to write a state of art project? kind regards, ...

PHP $string{0} vs. $string[0];

In PHP you can access characters of strings in a few different ways, one of which is substr(). You can also access the Nth character in a string with curly or square braces, like so: $string = 'hello'; echo $string{0}; // h echo $string[0]; // h My question is, is there a benefit of one over the other? What's the difference between ...

PHP Regex - Change to an URL regex for a dash match

I have used the following regex to get the urls from text (e.g. this is text http://url.com/blabla possibly some more text). '@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@' This works for all URLs but I just found out it doesn't work for URLs shortened like: "blabla bla http://ff.im/-bEnA blabla" turns becomes http://ff.im/ a...

SOAP Attachment from .NET 3.5 to PHP web service

We've got a PHP web service which we need to send a file from a .NET 3.5 web app. The PHP team has stated that we need to provide the file in the form of a SOAP attachment, but we can't find a way from which we can do that in .NET. All reference examples that we've been able to come across refer to using the DIME, but that's not suppor...

What function to use to hash passwords in MySQL?

I have a user table in my mysql database that has a password column. Currently, I use the MD5 algorithm to hash the users' password for storage in the database. Now I like to think that I am a security conscience person. I noticed while reading the MySQL docs that they don't recommend MD5 or the SHA/SHA1 hashing methods, but don't offer ...

Best solution to protect PHP code without encryption

First of all, I'm not looking for miracle... I know how PHP works and that there's not really way to hide my code from the clients without using encryption. But that comes with the cost of an extension to be installed on the running server. I'm looking for something different though... I'm not looking to encrypt my code or even obfuscat...

PHP mySQL - When is the best time to disconnect from the database?

I use lazy connection to connect to my DB within my DB object. This basically means that it doesn't call mysql_connect() until the first query is handed to it, and it subsequently skips reconnecting from then on after. Now I have a method in my DB class called disconnectFromDB() which pretty much calls mysql_close() and sets $_connected...

Calculate business days

Hi, I need a method for adding "business days" in PHP. For example, Friday 12/5 + 3 business days = Wednesday 12/10. At a minimum I need the code to understand weekends, but ideally it should account for US federal holidays as well. I'm sure I could come up with a solution by brute force if necessary, but I'm hoping there's a more eleg...

How can I create an array of a particular model? [PHP MVC]

Well I'm new to MVC and am trying to write a site in it. The site is a basic flash games site and has categories to track the games. My first step was to create a basic MVC setup and list all the categories. The problem is I don't know how to create an array with all of the categories in it. Can I add this to the controller? Should ...