Sign up Login
home | you | technology | web 2.0 | podcasts | entertainment | photos | comics | videos
 

Planets [view: normal]

deck | river | normal
 

How-to create a Password Generator using PHP 22.11 16:54

Do you need a password generator function for your user registration application or do you have to write a script in PHP? Than is this PHP tutorial for you. The function in this guide is flexible enough to use it during the user registration process or for a password recovery function. The generated password from this function is so safe as you which: Generate alpha-numerical password combined wi...

Recommend me a CMS 21.11 11:36

In my last blog post I have explained a bit more complaints about pretty much all CMS that I have seen in the PHP space to date. Now I wonder is there any CMS I should be checking out? Note I am not so interested in a CMS that is still in its infancy, I am looking for a CMS that can have a fighting chance to compete against Drupal, ezPublish and friends in a feature checklist comparison. Actually ...

The Value of Self-Serving Code 21.11 06:36

It's Friday night. I'm writing code. Not good code, mind you. Crappy code. Completely self-serving code that serves only one purpose: to solve a problem I alone have. No one else will see this code. No one else will use this mini-app. I'm writing it for myself and myself alone.

I did not test this code.
I did not use a framework.
I mixed PHP and html in one file.
I'm sure there are numerous XSS and o...

DevZone updated to Zend Framework v1.9.5 20.11 18:28

I just this morning pushed a new version of Zend DevZone, and the biggest change was a move to Zend Framework version 1.9.5 – Why is this important? Because it was previously running v1.0.1 ( gasp ), and I wanted to tell the story of the work it took to upgrade.

Developer’s SugarCRM book coming to a bookstore near you. 20.11 17:27

A

Conference Biography Help 20.11 12:15

I've been updating my conference details recently, in order to submit my talks for php|tek in Chicago (the call for papers closes on Monday - get your submissions in!). One thing which I struggled with is my biography, I used to have a paragraph which sort of said "Lorna is a PHP Developer and involved with PHPWomen", and I used that same entry for every conference for a year or more. However, j...

Web 2.0 Security revisited Vortrag@Mayflower-München 20.11 11:16

Am kommenden Donnerstag, den 26.11.2009 findet wieder ein öffentlicher Vortrag im Mayflower Büro in München statt (Mannhardtstraße 6, S-Bahn Isartor).
Beginn ist um 18:00 Uhr, Thema des Vortrags ist “Web 2.0 Security revisited".

AJAX- und RIA-Applikationen werden zum Standard, Clouds zur normalen Plattform für Webapplikationen und Services lösen den Code in Bibliotheken ab. Parallel dazu si...

Part Of Speech Tagging 20.11 11:00

Poetry tags pretty wellUntil now, all the posts here have looked at text in a purely statistical way. What the words actually were was less important than how common they were, and whether they occurred in a query or a category. There are plenty of applications, however, where a deeper parsing of the text could be huge beneficial, and the first step in such parsing is often part of speech tagging. The tags in question...

Designing Databases: Picking The Right Data Types 20.11 07:00

When I started writing this blog post, I had titled it “Tips for Designing Databases” and I planned to talk about various database design techniques. However, as I did more and more research, it dawned on me that one of the most crucial, and most overlooked, components of database development, is the selection of data types for columns.

Much of the information presented in this article was taken f...

Igbinary, The great serializer 19.11 17:05

If you are using PHP, chances are that at some point you needed to serialize PHP data, whether it was transparently done for you inside the PHP's session handler or directly so that complex PHP data types (objects & arrays) could be stored in DB or files, most people have done this.

The default way of doing it is via a native PHP serializer, which creates a clear-text version of the data, which i...

IE9 will have rounded corners (and a bunch of other stuff) 19.11 14:45

And then, there was much jubilation.

Marvel of marvels, the upcoming Internet Explorer 9, which was previewed yesterday at PDC, will finally support rounded corners. I have, of course, no illusion about the fact that this isn’t related to my post from a couple of days ago, but it’s good to hear that they’re at last catching up.

Of course, this also means that there is yet another version of IE tha...

What is a content repository 19.11 11:02

Joint post of Henri Bergius and Michael Marth cross-posted here and here.

