Created User will stream music but anonymous user will not.

Having trouble installing AmpJuke ?
Check this.

Created User will stream music but anonymous user will not.

Postby dontaco2000 on 09-07-2010 21:37

Hi there. Love your script. I'm hitting a snag though. When logged on as any created user, I can stream the music to winamp or anything else.

When logged in as Anonymous, however, I am not able to stream music. It gives me an "Error when syncing" message. I'm sure it's something I'm overlooking but I can't see it.

Thank You in Advance
dontaco2000
Newbie
Newbie
 
Posts: 5
Joined: 09-07-2010 21:30

Re: Created User will stream music but anonymous user will n

Postby Michael on 13-07-2010 00:01

Hello dontaco2000,

Welcome to the AmpJuke forum and thanks for posting.

In order to try and answer your question, I'll have to throw a couple of questions the other way:

1. Have you checked that "Also allow anonymous users to stream music" is checked (turned on) ?
You can find it on the configuration page (login -> Configuration; "Miscellaneous options" section).

2. Are all permissions ok ?
Especially "/path/to/ampjuke/tmp" should be rwxrwxrwx (777).

Hope some of this helps.

If not, please post an update (well...feel free to do so anyway).

//Michael.

P.S. Thanks for the nice words about AmpJuke :)
User avatar
Michael
Site Admin
Site Admin
 
Posts: 449
Joined: 03-07-2007 13:46
Location: Denmark

Re: Created User will stream music but anonymous user will n

Postby dontaco2000 on 15-07-2010 20:54

Well I have permissions right and the check box is checked.

It still won't stream for anonymous unless I create an anonymous user.

I have an anonymous user now and went into the php and removed the settings option so people won't change the settings. It's a dirty workaround though so I'd like it to be proper if at all possible.

Thanks for your assistance.
dontaco2000
Newbie
Newbie
 
Posts: 5
Joined: 09-07-2010 21:30

Re: Created User will stream music but anonymous user will n

Postby Michael on 15-07-2010 21:45

Hi dontaco2000,

Well...perhaps I played the "did you check at your end" card a little too fast in my previous post...
...turned out I had exactly the same problem as you described :oops:

The situation comes up because a user-id is supposed to be in the .m3u-playlist.
If none is found, things stop (AmpJuke checks for that, among other things).
The "anonymous" user doesn't have a user-id, since there's really no such user present (unless one is created, - like you did).

Here's a workaround. You will have to get your hands a little dirty in some code:

Open "disp.php" in an editor, and locate the function get_user_id($user), it's around line 780 and currently says:
Code: Select all
function get_user_id($user) { // 0.5.0: get userid based on username:
   $ret="";
   $q="SELECT id,name FROM user WHERE name='".$user."' LIMIT 1";
   $r=execute_sql($q,0,-1,$nr);
   $row=mysql_fetch_array($r);
   $ret=$row['id'];
   return $ret;
}   


Replace the function with this:
Code: Select all
function get_user_id($user) { // 0.5.0: get userid based on username:
   $ret="";
   $q="SELECT id,name FROM user WHERE name='".$user."' LIMIT 1";
   $r=execute_sql($q,0,-1,$nr);
   $row=mysql_fetch_array($r);
   $ret=$row['id'];
   // 0.8.3: Obviously, some extremely, handy things (f.ex. streaming!) will STOP unless there's a user-id set...
   // ...in case we're 'anonymous' just return a pseudo-number:
   if ($user=='anonymous') {
      $ret='99999';
   }
   return $ret;
}   

...basically, we're just returning a pseudo-number (99999), if the user is logged in as "anonymous" (which is the case, if we allow anonymous users).


That should work...
...however, on the box I'm currently sitting at (Linux Mint w. Totem as mediaplayer), it will not work unless you turn off "Now playing" (http://www.ampjuke.org/faq.php?q_id=42).
Unfortunately "Now playing" is turned on by default, if the user is "anonymous" :roll:

To change that, open "loginvalidate.php" in an editor and change line 119, so it says:
Code: Select all
$row['disp_now_playing']="0"; // 0.8.3: Changed from "1" -> might introduce more problems than we want...


Save "disp.php" and "loginvalidate.php", log out of AmpJuke, log in again (as "anonymous"), and start streaming...
...it worked for me with the above mentioned tweaks.

Hope this helps.
If not, please update this thread - actually, if you could confirm that it's also working at your end, I'd be grateful to know.

Thanks in advance.

//Michael.
User avatar
Michael
Site Admin
Site Admin
 
Posts: 449
Joined: 03-07-2007 13:46
Location: Denmark

Re: Created User will stream music but anonymous user will n

Postby Michael on 15-07-2010 21:48

...forgot to mention: I've checked the above as "anonymous" and tried playing a single track, an album and trying out some random tracks.

Everything worked.

//Michael.
User avatar
Michael
Site Admin
Site Admin
 
Posts: 449
Joined: 03-07-2007 13:46
Location: Denmark

Re: Created User will stream music but anonymous user will n

Postby dontaco2000 on 19-07-2010 00:34

Totally worked. Thank you very much.

Additionally, how can I create a link that will allow the user to automatically log in as anonymous when they click on it say from a navbar?

Thank you for all the help.
dontaco2000
Newbie
Newbie
 
Posts: 5
Joined: 09-07-2010 21:30

Re: Created User will stream music but anonymous user will n

Postby Michael on 20-07-2010 20:47

Thanks for the quick response.

It's highly appreciated. Really.

I'm happy the error in relation to anonymous vs. streaming was discovered before 0.8.3 will be released.

In relation to your question: Have to think a little about this..
...sine AmpJuke expects a "valid" user to come from the login page (checks are made).

Once again thanks for the notification about the error.

//Michael.
User avatar
Michael
Site Admin
Site Admin
 
Posts: 449
Joined: 03-07-2007 13:46
Location: Denmark

Re: Created User will stream music but anonymous user will n

Postby dontaco2000 on 20-07-2010 23:45

My pleasure. I got the Autologin function btw. I took login.php and copied it and renamed it autologin.php and removed the conditional statements where it checks for a cookie and hard coded "anonymous" as the user and pass.

I link to that page in all my stuff so it logs them right in and you hardly notice.
dontaco2000
Newbie
Newbie
 
Posts: 5
Joined: 09-07-2010 21:30

Re: Created User will stream music but anonymous user will n

Postby marlow_bg on 23-07-2010 07:33

Hello there,
thanks for all the help in this topic, because I also needed a way to make a use of anonymous users. Ampjuke is installed in environment with a lot of pcs so I cannot make accounts for everybody.

May be it is a good idea to make an Option for Users to SignUp by themselves, that way it will be no pain for the admin of the ampjuke box, and if somebody wants more functionalities (like Playlists, Favorites) they will register, rest will only play music.

What do you think about this Idea?

And please dontaco2000, can you give me this file that you created, "autologin.php " because I will also need fast Anonymous Login Link, to make it as a button in our System.

10x in advance for the cooperation, Amjuke is really nice software.

P.S.
If you forget to do this part of the change:
$row['disp_now_playing']="0"; // 0.8.3: Changed from "1" -> might introduce more problems than we want...

something very bad will hapen when you are logged as anonymous and play some music. A Lot of errors will be generated in your Apache error.log
[Fri Jul 23 16:56:43 2010] [error] [client 10.10.10.150] PHP Warning: fgets(): supplied argument is not a valid stream resource in /var/www/dvdserver/Music/ampjuke/stream.php on line 206

It will write 3 Gbytes of errors for seconds...
So please don't forget to make this change also.
marlow_bg
Newbie
Newbie
 
Posts: 2
Joined: 23-07-2010 07:20

Re: Created User will stream music but anonymous user will n

Postby dontaco2000 on 29-07-2010 22:43

I'll try to upload the file, you should just be able to drop it into root and point to it and it should just work.
Attachments
autologin.rar
my autologin.php for logging in automatically as "anonymous"
(1.92 KiB) Downloaded 796 times
dontaco2000
Newbie
Newbie
 
Posts: 5
Joined: 09-07-2010 21:30


Return to Installation / support

Who is online

Users browsing this forum: No registered users and 2 guests

cron