php

uploadprogress.so for PHP 5.3?

I'm using XAMPP (latest version) on OS 10.6.2, that's bundled with PHP 5.3.0 I installed the XAMPP development package for the PHP source/header files and ran the following command from Terminal- sudo ./pecl install uploadprogress Everything appeared to work fine. My php.ini file (yup - I checked it's the same one being loaded in php...

HTTP Header Referrer Cheating using PHP

I need to make a false referrer to certain pages using PHP. In my http://www.a.com/header.php page I tried the following code header("Referer: http://www.b.com\n"); header("Location: http://www.c.com"); But this doesn't work, at least for Google Analysis. Can anyone tell me how to do it? ...

Foreach and 2D Array in PHP

$mainMenu['Home'][1] = '/mult/index.php'; $mainMenu['Map'][1] = '/mult/kar.php'; $mainMenu['MapA'][2] = '/mult/kara.php'; $mainMenu['MapB'][2] = '/mult/karb.php'; $mainMenu['Contact'][1] = '/mult/sni.php'; $mainMenu['Bla'][1] = '/mult/vid.php'; This is a menu, 1 indicates the main part, 2 indicates the sub-menu. Like: Home Map -MapA...

Reading an HTTP stream into an array

I need to read an http stream into an array but can't seem to get this quite right. Ultimately, what I need is an array of the html to use in an implode function. Can someone please point me in the right direction? ...

PHP: storing/displaying relative dates in UTC

I have a list of dates stored in MySQL using PHP. These were stored using the following code: date_default_timezone_set('UTC'); $strDate = date("Y-m-d H:i:s",time()); I can only test this from my timezone, which is also UTC! If a web visitor from eg Eastern Time USA views the page, will the date be converted to UTC correctly? Presu...

What is a good algorithm or library for cropping images to avoid whitespace or empty areas?

I have a whole bunch of images of illustrations that I would like to crop to a smaller preview size. The problem is that I want to crop them to show an "interesting" part of the illustration (ie avoid areas of whitespace). The images typically have a flat color or a subtle gradient for the background. They are mostly vector style artwo...

PHP: Printing HTML-Friendly Code?

Hi All, I am wondering if there is any technique out there for making HTML code look good when printing that HTML (multiple lines) from a PHP function? In particular, new lines and tabs. Obviously, I want the HTML tags behind-the-scenes to look good with the proper new lines and tabs. However, depending on when I call the PHP function...

MySQL Result - "Group By" removing incorrect duplicates

Will do my best to describe the problem Im having :) Each thread/topic in my forum represents one disc. Registered members of the forum use a series of checkboxes (one displayed next to each disc) to tick each disc that they have in their collection. When the form is $_POST'ed it stores the information in a table like so: | user_id - ...

Help with writing a MySQL query involving date differences.

I need to delete rows where a datetime field is over 2 weeks old. This is what I have came up with $duration = Date::WEEK * 2; // int(1209600) $query = 'DELETE FROM properties WHERE TIMEDIFF(' . date(DATE_ISO8601) . ', reserved_datetime) > ' . $duration; I don't often write complicated queries (preferring to do stuff in P...

At my wits end on sleep().

I've got sleep(n) in a loop that is intended to do output on a periodic cycle. But when I run the loop, nothing happens until all of the seconds in the intended loop duration accrue collectively, after which all of the output comes spilling out at once. Help. Thanks. ...

Can PHP tell if the server os it 64-bit?

I am dealing with Windows here. I know you can use the $_SERVER['HTTP_USER_AGENT'] variable to detect the OS of the browser viewing the page, but is the any way that PHP can detect the server's OS? For my program's UI I am using a php webpage. I need to read a key in the registry that is in a different location on a 64-bit OS (It is u...

If I make my application with the Zend framework, will I be able to host it with any company that supports PHP?

Thank you for the answers. :) I'm mainly looking to host my website with A Small Orange, but they don't say if they support Zend anywhere. :S ...

CakePHP Router::connect() aliases?

Is it possible in CakePHP to have URL aliases in routes.php? Or by what other means can achieve something equivalent: Lets assume I have some paginated views. Among the possible orderings there are particular ones I want to bind to a simple URL. E.g.: http://example.com/headlines => http://example.com/posts/listView/page:1/sort:Post.c...

PHP Powershell command

Trying to run the following command in php to run powershell command... the following works: $output = shell_exec(escapeshellcmd('powershell get-service | group-object')); I can not run it like this: $output = shell_exec('powershell get-service | group-object'); it will not pass the pipe | character but if I try to run: $output...

How to create a "genuinely extensible" class

I have read a lot of articles on developing classes (I am using php), with the tag lines : 'scalable, robust, maintainable and extensible'. But as a beginner, I have been creating classes that are, in my words, "just abstracted". Meaning I just separated a bunch or repetitive codes and put them in a class and provide methods for access...

Evenly distributed integers within a range

Lets say I have a range between 0 and 100 and I want an array returned containing 3 integers which are evenly distributed within that range, what would be the best way to do this? For example: Range: 0-100 Wanted: 3 Returned: 25, 50, 75 ...

PHP: Is mysql_real_escape_string sufficient for cleaning user input?

Is mysql_real_escape_string sufficient for cleaning user input in most situations? ::EDIT:: I'm thinking mostly in terms of preventing SQL injection but I ultimately want to know if I can trust user data after I apply mysql_real_escape_string or if I should take extra measures to clean the data before I pass it around the application a...

javascript string replace equivalent on php?

I am trying to prevent xss injection. So before I submit a form, a javascript function is called function validatefield(id) { var description = document.getElementById(id).value; description = description.replace(/[\"\'][\s]*javascript:(.*)[\"\']/gi, ""); description = description.replace(/script(.*)/gi, ""); desc...

Persisting Zend Framework ACL Lists

Does the Zend Framework (or applications built using Zend_Application) provide any mechanism for persisting ACL lists, or is that detail left to the individual system/application developer? Most of the examples I see online involve setting up your ACL rules in code. I'm curious if there's any standard/preferred way to save these rules ...

[PHP | MySQL] multi-page forms and SESSIONS vs HIDDEN form data

I'm working on a 2 page form that POSTs a query to a database. Read-only, no writing. None of the information is confidential, nor will it every be. The site must be 100% non-JS compliant, so Ajax and the like are not available. All I got is PHP, baby! FORM-2's content is dependent on a fraction of the data in FORM-1, but ALL of the da...