1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
<?php require_once '../webadmin/configure.php';
if (isset($_GET['id'])) $id = $_GET['id'];
$news = News::whereRaw("deleted=? and status=? and id=?", array(0, 1, $id))->first();
$url = $_SERVER['REQUEST_URI']; $parts = explode('/',$url); $dir = $_SERVER['SERVER_NAME']; for ($i = 0; $i < count($parts) - 1; $i++) { $dir .= $parts[$i] . "/"; }
$actual_link = "http://".$dir."news.php?id=".$id;
$shortdesc = $news['shortdesc_tc']; //$shortdesc = preg_replace("/<img[^>]+\>/i", "", $shortdesc);
preg_match('/<img.+src=[\'"](?P<src>.+?)[\'"].*>/i', $shortdesc, $image); //Del all tag $shortdesc = preg_replace('/<(|\/)(?!\?).*?(|\/)>/', "", $shortdesc);
$path = $image['src'];
$pic = ""; if ($path != ""){ $pic = rel2abs($path, $actual_link); } else{ $url = $_SERVER['REQUEST_URI']; $parts = explode('/',$url); $dir = $_SERVER['SERVER_NAME']; for ($i = 0; $i < count($parts) - 1; $i++) { $dir .= $parts[$i] . "/"; }
$pic = "http://".$dir."headLogo.jpg"; }
//echo $pic;
function rel2abs($rel, $base) { /* return if already absolute URL */ if (parse_url($rel, PHP_URL_SCHEME) != '') return $rel;
/* queries and anchors */ if ($rel[0]=='#' || $rel[0]=='?') return $base.$rel;
/* parse base URL and convert to local variables: $scheme, $host, $path */ extract(parse_url($base));
/* remove non-directory element from path */ $path = preg_replace('#/[^/]*$#', '', $path);
/* destroy path if relative url points to root */ if ($rel[0] == '/') $path = '';
/* dirty absolute URL */ $abs = "$host$path/$rel";
/* replace '//' or '/./' or '/foo/../' with '/' */ $re = array('#(/\.?/)#', '#/(?!\.\.)[^/]+/\.\./#'); for($n=1; $n>0; $abs=preg_replace($re, '/', $abs, -1, $n)) {}
/* absolute URL is ready! */ return $scheme.'://'.$abs; } ?>
<!DOCTYPE html> <html lang="en">
<head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, user-scalable=yes"> <title><?= _h($news['name_tc']) ?></title>
<link rel="shortcut icon" href="../images/headLogo.jpg"> <link rel="stylesheet" type="text/css" href="../css/post.css"> <meta property="og:url" content="<?= $actual_link ?>" /> <meta property="og:type" content="website" /> <meta property="og:title" content="<?= _h($news['name_tc']) ?>" /> <meta property="og:description" content="<?= $shortdesc ?>" /> <meta property="og:image" content="<?= $pic ?>" /> </head> <body> <div id="fb-root"></div> <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/zh_TW/sdk.js#xfbml=1&version=v2.7"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script>
<div class="popIframe"> <h1><?= _h($news['name_tc']) ?></h1> <div class="popText"><?= $news['desc_tc'] ?></div> <br/><br/> <div class="shareFB"> <div class="fb-share-button" data-href="<?= $actual_link ?>" data-layout="button_count" data-size="large"> </div> </div> </div> </body>
</html>
|