I want to know the programmable logic of getting the magento version by just entering URL of the magento store.Something similar is seen here.
2 Answers
Finally after long research I found Following code useful to determine Version of Magento.
<?php
function get_data($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$file = $url.'/skin/frontend/default/default/css/styles.css';
$data = get_data($file);
$data = explode("\n", $data);
for ($line = 0; $line < count($data); $line++)
{
if(strpos($data[$line],"2010" )){$mver= 1.5;}
elseif(strpos($data[$line],"2011")){$mver= 1.6;}
elseif(strpos($data[$line],"2012")){$mver= 1.7;}
elseif(strpos($data[$line],"2013")){$mver= 1.8;}
elseif(strpos($data[$line],"2014")){$mver= 1.9;}
}
?>
I hope it would help you all
https://github.com/steverobbins/magento-guest-audit/blob/master/src/MGA/Check/Version.php(broken)
https://github.com/steverobbins/magescan/blob/master/src/MageScan/Check/Version.php
MGA fetches js/varien/product.js, and then pulls license information and the copyright year from the header to guess at the version. Note that it can't differentiate 1.4 from 1.5 this way - if you cared enough you could keep a list of hashes of each JS file and track changes in more detail.
-
Can you explain me this code in deep please I am not getting it. Commented May 11, 2015 at 5:27