Fix: Fix some bugs. There still a lot of new bugs to fix (like compatibility through proxy, or restore performance by avoiding huge number of file_exists).

This commit is contained in:
Laurent Destailleur 2010-12-19 18:05:38 +00:00
parent a9436e521b
commit 9a0de89827
6 changed files with 52 additions and 28 deletions

View File

@ -105,7 +105,12 @@ class box_bookmarks extends ModeleBoxes {
$i++; $i++;
} }
if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center" colspan="2"', 'url'=> DOL_URL_ROOT.'/bookmarks/liste.php', 'text'=>$langs->trans("NoRecordedBookmarks")); if ($num==0)
{
$mytxt=$langs->trans("NoRecordedBookmarks");
if ($user->rights->bookmark->creer) $mytxt.=' '.$langs->trans("ClickHereToAdd");
$this->info_box_contents[$i][0] = array('td' => 'align="center" colspan="2"', 'url'=> DOL_URL_ROOT.'/bookmarks/liste.php', 'text'=>$mytxt);
}
} }
else else
{ {

View File

@ -63,7 +63,7 @@ function print_auguria_menu($db,$atarget,$type_user)
} }
else else
{ {
dol_file_exists($tabMenu[$i]['url'],1); $url=dol_file_exists($tabMenu[$i]['url'],1);
if (! preg_match('/\?/',$url)) $url.='?'; if (! preg_match('/\?/',$url)) $url.='?';
else $url.='&'; else $url.='&';
if (! preg_match('/mainmenu/i',$url) || ! preg_match('/leftmenu/i',$url)) if (! preg_match('/mainmenu/i',$url) || ! preg_match('/leftmenu/i',$url))
@ -275,7 +275,7 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after)
} }
// Add mainmenu in GET url. This make to go back on correct menu even when using Back on browser. // Add mainmenu in GET url. This make to go back on correct menu even when using Back on browser.
dol_files_exists($menu_array[$i]['url'],1); $url=dol_file_exists($menu_array[$i]['url'],1);
if (! preg_match('/mainmenu=/i',$menu_array[$i]['url'])) if (! preg_match('/mainmenu=/i',$menu_array[$i]['url']))
{ {

View File

@ -44,7 +44,8 @@ BoxTitleTotalUnpaidSuppliersBills=Unpaid supplier's invoices
BoxMyLastBookmarks=My last %s bookmarks BoxMyLastBookmarks=My last %s bookmarks
FailedToRefreshDataInfoNotUpToDate=Failed to refresh RSS flux. Last successfull refresh date: %s FailedToRefreshDataInfoNotUpToDate=Failed to refresh RSS flux. Last successfull refresh date: %s
LastRefreshDate=Last refresh date LastRefreshDate=Last refresh date
NoRecordedBookmarks=No bookmarks defined. Click <a href="%s">here</a> to add bookmarks. NoRecordedBookmarks=No bookmarks defined.
ClickToAdd=Click here to add.
NoRecordedCustomers=No recorded customers NoRecordedCustomers=No recorded customers
BoxTitleLastActionsToDo=Last %s actions to do BoxTitleLastActionsToDo=Last %s actions to do
BoxTitleLastContracts=Last %s contracts BoxTitleLastContracts=Last %s contracts

View File

@ -44,7 +44,8 @@ BoxTitleTotalUnpaidSuppliersBills=Impayés fournisseurs
BoxMyLastBookmarks=Mes %s derniers marque-pages BoxMyLastBookmarks=Mes %s derniers marque-pages
FailedToRefreshDataInfoNotUpToDate=Échec du rafraichissement du flux RSS. Date du dernier rafraichissement: %s FailedToRefreshDataInfoNotUpToDate=Échec du rafraichissement du flux RSS. Date du dernier rafraichissement: %s
LastRefreshDate=Date dernier rafraichissement LastRefreshDate=Date dernier rafraichissement
NoRecordedBookmarks=Pas de bookmarks personnels. Cliquer ici pour en ajouter. NoRecordedBookmarks=Pas de bookmarks personnels.
ClickToAdd=Cliquer ici pour ajouter.
NoRecordedCustomers=Pas de client enregistré NoRecordedCustomers=Pas de client enregistré
BoxTitleLastActionsToDo=Les %s dernières actions à faire BoxTitleLastActionsToDo=Les %s dernières actions à faire
BoxTitleLastContracts=Les %s derniers contrats BoxTitleLastContracts=Les %s derniers contrats

View File

@ -87,30 +87,41 @@ function dol_require_once($relpath)
// Forced to use file_exists otherwise there is a blank page // Forced to use file_exists otherwise there is a blank page
//$res=@require_once(DOL_DOCUMENT_ROOT.$relpath); //$res=@require_once(DOL_DOCUMENT_ROOT.$relpath);
//if (! $res && defined('DOL_DOCUMENT_ROOT_ALT')) $res=@require_once(DOL_DOCUMENT_ROOT_ALT.$relpath); //if (! $res && defined('DOL_DOCUMENT_ROOT_ALT')) $res=@require_once(DOL_DOCUMENT_ROOT_ALT.$relpath);
$res=@require_once(dol_file_exists($relpath)); $res=require_once(dol_file_exists($relpath));
return $res; return $res;
} }
/** /**
* Make an file_exists using default root and alternate root if it fails. * Return path of url or filesystem. Return default_root or alternate root if file_exist fails.
* TODO Rename function into dol_buildpath
* @param path Relative or absolute path to file (Ie: mydir/myfile, ../myfile, ...) * @param path Relative or absolute path to file (Ie: mydir/myfile, ../myfile, ...)
* @return int Result * @param mode 0=Used for a Filesystem path, 1=Used for an URL path
* @return string Full filsystem path (if mode=0), Relative url path (if mode=1)
*/ */
function dol_file_exists($path,$absolute=0) function dol_file_exists($path,$mode=0)
{ {
$res=false; if (empty($mode)) // For a filesystem path
if ($absolute)
{ {
preg_match('/^([^<]+\.php)/i',$path,$regs); $res = DOL_DOCUMENT_ROOT.$path; // Standard value
$res=DOL_URL_ROOT.$path; if (defined('DOL_DOCUMENT_ROOT_ALT') && DOL_DOCUMENT_ROOT_ALT) // We check only if alternate feature is used
if (defined('DOL_URL_ROOT_ALT') && ! file_exists(DOL_DOCUMENT_ROOT.$regs[1])) $res=DOL_URL_ROOT_ALT.$path; {
if (! file_exists(DOL_DOCUMENT_ROOT.$path)) $res = DOL_DOCUMENT_ROOT_ALT.$path;
}
} }
else else // For an url path
{ {
$res = DOL_DOCUMENT_ROOT.$path; $res = DOL_URL_ROOT.$path; // Standard value
if (defined('DOL_DOCUMENT_ROOT_ALT') && ! file_exists(DOL_DOCUMENT_ROOT.$path)) $res = DOL_DOCUMENT_ROOT_ALT.$path; if (defined('DOL_URL_ROOT_ALT') && DOL_URL_ROOT_ALT) // We check only if alternate feature is used
{
// We try to get local path of file on filesystem from url
// FIXME Trying to know if a file on disk exist by forging path on disk from url
// works only for some web server and some setup. This is bugged when
// using proxy, rewriting, virtual path, etc...
preg_match('/^([^<]+\.php)$/i',$path,$regs); // Why a "<" char ?
if (! empty($regs[1])) $path = $regs[1];
if (! file_exists(DOL_DOCUMENT_ROOT.$path)) $res = DOL_URL_ROOT_ALT.$path;
}
} }
return $res; return $res;

View File

@ -32,6 +32,7 @@ define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
require("../../main.inc.php"); require("../../main.inc.php");
$langs->load("main"); $langs->load("main");
$langs->load("install");
$langs->load("other"); $langs->load("other");
// Security check // Security check
@ -228,16 +229,21 @@ foreach ($demoprofiles as $profilarray)
{ {
$url=$_SERVER["PHP_SELF"].'?action=gotodemo&amp;urlfrom='.urlencode($_SERVER["PHP_SELF"]); $url=$_SERVER["PHP_SELF"].'?action=gotodemo&amp;urlfrom='.urlencode($_SERVER["PHP_SELF"]);
$urlwithmod=$url.'&amp;demochoice='.$profilarray['key']; $urlwithmod=$url.'&amp;demochoice='.$profilarray['key'];
// Should work with DOL_URL_ROOT='' or DOL_URL_ROOT='/dolibarr'
//print "xx".$_SERVER["PHP_SELF"].' '.DOL_URL_ROOT.'<br>';
$urlfrom=preg_replace('/^'.preg_quote(DOL_URL_ROOT,'/').'/i','',$_SERVER["PHP_SELF"]);
//print $urlfrom;
//if ($i % $NBOFCOLS == 0) print '<tr>'; //if ($i % $NBOFCOLS == 0) print '<tr>';
print '<tr>'; print '<tr>';
print '<td>'."\n"; print '<td>'."\n";
print '<form method="POST" name="form'.$profilarray['key'].'" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" name="form'.$profilarray['key'].'" action="'.$_SERVER["PHP_SELF"].'">'."\n";
print '<input type="hidden" name="action" value="gotodemo">'; print '<input type="hidden" name="action" value="gotodemo">'."\n";
print '<input type="hidden" name="urlfrom" value="'.urlencode($_SERVER["PHP_SELF"]).'">'; print '<input type="hidden" name="urlfrom" value="'.urlencode($urlfrom).'">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'."\n";
print '<input type="hidden" name="username" value="demo">'; print '<input type="hidden" name="username" value="demo">'."\n";
print '<table summary="Dolibarr online demonstration for profile '.$profilarray['label'].'" style="font-size:14px;" width="100%" class="CTableRow'.($i%2==0?'1':'2').'">'."\n"; print '<table summary="Dolibarr online demonstration for profile '.$profilarray['label'].'" style="font-size:14px;" width="100%" class="CTableRow'.($i%2==0?'1':'1').'">'."\n";
print '<tr>'; print '<tr>';
print '<td width="50"><a href="'.$urlwithmod.'" id="a1'.$profilarray['key'].'" class="modulelineshow"><img src="'.$profilarray['icon'].'" width="48" border="0" alt="Demo '.$profilarray['label'].'"></a></td>'; print '<td width="50"><a href="'.$urlwithmod.'" id="a1'.$profilarray['key'].'" class="modulelineshow"><img src="'.$profilarray['icon'].'" width="48" border="0" alt="Demo '.$profilarray['label'].'"></a></td>';
//print '<td><input type="radio" name="demochoice"'; //print '<td><input type="radio" name="demochoice"';
@ -346,9 +352,9 @@ function llxHeaderVierge($title, $head = "")
print "<title>".$title."</title>\n"; print "<title>".$title."</title>\n";
print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/theme/eldy/style.css.php?lang='.$langs->defaultlang.'">'."\n"; print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/theme/eldy/style.css.php?lang='.$langs->defaultlang.'">'."\n";
print '<!-- Includes for JQuery -->'."\n"; print '<!-- Includes for JQuery -->'."\n";
print '<script type="text/javascript" src="/includes/jquery/js/jquery-latest.min.js"></script>'."\n"; print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery-latest.min.js"></script>'."\n";
print '<script type="text/javascript" src="/includes/jquery/js/jquery-ui-latest.custom.min.js"></script>'."\n"; print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery-ui-latest.custom.min.js"></script>'."\n";
print '<script type="text/javascript" src="/includes/jquery/plugins/tablednd/jquery.tablednd_0_5.js"></script>'."\n"; print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/tablednd/jquery.tablednd_0_5.js"></script>'."\n";
if ($head) print $head."\n"; if ($head) print $head."\n";
print '<style type="text/css">'; print '<style type="text/css">';
print '.CTableRow1 { margin: 1px; padding: 3px; font: 12px verdana,arial; background: #e6E6eE; color: #000000; -moz-border-radius-topleft:6px; -moz-border-radius-topright:6px; -moz-border-radius-bottomleft:6px; -moz-border-radius-bottomright:6px;}'; print '.CTableRow1 { margin: 1px; padding: 3px; font: 12px verdana,arial; background: #e6E6eE; color: #000000; -moz-border-radius-topleft:6px; -moz-border-radius-topright:6px; -moz-border-radius-bottomleft:6px; -moz-border-radius-bottomright:6px;}';