diff options
author | Loui Chang <louipc.ist@gmail.com> | 2008-11-03 21:52:07 -0500 |
---|---|---|
committer | Loui Chang <louipc.ist@gmail.com> | 2008-11-03 21:52:07 -0500 |
commit | a6147ab5ab297728adefdb97aaeedc93114b896d (patch) | |
tree | 49b508439ab2aa0cf4bd039d3b2d2d53e8860df0 /web/html | |
parent | c85dfacc747387b9be6c53b4518ac680b505e0f7 (diff) | |
parent | 100451a9665cb387eeae2cb06cc22870cfd57c82 (diff) | |
download | aurweb-a6147ab5ab297728adefdb97aaeedc93114b896d.tar.xz |
Merge branch 'testing'
Conflicts:
web/html/pkgsubmit.php
Signed-off-by: Loui Chang <louipc.ist@gmail.com>
Diffstat (limited to 'web/html')
-rw-r--r-- | web/html/addvote.php | 30 | ||||
-rw-r--r-- | web/html/css/fonts.css | 6 | ||||
-rw-r--r-- | web/html/guidelines.html | 273 | ||||
-rw-r--r-- | web/html/index.php | 220 | ||||
-rw-r--r-- | web/html/packages.php | 403 | ||||
-rw-r--r-- | web/html/pkgedit.php | 2 | ||||
-rw-r--r-- | web/html/pkgsubmit.php | 265 | ||||
-rw-r--r-- | web/html/template.php | 20 | ||||
-rw-r--r-- | web/html/testpo.php | 45 | ||||
-rw-r--r-- | web/html/tu.php | 440 |
10 files changed, 269 insertions, 1435 deletions
diff --git a/web/html/addvote.php b/web/html/addvote.php index 8e4df79..449bbb0 100644 --- a/web/html/addvote.php +++ b/web/html/addvote.php @@ -2,7 +2,7 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../lang'); -include("pkgfuncs_po.inc"); +include("tu_po.inc"); include("aur.inc"); set_lang(); check_sid(); @@ -25,23 +25,23 @@ if ($atype == "Trusted User" OR $atype == "Developer") { $check = mysql_num_rows(db_query($qcheck, $dbh)); if ($check == 0) { - $error.= "<div style='color: red; font-weight: bold'>Username does not exist.</div>"; + $error.= "<div style='color: red; font-weight: bold'>" . __("Username does not exist.") . "</div>"; } else { $qcheck = "SELECT * FROM TU_VoteInfo WHERE User = '" . mysql_real_escape_string($_POST['user']) . "'"; $qcheck.= " AND End > UNIX_TIMESTAMP()"; $check = mysql_num_rows(db_query($qcheck, $dbh)); if ($check != 0) { - $error.= "<div style='color: red; font-weight: bold'>" . htmlentities($_POST['user']) . " already has proposal running for them.</div>"; + $error.= "<div style='color: red; font-weight: bold'>" . __("%s already has proposal running for them.", htmlentities($_POST['user'])) . "</div>"; } } } if (!empty($_POST['length'])) { if (!is_numeric($_POST['length'])) { - $error.= "<div style='color: red; font-weight: bold'>Length must be a number.</div>"; + $error.= "<div style='color: red; font-weight: bold'>" . __("Length must be a number.") . "</div>"; } else if ($_POST['length'] < 1) { - $error.= "<div style='color: red; font-weight: bold'>Length must be at least 1.</div>"; + $error.= "<div style='color: red; font-weight: bold'>" . __("Length must be at least 1.") . "</div>"; } else { $len = (60*60*24)*$_POST['length']; } @@ -50,7 +50,7 @@ if ($atype == "Trusted User" OR $atype == "Developer") { } if (empty($_POST['agenda'])) { - $error.= "<div style='color: red; font-weight: bold'>Proposal cannot be empty.</div>"; + $error.= "<div style='color: red; font-weight: bold'>" . __("Proposal cannot be empty.") . "</div>"; } } @@ -62,21 +62,21 @@ if ($atype == "Trusted User" OR $atype == "Developer") { $q.= ", " . uid_from_sid($_COOKIE["AURSID"]) . ")"; db_query($q, $dbh); - print "<p>New proposal submitted.</p>\n"; + print "<p>" . __("New proposal submitted.") . "</p>\n"; } else { ?> -<p>Submit a proposal to vote on.</p> +<p><?php print __("Submit a proposal to vote on.") ?></p> <?php if (!empty($error)) { print $error . "<br />"; } ?> <form action='addvote.php' method='post'> -<b>Applicant/TU:</b> +<b><?php print __("Applicant/TU:") ?></b> <input type='text' name='user' value='<?php if (!empty($_POST['user'])) { print htmlentities($_POST['user'], ENT_QUOTES); } ?>'> -(empty if not applicable) +<?php print __("(empty if not applicable)") ?> <br /> -<b>Length in days:</b> +<b><?php print __("Length in days:") ?></b> <input type='text' name='length' value='<?php if (!empty($_POST['length'])) { print htmlentities($_POST['length'], ENT_QUOTES); } ?>'> -(defaults to 7 if empty) +<?php print __("(defaults to 7 if empty)") ?> <br /> -<b>Proposal:</b><br /> +<b><?php print __("Proposal:") ?></b><br /> <textarea name='agenda' rows='10' cols='50'><?php if (!empty($_POST['agenda'])) { print htmlentities($_POST['agenda']); } ?></textarea><br /> <input type='hidden' name='addVote' value='1'> <input type='submit' class='button' value='Submit'> @@ -84,9 +84,9 @@ if ($atype == "Trusted User" OR $atype == "Developer") { <br /> <?php } - print "<a href='tu.php'>Back</a>"; + print "<a href='tu.php'>" . __("Back") . "</a>"; } else { - print "You are not allowed to access this area.\n"; + print __("You are not allowed to access this area."); } html_footer(AUR_VERSION); diff --git a/web/html/css/fonts.css b/web/html/css/fonts.css index dc65070..baa7560 100644 --- a/web/html/css/fonts.css +++ b/web/html/css/fonts.css @@ -99,5 +99,9 @@ a:hover { h1, h2, h3, h4 { font-size: 16pt; } -span.important { color: #f00; } + +.important { + font-weight: bold; + color: #f00; +} diff --git a/web/html/guidelines.html b/web/html/guidelines.html deleted file mode 100644 index c2acd77..0000000 --- a/web/html/guidelines.html +++ /dev/null @@ -1,273 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><title>AUR Guidelines</title> - - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> - <link rel="stylesheet" type="text/css" href="http://archlinux.org/docs/css/arch-styles.css"></head> - - - - <body> - <h1>AUR Guidelines</h1> - - <div class="date">Jun 08, 2005</div> - <div class="version">1.1.0</div> - - <address> - Ben Mazer - <a class="email" href="mailto:blm@groknil.org">blm@groknil.org</a> - </address> - <address> - The Trusted Users - <a class="email" href="mailto:aur-general@archlinux.org">aur-general@archlinux.org</a> - </address> - - <h2 id="summary">Summary</h2> - <p> - Basic guidelines for the Arch User Repository. - </p> - - <h2 id="toc">Table Of Contents</h2> - <div class="toc"> - <ol> - <li><a href="#purpose">Purpose</a></li> - <li><a href="#user">The User</a> - <ol> - <li><a href="#usersub">Submitting Packages</a></li> - - </ol> - </li> - <li><a href="#tu">The TU</a> - <ol> - <li><a href="#tuaddition">Adding a TU</a></li> - <li><a href="#turemoval">Removing a TU</a></li> - <li><a href="#otherduties">Other Duties</a></li> -<li><a href="#tuguidelines">Guidelines for Package Maintenance</a> - <ol> - <li><a href="#accessing">Accessing the Repo</a></li> - <li><a href="#adopting">Adopting a package</a></li> - <li><a href="#disowning">Disowning a package</a></li> - <li><a href="#pkgguidelines">Packaging Etiquette</a></li> - </ol> - </li> - - - </ol> </li> - <li><a href="#faq">Frequently Asked Questions</a></li> - </ol> - </div> - - <h2 id="purpose">Purpose</h2> - <p> - The <acronym title="Arch User Repository">AUR</acronym> -is a community of Arch users, where packages outside of the core Arch -distribution are maintained. The AUR Community Repo is a supplement to -the EXTRA and CURRENT repositories; less popular packages will be -maintained as a service to the general Arch-using population. Packages -in the AUR will depend on EXTRA and CURRENT. <br><br> The AUR was -created to lift the burden on the developers. They should be allowed to -focus on adding new features, rather than doing the mundane job of -package maintenance. Therefore, all packages start inside the AUR, and -as developers consider them crucial to the distribution, they will be -adopted into EXTRA/CURRENT. The AUR was also created to allow easy -participation. Arch is completely volunteer-based, and needs help from -its users. Lastly, the AUR helps to further the Arch philosophy of -KISS. The Arch Core (EXTRA/CURRENT/UNSTABLE) is a complete -distribution, but it does not attempt to provide every single package. -The AUR helps by maintaining less popular packages; but the AUR also -follows KISS, and only popular packages from UNSUPPORTED will make it -into the official AUR repository. </p> - <h2 id="user">The User</h2> - <p> Users of the -AUR can do many things, the main function being to download and use -packages. One can access the AUR by adding this to their pacman.conf -file:<br><br> - <code>[community]<br>Server = ftp://ftp.archlinux.org/community/os/i686/</code><br><br> -But a user can also help with package maintenance, by: submitting -packages (and then maintaining them while they remain in UNSUPPORTED), -filing bug reports, reporting out-of-date packages, helping with other -user-submitted PKGBUILDs, and voting for packages that should be -maintained by the TUs. Once a user account has been created, all -functions can be performed inside the web interface. </p><h3 id="usersub">Submitting Packages</h3> - <p> -Inside the web interface, a user can submit a tarball (tar.gz) of a -directory containing build files for a package. The directory inside -the tarball should contain a PKGBUILD, any .install files, patches, etc -(<b>no binaries</b>). Examples of what a directory looks like can be seen inside /var/abs. <br><br> - When submitting a package, observe the following rules: - </p><ul> - <li>Check -EXTRA, CURRENT, UNSTABLE, UNSUPPORTED, and AUR for the package. If it -is inside any of those repositories in any form, do not submit the -package (if the package is broken in some way, file a bug report). </li> - <li>Verify -carefully that what you are uploading is correct. Follow the -TU/Developer Package Building Guidelines exactly. Broken packages make -the AUR messy, and prevent the TUs from doing their other duties. </li> - <li>If -you are unsure about the package (or the build/submission process) in -any way, submit the PKGBUILD to the AUR Mailing List for public review -before adding it to the AUR.</li> - <li>Make sure the package -is useful. Will anyone else want to use this package? Is it extremely -specialized? If more than a few people would find this package useful, -it is appropriate for submission. </li> - <li>Gain some experience before submitting packages. Build a few packages to learn the process and then submit. </li> - <li>Do -not abandon packages. While in UNSUPPORTED, it is the user's job to -maintain the package. If you do not want to maintain the package for -some reason, post a message to the AUR Mailing List. </li> - </ul> - - - <h2 id="tu">The TU</h2> - <p> -The TU -or Trusted User- is a member of the community charged with -keeping the AUR in working order. He maintains popular packages, and -votes in administrative matters. A TU is elected from active community -members by current TUs in a democratic process. TUs are the only -members who have a final say in the direction of the AUR. </p> - <h3 id="tuaddition">Adding a TU</h3> - <p> -TUs are only added as needed, and applications will only be accepted at -certain times. Check the AUR website for details on whether -applications are being accepted. <br><br> -TUs are elected democratically. If you would like to become a TU, a -sponsor (another TU) is needed. You must solicit requests for a sponsor -privately before posting on the mailing list. After this is received, a -request must be made on the AUR Mailing List by the sponsor. Ideally, a -TU should have a specific subset of packages he wishes to maintain. <br><br> -Four other votes must be received from other TUs or developers for an -applicant to be accepted. Once these have been received, the user will -be given the proper passwords, and a TU will upgrade the user's status -on the web interface. <br><br> -Once an application has been published on the mailing list, it is open -for voting for 3 weeks. If the applicant does not receive enough votes -within that time period, he must wait 3 months to submit another -application, with vote tallies being reset. <br> - - </p> - <h3 id="turemoval">Sanctioning/Removing a TU</h3> - <p> -There is a basic sanctioning system for TUs. If a TU breaks a rule, -either official or through "community standards" when he was already -aware of this rule, one can request a sanction. If two other votes from -TUs are received, a sanction will be added. After two sanctions, the TU -will automatically come up for a removal vote. <br><br> If a TU is not working out, for any reason, one can -request him to be expelled. Someone requesting a removal of a TU must -state a valid reason, and why immediate removal is necessary. Almost -always, previous sanctions will be needed. With four additional votes, -that TU will be immediately removed and his packages will have to be -adopted by a different TU. </p> - <h3 id="otherduties">Other Duties</h3> - <p> -All other duties (changing rules, adding new regulations, new features, -etc) should be discussed openly on the AUR Mailing List and voted on. -Various pieces of documentation and code can have specified -"maintainers" that can perform basic updates (typo/bug fixes) without a -vote, but any changes should be reported on the mailing list. Any major -changes should receive a simple majority vote. </p> - <h3 id="tuguidelines">Guidelines for Package Maintenance</h3> - <p> - </p> - <h4 id="accessing">Accessing the Repo</h4> - <p> - Follow these instructions for uploading/modifying packages once you have become a TU: - </p><ol> - <li>Install the "aurtools" package.</li> - <li>Email Jason (<a class="email" href="mailto:jason@archlinux.org">jason@archlinux.org</a>) for a CVS account.</li> - <li>Run the following commands to checkout the AUR CVS:<br> - <kbd> - export CVSROOT=":pserver:<userid>@cvs.archlinux.org:/home/cvs-community"<br> - cvs login<br> - cvs co community</kbd></li> - <li>To add a PKGBUILD and other build files:<br> - <kbd> - cvs add <directory><br> - cd <directory><br> - cvs add PKGBUILD<br> - .<br> - .<br> - cvs commit</kbd></li> - <li>To upload a binary package: - <kbd>tupkg --user <userid> --password <password> <packagefile.pkg.tar.gz></kbd></li> - <li>After uploading a package and committing the build files, tag the files with this command: - <kbd>cvs tag -cFR CURRENT <newpackagebuilddir></kbd></li> - <li>Package -changes should be available within 10 minutes. Verify everything was -uploaded properly, then select the newly added or updated package in -the web interface and set yourself as the maintainer.</li> - </ol> - - <h4 id="adopting">Adopting Packages</h4> - <p> -A TU may adopt any package at any time. But because the TU's time is -limited, he should try to only adopt popular packages. The voting -mechanism in the AUR allows a TU to quickly gage which packages users -want. <br><br> -If a package receives 25 votes, it may be adopted by a TU. A maintainer -should adopt it via the web interface. That maintainer is then -responsible for bug fixes and new version updates. Packages must be -properly cleaned and fixed after adoption. </p> - - <h4 id="disowning">Disowning packages</h4> - <p> -If a TU can't or doesn't want to maintain a package any longer, a -notice should be posted to the AUR Mailing List, so another TU can -maintain it. A package can still be disowned even if no other TU wants -to maintain it, but the TUs should try not to drop many packages (they -shouldn't take on more than they have time for). If a package has -become obsolete or isn't used any longer, it can be removed completely -as well. <br><br> -If a package has been removed completely, it can be uploaded once again -(fresh) to UNSUPPORTED, where a regular user can maintain the package -instead of the TU. </p> - <h4 id="pkgguidelines">Packaging Etiquette</h4> - <p> - Adhere to the following rules when building/maintaining packages: - <br> - </p><ul> - <li>Follow all rules in the <a href="http://www.archlinux.org/docs/en/guide/install/arch-install-guide.html#build">Arch Packaging Guidelines</a>.</li> - <li>Always run Namcap on all packages and PKGBUILDs.</li> - <li>All -important messages should be echoed inside the .install file. For -example, if a package needs extra setup to work, directions should be -echoed. </li> - <li>Any optional dependencies that aren't -needed to run the package or have it generally function shouldn't be -included, but a warning message inside the .install file should echo -something like: "To enable SMB support, download the Samba package."</li> - - <li>Always look at current packages for ideas on how various problems should be handled. Most problems have already been solved. </li> - <li>Dependencies -are the most common packaging error. Namcap can help detect them, but -it is not always correct. Verify dependencies by looking at source -documentation and the program website. </li> - <li>All packages should be buildable as a user, under fakeroot. </li> - <li>New user creation should only be done when absolutely necessary. </li> - <li>Always -fill out all applicable fields in the PKGBUILD (never forget a URL, -md5sum, etc). The LICENSE variable is not currently used, but will be -very shortly. </li> - <li>All custom variables should begin with an underscore (_). </li> - <li>A PKGBUILD should never modify any files outside of the build directory. </li> - </ul> - - <h2 id="faq">Frequently Asked Questions</h2> - <p> - Q: What is the difference between the AUR, COMMUNITY, and TUR? Why don't packages I upload to the AUR show up in pacman?<br><br> -A: The TUR, or Trusted User Repository, was the old system used to -manage user submissions. It had a number of flaws, so was discontinued. -The TUR website is still up, but is dead and will be removed shortly. -AUR is the official replacement for the TUR. It is a web system that -allows users to submit their own PKGBUILDs for both the TUs and the -general community to see. COMMUNITY is a new Arch repository, run by -the TUs, that is available via pacman.<br><br> -User submitted PKGBUILDs are available from the AUR, but because they -have not been reviewed, packages are not available. If a PKGBUILD is -reviewed, and receives many votes, it may "graduate" into the COMMUNITY -repo. There it will easily be retrievable from pacman.<br><br> -If you are a new user, it is safe to use the COMMUNITY repo, as -packages have been verified. Any PKGBUILDs in the UNSUPPORTED section -of the AUR have not been tested, and could be dangerous or broken. Use -at your own risk. </p> - </body></html> diff --git a/web/html/index.php b/web/html/index.php index 7a95abf..c7847f2 100644 --- a/web/html/index.php +++ b/web/html/index.php @@ -5,66 +5,13 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR # Add to handle the i18n of My Packages include("pkgfuncs_po.inc"); include("aur.inc"); +include('stats.inc'); set_lang(); check_sid(); html_header( __("Home") ); - -# Newest packages -$q = "SELECT * FROM Packages WHERE DummyPkg != 1 ORDER BY GREATEST(SubmittedTS,ModifiedTS) DESC LIMIT 0 , 10"; -$newest_packages = db_query($q, $dbh); - -# AUR statistics -$q = "SELECT count(*) FROM Packages,PackageLocations WHERE Packages.LocationID = PackageLocations.ID AND PackageLocations.Location = 'unsupported'"; -$result = db_query($q, $dbh); -$row = mysql_fetch_row($result); -$unsupported_count = $row[0]; - -$q = "SELECT count(*) FROM Packages,PackageLocations WHERE Packages.LocationID = PackageLocations.ID AND PackageLocations.Location = 'community'"; -$result = db_query($q, $dbh); -$row = mysql_fetch_row($result); -$community_count = $row[0]; - -$q = "SELECT count(*) from Users"; -$result = db_query($q, $dbh); -$row = mysql_fetch_row($result); -$user_count = $row[0]; - -$q = "SELECT count(*) from Users,AccountTypes WHERE Users.AccountTypeID = AccountTypes.ID AND AccountTypes.AccountType = 'Trusted User'"; -$result = db_query($q, $dbh); -$row = mysql_fetch_row($result); -$tu_count = $row[0]; - -$targstamp = intval(strtotime("-7 days")); -$q = "SELECT count(*) from Packages WHERE (Packages.SubmittedTS >= $targstamp OR Packages.ModifiedTS >= $targstamp)"; -$result = db_query($q, $dbh); -$row = mysql_fetch_row($result); -$update_count = $row[0]; - -$user = username_from_sid($_COOKIE["AURSID"]); - -if (!empty($user)) { - $q = "SELECT count(*) FROM Packages,PackageLocations,Users WHERE Packages.MaintainerUID = Users.ID AND Packages.LocationID = PackageLocations.ID AND PackageLocations.Location = 'unsupported' AND Users.Username='".mysql_real_escape_string($user)."'"; - $result = db_query($q, $dbh); - $row = mysql_fetch_row($result); - $maintainer_unsupported_count = $row[0]; - - $q = "SELECT count(*) FROM Packages,Users WHERE Packages.OutOfDate = 1 AND Packages.MaintainerUID = Users.ID AND Users.Username='".mysql_real_escape_string($user)."'"; - $result = db_query($q, $dbh); - $row = mysql_fetch_row($result); - $flagged_outdated = $row[0]; - - # If the user is a TU calculate the number of the packages - $atype = account_from_sid($_COOKIE["AURSID"]); - - if ($atype == 'Trusted User') { - $q = "SELECT count(*) FROM Packages,PackageLocations,Users WHERE Packages.MaintainerUID = Users.ID AND Packages.LocationID = PackageLocations.ID AND PackageLocations.Location = 'community' AND Users.Username='".mysql_real_escape_string($user)."'"; - $result = db_query($q, $dbh); - $row = mysql_fetch_row($result); - $maintainer_community_count = $row[0]; - } -} +$dbh = db_connect(); ?> @@ -73,167 +20,64 @@ if (!empty($user)) { <span class="f3">AUR <?php print __("Home"); ?></span> </div> <div class="frontpgboxbody"> -<table border='0' cellpadding='0' cellspacing='3' width='90%'> -<tr> -<td class='boxSoft' valign='top' colspan='2'> <p> <?php -print __( 'Welcome to the AUR! Please read the %hAUR User Guidelines%h and %hAUR TU Guidelines%h for more information.' - , '<a href="http://wiki.archlinux.org/index.php/AUR_User_Guidelines">' - , '</a>' - , '<a href="http://wiki.archlinux.org/index.php/AUR_Trusted_User_Guidelines">' - , '</a>' +echo __( + 'Welcome to the AUR! Please read the %hAUR User Guidelines%h and %hAUR TU Guidelines%h for more information.', + '<a href="http://wiki.archlinux.org/index.php/AUR_User_Guidelines">', + '</a>', + '<a href="http://wiki.archlinux.org/index.php/AUR_Trusted_User_Guidelines">', + '</a>' ); ?> -<br> +<br /> <?php -print __( 'Contributed PKGBUILDs <b>must</b> conform to the %hArch Packaging Standards%h otherwise they will be deleted!' - , '<a href="http://wiki.archlinux.org/index.php/Arch_Packaging_Standards">' - , '</a>' +echo __( + 'Contributed PKGBUILDs %hmust%h conform to the %hArch Packaging Standards%h otherwise they will be deleted!', + '<b>', '</b>', + '<a href="http://wiki.archlinux.org/index.php/Arch_Packaging_Standards">', + '</a>' ); ?> </p> <p> -<?php print __("Remember to vote for your favourite packages!"); ?> -<br> -<?php print __("The most popular packages will be provided as binary packages in [community]."); ?> +<?php echo __('Remember to vote for your favourite packages!'); ?> +<br /> +<?php echo __('Some packages may be provided as binaries in [community].'); ?> </p> -</td> -</tr> +<table border='0' cellpadding='0' cellspacing='3' width='90%'> <tr> <td class='boxSoft' valign='top'> -<table class="boxSoft"> -<tr> -<th colspan="2" class="boxSoftTitle" style="text-align: right"> -<a href="/rss2.php"><img src="/images/rss.gif"></a> <span class="f3"><?php print __("Recent Updates") ?><span class="f5"></span></span> -</th> -</tr> - -<?php while ($row = mysql_fetch_assoc($newest_packages)): ?> - -<tr> -<td class="boxSoft"> -<span class="f4"><span class="blue"><a href="/packages.php?ID=<?php print intval($row["ID"]); ?>"> -<?php print $row["Name"] . ' ' . $row["Version"]; ?> -</a></span> +<?php updates_table($dbh); ?> </td> -<td class="boxSoft"> - +<td class='boxSoft' valign='top'> <?php -$mod_int = intval($row["ModifiedTS"]); -$sub_int = intval($row["SubmittedTS"]); - -if ($mod_int != 0): - $modstring = gmdate("r", $mod_int); -elseif ($sub_int != 0): - $modstring = '<img src="/images/new.gif"/> ' . gmdate("r", $sub_int); -else: - $modstring = '(unknown)'; -endif; -?> - -<span class="f4"><?php print $modstring; ?></span> -</td> -</tr> +$user = username_from_sid($_COOKIE["AURSID"]); +if (!empty($user)) { + user_table($user, $dbh); + echo '<br />'; +} -<?php endwhile; ?> +general_stats_table($dbh); +?> </td> </tr> </table> -<td class='boxSoft' valign='top'> - -<?php if (!empty($user)): ?> - -<table class='boxSoft'> -<tr> -<th colspan='2' class='boxSoftTitle'> -<span class='f3'><?php print __("My Statistics"); ?></span> -</th> -</tr> -<tr> -<td class='boxSoft'> -<span class='f4'><?php print __("Packages in unsupported"); ?></span> -</td> -<td class='boxSoft'> -<span class='f4'><?php print $maintainer_unsupported_count; ?></span> -</td> -</tr> -<?php if ($atype == 'Trusted User'): ?> - -<tr> -<td class='boxSoft'> -<span class='f4'><?php print __("Packages in [community]"); ?></span> -</td> -<td class='boxSoft'> -<span class='f4'><?php print $maintainer_community_count; ?></span> -</td> -</tr> - -<?php endif; ?> - -<tr> -<td class='boxSoft'> -<span class='f4'><?php print __("Out-of-date"); ?></span> -</td> -<td class='boxSoft'> -<span class='f4'><?php print $flagged_outdated ?></span> -</td> -</tr> -</table> <br /> +<div class="important"><?php +echo __('DISCLAIMER') . ':<br />'; +echo __('Unsupported PKGBUILDs are user produced content. Any use of files is at your own risk.'); +?></div> -<?php endif; ?> - -<table class='boxSoft'> -<tr> -<th colspan='2' class='boxSoftTitle'> -<span class='f3'><?php print __("Statistics") ?></span> -</th> -</tr> -<tr> -<td class='boxSoft'> -<span class='f4'><?php print __("Packages in unsupported"); ?></span> -</td> -<td class='boxSoft'><span class='f4'><?php print $unsupported_count; ?></span></td> -</tr> -<tr> -<td class='boxSoft'> -<span class='f4'><?php print __("Packages in [community]"); ?></span> -</td> -<td class='boxSoft'><span class='f4'><?php print $community_count; ?></span></td> -</tr> -<tr> -<td class='boxSoft'> -<span class='f4'><?php print __("Packages added or updated in the past 7 days"); ?></span> -</td> -<td class='boxSoft'><span class='f4'><?php print $update_count; ?></span></td> -</tr> -<tr> -<td class='boxSoft'> -<span class='blue'><span class='f4'><?php print __("Registered Users"); ?></span></span> -</td> -<td class='boxSoft'><span class='f4'><?php print $user_count; ?></span></td> -</tr> -<tr> -<td class='boxSoft'> -<span class='f4'><?php print __("Trusted Users"); ?></span> -</td> -<td class='boxSoft'><span class='f4'><?php print $tu_count; ?></span></td> -</tr> -</table> -</td> -</tr> -</table> -<br /><span class='important'><?php print __("DISCLAIMER"); ?></span> </div> </div> <?php html_footer(AUR_VERSION); -?> + diff --git a/web/html/packages.php b/web/html/packages.php index 4cfe9c4..91b0e6e 100644 --- a/web/html/packages.php +++ b/web/html/packages.php @@ -22,7 +22,7 @@ if (isset($_GET['ID'])) { $title = __("Packages"); } -html_header($title); # print out the HTML header +html_header($title); # get login privileges # @@ -37,396 +37,37 @@ if (isset($_COOKIE["AURSID"])) { # grab the list of Package IDs to be operated on # isset($_POST["IDs"]) ? $ids = $_POST["IDs"] : $ids = array(); -#isset($_REQUEST["All_IDs"]) ? -# $all_ids = explode(":", $_REQUEST["All_IDs"]) : -# $all_ids = array(); - # determine what button the visitor clicked # if ($_POST['action'] == "do_Flag" || isset($_POST['do_Flag'])) { - if (!$atype) { - print __("You must be logged in before you can flag packages."); - print "<br />\n"; - - } else { - - if (!empty($ids)) { - $dbh = db_connect(); - - # Flag the packages in $ids array - # - $first = 1; - while (list($pid, $v) = each($ids)) { - if ($first) { - $first = 0; - $flag = $pid; - } else { - $flag .= ", ".$pid; - } - } - $q = "UPDATE Packages SET OutOfDate = 1 "; - $q.= "WHERE ID IN (" . $flag . ")"; - db_query($q, $dbh); - - print "<p>\n"; - print __("The selected packages have been flagged out-of-date."); - print "</p>\n"; - - # notification by tardo. - $f_name = username_from_sid($_COOKIE['AURSID']); - $f_email = email_from_sid($_COOKIE['AURSID']); - $f_uid = uid_from_sid($_COOKIE['AURSID']); - $q = "SELECT Packages.Name, Users.Email, Packages.ID "; - $q.= "FROM Packages, Users "; - $q.= "WHERE Packages.ID IN (" . $flag .") "; - $q.= "AND Users.ID = Packages.MaintainerUID "; - $q.= "AND Users.ID != " . $f_uid; - $result = db_query($q, $dbh); - if (mysql_num_rows($result)) { - while ($row = mysql_fetch_assoc($result)) { - # construct email - $body = "Your package " . $row['Name'] . " has been flagged out of date by " . $f_name . ". You may view your package at:\nhttp://aur.archlinux.org/packages.php?do_Details=1&ID=" . $row['ID']; - $body = wordwrap($body, 70); - $headers = "To: ".$row['Email']."\nReply-to: nobody@archlinux.org\nFrom:aur-notify@archlinux.org\nX-Mailer: PHP\nX-MimeOLE: Produced By AUR\n"; - @mail(' ', "AUR Out-of-date Notification for ".$row['Name'], $body, $headers); - } - } - - } else { - print "<p>\n"; - print __("You did not select any packages to flag."); - print "</p>\n"; - } - } - + print "<p>"; + print pkg_flag($atype, $ids, True); + print "</p>"; } elseif ($_POST['action'] == "do_UnFlag" || isset($_POST['do_UnFlag'])) { - if (!$atype) { - print __("You must be logged in before you can unflag packages."); - print "<br />\n"; - - } else { - - if (!empty($ids)) { - $dbh = db_connect(); - - # Un-Flag the packages in $ids array - # - $first = 1; - while (list($pid, $v) = each($ids)) { - if ($first) { - $first = 0; - $unflag = $pid; - } else { - $unflag .= ", ".$pid; - } - } - $q = "UPDATE Packages SET OutOfDate = 0 "; - $q.= "WHERE ID IN (" . $unflag . ")"; - db_query($q, $dbh); - - print "<p>\n"; - print __("The selected packages have been unflagged."); - print "</p>\n"; - } else { - print "<p>\n"; - print __("You did not select any packages to unflag."); - print "</p>\n"; - } - - - } - + print "<p>"; + print pkg_flag($atype, $ids, False); + print "</p>"; } elseif ($_POST['action'] == "do_Disown" || isset($_POST['do_Disown'])) { - if (!$atype) { - print __("You must be logged in before you can disown packages."); - print "<br />\n"; - - } else { - # Disown the packages in $ids array - # - if (!empty($ids)) { - $dbh = db_connect(); - - # Disown the packages in $ids array - # - $first = 1; - while (list($pid, $v) = each($ids)) { - if ($first) { - $first = 0; - $disown = $pid; - } else { - $disown .= ", ".$pid; - } - } - - $field = "MaintainerUID"; - $q = "UPDATE Packages "; - $q.= "SET ".$field." = 0 "; - $q.= "WHERE ID IN (" . $disown . ") "; - # If a user is a TU or dev they can disown any package - if ($atype == "User") { - $q.= "AND ".$field." = ".uid_from_sid($_COOKIE["AURSID"]); - } - db_query($q, $dbh); - - print "<p>\n"; - print __("The selected packages have been disowned."); - print "</p>\n"; - } else { - print "<p>\n"; - print __("You did not select any packages to disown."); - print "</p>\n"; - } - - - } - - + print "<p>"; + print pkg_adopt($atype, $ids, False); + print "</p>"; } elseif ($_POST['action'] == "do_Delete" || isset($_POST['do_Delete'])) { - if (!$atype) { - print __("You must be logged in before you can disown packages."); - print "<br />\n"; - } else { - # Delete the packages in $ids array (but only if they are Unsupported) - # - if (!empty($ids)) { - $dbh = db_connect(); - - # Delete the packages in $ids array - # - $first = 1; - while (list($pid, $v) = each($ids)) { - if ($first) { - $first = 0; - $delete = $pid; - } else { - $delete .= ", ".$pid; - } - } - - $field = "MaintainerUID"; - - # Only grab Unsupported packages that "we" own or are not owned at all - # - $ids_to_delete = array(); - $q = "SELECT Packages.ID FROM Packages, PackageLocations "; - $q.= "WHERE Packages.ID IN (" . $delete . ") "; - $q.= "AND Packages.LocationID = PackageLocations.ID "; - $q.= "AND PackageLocations.Location = 'unsupported' "; - # If they're a TU or dev, can always delete, otherwise check ownership - # - if ($atype == "Trusted User" || $atype == "Developer") { - $result = db_query($q, $dbh); - } - if ($result != Null && mysql_num_rows($result) > 0) { - while ($row = mysql_fetch_assoc($result)) { - $ids_to_delete[] = $row['ID']; - } - } - if (!empty($ids_to_delete)) { - # These are the packages that are safe to delete - # - foreach ($ids_to_delete as $id) { - # delete from PackageVotes - $q = "DELETE FROM PackageVotes WHERE PackageID = " . $id; - $result = db_query($q, $dbh); - - # delete from PackageDepends - $q = "DELETE FROM PackageDepends WHERE PackageID = " . $id; - $result = db_query($q, $dbh); - - # delete from PackageSources - $q = "DELETE FROM PackageSources WHERE PackageID = " . $id; - $result = db_query($q, $dbh); - - # delete from PackageComments - $q = "DELETE FROM PackageComments WHERE PackageID = " . $id; - $result = db_query($q, $dbh); - - # delete from Packages - $q = "DELETE FROM Packages WHERE ID = " . $id; - $result = db_query($q, $dbh); - - # delete from CommentNotify - $q = "DELETE FROM CommentNotify WHERE PkgID = " . $id; - $result = db_query($q, $dbh); - - # Print the success message - print "<p>\n"; - print __("The selected packages have been deleted."); - print "</p>\n"; - } - } else { - print "<p>\n"; - print __("None of the selected packages could be deleted."); - print "</p>\n"; - } # end if (!empty($ids_to_delete)) - } else { - print "<p>\n"; - print __("You did not select any packages to delete."); - print "</p>\n"; - } # end if (!empty($ids)) - } # end if (!atype) - + print "<p>"; + print pkg_delete($atype, $ids, False); + print "</p>"; } elseif ($_POST['action'] == "do_Adopt" || isset($_POST['do_Adopt'])) { - if (!$atype) { - print __("You must be logged in before you can adopt packages."); - print "<br />\n"; - - } else { - # Adopt the packages in $ids array - # - if (!empty($ids)) { - $dbh = db_connect(); - - # Adopt the packages in $ids array - # - $first = 1; - while (list($pid, $v) = each($ids)) { - if ($first) { - $first = 0; - $adopt = $pid; - } else { - $adopt .= ", ".$pid; - } - } - - $field = "MaintainerUID"; - # NOTE: Only "orphaned" packages can be adopted at a particular - # user class (TU/Dev or User). - # - $q = "UPDATE Packages "; - $q.= "SET ".$field." = ".uid_from_sid($_COOKIE["AURSID"])." "; - $q.= "WHERE ID IN (" . $adopt . ") "; - if ($atype == "User") - { - # Regular users may only adopt orphan packages from unsupported - # FIXME: We assume that LocationID for unsupported is "2" - $q.= "AND ".$field." = 0"; - $q.= " AND LocationID = 2"; - } - db_query($q, $dbh); - - print "<p>\n"; - print __("The selected packages have been adopted."); - print "</p>\n"; - } else { - print "<p>\n"; - print __("You did not select any packages to adopt."); - print "</p>\n"; - } - } - - + print "<p>"; + print pkg_adopt($atype, $ids, True); + print "</p>"; } elseif ($_POST['action'] == "do_Vote" || isset($_POST['do_Vote'])) { - if (!$atype) { - print __("You must be logged in before you can vote for packages."); - print "<br />\n"; - - } else { - # vote on the packages in $ids array. - # - if (!empty($ids)) { - $dbh = db_connect(); - $my_votes = pkgvotes_from_sid($_COOKIE["AURSID"]); - $uid = uid_from_sid($_COOKIE["AURSID"]); - # $vote_ids will contain the string of Package.IDs that - # the visitor hasn't voted for already - # - $first = 1; - while (list($pid, $v) = each($ids)) { - if (!isset($my_votes[$pid])) { - # cast a vote for this package - # - if ($first) { - $first = 0; - $vote_ids = $pid; - $vote_clauses = "(".$uid.", ".$pid.")"; - } else { - $vote_ids .= ", ".$pid; - $vote_clauses .= ", (".$uid.", ".$pid.")"; - } - } - } - # only vote for packages the user hasn't already voted for - # - $q = "UPDATE Packages SET NumVotes = NumVotes + 1 "; - $q.= "WHERE ID IN (".$vote_ids.")"; - db_query($q, $dbh); - - $q = "INSERT INTO PackageVotes (UsersID, PackageID) VALUES "; - $q.= $vote_clauses; - db_query($q, $dbh); - - # Update the LastVoted field for this user - # - $q = "UPDATE Users SET LastVoted = UNIX_TIMESTAMP() "; - $q.= "WHERE ID = ".$uid; - db_query($q, $dbh); - - print "<p>\n"; - print __("Your votes have been cast for the selected packages."); - print "</p>\n"; - - } else { - print "<p>\n"; - print __("You did not select any packages to vote for."); - print "</p>\n"; - } - } - - + print "<p>"; + print pkg_vote($atype, $ids, True); + print "</p>"; } elseif ($_POST['action'] == "do_UnVote" || isset($_POST['do_UnVote'])) { - if (!$atype) { - print __("You must be logged in before you can un-vote for packages."); - print "<br />\n"; - - } else { - # un-vote on the packages in $ids array. - # - if (!empty($ids)) { - $dbh = db_connect(); - $my_votes = pkgvotes_from_sid($_COOKIE["AURSID"]); - $uid = uid_from_sid($_COOKIE["AURSID"]); - # $unvote_ids will contain the string of Package.IDs that - # the visitor has voted for and wants to unvote. - # - $first = 1; - while (list($pid, $v) = each($ids)) { - if (isset($my_votes[$pid])) { - # cast a un-vote for this package - # - if ($first) { - $first = 0; - $unvote_ids = $pid; - } else { - $unvote_ids .= ", ".$pid; - } - } - } - # only un-vote for packages the user has already voted for - # - $q = "UPDATE Packages SET NumVotes = NumVotes - 1 "; - $q.= "WHERE ID IN (".$unvote_ids.")"; - db_query($q, $dbh); - - $q = "DELETE FROM PackageVotes WHERE UsersID = ".$uid." "; - $q.= "AND PackageID IN (".$unvote_ids.")"; - db_query($q, $dbh); - - print "<p>\n"; - print __("Your votes have been removed from the selected packages."); - print "</p>\n"; - - } else { - print "<p>\n"; - print __("You did not select any packages to un-vote for."); - print "</p>\n"; - } - } - - + print "<p>"; + print pkg_vote($atype, $ids, False); + print "</p>"; } elseif (isset($_GET["ID"])) { if (!intval($_GET["ID"])) { diff --git a/web/html/pkgedit.php b/web/html/pkgedit.php index 610113a..974f14b 100644 --- a/web/html/pkgedit.php +++ b/web/html/pkgedit.php @@ -91,7 +91,7 @@ if ($_REQUEST["add_Comment"]) { #TODO: native language emails for users, based on their prefs # Simply making these strings translatable won't work, users would be # getting emails in the language that the user who posted the comment was in - $body = "A comment has been added to ".$row['Name'].", you may view it at:\nhttp://aur.archlinux.org/packages.php?ID=".$_REQUEST["ID"]."\n\n\n---\nYou received this e-mail because you chose to recieve notifications of new comments on this package, if you no longer wish to recieve notifications about this package, please go the the above package page and click the UnNotify button."; + $body = "A comment has been added to ".$row['Name']." by " . username_from_sid($_COOKIE["AURSID"]) . ", you may view it at:\nhttp://aur.archlinux.org/packages.php?ID=".$_REQUEST["ID"]."\n\n\"" . $_POST['comment'] . "\"\n\n---\nYou received this e-mail because you chose to receive notifications of new comments on this package, if you no longer wish to recieve notifications about this package, please go the the above package page and click the UnNotify button."; $body = wordwrap($body, 70); $bcc = implode(', ', $bcc); $headers = "Bcc: $bcc\nReply-to: nobody@archlinux.org\nFrom:aur-notify@archlinux.org\nX-Mailer: PHP\nX-MimeOLE: Produced By AUR\n"; diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php index abd6614..c38e224 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -12,25 +12,14 @@ include("pkgfuncs.inc"); # package functions set_lang(); # this sets up the visitor's language check_sid(); # see if they're still logged in -html_header("Submit"); - -?> - -<div class="pgbox"> - <div class="pgboxtitle"> - <span class="f3"><?php print __("Submit"); ?></span> - </div> - <div class="pgboxbody"> - -<?php if ($_COOKIE["AURSID"]): - + # Track upload errors $error = ""; if ($_REQUEST["pkgsubmit"]) { - + # Before processing, make sure we even have a file if ($_FILES['pfile']['size'] == 0){ $error = __("Error - No file uploaded"); @@ -48,30 +37,30 @@ if ($_COOKIE["AURSID"]): $error = __("Could not change directory to %s.", array($tempdir)); } else { - if ($_FILES['pfile']['name'] == "PKGBUILD") { - move_uploaded_file($_FILES['pfile']['tmp_name'], $tempdir . "/PKGBUILD"); - } else { - $tar = new Archive_Tar($_FILES['pfile']['tmp_name']); - $extract = $tar->extract(); - - if (!$extract) { - $error = __("Unknown file format for uploaded file."); - } - } + if ($_FILES['pfile']['name'] == "PKGBUILD") { + move_uploaded_file($_FILES['pfile']['tmp_name'], $tempdir . "/PKGBUILD"); + } else { + $tar = new Archive_Tar($_FILES['pfile']['tmp_name']); + $extract = $tar->extract(); + + if (!$extract) { + $error = __("Unknown file format for uploaded file."); + } + } } } } # Find the PKGBUILD if (!$error) { - $pkgbuild = File_Find::search('PKGBUILD', $tempdir); - - if (count($pkgbuild)) { - $pkgbuild = $pkgbuild[0]; - $pkg_dir = dirname($pkgbuild); - } else { - $error = __("Error trying to unpack upload - PKGBUILD does not exist."); - } + $pkgbuild = File_Find::search('PKGBUILD', $tempdir); + + if (count($pkgbuild)) { + $pkgbuild = $pkgbuild[0]; + $pkg_dir = dirname($pkgbuild); + } else { + $error = __("Error trying to unpack upload - PKGBUILD does not exist."); + } } # if no error, get list of directory contents and process PKGBUILD @@ -121,7 +110,7 @@ if ($_COOKIE["AURSID"]): fclose($fp); # Now process the lines and put any var=val lines into the - # 'pkgbuild' array. Also check to make sure it has the build() + # 'pkgbuild' array. Also check to make sure it has the build() # function. # $seen_build_function = 0; @@ -136,13 +125,13 @@ if ($_COOKIE["AURSID"]): $lparts[1]{strlen($lparts[1])-1} == '"') { $pkgbuild[$lparts[0]] = substr($lparts[1], 1, -1); } - elseif + elseif ($lparts[1]{0} == "'" && $lparts[1]{strlen($lparts[1])-1} == "'") { $pkgbuild[$lparts[0]] = substr($lparts[1], 1, -1); } else { $pkgbuild[$lparts[0]] = $lparts[1]; - } + } } else { $pkgbuild[$lparts[0]] = str_replace(array("(",")","\"","'"), "", $lparts[1]); @@ -163,20 +152,20 @@ if ($_COOKIE["AURSID"]): if (!$seen_build_function) { $error = __("Missing build function in PKGBUILD."); } - + $req_vars = array("md5sums", "source", "url", "pkgdesc", "license", "pkgrel", "pkgver", "arch", "pkgname"); foreach ($req_vars as $var) { - if (!array_key_exists($var, $pkgbuild)) { - $error = __("Missing " . $var . " variable in PKGBUILD."); - } - } + if (!array_key_exists($var, $pkgbuild)) { + $error = __("Missing " . $var . " variable in PKGBUILD."); + } + } } # TODO This is where other additional error checking can be - # performed. Examples: #md5sums == #sources?, md5sums of any + # performed. Examples: #md5sums == #sources?, md5sums of any # included files match?, install scriptlet file exists? # - + # Check for http:// or other protocol in url # if (!$error) { @@ -185,7 +174,7 @@ if ($_COOKIE["AURSID"]): $error = __("Package URL is missing a protocol (ie. http:// ,ftp://)"); } } - + # Now, run through the pkgbuild array and do any $pkgname/$pkgver # substituions. # @@ -208,9 +197,9 @@ if ($_COOKIE["AURSID"]): $pkg_name = str_replace("'", "", $pkgbuild['pkgname']); $pkg_name = escapeshellarg($pkg_name); $pkg_name = str_replace("'", "", $pkg_name); - + $presult = preg_match("/^[a-z0-9][a-z0-9\.+_-]*$/", $pkg_name); - + if (!$presult) { $error = __("Invalid name: only lowercase letters are allowed."); } @@ -226,18 +215,14 @@ if ($_COOKIE["AURSID"]): } if (!@mkdir(INCOMING_DIR . $pkg_name)) { - $error = __( "Could not create directory %s." - , INCOMING_DIR . $pkg_name - ); + $error = __( "Could not create directory %s.", + INCOMING_DIR . $pkg_name); } - rename($pkg_dir, INCOMING_DIR . $pkg_name . "/" . $pkg_name); + rename($pkg_dir, INCOMING_DIR . $pkg_name . "/" . $pkg_name); } else { - $error = __( "You are not allowed to overwrite the %h%s%h package." - , "<b>" - , $pkg_name - , "</b>" - ); + $error = __( "You are not allowed to overwrite the %h%s%h package.", + "<b>", $pkg_name, "</b>"); } } @@ -248,16 +233,16 @@ if ($_COOKIE["AURSID"]): array(INCOMING_DIR . $pkg_name)); } } - + if (!$error) { - $tar = new Archive_Tar($pkg_name . '.tar.gz'); - $create = $tar->create(array($pkg_name)); - + $tar = new Archive_Tar($pkg_name . '.tar.gz'); + $create = $tar->create(array($pkg_name)); + if (!$create) { $error = __("Could not re-tar"); } } - + # Whether it failed or not we can clean this out if (file_exists($tempdir)) { rm_rf($tempdir); @@ -265,13 +250,13 @@ if ($_COOKIE["AURSID"]): # Update the backend database if (!$error) { - + $dbh = db_connect(); - + # This is an overwrite of an existing package, the database ID - # needs to be preserved so that any votes are retained. However, + # needs to be preserved so that any votes are retained. However, # PackageDepends and PackageSources can be purged. - + $q = "SELECT * FROM Packages WHERE Name = '" . mysql_real_escape_string($new_pkgbuild['pkgname']) . "'"; $result = db_query($q, $dbh); $pdata = mysql_fetch_assoc($result); @@ -286,53 +271,52 @@ if ($_COOKIE["AURSID"]): # If the package was a dummy, undummy it if ($pdata['DummyPkg']) { - $q = sprintf( "UPDATE Packages SET DummyPkg = 0, SubmitterUID = %d, MaintainerUID = %d, SubmittedTS = UNIX_TIMESTAMP() WHERE ID = %d" - , uid_from_sid($_COOKIE["AURSID"]) - , uid_from_sid($_COOKIE["AURSID"]) - , $pdata["ID"] - ); + $q = sprintf( "UPDATE Packages SET DummyPkg = 0, SubmitterUID = %d, MaintainerUID = %d, SubmittedTS = UNIX_TIMESTAMP() WHERE ID = %d", + uid_from_sid($_COOKIE["AURSID"]), + uid_from_sid($_COOKIE["AURSID"]), + $pdata["ID"]); - db_query($q, $dbh); + db_query($q, $dbh); } - + # If a new category was chosen, change it to that if ($_POST['category'] > 1) { - $q = sprintf( "UPDATE Packages SET CategoryID = %d WHERE ID = %d" - , mysql_real_escape_string($_REQUEST['category']) - , $pdata["ID"] - ); - - db_query($q, $dbh); - } - + $q = sprintf( "UPDATE Packages SET CategoryID = %d WHERE ID = %d", + mysql_real_escape_string($_REQUEST['category']), + $pdata["ID"]); + + db_query($q, $dbh); + } + # Update package data - $q = sprintf( "UPDATE Packages SET ModifiedTS = UNIX_TIMESTAMP(), Name = '%s', Version = '%s-%s', License = '%s', Description = '%s', URL = '%s', LocationID = 2, FSPath = '%s', URLPath = '%s', OutOfDate = 0 WHERE ID = %d" - , mysql_real_escape_string($new_pkgbuild['pkgname']) - , mysql_real_escape_string($new_pkgbuild['pkgver']) - , mysql_real_escape_string($new_pkgbuild['pkgrel']) - , mysql_real_escape_string($new_pkgbuild['license']) - , mysql_real_escape_string($new_pkgbuild['pkgdesc']) - , mysql_real_escape_string($new_pkgbuild['url']) - , mysql_real_escape_string(INCOMING_DIR . $pkg_name . "/" . $pkg_name . ".tar.gz") - , mysql_real_escape_string(URL_DIR . $pkg_name . "/" . $pkg_name . ".tar.gz") - , $pdata["ID"] - ); - + $q = sprintf("UPDATE Packages SET ModifiedTS = UNIX_TIMESTAMP(), Name = '%s', Version = '%s-%s', License = '%s', Description = '%s', URL = '%s', LocationID = 2, FSPath = '%s', URLPath = '%s', OutOfDate = 0 WHERE ID = %d", + mysql_real_escape_string($new_pkgbuild['pkgname']), + mysql_real_escape_string($new_pkgbuild['pkgver']), + mysql_real_escape_string($new_pkgbuild['pkgrel']), + mysql_real_escape_string($new_pkgbuild['license']), + mysql_real_escape_string($new_pkgbuild['pkgdesc']), + mysql_real_escape_string($new_pkgbuild['url']), + mysql_real_escape_string(INCOMING_DIR . $pkg_name . "/" . $pkg_name . ".tar.gz"), + mysql_real_escape_string(URL_DIR . $pkg_name . "/" . $pkg_name . ".tar.gz"), + $pdata["ID"]); + db_query($q, $dbh); # Update package depends $depends = explode(" ", $new_pkgbuild['depends']); - foreach ($depends as $dep) { + foreach ($depends as $dep) { $q = "INSERT INTO PackageDepends (PackageID, DepPkgID, DepCondition) VALUES ("; $deppkgname = preg_replace("/[<>]?=.*/", "", $dep); - $depcondition = str_replace($deppkgname, "", $dep); - - if ($deppkgname == "#") { break; } - + $depcondition = str_replace($deppkgname, "", $dep); + + if ($deppkgname == "#") { + break; + } + $deppkgid = create_dummy($deppkgname, $_COOKIE['AURSID']); - $q .= $pdata["ID"] . ", " . $deppkgid . ", '" . mysql_real_escape_string($depcondition) . "')"; + $q .= $pdata["ID"] . ", " . $deppkgid . ", '" . mysql_real_escape_string($depcondition) . "')"; - db_query($q, $dbh); + db_query($q, $dbh); } # Insert sources @@ -341,24 +325,25 @@ if ($_COOKIE["AURSID"]): $q = "INSERT INTO PackageSources (PackageID, Source) VALUES ("; $q .= $pdata["ID"] . ", '" . mysql_real_escape_string($src) . "')"; db_query($q, $dbh); - } - + } + + header('Location: packages.php?ID=' . $pdata['ID']); + } else { - + # This is a brand new package - $q = sprintf( "INSERT INTO Packages (Name, License, Version, CategoryID, Description, URL, LocationID, SubmittedTS, SubmitterUID, MaintainerUID, FSPath, URLPath) VALUES ('%s', '%s', '%s-%s', %d, '%s', '%s', 2, UNIX_TIMESTAMP(), %d, %d, '%s', '%s')" - , mysql_real_escape_string($new_pkgbuild['pkgname']) - , mysql_real_escape_string($new_pkgbuild['license']) - , mysql_real_escape_string($new_pkgbuild['pkgver']) - , mysql_real_escape_string($new_pkgbuild['pkgrel']) - , mysql_real_escape_string($_REQUEST['category']) - , mysql_real_escape_string($new_pkgbuild['pkgdesc']) - , mysql_real_escape_string($new_pkgbuild['url']) - , uid_from_sid($_COOKIE["AURSID"]) - , uid_from_sid($_COOKIE["AURSID"]) - , mysql_real_escape_string(INCOMING_DIR . $pkg_name . "/" . $pkg_name . ".tar.gz") - , mysql_real_escape_string(URL_DIR . $pkg_name . "/" . $pkg_name . ".tar.gz") - ); + $q = sprintf("INSERT INTO Packages (Name, License, Version, CategoryID, Description, URL, LocationID, SubmittedTS, SubmitterUID, MaintainerUID, FSPath, URLPath) VALUES ('%s', '%s', '%s-%s', %d, '%s', '%s', 2, UNIX_TIMESTAMP(), %d, %d, '%s', '%s')", + mysql_real_escape_string($new_pkgbuild['pkgname']), + mysql_real_escape_string($new_pkgbuild['license']), + mysql_real_escape_string($new_pkgbuild['pkgver']), + mysql_real_escape_string($new_pkgbuild['pkgrel']), + mysql_real_escape_string($_REQUEST['category']), + mysql_real_escape_string($new_pkgbuild['pkgdesc']), + mysql_real_escape_string($new_pkgbuild['url']), + uid_from_sid($_COOKIE["AURSID"]), + uid_from_sid($_COOKIE["AURSID"]), + mysql_real_escape_string(INCOMING_DIR . $pkg_name . "/" . $pkg_name . ".tar.gz"), + mysql_real_escape_string(URL_DIR . $pkg_name . "/" . $pkg_name . ".tar.gz")); $result = db_query($q, $dbh); $packageID = mysql_insert_id($dbh); @@ -369,12 +354,14 @@ if ($_COOKIE["AURSID"]): $q = "INSERT INTO PackageDepends (PackageID, DepPkgID, DepCondition) VALUES ("; $deppkgname = preg_replace("/[<>]?=.*/", "", $dep); $depcondition = str_replace($deppkgname, "", $dep); - - if ($deppkgname == "#") { break; } - - $deppkgid = create_dummy($deppkgname, $_COOKIE['AURSID']); - $q .= $packageID . ", " . $deppkgid . ", '" . mysql_real_escape_string($depcondition) . "')"; - + + if ($deppkgname == "#") { + break; + } + + $deppkgid = create_dummy($deppkgname, $_COOKIE['AURSID']); + $q .= $packageID . ", " . $deppkgid . ", '" . mysql_real_escape_string($depcondition) . "')"; + db_query($q, $dbh); } @@ -384,15 +371,29 @@ if ($_COOKIE["AURSID"]): $q = "INSERT INTO PackageSources (PackageID, Source) VALUES ("; $q .= $packageID . ", '" . mysql_real_escape_string($src) . "')"; db_query($q, $dbh); - } - + } + + header('Location: packages.php?ID=' . $packageID); + } } chdir($_SERVER['DOCUMENT_ROOT']); } +# Logic over, let's do some output + +html_header("Submit"); +?> + +<div class="pgbox"> + <div class="pgboxtitle"> + <span class="f3"><?php print __("Submit"); ?></span> + </div> + <div class="pgboxbody"> + +<?php if (!$_REQUEST["pkgsubmit"] || $error): # User is not uploading, or there were errors uploading - then # give the visitor the default upload form @@ -405,15 +406,7 @@ if ($_COOKIE["AURSID"]): <?php endif; - if ($warning): -?> - -<br><span class='error'><?php print $warning; ?></span><br /> -<br /> -<?php - endif; - $pkg_categories = pkgCategories(); $pkg_locations = pkgLocations(); ?> @@ -461,17 +454,6 @@ if ($_COOKIE["AURSID"]): <?php endif; - else: - print __("Package upload successful."); - - if ($warning): -?> - -<span class='warning'><?php print $warning; ?></span><br /> -<br /> - -<?php - endif; endif; else: # Visitor is not logged in @@ -479,15 +461,14 @@ else: ?> <br /> - + <?php endif; ?> - </div> + </div> </div> <?php html_footer(AUR_VERSION); -?> diff --git a/web/html/template.php b/web/html/template.php deleted file mode 100644 index 11e05e0..0000000 --- a/web/html/template.php +++ /dev/null @@ -1,20 +0,0 @@ -<?php - -set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../lang'); - -include("aur.inc"); # access AUR common functions -include("template_po.inc"); # use some form of this for i18n support -set_lang(); # this sets up the visitor's language -check_sid(); # see if they're still logged in -html_header(); # print out the HTML header - - -# Any text you print out to the visitor, use the __() function -# for i18n support. See 'testpo.php' for more details. -# -print __("Hi, this is worth reading!")."<br />\n"; - - -html_footer(AUR_VERSION); - -?> diff --git a/web/html/testpo.php b/web/html/testpo.php deleted file mode 100644 index a8a6337..0000000 --- a/web/html/testpo.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php - -set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../lang'); - -# This is a sample script to demonstrate how the AUR will -# handle i18n. Note: When the PHP script is finished, and -# has the proper include file (see below), and the __() -# function has been used (see below), use the web/utils/genpopo -# script to parse the PHP script and pull out the text -# that requires translation and puts the mapping into the -# include file. -# - -# Each AUR PHP script that requires i18n support, needs to -# define an 'xxx_po.inc' file where the i18n mapping will -# reside. -# -include("test_po.inc"); - - -# Use the __() function to identify text that requires -# translation to other languages. The examples below -# show how to use %-substitution. -# -print "<html><body bgcolor='white'>\n"; - -print "<p>\n"; -print __("Select your language here: %h%s%h, %h%s%h, %h%s%h, %h%s%h.", - array("<a href='".$_SERVER['PHP_SELF']."?LANG=en'>","English","</a>", - "<a href='".$_SERVER['PHP_SELF']."?LANG=es'>","Español","</a>", - "<a href='".$_SERVER['PHP_SELF']."?LANG=de'>","Deutsch","</a>", - "<a href='".$_SERVER['PHP_SELF']."?LANG=fr'>","Français","</a>")); -print "</p>\n"; - -print "<p>\n"; -print __("My current language tag is: '%s'.", array($LANG)); -print "</p>\n"; - -print "<ul>\n"; -print __("Hello, world!")."<br />\n"; -print __("Hello, again!")."<br />\n"; -print "</ul>\n"; -print "</body>\n</html>"; - -?> diff --git a/web/html/tu.php b/web/html/tu.php index 524e14d..67ac3f2 100644 --- a/web/html/tu.php +++ b/web/html/tu.php @@ -2,50 +2,36 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../lang'); -include("pkgfuncs_po.inc"); +include("tu_po.inc"); include("aur.inc"); set_lang(); check_sid(); html_header(); -# get login privileges -# +# Default votes per page +$pp = 5; + +$atype = ""; if (isset($_COOKIE["AURSID"])) { - # Only logged in users can do stuff - # $atype = account_from_sid($_COOKIE["AURSID"]); -} else { - $atype = ""; } if ($atype == "Trusted User" OR $atype == "Developer") { - # Show the TU interface - # - - # Temp value for results per page $pp = 5; - if (isset($_REQUEST['id'])) { - # Show application details - # depending on action and time frame will show either - # sponsor button, comments and vote buttons - # - - if (intval($_REQUEST['id'])) { + if (isset($_GET['id'])) { + if (is_numeric($_GET['id'])) { $q = "SELECT * FROM TU_VoteInfo "; - $q.= "WHERE ID = " . $_REQUEST['id']; + $q.= "WHERE ID = " . $_GET['id']; $dbh = db_connect(); $results = db_query($q, $dbh); $row = mysql_fetch_assoc($results); if (empty($row)) { - print "Could not retrieve proposal details.\n"; + print __("Could not retrieve proposal details."); } else { - # Print out application details, thanks again AUR - # - $isrunning = $row['End'] > time() ? 1 : 0; $qvoted = "SELECT * FROM TU_Votes WHERE "; @@ -53,30 +39,27 @@ if ($atype == "Trusted User" OR $atype == "Developer") { $qvoted.= "UserID = " . uid_from_sid($_COOKIE["AURSID"]); $hasvoted = mysql_num_rows(db_query($qvoted, $dbh)); - # Can this person vote? - # - $canvote = 1; // we assume they can - $errorvote = ""; // error message to give + $canvote = 1; + $errorvote = ""; if ($isrunning == 0) { $canvote = 0; - $errorvote = "Voting is closed for this proposal."; + $errorvote = __("Voting is closed for this proposal."); } else if ($row['User'] == username_from_sid($_COOKIE["AURSID"])) { $canvote = 0; - $errorvote = "You cannot vote in an proposal regarding you."; + $errorvote = __("You cannot vote in an proposal about you."); } else if ($hasvoted != 0) { $canvote = 0; - $errorvote = "You've already voted in this proposal."; + $errorvote = __("You've already voted in this proposal."); } - # have to put this here so results are correct immediately after voting if ($canvote == 1) { if (isset($_POST['doVote'])) { if (isset($_POST['voteYes'])) { - $myvote = "Yes"; + $myvote = __("Yes"); } else if (isset($_POST['voteNo'])) { - $myvote = "No"; + $myvote = __("No"); } else if (isset($_POST['voteAbstain'])) { - $myvote = "Abstain"; + $myvote = __("Abstain"); } $qvote = "UPDATE TU_VoteInfo SET " . $myvote . " = " . ($row[$myvote] + 1) . " WHERE ID = " . $row['ID']; @@ -87,7 +70,7 @@ if ($atype == "Trusted User" OR $atype == "Developer") { # Can't vote anymore # $canvote = 0; - $errorvote = "You've already voted for this proposal."; + $errorvote = __("You've already voted for this proposal."); # Update if they voted $hasvoted = mysql_num_rows(db_query($qvoted, $dbh)); @@ -95,357 +78,76 @@ if ($atype == "Trusted User" OR $atype == "Developer") { $row = mysql_fetch_assoc($results); } } - - # I think I understand why MVC is good for this stuff.. - echo "<div class=\"pgbox\">\n"; - echo " <div class=\"pgboxtitle\"><span class=\"f3\">Proposal Details</span></div>\n"; - echo " <div class=\"pgboxbody\">\n"; - - if ($isrunning == 1) { - print "<div style='text-align: center; font-weight: bold; color: red'>This vote is still running.</div>"; - print "<br />"; - } - - print "User: <b>"; - - if (!empty($row['User'])) { - print "<a href='packages.php?K=" . $row['User'] . "&SeB=m'>" . $row['User'] . "</a>"; - } else { - print "N/A"; - } - - print "</b><br />\n"; - - print "Submitted: <b>" . gmdate("r", $row['Submitted']) . "</b> by "; - print "<b>" . username_from_id($row['SubmitterID']) . "</b><br />\n"; - - if ($isrunning == 0) { - print "Ended: "; - } else { - print "Ends: "; - } - print "<b>" . gmdate("r", $row['End']) . "</b><br />\n"; - - print "<br />\n"; - - $row['Agenda'] = htmlentities($row['Agenda']); - # str_replace seems better than <pre> because it still maintains word wrapping - print str_replace("\n", "<br />\n", $row['Agenda']); - - print "<br />\n"; - print "<br />\n"; - - print "<center>\n"; - print "<table cellspacing='3' class='boxSoft' style='width: 50%'>\n"; - print "</tr>\n"; - print "<tr>\n"; - print " <td class='boxSoft'>\n"; - print "<table width='100%' cellspacing='0' cellpadding='2'>\n"; - - print "<tr>\n"; - print " <th style='border-bottom: #666 1px solid; vertical-align:"; - print " bottom'><span class='f2'>"; - print "Yes"; - print "</span></th>\n"; - print " <th style='border-bottom: #666 1px solid; vertical-align:"; - print " bottom'><span class='f2'>"; - print "No"; - print "</span></th>\n"; - print " <th style='border-bottom: #666 1px solid; vertical-align:"; - print " bottom'><span class='f2'>"; - print "Abstain"; - print "</span></th>\n"; - print " <th style='border-bottom: #666 1px solid; vertical-align:"; - print " bottom'><span class='f2'>"; - print "Total"; - print "</span></th>\n"; - print " <th style='border-bottom: #666 1px solid; vertical-align:"; - print " bottom'><span class='f2'>"; - print "Voted?"; - print "</span></th>\n"; - print "</tr>\n"; - - $c = "data1"; - - print "<tr>\n"; - print " <td class='".$c."'><span class='f5'><span class='blue'>"; - print $row['Yes']; - print "</span></span></td>\n"; - print " <td class='".$c."'><span class='f5'><span class='blue'>"; - print $row['No']; - print "</span></span></td>\n"; - print " <td class='".$c."'><span class='f5'><span class='blue'>"; - print $row['Abstain']; - print "</span></span></td>\n"; - print " <td class='".$c."'><span class='f5'><span class='blue'>"; - print ($row['Yes'] + $row['No'] + $row['Abstain']); - print "</span></span></td>\n"; - print " <td class='".$c."'><span class='f5'><span class='blue'>"; - - if ($hasvoted == 0) { - print "<span style='color: red; font-weight: bold'>No</span>"; - } else { - print "<span style='color: green; font-weight: bold'>Yes</span>"; - } - - print "</span></span></td>\n"; - print "</tr>\n"; - - print "</table>\n"; - print "</table>\n"; - - echo "</div></div>\n"; - - # Actions, vote buttons - # - print "<br />\n"; - print "<div class='pgbox'>\n"; - print "<div class='pgboxtitle'><span class='f3'>Vote Actions</span></div>\n"; - print "<div class='pgboxbody'>\n"; - - if ($canvote == 1) { - print "<center><form action='tu.php?id=" . $row['ID'] . "' method='post'>\n"; - print "<input type='submit' class='button' name='voteYes' value='Yes'>\n"; - print "<input type='submit' class='button' name='voteNo' value='No'>\n"; - print "<input type='submit' class='button' name='voteAbstain' value='Abstain'>\n"; - print "<input type='hidden' name='doVote' value='1'>\n"; - print "</form></center>\n"; - } else { - print "<center>$errorvote</center>"; - } - - print "</div></div>\n"; - print "<br /><center><a href='tu.php'>Back</a></center>\n"; - + include("tu_details.php"); } - } else { - print "Vote ID not valid.\n"; + print __("Vote ID not valid."); } } else { - # page listing applications being discussed, voted on and all those finished - # - - # I guess there should be a function since I use this a few times - function gen_results($offset, $limit, $sort, $by, $type="normal") { - - $dbh = db_connect(); - - if (!empty($offset) AND is_numeric($offset)) { - if ($offset >= 1) { - $off = $offset; - } else { - $off = 0; - } - } else { - $off = 0; - } - - $q = "SELECT * FROM TU_VoteInfo"; - - if ($type == "new") { - $q.= " WHERE End > " . time(); - $application = "Current Votes"; - } else { - $application = "All Votes"; - } - - $order = ($by == 'down') ? 'DESC' : 'ASC'; - - # not much to sort, I'm unsure how to sort by username - # when we only store the userid, someone come up with a nifty - # way to do this - # - switch ($sort) { - case 'sub': - $q.= " ORDER BY Submitted $order"; - break; - default: - $q.= " ORDER BY Submitted $order"; - break; - } - - if ($limit != 0) { - $q.= " LIMIT " . $off . ", ". $limit; - } - - $result = db_query($q, $dbh); - - if ($by == "down") { - $by_next = "up"; - } else { - $by_next = "down"; - } - - print "<center>\n"; - print "<table cellspacing='3' class='boxSoft'>\n"; - print "<tr>\n"; - print " <td class='boxSoftTitle' align='right'>\n"; - print " <span class='f3'>$application</span>\n"; - print " </td>\n"; - print "</tr>\n"; - print "<tr>\n"; - print " <td class='boxSoft'>\n"; - print "<table width='100%' cellspacing='0' cellpadding='2'>\n"; - - print "<tr>\n"; - print " <th style='border-bottom: #666 1px solid; vertical-align:"; - print " bottom'><span class='f2'>"; - print "Proposal"; - print "</span></th>\n"; - print " <th style='border-bottom: #666 1px solid; vertical-align:"; - print " bottom'><span class='f2'>"; - print "<a href='?off=$off&sort=sub&by=$by_next'>Start</a>"; - print "</span></th>\n"; - print " <th style='border-bottom: #666 1px solid; vertical-align:"; - print " bottom'><span class='f2'>"; - print "End"; - print "</span></th>\n"; - print " <th style='border-bottom: #666 1px solid; vertical-align:"; - print " bottom'><span class='f2'>"; - print "User"; - print "</span></th>\n"; - print " <th style='border-bottom: #666 1px solid; vertical-align:"; - print " bottom'><span class='f2'>"; - print "Yes"; - print "</span></th>\n"; - print " <th style='border-bottom: #666 1px solid; vertical-align:"; - print " bottom'><span class='f2'>"; - print "No"; - print "</span></th>\n"; -# I'm not sure if abstains are necessary inthis view, it's just extra clutter -# print " <th style='border-bottom: #666 1px solid; vertical-align:"; -# print " bottom'><span class='f2'>"; -# print "Abstain"; -# print "</span></th>\n"; - print " <th style='border-bottom: #666 1px solid; vertical-align:"; - print " bottom'><span class='f2'>"; - print "Voted?"; - print "</span></th>\n"; - print "</tr>\n"; - - if (mysql_num_rows($result) == 0) { - print "<tr><td align='center' colspan='0'>No results found.</td></tr>\n"; - } else { - for ($i = 0; $row = mysql_fetch_assoc($result); $i++) { - # Thankyou AUR - - # alright, I'm going to just have a "new" table and the - # "old" table can just have every vote, works just as well - # and probably saves on doing some crap - # - - (($i % 2) == 0) ? $c = "data1" : $c = "data2"; - print "<tr>\n"; - print " <td class='".$c."'><span class='f4'><span class='blue'>"; - - $prev_Len = 100; - - if (strlen($row["Agenda"]) >= $prev_Len) { - $row["Agenda"] = htmlentities(substr($row["Agenda"], 0, $prev_Len)) . "... -"; - } else { - $row["Agenda"] = htmlentities($row["Agenda"]) . " -"; - } - - print $row["Agenda"]; - print " <a href='/tu.php?id=" . $row['ID'] . "'>[More]</a>"; - print "</span></span></td>\n"; - print " <td class='".$c."'><span class='f5'><span class='blue'>"; - # why does the AUR use gmdate with formatting that includes the offset - # to GMT?! - print gmdate("j M y", $row["Submitted"]); - print "</span></span></td>\n"; - print " <td class='".$c."'><span class='f5'><span class='blue'>"; - print gmdate("j M y", $row["End"]); - print "</span></span></td>\n"; - print " <td class='".$c."'><span class='f6'><span class='blue'>"; - - if (!empty($row['User'])) { - print "<a href='packages.php?K=" . $row['User'] . "&SeB=m'>"; - print $row['User'] . "</a>"; - } else { - print "N/A"; - } - - print "</span></span></td>\n"; - print " <td class='".$c."'><span class='f5'><span class='blue'>"; - print $row['Yes']; - print "</span></span></td>\n"; - print " <td class='".$c."'><span class='f5'><span class='blue'>"; - print $row['No']; - print "</span></span></td>\n"; - print " <td class='".$c."'><span class='f5'><span class='blue'>"; - # See above - # print $row['Abstain']; - # print "</span></span></td>\n"; - # print " <td class='".$c."'><span class='f5'><span class='blue'>"; - - $qvoted = "SELECT * FROM TU_Votes WHERE "; - $qvoted.= "VoteID = " . $row['ID'] . " AND "; - $qvoted.= "UserID = " . uid_from_sid($_COOKIE["AURSID"]); - $hasvoted = mysql_num_rows(db_query($qvoted, $dbh)); - - if ($hasvoted == 0) { - print "<span style='color: red; font-weight: bold'>No</span>"; - } else { - print "<span style='color: green; font-weight: bold'>Yes</span>"; - } - - print "</span></span></td>\n"; - print "</tr>\n"; - } - } + $dbh = db_connect(); - print "</table>\n"; - print "</table>\n"; + $offset = $_GET['off']; + $limit = $pp; + $by = $_GET['by']; - if ($type == "old" AND $limit != 0) { - $qnext = "SELECT ID FROM TU_VoteInfo"; - $nextresult = db_query($qnext, $dbh); + if (!empty($offset) AND is_numeric($offset)) { + if ($offset >= 1) { + $off = $offset; + } else { + $off = 0; + } + } else { + $off = 0; + } - print "<table style='width: 90%'>\n"; + $order = ($by == 'down') ? 'DESC' : 'ASC'; + $lim = ($limit > 0) ? " LIMIT " . $off . ", " . $limit : ""; + $by_next = ($by == "down") ? "up" : "down"; - if (mysql_num_rows($result)) { - $sort = htmlentities($sort, ENT_QUOTES); - $by = htmlentities($by, ENT_QUOTES); + $prev_Len = 100; - print "<tr>\n"; - print "<td align='left'>\n"; - if ($off != 0) { - $back = (($off - $limit) <= 0) ? 0 : $off - $limit; - print "<a href='tu.php?off=$back&sort=" . $sort . "&by=" . $by . "'>Back</a>"; - } - print "</td>\n"; + $q = "SELECT * FROM TU_VoteInfo WHERE End > " . time() . " ORDER BY Submitted " . $order; + $result = db_query($q, $dbh); - print "<td align='right'>\n"; - if (($off + $limit) < mysql_num_rows($nextresult)) { - $forw = $off + $limit; - print "<a href='tu.php?off=$forw&sort=" . $sort . "&by=" . $by . "'>Next</a>"; - } - print "</td>\n"; - print "</tr>\n"; - } - print "</table>\n"; - } + $type = __("Current Votes"); + include("tu_list.php"); +?> - print "</center>\n"; - } +<center> + <a href='addvote.php'><?php print __("Add") ?></a> +</center><br /> - # stop notices, ythanku Xilon - if (empty($_REQUEST['sort'])) { $_REQUEST['sort'] = ""; } - if (empty($_REQUEST['by'])) { $_REQUEST['by'] = ""; } - if (empty($_REQUEST['off'])) { $_REQUEST['off'] = ""; } +<?php + $q = "SELECT * FROM TU_VoteInfo ORDER BY Submitted " . $order . $lim; + $result = db_query($q, $dbh); - gen_results(0, 0, $_REQUEST['sort'], $_REQUEST['by'], "new"); - print "<center><a href='addvote.php'>Add</a></center><br />"; - gen_results($_REQUEST['off'], $pp, $_REQUEST['sort'], $_REQUEST['by'], "old"); + $type = __("All Votes"); + include("tu_list.php"); + $qnext = "SELECT ID FROM TU_VoteInfo"; + $nextresult = db_query($qnext, $dbh); +?> +<table style='width: 90%'> + <?php if (mysql_num_rows($result)) { $by = htmlentities($by, ENT_QUOTES); ?> + <tr> + <td align='left'> + <?php if ($off != 0) { $back = (($off - $limit) <= 0) ? 0 : $off - $limit; ?> + <a href='tu.php?off=<?php print $back ?>&by=<?php print $by ?>'><?php print __("Back") ?></a> + <?php } ?> + </td> + <td align='right'> + <?php if (($off + $limit) < mysql_num_rows($nextresult)) { $forw = $off + $limit; ?> + <a href='tu.php?off=<?php print $forw ?>&by=<?php print $by ?>'><?php print __("Next") ?></a> + <?php } ?> + </td> + </tr> + <?php } ?> +</table> +<?php } } else { - print "You are not allowed to access this area.\n"; + print __("You are not allowed to access this area."); } html_footer(AUR_VERSION); - -?> |