packages.php 2.55 KB
Newer Older
1
<?php
pjmattal's avatar
pjmattal committed
2
3
4

set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../lang');

eric's avatar
eric committed
5
include("aur.inc");         # access AUR common functions
6
include("pkgfuncs.inc");    # package specific functions
eric's avatar
eric committed
7
8
include("search_po.inc");   # use some form of this for i18n support
set_lang();                 # this sets up the visitor's language
eric's avatar
eric committed
9
check_sid();                # see if they're still logged in
10
11
12
13
14
15
16
17
18

# set the title to something useful depending on
# what "page" we're on
#
if (isset($_GET['ID'])) {
	$id = pkgname_from_id($_GET['ID']);
	if (!empty($id)) {
		$title = $id;
	}
19
}	else if (!empty($_GET['K'])) {
20
21
22
23
24
	$title = "Search: " . $_GET['K'];
} else {
	$title = __("Packages");
}

25
html_header($title);
eric's avatar
eric committed
26

eric's avatar
eric committed
27
# get login privileges
eric's avatar
eric committed
28
#
eric's avatar
eric committed
29
30
31
32
33
34
35
36
if (isset($_COOKIE["AURSID"])) {
	# Only logged in users can do stuff
	#
	$atype = account_from_sid($_COOKIE["AURSID"]);
} else {
	$atype = "";
}

37
38
# grab the list of Package IDs to be operated on
#
Callan Barrett's avatar
Callan Barrett committed
39
isset($_POST["IDs"]) ? $ids = $_POST["IDs"] : $ids = array();
40
41
42

# determine what button the visitor clicked
#
Simo Leone's avatar
Simo Leone committed
43
if ($_POST['action'] == "do_Flag" || isset($_POST['do_Flag'])) {
44
45
46
	print "<p>";
	print pkg_flag($atype, $ids, True);
	print "</p>";
Simo Leone's avatar
Simo Leone committed
47
} elseif ($_POST['action'] == "do_UnFlag" || isset($_POST['do_UnFlag'])) {
48
49
50
	print "<p>";
	print pkg_flag($atype, $ids, False);
	print "</p>";
Simo Leone's avatar
Simo Leone committed
51
} elseif ($_POST['action'] == "do_Disown" || isset($_POST['do_Disown'])) {
52
53
54
	print "<p>";
	print pkg_adopt($atype, $ids, False);
	print "</p>";
Simo Leone's avatar
Simo Leone committed
55
} elseif ($_POST['action'] == "do_Delete" || isset($_POST['do_Delete'])) {
56
57
58
	print "<p>";
	print pkg_delete($atype, $ids, False);
	print "</p>";
Simo Leone's avatar
Simo Leone committed
59
} elseif ($_POST['action'] == "do_Adopt" || isset($_POST['do_Adopt'])) {
60
61
62
	print "<p>";
	print pkg_adopt($atype, $ids, True);
	print "</p>";
Simo Leone's avatar
Simo Leone committed
63
} elseif ($_POST['action'] == "do_Vote" || isset($_POST['do_Vote'])) {
64
65
66
	print "<p>";
	print pkg_vote($atype, $ids, True);
	print "</p>";
Simo Leone's avatar
Simo Leone committed
67
} elseif ($_POST['action'] == "do_UnVote" || isset($_POST['do_UnVote'])) {
68
69
70
	print "<p>";
	print pkg_vote($atype, $ids, False);
	print "</p>";
71
72
73
74
75
76
77
78
} elseif ($_POST['action'] == "do_Notify" || isset($_POST['do_Notify'])) {
	print "<p>";
	print pkg_notify($atype, $ids);
	print "</p>";
} elseif ($_POST['action'] == "do_UnNotify" || isset($_POST['do_UnNotify'])) {
	print "<p>";
	print pkg_notify($atype, $ids, False);
	print "</p>";
Callan Barrett's avatar
Callan Barrett committed
79
} elseif (isset($_GET["ID"])) {
eric's avatar
eric committed
80

Callan Barrett's avatar
Callan Barrett committed
81
	if (!intval($_GET["ID"])) {
eric's avatar
eric committed
82
83
		print __("Error trying to retrieve package details.")."<br />\n";
		
eric's avatar
eric committed
84
	} else {
Callan Barrett's avatar
Callan Barrett committed
85
		package_details($_GET["ID"], $_COOKIE["AURSID"]);
eric's avatar
eric committed
86
87
	}

88
} else {
Simo Leone's avatar
Simo Leone committed
89
	# just do a search
90
	#
91
	pkg_search_page($_COOKIE["AURSID"]);
92

eric's avatar
eric committed
93
}
eric's avatar
eric committed
94

tardo's avatar
tardo committed
95
html_footer(AUR_VERSION);
96