Plugin Directory

Changeset 411180


Ignore:
Timestamp:
07/17/2011 09:23:51 PM (15 years ago)
Author:
Beaver6813
Message:

Merged pathParse and pathSign into one serialized array

Location:
infinite-scroll/branches/Beta
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • infinite-scroll/branches/Beta/infinitescroll.init.js.php

    r411053 r411180  
    99License   : http://creativecommons.org/licenses/GPL/2.0/
    1010*/
     11define('infscr_version'     ,   '2.0b2.110716');
     12
    1113header('Content-Type: application/javascript');
    1214require_once( '../../../wp-load.php' );
    1315wp();
    14 
    15 define('infscr_version'     ,   '2.0b2.110716');
    1616
    1717function outputLicense()
     
    3434//Get pathParse and validate it.
    3535$error = false;
    36 if((!empty($_GET['p'])&&!empty($_GET['s']))&&($_GET['s']==md5(NONCE_KEY.$_GET['p']."infscr".infscr_version)))
     36if($pathInfo = unserialize(base64_decode($_GET['p'])))
    3737    {
    38     if(!$pathParse = unserialize(base64_decode($_GET['p'])))
    39         $error = true;
     38    if(empty($pathInfo[0])||count($pathInfo[0])<2||empty($pathInfo[1])||$pathInfo[1]!=md5(NONCE_KEY.$pathInfo[0][0]."infscr".$pathInfo[0][1].infscr_version))
     39        $error = true;     
    4040    }
    4141else
     
    9090                    contentSelector : "'.$content_selector.'",
    9191                    itemSelector    : "'.$post_selector.'",
    92                     pathParse       : ["'.$pathParse[0].'", "'.$pathParse[1].'"]
     92                    pathParse       : ["'.$pathInfo[0][0].'", "'.$pathInfo[0][1].'"]
    9393                    }, function() { window.setTimeout(infinite_scroll_callback(), 1); } );
    9494                    });';
     
    9898        echo file_get_contents("js/jquery.infinitescroll.min.js");
    9999        echo 'function infinite_scroll_callback(){'.$js_calls.'}
    100 jQuery(document).ready(function($){$("'.$content_selector.'").infinitescroll({debug:'.$debug.',loading:{img:"'.$loading_image.'",msgText:"'.$loading_text.'",finishedMsg:"'.$donetext.'"},state:{currPage:"'.$current_page.'"},nextSelector:"'.$next_selector.'",navSelector:"'.$navigation_selector.'",contentSelector:"'.$content_selector.'",itemSelector:"'.$post_selector.'",pathParse:["'.$pathParse[0].'","'.$pathParse[1].'"]},function(){window.setTimeout(infinite_scroll_callback(),1);});});';
     100jQuery(document).ready(function($){$("'.$content_selector.'").infinitescroll({debug:'.$debug.',loading:{img:"'.$loading_image.'",msgText:"'.$loading_text.'",finishedMsg:"'.$donetext.'"},state:{currPage:"'.$current_page.'"},nextSelector:"'.$next_selector.'",navSelector:"'.$navigation_selector.'",contentSelector:"'.$content_selector.'",itemSelector:"'.$post_selector.'",pathParse:["'.$pathInfo[0][0].'","'.$pathInfo[0][1].'"]},function(){window.setTimeout(infinite_scroll_callback(),1);});});';
    101101        }   
    102102    }
  • infinite-scroll/branches/Beta/wp_infinite_scroll.php

    r411053 r411180  
    88Author URI: http://www.infinite-scroll.com
    99License   : http://creativecommons.org/licenses/GPL/2.0/
    10 
    11 
    12 BUGS:
    13  - javascript insertion doesnt work on themes: qwiilm!, craving4green, Lush, no limits, stripedplus   
    14  - Note: Above bug left over from old plugin. Needs verifying.
    1510*/
    1611define('infscr_version'     ,   '2.0b2.110716');
     
    1813define('infscr_enabled'     , 'enabled');
    1914define('infscr_disabled'    , 'disabled');
    20 define('infscr_config'  , 'enabledforadmins');
    21 define('infscr_maint'   , 'disabledforadmins');
     15define('infscr_config'      , 'enabledforadmins');
     16define('infscr_maint'       , 'disabledforadmins');
    2217
    2318
    2419// options keys constants
    25 define('key_infscr_state'           , 'infscr_state');
     20define('key_infscr_state'               , 'infscr_state');
    2621define('key_infscr_js_calls'            , 'infscr_js_calls');
    27 define('key_infscr_image'           , 'infscr_image');
    28 define('key_infscr_text'            , 'infscr_text');
     22define('key_infscr_image'               , 'infscr_image');
     23define('key_infscr_text'                , 'infscr_text');
    2924define('key_infscr_donetext'            , 'infscr_donetext');
    30 define('key_infscr_content_selector'        , 'infscr_content_selector');
     25define('key_infscr_content_selector'    , 'infscr_content_selector');
    3126define('key_infscr_nav_selector'        , 'infscr_nav_selector');
    3227define('key_infscr_post_selector'       , 'infscr_post_selector');
     
    3429
    3530// add options and defaults
    36 add_option(key_infscr_state     , infscr_config         , 'If InfiniteScroll is turned on, off, or in maintenance');
    37 add_option(key_infscr_js_calls      , ''        , 'Javascript to execute when new content loads in');
    38 add_option(key_infscr_image     , plugins_url( 'infinite-scroll/ajax-loader.gif')           , 'Loading image');
    39 add_option(key_infscr_text      , '<em>Loading the next set of posts...</em>'           , 'Loading text');
    40 add_option(key_infscr_donetext      , '<em>Congratulations, you\'ve reached the end of the internet.</em>'          , 'Completed text');
    41 add_option(key_infscr_content_selector  , '#content'    , 'Content Div css selector');
    42 add_option(key_infscr_nav_selector  , 'div.navigation'      , 'Navigation Div css selector');
    43 add_option(key_infscr_post_selector     , '#content  div.post'      , 'Post Div css selector');
    44 add_option(key_infscr_next_selector     , 'div.navigation a:first'      , 'Next page Anchor css selector');
    45 add_option(key_infscr_viewed_options    , false     , 'Ever Viewed Options Page');
    46 add_option(key_infscr_debug     , 0     , 'Debug Mode');
     31add_option(key_infscr_state             , infscr_config         , 'If InfiniteScroll is turned on, off, or in maintenance');
     32add_option(key_infscr_js_calls          , ''                    , 'Javascript to execute when new content loads in');
     33add_option(key_infscr_image             , plugins_url( 'infinite-scroll/ajax-loader.gif')                       , 'Loading image');
     34add_option(key_infscr_text              , '<em>Loading the next set of posts...</em>'                           , 'Loading text');
     35add_option(key_infscr_donetext          , '<em>Congratulations, you\'ve reached the end of the internet.</em>'  , 'Completed text');
     36add_option(key_infscr_content_selector  , '#content'                                                            , 'Content Div css selector');
     37add_option(key_infscr_nav_selector      , 'div.navigation'                                                      , 'Navigation Div css selector');
     38add_option(key_infscr_post_selector     , '#content  div.post'                                                  , 'Post Div css selector');
     39add_option(key_infscr_next_selector     , 'div.navigation a:first'                                              , 'Next page Anchor css selector');
     40add_option(key_infscr_viewed_options    , false                                                                 , 'Ever Viewed Options Page');
     41add_option(key_infscr_debug             , 0                                                                     , 'Debug Mode');
    4742
    4843// adding actions
    4944add_action('template_redirect'  , 'wp_inf_scroll_pre_init');
    50 add_action('admin_menu'     , 'add_wp_inf_scroll_options_page');
    51 add_action("wp"             , 'wp_inf_scroll_404');
     45add_action('admin_menu'         , 'add_wp_inf_scroll_options_page');
     46add_action("wp"                 , 'wp_inf_scroll_404');
    5247
    5348if ( get_option(key_infscr_state) == infscr_state_default && get_option(key_infscr_viewed_options) == false && !isset($_POST['submit']) )
     
    112107installations.
    113108Added Build: 110628 */
    114 function wp_inf_scroll_get_pagenum_link() {
     109function wp_inf_scroll_get_pagenum_link()
     110    {
    115111    global $wp_rewrite;
    116112
     
    152148    $result = apply_filters('get_pagenum_link', $result);
    153149    return explode("|||INF-SPLITHERE|||",$result);
    154 }
     150    }
    155151function wp_inf_scroll_init()
    156152    {
    157153    global $user_level;
    158     $load_infinite_scroll = true;
    159     $error_reason = "";
    160    
     154    $load_infinite_scroll = true;   
    161155    /* Lets start our pre-flight checks */
    162     if (get_option(key_infscr_state) == infscr_disabled)
     156    if (get_option(key_infscr_state) == infscr_disabled || (is_page() || is_single()) || (get_option(key_infscr_state) == infscr_maint && $user_level >= 8) || (get_option(key_infscr_state) == infscr_config && $user_level <= 8) || (!have_posts()))
    163157        $load_infinite_scroll = false;
    164     else if (is_page() || is_single() ) /* single posts/pages dont get it */
    165         {
    166         $error_reason = 'Single post/page';
    167         $load_infinite_scroll = false;
    168         }
    169     else if (get_option(key_infscr_state) == infscr_maint && $user_level >= 8)
    170         {
    171         $error_reason = 'Administrator (Maintenance State)';
    172         $load_infinite_scroll = false;
    173         }
    174     else if (get_option(key_infscr_state) == infscr_config && $user_level <= 8)
    175         {
    176         $error_reason = 'Visitors (Config State)';
    177         $load_infinite_scroll = false; 
    178         }
    179     else if ( !have_posts() )
    180         {
    181         $error_reason = 'No Posts to Display';
    182         $load_infinite_scroll = false;     
    183         }
    184158       
    185159    /* Pre-flight checks complete. Are we good to fly? */   
     
    192166        $nextpage_no        = intval($current_page) + 1;
    193167        $max_page           = $wp_query->max_num_pages;
    194         $pathParse          = base64_encode(serialize(wp_inf_scroll_get_pagenum_link()));
    195        
    196168        if ( !$max_page || $max_page >= $nextpage )
    197169            {
    198             //We have to pass pathParse to the script as the script can't determine the path itself.
    199             //We have to introduce some form of validation, so we can validate/sign the pathParse we create.
    200             $pathSign = md5(NONCE_KEY.$pathParse."infscr".infscr_version);
    201             wp_register_script( "infinite-scroll-init", "$plugin_dir/infinitescroll.init.js.php?p=$pathParse&s=$pathSign", array("jquery"), infscr_version, false );
     170            //We have to pass pathInfo to the script as the script can't determine the path itself.
     171            //We have to introduce some form of validation, so we can validate/sign the pathInfo we create.
     172            $pathParse          = wp_inf_scroll_get_pagenum_link();
     173            $pathInfo           = base64_encode(serialize(array($pathParse,md5(NONCE_KEY.$pathParse[0]."infscr".$pathParse[1].infscr_version))));
     174            wp_register_script( "infinite-scroll-init", "$plugin_dir/infinitescroll.init.js.php?p=$pathInfo", array("jquery"), NULL, false );
    202175            wp_enqueue_script( "infinite-scroll-init" );
    203176            return true;
    204             }
    205         else
    206             {
    207             echo "<!-- Infinite-Scroll not added. Reason: No More Posts To Display After This -->\r\n";
    208             return false;
    209             }           
     177            }       
    210178        }
    211     else
    212         {
    213         echo "<!-- Infinite-Scroll not added. Reason: $error_reason -->\r\n";
    214         return false;
    215         }
     179    return false;
    216180    }
    217181
     
    220184    // if postback, store options
    221185    if (isset($_POST['info_update']))
    222     {
     186        {
    223187        check_admin_referer(); 
    224188
     
    284248        // update notification
    285249        echo "<div class='updated'><p><strong>Infinite Scroll options updated</strong></p></div>";
    286     }
     250        }
    287251
    288252    // output the options page
     
    294258    <div class="wrap">
    295259<?php
    296     update_option(key_infscr_viewed_options, true);
    297     if (get_option(key_infscr_state) == infscr_disabled)
    298             echo wp_inf_scroll_error("Infinite-Scroll plugin is <strong>disabled</strong>.");?>
     260update_option(key_infscr_viewed_options, true);
     261if (get_option(key_infscr_state) == infscr_disabled)
     262    echo wp_inf_scroll_error("Infinite-Scroll plugin is <strong>disabled</strong>.");?>
    299263         
    300   <style type="text/css">
    301     table.infscroll-opttable { width: 100%;}
    302     table.infscroll-opttable td, table.infscroll-opttable th { vertical-align: top; padding: 9px 4px; }
    303     table.infscroll-opttable th { padding-top: 13px; text-align: right;}
    304     table.infscroll-opttable td p { margin: 0;}
    305     table.infscroll-opttable dl { font-size: 90%; color: #666; margin-top: 5px; }
    306     table.infscroll-opttable dd { margin-bottom: 0 }
    307   </style>
     264<style type="text/css">
     265table.infscroll-opttable { width: 100%;}
     266table.infscroll-opttable td, table.infscroll-opttable th { vertical-align: top; padding: 9px 4px; }
     267table.infscroll-opttable th { padding-top: 13px; text-align: right;}
     268table.infscroll-opttable td p { margin: 0;}
     269table.infscroll-opttable dl { font-size: 90%; color: #666; margin-top: 5px; }
     270table.infscroll-opttable dd { margin-bottom: 0 }
     271</style>
    308272 
    309273    <h2>Infinite Scroll Options</h2>
Note: See TracChangeset for help on using the changeset viewer.