Exemple #1
0
        break;
    case 'remove':
        $winner = ChallengeWinner::getChallengeWinner($winner_id);
        $winner->doRemove("Deleted challenge winner successfully.");
        break;
    case 'claim':
        $team = Session::currentTeam();
        $challenge = Challenge::getChallengeByCode($code);
        if (!$team) {
            add_notification('You cannot claim a challenge if you have no team.');
        } else {
            if (!$challenge) {
                add_notification('No challenge with this code found. If you think you received this message in error, bring your code to a coordinator in person.');
            } else {
                if ($challenge->getWinners()) {
                    add_notification('Someone else has already claimed the code you entered.');
                } else {
                    $winner = new ChallengeWinner(array('team' => $team->getID(), 'challenge' => $challenge->getID()));
                    $winner->doAdd("Claimed code successfully.");
                }
            }
        }
}
// VIEW
$page = new UIPage();
function challenge_claim_form()
{
    return <<<EOT
<form method="POST" action="challenges.php">
Enter Claim Code: <input type="text" name="code" />
<input type="submit" name="claim" value="Claim!" />
Exemple #2
0
 protected function handleException(DBException $ex)
 {
     // for now, print it. Maybe later, log it.
     add_notification($ex->getMessage());
 }
Exemple #3
0
        $clue->doRemove('Deleted clue successfully.');
        break;
    case 'answer':
        $team = Session::currentTeam();
        if ($team) {
            if ($latitude && $longitude) {
                $clue = Clue::getClue($clue_id);
                if ($clue) {
                    CheckIn::doCheckIn($team, $latitude, $longitude, $guess);
                    $team->doGuessAnswer($clue, $guess);
                }
            } else {
                add_notification('You must have location turned on to submit clue answers.');
            }
        } else {
            add_notification('You must have a team to submit clue answers.');
        }
}
// VIEW
$page = new UIPage();
$position = Session::defaultPosition();
function answerForm($clueID, $clueSalt, $hashedAnswers, $serialized)
{
    return <<<EOT
<form id="answerform" method="POST" action="clues.php">
<input type="text" name="guess" size=30 id="g{$clueID}" />
<input type="submit" name="answer" value="Submit" />
<br />
<span id="feedback" style="font-size: 12px; color: #FF0000;"></span>
<input type="hidden" id="clueID" name="id" value="{$clueID}" />
<input type="hidden" id="latitude" name="latitude" />
Exemple #4
0
         if ($mutual) {
             $mutual2 = 1;
         }
         //在关注表出入数据
         $follow_data = array("uid" => $fuid, "username" => $fromusername, "followuid" => $tuid, "fusername" => $tousername, "bkname" => "", "status" => 0, "mutual" => $mutual2, "dateline" => $now);
         $flag = $db->AutoExecute("disc_home_follow", $follow_data, "INSERT");
         $in_id = $db->Affected_Rows();
         if ($in_id) {
             //关注者人数增加
             $sql2 = "update disc_common_member_count set following=following+1  where uid='{$fuid}'";
             $db->Execute($sql2);
             //被关注者人数增加
             $sql3 = "update disc_common_member_count set follower=follower+1, newfollower=newfollower+1 where uid='{$tuid}'";
             $db->Execute($sql3);
             $note = "<a href='home.php?mod=space&uid={$fuid}'>{$fromusername}</a> 收听了您。<a href='home.php?mod=follow&do=follower'>点击查看</a>";
             $flag = add_notification($tuid, "follower", 1, $fuid, $fromusername, $note, $now, $fuid, "following", 2, 6);
             $data = array("status" => "ok", "info" => "关注成功");
         } else {
             $error = $db->ErrorMsg();
             $data = array("status" => "error", "info" => "关注失败: {$error}");
         }
     } else {
         $data = array("status" => "error", "info" => "重复的关注");
     }
 } else {
     if ($act == "unfollow") {
         //取消关注   http://51fabu.bj-soft.cn/mobile/profile.php?act=unfollow&fromuid=1&touid=2
         $fuid = htmlspecialchars($_GET['fromuid']);
         $tuid = htmlspecialchars($_GET['touid']);
         //follow表关系删除
         $sql1 = "delete from disc_home_follow where uid='{$tuid}' and followuid='{$fuid}'";
        return '"' . $product_title . '"';
    }, $overhead_quantity_products);
    add_notification('Для товаров ' . implode(', ', $overhead_quantity_products) . ' недостаточен остаток.');
    browser_redirect('cart');
    exit;
}
$order = array(':user_id' => $_SESSION['user_id']);
db_query('INSERT INTO `orders` (`user_id`) VALUES (:user_id);', $order);
$order_id = db_select('SELECT LAST_INSERT_ID();');
$order_id = reset($order_id);
$order_id = reset($order_id);
$order_id = (int) $order_id;
$sql_add_product_to_order = <<<SQL
INSERT INTO `products_at_orders`
  (`product_id`, `order_id`, `quantity`)
  VALUES
  (:product_id, :order_id, :quantity)
