forgot password?
need an account?

Notifications close x

WI2 add on Sharing Posts

loading social widgets...
LewisAndersonWritten By: LewisAnderson   flag
Publish Date: December 10, 2014
Code snippets... template_status.php
$shareButton = ""; if($log_username != "" && $author != $log_username && $account_name != $log_username){ $shareButton = '<a href="#" onclick="return false;" onmousedown="shareStatus(''.$statusid.'');" title="SHARE THIS">Share This</a>'; }
and.... from this...
$statuslist .= '<div id="status_'.$statusid.'" class="status_boxes"><div><b>Posted by <a href="user.php?u='.$author.'">'.$author.'</a> '.$postdate.':</b> '.$statusDeleteButton.' <br />'.$data.'</div>'.$status_replies.'</div>';
to this...
$statuslist .= '<div id="status_'.$statusid.'" class="status_boxes"><div><b>Posted by <a href="user.php?u='.$author.'">'.$author.'</a> '.$postdate.':</b> '.$statusDeleteButton.' '.$shareButton.'<br />'.$data.'</div>'.$status_replies.'</div>';
and the function
function shareStatus(id){ var ajax = ajaxObj("POST", "php_parsers/status_system.php"); ajax.onreadystatechange = function() { if(ajaxReturn(ajax) == true) { if(ajax.responseText == "share_ok"){ alert("Thanks for Sharing!"); } else { alert(ajax.responseText); } } } ajax.send("action=share&id="+id); }
now for the code for php_parsers/status_system.php
<?php if (isset($_POST['action']) && $_POST['action'] == "share"){ if(!isset($_POST['id'])){ mysqli_close($db_conx); echo "fail"; exit(); } $id = preg_replace('#[^0-9]#', '', $_POST['id']); if($id == ""){ mysqli_close($db_conx); echo "fail"; exit(); } $sql = "SELECT author, data FROM status WHERE id='$id' LIMIT 1"; $query = mysqli_query($db_conx, $sql); $numrows = mysqli_num_rows($query); if($numrows < 1){ mysqli_close($db_conx); echo "fail"; exit(); } $row = mysqli_fetch_row($query); $data = "<br /><b>Shared via $row[0]</b><br /><hr><br />"; $data .= $row[1]; $sql = "INSERT INTO status(account_name, author, type, data, postdate) VALUES('$log_username','$log_username','a','$data',now())"; $query = mysqli_query($db_conx, $sql); mysqli_close($db_conx); echo "share_ok"; exit(); } ?>
You can read more articles by LewisAnderson by clicking this link:
Articles written by LewisAnderson

User Notes And Comments ↓

Wednesday December 10, 2014 12:04:41 PM
Adam said:Nice man. We are going to all owe you money if you expose many more development tactics.
Thursday December 11, 2014 04:51:47 AM
LewisAnderson said:lol, I only accept bacon as currency..... mmmmmmm bacon. They have bitcoin... where is the baconbitCoin? hahaha
Tuesday December 23, 2014 12:57:59 PM
jameslll said:theres an error in the 'id' osid' on the database, OSID needs to be set to ID. just like POST TO STATUS PHP.
Wednesday May 18, 2016 03:59:34 PM
herbertbruce8gm said:Thanks Lewis am happy to meet right people in right community
© 2015
There is a top-shelf free educational course of videos associated with this domain, all about how to build custom communities and social network websites. There are over 45 videos in the course totaling just over 10 hours. We also archived the deprecated course material here for you to reference on the source files page.