영카트 5.4 버전 내용 적용
This commit is contained in:
254
plugin/debugbar/debugbar.php
Normal file
254
plugin/debugbar/debugbar.php
Normal file
@ -0,0 +1,254 @@
|
||||
<?php
|
||||
if (!defined('_GNUBOARD_')) exit;
|
||||
|
||||
add_stylesheet('<link rel="stylesheet" href="'.G5_PLUGIN_URL.'/debugbar/style.css">', 0);
|
||||
?>
|
||||
<style>
|
||||
<?php if (defined('G5_IS_ADMIN') && G5_IS_ADMIN){ ?>
|
||||
.debug_bar_wrap{z-index:991001}
|
||||
<?php } ?>
|
||||
</style>
|
||||
<div class="debug_bar_wrap">
|
||||
<div class="debug_bar_text_group">
|
||||
<div class="debug_bar_btn_group"><button class="view_debug_bar debug_button">디버그</button></div>
|
||||
<div class="debug_bar_text">
|
||||
<?php echo 'PHP 실행시간 : '.$php_run_time.' | 메모리 사용량 : '.number_format($memory_usage).' bytes'; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="debug_bar_content">
|
||||
<div class="content_inner">
|
||||
|
||||
<div class="debugbar_close_btn_el"><button class="debugbar_close_btn btn">닫기</button></div>
|
||||
<div id="debugbar">
|
||||
<ul class="debugbar_tab">
|
||||
<li class="debug_tab active" data-tab="executed_query"><a href="#debug_executed_query">SQL Query</a></li>
|
||||
<li class="debug_tab" data-tab="hook_info"><a href="#debug_hook_info">HOOK 정보</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div id="debug_executed_query" class="inner_debug">
|
||||
<h3 class="query_top">
|
||||
총 쿼리수 : <span><?php echo isset($g5_debug['sql']) ? count($g5_debug['sql']) : 0; ?></span>
|
||||
</h3>
|
||||
|
||||
<div class="sql_query_list">
|
||||
<table class="debug_table">
|
||||
<caption>
|
||||
쿼리 목록
|
||||
</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">실행순서</th>
|
||||
<th scope="col">쿼리문</th>
|
||||
<th scope="col">실행시간</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach((array) $g5_debug['sql'] as $key=>$query){
|
||||
|
||||
if( empty($query) ) continue;
|
||||
|
||||
$executed_time = $query['end_time'] - $query['start_time'];
|
||||
$show_excuted_time = number_format((float)$executed_time * 1000, 2, '.', '');
|
||||
?>
|
||||
<tr>
|
||||
<td scope="row" data-label="실행순서"><?php echo $key; ?></td>
|
||||
<td class="left" data-label="쿼리문"><?php echo $query['sql']; ?></td>
|
||||
<td data-label="실행시간"><?php echo $show_excuted_time.' ms'; ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="debug_hook_info" class="inner_debug">
|
||||
<?php
|
||||
$event_totals = get_hook_datas('event');
|
||||
$event_callbacks = get_hook_datas('event', 1);
|
||||
$replace_totals = get_hook_datas('replace');
|
||||
$replace_callbacks = get_hook_datas('replace', 1);
|
||||
?>
|
||||
<div class="hook_list">
|
||||
|
||||
<div class="debug_table_wrap">
|
||||
<table class="debug_table hook_table">
|
||||
<caption>
|
||||
HOOK 목록
|
||||
</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" width="20%">event_tag (갯수)</th>
|
||||
<th scope="col" width="60%">event_function</th>
|
||||
<th scope="col" width="10%">인수의 수</th>
|
||||
<th scope="col" width="10%">우선 순위</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<?php
|
||||
foreach((array) $event_totals as $tag=>$count){
|
||||
|
||||
if( $tag === 'count' ) continue;
|
||||
if( empty($count) ) continue;
|
||||
|
||||
$datas = array();
|
||||
if( isset($event_callbacks[$tag]) ){
|
||||
|
||||
$event_callbacks_tag = $event_callbacks[$tag];
|
||||
ksort($event_callbacks_tag);
|
||||
|
||||
foreach((array) $event_callbacks_tag as $priority=>$event_args){
|
||||
if( empty($event_args) ) continue;
|
||||
|
||||
foreach($event_args as $index=>$funcs){
|
||||
$datas[] = array(
|
||||
'priority' => $priority,
|
||||
'function' => $funcs['function'],
|
||||
'arguments' => $funcs['arguments'],
|
||||
);
|
||||
} //end foreach
|
||||
} //end foreach
|
||||
|
||||
$rowspan = $datas ? ' rowspan='.count($datas) : '';
|
||||
|
||||
$is_print = $rowspan;
|
||||
|
||||
foreach($datas as $data){
|
||||
?>
|
||||
<tr>
|
||||
<?php if ($is_print){ ?>
|
||||
<td scope="row" data-label="event_tag" <?php echo $rowspan; ?>><?php echo $tag.' <span class="hook_count">('.$count.')</span>'; ?></td>
|
||||
<?php } ?>
|
||||
<td data-label="event_function">
|
||||
<?php echo $data['function']; ?>
|
||||
</td>
|
||||
<td data-label="인수의 수"><?php echo $data['arguments']; ?></td>
|
||||
<td data-label="우선 순위"><?php echo $data['priority']; ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
$is_print = '';
|
||||
} //end foreach
|
||||
} else { // else if
|
||||
?>
|
||||
<tr>
|
||||
<td scope="row" data-label="event_tag"><?php echo $tag.' <span class="hook_count">('.$count.')</span>'; ?></td>
|
||||
<td data-label="event_function"> </td>
|
||||
<td data-label="인수의 수"> </td>
|
||||
<td data-label="우선 순위"> </td>
|
||||
</tr>
|
||||
<?php
|
||||
}//end if
|
||||
} //end foreach
|
||||
?>
|
||||
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="debug_table_wrap">
|
||||
<table class="debug_table hook_table">
|
||||
<caption>
|
||||
HOOK 목록
|
||||
</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" width="20%">replace_tag (갯수)</th>
|
||||
<th scope="col" width="60%">replace_function</th>
|
||||
<th scope="col" width="10%">인수의 수</th>
|
||||
<th scope="col" width="10%">우선 순위</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<?php
|
||||
foreach((array) $replace_totals as $tag=>$count){
|
||||
|
||||
if( $tag === 'count' ) continue;
|
||||
if( empty($count) ) continue;
|
||||
|
||||
$datas = array();
|
||||
if( isset($replace_callbacks[$tag]) ){
|
||||
|
||||
$replace_callbacks_tag = $replace_callbacks[$tag];
|
||||
ksort($replace_callbacks_tag);
|
||||
|
||||
foreach((array) $replace_callbacks_tag as $priority=>$replace_args){
|
||||
if( empty($replace_args) ) continue;
|
||||
|
||||
foreach($replace_args as $index=>$funcs){
|
||||
$datas[] = array(
|
||||
'priority' => $priority,
|
||||
'function' => $funcs['function'],
|
||||
'arguments' => $funcs['arguments'],
|
||||
);
|
||||
} //end foreach
|
||||
} //end foreach
|
||||
|
||||
$rowspan = $datas ? ' rowspan='.count($datas) : '';
|
||||
|
||||
$is_print = $rowspan;
|
||||
|
||||
foreach($datas as $data){
|
||||
?>
|
||||
<tr>
|
||||
<?php if ($is_print){ ?>
|
||||
<td scope="row" data-label="replace_tag" <?php echo $rowspan; ?>><?php echo $tag.' <span class="hook_count">('.$count.')</span>'; ?></td>
|
||||
<?php } ?>
|
||||
<td data-label="replace_function">
|
||||
<?php echo $data['function']; ?>
|
||||
</td>
|
||||
<td data-label="인수의 수"><?php echo $data['arguments']; ?></td>
|
||||
<td data-label="우선 순위"><?php echo $data['priority']; ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
$is_print = '';
|
||||
} //end foreach
|
||||
} else { // else if
|
||||
?>
|
||||
<tr>
|
||||
<td scope="row" data-label="replace_tag"><?php echo $tag.' <span class="hook_count">('.$count.')</span>'; ?></td>
|
||||
<td data-label="replace_function"> </td>
|
||||
<td data-label="인수의 수"> </td>
|
||||
<td data-label="우선 순위"> </td>
|
||||
</tr>
|
||||
<?php
|
||||
}//end if
|
||||
} //end foreach
|
||||
?>
|
||||
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div> <!-- end .hook_list -->
|
||||
</div>
|
||||
|
||||
</div> <!-- end .content_inner -->
|
||||
</div> <!-- end .debug_bar_content -->
|
||||
</div> <!-- end .debug_bar_wrap -->
|
||||
<script>
|
||||
jQuery(function($){
|
||||
$(".debug_tab").on("click", function() {
|
||||
$(".inner_debug").hide();
|
||||
$(this).addClass("active").siblings().removeClass("active");
|
||||
$("#debug_" + $(this).attr('data-tab')).show();
|
||||
});
|
||||
|
||||
$(".debug_tab").on("click", "a", function(e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
$(".debug_bar_wrap").on("click", ".debugbar_close_btn", function() {
|
||||
$(".view_debug_bar").trigger("click");
|
||||
})
|
||||
.on("click", ".view_debug_bar", function() {
|
||||
$(".debug_bar_content").toggle();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
0
plugin/debugbar/index.php
Normal file
0
plugin/debugbar/index.php
Normal file
51
plugin/debugbar/style.css
Normal file
51
plugin/debugbar/style.css
Normal file
@ -0,0 +1,51 @@
|
||||
.debug_bar_wrap{clear:both;display:block;position:relative;z-index:80;height:32px;background-color:#1ABC9C}
|
||||
.debug_bar_content{display:none;position:absolute;z-index:81;width:100%;top:32px;min-height:300px;overflow:hidden;background:#fff;overflow-y:scroll;box-sizing:content-box;border-top:thin solid gray}
|
||||
.debug_bar_text_group{position:relative;padding:0 20px 0 120px;line-height:32px;}
|
||||
.debug_bar_btn_group{position:absolute;top:0;left:1em;line-height:32px;text-align:left}
|
||||
.debug_bar_text{line-height:32px;display:block;width:100%;color:#fff;text-align:right;font-size:1.2em;overflow:hidden;text-overflow: ellipsis;-o-text-overflow:ellipsis;white-space:nowrap;word-wrap:normal !important}
|
||||
.sql_query_list li{padding:1em;line-height:1em}
|
||||
.debug_bar_content .content_inner{position:relative;padding:1em}
|
||||
.debug_bar_content .debug_table_wrap{margin:10px 0}
|
||||
.debugbar_tab::after{display:block;visibility:hidden;clear:both;content:""}
|
||||
.debugbar_tab li{float:left;margin-bottom:-1px;position:relative;display:block;position:relative;display:block;padding:10px 15px}
|
||||
.debugbar_tab li.debug_tab{border-bottom:2px solid #DDD}
|
||||
.debugbar_tab li.active a,.debugbar_tab li.active a:focus,.debugbar_tab li.active a:hover{border-width:0}
|
||||
.debugbar_tab li a{border:none;color:#666}
|
||||
.debugbar_tab li.active a,.debugbar_tab li a:hover{border:none;color:#4285F4!important;background:transparent}
|
||||
.debugbar_tab li a::after{content:"";background:#4285F4;height:2px;position:absolute;width:100%;left:0;bottom:-1px;transition:all 250ms ease 0;transform:scale(0)}
|
||||
.debugbar_tab li.active a::after,.debugbar_tab li:hover a::after{transform:scale(1)}
|
||||
.debugbar_tab li a::after{background:#21527d none repeat scroll 0 0;color:#fff}
|
||||
.inner_debug {display:none}
|
||||
.inner_debug h3.query_top{padding:1em;font-size:1.3em}
|
||||
#debug_executed_query{display:block}
|
||||
.lang_domain_list td .num{margin-right:10px;color:#9b9ea5;font-size:9px}
|
||||
.debugbar_close_btn_el{position:absolute;top:20px;right:20px}
|
||||
.debug_table{border:1px solid #ccc;border-collapse:collapse;margin:0;padding:0;width:100%}
|
||||
.debug_table caption{display:none}
|
||||
.debug_table tr{background:#f8f8f8;border:1px solid #ddd;padding:.35em}
|
||||
.debug_table th,.debug_table td{padding:.625em;text-align:center}
|
||||
.debug_table tbody tr:hover td{background:#c7d4dd!important}
|
||||
.debug_table tbody tr:nth-child(even){background-color:#fff}
|
||||
.debug_table td.left{text-align:left}
|
||||
.debug_table th{font-size:.85em;letter-spacing:.1em;text-transform:uppercase}
|
||||
.debug_table td img{text-align:center}
|
||||
|
||||
.debug_table.hook_table th, .debug_table.hook_table td {text-align:left;border:1px solid #ddd;}
|
||||
.hook_table .hook_count{margin-left:3px;font-size:0.9em;color:#7cbc0a}
|
||||
|
||||
.debug_bar_btn_group button.debug_button{margin-top:3px}
|
||||
button.debug_button{background-color:#7fbf4d;background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#7fbf4d),color-stop(100%,#63a62f));background-image:-webkit-linear-gradient(top,#7fbf4d,#63a62f);background-image:-moz-linear-gradient(top,#7fbf4d,#63a62f);background-image:-ms-linear-gradient(top,#7fbf4d,#63a62f);background-image:-o-linear-gradient(top,#7fbf4d,#63a62f);background-image:linear-gradient(top,#7fbf4d,#63a62f);border:1px solid #63a62f;border-bottom:1px solid #5b992b;border-radius:3px;-webkit-box-shadow:inset 0 1px 0 0 #96ca6d;box-shadow:inset 0 1px 0 0 #96ca6d;color:#fff;padding:3px 0 4px;text-align:center;text-shadow:0 -1px 0 #4c9021;width:100px;font-weight:700;font-size:14px;vertical-align:top}
|
||||
button.debug_button:hover{background-color:#76b347;background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#76b347),color-stop(100%,#5e9e2e));background-image:-webkit-linear-gradient(top,#76b347,#5e9e2e);background-image:-moz-linear-gradient(top,#76b347,#5e9e2e);background-image:-ms-linear-gradient(top,#76b347,#5e9e2e);background-image:-o-linear-gradient(top,#76b347,#5e9e2e);background-image:linear-gradient(top,#76b347,#5e9e2e);-webkit-box-shadow:inset 0 1px 0 0 #8dbf67;box-shadow:inset 0 1px 0 0 #8dbf67;cursor:pointer}
|
||||
button.debug_button:active{border:1px solid #5b992b;border-bottom:1px solid #538c27;-webkit-box-shadow:inset 0 0 8px 4px #548c29,0 1px 0 0 #eee;box-shadow:inset 0 0 8px 4px #548c29,0 1px 0 0 #eee}
|
||||
|
||||
@media screen and (max-width: 600px) {
|
||||
.debug_table{border:0}
|
||||
.debug_table caption{font-size:1.3em}
|
||||
.debug_table thead{display:none}
|
||||
.debug_table tr{border-bottom:3px solid #ddd;display:block;margin-bottom:.625em}
|
||||
.debug_table td{border-bottom:1px solid #ddd;display:block;font-size:.8em;text-align:right}
|
||||
.debug_table td.left{text-align:right}
|
||||
.debug_table td:before{content:attr(data-label);float:left;font-weight:700;text-transform:uppercase}
|
||||
.debug_table.hook_table th, .debug_table.hook_table td{border:0 none;border-bottom:1px solid #ddd;text-align:right}
|
||||
.debug_table td:last-child{border-bottom:0 !important}
|
||||
}
|
||||
@ -34,6 +34,10 @@ if( $file_arr[1] !== che_get_file_passname() ){
|
||||
$filepath = SAVE_DIR . '/' . $filesrc;
|
||||
$r = false;
|
||||
|
||||
if( function_exists('run_event') ){
|
||||
run_event('delete_editor_file', $filepath, $r);
|
||||
}
|
||||
|
||||
if (file_exists($filepath)) {
|
||||
$r = unlink($filepath);
|
||||
if ($r) {
|
||||
|
||||
@ -117,9 +117,14 @@ try {
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
$rdata = sprintf('{"fileUrl": "%s/%s", "filePath": "%s", "fileName": "%s", "fileSize": "%d" }',
|
||||
SAVE_URL,
|
||||
$filename,
|
||||
$file_url = SAVE_URL.'/'.$filename;
|
||||
|
||||
if( function_exists('run_replace') ){
|
||||
$file_url = run_replace('get_editor_upload_url', $file_url, $savefile, array());
|
||||
}
|
||||
|
||||
$rdata = sprintf('{"fileUrl": "%s", "filePath": "%s", "fileName": "%s", "fileSize": "%d" }',
|
||||
$file_url,
|
||||
$savefile,
|
||||
$filename,
|
||||
$filesize );
|
||||
|
||||
@ -1176,6 +1176,10 @@ class UploadHandler
|
||||
$image_width_height = $this->get_image_size($file_path);
|
||||
$file->width = $image_width_height[0];
|
||||
$file->height = $image_width_height[1];
|
||||
|
||||
if( function_exists('run_replace') ){
|
||||
$file->url = run_replace('get_editor_upload_url', $file->url, $file_path, $file);
|
||||
}
|
||||
} else { //로빈아빠님이 알려주심, 이미지 업로드 체크
|
||||
unlink($file_path);
|
||||
$file->error = $this->get_error_message('accept_file_types');
|
||||
@ -1441,6 +1445,11 @@ class UploadHandler
|
||||
if( substr($file_name, 0 , 32) != $this->get_file_passname() ) continue; //session_id() 와 비교하여 틀리면 지우지 않음
|
||||
$file_path = $this->get_upload_path($file_name);
|
||||
$success = is_file($file_path) && $file_name[0] !== '.' && unlink($file_path);
|
||||
|
||||
if( function_exists('run_event') ){
|
||||
run_event('delete_editor_file', $file_path, $success);
|
||||
}
|
||||
|
||||
if ($success) {
|
||||
foreach($this->options['image_versions'] as $version => $options) {
|
||||
if (!empty($version)) {
|
||||
|
||||
1
plugin/sns/facebook/.gitignore
vendored
1
plugin/sns/facebook/.gitignore
vendored
@ -1 +0,0 @@
|
||||
/coverage/
|
||||
@ -1,5 +0,0 @@
|
||||
language: php
|
||||
php:
|
||||
- 5.3
|
||||
- 5.4
|
||||
script: phpunit --stderr --bootstrap tests/bootstrap.php tests/tests.php
|
||||
@ -1,3 +0,0 @@
|
||||
<?php
|
||||
include_once("../../../common.php");
|
||||
?>
|
||||
@ -1,62 +0,0 @@
|
||||
<?php
|
||||
include_once("./_common.php");
|
||||
include_once(G5_SNS_PATH."/facebook/src/facebook.php");
|
||||
|
||||
$facebook = new Facebook(array(
|
||||
'appId' => $config['cf_facebook_appid'],
|
||||
'secret' => $config['cf_facebook_secret']
|
||||
));
|
||||
|
||||
$user = $facebook->getUser();
|
||||
|
||||
if ($user) {
|
||||
try {
|
||||
$user_profile = $facebook->api('/me');
|
||||
} catch (FacebookApiException $e) {
|
||||
error_log($e);
|
||||
$user = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
$g5['title'] = '페이스북 콜백';
|
||||
include_once(G5_PATH.'/head.sub.php');
|
||||
|
||||
if ($user) {
|
||||
$sns_name = $user_profile['name'];
|
||||
$sns_user = $user;
|
||||
|
||||
set_cookie('ck_sns_name', $sns_name, 86400);
|
||||
set_session('ss_facebook_user', $user);
|
||||
|
||||
$g5_sns_url = G5_SNS_URL;
|
||||
|
||||
echo <<<EOT
|
||||
<script>
|
||||
$(function() {
|
||||
document.write("<strong>페이스북 승인이 되었습니다.</strong>");
|
||||
|
||||
var opener = window.opener;
|
||||
opener.$("#wr_name").val("{$sns_name}");
|
||||
opener.$("#facebook_icon").attr("src", "{$g5_sns_url}/icon/facebook.png");
|
||||
opener.$("#facebook_checked").attr("disabled", false);
|
||||
opener.$("#facebook_checked").attr("checked", true);
|
||||
window.close();
|
||||
});
|
||||
</script>
|
||||
EOT;
|
||||
|
||||
} else {
|
||||
|
||||
echo <<<EOT
|
||||
<script>
|
||||
$(function() {
|
||||
alert("페이스북 승인이 되지 않았습니다.");
|
||||
window.close();
|
||||
});
|
||||
</script>
|
||||
EOT;
|
||||
|
||||
}
|
||||
|
||||
include_once(G5_PATH.'/tail.sub.php');
|
||||
?>
|
||||
@ -1,28 +0,0 @@
|
||||
Facebook PHP SDK (v.3.0.0)
|
||||
==========================
|
||||
|
||||
The new PHP SDK (v3.0.0) is a major upgrade to the older one (v2.2.x):
|
||||
|
||||
- Uses OAuth authentication flows instead of our legacy authentication flow
|
||||
- Consists of two classes. The first (class BaseFacebook) maintains the core of the upgrade, and the second one (class Facebook) is a small subclass that uses PHP sessions to store the user id and access token.
|
||||
|
||||
If you’re currently using the PHP SDK (v2.2.x) for authentication, you will recall that the login code looked like this:
|
||||
|
||||
$facebook = new Facebook(…);
|
||||
$session = $facebook->getSession();
|
||||
if ($session) {
|
||||
// proceed knowing you have a valid user session
|
||||
} else {
|
||||
// proceed knowing you require user login and/or authentication
|
||||
}
|
||||
|
||||
The login code is now:
|
||||
|
||||
$facebook = new Facebook(…);
|
||||
$user = $facebook->getUser();
|
||||
if ($user) {
|
||||
// proceed knowing you have a logged in user who's authenticated
|
||||
} else {
|
||||
// proceed knowing you require user login and/or authentication
|
||||
}
|
||||
|
||||
@ -1,22 +0,0 @@
|
||||
{
|
||||
"name": "facebook/php-sdk",
|
||||
"description": "Facebook PHP SDK",
|
||||
"keywords": ["facebook", "sdk"],
|
||||
"type": "library",
|
||||
"homepage": "https://github.com/facebook/facebook-php-sdk",
|
||||
"license": "Apache2",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Facebook",
|
||||
"homepage": "https://github.com/facebook/facebook-php-sdk/contributors"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.2.0",
|
||||
"ext-curl": "*",
|
||||
"ext-json": "*"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": ["src"]
|
||||
}
|
||||
}
|
||||
@ -1,85 +0,0 @@
|
||||
Facebook PHP SDK (v.3.2.2)
|
||||
|
||||
The [Facebook Platform](http://developers.facebook.com/) is
|
||||
a set of APIs that make your app more social.
|
||||
|
||||
This repository contains the open source PHP SDK that allows you to
|
||||
access Facebook Platform from your PHP app. Except as otherwise noted,
|
||||
the Facebook PHP SDK is licensed under the Apache Licence, Version 2.0
|
||||
(http://www.apache.org/licenses/LICENSE-2.0.html).
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
The [examples][examples] are a good place to start. The minimal you'll need to
|
||||
have is:
|
||||
|
||||
require 'facebook-php-sdk/src/facebook.php';
|
||||
|
||||
$facebook = new Facebook(array(
|
||||
'appId' => 'YOUR_APP_ID',
|
||||
'secret' => 'YOUR_APP_SECRET',
|
||||
));
|
||||
|
||||
// Get User ID
|
||||
$user = $facebook->getUser();
|
||||
|
||||
To make [API][API] calls:
|
||||
|
||||
if ($user) {
|
||||
try {
|
||||
// Proceed knowing you have a logged in user who's authenticated.
|
||||
$user_profile = $facebook->api('/me');
|
||||
} catch (FacebookApiException $e) {
|
||||
error_log($e);
|
||||
$user = null;
|
||||
}
|
||||
}
|
||||
|
||||
Login or logout url will be needed depending on current user state.
|
||||
|
||||
if ($user) {
|
||||
$logoutUrl = $facebook->getLogoutUrl();
|
||||
} else {
|
||||
$loginUrl = $facebook->getLoginUrl();
|
||||
}
|
||||
|
||||
[examples]: http://github.com/facebook/facebook-php-sdk/blob/master/examples/example.php
|
||||
[API]: http://developers.facebook.com/docs/api
|
||||
|
||||
|
||||
Tests
|
||||
-----
|
||||
|
||||
In order to keep us nimble and allow us to bring you new functionality, without
|
||||
compromising on stability, we have ensured full test coverage of the SDK.
|
||||
We are including this in the open source repository to assure you of our
|
||||
commitment to quality, but also with the hopes that you will contribute back to
|
||||
help keep it stable. The easiest way to do so is to file bugs and include a
|
||||
test case.
|
||||
|
||||
The tests can be executed by using this command from the base directory:
|
||||
|
||||
phpunit --stderr --bootstrap tests/bootstrap.php tests/tests.php
|
||||
|
||||
|
||||
Contributing
|
||||
===========
|
||||
For us to accept contributions you will have to first have signed the
|
||||
[Contributor License Agreement](https://developers.facebook.com/opensource/cla).
|
||||
|
||||
When commiting, keep all lines to less than 80 characters, and try to
|
||||
follow the existing style.
|
||||
|
||||
Before creating a pull request, squash your commits into a single commit.
|
||||
|
||||
Add the comments where needed, and provide ample explanation in the
|
||||
commit message.
|
||||
|
||||
|
||||
Report Issues/Bugs
|
||||
===============
|
||||
[Bugs](https://developers.facebook.com/bugs)
|
||||
|
||||
[Questions](http://facebook.stackoverflow.com)
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,160 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License. You may obtain
|
||||
* a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
require_once "base_facebook.php";
|
||||
|
||||
/**
|
||||
* Extends the BaseFacebook class with the intent of using
|
||||
* PHP sessions to store user ids and access tokens.
|
||||
*/
|
||||
class Facebook extends BaseFacebook
|
||||
{
|
||||
const FBSS_COOKIE_NAME = 'fbss';
|
||||
|
||||
// We can set this to a high number because the main session
|
||||
// expiration will trump this.
|
||||
const FBSS_COOKIE_EXPIRE = 31556926; // 1 year
|
||||
|
||||
// Stores the shared session ID if one is set.
|
||||
protected $sharedSessionID;
|
||||
|
||||
/**
|
||||
* Identical to the parent constructor, except that
|
||||
* we start a PHP session to store the user ID and
|
||||
* access token if during the course of execution
|
||||
* we discover them.
|
||||
*
|
||||
* @param Array $config the application configuration. Additionally
|
||||
* accepts "sharedSession" as a boolean to turn on a secondary
|
||||
* cookie for environments with a shared session (that is, your app
|
||||
* shares the domain with other apps).
|
||||
* @see BaseFacebook::__construct in facebook.php
|
||||
*/
|
||||
public function __construct($config) {
|
||||
if (!session_id()) {
|
||||
session_start();
|
||||
}
|
||||
parent::__construct($config);
|
||||
if (!empty($config['sharedSession'])) {
|
||||
$this->initSharedSession();
|
||||
}
|
||||
}
|
||||
|
||||
protected static $kSupportedKeys =
|
||||
array('state', 'code', 'access_token', 'user_id');
|
||||
|
||||
protected function initSharedSession() {
|
||||
$cookie_name = $this->getSharedSessionCookieName();
|
||||
if (isset($_COOKIE[$cookie_name])) {
|
||||
$data = $this->parseSignedRequest($_COOKIE[$cookie_name]);
|
||||
if ($data && !empty($data['domain']) &&
|
||||
self::isAllowedDomain($this->getHttpHost(), $data['domain'])) {
|
||||
// good case
|
||||
$this->sharedSessionID = $data['id'];
|
||||
return;
|
||||
}
|
||||
// ignoring potentially unreachable data
|
||||
}
|
||||
// evil/corrupt/missing case
|
||||
$base_domain = $this->getBaseDomain();
|
||||
$this->sharedSessionID = md5(uniqid(mt_rand(), true));
|
||||
$cookie_value = $this->makeSignedRequest(
|
||||
array(
|
||||
'domain' => $base_domain,
|
||||
'id' => $this->sharedSessionID,
|
||||
)
|
||||
);
|
||||
$_COOKIE[$cookie_name] = $cookie_value;
|
||||
if (!headers_sent()) {
|
||||
$expire = time() + self::FBSS_COOKIE_EXPIRE;
|
||||
setcookie($cookie_name, $cookie_value, $expire, '/', '.'.$base_domain);
|
||||
} else {
|
||||
// @codeCoverageIgnoreStart
|
||||
self::errorLog(
|
||||
'Shared session ID cookie could not be set! You must ensure you '.
|
||||
'create the Facebook instance before headers have been sent. This '.
|
||||
'will cause authentication issues after the first request.'
|
||||
);
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the implementations of the inherited abstract
|
||||
* methods. The implementation uses PHP sessions to maintain
|
||||
* a store for authorization codes, user ids, CSRF states, and
|
||||
* access tokens.
|
||||
*/
|
||||
protected function setPersistentData($key, $value) {
|
||||
if (!in_array($key, self::$kSupportedKeys)) {
|
||||
self::errorLog('Unsupported key passed to setPersistentData.');
|
||||
return;
|
||||
}
|
||||
|
||||
$session_var_name = $this->constructSessionVariableName($key);
|
||||
$_SESSION[$session_var_name] = $value;
|
||||
}
|
||||
|
||||
protected function getPersistentData($key, $default = false) {
|
||||
if (!in_array($key, self::$kSupportedKeys)) {
|
||||
self::errorLog('Unsupported key passed to getPersistentData.');
|
||||
return $default;
|
||||
}
|
||||
|
||||
$session_var_name = $this->constructSessionVariableName($key);
|
||||
return isset($_SESSION[$session_var_name]) ?
|
||||
$_SESSION[$session_var_name] : $default;
|
||||
}
|
||||
|
||||
protected function clearPersistentData($key) {
|
||||
if (!in_array($key, self::$kSupportedKeys)) {
|
||||
self::errorLog('Unsupported key passed to clearPersistentData.');
|
||||
return;
|
||||
}
|
||||
|
||||
$session_var_name = $this->constructSessionVariableName($key);
|
||||
unset($_SESSION[$session_var_name]);
|
||||
}
|
||||
|
||||
protected function clearAllPersistentData() {
|
||||
foreach (self::$kSupportedKeys as $key) {
|
||||
$this->clearPersistentData($key);
|
||||
}
|
||||
if ($this->sharedSessionID) {
|
||||
$this->deleteSharedSessionCookie();
|
||||
}
|
||||
}
|
||||
|
||||
protected function deleteSharedSessionCookie() {
|
||||
$cookie_name = $this->getSharedSessionCookieName();
|
||||
unset($_COOKIE[$cookie_name]);
|
||||
$base_domain = $this->getBaseDomain();
|
||||
setcookie($cookie_name, '', 1, '/', '.'.$base_domain);
|
||||
}
|
||||
|
||||
protected function getSharedSessionCookieName() {
|
||||
return self::FBSS_COOKIE_NAME . '_' . $this->getAppId();
|
||||
}
|
||||
|
||||
protected function constructSessionVariableName($key) {
|
||||
$parts = array('fb', $this->getAppId(), $key);
|
||||
if ($this->sharedSessionID) {
|
||||
array_unshift($parts, $this->sharedSessionID);
|
||||
}
|
||||
return implode('_', $parts);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,5 +0,0 @@
|
||||
<?php
|
||||
|
||||
$base = realpath(dirname(__FILE__) . '/..');
|
||||
require "$base/src/base_facebook.php";
|
||||
require "$base/src/facebook.php";
|
||||
File diff suppressed because it is too large
Load Diff
@ -58,15 +58,12 @@ $bo_v_sns_class = $config['cf_kakao_js_apikey'] ? 'show_kakao' : '';
|
||||
//]]>
|
||||
</script>
|
||||
<?php } ?>
|
||||
<div class="bo_v_snswr">
|
||||
<button type="button" class="btn btn_b03 btn_share"><i class="fa fa-share-alt" aria-hidden="true"></i> SNS공유</button>
|
||||
|
||||
<ul id="bo_v_sns" class="<?php echo $bo_v_sns_class; ?>">
|
||||
<li><a href="<?php echo $twitter_url; ?>" target="_blank" class="sns_t"><img src="<?php echo G5_SNS_URL; ?>/icon/twitter.png" alt="트위터로 보내기" width="20"></a></li>
|
||||
<li><a href="<?php echo $facebook_url; ?>" target="_blank" class="sns_f"><img src="<?php echo G5_SNS_URL; ?>/icon/facebook.png" alt="페이스북으로 보내기" width="20"></a></li>
|
||||
<li><a href="<?php echo $gplus_url; ?>" target="_blank" class="sns_g"><img src="<?php echo G5_SNS_URL; ?>/icon/gplus.png" alt="구글플러스로 보내기" width="20"></a></li>
|
||||
<li><a href="<?php echo $facebook_url; ?>" target="_blank" class="sns_f"><img src="<?php echo G5_SNS_URL; ?>/icon/facebook.png" alt="페이스북으로 공유" width="20"><span>페이스북 공유</span></a></li>
|
||||
<li><a href="<?php echo $twitter_url; ?>" target="_blank" class="sns_t"><img src="<?php echo G5_SNS_URL; ?>/icon/twitter.png" alt="트위터로 공유" width="20"><span>트위터 공유</span></a></li>
|
||||
<li><a href="<?php echo $gplus_url; ?>" target="_blank" class="sns_g"><img src="<?php echo G5_SNS_URL; ?>/icon/gplus.png" alt="구글플러스로 공유" width="20"><span>구글+ 공유</span></a></li>
|
||||
<?php if($config['cf_kakao_js_apikey']) { ?>
|
||||
<li><a href="javascript:Kakao_sendLink();" class="sns_k" ><img src="<?php echo G5_SNS_URL; ?>/icon/kakaotalk.png" alt="카카오톡으로 보내기" width="20"></a></li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@ -6,47 +6,6 @@ if (!$board['bo_use_sns']) return;
|
||||
|
||||
<ul id="bo_vc_sns">
|
||||
<?php
|
||||
//============================================================================
|
||||
// 페이스북
|
||||
//----------------------------------------------------------------------------
|
||||
if ($config['cf_facebook_appid']) {
|
||||
$facebook_user = get_session("ss_facebook_user");
|
||||
if (!$facebook_user) {
|
||||
include_once(G5_SNS_PATH."/facebook/src/facebook.php");
|
||||
$facebook = new Facebook(array(
|
||||
'appId' => $config['cf_facebook_appid'],
|
||||
'secret' => $config['cf_facebook_secret']
|
||||
));
|
||||
|
||||
$facebook_user = $facebook->getUser();
|
||||
|
||||
if ($facebook_user) {
|
||||
try {
|
||||
$facebook_user_profile = $facebook->api('/me');
|
||||
} catch (FacebookApiException $e) {
|
||||
error_log($e);
|
||||
$facebook_user = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo '<li class="sns_li_f '.($facebook_user?'':'sns_li_off').'">';
|
||||
if ($facebook_user) {
|
||||
echo '<img src="'.G5_SNS_URL.'/icon/facebook.png" id="facebook_icon">';
|
||||
echo '<label for="" class="sound_only">페이스북 동시 등록</label>';
|
||||
echo '<input type="checkbox" name="facebook_checked" id="facebook_checked" '.(get_cookie('ck_facebook_checked')?'checked':'').' value="1">';
|
||||
} else {
|
||||
$facebook_url = $facebook->getLoginUrl(array("redirect_uri"=>G5_SNS_URL."/facebook/callback.php", "scope"=>"publish_stream,read_stream,offline_access", "display"=>"popup"));
|
||||
echo '<input type="checkbox" name="facebook_checked" id="facebook_checked" disabled value="1">';
|
||||
echo '<a href="'.$facebook_url.'" id="facebook_url" onclick="return false;"><img src="'.G5_SNS_URL.'/icon/facebook.png" id="facebook_icon" width="20"></a>';
|
||||
echo '<label for="" class="sound_only">페이스북 동시 등록</label>';
|
||||
echo '<script>$(function(){ $(document).on("click", "#facebook_url", function(){ window.open(this.href, "facebook_url", "width=600,height=250"); }); });</script>';
|
||||
}
|
||||
echo '</li>';
|
||||
}
|
||||
//============================================================================
|
||||
|
||||
|
||||
//============================================================================
|
||||
// 트위터
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user