headerim
<?php if (isset($_GET['page']) && $_GET['page']=='view'): ?>
<meta property="og:title" content="<?php echo ogmeta($_GET['id'], 'title') ?>">
<meta property="og:description" content="<?php echo ogmeta($_GET['id'], 'description' ) ?>">
<meta property="og:url" content="<?php echo ogmeta($_GET['id'], 'url') ?>">
<meta property="og:image" content="<?php echo ogmeta($_GET['id'], 'photo') ?>sss"/>
<meta property="og:site_name" content="<?php echo $_SERVER['HTTP_HOST'] ?>">
<?php endif; ?>function.php
require 'db.php;
function ogmeta($id,$arr){
GLOBAL $db;
$select=$db->prepare("SELECT *, items.id as iid, estatetype.name as ename, estatetype.id as eid from items RIGHT JOIN estatetype ON items.estatetype=estatetype.id where items.id=?");
$select->execute(array($id));
$row=$select->fetch(PDO::FETCH_ASSOC);
if($arr=='description'){
$text=$row['info'];
}elseif($arr='url'){
$text=$_SERVER["HTTP_HOST"].'/elan-'.$id.'-'.$row['seo'];
}elseif($arr='photo'){
$photo=$db->prepare("SELECT * from photo where itemid=? order by row ASC LIMIT 1");
$photo->execute((array($id)));
$prow=$photo->fetch(PDO::FETCH_ASSOC);
$text=$prow['src'];
}
return $text;
}