Compare commits
No commits in common. "51f7fc039421443ec24607716804365442254320" and "cba57167c245b495d80765e2153f6aa4c6546bef" have entirely different histories.
51f7fc0394
...
cba57167c2
1
client/.gitignore
vendored
1
client/.gitignore
vendored
@ -3,4 +3,3 @@ CMakeFiles
|
||||
*.cmake
|
||||
yacos
|
||||
*~
|
||||
build-*
|
||||
|
@ -179,47 +179,9 @@ void yacos_cart_item_fetch_meta(YacosCartItem *self)
|
||||
// TODO: The soup 's probably memory-leaking all over the place. Check this some time..
|
||||
}
|
||||
|
||||
static void yacos_cart_item_fetch_image_cb (SoupSession *session, SoupMessage *msg, gpointer user_data)
|
||||
{
|
||||
YacosCartItem *self = YACOS_CART_ITEM(user_data);
|
||||
GdkPixbuf *pixbuf_raw, *pixbuf_scaled;
|
||||
GMemoryInputStream *s;
|
||||
|
||||
if (msg->status_code != 200) {
|
||||
g_warning("image: Received error code %d from server.", msg->status_code);
|
||||
} else {
|
||||
s = G_MEMORY_INPUT_STREAM(g_memory_input_stream_new());
|
||||
g_memory_input_stream_add_data(s, msg->response_body->data, msg->response_body->length, NULL);
|
||||
pixbuf_raw = gdk_pixbuf_new_from_stream(G_INPUT_STREAM(s), NULL, NULL);
|
||||
g_object_unref(s);
|
||||
pixbuf_scaled = gdk_pixbuf_scale_simple(pixbuf_raw, 100, 100, GDK_INTERP_BILINEAR);
|
||||
g_object_unref(pixbuf_raw);
|
||||
gtk_image_set_from_pixbuf(GTK_IMAGE(self->priv.image), pixbuf_scaled);
|
||||
g_object_unref(pixbuf_scaled);
|
||||
}
|
||||
|
||||
gtk_stack_set_visible_child(self->priv.stack_image_loader, self->priv.image);
|
||||
}
|
||||
|
||||
void yacos_cart_item_fetch_image(YacosCartItem *self)
|
||||
{
|
||||
SoupMessage *msg;
|
||||
gchar *url;
|
||||
gchar *id_str;
|
||||
|
||||
id_str = yacos_tag_id_to_str(self->priv.tag_id);
|
||||
url = g_strdup_printf("%s?image&id=%s", self->priv.api.url_base, id_str);
|
||||
g_free(id_str);
|
||||
msg = soup_message_new("GET", url);
|
||||
soup_message_headers_append (msg->request_headers, "x-token", self->priv.api.token);
|
||||
g_free(url);
|
||||
|
||||
soup_session_queue_message(self->priv.api.soup_session_meta,
|
||||
msg,
|
||||
yacos_cart_item_fetch_image_cb,
|
||||
self);
|
||||
|
||||
/* TODO: More memory leaks? */
|
||||
return;
|
||||
}
|
||||
|
||||
yacos_tag_id yacos_cart_item_get_id(YacosCartItem *self)
|
||||
|
@ -2,22 +2,10 @@
|
||||
// This is just a dummy implementation during the development of the GTK+3 GUI
|
||||
|
||||
|
||||
if ($_SERVER['HTTP_X_TOKEN'] != "123456") {
|
||||
http_response_code(403);
|
||||
die("Invalid token.\n");
|
||||
}
|
||||
|
||||
$id = $_GET['id'];
|
||||
preg_match("/^[A-Za-z0-9]{6,10}$/", $id, $matches);
|
||||
if (!$matches) {
|
||||
http_response_code(400);
|
||||
die ("Invalid tag ID.");
|
||||
}
|
||||
|
||||
// $id is now safe to use
|
||||
if ($_SERVER['HTTP_X_TOKEN'] != "123456") die("Invalid token.\n");
|
||||
|
||||
if (isset($_GET['meta'])) {
|
||||
if ($id == "BF09CE") {
|
||||
if ($_GET['id'] == "BF09CE") {
|
||||
?>
|
||||
{
|
||||
"title" : "Cute Wifi Cat",
|
||||
@ -25,7 +13,7 @@ if (isset($_GET['meta'])) {
|
||||
"comment" : "It's mewine!"
|
||||
}
|
||||
<?php
|
||||
} else if ($id == "BE6200") {
|
||||
} else if ($_GET['id'] == "BE6200") {
|
||||
?>
|
||||
{
|
||||
"title" : "Crazy Stuff",
|
||||
@ -34,7 +22,6 @@ if (isset($_GET['meta'])) {
|
||||
}
|
||||
<?php
|
||||
} else {
|
||||
http_response_code(400);
|
||||
?>
|
||||
{
|
||||
"title" : "INVALID",
|
||||
@ -43,17 +30,5 @@ if (isset($_GET['meta'])) {
|
||||
}
|
||||
<?php
|
||||
}
|
||||
} else if (isset($_GET['image'])) {
|
||||
header('Content-Type: image/png');
|
||||
$fn = "img/$id.png";
|
||||
if (file_exists($fn)) {
|
||||
readfile($fn);
|
||||
} else {
|
||||
http_response_code(404);
|
||||
die ("Image not found.");
|
||||
}
|
||||
} else {
|
||||
http_response_code(400);
|
||||
die("Invalid request.");
|
||||
}
|
||||
?>
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 5.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 19 KiB |
Loading…
Reference in New Issue
Block a user