Ejemplo n.º 1
0
static void
render_front(const char *m, const st_rss_item_t *e)
{
	char fn[1024], *errmsg;
	/*
		catid = 1 - tech
		catid = 2 - blog
		catid = 3 - news
	*/
	char feeds_query[256];

	sqlite3_snprintf(sizeof(feeds_query), feeds_query, "SELECT id, modified, link, title, description, pubdate from feeds where chanid IN (select id from channels where catid = '%q') order by id desc limit '%q', '%d'", query_category, query_limit, rssroll->feeds);
	//char *feeds_query = "SELECT id, modified, link, title, description, pubdate from feeds where chanid IN (select id from channels where catid = 2) order by id desc limit 10";

	if (!strcmp(m, "FEEDS")) {
		if(sqlite3_exec(db, feeds_query, trace_feeds_callback, &callback_result, &errmsg) != SQLITE_OK) {
			render_error("cannot load database");
		}
	} else if (!strcmp(m, "HEADER")) {
		snprintf(fn, sizeof(fn), "%s/%s/header.html", rssroll->htmldir, rssroll->webtheme);
		render_html(fn, NULL, NULL);
	} else if (!strcmp(m, "FOOTER")) {
		snprintf(fn, sizeof(fn), "%s/%s/footer.html", rssroll->htmldir, rssroll->webtheme);
		render_html(fn, NULL, NULL);
	} else
		d_printf("render_front: unknown macro '%s'<br>\n", m);
}
Ejemplo n.º 2
0
int
trace_feeds_callback (void *p_data, int num_fields, char **p_fields, char **p_col_names) 
{
	/*
		p_fields[0]	-	id
		p_fields[1]	-	modified
		p_fields[2]	-	link
		p_fields[3]	-	title
		p_fields[4]	-	description
		p_fields[5]	-	pubdate
	*/
	st_rss_item_t	rss_item;	
	char	fn[1024];
	unsigned long *p_rn = (unsigned long*)p_data;
	
	/* PREV option */
	/* callback_result++ */
	(*p_rn)++;

	snprintf(fn, sizeof(fn), "%s/%s/feed.html", rssroll->htmldir, rssroll->webtheme);

//	printf("%s\n", p_fields[5]);
	snprintf(rss_item.title, sizeof(rss_item.title), "%s", p_fields[3]);
	snprintf(rss_item.url, sizeof(rss_item.url), "%s", p_fields[2]);
	snprintf(rss_item.desc, sizeof(rss_item.desc), "%s", p_fields[4]);
	rss_item.date = strtol(p_fields[5], NULL, 0);
//	snprintf(rss_item.date, sizeof(rss_item.date), "%s", p_fields[5]);

	render_html(fn, &render_front_feed, &rss_item);
	//render_html(fn, NULL, NULL);
	
	return 0;
}
Ejemplo n.º 3
0
Archivo: main.c Proyecto: txdv/cmark
int main() {
	int retval;
	test_batch_runner *runner = test_batch_runner_new();

	version(runner);
	constructor(runner);
	accessors(runner);
	node_check(runner);
	iterator(runner);
	iterator_delete(runner);
	create_tree(runner);
	hierarchy(runner);
	parser(runner);
	render_html(runner);
	utf8(runner);
	line_endings(runner);
	numeric_entities(runner);
	test_cplusplus(runner);

	test_print_summary(runner);
	retval =  test_ok(runner) ? 0 : 1;
	free(runner);

	return retval;
}
Ejemplo n.º 4
0
void
render_edit(const char *m, void *arg)
{
	ChopstixMenuitem *mi = (ChopstixMenuitem *)arg;
	tbstring sa = {0};
	char fn[MAXPATHLEN];
	unsigned int u;

	if (mi == NULL)
		if ((mi = menu_getitem(menucode)) == NULL)
			return;

	if (!strcmp(m, "ITEMCODE"))
		printf("%s", html_esc(mi->code, &sa, 0));
	else if (!strcmp(m, "ITEMGEN"))
		printf("%d", mi->gen);
	else if (!strcmp(m, "ITEMFLAGS"))
		printf("%s", mi->flags.deleted ? "Deleted" : "Active");
	else if (!strcmp(m, "ITEMNAME"))
		printf("%s", html_esc(mi->name, &sa, 0));
	else if (!strcmp(m, "ITEMPRICE"))
		PRINTF_MONEY(mi->price);
	else if (!strcmp(m, "EDITSTYLES")) {
		snprintf(fn, sizeof(fn), "%s/edit_style.html", conf.htmldir);
		for (u = 0; u < mi->styles.len; u++)
			render_html(fn, render_edit_style, &mi->styles.val[u]);
	} else if (!strcmp(m, "EDITEXTRAS")) {
		snprintf(fn, sizeof(fn), "%s/edit_extra.html", conf.htmldir);
		for (u = 0; u < mi->extras.len; u++)
			render_html(fn, render_edit_extra, &mi->extras.val[u]);
	} else if (!strcmp(m, "EDITSUBITEMS")) {
		snprintf(fn, sizeof(fn), "%s/edit_subitem.html", conf.htmldir);
		if (mi->subitems)
			for (u = 0; u < mi->subitems->len; u++)
				render_html(fn, render_edit_extra, &mi->subitems->val[u]);
	} else
		printf("render_list: unknown macro '%s'", m);

	tbstrfree(&sa);
}
Ejemplo n.º 5
0
void
render_list(const char *m, void *arg)
{
	char fn[MAXPATHLEN];
	unsigned int u;

	if (!strcmp(m, "ITEMLIST")) {
		snprintf(fn, sizeof(fn), "%s/item.html", conf.htmldir);
		for (u = 0; u < menu.len; u++) {
			/* skip over deleted items */
			if (menu.val[u].flags.deleted)
				continue;
			render_html(fn, render_item, &menu.val[u]);
		}
	} else
		printf("render_list: unknown macro '%s'", m);
}
Ejemplo n.º 6
0
static int
order_getrange_cb(const ChopstixOrder *order, void *arg)
{
	const char *fn = arg;
	ChopstixOrder *v_order;

	if (fn) {
		(const ChopstixOrder *)v_order = order;
		render_html(fn, render_order_list, v_order);
	}

	if (total_ok == 0) {
		grand_total.subtotal += order->total.subtotal;
		grand_total.discount += order->total.discount;
		grand_total.delivery += order->total.delivery;
		grand_total.credit += order->total.credit;
		grand_total.tax1 += order->total.tax1;
		grand_total.tax2 += order->total.tax2;
		grand_total.total += order->total.total;
	}

	return 0;
}
Ejemplo n.º 7
0
void
render_order(const char *m, void *arg)
{
	char fn[1024];
	struct tm tm_start, tm_end;
	time_t start, end;

	bcopy(localtime(&time_start), &tm_start, sizeof(tm_start));
	start = mktime(&tm_start);

	bcopy(localtime(&time_stop), &tm_end, sizeof(tm_end));
	end = mktime(&tm_end);

	if (!strcmp(m, "ORDERLIST")) {
		snprintf(fn, sizeof(fn), "%s/order_list.html", conf.htmldir);
		if (odbf.getrange(&odbh, start, end, order_getrange_cb, fn) == -1) {
			render_error("cannot load orders, see system log for details");
			return;
		}
		total_ok = 1;

	} else if (!strcmp(m, "ORDERTOTALS")) {
		if (!total_ok) {
			if (odbf.getrange(&odbh, start, end, order_getrange_cb, NULL)
					== -1) {
				render_error("cannot load orders, see system log for details");
				return;
			}
			total_ok = 1;
		}
		snprintf(fn, sizeof(fn), "%s/order_total.html", conf.htmldir);
		render_html(fn, render_order_totals, &grand_total);

	} else
		printf("render_order: unknown macro '%s'<br>\n", m);
}
Ejemplo n.º 8
0
int
render_html(const char *html_fn, render_cb r, void *arg)
{
	FILE *f;
	char s[8192];
	char fn[MAXPATHLEN];
	const char *s2;

	if ((f = fopen(html_fn, "r")) == NULL) {
		printf("ERROR: fopen: %s: %s<br>\n", html_fn, strerror(errno));
		return (1);
	}
	while (fgets(s, sizeof(s), f)) {
		char *a, *b;

		for (a = s; (b = strstr(a, "%%")) != NULL;) {
			*b = 0;
			printf("%s", a);
			a = b + 2;
			if ((b = strstr(a, "%%")) != NULL) {
				*b = 0;
				if (!strcmp(a, "ACTION")) {
					if ((s2 = get_query_param(q, "action")) == NULL)
						s2 = "front";
					printf("%s", s2);
				} else if (!strcmp(a, "BASEURL"))
					printf("%s", conf.baseurl);
				else if (!strcmp(a, "BASEDIR"))
					printf("%s", conf.htmldir);
				else if (!strcmp(a, "BASECSS")) {
					printf("%s?action=css%s", conf.baseurl,
							display_type == DISPLAY_PRINT ?
							"&amp;display=print" :
							display_type == DISPLAY_CSV ?
							"&amp;display=csv" : "");
				} else if (!strcmp(a, "TITLE"))
					printf("%s", conf.title);
				else if (!strcmp(a, "HEADER")) {
					snprintf(fn, sizeof(fn), "%s/header.html", conf.htmldir);
					render_html(fn, NULL, NULL);
				} else if (!strcmp(a, "FOOTER")) {
					snprintf(fn, sizeof(fn), "%s/footer.html", conf.htmldir);
					render_html(fn, NULL, NULL);
				} else if (!strcmp(a, "ROW")) {
					printf("row%d", rowselect);
					rowselect = !rowselect;
				} else if (!strcmp(a, "ROWRESET"))
					rowselect = 0;
				else if (!strcmp(a, "TIMESTART"))
					printf("%s", time_print(time_start));
				else if (!strcmp(a, "TIMESTOP"))
					printf("%s", time_print(time_stop));
				else if (!strcmp(a, "TIMENOW")) {
					char datetime[sizeof("9999-12-31T23:59:60+0000")];
					time_t now = time(NULL);
					strftime(datetime, sizeof(datetime), "%FT%T%z",
							localtime(&now));
					printf("%s", datetime);
				} else if (!strcmp(a, "TIMETODAY"))
					printf("%s", time_print(time_ext(TIME_TODAY)));
				else if (!strcmp(a, "TIMEYESTERDAY"))
					printf("%s", time_print(time_ext(TIME_YESTERDAY)));
				else if (!strcmp(a, "TIMETOMORROW"))
					printf("%s", time_print(time_ext(TIME_TOMORROW)));
				else if (!strcmp(a, "TIMETHISWEEK"))
					printf("%s", time_print(time_ext(TIME_THISWEEK)));
				else if (!strcmp(a, "TIMETHISMONTH"))
					printf("%s", time_print(time_ext(TIME_THISMONTH)));
				else if (!strcmp(a, "TIMETHISYEAR"))
					printf("%s", time_print(time_ext(TIME_THISYEAR)));
				else if (!strcmp(a, "TIMELASTWEEK"))
					printf("%s", time_print(time_ext(TIME_LASTWEEK)));
				else if (!strcmp(a, "TIMELASTMONTH"))
					printf("%s", time_print(time_ext(TIME_LASTMONTH)));
				else if (!strcmp(a, "TIMELASTYEAR"))
					printf("%s", time_print(time_ext(TIME_LASTYEAR)));
				else if (!strcmp(a, "QUERY"))
					printf("%s", q->query_string);
#if 0
				else if (!strcmp(a, "RCSID"))
					printf("%s", rcsid);
#endif
				else if (r != NULL)
					(*r)(a, arg);
				a = b + 2;
			}
		}
		printf("%s", a);
	}
	fclose(f);
	return 0;
}
Ejemplo n.º 9
0
void itemview_formaction::prepare() {
	/*
	 * whenever necessary, the item view is regenerated. This is done
	 * by putting together the feed name, title, link, author, optional
	 * flags and podcast download URL (enclosures) and then render the
	 * HTML. The links extracted by the renderer are then appended, too.
	 */
	if (do_redraw) {

		{
			scope_measure("itemview::prepare: rendering");
			f->run(-3); // XXX HACK: render once so that we get a proper widget width
		}

		std::vector<std::string> lines;
		std::string widthstr = f->get("article:w");
		unsigned int render_width = 80;
		unsigned int view_width = 0;
		if (widthstr.length() > 0) {
			view_width = render_width = utils::to_u(widthstr);
			if (render_width - 5 > 0)
				render_width -= 5;
		}

		std::shared_ptr<rss_item> item = feed->get_item_by_guid(guid);
		listformatter listfmt;

		std::shared_ptr<rss_feed> feedptr = item->get_feedptr();

		std::string title, feedtitle;
		if (feedptr.get() != NULL) {
			if (feedptr->title().length() > 0) {
				title = feedptr->title();
			} else if (feedptr->link().length() > 0) {
				title = feedptr->link();
			} else if (feedptr->rssurl().length() > 0) {
				title = feedptr->rssurl();
			}
		}
		if (title.length() > 0) {
			feedtitle = utils::strprintf("%s%s", _("Feed: "), title.c_str());
			listfmt.add_line(feedtitle, UINT_MAX, view_width);
		}

		if (item->title().length() > 0) {
			title = utils::strprintf("%s%s", _("Title: "), item->title().c_str());
			listfmt.add_line(title, UINT_MAX, view_width);
		}

		if (item->author().length() > 0) {
			std::string author = utils::strprintf("%s%s", _("Author: "), item->author().c_str());
			listfmt.add_line(author, UINT_MAX, view_width);
		}

		if (item->link().length() > 0) {
			std::string link = utils::strprintf("%s%s", _("Link: "), utils::censor_url(item->link()).c_str());
			listfmt.add_line(link, UINT_MAX, view_width);
		}

		std::string date = utils::strprintf("%s%s", _("Date: "), item->pubDate().c_str());
		listfmt.add_line(date, UINT_MAX, view_width);

		if (item->flags().length() > 0) {
			std::string flags = utils::strprintf("%s%s", _("Flags: "), item->flags().c_str());
			listfmt.add_line(flags, UINT_MAX, view_width);
		}

		if (item->enclosure_url().length() > 0) {
			std::string enc_url = utils::strprintf("%s%s", _("Podcast Download URL: "), utils::censor_url(item->enclosure_url()).c_str());
			if (item->enclosure_type() != "") {
				enc_url.append(utils::strprintf(" (%s%s)",  _("type: "), item->enclosure_type().c_str()));
			}
			listfmt.add_line(enc_url, UINT_MAX, view_width);
		}

		listfmt.add_line("");

		unsigned int unread_item_count = feed->unread_item_count();
		// we need to subtract because the current item isn't yet marked as read
		if (item->unread())
			unread_item_count--;
		set_head(item->title(), unread_item_count, feed->items().size());

		unsigned int textwidth = v->get_cfg()->get_configvalue_as_int("text-width");
		if (textwidth > 0) {
			render_width = textwidth;
		}

		if (show_source) {
			render_source(lines, utils::quote_for_stfl(item->description()), render_width);
		} else {
			std::string baseurl = item->get_base() != "" ? item->get_base() : item->feedurl();
			lines = render_html(item->description(), links, baseurl, render_width);
		}

		listfmt.add_lines(lines, view_width);

		num_lines = listfmt.get_lines_count();

		f->modify("article","replace_inner",listfmt.format_list(rxman, "article"));
		f->set("articleoffset","0");

		if (in_search) {
			rxman->remove_last_regex("article");
			in_search = false;
		}

		do_redraw = false;
	}

}
Ejemplo n.º 10
0
int
render_html(const char *html_fn, render_cb r, void *arg)
{
	FILE *f;
	char s[8192];
	char fn[MAXPATHLEN];
	tbstring sa = {0};

	if ((f = fopen(html_fn, "r")) == NULL) {
		printf("ERROR: fopen: %s: %s<br>\n", html_fn, strerror(errno));
		return (1);
	}
	while (fgets(s, sizeof(s), f)) {
		char *a, *b;

		for (a = s; (b = strstr(a, "%%")) != NULL;) {
			*b = 0;
			printf("%s", a);
			a = b + 2;
			if ((b = strstr(a, "%%")) != NULL) {
				*b = 0;
				if (!strcmp(a, "ACTION")) {
					if (action == NULL)
						action = "front";
					printf("%s", action);
				} else if (!strcmp(a, "BASEURL"))
					printf("%s", conf.baseurl);
				else if (!strcmp(a, "BASEDIR"))
					printf("%s", conf.htmldir);
				else if (!strcmp(a, "BASECSS")) {
					printf("%s?action=css%s", conf.baseurl,
							display_type == DISPLAY_PRINT ?
							"&amp;display=print" :
							display_type == DISPLAY_CSV ?
							"&amp;display=csv" : "");
				} else if (!strcmp(a, "TITLE"))
					printf("%s", conf.title);
				else if (!strcmp(a, "HEADER")) {
					snprintf(fn, sizeof(fn), "%s/header.html", conf.htmldir);
					render_html(fn, NULL, NULL);
				} else if (!strcmp(a, "FOOTER")) {
					snprintf(fn, sizeof(fn), "%s/footer.html", conf.htmldir);
					render_html(fn, NULL, NULL);
				} else if (!strcmp(a, "ROW")) {
					printf("row%d", rowselect);
					rowselect = !rowselect;
				} else if (!strcmp(a, "ROWRESET"))
					rowselect = 0;
				else if (!strcmp(a, "MENUCODE")) {
					printf("%s", html_esc(menucode, &sa, 0));
				} else if (!strcmp(a, "QUERY"))
					printf("%s", q->query_string);
#if 0
				else if (!strcmp(a, "RCSID"))
					printf("%s", rcsid);
#endif
				else if (r != NULL)
					(*r)(a, arg);
				a = b + 2;
			}
		}
		printf("%s", a);
	}
	fclose(f);
	tbstrfree(&sa);
	return 0;
}
Ejemplo n.º 11
0
int 
main(int argc, char *argv[])
{
	const char *s, *query_args;
	time_t if_modified_since = 0;
	int i;

	umask(007);
	load_default_config();
	if (parse_configfile(rssrollrc, config_cb) == -1) {
		render_error("error: cannot open config file: %s", rssrollrc);	
		goto done;
	}
	/*if (chdir("/tmp")) {
		printf("error main: chdir: /tmp: %s", strerror(errno));
		render_error("chdir: /tmp: %s", strerror(errno));
		goto done;
	} */

	if (sqlite3_open(rssroll->dbpath, &db) != SQLITE_OK) {
		render_error("cannot load database: %s", rssroll->dbpath);
		goto done;
	}

	// default feeds
	snprintf(query_category, sizeof(query_string), "%d", rssroll->defcat);
	snprintf(query_limit, sizeof(query_limit), "0");

	if ((q = get_query()) == NULL) {
		render_error("get_query");
		printf("error main: get_query() NULL");
		goto done;
	}
	if ((s = getenv("QUERY_STRING")) != NULL) {
		if (strlen(s) > 64) {
			printf("Status: 400\r\n\r\n You are trying to send very long query!\n");
			fflush(stdout);
			return (0);

		} else if (strstr(s, "&amp;") != NULL) {
			printf("warning main: escaped query '%s', user agent '%s', "
			    "referer '%s'", s,
			    q->user_agent ? q->user_agent : "(null)",
			    q->referer ? q->referer : "(null)");
			printf("Status: 400\r\n\r\nHTML escaped ampersand in cgi "
			    "query string \"%s\"\n"
			    "This might be a problem in your client \"%s\",\n"
			    "or in the referring document \"%s\"\n"
			    "See http://www.htmlhelp.org/tools/validator/problems.html"
			    "#amp\n", s, q->user_agent ? q->user_agent : "",
			    q->referer ? q->referer : "");
			fflush(stdout);
			return (0);
		} else {
			for (i = 0; i < strlen(s); i++) {
				/* 
					sanity check of the query string, accepts only alpha
				*/
                        	if (!isdigit(s[i])) {
					if(s[i] != '/') {
                                		printf("Status: 400\r\n\r\nYou are trying to send wrong query!\n");
	                                	fflush(stdout);
        	                        	return (0);
					}
                	        }
                	}
			snprintf(query_string, sizeof(query_string), "%s", s);
			query_args = strtok(query_string, "/");
			snprintf(query_category, sizeof(query_category), "%s", query_args);
			query_args = strtok(NULL, "/");
			if (query_args != NULL)
				snprintf(query_limit, sizeof(query_limit), "%s", query_args);
		}	
	}

	if ((q->referer != NULL && strstr(q->referer, "morisit")) ||
	    (s != NULL && strstr(s, "http://"))) {
		printf("Status: 503\r\n\r\nWe are not redirecting, "
		    "nice try.\n");
		fflush(stdout);
		return (0);
	}
	if (q->user_agent != NULL && !strncmp(q->user_agent, "Googlebot", 9)) {
		printf("Status: 503\r\n\r\nGooglebot you are not.\n");
		fflush(stdout);
		return (0);
	}
	
	if ((s = getenv("IF_MODIFIED_SINCE")) != NULL) {
		if_modified_since = convert_rfc822_time(s);
		if (!if_modified_since)
			if_modified_since =
			    (time_t)strtoul(s, NULL, 10);
		if (!if_modified_since)
			printf("warning main: invalid IF_MODIFIED_SINCE '%s'", s);
	}
	if ((s = getenv("HTTP_ACCEPT_ENCODING")) != NULL) {
		char *p = strstr(s, "gzip");

		if (p != NULL && (strncmp(p, "gzip;q=0", 8) ||
		    atoi(p + 7) > 0.0)) {
			gz = gzdopen(fileno(stdout), "wb9");
			if (gz == NULL)
				printf("error main: gzdopen");
			else
				printf("Content-Encoding: gzip\r\n");
		}
	}

	char fn[1024];
	
	printf("%s\r\n\r\n", rssroll->ct_html);
	fflush(stdout);
	snprintf(fn, sizeof(fn), "%s/main.html", rssroll->htmldir);
	render_html(fn, &render_front, NULL);

done:
	if (gz != NULL) {
		if (gzclose(gz) != Z_OK)
			printf("error main: gzclose");
		gz = NULL;
	} else
		fflush(stdout);
	if (q != NULL)
		free_query(q);

	sqlite3_close(db);
	return (0);
}
Ejemplo n.º 12
0
void
render_order_list(const char *m, void *arg)
{
	ChopstixOrder *order = (ChopstixOrder *)arg;
	char fn[1024];
	unsigned int u, s;
	tbstring sa = {0};
	tbstring sa2 = {0};

	if (!strcmp(m, "ORDERCODE"))
		printf("%d", order->key);

	else if (!strcmp(m, "ORDERCODEEDIT"))
		printf("<a href=\"%s?action=orderdetail&amp;code=%d\">%d</a>",
				conf.baseurl, order->key, order->key);

	else if (!strcmp(m, "ORDERDATETIME")) {
		char datetime[sizeof("YYYY-MM-DD HH:MM:SS")];
		strftime(datetime, sizeof(datetime), "%F %T",
				localtime(&order->date));
		printf("%s", datetime);

	} else if (!strcmp(m, "ORDERTYPE")) {
		switch (order->type) {
			case ORDER_NONE:
				printf("NONE");
				break;
			case ORDER_PICKUP:
				printf("PICKUP");
				break;
			case ORDER_DELIVERY:
				printf("DELIVERY");
				break;
			case ORDER_WALKIN:
				printf("WALKIN");
				break;
			case ORDER_VOID:
				printf("VOID");
				break;
		}

	} else if (!strcmp(m, "ORDERPAYTYPE")) {
		switch (order->payment.type) {
			case PAYMENT_NONE:
				printf("NONE");
				break;
			case PAYMENT_CASH:
				printf("CASH");
				break;
			case PAYMENT_CREDIT:
				printf("CREDIT");
				break;
			case PAYMENT_VOID:
				printf("VOID");
				break;
			case PAYMENT_DEBIT:
				printf("DEBIT");
				break;
			case PAYMENT_CHEQUE:
				printf("CHEQUE");
				break;
			case PAYMENT_OTHER:
				printf("OTHER");
				break;
		}

	} else if (!strcmp(m, "ORDERPAYDETAIL")) {
		switch (order->payment.type) {
			case PAYMENT_NONE:
				printf("NONE");
				break;
			case PAYMENT_CASH:
				printf("CASH");
				break;
			case PAYMENT_CREDIT:
				if (order->payment.ccinfo)
					printf("CREDIT - CC# %s EXP %s",
							html_esc(order->payment.ccinfo->number, &sa, 0),
							html_esc(order->payment.ccinfo->expiry, &sa2, 0));
				else
					printf("CREDIT - (INFO PURGED)");
				break;
			case PAYMENT_VOID:
				printf("VOID");
				break;
			case PAYMENT_DEBIT:
				printf("DEBIT");
				break;
			case PAYMENT_CHEQUE:
				printf("CHEQUE");
				break;
			case PAYMENT_OTHER:
				printf("OTHER");
				break;
		}

	} else if (!strcmp(m, "ORDERSPECIAL"))
		printf("%s", strlen(order->special)
				? html_esc(order->special, &sa, 0) : "&nbsp;");
	else if (!strcmp(m, "ORDERSUBTOTAL"))
		PRINTF_MONEY(order->total.subtotal);
	else if (!strcmp(m, "ORDERDISCOUNT"))
		PRINTF_MONEY(order->total.discount);
	else if (!strcmp(m, "ORDERDELIVERY"))
		PRINTF_MONEY(order->total.delivery);
	else if (!strcmp(m, "ORDERCREDIT"))
		PRINTF_MONEY(order->total.credit);
	else if (!strcmp(m, "ORDERTAX1"))
		PRINTF_MONEY(order->total.tax1);
	else if (!strcmp(m, "ORDERTAX2"))
		PRINTF_MONEY(order->total.tax2);
	else if (!strcmp(m, "ORDERTOTAL"))
		PRINTF_MONEY(order->total.total);
	else if (!strncmp(m, "CUST", 4))
		render_customer_info(m, &order->customer);
	else if (!strcmp(m, "ORDERITEMS")) {
		snprintf(fn, sizeof(fn), "%s/order_item.html", conf.htmldir);
		for (u = 0; u < order->items.len; u++) {
			render_html(fn, render_order_item, &order->items.val[u]);
			if (order->items.val[u].subitems)
				for (s = 0; s < order->items.val[u].subitems->len; s++)
					render_html(fn, render_order_subitem,
							&order->items.val[u].subitems->val[s]);
		}
	} else if (!strcmp(m, "ORDERRULEITEMS")) {
		snprintf(fn, sizeof(fn), "%s/order_item.html", conf.htmldir);
		for (u = 0; u < order->ruleitems.len; u++)
			render_html(fn, render_order_item, &order->ruleitems.val[u]);
	} else
		printf("render_order_list: unknown macro '%s'<br>\n", m);

	tbstrfree(&sa);
	tbstrfree(&sa2);
}
Ejemplo n.º 13
0
static void profile_show_html(lua_State *L) {
    Meta **array = get_metadata_array(L);
    render_html(L, array, STACK_INDEX - 1);
}