SQL;
$sql_decrease_product_quantity = <<<SQL
UPDATE `products`
SET `quantity` = :new_quantity
WHERE `id` = :product_id
SQL;
foreach ($products as $product) {
    db_query($sql_add_product_to_order, array(':product_id' => $product['id'], ':order_id' => $order_id, ':quantity' => $product['quantity_at_cart']));
    db_query($sql_decrease_product_quantity, array(':product_id' => $product['id'], ':new_quantity' => $product['quantity'] - $product['quantity_at_cart']));
}
$_SESSION['cart'] = array();
add_notification('Заказ успешно создан!');
browser_redirect('order', array('order_id' => $order_id));
exit;
Exemple #6
0
require 'core/init.php';
$topic = new Topic();
$user = new User();
$template = new Template("templates/topic.php");
$topic_id = isset($_GET['topic']) ? $_GET['topic'] : null;
$template->topicSel = $topic->getTopicById($topic_id);
$template->replies = $topic->getRepliesBytopic($topic_id);
$template->title = $topic->getTopicById($topic_id)->title;
$template->totUsers = totUsers();
$template->totTopics = topicsCount("all");
if (isLoggedIn()) {
    $template->user_id = $_SESSION['user_id'];
    $template->username = $_SESSION['username'];
    $template->email = $_SESSION['email'];
    $template->last_activity = $_SESSION['last_activity'];
    $template->avatar = $_SESSION['avatar'];
    $template->details = $_SESSION['details'];
    if (!empty($_POST['reply']) && isset($_POST['reply']) && $_POST['reply'] != '<br>') {
        $data['topic_id'] = $_GET['topic'];
        $data['user_id'] = $_SESSION['user_id'];
        $data['body'] = $_POST['reply'];
        $redirect = "topic.php?topic=" . urlFormat($_GET['topic']);
        if ($user->reply($data)) {
            add_notification($_SESSION['user_id'], " added an answer to a topic ", $_GET['topic'], $_POST['newAns'], followers_id($_SESSION['user_id']));
        }
        redirect($redirect);
    }
} else {
    redirect("home.php");
}
echo $template;
Exemple #7
0
            $user->doUpdate("Added user {$sunetid} successfully.");
        } else {
            add_notification("No user with SUNetID {$sunetid} exists!");
        }
        break;
    case 'remove':
        $user = Person::getPersonBySUNetID($sunetid);
        if ($user) {
            if ($user->getTeam()->getID() == $team_id) {
                $user->makeChanges(array('team' => null));
                $user->doUpdate("Removed user {$sunetid} successfully.");
            } else {
                add_notification("User {$sunetid} is not on this team!");
            }
        } else {
            add_notification("No user with SUNetID {$sunetid} exists!");
        }
        break;
    case 'rename':
        $team = Team::getTeam($team_id);
        $team->makeChanges(array('name' => $team_name));
        $team->doUpdate("Changed name to {$team_name} successfully.");
        break;
}
// VIEW
$page = new UIPage();
// condition on whether user is admin
function team_summary($position, Team $team)
{
    switch ($position) {
        case POSITION_NONE:
Exemple #8
0
 public function doGuessAnswer(Clue $clue, $guess)
 {
     $clueState = $clue->getClueState($this);
     $currentState = $clue->calculateClueState($this);
     if ($currentState >= STATE_ANSWERED) {
         add_notification('This clue has already been answered.');
         return false;
     } else {
         if ($currentState < STATE_ANSWERABLE) {
             add_notification('This clue cannot be answered yet. Try waiting or changing your location as indicated.');
             return false;
         }
     }
     if ($clue->isGuessCorrect($guess)) {
         add_notification('Correct answer!');
         if ($clueState == null) {
             $clueState = new ClueState(array('team' => $this->id, 'clue' => $clue->getID()));
             $clueState->doAdd();
             $clue->setClueState($this, $clueState);
         }
         $clueState->makeChanges(array('state' => STATE_ANSWERED, 'answer' => $guess));
         $clueState->doUpdate();
         return true;
     } else {
         add_notification('Incorrect guess!');
         return false;
     }
 }
Exemple #9
0
            $db = new Database();
            $db->query("INSERT INTO categories VALUES ('',:name,:description)");
            $db->bind(":name", strip_tags($_POST['newCat'], ''));
            $db->bind(":description", $b);
            $db->execute();
            $db->query("SELECT id FROM categories ORDER BY id DESC LIMIT 1");
            $result = $db->single();
            $data['category_id'] = $result->id;
        } else {
            $data['category_id'] = strip_tags($_POST['category'], '');
        }
        $data['user_id'] = $_SESSION['user_id'];
        $data['last_activity'] = date("Y-m-d H:i:s");
        $data['body'] = strip_tags($_POST['body'], '<iframe><br>');
        $required = array("title", "category_id");
        if (requiredFields($required, $data)) {
            if ($user->createTopic($data)) {
                add_notification($_SESSION['user_id'], "asked a question", getlastid('topics'), 0, followers_id($_SESSION['user_id']));
                echo '<div class="al alert alert-success" style="text-align:center">Successfully posted your query</div>
	 <script>reload();</script>';
            } else {
                echo '<div class="al alert alert-danger" style="text-align:center">Couldn\'t Upload. Please try after some time </div>';
            }
        } else {
            echo '<div class="al alert alert-warning" style="text-align:center">Please fill all the required fields</div>';
        }
    }
    echo $template;
} else {
    redirect("index.php");
}
Exemple #10
0
            if ($result->count == 0) {
                $db->query("INSERT INTO upvotes VALUES ('',:t_id,:r_id,:u_id,:v_f,'1',:date)");
            } else {
                $db->query("UPDATE upvotes SET vote='1',last_activity=:date WHERE u_id=:u_id AND t_id=:t_id AND r_id=:r_id AND v_for=:v_f");
            }
            $db->bind("u_id", $user_id);
            $db->bind("r_id", $r_id);
            $db->bind("t_id", $t_id);
            $db->bind("v_f", $s->user_id);
            $db->bind("date", date("Y-m-d H:i:s"));
            if ($db->execute()) {
                if ($r_id != 0) {
                    add_notification($user_id, "upvoted for an answer to the question", $t_id, $r_id, followers_id($user_id));
                } else {
                    if ($_id == 0) {
                        add_notification($user_id, "upvoted for a question", $t_id, $r_id, followers_id($user_id));
                    }
                }
            }
            break;
        case "downvote":
            $db->query("UPDATE upvotes SET vote='0',last_activity=:date WHERE u_id=:u_id AND t_id=:t_id AND r_id=:r_id");
            $db->bind("u_id", $user_id);
            $db->bind("r_id", $r_id);
            $db->bind("t_id", $t_id);
            $db->bind("date", date("Y-m-d H:i:s"));
            if ($db->execute()) {
            }
    }
} else {
    redirect("home.php");