$error = $obj->validate();
    if ($error) {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>" . $error . "</font>";
    } else {
        /*save bannr section content*/
        if ($_FILES['file']['name'] != "") {
            $image_name = time() . $_FILES['file']['name'];
            $path = LIST_ROOT . '/images/logistique/';
            move_uploaded_file($_FILES["file"]["tmp_name"], $path . $image_name);
        } else {
            $image_name = $oldimage;
        }
        $slug = str_replace(' ', '_', strtolower($tabtitle));
        $dataArr = array('tab_title' => htmlentities($tabtitle), 'banner_image' => $image_name, 'content' => $content, 'page_name' => 'Logistique', 'slug' => $slug);
        if ($id == "") {
            $banner_insert = $obj_setting->save('content_page', $dataArr);
        } else {
            $banner_insert = $obj_setting->update('content_page', $dataArr, "id=" . $id);
        }
        $_SESSION['success_msg'] = 'Successfully Saved';
        echo '<script>location.href="' . DEFAULT_URL . '/superadmin/logistique/index.php";</script>';
        exit;
    }
}
/*Fetch banner section content*/
if (isset($_GET['id'])) {
    $fetchSetting = $obj_setting->read('content_page', 'id = ' . $_GET['id']);
    $getSetting = $db->fetchNextObject($fetchSetting);
    $id = $getSetting->id;
    $tabTitle = $getSetting->tab_title;
    $bannerImage = $getSetting->banner_image;
    unset($obj);
    if ($error_tab1 != '') {
        $errorMsges .= $error_tab1;
    }
    if ($error_tab2 != '') {
        $errorMsges .= $error_tab2;
    }
    if ($error_tab3 != '') {
        $errorMsges .= $error_tab3;
    }
    if ($error_tab4 != '') {
        $errorMsges .= $error_tab4;
    }
    if ($error_tab4 == '' && $error_tab3 == '' && $error_tab1 == '' && $error_tab2 == '') {
        $_SESSION['success_msg'] = 'New car has been saved successfully.';
        if ($formObj->AddCar($_POST, $_FILES)) {
            /*Save data in car_flat for searching*/
            $lastInsertedId = mysql_insert_id();
            $images = $obj_setting->getAllImage($lastInsertedId);
            $dataArr = array('car_id' => $lastInsertedId, 'make' => $obj_setting->getOptionNameById($manufacturer), 'model' => $model, 'year' => $madeYear, 'price' => $price, 'description' => $description, 'title' => $fullName, 'date' => date("Y-m-d H:i:s"), 'images' => implode(',', $images));
            $obj_setting->save('car_flat', $dataArr);
            if (!empty($_REQUEST['type']) && $_REQUEST['type'] == 'nostock') {
                echo '<script>location.href="' . DEFAULT_ADMIN_URL . '/new_stock/new_car/index.php";</script>';
            }
            echo '<script>location.href="' . DEFAULT_ADMIN_URL . '/car";</script>';
            exit;
        } else {
            $errorMsg = "<font color='#FF0000' family='verdana' size=2>" . $formObj->error . "</font>";
        }
    }
}
<?php

include_once "conf/config.inc.php";
if (isset($_POST) && isset($_POST["submit_inq"])) {
    global $db;
    $common_obj = new common();
    $arr = array("car_id" => $_POST['car_id'], "name" => $_POST['name'], "email" => $_POST['email'], "phone" => $_POST['phone'], "message" => $_POST['message'], "address" => $_POST['address'], "type" => 0);
    $common_obj->save("contact", $arr);
    $to = '*****@*****.**';
    // Your subject
    $subject = 'Inquiry About Car';
    // From
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    // Additional headers
    $headers .= 'From: ' . $_POST['name'] . '<' . $_POST['email'] . '>' . "\r\n";
    $message = 'The person that contacted you is  ' . $_POST['name'] . '<br/>	E-mail: ' . $_POST['email'] . '<br/>
			Phone Number: ' . $_POST['phone'] . '<br/>
			Address: ' . $_POST['address'] . '<br/>
			Message: ' . $_POST['message'] . '<br/>';
    $sentmail = mail(SITE_ADMIN_EMAIL, $subject, $message, $headers);
}
?>


  <?php 
include LIST_ROOT . "/includes/views/header.php";
?>
  <div class="main_middle">
    <div class="middle">
      <div class="middle_two">
        $file_type = strtolower(end(explode(".", $_FILES["image"]["name"])));
        if ($file_type == "png" || $file_type == "jpeg" || $file_type == "jpg" || $file_type == "gif") {
            $valid_file_type = 'yeap';
        } else {
            $valid_file_type = '';
        }
        $obj->add_fields($valid_file_type, 'req', 'Please upload image file only.');
    }
    $error = $obj->validate();
    //--------------------------------------------//
    if ($error) {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>" . $error . "</font>";
    } else {
        $image = '';
        if (!empty($_FILES["image"]["name"])) {
            $type = strtolower(end(explode(".", $_FILES["image"]["name"])));
            if ($type == "png" || $type == "jpeg" || $type == "jpg" || $type == "gif") {
                $image = $currentTimestamp . '-' . $obj_handle->makeAlias($_FILES["image"]["name"]) . '.' . $type;
                @chmod(LIST_ROOT_ADMIN . "/images/new_model", 0777);
                move_uploaded_file($_FILES["image"]["tmp_name"], LIST_ROOT_ADMIN . "/images/new_model/" . $image);
            }
        }
        $dataArr = array('brand_name' => $brand_name, 'year' => $year, 'image' => $image, 'prix' => $prix, 'publish' => $publish, 'creation_date' => $currentTimestamp);
        $add_product = $obj_block->save(TBL_NEW_MODEL, $dataArr);
        $_SESSION['msg'] = 'New Model Successfully Added';
        redirectUrl(DEFAULT_ADMIN_URL . '/new_model/index.php');
        unset($obj_block);
        unset($obj);
        exit;
    }
}
        $emailData['téléphone'] = $phone;
        $emailData['Un message'] = $massage;
        $emailData["Vous avez reçu un e-mail à partir d'ici"] = DEFAULT_URL . "/contacts";
        $message = emailContentsWrapper($emailData, $heading, $subHeading);
        $adminEmails = $common->getAdminNotificationEmails();
        foreach ($adminEmails as $emaiA) {
            $sentmail = sendSmtpMail($emaiA, $subject, $message);
        }
        //Send confirmation to User
        $heading = 'Merci';
        $subHeading = 'Votre demande de contact a été reçu avec succès.';
        $footerHeading = 'Merci encore<br/>Americamcarcentrale.com';
        $message = emailContentsWrapper(null, $heading, $subHeading, $footerHeading);
        sendSmtpMail($_POST['email'], 'Merci', $message);
        // Save request for admin leads
        $time = time();
        $currentTimestamp = getCurrentTimestamp();
        $dataArray = array('name' => $fname . " " . $lname, 'email' => $email, 'phone' => $phone, 'message' => $massage, 'type' => 1, 'mail_date' => $currentTimestamp);
        $save = $common->save("contact", $dataArray);
        $send = 1;
        $_SESSION['success'] = "ok";
        echo "<script>location.href='" . DEFAULT_URL . "/thank_you.php';</script>";
        exit;
    }
    unset($obj);
} else {
    if ($website != "") {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>Please provide all fields value.</font>";
        $_SESSION['msg'] = $errorMsg;
    }
}
        $result = $obj_product->numberOfRows(TBL_MEMBER, 'name = "' . $name . '" AND cat_id=' . $cat_id . ' AND sub_cat_id =' . $sub_cat_id);
    }
    $obj->add_fields($cat_id, 'req', 'Please Select Product Category');
    $obj->add_fields($sub_cat_id, 'req', 'Please Select Product Sub Category');
    $error = $obj->validate();
    if ($error || $result > 0) {
        if ($result > 0) {
            $error .= "Product already Exist in selected Category.";
        }
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>" . $error . "</font>";
    } else {
        if ($_FILES['logo']['name']) {
            $logo = $currentTimestamp . '_' . $_FILES['logo']['name'];
            move_uploaded_file($_FILES['logo']['tmp_name'], LIST_ROOT_ADMIN . "/products_manager/upload/" . $logo);
        } else {
            $logo = 'no_img.jpg';
        }
        $p_slug = $obj_handle->makeAlias($name);
        if ($obj_product->numberOfRows(TBL_PRODUCT, "p_slug = '" . $p_slug . "'") > 0) {
            $p_slug = $obj_handle->makeAlias($p_slug . " " . $cat_id);
        }
        $dataArr = array('name' => $name, 'logo' => $logo, 'desc' => $desc, 'cat_id' => $cat_id, 'sub_cat_id' => $sub_cat_id, 'publish' => $publish, 'creation_date' => $currentTimestamp, 'p_slug' => $p_slug);
        $add_product = $obj_product->save(TBL_PRODUCT, $dataArr);
        $_SESSION['msg'] = RECORD_ADD;
        redirectUrl(DEFAULT_ADMIN_URL . '/members/product.php');
        exit;
    }
}
?>

                    $carlist .= '<tr>';
                    $carlist .= '<td>' . $ebays->title . ' </td>';
                    $carlist .= '<td> - $' . number_format($ebays->buyItNowPrice, 2) . '</td>';
                    $carlist .= '</tr>';
                    $flage = true;
                    $common->update('contact', array("mail_date" => $currentTimestamp, 'status' => 1), ' id=' . $contact_id);
                }
            }
        }
    }
    $carlist .= '</table>';
    //echo $carlist; die;
    if ($flage) {
        $replaces = array('[CUSTOMER_NAME]' => $name, '[CAR_LIST]' => $carlist, '[ADDRESS]' => $address, '[TELEPHONE]' => $phone, '[EMAIL_ADDRESS]' => $adminemail, '[TERMS_URL]' => DEFAULT_URL);
        $messages = strReplaceAssoc($replaces, $message);
        $headers = "From: " . $adminemail . "\r\n";
        $headers .= "Reply-To: " . $adminemail . "\r\n";
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
        //echo $messages; die;
        //mail($toEmail,$subject,$messages,$headers);
        sendSmtpMail($toEmail, $subject, $message);
        $common->save('email_log', array("email" => $toEmail, "content" => $messages, "sent_date" => $currentTimestamp, "next_date" => $next, 'status' => 1));
        if ($i == $count) {
            $_SESSION['success_msg'] = "Mail Sent Succefully";
            echo '<script>alert("thanks");window.location.href="' . DEFAULT_ADMIN_URL . '/template/reminder/index.php";</script>';
            exit;
        }
        $i++;
    }
}
/* Get Current Date Time Stamp */
$currentTimestamp = getCurrentTimestamp();
if (isset($submit) && $submit != "" && $_SERVER['REQUEST_METHOD'] == 'POST') {
    $error = '';
    $obj->add_fields($title, 'req', 'Please Enter Title');
    $error = $obj->validate();
    $image = '';
    //--------------------------------------------//
    if ($error) {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>" . $error . "</font>";
    } else {
        if ($_FILES["logo"]["name"]) {
            $type = explode(".", $_FILES["logo"]["name"]);
            if (end($type) == "png" || end($type) == "jpeg" || end($type) == "jpg" || end($type) == "gif") {
                $image = getCurrentTimestamp() . '-' . $_FILES["logo"]["name"];
                //chmod(DEFAULT_ADMIN_URL."/images/brands",0777);
                move_uploaded_file($_FILES["logo"]["tmp_name"], LIST_ROOT_ADMIN . "/images/brands/" . $image);
            }
        }
        $dataArr = array('title' => $title, 'logo' => $image, 'publish' => $publish, 'creation_date' => $currentTimestamp);
        $add_product = $obj_block->save(TBL_BRANDS, $dataArr);
        $_SESSION['msg'] = 'Brand Successfully Added';
        redirectUrl(DEFAULT_ADMIN_URL . '/brands/index.php');
        unset($obj_block);
        unset($obj);
        exit;
    }
}
?>

        $file_type = strtolower(end(explode(".", $_FILES["image"]["name"])));
        if ($file_type == "png" || $file_type == "jpeg" || $file_type == "jpg" || $file_type == "gif") {
            $valid_file_type = 'yeap';
        } else {
            $valid_file_type = '';
        }
        $obj->add_fields($valid_file_type, 'req', 'Please upload image file only.');
    }
    $error = $obj->validate();
    //--------------------------------------------//
    if ($error) {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>" . $error . "</font>";
    } else {
        $image = '';
        if (!empty($_FILES["image"]["name"])) {
            $type = strtolower(end(explode(".", $_FILES["image"]["name"])));
            if ($type == "png" || $type == "jpeg" || $type == "jpg" || $type == "gif") {
                $image = $currentTimestamp . '-' . $obj_handle->makeAlias($_FILES["image"]["name"]) . '.' . $type;
                @chmod(LIST_ROOT_ADMIN . "/images/htmltemplate", 0777);
                move_uploaded_file($_FILES["image"]["tmp_name"], LIST_ROOT_ADMIN . "/images/htmltemplate/" . $image);
            }
        }
        $dataArr = array('title' => $title, 'details_url' => $details_url, 'image' => $image, 'price' => $price, 'publish' => $publish, 'creation_date' => $currentTimestamp);
        $add_product = $obj_block->save(TBL__HTMLTEMPLATE, $dataArr);
        $_SESSION['msg'] = 'Car Template Successfully Added';
        redirectUrl(DEFAULT_ADMIN_URL . '/htmltemplate/index.php');
        unset($obj_block);
        unset($obj);
        exit;
    }
}
    //$obj->add_fields($model, 'req', 'Please select a Model');
    $obj->add_fields($year, 'req', 'Please Enter year');
    $obj->add_fields($expert, 'req', 'Please Enter Excerpt');
    $obj->add_fields($ensemble, 'req', 'Please Enter Ensemble');
    $obj->add_fields($characteristique, 'req', 'Please Enter Characteristique');
    $obj->add_fields($_FILES['image']['name'], 'req', 'Please Upload Image');
    $obj->add_fields($_FILES['image'], 'ftype=jpg,gif,png', 'Please Upload Valid Image');
    $error = $obj->validate();
    //echo "<pre>";
    //print_r($error); die;
    if ($error) {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>Please fill all required fields.</font>";
    } else {
        $make_name = $makes[$make];
        $models_new = $getEntityObj->getEntityOutput($make, 4);
        $model_name = $models_new[$model];
        $image_name = time() . '-' . $_FILES['image']['name'];
        //$path = LIST_ROOT.'/images/reviews/media/';
        $path = LIST_ROOT_ADMIN_REVIEW_IMAGEPATH . '/';
        move_uploaded_file($_FILES["image"]["tmp_name"], $path . $image_name);
        $_SESSION['success_msg'] = 'New review has been saved successfully.';
        $dataArr = array('short_description' => $short_description, 'old_new' => $old_new, 'editorial' => $editorial, 'pdsf' => $pdsf, 'mpg' => $mpg, 'image' => $image_name, 'make' => $make, 'model' => $model, 'year' => $year, 'expert' => $expert, 'ensemble' => $ensemble, 'characteristique' => $characteristique, 'updated' => getCurrentTimestamp(), 'make_name' => $make_name, 'model_name' => $model_name);
        $review_id = $obj_setting->save('reviews', $dataArr);
        foreach ($medias as $media) {
            $dataArrMedia = array('review_id' => $review_id, 'media_type' => $media['mediatype'], 'order_id' => $media['order'], 'media_name' => $media['value'], 'updated' => getCurrentTimestamp());
            $review_media_id = $obj_setting->save('reviews_media', $dataArrMedia);
        }
        echo '<script>location.href="' . DEFAULT_ADMIN_URL . '/reviews";</script>';
        exit;
    }
}
extract($_GET);
extract($_POST);
$obj_setting = new common();
$obj = new validation();
echo $att_label;
/* Get Current Date Time Stamp */
$currentTimestamp = getCurrentTimestamp();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $error = '';
    $obj->add_fields($att_code, 'req', 'Please Enter Atrribute Code');
    $error = $obj->validate();
    if ($error) {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>Please fill all required fields.</font>";
    } else {
        if (trim($slug)) {
            $slug = makeAlias($slug);
        } else {
            $slug = makeAlias($name);
        }
        if (trim($metatitle)) {
            $metatitle = $metatitle;
        } else {
            $metatitle = $name;
        }
        $_SESSION['success_msg'] = 'New Attribute has been saved successfully.';
        $dataArr = array('attribute_code' => $att_code, 'frontend_type' => $att_type, 'frontend_label' => $att_label, 'is_required' => $req, 'default_value' => $att_def, 'publish' => $publish);
        $update_site = $obj_setting->save(TBL_ATTRIBUTE, $dataArr);
        echo '<script>location.href="' . DEFAULT_ADMIN_URL . '/page";</script>';
        exit;
    }
}
				content:"Nous avons ajouté votre demande avec succès",
				type:"info",
				timeOut:5000,
				opacity:0.6,
				autoClose:true
			});
		});
	})(jQuery); 
	</script>';
} elseif (isset($_POST) && isset($_POST["add_to_enquire"])) {
    global $db;
    //error_reporting(E_ALL);
    //ini_set('display_errors', '1');
    $common_obj = new common();
    $arr = array("car_id" => $_POST['car_id'], "email" => $_POST['email'], "submit_date" => date("Y-m-d H:i:s"));
    $common_obj->save("car_inquiry", $arr);
    $mailHeading = !empty($_POST['order']) && $_POST['order'] == 1 ? "A fait une demande de L’historique de cette voiture ici." : "A fait une demande de fiche technique de cette voiture ici.";
    //Send confirmation to User
    $heading = 'Merci';
    $subHeading = 'Votre adresse e-mail a été reçu, un de nos représentants vous contactera avec les informations de la voiture.<br><br>Merci encore<br/>Americamcarcentrale.com';
    $message = emailContentsWrapper(null, $heading, $subHeading);
    sendSmtpMail($_POST['email'], 'Merci', $message);
    // Send admin Notifications
    $heading = "Un invité envoyé demande d'enquête pour une voiture";
    $subHeading = 'ce client ' . $_POST['email'] . ' ' . $mailHeading . '<br/>Détails du véhicule';
    $emailData['Id de voiture'] = $_POST['car_id'];
    $emailData['titre'] = $carInfo['fullName'];
    $emailData['vin'] = $carInfo['vin'];
    $emailData['Achat immédiat Prix'] = $common->CurrencyConverter($carInfo['price']) . ' &euro;';
    $emailData['Construire'] = $carInfo['manufacturer'];
    $emailData['Modèle'] = $carInfo['model'];
function fetchEbayCar($itemId, $action)
{
    $common = new common();
    // crated by us
    //$version = 773;
    //$devid = "e872f3d0-8bee-4784-b631-f0c6e0468c21";
    //$appid = "Planetwe-4831-4322-a03c-57a0a2d3aafb";
    //$certid = "574bc5e0-889c-431c-b3aa-918f19b83e0e";
    //$siteid =0;
    //$callname = "GetItem";
    //$accesToken = "AgAAAA**AQAAAA**aAAAAA**4gqXUg**nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6AGkISjAJWBpg6dj6x9nY+seQ**An0BAA**AAMAAA**5D3c3AfScHkf+mmuQBsiuSAHvJ5dvb5KeUGyfX43IK6P4wjRzo5Rj7MxubzlEB+QmPf+nrkYAUU8V0nczpqvYaFl8orKRmqEdXKW0JqUE72CHfNIeNkcE7usMZZ9g97D9Be4yfDdAILBxTOEh4TdV4U3YD19Gfq1aSalXtSnLNndWFKS3j4vO4yBcZImdPkoNgCj7gtwidbz8l6zv+EHBUIRXqoEMP6gAZIY2JLjGq1T/u96NqQj7UKyzwoCvAsmUWL/0JTieQXuKqlM5sFdwKdEUAJzgaiK93ghP2aLFde3Rxqgh5sijGeT+f2KIKODYO9PILnRsiEKFyamt5OPLRmPfFeKBAv9kYoj0plLHbeeEBMP+F6QdwHrnK8pq/xMMm1K71JpjN1hoI3MbrFzNLNh/6b8NTHjlbYqjn8e6TJ2j8CyQe8XaiB4BlI4aBdJXW2ikxaWtBP7SAHTSmTFKk7t7xNP3Ti+BAAr1Uc+kyMBLs7o2m5vvJxz6bj/fxgcoUAv+GNt5/PtuuB60o4x9bG1WWp50+zZsqBlLCEwBxDKhbZ49jJRNc8nbM9xUcaupLxVTxUwbqoPpWB2i/dZuA+7xxfB0AyCTzFU9xPpZUIoEfCUcSFtZ0euub2w9jET4imzeJCc41sE3Qo/wB2AubK5oMn6wJXTsvu2sHRQgIsM/vJOweg6uLIZ15gb6Pn7JD+trob9IzCXoSwK/ytCdDOWfT589Fg7tw6A4pK31eMUjIwaYuH+l1SoItIBWBLV";
    //Details provided by client
    $version = 849;
    $devid = "E69WP8Z16P996R8H2K1EWU7LC2F4P4";
    $appid = "francois-1656-442d-bf2d-37b84676c2fb";
    $certid = "2f56d2cd-9d4b-45a5-8945-67c432f53d29";
    $siteid = 0;
    $callname = "GetItem";
    //$accesToken = "AgAAAA**AQAAAA**aAAAAA**It2lUg**nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6wJlIOhCJWCpQ6dj6x9nY+seQ**fzgAAA**AAMAAA**HO7Ff5QcNtBiD9NvWdD1xP+4GLKHGfpUP+SwT+cDf4AnxrGLcjv2DHcPivAGLK06agYWzcX4jpuhunP+WbdU5Uw8T8S1fBdsV2pwuCVTG1a2lMz2zHSgqvhQ+CLS3eBqZ9APg/gg/HVG8PBhJa147C4OtSAoJb0Q1CNM9Fmi4iHoX91KM14b6g9LhOUpIH1ODtlpkiwQhA+ZBe8lyxZzgNgVL1NpaWBv6Z5WRBgdQmGRh5OUxhteTOp0iDG5pzVA7isLCfQyBf41mcrdMAWrNBlyGGVSIWjk82M4kHYbd7uRA9w+cr+YUkC2J8f2T3DuoRqxBDShUnlm9rn+PYYqYJjn5c+DIz6GMMVnrgURZd/8HHu5jbGCGnEgnTIvcP64zdUSzzMV9i6XE32Mw2Wse0qVVPEMYRPwkGAejvBh5NlwpSYaTHw4ePmGV5oKYma/Qoyxa0CxsZ6YFIgKI2RVsjUJBihixnfQU7JUcjwwMtJ1oVfyjmT7aDX5CGkwR9LfGyJQWAYDler441lRFw8Ci7D87h1H6sd2SY2Szy5HsWuNTwOl8IHgio6Yw1acpZSAUDJ8jhWV8pKITBq0oJvQX7VF8DjjYNN+zp4329U89yfH1kjaS79a5TJgBSUMU9UDZi2HilDzEaPLJJcZr8DctxoZrEsh1fozvlvwbAehRQcsHnBqTCVGWme47BY9Ia5eTipFlSYDo7Sl8V0gUQeiEOtca+f0sR6qvb85sW5EYDWuWXCaS4YR+taT9L5OxO25";
    $accesToken = "AgAAAA**AQAAAA**aAAAAA**fqSbVQ**nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6AGkISjAJWBpg6dj6x9nY+seQ**An0BAA**AAMAAA**F5lNYkkTF5+eh9ORJHXXaAi0kOFTeYMNzeVxybYeVyTcvJWc8bn4auZqxUK25zO8gqfChFLU1b3UbRcgJmhoQcVqb0L7rmNpFctACptDN7zUw+iv9ZLeePmxUFivtc5KUtPa7XLYKF4khJc7l5MWBwtzGC7+QKPWNRBoccYnpz5X6n7KHymsf1sH00toTpSczFBzQGFQcP65pyioz45/QQ//8f90jOyFXs60nR0RGHItNnwjjfQy/J2U6AhXSorLl3jOhqJhMErkNrmzkv9hjTYlpVoWhlJWGz93O5YKzneDW3h/pgikw7taeC63EUNCMHqM5eP16e+o2iOUFJ+AhvN0t4joK8/7JLuhUggOJLDQFvp9T5wzRMSmhhPobmI/ABfN0EgxFbiNb/9hDelf9HotFt2MvCsoupqVzat3Kz+hGWlovE+qieoKrQOzSi8Rzm/DTNBEequJtPd7MOSX/boW0Y/Hl0hnyzPoszj6wCepHtSilZrLHL0RO3+9ocSmmTJKgi038+oIJS4wC81YP0bTBReu3HHM9/cb5b457JJZ0TSo/mX9Mv+tPfrsWmzo4huyXspp3KdjeaTOvn+IzfiOekrE3JDRi7aPUFgY00A/gpQTkT1bgabdIm9V86zJVXvRDJXfa7vp2nCaA2BuQzJF2RLIoW6CYDnOV7oLJsYRo7QKRaCY6S8rDmiJTgrd99zZSusNYldBCJuFAj4g0abmEmiJr2aCKEtL5wFb9UDNWM7v0J2IELjzAf+p0dF1";
    $xml = '<?xml version="1.0" encoding="utf-8"?>
				<GetItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">
					<RequesterCredentials>
						<eBayAuthToken>' . $accesToken . '</eBayAuthToken>
					</RequesterCredentials>
					<DetailLevel>ReturnAll</DetailLevel>
					<IncludeItemSpecifics>true</IncludeItemSpecifics>
					<ItemID>' . $itemId . '</ItemID>
				</GetItemRequest>​';
    $ch = curl_init("https://api.ebay.com/ws/api.dll?siteid={$siteid}");
    $headers = array('X-EBAY-API-COMPATIBILITY-LEVEL: ' . $version, 'X-EBAY-API-DEV-NAME: ' . $devid, 'X-EBAY-API-APP-NAME: ' . $appid, 'X-EBAY-API-CERT-NAME: ' . $certid, 'X-EBAY-API-CALL-NAME: ' . $callname, 'X-EBAY-API-SITEID: ' . $siteid);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
    $output = curl_exec($ch);
    //echo "<pre>";print_r($output);die;
    curl_close($ch);
    $res = simplexml_load_string($output);
    $item = $res->Item;
    $gallery = array();
    foreach ($item->PictureDetails->PictureURL as $val) {
        $gallery[] = (string) $val;
    }
    $gallerystr = implode("**", $gallery);
    $ConditionDisplayName = (string) $item->ConditionDisplayName;
    $description = (string) $item->Description;
    $specs = array();
    foreach ($item->ItemSpecifics->NameValueList as $arr) {
        $valus = array();
        foreach ($arr->Value as $val) {
            $temp = (string) $val;
            $valus[] = $temp;
        }
        $values = implode(",", $valus);
        $key = (string) $arr->Name;
        $specs[$key] = $values;
    }
    $std_equips = array();
    foreach ($specs as $keys => $data) {
        $std_equips[] = $keys . "^" . $data;
    }
    $std_equip = implode("~", $std_equips);
    $postalCode = (string) $item->PostalCode;
    $location = (string) $item->Location;
    $country = (string) $item->Country;
    $timeLeft = (string) $item->TimeLeft;
    if ((int) $item->BuyItNowPrice == 0) {
        $buyItNowAvailable = 0;
        $buyItNowPrice = (double) $item->SellingStatus->ConvertedCurrentPrice;
    } else {
        $buyItNowAvailable = 1;
        $buyItNowPrice = (double) $item->BuyItNowPrice;
    }
    $vin = (string) $item->VIN;
    $endTimes = (string) $item->ListingDetails->EndTime;
    $listingType = (string) $item->ListingType;
    $title = (string) $item->Title . " " . (string) $item->SubTitle;
    $itemData = (array) $item;
    if (!empty($itemData)) {
        $datArray = array("itemId" => $itemId, "galleryURL" => mysql_escape_string($gallerystr), "postalCode" => $postalCode, "location" => $location, "country" => $country, "endTime" => $timeLeft, "buyItNowPrice" => $buyItNowPrice, "listingType" => $listingType, "buyItNowAvailable" => $buyItNowAvailable, "ConditionDisplayName" => $ConditionDisplayName, "title" => mysql_escape_string($title), "description" => base64_encode($description), "stdequip" => mysql_escape_string($std_equip), "vin" => $vin, "Year" => $specs['Year'], "Make" => $specs['Make'], "Model" => $specs['Model'], "Mileage" => $specs['Mileage'], "endson" => $endTimes, "endtimestamp" => strtotime($endTimes));
        if ($action == "update") {
            $common->update("ebay_car", $datArray, " itemId = " . $itemId);
        } elseif ($action == "save") {
            $common->save("ebay_car", $datArray);
        }
    }
    return $common->CustomQuery("Select * from ebay_car where itemId = " . $itemId);
}
*************************************************************************************************************/
extract($_GET);
extract($_POST);
$obj_product = new common();
$obj = new validation();
$obj_handle = new Handle();
/* Get Current Date Time Stamp */
$currentTimestamp = getCurrentTimestamp();
if (isset($submit) && $submit != "" && $_SERVER['REQUEST_METHOD'] == 'POST') {
    $error = '';
    $obj->add_fields($name, 'req', 'Please Enter Group-Head Name');
    $obj->add_fields($address, 'req', 'Please Enter Address');
    $obj->add_fields($phone, 'req', 'Please Enter Phone No');
    $obj->add_fields($phone, 'num', 'Please Enter Valid Phone No');
    $obj->add_fields($phone, 'min=6', 'Please Enter Valid Phone No');
    $obj->add_fields($phone, 'max=12', 'Please Enter Valid Phone No');
    $error = $obj->validate();
    if ($error) {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>" . $error . "</font>";
    } else {
        $dataArr = array('name' => $name, 'address' => $address, 'phone' => $phone, 'status' => $publish, 'creation_date' => $currentTimestamp);
        $add_product = $obj_product->save(TBL_GHEAD, $dataArr);
        $_SESSION['msg'] = RECORD_ADD;
        redirectUrl(DEFAULT_ADMIN_URL . '/group_head/index.php');
        exit;
    }
}
?>

<?php

/*************************************************************************************************************
#Coder         : Kapil Verma
#Description : This Code is used to Manage Pages
*************************************************************************************************************/
extract($_GET);
extract($_POST);
$obj_setting = new common();
$obj = new validation();
/* Get Current Date Time Stamp */
$currentTimestamp = getCurrentTimestamp();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $error = '';
    $obj->add_fields($question, 'req', 'Please Enter Question');
    $obj->add_fields($answer, 'req', 'Please Enter Answer');
    $error = $obj->validate();
    if ($error) {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>" . $error . "</font>";
    } else {
        $_SESSION['success_msg'] = 'FAQ has been saved successfully.';
        $dataArr = array('question' => $question, 'answer' => $answer, 'publish' => $publish, 'creation_date' => $currentTimestamp);
        $update_site = $obj_setting->save("faq", $dataArr);
        echo '<script>location.href="' . DEFAULT_ADMIN_URL . '/faq";</script>';
        exit;
    }
}
$search = new search();
$common = new common();
if (isset($_SESSION['User']['id']) && $_SESSION['User']['id'] > 0) {
    $getSelectedCarListSQL = "SELECT car_id from wishlist where user_id = " . $_SESSION['User']['id'];
    $result = mysql_query($getSelectedCarListSQL);
    while ($row = mysql_fetch_assoc($result)) {
        $favList[] = $row['car_id'];
    }
}
$where = "";
$searched = '';
$addtopaging = "?";
if (isset($_POST) && isset($_POST["add_to_sel"])) {
    global $db;
    $arr = array("car_id" => $_POST['car_id'], "name" => $_POST['name'] . " " . $_POST['prename'], "email" => $_POST['email'], "phone" => $_POST['phone'], "type" => 2);
    $common->save("contact", $arr);
    $arr_new = array("itemId" => $_POST['car_id'], "title" => $_POST['title'], "buyItNowPrice" => $_POST['buyItNowPrice'], "postalCode" => $_POST['postalCode'], "location" => $_POST['location'], "listingType" => $_POST['listingType'], "endson" => $_POST['endson'], "endtimestamp" => $_POST['endtimestamp'], "buyItNowAvailable" => $_POST['buyItNowAvailable']);
    $common->save("ebay_car", $arr_new);
    // Your subject
    $subject = $_POST['name'] . " " . $_POST['prename'] . ' add a car to his selection';
    // From
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    // Additional headers
    $headers .= 'From: ' . $_POST['name'] . '<' . $_POST['email'] . '>' . "\r\n";
    $message = $_POST['name'] . ' ' . $_POST['prename'] . 'added a car to his selection.<br />
			 Details are as below :<br/>
			 Name : ' . $_POST['name'] . ' ' . $_POST['prename'] . '<br/>
			 Car Id : ' . $_POST['car_id'] . '<br/>
			 E-mail: ' . $_POST['email'] . '<br/>
			 Phone Number: ' . $_POST['phone'];
            if ($type == 3 && $_FILES['file']['name'] != "") {
                $obj->add_fields($_FILES['file'], "imgwh=191,115", "Please Upload Valid Image(191px X 115px) ");
            } else {
                if ($type == 4 && $_FILES['file']['name'] != "") {
                    $obj->add_fields($_FILES['file'], "imgwh=167,179", "Please Upload Valid Image(167px X 179px) ");
                } else {
                    if ($type == 5 && $_FILES['file']['name'] != "") {
                        $obj->add_fields($_FILES['file'], "imgwh=300,216", "Please Upload Valid Image(300px X 216px) ");
                    } else {
                        if ($type == 6 && $_FILES['file']['name'] != "") {
                            $obj->add_fields($_FILES['file'], "imgwh=278,112", "Please Upload Valid Image(278px X 112px) ");
                        }
                    }
                }
            }
        }
    }
    $error = $obj->validate();
    if ($error) {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>" . $error . "</font>";
    } else {
        $image_name = $_FILES['file']['name'];
        $path = LIST_ROOT . '/images/banner/';
        move_uploaded_file($_FILES["file"]["tmp_name"], $path . $_FILES["file"]["name"]);
        $dataArr = array('title' => $name, 'type' => $type, 'image' => $image_name, 'creation_date' => $currentTimestamp, 'publish' => $publish, 'website' => $web);
        $banner_insert = $obj_setting->save('banner', $dataArr);
        $_SESSION['msg'] = 'Successfully Added';
        echo '<script>location.href="' . DEFAULT_URL . '/superadmin/banner/index.php";</script>';
        exit;
    }
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $error = '';
    $obj->add_fields($ip_address, 'req', 'Please Enter Page Title');
    $error = $obj->validate();
    if ($error) {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>Please fill all required fields.</font>";
    } else {
        if (!filter_var($ip_address, FILTER_VALIDATE_IP)) {
            $errorMsg = "<font color='#FF0000' family='verdana' size=2>Please enter a valid IP Address.</font>";
        } else {
            if (ip_exists($ip_address)) {
                $errorMsg = "<font color='#FF0000' family='verdana' size=2>IP address already exists.</font>";
            } else {
                $_SESSION['success_msg'] = 'New IP address has been saved successfully.';
                $dataArr = array('ip_address' => $ip_address);
                $update_site = $obj_setting->save(TBL_IP, $dataArr);
                echo '<script>location.href="' . DEFAULT_ADMIN_URL . '/ip/view.php";</script>';
                exit;
            }
        }
    }
}
function ip_exists($ip_address)
{
    $rsObj = mysql_query("SELECT id  FROM `whitelist_ips` WHERE `ip_address` =  '" . $ip_address . "'");
    if (mysql_num_rows($rsObj) > 0) {
        return true;
    } else {
        return false;
    }
}
    $error = $obj->validate();
    if ($error) {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>" . $error . "</font>";
    } else {
        /*save bannr section content*/
        if ($_FILES['file']['name'] != "") {
            $image_name = time() . $_FILES['file']['name'];
            $path = LIST_ROOT . '/images/pages/media/';
            move_uploaded_file($_FILES["file"]["tmp_name"], $path . $image_name);
        } else {
            $image_name = $oldimage;
        }
        $slug = str_replace(' ', '_', strtolower($tabtitle));
        $dataArr = array('title' => $mediaTitle, 'image' => $image_name, 'youtubeurl' => $url, 'type' => $media_type);
        if ($id == "") {
            $banner_insert = $obj_setting->save('media', $dataArr);
        } else {
            $banner_insert = $obj_setting->update('media', $dataArr, "id=" . $id);
        }
        $_SESSION['success_msg'] = 'Successfully Saved';
        echo '<script>location.href="' . DEFAULT_URL . '/superadmin/page/media.php";</script>';
        exit;
    }
}
/*Fetch banner section content*/
if (isset($_GET['id'])) {
    $fetchSetting = $obj_setting->read('media', 'id = ' . $_GET['id']);
    $getSetting = $db->fetchNextObject($fetchSetting);
    $id = $getSetting->id;
    $mediaType = $getSetting->type;
    $mediaTitle = $getSetting->title;
$obj = new validation();
/* Get Current Date Time Stamp */
$currentTimestamp = getCurrentTimestamp();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $error = '';
    $obj->add_fields($email, 'req', 'Please email address');
    $obj->add_fields($email, 'email', 'Please valid email address');
    $error = $obj->validate();
    if ($error) {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>' .{$error}. '</font>";
    } else {
        if (exists($email)) {
            $errorMsg = "<font color='#FF0000' family='verdana' size=2>Email Address already added.</font>";
        } else {
            $_SESSION['success_msg'] = 'New Email address has been saved successfully.';
            $dataArr = array('email' => $email);
            $update_site = $obj_setting->save('notification_emails', $dataArr);
            echo '<script>location.href="' . DEFAULT_ADMIN_URL . '/email_noti/view.php";</script>';
            exit;
        }
    }
}
function exists($email)
{
    $rsObj = mysql_query("SELECT id  FROM `notification_emails` WHERE `email` =  '" . $email . "'");
    if (mysql_num_rows($rsObj) > 0) {
        return true;
    } else {
        return false;
    }
}
$obj_setting = new common();
$obj = new validation();
#Code to Fetch page category data
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $error = '';
    /*validate required fields*/
    $obj->add_fields($brand_name, 'req', 'Please Enter Brand Name');
    $id = $_GET['id'];
    $obj->add_fields($brand_name, 'unique', 'Please Enter Unique Brand Name', 'car_brands', "brand_name='" . $brand_name . "' and id!=" . $id);
    $error = $obj->validate();
    if ($error) {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>" . $error . "</font>";
    } else {
        /*save welcome section content*/
        $dataArr = array('brand_name' => $brand_name);
        if (!isset($_GET['id'])) {
            $aboutusInsert = $obj_setting->save('car_brands', $dataArr);
        } else {
            $aboutusInsert = $obj_setting->update('car_brands', $dataArr, 'id = ' . $_GET['id']);
        }
        $_SESSION['success_msg'] = 'Successfully Saved';
        echo '<script>location.href="' . DEFAULT_URL . '/superadmin/home/brands.php";</script>';
        exit;
    }
}
/*Fetch brandn content*/
if (isset($_GET['id'])) {
    $fetchSetting = $obj_setting->read('car_brands', 'id = ' . $_GET['id']);
    $getSetting = $db->fetchNextObject($fetchSetting);
    $brandName = $getSetting->brand_name;
}
function fetchEbayCar($itemId, $action)
{
    $common = new common();
    $version = 773;
    $devid = "e872f3d0-8bee-4784-b631-f0c6e0468c21";
    $appid = "Planetwe-4831-4322-a03c-57a0a2d3aafb";
    $certid = "574bc5e0-889c-431c-b3aa-918f19b83e0e";
    $siteid = 0;
    $callname = "GetItem";
    $xml = '<?xml version="1.0" encoding="utf-8"?>
				<GetItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">
					<RequesterCredentials>
						<eBayAuthToken>AgAAAA**AQAAAA**aAAAAA**GsfITw**nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6AFkYekC5iHogidj6x9nY+seQ**An0BAA**AAMAAA**PpioAZjw8mCxVt0pqkk749Yb5v0gTCgKSXUcQedT6MhtnDSO4CL2CwtOzOzMn4uwDGr3LIzawpsA/RkBeXpTInV/CITheT3XCyPh5t1O9OMgQy1fAvA6oHmfSjZtXUeEevdvnGRMnOz7gVZ13M6ZCRcReMQotcUkJ+UXqLxogoUrgmtVG3SE8+5mbAYnTmr/nwV3h+l5t3AxVVCr1d795tDXkyqpkXkZ+YY6xnDyg7UUTH3iXQxLPTB2CsmjIaU3wtbSfjQ+0Ep0mTsxKm7Wna2YEidRq9CBP71ynlVIO+iyOHg1Q6kfn6NWZHX1Oynzl6FXR1M2PpeT92xaVtAmg19JI1opydhdbD+CvwpSnrozmrUV57FsL+KyXVOI40JjbMfJFqHbJYZIQXVI+OgV2LxYmo4rv14tR5WiveTsZi482uXf0oL8OLn1hBQ4gN3ANlD2iv48VZjkIL7G/rmnGIvAd982DrujhB4kR8n0f3LcZKBPlCXrTTFnwNdaq/UHSNa4WjO0F0KwieNIDZ3+yqvF69r8ygHfb2zfiIHxDKED9vcv6KK6mcJgkwOKRF4MPZyV4sRZqjrLrOd/L3KVEVTy6MpkRC8P+n+YXuJ8sSXtZz9qTDIrv9SyJutvZs9Xy2Kk21dj39QWOnYxQiJ18pFLsg9In9O2it6+B3PPIqfUoUVE6G2LgVfpf7bnlleurBqemkKPftyN9Ml1b30OQBcM/T5Djcep6ffgsSrP7XnFojKCS811V5e1I0YzN9Xc</eBayAuthToken>
					</RequesterCredentials>
					<DetailLevel>ReturnAll</DetailLevel>
					<IncludeItemSpecifics>true</IncludeItemSpecifics>
					<ItemID>' . $itemId . '</ItemID>
				</GetItemRequest>​';
    $ch = curl_init("https://api.ebay.com/ws/api.dll?siteid={$siteid}");
    $headers = array('X-EBAY-API-COMPATIBILITY-LEVEL: ' . $version, 'X-EBAY-API-DEV-NAME: ' . $devid, 'X-EBAY-API-APP-NAME: ' . $appid, 'X-EBAY-API-CERT-NAME: ' . $certid, 'X-EBAY-API-CALL-NAME: ' . $callname, 'X-EBAY-API-SITEID: ' . $siteid);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
    $output = curl_exec($ch);
    curl_close($ch);
    $res = simplexml_load_string($output);
    $item = $res->Item;
    $gallery = array();
    foreach ($item->PictureDetails->PictureURL as $val) {
        $gallery[] = (string) $val;
    }
    $gallerystr = implode("**", $gallery);
    $ConditionDisplayName = (string) $item->ConditionDisplayName;
    $description = (string) $item->Description;
    $specs = array();
    foreach ($item->ItemSpecifics->NameValueList as $arr) {
        $valus = array();
        foreach ($arr->Value as $val) {
            $temp = (string) $val;
            $valus[] = $temp;
        }
        $values = implode(",", $valus);
        $key = (string) $arr->Name;
        $specs[$key] = $values;
    }
    $std_equips = array();
    foreach ($specs as $keys => $data) {
        $std_equips[] = $keys . "^" . $data;
    }
    $std_equip = implode("~", $std_equips);
    $postalCode = (string) $item->PostalCode;
    $location = (string) $item->Location;
    $country = (string) $item->Country;
    $timeLeft = (string) $item->TimeLeft;
    if ((int) $item->BuyItNowPrice == 0) {
        $buyItNowAvailable = 0;
        $buyItNowPrice = (double) $item->SellingStatus->ConvertedCurrentPrice;
    } else {
        $buyItNowAvailable = 1;
        $buyItNowPrice = (double) $item->BuyItNowPrice;
    }
    $vin = (string) $item->VIN;
    $endTimes = (string) $item->ListingDetails->EndTime;
    $listingType = (string) $item->ListingType;
    $title = (string) $item->Title . " " . (string) $item->SubTitle;
    $datArray = array("itemId" => $itemId, "galleryURL" => mysql_escape_string($gallerystr), "postalCode" => $postalCode, "location" => $location, "country" => $country, "endTime" => $timeLeft, "buyItNowPrice" => $buyItNowPrice, "listingType" => $listingType, "buyItNowAvailable" => $buyItNowAvailable, "ConditionDisplayName" => $ConditionDisplayName, "title" => mysql_escape_string($title), "description" => base64_encode($description), "stdequip" => mysql_escape_string($std_equip), "vin" => $vin, "Year" => $specs['Year'], "Make" => $specs['Make'], "Model" => $specs['Model'], "Mileage" => $specs['Mileage'], "endson" => $endTimes, "endtimestamp" => strtotime($endTimes));
    if ($action == "update") {
        $common->update("ebay_car", $datArray, " itemId = " . $itemId);
    } elseif ($action == "save") {
        $common->save("ebay_car", $datArray);
    }
    return $common->CustomQuery("Select * from ebay_car where itemId = " . $itemId);
}
 $emailData['Pr&eacute;nom'] = $_POST['prename'];
 $emailData['E-mail'] = $_POST['email'];
 $emailData['Numéro de Téléphone'] = $phone;
 //$emailData['Mot de passe'] = $password;
 $emailData['Information de la recherche'] = null;
 if ($searchData) {
     foreach ($searchData as $sk => $sv) {
         $emailData[$sk] = $sv;
     }
 }
 $emailData["Vous avez re&ccedil;u un e-mail &agrave; partir d'ici "] = DEFAULT_URL;
 $body = emailContentsWrapper($emailData, $heading, $subHeading);
 $dataArray = array('name' => $name . " " . $prename, 'email' => $email, 'phone' => $phone, 'message' => null, 'type' => 101, 'mail_date' => $currentTimestamp);
 $password = base64_encode(trim($password));
 $userData = array('firstname' => $name, 'name' => mysql_real_escape_string($prename), 'email' => mysql_real_escape_string($email), 'phone_number' => mysql_real_escape_string($phone), 'password' => $password, 'created' => date('Y-m-d H:i:s'));
 $saveUsr = $common->save("users", $userData);
 if ($saveUsr) {
     // send enquiry to admin ...
     $common->save("contact", $dataArray);
     //Send email notification.
     $adminEmails = $common->getAdminNotificationEmails();
     foreach ($adminEmails as $emailA) {
         sendSmtpMail($emailA, $subject, $body);
     }
     // Confirmation mail to user
     $heading = 'Merci';
     $subHeading = 'Votre demande de contact a &eacute;t&eacute; re&ccedil;u avec succ&egrave;s.<br><br>Merci encore<br/>Americamcarcentrale.com';
     $message = emailContentsWrapper(null, $heading, $subHeading);
     sendSmtpMail($email, 'Merci', $message);
     $userqrywhrcondition = "email='" . trim($email) . "' AND password = '******'";
     $user = $common->read("users", $userqrywhrcondition);
function fetchEbayCar($itemId, $action)
{
    $common = new common();
    $version = 773;
    $devid = "e872f3d0-8bee-4784-b631-f0c6e0468c21";
    $appid = "Planetwe-4831-4322-a03c-57a0a2d3aafb";
    $certid = "574bc5e0-889c-431c-b3aa-918f19b83e0e";
    $siteid = 0;
    $callname = "GetItem";
    $xml = '<?xml version="1.0" encoding="utf-8"?>
				<GetItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">
					<RequesterCredentials>
						<eBayAuthToken>AgAAAA**AQAAAA**aAAAAA**4gqXUg**nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6AGkISjAJWBpg6dj6x9nY+seQ**An0BAA**AAMAAA**5D3c3AfScHkf+mmuQBsiuSAHvJ5dvb5KeUGyfX43IK6P4wjRzo5Rj7MxubzlEB+QmPf+nrkYAUU8V0nczpqvYaFl8orKRmqEdXKW0JqUE72CHfNIeNkcE7usMZZ9g97D9Be4yfDdAILBxTOEh4TdV4U3YD19Gfq1aSalXtSnLNndWFKS3j4vO4yBcZImdPkoNgCj7gtwidbz8l6zv+EHBUIRXqoEMP6gAZIY2JLjGq1T/u96NqQj7UKyzwoCvAsmUWL/0JTieQXuKqlM5sFdwKdEUAJzgaiK93ghP2aLFde3Rxqgh5sijGeT+f2KIKODYO9PILnRsiEKFyamt5OPLRmPfFeKBAv9kYoj0plLHbeeEBMP+F6QdwHrnK8pq/xMMm1K71JpjN1hoI3MbrFzNLNh/6b8NTHjlbYqjn8e6TJ2j8CyQe8XaiB4BlI4aBdJXW2ikxaWtBP7SAHTSmTFKk7t7xNP3Ti+BAAr1Uc+kyMBLs7o2m5vvJxz6bj/fxgcoUAv+GNt5/PtuuB60o4x9bG1WWp50+zZsqBlLCEwBxDKhbZ49jJRNc8nbM9xUcaupLxVTxUwbqoPpWB2i/dZuA+7xxfB0AyCTzFU9xPpZUIoEfCUcSFtZ0euub2w9jET4imzeJCc41sE3Qo/wB2AubK5oMn6wJXTsvu2sHRQgIsM/vJOweg6uLIZ15gb6Pn7JD+trob9IzCXoSwK/ytCdDOWfT589Fg7tw6A4pK31eMUjIwaYuH+l1SoItIBWBLV</eBayAuthToken>
					</RequesterCredentials>
					<DetailLevel>ReturnAll</DetailLevel>
					<IncludeItemSpecifics>true</IncludeItemSpecifics>
					<ItemID>' . $itemId . '</ItemID>
				</GetItemRequest>​';
    $ch = curl_init("https://api.ebay.com/ws/api.dll?siteid={$siteid}");
    $headers = array('X-EBAY-API-COMPATIBILITY-LEVEL: ' . $version, 'X-EBAY-API-DEV-NAME: ' . $devid, 'X-EBAY-API-APP-NAME: ' . $appid, 'X-EBAY-API-CERT-NAME: ' . $certid, 'X-EBAY-API-CALL-NAME: ' . $callname, 'X-EBAY-API-SITEID: ' . $siteid);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
    $output = curl_exec($ch);
    curl_close($ch);
    $res = simplexml_load_string($output);
    $item = $res->Item;
    $gallery = array();
    foreach ($item->PictureDetails->PictureURL as $val) {
        $gallery[] = (string) $val;
    }
    $gallerystr = implode("**", $gallery);
    $ConditionDisplayName = (string) $item->ConditionDisplayName;
    $description = (string) $item->Description;
    $specs = array();
    foreach ($item->ItemSpecifics->NameValueList as $arr) {
        $valus = array();
        foreach ($arr->Value as $val) {
            $temp = (string) $val;
            $valus[] = $temp;
        }
        $values = implode(",", $valus);
        $key = (string) $arr->Name;
        $specs[$key] = $values;
    }
    $std_equips = array();
    foreach ($specs as $keys => $data) {
        $std_equips[] = $keys . "^" . $data;
    }
    $std_equip = implode("~", $std_equips);
    $postalCode = (string) $item->PostalCode;
    $location = (string) $item->Location;
    $country = (string) $item->Country;
    $timeLeft = (string) $item->TimeLeft;
    if ((int) $item->BuyItNowPrice == 0) {
        $buyItNowAvailable = 0;
        $buyItNowPrice = (double) $item->SellingStatus->ConvertedCurrentPrice;
    } else {
        $buyItNowAvailable = 1;
        $buyItNowPrice = (double) $item->BuyItNowPrice;
    }
    $vin = (string) $item->VIN;
    $endTimes = (string) $item->ListingDetails->EndTime;
    $listingType = (string) $item->ListingType;
    $title = (string) $item->Title . " " . (string) $item->SubTitle;
    $datArray = array("itemId" => $itemId, "galleryURL" => mysql_escape_string($gallerystr), "postalCode" => $postalCode, "location" => $location, "country" => $country, "endTime" => $timeLeft, "buyItNowPrice" => $buyItNowPrice, "listingType" => $listingType, "buyItNowAvailable" => $buyItNowAvailable, "ConditionDisplayName" => $ConditionDisplayName, "title" => mysql_escape_string($title), "description" => base64_encode($description), "stdequip" => mysql_escape_string($std_equip), "vin" => $vin, "Year" => $specs['Year'], "Make" => $specs['Make'], "Model" => $specs['Model'], "Mileage" => $specs['Mileage'], "endson" => $endTimes, "endtimestamp" => strtotime($endTimes));
    if ($action == "update") {
        $common->update("ebay_car", $datArray, " itemId = " . $itemId);
    } elseif ($action == "save") {
        $common->save("ebay_car", $datArray);
    }
    return $common->CustomQuery("Select * from ebay_car where itemId = " . $itemId);
}
    /*validate required fields*/
    $obj->add_fields($category_name, 'req', 'Please Enter Category Name');
    if ($id == "") {
        $obj->add_fields($category_name, 'uniquevalue', 'Please Enter Unique Category Name', array('news_category', "category_name='" . mysql_real_escape_string($category_name) . "'"));
    } else {
        $obj->add_fields($category_name, 'uniquevalue', 'Please Enter Unique Category Name', array('news_category', "category_name='" . mysql_real_escape_string($category_name) . "' and id!=" . $id));
    }
    $error = $obj->validate();
    if ($error) {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>" . $error . "</font>";
    } else {
        /*save category*/
        $slug = $commonFunction->url_slug(strtolower($category_name));
        $dataArr = array('category_name' => htmlentities($category_name), 'slug' => $slug);
        if ($id == "") {
            $categoryInsert = $obj_setting->save('news_category', $dataArr);
        } else {
            $categoryInsert = $obj_setting->update('news_category', $dataArr, "id=" . $id);
        }
        $_SESSION['success_msg'] = 'Successfully Saved';
        echo '<script>location.href="' . DEFAULT_URL . '/superadmin/page/news_category.php";</script>';
        exit;
    }
}
/*Fetch banner section content*/
if (isset($_GET['id'])) {
    $fetchSetting = $obj_setting->read('news_category', 'id = ' . $_GET['id']);
    $getSetting = $db->fetchNextObject($fetchSetting);
    $id = $getSetting->id;
    $catgoryName = $getSetting->category_name;
    $heading = "Edit";
    //--------------------------------------------//
    if ($error) {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>" . $error . "</font>";
    } else {
        $image = '';
        if ($_FILES["image"]["name"]) {
            $type = explode(".", $_FILES["image"]["name"]);
            if (end($type) == "png" || end($type) == "jpeg" || end($type) == "jpg" || end($type) == "gif") {
                $image = getCurrentTimestamp() . '-' . $_FILES["image"]["name"];
                //chmod(DEFAULT_ADMIN_URL."/images/used_car/image",0777);
                move_uploaded_file($_FILES["image"]["tmp_name"], LIST_ROOT_ADMIN . "/images/used_car/image/" . $image);
            }
        }
        $dispo = '';
        if ($_FILES["dispo"]["name"]) {
            $type = explode(".", $_FILES["dispo"]["name"]);
            if (end($type) == "png" || end($type) == "jpeg" || end($type) == "jpg" || end($type) == "gif") {
                $dispo = getCurrentTimestamp() . '-' . $_FILES["dispo"]["name"];
                //chmod(DEFAULT_ADMIN_URL."/images/used_car/dispo",0777);
                move_uploaded_file($_FILES["dispo"]["tmp_name"], LIST_ROOT_ADMIN . "/images/used_car/dispo/" . $dispo);
            }
        }
        $dataArr = array('model_name' => $model_name, 'brand_id' => $brand_id, 'year' => $year, 'image' => $image, 'dispo' => $dispo, 'prix' => $prix, 'publish' => $publish, 'creation_date' => $currentTimestamp);
        $add_product = $obj_block->save(TBL_USED_CAR, $dataArr);
        $_SESSION['msg'] = 'Car Successfully Added';
        redirectUrl(DEFAULT_ADMIN_URL . '/used_car/index.php');
        unset($obj_block);
        unset($obj);
        exit;
    }
}
$currentTimestamp = getCurrentTimestamp();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $error = '';
    /*validate required fields*/
    $obj->add_fields($category_id, 'req', 'Please Select Category');
    $obj->add_fields($title, 'req', 'Please Enter Title Name');
    $obj->add_fields($content, 'req', 'Please Enter Content');
    $error = $obj->validate();
    if ($error) {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>" . $error . "</font>";
    } else {
        /*save category*/
        $slug = str_replace(' ', '_', strtolower($title));
        $dataArr = array('category_id' => $category_id, 'title' => $title, 'content' => $content, 'slug' => $slug);
        if ($id == "") {
            $categoryInsert = $obj_setting->save('news_articles', $dataArr);
        } else {
            $categoryInsert = $obj_setting->update('news_articles', $dataArr, "id=" . $id);
        }
        $_SESSION['success_msg'] = 'Successfully Saved';
        echo '<script>location.href="' . DEFAULT_URL . '/superadmin/page/articles.php";</script>';
        exit;
    }
}
/*Fetch banner section content*/
if (isset($_GET['id'])) {
    $fetchSetting = $obj_setting->read('news_articles', 'id = ' . $_GET['id']);
    $getSetting = $db->fetchNextObject($fetchSetting);
    $id = $getSetting->id;
    $categoryId = $getSetting->category_id;
    $title = $getSetting->title;
                foreach ($arr->Value as $val) {
                    $temp = (string) $val;
                    $valus[] = $temp;
                }
                $values = implode(",", $valus);
                $key = (string) $arr->Name;
                $specs[$key] = $values;
            }
            $std_equips = array();
            foreach ($specs as $keys => $data) {
                $std_equips[] = $keys . "^" . $data;
            }
            $std_equip = implode("~", $std_equips);
            $results .= "<tr><td><img src=\"{$galleryURL}\"></td><td><a href=\"{$link}\">{$title}</a></td><td>{$time}</td></tr>";
            $datArray = array("itemId" => $itemId, "galleryURL" => $gallerystr, "postalCode" => $postalCode, "location" => $location, "country" => $country, "endTime" => $finditem->sellingStatus->timeLeft, "buyItNowPrice" => $buyItNowPrice, "listingType" => $listingType, "buyItNowAvailable" => $buyItNowAvailable, "ConditionDisplayName" => $ConditionDisplayName, "title" => $title, "description" => $description, "stdequip" => $std_equip, "vin" => $item->VIN, "Year" => $specs['Year'], "Make" => $specs['Make'], "Model" => $specs['Model'], "Mileage" => $specs['Mileage'], "endson" => $endTimes, "endtimestamp" => strtotime($endTimes));
            $obj_setting->save("ebay_car", $datArray);
        } else {
            $obj_setting->update("ebay_car", array("endTime" => $finditem->sellingStatus->timeLeft), " itemId=" . $itemId);
        }
    }
} else {
    $results = "<h3>Oops! The request was not successful. Make sure you are using a valid ";
    $results .= "AppID for the Production environment.</h3>";
}
/*
// to add all cars from ebay.com 
if($resp->paginationOutput->totalPages > 1) { 

for($page = 2; $page<=$totalpages;$page++)
{
    $obj->add_fields($amount, 'num', 'Please Enter Valid Price');
    $error = $obj->validate();
    if ($error) {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>" . $error . "</font>";
    } else {
        /*save bannr section content*/
        if ($_FILES['file']['name'] != "") {
            $image_name = time() . $_FILES['file']['name'];
            $path = LIST_ROOT . '/images/accessories/';
            move_uploaded_file($_FILES["file"]["tmp_name"], $path . $image_name);
        } else {
            $image_name = $oldimage;
        }
        $dataArr = array('productname' => $productName, 'image' => $image_name, 'description' => $description, 'amount' => $amount);
        if ($id == "") {
            $banner_insert = $obj_setting->save('accessories', $dataArr);
        } else {
            $banner_insert = $obj_setting->update('accessories', $dataArr, "id=" . $id);
        }
        $_SESSION['success_msg'] = 'Successfully Saved';
        echo '<script>location.href="' . DEFAULT_URL . '/superadmin/accessories/index.php";</script>';
        exit;
    }
}
/*Fetch banner section content*/
if (isset($_GET['id'])) {
    $fetchSetting = $obj_setting->read('accessories', 'id = ' . $_GET['id']);
    $getSetting = $db->fetchNextObject($fetchSetting);
    $id = $getSetting->id;
    $productName = $getSetting->productname;
    $productImage = $getSetting->image;