-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix admin/user page which has incorrect checking, add vox importer
- Loading branch information
Showing
2 changed files
with
38 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
use \PDO; | ||
|
||
$_DATABASE = array( | ||
'host' => 'localhost', | ||
'db' => 'panel', | ||
'user' => 'root', | ||
'pass' => getopt("p:")["p"] | ||
); | ||
|
||
$database = new PDO("mysql:host=" . $_DATABASE['host'] . ";dbname=" . $_DATABASE['db'], $_DATABASE['user'], $_DATABASE['pass'], array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'")); | ||
|
||
$factoids = file_get_contents("http://vps.dope.ghoti.me/mcfaq/faqdatabase"); | ||
|
||
$list = explode("\n", $factoids); | ||
|
||
foreach ($list as $line) { | ||
if (!trim($line)) { | ||
continue; | ||
} | ||
list($name, $context) = explode('|', $line); | ||
$set = $database->prepare("SELECT game FROM factoids WHERE name = ?"); | ||
$set->execute(array($name)); | ||
$record = $set->fetch(); | ||
if (isset($record['game']) && $record['game'] == 0) { | ||
$database->prepare("UPDATE factoids SET content = ? WHERE game = 0 AND name = ?") | ||
->execute(array($context, $name)); | ||
} else { | ||
$database->prepare("INSERT INTO factoids (name, game, content) VALUES (?, 1, ?) ON DUPLICATE KEY UPDATE content = ?") | ||
->execute(array($name, $context, $context)); | ||
} | ||
} |