Changeset 386

Show
Ignore:
Timestamp:
07/26/08 09:55:51 (4 months ago)
Author:
082net
Message:

## wp-slimstat-ex ##

Fixed activation error
Fixed GeoIP detection
Fixed upgrade routine
Supports external tracking with Javascript

Location:
wp-slimstat-ex
Files:
2 added
8 modified

Legend:

Unmodified
Added
Removed
  • wp-slimstat-ex/branches/pins/GeoSlimStat/pin.php

    r376 r386  
    585585                                        if(!$wpdb->get_row($query)) { 
    586586//                                              timer_start(); 
    587                                                 if ( strpos($SlimCfg->geoip, 'city') !== false ) { 
     587                                                if ( $SlimCfg->geoip == 'city' ) { 
    588588                                                        $this->queryHostIP_bin($r['remote_ip']); 
    589589                                                } else if ( function_exists('curl_multi_init') ) { 
  • wp-slimstat-ex/trunk/lib/external-inc.php

    r385 r386  
    77/* BEGIN wp-settings.php  
    88---------------------------------------------------------------*/ 
    9 // Turn register globals off 
     9if ( !defined('WP_MEMORY_LIMIT') ) 
     10        define('WP_MEMORY_LIMIT', '32M'); 
     11 
     12if ( function_exists('memory_get_usage') && ( (int) @ini_get('memory_limit') < abs(intval(WP_MEMORY_LIMIT)) ) ) 
     13        @ini_set('memory_limit', WP_MEMORY_LIMIT); 
     14 
     15 
     16if (!function_exists('wp_unregister_globals')) : 
    1017function wp_unregister_GLOBALS() { 
    1118        if ( !ini_get('register_globals') ) 
     
    1926 
    2027        $input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array()); 
    21         foreach ( $input as $k => $v )  
     28        foreach ( $input as $k => $v ) 
    2229                if ( !in_array($k, $noUnset) && isset($GLOBALS[$k]) ) { 
    2330                        $GLOBALS[$k] = NULL; 
     
    2532                } 
    2633} 
    27  
    28 wp_unregister_GLOBALS();  
    29  
     34endif; 
     35wp_unregister_GLOBALS(); 
     36 
     37unset( $wp_filter, $cache_lastcommentmodified, $cache_lastpostdate ); 
     38 
     39/** 
     40 * The $blog_id global, which you can change in the config allows you to create a simple 
     41 * multiple blog installation using just one WordPress and changing $blog_id around. 
     42 * 
     43 * @global int $blog_id 
     44 * @since 2.0.0 
     45 */ 
    3046if ( ! isset($blog_id) ) 
    3147        $blog_id = 1; 
     
    3349// Fix for IIS, which doesn't set REQUEST_URI 
    3450if ( empty( $_SERVER['REQUEST_URI'] ) ) { 
    35         $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']; // Does this work under CGI? 
    36  
    37         // Append the query string if it exists and isn't null 
    38         if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) { 
    39                 $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; 
     51 
     52        // IIS Mod-Rewrite 
     53        if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) { 
     54                $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL']; 
     55        } 
     56        // IIS Isapi_Rewrite 
     57        else if (isset($_SERVER['HTTP_X_REWRITE_URL'])) { 
     58                $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL']; 
     59        } 
     60        else 
     61        { 
     62                // Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice) 
     63                if ( isset($_SERVER['PATH_INFO']) ) { 
     64                        if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] ) 
     65                                $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO']; 
     66                        else 
     67                                $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO']; 
     68                } 
     69 
     70                // Append the query string if it exists and isn't null 
     71                if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) { 
     72                        $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; 
     73                } 
    4074        } 
    4175} 
     
    5488        $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace("/(\?.*)?$/",'',$_SERVER["REQUEST_URI"]); 
    5589 
    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] ) : 
     90if ( 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. 
     95if (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 
     103require($WP_ROOT_PATH.'wp-includes/version.php'); 
     104if( strpos($wp_version, 'wordpress-mu') !== false || isset($wporg_version) || isset($wpmu_version) ) 
     105        return;// external tracking does not support wpmu by now. 
     106 
     107require_once ($WP_ROOT_PATH . 'wp-includes/compat.php'); 
     108 
     109/* START functions.php  
     110------------------------------------*/ 
     111if(!function_exists('get_option')) : 
     112function 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} 
     161endif; 
     162if(!function_exists('is_serialized')) : 
     163function 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] ) { 
    109173                case 'a' : 
    110174                case 'O' : 
    111175                case 's' : 
    112                         if ( preg_match("/^{$badions[1]}:[0-9]+:.*[;}]\$/s", $data) ) 
     176                        if ( preg_match( "/^{$badions[1]}:[0-9]+:.*[;}]\$/s", $data ) ) 
    113177                                return true; 
    114178                        break; 
     
    116180                case 'i' : 
    117181                case 'd' : 
    118                         if ( preg_match("/^{$badions[1]}:[0-9.E-]+;\$/", $data) ) 
     182                        if ( preg_match( "/^{$badions[1]}:[0-9.E-]+;\$/", $data ) ) 
    119183                                return true; 
    120184                        break; 
    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} 
     188endif; 
     189if(!function_exists('maybe_unserialize')) : 
     190function 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} 
     196endif; 
     197if(!function_exists('add_magic_quotes')): 
     198function 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} 
     210endif; 
     211/* END functions.php 
     212------------------------------------*/ 
     213 
     214/* START wp-db.php  
     215------------------------------------*/ 
     216if(!class_exists('wpdb')) : 
     217// prevent WP default wpdb instance 
     218$wpdb = ''; 
     219require_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']); 
     222endif; 
     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 
     231require_once ($WP_ROOT_PATH . 'wp-includes/cache.php'); 
     232 
     233wp_cache_init(); 
     234 
     235 
     236/* START formatting.php  
     237------------------------------------*/ 
     238if(!function_exists('backslashit')): 
     239function backslashit($string) { 
     240        $string = preg_replace('/^([0-9])/', '\\\\\\\\\1', $string); 
     241        $string = preg_replace('/([a-z])/i', '\\\\\1', $string); 
     242        return $string; 
     243} 
     244endif; 
     245if(!function_exists('trailingslashit')): 
     246function trailingslashit($string) { 
     247        return untrailingslashit($string) . '/'; 
     248} 
     249endif; 
     250if(!function_exists('untrailingslashit')): 
     251function untrailingslashit($string) { 
     252        return rtrim($string, '/'); 
     253} 
     254endif; 
     255if(!function_exists('addslashes_gpc')): 
     256function 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} 
     265endif; 
     266if(!function_exists('stripslashes_deep')): 
     267function stripslashes_deep($value) { 
     268         $value = is_array($value) ? 
     269                 array_map('stripslashes_deep', $value) : 
     270                 stripslashes($value); 
     271 
     272         return $value; 
     273} 
     274endif; 
     275if(!function_exists('seems_utf8')): 
     276function 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} 
     293endif; 
     294/* END formatting.php  
     295------------------------------------*/ 
     296 
     297/* START deprecated.php  
     298------------------------------------*/ 
     299if(!function_exists('get_settings')) : 
     300function get_settings($option) { 
     301        return get_option($option); 
     302} 
     303endif; 
     304/* END deprecated.php  
     305------------------------------------*/ 
     306 
     307/* Start plugin.php 
     308------------------------------------*/ 
     309if (!function_exists('plugin_basename')) : 
     310function 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} 
     318endif; 
     319/* END plugin.php  
     320------------------------------------*/ 
     321 
     322/* CONTINUE wp-settings.php  
     323------------------------------------*/ 
     324if (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. 
     330if ( 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------------------------------------*/ 
     344if(!function_exists('is_admin')): 
     345function 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 
    190366                return true; 
    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 ) 
    260372                        return true; 
    261                 } elseif (isset($wgCookiePrefix) && isset( $_COOKIE[$wgCookiePrefix.'UserID'] )) { // mediawiki 
    262                         return true; 
    263                 } elseif (isset($board_config['cookie_name']) && isset($_COOKIE[$board_config['cookie_name'].'_data'])) { // PHPBB 
    264                         $phpbb_auth = unserialize(stripslashes($_COOKIE[$board_config['cookie_name'] . '_data'])); 
    265                         if($phpbb_auth['userid'] > -1 ) 
    266                                 return true; 
    267                 } elseif (isset($_COOKIE['DokuWiki'])) { // DokuWiki 
    268                         return true; 
    269                 } 
    270                 return false; 
    271         } 
    272         endif; 
    273  
    274         include( SLIMSTATPATH . "wp-slimstat-ex-config.php" ); 
    275         $GLOBALS['SlimCfg'] =& $SlimCfg; 
     373        } elseif (isset($_COOKIE['DokuWiki'])) { // DokuWiki 
     374                return true; 
     375        } 
     376        return false; 
     377} 
     378endif; 
     379 
     380require_once ( SLIMSTATPATH . "wp-slimstat-ex-config.php" ); 
     381//$GLOBALS['SlimCfg'] =& $SlimCfg; 
     382if (!isset($GLOBALS['slimtrack_ext'])) 
    276383        $GLOBALS['slimtrack_ext'] =& $slimtrack_ext; 
    277         if ( $SlimCfg->geoip != 'mysql' ) { 
    278                 if ( !function_exists('geoip_country_code_by_name') ) 
    279                         require_once(SLIMSTATPATH . 'lib/geoip/geoipcity.inc'); 
    280                 require_once(SLIMSTATPATH . 'lib/geoip/geoipregionvars.php'); 
    281         } 
    282  
    283         include( SLIMSTATPATH . "lib/track.php" ); 
    284  
    285         $SSTrack->slimtrack(); 
    286         // destruct all. 
    287         $SlimCfg->geoip_close(); 
    288         mysql_close($GLOBALS['wpdb']->dbh); 
    289         $GLOBALS['wpdb'] = $GLOBALS['SlimCfg'] = $GLOBALS['slimtrack_ext'] = $wpdb = $SlimCfg = $slimtrack_ext = $SSTrack = null; 
    290         unset($GLOBALS['wpdb'], $GLOBALS['SlimCfg'], $GLOBALS['slimtrack_ext'], $wpdb, $SlimCfg, $slimtrack_ext, $SSTrack); 
     384if ( $SlimCfg->geoip != 'mysql' ) { 
     385        if ( !function_exists('geoip_country_code_by_name') ) 
     386                require_once(SLIMSTATPATH . 'lib/geoip/geoipcity.inc'); 
     387        require_once(SLIMSTATPATH . 'lib/geoip/geoipregionvars.php'); 
     388} 
     389// using javascript? 
     390if (isset($_GET['php_track'])) { 
     391        $_SERVER["HTTP_REFERER"] = urldecode($_GET["ref"]); 
     392         
     393        $url = @parse_url( urldecode($_GET["res"]) ); 
     394        if ( isset( $url["path"] ) ) { 
     395                if ( isset( $url["query"] ) ) { 
     396                        $_SERVER["REQUEST_URI"] = $url["path"]."?".$url["query"]; 
     397                } else { 
     398                        $_SERVER["REQUEST_URI"] = $url["path"]; 
     399                } 
     400        } 
     401} 
     402require_once ( SLIMSTATPATH . "lib/track.php" ); 
     403$SSTrack->slimtrack(); 
     404 
     405// destruct all. 
     406$SlimCfg->geoip_close(); 
     407mysql_close($GLOBALS['wpdb']->dbh); 
     408$GLOBALS['wpdb'] = $GLOBALS['SlimCfg'] = $GLOBALS['slimtrack_ext'] = $wpdb = $SlimCfg = $slimtrack_ext = $SSTrack = null; 
     409unset($GLOBALS['wpdb'], $GLOBALS['SlimCfg'], $GLOBALS['slimtrack_ext'], $wpdb, $SlimCfg, $slimtrack_ext, $SSTrack); 
    291410 
    292411}// End of sstrack_external 
    293412 
    294 register_shutdown_function('sstrack_external'); 
     413//if (!isset($_GET['php_track'])) 
     414        register_shutdown_function('sstrack_external'); 
    295415 
    296416/* External PHP program tracking END 
  • wp-slimstat-ex/trunk/lib/setup.php

    r379 r386  
    2121                        SSSetup::_importCountriesData(); 
    2222                } 
    23                 return wp_slimstat_ex::check_current_version();