SET client_min_messages = warning;
SET row_security = off;
+SET search_path = public, pg_catalog;
+
+SET default_with_oids = false;
+
+--
+-- Name: segnalazioni; Type: TABLE; Schema: public; Owner: -
+--
+
+CREATE TABLE segnalazioni (
+ id integer NOT NULL,
+ utente character varying(255) DEFAULT ''::character varying,
+ latitudine double precision,
+ longitudine double precision
+);
+
+
+--
+-- Name: segnalazioni_pkey; Type: CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY segnalazioni
+ ADD CONSTRAINT segnalazioni_pkey PRIMARY KEY (id);
+
+
--
-- PostgreSQL database dump complete
--
g_free (head);
g_free (content);
}
+
+void
+index_category (GMatchInfo *minfo, gpointer user_data)
+{
+ CtplEnviron *env;
+
+ gchar *filename;
+ gchar *content;
+
+ Commons *commons = (Commons *)user_data;
+
+ if (!get_is_logged (commons))
+ {
+ zak_cgi_main_redirect (commons->zcgi_main, "/bcity/bcity_fe/login/index");
+ return;
+ }
+
+ if (zak_cgi_main_is_post (commons->zcgi_main))
+ {
+ zak_cgi_session_set_value (commons->zcgi_session, "latitudine", g_value_get_string (zak_cgi_main_get_stdin_field (commons->zcgi_main, "lat")));
+ zak_cgi_session_set_value (commons->zcgi_session, "longitudine", g_value_get_string (zak_cgi_main_get_stdin_field (commons->zcgi_main, "lng")));
+
+ filename = g_build_filename (commons->ctpldir, "index_category.ctpl", NULL);
+ content = get_ctpl_filled (filename, NULL);
+ g_free (filename);
+
+ env = ctpl_environ_new ();
+ ctpl_environ_push_string (env, "head", "");
+ ctpl_environ_push_string (env, "body_tag", "");
+ ctpl_environ_push_string (env, "body", content);
+
+ filename = g_build_filename (commons->ctpldir, "template.ctpl", NULL);
+ g_string_printf (commons->out, "%s",
+ get_ctpl_filled (filename, env));
+ g_free (filename);
+
+ g_free (content);
+ }
+ else
+ {
+ zak_cgi_main_redirect (commons->zcgi_main, "/bcity/bcity_fe/index/index");
+ }
+}
+
+void
+index_save (GMatchInfo *minfo, gpointer user_data)
+{
+ CtplEnviron *env;
+
+ gchar *filename;
+ gchar *content;
+
+ Commons *commons = (Commons *)user_data;
+
+ if (!get_is_logged (commons))
+ {
+ zak_cgi_main_redirect (commons->zcgi_main, "/bcity/bcity_fe/login/index");
+ return;
+ }
+
+ if (zak_cgi_main_is_post (commons->zcgi_main))
+ {
+ guint newid;
+ gchar *sql;
+
+ newid = gdaex_get_new_id(commons->gdaex, "segnalazioni", "id", NULL);
+
+ sql = g_strdup_printf ("INSERT INTO segnalazioni"
+ " (id, utente, latitudine, longitudine)"
+ " VALUES (%d, '%s', %s, %s)",
+ newid,
+ zak_cgi_session_get_value (commons->zcgi_session, "username"),
+ zak_cgi_session_get_value (commons->zcgi_session, "latitudine"),
+ zak_cgi_session_get_value (commons->zcgi_session, "longitudine"));
+ gdaex_execute (commons->gdaex, sql);
+ g_free (sql);
+
+ filename = g_build_filename (commons->ctpldir, "index_save.ctpl", NULL);
+ content = get_ctpl_filled (filename, NULL);
+ g_free (filename);
+
+ env = ctpl_environ_new ();
+ ctpl_environ_push_string (env, "head", "");
+ ctpl_environ_push_string (env, "body_tag", "");
+ ctpl_environ_push_string (env, "body", content);
+
+ filename = g_build_filename (commons->ctpldir, "template.ctpl", NULL);
+ g_string_printf (commons->out, "%s",
+ get_ctpl_filled (filename, env));
+ g_free (filename);
+
+ g_free (content);
+ }
+ else
+ {
+ zak_cgi_main_redirect (commons->zcgi_main, "/bcity/bcity_fe/index/index");
+ }
+}
zak_cgi_url_connect (zcgi_url, "/", (ZakCgiUrlConnectedFunction)index_index, commons);
zak_cgi_url_connect (zcgi_url, "/index[/]?", (ZakCgiUrlConnectedFunction)index_index, commons);
zak_cgi_url_connect (zcgi_url, "/index/index", (ZakCgiUrlConnectedFunction)index_index, commons);
+ zak_cgi_url_connect (zcgi_url, "/index/category", (ZakCgiUrlConnectedFunction)index_category, commons);
+ zak_cgi_url_connect (zcgi_url, "/index/save", (ZakCgiUrlConnectedFunction)index_save, commons);
zak_cgi_url_connect (zcgi_url, "/login[/]?", (ZakCgiUrlConnectedFunction)login_index, commons);
zak_cgi_url_connect (zcgi_url, "/login/index", (ZakCgiUrlConnectedFunction)login_index, commons);