• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

Facebook "Like" System - Website Addon

Junior Spellweaver
Joined
May 2, 2010
Messages
120
Reaction score
10
I'm not releasing a function to add a person's "like" to your "likes" column in web_events/web_news table, if you can't do that you shouldn't be using this.

PHP:
    /**
	 * This function will remove all the specified values from an array and return the final array.
	 * Arguments :    The first argument is the array that should be edited
	 *                The arguments after the first argument is a list of values that must be removed.
	 * Example : array_remove_value($arr,"one","two","three");
	 * Return : The function will return an array after deleting the said values
	 * This is not my function, i got it from some random site.
	 */
	function array_remove_value() {
	    $args = func_get_args();
	    $arr = $args[0];
	    $values = array_slice($args,1);
	
	    foreach($arr as $k=>$v) {
	        if(in_array($v, $values)) {
	            unset($arr[$k]);
	        }
	    }
	
	    return $arr;
	}

    /**
	 * Credits : Trahb
	 * To use: Create a function to add " $userName" to a column of "likes" in your web_events or web_news table
	 * Where $userName is the name of the user that "likes" the post.  There MUST be a space before the name
	 * For this function to work properly.
	 * @param $type - "news" or "events"
	 * @param $id is the id of $type
	 */
	function showLikes($type, $id) {
		$a = mysql_query("SELECT * FROM `web_$type` WHERE `id`='$id'") or die(mysql_error());
		$b = mysql_fetch_array($a);
		if ($b['likes'] != NULL) {
			$q = mysql_query("SELECT * FROM `web_$type` WHERE `id`='$id'") or die(mysql_error());
			$d = mysql_fetch_array($q);
			$l = explode(" ", $d['likes']);
			$people = count($l);
			$like = "";
			$n = 0;
			$pname = (isset($_SESSION['pname']) ? $_SESSION['pname'] : " ");
			if (in_array($pname, $l)) {
				if ($people == 1) {
					$like .= "You";
				} else if ($people == 2){
					$like .= "You and ";
				} else {
					$like .= "You, ";
				}
			}
			// Now that it has already checked to see if "You" is involved, you can get rid of it :)
			$l = $this->array_remove_value($l, $pname, "");
			$people = count($l); // Now count how many there are left.
			if ($people > 1) {
				foreach ($l as $name) { // Go through all "likes"
					if ($name != $_SESSION['pname'] && $name != "") {
						$n++;
						$name = $this->userHandler->userLink($name);
						if ($n < $people) {
							// If there are more than two people (and it's not the last name entered) use commas
							if ($people > 2) {
								// If there are MORE THAN 2 and it is on the second to last, add a space
								if ($n == $people) {
									$like .= " ";
								// If it's on anything OTHER THAN the second to last, add a comma
								} else {
									$like .= $name.", ";
								}
							// If there are only 2 people
							} else {
								$like .= $name." ";
							}
						// If $n is equal to the number of people
						} else if ($n == $people) {
							$like .= "and ".$name;
					}
					}
				}
			// If there is only one person that likes it, and it isn't "You"
			} else {
				if ($like != "You") {
					$like .= $this->userHandler->userLink($l[1]);
				}
			}
			$like .= ($people == 1 ? ($like == "You" ? " like this." : " likes this.") : " like this.");
			return $like;
		}
	}
 
may web.very maple.pls.
Loyal Member
Joined
Aug 12, 2009
Messages
1,810
Reaction score
606
i don't get whats this, and show some ss or explain what is it o.o
 
Infraction Baɴɴed
Loyal Member
Joined
Apr 9, 2008
Messages
1,416
Reaction score
169
interesting because i thought this was MapleStory.
 
Junior Spellweaver
Joined
May 2, 2010
Messages
120
Reaction score
10
Oh and forgot one thing, the "userLink" function just returns a URL and displays the users name, so you can get rid of that and just replace it with their name.
 

Attachments

  • likes - Facebook "Like" System - Website Addon - RaGEZONE Forums
    likes.png
    6.8 KB · Views: 297
may web.very maple.pls.
Loyal Member
Joined
Aug 12, 2009
Messages
1,810
Reaction score
606
Ohh its like the thanks system here at ragezone?
 
may web.very maple.pls.
Loyal Member
Joined
Aug 12, 2009
Messages
1,810
Reaction score
606
I see nice release i guess o.o
i might use for my CMS
 
Junior Spellweaver
Joined
May 2, 2010
Messages
120
Reaction score
10
The only difference is mine lists them all, uses "and" when necessary, and says "like(s) this" at the end. It doesn't actually have the (s) on it, it decides which is appropriate and uses it.
 
may web.very maple.pls.
Loyal Member
Joined
Aug 12, 2009
Messages
1,810
Reaction score
606
WELL ITS GOOD BUT I PREFER THE OLD FASHION WAY =p
(sorry on caps, to lazy to rewrite that xD)
OMG HAII JOHNNY <33
 
Custom Title Activated
Loyal Member
Joined
Nov 27, 2009
Messages
1,905
Reaction score
948
Leave facebook at facebook.com, please!
 
Junior Spellweaver
Joined
May 2, 2010
Messages
120
Reaction score
10
Do you have to be logged onto facebook to "like" the posts?

Oh jeez. I hope it wasn't this vague for everyone. No, what this does is reads from your SQL file and breaks all of the different names into an array. Then from that array it displays them grammatically correct.

It's for use in a CMS. For example, you could make a system where users can "like" your news updates or comments, just things like that.

It has nothing to do with the actual Facebook.
 
Legendary Battlemage
Loyal Member
Joined
Jul 13, 2009
Messages
671
Reaction score
139
Ah, why did you call it Facebook "like" lol.
Just something like "Like System", would've been better.

Because the concept was from Facebook.
 
Junior Spellweaver
Joined
Sep 30, 2009
Messages
180
Reaction score
76
the fact that 3/4 of you guys thought this was linked to facebook shows what has become of the devlopment section today...

nonetheless gj trahb
 
Back
Top