Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <head>
- <meta charset="UTF-8">
- </head>
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "MySQLr00t$";
- $dbname = "skillz_copy";
- $dbname2 = "wp_skillz_v3";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- $conn2 = new mysqli($servername, $username, $password, $dbname2);
- $conn->set_charset("utf8");
- $conn2->set_charset("utf8");
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- if ($conn2->connect_error) {
- die("Connection 2 failed: " . $conn2->connect_error);
- }
- $sql = "SELECT
- news_id AS ID,
- lang_code AS LANGUAGE,
- user_id AS AUTHOR,
- title AS TITLE,
- text AS CONTENT,
- FROM_UNIXTIME(date) AS POST_DATE,
- news.discipline AS DISCILPINE
- FROM news_translates
- LEFT JOIN news ON news_translates.news_id = news.id WHERE lang_code='ru'";
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- while ($row = $result->fetch_array()) {
- $id = $row['ID'];
- $sqlCnt = "SELECT COUNT('id') as CNT FROM comment_sources WHERE source_id=" . $id;
- $re = $conn->query($sqlCnt)->fetch_array();
- $count = $re['CNT'];
- $post_author = $row['AUTHOR'];
- $post_date = $row['POST_DATE'];
- $post_date_gmt = $row['POST_DATE'];
- $post_content = htmlspecialchars($row['CONTENT']);
- $post_title = $row['TITLE'];
- $post_status = 'publish';
- $comment_status = 'open';
- $ping_status = 'open';
- $post_name = '';
- $post_modified = $row['POST_DATE'];
- $post_modified_gmt = $row['POST_DATE'];
- $guid = 'http://dev.battlegrounds.lv/?p=' . $id;
- $post_type = 'post';
- $comment_count = $count;
- $sqlt = "INSERT INTO sk_posts (ID, post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status, comment_status, ping_status, post_name, post_modified, post_modified_gmt, guid, post_type, comment_count)
- VALUES ('$id', '$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_title', '', '$post_status', '$comment_status', '$ping_status', '$post_name', '$post_modified', '$post_modified_gmt', '$guid', '$post_type', '$comment_count')";
- if ($conn2->query($sqlt) === TRUE) {
- echo "New record created successfully";
- } else {
- echo "Error: " . $sqlt . "<br>" . $conn->error;
- }
- $taxSql = "INSERT INTO sk_term_relationships (object_id, term_taxonomy_id) VALUES ('$id', '9')";
- if ($conn2->query($taxSql) === TRUE) {
- echo "New record created successfully";
- } else {
- echo "Error: " . $taxSql . "<br>" . $conn->error;
- }
- }
- }
- $sql_translated = "SELECT
- news_id AS ID,
- lang_code AS LANGUAGE,
- user_id AS AUTHOR,
- title AS TITLE,
- text AS CONTENT,
- FROM_UNIXTIME(date) AS POST_DATE,
- news.discipline AS DISCILPINE
- FROM news_translates
- LEFT JOIN news ON news_translates.news_id = news.id WHERE lang_code='lv'";
- $resultT = $conn->query($sql_translated);
- if ($resultT->num_rows > 0) {
- while ($rows = $resultT->fetch_array()) {
- $id = 10000 + intval($rows['ID']);
- $sqlCnt = "SELECT COUNT('id') as CNT FROM comment_sources WHERE source_id=" . $rows['ID'];
- $re = $conn->query($sqlCnt)->fetch_array();
- $count = $re['CNT'];
- $post_author = $rows['AUTHOR'];
- $post_date = $rows['POST_DATE'];
- $post_date_gmt = $rows['POST_DATE'];
- $post_content = htmlspecialchars($rows['CONTENT']);
- $post_title = $rows['TITLE'];
- $post_status = 'publish';
- $comment_status = 'open';
- $ping_status = 'open';
- $post_name = '';
- $post_modified = $rows['POST_DATE'];
- $post_modified_gmt = $rows['POST_DATE'];
- $guid = 'http://dev.battlegrounds.lv/?p=' . $id;
- $post_type = 'post';
- $comment_count = $count;
- $sql = "INSERT INTO sk_posts (ID, post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status, comment_status, ping_status, post_name, post_modified, post_modified_gmt, guid, post_type, comment_count)
- VALUES ('$id', '$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_title', '', '$post_status', '$comment_status', '$ping_status', '$post_name', '$post_modified', '$post_modified_gmt', '$guid', '$post_type', '$comment_count')";
- if ($conn2->query($sql) === TRUE) {
- echo "New record created successfully";
- } else {
- echo "Error: " . $sql . "<br>" . $conn->error;
- }
- $taxSql2 = "INSERT INTO sk_term_relationships (object_id, term_taxonomy_id) VALUES ('$id', '5')";
- if ($conn2->query($taxSql2) === TRUE) {
- echo "New record created successfully";
- } else {
- echo "Error: " . $taxSql2 . "<br>" . $conn->error;
- }
- }
- }
- $conn->close();
- echo 'done';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement