Ejemplo n.º 1
0
 public function maj_media_inside($idParent)
 {
     global $myAdmin;
     global $__POST;
     global $idCurrent;
     global $thisSite;
     $copy__POST = $__POST;
     $copy__POST2 = $__POST;
     foreach ($copy__POST as $field => $val) {
         // on cherche les champs commencant par fieldMedia__ qui indique qu'il y a des champs médias
         if (strpos($field, "fieldMedia__") === 0) {
             $liste = unserialize($val);
             if ($liste["type"] == "video") {
                 $type = $liste["type"] . "-" . $copy__POST["typeVideo"];
             } else {
                 $type = $liste["type"];
             }
             //echoa("<hr>");
             //echoa($type);
             //echoa($liste["field_media"]);
             //echoa($__POST);
             $field_media = $liste["field_media"];
             $idMedia = $liste["idMedia"];
             $prefixe = substr($field, strlen("fieldMedia__"), 100) . "__";
             $len_prefixe = strlen($prefixe);
             // on vide avant de remplir avec les données d'un nouveau média
             $__POST["fichier_media"] = "";
             $__POST["titre_media"] = "";
             $__POST["fichier_destination"] = "";
             $__POST["lien_destination"] = "";
             $__POST["cible_destination"] = "";
             if (count($myAdmin->LIST_LANG_DATAS) > 1) {
                 foreach ($myAdmin->LIST_LANG_DATAS as $clg => $nlg) {
                     $__POST["fichier_media_" . $clg] = "";
                     $__POST["titre_media_" . $clg] = "";
                     $__POST["fichier_destination_" . $clg] = "";
                     $__POST["lien_destination_" . $clg] = "";
                     $__POST["cible_destination_" . $clg] = "";
                 }
             }
             // echoa($copy__POST2);
             $emptyControl = array();
             foreach ($copy__POST2 as $field2 => $val2) {
                 // on cherche les champs médias correspondant
                 if (strpos($field2, $prefixe) === 0) {
                     // echoa($field2." : ".$val2);
                     $fieldOk = substr($field2, $len_prefixe, 100);
                     // on ajoute des éléments avec un nom de champs que set_datas pourra exploiter
                     $__POST[$fieldOk] = $val2;
                     foreach ($myAdmin->LIST_LANG_DATAS as $clg => $nlg) {
                         $__POST[$fieldOk . "_" . $clg] = $val2;
                     }
                     //echoa("." . $fieldOk . " : " . $val2);
                     if ($liste["type"] == "link" && strpos($fieldOk, "lien_destination") === 0) {
                         $emptyControl[] = $fieldOk;
                     }
                     if ($liste["type"] != "link" && strpos($fieldOk, "fichier_media") === 0) {
                         $emptyControl[] = $fieldOk;
                     }
                 }
             }
             //$__POST 2
             //echoa($emptyControl);
             // echoa($__POST);
             $empty = 0;
             foreach ($emptyControl as $fieldOk) {
                 //  echoa("-" . $liste["field_media"]."__" . $fieldOk);
                 if ($copy__POST2[$liste["field_media"] . "__" . $fieldOk] == "") {
                     $empty++;
                 }
             }
             // echoa($empty);
             if ($empty == count($emptyControl)) {
                 if ($idMedia != "") {
                     // on supprime le media
                     $myDeleteM = new myDelete(__FILE__);
                     $myDeleteM->table = $thisSite->PREFIXE_TBL_GEN . "medias";
                     $myDeleteM->where = "id=:id";
                     $myDeleteM->whereValue["id"] = array($idMedia, PDO::PARAM_STR);
                     $result = $myDeleteM->execute();
                 }
                 continue;
             }
             $idCurrent = 0;
             // attention, on remet à blanc l'IdCurrent du parent. (on le remet à jour à la fin)
             $formMaj2 = new formMaj();
             $formMaj2->maj_media_inside = true;
             $formMaj2->tables = $thisSite->PREFIXE_TBL_GEN . "medias";
             $formMaj2->fields = "*";
             $formMaj2->where = "id=:id";
             $formMaj2->whereValue["id"] = array($idMedia, PDO::PARAM_INT);
             $formMaj2->multiLang = true;
             $formMaj2->clause_where();
             // attribution par défaut si première image de l'Id_parent
             $formList2 = new formList();
             $formList2->tables = $thisSite->PREFIXE_TBL_GEN . "medias";
             $formList2->fields = "id";
             $formList2->where = "lg='" . $myAdmin->LANG_DATAS . "' AND field_media='" . $field_media . "' AND type='" . $type . "'";
             if ($idParent > 0) {
                 $formList2->where .= " AND id_parent=" . $idParent;
             }
             $formList2->clause_where();
             $count_datas = $formList2->get_datas();
             if ($count_datas == 0) {
                 if ($type == "image" || $type == "video") {
                     $__POST["image_principale"] = 1;
                 }
             }
             if (!isset($__POST["actif"])) {
                 $__POST["actif"] = 1;
             }
             $__POST["type"] = $type;
             $__POST["field_media"] = $field_media;
             //$this->tables . "." .
             $__POST["id_parent"] = $idParent;
             $formMaj2->set_datas();
             $idCurrent = $idParent;
             // on remet à jour l'IdCurrent du parent.
         }
         // if(strpos($field, "fieldMedia__")===0)
     }
     //$__POST
 }
