Skip to content

Commit

Permalink
Implemented news-text.php
Browse files Browse the repository at this point in the history
News articles are now loaded from the server.
  • Loading branch information
T0astBread committed Jul 27, 2017
1 parent d80c3e4 commit 753268d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions cs-website/php/news-text.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
<?php
include_once "utils.internal.php";

if(!isset($_GET["id"])) bad_request("You need to specifiy the id of the news story to load!");
if(!isset($_GET["id"]) || !isset($_GET["lang"])) bad_request("You need to specifiy the id and language (lang) of the news story to load!");
$id = $_GET["id"];
$lang = $_GET["lang"];
if(!is_numeric($id)) bad_request("The id must be a number!");
if($id < 0) bad_request("The id must be bigger than 0!");


echo "This is the news text for id ".$id;
require_once "db/db.internal.php";

$stmt = $mysqli->prepare("SELECT text FROM news_article_localizations, languages WHERE article_id = ? AND languages.abbreviation = ? AND news_article_localizations.language_id = languages.id");
$stmt->bind_param("is", $id, $lang);
$stmt->execute();
$stmt->bind_result($text);
$stmt->fetch();
echo $text;
?>
2 changes: 1 addition & 1 deletion cs-website/scripts/news.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ let loadNewsText = (articleId: number, finishCallback: (request: XMLHttpRequest)
{
let request = new XMLHttpRequest();
request.onload = () => finishCallback(request);
request.open("get", getWindowHost() + "/php/news-text.php?id=" + articleId, true);
request.open("get", getWindowHost() + "/php/news-text.php?lang=de&id=" + articleId, true);
request.send(null);
}

Expand Down

1 comment on commit 753268d

@T0astBread
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This closes #17

Please sign in to comment.