Skip to content

Instantly share code, notes, and snippets.

@AndrewCarterUK
Created May 9, 2016 14:07
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save AndrewCarterUK/038c84082a4d5ab6fd8c129786827ac7 to your computer and use it in GitHub Desktop.
Save AndrewCarterUK/038c84082a4d5ab6fd8c129786827ac7 to your computer and use it in GitHub Desktop.
Script used to verify fraudulent installs on PHPixie.
<?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