-
-
Save samayo/739ac014d1f4070d2e34346563b71b3d to your computer and use it in GitHub Desktop.
Script used to verify fraudulent installs on PHPixie.
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 | |
function getJsonPage($url) | |
{ | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$result = curl_exec($ch); | |
curl_close($ch); | |
return json_decode($result, true); | |
} | |
$baseUrl = 'https://packagist.org/packages/'; | |
$downloads = []; | |
foreach ([ | |
'phpixie/project', | |
'phpixie/orm', | |
'phpixie/config', | |
'symfony/symfony', | |
'laravel/framework', | |
'slim/slim', | |
'zendframework/zend-expressive', | |
] as $package) { | |
$apiUrl = $baseUrl . $package . '.json'; | |
$data = getJsonPage($apiUrl); | |
if (!isset($data['package']) || !isset($data['package']['downloads'])) { | |
continue; | |
} | |
$downloads[$package] = $data['package']['downloads']; | |
} | |
$dumpFile = __DIR__ . '/dump/' . date('Y-m-d-H-i') . '.json'; | |
file_put_contents($dumpFile, json_encode($downloads, JSON_PRETTY_PRINT)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment