Created
May 30, 2016 19:56
-
-
Save uzielweb/c278d4f6e6abfadc02a706c680daf0a8 to your computer and use it in GitHub Desktop.
This is a very usefull script to list all images in a Wordpress website and get it to Joomla Database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8"> | |
<meta name="generator" content="PSPad editor, www.pspad.com"> | |
<title></title> | |
<!-- Latest compiled and minified CSS --> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous"> | |
<!-- Optional theme --> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous"> | |
<!-- Latest compiled and minified JavaScript --> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script> | |
<style> | |
body *{ | |
font-size:14px; | |
color: #333; | |
} | |
table td { | |
padding: 10px; | |
} | |
thead td, thead td * { | |
background: #818181 none repeat scroll 0 0; | |
color: #fff !important; | |
font-weight: bold; | |
padding: 10px; | |
text-align: left !important; | |
text-transform: uppercase; | |
} | |
body > .container { | |
padding-top: 40px; | |
background-color: white; | |
} | |
/* | |
* Responsive stypes | |
*/ | |
@media (max-width: 980px) { | |
body > .container { | |
padding-top: 0px; | |
} | |
.navbar-fixed-top { | |
margin-bottom: 0; | |
} | |
} /* END: @media (max-width: 980px) */ | |
</style> | |
</head> | |
<body> | |
<div class="container"> | |
<div class="col-md-12 jumbotron"> | |
<p> | |
<?php | |
$servername = "localhost"; | |
$username = "xxx"; | |
$password = "xxx"; | |
$dbname = "xxxx"; | |
// Create connection | |
$conn = new mysqli($servername, $username, $password, $dbname); | |
mysqli_set_charset($conn, "utf8"); | |
// Check connection | |
if ($conn->connect_error) { | |
die("Connection failed: " . $conn->connect_error); | |
} | |
// output data of each row | |
foreach ($conn->query('SELECT ID, post_date, post_title, post_type, post_name, guid FROM nyk3_posts WHERE post_type = "post" ORDER BY ID ASC') as $row){ | |
echo "<b>ID: </b>".$row["ID"]." - <b>TÍTULO: </b><a data-toggle='lightbox' rel='modal' href='".$row["guid"]."' target='_blank'>". $row["post_title"]."</a> - <b>DATA: </b>". $row["post_date"]; | |
echo "<br>"; | |
foreach ($conn->query('SELECT ID, post_parent,guid FROM nyk3_posts WHERE post_type = "attachment"') as $row2){ | |
if ($row2["post_parent"] == $row["ID"]) { | |
foreach ($conn->query('SELECT post_id,meta_value, meta_key FROM nyk3_postmeta WHERE meta_key = "_thumbnail_id"') as $row3) | |
if ($row3["meta_value"] == $row2["ID"]) { | |
foreach ($conn->query('SELECT post_id,meta_value, meta_key FROM nyk3_postmeta WHERE meta_key = "_wp_attached_file"') as $row4){ | |
if ($row4["post_id"] == $row3["meta_value"]) { | |
echo "<a data-toggle='lightbox' rel='modal' href='wp-content/uploads/".$row4["meta_value"]."' target='_blank'>".$row4["meta_value"]."</a><br><br>"; | |
} | |
} | |
} | |
} | |
} | |
} | |
$conn->close(); | |
?> | |
</p> | |
</div></div> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment