apps.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. //
  3. // this file gets included from a couple of different places and depending on the values of $this_cat
  4. // and $key will run slightly different queries to prodocue the appropriate list of applications
  5. //
  6. require_once("apps.inc");
  7. $limit = 10;
  8. if( empty($_GET['offset']) ) {
  9. $offset = 0;
  10. }
  11. if( !empty($_GET['the_cat']) ) {
  12. $title = " : " . $appCats[$_GET['the_cat']]->name;
  13. $this_cat = $_GET['the_cat'];
  14. if( !empty($_GET['the_subcat']) ) {
  15. $title .= " : " . $appCats[$_GET['the_cat']]->sub[$_GET['the_subcat']]->name;
  16. $this_cat = $_GET['the_subcat'];
  17. }
  18. }
  19. if( !empty($this_cat) ) {
  20. if( is_array($appCats[$this_cat]->sub) ) {
  21. $these_cats = $this_cat . "," . join(",", array_keys($appCats[$this_cat]->sub));
  22. $res = mysql_query("SELECT * FROM app WHERE status = 'A' AND cat_id IN ($these_cats) ORDER BY name LIMIT $offset,$limit");
  23. }else {
  24. $res = mysql_query("SELECT * FROM app WHERE status = 'A' AND cat_id = $this_cat ORDER BY name LIMIT $offset,$limit");
  25. }
  26. print("<h1>Applications $title</h1>");
  27. }else if( $_GET['key'] == "new" ) {
  28. $res = mysql_query("SELECT * FROM app WHERE status = 'A' ORDER BY date_added DESC LIMIT $offset,$limit");
  29. print("<h1>Applications : New</h1>");
  30. }else if( $_GET['key'] == "rating" ) {
  31. $res = mysql_query("SELECT * FROM app WHERE status = 'A' ORDER BY rating DESC LIMIT $offset,$limit");
  32. print("<h1>Applications : Highest Rating</h1>");
  33. }else {
  34. $res = mysql_query("SELECT * FROM app WHERE status = 'A' ORDER BY date_added DESC LIMIT 4");
  35. print("
  36. <h1>Applications</h1>
  37. Here you will find PHP-GTK applications. If you know of an application that
  38. isn't in this database you can add it via the link on the left. If there is a category
  39. that you think should be added to this database please
  40. <a href='mailto:php-gtk-webmaster@lists.php.net'>email the webmaster</a>
  41. <h3>Rating applications</h3>
  42. If you like - or dislike - an application that you find on this
  43. site, please rate it to give others an idea of its usefulness.
  44. Ratings run from 1 (not good) through to 5 (brilliant).
  45. <h3>Newest Applications</h3>
  46. ");
  47. }
  48. $num_rows = mysql_num_rows($res);
  49. if( $res && $num_rows > 0 ) {
  50. print("<table border='0' cellpadding='2' cellspacing='0' width='100%'>");
  51. while( $row = mysql_fetch_object($res) ) {
  52. displayApp($row, $_GET['the_cat'], $_GET['the_subcat'], $_GET['offset']);
  53. }
  54. print("</table>");
  55. if( $num_rows >= $limit ) {
  56. print("<br/>");
  57. print("<p align=right>");
  58. print("<small>");
  59. if( !empty($this_cat) ) {
  60. print("<a href='index.php?the_cat={$_GET['the_cat']}&the_subcat={$_GET['the_subcat']}&offset=".($_GET['offset'] + $limit)."'>see more applications...</a>&nbsp;&nbsp;");
  61. }else if( !empty($_GET['key']) ) {
  62. print("<a href='index.php?key={$_GET['key']}&offset=" . ($_GET['offset'] + $limit) . "'>see more applications...</a>&nbsp;&nbsp;");
  63. }else {
  64. print("<a href='index.php?key=new'>see more new applications...</a>&nbsp;&nbsp;");
  65. }
  66. print("</small>");
  67. print("</p>");
  68. print("<br/>");
  69. print("<br/>");
  70. }
  71. }else {
  72. if( $offset > 0 ) {
  73. print("There are no more applications in this category.");
  74. }else {
  75. print("There are not any applications in this category.");
  76. print("<br/>");
  77. print("<br/>");
  78. print("Maybe you'd like to <a href='add.php?cat_id=$this_cat'>add one</a>?");
  79. }
  80. }
  81. ?>