2011-12-29 19:45:18 +01:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
Plugin Name: WP FDroid
|
2014-04-17 12:40:13 +02:00
|
|
|
Plugin URI: https://f-droid.org/
|
2011-12-29 19:45:18 +01:00
|
|
|
Description: An FDroid repository browser
|
|
|
|
Author: Ciaran Gultnieks
|
2014-04-17 12:40:13 +02:00
|
|
|
Version: 0.02
|
2011-12-29 19:45:18 +01:00
|
|
|
Author URI: http://ciarang.com
|
|
|
|
|
|
|
|
Revision history
|
2014-04-17 12:40:13 +02:00
|
|
|
0.02 - 2014-04-17: It's changed somewhat since then
|
2011-12-29 19:45:18 +01:00
|
|
|
0.01 - 2010-12-04: Initial development version
|
|
|
|
|
2014-01-29 14:44:48 +01:00
|
|
|
*/
|
2011-12-29 19:45:18 +01:00
|
|
|
|
2012-01-12 21:27:32 +01:00
|
|
|
include('android-permissions.php');
|
|
|
|
|
2014-04-17 12:40:13 +02:00
|
|
|
|
|
|
|
// Widget for displaying latest apps.
|
|
|
|
class FDroidLatestWidget extends WP_Widget {
|
|
|
|
|
|
|
|
function FDroidLatestWidget() {
|
|
|
|
parent::__construct(false, 'F-Droid Latest Apps');
|
|
|
|
}
|
|
|
|
|
|
|
|
function widget( $args, $instance ) {
|
|
|
|
extract($args);
|
|
|
|
$title = apply_filters('widget_title', $instance['title']);
|
|
|
|
echo $before_widget;
|
|
|
|
echo $before_title . $title . $after_title;
|
|
|
|
|
|
|
|
$handle = fopen(getenv('DOCUMENT_ROOT').'/repo/latestapps.dat', 'r');
|
|
|
|
if ($handle) {
|
|
|
|
while (($buffer = fgets($handle, 4096)) !== false) {
|
|
|
|
$app = explode("\t", $buffer);
|
2014-04-27 10:30:26 +02:00
|
|
|
echo '<div style="width:100%">';
|
2014-04-17 12:40:13 +02:00
|
|
|
if(isset($app[2]) && trim($app[2])) {
|
|
|
|
echo '<img src="' . site_url() . '/repo/icons/'.$app[2].'" style="width:32px;border:none;float:right;" />';
|
|
|
|
}
|
2014-04-27 10:30:26 +02:00
|
|
|
echo '<p style="margin:0px;"><a href="/repository/browse/?fdid='.$app[0].'">';
|
|
|
|
echo $app[1].'</a><br/>';
|
2014-04-17 12:40:13 +02:00
|
|
|
if(isset($app[3]) && trim($app[3])) {
|
2014-04-27 10:30:26 +02:00
|
|
|
echo '<span style="color:#BBBBBB;">'.$app[3].'</span></p>';
|
2014-04-17 12:40:13 +02:00
|
|
|
}
|
2014-04-27 10:30:26 +02:00
|
|
|
echo '</div>';
|
2014-04-17 12:40:13 +02:00
|
|
|
}
|
|
|
|
fclose($handle);
|
|
|
|
}
|
|
|
|
echo $after_widget;
|
|
|
|
}
|
|
|
|
|
|
|
|
function update($new_instance, $old_instance) {
|
|
|
|
$instance = array();
|
|
|
|
$instance['title'] = (!empty($new_instance['title'])) ? strip_tags($new_instance['title']) : '';
|
|
|
|
return $instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
function form($instance) {
|
|
|
|
if (isset($instance['title'])) {
|
|
|
|
$title = $instance['title'];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$title = __('New title', 'text_domain');
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<p>
|
|
|
|
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
|
|
|
|
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>">
|
|
|
|
</p>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-29 19:45:18 +01:00
|
|
|
class FDroid
|
|
|
|
{
|
|
|
|
|
|
|
|
// Our text domain, for internationalisation
|
|
|
|
private $textdom='wp-fdroid';
|
|
|
|
|
|
|
|
private $site_path;
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
function FDroid() {
|
|
|
|
add_shortcode('fdroidrepo',array($this, 'do_shortcode'));
|
|
|
|
add_filter('query_vars',array($this, 'queryvars'));
|
|
|
|
$this->inited=false;
|
2013-10-22 15:53:07 +02:00
|
|
|
$this->site_path=getenv('DOCUMENT_ROOT');
|
2014-04-17 12:40:13 +02:00
|
|
|
add_action('widgets_init', function() {
|
|
|
|
register_widget('FDroidLatestWidget');
|
|
|
|
});
|
2011-12-29 19:45:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Register additional query variables. (Handler for the 'query_vars' filter)
|
|
|
|
function queryvars($qvars) {
|
|
|
|
$qvars[]='fdfilter';
|
2012-02-12 16:44:50 +01:00
|
|
|
$qvars[]='fdcategory';
|
2011-12-29 19:45:18 +01:00
|
|
|
$qvars[]='fdid';
|
|
|
|
$qvars[]='fdpage';
|
|
|
|
$qvars[]='fdstyle';
|
|
|
|
return $qvars;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Lazy initialise. All non-trivial members should call this before doing anything else.
|
|
|
|
function lazyinit() {
|
|
|
|
if(!$this->inited) {
|
|
|
|
load_plugin_textdomain($this->textdom, PLUGINDIR.'/'.dirname(plugin_basename(__FILE__)), dirname(plugin_basename(__FILE__)));
|
|
|
|
|
|
|
|
$this->inited=true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Gets a required query parameter by name.
|
|
|
|
function getrequiredparam($name) {
|
|
|
|
global $wp_query;
|
|
|
|
if(!isset($wp_query->query_vars[$name]))
|
|
|
|
wp_die("Missing parameter ".$name,"Error");
|
|
|
|
return $wp_query->query_vars[$name];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handler for the 'fdroidrepo' shortcode.
|
|
|
|
// $attribs - shortcode attributes
|
|
|
|
// $content - optional content enclosed between the starting and
|
|
|
|
// ending shortcode
|
|
|
|
// Returns the generated content.
|
|
|
|
function do_shortcode($attribs,$content=null) {
|
|
|
|
global $wp_query,$wp_rewrite;
|
|
|
|
$this->lazyinit();
|
|
|
|
|
|
|
|
// Init local query vars
|
|
|
|
foreach($this->queryvars(array()) as $qv) {
|
|
|
|
if(array_key_exists($qv,$wp_query->query_vars)) {
|
|
|
|
$query_vars[$qv] = $wp_query->query_vars[$qv];
|
|
|
|
} else {
|
|
|
|
$query_vars[$qv] = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-29 14:44:48 +01:00
|
|
|
// Sanity check and standardise all query variables...
|
2011-12-29 19:45:18 +01:00
|
|
|
if(!isset($query_vars['fdpage']) || !is_numeric($query_vars['fdpage']) || $query_vars['fdpage'] <= 0) {
|
|
|
|
$query_vars['fdpage'] = 1;
|
2014-01-29 14:44:48 +01:00
|
|
|
} else {
|
|
|
|
$query_vars['fdpage'] = strval(intval($query_vars['fdpage']));
|
2011-12-29 19:45:18 +01:00
|
|
|
}
|
2014-01-29 14:44:48 +01:00
|
|
|
if(isset($query_vars['fdstyle']) && ($query_vars['fdstyle'] != 'list' && $query_vars['fdstyle'] != 'grid')) {
|
|
|
|
$query_vars['fdstyle'] = 'list';
|
2011-12-29 19:45:18 +01:00
|
|
|
}
|
2014-01-29 14:44:48 +01:00
|
|
|
if(isset($query_vars['fdcategory'])) {
|
|
|
|
if($query_vars['fdcategory'] == 'All categories') {
|
|
|
|
unset($query_vars['fdcategory']);
|
|
|
|
} else {
|
|
|
|
$query_vars['fdcategory'] = sanitize_text_field($query_vars['fdcategory']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(isset($query_vars['fdfilter'])) {
|
|
|
|
$query_vars['fdfilter'] = sanitize_text_field($query_vars['fdfilter']);
|
|
|
|
} else {
|
|
|
|
if(isset($attribs['search'])) {
|
|
|
|
$query_vars['fdfilter'] = '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(isset($query_vars['fdid'])) {
|
|
|
|
$query_vars['fdid'] = sanitize_text_field($query_vars['fdid']);
|
2012-02-12 16:44:50 +01:00
|
|
|
}
|
2013-12-30 17:04:16 +01:00
|
|
|
|
2014-01-29 14:44:48 +01:00
|
|
|
$out = '';
|
|
|
|
|
2011-12-29 19:45:18 +01:00
|
|
|
if($query_vars['fdid']!==null) {
|
|
|
|
$out.=$this->get_app($query_vars);
|
|
|
|
} else {
|
2014-01-29 14:44:48 +01:00
|
|
|
$out.='<form name="searchform" action="" method="get">';
|
2015-01-26 19:12:30 +01:00
|
|
|
$out.='<p><input name="fdfilter" type="text" value="'.esc_attr($query_vars['fdfilter']).'" size="30"> ';
|
2014-01-29 14:44:48 +01:00
|
|
|
$out.='<input type="hidden" name="fdpage" value="1">';
|
|
|
|
$out.='<input type="submit" value="Search"></p>';
|
|
|
|
$out.=$this->makeformdata($query_vars);
|
|
|
|
$out.='</form>'."\n";
|
2011-12-29 19:45:18 +01:00
|
|
|
|
|
|
|
$out.=$this->get_apps($query_vars);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $out;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-09 16:16:47 +01:00
|
|
|
// Get a URL for a full description of a license, as given by one of our
|
|
|
|
// pre-defined license abbreviations. This is a temporary function, as this
|
|
|
|
// needs to be data-driven so the same information can be used by the client,
|
|
|
|
// the web site and the documentation.
|
|
|
|
function getlicenseurl($license) {
|
2014-01-29 14:44:48 +01:00
|
|
|
switch($license) {
|
|
|
|
case 'MIT':
|
2014-02-20 10:28:47 +01:00
|
|
|
return 'https://www.gnu.org/licenses/license-list.html#X11License';
|
2014-01-29 14:44:48 +01:00
|
|
|
case 'NewBSD':
|
2014-02-20 10:28:47 +01:00
|
|
|
return 'https://www.gnu.org/licenses/license-list.html#ModifiedBSD';
|
2016-01-24 13:27:15 +01:00
|
|
|
case 'FreeBSD':
|
|
|
|
return 'https://www.gnu.org/licenses/license-list.html#FreeBSD';
|
2014-01-29 14:44:48 +01:00
|
|
|
case 'BSD':
|
2014-02-20 10:28:47 +01:00
|
|
|
return 'https://www.gnu.org/licenses/license-list.html#OriginalBSD';
|
2014-01-29 14:44:48 +01:00
|
|
|
case 'GPLv3':
|
|
|
|
case 'GPLv3+':
|
2014-02-20 10:28:47 +01:00
|
|
|
return 'https://www.gnu.org/licenses/license-list.html#GNUGPLv3';
|
2014-01-29 14:44:48 +01:00
|
|
|
case 'GPLv2':
|
|
|
|
case 'GPLv2+':
|
2014-02-20 10:28:47 +01:00
|
|
|
return 'https://www.gnu.org/licenses/license-list.html#GPLv2';
|
|
|
|
case 'AGPLv3':
|
|
|
|
case 'AGPLv3+':
|
|
|
|
return 'https://www.gnu.org/licenses/license-list.html#AGPLv3.0';
|
2014-01-29 14:44:48 +01:00
|
|
|
case 'LGPL':
|
2014-02-20 10:28:47 +01:00
|
|
|
return 'https://www.gnu.org/licenses/license-list.html#LGPL';
|
|
|
|
case 'LGPLv3':
|
|
|
|
return 'https://www.gnu.org/licenses/license-list.html#LGPLv3';
|
|
|
|
case 'LGPLv2.1':
|
|
|
|
return 'https://www.gnu.org/licenses/license-list.html#LGPLv2.1';
|
2014-01-29 14:44:48 +01:00
|
|
|
case 'Apache2':
|
2014-02-20 10:28:47 +01:00
|
|
|
return 'https://www.gnu.org/licenses/license-list.html#apache2';
|
|
|
|
case 'WTFPL':
|
|
|
|
return 'https://www.gnu.org/licenses/license-list.html#WTFPL';
|
2016-01-24 13:27:15 +01:00
|
|
|
case 'ISC':
|
|
|
|
return 'https://www.gnu.org/licenses/license-list.html#ISC';
|
|
|
|
case 'Expat':
|
|
|
|
return 'https://www.gnu.org/licenses/license-list.html#Expat';
|
|
|
|
case 'Artistic2':
|
|
|
|
return 'https://www.gnu.org/licenses/license-list.html#ArtisticLicense2';
|
|
|
|
case 'CC0':
|
|
|
|
return 'https://www.gnu.org/licenses/license-list.html#CC0';
|
|
|
|
case 'PublicDomain':
|
|
|
|
return 'https://www.gnu.org/licenses/license-list.html#PublicDomain';
|
|
|
|
case 'Unlicense':
|
|
|
|
return 'https://www.gnu.org/licenses/license-list.html#Unlicense';
|
|
|
|
case 'MPL':
|
|
|
|
return 'https://www.gnu.org/licenses/license-list.html#MPL';
|
|
|
|
case 'MPL2':
|
|
|
|
return 'https://www.gnu.org/licenses/license-list.html#MPL-2.0';
|
|
|
|
case 'NCSA':
|
|
|
|
return 'https://www.gnu.org/licenses/license-list.html#NCSA';
|
|
|
|
case 'Zlib':
|
|
|
|
return 'https://www.gnu.org/licenses/license-list.html#ZLib';
|
|
|
|
case 'EPL':
|
|
|
|
return 'https://www.gnu.org/licenses/license-list.html#EPL';
|
|
|
|
case 'EUPL':
|
|
|
|
return 'https://www.gnu.org/licenses/license-list.html#EUPL';
|
2014-01-29 14:44:48 +01:00
|
|
|
default:
|
2012-03-09 16:16:47 +01:00
|
|
|
return null;
|
2014-01-29 14:44:48 +01:00
|
|
|
}
|
2012-03-09 16:16:47 +01:00
|
|
|
}
|
2014-03-04 09:22:16 +01:00
|
|
|
function androidversion($sdkLevel) {
|
|
|
|
switch ($sdkLevel) {
|
2016-07-25 14:56:54 +02:00
|
|
|
case 24: return "7.0";
|
2015-08-20 18:56:14 +02:00
|
|
|
case 23: return "6.0";
|
2015-04-06 22:18:54 +02:00
|
|
|
case 22: return "5.1";
|
2015-01-04 04:26:24 +01:00
|
|
|
case 21: return "5.0";
|
|
|
|
case 20: return "4.4W";
|
2014-03-04 09:22:16 +01:00
|
|
|
case 19: return "4.4";
|
|
|
|
case 18: return "4.3";
|
|
|
|
case 17: return "4.2";
|
|
|
|
case 16: return "4.1";
|
|
|
|
case 15: return "4.0.3";
|
|
|
|
case 14: return "4.0";
|
|
|
|
case 13: return "3.2";
|
|
|
|
case 12: return "3.1";
|
|
|
|
case 11: return "3.0";
|
|
|
|
case 10: return "2.3.3";
|
|
|
|
case 9: return "2.3";
|
|
|
|
case 8: return "2.2";
|
|
|
|
case 7: return "2.1";
|
|
|
|
case 6: return "2.0.1";
|
|
|
|
case 5: return "2.0";
|
|
|
|
case 4: return "1.6";
|
|
|
|
case 3: return "1.5";
|
|
|
|
case 2: return "1.1";
|
|
|
|
case 1: return "1.0";
|
|
|
|
default: return "?";
|
|
|
|
}
|
|
|
|
}
|
2012-03-09 16:16:47 +01:00
|
|
|
|
2011-12-29 19:45:18 +01:00
|
|
|
function get_app($query_vars) {
|
2012-01-17 21:48:48 +01:00
|
|
|
global $permissions_data;
|
2012-01-19 17:53:39 +01:00
|
|
|
$permissions_object = new AndroidPermissions($this->site_path.'/wp-content/plugins/wp-fdroid/AndroidManifest.xml',
|
|
|
|
$this->site_path.'/wp-content/plugins/wp-fdroid/strings.xml',
|
|
|
|
sys_get_temp_dir().'/android-permissions.cache');
|
2012-01-12 21:46:49 +01:00
|
|
|
$permissions_data = $permissions_object->get_permissions_array();
|
2011-12-29 19:45:18 +01:00
|
|
|
|
2012-01-17 19:41:22 +01:00
|
|
|
// Get app data
|
2012-01-12 21:27:32 +01:00
|
|
|
$xml = simplexml_load_file($this->site_path.'/repo/index.xml');
|
2011-12-29 19:45:18 +01:00
|
|
|
foreach($xml->children() as $app) {
|
|
|
|
|
|
|
|
$attrs=$app->attributes();
|
|
|
|
if($attrs['id']==$query_vars['fdid']) {
|
|
|
|
$apks=array();;
|
|
|
|
foreach($app->children() as $el) {
|
|
|
|
switch($el->getName()) {
|
2014-01-29 14:44:48 +01:00
|
|
|
case "name":
|
|
|
|
$name=$el;
|
|
|
|
break;
|
|
|
|
case "icon":
|
|
|
|
$icon=$el;
|
|
|
|
break;
|
|
|
|
case "summary":
|
|
|
|
$summary=$el;
|
|
|
|
break;
|
|
|
|
case "desc":
|
|
|
|
$desc=$el;
|
|
|
|
break;
|
|
|
|
case "license":
|
|
|
|
$license=$el;
|
|
|
|
break;
|
2016-01-03 20:49:36 +01:00
|
|
|
case "author":
|
|
|
|
$author=$el;
|
|
|
|
break;
|
|
|
|
case "email":
|
|
|
|
$email=$el;
|
|
|
|
break;
|
2014-01-29 14:44:48 +01:00
|
|
|
case "source":
|
|
|
|
$source=$el;
|
|
|
|
break;
|
|
|
|
case "tracker":
|
|
|
|
$issues=$el;
|
|
|
|
break;
|
2015-01-11 02:26:41 +01:00
|
|
|
case "changelog":
|
|
|
|
$changelog=$el;
|
|
|
|
break;
|
2014-01-29 14:44:48 +01:00
|
|
|
case "donate":
|
|
|
|
$donate=$el;
|
|
|
|
break;
|
2014-04-12 13:27:34 +02:00
|
|
|
case "flattr":
|
|
|
|
$flattr=$el;
|
|
|
|
break;
|
2014-01-29 14:44:48 +01:00
|
|
|
case "web":
|
|
|
|
$web=$el;
|
|
|
|
break;
|
|
|
|
case "antifeatures":
|
|
|
|
$antifeatures=$el;
|
|
|
|
break;
|
|
|
|
case "requirements":
|
|
|
|
$requirements=$el;
|
|
|
|
break;
|
|
|
|
case "package":
|
|
|
|
$thisapk=array();
|
|
|
|
foreach($el->children() as $pel) {
|
|
|
|
switch($pel->getName()) {
|
|
|
|
case "version":
|
|
|
|
$thisapk['version']=$pel;
|
|
|
|
break;
|
|
|
|
case "vercode":
|
|
|
|
$thisapk['vercode']=$pel;
|
|
|
|
break;
|
2014-01-30 09:31:44 +01:00
|
|
|
case "added":
|
2014-02-20 09:25:39 +01:00
|
|
|
$thisapk['added']=$pel;
|
2014-01-30 09:31:44 +01:00
|
|
|
break;
|
2014-01-29 14:44:48 +01:00
|
|
|
case "apkname":
|
|
|
|
$thisapk['apkname']=$pel;
|
|
|
|
break;
|
|
|
|
case "srcname":
|
|
|
|
$thisapk['srcname']=$pel;
|
|
|
|
break;
|
|
|
|
case "hash":
|
|
|
|
$thisapk['hash']=$pel;
|
|
|
|
break;
|
|
|
|
case "size":
|
|
|
|
$thisapk['size']=$pel;
|
|
|
|
break;
|
|
|
|
case "sdkver":
|
|
|
|
$thisapk['sdkver']=$pel;
|
|
|
|
break;
|
2014-03-04 09:07:12 +01:00
|
|
|
case "maxsdkver":
|
|
|
|
$thisapk['maxsdkver']=$pel;
|
|
|
|
break;
|
|
|
|
case "nativecode":
|
|
|
|
$thisapk['nativecode']=$pel;
|
|
|
|
break;
|
2014-01-29 14:44:48 +01:00
|
|
|
case "permissions":
|
|
|
|
$thisapk['permissions']=$pel;
|
|
|
|
break;
|
2011-12-29 19:45:18 +01:00
|
|
|
}
|
2014-01-29 14:44:48 +01:00
|
|
|
}
|
|
|
|
$apks[]=$thisapk;
|
2011-12-29 19:45:18 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2012-01-21 13:22:37 +01:00
|
|
|
|
2012-01-17 19:41:22 +01:00
|
|
|
// Generate app diff data
|
|
|
|
foreach(array_reverse($apks, true) as $key=>$apk) {
|
|
|
|
if(isset($previous)) {
|
2012-01-21 13:22:37 +01:00
|
|
|
// Apk size
|
|
|
|
$apks[$key]['diff']['size'] = $apk['size']-$previous['size'];
|
2012-01-17 19:41:22 +01:00
|
|
|
}
|
2012-01-21 13:22:37 +01:00
|
|
|
|
|
|
|
// Permissions
|
|
|
|
$permissions = explode(',',$apk['permissions']);
|
|
|
|
$permissionsPrevious = isset($previous['permissions'])?explode(',',$previous['permissions']):array();
|
|
|
|
$apks[$key]['diff']['permissions']['added'] = array_diff($permissions, $permissionsPrevious);
|
|
|
|
$apks[$key]['diff']['permissions']['removed'] = array_diff($permissionsPrevious, $permissions);
|
|
|
|
|
2012-01-17 19:41:22 +01:00
|
|
|
$previous = $apk;
|
|
|
|
}
|
2011-12-29 19:45:18 +01:00
|
|
|
|
2012-01-17 19:41:22 +01:00
|
|
|
// Output app information
|
2011-12-29 19:45:18 +01:00
|
|
|
$out='<div id="appheader">';
|
2012-09-08 10:41:05 +02:00
|
|
|
$out.='<div style="float:left;padding-right:10px;"><img src="' . site_url() . '/repo/icons/'.$icon.'" width=48></div>';
|
2011-12-29 19:45:18 +01:00
|
|
|
$out.='<p><span style="font-size:20px">'.$name."</span>";
|
|
|
|
$out.="<br>".$summary."</p>";
|
|
|
|
$out.="</div>";
|
|
|
|
|
2012-09-17 23:15:48 +02:00
|
|
|
$out.=str_replace('href="fdroid.app:', 'href="/repository/browse/?fdid=', $desc);
|
2011-12-29 19:45:18 +01:00
|
|
|
|
2012-01-23 21:07:33 +01:00
|
|
|
if(isset($antifeatures)) {
|
|
|
|
$antifeaturesArray = explode(',',$antifeatures);
|
|
|
|
foreach($antifeaturesArray as $antifeature) {
|
2013-11-27 11:47:12 +01:00
|
|
|
$antifeatureDescription = $this->get_antifeature_description($antifeature);
|
|
|
|
$out.='<p style="border:3px solid #CC0000;background-color:#FFDDDD;padding:5px;"><strong>'.$antifeatureDescription['name'].'</strong><br />';
|
|
|
|
$out.=$antifeatureDescription['description'].' <a href="/wiki/page/Antifeature:'.$antifeature.'">more...</a></p>';
|
2012-01-23 21:07:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-23 21:21:40 +01:00
|
|
|
$out.="<p>";
|
2012-03-09 16:16:47 +01:00
|
|
|
$licenseurl=$this->getlicenseurl($license);
|
|
|
|
$out.="<b>License:</b> ";
|
|
|
|
if($licenseurl)
|
2014-01-29 14:44:48 +01:00
|
|
|
$out.='<a href="'.$licenseurl.'" target="_blank">';
|
2012-03-09 16:16:47 +01:00
|
|
|
$out.=$license;
|
|
|
|
if($licenseurl)
|
2014-01-29 14:44:48 +01:00
|
|
|
$out.='</a>';
|
2012-03-09 16:16:47 +01:00
|
|
|
|
2012-01-23 21:21:40 +01:00
|
|
|
if(isset($requirements)) {
|
|
|
|
$out.='<br /><b>Additional requirements:</b> '.$requirements;
|
|
|
|
}
|
|
|
|
$out.="</p>";
|
2011-12-29 19:45:18 +01:00
|
|
|
|
|
|
|
$out.="<p>";
|
|
|
|
if(strlen($web)>0)
|
|
|
|
$out.='<b>Website:</b> <a href="'.$web.'">'.$web.'</a><br />';
|
2016-01-03 20:49:36 +01:00
|
|
|
if(isset($author) && strlen($author)>0)
|
|
|
|
if(isset($email) && strlen($email)>0)
|
|
|
|
$out.='<b>Author(s):</b> <a href="mailto:'.$email.'">'.$author.'</a><br />';
|
|
|
|
else
|
|
|
|
$out.='<b>Author(s):</b> '.$author.'<br />';
|
2011-12-29 19:45:18 +01:00
|
|
|
if(strlen($issues)>0)
|
|
|
|
$out.='<b>Issue Tracker:</b> <a href="'.$issues.'">'.$issues.'</a><br />';
|
|
|
|
if(strlen($source)>0)
|
|
|
|
$out.='<b>Source Code:</b> <a href="'.$source.'">'.$source.'</a><br />';
|
2015-01-11 02:26:41 +01:00
|
|
|
if(strlen($changelog)>0)
|
|
|
|
$out.='<b>Changelog:</b> <a href="'.$changelog.'">'.$changelog.'</a><br />';
|
2014-04-17 13:12:50 +02:00
|
|
|
if(isset($donate) && strlen($donate)>0)
|
2011-12-29 19:45:18 +01:00
|
|
|
$out.='<b>Donate:</b> <a href="'.$donate.'">'.$donate.'</a><br />';
|
2014-04-17 13:12:50 +02:00
|
|
|
if(isset($flattr) && strlen($flattr)>0)
|
2014-04-12 13:33:07 +02:00
|
|
|
$out.='<b>Flattr:</b> <a href="https://flattr.com/thing/'.$flattr.'"><img src="/wp-content/uploads/flattr-badge-large.png" style="border:0" /></a><br />';
|
2011-12-29 19:45:18 +01:00
|
|
|
$out.="</p>";
|
|
|
|
|
2013-10-22 15:53:07 +02:00
|
|
|
$out.="<p>For full details and additional technical information, see ";
|
|
|
|
$out.="<a href=\"/wiki/page/".$query_vars['fdid']."\">this application's page</a> on the F-Droid wiki.</p>";
|
2013-07-16 17:28:26 +02:00
|
|
|
|
2012-01-12 21:27:32 +01:00
|
|
|
$out.='<script type="text/javascript">';
|
|
|
|
$out.='function showHidePermissions(id) {';
|
|
|
|
$out.=' if(document.getElementById(id).style.display==\'none\')';
|
|
|
|
$out.=' document.getElementById(id).style.display=\'block\';';
|
|
|
|
$out.=' else';
|
|
|
|
$out.=' document.getElementById(id).style.display=\'none\';';
|
|
|
|
$out.=' return false;';
|
|
|
|
$out.='}';
|
|
|
|
$out.='</script>';
|
|
|
|
|
2013-04-16 19:05:17 +02:00
|
|
|
$out.="<h3>Packages</h3>";
|
|
|
|
|
2013-10-24 19:02:51 +02:00
|
|
|
$out.='<div style="float:right; margin-left:10px;"><a id="downloadbutton" href="https://f-droid.org/FDroid.apk"><span>Download F-Droid</span></a></div>';
|
|
|
|
$out.="<p>Although APK downloads are available below to give ";
|
2012-08-31 18:27:26 +02:00
|
|
|
$out.="you the choice, you should be aware that by installing that way you ";
|
2012-11-02 11:32:05 +01:00
|
|
|
$out.="will not receive update notifications, and it's a less secure way ";
|
2013-10-24 18:53:10 +02:00
|
|
|
$out.="to download. ";
|
2012-08-31 18:27:26 +02:00
|
|
|
$out.="We recommend that you install the F-Droid client and use that.</p>";
|
|
|
|
|
2012-01-12 21:27:32 +01:00
|
|
|
$i=0;
|
2011-12-29 19:45:18 +01:00
|
|
|
foreach($apks as $apk) {
|
2012-01-21 13:22:37 +01:00
|
|
|
$first = $i+1==count($apks);
|
2014-02-15 00:10:40 +01:00
|
|
|
$out.="<p><b>Version ".$apk['version']."</b>";
|
|
|
|
$out.=" - Added on ".$apk['added']."<br />";
|
2012-08-23 15:25:39 +02:00
|
|
|
|
2014-03-04 09:22:16 +01:00
|
|
|
$hasminsdk = isset($apk['sdkver']);
|
|
|
|
$hasmaxsdk = isset($apk['maxsdkver']);
|
|
|
|
if($hasminsdk && $hasmaxsdk) {
|
2014-03-05 00:51:26 +01:00
|
|
|
$out.="<p>This version requires Android ".$this->androidversion($apk['sdkver'])." up to ".$this->androidversion($apk['maxsdkver'])."</p>";
|
2014-03-04 09:22:16 +01:00
|
|
|
} elseif($hasminsdk) {
|
2014-03-05 00:51:26 +01:00
|
|
|
$out.="<p>This version requires Android ".$this->androidversion($apk['sdkver'])." or newer.</p>";
|
2014-03-04 09:22:16 +01:00
|
|
|
} elseif($hasmaxsdk) {
|
2014-03-05 00:51:26 +01:00
|
|
|
$out.="<p>This version requires Android ".$this->androidversion($apk['maxsdkver'])." or old.</p>";
|
2014-03-04 09:22:16 +01:00
|
|
|
}
|
|
|
|
|
2014-03-04 09:07:12 +01:00
|
|
|
$hasabis = isset($apk['nativecode']);
|
|
|
|
if($hasabis) {
|
|
|
|
$abis = str_replace(',', ' ', $apk['nativecode']);
|
2015-08-28 16:10:24 +02:00
|
|
|
$out.="<p>This version uses native code and is built for: ".$abis."</p>";
|
2014-03-04 09:07:12 +01:00
|
|
|
}
|
|
|
|
|
2013-10-22 15:53:07 +02:00
|
|
|
// Is this source or binary?
|
|
|
|
$srcbuild = isset($apk['srcname']) && file_exists($this->site_path.'/repo/'.$apk['srcname']);
|
2012-08-23 15:25:39 +02:00
|
|
|
|
2013-10-22 15:53:07 +02:00
|
|
|
$out.="<p>This version is built and signed by ";
|
|
|
|
if($srcbuild) {
|
2014-01-29 14:44:48 +01:00
|
|
|
$out.="F-Droid, and guaranteed to correspond to the source tarball below.</p>";
|
2013-10-22 15:53:07 +02:00
|
|
|
} else {
|
2014-01-29 14:44:48 +01:00
|
|
|
$out.="the original developer.</p>";
|
2013-10-22 15:53:07 +02:00
|
|
|
}
|
2012-02-21 01:02:30 +01:00
|
|
|
$out.='<a href="https://f-droid.org/repo/'.$apk['apkname'].'">download apk</a> ';
|
2012-01-14 15:11:59 +01:00
|
|
|
$out.=$this->human_readable_size($apk['size']);
|
2012-01-17 19:41:22 +01:00
|
|
|
$diffSize = $apk['diff']['size'];
|
|
|
|
if(abs($diffSize) > 500) {
|
|
|
|
$out.=' <span style="color:#AAAAAA;">(';
|
|
|
|
$out.=$diffSize>0?'+':'';
|
|
|
|
$out.=$this->human_readable_size($diffSize, 1).')</span>';
|
|
|
|
}
|
2014-06-30 13:04:22 +02:00
|
|
|
if(file_exists($this->site_path.'/repo/'.$apk['apkname'].'.asc')) {
|
|
|
|
$out.=' <a href="https://f-droid.org/repo/'.$apk['apkname'].'.asc">GPG Signature</a> ';
|
2014-04-27 10:30:26 +02:00
|
|
|
}
|
2012-08-23 15:25:39 +02:00
|
|
|
if($srcbuild) {
|
2012-02-21 01:02:30 +01:00
|
|
|
$out.='<br /><a href="https://f-droid.org/repo/'.$apk['srcname'].'">source tarball</a> ';
|
2012-01-14 15:11:59 +01:00
|
|
|
$out.=$this->human_readable_size(filesize($this->site_path.'/repo/'.$apk['srcname']));
|
2016-11-03 10:38:22 +01:00
|
|
|
if(file_exists($this->site_path.'/repo/'.$apk['srcname'].'.asc')) {
|
|
|
|
$out.=' <a href="https://f-droid.org/repo/'.$apk['srcname'].'.asc">GPG Signature</a> ';
|
|
|
|
}
|
2012-01-14 15:11:59 +01:00
|
|
|
}
|
2012-01-12 21:27:32 +01:00
|
|
|
|
2012-01-14 12:39:33 +01:00
|
|
|
if(isset($apk['permissions'])) {
|
2012-01-21 13:22:37 +01:00
|
|
|
// Permissions diff link
|
|
|
|
if($first == false) {
|
|
|
|
$permissionsAddedCount = count($apk['diff']['permissions']['added']);
|
|
|
|
$permissionsRemovedCount = count($apk['diff']['permissions']['removed']);
|
|
|
|
$divIdDiff='permissionsDiff'.$i;
|
|
|
|
if($permissionsAddedCount || $permissionsRemovedCount) {
|
|
|
|
$out.='<br /><a href="javascript:void(0);" onClick="showHidePermissions(\''.$divIdDiff.'\');">permissions diff</a>';
|
|
|
|
$out.=' <span style="color:#AAAAAA;">(';
|
|
|
|
if($permissionsAddedCount)
|
|
|
|
$out.='+'.$permissionsAddedCount;
|
|
|
|
if($permissionsAddedCount && $permissionsRemovedCount)
|
|
|
|
$out.='/';
|
|
|
|
if($permissionsRemovedCount)
|
|
|
|
$out.='-'.$permissionsRemovedCount;
|
|
|
|
$out.=')</span>';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$out.='<br /><span style="color:#999999;">no permission changes</span>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Permissions list link
|
|
|
|
$permissionsListString = $this->get_permission_list_string(explode(',',$apk['permissions']), $permissions_data, $summary);
|
2012-01-14 12:39:33 +01:00
|
|
|
/*if($i==0)
|
|
|
|
$divStyleDisplay='block';
|
|
|
|
else*/
|
2014-01-29 14:44:48 +01:00
|
|
|
$divStyleDisplay='none';
|
2012-01-14 12:39:33 +01:00
|
|
|
$divId='permissions'.$i;
|
2012-01-21 13:22:37 +01:00
|
|
|
$out.='<br /><a href="javascript:void(0);" onClick="showHidePermissions(\''.$divId.'\');">view permissions</a>';
|
|
|
|
$out.=' <span style="color:#AAAAAA;">['.$summary.']</span>';
|
|
|
|
$out.='<br/>';
|
|
|
|
|
|
|
|
// Permissions list
|
2012-01-14 12:39:33 +01:00
|
|
|
$out.='<div style="display:'.$divStyleDisplay.';" id="'.$divId.'">';
|
2012-01-21 13:22:37 +01:00
|
|
|
$out.=$permissionsListString;
|
|
|
|
$out.='</div>';
|
|
|
|
|
|
|
|
// Permissions diff
|
|
|
|
{
|
|
|
|
$out.='<div style="display:'.$divStyleDisplay.';" id="'.$divIdDiff.'">';
|
|
|
|
$permissionsRemoved = $apk['diff']['permissions']['removed'];
|
|
|
|
usort($permissionsRemoved, "permissions_cmp");
|
|
|
|
|
|
|
|
// Added permissions
|
|
|
|
if($permissionsAddedCount) {
|
|
|
|
$out.='<h5>ADDED</h5><br />';
|
|
|
|
$out.=$this->get_permission_list_string($apk['diff']['permissions']['added'], $permissions_data, $summary);
|
2012-01-12 21:27:32 +01:00
|
|
|
}
|
|
|
|
|
2012-01-21 13:22:37 +01:00
|
|
|
// Removed permissions
|
|
|
|
if($permissionsRemovedCount) {
|
|
|
|
$out.='<h5>REMOVED</h5><br />';
|
|
|
|
$out.=$this->get_permission_list_string($apk['diff']['permissions']['removed'], $permissions_data, $summary);
|
|
|
|
}
|
|
|
|
|
|
|
|
$out.='</div>';
|
2012-01-12 21:27:32 +01:00
|
|
|
}
|
2012-01-14 12:39:33 +01:00
|
|
|
}
|
|
|
|
else {
|
2012-01-21 13:22:37 +01:00
|
|
|
$out.='<br /><span style="color:#999999;">no extra permissions needed</span><br />';
|
2012-01-12 21:27:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$out.='</p>';
|
|
|
|
$i++;
|
2011-12-29 19:45:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$out.='<hr><p><a href="'.makelink($query_vars,array('fdid'=>null)).'">Index</a></p>';
|
|
|
|
|
|
|
|
return $out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "<p>Application not found</p>";
|
|
|
|
}
|
|
|
|
|
2012-01-21 13:22:37 +01:00
|
|
|
private function get_permission_list_string($permissions, $permissions_data, &$summary) {
|
|
|
|
$out='';
|
|
|
|
usort($permissions, "permissions_cmp");
|
|
|
|
$permission_group_last = '';
|
|
|
|
foreach($permissions as $permission) {
|
|
|
|
$permission_group = $permissions_data['permission'][$permission]['permissionGroup'];
|
|
|
|
if($permission_group != $permission_group_last) {
|
|
|
|
$permission_group_label = $permissions_data['permission-group'][$permission_group]['label'];
|
|
|
|
if($permission_group_label=='') $permission_group_label = 'Extra/Custom';
|
|
|
|
$out.='<strong>'.strtoupper($permission_group_label).'</strong><br/>';
|
|
|
|
$permission_group_last = $permission_group;
|
|
|
|
}
|
|
|
|
|
|
|
|
$out.=$this->get_permission_protection_level_icon($permissions_data['permission'][$permission]['protectionLevel']).' ';
|
|
|
|
$out.='<strong>'.$permissions_data['permission'][$permission]['label'].'</strong> [<code>'.$permission.'</code>]<br/>';
|
|
|
|
if($permissions_data['permission'][$permission]['description']) $out.=$permissions_data['permission'][$permission]['description'].'<br/>';
|
|
|
|
//$out.=$permissions_data['permission'][$permission]['comment'].'<br/>';
|
|
|
|
$out.='<br/>';
|
|
|
|
|
|
|
|
if(!isset($summaryCount[$permissions_data['permission'][$permission]['protectionLevel']]))
|
|
|
|
$summaryCount[$permissions_data['permission'][$permission]['protectionLevel']] = 0;
|
|
|
|
$summaryCount[$permissions_data['permission'][$permission]['protectionLevel']]++;
|
|
|
|
}
|
|
|
|
|
2013-10-22 15:53:07 +02:00
|
|
|
$summary = '';
|
|
|
|
if(isset($summaryCount)) {
|
|
|
|
foreach($summaryCount as $protectionLevel => $count) {
|
|
|
|
$summary .= $this->get_permission_protection_level_icon($protectionLevel, 'regular').' '.$count;
|
|
|
|
$summary .= ', ';
|
|
|
|
}
|
|
|
|
}
|
2012-01-21 13:22:37 +01:00
|
|
|
$summary = substr($summary,0,-2);
|
|
|
|
|
|
|
|
return $out;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function get_permission_protection_level_icon($protection_level, $size='adjusted') {
|
|
|
|
$iconString = '';
|
2012-01-14 12:39:33 +01:00
|
|
|
if($protection_level=='dangerous') {
|
2012-01-21 13:22:37 +01:00
|
|
|
$iconString .= '<span style="color:#DD9900;';
|
|
|
|
if($size=='adjusted')
|
|
|
|
$iconString .= 'font-size:150%;';
|
2012-01-28 20:39:38 +01:00
|
|
|
$iconString .= '">⚠</span>'; // WARNING SIGN
|
2012-01-12 21:27:32 +01:00
|
|
|
}
|
2012-01-14 12:39:33 +01:00
|
|
|
elseif($protection_level=='normal') {
|
2012-01-21 13:22:37 +01:00
|
|
|
$iconString .= '<span style="color:#6666FF;';
|
|
|
|
if($size=='adjusted')
|
|
|
|
$iconString .= 'font-size:110%;';
|
2012-01-28 20:39:38 +01:00
|
|
|
$iconString .= '">ⓘ</span>'; // CIRCLED LATIN SMALL LETTER I
|
|
|
|
}
|
|
|
|
elseif($protection_level=='signature') {
|
|
|
|
$iconString .= '<span style="color:#33AAAA;';
|
|
|
|
if($size=='adjusted')
|
|
|
|
$iconString .= 'font-size:140%;';
|
|
|
|
$iconString .= '">✽</span>'; // HEAVY TEARDROP-SPOKED ASTERISK
|
|
|
|
}
|
|
|
|
elseif($protection_level=='signatureOrSystem') {
|
|
|
|
$iconString .= '<span style="color:#DD66DD;';
|
|
|
|
if($size=='adjusted')
|
|
|
|
$iconString .= 'font-size:140%;';
|
|
|
|
$iconString .= '">⚛</span>'; // ATOM SYMBOL
|
2012-01-12 21:27:32 +01:00
|
|
|
}
|
2012-01-14 12:39:33 +01:00
|
|
|
else {
|
2012-01-21 13:22:37 +01:00
|
|
|
$iconString .= '<span style="color:#33AA33';
|
|
|
|
if($size=='adjusted')
|
|
|
|
$iconString .= ';font-size:130%;';
|
2012-01-28 20:39:38 +01:00
|
|
|
$iconString .= '">⚙</span>'; // GEAR
|
2012-01-12 21:27:32 +01:00
|
|
|
}
|
2012-01-21 13:22:37 +01:00
|
|
|
|
|
|
|
return $iconString;
|
2012-01-12 21:27:32 +01:00
|
|
|
}
|
2012-01-21 13:22:37 +01:00
|
|
|
|
2012-01-17 19:41:22 +01:00
|
|
|
private function human_readable_size($size, $minDiv=0) {
|
2012-01-14 15:11:59 +01:00
|
|
|
$si_prefix = array('bytes','kB','MB');
|
2013-01-29 09:39:56 +01:00
|
|
|
$div = 1024;
|
2012-01-21 13:22:37 +01:00
|
|
|
|
2012-01-17 19:41:22 +01:00
|
|
|
for($i=0;(abs($size) > $div && $i < count($si_prefix)) || $i<$minDiv;$i++) {
|
2012-01-14 15:11:59 +01:00
|
|
|
$size /= $div;
|
|
|
|
}
|
|
|
|
|
|
|
|
return round($size,max(0,$i-1)).' '.$si_prefix[$i];
|
|
|
|
}
|
2011-12-29 19:45:18 +01:00
|
|
|
|
2012-01-23 21:07:33 +01:00
|
|
|
private function get_antifeature_description($antifeature) {
|
|
|
|
// Anti feature names and descriptions
|
2013-11-27 11:49:44 +01:00
|
|
|
$antifeatureDescription['Ads']['name'] = 'Advertising';
|
|
|
|
$antifeatureDescription['Ads']['description'] = 'This application contains advertising.';
|
|
|
|
$antifeatureDescription['Tracking']['name'] = 'Tracks You';
|
|
|
|
$antifeatureDescription['Tracking']['description'] = 'This application tracks and reports your activity to somewhere.';
|
|
|
|
$antifeatureDescription['NonFreeNet']['name'] = 'Non-Free Network Services';
|
|
|
|
$antifeatureDescription['NonFreeNet']['description'] = 'This application promotes a non-Free network service.';
|
|
|
|
$antifeatureDescription['NonFreeAdd']['name'] = 'Non-Free Addons';
|
|
|
|
$antifeatureDescription['NonFreeAdd']['description'] = 'This application promotes non-Free add-ons.';
|
|
|
|
$antifeatureDescription['NonFreeDep']['name'] = 'Non-Free Dependencies';
|
|
|
|
$antifeatureDescription['NonFreeDep']['description'] = 'This application depends on another non-Free application.';
|
|
|
|
$antifeatureDescription['UpstreamNonFree']['name'] = 'Upstream Non-Free';
|
|
|
|
$antifeatureDescription['UpstreamNonFree']['description'] = 'The upstream source code is non-free.';
|
2015-12-29 12:39:48 +01:00
|
|
|
$antifeatureDescription['NonFreeAssets']['name'] = 'Non-Free Assets';
|
|
|
|
$antifeatureDescription['NonFreeAssets']['description'] = 'This application contains non-free assets.';
|
2016-11-03 14:14:08 +01:00
|
|
|
$antifeatureDescription['KnownVuln']['name'] = 'Known Vulnerability';
|
|
|
|
$antifeatureDescription['KnownVuln']['description'] = 'This application known security vulnerabilities.';
|
2013-11-27 11:49:44 +01:00
|
|
|
|
|
|
|
if(isset($antifeatureDescription[$antifeature])) {
|
|
|
|
return $antifeatureDescription[$antifeature];
|
2012-01-23 21:13:32 +01:00
|
|
|
}
|
|
|
|
return array('name'=>$antifeature);
|
2012-01-23 21:07:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-29 19:45:18 +01:00
|
|
|
function get_apps($query_vars) {
|
|
|
|
|
|
|
|
$xml = simplexml_load_file($this->site_path."/repo/index.xml");
|
|
|
|
$matches = $this->show_apps($xml,$query_vars,$numpages);
|
|
|
|
|
|
|
|
$out='';
|
|
|
|
|
|
|
|
if(($query_vars['fdfilter']===null || $query_vars['fdfilter']!='') && $numpages>0)
|
|
|
|
{
|
|
|
|
$out.='<div style="float:left;">';
|
2013-10-22 15:53:07 +02:00
|
|
|
if($query_vars['fdfilter']===null) {
|
2012-03-03 11:56:28 +01:00
|
|
|
|
|
|
|
$categories = array('All categories');
|
|
|
|
$handle = fopen(getenv('DOCUMENT_ROOT').'/repo/categories.txt', 'r');
|
|
|
|
if ($handle) {
|
|
|
|
while (($buffer = fgets($handle, 4096)) !== false) {
|
2014-01-29 14:44:48 +01:00
|
|
|
$categories[] = rtrim($buffer);
|
2012-03-03 11:56:28 +01:00
|
|
|
}
|
2014-01-29 14:44:48 +01:00
|
|
|
fclose($handle);
|
2012-03-03 11:56:28 +01:00
|
|
|
}
|
2012-02-12 16:44:50 +01:00
|
|
|
|
|
|
|
$out.='<form name="categoryform" action="" method="get">';
|
|
|
|
$out.=$this->makeformdata($query_vars);
|
2013-12-30 17:04:16 +01:00
|
|
|
|
2012-02-12 16:44:50 +01:00
|
|
|
$out.='<select name="fdcategory" style="color:#333333;" onChange="document.categoryform.submit();">';
|
|
|
|
foreach($categories as $category) {
|
|
|
|
$out.='<option';
|
|
|
|
if(isset($query_vars['fdcategory']) && $category==$query_vars['fdcategory'])
|
|
|
|
$out.=' selected';
|
|
|
|
$out.='>'.$category.'</option>';
|
|
|
|
}
|
|
|
|
$out.='</select>';
|
2013-12-30 17:04:16 +01:00
|
|
|
|
2012-02-12 16:44:50 +01:00
|
|
|
$out.='</form>'."\n";
|
|
|
|
}
|
|
|
|
else {
|
2015-01-26 19:12:30 +01:00
|
|
|
$out.='Applications matching "'.esc_attr($query_vars['fdfilter']).'"';
|
2012-02-12 16:44:50 +01:00
|
|
|
}
|
2011-12-29 19:45:18 +01:00
|
|
|
$out.="</div>";
|
|
|
|
|
|
|
|
$out.='<div style="float:right;">';
|
2014-02-20 10:37:30 +01:00
|
|
|
$out.='<a href="'.makelink($query_vars, array('fdstyle'=>'list', 'fdpage'=>1)).'">List</a> | ';
|
|
|
|
$out.='<a href="'.makelink($query_vars, array('fdstyle'=>'grid', 'fdpage'=>1)).'">Grid</a>';
|
2011-12-29 19:45:18 +01:00
|
|
|
$out.='</div>';
|
|
|
|
|
|
|
|
$out.='<br break="all"/>';
|
|
|
|
}
|
|
|
|
|
|
|
|
if($numpages>0) {
|
|
|
|
$out.=$matches;
|
|
|
|
|
|
|
|
$out.='<hr><p>';
|
2012-01-03 21:43:02 +01:00
|
|
|
|
|
|
|
$out.='<div style="width:20%; float:left; text-align:left;">';
|
2011-12-29 19:45:18 +01:00
|
|
|
$out.=' Page '.$query_vars['fdpage'].' of '.$numpages.' ';
|
2012-01-03 21:43:02 +01:00
|
|
|
$out.='</div>';
|
|
|
|
|
|
|
|
$out.='<div style="width:60%; float:left; text-align:center;">';
|
2012-01-03 21:35:37 +01:00
|
|
|
if($numpages>1) {
|
2012-01-03 21:43:02 +01:00
|
|
|
for($i=1;$i<=$numpages;$i++) {
|
|
|
|
if($i == $query_vars['fdpage']) {
|
|
|
|
$out.='<b>'.$i.'</b>';
|
|
|
|
} else {
|
|
|
|
$out.='<a href="'.makelink($query_vars, array('fdpage'=>$i)).'">';
|
|
|
|
$out.=$i;
|
|
|
|
$out.='</a>';
|
|
|
|
}
|
|
|
|
$out.=' ';
|
|
|
|
}
|
|
|
|
$out.=' ';
|
2012-01-03 21:35:37 +01:00
|
|
|
}
|
2012-01-03 21:43:02 +01:00
|
|
|
$out.='</div>';
|
2012-01-03 21:35:37 +01:00
|
|
|
|
|
|
|
$out.='<div style="width:20%; float:left; text-align:right;">';
|
|
|
|
if($query_vars['fdpage']!=$numpages) {
|
2011-12-29 19:45:18 +01:00
|
|
|
$out.='<a href="'.makelink($query_vars, array('fdpage'=>($query_vars['fdpage']+1))).'">next></a> ';
|
|
|
|
}
|
2012-01-03 21:35:37 +01:00
|
|
|
$out.='</div>';
|
2012-01-03 21:43:02 +01:00
|
|
|
|
2011-12-29 19:45:18 +01:00
|
|
|
$out.='</p>';
|
|
|
|
} else if($query_vars['fdfilter']!='') {
|
|
|
|
$out.='<p>No matches</p>';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $out;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-12 16:44:50 +01:00
|
|
|
function makeformdata($query_vars) {
|
2011-12-29 19:45:18 +01:00
|
|
|
|
|
|
|
$out='';
|
|
|
|
|
2012-10-18 19:52:37 +02:00
|
|
|
$out.='<input type="hidden" name="page_id" value="'.(int)get_query_var('page_id').'">';
|
2011-12-29 19:45:18 +01:00
|
|
|
foreach($query_vars as $name => $value) {
|
2014-02-20 10:29:00 +01:00
|
|
|
if($value !== null && $name != 'fdfilter' && $name != 'fdpage')
|
2015-01-26 19:12:30 +01:00
|
|
|
$out.='<input type="hidden" name="'.esc_attr($name).'" value="'.esc_attr($value).'">';
|
2011-12-29 19:45:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return $out;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function show_apps($xml,$query_vars,&$numpages) {
|
|
|
|
|
|
|
|
$skipped=0;
|
|
|
|
$got=0;
|
|
|
|
$total=0;
|
|
|
|
|
|
|
|
if($query_vars['fdstyle']=='grid') {
|
|
|
|
$outputter = new FDOutGrid();
|
|
|
|
} else {
|
|
|
|
$outputter = new FDOutList();
|
|
|
|
}
|
|
|
|
|
|
|
|
$out = "";
|
|
|
|
|
|
|
|
$out.=$outputter->outputStart();
|
|
|
|
|
|
|
|
foreach($xml->children() as $app) {
|
|
|
|
|
|
|
|
if($app->getName() == 'repo') continue;
|
|
|
|
$appinfo['attrs']=$app->attributes();
|
|
|
|
$appinfo['id']=$appinfo['attrs']['id'];
|
|
|
|
foreach($app->children() as $el) {
|
|
|
|
switch($el->getName()) {
|
2014-01-29 14:44:48 +01:00
|
|
|
case "name":
|
|
|
|
$appinfo['name']=$el;
|
|
|
|
break;
|
|
|
|
case "icon":
|
|
|
|
$appinfo['icon']=$el;
|
|
|
|
break;
|
|
|
|
case "summary":
|
|
|
|
$appinfo['summary']=$el;
|
|
|
|
break;
|
|
|
|
case "desc":
|
|
|
|
$appinfo['description']=$el;
|
|
|
|
break;
|
|
|
|
case "license":
|
|
|
|
$appinfo['license']=$el;
|
|
|
|
break;
|
|
|
|
case "category":
|
|
|
|
$appinfo['category']=$el;
|
|
|
|
break;
|
2011-12-29 19:45:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-10 09:34:25 +01:00
|
|
|
if(($query_vars['fdfilter']===null || $query_vars['fdfilter']!='' && (stristr($appinfo['name'],$query_vars['fdfilter']) || stristr($appinfo['id'],$query_vars['fdfilter']) || stristr($appinfo['summary'],$query_vars['fdfilter']) || stristr($appinfo['description'],$query_vars['fdfilter']))) && (!isset($query_vars['fdcategory']) || $query_vars['fdcategory'] && $query_vars['fdcategory']==$appinfo['category'])) {
|
2011-12-29 19:45:18 +01:00
|
|
|
if($skipped<($query_vars['fdpage']-1)*$outputter->perpage) {
|
|
|
|
$skipped++;
|
|
|
|
} else if($got<$outputter->perpage) {
|
|
|
|
$out.=$outputter->outputEntry($query_vars, $appinfo);
|
|
|
|
$got++;
|
|
|
|
}
|
|
|
|
$total++;
|
|
|
|
}
|
2012-01-03 20:28:24 +01:00
|
|
|
|
2011-12-29 19:45:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$out.=$outputter->outputEnd();
|
|
|
|
|
|
|
|
$numpages = ceil((float)$total/$outputter->perpage);
|
|
|
|
|
|
|
|
return $out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Class to output app entries in a detailed list format
|
|
|
|
class FDOutList
|
|
|
|
{
|
|
|
|
var $perpage=30;
|
|
|
|
|
|
|
|
function FDOutList() {
|
|
|
|
}
|
|
|
|
|
|
|
|
function outputStart() {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
function outputEntry($query_vars, $appinfo) {
|
|
|
|
$out="";
|
2012-01-23 21:39:27 +01:00
|
|
|
$out.='<hr style="clear:both;" />'."\n";
|
2012-01-23 21:34:03 +01:00
|
|
|
$out.='<a href="'.makelink($query_vars, array('fdid'=>$appinfo['id'])).'">';
|
2011-12-29 19:45:18 +01:00
|
|
|
$out.='<div id="appheader">';
|
|
|
|
|
2013-10-22 15:53:07 +02:00
|
|
|
$out.='<div style="float:left;padding-right:10px;"><img src="' . site_url() . '/repo/icons/'.$appinfo['icon'].'" style="width:48px;border:none;"></div>';
|
2011-12-29 19:45:18 +01:00
|
|
|
|
|
|
|
$out.='<div style="float:right;">';
|
2012-01-23 21:34:03 +01:00
|
|
|
$out.='<p>Details...</p>';
|
2011-12-29 19:45:18 +01:00
|
|
|
$out.="</div>\n";
|
|
|
|
|
2012-01-23 21:34:03 +01:00
|
|
|
$out.='<p style="color:#000000;"><span style="font-size:20px;">'.$appinfo['name']."</span>";
|
2011-12-29 19:45:18 +01:00
|
|
|
$out.="<br>".$appinfo['summary']."</p>\n";
|
|
|
|
|
|
|
|
$out.="</div>\n";
|
2012-01-23 21:34:03 +01:00
|
|
|
$out.='</a>';
|
2011-12-29 19:45:18 +01:00
|
|
|
|
|
|
|
return $out;
|
|
|
|
}
|
|
|
|
|
|
|
|
function outputEnd() {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Class to output app entries in a compact grid format
|
|
|
|
class FDOutGrid
|
|
|
|
{
|
|
|
|
var $perpage=80;
|
|
|
|
|
|
|
|
var $itemCount = 0;
|
|
|
|
|
|
|
|
function FDOutGrid() {
|
|
|
|
}
|
|
|
|
|
|
|
|
function outputStart() {
|
|
|
|
return "\n".'<table border="0" width="100%"><tr>'."\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
function outputEntry($query_vars, $appinfo) {
|
|
|
|
$link=makelink($query_vars, array('fdid'=>$appinfo['id']));
|
|
|
|
|
|
|
|
$out='';
|
|
|
|
|
|
|
|
if($this->itemCount%4 == 0 && $this->itemCount > 0)
|
|
|
|
{
|
|
|
|
$out.='</tr><tr>'."\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
$out.='<td align="center" valign="top" style="background-color:#F8F8F8;">';
|
|
|
|
$out.='<p>';
|
|
|
|
$out.='<div id="appheader" style="text-align:center;width:110px;">';
|
|
|
|
|
|
|
|
$out.='<a href="'.$link.'" style="border-bottom-style:none;">';
|
2012-09-08 10:41:05 +02:00
|
|
|
$out.='<img src="' . site_url() . '/repo/icons/'.$appinfo['icon'].'" style="width:48px;border-width:0;padding-top:5px;padding-bottom:5px;"><br/>';
|
2011-12-29 19:45:18 +01:00
|
|
|
$out.=$appinfo['name'].'<br/>';
|
|
|
|
$out.='</a>';
|
|
|
|
|
|
|
|
$out.="</div>";
|
|
|
|
$out.='</p>';
|
|
|
|
$out.="</td>\n";
|
|
|
|
|
|
|
|
$this->itemCount++;
|
|
|
|
return $out;
|
|
|
|
}
|
|
|
|
|
|
|
|
function outputEnd() {
|
|
|
|
return '</tr></table>'."\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-17 21:48:48 +01:00
|
|
|
function permissions_cmp($a, $b) {
|
|
|
|
global $permissions_data;
|
|
|
|
|
|
|
|
$aProtectionLevel = $permissions_data['permission'][$a]['protectionLevel'];
|
|
|
|
$bProtectionLevel = $permissions_data['permission'][$b]['protectionLevel'];
|
|
|
|
|
|
|
|
if($aProtectionLevel != $bProtectionLevel) {
|
|
|
|
if(strlen($aProtectionLevel)==0) return 1;
|
|
|
|
if(strlen($bProtectionLevel)==0) return -1;
|
|
|
|
|
|
|
|
return strcmp($aProtectionLevel, $bProtectionLevel);
|
|
|
|
}
|
|
|
|
|
|
|
|
$aGroup = $permissions_data['permission'][$a]['permissionGroup'];
|
|
|
|
$bGroup = $permissions_data['permission'][$b]['permissionGroup'];
|
|
|
|
|
|
|
|
if($aGroup != $bGroup) {
|
|
|
|
return strcmp($aGroup, $bGroup);
|
|
|
|
}
|
|
|
|
|
|
|
|
return strcmp($a, $b);
|
|
|
|
}
|
|
|
|
|
2011-12-29 19:45:18 +01:00
|
|
|
// Make a link to this page, with the current query vars attached and desired params added/modified
|
|
|
|
function makelink($query_vars, $params=array()) {
|
|
|
|
$link=get_permalink();
|
2012-10-18 19:52:37 +02:00
|
|
|
|
|
|
|
$p = array_merge($query_vars, $params);
|
|
|
|
|
|
|
|
// Page 1 is the default, don't clutter urls with it...
|
|
|
|
if($p['fdpage'] == 1)
|
|
|
|
unset($p['fdpage']);
|
|
|
|
// Likewise for list style...
|
|
|
|
if($p['fdstyle'] == 'list')
|
|
|
|
unset($p['fdstyle']);
|
|
|
|
|
|
|
|
$vars=linkify($p);
|
2011-12-29 19:45:18 +01:00
|
|
|
if(strlen($vars)==0)
|
|
|
|
return $link;
|
|
|
|
if(strpos($link,'?')===false)
|
|
|
|
$link.='?';
|
|
|
|
else
|
|
|
|
$link.='&';
|
|
|
|
return $link.$vars;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return the key value pairs in http-get-parameter format as a string
|
|
|
|
function linkify($vars) {
|
|
|
|
$retvar = '';
|
|
|
|
foreach($vars as $k => $v) {
|
|
|
|
if($k!==null && $v!==null && $v!='')
|
2014-09-04 15:31:37 +02:00
|
|
|
$retvar .= $k.'='.urlencode($v).'&';
|
2011-12-29 19:45:18 +01:00
|
|
|
}
|
|
|
|
return substr($retvar,0,-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
$wp_fdroid = new FDroid();
|
|
|
|
|
|
|
|
|
|
|
|
?>
|