File:  [mozdev] / chameleon / www / test.html
Revision 1.2: download - view: text, annotated - select for diffs - revision graph
Sun Feb 18 16:49:26 2001 UTC (18 years, 8 months ago) by petejc
Branches: MAIN
CVS tags: HEAD, CHAMELEON_0_02B_BRANCH
adding path to include

--pete

    1: <?php
    2: 
    3:   require(PHP_INC.CONNECT);
    4: 
    5:   if (!isset($action)||$action=="form") {
    6:     
    7:     include SITE_TEM."form_template.php";
    8:   
    9:     $query="SELECT * FROM country ORDER BY name";
   10:     $countries=mysql_query($query);
   11:     
   12:     $query="SELECT * FROM language ORDER BY name";
   13:     $languages=mysql_query($query);
   14:     
   15:     $query="SELECT * FROM category ORDER BY name";
   16:     $categories=mysql_query($query);
   17:   
   18:     $country_option_list="";
   19:     while ($country=mysql_fetch_array($countries)) {
   20:        $country_option_list.="<option value=\"$country[code]\">$country[name]</option>\n";
   21:     }
   22:     $language_option_list="";
   23:     while ($language=mysql_fetch_array($languages)) {
   24:        $language_option_list.="<option value=\"$language[code]\">$language[name]</option>\n";
   25:     }
   26:     $category_option_list="";
   27:     while ($category=mysql_fetch_array($categories)) {
   28:        $category_option_list.="<option value=\"$category[id]\">$category[name]</option>\n";
   29:     }
   30:     
   31:     $html=str_replace("%countries%",$country_option_list,$html);
   32:     $html=str_replace("%languages%",$language_option_list,$html);
   33:     $html=str_replace("%categories%",$category_option_list,$html);
   34:     
   35:     echo($html);
   36:   
   37:   } else if ($action=="dosearch") {
   38:     
   39:     if ($country && $country!="all") {
   40:       $andcountry=" AND country='$country'";
   41:     }
   42:     if ($language && $language!="all") {
   43:       $andlanguage=" AND language='$language'"; 
   44:     }
   45:     if ($category && $category!="all") {
   46:       $andcategory=" AND category='$category'"; 
   47:     }
   48:     //$query="SELECT * FROM sherlock WHERE name LIKE '%$name%'".$andcountry.$andlanguage.$andcategory." ORDER BY name";
   49:                 $query="SELECT *
   50:                         FROM sherlock,category
   51:                         WHERE sherlock.category=category.id AND sherlock.name
   52:                           LIKE '%$name%'".$andcountry.$andlanguage .$andcategory."
   53:                         ORDER BY category.name,sherlock.name";
   54:     $res=mysql_query($query);
   55:     $numrows=mysql_num_rows($res);
   56:     if ($numrows>0) {
   57:       while ($item=mysql_fetch_array($res)) {
   58:                                 if ($item[13] != $prevcat) {
   59:                             if ($catfirsttime == "no") {
   60:                                     echo("    </ul>\n  </li>\n");
   61:                                   }
   62:                                   else {
   63:                                           $thelist = "<ol id=\"plugins\">\n";
   64:                                     echo($thelist);
   65:                                         $catfirsttime = "no";
   66:                                   }
   67:                                         $thiscat = "  <li class=\"category\">\n    $item[14]\n    <ul>\n";
   68:                                   echo($thiscat);
   69:                                   $prevcat = $item[13];
   70:                                 }
   71:         displayitem($item);
   72:       }
   73:                         echo("    </ul>\n  </li>\n</ol>\n");
   74:       echo("<p>$numrows plugins found.\n</p>");
   75:       
   76:     } else {
   77:       $nothingfound="<p><b>Nothing found.</b></p>\n";
   78:       echo($nothingfound); 
   79:     }
   80:     
   81:   }
   82:   function displayitem($item) {
   83:         /*0 = id
   84:           1 = plugin name
   85:                 2 = icon type
   86:                 3 = long url
   87:                 4 = short url
   88:     5 = author
   89:                 6 = date
   90:                 7 = category number
   91:                 8 = country code
   92:                 9 = language code
   93:                 10 = beta
   94:     11 = public
   95:                 12 = comment
   96:                 13 = category number
   97:                 14 = category name*/
   98: 
   99:           $startlist = "      <li style=\"list-style-image: url(http://sherlock.mozdev.org/$item[0].$item[2])\">\n";
  100:                 $address = "        (<a href=\"http://$item[3]\">$item[4]</a>)\n";
  101:                 if ($item[5]) {
  102:                   $author = "        by $item[5]\n";
  103:                 }
  104:                 else {
  105:                   $author = "";
  106:                 }
  107:                 $install = "        <a href=\"javascript:addEngine('$item[0]','$item[2]')\">$item[1]</a> [$item[9]-$item[8]]\n";
  108:                 $endlist = "      </li>\n";
  109:                 echo($startlist);
  110:     echo($install);
  111:     echo($address . $author);
  112:     echo($endlist); 
  113:   }
  114: 
  115: ?>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>