<?php
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class tietusdk{
private $accesskey;
private $secretkey;
private $base64param;
function __construct($ak,$sk){
if($ak == ''||$sk =='')
return false;
$this->accesskey = $ak;
$this->secretkey = $sk;
}
public function Dealparam($param){
$this->base64param = $this->Base64(json_encode($param));
return $this;
}
public function Token(){
$sign = $this->Base64($this->Sign($this->base64param,$this->secretkey));
$token = $this->accesskey.':'.$sign.':'.$this->base64param;
return $token;
}
public function Sign($str, $key){
$hmac_sha1_str = "";
if (function_exists('hash_hmac')){
$hmac_sha1_str = $this->Base64(hash_hmac("sha1", $str, $key, true));
} else {
$blocksize = 64;
$hashfunc = 'sha1';
if (strlen($key) > $blocksize){
$key = pack('H*', $hashfunc($key));
}
$key = str_pad($key, $blocksize, chr(0x00));
$ipad = str_repeat(chr(0x36), $blocksize);
$opad = str_repeat(chr(0x5c), $blocksize);
$hmac = pack('H*', $hashfunc(($key ^ $opad) . pack('H*', $hashfunc(($key ^ $ipad) . $str))));
$hmac_sha1_str = $this->Base64($hmac);
}
return $hmac_sha1_str;
}
public function Base64($str){
$find = array('+', '/');
$replace = array('-', '_');
return str_replace($find, $replace, base64_encode($str));
}
}
class plugin_tietuku {
function plugin_tietuku(){
global $_G;
$accesskey=$_G['cache']['plugin']['tietuku']['accesskey'];
$secretkey=$_G['cache']['plugin']['tietuku']['secretkey'];
$album=$_G['cache']['plugin']['tietuku']['album'];
$r_url=$_G['cache']['plugin']['tietuku']['r_url'];
$this->shieldupload=$_G['cache']['plugin']['tietuku']['shieldupload'];
if(empty($r_url)){
$r_url=2;
}
$this->r_url=$r_url;
if(empty($accesskey)||empty($secretkey)||$album<1){
$accesskey='a73ae6f4fe55ac56125c78a49033af5e17b998b5';
$secretkey='966f69262732a26e95865490672186823de49f63';
}else{
$param['deadline']=time()+3600;
$param['album']=$album;
}
$t=new tietusdk($accesskey,$secretkey);
$this->token=$t->Dealparam($param)->Token();
$param['from']='web';
$this->urltoken=$t->Dealparam($param)->Token();
}
}
class plugin_tietuku_forum extends plugin_tietuku {
function post_editorctrl_left() {
global $_G;
$str='<script>var token="'.$this->token.'",
api="'.$_G['cache']['plugin']['tietuku']['api'] .'",
siteurl="'.$_G['siteurl'] .'",
urltoken="'.$this->urltoken .'",
localbtn="'.lang('plugin/tietuku', 'localbtn').'",
netbtn="'.lang('plugin/tietuku', 'netbtn').'",
queding="'.lang('plugin/tietuku', 'queding').'",
noticea="'.lang('plugin/tietuku', 'noticea').'",
noticeb="'.lang('plugin/tietuku', 'noticeb').'",
noticec="'.lang('plugin/tietuku', 'noticec').'",
noticed="'.lang('plugin/tietuku', 'noticed').'",
allinsert="'.lang('plugin/tietuku', 'allinsert').'",
description="'.lang('plugin/tietuku', 'description').'",
finderr="'.lang('plugin/tietuku', 'finderr').'",
notabel="'.lang('plugin/tietuku', 'notabel').'",
url_in="'.lang('plugin/tietuku', 'url_in').'",
findimg="'.lang('plugin/tietuku', 'findimg').'",
r_url="'.$this->r_url.'",
up="'.lang('plugin/tietuku', 'up').'",
select="'.lang('plugin/tietuku', 'select').'",
uploading="'.lang('plugin/tietuku', 'uploading').'",
uploadfailed="'.lang('plugin/tietuku', 'uploadfailed').'";function tietuku_box_c(){var box=document.getElementById("tietuku_box");if(box.style.display=="block")box.style.display="none"; else box.style.display="block";}/*drag start*/var drag_=false;var D=new Function("obj","return document.getElementById(obj);");var oevent=new Function("e","if (!e) e = window.event;return e");function Move_obj(obj){var x,y;D(obj).onmousedown=function(e){drag_=true;with(this){style.position="fixed";var temp1=offsetLeft;var temp2=offsetTop;x=oevent(e).clientX;y=oevent(e).clientY;document.onmousemove=function(e){if(!drag_){return false}with(this){style.left=temp1+oevent(e).clientX-x+"px";style.top=temp2+oevent(e).clientY-y+"px"}}}document.onmouseup=new Function("drag_=false")}};</script><style>#tietuku_box{display:none; position: fixed; top: 32%; right: 30%; z-index: 1000000;background:#fff;cursor:move;border-top:20px solid #ccc;width:530px;border-radius:5px;overflow:hidden; }.tietuku_box_c{width: 20px;height:20px; position: absolute; top: 8px; right: 8px;line-height:20px;text-align:center;cursor:pointer; background:#fff url(./source/plugin/tietuku/static/cls.gif) no-repeat;}.tietuku_box_c:hover {background-position:0 -20px}</style><div id="tietuku_box" onmouseover=Move_obj("tietuku_box")><div onclick="tietuku_box_c()" class="tietuku_box_c"></div><iframe style="width:520px;min-height:160px;border:5px solid #ccc;" src="./source/plugin/tietuku/template/up.htm?v=1.8" id="tietuku_ifr"></iframe></div>
<a class="tietuku" title="'.lang('plugin/tietuku', 'addpic').'" href="javascript:tietuku_box_c();">'.lang('plugin/tietuku', 'picture').'</a>';
if($this->shieldupload==true){
$str.='<style type="text/css">#e_image{display:none;} .edt .b1r .tietuku {background-position: -43px -80px;} .edt .b2r .tietuku {background-position: 0 -20px;}</style>';
}else{
$str.="<style type=\"text/css\">.edt .b1r .tietuku {background:url('./source/plugin/tietuku/tietuku.gif') no-repeat 4px 2px;} .edt .b2r .tietuku {background:url('./source/plugin/tietuku/tietuku_1.gif') no-repeat 4px 2px;}</style>";
}
return $str;
}
function forumdisplay_fastpost_ctrl_extra() {
global $_G;
$str='<script>var token="'.$this->token.'",
api="'.$_G['cache']['plugin']['tietuku']['api'] .'",
siteurl="'.$_G['siteurl'] .'",
urltoken="'.$this->urltoken .'",
localbtn="'.lang('plugin/tietuku', 'localbtn').'",
netbtn="'.lang('plugin/tietuku', 'netbtn').'",
queding="'.lang('plugin/tietuku', 'queding').'",
noticea="'.lang('plugin/tietuku', 'noticea').'",
noticeb="'.lang('plugin/tietuku', 'noticeb').'",
noticec="'.lang('plugin/tietuku', 'noticec').'",
noticed="'.lang('plugin/tietuku', 'noticed').'",
allinsert="'.lang('plugin/tietuku', 'allinsert').'",
description="'.lang('plugin/tietuku', 'description').'",
finderr="'.lang('plugin/tietuku', 'finderr').'",
notabel="'.lang('plugin/tietuku', 'notabel').'",
url_in="'.lang('plugin/tietuku', 'url_in').'",
findimg="'.lang('plugin/tietuku', 'findimg').'",
r_url="'.$this->r_url.'",
up="'.lang('plugin/tietuku', 'up').'",
select="'.lang('plugin/tietuku', 'select').'",
uploading="'.lang('plugin/tietuku', 'uploading').'",
uploadfailed="'.lang('plugin/tietuku', 'uploadfailed').'";function tietuku_box_c(){var box=document.getElementById("tietuku_box");if(box.style.display=="block")box.style.display="none"; else box.style.display="block";}/*drag start*/var drag_=false;var D=new Function("obj","return document.getElementById(obj);");var oevent=new Function("e","if (!e) e = window.event;return e");function Move_obj(obj){var x,y;D(obj).onmousedown=function(e){drag_=true;with(this){style.position="fixed";var temp1=offsetLeft;var temp2=offsetTop;x=oevent(e).clientX;y=oevent(e).clientY;document.onmousemove=function(e){if(!drag_){return false}with(this){style.left=temp1+oevent(e).clientX-x+"px";style.top=temp2+oevent(e).clientY-y+"px"}}}document.onmouseup=new Function("drag_=false")}};</script><style>#tietuku_box{display:none; position: fixed; top: 32%; right: 30%; z-index: 1000000;background:#fff;cursor:move;border-top:20px solid #ccc;width:530px;border-radius:5px;overflow:hidden; }.tietuku_box_c{width: 20px;height:20px; position: absolute; top: 8px; right: 8px;line-height:20px;text-align:center;cursor:pointer; background:#fff url(./source/plugin/tietuku/static/cls.gif) no-repeat;}.tietuku_box_c:hover {background-position:0 -20px} a.tietuku{float:left;}</style><div id="tietuku_box" onmouseover=Move_obj("tietuku_box")><div o