$com = $getSetting->com;
$obj_setting->getExchangeRate();
extract($_POST);
/* Get Current Date Time Stamp */
$currentTimestamp = getCurrentTimestamp();
#saving data in database after validation
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $error = '';
    $obj->add_fields($boat, 'req', 'Please Enter Transport By Boat');
    $obj->add_fields($boat, 'currency', 'Please Enter Valid Transport By Boat');
    $obj->add_fields($custom, 'req', 'Please Enter Customs');
    $obj->add_fields($custom, 'currency', 'Please Enter Valid Customs');
    $obj->add_fields($tva, 'req', 'Please Enter TVA');
    $obj->add_fields($tva, 'currency', 'Please Enter Valid TVA');
    $obj->add_fields($transp, 'req', 'Please Enter Transp');
    $obj->add_fields($transp, 'currency', 'Please Enter Valid Transp');
    $obj->add_fields($com, 'req', 'Please Enter Com');
    $obj->add_fields($com, 'currency', 'Please Enter Valid Com');
    $error = $obj->validate();
    if ($error) {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>" . $error . "</font>";
    } else {
        $_SESSION['success_msg'] = 'Exchange Rate has been saved successfully.';
        $dataArr = array('boat' => $boat, 'custom' => $custom, 'tva' => $tva, 'transp' => $transp, 'com' => $com);
        $update_site = $obj_setting->update('currency', $dataArr, ' id=1');
        echo '<script>location.href="' . DEFAULT_ADMIN_URL . '/currency/index.php' . $addToUrl . '";</script>';
        exit;
    }
}
//unset($obj_setting);
unset($obj);
            case 0:
                $imageName = $oldImageNameName;
                break;
            case 1:
                $imageName = $imageName;
                break;
            case 2:
                $imageName = $oldImageNameName;
                break;
        }
    } else {
        $imageName = $oldImageNameName;
        $successstatus = 1;
    }
    $dataArr = array('site_title' => $site_title, 'meta_title' => $meta_title, 'meta_keywords' => $meta_keywords, 'meta_description' => $meta_description, 'google_map_key' => $google_map_key, 'phone1' => $phone1, 'phone2' => $phone2, 'office_address' => $office_address, 'slogan' => $slogan, 'logo' => $imageName, 'copyright_text_footer' => $copyright_text_footer, 'facebook' => $facebook, 'twitter' => $twitter, 'youtube' => $youtube, 'rss' => $rss);
    $update_site = $obj_setting->update(TBL_ADMIN, $dataArr, 'id = ' . $_SESSION['LoggedInId']);
    if ($successstatus == 0) {
        $_SESSION['success_msg'] = 'Image size is greater then 200kb ,so this image could not be saved.Your other information has been saved successfully.';
    } else {
        if ($successstatus == 2) {
            $_SESSION['success_msg'] = 'Image type is not JPEG or GIF ,so this image could not be saved.Your other information has been saved successfully.';
        } else {
            $_SESSION['success_msg'] = 'Your information has been saved successfully.';
        }
    }
}
#Code to Fetch data to show on form
$fetchSetting = $obj_setting->read(TBL_ADMIN, 'id = ' . $_SESSION['LoggedInId']);
$getSetting = $db->fetchNextObject($fetchSetting);
$site_title = $getSetting->site_title;
$meta_title = $getSetting->meta_title;
        $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;
    $content = $getSetting->content;
    $heading = "Edit";
        $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);
                /*if(isset($old_image) && $old_image!='' && file_exists(LIST_ROOT_ADMIN."/images/new_model/".$old_image)) {
                			unlink(LIST_ROOT_ADMIN."/images/new_model/".$old_image);
                		}*/
                move_uploaded_file($_FILES["image"]["tmp_name"], LIST_ROOT_ADMIN . "/images/new_model/" . $image);
            }
        } else {
            $image = $old_image;
        }
        $dataArr = array('brand_name' => $brand_name, 'year' => $year, 'image' => $image, 'prix' => $prix, 'publish' => $publish);
        $update_product = $obj_block->update(TBL_NEW_MODEL, $dataArr, 'id=' . $model_id);
        $_SESSION['msg'] = 'New Model Successfully Updated';
        unset($obj_block);
        unset($obj);
        redirectUrl(DEFAULT_ADMIN_URL . '/new_model/index.php');
        exit;
    }
} else {
    #Code to Fetch seleted ID's data
    $getBlock = $obj_block->read(TBL_NEW_MODEL, 'id=' . $model_id);
    $fetchBlock = $db->fetchNextObject($getBlock);
    $brand_name = $fetchBlock->brand_name;
    $year = $fetchBlock->year;
    $old_image = $fetchBlock->image;
    $prix = $fetchBlock->prix;
    $publish = $fetchBlock->publish;
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);
}
$currentTimestamp = getCurrentTimestamp();
#Code to Fetch seleted ID's data
$fetchSetting = $obj_setting->read('template', ' id = 1');
$getSetting = $db->fetchNextObject($fetchSetting);
$email = $getSetting->email;
$subject = $getSetting->subject;
$template = $getSetting->template;
$next_date = $getSetting->next_date;
extract($_POST);
/* Get Current Date Time Stamp */
$currentTimestamp = getCurrentTimestamp();
#saving data in database after validation
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $error = '';
    $obj->add_fields($email, 'req', 'Please Enter Email');
    $obj->add_fields($email, 'email', 'Please Enter A Valid Email');
    $obj->add_fields($subject, 'req', 'Please Enter Subject');
    $obj->add_fields($template, 'req', 'Please Enter Template');
    $error = $obj->validate();
    if ($error) {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>" . $error . "</font>";
    } else {
        $_SESSION['success_msg'] = 'Template has been edited successfully.';
        $dataArr = array('email' => $email, 'subject' => $subject, 'template' => $template, 'next_date' => $next_date, 'mail_date' => $currentTimestamp);
        $update_site = $obj_setting->update('template', $dataArr, ' id=1');
        echo '<script>location.href="' . DEFAULT_ADMIN_URL . '/template/reminder/index.php' . $addToUrl . '";</script>';
        exit;
    }
}
unset($obj_setting);
unset($obj);
    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'] = 'Car has been saved successfully.';
        $value = '';
        if ($formObj->AddCar($_POST, $_FILES, true, $_GET['id'])) {
            /*Save data in car_flat for searching*/
            $images = $obj_setting->getAllImage($_GET['id']);
            $dataArr = array('make' => $obj_setting->getOptionNameById($manufacturer), 'model' => $model, 'year' => $madeYear, 'price' => $price, 'description' => $description, 'title' => $fullName, 'images' => implode(',', $images));
            $obj_setting->update('car_flat', $dataArr, 'car_id=' . $_GET['id']);
            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>";
        }
    }
}
#Coder         : Kapil Verma
#Description   : This Code is used to Manage Pages
*************************************************************************************************************/
extract($_POST);
extract($_GET);
$obj_setting = new common();
$obj = new validation();
if ($editsub == "editsub") {
    $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.';
        $updateSetting = $obj_setting->update('faq', array("publish" => 1, "question" => $question, "answer" => $answer), 'id=' . $id);
        echo '<script>location.href="' . DEFAULT_ADMIN_URL . '/faq";</script>';
        exit;
        unset($obj_setting);
        unset($obj);
    }
} else {
    #Code to Fetch seleted ID's data
    $fetchSetting = $obj_setting->read('faq', 'id = ' . $id);
    $getSetting = $db->fetchNextObject($fetchSetting);
    $id = $getSetting->id;
    $question = $getSetting->question;
    $answer = $getSetting->answer;
    $publish = $getSetting->publish;
}
        /*
        echo "<pre>";
        print_r($_FILES);
        print_r($_POST); 
        print_r($medias);
        die;
        */
        if (isset($main_image)) {
            if ($main_image) {
                $image_name = $main_image;
            } else {
                $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'] = 'Review has been updated 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->update('reviews', $dataArr, "id=" . $id);
        $obj_setting->delete('reviews_media', " review_id IN('{$id}')");
        foreach ($medias as $media) {
            $dataArrMedia = array('review_id' => $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;
    }
}
unset($obj_setting);
unset($obj);
<?php

/*************************************************************************************************************
#Coder         : Kapil Verma
#Description   : This Code is used to Manage Pages
*************************************************************************************************************/
extract($_GET);
$obj_setting = new common();
$obj = new validation();
#Code to Fetch seleted ID's data
$fetchSetting = $obj_setting->read('car_inquiry', 'id = ' . $id);
$getSetting = $db->fetchNextObject($fetchSetting);
$id = $getSetting->id;
$name = $getSetting->name;
$email = $getSetting->email;
$status = $getSetting->status;
$phone = $getSetting->phone;
$car_id = $getSetting->car_id;
$address = $getSetting->address;
$message = $getSetting->message;
$updateSetting = $obj_setting->update('car_inquiry', array(status => 1), 'id=' . $id);
unset($obj_setting);
unset($obj);
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);
}
    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/home/banner/';
            move_uploaded_file($_FILES["file"]["tmp_name"], $path . $image_name);
        } else {
            $image_name = $oldimage;
        }
        $dataArr = array('banner_image' => $image_name, 'content' => $content, 'url' => $url, 'status' => $status);
        if ($id == "") {
            $banner_insert = $obj_setting->save('rot_banner', $dataArr);
        } else {
            $banner_insert = $obj_setting->update('rot_banner', $dataArr, "id=" . $id);
        }
        $_SESSION['success_msg'] = 'Successfully Saved';
        echo '<script>location.href="' . DEFAULT_URL . '/superadmin/home/index.php";</script>';
        exit;
    }
}
/*Fetch banner section content*/
if (isset($_GET['id'])) {
    $fetchSetting = $obj_setting->read('rot_banner', 'id = ' . $_GET['id']);
    $getSetting = $db->fetchNextObject($fetchSetting);
    $id = $getSetting->id;
    $bannerImage = $getSetting->banner_image;
    $content = $getSetting->content;
    $url = $getSetting->url;
    $status = $getSetting->status;
    $error = '';
    /*validate required fields*/
    $obj->add_fields($content, 'req', 'Please Enter Content');
    $obj->add_fields($_FILES['file'], 'ftype=jpg,gif,png', 'Please Upload Valid Image');
    if ($_FILES['file']['name'] != "") {
        $obj->add_fields($_FILES['file'], "imgwh=1100,450", "Please Upload Valid Image(1100pxX450px)");
    }
    $error = $obj->validate();
    if ($error) {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>{$error}</font>";
    } else {
        /*save real facts section content*/
        if ($_FILES['file']['name'] != "") {
            $image_name = time() . $_FILES['file']['name'];
            $path = LIST_ROOT . '/images/home/';
            move_uploaded_file($_FILES["file"]["tmp_name"], $path . $image_name);
        } else {
            $image_name = $oldimage;
        }
        $dataArr = array('content' => $content, 'image' => $image_name);
        $aboutus_insert = $obj_setting->update('editor_rows', $dataArr, "id=3");
        $_SESSION['success_msg'] = 'Successfully Saved';
        echo '<script>location.href="' . DEFAULT_URL . '/superadmin/home/real_facts.php";</script>';
        exit;
    }
}
/*Fetch real facts section content*/
$fetchSetting = $obj_setting->read('editor_rows', 'id = 3');
$getSetting = $db->fetchNextObject($fetchSetting);
$content = $getSetting->content;
$backgroundImage = $getSetting->image;
<?php

