php

Web applications: Development to Production

Here is my company's current process for moving changes from our development server to our production server: Files that need updated are brought down from production, to ensure no changes were made in production only (no it shouldn't happen; but yes, it does happen). Old development files are given a ~ prefix as a sort of "backup". De...

PHP encoding with DOMDocument

<tag> Алекс М </tag> When I try to get the content of the following code using DOMDocument functions, it returns something like: ÐÐ»ÐµÐºÑ Ðœ I've tried setting DOMDocument encoding to different values (UTF-8, ISO-8859-1), using mb_convert_encoding, iconv and utf8_encode but without success. How can I get "Алекс М" instead of "ÐлÐ...

Server side browser that can execute JavaScript

Is there any programming libraries available that will parse an HTML document, execute JavaScript and then allow me to navigate the DOM?  This needs to be performed server side, not client side. Any language will do, but Java, PHP, or Ruby are preferred. ...

Same code on browser/server

I'm writing a web app using PHP, and running into several situations where I need similar code on the server and browser. For example: I want to validate user input, and generate the same error messages on both sides. I want to format data using certain rules (e.g. if a given field is less than 1, show it with two decimal places, other...

Algorithm for creating cells by spiral on the hexagonal field

Help to find an algorithm for creating cells by spiral on the hexagonal field. Look at the image: Let's imagine an dimensionless 2d array. The X axis is the blue line, Y is horizontal, spiral is red. I need to add cells from the central point x0y0 to point N by spiral Tell me the way to solve the problem, please. Thank you! ...

PHP: Converting png's and gif's into grayscale

Hello, im using the following script to convert jpgs into grayscale-images. http://bubble.ro/How_to_convert_an_image_to_grayscale_using_PHP.html i want to upgrade it to also convert pngs (with transparency) and gifs (with transparency) into grayscale images. At the moment it's not working. I'm querying the image-src for its file-extens...

What's wrong with using $_REQUEST[] ?

I've seen a number of posts on here saying not to use the $_REQUEST variable. I usually don't, but sometimes it's convenient. What's wrong with it? ...

Saving and retrieving blobs using Propel ORM (YML, Propel and PHP question)

I am using Propel (1.4) with Symfony 1.31 (with mySQL db). I want to save save/retriev BLOB (gzipped) data to/from the database My db schema is defined in YML. Suppose the schema looks like this: demo_blobbed_object: _attributes: { phpName: MrBlobby } id: name: {type: varchar(32)} data: {type: ? } I have the following questi...

Decoding JSON feed via PHP from Twitter not working?

Hello my fellow coders! So I'm pulling down a user's tweet steam in JSON format via PHP. I'd like to decode it into an associative array or at least some more usable fashion rather than a string so that I can maneuver through it. I've been reading like mad about json_decode, but for me it seems like when I use it, before and after, the...

PHPUnit test of ADODB classes fails on second test

I'm trying to use PHPUnit to test some ADODB based classes and I'm not having much luck. What I'm seeing is that is the test of the ADODB based class is not the first test it fails claiming that "Undefined index: MyTable". I created the simplest possible test case. I have A table with one column, an autoincrementing int An ADODB der...

PHP readfile or file_get_contents in a loop

there may be other ways to do this but I'm looking for an fairly easy set-up because it's basically a one-time process. I have 50 state directories with a handful of txt files in each one. I want to step into each directory, "read" each file (and then do a mysql insert of each file) I've tried a few variations, but each time I try to ...

Which PHP framework is the most "Rails-like"?

I've been using CodeIgniter for a few months and I keep finding the need to install 3rd party libraries that make it function more like Rails, specifically in its templates, testing, ORM, and before filters in controllers. Is there a PHP MVC framework that more closely follows Rails conventions? ...

PHP Include Path Problems

Setting the include path is really confusing me. I must be missing something important. So I have the following scripts in the public_html folder of my server. photoGallery.php header.php I have my htaccess file set to redirect a url with the following structure to photoGallery.php RewriteRule ^gallery/([^/]+)/([0-9]+)-([^/...

Safely convert user-provided array string into PHP array?

Users need to be able to enter a PHP array of parameters. Currently, they see a text area where they are expected to enter PHP code that defines an array: <textarea name="foo"> $bar = array( 'key' => 'value' ); </textarea> I get the value of the text area as, for instance, the string $_GET['foo']. How can I parse this so that I can...

PHP: exec(svn commit) is not returning any errors nor working..

Currently I'm writing out files with php into a directory, I add that directory (works fine), then when i try and do an svn commit its not working nor returning any kind of error codes. Does anyone have any idea on this? $tmp = exec('cd '.$this->build_locations[$this->type].'; svn commit --username user --password pw; ls', $output); I...

SPSS and PHP/MySQL Integration

I apologize up front for the broadness of this question, but I'm wondering if anyone has any suggestions/pointers. A friend's company uses SPSS for statistical data, surveys, etc. They'd like to be able to slice and dice the the info via a web interface. I have no knowledge of SPSS, so there may be a simple web front end, but being a PH...

Short PHP page to execute a command and pass an id?

I have a script which, given an ID, kicks off some complex processes and puts an RTF file onto stdout. For example, you might call it with something like foo.exe 27 to point it at ID 27. Now I'd like to write a short PHP page which: accepts a GET id parameter checks that the parameter is an integer number calls shell_exec(...) on the ...

Any preg_match() to extract image urls from text ?

Hi, i need a preg_match() syntax or something similar to extract JPG or PNG or GIF URLs from a mixed text and put them in an array or at last store the first url. maybe some syntax which searchs for strings that are beginning with http and ending with jpg/png/gif.. i believe it can be done with preg_match() Note: the text can be like ...

issuing login information upon receipt of purchase

I am selling stuff from here: http://foundationletters.com/buy-master-mind-products/ One of the things on sale is a subscription to a specific website. As you can see, I have connected e-junkie to my authorize.net account. Let's say that I already have pre-generated accounts. In other words, I have logins and passwords that I am sel...

How can I programmatically store an image in a publicly accessible location on my Drupal site?

Hi, I am writing a Drupal module where users send down content (formatted as HTML). The content will almost always include <img> tags. Those tags will reference the user's server. But, I don't want to hit the user's server every time that content is requested; I want to serve up a version on my server. So, I have written a function ...