示例#1
0
 public function execute($input_parameters = null)
 {
     try {
         return parent::execute($input_parameters);
     } catch (Exception $e) {
         TPP::setError($e);
     }
 }
示例#2
0
 public function setAttributes($attributes)
 {
     foreach ($attributes as $key => $value) {
         if (isset($value) && $value !== '') {
             if (!property_exists($this, $key)) {
                 $called_class = get_called_class();
                 TPP::setError($called_class . "->" . $key . ": Property '" . $key . "' does not exist for class '" . $called_class . "'");
             }
             $key = gettype($key) === 'string' && !ctype_alnum(str_replace(['-', '_', ' '], '', $key)) ? Helper::utf8ify($key) : $key;
             $this->{$key} = gettype($value) === 'string' ? Helper::utf8ify($value) : $value;
         }
     }
 }
示例#3
0
 public static function getMilestones()
 {
     $getMilestones = TPP::db()->query("SELECT `id`, `name`, `time` FROM `milestone` WHERE `visible` = 1 ORDER BY `time`");
     $return = [];
     if ($getMilestones) {
         while ($mile = $getMilestones->fetch()) {
             $newMilestone = new self();
             $newMilestone->setAttributes($mile);
             $newMilestone->time = Helper::getDateTime($newMilestone->time);
             $return[] = $newMilestone;
         }
     }
     return $return;
 }
示例#4
0
 /**
  * getCredits: Return all credits
  * @return		array		Array of all Credit objects
  */
 public static function getCredits()
 {
     self::prepareGenerations();
     $getCredits = TPP::db()->query("\n\t\t\tSELECT `id`, `name`, `title`, `pokemon`, `quote`, `gen_flags`, `link`\n\t\t\tFROM `credits`\n\t\t\tWHERE `order_id` > 0\n\t\t\tAND `visible` = 1\n\t\t\tORDER BY `order_id`, `id`\n\t\t");
     $return = [];
     if ($getCredits) {
         while ($credit = $getCredits->fetch()) {
             $newCredit = new self();
             $newCredit->setAttributes($credit);
             $newCredit->quote = self::getQuote($newCredit->quote);
             $newCredit->generations = self::getGenerations((int) $newCredit->gen_flags);
             $return[] = $newCredit;
         }
     }
     return $return;
 }
示例#5
0
 /**
  * @param        $content
  * @param string $key
  * @param bool   $query
  */
 public function log($content, $key = 'query', $query = true)
 {
     if (TPP::is_debug()) {
         $t = microtime(true);
         $micro = sprintf("%06d", ($t - floor($t)) * 1000000);
         $back_trace = debug_backtrace();
         $trace = '?';
         if (isset($back_trace[1])) {
             $tr = $back_trace[1];
             $trace = substr(str_replace(TPP::$main_path, '', $tr['file']) . ':' . $tr['line'], 1);
             if (isset($back_trace[2])) {
                 $tr2 = $back_trace[2];
                 $trace .= '<br>&nbsp;' . $tr2['function'] . '()';
             }
         }
         $GLOBALS['log'][$key][] = [$trace, (new DateTime(date("Y-m-d H:i:s." . $micro, $t)))->format('Y-m-d H:i:s.u'), $query ? SqlFormatter::highlight($content) : $content];
     }
 }
示例#6
0
 public function getFields()
 {
     $fields = [];
     $getFields = TPP::db()->query("\n\t\tSELECT\n\t\t\tf.`name`,\n\t\t\tpfe.`pokemon_id`,\n\t\t\tpfe.`value`\n\t\tFROM\n\t\t\t`pokemon_field_eav` pfe,\n\t\t\t`field` f\n\t\tWHERE\n\t\t\tpfe.`pokemon_id` = {$this->id}\n\t\tAND\n\t\t\tpfe.`field_id` = f.`id`");
     while ($fi = $getFields->fetch()) {
         $fields[$fi['name']] = $fi['value'];
     }
     if (isset($fields['next_move'])) {
         $move = new Move();
         $move->name = $fields['next_move'];
         unset($fields['next_move']);
         if (isset($fields['next_move_level'])) {
             $move->level = $fields['next_move_level'];
             unset($fields['next_move_level']);
         }
         $fields['next_move'] = $move;
     }
     return $fields;
 }
示例#7
0
<?php

use TPP\Models\TPP;
define('TPP_DEBUG', false);
require "vendor/autoload.php";
require "models/Init.php";
new Init();
TPP::initializeConnection();
return ['paths' => ['migrations' => 'db/migrations', 'seeds' => 'db/seeds'], 'environments' => ['default_migration_table' => 'migrations', 'default_database' => 'development', 'development' => ['name' => DB_DATABASE . TWITCHVERSION, 'connection' => TPP::db()]]];
示例#8
0
<?php

use TPP\Models\TPP;
require "vendor/autoload.php";
$time = microtime(true);
prioIncludes();
includes();
new Init();
if (TPP_DEBUG) {
    error_reporting(E_ALL);
    ini_set('display_errors', 1);
}
TPP::initializeConnection();
$site = new SiteController();
$site->actionIndex();
echo '<h1>loaded in ' . round(microtime(true) - $time, 7) . ' secs</h1>';
exit;
function prioIncludes()
{
    $priorityIncludes = ['controllers' => ['Controller'], 'models' => ['Init']];
    foreach ($priorityIncludes as $key => $prio) {
        foreach ($prio as $pr) {
            include_once $key . '/' . $pr . '.php';
        }
    }
}
function includes()
{
    $includes = ['controllers', 'models', 'helpers'];
    foreach ($includes as $inc) {
        foreach (glob($inc . "/*.php") as $filename) {
示例#9
0
 /**
  * @return array
  */
 public function getMessages()
 {
     $getMessages = TPP::db()->prepare("\r\n SELECT m.`id`, m.`message`, m.`sent_user`, s.`suggestion`\r\n FROM `message` m\r\n LEFT JOIN `suggestion` s ON m.`suggestion_id` = s.`id`\r\n WHERE m.`read` = 0 AND m.`ip` = :ip\r\n ORDER BY `date_created` ASC\r\n LIMIT 1") or die(TPP::db()->error);
     $getMessages->execute([':ip' => $_SERVER['REMOTE_ADDR']]);
     if ($getMessages->rowCount() > 0) {
         while ($m = $getMessages->fetch()) {
             $return = ['message' => $m['message'], 'id' => $m['id'], 'sentUser' => $m['sent_user'], 'suggestion' => $m['suggestion']];
         }
         return $return;
     }
     return [];
 }