Skip to content

Commit

Permalink
Server: generate letters
Browse files Browse the repository at this point in the history
  • Loading branch information
M66B committed Dec 7, 2013
1 parent f71a6b5 commit 2b9b60e
Showing 1 changed file with 15 additions and 23 deletions.
38 changes: 15 additions & 23 deletions server/xprivacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,19 +185,23 @@
echo '<pre>Error connecting to database</pre>';
exit();
}
//$db->query("SET NAMES 'utf8'");
$db->query("SET NAMES 'utf8'");
?>
<div class="page-header">
<?php
if (empty($package_name)) {
$count = 0;
$total = 0;
$sql = "SELECT COUNT(DISTINCT application_name) AS count";
$sql .= ", COUNT(*) AS total";
$sql .= " FROM xprivacy";
$result = $db->query($sql);
if ($result) {
$row = $result->fetch_object();
if ($row)
if ($row) {
$count = $row->count;
$total = $row->total;
}
$result->close();
}
?>
Expand All @@ -207,7 +211,8 @@
the <a href="https://github.com/M66B/XPrivacy#xprivacy">XPrivacy</a> restrictions.<br />
Everybody using XPrivacy can submit his/her restriction settings.<br />
With a <a href="http://www.faircode.eu/xprivacy">Pro license</a> you can fetch submitted restriction settings.<br />
There are currently restriction settings for <?php echo $count; ?> applications submitted.
There are currently <?php echo number_format($total, 0, '.', ','); ?> restriction settings
for <?php echo number_format($count, 0, '.', ',') ?> applications submitted.
</p>
<?php
} else {
Expand Down Expand Up @@ -241,23 +246,9 @@
<?php
if (empty($package_name)) {
echo '<p>';
$sql = "SELECT DISTINCT LEFT(UCASE(application_name), 1) AS letter";
$sql .= " FROM xprivacy";
$sql .= " ORDER BY application_name";
$result = $db->query($sql);
if ($result) {
while ($row = $result->fetch_object()) {
echo '<a href="?letter=' . urlencode($row->letter) . '">';
if ($row->letter == '')
echo '---';
else {
$ent = htmlentities($row->letter, ENT_NOQUOTES, 'UTF-8');
echo ($ent == '' ? '???' : $ent);
}
echo '</a> ';
}
$result->close();
}
foreach(range('A', 'Z') as $letter)
echo '<a href="?letter=' . $letter . '">' . $letter . '</a> ';
echo '<a href="?letter=*">other</a> ';
echo '</p>';
}
else {
Expand Down Expand Up @@ -301,18 +292,19 @@

if (empty($package_name)) {
// Get application list
$letter = isset($_REQUEST['letter']) ? $_REQUEST['letter'] :'A';
$letter = empty($_REQUEST['letter']) ? 'A' : $_REQUEST['letter'];
$sql = "SELECT DISTINCT application_name, package_name";
$sql .= " FROM xprivacy";
if ($letter == '')
$sql .= " WHERE application_name = ''";
if ($letter == '*')
$sql .= " WHERE application_name NOT REGEXP '^[[:alpha:]]'";
else
$sql .= " WHERE application_name LIKE '" . ($letter == '%' ? '\\' : '') . $db->real_escape_string($letter) . "%'";
$sql .= " ORDER BY application_name";
$result = $db->query($sql);
if ($result) {
while (($row = $result->fetch_object())) {
$count++;
ini_set('mbstring.substitute_character', "none");
$name = (empty($row->application_name) ? '---' : $row->application_name);
echo '<tr>';

Expand Down

0 comments on commit 2b9b60e

Please sign in to comment.