Beispiel #1
0
void FreeReclameWidget::paint(WebPage *page, String tag) {
	WebTemplate *tpl = new WebTemplate();
	if (!tpl->open(page->site->manager->widgetPath + "/freeReclameWidget/tpl.html")) return;
	tpl->exec();

	page->out(tag, tpl->html);
}
Beispiel #2
0
void UserModule::paintSignup(WebPage *page, HttpRequest &request) {
	WebTemplate * tpl = new WebTemplate();
	String userTpl = "signup_tpl.html";
	if (tpl->open(manager->modulePath + "/user/" + userTpl)) {
		tpl->exec();
		page->out("content", tpl->html);
	}
}
Beispiel #3
0
void NewsModule::paintAddNews(WebPage *page, HttpRequest &request) {
	WebTemplate *tpl = new WebTemplate();
	if (tpl->open(manager->modulePath + "/" + url + "/addPost_tpl.html")) {
	}

	tpl->exec();
	page->out("content", tpl->html);
}
Beispiel #4
0
void UserModule::paintAbout(WebPage *page, HttpRequest &request) {
	WebTemplate *tpl = new WebTemplate();
	String userTpl = "user_tpl.html";

	String uuid = request.header.COOKIE.getValue("uuid");
	String login = page->site->manager->getLogin(uuid);
	if (login == "") userTpl = "userNoEnter_tpl.html";

	String tplPath = manager->modulePath + "/user/" + userTpl;
	if (tpl->open(tplPath)) {
		tpl->out("email", login);
		tpl->out("money", "0");
		tpl->exec();
		page->out("content", tpl->html);
	}
}
Beispiel #5
0
void UserModule::activate(WebPage *page, HttpRequest &request) {
	MySQL *query = manager->newQuery();
	String p3 = request.header.GET.getValue("p3");
	String sql = "update users set active = '1', password=newPassword where uuid = '" + p3 + "'";
	WebTemplate * tpl = new WebTemplate();
	String activateTpl = "";
	if (query->exec(sql)) {
		activateTpl = "activateSuccess_tpl.html";
	}
	else {
		activateTpl = "activateFail_tpl.html";
	}
	if (tpl->open(manager->modulePath + "/user/" + activateTpl)) {
		tpl->exec();
		page->out("content", tpl->html);
	}
	manager->deleteQuery(query);
}
Beispiel #6
0
void NewsModule::paintTags(WebPage *page, String num, WebTemplate *tpl) {
	WebTemplate *tplTag = new WebTemplate();
	if (tplTag->open(manager->modulePath + "/" + url + "/tag_tpl.html")) {
		MySQL *query = manager->newQuery();
		String sql = "select tag1, tag2, tag3, tag4, tag5 from dataNews n, data d where d.dataId=n.id and d.pageId='" + (String)page->pageId + "' and d.moduleId='" +
			(String)moduleId + "' and n.num='" + num + "' order by n.num desc";
		if (query->exec(sql)) {
			if (query->storeResult()) {
				int count = query->getRowCount();
				if (count > 0) {
					for (int i = 1; i <= 5; i++) {
						String tag = query->getFieldValue(0, "tag" + (String)i);

						if (tag != "") {
							tplTag->out("name", tag);
							tplTag->exec();
							tpl->out("tags", tplTag->html);
						}
					}
				}
			}
		}
	}
}
Beispiel #7
0
void UserModule::reset(WebPage *page, HttpRequest &request) {
	MySQL *query = manager->newQuery();
	String guid = generateUUID();
	String email = request.header.POST.getValue("email");
	if (email != "") {
		String password = manager->generateUserPassword();
		String sql = "select * from users where email='" + email + "'";
		if (query->exec(sql)) {
			if (query->storeResult()) {
				int count = query->getRowCount();
				if (count > 0) {
					guid = query->getFieldValue(0, "uuid");
					sql = "update users set newPassword='******', uuid='" + guid + "' where email='" + email + "'";
					if (query->exec(sql)) {}
				}
				else {
					sql = "insert into users (email, newPassword, uuid) values('" + email + "', '" + password + "', '" + guid + "')";
					if (query->exec(sql)) {}
				}
			}
		}
		WebTemplate * tplEmail = new WebTemplate();
		String userTpl = "email_tpl.html";
		if (tplEmail->open(manager->modulePath + "/user/" + userTpl)) {
			tplEmail->out("host", page->site->host);
			tplEmail->out("email", email);
			tplEmail->out("password", password);
			tplEmail->out("guid", guid);
			tplEmail->exec();
			sendMail(email, "no-reply@" + page->site->host, page->site->host + ": подтверждение аккаунта", tplEmail->html);
		}

		WebTemplate * tpl = new WebTemplate();
		if (tpl->open(manager->modulePath + "/user/loginSendAccount_tpl.html")) {
			tpl->out("out", email);
			tpl->exec();
			page->out("content", tpl->html);
		}
	}
	manager->deleteQuery(query);
}
Beispiel #8
0
void UserModule::changePassword(WebPage *page, HttpRequest &request) {
	MySQL *query = manager->newQuery();
	String uuid = request.header.COOKIE.getValue("uuid");
	int userId = manager->getUserId(uuid);

	WebTemplate * tpl = new WebTemplate();
	String p3 = request.header.GET.getValue("p3");
	if (p3 == "") {
		if (userId != 0) {
			if (tpl->open(manager->modulePath + "/2/changePassword_tpl.html")) {
				tpl->exec();
				page->out("out", tpl->html);
			}
		}
		else {
			if (tpl->open(manager->documentRoot + "/tpl/message_tpl.html")) {
				tpl->out("caption", "����� ������");
				tpl->out("error", "��� ����� ������ ������� �� ���� ��� ����� ������� � ������ �������");
				tpl->exec();
				page->out("out", tpl->html);
			}
		}
	}
	else if (p3 == "done") {
		if (tpl->open(manager->documentRoot + "/tpl/message_tpl.html")) {
			tpl->out("caption", "����� ������");

			String message, error;

			if (userId != 0) {
				String oldPassword = request.header.POST.getValue("oldPassword");
				String sql = "select * from users where id='" + (String)userId + "' and password='******'";
				if (query->exec(sql)) {
					if (query->storeResult()) {
						int count = query->getRowCount();
						if (count > 0) {
							String newPassword = request.header.POST.getValue("newPassword");
							String repeatPassword = request.header.POST.getValue("repeatPassword");
							error = manager->isPasswordCorrect(newPassword);
							if (error == "") {
								if (newPassword == repeatPassword) {
									String sql = "update users set password='******' where id='" + userId + "'";
									if (query->exec(sql)) {
										message = "������ ��� ������� ������!";
									}
									else {
										error = "������ ���� ������";
									}
								}
								else error = "������ �� ���������";
							}
						}
						else error = "������ ������ ����� �� ���������";
					}
				}
			}
			else {
				error = "��� ����� ������ ������� �� ���� ��� ����� ������� � ������ �������";
			}
			tpl->out("message", message);
			tpl->out("error", error);
			tpl->exec();
			page->out("out", tpl->html);
		}
	}
}
Beispiel #9
0
void NewsModule::paintNewsItemView(WebPage *page, HttpRequest &request, String num) {
	MySQL *query = manager->newQuery();
	String uuid = request.header.COOKIE.getValue("uuid");
	int userId = manager->getUserId(uuid);

	String sql = "select dt, name, about, text, n.num, n.id newsId from dataNews n, data d where d.dataId=n.id and d.pageId='" + (String)page->pageId + "' and d.moduleId='" +
		(String)moduleId + "' and n.num='" + num + "' order by n.num desc";
	if (query->exec(sql)) {
		if (query->storeResult()) {
			int count = query->getRowCount();
			if (count > 0) {
				WebTemplate * tpl = new WebTemplate();
				if (tpl->open(manager->modulePath + "/" + url + "/view_tpl.html")) {
					String dt = query->getFieldValue(0, "dt");
					dt = dtRus(dt, 0);
					String name = query->getFieldValue(0, "name");
					String about = query->getFieldValue(0, "about");
					String text = query->getFieldValue(0, "text");
					//String num = query->getFieldValue(0, "num");
					int newsId = query->getFieldValue(0, "newsId").toInt();

					tpl->out("dt", dt);
					tpl->out("name", name);
					tpl->out("text", text);
					tpl->out("num", num);
					tpl->out("itemId", newsId);

					paintTags(page, num, tpl);

					sql = "select c.dt, c.comment, u.login from comments c, users u where u.id=c.userId and newsId='" + (String)newsId + "' order by c.id";
					if (query->exec(sql)) {
						if (query->storeResult()) {
							int count = query->getRowCount();
							for (int i = 0; i < count; i++) {
								String dt = query->getFieldValue(i, "dt");
								String comment = query->getFieldValue(i, "comment");
								String login = query->getFieldValue(i, "login");
								WebTemplate * tplCommentItem = new WebTemplate();
								if (tplCommentItem->open(manager->modulePath + "/" + url + "/commentItem_tpl.html")) {
									tplCommentItem->out("login", login);
									tplCommentItem->out("dt", dt);
									tplCommentItem->out("comment", comment);
									tplCommentItem->exec();
									tpl->out("comments", tplCommentItem->html);
								}

							}
						}
					}
					WebTemplate * tplSendComment = new WebTemplate();
					if (userId != 0) {
						if (tplSendComment->open(manager->modulePath + "/" + url + "/sendComment_tpl.html")) {
							tplSendComment->out("newsId", newsId);
						}
					}
					else {
						if (tplSendComment->open(manager->modulePath + "/" + url + "/sendCommentNotEnter_tpl.html")) {
							tplSendComment->out("newsId", newsId);
						}
					}
					tplSendComment->exec();
					tpl->out("sendComment", tplSendComment->html);
					tpl->exec();

					page->out("title", name);
					page->out("keywords", name);
					page->out("description", name);
					page->out("content", tpl->html);
				}
			}
		}
	}
}
Beispiel #10
0
void NewsModule::paintNews(WebPage *page, HttpRequest &request) {
	WebTemplate *tpl = new WebTemplate();
	if (!tpl->open(manager->modulePath + "/" + url + "/index_tpl.html")) return;

	WebTemplate *tplItem = new WebTemplate();
	if (!tplItem->open(manager->modulePath + "/" + url + "/item_tpl.html")) return;

	WebTemplate *tplLast = new WebTemplate();
	if (!tplLast->open(manager->modulePath + "/" + url + "/itemLast_tpl.html")) return;

	WebTemplate *tplTag = new WebTemplate();
	if (!tplTag->open(manager->modulePath + "/" + url + "/tag_tpl.html")) return;

	MySQL *query = manager->newQuery();

	String sql = "select count(*) cnt from dataNews n, data d where not isnull(num) and d.dataId=n.id and d.pageId='" + (String)page->pageId + "' and d.moduleId='" + (String)moduleId + "' order by dt desc";
	int newsCount = 0;
	if (query->active(sql) > 0) {
		newsCount = query->getFieldValue(0, "cnt").toInt();
	}

	int p = request.header.GET.getValue("p").toInt();
	sql = "select * from dataNews n, data d where not isnull(num) and d.dataId=n.id and d.pageId='" + (String)page->pageId + "' and d.moduleId='" + (String)moduleId + 
		"' order by dt desc limit " + (String)(p * 10) + ", 10";
	if (query->exec(sql)) {
		if (query->storeResult()) {
			int count = query->getRowCount();
			for (int i = 0; i < count; i++) {
				String id = query->getFieldValue(i, "id");
				String dt = query->getFieldValue(i, "dt");
				dt = dtRus(dt, 0);
				String name = query->getFieldValue(i, "name");
				String about = query->getFieldValue(i, "about");
				String text = query->getFieldValue(i, "text");
				int num = query->getFieldValue(i, "num").toInt();

				String tag1 = query->getFieldValue(i, "tag1");
				String tag2 = query->getFieldValue(i, "tag2");
				String tag3 = query->getFieldValue(i, "tag3");
				String tag4 = query->getFieldValue(i, "tag4");
				String tag5 = query->getFieldValue(i, "tag5");

				WebTemplate *tpli = tplItem;
				if (i + 1 == count) tpli = tplLast;
				tpli->clearAllTags();

				tpli->out("page", page->page);
				tpli->out("num", num);
				tpli->out("itemId", id);
				tpli->out("dt", dt);
				tpli->out("name", name);
				tpli->out("about", about);
				tpli->out("text", text);
				tpli->out("host", page->site->host);

				tplTag->clearAllTags();
				tplTag->out("tag1", tag1);
				tplTag->out("tag2", tag2);
				tplTag->out("tag3", tag3);
				tplTag->out("tag4", tag4);
				tplTag->out("tag5", tag5);
				tplTag->exec();

				tpli->out("tags", tplTag->html);
				tpli->exec();

				tpl->out("out", tpli->html);
			}
		}
	}

	if (newsCount != 0) {
		WebTemplate *tplPag = new WebTemplate();
		if (!tplPag->open(manager->modulePath + "/" + url + "/pagination_tpl.html")) return;

		int pageCount = newsCount / 10;
		if (newsCount % 10 != 0) pageCount++;
		for (int i = 0; i < pageCount; i++) {
			if (i == 0)	tplPag->out("out", "<li><a href=\"/\">" + (String)(i + 1) + "</a></li>");
			else tplPag->out("out", "<li><a href=\"/post?p=" + (String)i + "\">" + (String)(i + 1) + "</a></li>");

			if (i + 1 == pageCount) tplPag->out("next", "/post?p=" + (String)i);
		}
		tplPag->exec();
		tpl->out("out", tplPag->html);
	}

	String uuid = request.header.COOKIE.getValue("uuid");
	int userId = manager->getUserId(uuid);

	WebTemplate *tplWrite = new WebTemplate();
	if (userId != 0) {
		if (!tplWrite->open(manager->modulePath + "/" + url + "/addPostButton_tpl.html")) return;
	}
	else {
		if (!tplWrite->open(manager->modulePath + "/" + url + "/addPostButtonNotEnter_tpl.html")) return;
	}

	tplWrite->exec();
	tpl->out("out", tplWrite->html);


	tpl->out("caption", caption);
	tpl->exec();
	page->out("content", tpl->html);
}
Beispiel #11
0
void WebStudioModule::paintIndex(WebPage *page, HttpRequest &request) {
	WebTemplate *tpl = new WebTemplate();
	if (!tpl->open(manager->modulePath + "/webstudio/tpl.html")) return;
	tpl->exec();
	page->out("content", tpl->html);
}