function get_ensogo_item($q, $ini) { $ensogo_data = get_remote_data($ini['e_url'] . $q); // GET request preg_match("/<div class=\"esg-subcat esg-search\".*div>/", $ensogo_data, $ensogo_txt); $ensogo_dom = @DOMDocument::loadHTML($ensogo_txt[0]); $ensogo_dom->preserveWhiteSpace = false; $ensogo_xpath = new DOMXPath($ensogo_dom); //get result from ensogo $ensogo_item = $ensogo_xpath->query($ini['e_xpath']); $items = array(); foreach ($ensogo_item as $node) { $dom_node = new DOMDocument(); $dom_node->appendChild($dom_node->importNode($node, true)); $dom_xpath = new DOMXPath($dom_node); //xpath query from child node $href_node = $dom_xpath->query($ini['e_href']); $img_node = $dom_xpath->query($ini['e_image']); $title_node = $dom_xpath->query($ini['e_title']); $cur_price_node = $dom_xpath->query($ini['e_current_price']); $orig_price_node = $dom_xpath->query($ini['e_orig_price']); $discount_node = $dom_xpath->query($ini['e_discount']); $item = new ensogo_item(); try { $item->url = $href_node->item(0)->nodeValue; } catch (Exception $e) { } try { $item->item_image = $img_node->item(0)->nodeValue; } catch (Exception $e) { } try { $item->title = $title_node->item(0)->nodeValue; } catch (Exception $e) { } try { $item->cur_price = $cur_price_node->item(0)->nodeValue; } catch (Exception $e) { } try { $item->orig_price = $orig_price_node->item(0)->nodeValue; } catch (Exception $e) { } try { $item->percent_discount = $discount_node->item(0)->nodeValue; } catch (Exception $e) { } array_push($items, $item); } return $items; }
function get_lazada_item($q, $ini) { $lazada_data = get_remote_data($ini['l_url'] . $q); // GET request $lazada_dom = @DOMDocument::loadHTML($lazada_data); $lazada_dom->preserveWhiteSpace = false; $lazada_xpath = new DOMXPath($lazada_dom); //get result from lazada $lazada_item = $lazada_xpath->query($ini['l_xpath']); $items = array(); foreach ($lazada_item as $node) { $dom_node = new DOMDocument(); $dom_node->appendChild($dom_node->importNode($node, true)); $dom_xpath = new DOMXPath($dom_node); $href_node = $dom_xpath->query($ini['l_href']); $img_node = $dom_xpath->query($ini['l_image']); $title_node = $dom_xpath->query($ini['l_title']); $cur_price_node = $dom_xpath->query($ini['l_current_price']); $orig_price_node = $dom_xpath->query($ini['l_orig_price']); $discount_node = $dom_xpath->query($ini['l_discount']); $item = new lazada_item(); try { $item->url = $href_node->item(0)->nodeValue; } catch (Exception $e) { } try { $item->item_image = $img_node->item(0)->nodeValue; } catch (Exception $e) { } try { $item->title = $title_node->item(0)->nodeValue; } catch (Exception $e) { } try { $item->cur_price = $cur_price_node->item(0)->nodeValue; } catch (Exception $e) { } try { $item->orig_price = $orig_price_node->item(0)->nodeValue; } catch (Exception $e) { } try { $item->percent_discount = $discount_node->item(0)->nodeValue; } catch (Exception $e) { } array_push($items, $item); } return $items; }
private function sendToStripe($end_point, $data = array(), $order_data = array()) { $payment = $this->extension->getPayment('stripe'); $settings = !empty($payment['ext_data']) ? $payment['ext_data'] : array(); $url = 'https://api.stripe.com/v1/' . $end_point; if (isset($settings['live_secret_key']) and $settings['transaction_mode'] === 'live') { $options['HTTPHEADER'] = array("Authorization: Bearer " . $settings['live_secret_key']); } else { if (isset($settings['live_secret_key'])) { $options['HTTPHEADER'] = array("Authorization: Bearer " . $settings['test_secret_key']); } } $options['POSTFIELDS'] = $data; // Get response from the server. $response = get_remote_data($url, $options); $response = json_decode($response); if (isset($response->error->type) and $response->error->type !== 'card_error') { log_message('error', "Stripe Error -> {$order_data['order_id']}: {$response->error->message}"); } return $response; }
public function getRemoteData($url, $options = array(), $params = array()) { $options['USERAGENT'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:43.0) Gecko/20100101 Firefox/43.0'; $options['AUTOREFERER'] = TRUE; $options['FAILONERROR'] = TRUE; $options['FOLLOWLOCATION'] = 1; if (empty($options['TIMEOUT'])) { $options['TIMEOUT'] = 30; } if (!empty($params)) { $options['POSTFIELDS'] = $params; } return get_remote_data($url, $options); }
$filterParam = "navn"; } elseif ($filterParam == "orgnum") { $filterParam = "organisasjonsnummer"; } if ($filterType == "startswith") { $filterset = "startswith({$filterParam},'" . $filterValue . "')"; } elseif ($filterType == "equalto") { $filterset = "{$filterParam} eq '" . $filterValue . "'"; } if ($filterParam == "organisasjonsnummer" && $filterType == "equalto") { $endpointUrl = 'http://data.brreg.no/enhetsregisteret/underenhet/' . $filterValue . '.json'; } else { $endpointUrl = 'http://data.brreg.no/enhetsregisteret/enhet.' . $format . '?page=' . $page . '&size=' . $size . '&$filter=' . $filterset; } ## echo "<pre/>";print_r("Generated URL: ".$endpointUrl); $firmsData = get_remote_data($endpointUrl); header('Content-type: application/json'); $finalData = json_decode($firmsData); ## echo "<pre/>";print_r($finalData);die; //Check if it's a dataset or single firm'' if (property_exists($finalData, "data")) { $actualData = $finalData->data; } else { $actualData = $finalData; } ## echo "<pre/>";print_r($actualData);die; //If dataset of firms then extract firms one-by-one if (is_array($actualData)) { $firms = $actualData; foreach ($firms as $firm) { ## echo $firm->navn."\n";
function toXML($str) { if (strpos($str, "BEGIN:VCALENDAR") === false) { $str = get_remote_data($str); } $arr = $this->toHash($str); $str = '<?xml version="1.0" encoding="UTF-8"?>'; $str .= '<data>'; for ($i = 1; $i <= sizeof($arr); $i++) { $str .= '<event id="' . $arr[$i]['event_id'] . '">'; $str .= '<start_date><![CDATA[' . $arr[$i]['start_date'] . ']]></start_date>'; $str .= '<end_date><![CDATA[' . $arr[$i]['end_date'] . ']]></end_date>'; $str .= '<text><![CDATA[' . $arr[$i]['text'] . ']]></text>'; $str .= '<rec_type><![CDATA[' . $arr[$i]['rec_type'] . ']]></rec_type>'; $str .= '<event_pid><![CDATA[' . $arr[$i]['event_pid'] . ']]></event_pid>'; $str .= '<event_length><![CDATA[' . $arr[$i]['event_length'] . ']]></event_length>'; $str .= '</event>'; } $str .= '</data>'; return $str; }
public function lys_next() { $room_id = $this->session->set_userdata('room_id', $this->uri->segment(4)); if ($this->session->userdata('room_id') == '' && $this->uri->segment(4) == '') { redirect('users/signin'); } if ($this->uri->segment(4) != '') { $user_check = $this->db->where('id', $this->uri->segment(4))->where('user_id', $this->dx_auth->get_user_id())->get('list'); if ($user_check->num_rows() == 0) { redirect('users/signin'); } $room_id = $this->uri->segment(4); $this->session->set_userdata('room_id', $room_id); $new_check = $this->db->where('id', $room_id)->get('lys_status'); if ($new_check->num_rows() == 0) { redirect('rooms/edit_photo/' . $room_id); } } if ($this->uri->segment(3) == 'edit' || $this->input->get('month') != '') { if ($this->input->post("next")) { $db_name = $this->config->item('db'); $db_table = "calendar"; if ($this->input->post("ical_url") && $this->input->post("ical_url") != '') { $ical_url = trim($this->input->post("ical_url")); $ical_content = trim($ical_url); /* if (@file_get_contents($ical_url) == true) { $ical_content = trim($ical_url); } else { $problems[] = "Ical resource specified by url is not available."; }*/ } else { $problems[] = "Resource file should be specified."; $data['required_msg'] = 1; //echo '<span style="color:red">Please Give Valid URL.</span>'; } if (isset($ical_content)) { $check_ical = $this->db->where('url', trim($this->input->post('ical_url')))->where('list_id', $this->uri->segment(4))->get('ical_import'); $log = array(); if ($this->input->post('ical_url') != '') { if ($check_ical->num_rows() == 0) { $query1 = $this->db->query("SELECT table_name FROM information_schema.tables WHERE table_schema = '{$db_name}' AND table_name = '{$db_table}' LIMIT 1"); /*! exporting event from source into hash */ require_once realpath(APPPATH . '../app/views/templates/blue/rooms/codebase/class.php'); $exporter = new ICalExporter(); $events = $exporter->toHash($ical_content); $success_num = 0; $error_num = 0; /*! inserting events in database */ $check_tb = $this->db->select('group_id')->where('list_id', $this->uri->segment(4))->order_by('id', 'desc')->limit(1)->get('calendar'); if ($check_tb->num_rows() != 0) { $i1 = $check_tb->row()->group_id; } else { $i1 = 1; } $value_start = substr(get_remote_data($ical_url), 0, 5); if ($value_start == 'BEGIN') { $data = array('id' => NULL, 'list_id' => $this->uri->segment(4), 'url' => trim($this->input->post('ical_url')), 'last_sync' => date('d M Y, g:i a', gmt_to_local(time(), get_user_timezone(), false))); $this->Common_model->insertData('ical_import', $data); $ical_id = $this->db->insert_id(); if (count($events)) { for ($i = $i1; $i <= $i1 + count($events); $i++) { if ($i == $i1) { $event = $events[1]; } else { $event = $events[$i - $i1]; } $days = (strtotime($event["end_date"]) - strtotime($event["start_date"])) / (60 * 60 * 24); $created = $event["start_date"]; for ($j = 1; $j <= $days; $j++) { if ($days == 1) { $direct = 'single'; } else { if ($days > 1) { if ($j == 1) { $direct = 'left'; } else { if ($days == $j) { $direct = 'right'; } else { $direct = 'both'; } } } } $startdate1 = $event["start_date"]; $id = $this->uri->segment(4); $check_dates = $this->db->where('list_id', $this->uri->segment(4))->where('booked_days', strtotime($startdate1))->get('calendar'); if ($check_dates->num_rows() != 0) { } else { $data = array('id' => NULL, 'list_id' => $this->uri->segment(4), 'group_id' => $i, 'availability' => "Booked", 'value' => 0, 'currency' => "EUR", 'notes' => "Not Available", 'style' => $direct, 'booked_using' => $ical_id, 'booked_days' => strtotime($startdate1), 'created' => strtotime($created)); $this->Common_model->insertData('calendar', $data); } $abc = $event["start_date"]; $newdate = strtotime('+1 day', strtotime($abc)); $event["start_date"] = date("m/d/Y", $newdate); } $success_num++; } //for loop end $data['success_num'] = count($events); $log = array("text" => count($events) . " Booking were inserted successfully.", "type" => "Success"); } else { $log = array("text" => "No data in given URL.", "type" => "Error"); } } else { $log = array("text" => "Please give valid URL.", "type" => "Error"); } } else { $ical_id = $check_ical->row()->id; /*! exporting event from source into hash */ require_once realpath(APPPATH . '../app/views/templates/blue/rooms/codebase/class.php'); $exporter = new ICalExporter(); $events = $exporter->toHash($ical_content); $success_num = 0; $error_num = 0; /*! inserting events in database */ $check_tb = $this->db->select('group_id')->where('list_id', $this->uri->segment(4))->order_by('id', 'desc')->limit(1)->get('calendar'); if ($check_tb->num_rows() != 0) { $i1 = $check_tb->row()->group_id; } else { $i1 = 1; } if (count($events) != 0) { for ($i = $i1; $i <= $i1 + count($events); $i++) { if ($i == $i1) { $event = $events[1]; } else { $event = $events[$i - $i1]; } $days = (strtotime($event["end_date"]) - strtotime($event["start_date"])) / (60 * 60 * 24); $created = $event["start_date"]; for ($j = 1; $j <= $days; $j++) { if ($days == 1) { $direct = 'single'; } else { if ($days > 1) { if ($j == 1) { $direct = 'left'; } else { if ($days == $j) { $direct = 'right'; } else { $direct = 'both'; } } } } $startdate1 = $event["start_date"]; $id = $this->uri->segment(4); $check_dates = $this->db->where('list_id', $this->uri->segment(4))->where('booked_days', strtotime($startdate1))->get('calendar'); if ($check_dates->num_rows() != 0) { } else { $data = array('id' => NULL, 'list_id' => $this->uri->segment(4), 'group_id' => $i, 'availability' => "Booked", 'value' => 0, 'currency' => "EUR", 'notes' => "Not Available", 'style' => $direct, 'booked_using' => $ical_id, 'booked_days' => strtotime($startdate1), 'created' => strtotime($created)); $this->Common_model->insertData('calendar', $data); } $abc = $event["start_date"]; $newdate = strtotime('+1 day', strtotime($abc)); $event["start_date"] = date("m/d/Y", $newdate); } $success_num++; } //for loop end $update_sync['last_sync'] = date('d M Y, g:i a', gmt_to_local(time(), get_user_timezone(), false)); $this->db->where('id', $ical_id)->update('ical_import', $update_sync); } $log = array("text" => "This URL were already imported.", "type" => "Error"); } $data['log'] = $log; } } else { $log = array("text" => "No data in given URL.", "type" => "Error"); $data['log'] = $log; } } $check_calendar = $this->db->where('id', $this->uri->segment(4))->where('user_id', $this->dx_auth->get_user_id())->get('list'); if ($check_calendar->num_rows() == 0) { redirect('info'); } $list_id = $this->uri->segment(4); $param = $list_id; $day = date("d"); $month = $this->input->get('month', TRUE); $year = $this->input->get('year', TRUE); if (!empty($month) && !empty($year)) { $month = $month; $year = $year; } else { $month = date("m"); $year = date("Y"); } if ($month > 12 || $month < 1) { $month = date("m"); } else { $month = $month; } if ($year == $year - 3 || $year == $year + 3) { redirect('calendar/single/' . $list_id . '?month=' . $month . '&year=' . date("Y")); } $row = $this->Common_model->getTableData('list', array('id' => $param))->row(); $data['list_title'] = $row->title; $data['list_price'] = $row->price; $conditions = array('list_id' => $list_id); $data['result_cal'] = $this->Trips_model->get_calendar($conditions)->result(); $data['list_id'] = $list_id; $data['day'] = $day; $data['month'] = $month; $data['year'] = $year; //Remove incorrect list from seasonal price $query = $this->Common_model->getTableData('seasonalprice', array('list_id' => $list_id)); $res = $query->result_array(); foreach ($res as $seasonal) { $starttime = $seasonal['start_date']; $gmtTime = $seasonal['end_date']; if ($gmtTime < $starttime) { $list_id = $seasonal['list_id']; $remove_query = "delete from seasonalprice where list_id='" . $list_id . "' and start_date='" . $seasonal['start_date'] . "' and end_date='" . $seasonal['end_date'] . "'"; $remove_exe = $this->db->query($remove_query); } } } //edit function if condition close //data fetch to display $result = $this->db->where('id', $room_id)->get('list')->row(); // print_r($result); $lys_status = $this->db->where('id', $room_id)->get('lys_status')->row(); if ($result->lat != '' && $result->long != '') { $data['MapURL'] = $this->circle_map($result->lat, $result->long); } $data['city'] = $result->city; $data['state'] = $result->state; $data['room_type'] = $result->title; $data['room_id'] = $result->id; $data['calendar_type'] = $result->calendar_type; $data['price'] = $result->price; $data['house_rule'] = $result->house_rule; $data['currency'] = $result->currency; $data['lys_status'] = $lys_status; $data['beds'] = $result->beds; $data['bed_type'] = $result->bed_type; $data['instance_book'] = $result->instance_book; $data['address'] = $result->address; $data['street_address'] = $result->street_address; $data['optional_address'] = $result->optional_address; if ($result->country == 'UK') { $data['country_name'] = 'United Kingdom'; } else { $data['country_name'] = $result->country; } $data['lat'] = $result->lat; $data['lng'] = $result->long; $check_policy = $this->Common_model->getTableData('cancellation_policy', array('id' => $result->cancellation_policy)); if ($check_policy->num_rows() != 0) { $data['cancellation_policy'] = $check_policy->row()->id; } else { $data['cancellation_policy'] = 1; } $data['cancellation_policy_data'] = $this->Common_model->getTableData('cancellation_policy', array('is_standard' => "1")); $data['is_enable'] = $result->is_enable; $data['list_pay'] = $result->list_pay; //echo $data['country_name'];exit; $data['lys_status_count'] = $lys_status->calendar + $lys_status->price + $lys_status->overview + $lys_status->address + $lys_status->listing + $lys_status->photo; $data['total_status'] = $lys_status->overview + $lys_status->calendar + $lys_status->price + $lys_status->photo + $lys_status->listing + $lys_status->address; $data['zipcode'] = $result->zip_code; $data['room_type_org'] = $result->room_type . ' in ' . $this->session->userdata('city'); $data['room_type_only'] = $result->room_type; $data['desc'] = $result->desc; $data['amenities'] = $this->db->get('amnities'); $data['home_type'] = $this->db->where('id', $result->property_id)->get('property_type')->row()->type; $data['accommodates'] = $result->capacity; $data['bedrooms'] = $result->bedrooms; $data['bathrooms'] = $result->bathrooms; $data['result_amenites'] = $this->db->where('id', $room_id)->get('list')->row()->amenities; $data['country'] = $this->db->get('country'); $data['video_code'] = $result->video_code; $price_table = $this->db->where('id', $room_id)->get('price')->row(); $currency_check = $this->db->where('currency_code', $result->currency)->where('status', 1)->get('currency'); $data['currency_symbol'] = $this->db->where('currency_code', $result->currency)->get('currency')->row()->currency_symbol; if ($currency_check->num_rows() == 0) { $data['currency'] = get_currency_code(); $data['currency_symbol'] = $this->db->where('currency_code', get_currency_code())->get('currency')->row()->currency_symbol; $data['price'] = get_currency_value1($result->id, $result->price); $data['week_price'] = get_currency_value1($result->id, $price_table->week); $data['month_price'] = get_currency_value1($result->id, $price_table->month); $data['cleaning_fee'] = get_currency_value1($result->id, $price_table->cleaning); $data['security'] = get_currency_value1($result->id, $price_table->security); $data['guest_count'] = get_currency_value1($result->id, $price_table->guests); $data['extra_guest_price'] = get_currency_value1($result->id, $price_table->addguests); } else { $data['week_price'] = $price_table->week; $data['month_price'] = $price_table->month; $data['cleaning_fee'] = $price_table->cleaning; $data['security'] = $price_table->security; $data['guest_count'] = $price_table->guests; $data['extra_guest_price'] = $price_table->addguests; } $data['currency_result'] = $this->db->where('status', 1)->get('currency'); $data['list_photo'] = $this->db->where('list_id', $room_id)->order_by('id', 'asc')->get('list_photo'); $data["title"] = get_meta_details('List_Your_property', 'title'); $data["meta_keyword"] = get_meta_details('List_Your_property', 'meta_keyword'); $data["meta_description"] = get_meta_details('List_Your_property', 'meta_description'); $data["message_element"] = "list_your_space/view_list_your_space_next"; $this->load->view('template', $data); }
function DirectSELECT($query) { $query = urlencode($query); $query = QueryEndPoint() . "?query=" . $query; return get_remote_data($query); }