• Welcome to RadioDJ - Free Radio Automation Software Forum. Please log in or sign up.

Creating Rating script for radiodj (Listener is able to like or dislike songs)

Started by PresidentOfACPJ, March 11, 2019, 10:49:31 PM

Jhonny

Think 2gb can be oke for space on a server.
most of the time you use les than 1 gb.
R.T.F.M. means to me, Read The Fantastic Messages.
Einstein says: Make things simple, but don't make simple things simpler! (wise) this is just my life lesson you know.

I don't do drugs ( ͡° ͜ʖ ͡°)
The Radiodj tutorials site is now managed by Domstad radio .nl still  Just in English

PresidentOfACPJ

I VE YTRIED, BUT  i think this javascriptconflict is breaking me down,its ready,but i really want to make it responsive, and i dont want to let an absolute player and like/dislike buttons, its not good,but its hard to make it work with this javascript conflict. can you look and see if you get an solution?


the first code the first part, sends likes/dislikes to the pages that willsend it to database.

The seconds part of code is the code to load the main div of script to reload after 1 minute, then the song - image- bio etc changes automaticaly, but theres a conflict, if i put everything (php code) at the same div the page loads slowly and i can see the loading at the tab.

and if i press f5 for example after have pressed like or dislik button, the page shows an alert box syn that if i do it itll send data or something like this, its almost like itll send the like again, but of course it wont go because even going, my code prevent the same moment, anyway,idk ,because, if a few moments has spent, idk if its gonna be sent anyway.
KBMZ RADIO:

radiorockfm.com.br/
twitter: @radiorockfmreal/
fb: @radiorockfmreal

studioflashback.com.br
twitter: @radiosflashback
fb: @radiostudioflashback

BR The Classic Rock:
radiorockfm.com.br/br
twitter. @classicrockbr
fb: @classicrockbr

ZTOP:
radiorockfm.com.br/ztop
twitter: @ztop
fb: @ztop

PresidentOfACPJ

Its gonna be really good guys :), . i haeve to make a really good style, in it, i also have to solve some issues. but look to it now...




And now totally responsive! :cool: ive rebuilt all the code. and the player too, the other was stopping without warning.  :D
KBMZ RADIO:

radiorockfm.com.br/
twitter: @radiorockfmreal/
fb: @radiorockfmreal

studioflashback.com.br
twitter: @radiosflashback
fb: @radiostudioflashback

BR The Classic Rock:
radiorockfm.com.br/br
twitter. @classicrockbr
fb: @classicrockbr

ZTOP:
radiorockfm.com.br/ztop
twitter: @ztop
fb: @ztop

PresidentOfACPJ

Hey guys,m please, can you make a test on my webpatge, if tis working like its supposed to [question mark]


http://radiorockfm.com.br/like_song/live_stat.php

Thank you all guys :)
KBMZ RADIO:

radiorockfm.com.br/
twitter: @radiorockfmreal/
fb: @radiorockfmreal

studioflashback.com.br
twitter: @radiosflashback
fb: @radiostudioflashback

BR The Classic Rock:
radiorockfm.com.br/br
twitter. @classicrockbr
fb: @classicrockbr

ZTOP:
radiorockfm.com.br/ztop
twitter: @ztop
fb: @ztop

PresidentOfACPJ

Please, let your reviews here guys :)


KBMZ RADIO:

radiorockfm.com.br/
twitter: @radiorockfmreal/
fb: @radiorockfmreal

studioflashback.com.br
twitter: @radiosflashback
fb: @radiostudioflashback

BR The Classic Rock:
radiorockfm.com.br/br
twitter. @classicrockbr
fb: @classicrockbr

ZTOP:
radiorockfm.com.br/ztop
twitter: @ztop
fb: @ztop

PresidentOfACPJ

THERES ONLY ONE PROBLEM with the script.

You enter the page, then you click submit button (like or dislike).
BUT instead the rating to be sent, the page refresh, then when its refreshed, you have to click again in the rating submitt button (like/dislike).

