Posted by & filed under Web 2.0.

I found this article in eWeek really interesting:

Midmarket Digital Asset Management Firms Disappearing

Companies are drowning in content they generate, usually with no way to organize it. Furthermore, as the article states, there is less and less support for SMBs, who can’t spend a fortune on software. Normally new firms would enter the market and provide solutions for such needs – but the problem is that demand for such tools is low, because few businesses realize the need for such solutions until its too late.

What is the solution? Opensource? That usually requires a lot of expertiese in running & customizing, and few SMBs can dedicate the resources required. Outsourcing? The price tag might be even higher than the enterprise tools…

We’ll have to see.

Posted by & filed under TYPO3.

This took me some time to analyze, so I thought I would post it to save time to anyone faced with the same problem.

TYPO3 handles timezones, making sure that whatever input it gets is timezone-aware, both server-side, and client-side. Any input in TCEforms that is set to be evaluated as a datetime must be in GMT. TYPO3 backend automatically converts the timestamps based on client timezone before submitting the date. So if one user is in timezone GMT+1, and another is in GMT-5, and they insert a new record simultaneously, the timestamp in the DB will be the same.

TYPO3 then offsets the timestamp by the server offset. When presenting the result to the user, the timestamp is converted to user’s timezone.

Side note: I tested this in the back end – but I need to check the front end. I would assume it displays the time in server’s timezone. If not, it would be interesting how it works with caching…

When inserting records through the TCE, a time() function is not enough. Due to the processing described above, you must offset your timestamp by the timezone difference with GMT, even if you’re inserting it server side, on the same server that you’re storing it on. You can do it by:
$data[$table][$uid]['datetime'] = intval($data[$table][$uid]['datetime']) + ($GLOBALS['TYPO3_CONF_VARS']['SYS']['serverTimeZone'] * 3600);
This assumes serverTimeZone has been set correctly in the TYPO3 configuration.

Posted by & filed under Programming.

The new version of the greatest PHP IDE is officially out!! Here is the official list of key features:

PHP Debugging enhancements

  • Settings Wizard provides an easy to use, simple UI to help you start debug PHP scripts in any environment
  • Support for multiple Parallel debugging sessions. You can debug multiple PHP Scripts simultaneously and switch between debugging sessions using View->Debug windows->Debug sessions:
  • Support for the debugging of nested calls (PHP Scripts calling PHP Script)
  • Support for debugging of PHP CLI scripts

New CSS and PHP editing tools

  • CSS code navigator. New CSS mode is added to PhpED’s Code Navigator. Clicking on the elements of CSS tree places the cursor on the corresponding line of CSS code, making CSS editing really easy. Learn more about CSS Code Navigator
  • CSS Preview. Added by popular demand, CSS Preview feature lets you see how your CSS elements are displayed in the browser while you are editing the file in the Editor. Learn more about CSS Preview
  • CSS Code Folding. PhpED users have long enjoyed state of the art PHP Code Completion and other PHP Editor Tools provided in the IDE. CSS Code Folding and Code completion enables the same functionality for CSS files. PhpED Code Folding automatically detects and marks CSS Elements and allows you to mark and collapse any part of the text in the Editor. Learn more about CSS Code Folding and Code completion in PhpED 5.6!
  • Added by popular request: triple click is used for line selection, if double click selects a word. You can also start selection with double click, similar to Notepad.

Posted by & filed under TYPO3.

TYPO3 has a table for backend users. Those users need to occasionally upload files to the fileadmin directory via FTP. Wouldn’t it be nice to configure the FTP server to pull from the be_users table and authenticate them, so that two separate locations for userdata don’t have to be maintained?

It’s possible. This guide documents how I was able to set up FTP on a Debian Linux server running TYPO3 4.2. Our TYPO3 installation uses MySQL 5.0 DB.

My FTP server of choice was pure-ftpd. Fortunately this server has MySQL authentication capabilities, they just had to be set up.

apt-get install pure-ftpd-common pure-ftpd-mysql

This will remove plain old pure-ftpd package if you have it, and install the MySQL enabled version, that can use a MySQL DB to authenticate users against.

Next step is to set up the configuration, so edit /etc/pure-ftpd/db/mysq.conf. You need to set some configuration variables:

  • MYSQLServer: Point it to your MySQL server IP, or localhost
  • MYSQLUser: DB username
  • MYSQLPassword: DB password
  • MYSQLCrypt: TYPO3 encodes be_users passwords with md5
  • MYSQLGetPW: This query authenticates the user. Here is how I set it up:
    SELECT password FROM be_users WHERE username="\L" AND LEFT(username, 1) != '_' AND deleted=0
    In the first where clause, \L is replaced by the username of a user who is trying to login. The second clause is for security reasons – backend processes running as scheduled tasks require users with a prefix “_” (usually “_cli”). This clause prevents them from being awarded FTP access automatically. Third clause, of course, prevents deleted users from logging in.
  • MYSQLDefaultUID: since each TYPO3 user might not necessarily have a user account on the server, its better to set the default UID of the file owner here.
  • MYSQLDefaultGID: same as above, set the user group.
  • MYSQLGetDir: This is a fun one. As you may know, TYPO3 has file mounts for users and groups, which restrict the user to a certain folder. We would want to restrict the user to the same folder, right?
    The disadvantage of the code below is that 1) it requires relative filemounts 2) it ignores multiple filemounts and 3) it only allows one usergroup per user. If a user has several filemounts selected this query will fail, and the user will be denied FTP access. This is a problem I was not able to resolve yet.
  • SELECT CONCAT('/srv/ftp',file.path) AS Dir
    FROM be_users as user
    JOIN be_groups as ugroup ON user.usergroup=ugroup.uid
    JOIN sys_filemounts as file ON user.file_mountpoints=file.uid OR ugroup.file_mountpoints=file.uid
    WHERE user.username="\L" LIMIT 1

The manual documents other options quite well.

Next I tried to connect to FTP, but got an error: ‘Can’t exec /usr/sbin/pure-ftpd’. I had to modify /usr/sbin/pure-ftpd-wrapper to call pure-ftpd-mysql instead of pure-ftpd. This may be different depending on which package you install.

You would also want to secure the FTP by limiting the users to their respective directory. This can be done by creating a file /etc/pure-ftpd/conf/ChrootEveryone with content ‘yes’. Now when they login, they will have access only to their file-mounted folder.

So at this point everything should work. Nothing ever works as planned though, but pure-ftpd writes log messages to syslog, so go there to pinpoint the problem in your installation.

Posted by & filed under Programming.

After upgrading a Debian server to use mod_fcgid to run PHP instead of mod_php, I started seeing Internal Server Errors on some pages. Apache Error log had the following:
[error] Premature end of script headers: index.php

I haven’t seen messages this useless since my days of coding in Perl! I realized it must be an issue of timeout, since the message appeared after some loading time. Using the following resource, I changed fcgid.conf in /etc/apache2/mods_available directory, adding:
BusyTimeout 256
ProcessLifeTime 256
IPCConnectTimeout 60
IPCCommTimeout 256

This let the script run longer, allowing it to finish, and release the output to the browser. If it doesn’t work for you, increase the values until it does.