<?php
error_reporting(0);

/*
'**************************************************************************************************
' 程序名称: CCTVAI开源音乐管理系统
' 官方网站: http://www.cctvai.com
' 联系 Q Q: 1542367792
' QQ交流群：136687984
' 版本：(终结版)
' 备注：未经书面授权，不得向任何第三方提供本软件系统！
' 功能，模板，插件，扩展，定制请联系QQ：1542367792
'**************************************************************************************************
*/
include '../../../include/cctvai.conn.php';
?>
<!DOCTYPE html>
<html>
 <head>
  <meta charset="gbk" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
  <meta name="description" content="" />
  <meta name="author" content="" />
  <meta name="renderer" content="webkit|ie-comp|ie-stand" />
  <title>安装</title>
 </head>
 <body>
<?php    
$lockfile = 'install.lock';
if(file_exists($lockfile)) {
echo "<script>alert('警告：您已安装过幻灯片\\n如需重装请删除插件目录下的install.lock文件！\\n重装将清空原有数据，请注意备份！');history.back();</script>"; 
exit();
}
  
$mysql_host=cd_sqlservername;
$mysql_user=cd_sqluserid;
$mysql_dbname=cd_sqldbname;
$mysql_pass=cd_sqlpwd;
if (!@$link = mysql_connect($mysql_host, $mysql_user, $mysql_pass)) { //检查数据库连接情况    
echo "<script>alert('警告：数据库连接失败！请确认是否已安装x5Music程序！');history.back();</script>";   
exit();
}else{    
global $db;
$db->query("drop table " . tname('myppt') . "");
mysql_query("Create DATABASE `$mysql_dbname`");    
mysql_select_db($mysql_dbname);    
mysql_query("SET NAMES 'gb2312'");   
$sql_query[] = "CREATE TABLE `".cd_tablename."myppt` (
  `cd_id` int(11) NOT NULL AUTO_INCREMENT,
  `cd_order` int(10) NOT NULL DEFAULT '0',
  `cd_title` varchar(60) NOT NULL,
  `cd_pic`  varchar(255) NOT NULL,
  `cd_url`  varchar(255) NOT NULL,
  `cd_word` text,
  PRIMARY KEY (`cd_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=gbk;";    
    

foreach($sql_query as $val){    
mysql_query($val);    
}    
//$sql_query2[] = "Insert INTO contents VALUES ('1', '1', '添加内容测试。', 'PHP程序员', null, null);";   

foreach($sql_query2 as $val2){    
mysql_query($val2);    
}  
echo "<script>alert('恭喜：成功安装幻灯片！');history.back();</script>";     
fwrite(fopen("install.lock","wb"),"");   
exit();
}