<?php

//KwInstaller
//Part of KRU
//Copyright Kwpolska 2010. Licensed on GPLv3.
include_once './config.php';
if ($configured == false) {
    echo "It seems like you haven't configured it.  Read README.md.";
    die;
}
try {
    $pdo = createPDO();
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $stmt = $pdo->exec('CREATE TABLE  `' . $dbtbl . '` (
                        `pasteid` VARCHAR(100) NOT NULL,
                        `timestamp` INT(50) NOT NULL,
                        `language` VARCHAR(50) NOT NULL,
                        `dsc` VARCHAR(250) NULL,
                        `rmable` TINYINT(1) NOT NULL,
                        `rmid` VARCHAR(100) NOT NULL,
                        `code` TEXT NOT NULL,
                        PRIMARY KEY (`pasteid`)
                        )');
    echo "The KwPastebin was successfully installed.";
    @unlink('install.php') or die(' failed to remove installer -- do it
   yourself');
} catch (PDOException $e) {
    echo 'Error message:' . $e->getMessage();
}
Example #2
0
spl_autoload_register(function ($class) {
    $include_path = str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
    return include __DIR__ . '/' . $include_path;
});
require 'vendor/autoload.php';
require __DIR__ . '/GroupBot/Libraries/common.php';
require __DIR__ . '/GroupBot/Settings.php';
function createPDO()
{
    $pdo = new \PDO('mysql:host=' . BOT_DB_HOST . ';dbname=' . BOT_DB_NAME . ';charset=utf8', BOT_DB_USER, BOT_DB_PASSWORD);
    $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
    $pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
    return $pdo;
}
if (isset($argv[1])) {
    $db = createPDO();
    switch ($argv[1]) {
        case 'resetDailyCounters':
            $db = new \GroupBot\Database\Cron($db);
            $db->resetDailyCounters();
            break;
        case 'runRandomEvent':
            $Coin = new \GroupBot\Brains\Coin\Money\Events($db);
            //$Coin->eventRoulette();
            break;
        case 'sendReminders':
            $Reminder = new GroupBot\Brains\Reminder\Control($db);
            $Reminder->sendReminders();
            break;
    }
}
Example #3
0
function update_content($id, $filename)
{
    /* Keep track of our success. */
    $success = FALSE;
    /* Create a database interface object. */
    $blog = new Blog(createPDO());
    /* If the file exists: */
    if (file_exists($filename)) {
        $new_content = file_get_contents($filename);
        /* If the post content could be retrieved: */
        if ($new_content != FALSE) {
            /* Attempt to update the post's content. */
            $update_result = $blog->update_post_content($id, $new_content);
            /* If we have not failed, we have succeeded. */
            if ($update_result != FALSE) {
                $success = TRUE;
            }
        }
    }
    return $success;
}