tazbug view web/bugs.cgi @ rev 62
bugs.cgi: Dont show file path in results (again and again)
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Tue Jan 07 20:53:30 2014 +0100 (2014-01-07) |
parents | 8e3f723fc8e7 |
children | 1fa682f972c9 |
line source
1 #!/bin/sh
2 #
3 # TazBug Web interface
4 #
5 # Copyright (C) 2012-2014 SliTaz GNU/Linux - BSD License
6 #
7 . /usr/lib/slitaz/httphelper
9 # Source config file
10 [ -f "/etc/slitaz/tazbug.conf" ] && . /etc/slitaz/tazbug.conf
11 # Web interface can have different setting than cmdline tools
12 [ -f "/etc/slitaz/bugs.conf" ] && . /etc/slitaz/bugs.conf
14 # Internal variable
15 bugdir="$PWD/bug"
16 plugins="plugins"
17 sessions="/tmp/bugs/sessions"
18 script="$SCRIPT_NAME"
20 # Content negotiation for Gettext
21 IFS=","
22 for lang in $HTTP_ACCEPT_LANGUAGE
23 do
24 lang=${lang%;*} lang=${lang# } lang=${lang%-*}
25 case "$lang" in
26 en) LANG="C" ;;
27 de) LANG="de_DE" ;;
28 es) LANG="es_ES" ;;
29 fr) LANG="fr_FR" ;;
30 it) LANG="it_IT" ;;
31 pt) LANG="pt_BR" ;;
32 ru) LANG="ru_RU" ;;
33 zh) LANG="zh_TW" ;;
34 esac
35 if echo "$po" | fgrep -q "$lang"; then
36 break
37 fi
38 done
39 unset IFS
40 export LANG LC_ALL=$LANG
42 # Internationalization: $(gettext "")
43 . /usr/bin/gettext.sh
44 TEXTDOMAIN='tazbug'
45 export TEXTDOMAIN
47 #
48 # Functions
49 #
51 # HTML 5 header.
52 html_header() {
53 cat lib/header.html
54 }
56 # HTML 5 footer.
57 html_footer() {
58 cat << EOT
59 </div>
61 <div id="footer">
62 <a href="$script">SliTaz Bugs</a> -
63 <a href="$script?README">README</a>
64 </div>
66 </body>
67 </html>
68 EOT
69 }
71 GETfiltered() {
72 GET $1 | sed -e "s/'/\'/g; s|\n|<br/>|g; s/\t/\	/g;s/\%22/\"/g"
73 }
75 js_redirection_to() {
76 js_log "Redirecting to $1"
77 echo "<script type=\"text/javascript\"> document.location = \"$1\"; </script>"
78 }
80 js_log() {
81 echo "<script type=\"text/javascript\">console.log('$1')</script>";
82 }
84 js_set_cookie() {
85 name=$1
86 value=$2
87 js_log 'Setting cookie.'
88 echo "<script type=\"text/javascript\">"
89 echo "document.cookie = \"$name=$value; expires=0; path=/\"";
90 echo "</script>"
91 }
93 js_unset_cookie() {
94 name=$1
95 js_log 'Unsetting cookie.'
96 echo "<script type=\"text/javascript\">"
97 echo "document.cookie = \"$1=\"\"; expires=-1; path=/";
98 echo "</script>"
99 }
101 # Check if user is auth
102 check_auth() {
103 auth="$(COOKIE auth)"
104 user="$(echo $auth | cut -d ":" -f 1)"
105 md5cookie="$(echo $auth | cut -d ":" -f 2)"
106 [ -f "$sessions/$user" ] && md5session="$(cat $sessions/$user)"
107 if [ "$md5cookie" == "$md5session" ] && [ "$auth" ]; then
108 return 0
109 else
110 return 1
111 fi
112 }
114 # Check if user is admin
115 admin_user() {
116 fgrep -q 'ADMIN_USER="yes"' ${PEOPLE}/${user}/account.conf
117 }
119 # Authentified or not
120 user_box() {
122 IDLOC=""
123 if [[ "$(GET id)" ]] ;then
124 IDLOC="&id=$(GET id)"
125 fi
127 if check_auth; then
128 . $PEOPLE/$user/account.conf
129 cat << EOT
130 <div id="user">
131 <a href="?user=$user">$(get_gravatar $MAIL 20)</a>
132 <a href="?logout">$(gettext 'Logout')</a>
133 </div>
134 EOT
135 else
136 cat << EOT
137 <div id="user">
138 <a href="?login$IDLOC"><img src="images/avatar.png" alt="[ User ]" /></a>
139 <a href="?login$IDLOC">$(gettext 'Log in')</a>
140 </div>
141 EOT
142 fi
143 cat << EOT
145 <div id="search">
146 <form method="get" action="$script">
147 <input type="text" name="search" placeholder="$(gettext 'Search')" />
148 <!-- <input type="submit" value="$(gettext 'Search')" /> -->
149 </form>
150 </div>
152 <!-- Content -->
153 <div id="content">
155 EOT
156 }
158 # Signup page
159 signup_page() {
160 cat << EOT
162 <div id="signup">
163 <form method="post" name="signup" action="$SCRIPT_NAME" onsubmit="return checkSignup();">
164 <input type="hidden" name="signup" value="new" />
165 <input type="text" name="name" placeholder="$(gettext "Real name")" />
166 <input type="text" name="user" placeholder="$(gettext "User name")" />
167 <input type="text" name="mail" placeholder="$(gettext "Email")" />
168 <input type="password" name="pass" placeholder="$(gettext "Password")" />
169 <div>
170 <input type="submit" value="$(gettext "Create new account")" />
171 </div>
172 </form>
173 </div>
175 EOT
176 }
178 # Link for online signup if enabled.
179 online_signup() {
180 if [ "$ONLINE_SIGNUP" == "yes" ]; then
181 echo -n "<p>" && gettext "Or:"; echo -n " "
182 echo -n "<a href='$script?signup&online'>"
183 gettext "Sign Up Online"
184 echo '</a></p>'
185 fi
186 }
188 # Login page
189 login_page() {
191 IDLOC=""
192 if [[ "$(GET id)" ]] ;then
193 IDLOC="?id=$(GET id)"
194 fi
195 cat << EOT
196 <h2>$(gettext 'Login')</h2>
198 <div id="account-info">
199 <p>$(gettext "No account yet? You can signup using the SliTaz Bugs reporter \
200 on your SliTaz system.")</p>
201 $(online_signup)
202 <p>$(gettext "Tip: to attach big files or images, you can use SliTaz Paste \
203 services:") <a href="http://paste.slitaz.org/">paste.slitaz.org</a></p>
204 </div>
206 <div id="login">
207 <form method="post" action="$script">
208 <input type="text" name="auth" placeholder="$(gettext 'User name')" />
209 <input type="password" name="pass" placeholder="$(gettext 'Password')" />
210 <div>
211 <input type="submit" value="$(gettext 'Log in')" />
212 $error
213 </div>
214 </form>
215 </div>
217 <div style="clear: both;"></div>
218 EOT
219 }
221 # Display user public profile.
222 public_people() {
223 cat << EOT
224 <pre>
225 $(eval_gettext 'Real name : $NAME')
226 </pre>
227 EOT
228 }
230 # Display authentified user profile. TODO: change password
231 auth_people() {
232 cat << EOT
233 <pre>
234 $(eval_gettext 'Real name : $NAME')
235 $(eval_gettext 'Email : $MAIL')
236 $(eval_gettext 'Secure key : $KEY')
237 </pre>
238 EOT
239 }
241 # Usage: list_bug ID
242 list_bug() {
243 id="$1"
244 . ${bugdir}/${id}/bug.conf
245 [ -f "${PEOPLE}/${CREATOR}/account.conf" ] && \
246 . ${PEOPLE}/${CREATOR}/account.conf
247 cat << EOT
248 <a href="?user=$USER">$(get_gravatar "$MAIL" 24)</a> \
249 ID: $id <strong><a href="?id=$id">$BUG</a></strong> \
250 <span class="date">$DATE</span>
251 EOT
252 unset CREATOR USER MAIL
254 }
256 # Usage: list_bugs STATUS
257 list_bugs() {
258 status="$1"
259 echo "<h3>$(eval_gettext '$status Bugs')</h3>"
260 echo "<pre>"
261 for pr in critical standard
262 do
263 for bug in $(fgrep -H "$1" $bugdir/*/bug.conf | cut -d ":" -f 1)
264 do
265 . $bug
266 id=$(basename $(dirname $bug))
267 if [ "$PRIORITY" == "$pr" ]; then
268 [ -f "${PEOPLE}/${CREATOR}/account.conf" ] && \
269 . ${PEOPLE}/${CREATOR}/account.conf
270 cat << EOT
271 <a href="?user=$USER">$(get_gravatar "$MAIL" 24)</a> \
272 ID: $id <strong><a href="?id=$id">$BUG</a></strong> \
273 <span class="date">$DATE</span>
274 EOT
275 fi
276 unset CREATOR USER MAIL
277 done
278 done
279 }
281 # Stripped down Wiki parser for bug desc and messages which are simply
282 # displayed in <pre>
283 wiki_parser() {
284 sed \
285 -e s"#http://\([^']*\).png#<img src='\0' alt='[ Image ]' />#"g \
286 -e s"#http://\([^']*\).*# <a href='\0'>\1</a>#"g \
287 -e 's#\\\\n#\n#g;s#%22#"#g;s#%21#!#g'
288 }
290 # Bug page
291 bug_page() {
292 if [ -f "$PEOPLE/$CREATOR/account.conf" ]; then
293 . $PEOPLE/$CREATOR/account.conf
294 else
295 MAIL="default"
296 fi
297 cat << EOT
298 <h2>$(eval_gettext 'Bug $id: $STATUS')</h2>
299 <form method="get" action="$script">
301 <p>
302 $(get_gravatar $MAIL 32) <strong>$BUG</strong>
303 </p>
304 <p>
305 $(gettext "Date:") $DATE -
306 $(eval_gettext 'Priority $PRIORITY') -
307 $(eval_ngettext '$msgs message' '$msgs messages' $msgs)
308 </p>
310 <pre>
311 $(echo "$DESC" | wiki_parser)
312 </pre>
314 <div id="tools">
315 EOT
316 if check_auth; then
317 if [ "$STATUS" == "OPEN" ]; then
318 cat << EOT
319 <a href="?id=$id&close">$(gettext "Close bug")</a>
320 <a href="?edit=$id">$(gettext "Edit bug")</a>
321 EOT
322 else
323 cat << EOT
324 <a href="?id=$id&open">$(gettext "Re open bug")</a>
325 EOT
326 fi
327 fi
328 cat << EOT
329 </div>
331 <h3>$(gettext "Messages")</h3>
332 EOT
333 [ "$msgs" == "0" ] && gettext "No messages"
334 for msg in $(ls -1tr $bugdir/$id/msg.*)
335 do
336 . $msg
337 if [ "$MSG" ]; then
338 msgid=$(echo $msg | cut -d "." -f 2)
339 del=""
340 # User can delete his post.
341 [ "$user" == "$USER" ] && \
342 del="<a href=\"?id=$id&delmsg=$msgid\">delete</a>"
343 cat << EOT
344 <p><strong>$USER</strong> $DATE $del</p>
345 <pre>
346 $(echo "$MSG" | wiki_parser)
347 </pre>
348 EOT
349 fi
350 unset NAME DATE MSG
351 done
352 if check_auth; then
353 cat << EOT
354 <div>
355 <h3>$(gettext "New message")</h3>
357 <input type="hidden" name="id" value="$id" />
358 <textarea name="msg" rows="8"></textarea>
359 <p><input type="submit" value="$(gettext 'Send message')" /></p>
360 </form>
361 </div>
362 EOT
363 fi
364 }
366 # Write a new message
367 new_msg() {
368 date=$(date "+%Y-%m-%d %H:%M")
369 msgs=$(ls -1 $bugdir/$id/msg.* | wc -l)
370 count=$(($msgs + 1))
371 if check_auth; then
372 USER="$user"
373 fi
374 js_log "Will write message in $bugdir/$id/msg.$count "
375 sed "s/$(echo -en '\r') /\n/g" > $bugdir/$id/msg.$count << EOT
376 USER="$USER"
377 DATE="$date"
378 MSG="$(GETfiltered msg)"
379 EOT
380 }
382 # Create a new Bug
383 new_bug() {
384 count=$(ls -1 $bugdir | wc -l)
385 date=$(date "+%Y-%m-%d %H:%M")
386 # Sanity check, JS may be disabled.
387 [ ! "$(GET bug)" ] && echo "Missing bug title" && exit 1
388 [ ! "$(GET desc)" ] && echo "Missing bug description" && exit 1
389 if check_auth; then
390 USER="$user"
391 fi
392 mkdir -p $bugdir/$count
393 sed "s/$(echo -en '\r') /\n/g" > $bugdir/$count/bug.conf << EOT
394 # SliTaz Bug configuration
396 BUG="$(GETfiltered bug)"
397 STATUS="OPEN"
398 PRIORITY="$(GET priority)"
399 CREATOR="$USER"
400 DATE="$date"
401 PKGS="$(GETfiltered pkgs)"
403 DESC="$(GETfiltered desc)"
404 EOT
405 }
407 # New bug page for the web interface
408 new_bug_page() {
409 cat << EOT
410 <h2>$(gettext "New Bug")</h2>
411 <div id="newbug">
413 <form method="get" action="$script" onsubmit="return checkNewBug();">
414 <input type="hidden" name="addbug" />
415 <table>
416 <tbody>
417 <tr>
418 <td>$(gettext "Bug title")*</td>
419 <td><input type="text" name="bug" /></td>
420 </tr>
421 <tr>
422 <td>$(gettext "Description")*</td>
423 <td><textarea name="desc"></textarea></td>
424 </tr>
425 <tr>
426 <td>$(gettext "Packages")</td>
427 <td><input type="text" name="pkgs" /></td>
428 </tr>
429 <tr>
430 <td>$(gettext "Priority")</td>
431 <td>
432 <select name="priority">
433 <option value="standard">$(gettext "Standard")</option>
434 <option value="critical">$(gettext "Critical")</option>
435 </select>
436 <input type="submit" value="$(gettext "Create Bug")" />
437 </td>
438 </tr>
439 </tbody>
440 </table>
441 </form>
443 <p>
444 $(gettext "* field is obligatory. You can also specify affected packages.")
445 </p>
447 </div>
448 EOT
449 }
452 # Edit/Save a bug configuration file
453 edit_bug() {
454 cat << EOT
455 <h2>$(eval_gettext 'Edit Bug $bug')</h2>
456 <div id="edit">
458 <form method="get" action="$script">
459 <textarea name="bugconf">$(cat $bugdir/$bug/bug.conf)</textarea>
460 <input type="hidden" name="bug" value="$bug" />
461 <input type="submit" value="$(gettext 'Save configuration')" />
462 </form>
464 </div>
465 EOT
466 }
469 save_bug() {
470 bug="$(GET bug)"
471 content="$(GET bugconf)"
472 sed "s|\"|'|" | sed "s/$(echo -en '\r') /\n/g" > $bugdir/$bug/bug.conf << EOT
473 $content
474 EOT
475 }
477 # Close a fixed bug
478 close_bug() {
479 sed -i s'/OPEN/CLOSED/' $bugdir/$id/bug.conf
480 }
482 # Re open an old bug
483 open_bug() {
484 sed -i s'/CLOSED/OPEN/' $bugdir/$id/bug.conf
485 }
487 # Get and display Gravatar image: get_gravatar email size
488 # Link to profile: <a href="http://www.gravatar.com/$md5">...</a>
489 get_gravatar() {
490 email=$1
491 size=$2
492 [ "$size" ] || size=48
493 url="http://www.gravatar.com/avatar"
494 md5=$(md5crypt $email)
495 echo "<img src=\"$url/$md5?d=identicon&s=$size\" alt=\"\" />"
496 }
498 # Create a new user in AUTH_FILE and PEOPLE
499 new_user_config() {
500 if [ ! "$online" ]; then
501 name="$(GET name)"
502 mail="$(GET mail)"
503 pass="$(GET pass)"
504 echo "Creating Server Key..."
505 fi
506 key=$(echo -n "$user:$mail:$pass" | md5sum | awk '{print $1}')
507 echo "$user:$pass" >> $AUTH_FILE
508 mkdir -pm0700 $PEOPLE/$user/
509 cat > $PEOPLE/$user/account.conf << EOT
510 # SliTaz user configuration
511 #
513 NAME="$name"
514 USER="$user"
515 MAIL="$mail"
516 KEY="$key"
518 LOCATION="$(GET location)"
519 RELEASES="$(GET releases)"
520 PACKAGES="$(GET packages)"
521 EOT
522 chmod 0600 $PEOPLE/$user/account.conf
523 if [ ! -f $PEOPLE/$user/account.conf ]; then
524 echo "ERROR: User creation failed!"
525 fi
526 }
528 ########################################################################
529 # POST actions #
530 ########################################################################
532 case " $(POST) " in
533 *\ auth\ *)
534 header
535 html_header
536 # Authenticate user. Create a session file in $sessions to be used
537 # by check_auth. We have the user login name and a peer session
538 # md5 string in the COOKIE.
539 user="$(POST auth)"
540 pass="$(echo -n "$(POST pass)" | md5sum | awk '{print $1}')"
542 IDLOC=""
543 if [[ "$(GET id)" ]] ;then
544 IDLOC="&id=$(GET id)"
545 fi
547 if [ ! -f $AUTH_FILE ] ; then
548 js_log "$AUTH_FILE (defined in \$AUTH_FILE) has not been found."
549 js_redirection_to "$script?login$IDLOC"
550 fi;
552 valid=$(fgrep "${user}:" $AUTH_FILE | cut -d ":" -f 2)
553 if [ "$pass" == "$valid" ] && [ "$pass" != "" ]; then
554 if [[ "$(GET id)" ]] ;then
555 IDLOC="?id=$(GET id)"
556 fi
557 md5session=$(echo -n "$$:$user:$pass:$$" | md5sum | awk '{print $1}')
558 mkdir -p $sessions
559 echo "$md5session" > $sessions/$user
560 js_set_cookie 'auth' "$user:$md5session"
561 js_log "Login authentification has been executed & accepted :)"
562 js_redirection_to "$script$IDLOC"
563 else
564 js_log "Login authentification has been executed & refused"
565 js_redirection_to "$script?login&error$IDLOC"
566 fi
567 html_footer ;;
568 *\ signup\ *)
569 # POST action for online signup
570 name="$(POST name)"
571 user="$(POST user)"
572 mail="$(POST mail)"
573 pass="$(md5crypt "$(POST pass)")"
574 if ! grep "^${user}:" $AUTH_FILE; then
575 online="yes"
576 new_user_config
577 header "Location: $SCRIPT_NAME?login"
578 else
579 header
580 html_header
581 user_box
582 echo "<h2>$(gettext "User already exists:") $user</h2>"
583 html_footer && exit 0
584 fi ;;
585 esac
587 #
588 # Plugins Now!
589 #
590 for p in $(ls -1 $plugins)
591 do
592 [ -f "$plugins/$p/$p.conf" ] && . $plugins/$p/$p.conf
593 [ -x "$plugins/$p/$p.cgi" ] && . $plugins/$p/$p.cgi
594 done
596 ########################################################################
597 # GET actions #
598 ########################################################################
600 case " $(GET) " in
601 *\ README\ *)
602 header
603 html_header
604 user_box
605 echo '<h2>README</h2>'
606 echo '<pre>'
607 if [ -f "README" ]; then
608 cat README
609 else
610 cat /usr/share/doc/tazbug/README
611 fi
612 echo '</pre>'
613 html_footer ;;
614 *\ closed\ *)
615 # Show all closed bugs.
616 header
617 html_header
618 user_box
619 list_bugs CLOSED
620 echo "</pre>"
621 html_footer ;;
622 *\ login\ *)
623 # The login page
624 [ "$(GET error)" ] && \
625 error="<span class='error'>$(gettext 'Bad login or pass')</span>"
626 header
627 html_header
628 user_box
629 login_page
630 html_footer ;;
631 *\ logout\ *)
632 header
633 html_header
634 if check_auth; then
635 rm -f "$sessions/$user"
636 js_unset_cookie 'auth'
637 js_redirection_to "$script"
638 fi ;;
639 *\ user\ *)
640 # User profile
641 header
642 html_header
643 user_box
644 . $PEOPLE/"$(GET user)"/account.conf
645 echo "<h2>$(get_gravatar $MAIL) $(GET user)</h2>"
646 if check_auth && [ "$(GET user)" == "$user" ]; then
647 auth_people
648 else
649 public_people
650 fi
651 html_footer ;;
652 *\ newbug\ *)
653 # Add a bug from web interface.
654 header
655 html_header
656 user_box
657 if check_auth; then
658 new_bug_page
659 else
660 echo "<p>$(gettext 'You must be logged in to post a new bug')</p>"
661 fi
662 html_footer ;;
663 *\ addbug\ *)
664 # Add a bug from web interface.
665 header
666 html_header
667 if check_auth; then
668 new_bug
669 js_redirection_to "$script?id=$count"
670 fi ;;
671 *\ edit\ *)
672 bug="$(GET edit)"
673 header
674 html_header
675 user_box
676 edit_bug
677 html_footer ;;
678 *\ bugconf\ *)
679 header
680 html_header
681 if check_auth; then
682 save_bug
683 js_redirection_to "$script?id=$bug"
684 fi ;;
685 *\ id\ *)
686 # Empty deleted messages to keep msg count working.
687 header
688 html_header
689 id="$(GET id)"
690 [ "$(GET close)" ] && close_bug
691 [ "$(GET open)" ] && open_bug
692 [ "$(GET msg)" ] && new_msg
693 [ "$(GET delmsg)" ] && rm -f $bugdir/$id/msg.$(GET delmsg) && \
694 touch $bugdir/$id/msg.$(GET delmsg)
695 msgs=$(fgrep MSG= $bugdir/$id/msg.* | wc -l)
696 user_box
697 . $bugdir/$id/bug.conf
698 bug_page
699 html_footer ;;
700 *\ signup\ *)
701 # Signup
702 if [ "$(GET online)" ];then
703 header
704 html_header
705 user_box
706 echo "<h2>$(gettext "Sign Up")</h2>"
707 if [ "$ONLINE_SIGNUP" == "yes" ]; then
708 signup_page
709 else
710 gettext "Online registration is disabled"
711 fi
712 html_footer && exit 0
713 else
714 header "Content-type: text/plain;"
715 user="$(GET signup)"
716 echo "Requested user login : $user"
717 if fgrep -q "$user:" $AUTH_FILE; then
718 echo "ERROR: User already exists" && exit 1
719 else
720 echo "Creating account for : $(GET name)"
721 new_user_config
722 fi
723 fi ;;
724 *\ key\ *)
725 # Let user post new bug or message with crypted key (no gettext)
726 #
727 # Testing only and is security acceptable ?
728 #
729 key="$(GET key)"
730 id="$(GET bug)"
731 header "Content-type: text/plain;"
732 echo "Checking secure key..."
733 if fgrep -qH $key $PEOPLE/*/account.conf; then
734 conf=$(fgrep -H $key $PEOPLE/*/account.conf | cut -d ":" -f 1)
735 . $conf
736 echo "Authentified: $NAME ($USER)"
737 case " $(GET) " in
738 *\ msg\ *)
739 [ ! "$id" ] && echo "Missing bug ID" && exit 0
740 echo "Posting new message to bug: $id"
741 echo "Message: $(GET msg)"
742 new_msg ;;
743 *\ bug\ *)
744 echo "Adding new bug: $(GET bug)"
745 echo "Description: $(GET desc)"
746 new_bug ;;
747 esac
748 else
749 echo "Not a valid SliTaz user key"
750 exit 0
751 fi ;;
752 *\ search\ *)
753 found=0
754 header
755 html_header
756 user_box
757 cat << EOT
758 <h2>$(gettext "Search")</h2>
759 <form method="get" action="$script">
760 <input type="text" name="search" />
761 <input type="submit" value="$(gettext 'Search')" />
762 </form>
763 <div>
764 EOT
765 cd $bugdir
766 for bug in *
767 do
768 result=$(fgrep -i -h "$(GET search)" $bug/*)
769 if [ "$result" ]; then
770 found=$(($found + 1))
771 id=${bug}
772 echo "<p><strong>Bug $id</strong> <a href=\"?id=$id\">"$(gettext 'Show')"</a></p>"
773 echo '<pre>'
774 fgrep -i -h "$(GET search)" $bugdir/$id/* | \
775 sed s"/$(GET search)/<span class='ok'>$(GET search)<\/span>/"g
776 echo '</pre>'
777 fi
778 done
779 if [ "$found" == "0" ]; then
780 echo "<p>$(gettext 'No result found for') : $(GET search)</p>"
781 else
782 echo "<p> $found $(gettext 'results found')</p>"
783 fi
784 echo '</div>'
785 html_footer ;;
786 *)
787 # Default page.
788 bugs=$(ls -1 $bugdir | wc -l)
789 close=$(fgrep "CLOSED" $bugdir/*/bug.conf | wc -l)
790 fixme=$(fgrep "OPEN" $bugdir/*/bug.conf | wc -l)
791 msgs=$(find $bugdir -name msg.* ! -size 0 | wc -l)
792 pct=0
793 [ $bugs -gt 0 ] && pct=$(( ($close * 100) / $bugs ))
794 header
795 html_header
796 user_box
797 cat << EOT
799 <h2>$(gettext "Summary")</h2>
801 <p>
802 $(eval_ngettext 'Bug: $bugs in total -' 'Bugs: $bugs in total -' $bugs)
803 $(eval_ngettext '$close fixed -' '$close fixed -' $close)
804 $(eval_ngettext '$fixme to fix -' '$fixme to fix -' $fixme)
805 $(eval_ngettext '$msgs message' '$msgs messages' $msgs)
806 </p>
808 <div class="pctbar">
809 <div class="pct" style="width: ${pct}%;">${pct}%</div>
810 </div>
812 <p>$(gettext "Please read the <a href=\"?README\">README</a> for help and \
813 more information. You may also be interested by the SliTaz \
814 <a href=\"http://roadmap.slitaz.org/\">Roadmap</a> and the packages \
815 <a href=\"http://cook.slitaz.org/\">Cooker</a>. To perform a search \
816 enter your term and press ENTER.")
817 </p>
819 <div id="tools">
820 <a href="?closed">$(gettext 'View closed bugs')</a>
821 EOT
822 if check_auth; then
823 echo "<a href='?newbug'>$(gettext 'Create a new bug')</a>"
824 echo "$PLUGINS_TOOLS"
825 fi
826 cat << EOT
827 </div>
829 <h3>$(gettext "Latest Bugs")</h3>
830 EOT
831 # List last 3 bugs
832 echo "<pre>"
833 for lb in $(ls ${bugdir} | sort -r -n | head -n 3)
834 do
835 list_bug ${lb}
836 done
837 echo "</pre>"
838 list_bugs OPEN
839 echo "</pre>"
840 html_footer ;;
841 esac
843 exit 0