php

How do I create a node from a cron job in drupal?

In a custom module for drupal 4.7 I hacked together a node object and passed it to node_save($node) to create nodes. This hack appears to no longer work in drupal 6. While I'm sure this hack could be fixed I'm curious if there is a standard solution to create nodes without a form. In this case the data is pulled in from a custom feed ...

Code in PHP for the ceiling function

Anyone has ever programmed a PHP (or perl) function to get the ceiling value Excel style? TIA Roberto ...

PDF Imposition in PHP

I'm looking for a PHP library that will allow me to create a print-ready PDF. The imposition should include 1-up, 4-up, 24-up, etc. layouts, and crop marks. FPDF, TCPDF and PHP's included PDF libraries allow me to create an image and plop it on a PDF, but the more advanced layouts and crop marks are a bit beyond me. Thanks in advance!...

Zend Framework - ErrorHandler does not seem to be working as expected.

This is my first experience using the Zend Framework. I am attempting to follow the Quick Start tutorial. Everything was working as expected until I reached the section on the Error Controller and View. When I navigate to a page that does not exist, instead of receiving the error page I get the Fatal Error screen dump (in all it's glory)...

How can I ban a whole company from my web site?

For reasons I won't go into, I wish to ban an entire company from accessing my web site. Checking the remote hostname in php using gethostbyaddr() works, but this slows down the page load too much. Large organizations (eg. hp.com or microsoft.com) often have blocks of IP addresses. Is there anyway I get the full list, or am I stuck with ...

What's the best way to run Wordpress on the same domain as a Rails application?

I've got a standard Rails app with Nginx and Mongrel running at http://mydomain. I need to run a Wordpress blog at http://mydomain.com/blog. My preference would be to host the blog in Apache running on either the same server or a separate box but I don't want the user to see a different server in the URL. Is that possible and if not, w...

Which language is most like PHP?

I am a PHP dev looking to pickup a new language, I have tried and failed on C++ several times (possibly for my overall lack of interest). I've been hearing a lot about Python, and Ruby and my question is this: Which of these languages (Python, Ruby) should be easiest for someone with a background in PHP to learn? Update (6 months later)...

How do you find the difference between 2 strings in PHP?

I have 2 strings that I'd like to compare, and return the positions of the different characters in the second string. For instance, if I have 1. "The brown fox jumps over the lazy dog" and 2. "The quick brown fox jumped over the lazy dog", I want it to highlight "quick" and "ed". What's the best way to go about this in PHP? ...

Getting PHP to read .doc files on Linux

I'm trying to read a .doc file into a database so that I can index it's contents. Is there an easy way for PHP on Linux to read .doc files? Failing that is it possible to convert .doc files to rtf, pdf or some other 'open' format that is easy to read? Note, I am not interested in .docx files. ...

Learning PHP for fun and profit

Hi. I'm currently working as an applications developer, with a Java and C++ background, but I'd like to be able to work on more web-based projects. I was originally thinking of learning one of the newer languages, but I suspect that there'll be more value to learning php, as that's what most legacy code's written in. Hopefully then mov...

Should I mysql_real_escape_string all the cookies I get from the user to avoid mysql injection in php?

When a user goes to my site, my script checks for 2 cookies which store the user id + part of the password, to automatically log them in. Its possible to edit contents of cookies via a cookie editor, so I guess its possible to add some malicious content to a written cookie? Should I add mysql_real_escape_string (or something else) to al...

Fastest way to determine image resolution and file type in PHP or Unix command line?

I'm currently using ImageMagick to determine the resolution of images uploaded to the website. By calling ImageMagick's "identify" on the command line it takes about 0.42 seconds to determine a 1MB JPEG's resolution along with the fact that it's a JPEG. I find that a bit slow. Using the Imagick PHP library is even slower as it attemps t...

Simple, free PHP blog engine easy to redesign?

I am looking for a PHP blog engine which needs to be easy to redesign (CSS, HTML). It also needs to be free and have simple user interface so that the client doesn't struggle to add posts. Any suggestions? ...

What is the best PHP programming book?

I'm interested to find out what Stack Overflow believes the best PHP book is - both for those who are beginners to web programming as well as those who have previous programming experience (they don't have to be same book). "Best" includes being both reasonably up-to-date and encouraging best practices for secure, modern, PHP programming...

Multiple Inheritance in PHP

I'm looking for a good, clean way to go around the fact that PHP5 still doesn't support multiple inheritance. Here's the class hierarchy: Message -- TextMessage -------- InvitationTextMessage -- EmailMessage -------- InvitationEmailMessage The two types of Invitation* classes have a lot in common; i'd love to have a commo...

What is the difference between mysql_real_escape_string and addslashes?

mysql_real_escape_string and addslashes are both used to escape data before the database query, so what's the difference? (This question is not about parametrized queries/PDO/mysqli) ...

Where would you advertise for a UK based telecommuting PHP developer?

This is not an advert - it's where would you put an advert for the best effect. Clarification: it's a employer aiming to find a new (full-time) employee. ...

Is there any point for interfaces in dynamic languages?

In static languages like Java you need interfaces because otherwise the type system just won't let you do certain things. But in dynamic languages like PHP and Python you just take advantage of duck-typing. PHP supports interfaces. Ruby and Python don't have them. So you can clearly live happily without them. I've been mostly doing my ...

PHP equivalent of Perl's 'use strict' (to require variables to be initialzied before use)

Python's convention is that variables are created by first assignment, and trying to read their value before one has been assigned raises an exception. PHP by contrast implicitly creates a variable when it is read, with a null value. This means it is easy to do this in PHP: function mymodule_important_calculation() { $result = /* .....

How to create a fast PHP library ?

For our online game, we have written tons of PHP classes and functions grouped by theme in files and then folders. In the end, we have now all our backend code (logic & DB access layers) in a set of files that we call libs and we include our libs in our GUI (web pages, presentation layer) using *include_once('pathtolib/file.inc')*. The ...