From b5942784fe64dc30a7eddce5eebed73c6b31097d Mon Sep 17 00:00:00 2001 From: marco Date: Tue, 7 Aug 2018 18:37:18 +0200 Subject: [PATCH] Plugin per caricamento pubblicazioni MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Inserisce e controlla che le pubblicazioni inserire nelle mail agli utenti non siano già state approvate o rifiutate Es. url http://localhost/test/?email=alessandro.fasso@unibg.it&doi=http://arxiv.org/abs/hep-ph/0412178v1&appr=1&veto=0 --- apprplug.php | 193 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 193 insertions(+) create mode 100644 apprplug.php diff --git a/apprplug.php b/apprplug.php new file mode 100644 index 0000000..77d0a1c --- /dev/null +++ b/apprplug.php @@ -0,0 +1,193 @@ + +

+

Pubblicazione già approvata da $apprveto2ins[1] !

+

+ '; + echo $html; + echo ""; + echo ""; + exit(); + + } else { + + if ( $apprveto2ins[2] == '1'){ + $html = '
+

+

Pubblicazione già sottoposta a veto da $apprveto2ins[3] !

+

+
'; + echo $html; + echo ""; + echo ""; + exit(); + + } + + } + + $query = "UPDATE wp_articoli SET appr = 1, wp_articoli.emailAppr = '$email' + WHERE wp_articoli.doi = '$doi'"; + $res3 = mysqli_query($dbhandle,$query); + $queryPost = "SELECT wp_articoli.authors,wp_articoli.published,wp_articoli.title,wp_articoli.ajournal,wp_articoli.doi,wp_articoli.summary FROM wp_articoli WHERE wp_articoli.doi = '$doi'"; + + $post2ins = mysqli_query($dbhandle,$queryPost); + $post2insarr = mysqli_fetch_array($post2ins); + + + $year = strtok($post2insarr[1], '-'); + //echo $year; + $year2ins = array($year); + + $post2 = array( + 'post_author' => 1, + 'post_content' => $post2insarr[5], + 'post_title' => $post2insarr[2], + 'post_name' => 'my-page', + //'tax_input' => $year2ins[0], + 'post_category' => $year2ins, + 'tags_input' => array($post2insarr[0]), + 'meta_input' => array( + 'rivista' => $post2insarr[3], + 'arxivdoi' => $post2insarr[4] + ), + 'post_excerpt' => '', + 'post_status' => 'publish', + 'comment_status' => 'close', + 'ping_status' => 'open', + 'post_type' => 'post', + 'comment_count' => 0 + ); + + $postid = wp_insert_post($post2); + + $query = " SELECT name FROM wp_terms"; + //echo $query; + $res4 = mysqli_query($dbhandle,$query); + $rows = array(); + while(($row = mysqli_fetch_array($res4))) { + $rows[] = $row; + } + //$res4arr = mysqli_fetch_array($res4); + + if (in_array($year, $rows)) { + $cat2ins = get_cat_ID( $year ); + } else { + wp_create_category( $year); + $cat2ins = get_cat_ID( $year ); + } + + //$test = array('8'); + + //wp_set_post_terms( $postid, $year2ins, 'category'); + wp_set_post_categories( $postid, $cat2ins ); + + + $html = '
+

+

Pubblicazione inserita correttamete !

+

+
'; + echo $html; + echo ""; + + //echo ""; + + mysqli_close($dbhandle); + + } else { + $query = "SELECT appr,emailAppr,veto,emailVeto FROM wp_articoli WHERE wp_articoli.doi = '$doi'"; + $apprveto = mysqli_query($dbhandle,$query); + $apprveto2ins = mysqli_fetch_array($apprveto); + if ( $apprveto2ins[2] == '1'){ + $html = '
+

+

Pubblicazione già sottoposta a veto da $apprveto2ins[3] !

+

+
'; + echo $html; + echo ""; + echo ""; + exit(); + + } else { + + if ( $apprveto2ins[0] == '1'){ + $html = '
+

+

Pubblicazione già approvata da $apprveto2ins[1] !

+

+
'; + echo $html; + echo ""; + echo ""; + exit(); + } + + } + + $query = "UPDATE wp_articoli SET veto = 1, wp_articoli.emailVeto = '$email' + WHERE wp_articoli.doi = '$doi'"; + $res5 = mysqli_query($dbhandle,$query); + $html = '
+

+

Pubblicazione sottooposta a veto correttamete !

+

+
'; + echo $html; + echo ""; + + + } + + } else { + //echo "App is empty"; + ; + } +} +add_action('init', 'insertpub'); +?>