| 1 |
<?php |
| 2 |
|
| 3 |
class Wordpress { |
| 4 |
|
| 5 |
/** |
| 6 |
* search for a wordpress in that folder. |
| 7 |
* if this class think that a wordpress is here, returns the version number, normalized. |
| 8 |
*/ |
| 9 |
function search($root) { |
| 10 |
|
| 11 |
if (is_file($root."/wp-includes/version.php")) { |
| 12 |
$f=fopen($root."/wp-includes/version.php","rb"); |
| 13 |
if (!$f) return false; |
| 14 |
$version=false; $local=false; |
| 15 |
while($s=fgets($f,1024)) { |
| 16 |
if (preg_match('#\$wp_version\s+=\s+\'(.*)\';#',$s,$mat)) { |
| 17 |
$version=$mat[1]; |
| 18 |
} |
| 19 |
if (preg_match('#\$wp_local_package\s+=\s\'(.*)\';#',$s,$mat)) { |
| 20 |
$local=$mat[1]; |
| 21 |
} |
| 22 |
} |
| 23 |
fclose($f); |
| 24 |
if ($version && $local) return $version."-".$local; else return $version; |
| 25 |
} else { |
| 26 |
return false; |
| 27 |
} |
| 28 |
|
| 29 |
} // search |
| 30 |
|
| 31 |
} // class Wordpress |