function utf8_string_array_encode(&$array) { $func = function (&$value, &$key) { if (is_string($value)) { $value = utf8_encode($value); } if (is_string($key)) { $key = utf8_encode($key); } if (is_array($value)) { utf8_string_array_encode($value); } }; array_walk($array, $func); return $array; }
} if ($_POST['Type']) { $c = array($_POST['Type']); } else { $c[] = array("RO (58 mm)", "RU (58 mm)", "RV (58 mm)"); } if ($_POST['Connection']) { $c = array($_POST['Connection']); } else { $c[] = array("connector", "Cable", "terminals"); } if ($_POST['approval']) { $c = array($_POST['approval']); } else { $c[] = array("cNRTLus (TUV)", "e1"); } $c = utf8_string_array_encode($c); $tableName = "products_7"; $cols = "System,Design,Resolution,Shaft,Output,Features,Bit,Type,Connection,approval,imgurl"; $conn = sqlConnectDefault(); for ($i = 0; $i < $_POST['id']; $i++) { $select = array(); for ($j = 0; $j < 10; $j++) { $select[] = $c[$j][array_rand($c[$j])]; } $select[] = "'https://www.ifm.com/tedo/foto/400_00" . rand(10, 36) . ".gif'"; simpleInsert($select, $tableName, $cols, $conn); } $statusMessage = makeStatusMessage(26, "success", "Product added!"); mysqli_close($conn); return;
<?php require_once "config/config.php"; $q = ""; $data = array(); if (!empty($_POST["q"])) { if (file_exists("config/" . $_POST["q"] . ".php")) { require_once "config/" . $_POST["q"] . ".php"; $q = $_POST['q']; } else { $statusMessage = makeStatusMessage(1, "error", "Incorrect query request..."); } } else { $statusMessage = makeStatusMessage(0, "error", "Empty query request..."); } if (!empty($data)) { $main = array($q => $data, "status" => $statusMessage); } else { $main = array("status" => $statusMessage); } $main = utf8_string_array_encode($main); echo json_encode($main); if (isset($GLOBALS['debugSQL']) && $GLOBALS['debugSQL']) { echo "<form method=post action=handle.php>\n\t\t<input type=text name=q />\n\t\t<input type=text value=email name=email />\n\t\t<input type=text value=pass name=pass />\n\t\t<input type=text value=id name=id />\n\t\t<input type=text value=name name=names[EN] />\n\t\t<input type=text value=desc name=desc[EN] />\n\t\t\t\t\n\t\t\n\t\t<input type=hidden value=1 name=fid[] />\n\t\t<input type=hidden value=2 name=fid[] />\n\t\t<input type=hidden value=3 name=fid[] />\n\t\t<input type=hidden value=4 name=fid[] />\n\t\t<input type=hidden value=5 name=fid[] />\n\t\t<input type=hidden value=6 name=fid[] />\n\t\t<input type=hidden value=7 name=fid[] />\n\t\t<input type=hidden value=8 name=fid[] />\n\t\t<input type=hidden value=9 name=fid[] />\n\t\t<input type=hidden value=12 name=fid[] />\n\t\t\t\t\n\t\t<input type=text value=Cable name=filters[connection] />\n\t\t\t\t \n\t\t<input type=hidden value=1 name=debug />\n\t\t<input type=submit>\n\t\t</form>"; }