From fca76f83e3ead30e8eac310be8adfe846927ec0d Mon Sep 17 00:00:00 2001 From: marco Date: Thu, 2 Aug 2018 19:00:59 +0200 Subject: [PATCH] Update wip inserimento post --- appr.php | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 106 insertions(+), 1 deletion(-) diff --git a/appr.php b/appr.php index 737c873..65a3d76 100644 --- a/appr.php +++ b/appr.php @@ -2,13 +2,21 @@ $username="root"; $password="vpsad24068"; $hostname = "localhost"; +define( 'SHORTINIT', true ); +require( './wp-load.php' ); +// require( 'wp-includes/post.php' ); +// require( 'wp-includes/post-template.php' ); +// require( 'wp-includes/revision.php' ); +// require( 'wp-includes/class-wp-post.php' ); +// require( 'wp-includes/user.php' ); +// require( 'wp-includes/taxonomy.php' ); //connection string with database $dbhandle = mysqli_connect($hostname, $username, $password); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } - +inserisci_pubblicazioni(); //echo 'Hello ' . htmlspecialchars($_GET["email"]) . htmlspecialchars($_GET["doi"]) . '!'; $doi = htmlspecialchars($_GET["doi"]); $email = htmlspecialchars($_GET["email"]); @@ -18,6 +26,103 @@ $query = "UPDATE wp_articoli SET appr = 1, wp_articoli.emailAppr = '$email' WHERE wp_articoli.doi = '$doi'"; echo $query; $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'"; +echo $queryPost; +$post2ins = mysqli_query($dbhandle,$queryPost); +$post2insarr = mysqli_fetch_array($post2ins); +//$content = $post2insarr[5]; +//$title = $post2insarr[2]; + +$post = array( + 'post_author' => 1, + 'post_content' => $post2insarr[5], + 'post_title' => $post2insarr[2], + 'post_name' => 'my-page', + 'post_excerpt' => '', + 'post_status' => 'publish', + 'comment_status' => 'close', + 'ping_status' => 'open', + 'post_type' => 'page', + 'comment_count' => 0 +); + + +// $year = strtok($post2insarr[1], '-'); +// echo $year; +// $post2 = array( +// 'post_author' => 1, +// 'post_content' => $post2insarr[5], +// 'post_title' => $post2insarr[2], +// 'post_name' => 'my-page', +// 'post_category' => array($year), +// 'tags_input' => array($post2insarr[0]), +// 'meta_input' => array( +// 'ajournal' => $post2insarr[3], +// 'doi' => $post2insarr[4] +// ), +// 'post_excerpt' => '', +// 'post_status' => 'publish', +// 'comment_status' => 'close', +// 'ping_status' => 'open', +// 'post_type' => 'page', +// 'comment_count' => 0 +// ); + +//wp_insert_post($post2); + +$wpdb->insert( + 'wp_posts', + $post, + array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )); +$postID = $wpdb->insert_id; +echo $postID; + +$year = strtok($post2insarr[1], '-'); +echo $year; + +$wpdb->update( 'wp_posts', + array('comment_status'=> 'open',), // SET + array('ID'=> $postID,) // WHERE + ); +$wpdb->update( 'wp_postmeta', + array( + 'meta_value' => $post2insarr[3], + 'meta_key' => 'ajournal' + ), // SET + array('ID'=> $postID,) // WHERE +); +$wpdb->update( 'wp_postmeta', + array( + 'meta_value' => $post2insarr[4], + 'meta_key' => 'arxivdoi' + ), // SET + array('ID'=> $postID,) // WHERE +); + +//$item->published = date("Y",strtotime($item->published)); +//recupero l'anno di pubblicazione da inserire poi come categoria +$year = strtok($post2insarr[1], '-'); +echo $year; + +// $current_post = $postID; +// if($current_post){ +// setup_postdata( $GLOBALS['post'] =& $post_object ); +// $post = $current_post; +// update_post_meta( "$postID", "ajournal", "$post2insarr[3]" ); + +// } else { +// echo "cippa !"; +// } +//wp_set_post_tags( 50, array( 'awesome' ), true ); +//update_post_meta( "$postID", "ajournal", "$post2insarr[3]" ); + +// update_post_meta( $postID, 'doi', $post2insarr[4] ); + +// wp_set_post_tags( $postID, $post2insarr[0] ) ; + +// wp_set_post_categories( $postID, $year ); + mysqli_close($dbhandle); ?>