[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

same facebook comment in dynamic php pages

Posted on 2012-09-17
1
Medium Priority
?
662 Views
Last Modified: 2012-09-18
Im trying to use the facebook comment plugin in several php dynamic pages

I use the same page (vacio.php) to show the content, if the previous page is from facebook the page shows his own format but if the previous page came from our webpages (the administration site or the public site) show another format.

This is the code of vacio.php
<?php require_once('database.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_rs_dbnotes = "-1";
if (isset($_GET['rpl'])) {
    $temp=split(":",$_GET['rpl']);
  $origen = $temp[1];	
  $colname_rs_dbnotes = $temp[0];
}
mysql_select_db($database_dbnotes, $dbnotes);
$query_rs_dbnotes = sprintf("SELECT * FROM videos WHERE clave = %s", GetSQLValueString($colname_rs_dbnotes, "text"));
$rs_dbnotes = mysql_query($query_rs_dbnotes, $dbnotes) or die(mysql_error());
$row_rs_dbnotes = mysql_fetch_assoc($rs_dbnotes);
$totalRows_rs_dbnotes = mysql_num_rows($rs_dbnotes);
?>
<html>
<head>
<meta http-equiv="Content-Language" content="es-mx">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>VIDEO DE GRUPO SSC</title>
<div id="fb-root"></div>
<LINK id=mail href="http://www.grupossc.com/contenidos/mail.css" type=text/css rel=stylesheet>
<LINK id=estilos href="http://www.grupossc.com/contenidos/estilos.css" type=text/css rel=stylesheet>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/es_MX/all.js#xfbml=1&appId=xxxxxxxxxxx";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>


</head>

<body>
<?php if ($origen == 0) { // Viene de facebook ?>
<div align="center">
							<table border="0" width="684" cellspacing="0" cellpadding="0">
								<tr>
									<td width="684">
										<img border="0" src="http://www.grupossc.com/imagenes/ctrans.gif" width="1" height="5"></td>
								</tr>
								

								<tr>
									<td width="684" bgcolor="#F2F2F2" align="right">
										<font class="mapa">&nbsp;
                                        <?php
                                        if ($row_rs_dbnotes['album'] == "1")
											{ echo '<a style="color: 000080; text-decoration: underline" href="https://www.grupossc.com/facebook/videos/index.php?rpl=1">GRUPO SSC</a>';}
											else if ($row_rs_dbnotes['album'] == "2")
											{ echo '<a style="color: 000080; text-decoration: underline" href="https://www.grupossc.com/facebook/videos/index.php?rpl=2">NUESTROS CLIENTES</a>';}
                                            
                                          ?>  
                                            &nbsp;&nbsp; &gt;&nbsp;&nbsp;<font color="#C0C0C0"><?php echo $row_rs_dbnotes['titulo']; ?></font></font></td>
								</tr>
								<tr>
									<td width="684">
									<img width="1" height="5" border="0" src="http://www.grupossc.com/imagenes/ctrans.gif"></td>
								</tr>
							</table>
<table border="0" width="684" cellspacing="0" cellpadding="0" height="560">
	<tr>
		<td width="684" height="560" align="center"><?php echo $row_rs_dbnotes['liga']; ?></td>
		
	</tr>
	<tr>
		<td width="684" align="left"><font class="cuerpo_central1"><b><?php echo $row_rs_dbnotes['titulo']; ?></b></font></td>
		
	</tr>
    	<tr>
		<td width="684" align="left"><font class="cuerpo_central1"><?php echo $row_rs_dbnotes['resumen']; ?></font></td>
		
	</tr>
			  <tr><td width="684" valign="top" align="center"><img border="0" src="http://www.grupossc.com/imagenes/ctrans.gif" width="1" height="4" style="display:block;"></td></tr>
			  	  
		  <tr><td width="684" valign="top" align="center"><img border="0" src="http://www.grupossc.com/imagenes/linea2.jpg" width="686" height="1"></td></tr>
		  
				  <tr><td width="684" valign="top" align="center"><img border="0" src="http://www.grupossc.com/imagenes/ctrans.gif" width="1" height="1" style="display:block;"></td></tr>
	<tr>
		<td width="684" align="center"><?PHP    
$url = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
echo "<div class='fb-comments' data-href='$url' data-num-posts='10' data-width='684'></div>";
?>
</td>
		
	</tr>    
</table></td>
	</tr>
</table>
</div>
 <?php } // Viene de facebook ?>
 
 <?php if ($origen == 1) { // No viene de facebook ?>
<table border="0" width="1024" cellspacing="0" cellpadding="0" height="560">

	<tr>
		<td width="684" height="560" rowspan="2" align="center"><?php echo $row_rs_dbnotes['liga']; ?></td>
		<td width="340" height="322" valign="top" bgcolor="#FFFFFF"><font class="cuerpo_central1"><b><?php echo $row_rs_dbnotes['titulo']; ?></b></font><br><font class="cuerpo_central1"><?php echo $row_rs_dbnotes['resumen']; ?></font></td>
	</tr>
	<tr>
		<td width="340" height="238" valign="top" align="center" bgcolor="#FFFFFF">        <div style="padding: 0; margin: 0; overflow: auto; height: 238px; width: auto; border: none;">

<?PHP    
$url = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
echo "<div class='fb-comments' data-href='$url' data-num-posts='10' data-width='300'></div>";
?>
</td>
	</tr>

</table></td>
	</tr>
</table>
 <?php } // No viene de facebook ?>
 
</body>
</html>
<?php
mysql_free_result($rs_dbnotes);
?>

Open in new window


This is the problem:
If you try to enter to the same php dynamic page from facebook or our websites the comments that you enter in facebook doesnt show in our websites and viceversa

for example if you enter from facebook this is the link: http://www.grupossc.com/2012/vacio.php?rpl=181121546:0

and this is the link if you access from our websites: http://www.grupossc.com/2012/vacio.php?rpl=181121546:1

The diference is the number at the end of the link, it means wich is the previous page

If you access from facebook, shows no comments
example1
if you access from our websites, it shows comments
example2
I would like to know what I need to do that if I add a comment to one of this dynamic pages, this comment stays if I access to the same page from facebook of viceversa
0
Comment
Question by:altariamx2003
1 Comment
 

Accepted Solution

by:
altariamx2003 earned 0 total points
ID: 38410481
I found the solution.

The problem was the dynamic url that I use in our websites.

The solution is to use the same link in every site.

Also because I need to change the format if the previous page is facebook or our websites I add this lines

<?php $previo =  $_SERVER['HTTP_REFERER']; 

$pos = strrpos($previo, "facebook");
?>

Open in new window


if pos is greater than 0 the previous page came from the facebook site else came from our public sites.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
An introduction to the wonderful sport of Scam Baiting.  Learn how to help fight scammers by beating them at their own game. This great pass time helps the world, while providing an endless source of entertainment. Enjoy!
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses
Course of the Month18 days, 9 hours left to enroll

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question