Changeset 131

Show
Ignore:
Timestamp:
04/20/08 17:50:20 (7 months ago)
Author:
root
Message:

1.5.1 testing

Location:
trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/action.php

    r130 r131  
    22// action.php -- perform an action that renders an output to the browser 
    33 
    4 //force browser to disable caching to make action.php work as an ajax request 
     4//force browser to disable caching so action.php works as an ajax request 
    55header("Expires: Fri, 22 Jun 2007 05:00:00 GMT"); // Date in the past 
    66header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified 
     
    88header('Cache-Control: no-store, no-cache, must-revalidate'); 
    99header('Cache-Control: post-check=0, pre-check=0', false); 
     10//echo "\n"; 
    1011//#debug... 
    1112//error_reporting(E_ALL | E_STRICT);    //debug, E_STRICT=php5 only 
    1213//ini_set('display_errors','On');       //debug 
    13 //echo "\n"; //debug 
    1414 
    1515//#check for required files and include them 
    1616if (!defined('ABSPATH')) { 
    17         define ('ABSPATH', substr(__FILE__,0,strpos(__FILE__,'/wp-content/')+1)); 
    18         if (file_exists(ABSPATH. 'wp-blog-header.php')) { 
    19                 include_once(ABSPATH. 'wp-blog-header.php'); 
    20         } 
     17        $wpabspath=substr(__FILE__,0,strpos(__FILE__,'/wp-content/')+1); 
     18        if (file_exists($wpabspath. 'wp-blog-header.php')) { 
     19                include_once($wpabspath. 'wp-blog-header.php'); 
     20        } 
     21} else { 
     22        $wpabspath=ABSPATH; 
    2123} 
    2224if (!function_exists('get_bloginfo')) { 
    23         if (file_exists(ABSPATH. 'wp-config.php')) { 
    24                 include_once(ABSPATH.'wp-config.php'); 
     25        if (file_exists($wpabspath. 'wp-config.php')) { 
     26                include_once($wpabspath.'wp-config.php'); 
    2527        } else { 
    26                 echo '<span style="font-color:red;">Action.php '.__('ERROR: file not found','wassup').', '.ABSPATH.'wp-config.php</span>'; 
    27                 exit(); 
     28                //Note: localization functions, _e() and __(), are not used 
     29                //  here because they would not be defined if this error  
     30                //  occurred 
     31                echo '<span style="font-color:red;">Action.php ERROR: file not found, '.$wpabspath.'wp-config.php</span>'; 
     32                die(); 
    2833        } 
    2934} 
     
    3843//echo "Debug: Starting action.php from directory ".dirname(__FILE__).".  ABSPATH=".ABSPATH.".<br />\n"; //debug 
    3944 
     45//#set required variables 
     46$siteurl =  get_bloginfo('siteurl'); 
     47$wpurl =  get_bloginfo('wpurl'); 
     48$table_name = $wpdb->prefix . "wassup"; 
     49$wassup_settings = get_option('wassup_settings'); 
     50if (!defined('WASSUPFOLDER')) { 
     51        define('WASSUPFOLDER', substr(__FILE__,0,strpos(__FILE__,'/lib/')+1)); 
     52} 
     53 
    4054//#do a hash check 
    41 if (function_exists('wp_hash')) {       //in case it was not loaded by WP 
     55$hashfail = true; 
     56if (isset($_GET['whash']) && $_GET['whash'] == $wassup_settings['whash']) { 
    4257        $hashfail = false; 
    43         if (!empty($_GET['whash'])) {  
    44         if (defined('SECRET_KEY') && $_GET['whash'] == wp_hash(SECRET_KEY)) { 
    45                 $hashfail = false; 
    46         } elseif ($_GET['whash'] == wp_hash('wassup')) { 
    47                 $hashfail = false; 
    48         } 
    49         } 
    50 } else { 
    51         $hashfail = true; 
    5258} 
    5359//#perform the "action" and display the result 
     
    7177                exit(); 
    7278        } 
    73  
    74         //#set required variables 
    75         $siteurl =  get_bloginfo('siteurl'); 
    76         $wpurl =  get_bloginfo('wpurl'); 
    77         $table_name = $wpdb->prefix . "wassup"; 
    78         $wassup_settings = get_option('wassup_settings'); 
    7979 
    8080        //#perform action and display output 
     
    138138        // ACTION: RUN TOP TEN 
    139139        } elseif ($_GET['action'] == "topten") { 
     140                $top_ten = unserialize($wassup_settings['wassup_top10']); 
    140141                $sitedomain = parse_url($siteurl); 
    141142                $sitedomain = $sitedomain['host']; 
    142143                if (empty($max_char_len)) { 
    143144                        $max_char_len = ($wassup_settings['wassup_screen_res'])/10; 
     145                } 
     146                //#add an extra width offset when columns count < 5 
     147                $col_count = 0; 
     148                foreach ($top_ten as $topitem) { 
     149                        if ($topitem == 1) { $col_count = $col_count+1; } 
     150                } 
     151                if ($col_count > 0 && $col_count < 5 ) { 
     152                        $widthoffset = (($max_char_len*(5 - $col_count))/$col_count)*.4; //just a guess 
     153                } else {  
     154                        $widthoffset = 0; 
    144155                } 
    145156                //only exclude spam if it is being recorded 
     
    148159                } else { 
    149160                        $spamselect = ""; 
    150                 } 
    151                 $col_count = 0; 
    152                 $top_ten = unserialize($wassup_settings['wassup_top10']); 
    153                 //#get top 10 searches... 
     161                }  
     162        ?> 
     163        <style type="text/css">.top10 { color: #542; }</style> 
     164        <div id="toptenchart"> 
     165        <table width="100%" border=0> 
     166                <tr valign="top"> 
     167                <?php 
     168                //#output top 10 searches 
    154169                if ($top_ten['topsearch'] == 1) { 
    155                         $ch_search = $wpdb->get_results("SELECT count(search) as top_search, search, referrer FROM $table_name WHERE timestamp BETWEEN $from_date AND $to_date AND search!='' $spamselect GROUP BY search ORDER BY top_search DESC LIMIT 10"); 
    156                         $col_count = $col_count+1; 
    157                 } 
    158                 //#get top 10 requests... 
    159                 if ($top_ten['toprequest'] == 1) { 
    160                         $ch_urlreq = $wpdb->get_results("SELECT count(urlrequested) as top_urlrequested, urlrequested FROM $table_name WHERE timestamp BETWEEN $from_date AND $to_date AND urlrequested!='' $spamselect GROUP BY REPLACE(urlrequested, '/', '') ORDER BY top_urlrequested DESC LIMIT 10"); 
    161                         $col_count = $col_count+1; 
    162                 } 
    163                 //#get top 200 referrers...will be narrowed down to 10  
     170                        $top_results =  $wpdb->get_results("SELECT count(search) as top_search, search, referrer FROM $table_name WHERE timestamp BETWEEN $from_date AND $to_date AND search!='' $spamselect GROUP BY search ORDER BY top_search DESC LIMIT 10"); 
     171                        $char_len = round(($max_char_len*.30)+$widthoffset,0); 
     172                ?> 
     173                <td style="min-width:<?php echo $char_len; ?>px;"> 
     174                <ul class="charts"> 
     175                        <li class="chartsT"><?php _e("TOP QUERY", "wassup"); ?></li> 
     176                <?php  
     177                foreach ($top_results as $top10) { ?> 
     178                        <li class="charts"><?php echo $top10->top_search.': <a href="'.$top10->referrer.'" target="_BLANK">'.stringShortener(preg_replace('/'.preg_quote($siteurl,'/').'/i', '', $top10->search),$char_len).'</a>'; ?></li> 
     179                <?php } ?> 
     180                </ul> 
     181                </td> 
     182                <?php 
     183                } // end if topsearch 
     184 
     185                //#output top 10 referrers 
     186                //# select top 200 referrers: will be narrowed down to 10  
    164187                //#  with exclusion of wpurl referrals... 
    165188                if ($top_ten['topreferrer'] == 1) { 
    166                         $ch_referer = $wpdb->get_results("SELECT count(referrer) as top_referrer, referrer FROM $table_name WHERE timestamp BETWEEN $from_date AND $to_date AND referrer!='' AND referrer NOT LIKE '%".$sitedomain."%' AND searchengine='' $spamselect GROUP BY referrer ORDER BY top_referrer DESC LIMIT 200"); 
    167                         $col_count = $col_count+1; 
    168                 } 
    169                 //#get top 10 browsers... 
    170                 if ($top_ten['topbrowser'] == 1) { 
    171                         $ch_browser = $wpdb->get_results("SELECT count(browser) as top_browser, browser FROM $table_name WHERE timestamp BETWEEN $from_date AND $to_date AND browser!='' AND browser NOT LIKE '%N/A%' $spamselect GROUP BY browser ORDER BY top_browser DESC LIMIT 10"); 
    172                         $col_count = $col_count+1; 
    173                 } 
    174                 //#get top 10 operating systems... 
    175                 if ($top_ten['topos'] == 1) { 
    176                         $ch_os = $wpdb->get_results("SELECT count(os) as top_os, os FROM $table_name WHERE timestamp BETWEEN $from_date AND $to_date AND os!='' AND os NOT LIKE '%N/A%' $spamselect GROUP BY os ORDER BY top_os DESC LIMIT 10"); 
    177                         $col_count = $col_count+1; 
    178                 } 
    179  
    180                 //#add an extra width offset when number of columns < 5 
    181                 if ($col_count > 0 && $col_count < 5 ) { 
    182                         $widthoffset = (($max_char_len*(5 - $col_count))/$col_count)*.4; //just a guess 
    183                 } else {  
    184                         $widthoffset = 0; 
    185                 } 
    186         ?> 
    187         <div id="toptenchart"> 
    188                 <table width="100%" border=0> 
    189                 <tr valign="top"> 
    190                 <?php if ($top_ten['topsearch'] == 1) { ?> 
    191                 <td><ul class="charts"> 
    192                         <li class="chartsT"><?php _e("TOP QUERY", "wassup") ?></li> 
    193                 <?php  
    194                 $char_len = round(($max_char_len*.30)+$widthoffset,0); 
    195                 foreach ($ch_search as $chS) {  
    196                         print '<li class="charts">'.$chS->top_search.': <a href="'.$chS->referrer.'" target="_BLANK">'.stringShortener(preg_replace('/'.preg_quote($siteurl,'/').'/i', '', $chS->search),$char_len).'</a></li>'."\n"; 
    197                 } ?> 
    198                 </ul> 
    199                 </td> 
    200                 <?php } 
    201                 if ($top_ten['topreferrer'] == 1) { ?> 
    202                 <td><ul class="charts"> 
    203                         <li class="chartsT"><?php _e("TOP REFERER", "wassup") ?></li> 
    204                 <?php 
    205                 $char_len = round(($max_char_len*.22)+$widthoffset,0); 
     189                        $top_results = $wpdb->get_results("SELECT count(referrer) as top_referrer, referrer FROM $table_name WHERE timestamp BETWEEN $from_date AND $to_date AND referrer!='' AND referrer NOT LIKE '%".$sitedomain."%' AND searchengine='' $spamselect GROUP BY referrer ORDER BY top_referrer DESC LIMIT 200"); 
     190                        $char_len = round(($max_char_len*.22)+$widthoffset,0); 
     191                ?> 
     192                <td style="min-width:<?php echo $char_len; ?>px;"> 
     193                <ul class="charts"> 
     194                        <li class="chartsT"><?php _e("TOP REFERRER", "wassup"); ?></li> 
     195                <?php 
    206196                $rec_count=0;   //# of referrer records output... 
    207                 foreach ($ch_referer as $chR) { 
     197                foreach ($top_results as $top10) { 
    208198                        if ($rec_count < 10) { //limits output to 10... 
    209199                        //# exclude $wpurl from search results... 
    210200                        //# ...$siteurl already excluded in db query. 
    211                         if ($wpurl == $siteurl || !eregi($wpurl,$chR->referrer)) { 
    212                            print '<li class="charts">'.$chR->top_referrer.': '; 
    213                            print '<a href="'.$chR->referrer.'" title="'.$chR->referrer.'" target="_BLANK">'; 
     201                        if ($wpurl == $siteurl || !eregi($wpurl,$top10->referrer)) { ?> 
     202                        <li class="charts"><?php echo $top10->top_referrer.': '; 
     203                           print '<a href="'.$top10->referrer.'" title="'.$top10->referrer.'" target="_BLANK">'; 
    214204                           //#cut http:// from displayed url, then truncate 
    215205                           //#   instead of using stringShortener... 
    216                            print substr(eregi_replace("http://", "", attribute_escape($chR->referrer)),0,$char_len); 
    217                            if (strlen($chR->referrer) > ($char_len + 7)) {  
     206                           print substr(eregi_replace("http://", "", attribute_escape($top10->referrer)),0,$char_len); 
     207                           if (strlen($top10->referrer) > ($char_len + 7)) {  
    218208                                print '...'; 
    219209                           } 
    220                            print '</a></li>'."\n"; 
     210                           print '</a>'; ?></li> 
     211                           <?php 
    221212                           $rec_count=$rec_count+1; 
    222213                        } //end if !wpurl 
    223214                        } //end if rec_count 
    224                 } ?> 
     215                } //end foreach ?> 
    225216                </ul> 
    226217                </td> 
    227                 <?php }  
    228                 if ($top_ten['toprequest'] == 1) {  ?> 
    229                 <td><ul class="charts"> 
    230                         <li class="chartsT"><?php _e("TOP REQUEST", "wassup") ?></li> 
    231                 <?php 
    232                 $char_len = round(($max_char_len*.28)+$widthoffset,0); 
    233                 foreach ($ch_urlreq as $chU) {  
    234                         print '<li class="charts">'.$chU->top_urlrequested.': '; 
    235                         print '<a href="'.wAddSiteurl(htmlspecialchars(html_entity_decode($chU->urlrequested))).'" title="'.html_entity_decode($chU->urlrequested).'" target="_BLANK">'; 
    236                         print stringShortener(urlencode(html_entity_decode($chU->urlrequested)),$char_len).'</a></li>'."\n"; 
    237                 } ?> 
    238                 </ul> 
    239                 </td> 
    240                 <?php }  
    241                 if ($top_ten['topbrowser'] == 1) {  ?> 
    242                 <td><ul class="charts"> 
     218                <?php 
     219                } //end if topreferrer 
     220 
     221                //#output top 10 url requests 
     222                if ($top_ten['toprequest'] == 1) { 
     223                        $top_results = $wpdb->get_results("SELECT count(urlrequested) as top_urlrequested, urlrequested FROM $table_name WHERE timestamp BETWEEN $from_date AND $to_date AND urlrequested!='' $spamselect GROUP BY REPLACE(urlrequested, '/', '') ORDER BY top_urlrequested DESC LIMIT 10"); 
     224                        $char_len = round(($max_char_len*.28)+$widthoffset,0); 
     225                 ?> 
     226                <td style="min-width:<?php echo $char_len; ?>px;"> 
     227                <ul class="charts"> 
     228                        <li class="chartsT"><?php _e("TOP REQUEST", "wassup"); ?></li> 
     229                <?php 
     230                foreach ($top_results as $top10) { ?> 
     231                        <li class="charts"><?php echo $top10->top_urlrequested.': '; 
     232                        print '<a href="'.wAddSiteurl(htmlspecialchars(html_entity_decode($top10->urlrequested))).'" title="'.html_entity_decode($top10->urlrequested).'" target="_BLANK">'; 
     233                        print stringShortener(urlencode(html_entity_decode($top10->urlrequested)),$char_len).'</a>'; ?></li> 
     234                <?php } ?> 
     235                </ul> 
     236                </td> 
     237                <?php  
     238                } //end if toprequest 
     239 
     240                //#get top 10 browsers... 
     241                if ($top_ten['topbrowser'] == 1) { 
     242                        $top_results = $wpdb->get_results("SELECT count(browser) as top_browser, browser FROM $table_name WHERE timestamp BETWEEN $from_date AND $to_date AND browser!='' AND browser NOT LIKE '%N/A%' $spamselect GROUP BY browser ORDER BY top_browser DESC LIMIT 10"); 
     243                        $char_len = round(($max_char_len*.17)+$widthoffset,0); 
     244                ?> 
     245                <td style="min-width:<?php echo $char_len; ?>px;"> 
     246                <ul class="charts"> 
    243247                        <li class="chartsT"><?php _e("TOP BROWSER", "wassup") ?></li> 
    244248                <?php 
    245                 $char_len = round(($max_char_len*.17)+$widthoffset,0); 
    246                 foreach ($ch_browser as $chB) {  
    247                         print '<li class="charts"><span title="'.$chB->browser.'">'; 
    248                         print $chB->top_browser.': '.stringShortener($chB->browser, $char_len); 
    249                         print '</span></li>'."\n"; 
    250                 } ?> 
    251                 </ul> 
    252                 </td> 
    253                 <?php }  
    254                 if ($top_ten['topos'] == 1) {  ?> 
    255                 <td><ul class="charts"> 
     249                foreach ($top_results as $top10) { ?> 
     250                        <li class="charts"><?php echo $top10->top_browser.': '; 
     251                        echo '<span class="top10" title="'.$top10->browser.'">'.stringShortener($top10->browser, $char_len).'</span>'; ?> 
     252                        </li> 
     253                <?php } ?> 
     254                </ul> 
     255                </td> 
     256                <?php }  //end if topbrowser 
     257 
     258                //#output top 10 operating systems... 
     259                if ($top_ten['topos'] == 1) {  
     260                        $top_results = $wpdb->get_results("SELECT count(os) as top_os, os FROM $table_name WHERE timestamp BETWEEN $from_date AND $to_date AND os!='' AND os NOT LIKE '%N/A%' $spamselect GROUP BY os ORDER BY top_os DESC LIMIT 10"); 
     261                        $char_len = round(($max_char_len*.15)+$widthoffset,0); 
     262                 
     263                 ?> 
     264                <td style="min-width:<?php echo $char_len; ?>px;"> 
     265                <ul class="charts"> 
    256266                        <li class="chartsT"><?php _e("TOP OS", "wassup") ?></li> 
    257267                <?php  
    258                 $char_len = round(($max_char_len*.15)+$widthoffset,0); 
    259                 foreach ($ch_os as $chO) {  
    260                         print '<li class="charts"><span title="'.$chO->os.'">'; 
    261                         print $chO->top_os.': '.stringShortener($chO->os, $char_len); 
    262                         print '</span></li>'."\n"; 
    263                 } ?> 
    264                 </ul> 
    265                 </td> 
    266                 <?php } ?> 
     268                foreach ($top_results as $top10) { ?> 
     269                        <li class="charts"><?php print $top10->top_os.': '; ?> 
     270                                <span class="top10" title="<?php echo $top10->os; ?>"><?php echo stringShortener($top10->os, $char_len); ?></span> 
     271                        </li> 
     272                <?php } ?> 
     273                </ul> 
     274                </td> 
     275                <?php } // end if topos 
     276                 
     277                //#output top 10 locales/geographic regions... 
     278                if ($top_ten['toplocale'] == 1) { 
     279                        $top_results = $wpdb->get_results("SELECT count(UPPER(language)) as top_locale, UPPER(language) as locale FROM $table_name WHERE timestamp BETWEEN $from_date AND $to_date AND language!='' AND language NOT LIKE '%N/A%' $spamselect GROUP BY locale ORDER BY top_locale DESC LIMIT 10"); 
     280                        $char_len = round(($max_char_len*.15)+$widthoffset,0); 
     281                 
     282                 ?> 
     283                <td style="min-width:<?php echo $char_len; ?>px;"> 
     284                <ul class="charts"> 
     285                        <li class="chartsT"><?php _e("TOP LOCALE", "wassup"); ?></li> 
     286                <?php  
     287                foreach ($top_results as $top10) { ?> 
     288                        <li class="charts"><?php echo $top10->top_locale.': '; 
     289                        echo '<img src="'.$wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/img/flags/'.strtolower($top10->locale).'.png" alt="" />'; ?> 
     290                        <span class="top10" title="<?php echo $top10->locale; ?>"><?php echo $top10->locale; ?></span> 
     291                        </li> 
     292                <?php } ?> 
     293                </ul> 
     294                </td> 
     295                <?php } // end if toplocale 
     296                ?> 
    267297                </tr> 
    268298                </table> 
  • trunk/lib/settings.php

    r124 r131  
    116116                <input type="checkbox" name="topbrowser" value="1" <?php if($top_ten['topbrowser'] == 1) print "CHECKED"; ?> /><?php _e("Top Browsers", "wassup"); ?> <br /> 
    117117                <input type="checkbox" name="topos" value="1" <?php if($top_ten['topos'] == 1) print "CHECKED"; ?> /><?php _e("Top OS", "wassup"); ?> <br /> 
    118                 <input type="checkbox" name="toplocale" value="1" DISABLED /><span style="color:#555;"><?php _e("Top Locales", "wassup"); ?></span><br /> 
     118                <input type="checkbox" name="toplocale" value="1" <?php if($top_ten['topos'] == 1) print "CHECKED"; ?> /><?php _e("Top Locales", "wassup"); ?></span><br /> 
    119119                </div> 
    120120                <div style="display:block; vertical-align:top; float:left; width:225px; color:#555;"> 
  • trunk/lib/wassup.class.php

    r124 r131  
    3636        var $wassup_remind_flag; 
    3737        var $wassup_uninstall;  //for complete uninstall of wassup 
    38         var $wassup_optimize;   //new - for optimize table once a day 
     38        var $wassup_optimize;   //for optimize table once a day 
    3939 
    4040        /* chart display settings */ 
     
    6161        var $wmark; 
    6262        var $wip; 
     63        var $whash = "";        //new - wp_hash value used by action.php 
    6364 
    6465        /* Constructor */ 
     
    108109                $this->wassup_uninstall = "0"; 
    109110                $this->wassup_optimize = wassup_get_time(); 
    110                 //$this->wassup_top10 = array("1","1","1","1","1","0","0","0","0","0"); 
    111111                $this->wassup_top10 = serialize(array("topsearch"=>"1", 
    112112                                        "topreferrer"=>"1", 
     
    118118                                        "topcrawler"=>"0", 
    119119                                        "topvisitor"=>"0")); 
     120                $this->whash = $this->get_wp_hash(); 
    120121        } 
    121122 
     
    293294        } 
    294295 
     296        //#Set a wp_hash value and return it 
     297        function get_wp_hash($hashkey="") { 
     298                $wassuphash = ""; 
     299                if (function_exists('wp_hash')) {  
     300                        if (empty($hashkey)) { 
     301                                if (defined('SECRET_KEY')) {  
     302                                        $hashkey = SECRET_KEY; 
     303                                } else {  
     304                                        $hashkey = "wassup"; 
     305                                } 
     306                        } 
     307                        $wassuphash = wp_hash($hashkey); 
     308                } 
     309                return $wassuphash; 
     310        } //end function get_wp_hash 
     311 
    295312        //#show a system message in Wassup Admin menus 
    296313        function showMessage($message="") { 
  • trunk/wassup.php

    r130 r131  
    2121require_once(dirname(__FILE__).'/lib/wassup.class.php'); 
    2222require_once(dirname(__FILE__).'/lib/main.php'); 
    23 $wpurl = get_bloginfo('wpurl'); 
     23$wpurl = get_bloginfo('wpurl'); //global 
    2424 
    2525if (isset($_GET['export'])) { 
     
    4141        add_action('admin_menu', 'wassup_add_pages'); 
    4242        add_action('send_headers', 'wassupAppend'); 
    43         //add_action('activity_box_end', 'wassupDashChart'); 
     43        add_action('activity_box_end', 'wassupDashChart'); 
    4444} 
    4545 
     
    5252        $wassup_options = new wassupOptions; //#settings initialized here 
    5353 
    54         // Add timestamp to optimize table once a day 
     54        //# set hash 
     55        $whash = $wassup_options->get_wp_hash(); 
     56        if (!empty($whash)) { 
     57                $wassup_options->whash = $whash; 
     58        } 
     59        //# Add timestamp to optimize table once a day 
    5560        $wassup_options->wassup_optimize = wassup_get_time(); 
    56         // 
    57         //### For upgrade of Wassup, manually initialize any new settings 
     61 
     62        //# set wmark and wip to null   
     63        $wassup_options->wmark = 0;     //#no preservation of delete/mark 
     64        $wassup_options->wip = null; 
     65 
     66        //### For upgrade of Wassup, manually initialize new settings 
    5867        //# initialize settings for 'spamcheck', 'refspam', and 'spam' 
    5968        if (!isset($wassup_options->wassup_spamcheck)) { 
     
    6877        } 
    6978        //# update wassup settings for 'savepath' (default is null) 
     79        //$wassup_options->wassup_savepath = "/fakedirectory"; //#debug 
    7080        if (!isset($wassup_options->wassup_savepath)) { 
    7181                $wassup_options->wassup_savepath = null; 
     
    7585                $wassup_options->wassup_chart = 1; 
    7686        } 
    77         //# set wmark, and wip to null   
    78         $wassup_options->wmark = 0;     //#no preservation of delete/mark 
    79         $wassup_options->wip = null; 
    80  
    81         //$wassup_options->wassup_savepath = "/fakedirectory"; //#debug 
     87        //# assign top ten items for upgrades from 1.4.9 or less 
     88        if (empty($wassup_options->wassup_top10)) { 
     89                $wassup_options->wassup_top10 = serialize(array("topsearch"=>"1", 
     90                                                "topreferrer"=>"1", 
     91                                                "toprequest"=>"1", 
     92                                                "topbrowser"=>"1", 
     93                                                "topos"=>"1", 
     94                                                "toplocale"=>"0", 
     95                                                "topfeed"=>"0", 
     96                                                "topcrawler"=>"0", 
     97                                                "topvisitor"=>"0")); 
     98        } 
    8299        $wassup_options->saveSettings(); 
    83100 
     
    95112                } 
    96113                $wassup_options->saveSettings(); 
    97         } 
     114        } 
     115        unset($sessionpath); //because "install" works in global scope 
     116 
    98117        //# TODO: 
    99118        //###Detect known incompatible plugins like "wp_cache" and disable  
    100119        //#  recordings and show warning message... 
    101120 
    102         //### Create wassup TMP table 
    103         $table_tmp_name = $wpdb->prefix . "wassup_tmp"; 
    104         if ($wpdb->get_var("SHOW TABLES LIKE '$table_tmp_name'") != $table_tmp_name) {  
    105                 CreateTable("wassup_tmp"); 
    106         } 
    107121        //### Create/upgrade wassup MAIN table 
    108122        $table_name = $wpdb->prefix . "wassup"; 
    109123        if ($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {  
    110124                CreateTable("wassup"); 
     125                CreateTable("wassup_tmp"); 
    111126        } else { 
    112                 UpdateTable(); 
     127                UpdateTable(); //<== wassup_tmp is added here, if missing 
    113128        } 
    114129} //#end function wassup_install 
    115130 
     131//set global variables that are dependent on Wassup's wp_options values 
    116132$wassup_settings = get_option('wassup_settings'); //temp only.. 
    117133$wassup_options = new wassupOptions;  
    118134//$wassup_options->loadSettings();      //done automatically  
     135$whash = $wassup_options->whash;        //global... 
    119136 
    120137//#Completely remove all wassup tables and options from Wordpress when 
     
    172189//Add the wassup stylesheet and other javascripts... 
    173190function add_wassup_css() { 
    174         global $wpurl, $wassup_options; 
    175  
    176         //'wp_hash' is not available until all plugins are loaded 
    177         if (function_exists('wp_hash')) { 
    178                 if (defined('SECRET_KEY')) { $whash = wp_hash(SECRET_KEY); } 
    179                 else { $whash = wp_hash('wassup'); } 
    180         } else { 
    181                 $whash = ""; 
     191        global $wpurl, $wassup_options, $whash; 
     192 
     193        //assign a value to whash, if none 
     194        if ($whash == "") { 
     195                $whash = $wassup_options->get_wp_hash(); 
     196                $wassup_options->whash = $whash;        //save new hash 
     197                $wassup_options->saveSettings(); 
    182198        } 
    183199 
     
    255271           var id = $(this).attr('id'); 
    256272                 $.ajax({ 
    257                   url: "<?php echo $wpurl; ?>/wp-content/plugins/<?php echo WASSUPFOLDER; ?>/lib/action.php?action=delete&whash=<?php echo $whash; ?>&id=" + id, 
     273                  url: "<?php echo $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/lib/action.php?action=delete&whash='.$whash; ?>&id=" + id, 
    258274                  async: false 
    259275                 }) 
     
    384400        global $wpdb, $version, $wpurl, $wassup_options, $whash; 
    385401 
     402        //#debug... 
     403        //error_reporting(E_ALL);       //debug 
     404        //ini_set('display_errors','On');       //debug 
     405 
    386406        //assign a value to whash, if none 
    387         if (function_exists('wp_hash') && $whash == "") { 
    388                 if (defined('SECRET_KEY')) { 
    389                         $whash = wp_hash(SECRET_KEY); 
    390                 } else { 
    391                         $whash = wp_hash('wassup'); 
    392                 } 
    393         } 
     407        //if ($whash == "") { 
     408        //      $whash = $wassup_options->get_wp_hash(); 
     409        //      $wassup_options->whash = $whash;        //save new whash