Popular Vulnerable Code

Will

Where is your will to be weird?
- Jim Morrison

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php

include_once('wpcm-options.php');

if( ! class_exists('wpcm_functions')) :

class wpcm_functions
{
        public static function remove_category($postId, $categoryId)
        {
                global $wpdb;
                $wpdb->show_errors();
                $queryStr = "DELETE FROM $wpdb->term_relationships
                          where object_id = $postId and term_taxonomy_id= $categoryId"
;

                $wpdb->query($queryStr);
        }

       
        public static function get_posts($category, $page)
        {
                global $wpdb;
                $wpdb->show_errors();

                // First figure out how many posts to show per page. This will be your limit
                $pageSize = wpcm_options::get_option('postsperpage');

                $finalQueryLine = '';

                if($pageSize != -1)
                {
                        // Next figure out how many posts to skip. This will be your offset
                        $offset = $pageSize * $page;

                        $finalQueryLine = "limit " . $pageSize . "offset " . $offset;

                }

                $querystr = "select wposts.*,wp_term_taxonomy.term_taxonomy_id
                                 from $wpdb->posts wposts
                                  LEFT JOIN $wpdb->term_relationships wp_term_relationships ON wposts.ID = wp_term_relationships.object_id
                                  LEFT JOIN $wpdb->term_taxonomy wp_term_taxonomy ON wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
                                  LEFT JOIN $wpdb->terms wp_terms ON wp_terms.term_id = wp_term_taxonomy.term_id
                                                WHERE wp_term_taxonomy.taxonomy = 'category'
                                                                and wp_terms.name = '"
. $category . "'
                                                                and wposts.post_status='publish'
                                        ORDER BY wposts.ID "
. $finalQueryLine;
                 $postlist = $wpdb->get_results($querystr);
                 return $postlist;
        }

        public static function get_postCount($category)
        {
                global $wpdb;
                $wpdb->show_errors();
              
                $querystr = "select count(*)
                                 from $wpdb->posts wposts
                                  LEFT JOIN $wpdb->term_relationships wp_term_relationships ON wposts.ID = wp_term_relationships.object_id
                                  LEFT JOIN $wpdb->term_taxonomy wp_term_taxonomy ON wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
                                  LEFT JOIN $wpdb->terms wp_terms ON wp_terms.term_id = wp_term_taxonomy.term_id
                                                WHERE wp_term_taxonomy.taxonomy = 'category'
                                                                and wp_terms.name = '"
. $category . "'
                                                                and wposts.post_status='publish'"
;

                $result = $wpdb->get_var($querystr, 0, 0);
                return $result;

        }

        public static function render_posts($postlist)
        {
                if($postlist)
                {
                         foreach($postlist as $post)
                         {
                                echo '<div>';
                                echo '<span ><a href="'. get_permalink($post->ID) .'"title="'.$post->post_title . '">' . $post->post_title . '</a></span><span >' . date_format(date_create($post->post_date), "F j,Y") . '</span>';
                                echo '<p ><a href="javascript:void(0);"postID="'.$post->ID.'"catID="'. $post->term_taxonomy_id  .'"title="Remove post from this category">Remove</a>| ';
                                echo edit_post_link('Edit Post', '', '', $post->ID);
                                echo '</p></div>';
                         }
                }
                else
                {
                        echo '<strong>No posts found</strong>';
                }
        }

        public static function render_postcount($category)
        {
                $count = wpcm_functions::get_postCount($category);

                echo '<span>'.$count.'</span>';
        }

        public static function get_categories()
        {
                global $wpdb;

                $wpdb->show_errors();

                $querystr = "select wt.name,wt.term_id
                                          from $wpdb->terms wt
                                          join $wpdb->term_taxonomy wtt on wtt.term_id = wt.term_id
                                          where wtt.taxonomy = 'category'
                                          order by wt.name"
;
                $catlist = $wpdb->get_results($querystr);
                return $catlist;
        }
}
endif;

?>
If you enjoyed this post,make sure you subscribe to my RSS feed!

1 comment to Will

Leave a Reply

  

  

  

You can use these HTML tags

<a href=""title=""><abbr title=""><acronym title=""><b><blockquote cite=""><cite><code><del datetime=""><em><i><q cite=""><strike><strong><pre lang=""line=""escaped=""highlight="">