Plugin Directory

Changeset 1527897


Ignore:
Timestamp:
11/04/2016 07:27:48 AM (9 years ago)
Author:
froman118
Message:

Permission and security fixes

Location:
my-link-order/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • my-link-order/trunk/mylinkorder.php

    r1215408 r1527897  
    44Plugin URI: http://www.geekyweekly.com/mylinkorder
    55Description: My Link Order allows you to set the order in which links and link categories will appear in the sidebar. Uses a drag and drop interface for ordering. Adds a widget with additional options for easy installation on widgetized themes.
    6 Version: 4.3
     6Version: 4.4.2
    77Author: Andrew Charlton
    88Author URI: http://www.geekyweekly.com
    99Author Email: [email protected]
    1010*/
     11
     12function mylinkorder_init() {
    1113
    1214function mylinkorder_menu()
     
    5052    $catID = 0;
    5153   
     54    current_user_can('manage_links');
     55   
    5256    if (isset($_POST['btnCats']))
    5357        $catID = $_POST['cats'];
    5458    elseif (isset($_POST['hdnCatID']))
    5559        $catID = $_POST['hdnCatID'];
     60       
     61    if(!is_numeric($catID))
     62        return '<div id="message" class="error fade"><p>'. __('An error occured.', 'mylinkorder').'</p></div>';
    5663
    5764    if (isset($_POST['btnReturnParent']))
     
    7178   
    7279    if (isset($_POST['btnOrderCats'])) {
     80        check_admin_referer('update_cats_mylinkorder');
    7381        $idString = $_POST['hdnMyLinkOrder'];
    7482        $catIDs = explode(",", $idString);
    7583        $result = count($catIDs);
    76         for($i = 0; $i <= $result; $i++)
     84        for($i = 0; $i < $result; $i++)
    7785        {
    7886            $str = str_replace("id_", "", $catIDs[$i]);
     87           
     88            if(!is_numeric($str))
     89                return '<div id="message" class="error fade"><p>'. __('An error occured, order has not been saved.', 'mylinkorder').'</p></div>';
     90           
    7991            $wpdb->query( $wpdb->prepare("UPDATE $wpdb->terms SET term_order = %d WHERE term_id = %d", $i, $str) );
    8092        }
     
    8496   
    8597    if (isset($_POST['btnOrderLinks'])) {
     98        check_admin_referer('update_mylinkorder_'.$catID);
    8699        $idString = $_POST['hdnMyLinkOrder'];
    87100        $linkIDs = explode(",", $idString);
    88101        $result = count($linkIDs);
    89         for($i = 0; $i <= $result; $i++)
     102        for($i = 0; $i < $result; $i++)
    90103        {
    91104            $str = str_replace("id_", "", $linkIDs[$i]);
     105           
     106            if(!is_numeric($str))
     107                return '<div id="message" class="error fade"><p>'. __('An error occured, order has not been saved.', 'mylinkorder').'</p></div>';
     108               
    92109            $wpdb->query($wpdb->prepare("UPDATE $wpdb->links SET link_order = %d WHERE link_id =%d ", $i, $str));
    93110        }
     
    108125        $cat_name = $wpdb->get_var($wpdb->prepare("SELECT name FROM $wpdb->terms WHERE term_id= %d", $catID));
    109126    ?>
     127        <?php wp_nonce_field('update_mylinkorder_'.$catID); ?>
    110128        <h3><?php _e('Order Links for', 'mylinkorder') ?> <?php _e($cat_name) ?></h3>
    111129
     
    128146       
    129147        <p><?php _e('Choose a category from the drop down to order the links in that category or order the categories by dragging and dropping them.', 'mylinkorder') ?></p>
    130    
     148        <?php wp_nonce_field('update_cats_mylinkorder'); ?>
    131149        <h3><?php _e('Order Links', 'mylinkorder') ?></h3>
    132150   
     
    225243    <?php
    226244}
     245}
    227246
    228247function mylinkorder_applyorderfilter($orderby, $args)
     
    235254
    236255add_filter('get_terms_orderby', 'mylinkorder_applyorderfilter', 10, 2);
     256add_action('plugins_loaded', 'mylinkorder_init');
    237257add_action('init', 'mylinkorder_loadtranslation');
    238258
     
    244264
    245265    function __construct() {
    246         $widget_ops = array('classname' => 'widget_mylinkorder', 'description' => __( 'Enhanced Link widget provided by My Link Order') );
     266        $widget_ops = array('classname' => 'widget_mylinkorder widget_links', 'description' => __( 'Enhanced Link widget provided by My Link Order') );
    247267        parent::__construct('mylinkorder', __('My Link Order'), $widget_ops);   }
    248268
     
    273293
    274294        $before_widget = preg_replace('/id="[^"]*"/','id="%id"', $before_widget);
    275         mylinkorder_list_bookmarks(apply_filters('widget_links_args', array('title_before' => $before_title, 'title_after' => $after_title, 'class' => 'linkcat widget',
     295        mylinkorder_list_bookmarks(apply_filters('widget_links_args', array('title_before' => $before_title, 'title_after' => $after_title, 'class' => 'linkcat widget ',
    276296            'category_before' => $before_widget, 'category_after' => $after_widget, 'exclude' => $exclude, 'include' => $include,
    277297            'title_li' => $title_li, 'category_orderby' => $category_orderby, 'category_order' => $category_order, 'orderby' => $orderby, 'order' => $order,
     
    480500        'title_before' => '<h2>', 'title_after' => '</h2>',
    481501        'category_orderby' => 'name', 'category_order' => 'ASC',
    482         'class' => 'linkcat', 'category_before' => '<li id="%id" class="%class">',
     502        'class' => 'linkcat', 'category_before' => '<li id="%id" class="%class widget_links">',
    483503        'category_after' => '</li>'
    484504    );
     
    668688
    669689    $results = $wpdb->get_results($query);
    670 
     690   
    671691    $cache[ $key ] = $results;
    672692    wp_cache_set( 'get_bookmarks', $cache, 'bookmark' );
  • my-link-order/trunk/readme.txt

    r1215408 r1527897  
    44Tags: link, category, categories, order, sidebar, widget
    55Requires at least: 2.8
    6 Tested up to: 4.3
    7 Stable tag: 4.3
     6Tested up to: 4.4.2
     7Stable tag: 4.4.2
    88
    99My Link Order allows you to set the order in which links and link categories will appear in the sidebar.
     
    2525
    2626== Changelog ==
     27= 4.4.2 =
     28* Permission check and security improvement.
    2729= 4.3 =
    2830* PHP7 constructor update
Note: See TracChangeset for help on using the changeset viewer.