What is hapenning, i coudlnt discover yet :(
KBMZ RADIO:

radiorockfm.com.br/
twitter: @radiorockfmreal/
fb: @radiorockfmreal

studioflashback.com.br
twitter: @radiosflashback
fb: @radiostudioflashback

BR The Classic Rock:
radiorockfm.com.br/br
twitter. @classicrockbr
fb: @classicrockbr

ZTOP:
radiorockfm.com.br/ztop
twitter: @ztop
fb: @ztop

stevewa

live_stat.js:2 Uncaught ReferenceError: $ is not defined
    at live_stat.js:2
(anonymous) @ live_stat.js:2

PresidentOfACPJ

KBMZ RADIO:

radiorockfm.com.br/
twitter: @radiorockfmreal/
fb: @radiorockfmreal

studioflashback.com.br
twitter: @radiosflashback
fb: @radiostudioflashback

BR The Classic Rock:
radiorockfm.com.br/br
twitter. @classicrockbr
fb: @classicrockbr

ZTOP:
radiorockfm.com.br/ztop
twitter: @ztop
fb: @ztop

bpromma

Quote from: PresidentOfACPJ on April 21, 2019, 01:50:03 PM
Please, try again:
http://radiorockfm.com.br/like_song/live_stat.php
I tried, clicking on the button to like the music, the whole page is recharging and that causes the cut of the audio player.My web browser is Firefox.
THAIMUSIC.ME - BEST Thai Music! - https://www.thaimusic.me/

stevewa

Neste momento, nosso servidor de pedidos está fora do ar, por favor volte mais tarde...

PresidentOfACPJ

Quote from: bpromma on April 21, 2019, 10:12:11 PM
I tried, clicking on the button to like the music, the whole page is recharging and that causes the cut of the audio player.My web browser is Firefox.

This is my problem now, the same thing happens to me trying in Chrome :(

Idk more what bto do to try toi fix this issue.

I really dont understand why it has this behavior, honestly it wasnt sdupposed to happen like this.
KBMZ RADIO:

radiorockfm.com.br/
twitter: @radiorockfmreal/
fb: @radiorockfmreal

studioflashback.com.br
twitter: @radiosflashback
fb: @radiostudioflashback

BR The Classic Rock:
radiorockfm.com.br/br
twitter. @classicrockbr
fb: @classicrockbr

ZTOP:
radiorockfm.com.br/ztop
twitter: @ztop
fb: @ztop

PresidentOfACPJ

Eu nao posso mais perder muito tempo com programação do site e scripts , pois tenho que dar um carinho especial pro meu canal no youtube hehehe. mas aos pouquinhos devagarinho quando der uma brechinha vou produzindo mais codigo pra fazer um puta sistema interativo em site de radio.
KBMZ RADIO:

radiorockfm.com.br/
twitter: @radiorockfmreal/
fb: @radiorockfmreal

studioflashback.com.br
twitter: @radiosflashback
fb: @radiostudioflashback

BR The Classic Rock:
radiorockfm.com.br/br
twitter. @classicrockbr
fb: @classicrockbr

ZTOP:
radiorockfm.com.br/ztop
twitter: @ztop
fb: @ztop

PresidentOfACPJ

Im gonna have to get another kind of code javascript to send, ajax actually, to sent data from the form to database. but now i have 3 youtubechannels to increase, thank, if you fell able to solve this code issue, please tell us and post the code back again here.
KBMZ RADIO:

radiorockfm.com.br/
twitter: @radiorockfmreal/
fb: @radiorockfmreal

studioflashback.com.br
twitter: @radiosflashback
fb: @radiostudioflashback

BR The Classic Rock:
radiorockfm.com.br/br
twitter. @classicrockbr
fb: @classicrockbr

ZTOP:
radiorockfm.com.br/ztop
twitter: @ztop
fb: @ztop

EmmaSts

Here's my code for LIKING Songs to give you an idea on how it's put together, feel free to alter to your needs...

////////////////////////////////////////
Structure
////////////////////////////////////////
Song stats page
php parser [in parser folder]
Database Table `likes` [id - member - songid]

For a Dislike -------------------------
Same principle really

Database Table `dislikes` [id - member - songid]

////////////////////////////////////////
On the songs stats page (img below)


<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript">
$('#likes').submit(function(){$('input[type=submit]', this).attr('disabled', 'disabled');});
function sendLike ( ) {
     var songid = $("#songid");
     var memid = $("#memid");
     var url = "parsefolder/like.php";
      if (songid.val() == "") {
           $("#interactionResults").html('<div class="alert alert-danger"><i class="fa fa-minus-square"></i>&nbsp;<strong>DANGER 922</strong>&nbsp;SYSTEM_ERROR: Sorry!').show().fadeOut(6000);
      } else {
         $.post(url,{songid: songid.val(), memid: memid.val() } , function(data) {
            $("#interactionResults").html(data).show().fadeOut(12000);
            document.sendLike.likes.value='';
           });
     }
}
</script>


<div id="interactionResults">
<form action="javascript:sendLike();" name="likes" id="likes" method="post">
<input type="hidden" name="songid" id="songid" value="<?php echo $songid?>"/>
<input type="hidden" name="memid" id="memid" value="<?php echo $_SESSION['id']; ?>"/>
<button type="submit" class="btn btn-inverse" name="likes"><span class="fa fa-thumbs-up"></span>&nbsp;Like this Song</button>
</form></div>


//////////////////////////////////////
Parser [parsefolder/like.php]


<?php
session_start
();
require_once 
"path/to/your/website.config.file.php";
if (isset(
$_POST['songid'])) { 
  
$songid preg_replace('#[^0-9]#'''$_POST['songid']);
  
$memid preg_replace('#[^0-9]#'''$_POST['memid']);
  if (empty(
$songid) || empty($memid)) { 
    echo 
'<div class="alert alert-danger"><i class="fa fa-minus-square"></i>&nbsp;<strong>DANGER 919</strong>&nbsp;SYSTEM_ERROR: Missing Data to continue';
   exit();
  } else {    
  
$sqllikes mysqli_query ($db_conx"INSERT INTO `likes` (`member`,`songid`)VALUES('$memid','$songid')");
}
echo 
'<div style="padding:12px;background-color:#dbf1db;border:#e6e6e6 solid 1px;color:#26642c;font-size:12px;">&nbsp;&nbsp;<strong>Niiiiiice!</strong><br /><br />Thanks for liking</div>';
exit();
}
?>


Mine is membership based but you can alter the code to IP Address instead of a members id then just count distinct rows per song ID and check the database against IP to show a button or not.. It'd be simple to also create a dislike using this code also so it should get you on the right track :)
Hope this helps :)


RFU

Quote from: PresidentOfACPJ on April 23, 2019, 05:15:53 AM
Im gonna have to get another kind of code javascript to send, ajax actually, to sent data from the form to database. but now i have 3 youtubechannels to increase, thank, if you fell able to solve this code issue, please tell us and post the code back again here.

So what ever happened to this? Did you finish it?
Гордий бути українцем, Ми - Радіо Вільної України.