Exemple #1
0
    }
    if (check_submit($_POST['dosubmit'], $_POST['formhash'])) {
        if (empty($_POST['content'])) {
            show_message('answer_null', '');
            exit;
        }
        $query = $dblink->query("SELECT count(*) FROM {$dbprefix}answer WHERE uid={$cyask_uid} AND qid={$qid}");
        if ($dblink->result($query, 0)) {
            show_message('answer_more', '');
            exit;
        } else {
            $content = filters_content($_POST['content']);
            $sql = "INSERT INTO {$dbprefix}answer set qid={$qid},uid={$cyask_uid},username='******',answer='{$content}',answertime={$timestamp}";
            if ($dblink->query($sql)) {
                //$aid=$dblink->insert_id();
                add_score($cyask_uid, $score_answer);
                $dblink->query("UPDATE {$dbprefix}ques SET answercount=answercount+1 WHERE qid={$qid}");
                $referer = get_referer($default = './');
                header("location:signal.php?resultno=109&url={$referer}");
                exit;
            }
        }
    } else {
        show_message('url_error', './');
        exit;
    }
} elseif ($command == 'answer_response') {
    $aid = intval($_POST['aid']);
    $query = $dblink->query("select * from {$dbprefix}answer where aid={$aid}");
    if (!$dblink->num_rows($query)) {
        show_message('action_error', './');
ini_set('display_errors', 1);
echo 'start testing<br>';
require_once 'connect_redis.php';
require_once '../Controllers/add_score.php';
require_once '../Controllers/get_ranklist.php';
//try to insert new entry
$input = '
{
	"func":"add_score",
	"user":10,
	"username":"******",
	"score_add":720
}
';
$input = json_decode($input, true);
add_score($input);
//try to get inserted rank data
$query_param = '
{
    "func":"get_ranklist",
	"user":"******",
	"size":1
}
';
$query_param = json_decode($query_param, true);
$result = get_ranklist($query_param);
echo 'result:';
print_r($result);
echo 'verify result:';
//verify();
function verify($expected, $real, $matchtype = false)
Exemple #3
0
            }
        } else {
            // Ignore doubleposts
            if (strval($entries[$i]["author"]) == strval($entries[$i + 1]["author"])) {
                continue;
            }
            $interval = abs($entries[$i]["date"] - $entries[$i + 1]["date"]);
            $min = round($interval / 60);
            $score = ceil(pow($min, 1.1));
            // Insert to database
            $q = $db->prepare("INSERT INTO posts (id, author, date) VALUES (:id, :a, :d)");
            $q->bindValue(":id", $entries[$i]["id"]);
            $q->bindValue(":a", $entries[$i]["author"]);
            $q->bindValue(":d", strftime("%F %T", $entries[$i]["date"]));
            $q->execute();
            add_score($db, $entries[$i]["author"], $score);
            print $score . " points to " . $entries[$i]["id"] . " (" . $entries[$i]["author"] . ")\n";
        }
    }
    // Set "last updated"-date
    file_put_contents(NECRO_PATH . "update.txt", date("Y-m-d H:i:s"));
} else {
    // If HTTP request
    // GET DATA & GENERATE IMAGE
    $q = $db->prepare("SELECT author, score, (SELECT COUNT(*) FROM posts WHERE author = score.author) AS post_count FROM score ORDER BY score DESC");
    $r = $q->execute();
    $res = array();
    while ($row = $r->fetchArray()) {
        $res[] = $row;
    }
    // Determine image height, longest author text and longest points text
Exemple #4
0
    $query = $dblink->query("select title,score,answercount from {$dbprefix}ques where qid={$qid}");
    $question = $dblink->fetch_array($query);
    $ques_title = $question['title'];
    $ques_score = $question['score'];
    $answercount = $question['answercount'];
    include template('handle_ques_close');
} elseif ($command == 'ques_close_submit') {
    $query = $dblink->query("select score from {$dbprefix}ques where qid={$qid}");
    if (!$dblink->num_rows($query)) {
        show_message('action_error', './');
        exit;
    }
    if (check_submit($_POST['quesclosesubmit'], $_POST['formhash'])) {
        $ques_score = $dblink->result($query, 0);
        $dblink->query("UPDATE {$dbprefix}ques SET status=4 where qid={$qid}");
        add_score($cyask_uid, $ques_score);
        header("location:signal.php?resultno=107&url={$url}");
        exit;
    } else {
        show_message('url_error', './');
        exit;
    }
} elseif ($command == 'ques_vote') {
    $query = $dblink->query("select title,score from {$dbprefix}ques where qid={$qid}");
    if (!$dblink->num_rows($query)) {
        show_message('action_error', './');
        exit;
    }
    $title = $site_name;
    $question = $dblink->fetch_array($query);
    $ques_title = $question['title'];
 * OL
 * final
 * Sameer Jain
 * 12/18/15
 */
require '../model/database.php';
require '../model/product_db.php';
$student_id = filter_input(INPUT_POST, 'student_id');
$score = filter_input(INPUT_POST, 'score');
$event_id = filter_input(INPUT_POST, 'event_id');
$students = get_students();
$events = get_grades();
$event_counter = 0;
$student_counter = 0;
foreach ($events as $event) {
    if (in_array($event_id, $event)) {
        $event_counter++;
    }
}
foreach ($students as $student) {
    if (in_array($student_id, $student)) {
        $student_counter++;
    }
}
if ($student_id == NULL || $event_id == NULL || $score == NULL || $student_counter == 0 || $event_counter == 0) {
    $error = "Invalid product data. Check all fields and try again.";
    include '../errors/error.php';
} else {
    add_score($student_id, $event_id, $score);
    header("Location: ..");
}