remove unused library and features

This commit is contained in:
Amberstone 2024-10-10 06:42:38 +09:00
parent d84b2a3f93
commit 651e10d47e
Signed by: amber
GPG key ID: 094B0E55F98D8BF1
50 changed files with 22 additions and 10331 deletions

View file

@ -7,69 +7,3 @@ if (!$board['bo_use_sns'])
set_cookie('ck_facebook_checked', false, 86400 * 31); set_cookie('ck_facebook_checked', false, 86400 * 31);
set_cookie('ck_twitter_checked', false, 86400 * 31); set_cookie('ck_twitter_checked', false, 86400 * 31);
//============================================================================
// 페이스북
//----------------------------------------------------------------------------
$wr_facebook_user = "";
if ($_POST['facebook_checked']) {
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 {
$link = G5_BBS_URL . '/board.php?bo_table=' . $bo_table . '&wr_id=' . $wr['wr_parent'] . '&#c_' . $comment_id;
$attachment = array(
'message' => stripslashes($wr_content),
'name' => $wr_subject,
'link' => $link,
'description' => stripslashes(strip_tags($wr['wr_content']))
);
// 등록
$facebook->api('/me/feed/', 'post', $attachment);
//$errors = error_get_last(); print_r2($errros); exit;
set_cookie('ck_facebook_checked', true, 86400 * 31);
} catch (FacebookApiException $e) {
;
;
;
}
}
$wr_facebook_user = get_session("ss_facebook_user");
}
//============================================================================
//============================================================================
// 트위터
//----------------------------------------------------------------------------
$wr_twitter_user = "";
if ($_POST['twitter_checked']) {
include_once G5_SNS_PATH . "/twitter/twitteroauth/twitteroauth.php";
include_once G5_SNS_PATH . "/twitter/twitterconfig.php";
if (!(empty($_SESSION['access_token']) || empty($_SESSION['access_token']['oauth_token']) || empty($_SESSION['access_token']['oauth_token_secret']))) {
$comment_url = G5_BBS_URL . '/board.php?bo_table=' . $bo_table . '&wr_id=' . $wr['wr_parent'] . '&#c_' . $comment_id;
$post = googl_short_url($comment_url) . ' ' . $wr_content;
$post = utf8_strcut($post, 140);
$access_token = $_SESSION['access_token'];
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);
// 등록
$connection->post('statuses/update', ['status' => $post]);
set_cookie('ck_twitter_checked', true, 86400 * 31);
}
$wr_twitter_user = get_session("ss_twitter_user");
}
//============================================================================

View file

@ -49,8 +49,6 @@ define('G5_OKNAME_DIR', 'okname');
define('G5_KCPCERT_DIR', 'kcpcert'); define('G5_KCPCERT_DIR', 'kcpcert');
define('G5_LGXPAY_DIR', 'lgxpay'); define('G5_LGXPAY_DIR', 'lgxpay');
define('G5_SNS_DIR', 'sns');
define('G5_SYNDI_DIR', 'syndi');
define('G5_PHPMAILER_DIR', 'PHPMailer'); define('G5_PHPMAILER_DIR', 'PHPMailer');
define('G5_SESSION_DIR', 'session'); define('G5_SESSION_DIR', 'session');
define('G5_THEME_DIR', 'theme'); define('G5_THEME_DIR', 'theme');
@ -86,8 +84,6 @@ define('G5_EDITOR_URL', G5_PLUGIN_URL . '/' . G5_EDITOR_DIR);
define('G5_OKNAME_URL', G5_PLUGIN_URL . '/' . G5_OKNAME_DIR); define('G5_OKNAME_URL', G5_PLUGIN_URL . '/' . G5_OKNAME_DIR);
define('G5_KCPCERT_URL', G5_PLUGIN_URL . '/' . G5_KCPCERT_DIR); define('G5_KCPCERT_URL', G5_PLUGIN_URL . '/' . G5_KCPCERT_DIR);
define('G5_LGXPAY_URL', G5_PLUGIN_URL . '/' . G5_LGXPAY_DIR); define('G5_LGXPAY_URL', G5_PLUGIN_URL . '/' . G5_LGXPAY_DIR);
define('G5_SNS_URL', G5_PLUGIN_URL . '/' . G5_SNS_DIR);
define('G5_SYNDI_URL', G5_PLUGIN_URL . '/' . G5_SYNDI_DIR);
define('G5_MOBILE_URL', G5_URL . '/' . G5_MOBILE_DIR); define('G5_MOBILE_URL', G5_URL . '/' . G5_MOBILE_DIR);
// PATH 는 서버상에서의 절대경로 // PATH 는 서버상에서의 절대경로
@ -107,11 +103,20 @@ define('G5_OKNAME_PATH', G5_PLUGIN_PATH . '/' . G5_OKNAME_DIR);
define('G5_KCPCERT_PATH', G5_PLUGIN_PATH . '/' . G5_KCPCERT_DIR); define('G5_KCPCERT_PATH', G5_PLUGIN_PATH . '/' . G5_KCPCERT_DIR);
define('G5_LGXPAY_PATH', G5_PLUGIN_PATH . '/' . G5_LGXPAY_DIR); define('G5_LGXPAY_PATH', G5_PLUGIN_PATH . '/' . G5_LGXPAY_DIR);
define('G5_SNS_PATH', G5_PLUGIN_PATH . '/' . G5_SNS_DIR);
define('G5_SYNDI_PATH', G5_PLUGIN_PATH . '/' . G5_SYNDI_DIR);
define('G5_PHPMAILER_PATH', G5_PLUGIN_PATH . '/' . G5_PHPMAILER_DIR); define('G5_PHPMAILER_PATH', G5_PLUGIN_PATH . '/' . G5_PHPMAILER_DIR);
//============================================================================== //==============================================================================
/**
* 네이버 신디케이션 (검색 노출) SNS 기능은 사용하지 않을 것으로 예상되어 기능을 제거
* 해당 SNS 기능의 경우 2010~2014년에 자주 사용되던 기능으로 현재는 사용 빈도가 줄었을 것으로 추측
*/
define('G5_SNS_DIR', 'sns');
define('G5_SYNDI_DIR', 'syndi');
define('G5_SNS_URL', '');
define('G5_SYNDI_URL', '');
define('G5_SNS_PATH', '');
define('G5_SYNDI_PATH', '');
//============================================================================== //==============================================================================
// 사용기기 설정 // 사용기기 설정
// pc 설정 시 모바일 기기에서도 PC화면 보여짐 // pc 설정 시 모바일 기기에서도 PC화면 보여짐
@ -122,6 +127,8 @@ define('G5_SET_DEVICE', 'both');
define('G5_USE_MOBILE', true); // 모바일 홈페이지를 사용하지 않을 경우 false 로 설정 define('G5_USE_MOBILE', true); // 모바일 홈페이지를 사용하지 않을 경우 false 로 설정
define('G5_USE_CACHE', false); // 최신글등에 cache 기능 사용 여부 define('G5_USE_CACHE', false); // 최신글등에 cache 기능 사용 여부
// debug
// define('G5_USE_CACHE', true);
/******************** /********************
시간 상수 시간 상수

Binary file not shown.

View file

@ -1,270 +0,0 @@
<?php
define('NUM_BIG_BLOCK_DEPOT_BLOCKS_POS', 0x2c);
define('SMALL_BLOCK_DEPOT_BLOCK_POS', 0x3c);
define('ROOT_START_BLOCK_POS', 0x30);
define('BIG_BLOCK_SIZE', 0x200);
define('SMALL_BLOCK_SIZE', 0x40);
define('EXTENSION_BLOCK_POS', 0x44);
define('NUM_EXTENSION_BLOCK_POS', 0x48);
define('PROPERTY_STORAGE_BLOCK_SIZE', 0x80);
define('BIG_BLOCK_DEPOT_BLOCKS_POS', 0x4c);
define('SMALL_BLOCK_THRESHOLD', 0x1000);
// property storage offsets
define('SIZE_OF_NAME_POS', 0x40);
define('TYPE_POS', 0x42);
define('START_BLOCK_POS', 0x74);
define('SIZE_POS', 0x78);
define('IDENTIFIER_OLE', pack("CCCCCCCC",0xd0,0xcf,0x11,0xe0,0xa1,0xb1,0x1a,0xe1));
//echo 'ROOT_START_BLOCK_POS = '.ROOT_START_BLOCK_POS."\n";
//echo bin2hex($data[ROOT_START_BLOCK_POS])."\n";
//echo "a=";
//echo $data[ROOT_START_BLOCK_POS];
//function log
function GetInt4d($data, $pos)
{
$value = ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | (ord($data[$pos+3]) << 24);
if ($value>=4294967294)
{
$value=-2;
}
return $value;
}
class OLERead {
var $data = '';
function OLERead(){
}
function read($sFileName){
// check if file exist and is readable (Darko Miljanovic)
if(!is_readable($sFileName)) {
$this->error = 1;
return false;
}
$this->data = @file_get_contents($sFileName);
if (!$this->data) {
$this->error = 1;
return false;
}
//echo IDENTIFIER_OLE;
//echo 'start';
if (substr($this->data, 0, 8) != IDENTIFIER_OLE) {
$this->error = 1;
return false;
}
$this->numBigBlockDepotBlocks = GetInt4d($this->data, NUM_BIG_BLOCK_DEPOT_BLOCKS_POS);
$this->sbdStartBlock = GetInt4d($this->data, SMALL_BLOCK_DEPOT_BLOCK_POS);
$this->rootStartBlock = GetInt4d($this->data, ROOT_START_BLOCK_POS);
$this->extensionBlock = GetInt4d($this->data, EXTENSION_BLOCK_POS);
$this->numExtensionBlocks = GetInt4d($this->data, NUM_EXTENSION_BLOCK_POS);
/*
echo $this->numBigBlockDepotBlocks." ";
echo $this->sbdStartBlock." ";
echo $this->rootStartBlock." ";
echo $this->extensionBlock." ";
echo $this->numExtensionBlocks." ";
*/
//echo "sbdStartBlock = $this->sbdStartBlock\n";
$bigBlockDepotBlocks = array();
$pos = BIG_BLOCK_DEPOT_BLOCKS_POS;
// echo "pos = $pos";
$bbdBlocks = $this->numBigBlockDepotBlocks;
if ($this->numExtensionBlocks != 0) {
$bbdBlocks = (BIG_BLOCK_SIZE - BIG_BLOCK_DEPOT_BLOCKS_POS)/4;
}
for ($i = 0; $i < $bbdBlocks; $i++) {
$bigBlockDepotBlocks[$i] = GetInt4d($this->data, $pos);
$pos += 4;
}
for ($j = 0; $j < $this->numExtensionBlocks; $j++) {
$pos = ($this->extensionBlock + 1) * BIG_BLOCK_SIZE;
$blocksToRead = min($this->numBigBlockDepotBlocks - $bbdBlocks, BIG_BLOCK_SIZE / 4 - 1);
for ($i = $bbdBlocks; $i < $bbdBlocks + $blocksToRead; $i++) {
$bigBlockDepotBlocks[$i] = GetInt4d($this->data, $pos);
$pos += 4;
}
$bbdBlocks += $blocksToRead;
if ($bbdBlocks < $this->numBigBlockDepotBlocks) {
$this->extensionBlock = GetInt4d($this->data, $pos);
}
}
// var_dump($bigBlockDepotBlocks);
// readBigBlockDepot
$pos = 0;
$index = 0;
$this->bigBlockChain = array();
for ($i = 0; $i < $this->numBigBlockDepotBlocks; $i++) {
$pos = ($bigBlockDepotBlocks[$i] + 1) * BIG_BLOCK_SIZE;
//echo "pos = $pos";
for ($j = 0 ; $j < BIG_BLOCK_SIZE / 4; $j++) {
$this->bigBlockChain[$index] = GetInt4d($this->data, $pos);
$pos += 4 ;
$index++;
}
}
//var_dump($this->bigBlockChain);
//echo '=====2';
// readSmallBlockDepot();
$pos = 0;
$index = 0;
$sbdBlock = $this->sbdStartBlock;
$this->smallBlockChain = array();
while ($sbdBlock != -2) {
$pos = ($sbdBlock + 1) * BIG_BLOCK_SIZE;
for ($j = 0; $j < BIG_BLOCK_SIZE / 4; $j++) {
$this->smallBlockChain[$index] = GetInt4d($this->data, $pos);
$pos += 4;
$index++;
}
$sbdBlock = $this->bigBlockChain[$sbdBlock];
}
// readData(rootStartBlock)
$block = $this->rootStartBlock;
$pos = 0;
$this->entry = $this->__readData($block);
/*
while ($block != -2) {
$pos = ($block + 1) * BIG_BLOCK_SIZE;
$this->entry = $this->entry.substr($this->data, $pos, BIG_BLOCK_SIZE);
$block = $this->bigBlockChain[$block];
}
*/
//echo '==='.$this->entry."===";
$this->__readPropertySets();
}
function __readData($bl) {
$block = $bl;
$pos = 0;
$data = '';
while ($block != -2) {
$pos = ($block + 1) * BIG_BLOCK_SIZE;
$data = $data.substr($this->data, $pos, BIG_BLOCK_SIZE);
//echo "pos = $pos data=$data\n";
$block = $this->bigBlockChain[$block];
}
return $data;
}
function __readPropertySets(){
$offset = 0;
//var_dump($this->entry);
while ($offset < strlen($this->entry)) {
$d = substr($this->entry, $offset, PROPERTY_STORAGE_BLOCK_SIZE);
$nameSize = ord($d[SIZE_OF_NAME_POS]) | (ord($d[SIZE_OF_NAME_POS+1]) << 8);
$type = ord($d[TYPE_POS]);
//$maxBlock = strlen($d) / BIG_BLOCK_SIZE - 1;
$startBlock = GetInt4d($d, START_BLOCK_POS);
$size = GetInt4d($d, SIZE_POS);
$name = '';
for ($i = 0; $i < $nameSize ; $i++) {
$name .= $d[$i];
}
$name = str_replace("\x00", "", $name);
$this->props[] = array (
'name' => $name,
'type' => $type,
'startBlock' => $startBlock,
'size' => $size);
if (($name == "Workbook") || ($name == "Book")) {
$this->wrkbook = count($this->props) - 1;
}
if ($name == "Root Entry") {
$this->rootentry = count($this->props) - 1;
}
//echo "name ==$name=\n";
$offset += PROPERTY_STORAGE_BLOCK_SIZE;
}
}
function getWorkBook(){
if ($this->props[$this->wrkbook]['size'] < SMALL_BLOCK_THRESHOLD){
// getSmallBlockStream(PropertyStorage ps)
$rootdata = $this->__readData($this->props[$this->rootentry]['startBlock']);
$streamData = '';
$block = $this->props[$this->wrkbook]['startBlock'];
//$count = 0;
$pos = 0;
while ($block != -2) {
$pos = $block * SMALL_BLOCK_SIZE;
$streamData .= substr($rootdata, $pos, SMALL_BLOCK_SIZE);
$block = $this->smallBlockChain[$block];
}
return $streamData;
}else{
$numBlocks = $this->props[$this->wrkbook]['size'] / BIG_BLOCK_SIZE;
if ($this->props[$this->wrkbook]['size'] % BIG_BLOCK_SIZE != 0) {
$numBlocks++;
}
if ($numBlocks == 0) return '';
//echo "numBlocks = $numBlocks\n";
//byte[] streamData = new byte[numBlocks * BIG_BLOCK_SIZE];
//print_r($this->wrkbook);
$streamData = '';
$block = $this->props[$this->wrkbook]['startBlock'];
//$count = 0;
$pos = 0;
//echo "block = $block";
while ($block != -2) {
$pos = ($block + 1) * BIG_BLOCK_SIZE;
$streamData .= substr($this->data, $pos, BIG_BLOCK_SIZE);
$block = $this->bigBlockChain[$block];
}
//echo 'stream'.$streamData;
return $streamData;
}
}
}

View file

@ -1,207 +0,0 @@
<?php
/*
* Copyleft 2002 Johann Hanne
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*/
/*
* This is the Spreadsheet::WriteExcel Perl package ported to PHP
* Spreadsheet::WriteExcel was written by John McNamara, jmcnamara@cpan.org
*/
class writeexcel_biffwriter {
var $byte_order;
var $BIFF_version;
var $_byte_order;
var $_data;
var $_datasize;
var $_limit;
var $_debug;
/*
* Constructor
*/
function writeexcel_biffwriter() {
$this->byte_order = '';
$this->BIFF_version = 0x0500;
$this->_byte_order = '';
$this->_data = false;
$this->_datasize = 0;
$this->_limit = 2080;
$this->_set_byte_order();
}
/*
* Determine the byte order and store it as class data to avoid
* recalculating it for each call to new().
*/
function _set_byte_order() {
$this->byteorder=0;
// Check if "pack" gives the required IEEE 64bit float
$teststr = pack("d", 1.2345);
$number = pack("C8", 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F);
if ($number == $teststr) {
$this->byte_order = 0; // Little Endian
} elseif ($number == strrev($teststr)) {
$this->byte_order = 1; // Big Endian
} else {
// Give up
trigger_error("Required floating point format not supported ".
"on this platform. See the portability section ".
"of the documentation.", E_USER_ERROR);
}
$this->_byte_order = $this->byte_order;
}
/*
* General storage function
*/
function _prepend($data) {
if (func_num_args()>1) {
trigger_error("writeexcel_biffwriter::_prepend() ".
"called with more than one argument", E_USER_ERROR);
}
if ($this->_debug) {
print "*** writeexcel_biffwriter::_prepend() called:";
for ($c=0;$c<strlen($data);$c++) {
if ($c%16==0) {
print "\n";
}
printf("%02X ", ord($data[$c]));
}
print "\n";
}
if (strlen($data) > $this->_limit) {
$data = $this->_add_continue($data);
}
$this->_data = $data . $this->_data;
$this->_datasize += strlen($data);
}
/*
* General storage function
*/
function _append($data) {
if (func_num_args()>1) {
trigger_error("writeexcel_biffwriter::_append() ".
"called with more than one argument", E_USER_ERROR);
}
if ($this->_debug) {
print "*** writeexcel_biffwriter::_append() called:";
for ($c=0;$c<strlen($data);$c++) {
if ($c%16==0) {
print "\n";
}
printf("%02X ", ord($data[$c]));
}
print "\n";
}
if (strlen($data) > $this->_limit) {
$data = $this->_add_continue($data);
}
$this->_data = $this->_data . $data;
$this->_datasize += strlen($data);
}
/*
* Writes Excel BOF record to indicate the beginning of a stream or
* sub-stream in the BIFF file.
*
* $type = 0x0005, Workbook
* $type = 0x0010, Worksheet
*/
function _store_bof($type) {
$record = 0x0809; // Record identifier
$length = 0x0008; // Number of bytes to follow
$version = $this->BIFF_version;
// According to the SDK $build and $year should be set to zero.
// However, this throws a warning in Excel 5. So, use these
// magic numbers.
$build = 0x096C;
$year = 0x07C9;
$header = pack("vv", $record, $length);
$data = pack("vvvv", $version, $type, $build, $year);
$this->_prepend($header . $data);
}
/*
* Writes Excel EOF record to indicate the end of a BIFF stream.
*/
function _store_eof() {
$record = 0x000A; // Record identifier
$length = 0x0000; // Number of bytes to follow
$header = pack("vv", $record, $length);
$this->_append($header);
}
/*
* Excel limits the size of BIFF records. In Excel 5 the limit is 2084
* bytes. In Excel 97 the limit is 8228 bytes. Records that are longer
* than these limits must be split up into CONTINUE blocks.
*
* This function take a long BIFF record and inserts CONTINUE records as
* necessary.
*/
function _add_continue($data) {
$limit = $this->_limit;
$record = 0x003C; // Record identifier
// The first 2080/8224 bytes remain intact. However, we have to change
// the length field of the record.
$tmp = substr($data, 0, $limit);
$data = substr($data, $limit);
$tmp = substr($tmp, 0, 2) . pack ("v", $limit-4) . substr($tmp, 4);
// Strip out chunks of 2080/8224 bytes +4 for the header.
while (strlen($data) > $limit) {
$header = pack("vv", $record, $limit);
$tmp .= $header;
$tmp .= substr($data, 0, $limit);
$data = substr($data, $limit);
}
// Mop up the last of the data
$header = pack("vv", $record, strlen($data));
$tmp .= $header;
$tmp .= $data;
return $tmp;
}
}

View file

