if($_POST['install_type'] != 'bare') { message('Устанавливаем базовый контент...'); install_sql('install/sql/default_loops.sql'); install_sql('install/sql/default_patterns.sql'); xcopy('install/media/dead', 'loops/dead'); xcopy('install/media/live', 'loops/live'); } if($_POST['install_type'] == 'extra') { message('Устанавливаем екстра контент...'); install_sql('install/sql/extra_loops.sql'); install_sql('install/sql/extra_patterns.sql'); xcopy('install/media/custom', 'loops/custom'); } $tc_db->Execute('ALTER TABLE `'.LOOPS_DBNAME.'` AUTO_INCREMENT=100'); function install_sql($f) { global $tc_db, $masterpass; $sql_file = fopen($f, 'r'); $data = fread($sql_file, filesize($f)); $data = str_replace('__LOOPDB__', LOOPS_DBNAME, $data); $data = str_replace('__PATTDB__', PATTERNS_DBNAME, $data); $data = str_replace('__MASTERPASS__', $masterpass, $data);
$tables = ""; foreach ($create_tables as $table) { $tables .= preg_replace("/^([a-zA-Z]*_)?(\\w+)\$/i", "{$plugin}_\$2", $table) . ";"; } if (substr($tables, -1) == ';') { $tables = substr($tables, 0, -1); } file_put_contents(dirname(__FILE__) . "/../plugins/{$plugin}/plugin_create_tables.php", $tables); //file_put_contents(dirname(__file__)."/../plugins/$plugin/plugin_create_tables.php","{$plugin}_".implode(";{$plugin}_",$create_tables)); echo "<div style='text-align:center'>数据库文件已经配制成功!</div><script>parent.right.diag_install.URL='install_plugin_3.php?type={$type}&path={$plugin}';</script>"; } else { echo "<div style='text-align:center'>数据库文件配制失败!</div>"; } } else { if ($check_sql) { if (install_sql($sqls)) { file_put_contents(dirname(__FILE__) . "/../plugins/{$plugin}/plugin_create_tables.php", implode(";", $create_tables)); echo "<div style='text-align:center'>数据库文件已经配制成功!<script>parent.right.diag_install.URL='install_plugin_3.php?type={$type}&path={$plugin}';</script></div>"; } else { echo "<div style='text-align:center'>数据库文件配制失败!</div>"; } } else { echo "<div style='text-align:center;color:red'>"; foreach ($result as $row) { if (isset($drop_tables[$row[0]]) || isset($create_tables[$row[0]])) { echo "表{$row['0']}已经存在<br/>"; } } echo "致使插件无法安装!</div>"; $config = dirname(__FILE__) . "/../plugins/{$plugin}/config.php"; if (file_exists($config)) {