<?php

include 'simple_html_dom.php';
function auth_ruris()
{
    $url = 'https://web.rurisx5w.expert-account.com/webshop/2';
    $user = 'andrei.vasile@travandi.ro';
    $pass = '5425an748';
    $url_login = 'https://web.rurisx5w.expert-account.com/webshop/?wsaid=2';
    $login = ['server' => 'xhttp2502', 'ajax' => '.ruris redirectate.mod_ajax.php', 'function' => 'store_loginruris1()', 'var0' => 'travandi', 'var1' => '5425an748', 'email' => 'travandi', 'psw' => '5425an748'];
    $data = ["server" => "xhttp2504", "ajax" => "ws.itemlist.client_ajax.php", "function" => "ctlboxst_click1()", "function" => "ctlboxst_click2()"];
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url_login);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.A.B.C Safari/525.13");
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Access-Control-Allow-Origin: *'));
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($login));
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_COOKIEFILE, "ruris_cookies.txt");
    curl_setopt($ch, CURLOPT_COOKIEJAR, "ruris_cookies.txt");
    $response = curl_exec($ch);
    curl_close($ch);
    $cod_produs = '6500k2017';
    $ch0 = curl_init();
    curl_setopt($ch0, CURLOPT_URL, "https://web.rurisx5w.expert-account.com/webshop/?wsaid=2&lang=romana&page=ws.itemlist&q=" . $cod_produs);
    curl_setopt($ch0, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.A.B.C Safari/525.13");
    curl_setopt($ch0, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch0, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch0, CURLOPT_HTTPHEADER, array('Access-Control-Allow-Origin: *'));
    curl_setopt($ch0, CURLOPT_POST, 1);
    $data = ["server" => "xhttp2504", "ajax" => "ws.itemlist.client_ajax.php", "function" => "ctlboxst_click1()"];
    curl_setopt($ch0, CURLOPT_POSTFIELDS, http_build_query($data));
    curl_setopt($ch0, CURLOPT_COOKIEFILE, "ruris_cookies.txt");
    curl_setopt($ch0, CURLOPT_COOKIEJAR, "ruris_cookies.txt");
    $reponsez = curl_exec($ch0);
    curl_close($ch0);
    $ch1 = curl_init();
    curl_setopt($ch1, CURLOPT_URL, "https://web.rurisx5w.expert-account.com/webshop/?wsaid=2&lang=romana&page=ws.itemlist&q=" . $cod_produs);
    curl_setopt($ch1, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.A.B.C Safari/525.13");
    curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch1, CURLOPT_HTTPHEADER, array('Access-Control-Allow-Origin: *'));
    curl_setopt($ch1, CURLOPT_POST, 1);
    $data = ["server" => "xhttp2504", "ajax" => "ws.itemlist.client_ajax.php", "function" => "ctlboxst_click1()"];
    curl_setopt($ch1, CURLOPT_COOKIEFILE, "ruris_cookies.txt");
    curl_setopt($ch1, CURLOPT_COOKIEJAR, "ruris_cookies.txt");
    $reponsez = curl_exec($ch1);
    curl_close($ch1);
    $html = str_get_html($reponsez);
    $test = $html->find('p.price');
    foreach ($test as $a) {
        echo $a->innertext;
    }
}
auth_ruris();