@ -1,693 +0,0 @@
<?php
/*
* Copyleft 2002 Johann Hanne
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*/
/*
* This is the Spreadsheet::WriteExcel Perl package ported to PHP
* Spreadsheet::WriteExcel was written by John McNamara, jmcnamara@cpan.org
*/
class writeexcel_format {
var $_xf_index;
var $_font_index;
var $_font;
var $_size;
var $_bold;
var $_italic;
var $_color;
var $_underline;
var $_font_strikeout;
var $_font_outline;
var $_font_shadow;
var $_font_script;
var $_font_family;
var $_font_charset;
var $_num_format;
var $_hidden;
var $_locked;
var $_text_h_align;
var $_text_wrap;
var $_text_v_align;
var $_text_justlast;
var $_rotation;
var $_fg_color;
var $_bg_color;
var $_pattern;
var $_bottom;
var $_top;
var $_left;
var $_right;
var $_bottom_color;
var $_top_color;
var $_left_color;
var $_right_color;
/*
* Constructor
*/
function writeexcel_format() {
$_=func_get_args();
$this->_xf_index = (sizeof($_)>0) ? array_shift($_) : 0;
$this->_font_index = 0;
$this->_font = 'Arial';
$this->_size = 10;
$this->_bold = 0x0190;
$this->_italic = 0;
$this->_color = 0x7FFF;
$this->_underline = 0;
$this->_font_strikeout = 0;
$this->_font_outline = 0;
$this->_font_shadow = 0;
$this->_font_script = 0;
$this->_font_family = 0;
$this->_font_charset = 0;
$this->_num_format = 0;
$this->_hidden = 0;
$this->_locked = 1;
$this->_text_h_align = 0;
$this->_text_wrap = 0;
$this->_text_v_align = 2;
$this->_text_justlast = 0;
$this->_rotation = 0;
$this->_fg_color = 0x40;
$this->_bg_color = 0x41;
$this->_pattern = 0;
$this->_bottom = 0;
$this->_top = 0;
$this->_left = 0;
$this->_right = 0;
$this->_bottom_color = 0x40;
$this->_top_color = 0x40;
$this->_left_color = 0x40;
$this->_right_color = 0x40;
// Set properties passed to writeexcel_workbook::addformat()
if (sizeof($_)>0) {
call_user_func_array(array(&$this, 'set_properties'), $_);
}
}
/*
* Copy the attributes of another writeexcel_format object.
*/
function copy($other) {
$xf = $this->_xf_index; // Backup XF index
foreach ($other as $key->$value) {
$this->{$key} = $value;
}
$this->_xf_index = $xf; // Restore XF index
}
/*
* Generate an Excel BIFF XF record.
*/
function get_xf() {
$_=func_get_args();
// $record Record identifier
// $length Number of bytes to follow
// $ifnt Index to FONT record
// $ifmt Index to FORMAT record
// $style Style and other options
// $align Alignment
// $icv fg and bg pattern colors
// $fill Fill and border line style
// $border1 Border line style and color
// $border2 Border color
// Set the type of the XF record and some of the attributes.
if ($_[0] == "style") {
$style = 0xFFF5;
} else {
$style = $this->_locked;
$style |= $this->_hidden << 1;
}
// Flags to indicate if attributes have been set.
$atr_num = ($this->_num_format != 0) ? 1 : 0;
$atr_fnt = ($this->_font_index != 0) ? 1 : 0;
$atr_alc = $this->_text_wrap ? 1 : 0;
$atr_bdr = ($this->_bottom ||
$this->_top ||
$this->_left ||
$this->_right) ? 1 : 0;
$atr_pat = ($this->_fg_color != 0x41 ||
$this->_bg_color != 0x41 ||
$this->_pattern != 0x00) ? 1 : 0;
$atr_prot = 0;
// Reset the default colors for the non-font properties
if ($this->_fg_color == 0x7FFF) $this->_fg_color = 0x40;
if ($this->_bg_color == 0x7FFF) $this->_bg_color = 0x41;
if ($this->_bottom_color == 0x7FFF) $this->_bottom_color = 0x41;
if ($this->_top_color == 0x7FFF) $this->_top_color = 0x41;
if ($this->_left_color == 0x7FFF) $this->_left_color = 0x41;
if ($this->_right_color == 0x7FFF) $this->_right_color = 0x41;
// Zero the default border colour if the border has not been set.
if ($this->_bottom == 0) {
$this->_bottom_color = 0;
}
if ($this->_top == 0) {
$this->_top_color = 0;
}
if ($this->_right == 0) {
$this->_right_color = 0;
}
if ($this->_left == 0) {
$this->_left_color = 0;
}
// The following 2 logical statements take care of special cases in
// relation to cell colors and patterns:
// 1. For a solid fill (_pattern == 1) Excel reverses the role of
// foreground and background colors
// 2. If the user specifies a foreground or background color
// without a pattern they probably wanted a solid fill, so we
// fill in the defaults.
if ($this->_pattern <= 0x01 &&
$this->_bg_color != 0x41 &&
$this->_fg_color == 0x40 )
{
$this->_fg_color = $this->_bg_color;
$this->_bg_color = 0x40;
$this->_pattern = 1;
}
if ($this->_pattern <= 0x01 &&
$this->_bg_color == 0x41 &&
$this->_fg_color != 0x40 )
{
$this->_bg_color = 0x40;
$this->_pattern = 1;
}
$record = 0x00E0;
$length = 0x0010;
$ifnt = $this->_font_index;
$ifmt = $this->_num_format;
$align = $this->_text_h_align;
$align |= $this->_text_wrap << 3;
$align |= $this->_text_v_align << 4;
$align |= $this->_text_justlast << 7;
$align |= $this->_rotation << 8;
$align |= $atr_num << 10;
$align |= $atr_fnt << 11;
$align |= $atr_alc << 12;
$align |= $atr_bdr << 13;
$align |= $atr_pat << 14;
$align |= $atr_prot << 15;
$icv = $this->_fg_color;
$icv |= $this->_bg_color << 7;
$fill = $this->_pattern;
$fill |= $this->_bottom << 6;
$fill |= $this->_bottom_color << 9;
$border1 = $this->_top;
$border1 |= $this->_left << 3;
$border1 |= $this->_right << 6;
$border1 |= $this->_top_color << 9;
$border2 = $this->_left_color;
$border2 |= $this->_right_color << 7;
$header = pack("vv", $record, $length);
$data = pack("vvvvvvvv", $ifnt, $ifmt, $style, $align,
$icv, $fill,
$border1, $border2);
return($header . $data);
}
/*
* Generate an Excel BIFF FONT record.
*/
function get_font() {
// $record Record identifier
// $length Record length
// $dyHeight Height of font (1/20 of a point)
// $grbit Font attributes
// $icv Index to color palette
// $bls Bold style
// $sss Superscript/subscript
// $uls Underline
// $bFamily Font family
// $bCharSet Character set
// $reserved Reserved
// $cch Length of font name
// $rgch Font name
$dyHeight = $this->_size * 20;
$icv = $this->_color;
$bls = $this->_bold;
$sss = $this->_font_script;
$uls = $this->_underline;
$bFamily = $this->_font_family;
$bCharSet = $this->_font_charset;
$rgch = $this->_font;
$cch = strlen($rgch);
$record = 0x31;
$length = 0x0F + $cch;
$reserved = 0x00;
$grbit = 0x00;
if ($this->_italic) {
$grbit |= 0x02;
}
if ($this->_font_strikeout) {
$grbit |= 0x08;
}
if ($this->_font_outline) {
$grbit |= 0x10;
}
if ($this->_font_shadow) {
$grbit |= 0x20;
}
$header = pack("vv", $record, $length);
$data = pack("vvvvvCCCCC", $dyHeight, $grbit, $icv, $bls,
$sss, $uls, $bFamily,
$bCharSet, $reserved, $cch);
return($header . $data . $this->_font);
}
/*
* Returns a unique hash key for a font.
* Used by writeexcel_workbook::_store_all_fonts()
*/
function get_font_key() {
# The following elements are arranged to increase the probability of
# generating a unique key. Elements that hold a large range of numbers
# eg. _color are placed between two binary elements such as _italic
#
$key = $this->_font.$this->_size.
$this->_font_script.$this->_underline.
$this->_font_strikeout.$this->_bold.$this->_font_outline.
$this->_font_family.$this->_font_charset.
$this->_font_shadow.$this->_color.$this->_italic;
$key = preg_replace('/ /', '_', $key); # Convert the key to a single word
return $key;
}
/*
* Returns the used by Worksheet->_XF()
*/
function get_xf_index() {
return $this->_xf_index;
}
/*
* Used in conjunction with the set_xxx_color methods to convert a color
* string into a number. Color range is 0..63 but we will restrict it
* to 8..63 to comply with Gnumeric. Colors 0..7 are repeated in 8..15.
*/
function _get_color($color=false) {
$colors = array(
'aqua' => 0x0F,
'cyan' => 0x0F,
'black' => 0x08,
'blue' => 0x0C,
'brown' => 0x10,
'magenta' => 0x0E,
'fuchsia' => 0x0E,
'gray' => 0x17,
'grey' => 0x17,
'green' => 0x11,
'lime' => 0x0B,
'navy' => 0x12,
'orange' => 0x35,
'purple' => 0x14,
'red' => 0x0A,
'silver' => 0x16,
'white' => 0x09,
'yellow' => 0x0D
);
// Return the default color, 0x7FFF, if undef,
if ($color===false) {
return 0x7FFF;
}
// or the color string converted to an integer,
if (isset($colors[strtolower($color)])) {
return $colors[strtolower($color)];
}
// or the default color if string is unrecognised,
if (preg_match('/\D/', $color)) {
return 0x7FFF;
}
// or an index < 8 mapped into the correct range,
if ($color<8) {
return $color + 8;
}
// or the default color if arg is outside range,
if ($color>63) {
return 0x7FFF;
}
// or an integer in the valid range
return $color;
}
/*
* Set cell alignment.
*/
function set_align($location) {
// Ignore numbers
if (preg_match('/\d/', $location)) {
return;
}
$location = strtolower($location);
switch ($location) {
case 'left':
$this->set_text_h_align(1);
break;
case 'centre':
case 'center':
$this->set_text_h_align(2);
break;
case 'right':
$this->set_text_h_align(3);
break;
case 'fill':
$this->set_text_h_align(4);
break;
case 'justify':
$this->set_text_h_align(5);
break;
case 'merge':
$this->set_text_h_align(6);
break;
case 'equal_space':
$this->set_text_h_align(7);
break;
case 'top':
$this->set_text_v_align(0);
break;
case 'vcentre':
case 'vcenter':
$this->set_text_v_align(1);
break;
break;
case 'bottom':
$this->set_text_v_align(2);
break;
case 'vjustify':
$this->set_text_v_align(3);
break;
case 'vequal_space':
$this->set_text_v_align(4);
break;
}
}
/*
* Set vertical cell alignment. This is required by the set_properties()
* method to differentiate between the vertical and horizontal properties.
*/
function set_valign($location) {
$this->set_align($location);
}
/*
* This is an alias for the unintuitive set_align('merge')
*/
function set_merge() {
$this->set_text_h_align(6);
}
/*
* Bold has a range 0x64..0x3E8.
* 0x190 is normal. 0x2BC is bold.
*/
function set_bold($weight=1) {
if ($weight == 1) {
// Bold text
$weight = 0x2BC;
}
if ($weight == 0) {
// Normal text
$weight = 0x190;
}
if ($weight < 0x064) {
// Lower bound
$weight = 0x190;
}
if ($weight > 0x3E8) {
// Upper bound
$weight = 0x190;
}
$this->_bold = $weight;
}
/*
* Set all cell borders (bottom, top, left, right) to the same style
*/
function set_border($style) {
$this->set_bottom($style);
$this->set_top($style);
$this->set_left($style);
$this->set_right($style);
}
/*
* Set all cell borders (bottom, top, left, right) to the same color
*/
function set_border_color($color) {
$this->set_bottom_color($color);
$this->set_top_color($color);
$this->set_left_color($color);
$this->set_right_color($color);
}
/*
* Convert hashes of properties to method calls.
*/
function set_properties() {
$_=func_get_args();
$properties=array();
foreach($_ as $props) {
if (is_array($props)) {
$properties=array_merge($properties, $props);
} else {
$properties[]=$props;
}
}
foreach ($properties as $key=>$value) {
// Strip leading "-" from Tk style properties eg. -color => 'red'.
$key = preg_replace('/^-/', '', $key);
/* Make sure method names are alphanumeric characters only, in
case tainted data is passed to the eval(). */
if (preg_match('/\W/', $key)) {
trigger_error("Unknown property: $key.",
E_USER_ERROR);
}
/* Evaling all $values as a strings gets around the problem of
some numerical format strings being evaluated as numbers, for
example "00000" for a zip code. */
if (is_int($key)) {
eval("\$this->set_$value();");
} else {
eval("\$this->set_$key('$value');");
}
}
}
function set_font($font) {
$this->_font=$font;
}
function set_size($size) {
$this->_size=$size;
}
function set_italic($italic=1) {
$this->_italic=$italic;
}
function set_color($color) {
$this->_color=$this->_get_color($color);
}
function set_underline($underline=1) {
$this->_underline=$underline;
}
function set_font_strikeout($font_strikeout=1) {
$this->_font_strikeout=$font_strikeout;
}
function set_font_outline($font_outline=1) {
$this->_font_outline=$font_outline;
}
function set_font_shadow($font_shadow=1) {
$this->_font_shadow=$font_shadow;
}
function set_font_script($font_script=1) {
$this->_font_script=$font_script;
}
/* Undocumented */
function set_font_family($font_family=1) {
$this->_font_family=$font_family;
}
/* Undocumented */
function set_font_charset($font_charset=1) {
$this->_font_charset=$font_charset;
}
function set_num_format($num_format=1) {
$this->_num_format=$num_format;
}
function set_hidden($hidden=1) {
$this->_hidden=$hidden;
}
function set_locked($locked=1) {
$this->_locked=$locked;
}
function set_text_h_align($align) {
$this->_text_h_align=$align;
}
function set_text_wrap($wrap=1) {
$this->_text_wrap=$wrap;
}
function set_text_v_align($align) {
$this->_text_v_align=$align;
}
function set_text_justlast($text_justlast=1) {
$this->_text_justlast=$text_justlast;
}
function set_rotation($rotation=1) {
$this->_rotation=$rotation;
}
function set_fg_color($color) {
$this->_fg_color=$this->_get_color($color);
}
function set_bg_color($color) {
$this->_bg_color=$this->_get_color($color);
}
function set_pattern($pattern=1) {
$this->_pattern=$pattern;
}
function set_bottom($bottom=1) {
$this->_bottom=$bottom;
}
function set_top($top=1) {
$this->_top=$top;
}
function set_left($left=1) {
$this->_left=$left;
}
function set_right($right=1) {
$this->_right=$right;
}
function set_bottom_color($color) {
$this->_bottom_color=$this->_get_color($color);
}
function set_top_color($color) {
$this->_top_color=$this->_get_color($color);
}
function set_left_color($color) {
$this->_left_color=$this->_get_color($color);
}
function set_right_color($color) {
$this->_right_color=$this->_get_color($color);
}
}

View file

@ -1,351 +0,0 @@
<?php
/*
* Copyleft 2002 Johann Hanne
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*/
/*
* This is the Spreadsheet::WriteExcel Perl package ported to PHP
* Spreadsheet::WriteExcel was written by John McNamara, jmcnamara@cpan.org
*/
class writeexcel_olewriter {
var $_OLEfilename;
var $_OLEtmpfilename; /* ABR */
var $_filehandle;
var $_fileclosed;
var $_internal_fh;
var $_biff_only;
var $_size_allowed;
var $_biffsize;
var $_booksize;
var $_big_blocks;
var $_list_blocks;
var $_root_start;
var $_block_count;
/*
* Constructor
*/
function writeexcel_olewriter($filename) {
$this->_OLEfilename = $filename;
$this->_filehandle = false;
$this->_fileclosed = 0;
$this->_internal_fh = 0;
$this->_biff_only = 0;
$this->_size_allowed = 0;
$this->_biffsize = 0;
$this->_booksize = 0;
$this->_big_blocks = 0;
$this->_list_blocks = 0;
$this->_root_start = 0;
$this->_block_count = 4;
$this->_initialize();
}
/*
* Check for a valid filename and store the filehandle.
*/
function _initialize() {
$OLEfile = $this->_OLEfilename;
/* Check for a filename. Workbook.pm will catch this first. */
if ($OLEfile == '') {
trigger_error("Filename required", E_USER_ERROR);
}
/*
* If the filename is a resource it is assumed that it is a valid
* filehandle, if not we create a filehandle.
*/
if (is_resource($OLEfile)) {
$fh = $OLEfile;
} else {
// Create a new file, open for writing
$fh = fopen($OLEfile, "wb");
// The workbook class also checks this but something may have
// happened since then.
if (!$fh) {
trigger_error("Can't open $OLEfile. It may be in use or ".
"protected", E_USER_ERROR);
}
$this->_internal_fh = 1;
}
// Store filehandle
$this->_filehandle = $fh;
}
/*
* Set the size of the data to be written to the OLE stream
*
* $big_blocks = (109 depot block x (128 -1 marker word)
* - (1 x end words)) = 13842
* $maxsize = $big_blocks * 512 bytes = 7087104
*/
function set_size($size) {
$maxsize = 7087104;
if ($size > $maxsize) {
trigger_error("Maximum file size, $maxsize, exceeded. To create ".
"files bigger than this limit please use the ".
"workbookbig class.", E_USER_ERROR);
return ($this->_size_allowed = 0);
}
$this->_biffsize = $size;
// Set the min file size to 4k to avoid having to use small blocks
if ($size > 4096) {
$this->_booksize = $size;
} else {
$this->_booksize = 4096;
}
return ($this->_size_allowed = 1);
}
/*
* Calculate various sizes needed for the OLE stream
*/
function _calculate_sizes() {
$datasize = $this->_booksize;
if ($datasize % 512 == 0) {
$this->_big_blocks = $datasize/512;
} else {
$this->_big_blocks = floor($datasize/512)+1;
}
// There are 127 list blocks and 1 marker blocks for each big block
// depot + 1 end of chain block
$this->_list_blocks = floor(($this->_big_blocks)/127)+1;
$this->_root_start = $this->_big_blocks;
//print $this->_biffsize. "\n";
//print $this->_big_blocks. "\n";
//print $this->_list_blocks. "\n";
}
/*
* Write root entry, big block list and close the filehandle.
* This method must be called so that the file contents are
* actually written.
*/
function close() {
if (!$this->_size_allowed) {
return;
}
if (!$this->_biff_only) {
$this->_write_padding();
$this->_write_property_storage();
$this->_write_big_block_depot();
}
// Close the filehandle if it was created internally.
if ($this->_internal_fh) {
fclose($this->_filehandle);
}
/* ABR */
if ($this->_OLEtmpfilename != '') {
$fh = fopen($this->_OLEtmpfilename, "rb");
if ($fh == false) {
trigger_error("Can't read temporary file.", E_USER_ERROR);
}
fpassthru($fh);
fclose($fh);
unlink($this->_OLEtmpfilename);
};
$this->_fileclosed = 1;
}
/*
* Write BIFF data to OLE file.
*/
function write($data) {
fputs($this->_filehandle, $data);
}
/*
* Write OLE header block.
*/
function write_header() {
if ($this->_biff_only) {
return;
}
$this->_calculate_sizes();
$root_start = $this->_root_start;
$num_lists = $this->_list_blocks;
$id = pack("C8", 0xD0, 0xCF, 0x11, 0xE0,
0xA1, 0xB1, 0x1A, 0xE1);
$unknown1 = pack("VVVV", 0x00, 0x00, 0x00, 0x00);
$unknown2 = pack("vv", 0x3E, 0x03);
$unknown3 = pack("v", -2);
$unknown4 = pack("v", 0x09);
$unknown5 = pack("VVV", 0x06, 0x00, 0x00);
$num_bbd_blocks = pack("V", $num_lists);
$root_startblock = pack("V", $root_start);
$unknown6 = pack("VV", 0x00, 0x1000);
$sbd_startblock = pack("V", -2);
$unknown7 = pack("VVV", 0x00, -2 ,0x00);
$unused = pack("V", -1);
fputs($this->_filehandle, $id);
fputs($this->_filehandle, $unknown1);
fputs($this->_filehandle, $unknown2);
fputs($this->_filehandle, $unknown3);
fputs($this->_filehandle, $unknown4);
fputs($this->_filehandle, $unknown5);
fputs($this->_filehandle, $num_bbd_blocks);
fputs($this->_filehandle, $root_startblock);
fputs($this->_filehandle, $unknown6);
fputs($this->_filehandle, $sbd_startblock);
fputs($this->_filehandle, $unknown7);
for ($c=1;$c<=$num_lists;$c++) {
$root_start++;
fputs($this->_filehandle, pack("V", $root_start));
}
for ($c=$num_lists;$c<=108;$c++) {
fputs($this->_filehandle, $unused);
}
}
/*
* Write big block depot.
*/
function _write_big_block_depot() {
$num_blocks = $this->_big_blocks;
$num_lists = $this->_list_blocks;
$total_blocks = $num_lists * 128;
$used_blocks = $num_blocks + $num_lists + 2;
$marker = pack("V", -3);
$end_of_chain = pack("V", -2);
$unused = pack("V", -1);
for ($i=1;$i<=($num_blocks-1);$i++) {
fputs($this->_filehandle, pack("V", $i));
}
fputs($this->_filehandle, $end_of_chain);
fputs($this->_filehandle, $end_of_chain);
for ($c=1;$c<=$num_lists;$c++) {
fputs($this->_filehandle, $marker);
}
for ($c=$used_blocks;$c<=$total_blocks;$c++) {
fputs($this->_filehandle, $unused);
}
}
/*
* Write property storage. TODO: add summary sheets
*/
function _write_property_storage() {
$rootsize = -2;
$booksize = $this->_booksize;
// name type dir start size
$this->_write_pps('Root Entry', 0x05, 1, -2, 0x00);
$this->_write_pps('Book', 0x02, -1, 0x00, $booksize);
$this->_write_pps('', 0x00, -1, 0x00, 0x0000);
$this->_write_pps('', 0x00, -1, 0x00, 0x0000);
}
/*
* Write property sheet in property storage
*/
function _write_pps($name, $type, $dir, $start, $size) {
$names = array();
$length = 0;
if ($name != '') {
$name = $name . "\0";
// Simulate a Unicode string
$chars=preg_split("''", $name, -1, PREG_SPLIT_NO_EMPTY);
foreach ($chars as $char) {
array_push($names, ord($char));
}
$length = strlen($name) * 2;
}
$rawname = call_user_func_array('pack', array_merge(array("v*"), $names));
$zero = pack("C", 0);
$pps_sizeofname = pack("v", $length); //0x40
$pps_type = pack("v", $type); //0x42
$pps_prev = pack("V", -1); //0x44
$pps_next = pack("V", -1); //0x48
$pps_dir = pack("V", $dir); //0x4c
$unknown1 = pack("V", 0);
$pps_ts1s = pack("V", 0); //0x64
$pps_ts1d = pack("V", 0); //0x68
$pps_ts2s = pack("V", 0); //0x6c
$pps_ts2d = pack("V", 0); //0x70
$pps_sb = pack("V", $start); //0x74
$pps_size = pack("V", $size); //0x78
fputs($this->_filehandle, $rawname);
fputs($this->_filehandle, str_repeat($zero, (64-$length)));
fputs($this->_filehandle, $pps_sizeofname);
fputs($this->_filehandle, $pps_type);
fputs($this->_filehandle, $pps_prev);
fputs($this->_filehandle, $pps_next);
fputs($this->_filehandle, $pps_dir);
fputs($this->_filehandle, str_repeat($unknown1, 5));
fputs($this->_filehandle, $pps_ts1s);
fputs($this->_filehandle, $pps_ts1d);
fputs($this->_filehandle, $pps_ts2d);
fputs($this->_filehandle, $pps_ts2d);
fputs($this->_filehandle, $pps_sb);
fputs($this->_filehandle, $pps_size);
fputs($this->_filehandle, $unknown1);
}
/*
* Pad the end of the file
*/
function _write_padding() {
$biffsize = $this->_biffsize;
if ($biffsize < 4096) {
$min_size = 4096;
} else {
$min_size = 512;
}
if ($biffsize % $min_size != 0) {
$padding = $min_size - ($biffsize % $min_size);
fputs($this->_filehandle, str_repeat("\0", $padding));
}
}
}

View file

@ -1,53 +0,0 @@
<?php
/*
* Copyleft 2002 Johann Hanne
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*/
/*
* This is the Spreadsheet::WriteExcel Perl package ported to PHP
* Spreadsheet::WriteExcel was written by John McNamara, jmcnamara@cpan.org
*/
require_once "class.writeexcel_workbook.inc.php";
require_once "class.ole_pps_root.php";
require_once "class.ole_pps_file.php";
class writeexcel_workbookbig extends writeexcel_workbook {
function writeexcel_workbookbig($filename) {
$this->writeexcel_workbook($filename);
}
function _store_OLE_file() {
$file=new ole_pps_file(asc2ucs("Book"));
$file->append($this->_data);
for ($c=0;$c<sizeof($this->_worksheets);$c++) {
$worksheet=&$this->_worksheets[$c];
while ($data=$worksheet->get_data()) {
$file->append($data);
}
$worksheet->cleanup();
}
$ole=new ole_pps_root(false, false, array($file));
$ole->save($this->_filename);
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,7 @@
<?php <?php
/**
* @suppress PHP0419
*/
if (!defined('_GNUBOARD_')) if (!defined('_GNUBOARD_'))
exit; exit;

View file

@ -1,57 +0,0 @@
<?php
if (!defined('_GNUBOARD_'))
exit;
// http://kr1.php.net/manual/en/function.curl-setopt-array.php 참고
if (!function_exists('curl_setopt_array')) {
function curl_setopt_array(&$ch, $curl_options)
{
foreach ($curl_options as $option => $value) {
if (!curl_setopt($ch, $option, $value)) {
return false;
}
}
return true;
}
}
// 네이버 신디케이션에 ping url 을 curl 로 전달합니다.
function naver_syndi_ping($bo_table, $wr_id)
{
global $config;
$token = trim($config['cf_syndi_token']);
// 토큰값이 없다면 네이버 신디케이션 사용안함
if ($token == '')
return 0;
// 신디케이션 수집 제외게시판
if (preg_match('#^(' . $config['cf_syndi_except'] . ')$#', $bo_table))
return -2;
// curl library 가 지원되어야 합니다.
if (!function_exists('curl_init'))
return -3;
$ping_auth_header = "Authorization: Bearer " . $token;
$ping_url = urlencode(G5_SYNDI_URL . "/ping.php?bo_table={$bo_table}&wr_id={$wr_id}");
$ping_client_opt = array(
CURLOPT_URL => "https://apis.naver.com/crawl/nsyndi/v2",
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => "ping_url=" . $ping_url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_TIMEOUT => 10,
CURLOPT_HTTPHEADER => ["Host: apis.naver.com", "Pragma: no-cache", "Accept: */*", $ping_auth_header]
);
//print_r2($ping_client_opt); exit;
$ping = curl_init();
curl_setopt_array($ping, $ping_client_opt);
$response = curl_exec($ping);
curl_close($ping);
return $response;
}

View file

@ -1,2 +0,0 @@
<?php
include_once "../../common.php";

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 920 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1,022 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 969 B

View file

@ -1,22 +0,0 @@
Copyright (c) 2009 Abraham Williams - http://abrah.am - abraham@poseurte.ch
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

View file

@ -1,114 +0,0 @@
TwitterOAuth
------------
PHP library for working with Twitter's OAuth API.
Flow Overview
=============
1. Build TwitterOAuth object using client credentials.
2. Request temporary credentials from Twitter.
3. Build authorize URL for Twitter.
4. Redirect user to authorize URL.
5. User authorizes access and returns from Twitter.
6. Rebuild TwitterOAuth object with client credentials and temporary credentials.
7. Get token credentials from Twitter.
8. Rebuild TwitterOAuth object with client credentials and token credentials.
9. Query Twitter API.
Terminology
===========
The terminology has changed since 0.1.x to better match the draft-hammer-oauth IETF
RFC. You can read that at http://tools.ietf.org/html/draft-hammer-oauth. Some of the
terms will differ from those Twitter uses as well.
client credentials - Consumer key/secret you get when registering an app with Twitter.
temporary credentials - Previously known as the request token.
token credentials - Previously known as the access token.
Parameters
==========
There are a number of parameters you can modify after creating a TwitterOAuth object.
Switch an existing TwitterOAuth install to use version 1.1 of the API.
$connection->$host = "https://api.twitter.com/1.1/";
Custom useragent.
$connection->useragent = 'Custom useragent string';
Verify Twitters SSL certificate.
$connection->ssl_verifypeer = TRUE;
There are several more you can find in TwitterOAuth.php.
Extended flow using example code
================================
To use TwitterOAuth with the Twitter API you need *TwitterOAuth.php*, *OAuth.php* and
client credentials. You can get client credentials by registering your application at
[dev.twitter.com/apps](https://dev.twitter.com/apps).
Users start out on connect.php which displays the "Sign in with Twitter" image hyperlinked
to redirect.php. This button should be displayed on your homepage in your login section. The
client credentials are saved in config.php as `CONSUMER_KEY` and `CONSUMER_SECRET`. You can
save a static callback URL in the app settings page, in the config file or use a dynamic
callback URL later in step 2. In example use https://example.com/callback.php.
1) When a user lands on redirect.php we build a new TwitterOAuth object using the client credentials.
If you have your own configuration method feel free to use it instead of config.php.
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET); // Use config.php client credentials
$connection = new TwitterOAuth('abc890', '123xyz');
2) Using the built $connection object you will ask Twitter for temporary credentials. The `oauth_callback` value is required.
$temporary_credentials = $connection->getRequestToken(OAUTH_CALLBACK); // Use config.php callback URL.
3) Now that we have temporary credentials the user has to go to Twitter and authorize the app
to access and updates their data. You can also pass a second parameter of FALSE to not use [Sign
in with Twitter](https://dev.twitter.com/docs/auth/sign-twitter).
$redirect_url = $connection->getAuthorizeURL($temporary_credentials); // Use Sign in with Twitter
$redirect_url = $connection->getAuthorizeURL($temporary_credentials, FALSE);
4) You will now have a Twitter URL that you must send the user to.
https://api.twitter.com/oauth/authenticate?oauth_token=xyz123
5) The user is now on twitter.com and may have to login. Once authenticated with Twitter they will
will either have to click on allow/deny, or will be automatically redirected back to the callback.
6) Now that the user has returned to callback.php and allowed access we need to build a new
TwitterOAuth object using the temporary credentials.
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['oauth_token'],
$_SESSION['oauth_token_secret']);
7) Now we ask Twitter for long lasting token credentials. These are specific to the application
and user and will act like password to make future requests. Normally the token credentials would
get saved in your database but for this example we are just using sessions.
$token_credentials = $connection->getAccessToken($_REQUEST['oauth_verifier']);
8) With the token credentials we build a new TwitterOAuth object.
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $token_credentials['oauth_token'],
$token_credentials['oauth_token_secret']);
9) And finally we can make requests authenticated as the user. You can GET, POST, and DELETE API
methods. Directly copy the path from the API documentation and add an array of any parameter
you wish to include for the API method such as curser or in_reply_to_status_id.
$account = $connection->get('account/verify_credentials');
$status = $connection->post('statuses/update', array('status' => 'Text of status here', 'in_reply_to_status_id' => 123456));
$status = $connection->delete('statuses/destroy/12345');
Contributors
============
* [Abraham Williams](https://twitter.com/abraham) - Main developer, current maintainer.

View file

@ -1,2 +0,0 @@
<?php
include_once "../../../common.php";

View file

@ -1,40 +0,0 @@
<?php
/**
* @file
* Take the user when they return from Twitter. Get access tokens.
* Verify credentials and redirect to based on response from Twitter.
*/
/* Start session and load lib */
session_start();
include_once 'twitteroauth/twitteroauth.php';
include_once 'config.php';
/* If the oauth_token is old redirect to the connect page. */
if (isset($_REQUEST['oauth_token']) && $_SESSION['oauth_token'] !== $_REQUEST['oauth_token']) {
$_SESSION['oauth_status'] = 'oldtoken';
header('Location: ./clearsessions.php');
}
/* Create TwitteroAuth object with app key/secret and token key/secret from default phase */
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
/* Request access tokens from twitter */
$access_token = $connection->getAccessToken($_REQUEST['oauth_verifier']);
/* Save the access tokens. Normally these would be saved in a database for future use. */
$_SESSION['access_token'] = $access_token;
/* Remove no longer needed request tokens */
unset($_SESSION['oauth_token']);
unset($_SESSION['oauth_token_secret']);
/* If HTTP response is 200 continue otherwise send to connect page to retry */
if (200 == $connection->http_code) {
/* The user has been verified and the access tokens can be saved for future use */
$_SESSION['status'] = 'verified';
header('Location: ./index.php');
} else {
/* Save HTTP status for error dialog on connnect page.*/
header('Location: ./clearsessions.php');
}

View file

@ -1,87 +0,0 @@
<?php
include_once "./_common.php";
/**
* @file
* Take the user when they return from Twitter. Get access tokens.
* Verify credentials and redirect to based on response from Twitter.
*/
/* Start session and load lib */
//session_start();
include_once G5_SNS_PATH . '/twitter/twitteroauth/twitteroauth.php';
include_once G5_SNS_PATH . '/twitter/twitterconfig.php';
//print_r2($_SESSION); print_r2($_REQUEST); exit;
/* If the oauth_token is old redirect to the connect page. */
if (isset($_REQUEST['oauth_token']) && $_SESSION['oauth_token'] !== $_REQUEST['oauth_token']) {
$_SESSION['oauth_status'] = 'oldtoken';
header('Location: ./clearsessions.php');
}
/* Create TwitteroAuth object with app key/secret and token key/secret from default phase */
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
/* Request access tokens from twitter */
$access_token = $connection->getAccessToken($_REQUEST['oauth_verifier']);
/* Save the access tokens. Normally these would be saved in a database for future use. */
$_SESSION['access_token'] = $access_token;
/* Remove no longer needed request tokens */
unset($_SESSION['oauth_token']);
unset($_SESSION['oauth_token_secret']);
/*
if (200 == $connection->http_code) {
$_SESSION['status'] = 'verified';
header('Location: ./index.php');
} else {
header('Location: ./clearsessions.php');
}
exit;
*/
$g5['title'] = '트위터 콜백';
include_once G5_PATH . "/head.sub.php";
if (200 == $connection->http_code) {
$content = $connection->get('account/verify_credentials');
$sns_name = $content->name;
$sns_user = $content->screen_name;
set_cookie('ck_sns_name', $sns_name, 86400);
set_session('ss_twitter_user', $sns_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.$("#twitter_icon").attr("src", "{$g5_sns_url}/icon/twitter.png");
opener.$("#twitter_checked").attr("disabled", false);
opener.$("#twitter_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";

View file

@ -1,14 +0,0 @@
<?php
include_once "./_common.php";
/**
* @file
* Clears PHP sessions and redirects to the connect page.
*/
/* Load and clear sessions */
session_start();
session_destroy();
/* Redirect to page with the connect to Twitter option. */
header('Location: ./connect.php');

View file

@ -1,10 +0,0 @@
<?php
/**
* @file
* A single location to store configuration.
*/
define('CONSUMER_KEY', 'CONSUMER_KEY_HERE');
define('CONSUMER_SECRET', 'CONSUMER_SECRET_HERE');
define('OAUTH_CALLBACK', 'http://example.com/twitteroauth/callback.php');

View file

@ -1,22 +0,0 @@
<?php
include_once "./_common.php";
/**
* @file
* Check if consumer token is set and if so send user to get a request token.
*/
/**
* Exit with an error message if the CONSUMER_KEY or CONSUMER_SECRET is not defined.
*/
include_once G5_SNS_PATH.'/twitter/twitterconfig.php';
if (CONSUMER_KEY === '' || CONSUMER_SECRET === '' || CONSUMER_KEY === 'CONSUMER_KEY_HERE' || CONSUMER_SECRET === 'CONSUMER_SECRET_HERE') {
echo 'You need a consumer key and secret to test the sample code. Get one from <a href="https://dev.twitter.com/apps">dev.twitter.com/apps</a>';
exit;
}
/* Build an image link to start the redirect process. */
$content = '<a href="./redirect.php"><img src="./images/lighter.png" alt="Sign in with Twitter"/></a>';
/* Include HTML to display on the page. */
include 'html.inc';

View file

@ -1,39 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Twitter OAuth in PHP</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<style type="text/css">
img {border-width: 0}
* {font-family:'Lucida Grande', sans-serif;}
</style>
</head>
<body>
<div>
<h2>Welcome to a Twitter OAuth PHP example.</h2>
<p>This site is a basic showcase of Twitters OAuth authentication method. If you are having issues try <a href='./clearsessions.php'>clearing your session</a>.</p>
<p>
Links:
<a href='http://github.com/abraham/twitteroauth'>Source Code</a> &amp;
<a href='http://wiki.github.com/abraham/twitteroauth/documentation'>Documentation</a> |
Contact @<a href='http://twitter.com/abraham'>abraham</a>
</p>
<hr />
<?php if (isset($menu)) { ?>
<?php echo $menu; ?>
<?php } ?>
</div>
<?php if (isset($status_text)) { ?>
<?php echo '<h3>'.$status_text.'</h3>'; ?>
<?php } ?>
<p>
<pre>
<?php print_r($content); ?>
</pre>
</p>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

View file

@ -1,35 +0,0 @@
<?php
include_once "./_common.php";
/**
* @file
* User has successfully authenticated with Twitter. Access tokens saved to session and DB.
*/
/* Load required lib files. */
//session_start();
include_once G5_SNS_PATH.'/twitter/twitteroauth/twitteroauth.php';
include_once G5_SNS_PATH.'/twitter/twitterconfig.php';
/* If access tokens are not available redirect to connect page. */
if (empty($_SESSION['access_token']) || empty($_SESSION['access_token']['oauth_token']) || empty($_SESSION['access_token']['oauth_token_secret'])) {
header('Location: ./clearsessions.php');
}
/* Get user access tokens out of the session. */
$access_token = $_SESSION['access_token'];
/* Create a TwitterOauth object with consumer/user tokens. */
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);
/* If method is set change API call made. Test is called by default. */
$content = $connection->get('account/verify_credentials');
/* Some example calls */
//$connection->get('users/show', array('screen_name' => 'abraham'));
//$connection->post('statuses/update', array('status' => date(DATE_RFC822)));
//$connection->post('statuses/destroy', array('id' => 5437877770));
//$connection->post('friendships/create', array('id' => 9436992));
//$connection->post('friendships/destroy', array('id' => 9436992));
/* Include HTML to display on the page */
include 'html.inc';

View file

@ -1,31 +0,0 @@
<?php
include_once "./_common.php";
/* Start session and load library. */
//session_start();
include_once G5_SNS_PATH.'/twitter/twitteroauth/twitteroauth.php';
include_once G5_SNS_PATH.'/twitter/twitterconfig.php';
/* Build TwitterOAuth object with client credentials. */
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
/* Get temporary credentials. */
$request_token = $connection->getRequestToken(OAUTH_CALLBACK);
/* Save temporary credentials to session. */
$_SESSION['oauth_token'] = $token = @$request_token['oauth_token'];
$_SESSION['oauth_token_secret'] = @$request_token['oauth_token_secret'];
//print_r2($_SESSION); exit;
/* If last connection failed don't display authorization link. */
switch ($connection->http_code) {
case 200:
/* Build authorize URL and redirect user to Twitter. */
$url = $connection->getAuthorizeURL($token);
header('Location: ' . $url);
break;
default:
/* Show notification if something went wrong. */
echo 'Could not connect to Twitter. Refresh the page or try again later.';
}

View file

@ -1,10 +0,0 @@
<?php
/**
* @file
* A single location to store configuration.
*/
define('CONSUMER_KEY', $config['cf_twitter_key']);
define('CONSUMER_SECRET', $config['cf_twitter_secret']);
define('OAUTH_CALLBACK', G5_SNS_URL.'/twitter/callback.php');
//define('OAUTH_CALLBACK', '');

View file

@ -1,872 +0,0 @@
<?php
// vim: foldmethod=marker
/* Generic exception class
*/
class OAuthException extends Exception {
// pass
}
class OAuthConsumer {
public $key;
public $secret;
function __construct($key, $secret, $callback_url=NULL) {
$this->key = $key;
$this->secret = $secret;
$this->callback_url = $callback_url;
}
function __toString() {
return "OAuthConsumer[key=$this->key,secret=$this->secret]";
}
}
class OAuthToken {
// access tokens and request tokens
public $key;
public $secret;
/**
* key = the token
* secret = the token secret
*/
function __construct($key, $secret) {
$this->key = $key;
$this->secret = $secret;
}
/**
* generates the basic string serialization of a token that a server
* would respond to request_token and access_token calls with
*/
function to_string() {
return "oauth_token=" .
OAuthUtil::urlencode_rfc3986($this->key) .
"&oauth_token_secret=" .
OAuthUtil::urlencode_rfc3986($this->secret);
}
function __toString() {
return $this->to_string();
}
}
/**
* A class for implementing a Signature Method
* See section 9 ("Signing Requests") in the spec
*/
abstract class OAuthSignatureMethod {
/**
* Needs to return the name of the Signature Method (ie HMAC-SHA1)
* @return string
*/
abstract public function get_name();
/**
* Build up the signature
* NOTE: The output of this function MUST NOT be urlencoded.
* the encoding is handled in OAuthRequest when the final
* request is serialized
* @param OAuthRequest $request
* @param OAuthConsumer $consumer
* @param OAuthToken $token
* @return string
*/
abstract public function build_signature($request, $consumer, $token);
/**
* Verifies that a given signature is correct
* @param OAuthRequest $request
* @param OAuthConsumer $consumer
* @param OAuthToken $token
* @param string $signature
* @return bool
*/
public function check_signature($request, $consumer, $token, $signature) {
$built = $this->build_signature($request, $consumer, $token);
return $built == $signature;
}
}
/**
* The HMAC-SHA1 signature method uses the HMAC-SHA1 signature algorithm as defined in [RFC2104]
* where the Signature Base String is the text and the key is the concatenated values (each first
* encoded per Parameter Encoding) of the Consumer Secret and Token Secret, separated by an '&'
* character (ASCII code 38) even if empty.
* - Chapter 9.2 ("HMAC-SHA1")
*/
class OAuthSignatureMethod_HMAC_SHA1 extends OAuthSignatureMethod {
function get_name() {
return "HMAC-SHA1";
}
public function build_signature($request, $consumer, $token) {
$base_string = $request->get_signature_base_string();
$request->base_string = $base_string;
$key_parts = array(
$consumer->secret,
($token) ? $token->secret : ""
);
$key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
$key = implode('&', $key_parts);
return base64_encode(hash_hmac('sha1', $base_string, $key, true));
}
}
/**
* The PLAINTEXT method does not provide any security protection and SHOULD only be used
* over a secure channel such as HTTPS. It does not use the Signature Base String.
* - Chapter 9.4 ("PLAINTEXT")
*/
class OAuthSignatureMethod_PLAINTEXT extends OAuthSignatureMethod {
public function get_name() {
return "PLAINTEXT";
}
/**
* oauth_signature is set to the concatenated encoded values of the Consumer Secret and
* Token Secret, separated by a '&' character (ASCII code 38), even if either secret is
* empty. The result MUST be encoded again.
* - Chapter 9.4.1 ("Generating Signatures")
*
* Please note that the second encoding MUST NOT happen in the SignatureMethod, as
* OAuthRequest handles this!
*/
public function build_signature($request, $consumer, $token) {
$key_parts = array(
$consumer->secret,
($token) ? $token->secret : ""
);
$key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
$key = implode('&', $key_parts);
$request->base_string = $key;
return $key;
}
}
/**
* The RSA-SHA1 signature method uses the RSASSA-PKCS1-v1_5 signature algorithm as defined in
* [RFC3447] section 8.2 (more simply known as PKCS#1), using SHA-1 as the hash function for
* EMSA-PKCS1-v1_5. It is assumed that the Consumer has provided its RSA public key in a
* verified way to the Service Provider, in a manner which is beyond the scope of this
* specification.
* - Chapter 9.3 ("RSA-SHA1")
*/
abstract class OAuthSignatureMethod_RSA_SHA1 extends OAuthSignatureMethod {
public function get_name() {
return "RSA-SHA1";
}
// Up to the SP to implement this lookup of keys. Possible ideas are:
// (1) do a lookup in a table of trusted certs keyed off of consumer
// (2) fetch via http using a url provided by the requester
// (3) some sort of specific discovery code based on request
//
// Either way should return a string representation of the certificate
protected abstract function fetch_public_cert(&$request);
// Up to the SP to implement this lookup of keys. Possible ideas are:
// (1) do a lookup in a table of trusted certs keyed off of consumer
//
// Either way should return a string representation of the certificate
protected abstract function fetch_private_cert(&$request);
public function build_signature($request, $consumer, $token) {
$base_string = $request->get_signature_base_string();
$request->base_string = $base_string;
// Fetch the private key cert based on the request
$cert = $this->fetch_private_cert($request);
// Pull the private key ID from the certificate
$privatekeyid = openssl_get_privatekey($cert);
// Sign using the key
$ok = openssl_sign($base_string, $signature, $privatekeyid);
// Release the key resource
openssl_free_key($privatekeyid);
return base64_encode($signature);
}
public function check_signature($request, $consumer, $token, $signature) {
$decoded_sig = base64_decode($signature);
$base_string = $request->get_signature_base_string();
// Fetch the public key cert based on the request
$cert = $this->fetch_public_cert($request);
// Pull the public key ID from the certificate
$publickeyid = openssl_get_publickey($cert);
// Check the computed signature against the one passed in the query
$ok = openssl_verify($base_string, $decoded_sig, $publickeyid);
// Release the key resource
openssl_free_key($publickeyid);
return $ok == 1;
}
}
class OAuthRequest {
private $parameters;
private $http_method;
private $http_url;
// for debug purposes
public $base_string;
public static $version = '1.0';
public static $POST_INPUT = 'php://input';
function __construct($http_method, $http_url, $parameters=NULL) {
@$parameters or $parameters = array();
$parameters = array_merge( OAuthUtil::parse_parameters(parse_url($http_url, PHP_URL_QUERY)), $parameters);
$this->parameters = $parameters;
$this->http_method = $http_method;
$this->http_url = $http_url;
}
/**
* attempt to build up a request from what was passed to the server
*/
public static function from_request($http_method=NULL, $http_url=NULL, $parameters=NULL) {
$scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on")
? 'http'
: 'https';
@$http_url or $http_url = $scheme .
'://' . $_SERVER['HTTP_HOST'] .
':' .
$_SERVER['SERVER_PORT'] .
$_SERVER['REQUEST_URI'];
@$http_method or $http_method = $_SERVER['REQUEST_METHOD'];
// We weren't handed any parameters, so let's find the ones relevant to
// this request.
// If you run XML-RPC or similar you should use this to provide your own
// parsed parameter-list
if (!$parameters) {
// Find request headers
$request_headers = OAuthUtil::get_headers();
// Parse the query-string to find GET parameters
$parameters = OAuthUtil::parse_parameters($_SERVER['QUERY_STRING']);
// It's a POST request of the proper content-type, so parse POST
// parameters and add those overriding any duplicates from GET
if ($http_method == "POST"
&& @strstr($request_headers["Content-Type"],
"application/x-www-form-urlencoded")
) {
$post_data = OAuthUtil::parse_parameters(
file_get_contents(self::$POST_INPUT)
);
$parameters = array_merge($parameters, $post_data);
}
// We have a Authorization-header with OAuth data. Parse the header
// and add those overriding any duplicates from GET or POST
if (@substr($request_headers['Authorization'], 0, 6) == "OAuth ") {
$header_parameters = OAuthUtil::split_header(
$request_headers['Authorization']
);
$parameters = array_merge($parameters, $header_parameters);
}
}
return new OAuthRequest($http_method, $http_url, $parameters);
}
/**
* pretty much a helper function to set up the request
*/
public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=NULL) {
@$parameters or $parameters = array();
$defaults = array("oauth_version" => OAuthRequest::$version,
"oauth_nonce" => OAuthRequest::generate_nonce(),
"oauth_timestamp" => OAuthRequest::generate_timestamp(),
"oauth_consumer_key" => $consumer->key);
if ($token)
$defaults['oauth_token'] = $token->key;
$parameters = array_merge($defaults, $parameters);
return new OAuthRequest($http_method, $http_url, $parameters);
}
public function set_parameter($name, $value, $allow_duplicates = true) {
if ($allow_duplicates && isset($this->parameters[$name])) {
// We have already added parameter(s) with this name, so add to the list
if (is_scalar($this->parameters[$name])) {
// This is the first duplicate, so transform scalar (string)
// into an array so we can add the duplicates
$this->parameters[$name] = array($this->parameters[$name]);
}
$this->parameters[$name][] = $value;
} else {
$this->parameters[$name] = $value;
}
}
public function get_parameter($name) {
return isset($this->parameters[$name]) ? $this->parameters[$name] : null;
}
public function get_parameters() {
return $this->parameters;
}
public function unset_parameter($name) {
unset($this->parameters[$name]);
}
/**
* The request parameters, sorted and concatenated into a normalized string.
* @return string
*/
public function get_signable_parameters() {
// Grab all parameters
$params = $this->parameters;
// Remove oauth_signature if present
// Ref: Spec: 9.1.1 ("The oauth_signature parameter MUST be excluded.")
if (isset($params['oauth_signature'])) {
unset($params['oauth_signature']);
}
return OAuthUtil::build_http_query($params);
}
/**
* Returns the base string of this request
*
* The base string defined as the method, the url
* and the parameters (normalized), each urlencoded
* and the concated with &.
*/
public function get_signature_base_string() {
$parts = array(
$this->get_normalized_http_method(),
$this->get_normalized_http_url(),
$this->get_signable_parameters()
);
$parts = OAuthUtil::urlencode_rfc3986($parts);
return implode('&', $parts);
}
/**
* just uppercases the http method
*/
public function get_normalized_http_method() {
return strtoupper($this->http_method);
}
/**
* parses the url and rebuilds it to be
* scheme://host/path
*/
public function get_normalized_http_url() {
$parts = parse_url($this->http_url);
$port = @$parts['port'];
$scheme = $parts['scheme'];
$host = $parts['host'];
$path = @$parts['path'];
$port or $port = ($scheme == 'https') ? '443' : '80';
if (($scheme == 'https' && $port != '443')
|| ($scheme == 'http' && $port != '80')) {
$host = "$host:$port";
}
return "$scheme://$host$path";
}
/**
* builds a url usable for a GET request
*/
public function to_url() {
$post_data = $this->to_postdata();
$out = $this->get_normalized_http_url();
if ($post_data) {
$out .= '?'.$post_data;
}
return $out;
}
/**
* builds the data one would send in a POST request
*/
public function to_postdata() {
return OAuthUtil::build_http_query($this->parameters);
}
/**
* builds the Authorization: header
*/
public function to_header($realm=null) {
$first = true;
if($realm) {
$out = 'Authorization: OAuth realm="' . OAuthUtil::urlencode_rfc3986($realm) . '"';
$first = false;
} else
$out = 'Authorization: OAuth';
$total = array();
foreach ($this->parameters as $k => $v) {
if (substr($k, 0, 5) != "oauth") continue;
if (is_array($v)) {
throw new OAuthException('Arrays not supported in headers');
}
$out .= ($first) ? ' ' : ',';
$out .= OAuthUtil::urlencode_rfc3986($k) .
'="' .
OAuthUtil::urlencode_rfc3986($v) .
'"';
$first = false;
}
return $out;
}
public function __toString() {
return $this->to_url();
}
public function sign_request($signature_method, $consumer, $token) {
$this->set_parameter(
"oauth_signature_method",
$signature_method->get_name(),
false
);
$signature = $this->build_signature($signature_method, $consumer, $token);
$this->set_parameter("oauth_signature", $signature, false);
}
public function build_signature($signature_method, $consumer, $token) {
$signature = $signature_method->build_signature($this, $consumer, $token);
return $signature;
}
/**
* util function: current timestamp
*/
private static function generate_timestamp() {
return time();
}
/**
* util function: current nonce
*/
private static function generate_nonce() {
$mt = microtime();
$rand = mt_rand();
return md5($mt . $rand); // md5s look nicer than numbers
}
}
class OAuthServer {
protected $timestamp_threshold = 300; // in seconds, five minutes
protected $version = '1.0'; // hi blaine
protected $signature_methods = array();
protected $data_store;
function __construct($data_store) {
$this->data_store = $data_store;
}
public function add_signature_method($signature_method) {
$this->signature_methods[$signature_method->get_name()] =
$signature_method;
}
// high level functions
/**
* process a request_token request
* returns the request token on success
*/
public function fetch_request_token(&$request) {
$this->get_version($request);
$consumer = $this->get_consumer($request);
// no token required for the initial token request
$token = NULL;
$this->check_signature($request, $consumer, $token);
// Rev A change
$callback = $request->get_parameter('oauth_callback');
$new_token = $this->data_store->new_request_token($consumer, $callback);
return $new_token;
}
/**
* process an access_token request
* returns the access token on success
*/
public function fetch_access_token(&$request) {
$this->get_version($request);
$consumer = $this->get_consumer($request);
// requires authorized request token
$token = $this->get_token($request, $consumer, "request");
$this->check_signature($request, $consumer, $token);
// Rev A change
$verifier = $request->get_parameter('oauth_verifier');
$new_token = $this->data_store->new_access_token($token, $consumer, $verifier);
return $new_token;
}
/**
* verify an api call, checks all the parameters
*/
public function verify_request(&$request) {
$this->get_version($request);
$consumer = $this->get_consumer($request);
$token = $this->get_token($request, $consumer, "access");
$this->check_signature($request, $consumer, $token);
return array($consumer, $token);
}
// Internals from here
/**
* version 1
*/
private function get_version(&$request) {
$version = $request->get_parameter("oauth_version");
if (!$version) {
// Service Providers MUST assume the protocol version to be 1.0 if this parameter is not present.
// Chapter 7.0 ("Accessing Protected Ressources")
$version = '1.0';
}
if ($version !== $this->version) {
throw new OAuthException("OAuth version '$version' not supported");
}
return $version;
}
/**
* figure out the signature with some defaults
*/
private function get_signature_method(&$request) {
$signature_method =
@$request->get_parameter("oauth_signature_method");
if (!$signature_method) {
// According to chapter 7 ("Accessing Protected Ressources") the signature-method
// parameter is required, and we can't just fallback to PLAINTEXT
throw new OAuthException('No signature method parameter. This parameter is required');
}
if (!in_array($signature_method,
array_keys($this->signature_methods))) {
throw new OAuthException(
"Signature method '$signature_method' not supported " .
"try one of the following: " .
implode(", ", array_keys($this->signature_methods))
);
}
return $this->signature_methods[$signature_method];
}
/**
* try to find the consumer for the provided request's consumer key
*/
private function get_consumer(&$request) {
$consumer_key = @$request->get_parameter("oauth_consumer_key");
if (!$consumer_key) {
throw new OAuthException("Invalid consumer key");
}
$consumer = $this->data_store->lookup_consumer($consumer_key);
if (!$consumer) {
throw new OAuthException("Invalid consumer");
}
return $consumer;
}
/**
* try to find the token for the provided request's token key
*/
private function get_token(&$request, $consumer, $token_type="access") {
$token_field = @$request->get_parameter('oauth_token');
$token = $this->data_store->lookup_token(
$consumer, $token_type, $token_field
);
if (!$token) {
throw new OAuthException("Invalid $token_type token: $token_field");
}
return $token;
}
/**
* all-in-one function to check the signature on a request
* should guess the signature method appropriately
*/
private function check_signature(&$request, $consumer, $token) {
// this should probably be in a different method
$timestamp = @$request->get_parameter('oauth_timestamp');
$nonce = @$request->get_parameter('oauth_nonce');
$this->check_timestamp($timestamp);
$this->check_nonce($consumer, $token, $nonce, $timestamp);
$signature_method = $this->get_signature_method($request);
$signature = $request->get_parameter('oauth_signature');
$valid_sig = $signature_method->check_signature(
$request,
$consumer,
$token,
$signature
);
if (!$valid_sig) {
throw new OAuthException("Invalid signature");
}
}
/**
* check that the timestamp is new enough
*/
private function check_timestamp($timestamp) {
if( ! $timestamp )
throw new OAuthException(
'Missing timestamp parameter. The parameter is required'
);
// verify that timestamp is recentish
$now = time();
if (abs($now - $timestamp) > $this->timestamp_threshold) {
throw new OAuthException(
"Expired timestamp, yours $timestamp, ours $now"
);
}
}
/**
* check that the nonce is not repeated
*/
private function check_nonce($consumer, $token, $nonce, $timestamp) {
if( ! $nonce )
throw new OAuthException(
'Missing nonce parameter. The parameter is required'
);
// verify that the nonce is uniqueish
$found = $this->data_store->lookup_nonce(
$consumer,
$token,
$nonce,
$timestamp
);
if ($found) {
throw new OAuthException("Nonce already used: $nonce");
}
}
}
class OAuthDataStore {
function lookup_consumer($consumer_key) {
// implement me
}
function lookup_token($consumer, $token_type, $token) {
// implement me
}
function lookup_nonce($consumer, $token, $nonce, $timestamp) {
// implement me
}
function new_request_token($consumer, $callback = null) {
// return a new token attached to this consumer
}
function new_access_token($token, $consumer, $verifier = null) {
// return a new access token attached to this consumer
// for the user associated with this token if the request token
// is authorized
// should also invalidate the request token
}
}
class OAuthUtil {
public static function urlencode_rfc3986($input) {
if (is_array($input)) {
return array_map(array('OAuthUtil', 'urlencode_rfc3986'), $input);
} else if (is_scalar($input)) {
return str_replace(
'+',
' ',
str_replace('%7E', '~', rawurlencode($input))
);
} else {
return '';
}
}
// This decode function isn't taking into consideration the above
// modifications to the encoding process. However, this method doesn't
// seem to be used anywhere so leaving it as is.
public static function urldecode_rfc3986($string) {
return urldecode($string);
}
// Utility function for turning the Authorization: header into
// parameters, has to do some unescaping
// Can filter out any non-oauth parameters if needed (default behaviour)
public static function split_header($header, $only_allow_oauth_parameters = true) {
$pattern = '/(([-_a-z]*)=("([^"]*)"|([^,]*)),?)/';
$offset = 0;
$params = array();
while (preg_match($pattern, $header, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
$match = $matches[0];
$header_name = $matches[2][0];
$header_content = (isset($matches[5])) ? $matches[5][0] : $matches[4][0];
if (preg_match('/^oauth_/', $header_name) || !$only_allow_oauth_parameters) {
$params[$header_name] = OAuthUtil::urldecode_rfc3986($header_content);
}
$offset = $match[1] + strlen($match[0]);
}
if (isset($params['realm'])) {
unset($params['realm']);
}
return $params;
}
// helper to try to sort out headers for people who aren't running apache
public static function get_headers() {
if (function_exists('apache_request_headers')) {
// we need this to get the actual Authorization: header
// because apache tends to tell us it doesn't exist
$headers = apache_request_headers();
// sanitize the output of apache_request_headers because
// we always want the keys to be Cased-Like-This and arh()
// returns the headers in the same case as they are in the
// request
$out = array();
foreach( $headers AS $key => $value ) {
$key = str_replace(
" ",
"-",
ucwords(strtolower(str_replace("-", " ", $key)))
);
$out[$key] = $value;
}
} else {
// otherwise we don't have apache and are just going to have to hope
// that $_SERVER actually contains what we need
$out = array();
if( isset($_SERVER['CONTENT_TYPE']) )
$out['Content-Type'] = $_SERVER['CONTENT_TYPE'];
if( isset($_ENV['CONTENT_TYPE']) )
$out['Content-Type'] = $_ENV['CONTENT_TYPE'];
foreach ($_SERVER as $key => $value) {
if (substr($key, 0, 5) == "HTTP_") {
// this is chaos, basically it is just there to capitalize the first
// letter of every word that is not an initial HTTP and strip HTTP
// code from przemek
$key = str_replace(
" ",
"-",
ucwords(strtolower(str_replace("_", " ", substr($key, 5))))
);
$out[$key] = $value;
}
}
}
return $out;
}
// This function takes a input like a=b&a=c&d=e and returns the parsed
// parameters like this
// array('a' => array('b','c'), 'd' => 'e')
public static function parse_parameters( $input ) {
if (!isset($input) || !$input) return array();
$pairs = explode('&', $input);
$parsed_parameters = array();
foreach ($pairs as $pair) {
$split = explode('=', $pair, 2);
$parameter = OAuthUtil::urldecode_rfc3986($split[0]);
$value = isset($split[1]) ? OAuthUtil::urldecode_rfc3986($split[1]) : '';
if (isset($parsed_parameters[$parameter])) {
// We have already recieved parameter(s) with this name, so add to the list
// of parameters with this name
if (is_scalar($parsed_parameters[$parameter])) {
// This is the first duplicate, so transform scalar (string) into an array
// so we can add the duplicates
$parsed_parameters[$parameter] = array($parsed_parameters[$parameter]);
}
$parsed_parameters[$parameter][] = $value;
} else {
$parsed_parameters[$parameter] = $value;
}
}
return $parsed_parameters;
}
public static function build_http_query($params) {
if (!$params) return '';
// Urlencode both keys and values
$keys = OAuthUtil::urlencode_rfc3986(array_keys($params));
$values = OAuthUtil::urlencode_rfc3986(array_values($params));
$params = array_combine($keys, $values);
// Parameters are sorted by name, using lexicographical byte value ordering.
// Ref: Spec: 9.1.1 (1)
uksort($params, 'strcmp');
$pairs = array();
foreach ($params as $parameter => $value) {
if (is_array($value)) {
// If two or more parameters share the same name, they are sorted by their value
// Ref: Spec: 9.1.1 (1)
natsort($value);
foreach ($value as $duplicate_value) {
$pairs[] = $parameter . '=' . $duplicate_value;
}
} else {
$pairs[] = $parameter . '=' . $value;
}
}
// For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
// Each name-value pair is separated by an '&' character (ASCII code 38)
return implode('&', $pairs);
}
}

View file

@ -1,241 +0,0 @@
<?php
/*
* Abraham Williams (abraham@abrah.am) http://abrah.am
*
* The first PHP Library to support OAuth for Twitter's REST API.
*/
/* Load OAuth lib. You can find it at http://oauth.net */
include_once 'OAuth.php';
/**
* Twitter OAuth class
*/
class TwitterOAuth {
/* Contains the last HTTP status code returned. */
public $http_code;
/* Contains the last API call. */
public $url;
/* Set up the API root URL. */
public $host = "https://api.twitter.com/1.1/";
/* Set timeout default. */
public $timeout = 30;
/* Set connect timeout. */
public $connecttimeout = 30;
/* Verify SSL Cert. */
public $ssl_verifypeer = FALSE;
/* Respons format. */
public $format = 'json';
/* Decode returned json data. */
public $decode_json = TRUE;
/* Contains the last HTTP headers returned. */
public $http_info;
/* Set the useragnet. */
public $useragent = 'TwitterOAuth v0.2.0-beta2';
/* Immediately retry the API call if the response was not successful. */
//public $retry = TRUE;
/**
* Set API URLS
*/
function accessTokenURL() { return 'https://api.twitter.com/oauth/access_token'; }
function authenticateURL() { return 'https://api.twitter.com/oauth/authenticate'; }
function authorizeURL() { return 'https://api.twitter.com/oauth/authorize'; }
function requestTokenURL() { return 'https://api.twitter.com/oauth/request_token'; }
/**
* Debug helpers
*/
function lastStatusCode() { return $this->http_status; }
function lastAPICall() { return $this->last_api_call; }
/**
* construct TwitterOAuth object
*/
function __construct($consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL) {
$this->sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
$this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
if (!empty($oauth_token) && !empty($oauth_token_secret)) {
$this->token = new OAuthConsumer($oauth_token, $oauth_token_secret);
} else {
$this->token = NULL;
}
}
/**
* Get a request_token from Twitter
*
* @returns a key/value array containing oauth_token and oauth_token_secret
*/
function getRequestToken($oauth_callback) {
$parameters = array();
$parameters['oauth_callback'] = $oauth_callback;
$request = $this->oAuthRequest($this->requestTokenURL(), 'GET', $parameters);
$token = OAuthUtil::parse_parameters($request);
$this->token = new OAuthConsumer(@$token['oauth_token'], @$token['oauth_token_secret']);
return $token;
}
/**
* Get the authorize URL
*
* @returns a string
*/
function getAuthorizeURL($token, $sign_in_with_twitter = TRUE) {
if (is_array($token)) {
$token = $token['oauth_token'];
}
if (empty($sign_in_with_twitter)) {
return $this->authorizeURL() . "?oauth_token={$token}";
} else {
return $this->authenticateURL() . "?oauth_token={$token}";
}
}
/**
* Exchange request token and secret for an access token and
* secret, to sign API calls.
*
* @returns array("oauth_token" => "the-access-token",
* "oauth_token_secret" => "the-access-secret",
* "user_id" => "9436992",
* "screen_name" => "abraham")
*/
function getAccessToken($oauth_verifier) {
$parameters = array();
$parameters['oauth_verifier'] = $oauth_verifier;
$request = $this->oAuthRequest($this->accessTokenURL(), 'GET', $parameters);
$token = OAuthUtil::parse_parameters($request);
$this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
return $token;
}
/**
* One time exchange of username and password for access token and secret.
*
* @returns array("oauth_token" => "the-access-token",
* "oauth_token_secret" => "the-access-secret",
* "user_id" => "9436992",
* "screen_name" => "abraham",
* "x_auth_expires" => "0")
*/
function getXAuthToken($username, $password) {
$parameters = array();
$parameters['x_auth_username'] = $username;
$parameters['x_auth_password'] = $password;
$parameters['x_auth_mode'] = 'client_auth';
$request = $this->oAuthRequest($this->accessTokenURL(), 'POST', $parameters);
$token = OAuthUtil::parse_parameters($request);
$this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
return $token;
}
/**
* GET wrapper for oAuthRequest.
*/
function get($url, $parameters = array()) {
$response = $this->oAuthRequest($url, 'GET', $parameters);
if ($this->format === 'json' && $this->decode_json) {
return json_decode($response);
}
return $response;
}
/**
* POST wrapper for oAuthRequest.
*/
function post($url, $parameters = array()) {
$response = $this->oAuthRequest($url, 'POST', $parameters);
if ($this->format === 'json' && $this->decode_json) {
return json_decode($response);
}
return $response;
}
/**
* DELETE wrapper for oAuthReqeust.
*/
function delete($url, $parameters = array()) {
$response = $this->oAuthRequest($url, 'DELETE', $parameters);
if ($this->format === 'json' && $this->decode_json) {
return json_decode($response);
}
return $response;
}
/**
* Format and sign an OAuth / API request
*/
function oAuthRequest($url, $method, $parameters) {
if (strrpos($url, 'https://') !== 0 && strrpos($url, 'http://') !== 0) {
$url = "{$this->host}{$url}.{$this->format}";
}
$request = OAuthRequest::from_consumer_and_token($this->consumer, $this->token, $method, $url, $parameters);
$request->sign_request($this->sha1_method, $this->consumer, $this->token);
switch ($method) {
case 'GET':
return $this->http($request->to_url(), 'GET');
default:
return $this->http($request->get_normalized_http_url(), $method, $request->to_postdata());
}
}
/**
* Make an HTTP request
*
* @return API results
*/
function http($url, $method, $postfields = NULL) {
$this->http_info = array();
$ci = curl_init();
/* Curl settings */
curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ci, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader'));
curl_setopt($ci, CURLOPT_HEADER, FALSE);
switch ($method) {
case 'POST':
curl_setopt($ci, CURLOPT_POST, TRUE);
if (!empty($postfields)) {
curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
}
break;
case 'DELETE':
curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
if (!empty($postfields)) {
$url = "{$url}?{$postfields}";
}
}
curl_setopt($ci, CURLOPT_URL, $url);
$response = curl_exec($ci);
$this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
$this->http_info = array_merge($this->http_info, curl_getinfo($ci));
$this->url = $url;
curl_close ($ci);
return $response;
}
/**
* Get the header info to store.
*/
function getHeader($ch, $header) {
$i = strpos($header, ':');
if (!empty($i)) {
$key = str_replace('-', '_', strtolower(substr($header, 0, $i)));
$value = trim(substr($header, $i + 2));
$this->http_header[$key] = $value;
}
return strlen($header);
}
}

View file

@ -1,79 +0,0 @@
<?php
if (!defined('_GNUBOARD_'))
exit;
if (!$board['bo_use_sns'])
return;
$sns_msg = urlencode(str_replace('\"', '"', $view['subject']));
//$sns_url = googl_short_url('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
//$msg_url = $sns_msg.' : '.$sns_url;
/*
$facebook_url = 'http://www.facebook.com/sharer/sharer.php?s=100&p[url]='.$sns_url.'&p[title]='.$sns_msg;
$twitter_url = 'http://twitter.com/home?status='.$msg_url;
$gplus_url = 'https://plus.google.com/share?url='.$sns_url;
*/
$sns_send = G5_BBS_URL . '/sns_send.php?longurl=' . urlencode('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
//$sns_send .= '&amp;title='.urlencode(utf8_strcut(get_text($view['subject']),140));
$sns_send .= '&amp;title=' . $sns_msg;
$facebook_url = $sns_send . '&amp;sns=facebook';
$twitter_url = $sns_send . '&amp;sns=twitter';
$gplus_url = $sns_send . '&amp;sns=gplus';
$bo_v_sns_class = $config['cf_kakao_js_apikey'] ? 'show_kakao' : '';
?>
<?php if ($config['cf_kakao_js_apikey']) { ?>
<script src="//developers.kakao.com/sdk/js/kakao.min.js" async charset="utf-8"></script>
<script src="<?php echo G5_JS_URL; ?>/kakaolink.js?ver=<?php echo G5_JS_VER; ?>" charset="utf-8"></script>
<script type='text/javascript'>
//<![CDATA[
var kakao_javascript_apikey = "<?php echo $config['cf_kakao_js_apikey']; ?>";
function Kakao_sendLink() {
if (window.Kakao && (kakao_javascript_apikey !== undefined)) {
if (!Kakao.isInitialized()) {
Kakao.init(kakao_javascript_apikey);
}
}
var webUrl = location.protocol + "<?php echo '//' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; ?>",
imageUrl = $("#bo_v_img").find("img").attr("src") || $(".view_image").find("img").attr("src") || '';
Kakao.Link.sendDefault({
objectType: 'feed',
content: {
title: "<?php echo str_replace(['%27', '&#034;', '\"'], '', strip_tags($view['subject'])); ?>",
description: "<?php echo preg_replace('/\r\n|\r|\n/', '', strip_tags(get_text(cut_str(strip_tags($view['wr_content']), 200), 1))); ?>",
imageUrl: imageUrl,
link: {
mobileWebUrl: webUrl,
webUrl: webUrl
}
},
buttons: [{
title: '자세히 보기',
link: {
mobileWebUrl: webUrl,
webUrl: webUrl
}
}]
});
}
//]]>
</script>
<?php } ?>
<ul id="bo_v_sns" class="<?php echo $bo_v_sns_class; ?>">
<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>
<?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>

View file

@ -1,21 +0,0 @@
<?php
if (!defined('_GNUBOARD_'))
exit;
$mobile_sns_icon = '';
if (G5_IS_MOBILE)
$sns_mc_icon = '';
else
$sns_mc_icon = '_cmt';
if (!$board['bo_use_sns'])
return;
?>
<?php if ($list[$i]['wr_facebook_user']) { ?>
<a href="https://www.facebook.com/profile.php?id=<?php echo $list[$i]['wr_facebook_user']; ?>" target="_blank"><img
src="<?php echo G5_SNS_URL; ?>/icon/facebook<?php echo $sns_mc_icon; ?>.png" alt="페이스북에도 등록됨"></a>
<?php } ?>
<?php if ($list[$i]['wr_twitter_user']) { ?>
<a href="https://www.twitter.com/<?php echo $list[$i]['wr_twitter_user']; ?>" target="_blank"><img
src="<?php echo G5_SNS_URL; ?>/icon/twitter<?php echo $sns_mc_icon; ?>.png" alt="트위터에도 등록됨"></a>
<?php }

View file

@ -1,69 +0,0 @@
<?php
include_once "./_common.php";
if (!$board['bo_use_sns'])
return;
?>
<ul id="bo_vc_sns">
<?php
//============================================================================
// 트위터
//----------------------------------------------------------------------------
if ($config['cf_twitter_key']) {
$twitter_user = get_session("ss_twitter_user");
if (!$twitter_user) {
include_once G5_SNS_PATH . "/twitter/twitteroauth/twitteroauth.php";
include_once G5_SNS_PATH . "/twitter/twitterconfig.php";
$twitter_user = false;
/*
if (empty($_SESSION['access_token']) || empty($_SESSION['access_token']['oauth_token']) || empty($_SESSION['access_token']['oauth_token_secret'])) {
$twitter_url = G5_SNS_URL."/twitter/redirect.php";
} else {
$access_token = $_SESSION['access_token'];
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);
$content = $connection->get('account/verify_credentials');
switch ($connection->http_code) {
case 200:
$twitter_user = true;
$twitter_url = $connection->getAuthorizeURL($token);
break;
default :
$twitter_url = G5_SNS_URL."/twitter/redirect.php";
}
}
*/
$access_token = get_session('access_token');
$access_oauth_token = isset($access_token['oauth_token']) ? $access_token['oauth_token'] : '';
$access_oauth_token_secret = isset($access_token['oauth_token_secret']) ? $access_token['oauth_token_secret'] : '';
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_oauth_token, $access_oauth_token_secret);
$content = $connection->get('account/verify_credentials');
switch ($connection->http_code) {
case 200:
$twitter_user = true;
$twitter_url = $connection->getAuthorizeURL($token);
break;
default:
$twitter_url = G5_SNS_URL . "/twitter/redirect.php";
}
}
echo '<li class="sns_li_t ' . ($twitter_user ? '' : 'sns_li_off') . '">';
if ($twitter_user) {
echo '<img src="' . G5_SNS_URL . '/icon/twitter.png" id="twitter_icon">';
echo '<label for="" class="sound_only">트위터 동시 등록</label>';
echo '<input type="checkbox" name="twitter_checked" id="twitter_checked" ' . (get_cookie('ck_twitter_checked') ? 'checked' : '') . ' value="1">';
} else {
echo '<label for="" class="sound_only">트위터 동시 등록</label>';
echo '<input type="checkbox" name="twitter_checked" id="twitter_checked" disabled value="1">';
echo '<a href="' . $twitter_url . '" id="twitter_url" onclick="return false;" "><img src="' . G5_SNS_URL . '/icon/twitter.png" id="twitter_icon" width="20"></a>';
echo '<script>$(function(){ $(document).on("click", "#twitter_url", function(){ window.open(this.href, "twitter_url", "width=600,height=250"); }); });</script>';
}
echo '</li>';
}
//============================================================================
?>
</ul>

View file

@ -1,2 +0,0 @@
<?php
include_once "../../common.php";

View file

@ -1,64 +0,0 @@
<?php
include_once "./_common.php";
if (!$write)
die("게시글이 없습니다.");
if ($group['gr_use_access'])
die("게시판그룹에서 접근사용을 해제하여 주십시오.");
if ($board['bo_read_level'] > 1)
die("비회원 읽기가 가능한 게시판만 신디케이션을 지원합니다.");
if (strstr($write['wr_option'], 'secret'))
die("비밀글은 신디케이션을 지원하지 않습니다.");
if (preg_match('#^('.$config['cf_syndi_except'].')$#', $bo_table))
die("신디케이션에서 제외된 게시판입니다.");
$title = htmlspecialchars($write['wr_subject']);
$author = htmlspecialchars($write['wr_name']);
$published = date('Y-m-d\TH:i:s\+09:00', strtotime($write['wr_datetime']));
$updated = $published;
$link_href = G5_BBS_URL . "/board.php?bo_table={$bo_table}";
$id = $link_href . htmlspecialchars("&wr_id={$wr_id}");
$cf_title = htmlspecialchars($config['cf_title']);
$link_title = htmlspecialchars($board['bo_subject']);
$feed_updated = date('Y-m-d\TH:i:s\+09:00', G5_SERVER_TIME);
$find = array('&amp;', '&nbsp;'); # 찾아서
$replace = array('&', ' '); # 바꾼다
$content = str_replace( $find, $replace, html_purifier($write['wr_content']) );
$summary = str_replace( $find, $replace, strip_tags($write['wr_content']) );
Header("Content-type: text/xml");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
echo "<feed xmlns=\"http://webmastertool.naver.com\">\n";
echo "<id>" . G5_URL . "</id>\n";
echo "<title>naver syndication feed document</title>\n";
echo "<author>\n";
echo "<name>webmaster</name>\n";
echo "</author>\n";
echo "<updated>{$feed_updated}</updated>\n";
echo "<link rel=\"site\" href=\"" . G5_URL . "\" title=\"{$cf_title}\" />\n";
echo "<entry>\n";
echo "<id>{$id}</id>\n";
echo "<title><![CDATA[{$title}]]></title>\n";
echo "<author>\n";
echo "<name>{$author}</name>\n";
echo "</author>\n";
echo "<updated>{$updated}</updated>\n";
echo "<published>{$published}</published>\n";
echo "<link rel=\"via\" href=\"{$link_href}\" title=\"{$link_title}\" />\n";
echo "<link rel=\"mobile\" href=\"{$id}\" />\n";
echo "<content type=\"html\"><![CDATA[{$content}]]></content>\n";
echo "<summary type=\"text\"><![CDATA[{$summary}]]></summary>\n";
echo "<category term=\"{$bo_table}\" label=\"{$link_title}\" />\n";
echo "</entry>\n";
echo "</feed>";

View file

@ -36,10 +36,8 @@ $comment_action_url = https_url(G5_BBS_DIR) . "/write_comment_update.php";
<span class="bo_vc_hdinfo"><?php echo $list[$i]['ip']; ?></span> <span class="bo_vc_hdinfo"><?php echo $list[$i]['ip']; ?></span>
<?php } ?> <?php } ?>
<span class="bo_vc_hdinfo"><time <span class="bo_vc_hdinfo"><time
datetime="<?php echo date('Y-m-d\TH:i:s+09:00', strtotime($list[$i]['datetime'])) ?>"><?php echo date('m/d H:i', strtotime($list[$i]['datetime'])) ?></time></span> datetime="<?php echo date('Y-m-d\TH:i:s+09:00', strtotime($list[$i]['datetime'])) ?>"><?php echo date('m/d H:i', strtotime($list[$i]['datetime'])) ?></time>
<?php </span>
include G5_SNS_PATH . '/view_comment_list.sns.skin.php';
?>
</header> </header>
<!-- 댓글 출력 --> <!-- 댓글 출력 -->
@ -311,18 +309,6 @@ $comment_action_url = https_url(G5_BBS_DIR) . "/write_comment_update.php";
} }
comment_box('', 'c'); // 댓글 입력폼이 보이도록 처리하기위해서 추가 (root님) comment_box('', 'c'); // 댓글 입력폼이 보이도록 처리하기위해서 추가 (root님)
<?php if ($board['bo_use_sns'] && ($config['cf_facebook_appid'] || $config['cf_twitter_key'])) { ?>
// sns 등록
$(function () {
$("#bo_vc_send_sns").load(
"<?php echo G5_SNS_URL; ?>/view_comment_write.sns.skin.php?bo_table=<?php echo $bo_table; ?>",
function () {
save_html = document.getElementById('bo_vc_w').innerHTML;
}
);
});
<?php } ?>
</script> </script>
<?php } ?> <?php } ?>
<!-- } 댓글 쓰기 --> <!-- } 댓글 쓰기 -->

View file

@ -36,10 +36,8 @@ $comment_action_url = https_url(G5_BBS_DIR) . "/write_comment_update.php";
<span class="bo_vc_hdinfo"><?php echo $list[$i]['ip']; ?></span> <span class="bo_vc_hdinfo"><?php echo $list[$i]['ip']; ?></span>
<?php } ?> <?php } ?>
<span class="bo_vc_hdinfo"><time <span class="bo_vc_hdinfo"><time
datetime="<?php echo date('Y-m-d\TH:i:s+09:00', strtotime($list[$i]['datetime'])) ?>"><?php echo date('m/d H:i', strtotime($list[$i]['datetime'])) ?></time></span> datetime="<?php echo date('Y-m-d\TH:i:s+09:00', strtotime($list[$i]['datetime'])) ?>"><?php echo date('m/d H:i', strtotime($list[$i]['datetime'])) ?></time>
<?php </span>
include G5_SNS_PATH . '/view_comment_list.sns.skin.php';
?>
</header> </header>
<!-- 댓글 출력 --> <!-- 댓글 출력 -->
@ -311,18 +309,6 @@ $comment_action_url = https_url(G5_BBS_DIR) . "/write_comment_update.php";
} }
comment_box('', 'c'); // 댓글 입력폼이 보이도록 처리하기위해서 추가 (root님) comment_box('', 'c'); // 댓글 입력폼이 보이도록 처리하기위해서 추가 (root님)
<?php if ($board['bo_use_sns'] && ($config['cf_facebook_appid'] || $config['cf_twitter_key'])) { ?>
// sns 등록
$(function () {
$("#bo_vc_send_sns").load(
"<?php echo G5_SNS_URL; ?>/view_comment_write.sns.skin.php?bo_table=<?php echo $bo_table; ?>",
function () {
save_html = document.getElementById('bo_vc_w').innerHTML;
}
);
});
<?php } ?>
</script> </script>
<?php } ?> <?php } ?>
<!-- } 댓글 쓰기 --> <!-- } 댓글 쓰기 -->

