function page($page) { $start = ($page - 1) * config('post.per'); $end = $start + config('post.per'); foreach (posts() as $i => $post) { if ($i >= $end) { (yield true); } if ($i >= $start && $i < $end) { (yield $post); } } }
echo date(DATE_W3C, article_time()); ?> "><?php echo relative_time(article_time()); ?> </time> by <?php echo article_author('real_name'); ?> . </footer> <hr> </article> </li> <?php $i = 0; while (posts()) { ?> <li> <article class="wrap"> <h2> <a href="<?php echo article_url(); ?> " title="<?php echo article_title(); ?> "><?php echo article_title(); ?> </a> </h2>
<?php require '../vendor/autoload.php'; header('Content-Type: application/xml; charset=utf-8'); echo cache('rss.xml', function () { return tmpl('rss', ['posts' => posts()]); }); exit;
/** * Returns true while there are still tagged posts in the array. * This replaces the Anchor posts() method * * @return bool */ function tagged_posts() { $tag = extract_tag(); if ($tag != '') { if (!($posts = Registry::get('tagged_posts'))) { $tagged_posts = get_posts_with_tag($tag); $posts = Post::where_in('id', $tagged_posts)->where('status', '=', 'published')->sort('created', 'desc')->get(); Registry::set('tagged_posts', $posts = new Items($posts)); } if ($posts instanceof Items) { if ($result = $posts->valid()) { // register single post Registry::set('article', $posts->current()); // move to next $posts->next(); } else { $posts->rewind(); } return $result; } } else { return posts(); } return false; }
{ $result = $mysqli->query($query); $array_tasks = array(); while ($data = mysqli_fetch_assoc($result)) { $array_tasks[] = $data; } echo json_encode($array_tasks); } if (isset($_POST)) { if (isset($_POST['answers'])) { $taskId = $_POST['taskid']; $studentId = $_POST['studentid']; $taskId = $mysqli->real_escape_string($taskId); $studentId = $mysqli->real_escape_string($studentId); $query = "SELECT DISTINCT question_text, control_answers.question_id, control_answers.task_id, control_answers.student_id, task_option, answer_text, task_time FROM control_answers, tasks_completed, questions WHERE control_answers.student_id = '{$studentId}' AND tasks_completed.task_time = (SELECT task_time FROM tasks_completed WHERE student_id = '{$studentId}' AND task_id = '{$taskId}') AND questions.question_id = control_answers.question_id AND control_answers.task_option = (SELECT DISTINCT task_option FROM control_answers WHERE student_id = '{$studentId}' AND task_id = '{$taskId}') AND control_answers.task_id = '{$taskId}'"; posts($mysqli, $query); } else { if (isset($_POST['sendrating'])) { $rating = $_POST['sendrating']; $teacherAnswers = $_POST['teacheranswers']; $questionsId = $_POST['questionid']; $studentId = $_POST['studentid']; $taskId = $_POST['taskid']; $rating = $mysqli->real_escape_string($rating); $studentId = $mysqli->real_escape_string($studentId); $taskId = $mysqli->real_escape_string($taskId); $query = "UPDATE students_tasks SET rating = '{$rating}' WHERE student_id = '{$studentId}' AND task_id = '{$taskId}'"; $mysqli->query($query); for ($i = 0; $i < count($teacherAnswers); $i++) { $answer = $teacherAnswers[$i]; $questionId = $questionsId[$i];
<?php theme_include('header'); ?> <!-- <p>Nice try</p> --> <div class="box"> <?php if (has_posts()) { ?> <?php posts(); ?> <article class="wrap"> <h1 class="mb0"> <a href="<?php echo article_url(); ?> " title="<?php echo article_title(); ?> "><?php echo article_title(); ?> </a> </h1> <small class="muted"> <time datetime="<?php echo date(DATE_W3C, article_time());
<?php require '../vendor/autoload.php'; $request = trim(strtok($_SERVER['REQUEST_URI'], '?'), '/'); if (preg_match('/^page\\/[1-9][0-9]*$/', $request)) { $page = (int) explode('/', $request)[1]; $isPage = true; } else { $page = 1; $isPage = false; } $output = cache($request, function () use($request, $page, $isPage) { if ($request && !$isPage) { foreach (posts() as $post) { if (config('post.url') . $post['meta']['slug'] == $request) { $filter = compose('markdown', 'pygments', 'graphviz'); $post['post'] = $filter($post['post']); return tmpl('post', $post); } } } else { $posts = page($page); if ($posts->key() !== null) { return tmpl('main', ['posts' => $posts, 'page' => $page]); } } return false; }); if ($output === false) { header('HTTP/1.0 404 Not Found'); echo tmpl('404');