Author Topic: Error loading template - looking in installer directory  (Read 19256 times)

Offline WHairstonLOI

  • Jr. Member
  • **
  • Posts: 14
Partial Success!!!
« Reply #30 on: August 07, 2010, 11:47:16 PM »
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 PHP

Then, 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.

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,876
    • SKaero - Custom Roundcube development
Error loading template - looking in installer directory
« Reply #31 on: August 08, 2010, 12:36:37 AM »
Quote from: WHairstonLOI;29199

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.

RoundCube does work on Windows and ISS I know several who are running just fine and don't have this problem.

Quote from: WHairstonLOI;29199

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?

Is there anything in your error log, and can you enable $rcmail_config['imap_debug'] in /config/main.inc.php

Offline WHairstonLOI

  • Jr. Member
  • **
  • Posts: 14
The Missing Piece!
« Reply #32 on: August 08, 2010, 12:42:51 AM »
Shortly after my previous post, I found the two changes that needed to be made to get everything visible on Windows/IIS:


//File: /index.php
//{near the bottom under the comment: "include task specific functions"}
//changed this line:
if (is_file($incfile 'program/steps/'.$RCMAIL->task.'/func.inc'))

//to this:
if (is_file($incfile INSTALL_PATH 'program/steps/'.$RCMAIL->task.'/func.inc'))

This change allows the correct function file to be included.


//File: /index.php
//{near the bottom under the comment: "include task specific functions"}
//changed this line:
else if (is_file($incfile 'program/steps/'.$RCMAIL->task.'/'.$stepfile)) {

//to this:
else if (is_file($incfile INSTALL_PATH 'program/steps/'.$RCMAIL->task.'/'.$stepfile)) {

This change allows the correct step file to be included.

With these changes, I can see everything I couldn't see before (messages, address options, etc.)

Offline WHairstonLOI

  • Jr. Member
  • **
  • Posts: 14
Error loading template - looking in installer directory
« Reply #33 on: August 08, 2010, 01:02:50 AM »
Quote from: skaero;29200
RoundCube does work on Windows and ISS I know several who are running just fine and don't have this problem.


I will be the first to admit that I'm a total n00b when it comes to PHP, but I can only tell you what worked for me on a new, clean Windows Server 2008 with a new, clean installation of Roundcube 0.4. I'd guess there are probably others like me who just gave up after seeing the initial failure and seeing that Windows/IIS is not an officially supported platform.

I suppose it's possible that there's a global PHP or RoundCube setting somewhere that could be changed to make my code edits unnecessary, but nobody here has been willing/able to point that out as of yet.

For what it's worth, there are numerous SQL errors in the MS SQL script that creates the initial database as well (I'm using SQL Server 2008 R2 Express Edition) - I also had to fix them by hand, but fortunately, that's a platform I'm fairly familiar with.

Offline alec

  • Hero Member
  • *****
  • Posts: 1,363
Error loading template - looking in installer directory
« Reply #34 on: August 08, 2010, 03:35:43 AM »
Quote from: WHairstonLOI;29202

For what it's worth, there are numerous SQL errors in the MS SQL script that creates the initial database as well (I'm using SQL Server 2008 R2 Express Edition) - I also had to fix them by hand, but fortunately, that's a platform I'm fairly familiar with.


What errors? You should open a ticket in Roundcube's bagtucker.

Offline WHairstonLOI

  • Jr. Member
  • **
  • Posts: 14
Error loading template - looking in installer directory
« Reply #35 on: August 09, 2010, 12:33:53 PM »
Quote from: alec;29203
What errors? You should open a ticket in Roundcube's bagtucker.


As the MS SQL script is shipped, it throws a couple of errors related to the TEXTIMAGE_ON clause, which causes some of the tables not to be created. There are also several foreign keys which don't get created because only the column names from one table are specified.

I'll write these up in more detail and submit the corrections to the "bagtucker" as soon as I can get some free time.