View file

@ -106,7 +106,6 @@ add_stylesheet('<link rel="stylesheet" href="' . $board_skin_url . '/style.css">
<section id="bo_v_atc"> <section id="bo_v_atc">
<h2 id="bo_v_atc_title">본문</h2> <h2 id="bo_v_atc_title">본문</h2>
<div id="bo_v_share"> <div id="bo_v_share">
<?php include_once G5_SNS_PATH . "/view.sns.skin.php"; ?>
<?php if ($scrap_href) { ?><a href="<?php echo $scrap_href; ?>" target="_blank" class="btn btn_b03" <?php if ($scrap_href) { ?><a href="<?php echo $scrap_href; ?>" target="_blank" class="btn btn_b03"
onclick="win_scrap(this.href); return false;"><i class="fa fa-bookmark" aria-hidden="true"></i> onclick="win_scrap(this.href); return false;"><i class="fa fa-bookmark" aria-hidden="true"></i>
스크랩</a><?php } ?> 스크랩</a><?php } ?>

View file

@ -43,10 +43,8 @@ if (!defined('_GNUBOARD_'))
<?php } ?> <?php } ?>
<span class="sound_only">작성일</span> <span class="sound_only">작성일</span>
<span class="bo_vc_hdinfo"><i class="fa fa-clock-o" aria-hidden="true"></i> <time <span class="bo_vc_hdinfo"><i class="fa fa-clock-o" aria-hidden="true"></i> <time
datetime="<?php echo date('Y-m-d\TH:i:s+09:00', strtotime($list[$i]['datetime'])) ?>"><?php echo $list[$i]['datetime'] ?></time></span> datetime="<?php echo date('Y-m-d\TH:i:s+09:00', strtotime($list[$i]['datetime'])) ?>"><?php echo $list[$i]['datetime'] ?></time>
<?php </span>
include G5_SNS_PATH . '/view_comment_list.sns.skin.php';
?>
</header> </header>
<!-- 댓글 출력 --> <!-- 댓글 출력 -->
<div class="cmt_contents"> <div class="cmt_contents">
@ -318,19 +316,6 @@ if (!defined('_GNUBOARD_'))
} }
comment_box('', 'c'); // 댓글 입력폼이 보이도록 처리하기위해서 추가 (root님) comment_box('', 'c'); // 댓글 입력폼이 보이도록 처리하기위해서 추가 (root님)
<?php if ($board['bo_use_sns'] && ($config['cf_facebook_appid'] || $config['cf_twitter_key'])) { ?>
$(function () {
// sns 등록
$("#bo_vc_send_sns").load(
"<?php echo G5_SNS_URL; ?>/view_comment_write.sns.skin.php?bo_table=<?php echo $bo_table; ?>",
function () {
save_html = document.getElementById('bo_vc_w').innerHTML;
}
);
});
<?php } ?>
</script> </script>
<?php } ?> <?php } ?>
<!-- } 댓글 쓰기 --> <!-- } 댓글 쓰기 -->