php

CRC8-Check in PHP

How can I generate a CRC-8 checksum in PHP? ...

Alternative/faster methods of converting an integer to a cartesian coordinate?

As a fun side-project for myself to help in learning yet another PHP MVC framework, I've been writing Reversi / Othello as a PHP & Ajax application, mostly straightforward stuff. I decided against using a multidimensional array for a number of reasons and instead have a linear array ( in this case 64 elements long ) and a couple methods...

PHP Query String Limit

I have PHP 5.1.6 (cli) installed and whenever the GET query string is more than 128 characters it fails with HTTP 406 Not Acceptable error. Any suggestions how I can fix this so can use more than 128 characters? POST is not an option. The error is being returned by the server so don't think it's browser issue. And the reason I think it'...

How do I linkify urls in a string with php?

I have the following string: "Look on http://www.google.com". I need to convert it to: "Look on http://www.google.com" The original string can have more than 1 URL string. How do I do this in php? Thanks ...

Connect to MS SQL Server from PHP on Linux?

I need to connect to an MS SQL Server database from a PHP script running on a Linux server. I'm looking at using FreeTDS as there is no official MS SQL Server driver for Linux. Is this my best option? Is it ok in a production environment? Are there other options, perhaps ODBC? ...

PHP signup email-validate login script/class

I am looking for a decent PHP script or class library to handle user sign-up/register, email-validation and login for a website. I've written this sorta thing before, but I'd rather use something more tested and robust. The handful of open-source offerings I have thus far come across are, in my view, not very good. I've also looked at RP...

What is the best way to escape user output with the Zend Framework?

I'm a little confused by what I should use to escape user output. Firstly, there's the Zend_Filter_Input class which looks like it might do what I want but seems oriented towards batch filtering lots of items. At the moment I only want to filter one. Also I'm a little confused by the definition of escapers compared to filters. What's th...

Select max 5 integers from set of 20

I'm trying to select the 5 most viewed articles out of a list of the 20 most recent entries in a table. My table structure is essentially this: id | date | title | content | views My first thought was just to use an inner select to get the 20 most recent articles, then select from that, but I have yet to have any luck. //doesn't wor...

running a php task every 24 hours

Hi, I have some functions that use curl to pull information off a couple of sites and insert them into my database. I was just wondering what is the best way to go about executing this task every 24 hours? I am running off windows now, but will probably switch to linux once I am live (if that makes a difference). I am working inside sy...

Is PHP or Perl the right choice for my web project?

I'm looking forward to hear some suggestions for choosing the "right" language (and modules?) to realize a 1-man web project (LAMP only, complexity somewhere between a guestbook and a fully fledged blog, developed for high traffic sites with 50,000+ impressions per day) based on these requirements: Output cache (think: Wordpress Super-...

How do I execute a query once a day and output results to flat file using cron?

Hello all. I have a PHP/MySQL web site where I want to output the # of entries in a DB/table on the main page, but I don't want to make this query every time a user hits the home page. I want it to automatically run once a day and output the query results to a flat file which I can then just include. I figure that should reduce load...

Zend_Form_Decorator - How to add attrib to Zend_Form_Element_Hidden ?

I have 2 requirements: 1) All hidden input elements should be affected without removing standard decorators. 2) This should happen WITHOUT having to specify it on a per-element basis. All I need is for a CSS class to be attached to the DT & DD tags IF the element type is Zend_Form_Element_Hidden. I've tried creating custom HtmlTag, DtD...

PHP Encryption openssl_pkcs7_encrypt() Failing

Hey all, I have this code: $fp = fopen($unenc_path, "w"); fwrite($fp, $msg); fclose($fp); $easy_access_emails = 'person@##.com'; $headers = "From: support@##.com <support@##.com>\n" . "Reply-to: support@##.com\n" . "Subject: " . $subject . "\n"; $key = implode("", file("../newcert.pem")); $Ar...

Generating .po/.mo files

I have a database full of translations I'd like to generate either .po or .mo files. I'm using C#, but I could also port an implementation from PHP if one exists. I can't find any examples in any languages using anything other than GNUs gettext utilities. Does anyone know of one? ...

Truly destroying a PHP Session?

I have heard mixed responses on this topic, so what is a sure fire way to destroy a PHP session? session_start(); if(isset($_SESSION['foo']))   unset($_SESSION['foo']; //etc session_destroy(); In the most simple of cases, would this sufficient to truly terminate the session between the user and the server? Nicholas ...

Zend_Form + DHTML content

Whats the best way to dynamically add NEW dhtml content to a form that's generated via Zend_Form. Example, say the form is created like so: class formUser extends Zend_Form { public function __construct( $options = null ) { parent::__construct( $options ); $page1 = new Zend_Form_Element_Text( 'page1' ); $pag...

New Website Project Sliverlight / Php

Hi, Very recently i have been given a facebook like project to develop for a client of mine. Most of the time when i comes to web development i use php since the solution PHP, apache, MySql which are all freely availble solutions, i have been thinking about using sliverlight to develop th web application, and i would like to hear some p...

Programatically changing PDF quality in PHP.

Can I programatically change the quality of a PDF? I have a client that is a newspaper, and when they submit the PDF form of the paper to their site they are submitting the same copy they send to the printer which can range from 30-50Mb. I can manually lower the quality (still plenty high for the web) and it will be 3-5Mb so this will h...

Accessing child variables from the super class without instanciation

I'm attempting to access member variables in a child class via the parent class without instantiation. This is one of my attempts but B::getStatic() fails with Access to undeclared static property. Is there another solution to this, possibly without static? class A { static public function getStatic() { return self::$myS...

Data Mapper + Observer pattern

Hi, I'm building an app in PHP and I'm using the data mapper pattern for my DB access. I was considering using the Observer pattern to have all my mappers observe the entities they create, so that they can automatically save any changes back to the database without me having to parse them back manually. I was just wondering if this was...