<?php
/**
 * MyBB中文资源包 1.4
 * 版权所有 ?2008 MyBB中文论坛, All Rights Reserved
 *
 * 网站: http://mybb.netmkt.cn
 *
 * $Id: cnpack_db_inserts.php 0001 2008-12-21 14:03Z MyBB中文论坛 $
 */
function cnpack($install_cnpack)
{
	global $output, $lang, $db;
	
	require MYBB_ROOT.'inc/config.php';
	$db = db_connection($config);

	$output->print_header('安装中文资源包', 'cnpack');
	
	if ($install_cnpack) {
		echo '<ol>';
		echo '<li>设置默认时间格式 - "2008年11月13日 17:26"<br /></li>';
		echo '<li>设置默认注册时间格式 - "2008年11月"<br /></li>';
		echo '<li>设置默认时区 - "+8"<br /></li>';
		echo '<li>添加用户个人资料字段 - "QQ"<br /></li>';
		echo '<li>添加中文搜索引擎蜘蛛机器人 - "百度, 搜搜, 搜狗, 有道"<br /></li>';
		//echo '<li>添加自定义MyCode - "[flash][/flash], [mp3][/mp3], [wma][/wma], [wmv][/wmv], [ra][/ra], [rm][/rm]等"<br /></li>';
		//echo '<li>添加帮助文档 - "自定义MyCode"<br /></li>';
		echo '</ol>';
		
		$inserts = cnpack_db();
		foreach($inserts as $val) {
			$val = preg_replace('#mybb_(\S+?)([\s\.,]|$)#', $config['database']['table_prefix'].'\\1\\2', $val);
			$db->query($val);
		}
		
		echo '<p class="success">中文资源包安装完成</p>';
	}
	
	$written = 0;
	if(is_writable('./'))
	{
		$lock = @fopen('./lock', 'w');
		$written = @fwrite($lock, '1');
		@fclose($lock);
		if($written)
		{
			echo $lang->done_step_locked;
		}
	}
	if(!$written)
	{
		echo $lang->done_step_dirdelete;
	}
	echo $lang->done_subscribe_mailing;

	rebuild_settings();
	$output->print_footer('');
}

function cnpack_db()
{

$inserts[] = "UPDATE mybb_settings SET value = 'Y年m月d日' WHERE sid = 8 LIMIT 1 ;";
$inserts[] = "UPDATE mybb_settings SET value = 'H:i' WHERE sid = 9 LIMIT 1 ;";
$inserts[] = "UPDATE mybb_settings SET value = 'Y年m月' WHERE sid = 10 LIMIT 1 ;";
$inserts[] = "UPDATE mybb_settings SET value = '+8' WHERE sid = 11 LIMIT 1 ;";

$inserts[] = "INSERT INTO mybb_profilefields (fid, name, description, disporder, type, length, maxlength, required, editable, hidden) VALUES (4, 'QQ', '输入您的QQ号', 1, 'text', 0, 13, 0, 1, 0);";
$inserts[] = "ALTER TABLE `mybb_userfields` ADD `fid4` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL";

$inserts[] = "INSERT INTO mybb_spiders (name,useragent) VALUES ('BaiduSpider','Baiduspider');";
$inserts[] = "INSERT INTO mybb_spiders (name,useragent) VALUES ('SosoSpider','Sosospider');";
$inserts[] = "INSERT INTO mybb_spiders (name,useragent) VALUES ('SogouSpider','Sogou spider');";
$inserts[] = "INSERT INTO mybb_spiders (name,useragent) VALUES ('YodaoBot','YodaoBot');";
/*
$inserts[] = "INSERT INTO mybb_mycode (title,description,regex,replacement) VALUES ('插入mp3','使用方式: [mp3]http://www.some-music-site.com/some/name.mp3[/mp3]','\[mp3\](.*?)\[/mp3\]','<object classid=\"clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6\" width=\"400\" height=\"64\"><param name=\"autostart\" value=\"0\" /><param name=\"url\" value=\"$1\" /><embed src=\"$1\" autostart=\"0\" type=\"application/x-mplayer2\" width=\"400\" height=\"64\"></embed></object>');";
$inserts[] = "INSERT INTO mybb_mycode (title,description,regex,replacement) VALUES ('插入wma','使用方式: [mp3]http://www.some-music-site.com/some/name.mp3[/mp3]','\[mp3\](.*?)\[/mp3\]','<object classid=\"clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6\" width=\"400\" height=\"64\"><param name=\"autostart\" value=\"0\" /><param name=\"url\" value=\"$1\" /><embed src=\"$1\" autostart=\"0\" type=\"application/x-mplayer2\" width=\"400\" height=\"64\"></embed></object>');";
$inserts[] = "INSERT INTO mybb_mycode (title,description,regex,replacement) VALUES ('插入mp3','使用方式: [mp3]http://www.some-music-site.com/some/name.mp3[/mp3]','\[mp3\](.*?)\[/mp3\]','<object classid=\"clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6\" width=\"400\" height=\"64\"><param name=\"autostart\" value=\"0\" /><param name=\"url\" value=\"$1\" /><embed src=\"$1\" autostart=\"0\" type=\"application/x-mplayer2\" width=\"400\" height=\"64\"></embed></object>');";
$inserts[] = "INSERT INTO mybb_mycode (title,description,regex,replacement) VALUES ('插入mp3','使用方式: [mp3]http://www.some-music-site.com/some/name.mp3[/mp3]','\[mp3\](.*?)\[/mp3\]','<object classid=\"clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6\" width=\"400\" height=\"64\"><param name=\"autostart\" value=\"0\" /><param name=\"url\" value=\"$1\" /><embed src=\"$1\" autostart=\"0\" type=\"application/x-mplayer2\" width=\"400\" height=\"64\"></embed></object>');";
$inserts[] = "INSERT INTO mybb_mycode (title,description,regex,replacement) VALUES ('插入mp3','使用方式: [mp3]http://www.some-music-site.com/some/name.mp3[/mp3]','\[mp3\](.*?)\[/mp3\]','<object classid=\"clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6\" width=\"400\" height=\"64\"><param name=\"autostart\" value=\"0\" /><param name=\"url\" value=\"$1\" /><embed src=\"$1\" autostart=\"0\" type=\"application/x-mplayer2\" width=\"400\" height=\"64\"></embed></object>');";
$inserts[] = "INSERT INTO mybb_mycode (title,description,regex,replacement) VALUES ('插入mp3','使用方式: [mp3]http://www.some-music-site.com/some/name.mp3[/mp3]','\[mp3\](.*?)\[/mp3\]','<object classid=\"clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6\" width=\"400\" height=\"64\"><param name=\"autostart\" value=\"0\" /><param name=\"url\" value=\"$1\" /><embed src=\"$1\" autostart=\"0\" type=\"application/x-mplayer2\" width=\"400\" height=\"64\"></embed></object>');";

$inserts[] = "INSERT INTO mybb_helpdocs (hid, sid, name, description, document, usetranslation, enabled, disporder) VALUES (7, 2, 'MyCode', '学习如何使用 MyCode 增强您的帖子。', '您可以使用MyCode，一个简化版的HTML，以便在您的帖子中使用特定的效果。\r\n<p><br />\r\n[b]这是粗体[/b]<br />\r\n&nbsp;&nbsp;&nbsp;<b>这是粗体</b>\r\n<p>\r\n[i]这是斜体[/i]<br />\r\n&nbsp;&nbsp;&nbsp;<i>这是斜体</i>\r\n<p>\r\n[u]这是下划线[/u]<br />\r\n&nbsp;&nbsp;&nbsp;<u>这是下划线</u>\r\n<p><br />\r\n[url]http://mybb.netmkt.cn/[/url]<br />\r\n&nbsp;&nbsp;&nbsp;<a href=\"http://mybb.netmkt.cn/\">http://mybb.netmkt.cn/</a>\r\n<p>\r\n[url=http://mybb.netmkt.cn/]Netmkt.cn[/url]<br />\r\n&nbsp;&nbsp;&nbsp;<a href=\"http://mybb.netmkt.cn/\">Netmkt.cn</a>\r\n<p>\r\n[email]example@example.com[/email]<br />\r\n&nbsp;&nbsp;&nbsp;<a href=\"mailto:example@example.com\">example@example.com</a>\r\n<p>\r\n[email=example@example.com]给我发E-mail！[/email]<br />\r\n&nbsp;&nbsp;&nbsp;<a href=\"mailto:example@example.com\">给我发E-mail！</a>\r\n<p>\r\n[email=example@example.com?subject=spam]包含标题的 E-mail[/email]<br />\r\n&nbsp;&nbsp;&nbsp;<a href=\"mailto:example@example.com?subject=spam\">包含标题的 E-mail</a>\r\n<p><br />\r\n[quote]这里是引用文字[/quote]<br />\r\n&nbsp;&nbsp;&nbsp;<quote>这里是引用文字</quote>\r\n<p>\r\n[code]这里是代码[/code]<br />\r\n&nbsp;&nbsp;&nbsp;<code>这里是代码</code>\r\n<p><br />\r\n[img]http://www.php.net/images/php.gif[/img]<br />\r\n&nbsp;&nbsp;&nbsp;<img src=\"http://www.php.net/images/php.gif\">\r\n<p>\r\n[img=50x50]http://www.php.net/images/php.gif[/img]<br />\r\n&nbsp;&nbsp;&nbsp;<img src=\"http://www.php.net/images/php.gif\" width=\"50\" height=\"50\">\r\n<p><br />\r\n[color=red]这是红色[/color]<br />\r\n&nbsp;&nbsp;&nbsp;<font color=\"red\">这是红色</font>\r\n<p>\r\n[size=3]这是3号字[/size]<br />\r\n&nbsp;&nbsp;&nbsp;<font size=\"3\">这是3号字</font>\r\n<p>\r\n[font=Tahoma]字体是Tahoma[/font]<br />\r\n&nbsp;&nbsp;&nbsp;<font face=\"Tahoma\">字体是Tahoma</font>\r\n<p><br />\r\n[align=center]这是居中[/align]<div align=\"center\">这是居中</div>\r\n<p>\r\n[align=right]这是右对齐[/align]<div align=\"right\">这是右对齐</div>\r\n<p><br />\r\n[list]<br />\r\n[*]列表项 #1<br />\r\n[*]列表项 #2<br />\r\n[*]列表项 #3<br />\r\n[/list]<br />\r\n<ul>\r\n<li>列表项 #1</li>\r\n<li>列表项 #2</li>\r\n<li>列表项 #3</li>\r\n</ul><p><font size=1>您也可以用 [list=1] 创建一个数字顺序列表，用 [list=a] 创建字母顺序列表。</size>', 1, 1, 3);";
*/
return $inserts;
}
?>