"Admin" role for chat

Posted by baochan 
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.
Now, this forum is in read-only mode. You find details Details hereContinue on /r/PirateBox
"Admin" role for chat
July 15, 2014 05:08AM
Just made my PirateBox, really looking forward to playing around with tweaking it! Thought I would share a little mod I made, it lets you post to chat in a special color/format that ordinary anonymous users can't use, handy if you want to identify yourself as the owner of the box and prevent anyone from stealing your identity. This is done on PirateBox 1.0 code.

Using your favorite text editor, in the file /opt/piratebox/www/style.css , after
.orange {
  color: #ff8040;
}
add the following:
.admin	{ 
  color: #000000; 
  background: #FF80FF; 
  font-weight: bold 
}
(Tweak it however you'd like, I chose bold black text on a pink background. A bunch of hex values for common colors can be found here.

Then in /opt/piratebox/www/cgi-bin/psowrte.py , just before
process_form( name , rawdata , color )
add this code:
if color.lower() == "admin":
  color = "def"
adminpass = "-mysecretpassword"
if name.endswith(adminpass):
  name = name[0:-1*len(adminpass)]
  color = "admin"

Be sure the indented lines are indented with exactly two spaces, because Python is silly. (honestly, a language that treats whitespace as a special character?) Change "-mysecretpassword" to something you'll remember. The first two lines just prevent someone from injecting the admin style by messing with the html before post.

Now if you type that password at the end of your username it will format your text using the custom CSS style (i.e., put your username as "admin-mysecretpassword", it will show your name as "admin" and highlight your text in pink). You can easily go "anonymous" again by leaving off the password.
Re: "Admin" role for chat
July 15, 2014 06:10PM
Will definitely give this a try. Thank you!
Re: "Admin" role for chat
July 15, 2014 10:37PM
neato

--
lnikon
Entity
Re: "Admin" role for chat
August 13, 2014 12:36PM
Works fine, absolutely great
Re: "Admin" role for chat
August 14, 2014 03:30PM
Does anyone want to push this changes to our Repository? [github.com]

Would be awesome.

Maybe with an option, that a default password setup in the configuration, wont take any effect


This is only my signature.
Re: "Admin" role for chat
September 02, 2014 04:46PM
Does anyone know how to make this work on the Android app?

There is no cgi-bin folder and the closest thing to a psowrt.py is bsowrt.xhtml.
Here is what the apps equivalent to the www folder is: Dropbox ZIP
Re: "Admin" role for chat
September 02, 2014 09:35PM
Not sure it makes sense to add to the code base, at least not as it is. The password is hard-coded and it lacks the features you'd want in a full admin function (namely deleting posts and files). I meant it more as an example of the kind of tweaking you can do to an open-source project like this. I like that existing code is straightforward and relatively simple.

It looks like the Android version works differently - instead of Python it's using BeanShell(?) scripts to make the chat box. Should be able to change the bsowrte.xhtml file to do something similar but the code would look different (can't just copy-paste the above). I don't have time to play around with it just now but maybe someone can help.
Re: "Admin" role for chat
September 06, 2014 05:10AM
Hi,
ok, I understand that argumentation- you are right.

The Android-App is a completly different technique behind, so you can't apply that on the App. Sorry.

Matthias


This is only my signature.
kane
Re: "Admin" role for chat
September 09, 2014 10:32PM
Quote

in the file /opt/piratebox/www/style.css

where do i find this directory?
Re: "Admin" role for chat
October 13, 2014 11:03PM
Thank you. Really helpful!=)
Re: "Admin" role for chat
November 26, 2014 08:07PM
Thanks for the share! Works perfectly and is very useful. thumbs up
Birky
Re: "Admin" role for chat
January 27, 2015 12:05PM
Hi Baochan,

I'm not having much luck with you're how to haha

I'm sure I've entered everything correctly and am at a loss as to why It's not working.

After following your steps I can no longer submit anything to the shoutbox. I suspect it's something I'm missing in psowrte.py but I've double and triple checked my code matches yours.

Any tips or ideas would be great.
Birky
Re: "Admin" role for chat
January 27, 2015 12:47PM
Birky Wrote:
-------------------------------------------------------
> Hi Baochan,
>
> I'm not having much luck with you're how to haha
>
> I'm sure I've entered everything correctly and am
> at a loss as to why It's not working.
>
> After following your steps I can no longer submit
> anything to the shoutbox. I suspect it's something
> I'm missing in psowrte.py but I've double and
> triple checked my code matches yours.
>
> Any tips or ideas would be great.

All fixed. Matthias gave me a hand on the irc. Needed to change 'name' to 'rawname' as process_form uses 'rawname'.

if color.lower() == "admin":
  color = "def"
adminpass = "-mysecretpassword"
if rawname.endswith(adminpass):
  rawname = rawname[0:-1*len(adminpass)]
  color = "admin"
Re: "Admin" role for chat
January 27, 2015 07:15PM
Ah ok, glad you got it worked out. Do you know if this is something that changed in 1.0.1? Guess that's a drawback of playing around with something that's in active development.
Re: "Admin" role for chat
January 29, 2015 03:19PM
Hi boachan,
with 1.0.2 we got some a series of fixes to prevent XSS, which changed that part.

As we have slow release cycles and try to keep our version numbers in a correct lineup (thing that may brake other things are released within the 2nd digit) should help to identify issues.

But, please take notice, that we can't stay close to "unsupported" mods and keeping thos up-to-date sad smiley

regards Matthias
Re: "Admin" role for chat
January 29, 2015 11:37PM
Matthias Wrote:
-------------------------------------------------------
> But, please take notice, that we can't stay close
> to "unsupported" mods and keeping thos up-to-date
> sad smiley

Oh absolutely, I wouldn't expect you to. I was just thinking I should update my original post. I haven't updated to the latest PirateBox on my device so I couldn't test it.
humus
Re: "Admin" role for chat
April 05, 2015 02:37PM
well here we are..

i tried to implemedn the "admin-role" feature.
but ended up having the same problem as Birky.
After changing name to rawname i managed to use the chatbox,
but wierdly it seems to refresh way too fast.

#the name and the message field dont get any input or it dissappears right after writing (max 3 letters)
#when i refresh the page it seems to record the empty messages i sent before (as the input dissappeares before i reach the send button
This is the code i changed: /opt/piratebox/www/cgi-bin/pswowhateveruknow.py

if color.lower() == "admin":
color = "def"
adminpass = "-mysecretpassword"
if rawname.endswith(adminpass):
rawname = rawname[0:-1*len(adminpass)]
color = "admin"


what could cause this problem, any ideas?
Re: "Admin" role for chat
April 05, 2015 03:16PM
That sounds more like a problem with the javascript or any other changes in index.html.

Did you make any?
humus
Re: "Admin" role for chat
April 05, 2015 03:58PM
ye

i changed the host to myhost.lan

i guess the javescript trys to post a shoutboxrequest to "piratebox.lan:8080" while my host is set to "MYHOST.lan:8080" therefor the request failes and gets continuesly reestablished, thus the refreshing,
its how far i have come. Ill post the code as soon i get time to look into it

so long
humus
Re: "Admin" role for chat
April 05, 2015 04:21PM
humus Wrote:
-------------------------------------------------------
> ye
>
> i changed the host to myhost.lan
>
> i guess the javescript trys to post a
> shoutboxrequest to "piratebox.lan:8080" while my
> host is set to "MYHOST.lan:8080" therefor the
> request failes and gets continuesly reestablished,
> thus the refreshing,
> its how far i have come. Ill post the code as soon
> i get time to look into it
>
> so long

here is the solution fo my problem.
Great Community.

[forum.piratebox.cc]
humus
Re: "Admin" role for chat
April 05, 2015 05:24PM
humus Wrote:
-------------------------------------------------------
> humus Wrote:
> --------------------------------------------------
> -----
> > ye
> >
> > i changed the host to myhost.lan
> >
> > i guess the javescript trys to post a
> > shoutboxrequest to "piratebox.lan:8080" while
> my
> > host is set to "MYHOST.lan:8080" therefor the
> > request failes and gets continuesly
> reestablished,
> > thus the refreshing,
> > its how far i have come. Ill post the code as
> soon
> > i get time to look into it
> >
> > so long
>
> here is the solution fo my problem.
> Great Community.
>
> [forum.piratebox.cc]

too hasty.... still searchin
Re: "Admin" role for chat
April 05, 2015 08:55PM
humus, please post a copy of your .py files + css + html files to pastbin or something like that for reviewing it.

thanks
humus
Re: "Admin" role for chat
April 05, 2015 10:29PM
SO...


after x-times digging and repassing the py files i got it now.
as i wanted to host a pure download server on the piratebox i commented out the upload section in the index.html

it appears that the psogen.py refers to the div in which said uploadsection lies in, as for resolving the hostname or something
uncommenting the upload section made the chatbox working again.

so long...
Re: "Admin" role for chat
April 08, 2015 05:49PM
sorry, but that makes no sense to me.
Re: "Admin" role for chat
March 24, 2018 01:41PM
Hello,

This seems not to work on 1.0.3

Snipy