tazbug annotate web/bugs.cgi @ rev 33
seperate .conf file & fix last commit on bugs.cgi
author | xfred222 |
---|---|
date | Thu Dec 13 20:06:57 2012 -0500 (2012-12-13) |
parents | db97998089d6 |
children | 8ec2f574923b |
rev | line source |
---|---|
pankso@9 | 1 #!/bin/sh |
pankso@9 | 2 # |
pankso@9 | 3 # TazBug Web interface |
pankso@9 | 4 # |
pankso@9 | 5 # Copyright (C) 2012 SliTaz GNU/Linux - BSD License |
pankso@9 | 6 # |
pankso@9 | 7 . /usr/lib/slitaz/httphelper |
xfred222@32 | 8 [ -f "/etc/slitaz/bugs.conf" ] && . /etc/slitaz/bugs.conf |
xfred222@32 | 9 |
pankso@9 | 10 # Internal variable |
pankso@9 | 11 bugdir="bug" |
pankso@29 | 12 plugins="plugins" |
pankso@9 | 13 sessions="/tmp/tazbug/sessions" |
pankso@30 | 14 po="" |
xfred222@32 | 15 error_log_file="/var/log/tazbug-server.log" |
xfred222@32 | 16 |
pankso@9 | 17 # Content negotiation for Gettext |
pankso@9 | 18 IFS="," |
pankso@9 | 19 for lang in $HTTP_ACCEPT_LANGUAGE |
pankso@9 | 20 do |
pankso@9 | 21 lang=${lang%;*} lang=${lang# } lang=${lang%-*} |
pankso@9 | 22 case "$lang" in |
pankso@30 | 23 en) LANG="C" ;; |
pankso@30 | 24 de) LANG="de_DE" ;; |
pankso@30 | 25 es) LANG="es_ES" ;; |
pankso@30 | 26 fr) LANG="fr_FR" ;; |
pankso@30 | 27 it) LANG="it_IT" ;; |
pankso@30 | 28 pt) LANG="pt_BR" ;; |
pankso@30 | 29 ru) LANG="ru_RU" ;; |
pankso@30 | 30 zh) LANG="zh_TW" ;; |
pankso@9 | 31 esac |
pankso@30 | 32 if echo "$po" | fgrep -q "$lang"; then |
pankso@30 | 33 break |
pankso@30 | 34 fi |
pankso@9 | 35 done |
pankso@9 | 36 unset IFS |
pankso@30 | 37 export LANG LC_ALL=$LANG |
pankso@9 | 38 |
pankso@9 | 39 # Internationalization: $(gettext "") |
pankso@9 | 40 . /usr/bin/gettext.sh |
pankso@9 | 41 TEXTDOMAIN='tazbug' |
pankso@9 | 42 export TEXTDOMAIN |
pankso@9 | 43 |
xfred222@33 | 44 |
xfred222@33 | 45 |
xfred222@33 | 46 |
xfred222@33 | 47 |
xfred222@33 | 48 |
pankso@9 | 49 # |
pankso@9 | 50 # Functions |
pankso@9 | 51 # |
pankso@9 | 52 |
pankso@9 | 53 # HTML 5 header. |
pankso@9 | 54 html_header() { |
pankso@9 | 55 cat lib/header.html |
pankso@9 | 56 } |
pankso@9 | 57 |
pankso@9 | 58 # HTML 5 footer. |
pankso@9 | 59 html_footer() { |
pankso@9 | 60 cat << EOT |
pankso@9 | 61 </div> |
pankso@9 | 62 |
pankso@9 | 63 <div id="footer"> |
pankso@9 | 64 <a href="./">SliTaz Bugs</a> - |
pankso@9 | 65 <a href="./?README">README</a> |
pankso@9 | 66 </div> |
pankso@9 | 67 |
pankso@9 | 68 </body> |
pankso@9 | 69 </html> |
pankso@9 | 70 EOT |
pankso@9 | 71 } |
pankso@9 | 72 |
xfred222@32 | 73 |
xfred222@32 | 74 |
pankso@9 | 75 # Check if user is auth |
pankso@9 | 76 check_auth() { |
pankso@9 | 77 auth="$(COOKIE auth)" |
pankso@9 | 78 user="$(echo $auth | cut -d ":" -f 1)" |
pankso@9 | 79 md5cookie="$(echo $auth | cut -d ":" -f 2)" |
pankso@9 | 80 [ -f "$sessions/$user" ] && md5session="$(cat $sessions/$user)" |
pankso@9 | 81 if [ "$md5cookie" == "$md5session" ] && [ "$auth" ]; then |
pankso@9 | 82 return 0 |
pankso@9 | 83 else |
pankso@9 | 84 return 1 |
pankso@9 | 85 fi |
pankso@9 | 86 } |
pankso@9 | 87 |
pankso@9 | 88 # Authentified or not |
pankso@9 | 89 user_box() { |
xfred222@33 | 90 |
xfred222@33 | 91 #bug id to remember |
xfred222@33 | 92 IDLOC="" |
xfred222@33 | 93 if [[ "$(GET id)" ]] ;then |
xfred222@33 | 94 IDLOC="&id=$(GET id)" |
xfred222@33 | 95 fi |
xfred222@33 | 96 |
pankso@9 | 97 if check_auth; then |
pankso@26 | 98 . $PEOPLE/$user/account.conf |
pankso@9 | 99 cat << EOT |
pankso@9 | 100 <div id="user"> |
pankso@24 | 101 <a href="?user=$user">$(get_gravatar $MAIL 20)</a> |
al@31 | 102 <a href="?logout">$(gettext 'Log out')</a> |
pankso@9 | 103 </div> |
pankso@9 | 104 EOT |
pankso@9 | 105 else |
pankso@9 | 106 cat << EOT |
xfred222@33 | 107 <div id="user"> |
xfred222@33 | 108 <a href="?login$IDLOC"><img src="images/avatar.png" alt="[ User ]" /></a> |
xfred222@33 | 109 <a href="?login$IDLOC">$(gettext 'Log in')</a> |
xfred222@33 | 110 </div> |
pankso@9 | 111 EOT |
pankso@9 | 112 fi |
pankso@9 | 113 cat << EOT |
pankso@9 | 114 |
pankso@24 | 115 <div id="search"> |
pankso@24 | 116 <form method="get" action="./"> |
al@31 | 117 <input type="text" name="search" placeholder="$(gettext 'Search')" /> |
al@31 | 118 <!-- <input type="submit" value="$(gettext 'Search')" /> --> |
pankso@24 | 119 </form> |
pankso@24 | 120 </div> |
pankso@24 | 121 |
pankso@9 | 122 <!-- Content --> |
pankso@9 | 123 <div id="content"> |
pankso@9 | 124 |
pankso@9 | 125 EOT |
pankso@9 | 126 } |
pankso@9 | 127 |
pankso@9 | 128 # Login page |
pankso@9 | 129 login_page() { |
xfred222@33 | 130 IDLOC="" |
xfred222@33 | 131 if [[ "$(GET id)" ]] ;then |
xfred222@33 | 132 IDLOC="?id=$(GET id)" |
xfred222@33 | 133 fi |
xfred222@33 | 134 |
xfred222@33 | 135 |
pankso@9 | 136 cat << EOT |
al@31 | 137 <h2>$(gettext 'Login')</h2> |
pankso@9 | 138 |
pankso@9 | 139 <div id="account-info"> |
al@31 | 140 <p>$(gettext "No account yet? Please signup using the SliTaz Bugs reporter \ |
al@31 | 141 on your SliTaz system.")</p> |
al@31 | 142 <p>$(gettext "Tip: to attach big files or images, you can use SliTaz Paste \ |
al@31 | 143 services:") <a href="http://paste.slitaz.org/">paste.slitaz.org</a></p> |
pankso@9 | 144 </div> |
pankso@9 | 145 |
pankso@9 | 146 <div id="login"> |
xfred222@33 | 147 <form method="post" action="$SCRIPT_NAME$IDLOC"> |
al@31 | 148 <input type="text" name="auth" placeholder="$(gettext 'User name')" /> |
al@31 | 149 <input type="password" name="pass" placeholder="$(gettext 'Password')" /> |
pankso@21 | 150 <div> |
al@31 | 151 <input type="submit" value="$(gettext 'Log in')" /> |
pankso@21 | 152 $error |
pankso@21 | 153 </div> |
pankso@9 | 154 </form> |
pankso@9 | 155 </div> |
pankso@9 | 156 |
pankso@9 | 157 <div style="clear: both;"></div> |
pankso@9 | 158 EOT |
pankso@9 | 159 } |
pankso@9 | 160 |
pankso@9 | 161 # Display user public profile. |
pankso@9 | 162 public_people() { |
pankso@9 | 163 cat << EOT |
pankso@9 | 164 <pre> |
al@31 | 165 $(eval_gettext 'Real name : $NAME') |
pankso@9 | 166 </pre> |
pankso@9 | 167 EOT |
pankso@9 | 168 } |
pankso@9 | 169 |
pankso@9 | 170 # Display authentified user profile. TODO: change password |
pankso@9 | 171 auth_people() { |
pankso@9 | 172 cat << EOT |
pankso@9 | 173 <pre> |
al@31 | 174 $(eval_gettext 'Real name : $NAME') |
al@31 | 175 $(eval_gettext 'Email : $MAIL') |
al@31 | 176 $(eval_gettext 'Secure key : $KEY') |
pankso@9 | 177 </pre> |
pankso@9 | 178 EOT |
pankso@9 | 179 } |
pankso@9 | 180 |
pankso@9 | 181 # Usage: list_bugs STATUS |
pankso@9 | 182 list_bugs() { |
al@31 | 183 bug="$1" |
al@31 | 184 echo "<h3>$(eval_gettext '$bug Bug')</h3>" |
pankso@9 | 185 for pr in critical standard |
pankso@9 | 186 do |
pankso@9 | 187 for bug in $(fgrep -H "$1" $bugdir/*/bug.conf | cut -d ":" -f 1) |
pankso@9 | 188 do |
pankso@9 | 189 . $bug |
pankso@9 | 190 id=$(dirname $bug | cut -d "/" -f 2) |
pankso@9 | 191 if [ "$PRIORITY" == "$pr" ]; then |
pankso@9 | 192 cat << EOT |
pankso@9 | 193 <pre> |
al@31 | 194 $(gettext 'Bug title :') <strong>$BUG</strong> <a href="?id=$id">$(gettext 'Show')</a> |
al@31 | 195 $(gettext 'ID - Date :') $id - $DATE |
al@31 | 196 $(gettext 'Creator :') <a href="?user=$CREATOR">$CREATOR</a> |
pankso@9 | 197 </pre> |
pankso@9 | 198 EOT |
pankso@9 | 199 fi |
pankso@9 | 200 done |
pankso@9 | 201 done |
pankso@9 | 202 } |
pankso@9 | 203 |
paul@17 | 204 # Stripped down Wiki parser for bug desc and messages which are simply |
paul@17 | 205 # displayed in <pre> |
pankso@9 | 206 wiki_parser() { |
pankso@9 | 207 sed \ |
pankso@9 | 208 -e s"#http://\([^']*\).png#<img src='\0' alt='[ Image ]' />#"g \ |
pankso@9 | 209 -e s"#http://\([^']*\).*# <a href='\0'>\1</a>#"g |
pankso@9 | 210 } |
pankso@9 | 211 |
pankso@9 | 212 # Bug page |
pankso@9 | 213 bug_page() { |
pankso@26 | 214 if [ -f "$PEOPLE/$CREATOR/account.conf" ]; then |
pankso@26 | 215 . $PEOPLE/$CREATOR/account.conf |
pankso@9 | 216 else |
pankso@15 | 217 MAIL="default" |
pankso@9 | 218 fi |
pankso@9 | 219 cat << EOT |
al@31 | 220 <h2>$(eval_gettext 'Bug $id')</h2> |
pankso@9 | 221 <form method="get" action="./"> |
pankso@9 | 222 |
pankso@9 | 223 <p> |
al@31 | 224 $(get_gravatar $MAIL 32) |
al@31 | 225 <strong>$STATUS</strong> |
al@31 | 226 $BUG - $DATE - |
al@31 | 227 $(eval_gettext 'Priority $PRIORITY') - |
al@31 | 228 $(eval_ngettext '$msgs message' '$msgs messages' $msgs) |
pankso@9 | 229 </p> |
pankso@9 | 230 |
pankso@9 | 231 <pre> |
pankso@9 | 232 $(echo "$DESC" | wiki_parser) |
pankso@9 | 233 </pre> |
pankso@9 | 234 |
pankso@9 | 235 <div id="tools"> |
pankso@9 | 236 EOT |
pankso@9 | 237 if check_auth; then |
pankso@9 | 238 if [ "$STATUS" == "OPEN" ]; then |
pankso@30 | 239 cat << EOT |
pankso@9 | 240 <a href="?id=$id&close">$(gettext "Close bug")</a> |
pankso@9 | 241 <a href="?edit=$id">$(gettext "Edit bug")</a> |
pankso@9 | 242 EOT |
pankso@9 | 243 else |
pankso@9 | 244 cat << EOT |
pankso@9 | 245 <a href="?id=$id&open">$(gettext "Re open bug")</a> |
pankso@9 | 246 EOT |
pankso@9 | 247 fi |
pankso@9 | 248 fi |
pankso@9 | 249 cat << EOT |
pankso@9 | 250 </div> |
pankso@9 | 251 |
pankso@9 | 252 <h3>$(gettext "Messages")</h3> |
pankso@9 | 253 EOT |
pankso@9 | 254 [ "$msgs" == "0" ] && gettext "No messages" |
pankso@9 | 255 for msg in $(ls -1tr $bugdir/$id/msg.*) |
pankso@9 | 256 do |
pankso@9 | 257 . $msg |
pankso@9 | 258 if [ "$MSG" ]; then |
pankso@9 | 259 msgid=$(echo $msg | cut -d "." -f 2) |
pankso@9 | 260 del="" |
pankso@9 | 261 # User can delete his post. |
pankso@9 | 262 [ "$user" == "$USER" ] && \ |
pankso@9 | 263 del="<a href=\"?id=$id&delmsg=$msgid\">delete</a>" |
pankso@9 | 264 cat << EOT |
pankso@9 | 265 <p><strong>$USER</strong> $DATE $del</p> |
pankso@9 | 266 <pre> |
pankso@9 | 267 $(echo "$MSG" | wiki_parser) |
pankso@9 | 268 </pre> |
pankso@9 | 269 EOT |
pankso@9 | 270 fi |
pankso@9 | 271 unset NAME DATE MSG |
pankso@9 | 272 done |
pankso@9 | 273 if check_auth; then |
pankso@9 | 274 cat << EOT |
pankso@9 | 275 <div> |
pankso@9 | 276 <h3>$(gettext "New message")</h3> |
pankso@30 | 277 |
pankso@9 | 278 <input type="hidden" name="id" value="$id" /> |
pankso@9 | 279 <textarea name="msg" rows="8"></textarea> |
al@31 | 280 <p><input type="submit" value="$(gettext 'Send message')" /></p> |
pankso@9 | 281 </form> |
pankso@9 | 282 </div> |
pankso@9 | 283 EOT |
pankso@9 | 284 fi |
pankso@9 | 285 } |
pankso@9 | 286 |
pankso@9 | 287 # Write a new message |
pankso@9 | 288 new_msg() { |
pankso@9 | 289 date=$(date "+%Y-%m-%d %H:%M") |
pankso@9 | 290 msgs=$(ls -1 $bugdir/$id/msg.* | wc -l) |
pankso@9 | 291 count=$(($msgs + 1)) |
pankso@9 | 292 if check_auth; then |
pankso@9 | 293 USER="$user" |
pankso@9 | 294 fi |
pankso@9 | 295 sed "s/$(echo -en '\r') /\n/g" > $bugdir/$id/msg.$count << EOT |
pankso@9 | 296 USER="$USER" |
pankso@9 | 297 DATE="$date" |
pankso@9 | 298 MSG="$(GET msg)" |
pankso@9 | 299 EOT |
pankso@9 | 300 } |
pankso@9 | 301 |
pankso@9 | 302 # Create a new Bug |
pankso@9 | 303 new_bug() { |
pankso@9 | 304 count=$(ls -1 $bugdir | wc -l) |
pankso@9 | 305 date=$(date "+%Y-%m-%d %H:%M") |
pankso@9 | 306 # Sanity check, JS may be disabled. |
pankso@9 | 307 [ ! "$(GET bug)" ] && echo "Missing bug title" && exit 1 |
pankso@9 | 308 [ ! "$(GET desc)" ] && echo "Missing bug description" && exit 1 |
pankso@9 | 309 if check_auth; then |
pankso@9 | 310 USER="$user" |
pankso@9 | 311 fi |
pankso@9 | 312 mkdir -p $bugdir/$count |
pankso@9 | 313 sed "s/$(echo -en '\r') /\n/g" > $bugdir/$count/bug.conf << EOT |
pankso@9 | 314 # SliTaz Bug configuration |
pankso@9 | 315 |
pankso@9 | 316 BUG="$(GET bug)" |
pankso@9 | 317 STATUS="OPEN" |
pankso@9 | 318 PRIORITY="$(GET priority)" |
pankso@9 | 319 CREATOR="$USER" |
pankso@9 | 320 DATE="$date" |
pankso@9 | 321 PKGS="$(GET pkgs)" |
pankso@9 | 322 |
pankso@9 | 323 DESC="$(GET desc)" |
pankso@9 | 324 EOT |
pankso@9 | 325 } |
pankso@9 | 326 |
pankso@9 | 327 # New bug page for the web interface |
pankso@9 | 328 new_bug_page() { |
pankso@9 | 329 cat << EOT |
pankso@9 | 330 <h2>$(gettext "New Bug")</h2> |
pankso@9 | 331 <div id="newbug"> |
pankso@9 | 332 |
pankso@9 | 333 <form method="get" action="./" onsubmit="return checkNewBug();"> |
pankso@9 | 334 <input type="hidden" name="addbug" /> |
pankso@9 | 335 <table> |
pankso@9 | 336 <tbody> |
pankso@9 | 337 <tr> |
pankso@9 | 338 <td>$(gettext "Bug title")*</td> |
pankso@9 | 339 <td><input type="text" name="bug" /></td> |
pankso@9 | 340 </tr> |
pankso@9 | 341 <tr> |
pankso@9 | 342 <td>$(gettext "Description")*</td> |
pankso@9 | 343 <td><textarea name="desc"></textarea></td> |
pankso@9 | 344 </tr> |
pankso@9 | 345 <tr> |
pankso@9 | 346 <td>$(gettext "Packages")</td> |
pankso@9 | 347 <td><input type="text" name="pkgs" /></td> |
pankso@9 | 348 </tr> |
pankso@9 | 349 <tr> |
pankso@9 | 350 <td>$(gettext "Priority")</td> |
pankso@9 | 351 <td> |
pankso@9 | 352 <select name="priority"> |
pankso@9 | 353 <option value="standard">$(gettext "Standard")</option> |
pankso@9 | 354 <option value="critical">$(gettext "Critical")</option> |
pankso@9 | 355 </select> |
pankso@9 | 356 <input type="submit" value="$(gettext "Create Bug")" /> |
pankso@9 | 357 </td> |
pankso@9 | 358 </tr> |
pankso@9 | 359 </tbody> |
pankso@9 | 360 </table> |
pankso@9 | 361 </form> |
pankso@9 | 362 |
pankso@9 | 363 <p> |
al@19 | 364 $(gettext "* field is obligatory. You can also specify affected packages.") |
pankso@9 | 365 </p> |
pankso@9 | 366 |
pankso@9 | 367 </div> |
pankso@9 | 368 EOT |
pankso@9 | 369 } |
pankso@9 | 370 |
pankso@9 | 371 # Edit/Save a bug configuration file |
pankso@9 | 372 edit_bug() { |
pankso@9 | 373 cat << EOT |
al@31 | 374 <h2>$(eval_gettext 'Edit Bug $bug')</h2> |
pankso@9 | 375 <div id="edit"> |
pankso@9 | 376 |
pankso@9 | 377 <form method="get" action="./"> |
pankso@9 | 378 <textarea name="bugconf">$(cat $bugdir/$bug/bug.conf)</textarea> |
pankso@9 | 379 <input type="hidden" name="bug" value="$bug" /> |
al@31 | 380 <input type="submit" value="$(gettext 'Save configuration')" /> |
pankso@9 | 381 </form> |
pankso@9 | 382 |
pankso@9 | 383 </div> |
pankso@9 | 384 EOT |
pankso@9 | 385 } |
pankso@9 | 386 |
pankso@9 | 387 save_bug() { |
pankso@9 | 388 bug="$(GET bug)" |
pankso@9 | 389 content="$(GET bugconf)" |
al@31 | 390 sed "s|\"|'|" | sed "s/$(echo -en '\r') /\n/g" > $bugdir/$bug/bug.conf << EOT |
pankso@9 | 391 $content |
pankso@9 | 392 EOT |
pankso@9 | 393 } |
pankso@9 | 394 |
pankso@9 | 395 # Close a fixed bug |
pankso@9 | 396 close_bug() { |
pankso@9 | 397 sed -i s'/OPEN/CLOSED/' $bugdir/$id/bug.conf |
pankso@9 | 398 } |
pankso@9 | 399 |
pankso@9 | 400 # Re open an old bug |
pankso@9 | 401 open_bug() { |
pankso@9 | 402 sed -i s'/CLOSED/OPEN/' $bugdir/$id/bug.conf |
pankso@9 | 403 } |
pankso@9 | 404 |
pankso@9 | 405 # Get and display Gravatar image: get_gravatar email size |
pankso@9 | 406 # Link to profile: <a href="http://www.gravatar.com/$md5">...</a> |
pankso@9 | 407 get_gravatar() { |
pankso@9 | 408 email=$1 |
pankso@9 | 409 size=$2 |
pankso@9 | 410 [ "$size" ] || size=48 |
pankso@9 | 411 url="http://www.gravatar.com/avatar" |
pankso@29 | 412 md5=$(md5crypt $email) |
al@31 | 413 echo "<img src=\"$url/$md5?d=identicon&s=$size\" alt=\"\" />" |
pankso@9 | 414 } |
pankso@9 | 415 |
pankso@21 | 416 # Create a new user in AUTH_FILE and PEOPLE |
pankso@9 | 417 new_user_config() { |
xfred222@32 | 418 |
xfred222@32 | 419 |
pankso@9 | 420 mail="$(GET mail)" |
pankso@9 | 421 pass="$(GET pass)" |
pankso@9 | 422 key=$(echo -n "$user:$mail:$pass" | md5sum | awk '{print $1}') |
pankso@9 | 423 echo "$user:$pass" >> $AUTH_FILE |
pankso@9 | 424 mkdir -p $PEOPLE/$user/ |
pankso@26 | 425 cat > $PEOPLE/$user/account.conf << EOT |
pankso@9 | 426 # SliTaz user configuration |
pankso@9 | 427 # |
pankso@9 | 428 |
pankso@9 | 429 NAME="$(GET name)" |
pankso@9 | 430 USER="$user" |
pankso@9 | 431 MAIL="$mail" |
pankso@9 | 432 KEY="$key" |
pankso@9 | 433 |
pankso@9 | 434 COMMUNITY="$(GET scn)" |
pankso@9 | 435 LOCATION="$(GET location)" |
pankso@9 | 436 RELEASES="$(GET releases)" |
pankso@9 | 437 PACKAGES="$(GET packages)" |
pankso@9 | 438 EOT |
pankso@26 | 439 chmod 0600 $PEOPLE/$user/account.conf |
xfred222@32 | 440 } |
pankso@9 | 441 |
pankso@9 | 442 # |
pankso@9 | 443 # POST actions |
pankso@9 | 444 # |
pankso@9 | 445 |
pankso@9 | 446 case " $(POST) " in |
pankso@9 | 447 *\ auth\ *) |
pankso@9 | 448 # Authenticate user. Create a session file in $sessions to be used |
pankso@9 | 449 # by check_auth. We have the user login name and a peer session |
pankso@9 | 450 # md5 string in the COOKIE. |
pankso@9 | 451 user="$(POST auth)" |
pankso@29 | 452 pass="$(md5crypt "$(POST pass)")" |
pankso@9 | 453 valid=$(fgrep "${user}:" $AUTH_FILE | cut -d ":" -f 2) |
pankso@9 | 454 if [ "$pass" == "$valid" ] && [ "$pass" != "" ]; then |
pankso@9 | 455 md5session=$(echo -n "$$:$user:$pass:$$" | md5sum | awk '{print $1}') |
pankso@9 | 456 mkdir -p $sessions |
pankso@9 | 457 echo "$md5session" > $sessions/$user |
pankso@9 | 458 header "Location: $WEB_URL" \ |
pankso@9 | 459 "Set-Cookie: auth=$user:$md5session; HttpOnly" |
pankso@9 | 460 else |
xfred222@32 | 461 header "Location: $cd /va ?login&error" |
pankso@9 | 462 fi ;; |
pankso@9 | 463 esac |
pankso@9 | 464 |
pankso@9 | 465 # |
pankso@29 | 466 # Plugins |
pankso@29 | 467 # |
pankso@29 | 468 for p in $(ls -1 $plugins) |
pankso@29 | 469 do |
pankso@29 | 470 [ -f "$plugins/$p/$p.conf" ] && . $plugins/$p/$p.conf |
pankso@29 | 471 [ -x "$plugins/$p/$p.cgi" ] && . $plugins/$p/$p.cgi |
pankso@29 | 472 done |
pankso@29 | 473 |
pankso@29 | 474 # |
pankso@9 | 475 # GET actions |
pankso@9 | 476 # |
pankso@9 | 477 |
pankso@9 | 478 case " $(GET) " in |
pankso@9 | 479 *\ README\ *) |
pankso@9 | 480 header |
pankso@9 | 481 html_header |
pankso@9 | 482 user_box |
pankso@9 | 483 echo '<h2>README</h2>' |
pankso@9 | 484 echo '<pre>' |
pankso@9 | 485 cat /usr/share/doc/tazbug/README |
pankso@30 | 486 echo '</pre>' |
pankso@9 | 487 html_footer ;; |
pankso@9 | 488 *\ closed\ *) |
pankso@9 | 489 # Show all closed bugs. |
pankso@9 | 490 header |
pankso@9 | 491 html_header |
pankso@9 | 492 user_box |
pankso@9 | 493 list_bugs CLOSED |
pankso@9 | 494 html_footer ;; |
pankso@9 | 495 *\ login\ *) |
pankso@9 | 496 # The login page |
pankso@9 | 497 [ "$(GET error)" ] && \ |
al@31 | 498 error="<span class='error'>$(gettext 'Bad login or pass')</span>" |
pankso@30 | 499 header |
pankso@9 | 500 html_header |
pankso@21 | 501 user_box |
xfred222@33 | 502 login_page |
pankso@9 | 503 html_footer ;; |
pankso@9 | 504 *\ logout\ *) |
pankso@9 | 505 # Set a Cookie in the past to logout. |
pankso@9 | 506 expires="Expires=Wed, 01-Jan-1980 00:00:00 GMT" |
pankso@9 | 507 if check_auth; then |
pankso@9 | 508 rm -f "$sessions/$user" |
pankso@9 | 509 header "Location: $WEB_URL" "Set-Cookie: auth=none; $expires; HttpOnly" |
pankso@9 | 510 fi ;; |
pankso@9 | 511 *\ user\ *) |
pankso@9 | 512 # User profile |
pankso@9 | 513 header |
pankso@9 | 514 html_header |
pankso@9 | 515 user_box |
pankso@26 | 516 . $PEOPLE/"$(GET user)"/account.conf |
pankso@9 | 517 echo "<h2>$(get_gravatar $MAIL) $(GET user)</h2>" |
pankso@9 | 518 if check_auth && [ "$(GET user)" == "$user" ]; then |
pankso@9 | 519 auth_people |
pankso@9 | 520 else |
pankso@9 | 521 public_people |
pankso@9 | 522 fi |
pankso@9 | 523 html_footer ;; |
pankso@9 | 524 *\ newbug\ *) |
pankso@9 | 525 # Add a bug from web interface. |
pankso@9 | 526 header |
pankso@9 | 527 html_header |
pankso@9 | 528 user_box |
pankso@9 | 529 if check_auth; then |
pankso@9 | 530 new_bug_page |
pankso@9 | 531 else |
al@31 | 532 echo "<p>$(gettext 'You must be logged in to post a new bug')</p>" |
pankso@9 | 533 fi |
pankso@9 | 534 html_footer ;; |
pankso@9 | 535 *\ addbug\ *) |
pankso@9 | 536 # Add a bug from web interface. |
pankso@9 | 537 if check_auth; then |
pankso@9 | 538 new_bug |
pankso@9 | 539 header "Location: $WEB_URL?id=$count" |
pankso@9 | 540 fi ;; |
pankso@9 | 541 *\ edit\ *) |
pankso@9 | 542 bug="$(GET edit)" |
pankso@9 | 543 header |
pankso@9 | 544 html_header |
pankso@9 | 545 user_box |
pankso@9 | 546 edit_bug |
pankso@9 | 547 html_footer ;; |
pankso@9 | 548 *\ bugconf\ *) |
pankso@9 | 549 if check_auth; then |
pankso@9 | 550 save_bug |
pankso@9 | 551 header "Location: $WEB_URL?id=$bug" |
pankso@9 | 552 fi ;; |
pankso@9 | 553 *\ id\ *) |
pankso@9 | 554 # Empty deleted messages to keep msg count working. |
pankso@9 | 555 id="$(GET id)" |
pankso@9 | 556 [ "$(GET close)" ] && close_bug |
pankso@9 | 557 [ "$(GET open)" ] && open_bug |
pankso@9 | 558 [ "$(GET msg)" ] && new_msg |
pankso@9 | 559 [ "$(GET delmsg)" ] && rm -f $bugdir/$id/msg.$(GET delmsg) && \ |
pankso@9 | 560 touch $bugdir/$id/msg.$(GET delmsg) |
pankso@9 | 561 msgs=$(fgrep MSG= $bugdir/$id/msg.* | wc -l) |
pankso@30 | 562 header |
pankso@9 | 563 html_header |
pankso@30 | 564 user_box |
pankso@9 | 565 . $bugdir/$id/bug.conf |
pankso@9 | 566 bug_page |
pankso@9 | 567 html_footer ;; |
pankso@9 | 568 *\ signup\ *) |
pankso@9 | 569 # Signup |
pankso@9 | 570 header "Content-type: text/plain;" |
pankso@9 | 571 user="$(GET signup)" |
pankso@9 | 572 echo "Requested user login : $user" |
pankso@9 | 573 if fgrep -q "$user:" $AUTH_FILE; then |
paul@17 | 574 echo "ERROR: User already exists" && exit 1 |
pankso@9 | 575 else |
xfred222@32 | 576 |
pankso@9 | 577 echo "Creating account for : $(GET name)" |
pankso@30 | 578 new_user_config |
pankso@9 | 579 fi ;; |
pankso@9 | 580 *\ key\ *) |
pankso@9 | 581 # Let user post new bug or message with crypted key (no gettext) |
pankso@9 | 582 # |
pankso@9 | 583 # Testing only and is security acceptable ? |
pankso@9 | 584 # |
pankso@9 | 585 key="$(GET key)" |
pankso@9 | 586 id="$(GET bug)" |
pankso@9 | 587 header "Content-type: text/plain;" |
pankso@30 | 588 echo "Checking secure key..." |
pankso@26 | 589 if fgrep -qH $key $PEOPLE/*/account.conf; then |
pankso@26 | 590 conf=$(fgrep -H $key $PEOPLE/*/account.conf | cut -d ":" -f 1) |
pankso@9 | 591 . $conf |
pankso@9 | 592 echo "Authentified: $NAME ($USER)" |
pankso@9 | 593 case " $(GET) " in |
pankso@9 | 594 *\ msg\ *) |
pankso@9 | 595 [ ! "$id" ] && echo "Missing bug ID" && exit 0 |
pankso@9 | 596 echo "Posting new message to bug: $id" |
pankso@9 | 597 echo "Message: $(GET msg)" |
pankso@9 | 598 new_msg ;; |
pankso@9 | 599 *\ bug\ *) |
pankso@30 | 600 echo "Adding new bug: $(GET bug)" |
pankso@30 | 601 echo "Description: $(GET desc)" |
pankso@9 | 602 new_bug ;; |
pankso@30 | 603 esac |
pankso@9 | 604 else |
pankso@9 | 605 echo "Not a valid SliTaz user key" |
pankso@9 | 606 exit 0 |
pankso@9 | 607 fi ;; |
pankso@9 | 608 *\ search\ *) |
pankso@9 | 609 header |
pankso@9 | 610 html_header |
pankso@9 | 611 user_box |
pankso@9 | 612 cat << EOT |
pankso@9 | 613 <h2>$(gettext "Search")</h2> |
pankso@9 | 614 <form method="get" action="./"> |
pankso@9 | 615 <input type="text" name="search" /> |
al@31 | 616 <input type="submit" value="$(gettext 'Search')" /> |
pankso@9 | 617 </form> |
pankso@21 | 618 <div> |
pankso@9 | 619 EOT |
pankso@30 | 620 |
pankso@21 | 621 #found=0 JS to notify or write results nb under the search box. |
pankso@21 | 622 for bug in $bugdir/* |
pankso@9 | 623 do |
pankso@21 | 624 result=$(fgrep -i "$(GET search)" $bug/*) |
pankso@21 | 625 if [ "$result" ]; then |
pankso@21 | 626 #found=$(($found + 1)) |
pankso@21 | 627 id=${bug#bug/} |
al@31 | 628 echo "<p><strong>Bug $id</strong> <a href=\"?id=$id\">"$(gettext 'Show')"</a></p>" |
pankso@21 | 629 echo '<pre>' |
pankso@21 | 630 fgrep -i "$(GET search)" $bugdir/$id/* | \ |
pankso@21 | 631 sed s"/$(GET search)/<span class='ok'>$(GET search)<\/span>/"g |
pankso@21 | 632 echo '</pre>' |
pankso@21 | 633 else |
al@31 | 634 get_search=$(GET search) |
al@31 | 635 echo "<p>$(eval_gettext 'No result found for: $get_search')</p>" |
pankso@21 | 636 fi |
pankso@9 | 637 done |
pankso@21 | 638 echo '</div>' |
pankso@9 | 639 html_footer ;; |
pankso@9 | 640 *) |
pankso@9 | 641 # Default page. |
pankso@9 | 642 bugs=$(ls -1 $bugdir | wc -l) |
pankso@9 | 643 close=$(fgrep "CLOSED" $bugdir/*/bug.conf | wc -l) |
pankso@9 | 644 fixme=$(fgrep "OPEN" $bugdir/*/bug.conf | wc -l) |
pankso@9 | 645 msgs=$(find $bugdir -name msg.* ! -size 0 | wc -l) |
pankso@9 | 646 pct=0 |
pankso@9 | 647 [ $bugs -gt 0 ] && pct=$(( ($close * 100) / $bugs )) |
pankso@9 | 648 header |
pankso@9 | 649 html_header |
pankso@9 | 650 user_box |
pankso@9 | 651 cat << EOT |
pankso@9 | 652 |
pankso@9 | 653 <h2>$(gettext "Summary")</h2> |
pankso@9 | 654 |
pankso@9 | 655 <p> |
al@31 | 656 $(eval_ngettext 'Bug: $bugs in total -' 'Bugs: $bugs in total -' $bugs) |
al@31 | 657 $(eval_ngettext '$close fixed -' '$close fixed -' $close) |
al@31 | 658 $(eval_ngettext '$fixme to fix -' '$fixme to fix -' $fixme) |
al@31 | 659 $(eval_ngettext '$msgs message' '$msgs messages' $msgs) |
pankso@9 | 660 </p> |
pankso@9 | 661 |
pankso@9 | 662 <div class="pctbar"> |
pankso@9 | 663 <div class="pct" style="width: ${pct}%;">${pct}%</div> |
pankso@9 | 664 </div> |
pankso@9 | 665 |
al@31 | 666 <p>$(gettext "Please read the <a href=\"?README\">README</a> for help and more \ |
al@31 | 667 information. You may also be interested by the SliTaz \ |
al@31 | 668 <a href=\"http://roadmap.slitaz.org/\">Roadmap</a> and the packages \ |
al@31 | 669 <a href=\"http://cook.slitaz.org/\">Cooker</a>. To perform a search \ |
al@31 | 670 enter your term and press ENTER.") |
pankso@9 | 671 </p> |
pankso@9 | 672 |
pankso@9 | 673 <div id="tools"> |
al@31 | 674 <a href="?closed">$(gettext 'View closed bugs')</a> |
pankso@9 | 675 EOT |
pankso@9 | 676 if check_auth; then |
al@31 | 677 echo "<a href='?newbug'>$(gettext 'Create a new bug')</a>" |
pankso@9 | 678 fi |
pankso@9 | 679 cat << EOT |
pankso@9 | 680 </div> |
pankso@9 | 681 EOT |
pankso@9 | 682 list_bugs OPEN |
pankso@9 | 683 html_footer ;; |
pankso@9 | 684 esac |
pankso@9 | 685 |
pankso@9 | 686 exit 0 |