dolibarr-bugtrack
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dolibarr-bugtrack] [Bug #1072] Wrong DOL_URL_ROOT value calculated


From: Doliforge
Subject: [Dolibarr-bugtrack] [Bug #1072] Wrong DOL_URL_ROOT value calculated
Date: Thu, 19 Sep 2013 12:14:21 +0200

Doliforge
Ce message ne s'affiche pas correctement?
mettez à jour vos préférences utilisateur.

Wrong DOL_URL_ROOT value calculated

État

 Détails
Submitted by:  Anthony SKRZYPCZYK (anthony.skrzypczyk) Submitted on:  19/09/2013 12:14
Last Modified On:  19/09/2013 12:14 
Summary:  Wrong DOL_URL_ROOT value calculated
Description:  During first execution after first installation, no ressources (images, css, js) was found in the page, caused by wrong DOL_URL_ROOT value.

HTTPD server : Lighttpd 1.4.31

Configuration:
$dolibarr_main_url_root='http://www.colinky.com/dolibarr';
$dolibarr_main_document_root='/home/colinky/web/dolibarr/htdocs';


Problem located on filefunc.inc.php - line 152 to 177


foreach($paths as $tmppath) // We check to find (B+start of C)=A
{
if ($tmppath) $concatpath.='/'.$tmppath;
print $_SERVER["DOCUMENT_ROOT"] . "@" . $tmppath . "*" . $_SERVER["SCRIPT_NAME"].'-'.$pathroot.'-'.$concatpath.'-'.$real_dolibarr_main_document_root.'-'.realpath($pathroot.$concatpath).'<br>';
if ($real_dolibarr_main_document_root == @realpath($pathroot.$concatpath)) // @ avoid warning when safe_mode is on.
{
$tmp3=$concatpath;
$found=1;
break;
}
//else print "Not found yet for concatpath=".$concatpath."<br>\n";
}



When I go to http://www.colinky.com/dolibarr/admin/index.php :

$paths = $_SERVER["SCRIPT_NAME"] = "/dolibarr/admin/index.php"
When splitted we have :
Array
(
[0] =>
[1] => dolibarr
[2] => admin
[3] => index.php
)

During first foreach iteration:
- $tmppath = ''
- $concatpath = ''
- $real_dolibarr_main_document_root = "/home/colinky/web/dolibarr/htdocs"
- $pathroot = $_SERVER["DOCUMENT_ROOT"] = "/home/colinky/web/dolibarr/htdocs"
- @realpath($pathroot.$concatpath) returns "/home/colinky/web/dolibarr/htdocs"

Path is detected as found but :
- $tmp3 = $concatpath = ''
- $found = 1


After we calculate $tmp :

if (! $found) $tmp=$dolibarr_main_url_root; // If autodetect fails (Ie: when using apache alias that point outside default DOCUMENT_ROOT.
else $tmp='http'.(((empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != 'on') && (empty($_SERVER["SERVER_PORT"])||$_SERVER["SERVER_PORT"]!=443))?'':'s').'://'.$_SERVER["SERVER_NAME"].((empty($_SERVER["SERVER_PORT"])||$_SERVER["SERVER_PORT"]==80||$_SERVER["SERVER_PORT"]==443)?'':':'.$_SERVER["SERVER_PORT"]).($tmp3?(preg_match('/^\//',$tmp3)?'':'/').$tmp3:'');
//print "tmp1=".$tmp1." tmp2=".$tmp2." tmp3=".$tmp3." tmp=".$tmp;
if (! empty($dolibarr_main_force_https)) $tmp=preg_replace('/^http:/i','https:',$tmp);
define('DOL_MAIN_URL_ROOT', $tmp); // URL absolute root (https://sss/dolibarr, ...)

DOL_MAIN_URL_ROOT = $tmp = 'http://www.colinky.com' (because $tmp3 is empty)


We calculate relative root :

$uri=preg_replace('/^http(s?):\/\//i','',constant('DOL_MAIN_URL_ROOT')); // $uri contains url without http*
$suburi = strstr($uri, '/'); // $suburi contains url without domain
if ($suburi == '/') $suburi = ''; // If $suburi is /, it is now ''
define('DOL_URL_ROOT', $suburi); // URL relative root ('', '/dolibarr', ...)


So finally :
DOL_URL_ROOT = ''


Which is wrong in my case. Results on HTML content :

<script type="text/_javascript_" src="" /> <script type="text/_javascript_" src="" /> <script type="text/_javascript_" src="" /> <script type="text/_javascript_" src="" />

Instead of :

<script type="text/_javascript_" src="" /> <script type="text/_javascript_" src="" /> <script type="text/_javascript_" src="" /> <script type="text/_javascript_" src="" />



Temporary workaround for Colinky :
Force $found = 0 after the foreach loop.
Step to reproduce bug:  Basic installation on Debhian 7 / Lighttpd 1.4.31 (debian package) / PHP 5.4.4 (debian package)
Version:  3.4.0 Category:  Core Problem
Severity:  5 - Major OS Type/Version:  Debian 7 Wheezy
PHP version:  5.4.4 Database type and version:  MySQL 5.5.31
 Etat
Status:  Open Assigned to:  Aucun
Resolution:  Aucun 

Répondre



reply via email to

[Prev in Thread] Current Thread [Next in Thread]