set_include_path($_SERVER['DOCUMENT_ROOT']);
include_once 'plugin_funcs.php';
header("Content-Type: text/plain");
$rss_array = createRSSArray();
$cats = getPluginCats();
$list_array = createPluginArray($cats,true);
$size = count($cats);
$resp_cats = array();
$resp_plugs = array();
$response = array();
function setInArray(&$p, $key, $val) {
if (!empty($val)) {
$p[$key] = $val;
}
}
function getPluginDetails($plug,$detailed = false) {
global $rss_array;
global $min_az_version;
global $min_az_version_cvs;
global $version_cvs;
global $dl_link_cvs;
global $src_link_cvs;
global $version;
global $dl_link;
global $src_link;
global $comment;
global $versions_live_index;
include('plugins/details/'.$plug->pluginFile);
$file = substr($dl_link, 8);
if (isset($dl_link) && !file_exists("../" . $dl_link)) {
unset($dl_link);
}
if (isset($src_link) && !file_exists("../" . $src_link)) {
unset($src_link);
}
if (isset($dl_link_cvs) && !file_exists("../" . $dl_link_cvs)) {
unset($dl_link_cvs);
}
if (isset($src_link_cvs) && !file_exists("../" . $src_link_cvs)) {
unset($src_link_cvs);
}
$description_short = substr($description,0,strpos($description,"
"));
$p = array();
$p['id'] = substr($plug->pluginFile, 0, -4);
setInArray($p, 'name', $name);
setInArray($p, 'category_id', $category);
$cat = getPluginCatByValue($category);
$p['category']=$cat[0];
$p['featured']=@$featured;
setInArray($p, 'author', $author);
setInArray($p, 'file_path', $plug->pluginFile);
if(isset($bigImage) && $bigImage != "") {
$p['has_image']=1;
$p['image']=@$bigImage;
$p['image_link']=@$bigImage_link;
} else {
if(isset($image) && $image != "") {
$p['has_image']=1;
$p['image']=@$image;
$p['image_link']=@$image_link;
}
}
setInArray($p, 'description', $description);
setInArray($p, 'description_short', $description_short);
if( false && isset($rss_array[$file]) ) {
$p['fromfeed_dl_link']=@$rss_array[$file]['link'];
$p['fromfeed_title']=@$rss_array[$file]['title'];
$p["seeders"] = @$rss_array[$file]['seeders'];
$p["leechers"] = @$rss_array[$file]['leechers'];
$p["completed"] = @$rss_array[$file]['completed'];
}
setInArray($p, 'comment', @$comment);
setInArray($p, 'version', @$version);
setInArray($p, 'dl_link', @$dl_link);
setInArray($p, 'src_link', @$src_link);
setInArray($p, 'version_cvs', @$version_cvs);
setInArray($p, 'dl_link_cvs', @$dl_link_cvs);
setInArray($p, 'src_link_cvs', @$src_link_cvs);
if( $detailed ) {
if (!isset($versions)) {
$versions = array(0 => new PluginVersionInfo("",
isset($version) ? $version : "",
isset($dl_link) ? $dl_link : "",
isset($src_link) ? $src_link : ""
)
);
} else {
if (!isset($versions[0]))
$versions[0] = new PluginVersionInfo("", "", "", "");
}
if (!isset($versions_live_index)) {
$versions_live_index = 0;
}
if (!isset($cvsVersionInfo)) {
$cvsVersionInfo = new PluginVersionInfo(
isset($min_az_version_cvs) ? $min_az_version_cvs : "",
isset($version_cvs) ? $version_cvs : "",
isset($dl_link_cvs) ? $dl_link_cvs : "",
isset($src_link_cvs) ? $src_link_cvs : ""
);
} else {
$cvsVersionInfo = new PluginVersionInfo("", "", "", "");
}
$latestVersions = array($versions[$versions_live_index], $cvsVersionInfo);
$p['current_version'] = populatePluginDetails($latestVersions[0]);
setInArray($p, 'current_version_cvs', @populatePluginDetails($latestVersions[1]));
$size = count($versions);
setInArray($p, 'size', @$size);
for ($i = 0; $i < $size; $i++) {
$versionInfo = $versions[$i];
if ($versionInfo->minAZVersion == "")
continue;
$p['history'][$i] = populatePluginDetails($versionInfo,false);
}
}
clearPluginVars();
return $p;
}
function populatePluginDetails($currentPlugin,$includeComment=true) {
if (!$currentPlugin->hasData()) {
return;
}
$ver = ( strpos($currentPlugin->version, "_") !== false ) ? substr($currentPlugin->version, 0, strpos($currentPlugin->version, "_")) : $currentPlugin->version;
$a = array();
$a["min_az_version"] = $currentPlugin->minAZVersion;
$a["version"] = $ver;
if (isset($currentPlugin->dl_link) && file_exists("../" . $currentPlugin->dl_link)) {
$a["dl_link"] = $currentPlugin->dl_link;
}
if (isset($currentPlugin->src_link) && file_exists("../" . $currentPlugin->src_link)) {
$a["src_link"] = $currentPlugin->src_link;
}
$a["comments"] = $includeComment ? $currentPlugin->comments : "";
return $a;
}
if(@$_GET['plugin']) {
$p = $_GET['plugin'];
foreach($list_array as $plug) {
if($plug->pluginID == $p)
$resp_plugs[] = getPluginDetails($plug,true);
}
if( isset($resp_plugs[0]) ) {
$response['plugin'] = $resp_plugs[0];
} else {
$response['error'] = "no natching plugin found for id $p";
}
} else {
for ($i = 0; $i < $size; $i++) {
$cat = $cats[$i];
$plugsbycat = createPluginArrayByCat($list_array, $i);
// echo "*******************************"."
";
// echo "Category=".$cat[0]."
";
$resp_cats[] = $cat;
foreach($plugsbycat as $plug) {
$resp_plugs[] = getPluginDetails($plug);
}
}
$response['categories'] = $resp_cats;
$response['plugins'] = $resp_plugs;
}
echo json_encode($response);
?>