I am NOT a PHP programmer.
With that said, I have spent a LOT of time looking at source code, and I think the bulk of the problems are with relative vs. absolute path names on the Windows platform.
I started by reading this excellent blog post on paths and Apache vs. IIS:
Finding the document root in PHPThen, I made the following changes to the source code:
//File: /installer/index.php
//{near the top of the file}
//changed this line:
define('INSTALL_PATH', realpath(dirname(__FILE__) . '/../').'/');
//to this:
define('INSTALL_PATH', 'C:/PathToRoundcube/wwwroot/');
This change allows INSTALL_PATH to correctly be defined as the absolute path to the web on the server. This allows the installer to run while referencing the correct folder(s) internally.
With this change, I was able to successfully run the installer and test SMTP and IMAP functionality.
Then, I made these changes:
//File: /program/include/iniset.php
//{near the top of the file}
//changed this line:
define('INSTALL_PATH', dirname($_SERVER['SCRIPT_FILENAME']).'/');
//to this:
define('INSTALL_PATH', 'C:/PathToRoundcube/wwwroot/');
This change performs the same function as the change above performed for the installer.
//File: /program/include/rcube_html_page.php
//{in function include_script}
//changed this line:
$file = $this->scripts_path . $file . (($fs = @filemtime($this->scripts_path . $file)) ? '?s='.$fs : '');
//to this:
$file = $this->scripts_path . $file . (($fs = @filemtime(INSTALL_PATH . $this->scripts_path . $file)) ? '?s='.$fs : '');
This change is necessary because @filemtime expects an absolute path (at least, on Windows). This allows RC to accurately get the file information for the Javascript file being included.
//File: /program/include/rcube_html_page.php
//{in function file_callback}
//changed this if statement:
if (preg_match('/\.(js|css)$/', $file))
$file .= '?s=' . @filemtime($file);
//to this:
if (preg_match('/\.(js|css)$/', $file))
$file .= '?s=' . @filemtime(INSTALL_PATH . $file);
This change basically matches the change above so that the script callbacks match the script(s) included from function include_script.
//File: /program/include/rcube_template.php
//{in function template_exists}
//changed this line:
$filename = $this->config['skin_path'] . '/templates/' . $name . '.html';
//to this:
$filename = INSTALL_PATH . $this->config['skin_path'] . '/templates/' . $name . '.html';
This change allows the code that follows in the function to determine if the actual absolute filename actually exists. (On Windows, the is_file and is_readable function calls return false if fed relative filenames).
//File: /program/include/rcube_template.php
//{in function parse}
//changed this line:
$path = "$skin_path/templates/$name.html";
//to this line:
$path = INSTALL_PATH . "$skin_path/templates/$name.html";
This change by itself basically eliminates the 501 error because the code that follows this statement tries to include the file named here, but on Windows this file can't be read with a relative filename. This change makes the filename absolute.
//File: /program/include/rcube_template.php
//{in function xml_command, under the switch/case for 'include'}
//changed this line:
$path = realpath($this->config['skin_path'].$attrib['file']);
//to this line:
$path = INSTALL_PATH . $this->config['skin_path'].$attrib['file'];
This change allows the following call to is_readable to succeed by examining the absolute filename.
I have no idea what effect, if any, these changes would have on an Apache platform, but it would appear that they would continue to let the program function as expected. I would hope the programmers who are working on this project would consider making sufficient changes to the program to allow it to run on the Windows platform with IIS, as it would only open up this great software to a wider user base.
With the above changes, I can successfully load the skin and login to my hMailserver. I get the rough appearance of the mail window after logging in. However, I still don't see any messages, and navigating to the address book and/or settings screens doesn't cause any information to appear. Obviously, there are some additional changes within the source code that are needed to get everything to function correctly, but I don't know what else to look for. Perhaps someone who is more familiar with the inner workings of RoundCube can point me in the right direction?
By the way, I upgraded to the 0.4 STABLE version of RoundCube today and had the same results as with the 0.4 beta version.