Ejemplo n.º 2
0
//for($i=0;$i<=101;$i++) {
//	$lg = array_rand($myAdmin->LIST_LANG_DATAS, 1);
//	$e = array_rand($listEmplacements, 1);
//	$c = array_rand($listCampagnes, 1);
//	$b = rand(1, 5);
//	$aa = rand(2014, 2015);
//	$mm = rand(1, 12);
//	$jj = rand(1, 30);
//
//	$nb_aff = rand(0, 500);
//	$nb_click = rand(0, 50);
//
//	$resultx = $PDO->free_requete("INSERT INTO " . $myTable . " (lg, id_emplacement, id_campagne, id_bandeau, aa, mm, jj, nb_aff, nb_click) VALUES ('$lg', $e, $c, $b, $aa, $mm, $jj, $nb_aff, $nb_click)");
//}
// CHARGEMENT LISTE //////////////////////////////////////////
$formList = new formList();
$formList->tables = $myTable;
$formList->pagination = false;
// Filtres /////////////////////////////////////// ????
$formList->where = "0=0";
if ($F__id_emplacement != "" && $F__id_emplacement != "allItems") {
    $formList->where .= " AND id_emplacement='" . $F__id_emplacement . "'";
}
if ($F__id_campagne != "" && $F__id_campagne != "allItems") {
    $formList->where .= " AND id_campagne='" . $F__id_campagne . "'";
}
if ($F__lg != "" && $F__lg != "allItems") {
    $formList->where .= " AND lg='" . $F__lg . "'";
}
$formList->where .= " AND aa='" . $F__annee . "'";
$groupby = "mm";
Ejemplo n.º 3
0
<?php

require_once "config.php";
require_once DIR_LIB . "SetUpPC.php";
require_once DIR_HTDOCS . "formList.php";
$form = new formList($_POST);
// 受け取った値をセッションにセットします
foreach ($form->post as $key) {
    $_SESSION[$key] = isset($_POST[$key]) ? $_POST[$key] : null;
}
// バリデート用にセッションにセットします
$_SESSION["re_and_password"] = array($_SESSION["password"], $_SESSION["re_password"]);
$_SESSION["birth_date"] = array($_SESSION["birth_year"], $_SESSION["birth_month"], $_SESSION["birth_day"]);
// エラーチェックします
$result = $form->validate($_SESSION);
// エラーがあった場合
if ($result == false) {
    // セッションにエラーメッセージを保存します
    foreach ($form->messages as $error_name => $message) {
        $_SESSION[$error_name] = $message;
    }
    // フォームに戻ります
    header("location: member_form.php");
    exit;
}
// エラーが無かったら次に進みます
header("location: member_confirm.php");
exit;