When I checked the ScratchBB and Loves/Hates about the forums threads, I noticed people want a like button. I also realized that I have one ready, with only a few tweaks for a post. I have already made the tweaks and it is ready for use. Here's how it works:
Like counter:
<img src="http://like.cfagency.org/scratchbb/counter.php?pid=postIdHere" />
Like button:
<a href="http://like.cfagency.org/scratchbb/like.php?pid=postIdHere"><img src="http://like.cfagency.org/scratchbb/like.png" /></a>
The code is shown in HTML because that's how it would be implemented into ScratchBB. Thanks for your attention and time.
Offline
jvvg wrote:
Is there any way you could convert that into BBCode for our user signatures (like in yours)?
Yes. I can. That code doesn't currently work because it has been modified for ScratchBB, but the original works in signatures. Here it is:
[url=http://like.cfagency.org/like.php?site=referer][i mg]http://like.cfagency.org/like.png[/im g][/url] [i mg]http://like.cfagency.org/counter.php?site=referer[/im g] people like this.
You need to remove the spaces in the IMG tags.
Offline
Hi. I am Zeus. ScratchBB human resources team.
I like the idea of like counters. I would love to implement this in the software. Wait while I implement this. Be back in 10 mins.
Zeusking19
ScratchBB Team
Offline
Hi again, Zeus from ScratchBB human resources.
I need the server-side code as well as the html. We need to have our own server side code implemented so ScratchBB dosnt have to contact the outside world.
If the server side requires SQL code, we will implement that to our install.sql script.
Offline
Server side... well, here goes nothing:
counter.php (Counter image script):
<?php
mysql_connect("mysql host", "mysql username", "*********");
mysql_select_db("sqldb");
$post = $_GET["pid"];
$count = mysql_numrows(mysql_query("SELECT * FROM table WHERE post_id = '$post'"));
$count = strval($count);
$digits = strlen($count);
$width = 9.5 * $digits;
$img = imagecreate($width, 15);
$white = imagecolorallocate($img, 255, 255, 255);
$black = imagecolorallocate($img, 0, 0, 0);
imagecolortransparent($img, $white);
imagestring($img, 5, 0, 0, $count, $black);
header("Content-type: image/png");
imagepng($img);
?>
like.php
<?php
mysql_connect(sql info);
mysql_select_db("sqldb");
$post = $_GET["pid"];
$ip = $_SERVER["REMOTE_ADDR"];
if(mysql_numrows(mysql_query("SELECT * FROM table WHERE ip = '$ip' AND post_id = '$post'")) > 0) {
header("Location: ".$_SERVER["HTTP_REFERER"]);
}
else {
mysql_query("INSERT INTO table VALUES (null, '$ip', '$post')") or die(mysql_error());
header("Location: ".$_SERVER["HTTP_REFERER"]);
}
?>
like.png
On ImageShack:
Or link: http://img84.imageshack.us/img84/8777/likezb.png
EDIT: for the code, you might want to qoute this to extract the code. Also, green stuff means you need to change it to your MySQL info.
Last edited by GeonoTRON2000 (2012-04-08 16:56:30)
Offline
SQL Code:
CREATE TABLE `scratchbb_likes` ( `id` bigint(255) NOT NULL AUTO_INCREMENT, `ip` varchar(15) COLLATE latin1_general_ci NOT NULL, `post_id` varchar(255) COLLATE latin1_general_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=1 ;
Offline
Squawkers13 wrote:
you need to move your imgs before it will work
To where?
EDIT: OH! IN THE CODE!
Last edited by GeonoTRON2000 (2012-04-08 16:58:01)
Offline
Ah, you're the one who created this?
I really enjoy this button, it's the better version of this, IMHO.
Offline
Offline