Plugin Directory

Changeset 770831


Ignore:
Timestamp:
09/12/2013 08:40:43 AM (12 years ago)
Author:
laki_patel
Message:

Fix SQL Injection and Cross Site Scripting issues

Location:
indianic-testimonial/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • indianic-testimonial/trunk/add.php

    r567750 r770831  
    44  $_result = $_result[0];
    55 
    6   $id = $_result->id;
    7   $project_name = $_result->project_name;
    8   $project_url = $_result->project_url;
    9   $client_name = $_result->client_name;
    10   $city = $_result->city;
    11   $state = $_result->state;
    12   $country = $_result->country;
    13   $description = $_result->description;
    14   $tags = $_result->tags;
    15   $video_url = $_result->video_url;
    16   $thumb_img_url = $_result->thumb_img_url;
    17   $large_img_url = $_result->large_img_url;
    18   $is_featured = $_result->is_featured;
     6  $id = esc_attr($_result->id);
     7  $project_name = esc_attr($_result->project_name);
     8  $project_url = esc_attr($_result->project_url);
     9  $client_name = esc_attr($_result->client_name);
     10  $city = esc_attr($_result->city);
     11  $state = esc_attr($_result->state);
     12  $country = esc_attr($_result->country);
     13  $description = esc_attr($_result->description);
     14  $tags = esc_attr($_result->tags);
     15  $video_url = esc_attr($_result->video_url);
     16  $thumb_img_url = esc_attr($_result->thumb_img_url);
     17  $large_img_url = esc_attr($_result->large_img_url);
     18  $is_featured = esc_attr($_result->is_featured);
    1919}
    2020?>
     
    2626  <div id="message" class="below-h2"></div>
    2727  <form name="testimonial_add" method="post" action="" enctype="multipart/form-data">
     28    <?php wp_nonce_field('save_testimonial','_nonce'); ?>
    2829    <input type="hidden" name="action" value="iNIC_testimonial_save" />
    2930    <?php
    3031    if (isset($_REQUEST['id']) && $_REQUEST['id']) {
    31       echo '<input type="hidden" name="id" value="' . $_REQUEST['id'] . '" />';
     32      echo '<input type="hidden" name="id" value="' . esc_attr($_REQUEST['id']) . '" />';
    3233    }
    3334    ?>
  • indianic-testimonial/trunk/listing_template.php

    r563885 r770831  
    5858
    5959    <form name="testimonial_listing_template" method="post" action="">
     60      <?php wp_nonce_field('save_testimonial_listing_template','_nonce'); ?>
    6061      <input type="hidden" name="action" value="iNIC_testimonial_save_listing_template" />
    6162
     
    7172          <tr>
    7273            <th><label for="title">Title</label></th>
    73             <td><input name="title" type="text" id="title" value="<?php echo $title; ?>" class="regular-text"></td>
     74            <td><input name="title" type="text" id="title" value="<?php echo esc_attr($title); ?>" class="regular-text"></td>
    7475          </tr>
    7576
     
    7778          <tr>
    7879            <th><label for="no_of_testimonial">No. of Testimonials</label></th>
    79             <td><input name="no_of_testimonial" type="text" id="no_of_testimonial" value="<?php echo $no_of_testimonial; ?>" class="small-text"></td>
     80            <td><input name="no_of_testimonial" type="text" id="no_of_testimonial" value="<?php echo esc_attr($no_of_testimonial); ?>" class="small-text"></td>
    8081          </tr>
    8182
    8283          <tr>
    8384            <th><label for="list_per_page">Listing Testimonials Per Page</label></th>
    84             <td><input name="list_per_page" type="text" id="list_per_page" value="<?php echo $list_per_page; ?>" class="small-text"></td>
     85            <td><input name="list_per_page" type="text" id="list_per_page" value="<?php echo esc_attr($list_per_page); ?>" class="small-text"></td>
    8586          </tr>
    8687
     
    9495                foreach ($_table_field as $_table_field) {
    9596                  $_is_selected = $_ord_by[0] == $_table_field->Field ? ' selected="selected"' : '';
    96                   echo "<option value=\"{$_table_field->Field}\"{$_is_selected}>{$_table_field->Field}</option>";
     97                  echo "<option value=\"".  esc_attr($_table_field->Field)."\"{$_is_selected}>{$_table_field->Field}</option>";
    9798                }
    9899                ?>
     
    107108          <tr>
    108109            <th><label for="filter_by_country">Filter by Country</label></th>
    109             <td><input name="filter_by_country" type="text" id="filter_by_country" value="<?php echo $filter_by_country; ?>" class="regular-text"> Comma Separated. <code>country1,country2,country3</code></td>
     110            <td><input name="filter_by_country" type="text" id="filter_by_country" value="<?php echo esc_attr($filter_by_country); ?>" class="regular-text"> Comma Separated. <code>country1,country2,country3</code></td>
    110111          </tr>
    111112
    112113          <tr>
    113114            <th><label for="filter_by_tags">Filter by Tags</label></th>
    114             <td><input name="filter_by_tags" type="text" id="filter_by_tags" value="<?php echo $filter_by_tags; ?>" class="regular-text"> Comma Separated. <code>tag1,tag2,tag3</code></td>
     115            <td><input name="filter_by_tags" type="text" id="filter_by_tags" value="<?php echo esc_attr($filter_by_tags); ?>" class="regular-text"> Comma Separated. <code>tag1,tag2,tag3</code></td>
    115116          </tr>
    116117
    117118          <tr>
    118119            <th><label for="custom_query">Custom SQL Where condition</label></th>
    119             <td><input name="custom_query" type="text" id="custom_query" value="<?php echo $custom_query; ?>" class="regular-text">LIKE <code>feature='1' AND city != ''</code></td>
     120            <td><input name="custom_query" type="text" id="custom_query" value="<?php echo esc_attr($custom_query); ?>" class="regular-text">LIKE <code>feature='1' AND city != ''</code></td>
    120121          </tr>
    121122
     
    133134          <tr class="hidewhennotfeatured">
    134135            <th><label for="no_of_featured">No. of Featured</label></th>
    135             <td><input name="no_of_featured" type="text" id="no_of_featured" value="<?php echo $no_of_featured ? $no_of_featured : 1; ?>" class="small-text"></td>
     136            <td><input name="no_of_featured" type="text" id="no_of_featured" value="<?php echo $no_of_featured ? esc_attr($no_of_featured) : 1; ?>" class="small-text"></td>
    136137          </tr>
    137138
    138139          <tr class="hidewhennotfeatured">
    139140            <th><label for="featured_template">Featured HTML Template</label></th>
    140             <td><?php wp_editor(stripslashes($featured_template), 'featured_template', array('media_buttons' => false, 'textarea_rows' => 10, 'tinymce' => false)); ?></td>
     141            <td><?php wp_editor(esc_attr(stripslashes($featured_template)), 'featured_template', array('media_buttons' => false, 'textarea_rows' => 10, 'tinymce' => false)); ?></td>
    141142          </tr>
    142143
    143144          <tr>
    144145            <th><label for="listing_template_odd">Listing HTML Template (Odd)</label></th>
    145             <td><?php wp_editor(stripslashes($listing_template_odd), 'listing_template_odd', array('media_buttons' => false, 'textarea_rows' => 10, 'tinymce' => false)); ?></td>
     146            <td><?php wp_editor(esc_attr(stripslashes($listing_template_odd)), 'listing_template_odd', array('media_buttons' => false, 'textarea_rows' => 10, 'tinymce' => false)); ?></td>
    146147          </tr>
    147148
    148149          <tr>
    149150            <th><label for="listing_template_even">Listing HTML Template (Even)</label></th>
    150             <td><?php wp_editor(stripslashes($listing_template_even), 'listing_template_even', array('media_buttons' => false, 'textarea_rows' => 10, 'tinymce' => false)); ?></td>
     151            <td><?php wp_editor(esc_attr(stripslashes($listing_template_even)), 'listing_template_even', array('media_buttons' => false, 'textarea_rows' => 10, 'tinymce' => false)); ?></td>
    151152          </tr>
    152153
     
    225226            echo "<tr>
    226227                    <td>
    227                       {$_results->title}<br /><i>[iNICtestimonial tpl={$_results->id}]</i>
     228                      ".  esc_html($_results->title)."<br /><i>[iNICtestimonial tpl=".  esc_html($_results->id)."]</i>
    228229                      <div class=\"row-actions\">
    229                         <span class=\"edit\"><a href=\"admin.php?page=inic_testimonial_listing_template&type=add&id={$_results->id}\" title=\"Edit this item\">Edit</a> | </span>
    230                         <span class=\"trash\"><a class=\"submitdelete\" title=\"Delete this item\" href=\"javascript:void(0)\" rel=\"{$_results->id}\">Delete</a></span>
     230                        <span class=\"edit\"><a href=\"admin.php?page=inic_testimonial_listing_template&type=add&id=".  esc_attr($_results->id)."\" title=\"Edit this item\">Edit</a> | </span>
     231                        <span class=\"trash\"><a class=\"submitdelete\" title=\"Delete this item\" href=\"javascript:void(0)\" rel=\"".  esc_attr($_results->id)."\">Delete</a></span>
    231232                      </div>
    232233                    </td>
    233                     <td>{$_results->no_of_testimonial}</td>
    234                     <td>{$_results->list_per_page}</td>
    235                     <td>{$_results->ord_by}</td>
    236                     <td>{$_filter_by}</td>
    237                     <td>{$_results->show_featured_at}{$_no_of_featured}</td>
     234                    <td>".  esc_html($_results->no_of_testimonial)."</td>
     235                    <td>".  esc_html($_results->list_per_page)."</td>
     236                    <td>".  esc_html($_results->ord_by)."</td>
     237                    <td>".  esc_html($_filter_by)."</td>
     238                    <td>".  esc_html($_results->show_featured_at)." ".  esc_html($_no_of_featured)."</td>
    238239                  </tr>";
    239240          }
  • indianic-testimonial/trunk/settings.php

    r567750 r770831  
    3838   
    3939    <form name="testimonial_setting" method="post" action="">
     40    <?php wp_nonce_field('save_testimonial_options','_nonce'); ?>
     41   
    4042        <input type="hidden" name="action" value="iNIC_testimonial_save_setting" />
    4143        <table class="form-table">
     
    5355                <tr>
    5456                    <th><label for="inic_testimonial_admin_list_per_page">Admin pages show at most</label></th>
    55                     <td><input name="inic_testimonial_admin_list_per_page" type="text" id="inic_testimonial_admin_list_per_page" value="<?php echo get_option("inic_testimonial_admin_list_per_page"); ?>" class="small-text"> Testimonials</td>
     57          <td><input name="inic_testimonial_admin_list_per_page" type="text" id="inic_testimonial_admin_list_per_page" value="<?php echo esc_attr(get_option("inic_testimonial_admin_list_per_page")); ?>" class="small-text"> Testimonials</td>
    5658                </tr>
    5759               
     
    6567                        foreach($_table_field as $_table_field) {
    6668                          $_is_selected = $_ord_by[0] == $_table_field->Field ? ' selected="selected"' : '';
    67                           echo "<option value=\"{$_table_field->Field}\"{$_is_selected}>{$_table_field->Field}</option>";
     69                          echo "<option value=\"".  esc_attr($_table_field->Field)."\"{$_is_selected}>".  esc_attr($_table_field->Field)."</option>";
    6870                        }
    6971                        ?>
  • indianic-testimonial/trunk/testimonial.php

    r770202 r770831  
    4949
    5050    $_search = array("{#ID}", "{#ProjectName}", "{#ProjectUrl}", "{#ClientName}", "{#City}", "{#State}", "{#Country}", "{#Description}", "{#Tags}", "{#VideoUrl}", "{#ThumbImgUrl}", "{#LargeImgUrl}", "{#Counter}");
    51     $_replace = array($_data->id, $_data->project_name, $_data->project_url, $_data->client_name, $_data->city, $_data->state, $_data->country, $_data->description, $_data->tags, $_data->video_url, $_data->thumb_img_url, $_data->large_img_url, $_data->counter);
    52     $_code_value = array("{#ID}" => $_data->id, "{#ProjectName}" => $_data->project_name, "{#ProjectUrl}" => $_data->project_url, "{#ClientName}" => $_data->client_name, "{#City}" => $_data->city, "{#State}" => $_data->state, "{#Country}" => $_data->country, "{#Description}" => $_data->description, "{#Tags}" => $_data->tags, "{#VideoUrl}" => $_data->video_url, "{#ThumbImgUrl}" => $_data->thumb_img_url, "{#LargeImgUrl}" => $_data->large_img_url, "{#Counter}" => $_data->counter);
     51    $_replace = array(esc_html($_data->id), esc_html($_data->project_name), esc_html($_data->project_url), esc_html($_data->client_name), esc_html($_data->city), esc_html($_data->state), esc_html($_data->country), esc_html($_data->description), esc_html($_data->tags), esc_html($_data->video_url), esc_html($_data->thumb_img_url), esc_html($_data->large_img_url), esc_html($_data->counter));
     52    $_code_value = array("{#ID}" => esc_html($_data->id), "{#ProjectName}" => esc_html($_data->project_name), "{#ProjectUrl}" => esc_html($_data->project_url), "{#ClientName}" => esc_html($_data->client_name), "{#City}" => esc_html($_data->city), "{#State}" => esc_html($_data->state), "{#Country}" => esc_html($_data->country), "{#Description}" => esc_html($_data->description), "{#Tags}" => esc_html($_data->tags), "{#VideoUrl}" => esc_html($_data->video_url), "{#ThumbImgUrl}" => esc_html($_data->thumb_img_url), "{#LargeImgUrl}" => esc_html($_data->large_img_url), "{#Counter}" => esc_html($_data->counter));
    5353
    5454    preg_match('#\[IF\s(.+?)](.+?)\[/IF]#s', $_tpl_data, $matches_if);
     
    136136        $_testimonial_result = isset($_array_chunk[$_current_page - 1]) && $_array_chunk[$_current_page - 1] ? $_array_chunk[$_current_page - 1] : $_array_chunk[0];
    137137        $_pagination = "";
    138        
     138
    139139        if ($_total_pages > 1) {
    140140          $_pagination .= "<div class='testimonial_pagination'>";
    141          
    142           if($_current_page > 1) {
    143             $_pagination .= "<a href=\"?".build_query(array_merge($_REQUEST, array($this->blog_page_pagination_key => 1)))."\" title=\"Go to the first page\" class=\"first-page\">&laquo;</a> ";
    144             $_pagination .= "<a href=\"?".build_query(array_merge($_REQUEST, array($this->blog_page_pagination_key => ($_current_page - 1))))."\" title=\"Go to the previous page\" class=\"prev-page\">&lsaquo;</a> ";
     141
     142          if ($_current_page > 1) {
     143            $_pagination .= "<a href=\"?" . build_query(array_merge($_REQUEST, array($this->blog_page_pagination_key => 1))) . "\" title=\"Go to the first page\" class=\"first-page\">&laquo;</a> ";
     144            $_pagination .= "<a href=\"?" . build_query(array_merge($_REQUEST, array($this->blog_page_pagination_key => ($_current_page - 1)))) . "\" title=\"Go to the previous page\" class=\"prev-page\">&lsaquo;</a> ";
    145145          }
    146          
     146
    147147          for ($i = 1; $i <= $_total_pages; ++$i) {
    148148            $_url_prefix = build_query(array_merge($_REQUEST, array($this->blog_page_pagination_key => $i)));
     
    150150            $_pagination .= "<a href=\"?{$_url_prefix}\"{$_is_active}>{$i}</a> ";
    151151          }
    152          
    153           if($_current_page < $_total_pages) {
    154             $_pagination .= "<a href=\"?".build_query(array_merge($_REQUEST, array($this->blog_page_pagination_key => ($_current_page + 1))))."\" title=\"Go to the next page\" class=\"next-page\">&rsaquo;</a> ";
    155             $_pagination .= "<a href=\"?".build_query(array_merge($_REQUEST, array($this->blog_page_pagination_key => $_total_pages)))."\" title=\"Go to the last page\" class=\"last-page\">&raquo;</a> ";
     152
     153          if ($_current_page < $_total_pages) {
     154            $_pagination .= "<a href=\"?" . build_query(array_merge($_REQUEST, array($this->blog_page_pagination_key => ($_current_page + 1)))) . "\" title=\"Go to the next page\" class=\"next-page\">&rsaquo;</a> ";
     155            $_pagination .= "<a href=\"?" . build_query(array_merge($_REQUEST, array($this->blog_page_pagination_key => $_total_pages))) . "\" title=\"Go to the last page\" class=\"last-page\">&raquo;</a> ";
    156156          }
    157          
     157
    158158          $_pagination .= "</div>";
    159159        }
    160 
    161160      }
    162161
     
    196195  public function iNIC_testimonial_save() {
    197196
     197    if (!wp_verify_nonce($_POST['_nonce'], 'save_testimonial')) {
     198      echo json_encode(array('error' => "Sorry, your nonce did not verify."));
     199      die();
     200    }
     201
    198202    $_search = array("http://", "https://");
    199203    $_replace = array("", "");
    200204
    201205    $_data = array(
    202         "project_name" => $_POST['project_name'],
    203         "project_url" => $_POST['project_url'],
    204         "client_name" => $_POST['client_name'],
    205         "city" => $_POST['client_city'],
    206         "state" => $_POST['client_state'],
    207         "country" => $_POST['client_country'],
    208         "description" => $_POST['description'],
    209         "tags" => $_POST['tags'],
    210         "video_url" => $_POST['video_url'],
    211         "thumb_img_url" => str_replace($_SERVER['HTTP_HOST'], "", str_replace($_search, $_replace, $_POST['thumb_img'])),
    212         "large_img_url" => str_replace($_SERVER['HTTP_HOST'], "", str_replace($_search, $_replace, $_POST['large_img'])),
    213         "is_featured" => $_POST['is_featured']
     206        "project_name" => esc_html($this->clean_text($_POST['project_name'])),
     207        "project_url" => esc_html($this->clean_text($_POST['project_url'])),
     208        "client_name" => esc_html($this->clean_text($_POST['client_name'])),
     209        "city" => esc_html($this->clean_text($_POST['client_city'])),
     210        "state" => esc_html($this->clean_text($_POST['client_state'])),
     211        "country" => esc_html($this->clean_text($_POST['client_country'])),
     212        "description" => esc_html($this->clean_text($_POST['description'])),
     213        "tags" => esc_html($this->clean_text($_POST['tags'])),
     214        "video_url" => esc_html($this->clean_text($_POST['video_url'])),
     215        "thumb_img_url" => str_replace($_SERVER['HTTP_HOST'], "", str_replace($_search, $_replace, esc_html($this->clean_text($_POST['thumb_img'])))),
     216        "large_img_url" => str_replace($_SERVER['HTTP_HOST'], "", str_replace($_search, $_replace, esc_html($this->clean_text($_POST['large_img'])))),
     217        "is_featured" => esc_html($this->clean_text($_POST['is_featured']))
    214218    );
    215219
     
    237241    if ($_POST['action'] == 'iNIC_testimonial_save_listing_template') {
    238242
     243      if (!wp_verify_nonce($_POST['_nonce'], 'save_testimonial_listing_template')) {
     244        echo json_encode(array('error' => "Sorry, your nonce did not verify."));
     245        die();
     246      }
     247
    239248      if ($_POST['title'] && $_POST['listing_template_odd']) {
    240249        $_POST['ord_by'] = "{$_POST['ord_by']} {$_POST['ord_type']}";
    241250        $_POST['no_of_featured'] = $_POST['no_of_featured'] ? $_POST['no_of_featured'] : "1";
    242         $_POST['filter_by_country'] = $_POST['filter_by_country'] ? str_replace(", ", ",", $_POST['filter_by_country']) : "";
     251        $_POST['filter_by_country'] = $_POST['filter_by_country'] ? str_replace(", ", ",", $this->clean_text($_POST['filter_by_country'])) : "";
    243252        $_POST['filter_by_tags'] = str_replace(", ", ",", $_POST['filter_by_tags']);
    244         $_POST['custom_query'] = $_POST['custom_query'] ? str_replace("WHERE ", "", stripslashes($_POST['custom_query'])) : "";
    245         $_POST['featured_template'] = stripslashes($_POST['featured_template']);
    246         $_POST['listing_template_odd'] = stripslashes($_POST['listing_template_odd']);
    247         $_POST['listing_template_even'] = stripslashes($_POST['listing_template_even']);
     253        $_POST['custom_query'] = $_POST['custom_query'] ? str_replace("WHERE ", "", stripslashes($this->clean_text($_POST['custom_query']))) : "";
     254        $_POST['featured_template'] = $this->clean_text(stripslashes($_POST['featured_template']));
     255        $_POST['listing_template_odd'] = $this->clean_text(stripslashes($_POST['listing_template_odd']));
     256        $_POST['listing_template_even'] = $this->clean_text(stripslashes($_POST['listing_template_even']));
    248257
    249258        unset($_POST['action'], $_POST['ord_type']);
     
    304313    if ($_POST['action'] == "iNIC_testimonial_save_widget") {
    305314
     315      if (!wp_verify_nonce($_POST['_nonce'], 'save_testimonial_widget_template')) {
     316        echo json_encode(array('error' => "Sorry, your nonce did not verify."));
     317        die();
     318      }
     319
    306320      if ($_POST['widget_title']) {
    307321        $_POST['no_of_testimonials'] = $_POST['no_of_testimonials'] && is_numeric($_POST['no_of_testimonials']) ? $_POST['no_of_testimonials'] : "";
     
    311325
    312326        $_data = array(
    313             "title" => $_POST['widget_title'],
    314             "no_of_testimonial" => $_POST['no_of_testimonials'],
    315             "only_featured" => $_POST['list_only_featured_testimonials'],
    316             "filter_by_country" => $_POST['filter_by_country'],
    317             "filter_by_tags" => $_POST['filter_by_tags'],
    318             "display_randomly" => $_POST['display_randomly'],
    319             "html_template" => $_POST['widget_template'],
     327            "title" => esc_html($this->clean_text($_POST['widget_title'])),
     328            "no_of_testimonial" => $this->clean_text($_POST['no_of_testimonials']),
     329            "only_featured" => $this->clean_text($_POST['list_only_featured_testimonials']),
     330            "filter_by_country" => $this->clean_text($_POST['filter_by_country']),
     331            "filter_by_tags" => $this->clean_text($_POST['filter_by_tags']),
     332            "display_randomly" => $this->clean_text($_POST['display_randomly']),
     333            "html_template" => $this->clean_text($_POST['widget_template']),
    320334        );
    321        
     335
    322336        if (isset($_POST['id']) && $_POST['id']) {
    323337          $this->wpdb->update("{$this->wpdb->prefix}inic_testimonial_widget", $_data, array('id' => $_POST['id']));
     
    342356
    343357  public function iNIC_testimonial_save_setting() {
     358
     359    if (!wp_verify_nonce($_POST['_nonce'], 'save_testimonial_options')) {
     360      echo json_encode(array('error' => "Sorry, your nonce did not verify."));
     361      die();
     362    }
     363
    344364    $_POST['inic_testimonial_admin_list_per_page'] = (is_numeric($_POST['inic_testimonial_admin_list_per_page']) && $_POST['inic_testimonial_admin_list_per_page'] > 0) ? $_POST['inic_testimonial_admin_list_per_page'] : "10";
    345     update_option('inic_testimonial_admin_list_per_page', $_POST['inic_testimonial_admin_list_per_page']);
    346     update_option('inic_testimonial_html_template', $_POST['inic_testimonial_html_template']);
     365    update_option('inic_testimonial_admin_list_per_page', is_numeric($_POST['inic_testimonial_admin_list_per_page']) ? $_POST['inic_testimonial_admin_list_per_page'] : 15);
     366    update_option('inic_testimonial_html_template', $this->clean_text($_POST['inic_testimonial_html_template']));
    347367    update_option("inic_testimonial_list_ord_by", "{$_POST['ord_by']} {$_POST['ord_type']}");
    348368    $_data['msg'] = "IndiaNIC Testimonial Setting has been saved successfully.";
     
    358378    add_submenu_page("inic_testimonial_view", "Widget Template", "Widget Template", 'administrator', "inic_testimonial_widget_template", array($this, 'inic_testimonial_widget_template'));
    359379    add_submenu_page("inic_testimonial_view", "Settings", "Settings", 'administrator', "inic_testimonial_settings", array($this, 'testimonial_settings'));
    360    
     380
    361381    require_once "{$this->pluginPath}/listing_data_table.php";
    362382    $this->tbl = new listing_data_table();
     
    450470  }
    451471
     472  public function clean_text($script_str) {
     473    $script_str = htmlspecialchars_decode($script_str);
     474    $search_arr = array('<script', '</script>');
     475    $script_str = str_ireplace($search_arr, $search_arr, $script_str);
     476    $split_arr = explode('<script', $script_str);
     477    $remove_jscode_arr = array();
     478
     479    foreach ($split_arr as $key => $val) {
     480      $newarr = explode('</script>', $split_arr[$key]);
     481      $remove_jscode_arr[] = ($key == 0) ? $newarr[0] : $newarr[1];
     482    }
     483
     484    return implode('', $remove_jscode_arr);
     485  }
     486
    452487}
    453488
  • indianic-testimonial/trunk/view.php

    r766128 r770831  
    22
    33if (isset($_GET['id']) && $_GET['id'] && isset($_GET['action']) && $_GET['action'] == 'delete') {
    4   $this->wpdb->query("DELETE FROM {$this->wpdb->prefix}inic_testimonial WHERE id={$_GET['id']}");
     4  $this->wpdb->delete("{$this->wpdb->prefix}inic_testimonial", array('id' => $_GET['id']));
    55  if ($this->wpdb->rows_affected) {
    66    $_data['updated'] = "The testimonial has been deleted successfully.";
     
    88}
    99   
    10 $_ord_by = get_option("inic_testimonial_list_ord_by") ? " ORDER BY " . get_option("inic_testimonial_list_ord_by") : "";
    11 $_result_per_page = get_option("inic_testimonial_admin_list_per_page");
     10$_ord_by = get_option("inic_testimonial_list_ord_by") ? " ORDER BY " . esc_html(get_option("inic_testimonial_list_ord_by")) : "";
     11$_result_per_page = esc_attr(get_option("inic_testimonial_admin_list_per_page"));
    1212?>
    1313
     
    1919  if(isset($_data) && is_array($_data)) {
    2020    foreach($_data as $_message_type => $_message) {
    21       echo '<div id="message" class="'.$_message_type.' below-h2"><p>'.$_message.'</p></div>';
     21      echo '<div id="message" class="'.  esc_attr($_message_type).' below-h2"><p>'.$_message.'</p></div>';
    2222    }
    2323  }
     
    3636      $this->tbl->display_col_function(function($item, $column_name) {
    3737                $item['is_featured'] = $item['is_featured'] ? "<br /><code style=\"color:#C00;\"> Featured </code>" : "";
    38                 return "<a href=\"{$item['project_url']}\" target=\"blank\">{$item['project_name']}</a><br /><i>[ {$item['tags']} ]{$item['is_featured']}</i>";
     38                return "<a href=\"".  esc_attr($item['project_url'])."\" target=\"blank\">".  esc_html($item['project_name'])."</a><br /><i>[ ".  esc_html($item['tags'])." ]{$item['is_featured']}</i>";
    3939              });
    4040
    4141      $this->tbl->add_col('client_name', "Client Name", true);
    4242      $this->tbl->display_col_function(function($item, $column_name) {
    43                 $item['city'] = $item['city'] ? "<br /><i>[ City: {$item['city']} ]</i>" : "";
    44                 $item['state'] = $item['state'] ? "<br /><i>[ State: {$item['state']} ]</i>" : "";
    45                 $item['country'] = $item['country'] ? "<br /><i>[ Country: {$item['country']} ]</i>" : "";
    46                 return "{$item['client_name']}{$item['city']}{$item['state']}{$item['country']}";
     43                $item['city'] = $item['city'] ? "<br /><i>[ City: ".  esc_html($item['city'])." ]</i>" : "";
     44                $item['state'] = $item['state'] ? "<br /><i>[ State: ".  esc_html($item['state'])." ]</i>" : "";
     45                $item['country'] = $item['country'] ? "<br /><i>[ Country: ".  esc_html($item['country'])." ]</i>" : "";
     46                return esc_html($item['client_name']) .  "{$item['city']}{$item['state']}{$item['country']}";
    4747              });
    4848
     
    5656      $this->tbl->add_col('thumb_img_url', "Thumb Image");
    5757      $this->tbl->display_col_function(function($item, $column_name) {
    58                 return $item['thumb_img_url'] ? "<a href=\"{$item['large_img_url']}\" target=\"_blank\"><img src=\"{$item['thumb_img_url']}\" width=\"100\" height=\"100\" /></a>" : "";
     58                return $item['thumb_img_url'] ? "<a href=\"".  esc_attr($item['large_img_url'])."\" target=\"_blank\"><img src=\"".  esc_attr($item['thumb_img_url'])."\" width=\"100\" height=\"100\" /></a>" : "";
    5959              });
    6060
  • indianic-testimonial/trunk/widget.php

    r567259 r770831  
    2424    <p>
    2525      <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
    26       <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" />
     26      <input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text" value="<?php echo esc_attr($title); ?>" />
    2727    </p>
    2828
    2929    <p>
    30       <label for="<?php echo $this->get_field_id('widget_template_id'); ?>"><?php _e('Select Widget Template:'); ?></label>
    31       <select class="widefat" id="<?php echo $this->get_field_id('widget_template_id'); ?>" name="<?php echo $this->get_field_name('widget_template_id'); ?>">
     30      <label for="<?php echo esc_attr($this->get_field_id('widget_template_id')); ?>"><?php _e('Select Widget Template:'); ?></label>
     31      <select class="widefat" id="<?php echo esc_attr($this->get_field_id('widget_template_id')); ?>" name="<?php echo esc_attr($this->get_field_name('widget_template_id')); ?>">
    3232        <?php
    3333        $available_widget_tpl = $this->wpdb->get_results("SELECT * FROM {$this->wpdb->prefix}inic_testimonial_widget");
     
    3535          foreach ($available_widget_tpl as $available_widget_tpl) {
    3636            $_selected = $widget_template_id == $available_widget_tpl->id ? ' selected="selected"' : '';
    37             echo "<option value=\"{$available_widget_tpl->id}\"{$_selected}>{$available_widget_tpl->title}</option>";
     37            echo "<option value=\"".  esc_attr($available_widget_tpl->id)."\"{$_selected}>".  esc_html($available_widget_tpl->title)."</option>";
    3838          }
    3939        } else {
     
    9898      }
    9999     
    100       //echo "SELECT * FROM {$this->wpdb->prefix}inic_testimonial{$_where}{$no_of_testimonial}";
    101100      $_testimonial_listing = $this->wpdb->get_results("SELECT * FROM {$this->wpdb->prefix}inic_testimonial{$_where}{$display_randomly}{$no_of_testimonial}");
    102101      if ($_testimonial_listing) {
    103102        foreach ($_testimonial_listing as $_testimonial_listing) {
    104103          $_search = array("{#ID}", "{#ProjectName}", "{#ProjectUrl}", "{#ClientName}", "{#City}", "{#State}", "{#Country}", "{#Description}", "{#Tags}", "{#VideoUrl}", "{#ThumbImgUrl}", "{#LargeImgUrl}", "{#Counter}");
    105           $_replace = array($_testimonial_listing->id, $_testimonial_listing->project_name, $_testimonial_listing->project_url, $_testimonial_listing->client_name, $_testimonial_listing->city, $_testimonial_listing->state, $_testimonial_listing->country, $_testimonial_listing->description, $_testimonial_listing->tags, $_testimonial_listing->video_url, $_testimonial_listing->thumb_img_url, $_testimonial_listing->large_img_url, $i);
     104          $_replace = array(esc_html($_testimonial_listing->id), esc_html($_testimonial_listing->project_name), esc_html($_testimonial_listing->project_url), esc_html($_testimonial_listing->client_name), esc_html($_testimonial_listing->city), esc_html($_testimonial_listing->state), esc_html($_testimonial_listing->country), esc_html($_testimonial_listing->description), esc_html($_testimonial_listing->tags), esc_html($_testimonial_listing->video_url), esc_html($_testimonial_listing->thumb_img_url), esc_html($_testimonial_listing->large_img_url), $i);
    106105
    107           $_code_value = array("{#ID}" => $_testimonial_listing->id, "{#ProjectName}" => $_testimonial_listing->project_name, "{#ProjectUrl}" => $_testimonial_listing->project_url, "{#ClientName}" => $_testimonial_listing->client_name, "{#City}" => $_testimonial_listing->city, "{#State}" => $_testimonial_listing->state, "{#Country}" => $_testimonial_listing->country, "{#Description}" => $_testimonial_listing->description, "{#Tags}" => $_testimonial_listing->tags, "{#VideoUrl}" => $_testimonial_listing->video_url, "{#ThumbImgUrl}" => $_testimonial_listing->thumb_img_url, "{#LargeImgUrl}" => $_testimonial_listing->large_img_url, "{#Counter}" => $i);
     106          $_code_value = array("{#ID}" => esc_html($_testimonial_listing->id), "{#ProjectName}" => esc_html($_testimonial_listing->project_name), "{#ProjectUrl}" => esc_html($_testimonial_listing->project_url), "{#ClientName}" => esc_html($_testimonial_listing->client_name), "{#City}" => esc_html($_testimonial_listing->city), "{#State}" => esc_html($_testimonial_listing->state), "{#Country}" => esc_html($_testimonial_listing->country), "{#Description}" => esc_html($_testimonial_listing->description), "{#Tags}" => esc_html($_testimonial_listing->tags), "{#VideoUrl}" => esc_html($_testimonial_listing->video_url), "{#ThumbImgUrl}" => esc_html($_testimonial_listing->thumb_img_url), "{#LargeImgUrl}" => esc_html($_testimonial_listing->large_img_url), "{#Counter}" => $i);
    108107          $inic_testimonial_html_template = $html_template;
    109108          preg_match('#\[IF\s(.+?)](.+?)\[/IF]#s', $inic_testimonial_html_template, $matches_if);
  • indianic-testimonial/trunk/widget_template.php

    r567259 r770831  
    5050      $_current_widget = $this->wpdb->get_results("SELECT * FROM {$this->wpdb->prefix}inic_testimonial_widget WHERE id='{$_GET['id']}'");
    5151      $_current_widget = $_current_widget[0];
    52       $id = $_current_widget->id;
    53       $title = $_current_widget->title;
    54       $no_of_testimonial = $_current_widget->no_of_testimonial;
    55       $only_featured = $_current_widget->only_featured;
    56       $filter_by_country = $_current_widget->filter_by_country;
    57       $filter_by_tags = $_current_widget->filter_by_tags;
    58       $display_randomly = $_current_widget->display_randomly;
    59       $html_template = $_current_widget->html_template;
     52      $id = esc_attr($_current_widget->id);
     53      $title = esc_attr($_current_widget->title);
     54      $no_of_testimonial = esc_attr($_current_widget->no_of_testimonial);
     55      $only_featured = esc_attr($_current_widget->only_featured);
     56      $filter_by_country = esc_attr($_current_widget->filter_by_country);
     57      $filter_by_tags = esc_attr($_current_widget->filter_by_tags);
     58      $display_randomly = esc_attr($_current_widget->display_randomly);
     59      $html_template = esc_attr($_current_widget->html_template);
    6060    } else {
    6161      $id = $title = $no_of_testimonial = $only_featured = $filter_by_country = $filter_by_tags = $display_randomly = $html_template = false;
     
    6464
    6565    <form name="testimonial_widget_template" method="post" action="">
     66      <?php wp_nonce_field('save_testimonial_widget_template','_nonce'); ?>
    6667      <input type="hidden" name="action" value="iNIC_testimonial_save_widget" />
    6768
     
    158159            $_results->only_featured = ($_results->only_featured) ? 'Yes' : 'No';
    159160            echo "<tr>
    160                     <td>{$_results->title}
     161                    <td>".  esc_html($_results->title)."
    161162                      <div class=\"row-actions\">
    162                         <span class=\"edit\"><a href=\"admin.php?page=inic_testimonial_widget_template&type=add&id={$_results->id}\" title=\"Edit this item\">Edit</a> | </span>
    163                         <span class=\"trash\"><a class=\"submitdelete\" title=\"Delete this item\" href=\"javascript:void(0)\" rel=\"{$_results->id}\">Delete</a></span>
     163                        <span class=\"edit\"><a href=\"admin.php?page=inic_testimonial_widget_template&type=add&id=".  esc_attr($_results->id)."\" title=\"Edit this item\">Edit</a> | </span>
     164                        <span class=\"trash\"><a class=\"submitdelete\" title=\"Delete this item\" href=\"javascript:void(0)\" rel=\"".  esc_attr($_results->id)."\">Delete</a></span>
    164165                      </div>
    165166                    </td>
    166                     <td>{$_results->no_of_testimonial}</td>
    167                     <td>{$_results->only_featured}</td>
    168                     <td>{$_results->filter_by_country}</td>
    169                     <td>{$_results->filter_by_tags}</td>
     167                    <td>". esc_html($_results->no_of_testimonial)."</td>
     168                    <td>".  esc_html($_results->only_featured)."</td>
     169                    <td>".  esc_html($_results->filter_by_country)."</td>
     170                    <td>".  esc_html($_results->filter_by_tags)."</td>
    170171                  </tr>";
    171172          }
Note: See TracChangeset for help on using the changeset viewer.