The way to avoid eval() usage when you receive data in PHP code

There is old known situation. We have script or service which gives us PHP arrays packed into strings as PHP code.(In  var_export() format). Or this is historically, something in the system gives us  arrays in PHP code format.

For example your script receives something like:

$test = "array('gmt' => 'Europe/Moscow',
'sudia3' => '',
'sudia1' => '',
'sudia2' => '',
'pos1' => '4-2-3-1',
'color1' => '#f00',
'pos2' => '4-4-1-1',
'color2' => '#000',
);";

PHP. var_dump, pointers and recursion. Why xdebug may be useful

This situation is quite rare, but still occurs. There is a certain variable, and we need look at its structure.

We do the following:

var_dump($fields);

and get into the mess looking on the following message in our log of webserver:

[Thu Feb 23 16:21:07 2012] [error] [client 127.0.0.1] PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 78045652 bytes) in /web/site1/includes/theme.inc on line 1080, referer: http://localhost/site1/

Redmine and Ruby 1.9.2. Solution.

There are a lot of project management systems for programmers(to track bug reports, project tickets, timelines, to work with tasks and documents). Today main products for that goals are Redmine, Trac, Jira, Bugzilla. Redmine is much more interesting for me because it's written on Ruby, has wiki, task management, charts, advanced user groups and permissions for projects. And looks comfortable for work after Jira or Trac.

Setting up correct work of HTTPS in Drupal for case of reverse HTTPS-proxy

I had to configure Drupal, working in the following configuration:

Drupal works on Apache2 webserver with mod_php, which works behind light-weight reverse HTTPS-proxy(e.g. nginx). Apache works with mod_rpaf, and configured correctly to handle requests via reverse proxy. But the problem  is with  connection between apache and proxy. It's over HTTP protocol, that's why  working PHP scripts on server(in our case Drupal) behave so as they work on direct http server. For example Drupal returns pages with incorrect hyperlinks, it's not possible  pass authorization.

Site now works on two languages

After audit of code of Drupal module i18n, I decided install it and start an experiment with translation of some articles into English.

Now, to the extent of my ability, every new article in Russian, will be translated into English. At the moment there are some problems with "integrity" of content, but I believe they will be solved, and the English-speaking users will be able to read the articles right here in English.

Subscribe to Ilya Azarov RSS