81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
static int sideboxUsed = 0;
/*
** Ad-unit styles.
*/
static unsigned adUnitFlags = 0;
/*
** Generate and return a anchor tag like this:
**
** <a href="URL">
** or <a id="ID">
**
|
>
>
>
>
>
|
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
static int sideboxUsed = 0;
/*
** Ad-unit styles.
*/
static unsigned adUnitFlags = 0;
/*
** True if the "href.js" javascript file is required.
*/
static int needHrefJs = 0;
/*
** Generate and return a anchor tag like this:
**
** <a href="URL">
** or <a id="ID">
**
|
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
185
186
187
188
189
190
191
192
193
194
195
|
zUrl = vmprintf(zFormat, ap);
va_end(ap);
if( g.perm.Hyperlink && !g.javascriptHyperlink ){
char *zHUrl = mprintf("<a %s href=\"%h\">", zExtra, zUrl);
fossil_free(zUrl);
return zHUrl;
}
return mprintf("<a %s data-href='%z' href='%R/honeypot'>",
zExtra, zUrl);
}
char *chref(const char *zExtra, const char *zFormat, ...){
char *zUrl;
va_list ap;
va_start(ap, zFormat);
zUrl = vmprintf(zFormat, ap);
va_end(ap);
if( g.perm.Hyperlink && !g.javascriptHyperlink ){
char *zHUrl = mprintf("<a %s href=\"%h\">", zExtra, zUrl);
fossil_free(zUrl);
return zHUrl;
}
return mprintf("<a class='%s' data-href='%z' href='%R/honeypot'>",
zExtra, zUrl);
}
char *href(const char *zFormat, ...){
char *zUrl;
va_list ap;
va_start(ap, zFormat);
zUrl = vmprintf(zFormat, ap);
va_end(ap);
if( g.perm.Hyperlink && !g.javascriptHyperlink ){
char *zHUrl = mprintf("<a href=\"%h\">", zUrl);
fossil_free(zUrl);
return zHUrl;
}
return mprintf("<a data-href='%s' href='%R/honeypot'>",
zUrl);
}
/*
** Generate <form method="post" action=ARG>. The ARG value is inserted
** by javascript.
*/
void form_begin(const char *zOtherArgs, const char *zAction, ...){
char *zLink;
va_list ap;
if( zOtherArgs==0 ) zOtherArgs = "";
va_start(ap, zAction);
zLink = vmprintf(zAction, ap);
va_end(ap);
if( g.perm.Hyperlink && !g.javascriptHyperlink ){
@ <form method="POST" action="%z(zLink)" %s(zOtherArgs)>
}else{
@ <form method="POST" data-action='%s(zLink)' action='%R/login' \
@ %s(zOtherArgs)>
}
}
/*
** Add a new element to the submenu
|
>
>
>
>
|
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
zUrl = vmprintf(zFormat, ap);
va_end(ap);
if( g.perm.Hyperlink && !g.javascriptHyperlink ){
char *zHUrl = mprintf("<a %s href=\"%h\">", zExtra, zUrl);
fossil_free(zUrl);
return zHUrl;
}
needHrefJs = 1;
return mprintf("<a %s data-href='%z' href='%R/honeypot'>",
zExtra, zUrl);
}
char *chref(const char *zExtra, const char *zFormat, ...){
char *zUrl;
va_list ap;
va_start(ap, zFormat);
zUrl = vmprintf(zFormat, ap);
va_end(ap);
if( g.perm.Hyperlink && !g.javascriptHyperlink ){
char *zHUrl = mprintf("<a %s href=\"%h\">", zExtra, zUrl);
fossil_free(zUrl);
return zHUrl;
}
needHrefJs = 1;
return mprintf("<a class='%s' data-href='%z' href='%R/honeypot'>",
zExtra, zUrl);
}
char *href(const char *zFormat, ...){
char *zUrl;
va_list ap;
va_start(ap, zFormat);
zUrl = vmprintf(zFormat, ap);
va_end(ap);
if( g.perm.Hyperlink && !g.javascriptHyperlink ){
char *zHUrl = mprintf("<a href=\"%h\">", zUrl);
fossil_free(zUrl);
return zHUrl;
}
needHrefJs = 1;
return mprintf("<a data-href='%s' href='%R/honeypot'>",
zUrl);
}
/*
** Generate <form method="post" action=ARG>. The ARG value is inserted
** by javascript.
*/
void form_begin(const char *zOtherArgs, const char *zAction, ...){
char *zLink;
va_list ap;
if( zOtherArgs==0 ) zOtherArgs = "";
va_start(ap, zAction);
zLink = vmprintf(zAction, ap);
va_end(ap);
if( g.perm.Hyperlink && !g.javascriptHyperlink ){
@ <form method="POST" action="%z(zLink)" %s(zOtherArgs)>
}else{
needHrefJs = 1;
@ <form method="POST" data-action='%s(zLink)' action='%R/login' \
@ %s(zOtherArgs)>
}
}
/*
** Add a new element to the submenu
|
501
502
503
504
505
506
507
508
509
510
511
512
513
514
|
*pAdFlag = ADUNIT_RIGHT_OK;
return zAd;
}else if( !fossil_all_whitespace(zAd = db_get("adunit",0)) ){
return zAd;
}
return 0;
}
/*
** Draw the footer at the bottom of the page.
*/
void style_footer(void){
const char *zFooter;
const char *zAd = 0;
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
|
*pAdFlag = ADUNIT_RIGHT_OK;
return zAd;
}else if( !fossil_all_whitespace(zAd = db_get("adunit",0)) ){
return zAd;
}
return 0;
}
/*
** Generate code to load a single javascript file
*/
static void style_load_one_js_file(const char *zFile){
@ <script src='%R/builtin/%s(zFile)/%S(MANIFEST_UUID)'></script>
}
/*
** Generate code to load all required javascript files.
*/
static void style_load_all_js_files(void){
if( needHrefJs ){
int nDelay = db_get_int("auto-hyperlink-delay",0);
int bMouseover;
/* Load up the page data */
bMouseover = (!g.isHuman || db_get_boolean("auto-hyperlink-ishuman",0))
&& db_get_boolean("auto-hyperlink-mouseover",0);
@ <script id='href-data' type='application/json'>\
@ {"delay":%d(nDelay),"mouseover":%d(bMouseover)}</script>
style_load_one_js_file("href.js");
}
}
/*
** Draw the footer at the bottom of the page.
*/
void style_footer(void){
const char *zFooter;
const char *zAd = 0;
|
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
|
** the additional clear/both is needed to extend the content
** part to the end of an optional sidebox.
*/
@ <div class="endContent"></div>
}
@ </div>
/* Load up the page data */
@ <script id='page-data' type='application/json'>
if( !g.javascriptHyperlink ){
@ {"antibot":{"enable":0},
}else{
int nDelay = db_get_int("auto-hyperlink-delay",0);
int bMouseover;
bMouseover = (!g.isHuman || db_get_boolean("auto-hyperlink-ishuman",0))
&& db_get_boolean("auto-hyperlink-mouseover",0);
@ {"antibot":
@ {"enable":1,
@ "delay":%d(nDelay),
@ "mouseover":%d(bMouseover)},
}
@ "noop":0}
@ </script>
zFooter = skin_get("footer");
if( sqlite3_strlike("%</body>%", zFooter, 0)==0 ){
@ <script src='%s(g.zBaseURL)/main.js/%S(MANIFEST_UUID)' \
@ type='application/javascript'></script>
}
if( g.thTrace ) Th_Trace("BEGIN_FOOTER<br />\n", -1);
Th_Render(zFooter);
if( g.thTrace ) Th_Trace("END_FOOTER<br />\n", -1);
/* Render trace log if TH1 tracing is enabled. */
if( g.thTrace ){
cgi_append_content("<span class=\"thTrace\"><hr />\n", -1);
cgi_append_content(blob_str(&g.thLog), blob_size(&g.thLog));
cgi_append_content("</span>\n", -1);
}
/* Add document end mark if it was not in the footer */
if( sqlite3_strlike("%</body>%", zFooter, 0)!=0 ){
@ <script src='%s(g.zBaseURL)/main.js/%S(MANIFEST_UUID)' \
@ type='application/javascript'></script>
@ </body>
@ </html>
}
}
/*
** Begin a side-box on the right-hand side of a page. The title and
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
|
<
|
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
|
** the additional clear/both is needed to extend the content
** part to the end of an optional sidebox.
*/
@ <div class="endContent"></div>
}
@ </div>
zFooter = skin_get("footer");
if( sqlite3_strlike("%</body>%", zFooter, 0)==0 ){
style_load_all_js_files();
}
if( g.thTrace ) Th_Trace("BEGIN_FOOTER<br />\n", -1);
Th_Render(zFooter);
if( g.thTrace ) Th_Trace("END_FOOTER<br />\n", -1);
/* Render trace log if TH1 tracing is enabled. */
if( g.thTrace ){
cgi_append_content("<span class=\"thTrace\"><hr />\n", -1);
cgi_append_content(blob_str(&g.thLog), blob_size(&g.thLog));
cgi_append_content("</span>\n", -1);
}
/* Add document end mark if it was not in the footer */
if( sqlite3_strlike("%</body>%", zFooter, 0)!=0 ){
style_load_all_js_files();
@ </body>
@ </html>
}
}
/*
** Begin a side-box on the right-hand side of a page. The title and
|
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
|
Th_Render(blob_str(&css));
/* Tell CGI that the content returned by this page is considered cacheable */
g.isConst = 1;
}
/*
** WEBPAGE: main.js
**
** Return the javascript
*/
void page_main_js(void){
Blob mainjs;
cgi_set_content_type("application/javascript");
blob_init(&mainjs, builtin_text("main.js"), -1);
cgi_set_content(&mainjs);
g.isConst = 1;
}
/*
** WEBPAGE: test_env
**
|
|
>
|
>
>
>
>
>
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
|
|
|
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
|
Th_Render(blob_str(&css));
/* Tell CGI that the content returned by this page is considered cacheable */
g.isConst = 1;
}
/*
** WEBPAGE: builtin
** URL: builtin/FILENAME/VERSION
**
** Return the built-in text given by FILENAME. This is used internally
** by many Fossil web pages to load built-in javascript files.
**
** The VERSION string at the end is ignored. Fossil web pages will
** typically put the current Fossil check-in hash as VERSION, to cause
** javascript files to be reloaded rather than sourcing a stale javascript
** file from cache.
*/
void page_builtin_text(void){
Blob out;
const char *zName = P("name");
const char *zTxt = 0;
if( zName ){
int i;
for(i=0; zName[i]; i++){
if( zName[i]=='/' ){
zName = mprintf("%.*s", i, zName);
break;
}
}
zTxt = builtin_text(zName);
}
if( zTxt==0 ){
cgi_set_status(404, "Not Found");
@ File \"%h(zName)\" not found
return;
}
if( sqlite3_strglob("*.js", zName)==0 ){
cgi_set_content_type("application/javascript");
}else{
cgi_set_content_type("text/plain");
}
blob_init(&out, zTxt, -1);
cgi_set_content(&out);
g.isConst = 1;
}
/*
** WEBPAGE: test_env
**
|