include_once '../../conf/config.inc.php';
global $db;
$commonObj = new common();
$tbl_name = "car_media_gallery";
$result = $commonObj->read($tbl_name, "fetched = 0");
while ($url = $db->fetchNextObject($result)) {
    $path = returnPath($url->value);
    $arr = array("value" => $path, "fetched" => 1);
    $whereCondition = 'value_id = ' . $url->value_id;
    $commonObj->update($tbl_name, $arr, $whereCondition);
}
function returnPath($path)
{
    if (strpos($path, "http://") !== false || strpos($path, "https://") !== false) {
        $upload_path = getUploadDirPath(basename($path));
        save_image($path, UPLOAD_CAR_IMAGES . $upload_path);
        return $upload_path;
    }
}
function save_image($inPath, $outPath)
{
    //Download images from remote server
    $in = fopen($inPath, "rb");
    $out = fopen($outPath, "wb");
    while ($chunk = fread($in, 8192)) {
        fwrite($out, $chunk, 8192);
    }
    fclose($in);
    fclose($out);
        }
        $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 . "/members/upload/" . $logo);
            unlink(LIST_ROOT_ADMIN . "/members/upload/" . $logo_hidden);
        } else {
            $logo = $logo_hidden;
        }
        $p_slug = $obj_handle->makeAlias($name);
        if ($obj_product->numberOfRows(TBL_PRODUCT, "p_slug = '" . $p_slug . "'") > 0) {
            $p_slug = $obj_handle->makeAlias($p_slug . " " . $prod_id);
        }
        $dataArr = array('name' => $name, 'logo' => $logo, 'desc' => $desc, 'cat_id' => $cat_id, 'sub_cat_id' => $sub_cat_id, 'publish' => $publish, 'p_slug' => $p_slug);
        $update_product = $obj_product->update(TBL_PRODUCT, $dataArr, 'id=' . $prod_id);
        $_SESSION['msg'] = RECORD_UPDATE;
        redirectUrl(DEFAULT_ADMIN_URL . '/members/product.php');
        exit;
    }
} else {
    #Code to Fetch seleted ID's data
    $getProduct = $obj_product->read(TBL_PRODUCT, 'id=' . $prod_id);
    $fetchProduct = $db->fetchNextObject($getProduct);
    $name = $fetchProduct->name;
    $logo = $fetchProduct->logo;
    $desc = $fetchProduct->desc;
    $cat_id = $fetchProduct->cat_id;
    $sub_cat_id = $fetchProduct->sub_cat_id;
    $publish = $fetchProduct->publish;
    $old_p_slug = $fetchProduct->p_slug;
     				$common->update('contact',array("mail_date"=>$currentTimestamp,'status'=>1),' id='.$contact_id);
     			}
     		}
     		else */
     if ($car > 0 && $type == 0) {
         $ebay = $common->CustomQuery("Select * from ebay_car where itemId = " . $car);
         if (mysql_num_rows($ebay) > 0) {
             $ebays = mysql_fetch_object($ebay);
             //if(strtotime($ebays->endson) > mktime() && $ebays->title != ''){
             if ($ebays->title != '') {
                 $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);
    $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;
    $content = $getSetting->content;
    $heading = "Edit";
#Description : This Code is used to Manage Pages
*************************************************************************************************************/
extract($_GET);
extract($_POST);
$obj_setting = new common();
$obj = new validation();
#Code to Fetch page category data
#END
$publish = 1;
/* Get Current Date Time Stamp */
$currentTimestamp = getCurrentTimestamp();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $error = '';
    /*validate required fields*/
    $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 personalized search content*/
        $dataArr = array('content' => $content);
        $aboutus_insert = $obj_setting->update('content_page', $dataArr, "page_name = 'Personalized Search'");
        $_SESSION['success_msg'] = 'Successfully Saved';
        echo '<script>location.href="' . DEFAULT_URL . '/superadmin/personalized_search/index.php";</script>';
        exit;
    }
}
/*Fetch personalized search content*/
$fetchSetting = $obj_setting->read('content_page', "page_name = 'Personalized Search'");
$getSetting = $db->fetchNextObject($fetchSetting);
$content = $getSetting->content;
        }
        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);
                if (isset($old_dispo) && $old_dispo != '') {
                    unlink(LIST_ROOT_ADMIN . "/images/used_car/dispo/" . $old_dispo);
                }
                move_uploaded_file($_FILES["dispo"]["tmp_name"], LIST_ROOT_ADMIN . "/images/used_car/dispo/" . $dispo);
            }
        } else {
            $dispo = $old_dispo;
        }
        $dataArr = array('model_name' => $model_name, 'brand_id' => $brand_id, 'year' => $year, 'image' => $image, 'dispo' => $dispo, 'prix' => $prix, 'publish' => $publish);
        $update_product = $obj_block->update(TBL_USED_CAR, $dataArr, 'id=' . $car_id);
        $_SESSION['msg'] = 'Car Successfully Updated';
        unset($obj_block);
        unset($obj);
        redirectUrl(DEFAULT_ADMIN_URL . '/used_car/index.php');
    }
} else {
    #Code to Fetch seleted ID's data
    $getBlock = $obj_block->read(TBL_USED_CAR, 'id=' . $car_id);
    $fetchBlock = $db->fetchNextObject($getBlock);
    $model_name = $fetchBlock->model_name;
    $brand_id = $fetchBlock->brand_id;
    $year = $fetchBlock->year;
    $old_image = $fetchBlock->image;
    $old_dispo = $fetchBlock->dispo;
    $prix = $fetchBlock->prix;
        $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);
                if (isset($old_image) && $old_image != '') {
                    unlink(LIST_ROOT_ADMIN . "/images/brands/" . $old_image);
                }
                move_uploaded_file($_FILES["logo"]["tmp_name"], LIST_ROOT_ADMIN . "/images/brands/" . $image);
            }
        } else {
            $image = $old_image;
        }
        $dataArr = array('title' => $title, 'logo' => $image, 'publish' => $publish);
        $update_product = $obj_block->update(TBL_BRANDS, $dataArr, 'id=' . $brand_id);
        $_SESSION['msg'] = 'Brand Successfully Updated';
        unset($obj_block);
        unset($obj);
        redirectUrl(DEFAULT_ADMIN_URL . '/brands/index.php');
    }
} else {
    #Code to Fetch seleted ID's data
    $getBlock = $obj_block->read(TBL_BRANDS, 'id=' . $brand_id);
    $fetchBlock = $db->fetchNextObject($getBlock);
    $title = $fetchBlock->title;
    $old_image = $fetchBlock->logo;
    $publish = $fetchBlock->publish;
    unset($obj_block);
}
/* Get Current Date Time Stamp */
$currentTimestamp = getCurrentTimestamp();
$obj_handle = new Handle();
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);
        $update_product = $obj_product->update(TBL_GHEAD, $dataArr, 'id=' . $prod_id);
        $_SESSION['msg'] = RECORD_UPDATE;
        redirectUrl(DEFAULT_ADMIN_URL . '/group_head/index.php');
        //echo '<script>location.href="'.DEFAULT_ADMIN_URL.'/group_head/index.php";</script>';
        exit;
    }
} else {
    #Code to Fetch seleted ID's data
    $getProduct = $obj_product->read(TBL_GHEAD, 'id=' . $prod_id);
    $fetchProduct = $db->fetchNextObject($getProduct);
    $name = $fetchProduct->name;
    $address = $fetchProduct->address;
    $phone = $fetchProduct->phone;
    $publish = $fetchProduct->status;
}
        $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;
    $bannerImage = $getSetting->image;
    $url = $getSetting->youtubeurl;
