Source for file site_information.class.php

Documentation is available at site_information.class.php

  1. <?php   /*
  2.    *@=@=@=@ START LICENSE @=@=@=@*
  3.    Copyright or © or Copr. Stéphane TRICHET and Nicolas SOTRON
  4.    
  5.    stephane.t@simpliciweb.net and nicolas.s@simpliciweb.net
  6.    
  7.    This software is a computer program whose purpose is to make a
  8.    web hosting platform
  9.    
  10.    This software is governed by the CeCILL  license under French law and
  11.    abiding by the rules of distribution of free software.  You can  use, 
  12.    modify and/ or redistribute the software under the terms of the CeCILL
  13.    license as circulated by CEA, CNRS and INRIA at the following URL
  14.    "http://www.cecill.info". 
  15.    
  16.    As a counterpart to the access to the source code and  rights to copy,
  17.    modify and redistribute granted by the license, users are provided only
  18.    with a limited warranty  and the software's author,  the holder of the
  19.    economic rights,  and the successive licensors  have only  limited
  20.    liability. 
  21.    
  22.    In this respect, the user's attention is drawn to the risks associated
  23.    with loading,  using,  modifying and/or developing or reproducing the
  24.    software by the user in light of its specific status of free software,
  25.    that may mean  that it is complicated to manipulate,  and  that  also
  26.    therefore means  that it is reserved for developers  and  experienced
  27.    professionals having in-depth computer knowledge. Users are therefore
  28.    encouraged to load and test the software's suitability as regards their
  29.    requirements in conditions enabling the security of their systems and/or 
  30.    data to be ensured and,  more generally, to use and operate it in the 
  31.    same conditions as regards security. 
  32.    
  33.    The fact that you are presently reading this means that you have had
  34.    knowledge of the CeCILL license and that you accept its terms.
  35.    *@=@=@=@ END   LICENSE @=@=@=@*
  36.  
  37. */?><?php
  38.  
  39. /**
  40.  * siteInformation Class
  41.  * 
  42.  * 
  43.  * @author SimpliciWeb
  44.  * @version $Id: site_information.class.php 922 2008-03-22 09:35:03Z stephanet $
  45.  * @package Common
  46.  * @subpackage Start
  47.  */    
  48. /**
  49.  * Include the needed functions
  50.  */
  51. include_once('internal_components/common/globals/php_functions.inc.php');
  52.  
  53. /**
  54.  * The main class of PLICI. siteInformation give alls informations needed on a website.
  55.  * This class is launched for every PLICI webPage, you can use it for know if you are on an
  56.  * admin page or a front page for exemaple.
  57.  *
  58.  * @author SimpliciWeb
  59.  * @version $Id: site_information.class.php 922 2008-03-22 09:35:03Z stephanet $
  60.  * @package Common
  61.  * @subpackage Start
  62.  */
  63. class siteInformation {
  64.     /**
  65.      * The Entree Front path : racineweb.$this->m_entrees_from_root.$this->m_front_site_dir_name
  66.      *
  67.      * @var string 
  68.      */
  69.     var $m_fo_entry    = "";
  70.     /**
  71.      * The Entree Back path : racineweb.$this->m_entrees_from_root.$this->m_back_site_dir_name
  72.      *
  73.      * @var string 
  74.      */
  75.     var $m_bo_entry = "";
  76.     /**
  77.      * The Statistics entree path: $this->m_view_external.$this->m_ext_cmp_stat_dir = view/external_components/stats/
  78.      *
  79.      * @var string 
  80.      */
  81.     var $m_bo_stats_entry = "";
  82.     /**
  83.      * The Front Internal Path : $local_site_racineweb_path.$this->m_internal_from_root.$this->m_front_site_dir_name;
  84.      *
  85.      * @var string 
  86.      */
  87.     var $m_fo_internal = "";
  88.     /**
  89.      * The View Path : $local_site_racineweb_path.$this->m_view_from_root
  90.      *
  91.      * @var string 
  92.      */    
  93.     var $m_view_root = "";
  94.     /**
  95.      * Current site is BackOffice
  96.      *
  97.      * @var bool TRUE = BackOffice or Superadmin, FALSE = Front office
  98.      */
  99.     var $m_is_admin = false;
  100.     /**
  101.      * Database name for the current web site
  102.      *
  103.      * @var string 
  104.      */
  105.     var $m_database_site_name = "";
  106.     /**
  107.      * Sitename (database name for front, admin directory for backoffice or superadmin)
  108.      *
  109.      * @var string 
  110.      */
  111.     var $m_site_name = "";
  112.     /**
  113.      *Template site name (database name for front, admin directory for backoffice or superadmin)
  114.      *
  115.      * @var string 
  116.      */
  117.     var $m_template_site_name = "";
  118.     /**
  119.      * The Root Http url with language id : $this->m_root_http_without_lang."l".$lang_id."/";
  120.      *
  121.      * @var string 
  122.      */
  123.     var $m_root_http = "";
  124.     /**
  125.      * The root http url with language forced to Front URL: $this->m_root_http_fo_without_lang."l".$lang_id."/";
  126.      *
  127.      * @var unknown_type 
  128.      */
  129.     var $m_root_http_fo = "";
  130.     /**
  131.      * The short uri (for ini file) : /index.html
  132.      *
  133.      * @var string 
  134.      * @deprecated Ini file not used
  135.      */
  136.     var $m_uri_for_ini = "";
  137.     /**
  138.      * The only part of the url to be referenced ex : my%20product
  139.      * For an url http://www.plici.net/p254_my%20product.html
  140.      *
  141.      * @var string 
  142.      */
  143.     var $m_refenrencing_http_path = "";
  144.     /**
  145.      *     The picture http url : $this->m_root_http_fo.$this->getPictureDirectoryName();
  146.      *
  147.      * @var string 
  148.      */
  149.     var $m_picture_http = "";
  150.     /**
  151.      *     The picture http url for BackOffice : $this->m_root_http.$this->getPictureDirectoryName();
  152.      *
  153.      * @var string 
  154.      */
  155.     var $m_picture_http_bo = "";
  156.     /**
  157.      * Is a JSS or CSS page
  158.      *
  159.      * @var bool 
  160.      */
  161.     var $m_is_js_or_css = false;
  162.     /**
  163.      * Path to the view external : $local_site_racineweb_path."/".$this->m_view_external_from_root;
  164.      *
  165.      * @var string 
  166.      */
  167.     var $m_view_external    = "";
  168.  
  169.     /**
  170.      * I have no personal photo
  171.      *
  172.      * @var bool 
  173.      */
  174.     var $m_i_have_personal_no_photo = false;
  175.  
  176.     /**
  177.      * Template filename to display
  178.      *
  179.      * @var string 
  180.      */
  181.     var $m_template_filename = "";
  182.     
  183.     /**
  184.      * @var string 
  185.      * @deprecated Seems not used
  186.      */
  187.     var $m_message_file = "messages.txt";
  188.  
  189.  
  190.     /**
  191.      * "/core/entrees/"
  192.      *
  193.      * @var string 
  194.      */
  195.     var $m_entrees_from_root         = "/core/entrees/";
  196.     /**
  197.      * "view/external_components/"
  198.      *
  199.      * @var string 
  200.      */
  201.     var $m_view_external_from_root    = "view/external_components/";
  202.     /**
  203.      * "module/"
  204.      *
  205.      * @var string 
  206.      */
  207.     var $m_module_dir_file            = "module/";
  208.     /**
  209.      * "plici_mod"
  210.      *
  211.      * @var string 
  212.      */
  213.     var $m_module_dir_http            = "plici_mod";
  214.     /**
  215.      * "stats/"
  216.      *
  217.      * @var string 
  218.      */
  219.     var $m_ext_cmp_stat_dir         = "stats/";
  220.     
  221.     /**
  222.      * "../error_doc/busy.php"
  223.      *
  224.      * @var string 
  225.      */
  226.     var $m_error_doc_busy_page_from_view = "../error_doc/busy.php";
  227.     /**
  228.      * "/view/sites/"
  229.      *
  230.      * @var string 
  231.      */
  232.     var $m_view_from_root        = "/view/sites/";
  233.     /**
  234.      * "/tmp/"
  235.      *
  236.      * @var string 
  237.      */
  238.     var $m_tmp_from_root        = "/tmp/";
  239.     /**
  240.      * "/core/internal_components/"
  241.      *
  242.      * @var string 
  243.      */
  244.     var $m_internal_from_root     = "/core/internal_components/";
  245.     /**
  246.      * "theme_elements/"
  247.      *
  248.      * @var string 
  249.      */
  250.     var $m_core_themeelements = "theme_elements/";
  251.     /**
  252.      * "admin_"
  253.      *
  254.      * @var string 
  255.      */
  256.     var $m_admin_site_prefix"admin_";
  257.  
  258.     /**
  259.      * "front_sites/"
  260.      *
  261.      * @var string 
  262.      */
  263.     var $m_front_site_dir_name    = "front_sites/";
  264.     /**
  265.      * "admin_sites/"
  266.      *
  267.      * @var string 
  268.      */
  269.     var $m_back_site_dir_name    = "admin_sites/";
  270.     /**
  271.      * "admin_plici/"
  272.      *
  273.      * @var string 
  274.      */
  275.     var $m_admin_plici_site_dir_name    = "admin_plici/";
  276.     
  277.     /**
  278.      * "import/"
  279.      *
  280.      * @var string 
  281.      */
  282.     var $m_import_directory_name = "import/";
  283.     /**
  284.      * "picture/"
  285.      *
  286.      * @var string 
  287.      */
  288.     var $m_picture_directory_name = "picture/";
  289.     /**
  290.      * "template_not_compiled/"
  291.      *
  292.      * @var string 
  293.      */
  294.     var $m_tpl_not_compiled_file = "/"//"template_not_compiled/";
  295.     /**
  296.      * "template_compiled/"
  297.      *
  298.      * @var string 
  299.      */
  300.     var $m_tpl_compiled_file = "template_compiled/";
  301.     /**
  302.      * "config/"
  303.      *
  304.      * @var string 
  305.      */
  306.     var $m_tpl_config_file = "config/";
  307.     /**
  308.      * "cache/"
  309.      *
  310.      * @var string 
  311.      */
  312.     var $m_tpl_cache_file = "cache/";
  313.     /**
  314.      * "css_screen.css"
  315.      *
  316.      * @var string 
  317.      */
  318.     var $m_css_file = "css_screen.css";
  319.     /**
  320.      * "js_general.js"
  321.      *
  322.      * @var string 
  323.      */
  324.     var $m_js_file = "js_general.js";
  325.     /**
  326.      * pCODING/js/dialog/"
  327.      *
  328.      * @var string 
  329.      */
  330.     var $m_js_dialog_path = "pCODING/js/dialog/";
  331.     /**
  332.      * "pVISITEURS/stats/"
  333.      *
  334.      * @var string 
  335.      */
  336.     var $m_stats_file_path = "pVISITEURS/stats/";
  337.     /**
  338.      * "ext/"
  339.      *
  340.      * @var string 
  341.      */
  342.     //var $m_external_for_picture_theme = "ext/";
  343.     /**
  344.      * "bd/"
  345.      *
  346.      * @var string 
  347.      */
  348.     var $m_bd_from_root = "bd/";
  349.     /**
  350.      * "screen_shoot_little.jpg"
  351.      *
  352.      * @var string 
  353.      */
  354.     var $m_theme_screen_shoot_little = "/screen_shoot_little.jpg";
  355.     /**
  356.      * "/screen_shoot_big.jpg"
  357.      *
  358.      * @var string 
  359.      */
  360.     var $m_theme_screen_shoot_big = "/screen_shoot_big.jpg";
  361.     /**
  362.      * Is from locahost
  363.      *
  364.      * @var bool TRUE = website access by local
  365.      */
  366.     var $is_localhost = false;
  367.     /**
  368.      * The root http url without language forced to Front URL
  369.      *
  370.      * @var string 
  371.      */
  372.     var    $m_root_http_fo_without_lang = "";
  373.     /**
  374.      * The root http url without language
  375.      *
  376.      * @var string 
  377.      */
  378.     var    $m_root_http_without_lang = "";
  379.  
  380.     /**
  381.      * Page center can be cached
  382.      *
  383.      * @var bool 
  384.      */
  385.     var $m_page_center_can_be_cached = true;
  386.  
  387.     /**
  388.      * When making a redirect, list of parameters to doesn't pass again
  389.      *
  390.      * @var array 
  391.      */
  392.     var $params_to_not_pass_in_querystring = array("id_menu""c_l_a""ht_ray_id",
  393.             "page_id""tpl_name""father_page_id",'shopcart_pm_id','shopcart_ps_id','shopcart_quantity');
  394.     /**
  395.      * Racine web path (PLICI directory)
  396.      *
  397.      * @var string 
  398.      */
  399.     var $m_local_site_racineweb_path = "";
  400.  
  401.     /**
  402.      * Theme from my or plici (the name)
  403.      *
  404.      * @var string  for_plici|my
  405.      */
  406.     var $m_theme_from_my_or_plici = "";
  407.  
  408.     
  409.     /**
  410.      * Temporary file path : $local_site_racineweb_path.$this->m_tmp_from_root;
  411.      *
  412.      * @var string 
  413.      */
  414.     var $m_tmp_root = "";
  415.  
  416.     /**
  417.      * Return the current HTTP host, for example : www.plici.net for a web page from plici.net
  418.      * If the http host is not finded, we will return the server_name.
  419.      *
  420.      * @return string 
  421.      */
  422.     function getHost(){
  423.         $host (0strlen(trim($_SERVER['HTTP_HOST']))?$_SERVER['HTTP_HOST']:$_SERVER['SERVER_NAME']);
  424.         // Delete port if necessary
  425.         $pos strrpos($host":");
  426.         if ($pos !== false{
  427.           $host substr($host0$pos);
  428.         }
  429.         return $host;
  430.     }
  431.  
  432.     /**
  433.      * Test if it is from robot
  434.      *
  435.      * @return bool 
  436.      */
  437.     function isFromRobot(){
  438.  
  439.         $user_agent_source $_SERVER['HTTP_USER_AGENT'];
  440.         $user_agent_to_find array('googlebot',
  441.                                     'msnbot',
  442.                                     'Yahoo! Slurp',
  443.                                     "VoilaBot",
  444.                                     "ZyBorg",
  445.                                     "FAST-WebCrawler",
  446.                                     "DeepIndex",
  447.                                     "Teoma",
  448.                                     "walhello",
  449.                                     "Gigabot",
  450.                                     "HenriLeRobotMirago",
  451.                                     "psbot",
  452.                                     "Szukacz",
  453.                                     "Openbot",
  454.                                     "NaverRobot",
  455.                                     "dloader");
  456.         foreach ($user_agent_to_find as $bot_name)
  457.             if (preg_match("/".$bot_name."/i"$user_agent_source)>0)
  458.                 return true;
  459.  
  460.         return false;
  461.  
  462.     }
  463.  
  464.  
  465.  
  466.     /**
  467.      * Make url for language : /l1/
  468.      *
  469.      * @param integer $lang_id 
  470.      * @return string 
  471.      */
  472.     function makeUrlForLanguage($lang_id{
  473.         //$temp = str_replace($this->getBaseHttpFo(), $this->m_root_http_fo_without_lang."l".$lang_id."/", $_SERVER['REQUEST_URI']) ;
  474.         //return $this->getHTTPorHTTPS().$this->getHost().$temp;
  475.         //return str_replace($this->getBaseHttpFo(), "/l".$lang_id."/", $_SERVER['REQUEST_URI']) ;
  476.  
  477.         $uri str_replace("&""&amp;"$_SERVER['REQUEST_URI']);
  478.  
  479.         // If is the home url : http://www.truc.com then there is not /l([0-9]*)/ then add the new language
  480.         //echo_net("$uri == ".$this->getBaseHttpFo()."");
  481.         if ($uri == $this->m_root_http_fo_without_lang{
  482.             $uri_new_language .= "l".$lang_id."/";
  483.         else {
  484.             $uri_new_language ereg_replace("/l([0-9]*)/""/l".$lang_id."/"$uri);
  485.         }
  486.  
  487.  
  488.         return $uri_new_language;
  489.     }
  490.  
  491.     /**
  492.      * Get prefix language : /l1/
  493.      *
  494.      * @return unknown 
  495.      */
  496.     function getLanguagePart()
  497.     {
  498.         $lang=0;
  499.         $this->getCurrentLanguageId($lang);
  500.         return "/l".$lang;
  501.     }
  502.  
  503.     /**
  504.      * I have personal no photo
  505.      *
  506.      * @return bool 
  507.      */
  508.     function getIHavePersonalNoPhoto({
  509.         return $this->m_i_have_personal_no_photo;
  510.     }
  511.  
  512.     /**
  513.      * Get page part : /pxxx
  514.      *
  515.      * @return string 
  516.      */
  517.     function getPagePart()
  518.     {
  519.         $page_id=$_GET['plici_request_page_id'];
  520.         return "/p".$page_id;
  521.     }
  522.  
  523.     /**
  524.      * Set current language id
  525.      *
  526.      * @param integer $p_current_language_id 
  527.      * @return bool TRUE on error
  528.      */
  529.     function setCurrentLanguageId($p_current_language_id{
  530.         $_GET['c_l_a'$p_current_language_id;
  531.         $this->xSetLanguageIdToUrl($p_current_language_id);
  532.         return false;
  533.     }
  534.  
  535.     /**
  536.      * set language id to urls
  537.      *
  538.      * @access private
  539.      * @param unknown_type $lang_id 
  540.      */
  541.     function xSetLanguageIdToUrl($lang_id{
  542.  
  543.             $this->m_root_http    = $this->m_root_http_without_lang."l".$lang_id."/";
  544.             $this->m_root_http_fo = $this->m_root_http_fo_without_lang."l".$lang_id."/";
  545.     }
  546.  
  547.     /**
  548.      * Get current language id
  549.      *
  550.      * @param integer $default_lang_id 
  551.      * @return bool TRUE on error
  552.      */
  553.     function getCurrentLanguageId(&$default_lang_id{
  554.  
  555.         if (isset($_GET['c_l_a'])) {
  556. //echo_net('cla finded : '.$_GET['c_l_a']);
  557.             $default_lang_id sprintf("%d"$_GET['c_l_a']);
  558.             $error false;
  559.         else {
  560.  
  561.             global $g_object_loader;
  562.             // were are going to load the navigator language
  563.             $lang_code explode(",",@$_SERVER['HTTP_ACCEPT_LANGUAGE']);
  564.             $lang_code strtolower(substr(rtrim($lang_code[0]),0,2));
  565.             if ($this->isAdmin(|| $this->isAdminSuper())
  566.                 $object_tlanguage =$g_object_loader->getTLanguage();
  567.             else
  568.                 $object_tlanguage =$g_object_loader->getTLanguageFo();
  569.             $r_result array();
  570.             $object_tlanguage->getByCode($r_result$lang_code);
  571.  
  572.             if (isset($r_result['lang_id'])) {
  573.                 $default_lang_id $r_result['lang_id'];
  574.                 $this->setCurrentLanguageId($r_result['lang_id']);
  575. //echo_net("finded with navigator [$lang_code] => ".$default_lang_id);
  576.  
  577.                 return false;
  578.             else {
  579.                 // no navigator langage compatible with our language slots !
  580.                 // load the default language value
  581.                 $object_tglobalscopevariable =$g_object_loader->getTGlobalScopeVariable();
  582.                 $error $object_tglobalscopevariable->getDefaultLanguageId($default_lang_id);
  583.                 $this->setCurrentLanguageId($default_lang_id);
  584. //echo_net("finded with default language [$lang_code] => ".$default_lang_id);
  585.             }
  586.         }
  587.  
  588.  
  589.         return     $error;
  590.     }
  591.  
  592.  
  593.     /**
  594.      * Set current language id
  595.      *
  596.      * @param integer $id_lang 
  597.      */
  598.     function setCurrentFrontLanguageId($id_lang{
  599.             $_SESSION['bo_current_front_language'$id_lang;
  600.     }
  601.  
  602.     /**
  603.      * Return current language id for front
  604.      *
  605.      * @param integer $id_lang 
  606.      */
  607.     function getCurrentFrontLanguageId(&$id_lang{
  608.  
  609.         if ($this->isAdmin()) {
  610.             if (isset($_SESSION['bo_current_front_language']))
  611.                 $id_lang $_SESSION['bo_current_front_language'];
  612.             else {
  613.                 global $g_object_loader;
  614.                 $object_tglobalscopevariable =$g_object_loader->getTGlobalScopeVariable();
  615.                 $error $object_tglobalscopevariable->getDefaultLanguageId($id_lang);
  616.                 $this->setCurrentFrontLanguageId($id_lang);
  617.             }
  618.         else {
  619.             $this->getCurrentLanguageId($id_lang);
  620.         }
  621.  
  622.     }
  623.  
  624.     /**
  625.      * Set page can be cached
  626.      *
  627.      * @param bool $p_page_center_can_be_cached 
  628.      */
  629.     function setPageCenterCanBeCached($p_page_center_can_be_cached{
  630.             $this->m_page_center_can_be_cached = $p_page_center_can_be_cached;
  631.     }
  632.  
  633.     /**
  634.      * Page can be cached
  635.      *
  636.      * @return bool 
  637.      */
  638.     function getPageCenterCanBeCached({
  639.             return $this->m_page_center_can_be_cached ;
  640.     }
  641.  
  642.     /**
  643.      * Get current url with query string
  644.      *
  645.      * @return string 
  646.      */
  647.     function getUrlWithQueryString({
  648.         return $this->getHTTPorHTTPS().$this->getHost().$_SERVER['REQUEST_URI'];
  649.     }
  650.  
  651.     /**
  652.      * Get uri for ini section
  653.      *
  654.      * @deprecated INI file not used
  655.      * @return string 
  656.      */
  657.     function getUriForIniSection({
  658.         return $this->m_uri_for_ini;
  659.     }
  660.  
  661.     /**
  662.      * Site Name
  663.      *
  664.      * @return string 
  665.      */
  666.     function getSiteName({
  667.         return $this->m_site_name;
  668.     }
  669.  
  670.     /**
  671.      * Get site directory for view
  672.      *
  673.      * @param bool $p_force_front 
  674.      * @return string 
  675.      */
  676.     function getSiteDirectoryForView($p_force_front false{
  677.         if ($this->isAdmin(&& !$p_force_front)
  678.             if ($this->isAdminSuper())
  679.                 return PLICI_FOR_PLICI_DIRECTORY."/".$this->m_admin_plici_site_dir_name.$this->m_site_name."/";
  680.             else
  681.                 return PLICI_MY_DIRECTORY."/".$this->m_database_site_name."/".$this->m_site_name."/";
  682.         else
  683.             return PLICI_MY_DIRECTORY."/".$this->m_database_site_name."/";
  684.     }
  685.  
  686.     /**
  687.      * Get site directory for tmp : database_site_name ou template_site_name
  688.      *
  689.      * @param bool $p_force_front 
  690.      * @return string 
  691.      */
  692.     function getSiteDirectoryForTmp($p_force_front false{
  693. //        echo_net("m_database_site_name=".$this->m_database_site_name);
  694. //        echo_net("m_template_site_name=".$this->m_template_site_name);
  695.         if ($p_force_front)
  696.             return $this->m_database_site_name."/";
  697.         else
  698.             return $this->m_template_site_name."/";
  699.     }
  700.  
  701.  
  702.  
  703.     /**
  704.      * Database site name
  705.      *
  706.      * @return string 
  707.      */
  708.     function getDatabaseSiteName({
  709.         return $this->m_database_site_name;
  710.     }
  711.  
  712.  
  713.     /**
  714.      * Get theme element path (css build in path) : racineweb/internal_components/front_sites/theme_elements/
  715.      *
  716.      * @return string 
  717.      */
  718.     /*function getThemeElementsPath() {
  719.         return $this->m_fo_internal.$this->m_core_themeelements;
  720.     }*/
  721.  
  722.     /**
  723.      * Include the theme element to generate the css file
  724.      *
  725.      * @deprecated CSS in Database not used, became a file
  726.      *//*
  727.     function includeThemeElementsFile() {
  728. //        trigger_error("Deprecated");
  729.  
  730.         global $g_object_loader;
  731.         $object_db_connexion =&    $g_object_loader->getDbConnexion();
  732.         $inherited_site_name = $object_db_connexion->getCurrentInheritedSiteName();
  733.  
  734.  
  735.  
  736.         if ($inherited_site_name != "")
  737.             $r_result_file_path_theme = $this->m_fo_internal.$this->m_core_themeelements.$this->getMyOrPliciDirectoryForMyTheme()."/".$inherited_site_name.".php";
  738.         else
  739.             $r_result_file_path_theme = "";
  740.         $r_result_file_path_my    = $this->m_fo_internal.$this->m_core_themeelements.PLICI_MY_DIRECTORY."/".$this->getDatabaseSiteName().".php";
  741.  
  742.         global $sw_current_theme_element;
  743.         global $sw_current_theme_element_inline;
  744.  
  745.         // je charge la définition CSS du thème
  746.         $sw_current_theme_element=array();
  747.         $sw_current_theme_element_inline=array();
  748.         if (file_exists($r_result_file_path_theme)) {
  749. /* *
  750.  * Include $r_result_file_path_theme
  751.  * /
  752. include($r_result_file_path_theme);
  753.         }
  754.         $memory_sw_current_theme_element=$sw_current_theme_element;
  755.         $memory_sw_current_theme_element_inline=$sw_current_theme_element_inline;
  756.  
  757.         // je la surcharge par la définit du site qui lui est propre
  758.         $sw_current_theme_element=array();
  759.         $sw_current_theme_element_inline=array();
  760.         if (file_exists($r_result_file_path_my)) {
  761. /* *
  762.  * Include $r_result_file_path_my
  763.  * /
  764. include($r_result_file_path_my);
  765.  
  766.  
  767.             $getPictureHttpPath = $this->getPictureHttpPath();
  768.  
  769.             // on set le picture path car sinon il va etre faux (pris du theme)
  770.             foreach($sw_current_theme_element as $key => $value) {
  771.  
  772.                 if ($key == "no_photo") {
  773.                     $this->m_i_have_personal_no_photo = true;
  774.                 }
  775.  
  776.                 if (isset($sw_current_theme_element[$key]["style"]))
  777.                     $sw_current_theme_element[$key]["style"] =
  778.                             str_replace("%PICTURE_BASE_HTTP%", $getPictureHttpPath, $sw_current_theme_element[$key]["style"]);
  779.                 if (isset($sw_current_theme_element[$key]["img"]))
  780.                     $sw_current_theme_element[$key]["img"] =
  781.                             str_replace("%PICTURE_BASE_HTTP%", $getPictureHttpPath, $sw_current_theme_element[$key]["img"]);
  782.             }
  783.             foreach($sw_current_theme_element_inline as $key => $value) {
  784.                 if (isset($sw_current_theme_element_inline[$key]["style"]))
  785.                     $sw_current_theme_element_inline[$key]["style"] =
  786.                             str_replace("%PICTURE_BASE_HTTP%", $getPictureHttpPath, $sw_current_theme_element_inline[$key]["style"]);
  787.                 if (isset($sw_current_theme_element_inline[$key]["img"]))
  788.                     $sw_current_theme_element_inline[$key]["img"] =
  789.                             str_replace("%PICTURE_BASE_HTTP%", $getPictureHttpPath, $sw_current_theme_element_inline[$key]["img"]);
  790.             }
  791.  
  792.  
  793.  
  794.         }
  795.  
  796. //        print_r_net($memory_sw_current_theme_element);
  797. //        print_r_net($sw_current_theme_element);
  798.         $sw_current_theme_element = array_merge($memory_sw_current_theme_element, $sw_current_theme_element);
  799.         $sw_current_theme_element_inline = array_merge($memory_sw_current_theme_element_inline, $sw_current_theme_element_inline);
  800.  
  801. //        print_r_net($sw_current_theme_element);
  802.  
  803.         return;
  804.  
  805.     }
  806. */
  807.  
  808.  
  809.     /**
  810.      * Get root path for plici
  811.      *
  812.      * @return string 
  813.      */
  814.     function getRoot()
  815.     {
  816.         return $this->m_local_site_racineweb_path;
  817.     }
  818.  
  819.  
  820.     // -------- Gestion de la partie entry -------- //
  821.     /**
  822.      * "view/external_components/stats/"
  823.      *
  824.      * @return string 
  825.      */
  826.     function getBackSiteStatsEntry(){
  827.         return $this->m_bo_stats_entry;
  828.     }
  829.  
  830.  
  831.  
  832.     /**
  833.      * Get path : racineweb/core/entrees/front_sites/
  834.      *
  835.      * @return string 
  836.      */
  837.     function getFrontSiteEntry(){
  838.         return $this->m_fo_entry;
  839.     }
  840.  
  841.     /**
  842.      * Get path : racineweb/core/internal_components/front_sites/
  843.      *
  844.      * @return string 
  845.      */
  846.     function getFrontSiteInternal(){
  847.         return $this->m_fo_internal;
  848.     }
  849.  
  850.  
  851.     // gestion de la partie des repertoire physique "templates"
  852.  
  853.  
  854.     /**
  855.      * Get temporary root path : racineweb/tmp/
  856.      *
  857.      * @return string 
  858.      */
  859.     function getTmpRootPath({
  860.         return $this->m_tmp_root;
  861.     }
  862.  
  863.     // partie des templates qui sont dans le repertoire "tmp"
  864.     /**
  865.      * Get temporary file path for smarty
  866.      *
  867.      * @param bool $p_force_front 
  868.      * @return string 
  869.      */
  870.     function getTmpFilePath($p_force_front false{
  871.         return $this->getTmpRootPath().$this->getSiteDirectoryForTmp($p_force_front);
  872.     }
  873.  
  874.     /**
  875.      * Get template compiled file path for smarty
  876.      *
  877.      * @return string 
  878.      */
  879.     function getTemplateCompiledFilePath({
  880.         return $this->getTmpFilePath().$this->m_tpl_compiled_file;
  881.     }
  882.  
  883.     /**
  884.      * Get template config file path for smarty
  885.      *
  886.      * @return string 
  887.      */
  888.     function getTemplateConfigFilePath({
  889.         return $this->getTmpFilePath().$this->m_tpl_config_file;
  890.     }
  891.  
  892.     /**
  893.      * Get template cache file path for smarty
  894.      *
  895.      * @param bool $p_force_front 
  896.      * @return string 
  897.      */
  898.     function getTemplateCacheFilePath($p_force_front false{
  899.         return $this->getTmpFilePath($p_force_front).$this->m_tpl_cache_file.$this->m_database_site_name;
  900.     }
  901.  
  902.     /**
  903.      * Get template cache file path for smarty for a specified website
  904.      *
  905.      * @param string $p_database 
  906.      * @return string 
  907.      */
  908.     function getTemplateCacheFilePathSpecific($p_database ""{
  909.         if (""==$p_database)
  910.             return $this->getTemplateCacheFilePath();
  911.             else return $this->getTmpRootPath().$p_database."/".$this->m_tpl_cache_file.$p_database;
  912.     }
  913.  
  914.     /**
  915.      * Get template not compiled file path for smarty
  916.      *
  917.      * @param string $p_dir 
  918.      * @param bool $p_force_front 
  919.      * @return string 
  920.      */
  921.     function getTemplateNotCompiledFilePath($p_dir=""$p_force_front false)
  922.     {
  923.         $inherited_site_name "";
  924.  
  925.         $directory_my_or_user "";
  926.     if (($this->isAdmin()) && (!$p_force_front))  {
  927.           $directory_my_or_user PLICI_FOR_PLICI_DIRECTORY."/";
  928.     else {
  929.           $directory_my_or_user PLICI_MY_DIRECTORY."/";
  930.     }
  931.  
  932.         if (0!=strcasecmp(""$p_dir))
  933.         {
  934.             $inherited_site_name $p_dir;
  935.         else
  936.         {
  937.             if ($p_force_front{
  938.                 $inherited_site_name $this->m_database_site_name;
  939.             $directory_my_or_user PLICI_MY_DIRECTORY."/";
  940.             else
  941.                 $inherited_site_name $this->m_template_site_name;
  942.         }
  943.         $inherited_site_name .= "/";
  944.  
  945.         return $this->getViewRootPath().$directory_my_or_user.$inherited_site_name.$this->m_tpl_not_compiled_file;
  946.     }
  947.  
  948.  
  949.     /**
  950.      * Search and test if template exsit
  951.      *
  952.      * @param string $p_filename 
  953.      * @param string $r_template_not_compiled_path 
  954.      * @param bool $p_force_front 
  955.      * @param string $p_dir 
  956.      * @return bool TRUE = finded ($r_template_not_compiled_path set to path)
  957.      */
  958.     function getExistTemplateNotCompiledFilePath($p_filename&$r_template_not_compiled_path,
  959.         $p_force_front false$p_dir="")
  960.     {
  961.         global $g_object_loader;
  962.         // on regardes si on doit envoyer un mail
  963.         if (!isset($g_object_loader)) {
  964.             // on declare le $g_object_loader car il peut ne pas exister
  965.             // si on est sur une page de cache
  966.             /**
  967.              * Include 'internal_components/common/loader/object_loader.class.php'
  968.              */
  969.             require_once('internal_components/common/loader/object_loader.class.php');
  970.             global $g_object_loader;
  971. // not needed, now the require instanciante the objectloader:            $g_object_loader = new ObjectLoader();
  972.         }
  973.  
  974.  
  975.  
  976. //        echo_net($p_filename);
  977.         $r_template_not_compiled_path $this->getTemplateNotCompiledFilePath($p_dir$p_force_front);
  978.  
  979. //        echo_net($r_template_not_compiled_path.$p_filename);
  980.         if (file_exists($r_template_not_compiled_path.$p_filename)) {
  981. //            $this->m_suffix_for_cache_id = "A";
  982.             return true;
  983.         }
  984.  
  985.         $object_db_connexion =&    $g_object_loader->getDbConnexion();
  986.         $inherited_site_name $object_db_connexion->getCurrentInheritedSiteName()."/";
  987. //        echo_net('inherited_site_name'.$inherited_site_name);
  988.         if ($inherited_site_name == "/"{
  989.             $r_template_not_compiled_path "";
  990.             return false;
  991.         }
  992.  
  993.         $r_template_not_compiled_path $this->getViewRootPath().PLICI_FOR_PLICI_DIRECTORY."/".$inherited_site_name.$this->m_tpl_not_compiled_file;
  994. //        echo_net($r_template_not_compiled_path.$p_filename);
  995.         if (file_exists($r_template_not_compiled_path.$p_filename)) {
  996. //            $this->m_suffix_for_cache_id = "B";
  997.             return true;
  998.         }
  999.  
  1000.         // nécessaire pour trouver les templates des thèmes utilisateurs
  1001.     $r_template_not_compiled_path $this->getViewRootPath().PLICI_MY_DIRECTORY."/".$inherited_site_name.$this->m_tpl_not_compiled_file;
  1002. //        echo_net($r_template_not_compiled_path.$p_filename);
  1003.         if (file_exists($r_template_not_compiled_path.$p_filename)){
  1004. //            $this->m_suffix_for_cache_id = "C";
  1005.             return true;
  1006.         }
  1007.  
  1008.         $r_template_not_compiled_path "";
  1009.         return false;
  1010.     }
  1011.  
  1012.     /**
  1013.      * Get picture http path not special : /picture/ext/for_plici/my/theme1_com/
  1014.      *
  1015.      * @param bool $p_force_not_inherited 
  1016.      * @return string 
  1017.      */
  1018. /*    function getPictureHttpPathNotSpe($p_force_not_inherited = false) {
  1019.         $picture_http_path_not_spe = $this->getPictureHttpPath();
  1020.         if ($p_force_not_inherited)
  1021.             return $picture_http_path_not_spe;
  1022.  
  1023.         global $g_object_loader;
  1024.         $object_db_connexion =&    $g_object_loader->getDbConnexion();
  1025.         $inherited_site_name = $object_db_connexion->getCurrentInheritedSiteName();
  1026.  
  1027.         if ($inherited_site_name != "")
  1028.             $picture_http_path_not_spe .= $this->m_external_for_picture_theme.$this->getMyOrPliciDirectoryForMyTheme()."/".$inherited_site_name."/";
  1029.  
  1030.         return $picture_http_path_not_spe;
  1031.  
  1032.     }
  1033. */
  1034.  
  1035.     /**
  1036.      * Get View external from root : view/external_components/
  1037.      *
  1038.      * @return string 
  1039.      */
  1040.     function getViewExternalFromRoot()
  1041.     {
  1042.         return  $this->m_view_external_from_root;
  1043.     }
  1044.  
  1045.  
  1046.     // gestion de la partie des repertoire physiques "view"
  1047.  
  1048.     /**
  1049.      * Get view root : racineweb/view/sites/
  1050.      *
  1051.      * @return string 
  1052.      */
  1053.     function getViewRootPath({
  1054.         return $this->m_view_root;
  1055.     }
  1056.  
  1057.     /**
  1058.      * Get view file path front office : racineweb/view/sites/sitename/
  1059.      *
  1060.      * @return string 
  1061.      */
  1062.     function getViewFilePathFO({
  1063.         return $this->getViewRootPath().$this->getSiteDirectoryForView(true);
  1064.     }
  1065.  
  1066.     /**
  1067.      * Get view file path from BackOffice
  1068.      *
  1069.      * @return string 
  1070.      */
  1071.     function getViewFilePathBO({
  1072.         return $this->getViewRootPath().$this->getSiteDirectoryForView(false);
  1073.     }
  1074.  
  1075.     /**
  1076.      * Get picture file path : racineweb/view/sites/my/sitenamen/picture/
  1077.      *
  1078.      * @return string 
  1079.      */
  1080.     function getPictureFilePath({
  1081.         return $this->getViewFilePathFO().$this->getPictureDirectoryName();
  1082.     }
  1083.     /**
  1084.      * Get picture file path specified : /view/sites/my/sitename/picture/
  1085.      *
  1086.      * @param string $p_database_selected 
  1087.      * @return string 
  1088.      */
  1089.     function getPictureFilePathSpecified($p_database_selected)
  1090.     {
  1091.         return $this->getViewRootPath().PLICI_MY_DIRECTORY."/".$p_database_selected."/".$this->getPictureDirectoryName();
  1092.     }
  1093.     /**
  1094.      * Get picture directory name : picture/
  1095.      *
  1096.      * @return string 
  1097.      */
  1098.     function getPictureDirectoryName({
  1099.         return $this->m_picture_directory_name;
  1100.     }
  1101.  
  1102.     /**
  1103.      * Import file path : view/sites/my/sitename/admin_xxx/import/
  1104.      *
  1105.      * @return string 
  1106.      */
  1107.     function getImportPath({
  1108.         return $this->getViewFilePathBO().$this->m_import_directory_name;
  1109.     }
  1110.  
  1111.     /**
  1112.      * Get view external path : racineweb/view/external_components/
  1113.      *
  1114.      * @return string 
  1115.      */
  1116.     function getViewExternalPath({
  1117.         return $this->m_view_external;
  1118.     }
  1119.  
  1120.     /**
  1121.      * Get the module file path /view/external_components/module/
  1122.      *
  1123.      * @return string 
  1124.      */
  1125.     function getModulePath({
  1126.         return $this->getViewExternalPath().$this->m_module_dir_file;
  1127.     }
  1128.  
  1129.  
  1130.     // gestion de la partie des repertoires HTTP
  1131.  
  1132.     /**
  1133.      * Base Http path : / for example for front
  1134.      *
  1135.      * @return string 
  1136.      */
  1137.     function getBaseHttpFo({
  1138.         return $this->m_root_http_fo;
  1139.     }
  1140.  
  1141.     /**
  1142.      * Return the http or https url prefix
  1143.      *
  1144.      * @param bool $p_force_http 
  1145.      * @return string 
  1146.      */
  1147.     function getHTTPorHTTPS($p_force_http false{
  1148.         if ((!$p_force_http&& isset($_SERVER["HTTPS"]&& ($_SERVER["HTTPS"]=="on"))
  1149.             return "https://";
  1150.         else
  1151.             return "http://";
  1152.     }
  1153.  
  1154.     /**
  1155.      * Get htt servername : http(s)://www.host.xxx/
  1156.      *
  1157.      * @param true $p_force_http 
  1158.      * @return string 
  1159.      */
  1160.     function getHttpServername($p_force_http false{
  1161.         //echo($_SERVER["HTTPS"]);
  1162.  
  1163.         return $this->getHTTPorHTTPS($p_force_http).$this->getHost();
  1164.     }
  1165.  
  1166.     /**
  1167.      * Return full http path force front: http://www.xx.xxx/
  1168.      *
  1169.      * @return string 
  1170.      */
  1171.     function getBaseFullHttpFoWithoutLanguage({
  1172.         return $this->getHttpServername(true).$this->m_root_http_fo_without_lang;
  1173.     }
  1174.  
  1175.     /**
  1176.      * Return full http path force front: http://www.xx.xxx/l1/
  1177.      *
  1178.      * @return string 
  1179.      */
  1180.     function getBaseFullHttpFo({
  1181.         return $this->getHttpServername(true).$this->getBaseHttpFo();
  1182.     }
  1183.     /**
  1184.      * Return full http path : http://www.xx.xxx/l1/ or http://www.xx.xxx/admin_xxx/l1/
  1185.      *
  1186.      * @return string 
  1187.      */
  1188.     function getBaseFullHttp({
  1189.         return $this->getHttpServername().$this->getBaseHttp();
  1190.     }
  1191.  
  1192.     /**
  1193.      * Base Http path : / for example or /admin_xxx for back
  1194.      *
  1195.      * @return string 
  1196.      */
  1197.     function getBaseHttp({
  1198.         return $this->m_root_http;
  1199.     }
  1200.  
  1201.     /**
  1202.      * Set {@link m_refenrencing_http_path}
  1203.      *
  1204.      * @param string $p_value 
  1205.      */
  1206.     function appendBaseHttpForReferencing($p_value{
  1207.         $p_value net_urlencode($p_value);
  1208.         $this->m_refenrencing_http_path = $p_value;
  1209.     }
  1210.  
  1211.     /**
  1212.      * return the referencing part for url
  1213.      *
  1214.      * @return string 
  1215.      */
  1216.     function getBaseHttpReferencing({
  1217.         return $this->m_root_http.$this->m_refenrencing_http_path;
  1218.     }
  1219.  
  1220.     /**
  1221.      * Return the http stats stick : /pVISITEURS/stats/
  1222.      *
  1223.      * @return string 
  1224.      */
  1225.     function getHttpStatsStickFo({
  1226.         return $this->m_root_http_fo_without_lang.$this->m_stats_file_path;
  1227.     }
  1228.     /**
  1229.      * Return full http path: http://www.xx.xxx/admin_xxx/l1/pVISITEURS/stats/
  1230.      *
  1231.      * @return string 
  1232.      */
  1233.     function getBaseFullHttpStats({
  1234.         return $this->getHttpServername().$this->getBaseHttp().$this->m_stats_file_path;
  1235.     }
  1236.  
  1237.     /**
  1238.      * Get http path for css front in front : /css_screen.css
  1239.      *
  1240.      * @return unknown 
  1241.      */
  1242.     function getHttpCssFileFo({
  1243.         return $this->m_root_http_fo_without_lang.$this->m_css_file;
  1244.     }
  1245.  
  1246.     /**
  1247.      * Get Http path for css files : /css_screen.css
  1248.      *
  1249.      * @return string 
  1250.      */
  1251.     function getHttpCssFile({
  1252.  
  1253.         //return $this->getBaseFullHttp().$this->m_css_file;
  1254.         return $this->m_root_http.$this->m_css_file;
  1255.     }
  1256.  
  1257.     /**
  1258.      * Get Http path for css files : /js_general.js
  1259.      *
  1260.      * @return string 
  1261.      */
  1262.     function getHttpJsFile({
  1263.         //return $this->getBaseFullHttp().$this->m_js_file;
  1264.         return $this->m_root_http.$this->m_js_file;
  1265.     }
  1266.  
  1267.  
  1268.     /**
  1269.      * return htt path for js dialog : pCODING/js/dialog/
  1270.      *
  1271.      * @return string 
  1272.      */
  1273.     function getHttpPathJsDialog({
  1274.         return $this->m_root_http.$this->m_js_dialog_path;
  1275.     }
  1276.  
  1277.     /**
  1278.      * Get picture http path : /picture/
  1279.      *
  1280.      * @return string 
  1281.      */
  1282.     function getPictureHttpPath({
  1283.         return $this->m_picture_http;
  1284.     }
  1285.  
  1286.     /**
  1287.      * Get picture http path for BO: /admin_xxx/picture/
  1288.      *
  1289.      * @return string 
  1290.      */
  1291.     function getPictureHttpPathBO({
  1292.         return $this->m_root_http.$this->getPictureDirectoryName();
  1293.     }
  1294.  
  1295.     /**
  1296.      * Return the module http path : /plici_mod/
  1297.      *
  1298.      * @return string 
  1299.      */
  1300.     function getModuleHttpPath({
  1301.         return $this->getBaseHttp().$this->m_module_dir_http;
  1302.     }
  1303.     /**
  1304.      * FrontOffice session id name : fsid
  1305.      *
  1306.      * @return string 
  1307.      */
  1308.     function getSessionFoIdName({
  1309.         return 'fsid';
  1310.     }
  1311.  
  1312.     /**
  1313.      * BackOffice session id name : bsid
  1314.      *
  1315.      * @return string 
  1316.      */
  1317.     function getSessionBoIdName({
  1318.         return 'bsid';
  1319.     }
  1320.     /**
  1321.      * BackOffice Test session id name : bsidTest
  1322.      *
  1323.      * @return string 
  1324.      */
  1325.     function getSessionBoIdTestName({
  1326.         return 'bsidTest';
  1327.     }
  1328.  
  1329.     /**
  1330.      * Is page for admin site (becareful super admin is an admin site)
  1331.      *
  1332.      * @return bool 
  1333.      */
  1334.     function isAdmin({
  1335.     return $this->m_is_admin;
  1336.     }
  1337.  
  1338.     /**
  1339.      * Is page for super_admin
  1340.      *
  1341.      * @return bool 
  1342.      */
  1343.     function isAdminSuper({
  1344.            global $_PLICI_CFG;
  1345.         return ($this->getDatabaseSiteName(== $_PLICI_CFG['superadmin_databasename']);
  1346.     }
  1347.  
  1348.     /**
  1349.      * Is a page for a css or js file
  1350.      *
  1351.      * @return string 
  1352.      */
  1353.     function isJssOrCss({
  1354.         return $this->m_is_js_or_css;
  1355.     }
  1356.  
  1357.     /**
  1358.      * Modify the http parameters to add or delete someone
  1359.      *
  1360.      * @param string $p_from_string    REQUEST|POST|GET|GETPOST
  1361.      * @param array $p_add_array       Params to add
  1362.      * @param array $p_array_del_keys  Params to delete
  1363.      * @param bool $p_is_first_params_for_url 
  1364.      * @return array Parameters modified
  1365.      */
  1366.     function getArrayQueryString($p_from_string$p_add_array array()$p_array_del_keys array()$p_is_first_params_for_url true{
  1367.         if ($p_from_string == "REQUEST")
  1368.             $p_from_array $_REQUEST;
  1369.         else if ($p_from_string == "POST")
  1370.             $p_from_array $_POST;
  1371.         else if ($p_from_string == "GET")
  1372.             $p_from_array $_GET;
  1373.         else if ($p_from_string == "GETPOST")
  1374.             $p_from_array array_merge($_GET$_POST);
  1375.         else
  1376.             $p_from_array array();
  1377.  
  1378.         $array_params     array_merge($p_from_array$p_add_array);
  1379.         $p_array_del_keys array_merge($p_array_del_keys$this->params_to_not_pass_in_querystring);
  1380.         foreach($p_array_del_keys as $value)
  1381.             if (isset($array_params[$value]))
  1382.                 unset($array_params[$value]);
  1383.  
  1384.         return $array_params;
  1385.     }
  1386.  
  1387.     /**
  1388.      * Get the query string : ?var=value&var2=value2
  1389.      *
  1390.      * @param string $p_from_string    "REQUEST", "POST", "GET", "GETPOST"
  1391.      * @param array $p_add_array 
  1392.      * @param array $p_array_del_keys 
  1393.      * @param bool $p_is_first_params_for_url  Define if url start with & ou ?
  1394.      * @return string 
  1395.      */
  1396.     function getQueryString($p_from_string$p_add_array array()$p_array_del_keys array()$p_is_first_params_for_url true{
  1397.  
  1398.         $array_params $this->getArrayQueryString($p_from_string$p_add_array $p_array_del_keys $p_is_first_params_for_url );
  1399.  
  1400.         // $array_params doit contenir la liste des paramètres pour constituer
  1401.         // la querystring
  1402.         $query_string_params "";
  1403.         foreach ($array_params as $key => $value{
  1404.                 if (!is_array($value))  {
  1405.                     if ($value != ''{
  1406.                         if ($p_is_first_params_for_url{
  1407.                             $query_string_params .= "?";
  1408.                             $p_is_first_params_for_url false;
  1409.                         else {
  1410.                             $query_string_params .= "&";
  1411.                         }
  1412.                         $query_string_params .= $key."=".urlencode($value);
  1413.                     }
  1414.                 else {
  1415.                     foreach($value as $key_1 => $value_1{
  1416.                         if ($p_is_first_params_for_url{
  1417.                             $query_string_params .= "?";
  1418.                             $p_is_first_params_for_url false;
  1419.                         else {
  1420.                             $query_string_params .= "&";
  1421.                         }
  1422.                         $query_string_params .= $key."[".$key_1."]=".urlencode($value_1);
  1423.                     }
  1424.                 }
  1425.         }
  1426.         return $query_string_params;
  1427.     }
  1428.  
  1429.     /**
  1430.      * Redirect to external uri
  1431.      *
  1432.      * @param string $p_url must be a full url "http://www.xxx.xxx"
  1433.      */
  1434.     function redirectToExternalUrl($p_url{
  1435.         $this->xRedirect($p_urlfalse);
  1436.         die();
  1437.     }
  1438.  
  1439.     /**
  1440.      * Redirect
  1441.      *
  1442.      * @access private
  1443.      * @param string $p_url 
  1444.      * @param bool $p_transfert_query_string 
  1445.      */
  1446.     function xRedirect($p_url$p_transfert_query_string true{
  1447.         $param_string "";
  1448.         if ($p_transfert_query_string)
  1449.             $param_string $this->getQueryString("GET");
  1450.  
  1451.         if (headers_sent())
  1452.             trigger_error ("[".date("D M d G:i:s Y")."] "."REDIRECT error,  Location: ".$p_url.$param_string."\n".print_r(debug_backtrace()true));
  1453.  
  1454.         header("Location: ".$p_url.$param_string);
  1455.         //echo("Location: ".$p_url.$param_string);
  1456.         //debug_print_backtrace();
  1457.  
  1458.         flush();die();
  1459.  
  1460.     }
  1461.  
  1462.     /**
  1463.      * Redirect to Backoffice url
  1464.      *
  1465.      * @param string $p_url 
  1466.      */
  1467.     function redirectToBoUrl($p_url{
  1468.  
  1469.         $this->xRedirect($this->getBaseHttp().$p_url);
  1470.         die();
  1471.     }
  1472.     /**
  1473.      * Redirect to BackOffice index
  1474.      *
  1475.      */
  1476.     function redirectToBoIndex({
  1477.         //echo($this->getBaseFullHttpFo());
  1478.         //$language_id = 1;
  1479.         //$this->getCurrentLanguageId($language_id);
  1480.         $this->xRedirect($this->getBaseHttp());
  1481.         // je ne mets pas de die() ou exit() car little_authent qui utilise cette
  1482.         // méthode a besoin que le processus continue normalement afin de tuer
  1483.         // la session dans la logique des choses
  1484.     }
  1485.  
  1486.     /**
  1487.      * redirect to Front Office Index
  1488.      *
  1489.      */
  1490.     function redirectToIndex({
  1491.         //echo($this->getBaseFullHttpFo());
  1492.         $_GET array();
  1493.         $_POST array();
  1494.         $_REQUEST array();
  1495.         $this->xRedirect($this->getBaseFullHttpFo());
  1496.         // je ne mets pas de die() ou exit() car little_authent qui utilise cette
  1497.         // méthode a besoin que le processus continue normalement afin de tuer
  1498.         // la session dans la logique des choses
  1499.     }
  1500.  
  1501.     /**
  1502.      * Redirect to php self
  1503.      * Used when adding a product to avoid the link will be memorized by a navigator back
  1504.      *
  1505.      */
  1506.     function redirectToPhpSelfAndDie(){
  1507.         $this->xRedirect($_SERVER['PHP_SELF']);
  1508.         die();
  1509.     }
  1510.  
  1511.     /**
  1512.      * Redirect to a page and die
  1513.      *
  1514.      * @param integer $p_page_id 
  1515.      * @param string $p_page_title 
  1516.      * @param array $p_param 
  1517.      * @param bool $transfet_query_string 
  1518.      */
  1519.     function redirectToPageAndDie($p_page_id$p_page_title ""$p_param array()$transfet_query_string false {
  1520.  
  1521.         $param_to_transfert array('type'=>'LINK',
  1522.                             'page_id'=>$p_page_id,
  1523.                             'page_title'=>$p_page_title,
  1524.                             'nes'=>true
  1525.                             );
  1526.         foreach($p_param as $key => $value)
  1527.             $param_to_transfert['_'.$key$value;
  1528.  
  1529.         $this->xRedirect(net_url($param_to_transfertfalse)$transfet_query_string);
  1530.  
  1531.         die();
  1532.     }
  1533.  
  1534.     /**
  1535.      * Redirect to a product and die
  1536.      *
  1537.      * @param integer $pro_id 
  1538.      * @param integer $p_id_father_page 
  1539.      * @param string $pro_title 
  1540.      * @param bool $p_param 
  1541.      */
  1542.     function redirectToProductAndDie($pro_id$p_id_father_page$pro_title ""$p_param array()) {
  1543.  
  1544.         $param_to_transfert array('type'=>'PRODUCT',
  1545.                             'pro_id'=>$pro_id,
  1546.                             'pro_title'=>$pro_title,
  1547.                             'id_page'=>$p_id_father_page,
  1548.                             'nes'=>true
  1549.                             );
  1550.         foreach($p_param as $key => $value)
  1551.             $param_to_transfert['_'.$key$value;
  1552.  
  1553.         $this->xRedirect(net_url($param_to_transfertfalse));
  1554.  
  1555.         die();
  1556.     }
  1557.  
  1558.     /**
  1559.      * IS not from localhost
  1560.      *
  1561.      * @return bool 
  1562.      */
  1563.     function isNotLocalhost({
  1564.         return !$this->is_localhost;
  1565.     }
  1566.  
  1567.     /**
  1568.      * Find if it is My or For_plici direectory to use from theme.
  1569.      * because a theme can be in for_plici or my (personal theme)
  1570.      *
  1571.      * @return string 
  1572.      */
  1573.     function getMyOrPliciDirectoryForMyTheme({
  1574.         if ($this->m_theme_from_my_or_plici == ""{
  1575.             global $g_object_loader;
  1576.             $object_db_connexion =&    $g_object_loader->getDbConnexion();
  1577.             $inherited_site_name $object_db_connexion->getCurrentInheritedSiteName();
  1578.             $file_for_test $this->getViewRootPath()."/".PLICI_FOR_PLICI_DIRECTORY."/".$inherited_site_name."/";
  1579.             if ("" != $inherited_site_name && file_exists($file_for_test))
  1580.                 $this->m_theme_from_my_or_plici = PLICI_FOR_PLICI_DIRECTORY;
  1581.             else
  1582.                 $this->m_theme_from_my_or_plici = PLICI_MY_DIRECTORY;
  1583.         }
  1584.         return  $this->m_theme_from_my_or_plici;
  1585.     }
  1586.  
  1587.     /**
  1588.      * Find if it is admin
  1589.      *
  1590.      * @access private
  1591.      * @param siteInformation $p_siteinformation_object 
  1592.      * @param string $p_template_site_name 
  1593.      * @param string $p_fo_name 
  1594.      * @param string $p_bo_name 
  1595.      * @param string $p_admin_corresp_site_template 
  1596.      */
  1597.     function xFindIfIsAdmin(&$p_siteinformation_object&$p_template_site_name$p_fo_name$p_bo_name$p_admin_corresp_site_template{
  1598.                             // on détermine si on a affaire à un back office ou à un front office
  1599.                             // tout en définissant le répertoire de Template si c'est un BackOffice (car répertoire spéciaux)
  1600.                             $p_siteinformation_object->m_site_name $p_fo_name// sera sur définit si nécessaire dans la boucle ci-dessous
  1601.                             $p_siteinformation_object->m_is_admin false;
  1602.                             $template_site_name "";
  1603.                             //echo_net($bo_name);
  1604.                             if ($p_bo_name != ""{
  1605.                                 $words explode("_"$p_bo_name);
  1606.                                 if (sizeof($words>= 2)
  1607.                                     for ($i 0$i sizeof($p_admin_corresp_site_template)$i ++{
  1608.                                         if ($words[0== $p_admin_corresp_site_template[$i][0]{
  1609.                                             $p_siteinformation_object->m_is_admin true;
  1610.                                             // on positionne le nom du site
  1611.                                             $p_siteinformation_object->m_site_name $p_bo_name;
  1612.                                             $p_template_site_name $p_admin_corresp_site_template[$i][1];
  1613.                                         }
  1614.                                     }
  1615.                             }
  1616.                         }
  1617.  
  1618.     /**
  1619.      * Constructor, init the requests and objects
  1620.      *
  1621.      * @return siteInformation 
  1622.      */
  1623.     function siteInformation({
  1624.         // $local_site_racineweb_path = "C:/racine_web/";
  1625.           global $_PLICI_CFG;
  1626.           $local_site_racineweb_path $_PLICI_CFG['racine_web']."/";
  1627.  
  1628.         $this->m_fo_entry = $local_site_racineweb_path.$this->m_entrees_from_root.$this->m_front_site_dir_name;
  1629.         $this->m_bo_entry = $local_site_racineweb_path.$this->m_entrees_from_root.$this->m_back_site_dir_name;
  1630.         $this->m_fo_internal = $local_site_racineweb_path.$this->m_internal_from_root.$this->m_front_site_dir_name;
  1631.         $this->m_view_root = $local_site_racineweb_path.$this->m_view_from_root;
  1632.         $this->m_tmp_root = $local_site_racineweb_path.$this->m_tmp_from_root;
  1633.         //$this->m_themerewriting_root = $local_site_racineweb_path.$this->m_themerewriting_from_root;
  1634.         $this->m_view_external    = $local_site_racineweb_path."/".$this->getViewExternalFromRoot();
  1635.         $this->m_bo_stats_entry = $this->m_view_external.$this->m_ext_cmp_stat_dir;
  1636.  
  1637.         $this->m_local_site_racineweb_path = $local_site_racineweb_path;
  1638.  
  1639.         $admin_corresp_site_template array ();
  1640.         array_push($admin_corresp_site_templatearray ("admin""admin_sites"));
  1641.         array_push($admin_corresp_site_templatearray ("admins""admin_plici"));
  1642.         array_push($admin_corresp_site_templatearray ("adminp""admin_portails"));
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650.         //Stock les informations pour définir les informations sur le site
  1651.         $temp_chemin pathinfo($this->getHost().$_SERVER['REQUEST_URI']."padding");
  1652.  
  1653.  
  1654.  
  1655.         // determination si nous sommes sur :
  1656.         //    - localhost
  1657.         //  - ou un vrai nom domaine
  1658.         $this->is_localhost = (trim($_SERVER['SERVER_ADDR']== '127.0.0.1');
  1659.  
  1660.  
  1661.  
  1662.     // ########## start recode
  1663.  
  1664.  
  1665.  
  1666.  
  1667.  
  1668.     // on cherche le nom du Front Office (nom de domaine, ou par view/sites)
  1669.     $view_site_to_find "/".$this->getHost()."/".PLICI_VIEW_SITES_DIRECTORY."/";
  1670.     $current_http_access "/".$temp_chemin["dirname"];
  1671.     $pos_view_sites strpos($current_http_access$view_site_to_find);
  1672.     $template_site_name "";
  1673.     if (!($pos_view_sites === FALSE&& $pos_view_sites === 0{
  1674.         // l'utilisateur utilise localhost pour accéder à PLICI
  1675.         $path_after_view_sites substr($current_http_access$pos_view_sites+strlen($view_site_to_find));
  1676.  
  1677.         // definit les répertoires
  1678.         $temp_liste_rep explode("/"$path_after_view_sites);
  1679.  
  1680.         // on connait le nom du site (second nom)
  1681.         $fo_name (isset($temp_liste_rep[1])?$temp_liste_rep[1]:"");
  1682.  
  1683.         // on connait le nom du backOffice (troisieme nom)
  1684.         $bo_name (isset($temp_liste_rep[2])?$temp_liste_rep[2]:"")// nom potentiel du back office
  1685.  
  1686.         // on positionne les informations pour déterminer si on est en BO ou FO
  1687.         $this->xFindIfIsAdmin($this$template_site_name$fo_name$bo_name$admin_corresp_site_template);
  1688.  
  1689.         // on définit la racine Http du site mais sans nom de domaine juste en /
  1690.         $length_host_name_to_delete strpos($current_http_access"/"1);
  1691.         $this->m_root_http_fo = substr($current_http_access$length_host_name_to_delete$pos_view_sites+strlen($view_site_to_find)-$length_host_name_to_delete);
  1692.         // on rajoute le for_plici/nomsite/(admin/) suivant si on est en FO ou BO
  1693.         $this->m_root_http_fo .= $temp_liste_rep[0]."/".$fo_name."/";
  1694.         $this->m_root_http = $this->m_root_http_fo.($this->m_is_admin?$bo_name."/":"");
  1695.  
  1696.  
  1697.     else {
  1698.         // l'utilisateur utilise un nom de domaine pour accéder à PLICI
  1699.         $temp_liste_rep explode("/"$current_http_access);
  1700.  
  1701.         // on connait le nom de domaine c'est tout et suffisant
  1702.         // @TODO@ Enhance the detection
  1703.         $fo_name $this->getHost();
  1704.  
  1705.  
  1706.         // determine le back
  1707.         $bo_name (isset($temp_liste_rep[2])?$temp_liste_rep[2]:"")// nom potentiel du back office
  1708.  
  1709.         // on positionne les informations pour déterminer si on est en BO ou FO
  1710.         $this->xFindIfIsAdmin($this$template_site_name$fo_name$bo_name$admin_corresp_site_template);
  1711.  
  1712.         // on définit la racine Http du site mais sans nom de domaine juste en /
  1713.         $this->m_root_http_fo = "/";
  1714.         $this->m_root_http    = $this->m_root_http_fo.($this->m_is_admin?$bo_name."/":"");
  1715.  
  1716.     }
  1717.  
  1718.     
  1719.         
  1720.     // determination du chemin des images pour les sites
  1721.     $this->m_picture_http         = $this->m_root_http_fo.$this->getPictureDirectoryName();
  1722.     $this->m_picture_http_bo    = $this->m_root_http.$this->getPictureDirectoryName();
  1723.  
  1724.     // determination de la base de donnée que l'on va devoir utiliser
  1725.     $this->m_database_site_name = $this->multiDomaineModify($fo_name);
  1726.  
  1727.     // test de cohérence contre les attaques
  1728.     if (trim($this->m_database_site_name)==""){
  1729.             echo("?");
  1730.             trigger_error("Bad Requested URI (no db corresponding for $fo_name) : ".$_SERVER['REQUEST_URI']);
  1731.             die();
  1732.     }
  1733.  
  1734.     // determination du nom du répertoire de template
  1735.     if ($this->m_is_admin)
  1736.         $this->m_template_site_name = $template_site_name// $template_site_name recu de xFindIfIsAdmin()
  1737.     else
  1738.         $this->m_template_site_name = $this->m_database_site_name;
  1739.  
  1740.     // verification/création et test de l'existant du répertoire de cache
  1741.     if (!file_exists($this->getTemplateCacheFilePath()))
  1742.         if (!@net_mkdirs($this->getTemplateCacheFilePath()))
  1743.         {
  1744.             echo "<h1 style='color:red;'>Error creating cache directory. </h1>";
  1745.             trigger_error("[".date("D M d G:i:s Y")."] "."Error during creating cache directory :".$this->getTemplateCacheFilePath());
  1746.             flush;die();//$this->generateFatalError404();
  1747.         }
  1748.  
  1749.     // creation de la little URI pour config_smarty
  1750.     $litlle_uri $_SERVER["REQUEST_URI"];
  1751.     $litlle_uri str_replace($this->m_root_http""$litlle_uri);
  1752.     $pos explode("."$litlle_uri);
  1753.     if ($pos[0== $litlle_uri{
  1754.         $pos[0"index";
  1755.     }
  1756.     $litlle_uri $pos[0];
  1757.     $this->m_uri_for_ini = $litlle_uri;
  1758.  
  1759.  
  1760.  
  1761.     // rebuild du PHP_SELF car il est faut par rapport ?otre architecture
  1762.     $php_selfs explode("?"$_SERVER["REQUEST_URI"]);
  1763.     $_SERVER['PHP_SELF'$php_selfs[0];
  1764.  
  1765.     // determine si la page est un CSS ou JS
  1766.     $this->m_is_js_or_css = false;
  1767.     $len_of_php_self strlen($_SERVER['PHP_SELF']);
  1768.  
  1769.     if ($len_of_php_self 5{
  1770.         if ((substr($_SERVER['PHP_SELF']$len_of_php_self 3== ".js")){
  1771.                 header("Content-type: text/javascript");
  1772.                 $this->m_is_js_or_css = true;
  1773.         else if (substr($_SERVER['PHP_SELF']$len_of_php_self 4== ".css"{
  1774.                 header("Content-type: text/css");
  1775.                 $this->m_is_js_or_css = true;
  1776.         }
  1777.     }
  1778.  
  1779.  
  1780.     // partie s'impliquant dans la gestion des langues
  1781.     $this->m_root_http_fo_without_lang = $this->m_root_http_fo;
  1782.     $this->m_root_http_without_lang = $this->m_root_http;
  1783.  
  1784.     // ajout le repertoire indiquant la langue courrante
  1785.     if (isset($_GET['c_l_a'])) {
  1786.         $lang_id $_GET['c_l_a'];
  1787.         $this->xSetLanguageIdToUrl($lang_id);
  1788.     }
  1789. }
  1790.  
  1791.     /**
  1792.      * Display a busy page when the web site is unactivated by SuperAdmin
  1793.      *
  1794.      */
  1795.     function generateBusyPage(){
  1796.              @header('HTTP/1.0 200 OK');
  1797.              @header("Status: 200 OK");
  1798.              @header('Content-Type: text/html');
  1799.              $file_to_load $this->getViewRootPath().$this->m_error_doc_busy_page_from_view;
  1800.              $content_body "";
  1801.              if (file_exists($file_to_load)) {
  1802.                  ob_start();
  1803. /**
  1804.  * Include $file_to_load
  1805.  */
  1806. include($file_to_load);
  1807.                  $content_body ob_get_contents();
  1808.                  ob_clean();
  1809.              }
  1810.              @header('Content-Length: '.strlen($content_body));
  1811.              echo($content_body);
  1812.              die();
  1813.  
  1814.     }
  1815.  
  1816.     /**
  1817.      * Display the page not found error
  1818.      *
  1819.      */
  1820.     function generateFatalError404({
  1821.  
  1822.              @header('HTTP/1.0 404 File not found');
  1823.              @header("Status: 404 File not found");
  1824.              @header('Content-Type: text/html');
  1825.              $content_body '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">';
  1826.              $content_body.='<HTML><HEAD><TITLE>404 Not Found</TITLE>';
  1827.              $content_body.='</HEAD><BODY><H1>Not Found</H1>The requested URL "'.$_SERVER["REQUEST_URI"].'" was not found on this server.<P>';
  1828.              $content_body.='<HR><ADDRESS>IIS Server </ADDRESS></BODY></HTML>';
  1829.              @header('Content-Length: '.strlen($content_body));
  1830.              echo($content_body);
  1831.              die();
  1832.     }
  1833.  
  1834.         /**
  1835.          * CHeck for a site_name wich database it must used (manage the PLICI host)
  1836.          *
  1837.          * @param string $database_site_name 
  1838.          * @return string 
  1839.          */
  1840.         function multiDomaineModify($database_site_name){
  1841.             //echo_net($database_site_name);
  1842.           $r_result "";
  1843.           global $_PLICI_CFG;
  1844.           $id_sql_admin_super plici_mysql_connect($_PLICI_CFG['superadmin_hostname']$_PLICI_CFG['superadmin_username']$_PLICI_CFG['superadmin_password']);
  1845.  
  1846.  
  1847.           $select_db_is_ok mysql_select_db($_PLICI_CFG['superadmin_databasename']$id_sql_admin_super);
  1848.  
  1849.               if (!$select_db_is_ok)
  1850.               {
  1851.                 return "";
  1852.               }
  1853.  
  1854.           // récuperation des informations si c'est une redirection
  1855.           $sql_query "
  1856.              SELECT b.dbc_dbname
  1857.              FROM `databaseconnect` a, `databaseconnect` b
  1858.              where (a.dbc_sitename='".mysql_real_escape_string($database_site_name)."' or a.dbc_dbname='".mysql_real_escape_string($database_site_name)."')
  1859.              and a.dbc_dbname = b.dbc_dbname
  1860.              and b.dbc_dblogin<>'ALIAS';";
  1861.  
  1862.           $result @mysql_query($sql_query$id_sql_admin_super);
  1863.  
  1864.           while ($row @mysql_fetch_row($result)) {
  1865.               $r_result $row[0];
  1866.           }
  1867.           mysql_free_result($result);
  1868.           mysql_close($id_sql_admin_super);
  1869.  
  1870.           return $r_result;
  1871.         }
  1872.  
  1873.  
  1874.         /**
  1875.          * Set template's filename var
  1876.          *
  1877.          * @param string $p_tpl_filename 
  1878.          */
  1879.         function setTemplateFilename($p_tpl_filename{
  1880.             if (!is_string($p_tpl_filename))
  1881.                 $tpl_filename "incorrect_tpl_filename";
  1882.                 else $tpl_filename $p_tpl_filename;
  1883.             $this->m_template_filename = trim($tpl_filename);
  1884.         }
  1885.  
  1886.         /**
  1887.          * Return template's filename to display
  1888.          *
  1889.          * @return string 
  1890.          */
  1891.         function getTemplateFilename({
  1892.             return $this->m_template_filename;
  1893.         }
  1894.  
  1895. }
  1896.  
  1897. ?>

Documentation generated on Tue, 25 Mar 2008 15:35:48 +0100 by phpDocumentor 1.3.2