gaim/www
Clone
Summary
Browse
Changes
Graph
Initial import into CVS
chipx86
start
2002-09-26, Christian Hammond
2b210e25fed4
Initial import into CVS
<?php
require
"html.inc.php"
;
function
build_section_name
(
$section
)
{
$newstr
=
str_replace
(
"/"
,
"_"
,
$section
);
$newstr
=
str_replace
(
" "
,
"_"
,
$newstr
);
return
$newstr
;
}
function
start_q
()
{
global
$qa
,
$anchor
;
print
" <tr>
\n
"
;
print
" <td valign=
\"
top
\"
>"
;
print
"<a name=
\"
q"
.
$qa
.
"
\"
></a>
\n
"
;
if
(
$anchor
!=
""
)
{
print
"<a name=
\"
"
.
$anchor
.
"
\"
></a>
\n
"
;
$anchor
=
""
;
}
print
"<img src=
\"
/images/q.gif
\"
width=
\"
20
\"
height=
\"
32
\"
"
.
" border=
\"
0
\"
alt=
\"
Q.
\"
/></td>
\n
"
;
print
" <td valign=
\"
top
\"
><br />"
;
start_font
();
}
function
end_q
()
{
end_font
();
print
"</td>
\n
"
;
print
" </tr>
\n
"
;
}
function
start_a
()
{
print
" <tr>
\n
"
;
print
" <td valign=
\"
top
\"
>"
;
print
"<img src=
\"
/images/a.gif
\"
width=
\"
20
\"
height=
\"
27
\"
"
.
" border=
\"
0
\"
alt=
\"
A.
\"
/></td>
\n
"
;
print
" <td valign=
\"
top
\"
><br />"
;
start_font
();
}
function
end_a
()
{
end_font
();
print
"</td>
\n
"
;
print
" </tr>
\n
"
;
}
function
check_in_qa
()
{
global
$in_question
;
global
$in_answer
;
if
(
$in_question
)
{
end_q
();
$in_question
=
0
;
}
elseif
(
$in_answer
)
{
end_a
();
$in_answer
=
0
;
}
}
start_html
(
"FAQ"
);
/* The Q&A begins here */
$faq
=
file
(
"./faq.txt"
);
$faq_lines
=
count
(
$faq
);
$sections
=
array
();
/* Display the top-level section. */
start_section
(
"Frequently Asked Questions"
);
$qa
=
1
;
$in_section
=
0
;
$in_question
=
0
;
/* Loop through once to get all the questions. */
for
(
$i
=
0
;
$i
<
$faq_lines
;
$i
++
)
{
$line
=
$faq
[
$i
];
if
(
$line
==
""
||
$line
==
"
\n
"
||
substr
(
$line
,
0
,
3
)
==
"A:
\t
"
)
{
if
(
$in_question
)
{
print
"</a></li>
\n
"
;
$in_question
=
0
;
}
continue
;
}
elseif
(
substr
(
$line
,
0
,
3
)
==
"Q:
\t
"
)
{
if
(
$in_question
)
{
print
"</a></li>
\n
"
;
$in_question
=
0
;
}
$question
=
substr
(
$line
,
3
);
$question
=
preg_replace
(
"/(<\/?(br|code|pre|div)( ?\/)?>|[
\r\n\t
])/"
,
" "
,
$question
);
print
" <li><a href=
\"
#q"
.
$qa
.
"
\"
>"
;
print
$question
;
$in_question
=
1
;
$qa
++
;
}
elseif
(
substr
(
$line
,
0
,
9
)
==
"!SECTION
\t
"
)
{
if
(
$in_question
)
{
print
"</a></li>
\n
"
;
$in_question
=
0
;
}
if
(
$in_section
)
print
"</ul>
\n
"
;
print
"<b>"
.
trim
(
substr
(
$line
,
9
))
.
"</b>
\n
"
;
print
"<ul>
\n
"
;
$in_section
=
1
;
}
elseif
(
$in_question
)
{
print
preg_replace
(
"/(<\/?(br|code|pre|div)( ?\/)?>|[
\r\n\t
])/"
,
" "
,
$line
);
}
}
if
(
$in_question
==
1
)
{
print
"</a></li>
\n
"
;
}
if
(
$in_section
==
1
)
{
print
"</ul>
\n
"
;
end_section
();
}
/* Now we'll loop through again to print out the questions and answers. */
$qa
=
1
;
$in_section
=
0
;
$in_question
=
0
;
$in_answer
=
0
;
$anchor
=
""
;
for
(
$i
=
0
;
$i
<
$faq_lines
;
$i
++
)
{
$line
=
$faq
[
$i
];
if
(
substr
(
$line
,
0
,
3
)
==
"Q:
\t
"
)
{
check_in_qa
();
start_q
();
print
substr
(
$line
,
3
);
$qa
++
;
$in_question
=
1
;
}
elseif
(
substr
(
$line
,
0
,
3
)
==
"A:
\t
"
)
{
check_in_qa
();
start_a
();
print
substr
(
$line
,
3
);
$in_answer
=
1
;
}
elseif
(
substr
(
$line
,
0
,
9
)
==
"!SECTION
\t
"
)
{
check_in_qa
();
if
(
$in_section
==
1
)
{
print
"</table>
\n
"
;
end_section
();
}
$name
=
trim
(
substr
(
$line
,
9
));
print
"<a name=
\"
"
.
build_section_name
(
$name
)
.
"
\"
></a>
\n
"
;
start_section
(
$name
);
print
"<table border=
\"
0
\"
width=
\"
100%
\"
>
\n
"
;
$in_section
=
1
;
}
elseif
(
substr
(
$line
,
0
,
8
)
==
"!ANCHOR
\t
"
)
{
$anchor
=
trim
(
substr
(
$line
,
8
));
}
elseif
(
$in_question
||
$in_answer
)
{
print
$line
;
}
}
check_in_qa
();
if
(
$in_section
==
1
)
{
print
"</table>
\n
"
;
end_section
();
}
end_html
();
?>