<?php
$sql_new="select news_id,type,bg_sub,gb_sub,en_content,bg_content,gb_content,FROM_UNIXTIME(time) as ctime from news where news_id>783";
$result_news=mysql_query($sql_new);
while($row_news=mysql_fetch_array($result_news)){
switch ($row_news['type'])
{
case 0:
$catid=63;
$parent_id=190;
break;
case 1:
$catid=64;
$parent_id=191;
break;
case 2:
$catid=65;
$parent_id=192;
break;
case 3:
$catid=66;
$parent_id=193;
break;
case 4:
$catid=67;
$parent_id=194;
break;
case 5:
$catid=68;
$parent_id=195;
break;
case 6:
$catid=69;
$parent_id=196;
break;
default:
}
$attribs='{"show_title":"","link_titles":"","show_tags":"","show_intro":"","info_block_position":"","show_category":"","link_category":"","show_parent_category":"","link_parent_category":"","show_author":"","link_author":"","show_create_date":"","show_modify_date":"","show_publish_date":"","show_item_navigation":"","show_icons":"","show_print_icon":"","show_email_icon":"","show_vote":"","show_hits":"","show_noauth":"","urls_position":"","alternative_readmore":"","article_layout":"","show_publishing_options":"","show_article_options":"","show_urls_images_backend":"","show_urls_images_frontend":""}';
$metadata='{"robots":"","author":"","rights":"","xreference":""}';
$bg_content=addcslashes($row_news['bg_content'],"'");
$gb_content=addcslashes($row_news['gb_content'],"'");
$rules='{"core.delete":{"6":1},"core.edit":{"6":1,"4":1},"core.edit.state":{"6":1,"5":1}}';
$sql_en="insert into yor0a_content(asset_id,title,alias,introtext,state,catid,created,created_by,publish_up,attribs,access,metadata,language)values('','".$row_news['bg_sub']."','".$row_news['news_id']."_en','".$bg_content."',1,".$catid.",'".$row_news['ctime']."',8,'".$row_news['ctime']."','".$attribs."',1,'".$metadata."','en-GB')";
mysql_query("set names utf8");
mysql_query($sql_en);
$name_en="com_content.article.".mysql_insert_id();
$content_insert_id_en=mysql_insert_id();
$mysql_en="select * from yor0a_assets where name='".$name_en."'";
$result_num_en=mysql_query($mysql_en);
$num_en=mysql_num_rows($result_num_en);
if($num_en>0){
$ass_en=mysql_fetch_assoc($result_num_en);
$sql_update_ass_en="update yor0a_assets set parent_id=".$parent_id.",level=4,title='".$row_news['bg_sub']."',rules='".$rules."' where id=".$ass_en['id'];
mysql_query($sql_update_ass_en);
$ass_insert_id_en=$ass_en['id'];
}else{
$sql_en_ass="insert into yor0a_assets(parent_id,level,name,title,rules) values(".$parent_id.",4,'".$name_en."','".$row_news['bg_sub']."','".$rules."')";
mysql_query($sql_en_ass);
$ass_insert_id_en=mysql_insert_id();
}
$update_content_en="update yor0a_content set asset_id='".$ass_insert_id_en."' where id=".$content_insert_id_en;
mysql_query($update_content_en);
/**************************************************************************/
$sql_tw="insert into yor0a_content(asset_id,title,alias,introtext,state,catid,created,created_by,publish_up,attribs,access,metadata,language)values('','".$row_news['bg_sub']."','".$row_news['news_id']."_tw','".$bg_content."',1,".$catid.",'".$row_news['ctime']."',8,'".$row_news['ctime']."','".$attribs."',1,'".$metadata."','zh-TW')";
mysql_query("set names utf8");
mysql_query($sql_tw);
$name_tw="com_content.article.".mysql_insert_id();
$content_insert_id_tw=mysql_insert_id();
$mysql_tw="select * from yor0a_assets where name='".$name_tw."'";
$result_num_tw=mysql_query($mysql_tw);
$num_tw=mysql_num_rows($result_num_tw);
if($num_tw>0){
$ass_tw=mysql_fetch_assoc($result_num_tw);
$sql_update_ass_tw="update yor0a_assets set parent_id=".$parent_id.",level=4,title='".$row_news['bg_sub']."',rules='".$rules."' where id=".$ass_tw['id'];
mysql_query($sql_update_ass_tw);
$ass_insert_id_tw=$ass_tw['id'];
}else{
$sql_tw_ass="insert into yor0a_assets(parent_id,level,name,title,rules) values(".$parent_id.",4,'".$name_tw."','".$row_news['bg_sub']."','".$rules."')";
mysql_query($sql_tw_ass);
$ass_insert_id_tw=mysql_insert_id();
}
$update_content_tw="update yor0a_content set asset_id='".$ass_insert_id_tw."' where id=".$content_insert_id_tw;
mysql_query($update_content_tw);
/**************************************************************************/
$sql_zh="insert into yor0a_content(asset_id,title,alias,introtext,state,catid,created,created_by,publish_up,attribs,access,metadata,language)values('','".$row_news['gb_sub']."','".$row_news['news_id']."_zh','".$gb_content."',1,".$catid.",'".$row_news['ctime']."',8,'".$row_news['ctime']."','".$attribs."',1,'".$metadata."','zh-CN')";
mysql_query("set names utf8");
mysql_query($sql_zh);
$name_zh="com_content.article.".mysql_insert_id();
$content_insert_id_zh=mysql_insert_id();
$mysql_zh="select * from yor0a_assets where name='".$name_zh."'";
$result_num_zh=mysql_query($mysql_zh);
$num_zh=mysql_num_rows($result_num_zh);
if($num_zh>0){
$ass_zh=mysql_fetch_assoc($result_num_zh);
$sql_update_ass_zh="update yor0a_assets set parent_id=".$parent_id.",level=4,title='".$row_news['gb_sub']."',rules='".$rules."' where id=".$ass_zh['id'];
mysql_query($sql_update_ass_zh);
$ass_insert_id_zh=$ass_zh['id'];
}else{
$sql_zh_ass="insert into yor0a_assets(parent_id,level,name,title,rules) values(".$parent_id.",4,'".$name_zh."','".$row_news['gb_sub']."','".$rules."')";
mysql_query($sql_zh_ass);
$ass_insert_id_zh=mysql_insert_id();
}
$update_content_zh="update yor0a_content set asset_id='".$ass_insert_id_zh."' where id=".$content_insert_id_zh;
mysql_query($update_content_zh);
}
?>
JOOMLA 3 import content form other website
最新推荐文章于 2024-06-04 22:11:38 发布