Exemplo n.º 1
0
/**
 * Calculer une URL à partir d'un nom de fond.
 *
 * @param string fond le nom du fond
 * @param string parametres les parametres éventuels à ajouter à l'URL
 * @param boolean escape si true, on sépoare l'URL et les paramètres par &. Si false, par '&'
 */
function urlfond($fond = "", $parametres = false, $escape = false)
{
    $urlsite = urlsite();
    if (!empty($fond)) {
        if (Variable::lire("rewrite") != 0) {
            // Trouver une éventuelle reecriture
            $rw = new Reecriture();
            if ($rw->charger_param($fond, $parametres == false ? '' : "&" . $parametres, ActionsLang::instance()->get_id_langue_courante(), 1)) {
                return "{$urlsite}/{$rw->url}";
            }
        }
        $urlsite = sprintf("%s/?fond=%s", $urlsite, $fond);
    }
    if ($parametres !== false) {
        if ($escape) {
            $parametres = escape_ampersand($parametres);
        }
        $urlsite .= ($escape ? "&" : "&") . $parametres;
    }
    return $urlsite;
}
Exemplo n.º 2
0
function modifier($id, $lang, $dossier, $ligne, $titre, $chapo, $description, $postscriptum, $urlsuiv, $urlreecrite)
{
    if (!isset($id)) {
        $id = "";
    }
    if (!$lang) {
        $lang = 1;
    }
    $contenu = new Contenu();
    $contenudesc = new Contenudesc();
    $contenu->charger($id);
    $res = $contenudesc->charger($contenu->id, $lang);
    if (!$res) {
        CacheBase::getCache()->reset_cache();
        $temp = new Contenudesc();
        $temp->contenu = $contenu->id;
        $temp->lang = $lang;
        $lastid = $temp->add();
        $contenudesc = new Contenudesc();
        $contenudesc->charger_id($lastid);
    }
    $contenu->datemodif = date("Y-m-d H:i:s");
    if ($contenu->dossier != $dossier) {
        $param_old = Contenudesc::calculer_clef_url_reecrite($contenu->id, $contenu->dossier);
        $param_new = Contenudesc::calculer_clef_url_reecrite($contenu->id, $dossier);
        $reecriture = new Reecriture();
        $query_reec = "select * from {$reecriture->table} where param='&{$param_old}' and lang={$lang} and actif=1";
        $resul_reec = $reecriture->query($query_reec);
        while ($row_reec = $reecriture->fetch_object($resul_reec)) {
            $tmpreec = new Reecriture();
            $tmpreec->charger_id($row_reec->id);
            $tmpreec->param = "&{$param_new}";
            $tmpreec->maj();
        }
        $contenu->dossier = $dossier;
        $contenu->classement = $contenu->prochain_classement();
    }
    if ($ligne == "on") {
        $contenu->ligne = 1;
    } else {
        $contenu->ligne = 0;
    }
    $contenudesc->chapo = $chapo;
    $contenudesc->description = $description;
    $contenudesc->postscriptum = $postscriptum;
    $contenudesc->titre = $titre;
    $contenudesc->chapo = str_replace("\n", "<br/>", $contenudesc->chapo);
    $contenu->maj();
    $contenudesc->maj();
    $contenudesc->reecrire($urlreecrite);
    ActionsModules::instance()->appel_module("modcont", $contenu);
    if ($urlsuiv) {
        redirige("listdos.php?parent=" . $contenu->dossier);
    } else {
        redirige("" . $_SERVER['PHP_SELF'] . "?id=" . $contenu->id . "&dossier=" . $contenu->dossier . "&lang=" . $lang);
    }
    exit;
}
Exemplo n.º 3
0
}
// Chargement du contexte dans le cas d'une réécriture
if ($url != "") {
    $reecriture = new Reecriture();
    if ($reecriture->charger($url)) {
        if (!$reecriture->actif) {
            $redir = new Reecriture();
            if ($redir->charger_param($reecriture->fond, $reecriture->param, $reecriture->lang, 1)) {
                header("HTTP/1.1 301 Moved Permanently");
                redirige(urlsite($reecriture->lang) . "/" . $redir->url);
            }
        }
        // Si un changement de langue est demandé
        if (isset($_GET['lang'])) {
            // Rediriger vers l'URL dans cette langue, si elle existe
            $redir = new Reecriture();
            if ($redir->charger_param($reecriture->fond, $reecriture->param, $lang, 1)) {
                header("HTTP/1.1 301 Moved Permanently");
                redirige(urlsite($lang) . "/" . $redir->url);
            }
        } else {
            $urlcurr = urlsite($lang);
            $urlnext = urlsite($reecriture->lang);
            if ($urlcurr != $urlnext) {
                // URLs différentes: rediriger vers le domaine spécifique de la langue.
                redirige($urlnext . '/' . $reecriture->url);
            } else {
                // Mêmes URLs => fixer la langue courante est celle définie par l'URL ré-écrite, inutile de rediriger.
                $lang = $reecriture->lang;
            }
        }
Exemplo n.º 4
0
function boucleLangue($texte, $args)
{
    $exclure = lireTag($args, 'exclure');
    $id = lireTag($args, 'id');
    $res = '';
    $url = preg_replace('/[\\&\\?]*lang=[0-9]+/', '', url_page_courante());
    // S'il faut suffixer par lang=x, s'assurer de placer le bon séparateur
    if (!ActionsLang::instance()->get_un_domaine_par_langue()) {
        $url .= strstr($url, '?') == false ? '?' : '&';
    }
    $lng = new Lang();
    $query = 'select * from ' . $lng->table . ' where 1 ';
    if ($id != '') {
        $query .= ' and id in ( ' . $id . ')';
    }
    if ($exclure != '') {
        $query .= ' and id not in ( ' . $exclure . ')';
    }
    // Trouver l'url ré-écrite, si elle existe
    $reecriture = new Reecriture();
    if (Variable::lire("rewrite") != 0) {
        // L'URL de la page courante
        $requrl = lireParam('url', 'string');
        if ($requrl != '') {
            $reecriture->charger($requrl);
        }
    }
    $lngredir = new Reecriture();
    $result = $lng->query($query);
    while ($result && ($row = $lng->fetch_object($result))) {
        $lng->charger($row->id);
        if ($reecriture->actif && $lngredir->charger_param($reecriture->fond, $reecriture->param, $lng->id, 1)) {
            if (ActionsLang::instance()->get_un_domaine_par_langue()) {
                $lngurl = "{$row->url}/{$lngredir->url}";
            } else {
                $lngurl = $lngredir->url;
            }
        } else {
            if (ActionsLang::instance()->get_un_domaine_par_langue()) {
                $lngurl = str_replace(ActionsLang::instance()->get_langue_courante()->url, $row->url, $url);
            } else {
                $lngurl = $url . 'lang=' . $lng->id;
            }
        }
        $tmp = str_replace('#ID', $lng->id, $texte);
        $tmp = str_replace('#DESCRIPTION', $lng->description, $tmp);
        $tmp = str_replace('#CODE', $lng->code, $tmp);
        $tmp = str_replace('#DEFAUT', $lng->defaut ? '1' : '0', $tmp);
        $tmp = str_replace('#URL', $lngurl, $tmp);
        $res .= $tmp;
    }
    return $res;
}
Exemplo n.º 5
0
                $reecriture->maj();
                $reecriture_new = new Reecriture();
                $reecriture_new->url = $reecriture->url;
                $reecriture_new->fond = 'nexisteplus';
                $reecriture_new->param = $reecriture->param . '&ancienfond=' . $reecriture->fond;
                $reecriture_new->actif = 1;
                $reecriture_new->lang = $reecriture->lang;
                $reecriture_new->add();
            }
            break;
        case 'dossier':
            preg_match("#id_dossier=([0-9]+)([^[0-9]])*#", $a->param, $match);
            $id = $match[1];
            $dossier = new Dossier();
            if (!$dossier->charger($id)) {
                $reecriture = new Reecriture();
                $reecriture->charger($a->url);
                $reecriture->actif = 0;
                $reecriture->maj();
                $reecriture_new = new Reecriture();
                $reecriture_new->url = $reecriture->url;
                $reecriture_new->fond = 'nexisteplus';
                $reecriture_new->param = $reecriture->param . '&ancienfond=' . $reecriture->fond;
                $reecriture_new->actif = 1;
                $reecriture_new->lang = $reecriture->lang;
                $reecriture_new->add();
            }
            break;
    }
}
/*fin gestion retroactivité des url reecrites des produits supprimés*/
Exemplo n.º 6
0
function modifier($id, $lang, $ref, $prix, $ecotaxe, $promo, $prix2, $rubrique, $nouveaute, $perso, $poids, $stock, $tva, $ligne, $titre, $chapo, $description, $postscriptum, $urlsuiv, $urlreecrite)
{
    $produit = new Produit();
    $produitdesc = new Produitdesc();
    $produit->charger($ref);
    $res = $produitdesc->charger($produit->id, $lang);
    if (!$res) {
        CacheBase::getCache()->reset_cache();
        $temp = new Produitdesc();
        $temp->produit = $produit->id;
        $temp->lang = $lang;
        $lastid = $temp->add();
        $produitdesc = new Produitdesc();
        $produitdesc->charger_id($lastid);
    }
    $prix = str_replace(",", ".", $prix);
    $produit->datemodif = date("Y-m-d H:i:s");
    $produit->prix = $prix;
    $produit->prix2 = $prix2;
    $produit->ecotaxe = $ecotaxe;
    if ($produit->rubrique != $rubrique) {
        $param_old = Produitdesc::calculer_clef_url_reecrite($produit->id, $produit->rubrique);
        $param_new = Produitdesc::calculer_clef_url_reecrite($produit->id, $rubrique);
        $reecriture = new Reecriture();
        $query_reec = "select * from {$reecriture->table} where param='&{$param_old}' and lang={$lang} and actif=1";
        $resul_reec = $reecriture->query($query_reec);
        while ($row_reec = $reecriture->fetch_object($resul_reec)) {
            $tmpreec = new Reecriture();
            $tmpreec->charger_id($row_reec->id);
            $tmpreec->param = "&{$param_new}";
            $tmpreec->maj();
        }
        $produit->rubrique = $rubrique;
        $produit->classement = $produit->prochain_classement();
    }
    if ($promo == "on") {
        $produit->promo = 1;
    } else {
        $produit->promo = 0;
    }
    if ($nouveaute == "on") {
        $produit->nouveaute = 1;
    } else {
        $produit->nouveaute = 0;
    }
    if ($ligne == "on") {
        $produit->ligne = 1;
    } else {
        $produit->ligne = 0;
    }
    $produit->perso = $perso;
    $produit->poids = $poids;
    $produit->stock = $stock;
    $produit->tva = str_replace(",", ".", $tva);
    $produitdesc->chapo = $chapo;
    $produitdesc->description = $description;
    $produitdesc->postscriptum = $postscriptum;
    $produitdesc->titre = $titre;
    $produitdesc->chapo = str_replace("\n", "<br />", $produitdesc->chapo);
    $rubcaracteristique = new Rubcaracteristique();
    $caracteristiquedesc = new Caracteristiquedesc();
    $caracval = new Caracval();
    $query = "select * from {$rubcaracteristique->table} where rubrique='" . $produit->rubrique . "'";
    $resul = mysql_query($query);
    while ($row = mysql_fetch_object($resul)) {
        $caracval = new Caracval();
        $deb = "caract";
        $deb2 = "typecaract";
        $val = $row->caracteristique;
        $var = $deb . $val;
        $var2 = $deb2 . $val;
        global ${$var};
        global ${$var2};
        $query2 = "delete from {$caracval->table} where produit='" . $produit->id . "' and caracteristique='" . $row->caracteristique . "'";
        $resul2 = mysql_query($query2);
        if (${$var2} == "c" && ${$var} != "") {
            foreach (${$var} as $selectval) {
                if ($selectval != "") {
                    $caracval->produit = $produit->id;
                    $caracval->caracteristique = $row->caracteristique;
                    $caracval->caracdisp = $selectval;
                    $caracval->add();
                }
            }
        } else {
            if (${$var} != "") {
                $caracval->produit = $produit->id;
                $caracval->caracteristique = $row->caracteristique;
                $caracval->valeur = ${$var};
                $caracval->add();
            }
        }
    }
    $produit->maj();
    $produitdesc->maj();
    $produitdesc->reecrire($urlreecrite);
    $rubdeclinaison = new Rubdeclinaison();
    $declinaisondesc = new Declinaisondesc();
    $declidisp = new Declidisp();
    $declidispdesc = new Declidispdesc();
    $query = "select * from {$rubdeclinaison->table} where rubrique='" . $rubrique . "'";
    $resul = mysql_query($query);
    $nb = 0;
    while ($row = mysql_fetch_object($resul)) {
        $declinaisondesc->charger($row->declinaison);
        $query2 = "select * from {$declidisp->table} where declinaison='{$row->declinaison}'";
        $resul2 = mysql_query($query2);
        $nbres = mysql_num_rows($resul2);
        while ($row2 = mysql_fetch_object($resul2)) {
            $var = "stock" . $row2->id;
            $var2 = "surplus" . $row2->id;
            global ${$var}, ${$var2};
            $stock = new Stock();
            if ($stock->charger($row2->id, $produit->id) == 0) {
                $stock->declidisp = $row2->id;
                $stock->produit = $produit->id;
                $stock->valeur = ${$var};
                $stock->surplus = ${$var2};
                $stock->add();
                $nb += $stock->valeur;
            } else {
                $stock->valeur = ${$var};
                $stock->surplus = ${$var2};
                $stock->maj();
                $nb += $stock->valeur;
            }
        }
    }
    if ($nb) {
        $produit->stock = $nb;
    }
    $produit->maj();
    ActionsModules::instance()->appel_module("modprod", $produit);
    if ($urlsuiv) {
        ?>
            <script type="text/javascript">
                    window.location="parcourir.php?parent=<?php 
        echo $produit->rubrique;
        ?>
";
            </script>
            <?php 
    } else {
        ?>
            <script type="text/javascript">
                    window.location="<?php 
        echo $_SERVER['PHP_SELF'];
        ?>
?ref=<?php 
        echo $produit->ref;
        ?>
&rubrique=<?php 
        echo $produit->rubrique;
        ?>
&lang=<?php 
        echo $lang;
        ?>
";
            </script>
            <?php 
    }
}
 public function delete()
 {
     if ($reecriture = $this->charger_reecriture()) {
         $reecriture->actif = 0;
         $reecriture->maj();
         $reecriture_new = new Reecriture();
         $reecriture_new->url = $reecriture->url;
         $reecriture_new->fond = 'nexisteplus';
         $reecriture_new->param = $reecriture->param . '&ancienfond=' . $reecriture->fond;
         $reecriture_new->actif = 1;
         $reecriture_new->lang = $reecriture->lang;
         $reecriture_new->add();
     }
     parent::delete();
 }
 /**
  * 
  * if folder change, the rewriting must be check
  * 
  * @param int $folder
  */
 public function checkRewrite($folder)
 {
     if ($this->dossier != $folder) {
         $param_old = Contenudesc::calculer_clef_url_reecrite($this->id, $this->oldFolder);
         $param_new = Contenudesc::calculer_clef_url_reecrite($this->id, $folder);
         //$query_reec = "select * from ".Reecriture::TABLE." where param='&$param_old' and lang=$lang and actif=1";
         /* @author etienne
          * We need to edit params for all rewriting rules since :
          *  - inactive rules are redirected to new url based on these params
          *  - params are the same no matter the lang
          */
         $query_reec = "select * from " . Reecriture::TABLE . " where param='&{$param_old}'";
         $resul_reec = $this->query($query_reec);
         while ($resul_reec && ($row_reec = $this->fetch_object($resul_reec))) {
             $tmpreec = new Reecriture();
             $tmpreec->charger_id($row_reec->id);
             $tmpreec->param = "&{$param_new}";
             $tmpreec->maj();
         }
         $this->dossier = $folder;
     }
 }
Exemplo n.º 9
0
/*                                                                                   */
/*      This program is free software; you can redistribute it and/or modify         */
/*      it under the terms of the GNU General Public License as published by         */
/*      the Free Software Foundation; either version 3 of the License                */
/*                                                                                   */
/*      This program is distributed in the hope that it will be useful,              */
/*      but WITHOUT ANY WARRANTY; without even the implied warranty of               */
/*      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                */
/*      GNU General Public License for more details.                                 */
/*                                                                                   */
/*      You should have received a copy of the GNU General Public License            */
/*	    along with this program. If not, see <http://www.gnu.org/licenses/>.         */
/*                                                                                   */
/*************************************************************************************/
require_once __DIR__ . "/../pre.php";
require_once __DIR__ . "/../auth.php";
require_once __DIR__ . "/../../fonctions/divers.php";
if (!est_autorise("acces_catalogue")) {
    exit;
}
header('Content-Type: text/html; charset=utf-8');
$reecriture = new Reecriture();
if ($reecriture->charger($_GET['url'])) {
    ?>
		<img src="gfx/interdiction.png" style="float: right;" />
	<?php 
} else {
    ?>
		<img src="gfx/validation.png" style="float: right;" />
	<?php 
}
Exemplo n.º 10
0
 public function checkRewrite($category, $lang)
 {
     if ($this->rubrique != $category) {
         $query = "select max(classement) as maxClassement from " . Produit::TABLE . " where rubrique='" . $category . "'";
         $resul = $this->query($query);
         $this->classement = $this->get_result($resul, 0, "maxClassement") + 1;
         $param_old = Produitdesc::calculer_clef_url_reecrite($this->id, $this->rubrique);
         $param_new = Produitdesc::calculer_clef_url_reecrite($this->id, $category);
         //$query_reec = "select * from ".Reecriture::TABLE." where param='&$param_old' and lang=$lang and actif=1";
         /* @author etienne
          * We need to edit params for all rewriting rules since :
          *  - inactive rules are redirected to new url based on these params
          *  - params are the same no matter the lang
          */
         $query_reec = "select * from " . Reecriture::TABLE . " where param='&{$param_old}'";
         $resul_reec = $this->query($query_reec);
         while ($resul_reec && ($row_reec = $this->fetch_object($resul_reec))) {
             $tmpreec = new Reecriture();
             $tmpreec->charger_id($row_reec->id);
             $tmpreec->param = "&{$param_new}";
             $tmpreec->maj();
         }
         $this->rubrique = $category;
     }
 }