| 56 | | $WP_ROOT_PATH = preg_replace('|wp-content.*$|','', __FILE__); |
| 57 | | // Ignore wordpress mu |
| 58 | | require($WP_ROOT_PATH.'wp-includes/version.php'); |
| 59 | | if( strpos($wp_version, 'wordpress-mu') !== false || isset($wporg_version) || isset($wpmu_version) ) |
| 60 | | return;// external tracking does not support wpmu by now. |
| 61 | | |
| 62 | | /* START wp-db.php |
| 63 | | ------------------------------------*/ |
| 64 | | if(!class_exists('wpdb')) : |
| 65 | | // prevent WP default wpdb instance |
| 66 | | $wpdb = ''; |
| 67 | | require_once($WP_ROOT_PATH.'wp-includes/wp-db.php'); |
| 68 | | |
| 69 | | $wpdb = new wpdb($slimtrack_ext['DB_USER'], $slimtrack_ext['DB_PASSWORD'], $slimtrack_ext['DB_NAME'], $slimtrack_ext['DB_HOST']); |
| 70 | | endif; |
| 71 | | |
| 72 | | $wpdb->prefix = $slimtrack_ext['table_prefix']; |
| 73 | | |
| 74 | | $wpdb->options = $slimtrack_ext['table_prefix'] . 'options'; |
| 75 | | $GLOBALS['wpdb'] =& $wpdb; |
| 76 | | /* END wp-db.php |
| 77 | | ------------------------------------*/ |
| 78 | | |
| 79 | | /* START functions.php |
| 80 | | ------------------------------------*/ |
| 81 | | if(!function_exists('get_option')) : |
| 82 | | function get_option($setting) { |
| 83 | | global $wpdb; |
| 84 | | $row = $wpdb->get_row("SELECT option_value FROM $wpdb->options WHERE option_name = '$setting' LIMIT 1"); |
| 85 | | if( is_object( $row) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values |
| 86 | | $value = $row->option_value; |
| 87 | | } else { |
| 88 | | return false; |
| 89 | | } |
| 90 | | // If home is not set use siteurl. |
| 91 | | if ( 'home' == $setting && '' == $value ) |
| 92 | | return get_option('siteurl'); |
| 93 | | if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting ) |
| 94 | | $value = preg_replace('|/+$|', '', $value); |
| 95 | | return maybe_unserialize($value); |
| 96 | | } |
| 97 | | endif; |
| 98 | | if(!function_exists('is_serialized')) : |
| 99 | | function is_serialized($data) { |
| 100 | | // if it isn't a string, it isn't serialized |
| 101 | | if ( !is_string($data) ) |
| 102 | | return false; |
| 103 | | $data = trim($data); |
| 104 | | if ( 'N;' == $data ) |
| 105 | | return true; |
| 106 | | if ( !preg_match('/^([adObis]):/', $data, $badions) ) |
| 107 | | return false; |
| 108 | | switch ( $badions[1] ) : |
| | 90 | if ( version_compare( '4.3', phpversion(), '>' ) ) { |
| | 91 | die( sprintf( /*WP_I18N_OLD_PHP*/'Your server is running PHP version %s but WordPress requires at least 4.3.'/*/WP_I18N_OLD_PHP*/, php_version() ) ); |
| | 92 | } |
| | 93 | |
| | 94 | // Add define('WP_DEBUG',true); to wp-config.php to enable display of notices during development. |
| | 95 | if (defined('WP_DEBUG') and WP_DEBUG == true) { |
| | 96 | error_reporting(E_ALL); |
| | 97 | } else { |
| | 98 | error_reporting(E_ALL ^ E_NOTICE ^ E_USER_NOTICE); |
| | 99 | } |
| | 100 | |
| | 101 | $WP_ROOT_PATH = preg_replace('|wp-content.*$|','', __FILE__); |
| | 102 | // Ignore wordpress mu |
| | 103 | require($WP_ROOT_PATH.'wp-includes/version.php'); |
| | 104 | if( strpos($wp_version, 'wordpress-mu') !== false || isset($wporg_version) || isset($wpmu_version) ) |
| | 105 | return;// external tracking does not support wpmu by now. |
| | 106 | |
| | 107 | require_once ($WP_ROOT_PATH . 'wp-includes/compat.php'); |
| | 108 | |
| | 109 | /* START functions.php |
| | 110 | ------------------------------------*/ |
| | 111 | if(!function_exists('get_option')) : |
| | 112 | function get_option( $setting ) { |
| | 113 | global $wpdb; |
| | 114 | |
| | 115 | // Allow plugins to short-circuit options. |
| | 116 | // $pre = apply_filters( 'pre_option_' . $setting, false ); |
| | 117 | // if ( false !== $pre ) |
| | 118 | // return $pre; |
| | 119 | |
| | 120 | // prevent non-existent options from triggering multiple queries |
| | 121 | $notoptions = wp_cache_get( 'notoptions', 'options' ); |
| | 122 | if ( isset( $notoptions[$setting] ) ) |
| | 123 | return false; |
| | 124 | |
| | 125 | // $alloptions = wp_load_alloptions(); |
| | 126 | |
| | 127 | // if ( isset( $alloptions[$setting] ) ) { |
| | 128 | // $value = $alloptions[$setting]; |
| | 129 | // } else { |
| | 130 | $value = wp_cache_get( $setting, 'options' ); |
| | 131 | |
| | 132 | if ( false === $value ) { |
| | 133 | // if ( defined( 'WP_INSTALLING' ) ) |
| | 134 | // $supress = $wpdb->suppress_errors(); |
| | 135 | // expected_slashed ($setting) |
| | 136 | $row = $wpdb->get_row( "SELECT option_value FROM $wpdb->options WHERE option_name = '$setting' LIMIT 1" ); |
| | 137 | // if ( defined( 'WP_INSTALLING' ) ) |
| | 138 | // $wpdb->suppress_errors($suppress); |
| | 139 | |
| | 140 | if ( is_object( $row) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values |
| | 141 | $value = $row->option_value; |
| | 142 | wp_cache_add( $setting, $value, 'options' ); |
| | 143 | } else { // option does not exist, so we must cache its non-existence |
| | 144 | $notoptions[$setting] = true; |
| | 145 | wp_cache_set( 'notoptions', $notoptions, 'options' ); |
| | 146 | return false; |
| | 147 | } |
| | 148 | } |
| | 149 | // } |
| | 150 | |
| | 151 | // If home is not set use siteurl. |
| | 152 | if ( 'home' == $setting && '' == $value ) |
| | 153 | return get_option( 'siteurl' ); |
| | 154 | |
| | 155 | if ( in_array( $setting, array('siteurl', 'home', 'category_base', 'tag_base') ) ) |
| | 156 | $value = untrailingslashit( $value ); |
| | 157 | |
| | 158 | return maybe_unserialize( $value ); |
| | 159 | // return apply_filters( 'option_' . $setting, maybe_unserialize( $value ) ); |
| | 160 | } |
| | 161 | endif; |
| | 162 | if(!function_exists('is_serialized')) : |
| | 163 | function is_serialized( $data ) { |
| | 164 | // if it isn't a string, it isn't serialized |
| | 165 | if ( !is_string( $data ) ) |
| | 166 | return false; |
| | 167 | $data = trim( $data ); |
| | 168 | if ( 'N;' == $data ) |
| | 169 | return true; |
| | 170 | if ( !preg_match( '/^([adObis]):/', $data, $badions ) ) |
| | 171 | return false; |
| | 172 | switch ( $badions[1] ) { |
| 121 | | endswitch; |
| 122 | | return false; |
| 123 | | } |
| 124 | | endif; |
| 125 | | if(!function_exists('maybe_unserialize')) : |
| 126 | | function maybe_unserialize($original) { |
| 127 | | if ( is_serialized($original) ) // don't attempt to unserialize data that wasn't serialized going in |
| 128 | | if ( false !== $gm = @ unserialize($original) ) |
| 129 | | return $gm; |
| 130 | | return $original; |
| 131 | | } |
| 132 | | endif; |
| 133 | | if(!function_exists('add_magic_quotes')): |
| 134 | | function add_magic_quotes($array) { |
| 135 | | global $wpdb; |
| 136 | | |
| 137 | | foreach ($array as $k => $v) { |
| 138 | | if ( is_array($v) ) { |
| 139 | | $array[$k] = add_magic_quotes($v); |
| 140 | | } else { |
| 141 | | $array[$k] = $wpdb->escape($v); |
| 142 | | } |
| 143 | | } |
| 144 | | return $array; |
| 145 | | } |
| 146 | | endif; |
| 147 | | /* END functions.php |
| 148 | | ------------------------------------*/ |
| 149 | | |
| 150 | | /* START formatting.php |
| 151 | | ------------------------------------*/ |
| 152 | | if(!function_exists('trailingslashit')): |
| 153 | | function trailingslashit($string) { |
| 154 | | if ( '/' != substr($string, -1)) { |
| 155 | | $string .= '/'; |
| 156 | | } |
| 157 | | return $string; |
| 158 | | } |
| 159 | | endif; |
| 160 | | if(!function_exists('addslashes_gpc')): |
| 161 | | function addslashes_gpc($gpc) { |
| 162 | | global $wpdb; |
| 163 | | if (get_magic_quotes_gpc()) { |
| 164 | | $gpc = stripslashes($gpc); |
| 165 | | } |
| 166 | | return $wpdb->escape($gpc); |
| 167 | | } |
| 168 | | endif; |
| 169 | | if(!function_exists('stripslashes_deep')): |
| 170 | | function stripslashes_deep($value) { |
| 171 | | $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); |
| 172 | | return $value; |
| 173 | | } |
| 174 | | endif; |
| 175 | | if(!function_exists('seems_utf8')): |
| 176 | | function seems_utf8($Str) { # by bmorel at ssi dot fr |
| 177 | | for ($i=0; $i<strlen($Str); $i++) { |
| 178 | | if (ord($Str[$i]) < 0x80) continue; # 0bbbbbbb |
| 179 | | elseif ((ord($Str[$i]) & 0xE0) == 0xC0) $n=1; # 110bbbbb |
| 180 | | elseif ((ord($Str[$i]) & 0xF0) == 0xE0) $n=2; # 1110bbbb |
| 181 | | elseif ((ord($Str[$i]) & 0xF8) == 0xF0) $n=3; # 11110bbb |
| 182 | | elseif ((ord($Str[$i]) & 0xFC) == 0xF8) $n=4; # 111110bb |
| 183 | | elseif ((ord($Str[$i]) & 0xFE) == 0xFC) $n=5; # 1111110b |
| 184 | | else return false; # Does not match any model |
| 185 | | for ($j=0; $j<$n; $j++) { # n bytes matching 10bbbbbb follow ? |
| 186 | | if ((++$i == strlen($Str)) || ((ord($Str[$i]) & 0xC0) != 0x80)) |
| 187 | | return false; |
| 188 | | } |
| 189 | | } |
| | 185 | } |
| | 186 | return false; |
| | 187 | } |
| | 188 | endif; |
| | 189 | if(!function_exists('maybe_unserialize')) : |
| | 190 | function maybe_unserialize( $original ) { |
| | 191 | if ( is_serialized( $original ) ) // don't attempt to unserialize data that wasn't serialized going in |
| | 192 | if ( false !== $gm = @unserialize( $original ) ) |
| | 193 | return $gm; |
| | 194 | return $original; |
| | 195 | } |
| | 196 | endif; |
| | 197 | if(!function_exists('add_magic_quotes')): |
| | 198 | function add_magic_quotes( $array ) { |
| | 199 | global $wpdb; |
| | 200 | |
| | 201 | foreach ( $array as $k => $v ) { |
| | 202 | if ( is_array( $v ) ) { |
| | 203 | $array[$k] = add_magic_quotes( $v ); |
| | 204 | } else { |
| | 205 | $array[$k] = $wpdb->escape( $v ); |
| | 206 | } |
| | 207 | } |
| | 208 | return $array; |
| | 209 | } |
| | 210 | endif; |
| | 211 | /* END functions.php |
| | 212 | ------------------------------------*/ |
| | 213 | |
| | 214 | /* START wp-db.php |
| | 215 | ------------------------------------*/ |
| | 216 | if(!class_exists('wpdb')) : |
| | 217 | // prevent WP default wpdb instance |
| | 218 | $wpdb = ''; |
| | 219 | require_once($WP_ROOT_PATH . 'wp-includes/wp-db.php'); |
| | 220 | |
| | 221 | $wpdb = new wpdb($slimtrack_ext['DB_USER'], $slimtrack_ext['DB_PASSWORD'], $slimtrack_ext['DB_NAME'], $slimtrack_ext['DB_HOST']); |
| | 222 | endif; |
| | 223 | |
| | 224 | $wpdb->prefix = $slimtrack_ext['table_prefix']; |
| | 225 | |
| | 226 | $wpdb->options = $slimtrack_ext['table_prefix'] . 'options'; |
| | 227 | $GLOBALS['wpdb'] =& $wpdb; |
| | 228 | /* END wp-db.php |
| | 229 | ------------------------------------*/ |
| | 230 | |
| | 231 | require_once ($WP_ROOT_PATH . 'wp-includes/cache.php'); |
| | 232 | |
| | 233 | wp_cache_init(); |
| | 234 | |
| | 235 | |
| | 236 | /* START formatting.php |
| | 237 | ------------------------------------*/ |
| | 238 | if(!function_exists('backslashit')): |
| | 239 | function backslashit($string) { |
| | 240 | $string = preg_replace('/^([0-9])/', '\\\\\\\\\1', $string); |
| | 241 | $string = preg_replace('/([a-z])/i', '\\\\\1', $string); |
| | 242 | return $string; |
| | 243 | } |
| | 244 | endif; |
| | 245 | if(!function_exists('trailingslashit')): |
| | 246 | function trailingslashit($string) { |
| | 247 | return untrailingslashit($string) . '/'; |
| | 248 | } |
| | 249 | endif; |
| | 250 | if(!function_exists('untrailingslashit')): |
| | 251 | function untrailingslashit($string) { |
| | 252 | return rtrim($string, '/'); |
| | 253 | } |
| | 254 | endif; |
| | 255 | if(!function_exists('addslashes_gpc')): |
| | 256 | function addslashes_gpc($gpc) { |
| | 257 | global $wpdb; |
| | 258 | |
| | 259 | if (get_magic_quotes_gpc()) { |
| | 260 | $gpc = stripslashes($gpc); |
| | 261 | } |
| | 262 | |
| | 263 | return $wpdb->escape($gpc); |
| | 264 | } |
| | 265 | endif; |
| | 266 | if(!function_exists('stripslashes_deep')): |
| | 267 | function stripslashes_deep($value) { |
| | 268 | $value = is_array($value) ? |
| | 269 | array_map('stripslashes_deep', $value) : |
| | 270 | stripslashes($value); |
| | 271 | |
| | 272 | return $value; |
| | 273 | } |
| | 274 | endif; |
| | 275 | if(!function_exists('seems_utf8')): |
| | 276 | function seems_utf8($Str) { # by bmorel at ssi dot fr |
| | 277 | $length = strlen($Str); |
| | 278 | for ($i=0; $i < $length; $i++) { |
| | 279 | if (ord($Str[$i]) < 0x80) continue; # 0bbbbbbb |
| | 280 | elseif ((ord($Str[$i]) & 0xE0) == 0xC0) $n=1; # 110bbbbb |
| | 281 | elseif ((ord($Str[$i]) & 0xF0) == 0xE0) $n=2; # 1110bbbb |
| | 282 | elseif ((ord($Str[$i]) & 0xF8) == 0xF0) $n=3; # 11110bbb |
| | 283 | elseif ((ord($Str[$i]) & 0xFC) == 0xF8) $n=4; # 111110bb |
| | 284 | elseif ((ord($Str[$i]) & 0xFE) == 0xFC) $n=5; # 1111110b |
| | 285 | else return false; # Does not match any model |
| | 286 | for ($j=0; $j<$n; $j++) { # n bytes matching 10bbbbbb follow ? |
| | 287 | if ((++$i == $length) || ((ord($Str[$i]) & 0xC0) != 0x80)) |
| | 288 | return false; |
| | 289 | } |
| | 290 | } |
| | 291 | return true; |
| | 292 | } |
| | 293 | endif; |
| | 294 | /* END formatting.php |
| | 295 | ------------------------------------*/ |
| | 296 | |
| | 297 | /* START deprecated.php |
| | 298 | ------------------------------------*/ |
| | 299 | if(!function_exists('get_settings')) : |
| | 300 | function get_settings($option) { |
| | 301 | return get_option($option); |
| | 302 | } |
| | 303 | endif; |
| | 304 | /* END deprecated.php |
| | 305 | ------------------------------------*/ |
| | 306 | |
| | 307 | /* Start plugin.php |
| | 308 | ------------------------------------*/ |
| | 309 | if (!function_exists('plugin_basename')) : |
| | 310 | function plugin_basename($file) { |
| | 311 | $file = str_replace('\\','/',$file); // sanitize for Win32 installs |
| | 312 | $file = preg_replace('|/+|','/', $file); // remove any duplicate slash |
| | 313 | $plugin_dir = str_replace('\\','/',WP_PLUGIN_DIR); // sanitize for Win32 installs |
| | 314 | $plugin_dir = preg_replace('|/+|','/', $plugin_dir); // remove any duplicate slash |
| | 315 | $file = preg_replace('|^' . preg_quote($plugin_dir, '|') . '/|','',$file); // get relative path from plugins dir |
| | 316 | return $file; |
| | 317 | } |
| | 318 | endif; |
| | 319 | /* END plugin.php |
| | 320 | ------------------------------------*/ |
| | 321 | |
| | 322 | /* CONTINUE wp-settings.php |
| | 323 | ------------------------------------*/ |
| | 324 | if (function_exists('mb_internal_encoding')) { |
| | 325 | if (!@mb_internal_encoding(get_option('blog_charset'))) |
| | 326 | mb_internal_encoding('UTF-8'); |
| | 327 | } |
| | 328 | |
| | 329 | // If already slashed, strip. |
| | 330 | if ( get_magic_quotes_gpc() ) { |
| | 331 | $_GET = stripslashes_deep($_GET ); |
| | 332 | $_POST = stripslashes_deep($_POST ); |
| | 333 | $_COOKIE = stripslashes_deep($_COOKIE); |
| | 334 | } |
| | 335 | |
| | 336 | // Escape with wpdb. |
| | 337 | $_GET = add_magic_quotes($_GET ); |
| | 338 | $_POST = add_magic_quotes($_POST ); |
| | 339 | $_COOKIE = add_magic_quotes($_COOKIE); |
| | 340 | $_SERVER = add_magic_quotes($_SERVER); |
| | 341 | |
| | 342 | /* OTHERS |
| | 343 | ------------------------------------*/ |
| | 344 | if(!function_exists('is_admin')): |
| | 345 | function is_admin() {// TO DO |
| | 346 | $admin_check = array(// RegEx |
| | 347 | // zenphoto |
| | 348 | '/zen/', '/admin\.php','/admin$', '/admin/', |
| | 349 | // vanilla |
| | 350 | '/settings\.php', '/people\.php', '/settings/', '/account/', '/people/', |
| | 351 | // mediawiki |
| | 352 | 'title=Special:Userlog', 'Special:Preferences', 'title=MediaWiki:[^\.]+\.css&', 'title=-&action=', |
| | 353 | // dokuwiki |
| | 354 | '(\?|&)do=login', '(\?|&)do=admin', '(\?|&)do=edit', '(\?|&)do=logout', '(\?|&)do=profile', |
| | 355 | // photostack |
| | 356 | 'organize\.php', |
| | 357 | // phpbb |
| | 358 | '/profile.php', '/login.php', '/admin/' |
| | 359 | ); |
| | 360 | foreach($admin_check as $admin){ |
| | 361 | if(ereg($admin, $_SERVER['REQUEST_URI'])) |
| | 362 | return true; |
| | 363 | } |
| | 364 | global $wgCookiePrefix, $board_config; |
| | 365 | if(isset($_COOKIE['zenphoto_auth'])) { // ZenPhoto |
| 191 | | } |
| 192 | | endif; |
| 193 | | /* END formatting.php |
| 194 | | ------------------------------------*/ |
| 195 | | |
| 196 | | /* START deprecated.php |
| 197 | | ------------------------------------*/ |
| 198 | | if(!function_exists('get_settings')) : |
| 199 | | function get_settings($option) { |
| 200 | | return get_option($option); |
| 201 | | } |
| 202 | | endif; |
| 203 | | /* END deprecated.php |
| 204 | | ------------------------------------*/ |
| 205 | | |
| 206 | | /* Start plugin.php |
| 207 | | ------------------------------------*/ |
| 208 | | if (!function_exists('plugin_basename')) : |
| 209 | | function plugin_basename($file) { |
| 210 | | $file = str_replace('\\','/',$file); // sanitize for Win32 installs |
| 211 | | $file = preg_replace('|/+|','/', $file); // remove any duplicate slash |
| 212 | | $plugin_dir = str_replace('\\','/',WP_PLUGIN_DIR); // sanitize for Win32 installs |
| 213 | | $plugin_dir = preg_replace('|/+|','/', $plugin_dir); // remove any duplicate slash |
| 214 | | $file = preg_replace('|^' . preg_quote($plugin_dir, '|') . '/|','',$file); // get relative path from plugins dir |
| 215 | | return $file; |
| 216 | | } |
| 217 | | endif; |
| 218 | | /* END plugin.php |
| 219 | | ------------------------------------*/ |
| 220 | | |
| 221 | | /* CONTINUE wp-settings.php |
| 222 | | ------------------------------------*/ |
| 223 | | // If already slashed, strip. |
| 224 | | if ( get_magic_quotes_gpc() ) { |
| 225 | | $_GET = stripslashes_deep($_GET ); |
| 226 | | $_POST = stripslashes_deep($_POST ); |
| 227 | | $_COOKIE = stripslashes_deep($_COOKIE); |
| 228 | | } |
| 229 | | |
| 230 | | // Escape with wpdb. |
| 231 | | $_GET = add_magic_quotes($_GET ); |
| 232 | | $_POST = add_magic_quotes($_POST ); |
| 233 | | $_COOKIE = add_magic_quotes($_COOKIE); |
| 234 | | $_SERVER = add_magic_quotes($_SERVER); |
| 235 | | |
| 236 | | /* OTHERS |
| 237 | | ------------------------------------*/ |
| 238 | | if(!function_exists('is_admin')): |
| 239 | | function is_admin() {// TO DO |
| 240 | | $admin_check = array(// RegEx |
| 241 | | // zenphoto |
| 242 | | '/zen/', '/admin\.php', |
| 243 | | // vanilla |
| 244 | | '/settings\.php', '/people\.php', '/settings/', '/account/', '/people/', |
| 245 | | // mediawiki |
| 246 | | 'title=Special:Userlog', 'Special:Preferences', 'title=MediaWiki:[^\.]+\.css&', 'title=-&action=', |
| 247 | | // dokuwiki |
| 248 | | '(\?|&)do=login', '(\?|&)do=admin', '(\?|&)do=edit', '(\?|&)do=logout', '(\?|&)do=profile', |
| 249 | | // photostack |
| 250 | | 'organize\.php', |
| 251 | | // phpbb |
| 252 | | '/profile.php', '/login.php', '/admin/' |
| 253 | | ); |
| 254 | | foreach($admin_check as $admin){ |
| 255 | | if(ereg($admin, $_SERVER['REQUEST_URI'])) |
| 256 | | return true; |
| 257 | | } |
| 258 | | global $wgCookiePrefix, $board_config; |
| 259 | | if(isset($_COOKIE['zenphoto_auth'])) { // ZenPhoto |
| | 367 | } elseif (isset($wgCookiePrefix) && isset( $_COOKIE[$wgCookiePrefix.'UserID'] )) { // mediawiki |
| | 368 | return true; |
| | 369 | } elseif (isset($board_config['cookie_name']) && isset($_COOKIE[$board_config['cookie_name'].'_data'])) { // PHPBB |
| | 370 | $phpbb_auth = unserialize(stripslashes($_COOKIE[$board_config['cookie_name'] . '_data'])); |
| | 371 | if($phpbb_auth['userid'] > -1 ) |