Created
April 7, 2021 23:57
-
-
Save saerdnaer/4c60bb911bf3686ca836ed12feb69811 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/* | |
SELECT meta_value, u.user_login, u.user_registred, u.display_name | |
FROM wp_usermeta um LEFT JOIN wp_users u ON u.id = um.user_id | |
WHERE um.meta_key = 'session_tokens'; | |
*/ | |
$file = file('wp-usermeta.csv'); | |
$out = fopen('wp-usermeta-out.csv', 'w'); | |
$i = 0; | |
foreach($file as $row){ | |
$i += 1; echo('.'); | |
$row = str_getcsv($row); | |
// write header directly without processing | |
if ($i == 1) { | |
fputcsv($out, $row); | |
continue; | |
} | |
$data = unserialize(str_replace('\"', '"', $row[0])); | |
$mv = reset($data); | |
$row[0] = implode('|', [date("d.m.Y H:i", $mv['login']), date("d.m.Y G:I", $mv['expiration']), $mv['ip'], $mv['ua']]); | |
fputcsv($out, $row); | |
} | |
fclose($out); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment