function loadSuppliers() { global $api; // Get client groups from API // No input parameters are needed $result = $api->sendRequest("getSuppliers", array("recordsOnPage" => 100)); // Default output format is JSON, so we'll decode it into a PHP array $suppliers = json_decode($result, true); //print_r($suppliers); print "<pre>"; foreach (loadCSV() as $key => $row) { $newCode = $row[0]; list($newFirst, $newLast) = explode(" ", $row[1]); $newGroupID = $row[2]; $newNote = $row[3]; print "{$newFirst} | {$newLast} | {$newCode} | {$newGroupID} | {$newNote} <br />"; $isFound = FALSE; $supplierId; foreach ($suppliers["records"] as $key => $value) { //print "Value code: " . strcmp($value["code"],$newCode) . " | " . $value["code"] . " | " . $newCode . " | <br />"; if (isset($value["code"]) && strcmp($value["code"], $newCode) == 0) { $isFound = TRUE; $supplierId = $value["supplierID"]; print "Found Code: {$newCode} for {$newFirst} with supplier id of {$supplierId} <br />"; break; } } $saveSupplier; if ($isFound) { //Update supplier $saveSupplier = array("supplierID" => $supplierId, "firstName" => $newFirst, "lastName" => $newLast, "groupID" => $newGroupID, "notes" => $newNote, "code" => $newCode); print "Supplier will be *updated* with code: {$newCode} for {$newFirst} <br />\n"; } else { //New Supplier $saveSupplier = array("firstName" => $newFirst, "lastName" => $newLast, "groupID" => $newGroupID, "notes" => $newNote, "code" => $newCode); print "New Supplier will be added with code: {$newCode} for {$newFirst} <br />\n"; } $result = $api->sendRequest("saveSupplier", $saveSupplier); $suppliers = json_decode($result, true); print_r($suppliers); } print "</pre>"; }
function makeSmallAddrArray($limit, $rawParams) { setlocale(LC_ALL, 'ja_JP.UTF-8'); $params = makeAddrParams($rawParams); $directory = './addr'; $loadedFiles = array(); $randomAddrArray = array(); $scannedDirectory = array_diff(scandir($directory), array('..', '.')); for ($i = 0; $i < $limit; ++$i) { # 読み込むファイルを定義 $filePath = $directory . '/' . $scannedDirectory[array_rand($scannedDirectory)]; # 既に一度読み込まれていないかの確認 if (array_key_exists($filePath, $loadedFiles)) { $csv = $loadedFiles[$filePath]; } else { $csv = loadCSV($filePath, $params); # 2度同じファイルを読み込むことがないように配列に読み込み済みのデータを格納 $loadedFiles[$filePath] = $csv; } $randomAddrArray[] = $csv[array_rand($csv)]; } return $randomAddrArray; }
die('Maximale erlaubte Dateigröße: 2 MB'); } elseif ($_FILES['userfile']['size'] == 0) { die('Fehler: Dateigröße 0 MB'); } else { $_SESSION['fileNameInternal'] = makeUploadName($_SESSION['fileName']); while (file_exists('upload/files/' . $_SESSION['fileNameInternal'])) { $_SESSION['fileNameInternal'] = makeUploadName($_SESSION['fileName']); } move_uploaded_file($_FILES['userfile']['tmp_name'], 'upload/files/' . $_SESSION['fileNameInternal'] . '.' . $_SESSION['extension']); $_SESSION['upload'] = 1; echo 'Upload war erfolgreich.<br/>'; if ($_SESSION['extension'] == 'csv') { //validateCSV has to be called with the minimal number of columns as second argument $valid = validateCSV('upload/files/' . $_SESSION['fileNameInternal'] . '.csv', 40); if ($valid == 1) { $data = loadCSV('upload/files/' . $_SESSION['fileNameInternal'] . '.' . $_SESSION['extension']); $serialize = serialize($data); file_put_contents('upload/files/dataPHP-' . $_SESSION['fileNameInternal'], $serialize); $_SESSION['store'] = 1; echo 'Import war erfolgreich.<br /><a href="annotate.php">Weiter zur Metadatenaufnahme</a>'; } else { unlink('upload/files/' . $_SESSION['fileNameInternal'] . '.csv'); die('Fehler beim Import: ' . $valid); } } elseif ($_SESSION['extension'] == 'xml') { $valid = validateXML('upload/files/' . $_SESSION['fileNameInternal'] . '.xml', 'uploadXML.xsd', 'mods-3-4.xsd'); if ($valid == 1) { $data = loadXML('upload/files/' . $_SESSION['fileNameInternal'] . '.' . $_SESSION['extension']); $serialize = serialize($data); file_put_contents('upload/files/dataPHP-' . $_SESSION['fileNameInternal'], $serialize); $_SESSION['store'] = 1;
} } else { require_once '/home/opendatamap/mysql.inc.php'; $params[] = mysql_real_escape_string($_REQUEST['u']); $params[] = mysql_real_escape_string($_REQUEST['m']); $q = 'SELECT uri, lat, lon, source, name, icon FROM mappoints WHERE username = \'' . $params[0] . '\' AND map = \'' . $params[1] . '\''; $res = mysql_query($q); $location = array(); while ($row = mysql_fetch_assoc($res)) { $location[$row['uri']] = array($row['lat'], $row['lon'], $row['source'], $row['name'], $row['icon']); } $q = 'SELECT source FROM maps WHERE username = \'' . $params[0] . '\' AND mapid = \'' . $params[1] . '\''; $res = mysql_query($q); if ($row = mysql_fetch_assoc($res)) { if (substr($row['source'], 0, 7) == 'http://' || substr($row['source'], 0, 8) == 'https://' || $row['source'] == '') { $data = loadCSV($row['source'], '', 'code', 'name', 'icon', 'latitude', 'longitude', 'postcode', 'building', $location); } else { $data = null; } } else { $data = null; } } //if(!isset($_SESSION['username']) || !isset($_REQUEST['graphuri']) || $_REQUEST['graphuri'] == '') if (is_null($data)) { ?> </head> <body> Map not found. </body> <?php