php

Validate a number with grouped thousands with decimal to the hundreth

Looking for a simple way (Function/RegEx) to validate a number with grouped thousands. Example Numbers: .00 - 999.00 should validate 1,000.00 should validate 100,000.00 etc... should validate 100,000,000,000,000.00 should validate Now I've seen the number_format(), but this formats the number not validates. I wanted to use a RegEx b...

Creating An iCal Event, Without Creating A Calendar

I am using the iCalCreator class to create an event for user to load into their personal calendars. Here's the info, for those unfamiliar with it: http://www.kigkonsult.se/iCalcreator/ Using the documentation, right on the homepage, I'm able to create an event and output it to the browser. No problems. The issue is that when it is impor...

wordpress: replacing square brackets in the_content

First off, I admit I'm a WP-noob, so I'm not even sure I'm going about this the right way. I'm trying to create a simple plugin that replaces matched text in the_content. The code works on my PHP test server, but fails in WP, leaving me to believe I'm missing something. I am hoping someone can point me in the right direction. I would li...

What does $obj = new BlahBlahName($_GET); do?

I know that we use GET function to get the variables from the url in php when we use the GET method to pass data across pages or within the same page. However $obj = new BlahBlahName($_GET); what does this do? ...

PHP: Callback functions

Some functions in PHP require a callback function. How can I do this in a function myself? First of all, how do I define a function that require a callback function? And secondly, how do I provide a custom function as the callback function? How do I provide a regular function, an instance function and a static function? ...

Mixed content error in chrome; Site contains no mixed content; Clearing Cache and reopening Chrome does not solve

I am getting a mixed content warning from Google Chrome. It does not show in Firefox or Explorer. I'm opening the site from a test server on localhost running Vista, Apache2.2.16, mod_ssl2.2.16, OpenSSL0.9.8, and PHP5.3.3. All content is forced through https by apache. I am using a self-signed certificate. The entire source code i...

In PHP, can I get MySQL to rollback a transaction if I disconnect without committing, rather than commit it?

If I run the following PHP, I would expect no value to be inserted into the test table, because I have a transaction that I haven't committed: $db = mysql_connect("localhost","test","test"); mysql_select_db("test"); mysql_query("begin transaction;"); mysql_query("insert into Test values (1);") or die("insert error: ". mysql_errror()); d...

PHP/Apache crash when PHP call COM objects

I am working on calling COM object method from my PHP application, but often Apache/PHP CLI crashes when I launch the script. This one for example $domainObject = new COM("Excel.application"); foreach ($domainObject as $obj) { echo $obj->Name . "<br />"; } or this one $o=new COM("NeoScope2InterOpCOM.NeoScope2InterOp"); $o-...

Selling a PHP application

I wanted to get some thoughts on selling a PHP application (CMS). I intend on offering a free version that may include ads or be limited in some way. My main concern is how to detect if the user has purchased a license or the paid version or not. My idea is to have a file (license.php) which will check a variable against one on my datab...

Is it good to cache the Zend application.ini file to make my application run faster?

If I remember correctly, parsing .ini files in PHP takes a long time. So, why not cache it (the file won't change during a request) What is the best way to do this? Or are there any reasons not to do it? ...

How to implement MySQL::"LOAD DATA LOCAL INFILE" in PHP?

We have to implement the import procedure. The quantities of data is about 100 megabytes for one CSV files (the files already resides on server, so no upload necessary). Any advice on whether to implement the bulk "LOAD DATA LOCAL INFILE" or row-by-row "INSERT/REPLACE" on importing data into database. I've checked that "LOAD DATA LOCA...

Regex - negative look-ahead assertion

Hi, I wand to replace URLs like www.example.com/profile/USERNAME by [user]USERNAME[/user] BBCode! $userURLSearch = "#((https?|ftp)://|www\.)example\.com/profile/([A-Za-z][A-Za-z0-9_-]+)(?!/)#i"; $userURLReplace = "[user]\\3[/user]"; $text = preg_replace($userURLSearch, $userURLReplace, $text); But it also transforms URLs like www.ex...

Textarea validation

Hello! My script is supposed not to let the HTML form be submitted unless a user enters some data into a textarea control. However, the form gets submitted anyway and no message for the user is displayed. Could anyone see what I'm doing wrong? Here is my HTML: <textarea name="description" id="description" rows = "4" cols = "25"> <?...

Automatically redirect browser to many ip addresses using PHP or Javascript

I have a ton of IP addresses that I need to visit to see if they are active. So my plan is to redirect the browser over and over again and then just use the back button to view each page. What is the best way to do this? I will most likely have an array of IP addresses. like: array(234.324, 2343.323432, 234.234, 234.4543) Then I can u...

PHP: DATETIME in array as object. How to echo

Hope that title isn't too cryptic. I have an array with a DATETIME object in it and I'm just trying to figure out how to echo this to a page. ["created"]=> object(DateTime)#3 (3) { ["date"]=> string(19) "2010-10-22 00:00:00" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London" Can someone help me out? tried date() bu...

PHP DOMDucment and DOMXpath seem to be broken. Help Please (FIXED)

Hello All, So here is my problem in a nut shell. I'm working on a web scraping app for work and I've ran into a snag. I'm trying to load the HTML markup of a site using CURL, then use DOMDocument and XPath to find specific node values from that HTML. Initially, the user plugs in a URL which displays information they want to pull out o...

(SSO)Single sign-on or Open ID with PHP

Hello I have an application in PHP, fully built, with plugin capabilities and need to integrate SSO into it. Does anyone has a place where I can start some research or any code that can share to get me started. Thanks in Advance! ...

Poor performance resizing multiple images using Smart Image Resizer

I'm using Smart Image Resizer to resize images on the fly and it works great - for pages with few images. However, when loading a page containing 72 images, it takes 6-7 seconds to load (on localhost). If I just output the filenames, (not using image.php), the page loads within a second. This is what I do: 1. Loop through an array ...

Reading In A File While It's Being Changed

I'm curious what happens in this scenero. Suppose I open a file for reading, and begin reading the contents in a loop. Like this: $fp = fopen('test.txt', 'r'); while(!feof($fp)) { fread($fp, 1024); } fclose($fp); What happens if another process starts appending to the file while I'm reading it? ...

Retrieving like counts on entries from SQL.

Hey all, I've been adding a like feature to an entries database... here's the structure of the DBs: **Users** user_id user_name etc. **Entries** entry_id entry_content etc. **Likes** user_id entry_id (It's a little more complicated than that, there are groups/categories, but that should explain it fine...) Here's the SQL query I'm ...