Web Content Repositories are more than just plain old relational databases. In fact, the requirements that arise when managing web content have led to a class of content repository implementations that are comparable on a conceptual level. During the IKS community workshop in Rome we got together to compare JCR (the

new zf book 19.11 00:16

A

PHP 5.3.1 Released! 19.11 00:00

The PHP development team would like to announce the immediate availability of PHP 5.3.1. This release focuses on improving the stability of the PHP 5.3.x branch with over 100 bug fixes, some of which are security related. All users of PHP are encouraged to upgrade to this release.Security Enhancements and Fixes in PHP 5.3.1:Added "max_file_uploads" INI directive, which can be set to limit the numb...

Drupal Frustration Redux 18.11 23:31

Earlier this week, I wrote a piece on why I'm no longer willing to tolerate Drupal. It got a lot of traffic (for my blog), and a lot of comments.

Most of those comments were "classic apologetics" as one person put it, and upon reading them, I realized that I may not have done the best job of making my point (which boils down to: Drupal takes more effort to maintain than I'm willing to spend). If y...

PHP_Depend jumps on the D-BUS 18.11 18:47

Today I had the chance to visit Derick's IPC talk on PHP on the D-BUS. Beside the fact that it was an exciting talk, it inspired me to implement a small, but nice feature for PHP_Depend using the pecl/dbus extension.

PHP_Depend jumps on the D-BUS

Sometimes the parsing and analysis process of PHP_Depend can consume a lot of time to finish, so I always put the shell aside and do something different. Normally I take a look at the shell every few minutes to check if the process has finished, but it also happens that I totally forget that I have started a PHP_Depend process on my system. So I need something that says to me, "Hey, mapi PHP_Depend has finished its job...", and here comes D-BUS in the game.

With D-BUS it is really simple to send a message to a desktop notification panel, as it is available for desktop environments like Gnome or KDE. To use D-BUS in your php applications you must checkout the source code of pecl/dbus from the /svn.php.net/repository/pecl/dbus/trunk">svn repository and compile it for your php installation.

mapi@arwen ~ $ svn co http://svn.php.net/repository/pecl/dbus/trunk pecl-dbus
mapi@arwen ~ $ cd pecl-dbus
mapi@arwen pecl-dbus $ phpize
mapi@arwen pecl-dbus $ ./configure
mapi@arwen pecl-dbus $ make
mapi@arwen pecl-dbus $ sudo make install

That's it. Now you should see the --notify-me option when you open PHP_Depend's help screen.

mapi@arwen ~ $ ~/pdepend/pdepend.php --help
PHP_Depend @package_version@ by Manuel Pichler

// ... snipp ...

  --debug                   Prints debugging information.
  --help                    Print this help text.
  --version                 Print the current version.
  --notify-me               Show a notification after analysis.
  -d key[=value]            Sets a php.ini value.

Now you can add this option to your normal PHP_Depend command and it will show a notification window with the number of analyzed files and the time the process took.

mapi@arwen ~ $ ~/pdepend/pdepend.php --summary-xml=/tmp/summary.xml \
                                       --notify-me \
                                       ~/pdepend/PHP

For the moment this feature is only available through the 0.9.0 branch of PHP_Depend and not as a PEAR package.

...

Win a 52″ HD system with php|a’s new contest 18.11 15:16

PHP on Windows: give it a try—it might be worth your while

From the blatant self-promotion bin: in case you haven’t heard, php|a has a brand new contest running between now and the end of March.

The contest rules are fairly simple (despite all the legal gobbledygook): write the best PHP-on-Windows application (as judged by our panel of experts and the php|a readers) and you will be the winn...

Code Organization Dilemma 18.11 15:00

So, we have been building up our code library at dealnews for 9 years. It was started at the end of PHP3 and the beginning of PHP4. So, we did not have autoloading, static functions, and all that jazz. Classes had lots of overhead in early PHP4 so we started down a pure procedural road in 2000. And for a long time, it was very maintainable. We had 2 or 3 developers for most of this time. We now ha...

Raise the hammer! Midgard2 Mjolnir goes live 18.11 14:21

Mjolnir, the new major release of Midgard2 Content Repository is now out. Named after the hammer of Thor, this release finally provides a real content repository that can be used by both desktop and web application developers.

mjolnir-narrow.png

In addition to being a GObject-powered content repository for PHP, Python and Objective-C, the Mjolnir release provides several significant goodies on top of the older Midg...

IPC 2009 - slides and more 18.11 12:59

The IPC 2009 was amazing, even if it's still running while I write this blurb. Find my slides in this article, as well as a small resume of the conf. Thanks for the great event!

Upgrade to Fedora 12 from Fedora 11 18.11 12:56

Fedora 12 was just released and it is time to upgrade again of course. I almost thought this was going to be a version to yawn at but then I saw that there was going to be a new version of Fedora based on Moblin and it seemed exciting again. Of course that isn't the only thing being upgraded in the latest version of Fedora. Some of the more notable changes in this version:

  • Updated window managers ...

Suhosin: The Invisible Hand Of PHP 18.11 07:00

Last week, I received an email from someone who told me how the Suhosin patch had created problems for their team, and suggested that I write about it here. I thought this was a great idea, for a number of reasons. Particularly, Suhosin is one of those PHP patches that alters the way PHP operates in a fundamental fashion, yet also is installed by default in many places (for example, Ubuntu compile...

SemanticScuttle 0.94.1 17.11 22:13

Today, Benjamin finally released the security fix version 0.94.1 of my new toy, SemanticScuttle .

SemanticScuttle is a php-web-based bookmarking tool one can use to collect links and use them from every computer with internet access. Bookmarks can be public, private and shared (visible for registered users).

I needed such a tool for my personally ...

DBus notify-send over network 17.11 22:13

Last week I tried to use notify-send to notify me on my laptop when telephone calls come in. I already did that for our TV (Dreambox's /web/message?text= script) and had to have this for the computer since I'm using it more often than TV.

Since I don't use KDE anymore, any knotify tools were out of reach for me. There is a nice notify-send which communicates via DBus and has the ability to display bubbles with icons and priorities.

As I found out in IRC and mailing lists, DBus is networkable, in theory - not in practise. So the hard task was to get my remote home server to use notify-send on my laptop to display the message explicitely for me.

With DBus being not networkable, I needed a server daemon that waited for incoming notifications. Me being a web developer, apache2 is always running - no need for an own php daemon here. A simple php script waiting on my apache instance.

Getting going

The first try: A simple `/usr/bin/notify-send test`, which gave me exactly no errors and no notification. Yep, the trailing 2>&1 was missing which told me:

libnotify-Message: Unable to get session bus: dbus-launch failed to
  autolaunch D-Bus session: Autolaunch error: X11 initialization failed.

Clear as chicken soup: The apache user itself can't be notified since he doesn't have an X session. I need to notify my user, cweiske: `sudo -u cweiske /usr/bin/notify-send test 2>&1` which told me:

sudo: no tty present and no askpass program specified

That problem was quickly solved by doing a visudo and adding apache bogo = (cweiske) NOPASSWD: /usr/bin/notify-send to it. After that, I got the same error as before.

DBus itself doesn't need X11, but somehow it wants X session data - probably to display the notification. So, what do we need? ssh -Y sets $DISPLAY, that's for sure: `export DISPLAY=:0 && sudo -u cweiske /usr/bin/notify-send test 2>&1`. The result was slightly different, but no advance:

libnotify-Message: Unable to get session bus: dbus-launch failed to
  autolaunch D-Bus session: Xlib: connection to ":0.0" refused by server
  Xlib: No protocol specified
  
  Autolaunch error: X11 initialization failed.

So something X-y was still missing... as I learned from my previous CHM on Linux adventure, I need some X authorization (xauth). It's running on my laptop, but can't be found on that sudo session. After exporting $XAUTHORITY, it worked:

export DISPLAY=:0 && export XAUTHORITY=/home/cweiske/.Xauthority && sudo -u cweiske /usr/bin/notify-send test 2>&1

Now I have my notification whenever someone calls!

Screenshot of incoming call notification

And in case anyone is interested - for call notification, I use a Fritz!box USB on my home server together with a highly customized version of capiISDNmon that has been freed from the broken ldapv2-only name resolution and TCP call notification, and added script invocation on incoming calls.

...

ANSI Renderer for GeSHi 17.11 22:13

PhD, the PHP Docbook Renderer, supports multiple output formats: Xhtml, PDF and man pages. Yes, man pages. Simply install them via PEAR:

$ pear install doc.php.net/pman
 ...
$ pman functionname
 ...
$ pman classname.methodname

One thing missing in the man pages was syntax highlighted code, and yesterday while chatting with the #php.doc guys on EFnet, I decided to change that. I luckily found out that the troff format (base format used by man) supports color codes. Two minute later I had my own colored exemplary man page.

Now the smaller part of the problem was to get PhD generate syntax highlighted code in troff format. As mentioned earlier in this blog, PhD supports external syntax highlighters. My exemplary implementation was for GeSHi, so that was the first highlighter I looked at for troff code generation.

As I suspected does GeSHi support only html output. With the upcoming version 1.1.x (currently under heavy alpha-development in trunk), GeSHi supports renderers - just like PhD supports different output formats. So for starters I took the html renderer and began to modify it to become an ANSI color renderer that would display colored code to the shell.

Thanks to PEAR I was prepared to anything:

  • html_CSS to parse the CSS code generated by the GeSHi language files back into useable structures and extract color information from it.
  • Image_Color2 helped me to convert the different CSS color notations back into plain RGB.
  • Console_Color does the dirty job of generating all the ANSI control codes.

The only thing left to do for me was writing a mapper from RGB values to the limited 9 colors supported by ANSI. It turned out that to be some simple bit-shifting operations did the job, and after an hour of hacking, I had my first colored code on the shell:

GeSHi console output

After showing my screenshot around #geshi on FreeNode, I got in contact with GeSHi's current maintainer, Benny Baumann. Shortly after, my renderer was in offical SVN!

Two more hours were spent in fine-tuning the code, making it support bold font-weights and improving the rendering speed by 300%.

Now seeing that GeSHi is actually capable of everything I need, the troff renderer will be the next step. Integration into PhD is a no-brainer, and thus we should soon have colored xml and php code in the php man pages.

...
embed