<?php require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/csv-to-json.php'; $funcionarios = csvToJson('funcionarios.csv'); $fontes = csvToJson('fontes.csv'); $home = csvToJson('home.csv'); $app = new Silex\Application(); // use the factory to create a Faker\Generator instance $faker = \Faker\Factory::create(); $app->get('/search', function () use($faker) { $listaDemandas = array(); for ($i = 0; $i <= 50; $i++) { $item = array('coordenacaoTi' => 'CEDESSP' . $faker->numberBetween(0, 900), 'criadas' => $faker->numberBetween(100, 900), 'percAtendimento' => $faker->numberBetween(0, 100), 'pfEntregue' => $faker->numberBetween(0, 500), 'backlogInicial' => $faker->numberBetween(0, 100), 'backlogFinal' => $faker->numberBetween(0, 100), 'percVariacaoBacklog' => $faker->numberBetween(0, 100), 'backlogMeta' => $faker->numberBetween(0, 100), 'percBacklogMeta' => $faker->numberBetween(0, 100), 'percDefeitos' => $faker->numberBetween(0, 100), 'pfPorTecnico' => $faker->numberBetween(0, 100), 'pfPerCapita' => $faker->numberBetween(0, 100)); $listaDemandas[] = $item; } return json_encode($listaDemandas); }); $app->get('/', function () use($home) { return 'Home - SIGCM - PHP'; }); $app->get('/home', function () use($home) { return $home; }); $app->get('/funcionarios', function () use($funcionarios) { return $funcionarios; }); $app->get('/portfolio-interno', function () use($fontes) { return $fontes; }); //Enable CORS in a RESTFull Silex server
<?php $csv = shell_exec('cat /home/snchau/scripts/ucrex_querier/querier_php_output.txt'); function csvToJson($csv) { $rows = explode("\n", trim($csv)); $csvarr = array_map(function ($row) { $keys = array('qname', 'qtime', 'qsite1', 'qsite2', 'qsite3', 'qsite4'); return array_combine($keys, str_getcsv($row)); }, $rows); $json = json_encode($csvarr); return $json; } $json = csvToJson($csv); header('Content-Type: application/json'); header('Cache-Control: no-cache'); echo "{$json}"; ?>
echo "Sorry, your file is too large."; $uploadOk = 0; } // Allow certain file formats if ($imageFileType != "csv") { echo "Sorry, only CSV files are allowed."; $uploadOk = 0; } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { echo "Sorry, your file was not uploaded."; // if everything is ok, try to upload file } else { if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { echo "The file has been uploaded from" . $_FILES["fileToUpload"]["name"] . "to" . $target_file; csvToJson($target_file); return $target_file; } else { echo "Sorry, there was an error uploading your file."; } $csv = file_get_contents($target_file); $array = array_map("str_getcsv", explode("\n", $csv)); //$out = array_values($array); //echo json_encode($out); $json = json_encode($array); //print_r($json); //echo json_encode($array); //print($json); } ?> </body>
public function getTimeZoneInCSV($arg) { //echo display_form(1); csvToJson($arg); }