|
<?php |
|
|
|
echo "Asian FB Cookies to JSON Converter v1.2\n"; |
|
echo " by Yellow Web\n\n"; |
|
// Check if the filename is provided |
|
if ($argc < 2) { |
|
echo "Usage: php script.php filename\n"; |
|
exit(1); |
|
} |
|
|
|
// Get the filename from the command line argument |
|
$filename = __DIR__."/".$argv[1]; |
|
if (!is_file($filename)){ |
|
echo "File: {$filename} DOES NOT EXIST!\n"; |
|
exit(1); |
|
} |
|
|
|
// Read the entire file into an array of lines |
|
$lines = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|
|
|
// Prepare the base cookie attributes |
|
$baseCookie = [ |
|
"domain" => ".facebook.com", |
|
"expirationDate" => strtotime("+6 months"), |
|
"hostOnly" => false, |
|
"httpOnly" => true, |
|
"sameSite" => "None", |
|
"secure" => true, |
|
"session" => false, |
|
"path" => "/" |
|
]; |
|
|
|
// Process each line and convert cookies to JSON format |
|
$newLines = []; |
|
$i=0; |
|
foreach ($lines as $line) { |
|
$cookies = explode(';', $line); |
|
$jsonCookies = []; |
|
|
|
foreach ($cookies as $cookie) { |
|
if (trim($cookie) == '') { |
|
continue; |
|
} |
|
list($name, $value) = explode('=', trim($cookie), 2); |
|
|
|
$cookieDetails = $baseCookie; |
|
$cookieDetails['name'] = $name; |
|
$cookieDetails['value'] = $value; |
|
|
|
// Add to the JSON cookies array |
|
$jsonCookies[] = $cookieDetails; |
|
} |
|
|
|
// Convert the cookies array to JSON string |
|
$newLines[] = json_encode($jsonCookies, JSON_UNESCAPED_SLASHES); |
|
$i++; |
|
} |
|
|
|
// Define the new file path |
|
$newFilename = 'conv_' . basename($filename); |
|
|
|
// Write all new lines to the new file |
|
file_put_contents($newFilename, implode("\n", $newLines)); |
|
|
|
echo "Conversion completed. {$i} lines converted. Output written to {$newFilename}\n"; |