$obj = new validation();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $error = '';
    /*validate required fields*/
    $obj->add_fields($content, 'req', 'Please Enter Content');
    $obj->add_fields($_FILES['topbanner'], 'ftype=jpg,gif,png', 'Please Upload Valid Banner');
    $obj->add_fields($_FILES['topbanner'], "imgwh=1250,300", "Please Upload Valid Banner(1250pxX00px)");
    $error = $obj->validate();
    if ($error) {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>{$error}</font>";
    } else {
        /*save media content*/
        if ($_FILES['topbanner']['name'] != "") {
            $image_name = time() . $_FILES['topbanner']['name'];
            $path = LIST_ROOT . '/images/pages/media/';
            move_uploaded_file($_FILES["topbanner"]["tmp_name"], $path . $image_name);
        } else {
            $image_name = $oldtopimage;
        }
        $dataArr = array('page_name' => 'media', 'content' => $content, 'banner_image' => $image_name);
        $aboutus_insert = $obj_setting->update('content_page', $dataArr, "id=16");
        $_SESSION['success_msg'] = 'Successfully Saved';
        echo '<script>location.href="' . DEFAULT_URL . '/superadmin/page/mediacontent.php";</script>';
        exit;
    }
}
/*Fetch media content*/
$fetchSetting = $obj_setting->read('content_page', 'id = 16');
$getSetting = $db->fetchNextObject($fetchSetting);
$content = $getSetting->content;
$topBanner = $getSetting->banner_image;
$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**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);
}
    $obj->add_fields($name, 'req', 'Please Enter Page Title');
    $obj->add_fields($desc, 'req', 'Please Enter Description');
    $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;
        }
        if (isset($searchtext) and $searchtext != '') {
            $addToUrl = '?searchtext=' . $searchtext . '&searchcombo=' . $searchcombo;
        } else {
            $addToUrl = '';
        }
        $_SESSION['success_msg'] = 'Page has been edited successfully.';
        $dataArr = array('name' => $name, 'slug' => $slug, 'desc' => $desc, 'publish' => $publish, 'metatitle' => $metatitle, 'metakeyword' => $metakeyword, 'metadescription' => $metadescription, 'can_delete' => $can_delete, 'page_cat' => $page_cat);
        $update_site = $obj_setting->update(TBL_PAGE, $dataArr, ' id=' . $id);
        echo '<script>location.href="' . DEFAULT_ADMIN_URL . '/page/index.php' . $addToUrl . '";</script>';
        exit;
    }
}
$fetchPage_cat = $obj_setting->customQuery("SELECT * FROM pages where page_cat=0");
unset($obj_setting);
unset($obj);
#Description : This Code is used to Manage Pages
*************************************************************************************************************/
extract($_GET);
extract($_POST);
$obj_setting = new common();
$obj = new validation();
#Code to Fetch page category data
#END
$publish = 1;
/* Get Current Date Time Stamp */
$currentTimestamp = getCurrentTimestamp();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $error = '';
    /*validate required fields*/
    $obj->add_fields($content, 'req', 'Please Enter Content');
    $error = $obj->validate();
    if ($error) {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>Please fill all required fields.</font>";
    } else {
        /*save welcome section content*/
        $dataArr = array('content' => $content);
        $banner_insert = $obj_setting->update('editor_rows', $dataArr, "id=1");
        $_SESSION['success_msg'] = 'Successfully Saved';
        echo '<script>location.href="' . DEFAULT_URL . '/superadmin/home/welcome.php";</script>';
        exit;
    }
}
/*Fetch welcome section content*/
$fetchSetting = $obj_setting->read('editor_rows', 'id = 1');
$getSetting = $db->fetchNextObject($fetchSetting);
$content = $getSetting->content;
            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);
                /*if(isset($old_image) && $old_image!='' && file_exists(LIST_ROOT_ADMIN."/images/new_model/".$old_image)) {
                			unlink(LIST_ROOT_ADMIN."/images/new_model/".$old_image);
                		}*/
                if (isset($old_image) && $old_image != '' && file_exists(LIST_ROOT_ADMIN . "/images/htmltemplate/" . $old_image)) {
                    @unlink(LIST_ROOT_ADMIN . "/images/htmltemplate/" . $old_image);
                }
                move_uploaded_file($_FILES["image"]["tmp_name"], LIST_ROOT_ADMIN . "/images/htmltemplate/" . $image);
            }
        } else {
            $image = $old_image;
        }
        $dataArr = array('title' => $title, 'details_url' => $details_url, 'image' => $image, 'price' => $price, 'publish' => $publish);
        $update_product = $obj_block->update(TBL__HTMLTEMPLATE, $dataArr, 'id=' . $model_id);
        $_SESSION['msg'] = 'Car Template Successfully Updated';
        unset($obj_block);
        unset($obj);
        redirectUrl(DEFAULT_ADMIN_URL . '/htmltemplate/index.php');
        exit;
    }
} else {
    //echo "virender";
    #Code to Fetch seleted ID's data
    $getBlock = $obj_block->read(TBL__HTMLTEMPLATE, 'id=' . $model_id);
    $fetchBlock = $db->fetchNextObject($getBlock);
    // print_r($fetchBlock);
    $title = $fetchBlock->title;
    $details_url = $fetchBlock->details_url;
    $old_image = $fetchBlock->image;
                    $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++)
{

// Construct the findItemsByKeywords HTTP GET call 
$apicall = "$endpoint?";
<?php

/*************************************************************************************************************
#Coder         : Kapil Verma
#Description   : This Code is used to Manage Pages
*************************************************************************************************************/
extract($_GET);
$obj_setting = new common();
$obj = new validation();
#Code to Fetch seleted ID's data
$fetchSetting = $obj_setting->read('contact', 'id = ' . $id);
$getSetting = $db->fetchNextObject($fetchSetting);
$id = $getSetting->id;
$name = $getSetting->name;
$email = $getSetting->email;
$status = $getSetting->status;
$phone = $getSetting->phone;
$car_id = $getSetting->car_id;
$address = $getSetting->address;
$message = $getSetting->message;
$updateSetting = $obj_setting->update('contact', array(status => 1), 'id=' . $id);
unset($obj_setting);
unset($obj);