I would imagine powrhost have much the same TOS, concerning usage of CPU and stuff like that.
Offline
What's happened? ALL of the like buttons EVERYWHERE in the forums don't seem to work for me but they were working a while back??
Offline
joefarebrother wrote:
What's happened? ALL of the like buttons EVERYWHERE in the forums don't seem to work for me but they were working a while back??
That's because 000webhost blocked the account - Better than paid webhosting my eye!
Offline
rookwood101 wrote:
I would imagine powrhost have much the same TOS, concerning usage of CPU and stuff like that.
I cant see any tos lol.
Offline
WE'RE BACK! TO FIX YOUR LIKE BUTTONS, REPLACE scratchloveit.netne.net with rookwood101.tk in the urls of your image tags and url tags
Unfortunately, love it counters have been reset, so you will have to start tallying the up again
but better than nothing eh?
Also: STYLES ARE NOT WORKING YET - be patient
Last edited by rookwood101 (2011-10-02 18:15:43)
Offline
Yay! For some reason the love it in your Sig won't work though... The picture does but not the link.
Last edited by Pecola1 (2011-10-02 19:57:41)
Offline
rookwood101 wrote:
WE'RE BACK! TO FIX YOUR LIKE BUTTONS, REPLACE scratchloveit.netne.net with rookwood101.tk in the urls of your image tags and url tags
Unfortunately, love it counters have been reset, so you will have to start tallying the up againbut better than nothing eh?
![]()
Hello everyone, Rook here. I've been developing a way for people to "like" forum topics and I'm looking for some testers, all you need to do is click the button below and 'like' this topic. I will also post the source code and how you can add a like button to your own topic.
Click here for Sparks' self updating images and links in posts!!
How the liking system works
The image
This checks a mysql database and shows how many people have clicked the like button
The link
This does something a bit more complicated, first of all it checks to see whether people have liked the topic at all before, if not then it adds a whole new entry into the database this entry has your ip address and the topic id. If people have liked the topic before, it checks whether your ip is on the list of ips for that topic, if not then it adds your ip to the list of ips for that topic. This means that you can only like things once.
Please like this topic to show your support: http://rookwood101.tk/topicrate.php?id= … ;ret=image
and the source code:Code:
<?php function writetextimage($string, $substring) { if ($_REQUEST['type'] == 'post') { $img = imagecreatefrompng ('bgpost.png'); $text_colour = imagecolorallocate($img, 254, 254, 254); } else { $img = imagecreatefrompng ('bg.png'); $text_colour = imagecolorallocate($img, 1, 1, 1); } $font = realpath('font.ttf'); imagettftext($img, 7, 0, 10, imagefontheight(7), $text_colour, $font, $string); imagettftext($img, 7, 0, 10, 28, $text_colour, $font, $substring); $whit = imagecolorallocate($img, 0, 0, 0); imagecolortransparent($img, $whit); header('Content-type: image/png'); imagepng($img); imagecolordeallocate($text_color); imagedestroy($img); } include 'mysql.php'; $topicid = $_REQUEST['id']; $userip = $_SERVER['REMOTE_ADDR']; if ($_REQUEST['forum'] == 'tbg') { $url = 'http://scratch.mit.edu/tbgforums/viewtopic.php?id=' . $topicid; $database = 'tbg_topicrate'; if ($_REQUEST['type'] == 'post') { $url = 'http://scratch.mit.edu/tbgforums/viewtopic.php?pid=' . $topicid . '#p' . $topicid; $database = 'tbg_postrate'; } } else { $url = 'http://scratch.mit.edu/forums/viewtopic.php?id=' . $topicid; $database = 'topicrate'; if ($_REQUEST['type'] == 'post') { $url = 'http://scratch.mit.edu/forums/viewtopic.php?pid=' . $topicid . '#p' . $topicid; $database = 'postrate'; } } if ($_REQUEST['ret'] == 'image') { if (is_numeric($topicid) === false) { writetextimage('Error: id is not valid', ''); exit(); } $urlcontents = trim(file_get_contents($url)); if (strpos($urlcontents, $bdrq) != false) { writetextimage('Error:', 'id not found'); exit(); } mysql_connect($mysql_host, $mysql_user, $mysql_password) or die(mysql_error()); mysql_select_db($mysql_database) or die(mysql_error()); $checkquery = mysql_query("SELECT * FROM $database WHERE postid='$topicid'"); if (mysql_num_rows($checkquery) == 0) { $likes = 0; } else { $topicratings = mysql_fetch_row($checkquery) or die(mysql_error()); $ratedips = explode(',', $topicratings[1]); $likes = count($ratedips); if ($ratedips[0] == '') { $likes = 0; } } if ($likes == 1) { $likes = 1 . ' Like'; if($_REQUEST['verb'] == 'love') { $likes = 1 . ' Love-it'; } } else { if($_REQUEST['verb'] == 'love') { $likes = $likes . ' Love-its'; } else { $likes = $likes . ' Likes'; } } $checkquery = mysql_query("SELECT * FROM $database WHERE postid='$topicid'"); if (mysql_num_rows($checkquery) == 0) { $already_liked = 'Like This'; if ($_REQUEST['verb'] == 'love') { $already_liked = 'Love it?'; } } else { $topicratings = mysql_fetch_row($checkquery) or die(mysql_error()); $ratedips = explode(',', $topicratings[1]); $count = count($ratedips); if ($_REQUEST['verb'] == 'love') { $already_liked = 'Love it?'; } else { $already_liked = 'Like This'; } for($i=0; $i<$count; $i++) { if($ratedips[$i] == $userip) { $already_liked = 'Unlike This'; if ($_REQUEST['verb'] == 'love') { $already_liked = 'I love it!'; } } } } writetextimage($likes, $already_liked); } elseif ($_REQUEST['ret'] == 'add') { if (is_numeric($topicid) === false) { writetextimage('Error: id is not valid', ''); exit(); } $urlcontents = trim(file_get_contents($url)); if (strpos($urlcontents, $bdrq) != false) { writetextimage('Error: id not found', ''); exit(); } $headerurl = 'Location:' . $url; mysql_connect($mysql_host, $mysql_user, $mysql_password) or die(mysql_error()); mysql_select_db($mysql_database) or die(mysql_error()); $checkquery = mysql_query("SELECT * FROM $database WHERE postid='$topicid'"); if (mysql_num_rows($checkquery) == 0) { $addtopic_query = mysql_query("INSERT INTO $database (postid, ips) VALUES ('$topicid', '$userip')"); header($headerurl); exit(); } else { $topicratings = mysql_fetch_row($checkquery) or die(mysql_error()); $ratedips = explode(',', $topicratings[1]); $count = count($ratedips); for($i=0; $i<$count; $i++) { if($ratedips[$i] == $userip) { unset($ratedips[$i]); $ratedips = implode(',', $ratedips); $updateips_query = mysql_query("UPDATE $database SET ips='$ratedips' WHERE postid='$topicid'") or die(mysql_error()); header($headerurl); exit(); } } $ratedips[$count] = $userip; $ratedips2 = implode(',', $ratedips); if ($ratedips[0] == '') { $ratedips2 = $userip; } $updateips_query = mysql_query("UPDATE $database SET ips='$ratedips2' WHERE postid='$topicid'") or die(mysql_error()); header($headerurl); exit(); } } elseif ($_REQUEST['ret'] == 'top') { if($_REQUEST['forum'] == 'tbg') { if ($_REQUEST['type'] == 'post') { $database = 'tbg_postrate'; $type = 'Post'; } else { $database = 'tbg_topicrate'; $type = 'Topic'; } } else { if ($_REQUEST['type'] == 'post') { $database = 'postrate'; $type = 'Post'; } else { $database = 'topicrate'; $type = 'Topic'; } } mysql_connect($mysql_host, $mysql_user, $mysql_password) or die(mysql_error()); mysql_select_db($mysql_database) or die(mysql_error()); $query = mysql_query("SELECT * FROM $database"); for($i=0;$i<mysql_num_rows($query);$i++) { $temp = mysql_fetch_row($query); $postids[$i] = $temp[0]; $ips[$i] = count(explode(',', $temp[1])) . ',' . $i; $ipssort[$i] = $ips[$i]; } rsort($ipssort, SORT_NUMERIC); for($i=0;$i<count($postids);$i++) { if($ips[$i] == $ipssort[$_REQUEST['rank']-1]) { $winnerpost = $postids[$i]; } } if(!isset($ipssort[$_REQUEST['rank']-1])) { writetextimage('Error: Post with that', 'rank doesn\'t exist'); exit(); } if($_REQUEST['verb'] == 'love') { $likes = $likes . ' Love-its'; } else { $likes = $likes . ' Likes'; } $explodedip = explode(',', $ipssort[$_REQUEST['rank']-1]); writetextimage($_REQUEST['rank'] . '.' . " $type " . $winnerpost, $explodedip[0] . $likes); } elseif ($_REQUEST['ret'] == 'toplink') { if($_REQUEST['forum'] == 'tbg') { if ($_REQUEST['type'] == 'post') { $database = 'tbg_postrate'; $url = 'http://scratch.mit.edu/tbgforums/viewtopic.php?pid='; $afterbit = '#p'; } else { $database = 'tbg_topicrate'; $url = 'http://scratch.mit.edu/tbgforums/viewtopic.php?id='; } } else { if ($_REQUEST['type'] == 'post') { $database = 'postrate'; $url = 'http://scratch.mit.edu/forums/viewtopic.php?pid='; $afterbit = '#p'; } else { $database = 'topicrate'; $url = 'http://scratch.mit.edu/forums/viewtopic.php?id='; } } mysql_connect($mysql_host, $mysql_user, $mysql_password) or die(mysql_error()); mysql_select_db($mysql_database) or die(mysql_error()); $query = mysql_query("SELECT * FROM $database"); for($i=0;$i<mysql_num_rows($query);$i++) { $temp = mysql_fetch_row($query); $postids[$i] = $temp[0]; $ips[$i] = count(explode(',', $temp[1])) . ',' . $i; $ipssort[$i] = $ips[$i]; } rsort($ipssort, SORT_NUMERIC); for($i=0;$i<count($postids);$i++) { if($ips[$i] == $ipssort[$_REQUEST['rank']-1]) { $winnerpost = $postids[$i]; } } if(!isset($ipssort[$_REQUEST['rank']-1])) { writetextimage('Error: Post with that', 'rank doesn\'t exist'); exit(); } if (!isset($afterbit)) { $headerurl = $url . $winnerpost; header("Location:$headerurl"); exit(); } else { $headerurl = $url . $winnerpost . $afterbit . $winnerpost; header("Location:$headerurl"); exit(); } } else { writetextimage('Error: incorrect URL vars used', 'Better luck next time!'); } ?>This took a long time to write so please support me!
I'd like to thank LS97 for the writetextimage() code and Sparks for his inspirational API thread.
Right, now for how you can add it to your posts.
First off you need to make a url tag with the url http://rookwood101.tk/topicrate.php?id=TOPIC ID HERE&ret=add to find the topic id, you must first make the post, go out to the forums section your topic is in, click on your topic and you'll see in the url bar something like scratch.mit.edu/forums/viewtopic.php?id=# where # is a number, you need to copy this number and put it in the TOPIC ID HERE.
So far we haveCode:
[url=http://rookwood101.tk/topicrate.php?id=TOPIC ID HERE&ret=add][/url]Now for the image part
Basically you use the same id but you use an image tag and the url is slightly different soCode:
[url=http://rookwood101.tk/topicrate.php?id=TOPIC ID HERE&ret=add][url]http://rookwood101.tk/topicrate.php?id=TOPIC ID HERE&ret=image[/url][/url]notice ret=image now rather than ret=add.
To have a like button that likes a tbg forum topic, just add &forum=tbg to the url for both image and link. To make it use love-its instead of likes (changes the text) then add &verb=love onto the end of the image url only. this is what it looks like: http://rookwood101.tk/topicrate.php?id= … ;verb=love
Make sure to check out Sidharth's Javascript code that automatically generates the code for you based on the url of your post! Here it ishttp://rookwood101.tk/topicrate.php?id= … ;type=post and you can like it using the new likeable posts feature (see below on how to implement yourself)!
Which brings us nicely onto the new:
Likeable Posts!
So, you've made a post in a topic that you think everyone will like, and want to show there thanks, but the like button only supports topics. Well not anymore!
You can now have likeable posts, all you have to do is use the same code as topics, except change the id to the id of your post. To find this out, when you make a post, check (once you've posted it) what your url bar says, it will have on the end something like #p123456 you need to copy the number bit of it (in this case 123456) and put that as the id in my codeCode:
[url=http://rookwood101.tk/topicrate.php?id=POST ID HERE&ret=add&type=post][url]http://rookwood101.tk/topicrate.php?id=POST ID HERE&ret=image&type=post[/url][/url]then, as you can see here you put on the end of each of the urls (image and link) &type=post this is to tell my script that you're talking about a post and not a topic. If you leave this blank then it will think it is a topic, and either it won't work, or you will be liking some random topic.
Well, we're done! I hope you like this new feature!
Custom like button styles
So, you like the idea of 'like buttons' but don't like the style they're in?
Introducing:
Custom made like buttons
Basically, you tell me the style of button you want, font, background shape, colours etc. and I make it for you, adding it as an option in the URL of the image eg. stl=1 meaning style = style no.1. I might add the option to change the font colour & size from the URL, it all depends on how many custom requests I get.
Current Styles:
Style 1 - http://rookwood101.tk/topicrate.php?id= … ;ret=image Style 1 is default, no extra code needed
Style 2 - http://rookwood101.tk/topicrate.php?id= … mp;style=2 add &style=2 to the end of the image url to enable this style. Requested by IHeartGaming.
Style 3 - http://rookwood101.tk/topicrate.php?id= … mp;style=3 add &style=3 to the end of the image url to enable this style. Requested by Comp500.
Style 4 - http://rookwood101.tk/topicrate.php?id= … mp;style=4 add &style=4 to the end of the image url to enable this style. Requested by Nathanprocks.
Top liked rankings
See This Post for more info.
Thanks,
Rook
ChangelogCode:
V1.0 First Release, allows you to add like buttons to forum topics and like them. V1.1 Changed text size & Added redirect to topic V1.5 Added unlike feature so that if you liked something in the past you can change your mind and take away the like also added small text saying either like or unlike to show you what would happen if you clicked the link. V1.5.1 Bug Fixes, such as now displays image of Error messages and I had a couple of variables set the wrong way round. V1.6 Prettier like button, thanks LS97! V1.6.1 Fixed a bug where people could like topics even if they didn't exist also put the mysql details in a seperate file along with a variable that holds the string 'Bad request' something or other. V1.7 TBG support! add &forum=tbg to url for it to work. V1.7.1 Have it use Love-its instead of Likes put &verb=love on the end of the img url to make it work. V1.8 Added first custom style requested by IHeartGaming. V2.0 Finally added Likeable posts! as requested by LS97. V2.1 Added blue colouring for posts, and white colouring for topics V2.1.1 Added Comp500's style request. V3.0 Added Top liked list! V3.0.1 Added Nathanprocks' style request V3.1 Fixed Bug where if two posts had the same amount of likes, they would only use one id between them on the ranks list. V4 Basically a downgrade, new hosts so it will work, basically get rid of the scratchloveit.netne.net and replace it with rookwood101.tkTodo list
Code:
· Star Rating System (Seperate project) · Customisable Button-added requested one, need to make fully user customisable · Add Supporters list support using scratch login api. · Custom Button text (different to Like and Love) · Show rank of post/topic on like button · Stats
It still adds two likes...
Offline
scratcher7_13 wrote:
rookwood101 wrote:
WE'RE BACK! TO FIX YOUR LIKE BUTTONS, REPLACE scratchloveit.netne.net with rookwood101.tk in the urls of your image tags and url tags
Unfortunately, love it counters have been reset, so you will have to start tallying the up againbut better than nothing eh?
![]()
Hello everyone, Rook here. I've been developing a way for people to "like" forum topics and I'm looking for some testers, all you need to do is click the button below and 'like' this topic. I will also post the source code and how you can add a like button to your own topic.
Click here for Sparks' self updating images and links in posts!!
How the liking system works
The image
This checks a mysql database and shows how many people have clicked the like button
The link
This does something a bit more complicated, first of all it checks to see whether people have liked the topic at all before, if not then it adds a whole new entry into the database this entry has your ip address and the topic id. If people have liked the topic before, it checks whether your ip is on the list of ips for that topic, if not then it adds your ip to the list of ips for that topic. This means that you can only like things once.
Please like this topic to show your support: http://rookwood101.tk/topicrate.php?id= … ;ret=image
and the source code:Code:
<?php function writetextimage($string, $substring) { if ($_REQUEST['type'] == 'post') { $img = imagecreatefrompng ('bgpost.png'); $text_colour = imagecolorallocate($img, 254, 254, 254); } else { $img = imagecreatefrompng ('bg.png'); $text_colour = imagecolorallocate($img, 1, 1, 1); } $font = realpath('font.ttf'); imagettftext($img, 7, 0, 10, imagefontheight(7), $text_colour, $font, $string); imagettftext($img, 7, 0, 10, 28, $text_colour, $font, $substring); $whit = imagecolorallocate($img, 0, 0, 0); imagecolortransparent($img, $whit); header('Content-type: image/png'); imagepng($img); imagecolordeallocate($text_color); imagedestroy($img); } include 'mysql.php'; $topicid = $_REQUEST['id']; $userip = $_SERVER['REMOTE_ADDR']; if ($_REQUEST['forum'] == 'tbg') { $url = 'http://scratch.mit.edu/tbgforums/viewtopic.php?id=' . $topicid; $database = 'tbg_topicrate'; if ($_REQUEST['type'] == 'post') { $url = 'http://scratch.mit.edu/tbgforums/viewtopic.php?pid=' . $topicid . '#p' . $topicid; $database = 'tbg_postrate'; } } else { $url = 'http://scratch.mit.edu/forums/viewtopic.php?id=' . $topicid; $database = 'topicrate'; if ($_REQUEST['type'] == 'post') { $url = 'http://scratch.mit.edu/forums/viewtopic.php?pid=' . $topicid . '#p' . $topicid; $database = 'postrate'; } } if ($_REQUEST['ret'] == 'image') { if (is_numeric($topicid) === false) { writetextimage('Error: id is not valid', ''); exit(); } $urlcontents = trim(file_get_contents($url)); if (strpos($urlcontents, $bdrq) != false) { writetextimage('Error:', 'id not found'); exit(); } mysql_connect($mysql_host, $mysql_user, $mysql_password) or die(mysql_error()); mysql_select_db($mysql_database) or die(mysql_error()); $checkquery = mysql_query("SELECT * FROM $database WHERE postid='$topicid'"); if (mysql_num_rows($checkquery) == 0) { $likes = 0; } else { $topicratings = mysql_fetch_row($checkquery) or die(mysql_error()); $ratedips = explode(',', $topicratings[1]); $likes = count($ratedips); if ($ratedips[0] == '') { $likes = 0; } } if ($likes == 1) { $likes = 1 . ' Like'; if($_REQUEST['verb'] == 'love') { $likes = 1 . ' Love-it'; } } else { if($_REQUEST['verb'] == 'love') { $likes = $likes . ' Love-its'; } else { $likes = $likes . ' Likes'; } } $checkquery = mysql_query("SELECT * FROM $database WHERE postid='$topicid'"); if (mysql_num_rows($checkquery) == 0) { $already_liked = 'Like This'; if ($_REQUEST['verb'] == 'love') { $already_liked = 'Love it?'; } } else { $topicratings = mysql_fetch_row($checkquery) or die(mysql_error()); $ratedips = explode(',', $topicratings[1]); $count = count($ratedips); if ($_REQUEST['verb'] == 'love') { $already_liked = 'Love it?'; } else { $already_liked = 'Like This'; } for($i=0; $i<$count; $i++) { if($ratedips[$i] == $userip) { $already_liked = 'Unlike This'; if ($_REQUEST['verb'] == 'love') { $already_liked = 'I love it!'; } } } } writetextimage($likes, $already_liked); } elseif ($_REQUEST['ret'] == 'add') { if (is_numeric($topicid) === false) { writetextimage('Error: id is not valid', ''); exit(); } $urlcontents = trim(file_get_contents($url)); if (strpos($urlcontents, $bdrq) != false) { writetextimage('Error: id not found', ''); exit(); } $headerurl = 'Location:' . $url; mysql_connect($mysql_host, $mysql_user, $mysql_password) or die(mysql_error()); mysql_select_db($mysql_database) or die(mysql_error()); $checkquery = mysql_query("SELECT * FROM $database WHERE postid='$topicid'"); if (mysql_num_rows($checkquery) == 0) { $addtopic_query = mysql_query("INSERT INTO $database (postid, ips) VALUES ('$topicid', '$userip')"); header($headerurl); exit(); } else { $topicratings = mysql_fetch_row($checkquery) or die(mysql_error()); $ratedips = explode(',', $topicratings[1]); $count = count($ratedips); for($i=0; $i<$count; $i++) { if($ratedips[$i] == $userip) { unset($ratedips[$i]); $ratedips = implode(',', $ratedips); $updateips_query = mysql_query("UPDATE $database SET ips='$ratedips' WHERE postid='$topicid'") or die(mysql_error()); header($headerurl); exit(); } } $ratedips[$count] = $userip; $ratedips2 = implode(',', $ratedips); if ($ratedips[0] == '') { $ratedips2 = $userip; } $updateips_query = mysql_query("UPDATE $database SET ips='$ratedips2' WHERE postid='$topicid'") or die(mysql_error()); header($headerurl); exit(); } } elseif ($_REQUEST['ret'] == 'top') { if($_REQUEST['forum'] == 'tbg') { if ($_REQUEST['type'] == 'post') { $database = 'tbg_postrate'; $type = 'Post'; } else { $database = 'tbg_topicrate'; $type = 'Topic'; } } else { if ($_REQUEST['type'] == 'post') { $database = 'postrate'; $type = 'Post'; } else { $database = 'topicrate'; $type = 'Topic'; } } mysql_connect($mysql_host, $mysql_user, $mysql_password) or die(mysql_error()); mysql_select_db($mysql_database) or die(mysql_error()); $query = mysql_query("SELECT * FROM $database"); for($i=0;$i<mysql_num_rows($query);$i++) { $temp = mysql_fetch_row($query); $postids[$i] = $temp[0]; $ips[$i] = count(explode(',', $temp[1])) . ',' . $i; $ipssort[$i] = $ips[$i]; } rsort($ipssort, SORT_NUMERIC); for($i=0;$i<count($postids);$i++) { if($ips[$i] == $ipssort[$_REQUEST['rank']-1]) { $winnerpost = $postids[$i]; } } if(!isset($ipssort[$_REQUEST['rank']-1])) { writetextimage('Error: Post with that', 'rank doesn\'t exist'); exit(); } if($_REQUEST['verb'] == 'love') { $likes = $likes . ' Love-its'; } else { $likes = $likes . ' Likes'; } $explodedip = explode(',', $ipssort[$_REQUEST['rank']-1]); writetextimage($_REQUEST['rank'] . '.' . " $type " . $winnerpost, $explodedip[0] . $likes); } elseif ($_REQUEST['ret'] == 'toplink') { if($_REQUEST['forum'] == 'tbg') { if ($_REQUEST['type'] == 'post') { $database = 'tbg_postrate'; $url = 'http://scratch.mit.edu/tbgforums/viewtopic.php?pid='; $afterbit = '#p'; } else { $database = 'tbg_topicrate'; $url = 'http://scratch.mit.edu/tbgforums/viewtopic.php?id='; } } else { if ($_REQUEST['type'] == 'post') { $database = 'postrate'; $url = 'http://scratch.mit.edu/forums/viewtopic.php?pid='; $afterbit = '#p'; } else { $database = 'topicrate'; $url = 'http://scratch.mit.edu/forums/viewtopic.php?id='; } } mysql_connect($mysql_host, $mysql_user, $mysql_password) or die(mysql_error()); mysql_select_db($mysql_database) or die(mysql_error()); $query = mysql_query("SELECT * FROM $database"); for($i=0;$i<mysql_num_rows($query);$i++) { $temp = mysql_fetch_row($query); $postids[$i] = $temp[0]; $ips[$i] = count(explode(',', $temp[1])) . ',' . $i; $ipssort[$i] = $ips[$i]; } rsort($ipssort, SORT_NUMERIC); for($i=0;$i<count($postids);$i++) { if($ips[$i] == $ipssort[$_REQUEST['rank']-1]) { $winnerpost = $postids[$i]; } } if(!isset($ipssort[$_REQUEST['rank']-1])) { writetextimage('Error: Post with that', 'rank doesn\'t exist'); exit(); } if (!isset($afterbit)) { $headerurl = $url . $winnerpost; header("Location:$headerurl"); exit(); } else { $headerurl = $url . $winnerpost . $afterbit . $winnerpost; header("Location:$headerurl"); exit(); } } else { writetextimage('Error: incorrect URL vars used', 'Better luck next time!'); } ?>This took a long time to write so please support me!
I'd like to thank LS97 for the writetextimage() code and Sparks for his inspirational API thread.
Right, now for how you can add it to your posts.
First off you need to make a url tag with the url http://rookwood101.tk/topicrate.php?id=TOPIC ID HERE&ret=add to find the topic id, you must first make the post, go out to the forums section your topic is in, click on your topic and you'll see in the url bar something like scratch.mit.edu/forums/viewtopic.php?id=# where # is a number, you need to copy this number and put it in the TOPIC ID HERE.
So far we haveCode:
[url=http://rookwood101.tk/topicrate.php?id=TOPIC ID HERE&ret=add][/url]Now for the image part
Basically you use the same id but you use an image tag and the url is slightly different soCode:
[url=http://rookwood101.tk/topicrate.php?id=TOPIC ID HERE&ret=add][url]http://rookwood101.tk/topicrate.php?id=TOPIC ID HERE&ret=image[/url][/url]notice ret=image now rather than ret=add.
To have a like button that likes a tbg forum topic, just add &forum=tbg to the url for both image and link. To make it use love-its instead of likes (changes the text) then add &verb=love onto the end of the image url only. this is what it looks like: http://rookwood101.tk/topicrate.php?id= … ;verb=love
Make sure to check out Sidharth's Javascript code that automatically generates the code for you based on the url of your post! Here it ishttp://rookwood101.tk/topicrate.php?id= … ;type=post and you can like it using the new likeable posts feature (see below on how to implement yourself)!
Which brings us nicely onto the new:
Likeable Posts!
So, you've made a post in a topic that you think everyone will like, and want to show there thanks, but the like button only supports topics. Well not anymore!
You can now have likeable posts, all you have to do is use the same code as topics, except change the id to the id of your post. To find this out, when you make a post, check (once you've posted it) what your url bar says, it will have on the end something like #p123456 you need to copy the number bit of it (in this case 123456) and put that as the id in my codeCode:
[url=http://rookwood101.tk/topicrate.php?id=POST ID HERE&ret=add&type=post][url]http://rookwood101.tk/topicrate.php?id=POST ID HERE&ret=image&type=post[/url][/url]then, as you can see here you put on the end of each of the urls (image and link) &type=post this is to tell my script that you're talking about a post and not a topic. If you leave this blank then it will think it is a topic, and either it won't work, or you will be liking some random topic.
Well, we're done! I hope you like this new feature!
Custom like button styles
So, you like the idea of 'like buttons' but don't like the style they're in?
Introducing:
Custom made like buttons
Basically, you tell me the style of button you want, font, background shape, colours etc. and I make it for you, adding it as an option in the URL of the image eg. stl=1 meaning style = style no.1. I might add the option to change the font colour & size from the URL, it all depends on how many custom requests I get.
Current Styles:
Style 1 - http://rookwood101.tk/topicrate.php?id= … ;ret=image Style 1 is default, no extra code needed
Style 2 - http://rookwood101.tk/topicrate.php?id= … mp;style=2 add &style=2 to the end of the image url to enable this style. Requested by IHeartGaming.
Style 3 - http://rookwood101.tk/topicrate.php?id= … mp;style=3 add &style=3 to the end of the image url to enable this style. Requested by Comp500.
Style 4 - http://rookwood101.tk/topicrate.php?id= … mp;style=4 add &style=4 to the end of the image url to enable this style. Requested by Nathanprocks.
Top liked rankings
See This Post for more info.
Thanks,
Rook
ChangelogCode:
V1.0 First Release, allows you to add like buttons to forum topics and like them. V1.1 Changed text size & Added redirect to topic V1.5 Added unlike feature so that if you liked something in the past you can change your mind and take away the like also added small text saying either like or unlike to show you what would happen if you clicked the link. V1.5.1 Bug Fixes, such as now displays image of Error messages and I had a couple of variables set the wrong way round. V1.6 Prettier like button, thanks LS97! V1.6.1 Fixed a bug where people could like topics even if they didn't exist also put the mysql details in a seperate file along with a variable that holds the string 'Bad request' something or other. V1.7 TBG support! add &forum=tbg to url for it to work. V1.7.1 Have it use Love-its instead of Likes put &verb=love on the end of the img url to make it work. V1.8 Added first custom style requested by IHeartGaming. V2.0 Finally added Likeable posts! as requested by LS97. V2.1 Added blue colouring for posts, and white colouring for topics V2.1.1 Added Comp500's style request. V3.0 Added Top liked list! V3.0.1 Added Nathanprocks' style request V3.1 Fixed Bug where if two posts had the same amount of likes, they would only use one id between them on the ranks list. V4 Basically a downgrade, new hosts so it will work, basically get rid of the scratchloveit.netne.net and replace it with rookwood101.tkTodo list
Code:
· Star Rating System (Seperate project) · Customisable Button-added requested one, need to make fully user customisable · Add Supporters list support using scratch login api. · Custom Button text (different to Like and Love) · Show rank of post/topic on like button · StatsIt still adds two likes...
err.. no, I added one, and I'm assuming you did aswell, at the same time.
Offline
Pecola1 wrote:
Yay! For some reason the love it in your Sig won't work though... The picture does but not the link.
fixed!
Offline
it says
error:id not found
for me
Offline
rookwood101 wrote:
scratcher7_13 wrote:
rookwood101 wrote:
WE'RE BACK! TO FIX YOUR LIKE BUTTONS, REPLACE scratchloveit.netne.net with rookwood101.tk in the urls of your image tags and url tags
Unfortunately, love it counters have been reset, so you will have to start tallying the up againbut better than nothing eh?
![]()
Hello everyone, Rook here. I've been developing a way for people to "like" forum topics and I'm looking for some testers, all you need to do is click the button below and 'like' this topic. I will also post the source code and how you can add a like button to your own topic.
Click here for Sparks' self updating images and links in posts!!
How the liking system works
The image
This checks a mysql database and shows how many people have clicked the like button
The link
This does something a bit more complicated, first of all it checks to see whether people have liked the topic at all before, if not then it adds a whole new entry into the database this entry has your ip address and the topic id. If people have liked the topic before, it checks whether your ip is on the list of ips for that topic, if not then it adds your ip to the list of ips for that topic. This means that you can only like things once.
Please like this topic to show your support: http://rookwood101.tk/topicrate.php?id= … ;ret=image
and the source code:Code:
<?php function writetextimage($string, $substring) { if ($_REQUEST['type'] == 'post') { $img = imagecreatefrompng ('bgpost.png'); $text_colour = imagecolorallocate($img, 254, 254, 254); } else { $img = imagecreatefrompng ('bg.png'); $text_colour = imagecolorallocate($img, 1, 1, 1); } $font = realpath('font.ttf'); imagettftext($img, 7, 0, 10, imagefontheight(7), $text_colour, $font, $string); imagettftext($img, 7, 0, 10, 28, $text_colour, $font, $substring); $whit = imagecolorallocate($img, 0, 0, 0); imagecolortransparent($img, $whit); header('Content-type: image/png'); imagepng($img); imagecolordeallocate($text_color); imagedestroy($img); } include 'mysql.php'; $topicid = $_REQUEST['id']; $userip = $_SERVER['REMOTE_ADDR']; if ($_REQUEST['forum'] == 'tbg') { $url = 'http://scratch.mit.edu/tbgforums/viewtopic.php?id=' . $topicid; $database = 'tbg_topicrate'; if ($_REQUEST['type'] == 'post') { $url = 'http://scratch.mit.edu/tbgforums/viewtopic.php?pid=' . $topicid . '#p' . $topicid; $database = 'tbg_postrate'; } } else { $url = 'http://scratch.mit.edu/forums/viewtopic.php?id=' . $topicid; $database = 'topicrate'; if ($_REQUEST['type'] == 'post') { $url = 'http://scratch.mit.edu/forums/viewtopic.php?pid=' . $topicid . '#p' . $topicid; $database = 'postrate'; } } if ($_REQUEST['ret'] == 'image') { if (is_numeric($topicid) === false) { writetextimage('Error: id is not valid', ''); exit(); } $urlcontents = trim(file_get_contents($url)); if (strpos($urlcontents, $bdrq) != false) { writetextimage('Error:', 'id not found'); exit(); } mysql_connect($mysql_host, $mysql_user, $mysql_password) or die(mysql_error()); mysql_select_db($mysql_database) or die(mysql_error()); $checkquery = mysql_query("SELECT * FROM $database WHERE postid='$topicid'"); if (mysql_num_rows($checkquery) == 0) { $likes = 0; } else { $topicratings = mysql_fetch_row($checkquery) or die(mysql_error()); $ratedips = explode(',', $topicratings[1]); $likes = count($ratedips); if ($ratedips[0] == '') { $likes = 0; } } if ($likes == 1) { $likes = 1 . ' Like'; if($_REQUEST['verb'] == 'love') { $likes = 1 . ' Love-it'; } } else { if($_REQUEST['verb'] == 'love') { $likes = $likes . ' Love-its'; } else { $likes = $likes . ' Likes'; } } $checkquery = mysql_query("SELECT * FROM $database WHERE postid='$topicid'"); if (mysql_num_rows($checkquery) == 0) { $already_liked = 'Like This'; if ($_REQUEST['verb'] == 'love') { $already_liked = 'Love it?'; } } else { $topicratings = mysql_fetch_row($checkquery) or die(mysql_error()); $ratedips = explode(',', $topicratings[1]); $count = count($ratedips); if ($_REQUEST['verb'] == 'love') { $already_liked = 'Love it?'; } else { $already_liked = 'Like This'; } for($i=0; $i<$count; $i++) { if($ratedips[$i] == $userip) { $already_liked = 'Unlike This'; if ($_REQUEST['verb'] == 'love') { $already_liked = 'I love it!'; } } } } writetextimage($likes, $already_liked); } elseif ($_REQUEST['ret'] == 'add') { if (is_numeric($topicid) === false) { writetextimage('Error: id is not valid', ''); exit(); } $urlcontents = trim(file_get_contents($url)); if (strpos($urlcontents, $bdrq) != false) { writetextimage('Error: id not found', ''); exit(); } $headerurl = 'Location:' . $url; mysql_connect($mysql_host, $mysql_user, $mysql_password) or die(mysql_error()); mysql_select_db($mysql_database) or die(mysql_error()); $checkquery = mysql_query("SELECT * FROM $database WHERE postid='$topicid'"); if (mysql_num_rows($checkquery) == 0) { $addtopic_query = mysql_query("INSERT INTO $database (postid, ips) VALUES ('$topicid', '$userip')"); header($headerurl); exit(); } else { $topicratings = mysql_fetch_row($checkquery) or die(mysql_error()); $ratedips = explode(',', $topicratings[1]); $count = count($ratedips); for($i=0; $i<$count; $i++) { if($ratedips[$i] == $userip) { unset($ratedips[$i]); $ratedips = implode(',', $ratedips); $updateips_query = mysql_query("UPDATE $database SET ips='$ratedips' WHERE postid='$topicid'") or die(mysql_error()); header($headerurl); exit(); } } $ratedips[$count] = $userip; $ratedips2 = implode(',', $ratedips); if ($ratedips[0] == '') { $ratedips2 = $userip; } $updateips_query = mysql_query("UPDATE $database SET ips='$ratedips2' WHERE postid='$topicid'") or die(mysql_error()); header($headerurl); exit(); } } elseif ($_REQUEST['ret'] == 'top') { if($_REQUEST['forum'] == 'tbg') { if ($_REQUEST['type'] == 'post') { $database = 'tbg_postrate'; $type = 'Post'; } else { $database = 'tbg_topicrate'; $type = 'Topic'; } } else { if ($_REQUEST['type'] == 'post') { $database = 'postrate'; $type = 'Post'; } else { $database = 'topicrate'; $type = 'Topic'; } } mysql_connect($mysql_host, $mysql_user, $mysql_password) or die(mysql_error()); mysql_select_db($mysql_database) or die(mysql_error()); $query = mysql_query("SELECT * FROM $database"); for($i=0;$i<mysql_num_rows($query);$i++) { $temp = mysql_fetch_row($query); $postids[$i] = $temp[0]; $ips[$i] = count(explode(',', $temp[1])) . ',' . $i; $ipssort[$i] = $ips[$i]; } rsort($ipssort, SORT_NUMERIC); for($i=0;$i<count($postids);$i++) { if($ips[$i] == $ipssort[$_REQUEST['rank']-1]) { $winnerpost = $postids[$i]; } } if(!isset($ipssort[$_REQUEST['rank']-1])) { writetextimage('Error: Post with that', 'rank doesn\'t exist'); exit(); } if($_REQUEST['verb'] == 'love') { $likes = $likes . ' Love-its'; } else { $likes = $likes . ' Likes'; } $explodedip = explode(',', $ipssort[$_REQUEST['rank']-1]); writetextimage($_REQUEST['rank'] . '.' . " $type " . $winnerpost, $explodedip[0] . $likes); } elseif ($_REQUEST['ret'] == 'toplink') { if($_REQUEST['forum'] == 'tbg') { if ($_REQUEST['type'] == 'post') { $database = 'tbg_postrate'; $url = 'http://scratch.mit.edu/tbgforums/viewtopic.php?pid='; $afterbit = '#p'; } else { $database = 'tbg_topicrate'; $url = 'http://scratch.mit.edu/tbgforums/viewtopic.php?id='; } } else { if ($_REQUEST['type'] == 'post') { $database = 'postrate'; $url = 'http://scratch.mit.edu/forums/viewtopic.php?pid='; $afterbit = '#p'; } else { $database = 'topicrate'; $url = 'http://scratch.mit.edu/forums/viewtopic.php?id='; } } mysql_connect($mysql_host, $mysql_user, $mysql_password) or die(mysql_error()); mysql_select_db($mysql_database) or die(mysql_error()); $query = mysql_query("SELECT * FROM $database"); for($i=0;$i<mysql_num_rows($query);$i++) { $temp = mysql_fetch_row($query); $postids[$i] = $temp[0]; $ips[$i] = count(explode(',', $temp[1])) . ',' . $i; $ipssort[$i] = $ips[$i]; } rsort($ipssort, SORT_NUMERIC); for($i=0;$i<count($postids);$i++) { if($ips[$i] == $ipssort[$_REQUEST['rank']-1]) { $winnerpost = $postids[$i]; } } if(!isset($ipssort[$_REQUEST['rank']-1])) { writetextimage('Error: Post with that', 'rank doesn\'t exist'); exit(); } if (!isset($afterbit)) { $headerurl = $url . $winnerpost; header("Location:$headerurl"); exit(); } else { $headerurl = $url . $winnerpost . $afterbit . $winnerpost; header("Location:$headerurl"); exit(); } } else { writetextimage('Error: incorrect URL vars used', 'Better luck next time!'); } ?>This took a long time to write so please support me!
I'd like to thank LS97 for the writetextimage() code and Sparks for his inspirational API thread.
Right, now for how you can add it to your posts.
First off you need to make a url tag with the url http://rookwood101.tk/topicrate.php?id=TOPIC ID HERE&ret=add to find the topic id, you must first make the post, go out to the forums section your topic is in, click on your topic and you'll see in the url bar something like scratch.mit.edu/forums/viewtopic.php?id=# where # is a number, you need to copy this number and put it in the TOPIC ID HERE.
So far we haveCode:
[url=http://rookwood101.tk/topicrate.php?id=TOPIC ID HERE&ret=add][/url]Now for the image part
Basically you use the same id but you use an image tag and the url is slightly different soCode:
[url=http://rookwood101.tk/topicrate.php?id=TOPIC ID HERE&ret=add][url]http://rookwood101.tk/topicrate.php?id=TOPIC ID HERE&ret=image[/url][/url]notice ret=image now rather than ret=add.
To have a like button that likes a tbg forum topic, just add &forum=tbg to the url for both image and link. To make it use love-its instead of likes (changes the text) then add &verb=love onto the end of the image url only. this is what it looks like: http://rookwood101.tk/topicrate.php?id= … ;verb=love
Make sure to check out Sidharth's Javascript code that automatically generates the code for you based on the url of your post! Here it ishttp://rookwood101.tk/topicrate.php?id= … ;type=post and you can like it using the new likeable posts feature (see below on how to implement yourself)!
Which brings us nicely onto the new:
Likeable Posts!
So, you've made a post in a topic that you think everyone will like, and want to show there thanks, but the like button only supports topics. Well not anymore!
You can now have likeable posts, all you have to do is use the same code as topics, except change the id to the id of your post. To find this out, when you make a post, check (once you've posted it) what your url bar says, it will have on the end something like #p123456 you need to copy the number bit of it (in this case 123456) and put that as the id in my codeCode:
[url=http://rookwood101.tk/topicrate.php?id=POST ID HERE&ret=add&type=post][url]http://rookwood101.tk/topicrate.php?id=POST ID HERE&ret=image&type=post[/url][/url]then, as you can see here you put on the end of each of the urls (image and link) &type=post this is to tell my script that you're talking about a post and not a topic. If you leave this blank then it will think it is a topic, and either it won't work, or you will be liking some random topic.
Well, we're done! I hope you like this new feature!
Custom like button styles
So, you like the idea of 'like buttons' but don't like the style they're in?
Introducing:
Custom made like buttons
Basically, you tell me the style of button you want, font, background shape, colours etc. and I make it for you, adding it as an option in the URL of the image eg. stl=1 meaning style = style no.1. I might add the option to change the font colour & size from the URL, it all depends on how many custom requests I get.
Current Styles:
Style 1 - http://rookwood101.tk/topicrate.php?id= … ;ret=image Style 1 is default, no extra code needed
Style 2 - http://rookwood101.tk/topicrate.php?id= … mp;style=2 add &style=2 to the end of the image url to enable this style. Requested by IHeartGaming.
Style 3 - http://rookwood101.tk/topicrate.php?id= … mp;style=3 add &style=3 to the end of the image url to enable this style. Requested by Comp500.
Style 4 - http://rookwood101.tk/topicrate.php?id= … mp;style=4 add &style=4 to the end of the image url to enable this style. Requested by Nathanprocks.
Top liked rankings
See This Post for more info.
Thanks,
Rook
ChangelogCode:
V1.0 First Release, allows you to add like buttons to forum topics and like them. V1.1 Changed text size & Added redirect to topic V1.5 Added unlike feature so that if you liked something in the past you can change your mind and take away the like also added small text saying either like or unlike to show you what would happen if you clicked the link. V1.5.1 Bug Fixes, such as now displays image of Error messages and I had a couple of variables set the wrong way round. V1.6 Prettier like button, thanks LS97! V1.6.1 Fixed a bug where people could like topics even if they didn't exist also put the mysql details in a seperate file along with a variable that holds the string 'Bad request' something or other. V1.7 TBG support! add &forum=tbg to url for it to work. V1.7.1 Have it use Love-its instead of Likes put &verb=love on the end of the img url to make it work. V1.8 Added first custom style requested by IHeartGaming. V2.0 Finally added Likeable posts! as requested by LS97. V2.1 Added blue colouring for posts, and white colouring for topics V2.1.1 Added Comp500's style request. V3.0 Added Top liked list! V3.0.1 Added Nathanprocks' style request V3.1 Fixed Bug where if two posts had the same amount of likes, they would only use one id between them on the ranks list. V4 Basically a downgrade, new hosts so it will work, basically get rid of the scratchloveit.netne.net and replace it with rookwood101.tkTodo list
Code:
· Star Rating System (Seperate project) · Customisable Button-added requested one, need to make fully user customisable · Add Supporters list support using scratch login api. · Custom Button text (different to Like and Love) · Show rank of post/topic on like button · StatsIt still adds two likes...
err.. no, I added one, and I'm assuming you did aswell, at the same time.
It adds two every time.
Offline
joefarebrother wrote:
it says
error:id not found
for me
Can you give me an example of the code you are using? I'm assuming you've put a post id instead of a topic id, to use post ids, you have to put &type=post onto the end of your urls
Offline
it is this topic and my code is
[url=http://rookwood101.tk/topicrate.php?id=855724&ret=add][img]http://rookwood101.tk/topicrate.php?id=855724&ret=image[/img][/url]
Offline
the link you gave me was for a post, so you need to either put:
&type=post
on the end of your urls (after &ret=image OR &ret=add) OR set the id to 70231.
Offline
comp500 wrote:
lol rockwood101.tk doesnt work because of too many viesw loooooooooooooooooool
er... yes it does...
Offline
rookwood101 wrote:
comp500 wrote:
lol rockwood101.tk doesnt work because of too many viesw loooooooooooooooooool
er... yes it does...
redirects to http://www.search.tk/index.html&_=1317796799
Offline
Thats because it's rookwood101.tk not rockwood101.tk
Offline
comp500 wrote:
the styles dont work now. D:
Nope.
@sidharth thanks!
Offline
rookwood101 wrote:
comp500 wrote:
the styles dont work now. D:
Nope.
@sidharth thanks!
and you need to transfer database.
Offline
comp500 wrote:
rookwood101 wrote:
comp500 wrote:
the styles dont work now. D:
Nope.
@sidharth thanks!and you need to transfer database.
the database is lost, when they suspended my account I was given no access to any of it.
Offline