Plugin Directory

Changeset 2973108


Ignore:
Timestamp:
09/29/2023 07:02:10 PM (2 years ago)
Author:
RobertPHeller
Message:

Sanitize and Escape everything.

Location:
weblibrarian/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • weblibrarian/trunk/WebLibrarian.php

    r2955420 r2973108  
    44 * Plugin URI: http://www.deepsoft.com/WebLibrarian
    55 * Description: A plugin that implements a web-based library catalog and circulation System
    6  * Version: 3.5.8.3
     6 * Version: 3.5.8.4
    77 * Author: Robert Heller
    88 * Author URI: http://www.deepsoft.com/
     
    284284    // AJAX callbacks
    285285    function UpdatePatronID() {
    286       $userid = $_REQUEST['userid'];
    287       $patronid = $_REQUEST['patronid'];
     286      $userid = sanitize_text_field($_REQUEST['userid']);
     287      $patronid = sanitize_text_field($_REQUEST['patronid']);
    288288      $xml_response = '<?xml version="1.0" ?>';
    289289
     
    313313        wp_die( __('You do not have sufficient permissions to access this page.','weblibrarian') );
    314314      }
    315       $searchname = $_REQUEST['searchname'];
     315      $searchname = sanitize_text_field($_REQUEST['searchname']);
    316316      $xml_response = '<?xml version="1.0" ?>';
    317317
     
    341341    }
    342342    function PlaceHoldOnItem() {
    343       $barcode = $_REQUEST['barcode'];
     343      $barcode = sanitize_text_field($_REQUEST['barcode']);
    344344      $xml_response = '<?xml version="1.0" ?>';
    345345
    346346      if (current_user_can('manage_circulation') && isset($_REQUEST['patronid'])) {
    347         $patronid = $_REQUEST['patronid'];
     347        $patronid = sanitize_text_field($_REQUEST['patronid']);
    348348      } else {
    349349        $patronid = get_user_meta(wp_get_current_user()->ID,'PatronID',true);
     
    399399    }
    400400    function RenewItem() {
    401       $barcode = $_REQUEST['barcode'];
     401      $barcode = sanitize_text_field($_REQUEST['barcode']);
    402402      $xml_response = '<?xml version="1.0" ?>';
    403403
     
    492492          if ( isset($content_func) && is_string($content_func) )
    493493          do_action( "admin_head_{$content_func}" );
    494           $tab = isset($_REQUEST['tab'])?$_REQUEST['tab']:'links';
     494          $tab = isset($_REQUEST['tab'])?sanitize_text_field($_REQUEST['tab']):'links';
    495495         
    496496      ?></head>
     
    552552        wp_die("Opps too late");
    553553      }
    554       $dataselection = $_REQUEST['dataselection'];
     554      $dataselection = sanitize_text_field($_REQUEST['dataselection']);
    555555     
    556556      //file_put_contents("php://stderr","*** WebLibrarian::ExportLibraryData: dataselection = $dataselection\n");
     
    608608      }
    609609     
    610       $year  = isset( $_REQUEST['year'] )  ? $_REQUEST['year']  : date('Y',time());
    611       $month = isset( $_REQUEST['month'] ) ? $_REQUEST['month'] : date('m',time());
     610      $year  = isset( $_REQUEST['year'] )  ? sanitize_text_field($_REQUEST['year'])  : date('Y',time());
     611      $month = isset( $_REQUEST['month'] ) ? sanitize_text_field($_REQUEST['month']) : date('m',time());
    612612      $MonthNames =
    613613      array('Month Totals','January','February','March','April','May','June',
  • weblibrarian/trunk/includes/WEBLIB_Collection_Admin.php

    r2955407 r2973108  
    5151  }
    5252  function search_box($text, $input_id) {
    53     if ( empty( $_REQUEST['s'] ) && !$this->has_items() ) return;
     53    if ( empty( sanitize_text_field($_REQUEST['s']) ) && !$this->has_items() ) return;
    5454
    5555    $input_id = $input_id . '-search-input';
    5656
    57     if ( ! empty( $_REQUEST['orderby'] ) )
    58       echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
    59     if ( ! empty( $_REQUEST['order'] ) )
    60       echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
    61     $field = isset ($_REQUEST['f']) ? $_REQUEST['f'] : 'title';
     57    if ( ! empty( sanitize_text_field($_REQUEST['orderby']) ) )
     58      echo '<input type="hidden" name="orderby" value="' . esc_attr( sanitize_text_field($_REQUEST['orderby']) ) . '" />';
     59    if ( ! empty( sanitize_text_field($_REQUEST['order']) ) )
     60      echo '<input type="hidden" name="order" value="' . esc_attr( sanitize_text_field($_REQUEST['order']) ) . '" />';
     61    $field = isset ($_REQUEST['f']) ? sanitize_text_field($_REQUEST['f']) : 'title';
    6262?>
    6363<p class="search-box">
     
    7070             'ISBN'  => 'isbn',
    7171             'Keyword' => 'keyword') as $l => $f) {
    72         ?><option value="<?php echo $f; ?>"<?php
     72        ?><option value="<?php echo esc_attr($f); ?>"<?php
    7373          if ($f == $field) {echo ' selected="selected"';}
    7474        ?>><?php echo $l; ?></option>
     
    165165
    166166  function column_cb ($item) {
    167     return '<input type="checkbox" name="checked[]" value="'.$item.'" />';
     167    return '<input type="checkbox" name="checked[]" value="'.esc_attr($item).'" />';
    168168  }
    169169  function column_title ($item) {
     
    181181                        admin_url('admin.php')).'">'.
    182182        __('View','weblibrarian')."</a>",
    183     'delete' => '<a href="'.add_query_arg(array('page' => $_REQUEST['page'],
     183    'delete' => '<a href="'.add_query_arg(array('page' => sanitize_text_field($_REQUEST['page']),
    184184                            'action' => 'delete',
    185185                          'barcode' => $item),
     
    208208  function current_action() {
    209209   
    210     if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] )
    211       return $_REQUEST['action'];
    212 
    213     if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] )
    214       return $_REQUEST['action2'];
     210    if ( isset( $_REQUEST['action'] ) && -1 != sanitize_text_field($_REQUEST['action']) )
     211      return sanitize_text_field($_REQUEST['action']);
     212
     213    if ( isset( $_REQUEST['action2'] ) && -1 != sanitize_text_field($_REQUEST['action2']) )
     214      return sanitize_text_field($_REQUEST['action2']);
    215215  }
    216216
     
    220220    switch ($action) {
    221221      case 'delete':
    222     if ( isset($_REQUEST['checked']) && !empty($_REQUEST['checked'])) {
    223       foreach ( $_REQUEST['checked'] as $thebarcode ) {
     222    if ( isset($_REQUEST['checked']) && !empty(sanitize_text_field($_REQUEST['checked']))) {
     223      foreach ( sanitize_text_field($_REQUEST['checked']) as $thebarcode ) {
    224224        WEBLIB_ItemInCollection::DeleteItemByBarCode($thebarcode);
    225225        WEBLIB_ItemInCollection::DeleteKeywordsByBarCode($thebarcode);
    226226      }
    227227    } else if ( isset($_REQUEST['barcode']) ) {
    228       WEBLIB_ItemInCollection::DeleteItemByBarCode($_REQUEST['barcode']);
    229       WEBLIB_ItemInCollection::DeleteKeywordsByBarCode($_REQUEST['barcode']);
     228      WEBLIB_ItemInCollection::DeleteItemByBarCode(sanitize_text_field($_REQUEST['barcode']));
     229      WEBLIB_ItemInCollection::DeleteKeywordsByBarCode(sanitize_text_field($_REQUEST['barcode']));
    230230    }     
    231231    break;
     
    255255    $this->process_bulk_action();
    256256
    257     $search = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
    258     $field  = isset( $_REQUEST['f'] ) ? $_REQUEST['f'] : 'title';
    259     $orderby = isset( $_REQUEST['orderby'] ) ? $_REQUEST['orderby'] : 'barcode';
     257    $search = isset( $_REQUEST['s'] ) ? sanitize_text_field($_REQUEST['s']) : '';
     258    $field  = isset( $_REQUEST['f'] ) ? sanitize_text_field($_REQUEST['f']) : 'title';
     259    $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_text_field($_REQUEST['orderby']) : 'barcode';
    260260    if ( empty( $orderby ) ) $orderby = 'barcode';
    261     $order = isset( $_REQUEST['order'] ) ? $_REQUEST['order'] : 'ASC';
     261    $order = isset( $_REQUEST['order'] ) ? sanitize_text_field($_REQUEST['order']) : 'ASC';
    262262    if ( empty( $order ) ) $order = 'ASC';
    263263
     
    350350      $item    = $this->getitemfromform('');
    351351      if ($message == '') {
    352     $barcode = isset($_REQUEST['barcode']) ? $_REQUEST['barcode'] : '';
     352    $barcode = isset($_REQUEST['barcode']) ? sanitize_text_field($_REQUEST['barcode']) : '';
    353353    $newbarcode  = $item->store($barcode);
    354354    $keywords = $this->getkeywordsfromform();
     
    370370    } else if ( isset($_REQUEST['updateitem']) &&
    371371        isset($_REQUEST['barcode']) ) {
    372       $message = $this->checkiteminform($_REQUEST['barcode']);
    373       $item    = $this->getitemfromform($_REQUEST['barcode']);
     372      $message = $this->checkiteminform(sanitize_text_field($_REQUEST['barcode']));
     373      $item    = $this->getitemfromform(sanitize_text_field($_REQUEST['barcode']));
    374374      if ($message == '') {
    375375    $item->store();
     
    392392      $this->viewkeywords = $item->keywordsof();
    393393    } else {
    394       $this->viewmode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : 'add';
    395       $this->viewbarcode = isset($_REQUEST['barcode']) ? $_REQUEST['barcode'] : '';
     394      $this->viewmode = isset($_REQUEST['mode']) ? sanitize_text_field($_REQUEST['mode']) : 'add';
     395      $this->viewbarcode = isset($_REQUEST['barcode']) ? sanitize_text_field($_REQUEST['barcode']) : '';
    396396      switch ($this->viewmode) {
    397397    case 'edit':
     
    438438    if ( isset($_REQUEST['paged']) ) {
    439439      $paged = sanitize_text_field($_REQUEST['paged']);
    440       ?><input type="hidden" name="paged" value="<?php echo $paged; ?>" /><?php
     440      ?><input type="hidden" name="paged" value="<?php echo esc_attr($paged); ?>" /><?php
    441441    }
    442442    if ( isset($_REQUEST['screen-options-apply']) ) {
    443443      $screenopts = sanitize_text_field($_REQUEST['screen-options-apply']);
    444       ?><input type="hidden" name="screen-options-apply" value="<?php echo $screenopts; ?>" /><?php
     444      ?><input type="hidden" name="screen-options-apply" value="<?php echo esc_attr($screenopts); ?>" /><?php
    445445    }
    446446    if ( isset($_REQUEST['wp_screen_options']['option']) ) {
    447447      $wpscreenoptsopt = sanitize_text_field($_REQUEST['wp_screen_options']['option']);
    448       ?><input type="hidden" name="wp_screen_options[option]" value="<?php echo $wpscreenoptsopt; ?>" /><?php
     448      ?><input type="hidden" name="wp_screen_options[option]" value="<?php echo esc_attr($wpscreenoptsopt); ?>" /><?php
    449449    }
    450450    if ( isset($_REQUEST['wp_screen_options']['value']) ) {
    451451      $wpscreenoptsval = sanitize_text_field($_REQUEST['wp_screen_options']['value']);
    452       ?><input type="hidden" name="wp_screen_options[value]" value="<?php echo $wpscreenoptsval; ?>" /><?php
     452      ?><input type="hidden" name="wp_screen_options[value]" value="<?php echo esc_attr($wpscreenoptsval); ?>" /><?php
    453453    }
    454454    if ($this->viewmode == 'view') {
     
    464464                   style="width:75%;"
    465465                   maxlength="16"
    466                    value="<?php echo stripslashes($this->viewbarcode); ?>"<?php
     466                   value="<?php echo esc_attr(stripslashes($this->viewbarcode)); ?>"<?php
    467467                   if ($this->viewmode != 'add') {
    468468                     echo ' readonly="readonly"';
     
    474474           style="width:75%;"
    475475           maxlength="128"
    476            value="<?php echo stripslashes($this->viewitem->title()); ?>"<?php echo $ro; ?> /></td></tr>
     476           value="<?php echo esc_attr(stripslashes($this->viewitem->title())); ?>"<?php echo $ro; ?> /></td></tr>
    477477      <tr valign="top">
    478478    <th scope="row"><label for="itemauthor" style="width:20%;"><?php _e('Author:','weblibrarian'); ?></label></th>
     
    481481           style="width:75%;"
    482482           maxlength="64"
    483            value="<?php echo stripslashes($this->viewitem->author()); ?>"<?php echo $ro; ?> /></td></tr>
     483           value="<?php echo esc_attr(stripslashes($this->viewitem->author())); ?>"<?php echo $ro; ?> /></td></tr>
    484484      <tr valign="top">
    485485    <th scope="row"><label for="subject" style="width:20%;"><?php _e('Subject:','weblibrarian'); ?></label></th>
     
    488488           style="width:75%;"
    489489           maxlength="128"
    490            value="<?php echo stripslashes($this->viewitem->subject()); ?>"<?php echo $ro; ?> /></td></tr>
     490           value="<?php echo esc_attr(stripslashes($this->viewitem->subject())); ?>"<?php echo $ro; ?> /></td></tr>
    491491      <tr valign="top">
    492492    <th scope="row"><label for="description" style="width:20%;"><?php _e('Description:','weblibrarian'); ?></label></th>
     
    495495              style="width:75%);"
    496496              rows="5" cols="64"
    497               <?php echo $ro; ?>><?php echo stripslashes($this->viewitem->description()); ?></textarea></td></tr>
     497              <?php echo $ro; ?>><?php echo esc_attr(stripslashes($this->viewitem->description())); ?></textarea></td></tr>
    498498      <tr valign="top">
    499499    <th scope="row"><label for="itemcategory" style="width:20%;"><?php _e('Category:','weblibrarian'); ?></label></th>
     
    502502           style="width:75%;"
    503503           maxlength="36"
    504            value="<?php echo stripslashes($this->viewitem->category()); ?>"<?php echo $ro; ?> /></td></tr>
     504           value="<?php echo esc_attr(stripslashes($this->viewitem->category())); ?>"<?php echo $ro; ?> /></td></tr>
    505505      <tr valign="top">
    506506    <th scope="row"><label for="media" style="width:20%;"><?php _e('Media:','weblibrarian'); ?></label></th>
     
    509509           style="width:75%;"
    510510           maxlength="36"
    511            value="<?php echo stripslashes($this->viewitem->media()); ?>"<?php echo $ro; ?> /></td></tr>
     511           value="<?php echo esc_attr(stripslashes($this->viewitem->media())); ?>"<?php echo $ro; ?> /></td></tr>
    512512      <tr valign="top">
    513513    <th scope="row"><label for="publisher" style="width:20%;"><?php _e('Publisher:','weblibrarian'); ?></label></th>
     
    523523           style="width:75%;"
    524524           maxlength="36"
    525            value="<?php echo stripslashes($this->viewitem->publocation()); ?>"<?php echo $ro; ?> /></td></tr>
     525           value="<?php echo esc_attr(stripslashes($this->viewitem->publocation())); ?>"<?php echo $ro; ?> /></td></tr>
    526526      <tr valign="top">
    527527    <th scope="row"><label for="pubdate" style="width:20%;"><?php _e('Publish Date:','weblibrarian'); ?></label></th>
     
    530530           style="width:75%;"
    531531           maxlength="40"
    532            value="<?php echo $this->viewitem->pubdate(); ?>"<?php echo $ro; ?> /></td></tr>
     532           value="<?php echo esc_attr($this->viewitem->pubdate()); ?>"<?php echo $ro; ?> /></td></tr>
    533533      <tr valign="top">
    534534    <th scope="row"><label for="edition" style="width:20%;"><?php _e('Edition:','weblibrarian'); ?></label></th>
     
    537537           style="width:75%;"
    538538           maxlength="36"
    539            value="<?php echo stripslashes($this->viewitem->edition()); ?>"<?php echo $ro; ?> /></td></tr>
     539           value="<?php echo esc_attr(stripslashes($this->viewitem->edition())); ?>"<?php echo $ro; ?> /></td></tr>
    540540      <tr valign="top">
    541541    <th scope="row"><label for="isbn" style="width:20%;"><?php _e('ISBN:','weblibrarian'); ?></label></th>
     
    544544           style="width:75%;"
    545545           maxlength="20"
    546            value="<?php echo stripslashes($this->viewitem->isbn()); ?>"<?php echo $ro; ?> /></td></tr>
     546           value="<?php echo esc_attr(stripslashes($this->viewitem->isbn())); ?>"<?php echo $ro; ?> /></td></tr>
    547547      <tr valign="top">
    548548    <th scope="row"><label for="type" style="width:20%;"><?php _e('Type:','weblibrarian'); ?></label></th>
     
    552552             name="type"
    553553             style="width:75%;"
    554              value="<?php echo stripslashes($this->viewitem->type()); ?>"
     554             value="<?php echo esc_attr(stripslashes($this->viewitem->type())); ?>"
    555555             readonly="readonly" /><?php
    556556      } else {
     
    560560        if ($existingtype == '') $existingtype = $alltypes[0];
    561561        foreach ($alltypes as $atype) {
    562           ?><option value="<?php echo $atype; ?>"<?php
     562          ?><option value="<?php echo esc_attr($atype); ?>"<?php
    563563        if ($atype == $existingtype) echo ' selected="selected"';
    564           ?>><?php echo $atype; ?></option><?php
     564          ?>><?php echo esc_html($atype); ?></option><?php
    565565        }
    566566        ?></select><?php
     
    572572           style="width:75%;"
    573573           maxlength="256"
    574            value="<?php echo stripslashes($this->viewitem->thumburl()); ?>"<?php echo $ro; ?> /></td></tr>
     574           value="<?php echo esc_attr(stripslashes($this->viewitem->thumburl())); ?>"<?php echo $ro; ?> /></td></tr>
    575575              <tr valign="top">
    576576    <th scope="row"><label for="callnumber" style="width:20%;"><?php _e('Call Number:','weblibrarian'); ?></label></th>
     
    579579           style="width:75%;"
    580580           maxlength="36"
    581            value="<?php echo stripslashes($this->viewitem->callnumber()); ?>"<?php echo $ro; ?> /></td></tr>
     581           value="<?php echo esc_attr(stripslashes($this->viewitem->callnumber())); ?>"<?php echo $ro; ?> /></td></tr>
    582582      <tr valign="top">
    583583    <td colspan="2" width="100%">
     
    592592        ?><textarea id="itemedit-keyword-list" name="keywordlist"
    593593                rows="3" cols="20" class="the-keywords"<?php echo $ro; ?> ><?php
    594           echo implode(',',$this->viewkeywords); ?></textarea><?php
     594          echo implode(',',esc_html($this->viewkeywords)); ?></textarea><?php
    595595       if ($this->viewmode != 'view') {
    596596      ?></div><div class="hide-if-no-js">
     
    648648    $result = '';
    649649    if ($this->viewmode == 'add') {
    650       $newbarcode = $_REQUEST['barcode'];
     650      $newbarcode = sanitize_text_field($_REQUEST['barcode']);
    651651      if ($newbarcode != '') {
    652652    if (!preg_match('/^[a-zA-Z0-9]+$/',$newbarcode) || strlen($barcode) > 16) {
     
    655655      }
    656656    }
    657     if ($_REQUEST['title'] == '') {
     657    if (sanitize_text_field( $_REQUEST['title'] ) == '') {
    658658      $result .= '<br /><span id="error">'.__('Title is invalid','weblibrarian').'</span>';
    659659    }
    660     if ($_REQUEST['itemauthor'] == '') {
     660    if (sanitize_text_field($_REQUEST['itemauthor']) == '') {
    661661      $result .= '<br /><span id="error">'.__('Author is invalid','weblibrarian').'</span>';
    662662    }
    663     if ($_REQUEST['subject'] == '') {
     663    if (sanitize_text_field($_REQUEST['subject']) == '') {
    664664      $result .= '<br /><span id="error">'.__('Subject is invalid','weblibrarian').'</span>';
    665665    }
    666     WEBLIB_Patrons_Admin::ValidHumanDate($_REQUEST['pubdate'],$dummy,__('Publication Date','weblibrarian'),$result);
    667     if ($_REQUEST['type'] == '') {
     666    WEBLIB_Patrons_Admin::ValidHumanDate(sanitize_text_field($_REQUEST['pubdate']),$dummy,__('Publication Date','weblibrarian'),$result);
     667    if (sanitize_text_field($_REQUEST['type']) == '') {
    668668      $result .= '<br /><span id="error">'.__('Type is invalid','weblibrarian').'</span>';
    669669    }
     
    674674  {
    675675    $item = new WEBLIB_ItemInCollection($barcode);
    676     $item->set_title($_REQUEST['title']);
    677     $item->set_author($_REQUEST['itemauthor']);
    678     $item->set_subject($_REQUEST['subject']);
    679     $item->set_description($_REQUEST['description']);
    680     $item->set_category($_REQUEST['itemcategory']);
    681     $item->set_media($_REQUEST['media']);
    682     $item->set_publisher($_REQUEST['publisher']);
    683     $item->set_publocation($_REQUEST['publocation']);
    684     if (WEBLIB_Patrons_Admin::ValidHumanDate($_REQUEST['pubdate'],$thepubdate,'Publication Date',$error)) {
     676    $item->set_title(sanitize_text_field($_REQUEST['title']));
     677    $item->set_author(sanitize_text_field($_REQUEST['itemauthor']));
     678    $item->set_subject(sanitize_text_field($_REQUEST['subject']));
     679    $item->set_description(sanitize_text_field($_REQUEST['description']));
     680    $item->set_category(sanitize_text_field($_REQUEST['itemcategory']));
     681    $item->set_media(sanitize_text_field($_REQUEST['media']));
     682    $item->set_publisher(sanitize_text_field($_REQUEST['publisher']));
     683    $item->set_publocation(sanitize_text_field($_REQUEST['publocation']));
     684    if (WEBLIB_Patrons_Admin::ValidHumanDate(sanitize_text_field($_REQUEST['pubdate']),$thepubdate,'Publication Date',$error)) {
    685685      $item->set_pubdate($thepubdate);
    686686    }
    687     $item->set_edition($_REQUEST['edition']);
    688     $item->set_isbn($_REQUEST['isbn']);
    689     $item->set_type($_REQUEST['type']);
    690     $item->set_thumburl($_REQUEST['thumburl']);
    691     $item->set_callnumber($_REQUEST['callnumber']);
     687    $item->set_edition(sanitize_text_field($_REQUEST['edition']));
     688    $item->set_isbn(sanitize_text_field($_REQUEST['isbn']));
     689    $item->set_type(sanitize_text_field($_REQUEST['type']));
     690    $item->set_thumburl(sanitize_text_field($_REQUEST['thumburl']));
     691    $item->set_callnumber(sanitize_text_field($_REQUEST['callnumber']));
    692692    return $item;
    693693  }
     
    695695  function getkeywordsfromform()
    696696  {
    697     return explode(',',$_REQUEST['keywordlist']);
     697    return explode(',',sanitize_text_field($_REQUEST['keywordlist']));
    698698  }
    699699
     
    717717    if (!isset($_REQUEST['doupload']) ) return '';
    718718    $filename = $_FILES['file_name']['tmp_name'];
    719     $use_csv_headers = $_REQUEST['use_csv_header'];
    720     $field_sep = stripslashes($_REQUEST['field_sep']);
    721     $enclose_char = stripslashes($_REQUEST['enclose_char']);
     719    $use_csv_headers = sanitize_text_field($_REQUEST['use_csv_header']);
     720    $field_sep = stripslashes(sanitize_text_field($_REQUEST['field_sep']));
     721    $enclose_char = stripslashes(sanitize_text_field($_REQUEST['enclose_char']));
    722722    /*$escape_char = stripslashes($_REQUEST['escape_char']);*/
    723723    $result = WEBLIB_ItemInCollection::upload_csv($filename,$use_csv_headers,
     
    728728  function display_bulk_upload_form($returnURL) {
    729729    if ( isset($_REQUEST['paged']) ) {
    730       ?><input type="hidden" name="paged" value="<?php echo $_REQUEST['paged'] ?>" /><?php
     730      ?><input type="hidden" name="paged" value="<?php echo esc_attr(sanitize_text_field($_REQUEST['paged'])) ?>" /><?php
    731731    }
    732732    if ( isset($_REQUEST['screen-options-apply']) ) {
    733       ?><input type="hidden" name="screen-options-apply" value="<?php echo $_REQUEST['screen-options-apply'] ?>" /><?php
     733      ?><input type="hidden" name="screen-options-apply" value="<?php echo esc_attr(sanitize_text_field($_REQUEST['screen-options-apply'])) ?>" /><?php
    734734    }
    735735    if ( isset($_REQUEST['wp_screen_options']['option']) ) {
    736       ?><input type="hidden" name="wp_screen_options[option]" value="<?php echo $_REQUEST['wp_screen_options']['option'] ?>" /><?php
     736      ?><input type="hidden" name="wp_screen_options[option]" value="<?php echo esc_attr(sanitize_text_field($_REQUEST['wp_screen_options']['option'])) ?>" /><?php
    737737    }
    738738    if ( isset($_REQUEST['wp_screen_options']['value']) ) {
    739       ?><input type="hidden" name="wp_screen_options[value]" value="<?php echo $_REQUEST['wp_screen_options']['value'] ?>" /><?php
     739      ?><input type="hidden" name="wp_screen_options[value]" value="<?php echo esc_attr(sanitize_text_field($_REQUEST['wp_screen_options']['value'])) ?>" /><?php
    740740    }
    741741    ?><p><label for="file_name"><?php _e('CSV File:','weblibrarian'); ?></label>
    742742     <input type="file" id="file_name" name="file_name"
    743         value="<?php echo $_REQUEST['file_name']; ?>" /></p>
     743        value="<?php echo esc_attr(sanitize_text_field($_REQUEST['file_name'])); ?>" /></p>
    744744      <p><label for="use_csv_header"><?php _e('Use CSV Header?','weblibrarian'); ?></label>
    745745     <input type="checkbox" name="use_csv_header" id="use_csv_header"
     
    749749     <select id="field_sep" name="field_sep">
    750750     <option value="," <?php if (!isset($_REQUEST['field_sep']) ||
    751                      $_REQUEST['field_sep'] == ',') {
     751                     sanitize_text_field($_REQUEST['field_sep']) == ',') {
    752752                   echo 'selected="selected"';
    753753                 } ?>>,</option>
    754754     <option value="<?php echo "\t"; ?>" <?php
    755755        if (isset($_REQUEST['field_sep']) &&
    756             $_REQUEST['field_sep'] == "\t") {
     756            sanitize_text_field($_REQUEST['field_sep']) == "\t") {
    757757          echo 'selected="selected"';
    758758        } ?>><?php _e('TAB','weblibrarian'); ?></option>
     
    762762     <option value='<?php echo '"'; ?>' <?php
    763763        if (!isset($_REQUEST['enclose_char']) ||
    764             $_REQUEST['enclose_char'] == '"') {
     764            sanitize_text_field($_REQUEST['enclose_char']) == '"') {
    765765          echo 'selected="selected"';
    766766        } ?>>&quot;</option>
    767767     <option value="'" <?php
    768768        if (isset($_REQUEST['enclose_char']) &&
    769             $_REQUEST['enclose_char'] == "'") {
     769            sanitize_text_field($_REQUEST['enclose_char']) == "'") {
    770770          echo 'selected="selected"';
    771771        } ?>>'</option>
  • weblibrarian/trunk/includes/WEBLIB_PatronRecord_Admin.php

    r2754185 r2973108  
    206206  }
    207207  function current_action() {
    208     if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] )
    209       return $_REQUEST['action'];
    210 
    211     if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] )
    212       return $_REQUEST['action2'];
     208    if ( isset( $_REQUEST['action'] ) && -1 != sanitize_text_field($_REQUEST['action']) )
     209      return sanitize_text_field($_REQUEST['action']);
     210
     211    if ( isset( $_REQUEST['action2'] ) && -1 != sanitize_text_field($_REQUEST['action2']) )
     212      return sanitize_text_field($_REQUEST['action2']);
    213213  }
    214214
     
    217217    switch ($action) {
    218218      case 'removehold':
    219     if ( isset($_REQUEST['checked']) && !empty($_REQUEST['checked'])) {
    220       foreach ( $_REQUEST['checked'] as $theitem ) {
     219    if ( isset($_REQUEST['checked']) && !empty(sanitize_text_field($_REQUEST['checked']))) {
     220      foreach ( sanitize_text_field($_REQUEST['checked']) as $theitem ) {
    221221        WEBLIB_HoldItem::DeleteHeldItemByBarcodeAndPatronId($theitem,
    222222                            $this->patronid);
     
    224224        } else if ( isset($_REQUEST['barcode']) ) {
    225225      WEBLIB_HoldItem::DeleteHeldItemByBarcodeAndPatronId(
    226             $_REQUEST['barcode'],$this->patronid);
     226            sanitize_text_field($_REQUEST['barcode']),$this->patronid);
    227227    }
    228228    break;
     
    233233    $message = '';
    234234    $this->process_bulk_action();
    235     $orderby = isset( $_REQUEST['orderby'] ) ? $_REQUEST['orderby'] : 'barcode';
     235    $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_text_field($_REQUEST['orderby']) : 'barcode';
    236236    if ( empty( $orderby ) ) $orderby = 'barcode';
    237     $order = isset( $_REQUEST['order'] ) ? $_REQUEST['order'] : 'ASC';
     237    $order = isset( $_REQUEST['order'] ) ? sanitize_text_field($_REQUEST['order']) : 'ASC';
    238238    if ( empty( $order ) ) $order = 'ASC';
    239239    // Deal with columns
     
    328328  }
    329329  function current_action() {
    330     if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] )
    331       return $_REQUEST['action'];
    332 
    333     if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] )
    334       return $_REQUEST['action2'];
     330    if ( isset( $_REQUEST['action'] ) && -1 != sanitize_text_field($_REQUEST['action']) )
     331      return sanitize_text_field($_REQUEST['action']);
     332
     333    if ( isset( $_REQUEST['action2'] ) && -1 != sanitize_text_field($_REQUEST['action2']) )
     334      return sanitize_text_field($_REQUEST['action2']);
    335335  }
    336336
     
    338338    $message = '';
    339339    $action = $this->current_action();
    340     if ( isset($_REQUEST['action']) && $_REQUEST['action'] != -1 ) {
    341       $theaction = $_REQUEST['action'];
    342     } else if ( isset($_REQUEST['action2']) && $_REQUEST['action2'] != -1 ) {
    343       $theaction = $_REQUEST['action2'];
     340    if ( isset($_REQUEST['action']) && sanitize_text_field($_REQUEST['action']) != -1 ) {
     341      $theaction = sanitize_text_field($_REQUEST['action']);
     342    } else if ( isset($_REQUEST['action2']) && sanitize_text_field($_REQUEST['action2']) != -1 ) {
     343      $theaction = sanitize_text_field($_REQUEST['action2']);
    344344    } else {
    345345      $theaction = 'none';
     
    349349    if ( isset($_REQUEST['barcode']) ) {
    350350      $m = WEBLIB_OutItem::RenewByBarcodeAndPatronID(
    351                 $_REQUEST['barcode'],$this->patronid);
     351                sanitize_text_field($_REQUEST['barcode']),$this->patronid);
    352352      if (preg_match('/ Renewed\.$/',$m)) {
    353353        $message .= '<p>'.$m.'</p>';
     
    356356      }
    357357    } else {
    358       foreach ( $_REQUEST['checked'] as $barcode ) {
     358      foreach ( sanitize_text_field($_REQUEST['checked']) as $barcode ) {
    359359        $m = WEBLIB_OutItem::RenewByBarcodeAndPatronID(
    360360                $barcode,$this->patronid);
     
    374374    $message = '';
    375375    $message = $this->process_bulk_action();
    376     $orderby = isset( $_REQUEST['orderby'] ) ? $_REQUEST['orderby'] : 'barcode';
     376    $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_text_field($_REQUEST['orderby']) : 'barcode';
    377377    if ( empty( $orderby ) ) $orderby = 'barcode';
    378     $order = isset( $_REQUEST['order'] ) ? $_REQUEST['order'] : 'ASC';
     378    $order = isset( $_REQUEST['order'] ) ? sanitize_text_field($_REQUEST['order']) : 'ASC';
    379379    if ( empty( $order ) ) $order = 'ASC';
    380380
  • weblibrarian/trunk/includes/WEBLIB_Statistics_Admin.php

    r1747278 r2973108  
    126126  function extra_tablenav( $which ) {
    127127    if ($which == 'top') {
    128       ?><input type="hidden" name="year" value="<?php echo $this->year; ?>" />
    129     <input type="hidden" name="month" value="<?php echo $this->month; ?>" /><?php
     128      ?><input type="hidden" name="year" value="<?php echo esc_attr($this->year); ?>" />
     129    <input type="hidden" name="month" value="<?php echo esc_attr($this->month); ?>" /><?php
    130130    }
    131131
     
    157157    $this->check_permissions();
    158158    $message = '';
    159     $this->year = isset($_REQUEST['year']) ? $_REQUEST['year'] : date('Y',time());
    160     $this->month = isset($_REQUEST['month']) ? $_REQUEST['month'] : date('m',time());
     159    $this->year = isset($_REQUEST['year']) ? sanitize_text_field($_REQUEST['year']) : date('Y',time());
     160    $this->month = isset($_REQUEST['month']) ? sanitize_text_field($_REQUEST['month']) : date('m',time());
    161161
    162162    if ( isset($_REQUEST['filter_top']) ) {
    163       $this->year = isset($_REQUEST['year_top']) ? $_REQUEST['year_top'] : $this->year;
    164       $this->month = isset($_REQUEST['month_top']) ? $_REQUEST['month_top'] : $this->month;
     163      $this->year = isset($_REQUEST['year_top']) ? sanitize_text_field($_REQUEST['year_top']) : $this->year;
     164      $this->month = isset($_REQUEST['month_top']) ? sanitize_text_field($_REQUEST['month_top']) : $this->month;
    165165    } else if ( isset($_REQUEST['filter_bottom']) ) {
    166       $this->year = isset($_REQUEST['year_bottom']) ? $_REQUEST['year_bottom'] : $this->year;
    167       $this->month = isset($_REQUEST['month_bottom']) ? $_REQUEST['month_bottom'] : $this->month;
     166      $this->year = isset($_REQUEST['year_bottom']) ? sanitize_text_field($_REQUEST['year_bottom']) : $this->year;
     167      $this->month = isset($_REQUEST['month_bottom']) ? sanitize_text_field($_REQUEST['month_bottom']) : $this->month;
    168168    }
    169169    //file_put_contents("php://stderr","*** WEBLIB_Statistics_Admin::prepare_items: this->year = $this->year\n");
  • weblibrarian/trunk/includes/WEBLIB_Users_Admin.php

    r1747278 r2973108  
    126126    $message = '';
    127127    if ( isset( $_REQUEST['setid']) ) {
    128       $patronid = $_REQUEST['patronid'];
    129       $user_id  = $_REQUEST['user_id'];
     128      $patronid = sanitize_text_field($_REQUEST['patronid']);
     129      $user_id  = sanitize_text_field($_REQUEST['user_id']);
    130130      $user = get_userdata($user_id);
    131131      $patron = new WEBLIB_Patron($patronid);
     
    141141    }
    142142    global $usersearch;
    143     $usersearch = isset( $_REQUEST['s'] ) ? stripslashes( trim( $_REQUEST['s'] ) ) : '';
     143    $usersearch = isset( $_REQUEST['s'] ) ? stripslashes( trim( sanitize_text_field($_REQUEST['s']) ) ) : '';
    144144    // Deal with columns
    145145    $columns = $this->get_columns();    // All of our columns
     
    188188      $patronid = 0;
    189189      if (isset($_REQUEST['patronid']) ) {
    190     $patronid = $_REQUEST['patronid'];
     190    $patronid = sanitize_text_field($_REQUEST['patronid']);
    191191    $patron = new WEBLIB_Patron($patronid);
    192192    $error = '';
  • weblibrarian/trunk/includes/admin_page_classes.php

    r1747834 r2973108  
    115115      }
    116116      if ( isset($_REQUEST['saveoptions']) ) {
    117         $new_public_key = (isset($_REQUEST['aws_public_key']))?$_REQUEST['aws_public_key']:'';
    118         $new_private_key = (isset($_REQUEST['aws_private_key']))?$_REQUEST['aws_private_key']:'';
    119         $new_regiondom = (isset($_REQUEST['aws_regiondom']))?$_REQUEST['aws_regiondom']:'';
    120         $new_associate_tag = (isset($_REQUEST['associate_tag']))?$_REQUEST['associate_tag']:'';
     117        $new_public_key = (isset($_REQUEST['aws_public_key']))?sanitize_text_field($_REQUEST['aws_public_key']):'';
     118        $new_private_key = (isset($_REQUEST['aws_private_key']))?sanitize_text_field($_REQUEST['aws_private_key']):'';
     119        $new_regiondom = (isset($_REQUEST['aws_regiondom']))?sanitize_text_field($_REQUEST['aws_regiondom']):'';
     120        $new_associate_tag = (isset($_REQUEST['associate_tag']))?sanitize_text_field($_REQUEST['associate_tag']):'';
    121121    $message = ''; $valid = true;
    122122        if ($new_public_key == '' && $new_private_key == '' && $new_associate_tag == '') {
     
    142142    }
    143143    if ($valid) {   
    144       update_option('weblib_aws_public_key',$_REQUEST['aws_public_key']);
    145       update_option('weblib_aws_private_key',$_REQUEST['aws_private_key']);
    146       update_option('weblib_aws_regiondom',$_REQUEST['aws_regiondom']);
    147       update_option('weblib_associate_tag',$_REQUEST['associate_tag']);
    148       update_option('weblib_debugdb',$_REQUEST['debugdb']);
     144      update_option('weblib_aws_public_key',sanitize_text_field($_REQUEST['aws_public_key']));
     145      update_option('weblib_aws_private_key',sanitize_text_field($_REQUEST['aws_private_key']));
     146      update_option('weblib_aws_regiondom',sanitize_text_field($_REQUEST['aws_regiondom']));
     147      update_option('weblib_associate_tag',sanitize_text_field($_REQUEST['associate_tag']));
     148      update_option('weblib_debugdb',sanitize_text_field($_REQUEST['debugdb']));
    149149      $message = '<p>'.__('Options Saved','weblibrarian').'</p>';
    150150    }
     
    166166         <td><input type="text" id="aws_public_key"
    167167            name="aws_public_key"
    168             value="<?php echo $aws_public_key; ?>"
     168            value="<?php echo esc_attr($aws_public_key); ?>"
    169169             style="width:75%" /></td></tr>
    170170      <tr valign="top">
     
    173173         <td><input type="text" id="aws_private_key"
    174174            name="aws_private_key"
    175             value="<?php echo $aws_private_key; ?>"
     175            value="<?php echo esc_attr($aws_private_key); ?>"
    176176             style="width:75%" /></td></tr>
    177177      <tr valign="top">
     
    214214         <td><input type="text" id="associate_tag"
    215215            name="associate_tag"
    216             value="<?php echo $associate_tag; ?>"
     216            value="<?php echo esc_attr($associate_tag); ?>"
    217217            style="width:75%" /></td></tr>
    218218      <tr valign="top">
  • weblibrarian/trunk/readme.txt

    r2955420 r2973108  
    157157== Changelog ==
    158158
     159= 3.5.8.4 =
     160
     161Sanitize and Escape everything.
     162
    159163= 3.5.8.3 =
    160164
Note: See TracChangeset for help on using the changeset viewer.