Skip to content

Instantly share code, notes, and snippets.

@VIVEKLUCKY249
Created November 12, 2017 20:15
Show Gist options
  • Save VIVEKLUCKY249/8194b1f59ff5ab3ff9750dbb3a32db74 to your computer and use it in GitHub Desktop.
Save VIVEKLUCKY249/8194b1f59ff5ab3ff9750dbb3a32db74 to your computer and use it in GitHub Desktop.
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST') {
$fileExt = $_POST['typeoffile'];
$finalUrl = "https://".$_POST['MAGEID'].":".$_POST['Download_Access_Token']."@www.magentocommerce.com/products/downloads/info/filter/version/".$_POST['Magento_Version'];
// $response = get_web_page($finalUrl);
// echo "<pre>"; print_r($response); echo "</pre>";
// function get_web_page($url) {
// $options = array(
// CURLOPT_RETURNTRANSFER => true, // return web page
// CURLOPT_HEADER => false, // don't return headers
// CURLOPT_FOLLOWLOCATION => true, // follow redirects
// CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
// CURLOPT_ENCODING => "", // handle compressed
// CURLOPT_USERAGENT => "test", // name of client
// CURLOPT_AUTOREFERER => true, // set referrer on redirect
// CURLOPT_CONNECTTIMEOUT => 120, // time-out on connect
// CURLOPT_TIMEOUT => 120, // time-out on response
// );
// $ch = curl_init($url);
// curl_setopt_array($ch, $options);
// $content = curl_exec($ch);
// curl_close($ch);
// return $content;
// }
// Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $finalUrl);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
if (preg_match_all("/([^ ]+).${fileExt}/", $result, $matches)) {
#echo "<pre>";print_r($matches);echo "</pre>";
foreach ($matches[0] as $match) {
if(strpos($match, "Magento-") !== false) $filesList[] = $match;
}
echo "<pre>Links of files to download are as follows: <br/>";
foreach ($filesList as $fileName) {
echo "curl -O https://MAG005200257:9950ab04e82f33fa57e4b5ae7eacd8ac342f0d42@www.magentocommerce.com/products/downloads/file/".$fileName."<br/>";
}
echo "</pre>";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Magento Source Direct Download Link Generator</title>
<style type="text/css">
.ddlTextbox {
height: 20px;
width: 400px;
border: 1px solid black;
}
</style>
</head>
<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>" name="MageDDLForm">
<input type="text" name="MAGEID" placeholder="MAGEID" class="ddlTextbox"><br/><br/>
<input type="text" name="Download_Access_Token" placeholder="Download Access Token" class="ddlTextbox"><br/><br/>
<input type="text" name="Magento_Version" placeholder="Magento Version" class="ddlTextbox"><br/><br/>
<input type="text" name="typeoffile" placeholder="File Type" class="ddlTextbox"><br/><br/>
<button type="submit">
<span>
<span>Generate DDL</span>
</span>
</button>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment