Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
Initial Commit
  • Loading branch information
amarillonmc committed May 28, 2019
1 parent 8633438 commit 80d9d39
Show file tree
Hide file tree
Showing 343 changed files with 82,784 additions and 0 deletions.
25 changes: 25 additions & 0 deletions 500.shtml
@@ -0,0 +1,25 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="zh-cn" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>系统崩溃了……</title>
<style type="text/css">
.style1 {
text-align: center;
}
.style2 {
text-align: center;
font-size: x-large;
}
</style>
</head>

<body>

<p class="style2"><strong>系统崩溃了……</strong></p>
<p class="style1"><img src="http://x.azurerondo.tk/assets/500.jpg" align="middle" /></p>
<p class="style1">『奇怪的事情发生了……』</p>
<p class="style1">『请等待我们查出问题所在后进行维修。』</p>
<p class="style1">特此通告。&nbsp; By 冴月麟</p>
339 changes: 339 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions OTHER/README_s2kx.txt
@@ -0,0 +1,14 @@
===== Serissa to Kusaba X 0.8 Conversion Script =====

=== How to use ===

1. Copy s2xk.php and s2kx.sql to the folder containing config.php on your server.
2. Run s2kx.php.
3. Download the full version Kusaba X from http://kusabax.org
4. Make a backup of your current config.php
5. Extract the files that you downloaded where you want them installed. Overwrite everything.
6. If everything went right, congratulations! You are now running Kusaba X 0.8!

== When upgrading to Kusaba X 0.9 ==

7. Once converted, you will need to run the upgrade scripts to upgrade from Kusaba X 0.8 to Kusabax 0.9. These scripts are located in the OTHER directory.
146 changes: 146 additions & 0 deletions OTHER/install-mysql.php
@@ -0,0 +1,146 @@
<?php
/**
* @ignore
*/
################################################################################
# kusaba MySQL Importing Script v1.0 is © 2007 David Steven-Jennings (relixx@gmail.com)
#
# This work is licensed under the Creative Commons Attribution-ShareAlike 2.5 License.
# To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/2.5/
# or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco,
# California, 94105, USA.
#
# You can modify this script as you wish just as long as this box stays intact. If
# you do modify this script please state that you have done so and give me credit
# as the author of the original script (with my email address intact).
################################################################################
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>MySQL Batch File Importing Script</title>
<style type="text/css">
body { font-family: sans-serif; font-size: 75%; background: #ffe }
a { text-decoration: none; color: #550 }
h1,h2 { margin: 0px; background: #fca }
h1 { font-size: 150% }
h2 { font-size: 100%; margin-top: 1em }
.hl { font-style: italic }
.plus { float: right; font-size: 8px; font-weight: normal; padding: 1px 4px 2px 4px; margin: 0px 0px; background: #eb9; color: #000; border: 1px solid #da8; cursor: hand; cursor: pointer }
.plus:hover { background: #da8; border: 1px solid #c97 }
ul { list-style: none; padding-left: 0px; margin: 0px }
li { margin: 0px }
li:hover { background: #fec; }
li a { display: block; width: 100%; }
</style>
<link rel="shortcut icon" href="/favicon.ico" />
</head>

<body>
<div style="text-align:center;"><h1>MySQL Batch File Importing Script</h1></div>
<?php

if (!isset($_POST["confirm"])) {
?>
<br /><br />


<font color="#FF0000"><strong>WARNING!</strong></font><br /><br />
The purpose of this script is to quickly and easily run the commands contained within the kusaba SQL file, and is
to be used if you are installing the script for the first time or want to recreate the tables, for whatever reason.<br />
Running this script will delete any related tables and their data (including the admin files). I offer this script as-is and cannot be held
responsible for any damages caused or accidental loss of data incurred as a result of running this script.<br />
Before running this script, make sure that:<br />
<ul>
<li>-&gt; You have set up the database connection and that it is working</li>
<li>-&gt; You have created the database</li>
<li>-&gt; You have created the database user and set up the config file appropriately</li>
</ul>
<form action="install-mysql.php" method="post">
<br />
<input type="checkbox" name="confirm"> By clicking this check box I agree that the author of this script cannot be held responsible for my own stupidity if something goes wrong.<br /><br /><br />
<input type="submit" value="Import the MySQL batch file">
</form>

<?php
} else {
require('config.php');
$reqiredtables = array("ads","announcements","banlist","bannedhashes","blotter","boards","board_filetypes","embeds","events","filetypes","front","loginattempts","modlog","module_settings","posts","reports","sections","staff","watchedthreads","wordfilter");
foreach ($reqiredtables as $tablename) {
if (mysql_table_exists(KU_DBDATABASE,KU_DBPREFIX.$tablename)) {
die("Table <strong>".KU_DBPREFIX.$tablename."</strong> already exists in the database! Drop it, and re run this script.");
}
}
// Lets open the file for reading! :)
echo '<h2>SQL Batch File Processing</h2>';
echo 'Locating \'kusaba_freshinstall.mysql.sql\'... ';
if (file_exists('kusaba_freshinstall.mysql.sql') && (filesize('kusaba_freshinstall.mysql.sql') > 0)) {
echo 'found.<br />';
$sqlfile = fopen('kusaba_freshinstall.mysql.sql', 'r');
echo 'File opened.<br />';
$readdata = fread($sqlfile, filesize('kusaba_freshinstall.mysql.sql'));
$readdata = str_replace('PREFIX_',KU_DBPREFIX,$readdata);
fclose($sqlfile);
echo 'Contents read.<br />';
}else{
echo '<font color=red>error.</font> ';
die('An error occured. kusaba_freshinstall.mysql.sql does not exist in this directory or it is 0 bytes big :( Barring that, do you have read permissions for the directory?');
}

$tc_db->Execute("ALTER DATABASE `" . KU_DBDATABASE . "` CHARACTER SET utf8 COLLATE utf8_general_ci");

// Explodes the array
$sqlarray = explode("\n", $readdata);

// Loops through the array and deletes the non-SQL bits in the file, which is basically the '--' lines and the lines with no content
foreach ($sqlarray as $key => $sqldata) {
if (strstr($sqldata, '--') || strlen($sqldata) == 0){
unset($sqlarray[$key]);
}
}
// Here we are imploding everything together again...
$readdata = implode('',$sqlarray);

// ...then exploding it again. At this point we will have an array where each key's value is a one of the CREATE statements
$sqlarray = explode(';',$readdata);
echo 'File contents have been formatted for use with mysql_query.<br />';
// Lets drop any existing tables in the database
$listoftables = $tc_db->GetAll("show tables from ".KU_DBDATABASE."");

echo '<h2>Table Creation</h2>';
// Lets now loop through the array and create each table
foreach ($sqlarray as $sqldata) {

if (strlen($sqldata) !== 0) { // As the array was exploded on ';', the last ';' caused a blank element to be created as there was no data after it :p
// The following three lines retrieve the table name of the table from the sql command. It's dynamic so it doesn't matter how many tables need to be created
// As long as each CREATE TABLE statement stays in the format CREATE TABLE `table` then this part will work.
$pos1 = strpos($sqldata, '`');
$pos2 = strpos($sqldata, '`', $pos1 + 1);
$tablename = substr($sqldata, $pos1+1, ($pos2-$pos1)-1);
echo "Attempting to create table '$tablename'... ";
if($tc_db->Execute($sqldata)) {
echo "success.<br />";
} else {
echo "<font color='red'>failed</font>. Enable debugging by setting KU_DEBUG to true to see this error.<br />";
die ("Table creation failed. Please rerun this script again or attempt to fix the problem if you know how to solve it.");
}
}
}
// All done :)
echo '<br />SQL commands have finished. If all is well, proceed to the <a href="install.php"><strong><u>installation file</u></strong></a> but don\'t forget to delete this file!';
}

function mysql_table_exists($database, $tableName)
{
global $tc_db;
$tables = array();
$tablesResults = $tc_db->GetAll("SHOW TABLES FROM `$database`;");
foreach ($tablesResults AS $row) $tables[] = $row[0];
return(in_array($tableName, $tables));
}

?>
</body>
</html>
147 changes: 147 additions & 0 deletions OTHER/install-pgsql.php
@@ -0,0 +1,147 @@
<?php
/**
* @ignore
*/
################################################################################
# kusaba PostgreSQL Importing Script v1.0 is © 2007 David Steven-Jennings (relixx@gmail.com)
#
# This work is licensed under the Creative Commons Attribution-ShareAlike 2.5 License.
# To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/2.5/
# or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco,
# California, 94105, USA.
#
# You can modify this script as you wish just as long as this box stays intact. If
# you do modify this script please state that you have done so and give me credit
# as the author of the original script (with my email address intact).
################################################################################
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>PostgreSQL Batch File Importing Script</title>
<style type="text/css">
body { font-family: sans-serif; font-size: 75%; background: #ffe }
a { text-decoration: none; color: #550 }
h1,h2 { margin: 0px; background: #fca }
h1 { font-size: 150% }
h2 { font-size: 100%; margin-top: 1em }
.hl { font-style: italic }
.plus { float: right; font-size: 8px; font-weight: normal; padding: 1px 4px 2px 4px; margin: 0px 0px; background: #eb9; color: #000; border: 1px solid #da8; cursor: hand; cursor: pointer }
.plus:hover { background: #da8; border: 1px solid #c97 }
ul { list-style: none; padding-left: 0px; margin: 0px }
li { margin: 0px }
li:hover { background: #fec; }
li a { display: block; width: 100%; }
</style>
<link rel="shortcut icon" href="/favicon.ico" />
</head>

<body>
<div style="text-align:center;"><h1>PostgreSQL Batch File Importing Script</h1></div>
<?php

if (!isset($_POST["confirm"])) {
?>
<br /><br />


<font color="#FF0000"><strong>WARNING!</strong></font><br /><br />
The purpose of this script is to quickly and easily run the commands contained within the kusaba SQL file, and is
to be used if you are installing the script for the first time or want to recreate the tables, for whatever reason.<br />
Running this script will delete any related tables and their data (including the admin files). I offer this script as-is and cannot be held
responsible for any damages caused or accidental loss of data incurred as a result of running this script.<br />
Before running this script, make sure that:<br />
<ul>
<li>-&gt; You have set up the database connection and that it is working</li>
<li>-&gt; You have created the database</li>
<li>-&gt; You have created the database user and set up the config file appropriately</li>
</ul>
<form action="install-pgsql.php" method="post">
<br />
<input type="checkbox" name="confirm"> By clicking this check box I agree that the author of this script cannot be held responsible for my own stupidity if something goes wrong.<br /><br /><br />
<input type="submit" value="Import the PostgreSQL batch file">
</form>

<?php
} else {
require('config.php');
$reqiredtables = array("ads","announcements","banlist","bannedhashes","blotter","boards","board_filetypes","embeds","events","filetypes","front","loginattempts","modlog","module_settings","posts","reports","sections","staff","watchedthreads","wordfilter");
foreach ($reqiredtables as $tablename) {
if (pgsql_table_exists(KU_DBDATABASE,KU_DBPREFIX.$tablename)) {
die("Table <strong>".KU_DBPREFIX.$tablename."</strong> already exists in the database! Drop it, and re run this script.");
}
}
// Lets open the file for reading! :)
echo '<h2>SQL Batch File Processing</h2>';
echo 'Locating \'kusaba_freshinstall.postgres.sql\'... ';
if (file_exists('kusaba_freshinstall.postgres.sql') && (filesize('kusaba_freshinstall.postgres.sql') > 0)) {
echo 'found.<br />';
$sqlfile = fopen('kusaba_freshinstall.postgres.sql', 'r');
echo 'File opened.<br />';
$readdata = fread($sqlfile, filesize('kusaba_freshinstall.postgres.sql'));
$readdata = str_replace('PREFIX_',KU_DBPREFIX,$readdata);
fclose($sqlfile);
echo 'Contents read.<br />';
}else{
echo '<font color=red>error.</font> ';
die('An error occured. kusaba_freshinstall.postgres.sql does not exist in this directory or it is 0 bytes big :( Barring that, do you have read permissions for the directory?');
}

// Explodes the array
$sqlarray = explode("\n", $readdata);

// Loops through the array and deletes the non-SQL bits in the file, which is basically the '--' lines and the lines with no content
foreach ($sqlarray as $key => $sqldata) {
if (strstr($sqldata, '--') || strlen($sqldata) == 0){
unset($sqlarray[$key]);
}
}
// Here we are imploding everything together again...
$readdata = implode('',$sqlarray);

// ...then exploding it again. At this point we will have an array where each key's value is a one of the CREATE statements
$sqlarray = explode(';',$readdata);
echo 'File contents have been formatted for use with pg_query.<br />';
// Lets drop any existing tables in the database
$listoftables = $tc_db->GetAll("SELECT table_name FROM information_schema.tables WHERE table_schema='public' AND table_type='BASE TABLE'");

echo '<h2>Table Creation</h2>';
// Lets now loop through the array and create each table
foreach ($sqlarray as $sqldata) {

if (strlen($sqldata) !== 0) { // As the array was exploded on ';', the last ';' caused a blank element to be created as there was no data after it :p
// The following three lines retrieve the table name of the table from the sql command. It's dynamic so it doesn't matter how many tables need to be created
// As long as each CREATE TABLE statement stays in the format CREATE TABLE `table` then this part will work.
$sqldata = str_replace(":semicolon:", ";", $sqldata);
if (strpos($sqldata, "CREATE TABLE") !== false) {
preg_match("/CREATE TABLE (.*?) \(/", $sqldata, $tablename);
echo "Attempting to create table '{$tablename[1]}'... ";
}
else {
echo "Attempting to run query '".$sqldata."'... ";
}
if($tc_db->Execute($sqldata)) {
echo "success.<br />";
} else {
echo "<font color='red'>failed</font>. Enable debugging by setting KU_DEBUG to true to see this error.<br />";
die ("Table creation failed. Please rerun this script again or attempt to fix the problem if you know how to solve it.");
}
}
}
// All done :)
echo '<br />SQL commands have finished. If all is well, proceed to the <a href="install.php"><strong><u>installation file</u></strong></a> but don\'t forget to delete this file!';
}

function pgsql_table_exists($database, $tableName) {
global $tc_db;
$tables = array();
$tablesResults = $tc_db->GetAll("SELECT table_name FROM information_schema.tables WHERE table_schema='public' AND table_type='BASE TABLE'");
foreach ($tablesResults AS $row) $tables[] = $row[0];
return(in_array($tableName, $tables));
}

?>
</body>
</html>

0 comments on commit 80d9d39

Please sign in to comment.