summaryrefslogtreecommitdiff
path: root/microbbs.c
blob: 7670ddd54b138cd6a8437c3c619dbb1615358ac6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#include <stdio.h>
#include <stdlib.h>

#include "kconfig.h"
#include "logs.h"
#include "motd.h"
#include "libterm/term.h"

#include "ini.h"

int main( int argc, char **argv )
{
	int ret_len;

	size_t str_size=128;
	char *str=malloc(str_size);

	term_screen ts;
	term_init( &ts );
	term_clr_scr( &ts );

	//lunch captcha and try to detect if its random bot
#ifdef CONFIG_CAPTCHA
	if ( captcha_test1() != 1)
		return 1;
	bbs_log_captcha( NULL );
#endif

	//write to log that some user have accesed bbs
	//too much fake stuff comes to log
	bbs_log_main( NULL ); //write to default place
#ifdef CONFIG_MOTD
	bbs_login_motd( NULL, "art/motd.txt" );
	print_build_info();
#endif

	while ( strncmp( str, "q", 1 ) && strncmp( str, "Q", 1 ) )
	{
	#ifdef CONFIG_MOTD
		printf("(M)otd ");
	#endif

	#ifdef CONFIG_ARTICLES
		printf("(A)rticles ");
	#endif

	#ifdef CONFIG_DOORGAMES
		printf("(D)oor games ");
	#endif

	#ifdef CONFIG_TWIT
		printf("(T)wit ");
	#endif

	#ifdef CONFIG_BOARD
		printf("(B)oard ");
	#endif

	#ifdef CONFIG_LOGIN
		printf("(L)ogin ");
	#endif

	#ifdef CONFIG_TODO
		printf("T(o)do ");
	#endif

	#ifdef CONFIG_MESSAGING
		printf("Mesa(G)es ");
	#endif

		printf("(Q)uit (S)ysinfo: ");
		ret_len = getline( &str, &str_size, stdin );
		if ( ret_len > 0)
		{
			switch ( str[0] )
			{
			//------------------------------------------------------------------
			#ifdef CONFIG_MOTD
				case 'm':
				case 'M':
					{
						bbs_login_motd( &ts, "art/motd.txt" );
					}
					break;
			#endif

			//------------------------------------------------------------------
				case 's':
				case 'S':
					{
						bbs_sysinfo( &ts );
					}
					break;

			//------------------------------------------------------------------
			#ifdef CONFIG_ARTICLES
				case 'a':
				case 'A':
					{
						bbs_article_list( &ts, "./article/" );
					}
					break;
			#endif

			//------------------------------------------------------------------
			#ifdef CONFIG_TWIT		
				case 't':
				case 'T':
					{
						printf("Twitter like\n");
					}
					break;
			#endif

			//------------------------------------------------------------------
			#ifdef CONFIG_DOORGAMES
				case 'd':
				case 'D':
					{
						printf("Door games\n");
					}
					break;
			#endif

			//------------------------------------------------------------------
			#ifndef CONFIG_MESSAGING
				case 'g':
				case 'G':
					{
						printf("Messages\n");
					}
					break;
			#endif

			//------------------------------------------------------------------
			#ifdef CONFIG_BOARD
				case 'b':
				case 'B':
					{
						printf("Board\n");
					}
					break;
			#endif


			//------------------------------------------------------------------
			#ifdef CONFIG_LOGIN
				case 'l':
				case 'L':
					{
						printf("Login?\n");
					}
					break;
			#endif

			//------------------------------------------------------------------
			#ifdef CONFIG_TODO
				case 'o':
				case 'O':
					{
						printf("Todo list\n");
						bbs_todo( &ts, NULL );
					}
					break;
			#endif

			//------------------------------------------------------------------
				case 'q':
				case 'Q':
					bbs_log_quit( NULL );
					break;
				default:
					printf("Unknow command\n");
			}
		}
	}
#ifdef CONFIG_MOTD
	bbs_quit_motd( &ts, "art/quit.txt" );
#endif

	term_clr_scr( &ts );
	term_set_orig_mode( &ts );
	return 0;
}