Exemple #1
0
function getCategoriesForID($id)
{
    //subcategories
    //SELECT A1.name displayTitle, A1.slug link, A2.parent parentID, A3.name parentTitle FROM wp_3_terms A1, wp_3_term_taxonomy A2, wp_3_terms A3 WHERE A1.term_id = A2.term_id AND A2.taxonomy = "category" AND A2.parent != 0 AND A2.parent = A3.term_id ORDER BY parentTitle ASC
    //categories
    //SELECT A1.name displayTitle, A1.slug link, A2.term_id ID, A3.image_src imageURL FROM wp_3_terms A1, wp_3_term_taxonomy A2 LEFT JOIN category_images A3 ON (A2.term_id = A3.term_id) WHERE A1.term_id = A2.term_id AND A2.taxonomy = "category" AND A2.parent = 0 GROUP BY displayTitle ORDER BY displayTitle ASC
    if ($location = checkValid($id)) {
        $table1 = 'wp_' . $id . '_terms';
        $table2 = 'wp_' . $id . '_term_taxonomy';
        $table3 = 'category_images';
        $query = 'SELECT A1.name displayTitle, A1.slug link, A2.term_id ID, A3.image_src imageURL, A2.term_id ID 
FROM ' . $table1 . ' A1, ' . $table2 . ' A2 
LEFT JOIN ' . $table3 . ' A3 ON (A2.term_id = A3.term_id) 
WHERE A1.term_id = A2.term_id AND A2.taxonomy = "category" AND A2.parent = 0 AND A1.name != "Uncategorized" 
GROUP BY displayTitle 
ORDER BY displayTitle ASC';
        $categories = mysql_query($query);
        $query = 'SELECT A1.name displayTitle, A1.slug link, A2.parent parentID, A3.name parentTitle, A4.image_src imageURL, A2.term_id ID 
FROM ' . $table1 . ' A1 LEFT JOIN ' . $table3 . ' A4 ON (A1.term_id = A4.term_id), ' . $table2 . ' A2, ' . $table1 . ' A3  
WHERE A1.term_id = A2.term_id AND A2.taxonomy = "category" AND A2.parent != 0 AND A2.parent = A3.term_id AND A1.name != "Uncategorized" 
GROUP BY displayTitle 
ORDER BY parentTitle ASC, displayTitle ASC';
        $subcategories = mysql_query($query);
        ?>
	
<categories>
   <category>
      <displayTitle>Categories</displayTitle>
      <catLink>0</catLink>
      <imageURL></imageURL>
      <id></id>
   </category>
   <category>
      <displayTitle>Top Stories</displayTitle>
      <catLink>http://<?php 
        echo $location . '/feed/';
        ?>
</catLink>
      <imageURL>http://farm3.static.flickr.com/2203/2208986720_603c4f6433.jpg</imageURL>
      <id>Top Stories</id>
   </category>
<?php 
        $subcategory = mysql_fetch_array($subcategories);
        while ($category = mysql_fetch_array($categories)) {
            ?>
   <category>
      <displayTitle><?php 
            echo $category['displayTitle'];
            ?>
</displayTitle>
      <catLink>http://<?php 
            echo $location . '/category/' . $category['link'] . '/feed/';
            ?>
</catLink>
      <imageURL><?php 
            echo $category['imageURL'];
            ?>
</imageURL>
      <id><?php 
            echo $category['ID'];
            ?>
</id>
   </category>
<?php 
            while ($subcategory['parentID'] == $category['ID']) {
                ?>
   <category>
      <displayTitle><?php 
                echo '    ' . $subcategory['displayTitle'];
                ?>
</displayTitle>
      <catLink>http://<?php 
                echo $location . '/category/' . $category['link'] . '/' . $subcategory['link'] . '/feed/';
                ?>
</catLink>
      <imageURL><?php 
                echo $subcategory['imageURL'];
                ?>
</imageURL>
      <id><?php 
                echo $category['ID'];
                ?>
</id>
   </category>
<?php 
                $subcategory = mysql_fetch_array($subcategories);
            }
        }
        ?>
</categories>
<?php 
    } elseif ($id == NULL) {
        ?>
<error>no id specified</error>
<?php 
    } else {
        ?>
<error>invalid id specified</error>
<?php 
    }
}
Exemple #2
0
function validate($validators)
{
    $validate = explode(";", $validators);
    $overall = true;
    for ($i = 0; $i < sizeof($validate); $i++) {
        $validateargs = explode(",", $validate[$i]);
        $valid = checkValid(trim($validateargs[0]), trim($validateargs[1]), trim($validateargs[2]), trim($validateargs[3]), trim($validateargs[4]), trim($validateargs[5]));
        $overall = $overall && $valid;
    }
    return $overall;
}