How to check stock market data

Honestly, I am not an expert and am very confused how to even state my problem ... so please forgive my lack of knowledge and this long, confusing question.

I was assigned a project today, when clients display information about the stock market on their page (the image is attached below). And when you click on any of the buttons (for example, NASDAQ), additional information is displayed in a pop-up window.

screen shot

They use onClick()to send the entire row to this third party to collect data. Here is the HTML code for the NASDAQ link:

    <li>
        <a href="#" onClick="open('https://app.quotemedia.com/quotetools/clientForward?symbol=^NASD&targetURL=http://app.quotemedia.com/quotetools/popups/quote.jsp?webmasterId=99944&locale=en_US','miniwin','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=550,height=270,top=20,left=0'); return false;">  

           NASDAQ             
           <span id="imageNASDAQ"></span> 
           <span id="valueNASDAQ" class="share_value"></span> 
           <span id="textNASDAQ"></span> 
        </a> 

        <script type="text/javascript" src="/getStockInfo.php?Stocks[NASD]=NASDAQ"></script>
    </li>

And then in the file getStockInfo.phpthey collect the data as a JSON string and then parse it. Here's how they collect data:

    <?php
    if (array_key_exists("Stocks", $_GET)) {
        foreach($_GET['Stocks'] as $symbol=>$stock) {
           print file_get_contents("https://app.quotemedia.com/quotetools/jsVarsQuotes.go?webmasterId=99944&symbol=$symbol");
    ?>

Still pretty simple. But now the client wants to do something

  • " "
  • " 4 : SP500, SPX, DOW NASDAQ"

. ( HTML) , (open('...symbol=^NASD...'); open('...symbol=^SPX...'); open('...symbol=^DJI...');), / getStockInfo.php(src="/getStockInfo.php?Stocks[NASD]=NASDAQ" src="...Stocks[SPX]=SP500" src="...Stocks[DJI]=DOW"), . , - , .

, 2 . , .

, :( . , - . , !!:)

+3
1

:

if (array_key_exists("Stocks", $_GET)) {
    $stocks = array_filter($_GET['Stocks'], 'filterStocks');
    foreach ($stocks as $symbol => $stock) {
        print file_get_contents(…);
    }
}

function filterStocks($symbol) {
    return in_array(
        $symbol, 
        array('SP500', 'SPX', 'DOW', 'NASDAQ')
    )
}

getStockInfo.php . , filterStocks

function filterStocksForLoggedInUser($symbol) {
    return in_array($symbol, getAllowedSymbolsForUser());
}

function getAllowedSymbolsForUser()
{
    $permissions = include '/path/to/permissions/file.php';
    return isset($permissions[$_SESSION['username']])
        ? $permissions[$_SESSION['username']]
        : array();
    }
}

return array(
    'Walahh' => array('SP500', 'SPX', 'DOW', 'NASDAQ'),
    'JohnDoe' => array('SP500', 'GOOG')
);

1:. , , $_SESSION['username']. , , .

2: . - , .

3: . . , , , , , , .

+1

All Articles