Created
January 26, 2017 10:49
-
-
Save kyob/a920ff7a9c8c5ba198e8e3b559982e86 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$mysqli_remote = new mysqli("rhost", "rlogin", "rpass", "rdb"); | |
mysqli_local = new mysqli("lhost", "lroot", "lpass", "ldb"); | |
/* check connection */ | |
if (mysqli_connect_errno()) { | |
printf("Connect failed: %s\n", mysqli_connect_error()); | |
exit(); | |
} | |
$sqlt = "TRUNCATE TABLE radcheck"; | |
$mysqli_local->query($sqlt); | |
$query = "SELECT id, pin FROM customersview WHERE ssn != '' AND deleted = 0 AND email != '' AND consentdate > 0 ORDER BY id"; | |
$ile=0; | |
if ($result = $mysqli_remote->query($query)) { | |
/* fetch associative array */ | |
while ($row = $result->fetch_assoc()) { | |
$sql = "INSERT INTO radcheck (id,username,attribute,op,value) VALUES (NULL, ".$row['id'].", 'Cleartext-Password', ':=', ".$row['pin'].");"; | |
if(!$mysqli_local->query($sql)) { | |
echo "insert failed, error: ", $mysqli_local->error; | |
} | |
$ile++; | |
} | |
/* free result set */ | |
$result->free(); | |
} | |
echo "Affected rows (INSERT): ".$ile."\n"; | |
/* close connection */ | |
$mysqli_remote->close(); | |
$mysqli_local->close(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment