Example #1
0
 public function create($uuid, $email)
 {
     $statement = $this->db->prepare('INSERT INTO USER (token, token_time, email)
                             VALUES (:token, :token_time, :email)');
     $statement->bindValue(":token", $uuid);
     $statement->bindValue(":token_time", date('Y-m-d H:i:s', time()));
     $statement->bindValue(":email", $email);
     $count = $statement->execute();
     $user_id = $this->db->lastInsertId();
     $tag = new Tag($this->db, $user_id);
     $tag->create_default();
     $tag_id = $tag->by_name('flat');
     $trick = new Trick($this->db, $user_id);
     $trick->create_default($tag_id);
 }
Example #2
0
<?php

require __DIR__ . '/../../../init.php';
if (empty($_GET['name']) && empty($_POST['name'])) {
    redirect();
}
$trick = new Trick($db, $user->get_id());
if (isset($_POST['name'])) {
    $trick->delete_by_name($_POST['name']);
    redirect('/tricks');
}
$name = $_GET['name'];
echo html(title('Homespot - Delete Trick'), navigation($user->is_authed()) . content(h1("Delete Trick - " . $_GET['name']) . form('post', hidden('name', $_GET['name']) . submit('DELETE'))));
Example #3
0
<?php

require __DIR__ . '/../../../init.php';
$trick = new Trick($db, $user->get_id());
$tag = new Tag($db, $user->get_id());
$err = '';
if (isset($_POST['submit']) && $_POST['submit'] == 'defer') {
    if (isset($_POST['trick_ids'])) {
        $trick->defer($_POST['trick_ids']);
        redirect();
    } else {
        $err = 'select at least one track';
    }
}
if (isset($_POST['submit']) && $_POST['submit'] == 'reset') {
    if (isset($_POST['trick_ids'])) {
        $trick->reset($_POST['trick_ids']);
        redirect();
    } else {
        $err = 'select at least one track';
    }
}
if (empty($_GET['tag_names'])) {
    $rows = $tag->all_names();
    if (count($rows) > 0) {
        $uri_query = http_build_query(array('tag_names' => $rows));
        redirect("/index.php?{$uri_query}");
    } else {
        redirect('/tag/create/index.php?no_tags=1');
    }
}
Example #4
0
 }
 SmartTest::instance()->progress();
 if (!class_exists("Trick")) {
     class Trick extends RedBean_Decorator
     {
         public function __construct($id = 0)
         {
             parent::__construct("Customer", $id);
         }
         public function setHallo()
         {
             return "hallodaar";
         }
     }
 }
 $trick = new Trick();
 $trick->importFromPost(array("hallo", "there"));
 $message = array_shift($trick->problems());
 if ($message === "hallodaar") {
     SmartTest::instance()->progress();
 } else {
     die("<b style='color:red'>Error CANNOT:" . SmartTest::instance()->canwe);
     exit;
 }
 SmartTest::instance()->progress();
 SmartTest::instance()->canwe = "avoid race-conditions by locking?";
 RedBean_OODB::gen("Cheese,Wine");
 $cheese = new Cheese();
 $cheese->setName('Brie');
 $cheese->save();
 $cheese = new Cheese(1);
Example #5
0
<?php

require __DIR__ . '/../../init.php';
$trick = new Trick($db, $user->get_id());
$tricks = $trick->names();
$content = trick_names_ul($tricks);
echo html(title('Homespot - All Tricks'), navigation($user->is_authed()) . content(h1("All Tricks") . p('trick count: ' . count($tricks)) . $content));
Example #6
0
<?php

require __DIR__ . '/../../../init.php';
$error = array();
if (empty($_GET['name']) && empty($_POST['name'])) {
    redirect();
}
$name = isset($_GET['name']) ? $_GET['name'] : $_POST['name'];
$trick = new Trick($db, $user->get_id());
$tag = new Tag($db, $user->get_id());
$tricks = $trick->by_name($name);
$tricks_old = array_select_prefix($tricks);
$tags_old = array_select_key($tricks, 'tag_id');
$stances_old = array_select_key($tricks, 'stance');
$directions_old = array_select_key($tricks, 'direction');
$tags_all = $tag->all();
$tags_echo = tag_ids_checkbox_ul($tags_all, $tags_old);
if (!$tags_echo) {
    redirect('/tag/create/index.php?no_tags=1');
}
if (isset($_POST['name'])) {
    if (strlen(validate_name($_POST['name'])) > 0) {
        $error['name'] = validate_name($_POST['name']);
    }
    if (isset($_POST['tag_ids']) && count($_POST['tag_ids']) == 0) {
        $error['tag_ids'] = 'no tags were selected';
    }
    if (count($error) == 0) {
        $prefixes = generate_prefixes(array_keys($_POST['stance']), array_keys($_POST['direction']), $_POST['tag_ids']);
        $delete_tricks = compare_prefixes($tricks_old, $prefixes);
        $create_tricks = compare_prefixes($prefixes, $tricks_old);
Example #7
0
<?php

require __DIR__ . '/../../../init.php';
$tag = new Tag($db, $user->get_id());
$trick = new Trick($db, $user->get_id());
$error = array();
if (isset($_POST['name'])) {
    if (strlen(validate_name($_POST['name'])) > 0) {
        $error['name'] = validate_name($_POST['name']);
    }
    if (empty($_POST['tag_ids']) || count($_POST['tag_ids']) == 0) {
        $error['tag_ids'] = 'no tags were selected';
    }
    if (count($error) == 0) {
        $prefixes = generate_prefixes(array_keys($_POST['stance']), array_keys($_POST['direction']), $_POST['tag_ids']);
        $name = $_POST['name'];
        if (count($error) == 0) {
            $trick_name_id = $trick->create_trick_name($name);
            $trick->create($trick_name_id, $prefixes);
            redirect();
        }
    }
}
$rows = $tag->all();
$tags = tag_ids_checkbox_ul($rows);
if (!$tags) {
    redirect('/tag/create/index.php?no_tags=1');
}
echo html(title('Homespot - Create Trick'), navigation($user->is_authed()) . content(h1("Create Trick") . form('post', lable('stance:') . div(lable('normal:') . checkbox('stance[normal]') . lable('nolli:') . checkbox('stance[nolli]') . lable('switch:') . checkbox('stance[switch]') . lable('fakie:') . checkbox('stance[fakie]')) . lable('direction:') . div(lable('none:') . checkbox('direction[none]') . lable('fs:') . checkbox('direction[fs]', false) . lable('bs:') . checkbox('direction[bs]', false)) . input_err($error, 'name') . input('text', 'name') . div(lable('tags:')) . input_err($error, 'tag_ids') . $tags . submit())));