/** * Show Dolibarr default login page * @param langs Lang object (must be initialized by a new). * @param conf Conf object * @param mysoc Company object */ function dol_loginfunction($langs,$conf,$mysoc) { global $dolibarr_main_demo,$db; global $smartphone; $langcode=(GETPOST('lang')?((is_object($langs)&&$langs->defaultlang)?$langs->defaultlang:'auto'):GETPOST('lang')); $langs->setDefaultLang($langcode); $langs->load("main"); $langs->load("other"); $langs->load("help"); $langs->load("admin"); $main_authentication=$conf->file->main_authentication; $session_name=session_name(); $dol_url_root = DOL_URL_ROOT; $php_self = $_SERVER['PHP_SELF']; $php_self.= $_SERVER["QUERY_STRING"]?'?'.$_SERVER["QUERY_STRING"]:''; // Title $title='Dolibarr '.DOL_VERSION; if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$conf->global->MAIN_APPLICATION_TITLE; // Select templates if (preg_match('/^smartphone/',$conf->smart_menu) && isset($conf->browser->phone)) { $template_dir = DOL_DOCUMENT_ROOT.'/theme/phones/smartphone/tpl/'; } else { if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/login.tpl.php")) { $template_dir = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/"; } else { $template_dir = DOL_DOCUMENT_ROOT."/core/tpl/"; } } $conf->css = "/theme/".$conf->theme."/style.css.php?lang=".$langs->defaultlang; $conf_css = DOL_URL_ROOT.$conf->css; // Set cookie for timeout management $prefix=dol_getprefix(); $sessiontimeout='DOLSESSTIMEOUT_'.$prefix; if (! empty($conf->global->MAIN_SESSION_TIMEOUT)) setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", '', 0); if (GETPOST("urlfrom")) $_SESSION["urlfrom"]=GETPOST("urlfrom"); else unset($_SESSION["urlfrom"]); if (! GETPOST("username")) $focus_element='username'; else $focus_element='password'; $login_background=DOL_URL_ROOT.'/theme/login_background.png'; if (file_exists(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/login_background.png')) { $login_background=DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/login_background.png'; } $demologin=''; $demopassword=''; if (! empty($dolibarr_main_demo)) { $tab=explode(',',$dolibarr_main_demo); $demologin=$tab[0]; $demopassword=$tab[1]; } // Entity cookie if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY)) { $lastuser = ''; $lastentity = $_POST['entity']; if (! empty($conf->global->MAIN_MULTICOMPANY_COOKIE)) { $prefix=dol_getprefix(); $entityCookieName = 'DOLENTITYID_'.$prefix; if (isset($_COOKIE[$entityCookieName])) { include_once(DOL_DOCUMENT_ROOT . "/core/class/cookie.class.php"); $cryptkey = (! empty($conf->file->cookie_cryptkey) ? $conf->file->cookie_cryptkey : '' ); $entityCookie = new DolCookie($cryptkey); $cookieValue = $entityCookie->_getCookie($entityCookieName); list($lastuser, $lastentity) = explode('|', $cookieValue); } } } // Login $login = (!empty($lastuser)?$lastuser:(GETPOST("username")?GETPOST("username"):$demologin)); $password = $demopassword; // Show logo (search in order: small company logo, large company logo, theme logo, common logo) $width=0; $rowspan=2; $urllogo=DOL_URL_ROOT.'/theme/login_logo.png'; if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) { $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=companylogo&file='.urlencode('thumbs/'.$mysoc->logo_small); } elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) { $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=companylogo&file='.urlencode($mysoc->logo); $width=128; } elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.png')) { $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo.png'; } // Entity field $select_entity=''; if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY) && empty($conf->global->MULTICOMPANY_HIDE_LOGIN_COMBOBOX)) { $rowspan++; $res=dol_include_once('/multicompany/class/actions_multicompany.class.php'); if ($res) { $mc = new ActionsMulticompany($db); $select_entity=$mc->select_entities($lastentity, 'tabindex="3"'); } } // Security graphical code $captcha=0; $captcha_refresh=''; if (function_exists("imagecreatefrompng") && ! empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) { $captcha=1; $captcha_refresh=img_refresh(); } // Extra link $forgetpasslink=0; $helpcenterlink=0; if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK) || empty($conf->global->MAIN_HELPCENTER_DISABLELINK)) { if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK)) { $forgetpasslink=1; } if (empty($conf->global->MAIN_HELPCENTER_DISABLELINK)) { $helpcenterlink=1; } } // Home message if (! empty($conf->global->MAIN_HOME)) { $i=0; while (preg_match('/__\(([a-zA-Z]+)\)__/i',$conf->global->MAIN_HOME,$reg) && $i < 100) { $conf->global->MAIN_HOME=preg_replace('/__\('.$reg[1].'\)__/i',$langs->trans($reg[1]),$conf->global->MAIN_HOME); $i++; } } $main_home=dol_htmlcleanlastbr($conf->global->MAIN_HOME); // Google AD $main_google_ad_client = ((! empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && ! empty($conf->global->MAIN_GOOGLE_AD_SLOT))?1:0); $dol_loginmesg = $_SESSION["dol_loginmesg"]; include($template_dir.'login.tpl.php'); // To use native PHP $_SESSION["dol_loginmesg"] = ''; }
/** * Show photos of a product (nbmax maximum) * @param sdir Directory to scan * @param size 0=original size, 1 use thumbnail if possible * @param nbmax Nombre maximum de photos (0=pas de max) * @param nbbyrow Nombre vignettes par ligne (si mode vignette) * @param showfilename 1=Show filename * @param showaction 1=Show icon with action links (resize, delete) * @param maxheight Max height of image when size=1 * @return string Html code to show photo. Number of photos shown is saved in this->nbphoto * TODO Move this into html.formproduct.class.php */ function show_photos($sdir,$size=0,$nbmax=0,$nbbyrow=5,$showfilename=0,$showaction=0,$maxheight=120) { global $conf,$user,$langs; include_once(DOL_DOCUMENT_ROOT ."/lib/files.lib.php"); include_once(DOL_DOCUMENT_ROOT ."/lib/images.lib.php"); $pdir = get_exdir($this->id,2) . $this->id ."/photos/"; $dir = $sdir . '/'. $pdir; $dirthumb = $dir.'thumbs/'; $pdirthumb = $pdir.'thumbs/'; $return ='<!-- Photo -->'."\n"; /*$return.="<script type=\"text/javascript\"> jQuery(function() { jQuery('a.lightbox').lightBox({ overlayBgColor: '#888', overlayOpacity: 0.6, imageLoading: '".DOL_URL_ROOT."/theme/eldy/img/working.gif', imageBtnClose: '".DOL_URL_ROOT."/theme/eldy/img/previous.png', imageBtnPrev: '".DOL_URL_ROOT."/theme/eldy/img/1leftarrow.png', imageBtnNext: '".DOL_URL_ROOT."/theme/eldy/img/1rightarrow.png', containerResizeSpeed: 350, txtImage: '".$langs->trans("Image")."', txtOf: '".$langs->trans("on")."', fixedNavigation:false }); }); </script>\n"; */ $nbphoto=0; $dir_osencoded=dol_osencode($dir); if (file_exists($dir_osencoded)) { $handle=opendir($dir_osencoded); if (is_resource($handle)) { while (($file = readdir($handle)) != false) { $photo=''; if (! utf8_check($file)) $file=utf8_encode($file); // To be sure file is stored in UTF8 in memory if (dol_is_file($dir.$file) && preg_match('/(\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i',$dir.$file)) { $nbphoto++; $photo = $file; $viewfilename = $file; if ($size == 1) { // Format vignette // On determine nom du fichier vignette $photo_vignette=''; if (preg_match('/(\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i',$photo,$regs)) { $photo_vignette=preg_replace('/'.$regs[0].'/i','',$photo)."_small".$regs[0]; if (! dol_is_file($dirthumb.$photo_vignette)) $photo_vignette=''; } // Get filesize of original file $imgarray=dol_getImageSize($dir.$photo); if ($nbbyrow && $nbphoto == 1) $return.= '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">'; if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) $return.= '<tr align=center valign=middle border=1>'; if ($nbbyrow) $return.= '<td width="'.ceil(100/$nbbyrow).'%" class="photo">'; $return.= "\n"; $return.= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdir.$photo).'" class="lightbox" target="_blank">'; // Show image (width height=$maxheight) // Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine $alt=$langs->transnoentitiesnoconv('File').': '.$pdir.$photo; $alt.=' - '.$langs->transnoentitiesnoconv('Size').': '.$imgarray['width'].'x'.$imgarray['height']; if ($photo_vignette && $imgarray['height'] > $maxheight) { $return.= '<!-- Show thumb -->'; $return.= '<img class="photo" border="0" height="'.$maxheight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdirthumb.$photo_vignette).'" title="'.dol_escape_htmltag($alt).'">'; } else { $return.= '<!-- Show original file -->'; $return.= '<img class="photo" border="0" height="'.$maxheight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">'; } $return.= '</a>'."\n"; if ($showfilename) $return.= '<br>'.$viewfilename; if ($showaction) { $return.= '<br>'; // On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites if ($photo_vignette && preg_match('/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i',$photo) && ($product->imgWidth > $maxWidth || $product->imgHeight > $maxHeight)) { $return.= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&action=addthumb&file='.urlencode($pdir.$viewfilename).'">'.img_refresh($langs->trans('GenerateThumb')).' </a>'; } if ($user->rights->produit->creer || $user->rights->service->creer) { // Link to resize $return.= '<a href="'.DOL_URL_ROOT.'/core/photos_resize.php?modulepart='.urlencode('produit|service').'&id='.$_GET["id"].'&file='.urlencode($pdir.$viewfilename).'" title="'.dol_escape_htmltag($langs->trans("Resize")).'">'.img_picto($langs->trans("Resize"),DOL_URL_ROOT.'/theme/common/transform-crop-and-resize','',1).'</a> '; // Link to delete $return.= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&action=delete&file='.urlencode($pdir.$viewfilename).'">'; $return.= img_delete().'</a>'; } } $return.= "\n"; if ($nbbyrow) $return.= '</td>'; if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) $return.= '</tr>'; } if ($size == 0) { // Format origine $return.= '<img class="photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdir.$photo).'">'; if ($showfilename) $return.= '<br>'.$viewfilename; if ($showaction) { if ($user->rights->produit->creer || $user->rights->service->creer) { // Link to resize $return.= '<a href="'.DOL_URL_ROOT.'/core/photos_resize.php?modulepart='.urlencode('produit|service').'&id='.$_GET["id"].'&file='.urlencode($pdir.$viewfilename).'" title="'.dol_escape_htmltag($langs->trans("Resize")).'">'.img_picto($langs->trans("Resize"),DOL_URL_ROOT.'/theme/common/transform-crop-and-resize','',1).'</a> '; // Link to delete $return.= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&action=delete&file='.urlencode($pdir.$viewfilename).'">'; $return.= img_delete().'</a>'; } } } // On continue ou on arrete de boucler ? if ($nbmax && $nbphoto >= $nbmax) break; } } } if ($nbbyrow && $size==1) { // Ferme tableau while ($nbphoto % $nbbyrow) { $return.= '<td width="'.ceil(100/$nbbyrow).'%"> </td>'; $nbphoto++; } if ($nbphoto) $return.= '</table>'; } closedir($handle); } $this->nbphoto = $nbphoto; return $return; }
$entityCookieName = 'DOLENTITYID_'.$prefix; if (isset($_COOKIE[$entityCookieName])) { include_once(DOL_DOCUMENT_ROOT . "/core/class/cookie.class.php"); $cryptkey = (! empty($conf->file->cookie_cryptkey) ? $conf->file->cookie_cryptkey : '' ); $entityCookie = new DolCookie($cryptkey); $cookieValue = $entityCookie->_getCookie($entityCookieName); list($lastuser, $lastentity) = explode('|', $cookieValue); } } $res=dol_include_once('/multicompany/class/actions_multicompany.class.php'); if ($res) { $mc = new ActionsMulticompany($db); $select_entity = $mc->select_entities($lastentity,'tabindex="2"'); } } // Security graphical code if (function_exists("imagecreatefrompng") && ! $disabled) { $captcha = 1; $captcha_refresh = img_refresh(); } include($template_dir.'passwordforgotten.tpl.php'); // To use native PHP ?>
// Taille de l'image $object->get_image_size($dir.$filename); $imgWidth = ($object->imgWidth < $maxWidth) ? $object->imgWidth : $maxWidth; $imgHeight = ($object->imgHeight < $maxHeight) ? $object->imgHeight : $maxHeight; print '<img border="0" width="'.$imgWidth.'" height="'.$imgHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=categorie&file='.urlencode($pdir.$filename).'">'; print '</a>'; print '<br>'.$viewfilename; print '<br>'; // On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites if (!$obj['photo_vignette'] && preg_match('/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i',$obj['photo']) && ($object->imgWidth > $maxWidth || $object->imgHeight > $maxHeight)) { print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&action=addthumb&type='.$type.'&file='.urlencode($pdir.$viewfilename).'">'.img_refresh($langs->trans('GenerateThumb')).' </a>'; } if ($user->rights->categorie->creer) { print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&action=delete&type='.$type.'&file='.urlencode($pdir.$viewfilename).'">'; print img_delete().'</a>'; } if ($nbbyrow) print '</td>'; if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) print '</tr>'; } // Ferme tableau while ($nbphoto % $nbbyrow) { print '<td width="'.ceil(100/$nbbyrow).'%"> </td>'; $nbphoto++;