$last_modified = filemtime(pathCache($cache_hash)); $cache_reference = readCache($cache_hash); // Filter the cache reference if ($has_compression) { $output = gzinflate($cache_reference); } else { $output = $cache_reference; } } else { // Last modified date is now $last_modified = time(); // Initialize the loop $looped = ''; // Add the content of the current file foreach ($array as $current) { $looped .= rmBOM(file_get_contents($dir . $current)) . "\n"; } // Filter the CSS if ($type == 'stylesheets') { // Apply the CSS logos $looped = setLogos($looped, $array); // Apply the CSS background $looped = setBackground($looped); // Set the Get API paths $looped = setPath($looped, $hash, HOST_STATIC, $type, ''); } // Optimize the code rendering if ($type == 'stylesheets') { // Can minify the CSS if ($has_compression && !$is_developer) { $output = compressCSS($looped);
function get_sources($csv_file_path) { global $run_environment; global $max_records; if (($handle = fopen($csv_file_path, 'r')) !== false) { // get the first row, which contains the column-titles (if necessary) $header = fgetcsv($handle); $header = rmBOM($header[0]); $header = explode("\t", $header); $count = 1; // loop through the file line-by-line while (($data = fgetcsv($handle)) !== false) { // resort/rewrite data and insert into DB here // try to use conditions sparingly here, as those will cause slow-performance //$data = iconv('utf-16le', 'utf-8', $data[0]); $data = explode("\t", $data[0]); foreach ($data as $key => $value) { $row[$header[$key]] = $value; } if ($run_environment == 'dev') { $rows[] = $row; if ($count > $max_records) { break; } // { var_dump($rows); exit;} $count++; } if ($run_environment == 'prod') { scraperwiki::save(array('MUNICIPALITY_NAME', 'TITLE', 'NAME'), $row); } unset($row); } fclose($handle); } if ($run_environment == 'dev') { return $rows; } else { return true; } }