Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once ( '../config.php' );
- require_once ( $GLOBALS [ "Config" ] [ "Base_Dir" ] . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . "Bdd" . '.php' );
- require_once ( $GLOBALS [ "Config" ] [ "Base_Dir" ] . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . "Annonce" . '.php' );
- Function Verif_Static ( ) {
- if ( !is_string ( $_POST["type_transaction"] ) || !in_array ( $_POST["type_transaction"], Array ( 'vente', 'location') ) )
- Return "Veuillez choisir un type de transaction !";
- if ( !is_string ( $_POST["type_prop"] ) || !in_array ( $_POST["type_prop"], Array ( 'appartement', 'bureau_local',
- 'immeuble', 'maison', 'terrain') ) )
- Return "Veuillez choisir un type de bien immobilier";
- if ( !is_string ( $_POST["titre"] ) || empty ( $_POST["titre"] ) )
- Return "Veuillez entrer un titre";
- if ( strlen ( $_POST["titre"] ) <= 20 )
- Return "Veuillez entrer un titre d'une longueur de plus de 20 catectaires";
- if ( !is_string ( $_POST["description"] ) || empty ( $_POST["description"] ) )
- Return "Veuillez entrer une description";
- if ( strlen ( $_POST["description"] ) <= 100 )
- Return "Veuillez entrer une description d'une longueur de plus de 100 catectaires";
- if ( !is_string ( $_POST["superficie"] ) || !is_numeric ( $_POST["superficie"] ) )
- Return "Veuillez entrer une superficie valide";
- if ( !is_string ( $_POST["prix"] ) || !is_numeric ( $_POST["prix"] ) )
- Return "Veuillez entrer un prix valide";
- if ( !is_string ( $_POST["type_prix"] ) || !in_array ( $_POST["type_prix"], Array ( 'fixe', 'negociable') ) )
- Return "Veuillez l'etat de votre prix";
- if ( !is_string ( $_POST["adresse"] ) || empty ( $_POST["adresse"] ) )
- Return "veuillez entrer votre adresse";
- if ( !is_numeric ( $_POST["wilaya"] ) || $_POST["wilaya"] > 48 || $_POST["wilaya"] < 1 )
- Return "veuillez choisir une wilaya";
- if ( !is_numeric ( $_POST["region_"] ) )
- Return "veuillez choisir une commune";
- Return TRUE;
- }
- Function Verif_Static2 ( $Type ) {
- switch ( $Type ) {
- case 'appartement':
- if ( !is_numeric ( $_POST ["appartement"]['num_etages'] ) )
- Return "Veuillez choisir un numero d'etage";
- if ( !is_numeric ( $_POST ["appartement"]['nbr_pieces'] ) )
- Return "Veuillez choisir le nomre de pieces";
- Return TRUE;
- break;
- case 'bureau_local':
- if ( !is_numeric ( $_POST ["bureau_local"]['nbr_etages'] ) )
- Return "Veuillez choisir un nombre d'etages";
- Return TRUE;
- break;
- case 'immeuble':
- if ( $_POST ["immeuble"]["type_appart_f2"] == 0 &&
- $_POST ["immeuble"]["type_appart_f3"] == 0 &&
- $_POST ["immeuble"]["type_appart_f4"] == 0 &&
- $_POST ["immeuble"]["type_appart_f5"] == 0 &&
- $_POST ["immeuble"]["type_appart_plus"] == 0 )
- Return "Veuillez designer de quelle type d'appartements vous disposez";
- if ( !is_numeric ( $_POST ["immeuble"]['nbr_etages'] ) )
- Return "Veuillez choisir un nombre d'etages";
- Return TRUE;
- break;
- case 'maison':
- if ( !is_numeric ( $_POST ["maison"]['nbr_etages'] ) )
- Return "Veuillez choisir un nombre d'etages";
- if ( !is_numeric ( $_POST ["maison"]['nbr_pieces'] ) )
- Return "Veuillez choisir le nombre de pieces";
- Return TRUE;
- break;
- case 'terrain':
- Return TRUE;
- break;
- default:
- Return FALSE;
- break;
- }
- Return True;
- }
- Function array_map_recursive ( ) {
- $args = func_get_args();
- $callback = array_shift($args);
- $fn = __FUNCTION__;
- $out = array();
- $max = count(max($args));
- for($i=0; $i<$max; $i++) {
- if(count($args)==1) {
- foreach($args[0] as $key=>$value) {
- if(is_array($value))
- $out[$key] = $fn($callback, $value);
- else
- $out[$key] = call_user_func($callback, $value);
- }
- } else {
- $is_array = false;
- $callbacks_args = array();
- foreach($args as $array) {
- $values = array_values($array);
- if(isset($values[$i]))
- $value = $values[$i];
- else
- $value = '';
- if(is_array($value)) {
- $is_array = true;
- $callbacks_args[] = $value;
- } else {
- $callbacks_args[] = $value;
- }
- }
- if($is_array) {
- $m = count(max($callbacks_args));
- $new_callback_args = array($callback);
- foreach($callbacks_args as $arg) {
- if(!is_array($arg))
- $new_callback_args[] = array_fill(0, $m, $arg);
- else
- $new_callback_args[] = $arg;
- }
- $out[] = call_user_func_array($fn, $new_callback_args);
- } else {
- $out[] = call_user_func_array($callback, $callbacks_args);
- }
- }
- }
- return $out;
- }
- Function Format_Post ( ) {
- $_POST = array_map_recursive ('trim', $_POST );
- $_POST = array_map_recursive ('mysql_escape_string', $_POST );
- switch ( $_POST['type_prop'] ) {
- case 'appartement':
- $_POST ["appartement"]["meuble"] = ( isset ( $_POST ["appartement"]["meuble"] ) ? 1 : 0 );
- $_POST ["appartement"]["terrasse"] = ( isset ( $_POST ["appartement"]["terrasse"] ) ? 1 : 0 );
- $_POST ["appartement"]["balcons"] = ( isset ( $_POST ["appartement"]["balcons"] ) ? 1 : 0 );
- $_POST ["appartement"]["ascenseur"] = ( isset ( $_POST ["appartement"]["ascenseur"] ) ? 1 : 0 );
- $_POST ["appartement"]["cuisine"] = ( isset ( $_POST ["appartement"]["cuisine"] ) ? 1 : 0 );
- $_POST ["appartement"]["parking"] = ( isset ( $_POST ["appartement"]["parking"] ) ? 1 : 0 );
- break;
- case 'bureau_local':
- $_POST ["bureau_local"]["sanitaires"] = ( isset ( $_POST ["bureau_local"]["sanitaires"] ) ? 1 : 0 );
- $_POST ["bureau_local"]["vestiaires"] = ( isset ( $_POST ["bureau_local"]["vestiaires"] ) ? 1 : 0 );
- $_POST ["bureau_local"]["douche"] = ( isset ( $_POST ["bureau_local"]["douche"] ) ? 1 : 0 );
- $_POST ["bureau_local"]["parking"] = ( isset ( $_POST ["bureau_local"]["parking"] ) ? 1 : 0 );
- $_POST ["bureau_local"]["accessibilite"]= ( isset ( $_POST ["bureau_local"]["accessibilite"] ) ? 1 : 0 );
- break;
- case 'immeuble':
- $_POST ["immeuble"]["ascenseur"] = ( isset ( $_POST ["immeuble"]["ascenseur"] ) ? 1 : 0 );
- $_POST ["immeuble"]["commerce"] = ( isset ( $_POST ["immeuble"]["commerce"] ) ? 1 : 0 );
- $_POST ["immeuble"]["garage"] = ( isset ( $_POST ["immeuble"]["garage"] ) ? 1 : 0 );
- $_POST ["immeuble"]["parking"] = ( isset ( $_POST ["immeuble"]["parking"] ) ? 1 : 0 );
- $_POST ["immeuble"]["accessibilite"] = ( isset ( $_POST ["immeuble"]["accessibilite"] ) ? 1 : 0 );
- $_POST ["immeuble"]["type_appart_f2"] = ( isset ( $_POST ["immeuble"]["type_appart_f2"] ) ? 1 : 0 );
- $_POST ["immeuble"]["type_appart_f3"] = ( isset ( $_POST ["immeuble"]["type_appart_f3"] ) ? 1 : 0 );
- $_POST ["immeuble"]["type_appart_f4"] = ( isset ( $_POST ["immeuble"]["type_appart_f4"] ) ? 1 : 0 );
- $_POST ["immeuble"]["type_appart_f5"] = ( isset ( $_POST ["immeuble"]["type_appart_f5"] ) ? 1 : 0 );
- $_POST ["immeuble"]["type_appart_plus"] = ( isset ( $_POST ["immeuble"]["type_appart_plus"])? 1 : 0 );
- break;
- case 'maison':
- $_POST ["maison"]["meubles"] = ( isset ( $_POST ["maison"]["meubles"] ) ? 1 : 0 );
- $_POST ["maison"]["terrasse"] = ( isset ( $_POST ["maison"]["terrasse"] ) ? 1 : 0 );
- $_POST ["maison"]["balcons"] = ( isset ( $_POST ["maison"]["balcons"] ) ? 1 : 0 );
- $_POST ["maison"]["ascenseur"] = ( isset ( $_POST ["maison"]["ascenseur"] ) ? 1 : 0 );
- $_POST ["maison"]["acces_handicapes"] = ( isset ( $_POST ["maison"]["acces_handicapes"] ) ? 1 : 0 );
- $_POST ["maison"]["jardin"] = ( isset ( $_POST ["maison"]["jardin"] ) ? 1 : 0 );
- $_POST ["maison"]["picine"] = ( isset ( $_POST ["maison"]["picine"] ) ? 1 : 0 );
- $_POST ["maison"]["garage"] = ( isset ( $_POST ["maison"]["garage"] ) ? 1 : 0 );
- break;
- case 'terrain':
- $_POST ["terrain"]["accessibilite"] = ( isset ( $_POST ["terrain"]["accessibilite"] ) ? 1 : 0 );
- $_POST ["terrain"]["mitoyennete"] = ( isset ( $_POST ["terrain"]["mitoyennete"] ) ? 1 : 0 );
- break;
- }
- }
- Function Format_Data ( $Type ) {
- switch ( $_POST['type_prop'] ) {
- case 'appartement':
- Return Array (
- 'id' => '',
- 'num_etages' => $_POST ["appartement"]['num_etages'],
- 'nbr_pieces' => $_POST ["appartement"]['nbr_pieces'],
- 'meubles' => $_POST ["appartement"]["meuble"],
- 'terrasse' => $_POST ["appartement"]["terrasse"],
- 'balcons' => $_POST ["appartement"]["balcons"],
- 'ascenseur' => $_POST ["appartement"]["ascenseur"],
- 'cuisine_equipe'=> $_POST ["appartement"]["cuisine"],
- 'parking' => $_POST ["appartement"]["parking"]
- );
- break;
- case 'bureau_local':
- Return Array (
- 'id' => '',
- 'nbr_etages' => $_POST ["bureau_local"]['nbr_etages'],
- 'parking' => $_POST ["bureau_local"]['parking'],
- 'accessibilite' => $_POST ["bureau_local"]['accessibilite'],
- 'douche' => $_POST ["bureau_local"]['douche'],
- 'vestiaires' => $_POST ["bureau_local"]['vestiaires'],
- 'sanitaires' => $_POST ["bureau_local"]['sanitaires']
- );
- break;
- case 'immeuble':
- $Type_Appart .= ( isset ( $_POST ["immeuble"]["type_appart_f2"] ) ? 'F2 ' : NULL );
- $Type_Appart .= ( isset ( $_POST ["immeuble"]["type_appart_f3"] ) ? 'F3 ' : NULL );
- $Type_Appart .= ( isset ( $_POST ["immeuble"]["type_appart_f4"] ) ? 'F4 ' : NULL );
- $Type_Appart .= ( isset ( $_POST ["immeuble"]["type_appart_f5"] ) ? 'F5 ' : NULL );
- $Type_Appart .= ( isset ( $_POST ["immeuble"]["type_appart_plus"])? 'Plus ' : NULL );
- Return Array (
- 'id' => '',
- 'nbr_etages' => $_POST ["immeuble"]['nbr_etages'],
- 'type' => $Type_Appart,
- 'ascensseur' => $_POST ["immeuble"]['ascenseur'],
- 'commerce' => $_POST ["immeuble"]['commerce'],
- 'garage' => $_POST ["immeuble"]['garage'],
- 'parking' => $_POST ["immeuble"]['parking'],
- 'accessibilite' => $_POST ["immeuble"]['accessibilite']
- );
- break;
- case 'maison':
- Return Array (
- 'id' => '',
- 'nbr_etages' => $_POST ["maison"]['nbr_etages'],
- 'nbr_pieces' => $_POST ["maison"]['nbr_pieces'],
- 'garage' => $_POST ["maison"]['garage'],
- 'piscine' => $_POST ["maison"]['piscine'],
- 'jardin' => $_POST ["maison"]['jardin'],
- 'meubles' => $_POST ["maison"]['meubles'],
- 'terrasse' => $_POST ["maison"]['terrasse'],
- 'balcons' => $_POST ["maison"]['balcons'],
- 'cuisine_equipe' => $_POST ["maison"]['cuisine'],
- 'acces_handicapes' => $_POST ["maison"]['acces_handicapes']
- );
- break;
- case 'terrain':
- Return Array (
- 'id' => '',
- 'accesibilite' => $_POST ["terrain"]['accessibilite'],
- 'mitoyennete' => $_POST ["terrain"]['mitoyennete']
- );
- break;
- }
- }
- Format_Post ( );
- if ( is_string ( Verif_Static ( ) ) ) {
- echo '<img title="" alt="" src="images/err2.png"><p>'.Verif_Static ( ).'</p>';
- }
- else {
- if ( is_string ( Verif_Static2 ( $_POST['type_prop'] ) ) ) {
- echo '<img title="" alt="" src="images/err2.png"><p>'.Verif_Static2 ( $_POST['type_prop'] ).'</p>';
- }
- else
- {
- $Data = Format_Data ( $_POST['type_prop'] );
- $a = new Annonce ( );
- $a -> Insert_Advance_Data ( $_POST['type_prop'], $Data );
- $a -> Insert_Basic_Data ( $_POST["prix"], $_POST["type_prix"], $_POST["superficie"], $_POST["region_"], $_POST["type_transaction"], $_POST["titre"], "0", $_POST["description"], $_POST["adresse"], $_SESSION['account']['id'] );
- echo 1;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement