Pulizia formattazione e modifica logica inserimento
This commit is contained in:
+26
-55
@@ -4,52 +4,43 @@ $password="vpsad24068";
|
||||
$hostname = "localhost";
|
||||
//connection string with database
|
||||
$dbhandle = mysqli_connect($hostname, $username, $password)
|
||||
or die("Unable to connect to MySQL");
|
||||
echo "";
|
||||
or die("Unable to connect to MySQL");
|
||||
|
||||
// connect with database
|
||||
$selected = mysqli_select_db($dbhandle, "wptest")
|
||||
or die("Could not select examples");
|
||||
//$email = 'francesco.finazzi@unibg.it';
|
||||
or die("Could not select examples");
|
||||
|
||||
|
||||
$queryurl = "SELECT url,email FROM wp_autori2url";
|
||||
$result = mysqli_query($dbhandle,$queryurl);
|
||||
//$url = 'http://export.arxiv.org/api/query?search_query=au:Finazzi_F';
|
||||
|
||||
$url = '';
|
||||
while($row = mysqli_fetch_object($result)){
|
||||
$url = $row->url;
|
||||
$email = $row->email;
|
||||
$xml = file_get_contents($url);
|
||||
$newxml = str_replace('arxiv:','arxiv_',$xml);
|
||||
//$xml = simplexml_load_file($url); //retrieve URL and parse XML content
|
||||
//echo $xml->getName(); // output name of root element
|
||||
$xmlparse = simplexml_load_string($newxml);
|
||||
//$xmlparse = simplexml_load_string(html_entity_decode($xml), 'SimpleXMLElement', LIBXML_NOCDATA);
|
||||
$xml = file_get_contents($url);
|
||||
$newxml = str_replace('arxiv:','arxiv_',$xml);
|
||||
//$xml = simplexml_load_file($url); //retrieve URL and parse XML content
|
||||
//echo $xml->getName(); // output name of root element
|
||||
$xmlparse = simplexml_load_string($newxml);
|
||||
//$xmlparse = simplexml_load_string(html_entity_decode($xml), 'SimpleXMLElement', LIBXML_NOCDATA);
|
||||
|
||||
// $xml = file_get_contents('http://export.arxiv.org/api/query?search_query=au:Finazzi_F');
|
||||
//$articoli = array('http://export.arxiv.org/api/query?search_query=au:Finazzi_F');
|
||||
//foreach( $articoli as $articolo ) {
|
||||
//$xml = simplexml_load_file($articoli);
|
||||
$queryTrun = " TRUNCATE TABLE wp_rawdata ";
|
||||
mysqli_query($dbhandle,$queryTrun);
|
||||
|
||||
$queryTrun = " TRUNCATE TABLE wp_rawdata ";
|
||||
mysqli_query($dbhandle,$queryTrun);
|
||||
foreach($xmlparse->entry as $item)
|
||||
{
|
||||
$date_format = "j-n-Y"; // 7-7-2008
|
||||
|
||||
foreach($xmlparse->entry as $item)
|
||||
{
|
||||
$date_format = "j-n-Y"; // 7-7-2008
|
||||
|
||||
// foreach($item->xpath('link') as $link)
|
||||
// {
|
||||
// echo $link->xpath('title');
|
||||
// }
|
||||
|
||||
echo '<style type="text/css">.style1 { direction: rtl;</style><p class="style1">';
|
||||
echo $item->published;
|
||||
echo '<br><a href="'.$item->id.'" target="_blank">'.$item->title.'</a><br>';
|
||||
echo '<div>' . $item->summary . '</div><br><br><br><hr><br>';
|
||||
$autori = '';
|
||||
foreach($item->author as $autore){
|
||||
$autori = $autori.$autore->name. ', ';
|
||||
echo '<style type="text/css">.style1 { direction: rtl;</style><p class="style1">';
|
||||
echo $item->published;
|
||||
echo '<br><a href="'.$item->id.'" target="_blank">'.$item->title.'</a><br>';
|
||||
echo '<div>' . $item->summary . '</div><br><br><br><hr><br>';
|
||||
$autori = '';
|
||||
foreach($item->author as $autore){
|
||||
$autori = $autori.$autore->name. ', ';
|
||||
}
|
||||
|
||||
echo $autori .'<br>';
|
||||
|
||||
$categorie = '';
|
||||
@@ -57,21 +48,13 @@ foreach($item->category as $categoria){
|
||||
$categorie = $categorie.$categoria['term']. ', ';
|
||||
}
|
||||
|
||||
echo $categorie .'<br>';
|
||||
//echo $categorie .'<br>';
|
||||
//echo '<div>' . $item->xpath('link')->title . '</div><br><br><br><hr><br>';
|
||||
//echo '<div>' . $item->content . '</div><br><br><br>';
|
||||
echo '</p>';
|
||||
|
||||
$prova = mysqli_query($dbhandle,"SELECT * FROM wp_iscritti");
|
||||
//$item->published = '2018-07-04';
|
||||
//$newdate = date("Y-m-d",strtotime($item->published));
|
||||
// echo '</p>';
|
||||
|
||||
$item->published = date("Y-m-d",strtotime($item->published));
|
||||
|
||||
//$item->published = string(date($item->published));
|
||||
//echo $prova;
|
||||
//$query = "INSERT INTO wp_rawdata ( email, doi, published, title, summary, authors, ajournal, categories);
|
||||
|
||||
$query = "INSERT INTO wp_rawdata ( email, doi, published, title, summary, authors, ajournal, categories)
|
||||
|
||||
VALUES (
|
||||
@@ -87,18 +70,6 @@ VALUES (
|
||||
echo $query;
|
||||
mysqli_query($dbhandle,$query);
|
||||
|
||||
// mysqli_query($dbhandle,"INSERT INTO wp_rawdata (idx, doi, email, published, title, summary, authors, ajournal, categories)
|
||||
// VALUES (
|
||||
// '',
|
||||
// '".mysqli_real_escape_string($dbhandle,$item->id)."',
|
||||
// '".mysqli_real_escape_string($dbhandle,$email)."',
|
||||
// '".mysqli_real_escape_string($dbhandle,$item->published)."',
|
||||
// '".mysqli_real_escape_string($dbhandle,$item->title)."',
|
||||
// '".mysqli_real_escape_string($dbhandle,$item->summary)."',
|
||||
// '".mysqli_real_escape_string($dbhandle,$autori)."',
|
||||
// '".mysqli_real_escape_string($dbhandle,$item->arxiv_journal_ref)."',
|
||||
// '".mysqli_real_escape_string($dbhandle,$categorie)."',
|
||||
// ");
|
||||
}
|
||||
//inserimento nuovi articoli
|
||||
$query = "INSERT INTO wp_articoli (doi, published, title, summary, authors, ajournal, categories)
|
||||
|
||||
Reference in New Issue
Block a user