<?php // $Id$ include 'settings.php'; #read CSV-File $script = strtolower(getScriptName()); $CSVArray = getCSV(); if (isset($CSVArray[$script])) { $links = $CSVArray[$script]; } function cacheurl($url, $browser_req = true, $cookies = "", $browser = "Firefox") { global $myconfig; #find cache file $hash = md5($url); $datei = "cache/" . $hash; if (file_exists($datei)) { if (time() - filemtime($datei) < $myconfig['cachetime']) { return implode('', file($datei)); } } #no cache file exists send browser request if ($browser_req == true) { $objekt = new Browser($browser); if ($cookies != "") { $objekt->cookies_set($cookies); } $objekt->url = $url; $t_html = $objekt->read(); } else { $t_html = implode('', file($url));
<?php require_once "../init.php"; $redisMD5 = $redis->get("tqSDE:MD5"); if ($redisMD5 != null && date('i') != 0) { exit; } $sdeMD5 = file_get_contents("https://www.fuzzwork.co.uk/dump/mysql-latest.tar.bz2.md5"); if ($sdeMD5 == $redisMD5) { exit; } Util::out("New SDE detected, importing now"); getCSV("https://www.fuzzwork.co.uk/dump/latest/dgmTypeAttributes.csv.bz2", "updateSlots"); getCSV("https://www.fuzzwork.co.uk/dump/latest/invNames.csv.bz2", "updateLocationID"); $redis->setex("tqSDE:MD5", 86400 * 7, $sdeMD5); function getCSV($url, $method) { global $mdb, $redis; $file = $redis->get("RC:{$url}"); if ($file == null) { $file = file_get_contents($url); $redis->setex("RC:{$url}", 900, $file); } $csv = bzdecompress($file); Util::out("Parsing {$url}"); parseCSV($csv, $method); } function updateLocationID($fields) { global $mdb, $redis; $locationID = (int) $fields['ITEMID'];
<?php //var_dump($data[0]); $data = array_values($_POST); //var_dump($data[0]); getCSV($data[0], 'YourBCSPathway'); function getCSV($res, $fileName) { session_start(); if (!empty($_SESSION['download_' . $fileName]) && time() - $_SESSION['download_' . $fileName] < 10) { exit; } // Check, then exit if you have requested before in 10 seconds $_SESSION['download_' . $fileName] = time(); $header = "Semester;Code;Subject Name"; $data = ""; foreach ($res as $row) { $line = ''; foreach ($row as $value) { if (!isset($value) || $value == "") { $value = ";"; } else { $value = str_replace('"', '""', $value); $value = '"' . $value . '"' . ";"; } $line .= $value; } $data .= trim($line) . "\n"; } $data = str_replace("\r", "", $data); if ($data == "") {
<?php require 'includes/DBconnect.php'; set_time_limit(0); $tickerFile = fopen('tickers.txt', 'r'); while (!feof($tickerFile)) { $currentTicker = trim(fgets($tickerFile)); $currentFileURL = createURL($currentTicker); $currentTxtFile = "txtFiles/{$currentTicker}.txt"; getCSV($currentFileURL, $currentTxtFile); fileToDB($currentTxtFile, $currentTicker); } fclose($tickerFile); echo 'Action Complete!'; function createURL($ticker) { $startYear = 2010; $currentMonth = date('n') - 1; $currentDay = date('j'); $currentYear = date('Y'); return "http://real-chart.finance.yahoo.com/table.csv?s={$ticker}&d={$currentMonth}&e={$currentDay}&f={$currentYear}&g=d&a=00&b=1&c={$startYear}&ignore=.csv"; } function getCSV($url, $output) { $content = file_get_contents($url); $content = trim(str_replace('Date,Open,High,Low,Close,Volume,Adj Close', '', $content)); file_put_contents($output, $content); } function fileToDB($txtFile, $tableName) { global $dbh;