Plugin Directory

Changeset 2681715


Ignore:
Timestamp:
02/19/2022 09:15:03 AM (4 years ago)
Author:
frier
Message:

20220219 update

Location:
books-papers
Files:
36 added
2 edited

Legend:

Unmodified
Added
Removed
  • books-papers/trunk/books-n-papers.php

    r2479969 r2681715  
    33Plugin Name: Books & Papers
    44Plugin URI:
    5 Version: 0.20210223
     5Version: 0.20220219
    66Author: Research in Theory of Magnetism Department of Taras Shevchenko National University of Kyiv
    77Author_URI: http://ritm.knu.ua/
     
    115115    {
    116116        include(bnpp_plugin_dir . "./pages/add-author-page.php");
    117         if(isset($_POST['firstName'])&&isset($_POST['lastName'])&& check_admin_referer('bnp_add_author') && current_user_can('publish_pages')) //checks vital inputs for author creation
     117        if(isset($_POST['firstName'])&&isset($_POST['lastName'])&& check_admin_referer('bnp_add_author') && current_user_can('publish_pages') && !preg_match("/[\"'*?<>|]$/", $_POST["firstName"]) && !preg_match("/[\"'*?<>|]$/", $_POST["lastName"])) //checks vital inputs for author creation
    118118        {
    119119            $author = new BNPP_Author($this->dbAuthors); //creates author object and fills data fields
    120120            $author->firstName = sanitize_text_field($_POST['firstName']);
    121121            $author->lastName = sanitize_text_field($_POST['lastName']);
    122             $author->email = sanitize_email($_POST['email']);
    123             $author->personalUrl = sanitize_text_field($_POST['url']);
    124             $author->slug = sanitize_text_field($_POST['slug']);
     122            if(!preg_match("/[\"'*?<>|]$/", $_POST["email"])){
     123                $author->email = sanitize_email($_POST['email']);
     124            }
     125            if(!preg_match("/[\"'*?<>|]$/", $_POST["url"])){
     126                $author->personalUrl = sanitize_text_field($_POST['url']);
     127            }
     128            if(!preg_match("/[\"'*?<>|]$/", $_POST["slug"])){
     129                $author->personalUrl = sanitize_text_field($_POST['slug']);
     130            }
    125131            $author->InsertAuthorInfo(); //calls author creation function
    126132            $timeout = get_option('bnpp_timeout_step') * 100;
    127             //echo "<script>window.onload = function () { document.getElementById('success').innerHTML = 'Author $author->firstName $author->lastName was added.';setTimeout(function() {window.location=document.location.href;},$timeout);  } </script>";
    128133        }
    129134    }
     
    154159            } else if(sanitize_text_field($_POST["checkManage"])=="update") //checks if modification call was recieved
    155160            {
    156                 $sql = $wpdb->prepare("UPDATE $this->dbAuthors SET first_name = %s, last_name = %s, email = %s, personal_url = %s, slug = %s WHERE (id = %d)", array(sanitize_text_field($_POST["firstName"]), sanitize_text_field($_POST["lastName"]), sanitize_email($_POST["email"]), sanitize_text_field($_POST["url"]), sanitize_text_field($_POST["slug"]), sanitize_text_field($_POST["authorID"]))); //updates author data in table
    157                 $wpdb->query($sql);
     161                if(!preg_match("/[\"'*?<>|]$/", $_POST["firstName"]) && !preg_match("/[\"'*?<>|]$/", $_POST["lastName"])){
     162                    $sql = $wpdb->prepare("UPDATE $this->dbAuthors SET first_name = %s, last_name = %s, email = %s, personal_url = %s, slug = %s WHERE (id = %d)", array(sanitize_text_field($_POST["firstName"]), sanitize_text_field($_POST["lastName"]), (!preg_match("/[\"'*?<>|]$/", $_POST["email"]) ? sanitize_email($_POST["email"]) : ""), (!preg_match("/[\"'*?<>|]$/", $_POST["url"]) ? sanitize_text_field($_POST["url"]) : ""), (!preg_match("/[\"'*?<>|]$/", $_POST["slug"]) ? sanitize_text_field($_POST["slug"]) : ""), sanitize_text_field($_POST["authorID"]))); //updates author data in table
     163                    $wpdb->query($sql);
     164                }
    158165                echo "<script>window.onload = function () { document.getElementById('success').innerHTML = 'Author " . sanitize_text_field($_POST['authorID']) . " has been updated.';setTimeout(function() {window.location=document.location.href;},$timeout); }</script>";
    159166            }
     
    179186            echo "<script>window.location=document.location.href;</script>";
    180187        }
    181         if(isset($_POST["promote"])&& check_admin_referer('bnp_promote_authors') && current_user_can('publish_pages'))
     188        if(isset($_POST["promote"])&& check_admin_referer('bnp_promote_authors') && current_user_can('publish_pages') && !preg_match("/[\"'*?<>|]$/", $_POST["firstName"]) && !preg_match("/[\"'*?<>|]$/", $_POST["lastName"]))
    182189        {
    183190            $author = new BNPP_Author($this->dbAuthors); //creates author object and fills data fields
    184191            $author->firstName = sanitize_text_field($_POST['firstName']);
    185192            $author->lastName = sanitize_text_field($_POST['lastName']);
    186             $author->email = sanitize_email($_POST['email']);
    187             $author->personalUrl = sanitize_text_field($_POST['url']);
    188             $author->slug = sanitize_text_field($_POST['slug']);
     193            if(!preg_match("/[\"'*?<>|]$/", $_POST["email"])){
     194                $author->email = sanitize_email($_POST['email']);
     195            }
     196            if(!preg_match("/[\"'*?<>|]$/", $_POST["url"])){
     197                $author->personalUrl = sanitize_text_field($_POST['url']);
     198            }
     199            if(!preg_match("/[\"'*?<>|]$/", $_POST["slug"])){
     200                $author->personalUrl = sanitize_text_field($_POST['slug']);
     201            }
    189202            $author->InsertAuthorInfo(); //calls author creation function
    190203            $newAuthor = $wpdb->get_results("SELECT * FROM $this->dbAuthors ORDER BY id DESC LIMIT 1");
     
    212225            echo "<script>window.onload = function () { document.getElementById('success').innerHTML = 'Author $author->firstName $author->lastName was added.';setTimeout(function() {window.location=document.location.href;},$timeout);  } </script>";
    213226        }
     227    }
     228   
     229    function clean_input($text_input){ //cleans input text data from prohibited symbols
     230        if(preg_match("/[\"'*<>|]$/", $text_input)){
     231            $to_replace = array("'", "\"", "*", "<", ">", "|", "\\");
     232            $text_input = str_replace($to_replace, "", $text_input);
     233        }
     234        return $text_input;
    214235    }
    215236   
     
    261282                $fileName = "";
    262283                if(isset($_POST["file_m"]) && sanitize_text_field($_POST["file_m"])!="")
    263                     $fileName = sanitize_text_field($_POST["file_m"]);
     284                    $fileName = $this->clean_input(sanitize_text_field($_POST["file_m"]));
    264285                else
    265286                    $fileName = sanitize_mime_type($_FILES['file']['name']);
    266                 $this->bridge->addArticle(sanitize_text_field($_POST["title"]), sanitize_text_field($_POST["year"]), sanitize_text_field($_POST["pages"]), sanitize_text_field($_POST["doi"]), sanitize_text_field($_POST["url"]), sanitize_text_field($_POST["issn"]), sanitize_text_field($_POST["supp"]), $fileName, sanitize_text_field($_POST["date"]), sanitize_text_field($_POST["public"]), sanitize_text_field($_POST["arxiv"]), $this->bridge->checkJournal(sanitize_text_field($_POST["journal"])), sanitize_text_field($_POST["volume"]), sanitize_text_field($_POST["issue"]), $char1val, $char2val, $char3val, sanitize_text_field($_POST["preprint"])); //writes article data in table
     287                $this->bridge->addArticle(sanitize_text_field($_POST["title"]), sanitize_text_field($_POST["year"]), $this->clean_input(sanitize_text_field($_POST["pages"])), $this->clean_input(sanitize_text_field($_POST["doi"])), $this->clean_input(sanitize_text_field($_POST["url"])), $this->clean_input(sanitize_text_field($_POST["issn"])), $this->clean_input(sanitize_text_field($_POST["supp"])), $fileName, sanitize_text_field($_POST["date"]), sanitize_text_field($_POST["public"]), $this->clean_input(sanitize_text_field($_POST["arxiv"])), $this->bridge->checkJournal($this->clean_input(sanitize_text_field($_POST["journal"]))), sanitize_text_field($_POST["volume"]), sanitize_text_field($_POST["issue"]), $char1val, $char2val, $char3val, sanitize_text_field($_POST["preprint"])); //writes article data in table
    267288                $art_id;
    268289                $data = $wpdb->get_results("SELECT id FROM " . $this->dbArticles . " ORDER By id DESC LIMIT 1"); //gets id of previously created article
     
    275296                    if(isset($_POST["author" . $k]))
    276297                    { //relates every author with article
    277                         $this->bridge->addArticleAuthor($this->bridge->checkAuthor(sanitize_text_field($_POST["author" . $k])), $art_id);
     298                        $this->bridge->addArticleAuthor($this->bridge->checkAuthor($this->clean_input(sanitize_text_field($_POST["author" . $k]))), $art_id);
    278299                    }
    279300                }
     
    282303                    if(isset($_POST["tag" . $k]))
    283304                    { //relates every tag with article
    284                         $this->bridge->addArticleTag($this->bridge->checkTag(sanitize_text_field($_POST["tag" . $k])), $art_id);
     305                        $this->bridge->addArticleTag($this->bridge->checkTag($this->clean_input(sanitize_text_field($_POST["tag" . $k]))), $art_id);
    285306                    }
    286307                }
     
    308329                $fileName = "";
    309330                if(isset($_POST["file_m"]) && sanitize_text_field($_POST["file_m"])!="")
    310                     $fileName = sanitize_text_field($_POST["file_m"]);
     331                    $fileName = $this->clean_input(sanitize_text_field($_POST["file_m"]));
    311332                else
    312333                    $fileName = sanitize_mime_type($_FILES['file']['name']);
    313                 $this->bridge->addConference(sanitize_text_field($_POST["title"]), sanitize_text_field($_POST["year"]), sanitize_text_field($_POST["pages"]), sanitize_text_field($_POST["doi"]), sanitize_text_field($_POST["url"]), sanitize_text_field($_POST["issn"]), sanitize_text_field($_POST["supp"]), $fileName, sanitize_text_field($_POST["date"]), sanitize_text_field($_POST["public"]), sanitize_text_field($_POST["arxiv"]), sanitize_text_field($_POST["bookTitle"]), sanitize_text_field($_POST["confPages"]), $char1val, $char2val, $char3val); //writes conference data in table
     334                $this->bridge->addConference(sanitize_text_field($_POST["title"]), sanitize_text_field($_POST["year"]), $this->clean_input(sanitize_text_field($_POST["pages"])), $this->clean_input(sanitize_text_field($_POST["doi"])), $this->clean_input(sanitize_text_field($_POST["url"])), $this->clean_input(sanitize_text_field($_POST["issn"])), $this->clean_input(sanitize_text_field($_POST["supp"])), $fileName, sanitize_text_field($_POST["date"]), sanitize_text_field($_POST["public"]), $this->clean_input(sanitize_text_field($_POST["arxiv"])), sanitize_text_field($_POST["bookTitle"]), $this->clean_input(sanitize_text_field($_POST["confPages"])), $char1val, $char2val, $char3val); //writes conference data in table
    314335                $art_id;
    315336                $data = $wpdb->get_results("SELECT id FROM " . $this->dbConferences . " ORDER By id DESC LIMIT 1"); //gets id of previously created conference
     
    322343                    if(isset($_POST["author" . $k]))
    323344                    { //relates every author with conference
    324                         $this->bridge->addConferenceAuthor($this->bridge->checkAuthor(sanitize_text_field($_POST["author" . $k])), $art_id);
     345                        $this->bridge->addConferenceAuthor($this->bridge->checkAuthor($this->clean_input(sanitize_text_field($_POST["author" . $k]))), $art_id);
    325346                    }
    326347                }
     
    329350                    if(isset($_POST["tag" . $k]))
    330351                    { //relates every tag with conference
    331                         $this->bridge->addConferenceTag($this->bridge->checkTag(sanitize_text_field($_POST["tag" . $k])), $art_id);
     352                        $this->bridge->addConferenceTag($this->bridge->checkTag($this->clean_input(sanitize_text_field($_POST["tag" . $k]))), $art_id);
    332353                    }
    333354                }
     
    355376                $fileName = "";
    356377                if(isset($_POST["file_m"]) && sanitize_text_field($_POST["file_m"])!="")
    357                     $fileName = sanitize_text_field($_POST["file_m"]);
     378                    $fileName = $this->clean_input(sanitize_text_field($_POST["file_m"]));
    358379                else
    359380                    $fileName = sanitize_mime_type($_FILES['file']['name']);
    360                 $this->bridge->addBook(sanitize_text_field($_POST["title"]), sanitize_text_field($_POST["year"]), sanitize_text_field($_POST["pages"]), sanitize_text_field($_POST["doi"]), sanitize_text_field($_POST["url"]), sanitize_text_field($_POST["issn"]), sanitize_text_field($_POST["supp"]), $fileName, sanitize_text_field($_POST["date"]), sanitize_text_field($_POST["public"]), sanitize_text_field($_POST["arxiv"]), sanitize_text_field($_POST["publisher"]), sanitize_text_field($_POST["chapter"]), sanitize_text_field($_POST["isbn"]), $char1val, $char2val, $char3val); //writes book data in table
     381                $this->bridge->addBook(sanitize_text_field($_POST["title"]), sanitize_text_field($_POST["year"]), $this->clean_input(sanitize_text_field($_POST["pages"])), $this->clean_input(sanitize_text_field($_POST["doi"])), $this->clean_input(sanitize_text_field($_POST["url"])), $this->clean_input(sanitize_text_field($_POST["issn"])), $this->clean_input(sanitize_text_field($_POST["supp"])), $fileName, sanitize_text_field($_POST["date"]), sanitize_text_field($_POST["public"]), $this->clean_input(sanitize_text_field($_POST["arxiv"])), $this->clean_input(sanitize_text_field($_POST["publisher"])), $this->clean_input(sanitize_text_field($_POST["chapter"])), $this->clean_input(sanitize_text_field($_POST["isbn"])), $char1val, $char2val, $char3val); //writes book data in table
    361382                $art_id;
    362383                $data = $wpdb->get_results("SELECT id FROM " . $this->dbBooks . " ORDER By id DESC LIMIT 1"); //gets id of previously created book
     
    369390                    if(isset($_POST["author" . $k]))
    370391                    { //relates every author with book
    371                         $this->bridge->addBookAuthor($this->bridge->checkAuthor(sanitize_text_field($_POST["author" . $k])), $art_id);
     392                        $this->bridge->addBookAuthor($this->bridge->checkAuthor($this->clean_input(sanitize_text_field($_POST["author" . $k]))), $art_id);
    372393                    }
    373394                }
     
    376397                    if(isset($_POST["editor" . $k]))
    377398                    { //relates every editor with book
    378                         $this->bridge->addBookEditor($this->bridge->checkAuthor(sanitize_text_field($_POST["editor" . $k])), $art_id);
     399                        $this->bridge->addBookEditor($this->bridge->checkAuthor($this->clean_input(sanitize_text_field($_POST["editor" . $k]))), $art_id);
    379400                    }
    380401                }
     
    383404                    if(isset($_POST["tag" . $k]))
    384405                    { //relates every tag with book
    385                         $this->bridge->addBookTag($this->bridge->checkTag(sanitize_text_field($_POST["tag" . $k])), $art_id);
     406                        $this->bridge->addBookTag($this->bridge->checkTag($this->clean_input(sanitize_text_field($_POST["tag" . $k]))), $art_id);
    386407                    }
    387408                }
     
    451472                        if(isset($_POST["author" . $k]) && sanitize_text_field($_POST["author" . $k])!="")
    452473                        { //creates new relations between article and authors
    453                             $this->bridge->addArticleAuthor($this->bridge->checkAuthor(sanitize_text_field($_POST["author" . $k])), sanitize_text_field($_POST['articleID']));
     474                            $this->bridge->addArticleAuthor($this->bridge->checkAuthor($this->clean_input(sanitize_text_field($_POST["author" . $k]))), sanitize_text_field($_POST['articleID']));
    454475                        }
    455476                    }
     
    459480                        if(isset($_POST["tag" . $k]) && sanitize_text_field($_POST["tag" . $k])!="")
    460481                        { //creates new relations between article and tags
    461                             $this->bridge->addArticleTag($this->bridge->checkTag(sanitize_text_field($_POST["tag" . $k])), sanitize_text_field($_POST['articleID']));
     482                            $this->bridge->addArticleTag($this->bridge->checkTag($this->clean_input(sanitize_text_field($_POST["tag" . $k]))), sanitize_text_field($_POST['articleID']));
    462483                        }
    463484                    }
     
    479500                    $fileName = "";
    480501                    if(isset($_POST["file_m"]) && sanitize_text_field($_POST["file_m"])!="")
    481                         $fileName = sanitize_text_field($_POST["file_m"]);
     502                        $fileName = $this->clean_input(sanitize_text_field($_POST["file_m"]));
    482503                    else
    483504                        $fileName = sanitize_mime_type($_FILES['file']['name']);
    484                     $this->bridge->manageArticle(sanitize_text_field($_POST["title"]), sanitize_text_field($_POST["year"]), sanitize_text_field($_POST["pages"]), sanitize_text_field($_POST["doi"]), sanitize_text_field($_POST["url"]), sanitize_text_field($_POST["issn"]), sanitize_text_field($_POST["supp"]), $fileName, sanitize_text_field($_POST["date"]), sanitize_text_field($_POST["public"]), sanitize_text_field($_POST["arxiv"]), $this->bridge->checkJournal(sanitize_text_field($_POST["journal"])), sanitize_text_field($_POST["volume"]), sanitize_text_field($_POST["issue"]), sanitize_text_field($_POST["articleID"]), $char1val, $char2val, $char3val, sanitize_text_field($_POST["preprint"]));
     505                    $this->bridge->manageArticle(sanitize_text_field($_POST["title"]), sanitize_text_field($_POST["year"]), $this->clean_input(sanitize_text_field($_POST["pages"])), $this->clean_input(sanitize_text_field($_POST["doi"])), $this->clean_input(sanitize_text_field($_POST["url"])), $this->clean_input(sanitize_text_field($_POST["issn"])), $this->clean_input(sanitize_text_field($_POST["supp"])), $fileName, sanitize_text_field($_POST["date"]), sanitize_text_field($_POST["public"]), $this->clean_input(sanitize_text_field($_POST["arxiv"])), $this->bridge->checkJournal($this->clean_input(sanitize_text_field($_POST["journal"]))), sanitize_text_field($_POST["volume"]), sanitize_text_field($_POST["issue"]), sanitize_text_field($_POST["articleID"]), $char1val, $char2val, $char3val, sanitize_text_field($_POST["preprint"]));
    485506                    if(isset($_FILES['file']) && sanitize_mime_type($_FILES['file']['name']) != "")
    486507                    {
     
    521542                        if(isset($_POST["author" . $k]) && sanitize_text_field($_POST["author" . $k])!="")
    522543                        {
    523                             $this->bridge->addConferenceAuthor($this->bridge->checkAuthor(sanitize_text_field($_POST["author" . $k])), sanitize_text_field($_POST['articleID']));
     544                            $this->bridge->addConferenceAuthor($this->bridge->checkAuthor($this->clean_input(sanitize_text_field($_POST["author" . $k]))), sanitize_text_field($_POST['articleID']));
    524545                        }
    525546                    }
     
    529550                        if(isset($_POST["tag" . $k]) && sanitize_text_field($_POST["tag" . $k])!="")
    530551                        { //creates new relations between conference and tags
    531                             $this->bridge->addConferenceTag($this->bridge->checkTag(sanitize_text_field($_POST["tag" . $k])), sanitize_text_field($_POST['articleID']));
     552                            $this->bridge->addConferenceTag($this->bridge->checkTag($this->clean_input(sanitize_text_field($_POST["tag" . $k]))), sanitize_text_field($_POST['articleID']));
    532553                        }
    533554                    }
     
    549570                    $fileName = "";
    550571                    if(isset($_POST["file_m"]) && sanitize_text_field($_POST["file_m"])!="")
    551                         $fileName = sanitize_text_field($_POST["file_m"]);
     572                        $fileName = $this->clean_input(sanitize_text_field($_POST["file_m"]));
    552573                    else
    553574                        $fileName = sanitize_mime_type($_FILES['file']['name']);
    554                     $this->bridge->manageConference(sanitize_text_field($_POST["title"]), sanitize_text_field($_POST["year"]), sanitize_text_field($_POST["pages"]), sanitize_text_field($_POST["doi"]), sanitize_text_field($_POST["url"]), sanitize_text_field($_POST["issn"]), sanitize_text_field($_POST["supp"]), $fileName, sanitize_text_field($_POST["date"]), sanitize_text_field($_POST["public"]), sanitize_text_field($_POST["arxiv"]), sanitize_text_field($_POST["bookTitle"]), sanitize_text_field($_POST["confPages"]), sanitize_text_field($_POST["articleID"]), $char1val, $char2val, $char3val);
     575                    $this->bridge->manageConference(sanitize_text_field($_POST["title"]), sanitize_text_field($_POST["year"]), $this->clean_input(sanitize_text_field($_POST["pages"])), $this->clean_input(sanitize_text_field($_POST["doi"])), $this->clean_input(sanitize_text_field($_POST["url"])), $this->clean_input(sanitize_text_field($_POST["issn"])), $this->clean_input(sanitize_text_field($_POST["supp"])), $fileName, sanitize_text_field($_POST["date"]), sanitize_text_field($_POST["public"]), $this->clean_input(sanitize_text_field($_POST["arxiv"])), sanitize_text_field($_POST["bookTitle"]), $this->clean_input(sanitize_text_field($_POST["confPages"])), sanitize_text_field($_POST["articleID"]), $char1val, $char2val, $char3val);
    555576                    if(isset($_FILES['file']) && sanitize_mime_type($_FILES['file']['name']) != "")
    556577                    {
     
    591612                        if(isset($_POST["author" . $k]) && sanitize_text_field($_POST["author" . $k])!="")
    592613                        {
    593                             $this->bridge->addBookAuthor($this->bridge->checkAuthor(sanitize_text_field($_POST["author" . $k])), sanitize_text_field($_POST['articleID']));
     614                            $this->bridge->addBookAuthor($this->bridge->checkAuthor($this->clean_input(sanitize_text_field($_POST["author" . $k]))), sanitize_text_field($_POST['articleID']));
    594615                        }
    595616                    }
     
    599620                        if(isset($_POST["editor" . $k]) && sanitize_text_field($_POST["editor" . $k])!="")
    600621                        {
    601                             $this->bridge->addBookEditor($this->bridge->checkAuthor(sanitize_text_field($_POST["editor" . $k])), sanitize_text_field($_POST['articleID']));
     622                            $this->bridge->addBookEditor($this->bridge->checkAuthor($this->clean_input(sanitize_text_field($_POST["editor" . $k]))), sanitize_text_field($_POST['articleID']));
    602623                        }
    603624                    }
     
    607628                        if(isset($_POST["tag" . $k]) && sanitize_text_field($_POST["tag" . $k])!="")
    608629                        { //creates new relations between book and tags
    609                             $this->bridge->addBookTag($this->bridge->checkTag(sanitize_text_field($_POST["tag" . $k])), sanitize_text_field($_POST['articleID']));
     630                            $this->bridge->addBookTag($this->bridge->checkTag($this->clean_input(sanitize_text_field($_POST["tag" . $k]))), sanitize_text_field($_POST['articleID']));
    610631                        }
    611632                    }
     
    627648                    $fileName = "";
    628649                    if(isset($_POST["file_m"]) && sanitize_text_field($_POST["file_m"])!="")
    629                         $fileName = sanitize_text_field($_POST["file_m"]);
     650                        $fileName = $this->clean_input(sanitize_text_field($_POST["file_m"]));
    630651                    else
    631652                        $fileName = sanitize_mime_type($_FILES['file']['name']);
    632                     $this->bridge->manageBook(sanitize_text_field($_POST["title"]), sanitize_text_field($_POST["year"]), sanitize_text_field($_POST["pages"]), sanitize_text_field($_POST["doi"]), sanitize_text_field($_POST["url"]), sanitize_text_field($_POST["issn"]), sanitize_text_field($_POST["supp"]), $fileName, sanitize_text_field($_POST["date"]), sanitize_text_field($_POST["public"]), sanitize_text_field($_POST["arxiv"]), sanitize_text_field($_POST["publisher"]), sanitize_text_field($_POST["chapter"]), sanitize_text_field($_POST["isbn"]), sanitize_text_field($_POST["articleID"]), $char1val, $char2val, $char3val);
     653                    $this->bridge->manageBook(sanitize_text_field($_POST["title"]), sanitize_text_field($_POST["year"]), $this->clean_input(sanitize_text_field($_POST["pages"])), $this->clean_input(sanitize_text_field($_POST["doi"])), $this->clean_input(sanitize_text_field($_POST["url"])), $this->clean_input(sanitize_text_field($_POST["issn"])), $this->clean_input(sanitize_text_field($_POST["supp"])), $fileName, sanitize_text_field($_POST["date"]), sanitize_text_field($_POST["public"]), $this->clean_input(sanitize_text_field($_POST["arxiv"])), $this->clean_input(sanitize_text_field($_POST["publisher"])), $this->clean_input(sanitize_text_field($_POST["chapter"])), $this->clean_input(sanitize_text_field($_POST["isbn"])), sanitize_text_field($_POST["articleID"]), $char1val, $char2val, $char3val);
    633654                    if(isset($_FILES['file']) && sanitize_mime_type($_FILES['file']['name']) != "")
    634655                    {
     
    739760            if($_POST["paperType"]=="article") //inserts article paper info
    740761            {
    741                 $this->bridge->addArticle(sanitize_text_field($_POST["title"]), sanitize_text_field($_POST["year"]), sanitize_text_field($_POST["pages"]), sanitize_text_field($_POST["doi"]), sanitize_text_field($_POST["url"]), sanitize_text_field($_POST["issn"]), sanitize_text_field($_POST["supp"]), sanitize_text_field($_POST["file"]), sanitize_text_field($_POST["date"]), sanitize_text_field($_POST["public"]), sanitize_text_field($_POST["arxiv"]), $this->bridge->checkJournal(sanitize_text_field($_POST["journal"])), sanitize_text_field($_POST["volume"]), sanitize_text_field($_POST["issue"]), $char1val, $char2val, $char3val, sanitize_text_field($_POST["preprint"])); //writes article data in table
     762                $this->bridge->addArticle(sanitize_text_field($_POST["title"]), sanitize_text_field($_POST["year"]), $this->clean_input(sanitize_text_field($_POST["pages"])), $this->clean_input(sanitize_text_field($_POST["doi"])), $this->clean_input(sanitize_text_field($_POST["url"])), $this->clean_input(sanitize_text_field($_POST["issn"])), $this->clean_input(sanitize_text_field($_POST["supp"])), $this->clean_input(sanitize_text_field($_POST["file"])), sanitize_text_field($_POST["date"]), sanitize_text_field($_POST["public"]), $this->clean_input(sanitize_text_field($_POST["arxiv"])), $this->bridge->checkJournal($this->clean_input(sanitize_text_field($_POST["journal"]))), sanitize_text_field($_POST["volume"]), sanitize_text_field($_POST["issue"]), $char1val, $char2val, $char3val, sanitize_text_field($_POST["preprint"])); //writes article data in table
    742763                $art_id;
    743764                $data = $wpdb->get_results("SELECT id FROM " . $this->dbArticles . " ORDER By id DESC LIMIT 1"); //gets id of previously created article
     
    750771                    if(isset($_POST["author" . $k]))
    751772                    { //relates every author with article
    752                         $this->bridge->addArticleAuthor($this->bridge->checkAuthor(sanitize_text_field($_POST["author" . $k])), $art_id);
     773                        $this->bridge->addArticleAuthor($this->bridge->checkAuthor($this->clean_input(sanitize_text_field($_POST["author" . $k]))), $art_id);
    753774                    }
    754775                }
    755776                if(isset($_POST["tag"]))
    756777                { //relates tags with article
    757                     $this->bridge->addArticleTag($this->bridge->checkTag(sanitize_text_field($_POST["tag"])), $art_id);
     778                    $this->bridge->addArticleTag($this->bridge->checkTag($this->clean_input(sanitize_text_field($_POST["tag"]))), $art_id);
    758779                }
    759780                for($k = 0; $k <= 20; $k++)
     
    761782                    if(isset($_POST["tag" . $k]))
    762783                    { //relates tags with article
    763                         $this->bridge->addArticleTag($this->bridge->checkTag(sanitize_text_field($_POST["tag" . $k])), $art_id);
     784                        $this->bridge->addArticleTag($this->bridge->checkTag($this->clean_input(sanitize_text_field($_POST["tag" . $k]))), $art_id);
    764785                    }
    765786                }
    766787            } else if(sanitize_text_field($_POST["paperType"])=="conference") //inserts conference info
    767788            {
    768                 $this->bridge->addConference(sanitize_text_field($_POST["title"]), sanitize_text_field($_POST["year"]), sanitize_text_field($_POST["pages"]), sanitize_text_field($_POST["doi"]), sanitize_text_field($_POST["url"]), sanitize_text_field($_POST["issn"]), sanitize_text_field($_POST["supp"]), sanitize_text_field($_POST["file"]), sanitize_text_field($_POST["date"]), sanitize_text_field($_POST["public"]), sanitize_text_field($_POST["arxiv"]), sanitize_text_field($_POST["bookTitle"]), sanitize_text_field($_POST["confPages"]), $char1val, $char2val, $char3val); //writes conference data in table
     789                $this->bridge->addConference(sanitize_text_field($_POST["title"]), sanitize_text_field($_POST["year"]), $this->clean_input(sanitize_text_field($_POST["pages"])), $this->clean_input(sanitize_text_field($_POST["doi"])), $this->clean_input(sanitize_text_field($_POST["url"])), $this->clean_input(sanitize_text_field($_POST["issn"])), $this->clean_input(sanitize_text_field($_POST["supp"])), $this->clean_input(sanitize_text_field($_POST["file"])), sanitize_text_field($_POST["date"]), sanitize_text_field($_POST["public"]), $this->clean_input(sanitize_text_field($_POST["arxiv"])), sanitize_text_field($_POST["bookTitle"]), $this->clean_input(sanitize_text_field($_POST["confPages"])), $char1val, $char2val, $char3val); //writes conference data in table
    769790                $art_id;
    770791                $data = $wpdb->get_results("SELECT id FROM " . $this->dbConferences . " ORDER By id DESC LIMIT 1"); //gets id of previously created conference
     
    777798                    if(isset($_POST["author" . $k]))
    778799                    { //relates every author with conference
    779                         $this->bridge->addConferenceAuthor($this->bridge->checkAuthor(sanitize_text_field($_POST["author" . $k])), $art_id);
     800                        $this->bridge->addConferenceAuthor($this->bridge->checkAuthor($this->clean_input(sanitize_text_field($_POST["author" . $k]))), $art_id);
    780801                    }
    781802                }
    782803                if(isset($_POST["tag"]))
    783804                { //relates tags with article
    784                     $this->bridge->addConferenceTag($this->bridge->checkTag(sanitize_text_field($_POST["tag"])), $art_id);
     805                    $this->bridge->addConferenceTag($this->bridge->checkTag($this->clean_input(sanitize_text_field($_POST["tag"]))), $art_id);
    785806                }
    786807                for($k = 0; $k <= 20; $k++)
     
    788809                    if(isset($_POST["tag" . $k]))
    789810                    { //relates tags with article
    790                         $this->bridge->addConferenceTag($this->bridge->checkTag(sanitize_text_field($_POST["tag" . $k])), $art_id);
     811                        $this->bridge->addConferenceTag($this->bridge->checkTag($this->clean_input(sanitize_text_field($_POST["tag" . $k]))), $art_id);
    791812                    }
    792813                }
    793814            } else if(sanitize_text_field($_POST["paperType"])=="book") //inserts book info
    794815            {
    795                 $this->bridge->addBook(sanitize_text_field($_POST["title"]), sanitize_text_field($_POST["year"]), sanitize_text_field($_POST["pages"]), sanitize_text_field($_POST["doi"]), sanitize_text_field($_POST["url"]), sanitize_text_field($_POST["issn"]), sanitize_text_field($_POST["supp"]), sanitize_text_field($_POST["file"]), sanitize_text_field($_POST["date"]), sanitize_text_field($_POST["public"]), sanitize_text_field($_POST["arxiv"]), sanitize_text_field($_POST["publisher"]), sanitize_text_field($_POST["chapter"]), sanitize_text_field($_POST["isbn"]), $char1val, $char2val, $char3val); //writes book data in table
     816                $this->bridge->addBook(sanitize_text_field($_POST["title"]), sanitize_text_field($_POST["year"]), $this->clean_input(sanitize_text_field($_POST["pages"])), $this->clean_input(sanitize_text_field($_POST["doi"])), $this->clean_input(sanitize_text_field($_POST["url"])), $this->clean_input(sanitize_text_field($_POST["issn"])), $this->clean_input(sanitize_text_field($_POST["supp"])), $this->clean_input(sanitize_text_field($_POST["file"])), sanitize_text_field($_POST["date"]), sanitize_text_field($_POST["public"]), $this->clean_input(sanitize_text_field($_POST["arxiv"])), $this->clean_input(sanitize_text_field($_POST["publisher"])), $this->clean_input(sanitize_text_field($_POST["chapter"])), $this->clean_input(sanitize_text_field($_POST["isbn"])), $char1val, $char2val, $char3val); //writes book data in table
    796817                $art_id;
    797818                $data = $wpdb->get_results("SELECT id FROM " . $this->dbBooks . " ORDER By id DESC LIMIT 1"); //gets id of previously created book
     
    804825                    if(isset($_POST["author" . $k]))
    805826                    { //relates every author with book
    806                         $this->bridge->addBookAuthor($this->bridge->checkAuthor(sanitize_text_field($_POST["author" . $k])), $art_id);
     827                        $this->bridge->addBookAuthor($this->bridge->checkAuthor($this->clean_input(sanitize_text_field($_POST["author" . $k]))), $art_id);
    807828                    }
    808829                }
     
    811832                    if(isset($_POST["editor" . $k]))
    812833                    { //relates every editor with book
    813                         $this->bridge->addBookEditor($this->bridge->checkAuthor(sanitize_text_field($_POST["editor" . $k])), $art_id);
     834                        $this->bridge->addBookEditor($this->bridge->checkAuthor($this->clean_input(sanitize_text_field($_POST["editor" . $k]))), $art_id);
    814835                    }
    815836                }
    816837                if(isset($_POST["tag"]))
    817838                { //relates tags with article
    818                     $this->bridge->addBookTag($this->bridge->checkTag(sanitize_text_field($_POST["tag"])), $art_id);
     839                    $this->bridge->addBookTag($this->bridge->checkTag($this->clean_input(sanitize_text_field($_POST["tag"]))), $art_id);
    819840                }
    820841                for($k = 0; $k <= 20; $k++)
     
    822843                    if(isset($_POST["tag" . $k]))
    823844                    { //relates tags with article
    824                         $this->bridge->addBookTag($this->bridge->checkTag(sanitize_text_field($_POST["tag" . $k])), $art_id);
     845                        $this->bridge->addBookTag($this->bridge->checkTag($this->clean_input(sanitize_text_field($_POST["tag" . $k]))), $art_id);
    825846                    }
    826847                }
     
    862883        if(isset($_POST["prefix"])&& check_admin_referer('bnp_prefix_setting') && current_user_can('publish_pages')) //checks if db prefix was set
    863884        {
    864             if(sanitize_text_field($_POST["prefix"]) != "") //if not empty, sets new prefix value
     885            if(sanitize_text_field($_POST["prefix"]) != "" && preg_match("/^[a-zA-Z0-9_-]*$/", $_POST["prefix"])) //if not empty, sets new prefix value
    865886            {
    866887                update_option('bnpp_tables_created', false);
    867888                update_option('bnpp_custom_db_prefix',sanitize_text_field($_POST["prefix"]));
    868889                echo "<script type='text/javascript'> window.location=document.location.href;</script>";
     890            } else {
     891                echo "<script type='text/javascript'> alert('The prefix cannot contain special characters. Please, use letters, numbers, dash and underscore only!'); window.location=document.location.href;</script>";
    869892            }
    870893        }
     
    872895        if(isset($_POST["comp_rbracket"])&& check_admin_referer('bnp_compatibility_setting') && current_user_can('publish_pages'))
    873896        {
    874             update_option('bnpp_comp_rbracket',sanitize_text_field($_POST["comp_rbracket"]));
    875             update_option('bnpp_comp_lbracket',sanitize_text_field($_POST["comp_lbracket"]));
     897            if(preg_match("/^[a-zA-Z0-9_\[\](){}-]*$/", $_POST["comp_rbracket"])){
     898                update_option('bnpp_comp_rbracket',sanitize_text_field($_POST["comp_rbracket"]));
     899            } else {
     900                echo "<script type='text/javascript'> alert('The brackets cannot contain special characters. Please, use letters, numbers, dash, brackets and underscore only!'); window.location=document.location.href;</script>";
     901            }
     902            if(preg_match("/^[a-zA-Z0-9_\[\](){}-]*$/", $_POST["comp_lbracket"])){
     903                update_option('bnpp_comp_lbracket',sanitize_text_field($_POST["comp_lbracket"]));
     904            } else {
     905                echo "<script type='text/javascript'> alert('The brackets cannot contain special characters. Please, use letters, numbers, dash, brackets and underscore only!'); window.location=document.location.href;</script>";
     906            }
    876907            if(isset($_POST["comp_pub"]))
    877908                update_option('bnpp_comp_pub',true);
     
    903934        if(isset($_POST["upload_abs_hidden"])&& check_admin_referer('bnp_upload_dir_setting') && current_user_can('publish_pages'))
    904935        {
    905             update_option('bnpp_upload_dir',sanitize_text_field($_POST["upload"]));
     936            if(!preg_match("/[\"'*?<>|]$/", $_POST["upload"])){
     937                update_option('bnpp_upload_dir',sanitize_text_field($_POST["upload"]));
     938            } else {
     939                echo "<script type='text/javascript'> alert('Cannot accept the upload folder path. Please, avoid using these symbols for the folder: \", \', *, ?, <, >, |'); window.location=document.location.href;</script>";
     940            }
    906941            if(isset($_POST["upload_abs"]))
    907942                update_option('bnpp_upload_dir_abs',true);
     
    928963            }
    929964            update_option('bnpp_list_division',sanitize_text_field($_POST["listDivision"]));
    930             update_option('bnpp_list_division_style',sanitize_text_field($_POST["listDivisionStyle"]));
     965            if(preg_match("/^[a-zA-Z0-9_.,:; #()%-]*$/", $_POST["listDivisionStyle"])){
     966                update_option('bnpp_list_division_style',sanitize_text_field($_POST["listDivisionStyle"]));
     967            } else {
     968                echo "<script type='text/javascript'> alert('Style input contains disallowed symbols.'); window.location=document.location.href;</script>";
     969            }
    931970            update_option('bnpp_list_order',sanitize_text_field($_POST["listOrder"]));
    932971            echo "<script type='text/javascript'> window.location=document.location.href;</script>";
     
    934973        if(isset($_POST["lstylevalue"])&& check_admin_referer('bnp_lstyle_setting') && current_user_can('publish_pages'))
    935974        {
    936             update_option('bnpp_lstyle_value',sanitize_text_field($_POST["lstylevalue"]));
    937             echo "<script type='text/javascript'> window.location=document.location.href;</script>";
     975            if(preg_match("/^[a-zA-Z0-9_.,:; #()%-]*$/", $_POST["lstylevalue"])){
     976                update_option('bnpp_lstyle_value',sanitize_text_field($_POST["lstylevalue"]));
     977                echo "<script type='text/javascript'> window.location=document.location.href;</script>";
     978            } else {
     979                echo "<script type='text/javascript'> alert('Style input contains disallowed symbols.'); window.location=document.location.href;</script>";
     980            }
    938981        }
    939982        //sets characteristics values
    940983        if(isset($_POST["char1name"])&& check_admin_referer('bnp_char1_setting') && current_user_can('publish_pages'))
    941984        {
    942             update_option('bnpp_custom_char1_name',sanitize_text_field($_POST["char1name"]));
    943             update_option('bnpp_custom_char1_value',sanitize_text_field($_POST["char1value"]));
     985            if(preg_match("/^[a-zA-Z0-9_-]*$/", $_POST["char1name"])){
     986                update_option('bnpp_custom_char1_name',sanitize_text_field($_POST["char1name"]));
     987            } else {
     988                echo "<script type='text/javascript'> alert('The characteristic name cannot contain special characters. Please, use letters, numbers, dash and underscore only!'); window.location=document.location.href;</script>";
     989            }
     990            if(preg_match("/^[a-zA-Z0-9_.,:; #()%-]*$/", $_POST["char1value"])){
     991                update_option('bnpp_custom_char1_value',sanitize_text_field($_POST["char1value"]));
     992            } else {
     993                echo "<script type='text/javascript'> alert('Style input contains disallowed symbols.'); window.location=document.location.href;</script>";
     994            }
    944995            echo "<script type='text/javascript'> window.location=document.location.href;</script>";
    945996        }
    946997        if(isset($_POST["char2name"])&& check_admin_referer('bnp_char2_setting') && current_user_can('publish_pages'))
    947998        {
    948             update_option('bnpp_custom_char2_name',sanitize_text_field($_POST["char2name"]));
    949             update_option('bnpp_custom_char2_value',sanitize_text_field($_POST["char2value"]));
     999            if(preg_match("/^[a-zA-Z0-9_-]*$/", $_POST["char2name"])){
     1000                update_option('bnpp_custom_char2_name',sanitize_text_field($_POST["char2name"]));
     1001            } else {
     1002                echo "<script type='text/javascript'> alert('The characteristic name cannot contain special characters. Please, use letters, numbers, dash and underscore only!'); window.location=document.location.href;</script>";
     1003            }
     1004            if(preg_match("/^[a-zA-Z0-9_.,:; #()%-]*$/", $_POST["char2value"])){
     1005                update_option('bnpp_custom_char2_value',sanitize_text_field($_POST["char2value"]));
     1006            } else {
     1007                echo "<script type='text/javascript'> alert('Style input contains disallowed symbols.'); window.location=document.location.href;</script>";
     1008            }
    9501009            echo "<script type='text/javascript'> window.location=document.location.href;</script>";
    9511010        }
    9521011        if(isset($_POST["char3name"])&& check_admin_referer('bnp_char3_setting') && current_user_can('publish_pages'))
    9531012        {
    954             update_option('bnpp_custom_char3_name',sanitize_text_field($_POST["char3name"]));
    955             update_option('bnpp_custom_char3_value',sanitize_text_field($_POST["char3value"]));
     1013            if(preg_match("/^[a-zA-Z0-9_-]*$/", $_POST["char3name"])){
     1014                update_option('bnpp_custom_char3_name',sanitize_text_field($_POST["char3name"]));
     1015            } else {
     1016                echo "<script type='text/javascript'> alert('The characteristic name cannot contain special characters. Please, use letters, numbers, dash and underscore only!'); window.location=document.location.href;</script>";
     1017            }
     1018            if(preg_match("/^[a-zA-Z0-9_.,:; #()%-]*$/", $_POST["char3value"])){
     1019                update_option('bnpp_custom_char3_value',sanitize_text_field($_POST["char3value"]));
     1020            } else {
     1021                echo "<script type='text/javascript'> alert('Style input contains disallowed symbols.'); window.location=document.location.href;</script>";
     1022            }
    9561023            echo "<script type='text/javascript'> window.location=document.location.href;</script>";
    9571024        }
     
    9691036            } else
    9701037            {
    971                 $this->bridge->dropTables(get_option('custom_db_prefix'));
     1038                $this->bridge->dropTables(get_option('bnpp_custom_db_prefix'));
    9721039                update_option('bnpp_drop_db_tables',true);
    9731040                update_option('bnpp_db_import_debug', 'No logs');
  • books-papers/trunk/readme.txt

    r2479970 r2681715  
    44Tags: academic, publication, paper, article, conference, proceedings, bibliography, management, auto-fill, autofill
    55Requires at least: 5.1.1
    6 Tested up to: 5.6
    7 Stable tag: 0.20210223
     6Tested up to: 5.9
     7Stable tag: 0.20220219
    88Requires PHP: 5.6
    99License: GPLv2 or later
     
    113113== Changelog ==
    114114
     115= 0.20220219 =
     116* Fixed input fields vulnerability.
     117
    115118= 0.20210223 =
    116119* Fixed bug with incorrect representation of several authors with the same surnames.
     
    202205== Upgrade Notice ==
    203206
     207= 0.20220219 =
     208* Fixed input fields vulnerability.
     209
    204210= 0.20210223 =
    205211* Fixed bug with incorrect representation of several authors with the same surnames.
Note: See TracChangeset for help on using the changeset viewer.