This commit is contained in:
zyx0814
2021-12-09 21:00:09 +08:00
Unverified
parent 1d21f0a040
commit 16d13a39b2
530 changed files with 83287 additions and 41070 deletions

View File

@@ -1,11 +1,19 @@
## PicHome beta2.0 更新说明
### 1.增加移动端支持
### 2.导入逻辑优化,优化导入效率,修复文件移动分类后分类丢失问题
### 3.优化删除库逻辑修复删除库导致的导入状态bug
### 4.优化访问效率
### 5.其他已知bug修复
## PicHome beta3.0 更新说明
### 1.增加普通目录导入支持,普通目录可限定文件导入,默认使用 “站点设置”=>“导入设置”中的“允许导入文件”中的设置值,可根据需要更改。
### 2.支持选择或输入指定目录地址作为库库更改为手动添加以便于自由选择eagle库或者普通目录库
目录选择中默认屏蔽了一些由系统生成目录,可在站点设置=>导入设置中的“禁止导入目录”中更改。
###3.普通目录支持部分图片缩略图、颜色获取和部分音视频文件信息和缩略图获取(注:格式可参考 站点设置”=>“导入设置”中的“允许导入文件”;此功能
pdf格式需有iamgick支持linux下音视频需ffmpeg支持);该功能可在库的“设置”中选择开启或不开启,需要注意的是开启该功能可能会占用大量服务器资源。
###4.增加新的界面展示模板,可在 “站点设置”=>“界面设置”中切换
### 5.导入逻辑优化优化导入效率修复没有文件时一直在导入状态的bug
### 6.优化删除库逻辑,删除更改为异步删除
### 7.优化访问效率
### 8.其他已知bug修复

View File

@@ -1,170 +1,170 @@
<?php
/*
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
* @license https://www.oaooa.com/licenses/
*
* @link https://www.oaooa.com
* @author zyx(zyx@oaooa.com)
*/
if (!defined('IN_OAOOA') ) {
exit('Access Denied');
}
if (!function_exists('ajaxshowheader')) {
function ajaxshowheader() {
global $_G;
ob_end_clean();
@header("Expires: -1");
@header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE);
@header("Pragma: no-cache");
header("Content-type: application/xml");
echo "<?xml version=\"1.0\" encoding=\"" . CHARSET . "\"?>\n<root><![CDATA[";
}
}
if (!function_exists('ajaxshowfooter')) {
function ajaxshowfooter() {
echo ']]></root>';
exit();
}
}
if ($admincp->core ->var['inajax']) {
ajaxshowheader();
ajaxshowfooter();
}
if ($admincp -> cpaccess == -3) {
html_login_header(false);
} else {
html_login_header();
}
if ($admincp -> cpaccess == -3) {
echo '<p class="logintips">' . lang('login_cp_noaccess') . '</p>';
} elseif ($admincp -> cpaccess == -1) {
$ltime = $admincp -> sessionlife - (TIMESTAMP - $admincp -> adminsession['dateline']);
echo '<p class="logintips">' . lang('login_cplock', array('ltime' => $ltime)) . '</p>';
} elseif ($admincp -> cpaccess == -4) {
$ltime = $admincp -> sessionlife - (TIMESTAMP - $admincp -> adminsession['dateline']);
echo '<p class="logintips">' . lang('login_user_lock') . '</p>';
} else {
html_login_form();
}
html_login_footer();
function html_login_header($form = true) {
global $_G;
$uid = getglobal('uid');
$charset = CHARSET;
$lang = &lang();
$title = $lang['login_title'];
$tips = $lang['login_tips'];
echo <<<EOT
<!DOCTYPE>
<html>
<head>
<title>$title</title>
<base href="{$_G['siteurl']}">
<meta http-equiv="Content-Type" content="text/html;charset=$charset" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<link rel="stylesheet" href="static/bootstrap/css/bootstrap.min.css" type="text/css" media="all" />
<link rel="stylesheet" href="admin/login/images/adminlogin.css" type="text/css" media="all" />
<link rel="stylesheet" href="static/css/common.css" type="text/css" media="all" />
<script type="text/javascript" src="static/js/md5.js"></script>
<script type="text/javascript" src="static/jquery/jquery.min.js?{VERHASH}"></script>
<script type="text/javascript" src="static/js/common.js?{VERHASH}"></script>
<!--[if lt IE 9]>
<script src="static/js/jquery.placeholder.js" type="text/javascript"></script>
<![endif]-->
<meta content="oaooa.com" name="Copyright" />
</head>
<body>
EOT;
if ($form) {
$loginset_img=$_G['setting']['loginset']['img']?$_G['setting']['loginset']['img']:'user/login/images/login.jpg';
$loginset_bcolor=$_G['setting']['loginset']['bcolor']?$_G['setting']['loginset']['bcolor']:'#76838f';
echo <<<EOT
<div id="wrapper_div" style="width: 100%;height:100%; position: absolute; top: 0px; left: 0px; margin: 0px; padding: 0px; overflow: hidden;z-index:0; font-size: 0px; background:$loginset_bcolor;">
<img src="$loginset_img" name="imgbg" id="imgbg" style="right: 0px; bottom: 0px; top: 0px; left: 0px; z-index:1;margin:0;padding:0;overflow:hidden; position: absolute;width:100%;height:100%" height="100%" width="100%">
</div>
<div class="mainContainer">
<table class="loginContainer" wide="100%" height="100%">
<tr><td align="center" valign="middle">
EOT;
}
}
function html_login_footer($halt = true) {
$version = CORE_VERSION;
$release = CORE_RELEASE;
echo <<<EOT
</td>
</tr>
</table>
</div>
</body>
</html>
EOT;
$halt && exit();
}
function html_login_form() {
global $_G;
$uid = getglobal('uid');
$isguest = !getglobal('uid');
$lang1 = lang();
$year=dgmdate(TIMESTAMP,'Y');
$maintitle=lang('title_admincp');
$loginuser = $isguest ? '<input class="form-control" name="admin_email" type="text" title="" onfocus="if(this.value==\'' . lang('login_email_username') . '\'){this.value=\'\'}" onblur="if(this.value==\'\'){this.value=\'' . lang('login_email_username') . '\'}" autocomplete="off" />' : '<div class="username">' . $_G['member']['username'] . '</div><div class="email">' . $_G['member']['email'] . '</div>';
$sid = getglobal('sid');
$avatarstatus=getglobal('avatarstatus','member');
if(!$uid ){
$avastar ='<img src="'.($_G['setting']['sitelogo']?\IO::getFileUri('attach::'.$_G['setting']['sitelogo']):'static/image/common/logo.png').'" />';
}else{
$avastar = avatar_block($uid);
}
$avastar.='<div class="maintitle">'.$maintitle.'</div>';
$extra = BASESCRIPT . '?' . $_SERVER['QUERY_STRING'];
$forcesecques = '<option value="0">' . ($_G['config']['admincp']['forcesecques'] ? $lang1['forcesecques'] : $lang1['security_question_0']) . '</option>';
echo <<<EOT
<form method="post" name="login" id="loginform" action="$extra" onsubmit="pwmd5('admin_password')">
<input type="hidden" name="sid" value="$sid">
<input type="hidden" name="referer" value="$_GET[referer]">
<div class="loginformContainer">
<div class="avatarContainer">$avastar</div>
$loginuser
<div id="admin_password_Container">
<input name="admin_password" id="admin_password" type="password" class="form-control" value="" autocomplete="off" placeholder="$lang1[password]" />
</div>
<input name="submit" value="$lang1[login]" type="submit" class="btn btn-primary" />
<div class="copyright">Powered by <a href="https://www.oaooa.com/" target="_blank">oaooa</a> &copy; 2012-$year</div>
</div>
</form>
<script type="text/JavaScript">
jQuery(document).ready(function(e) {
jQuery('#loginform .form-control:first').focus();
if(jQuery('.ie8,.ie9').length){ //ie8模拟placeholder;
jQuery(':input[placeholder]').each(function(){
jQuery(this).placeholder();
});
}
});
</script>
EOT;
}
<?php
/*
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
* @license https://www.oaooa.com/licenses/
*
* @link https://www.oaooa.com
* @author zyx(zyx@oaooa.com)
*/
if (!defined('IN_OAOOA') ) {
exit('Access Denied');
}
if (!function_exists('ajaxshowheader')) {
function ajaxshowheader() {
global $_G;
ob_end_clean();
@header("Expires: -1");
@header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE);
@header("Pragma: no-cache");
header("Content-type: application/xml");
echo "<?xml version=\"1.0\" encoding=\"" . CHARSET . "\"?>\n<root><![CDATA[";
}
}
if (!function_exists('ajaxshowfooter')) {
function ajaxshowfooter() {
echo ']]></root>';
exit();
}
}
if ($admincp->core ->var['inajax']) {
ajaxshowheader();
ajaxshowfooter();
}
if ($admincp -> cpaccess == -3) {
html_login_header(false);
} else {
html_login_header();
}
if ($admincp -> cpaccess == -3) {
echo '<p class="logintips">' . lang('login_cp_noaccess') . '</p>';
} elseif ($admincp -> cpaccess == -1) {
$ltime = $admincp -> sessionlife - (TIMESTAMP - $admincp -> adminsession['dateline']);
echo '<p class="logintips">' . lang('login_cplock', array('ltime' => $ltime)) . '</p>';
} elseif ($admincp -> cpaccess == -4) {
$ltime = $admincp -> sessionlife - (TIMESTAMP - $admincp -> adminsession['dateline']);
echo '<p class="logintips">' . lang('login_user_lock') . '</p>';
} else {
html_login_form();
}
html_login_footer();
function html_login_header($form = true) {
global $_G;
$uid = getglobal('uid');
$charset = CHARSET;
$lang = &lang();
$title = $lang['login_title'];
$tips = $lang['login_tips'];
echo <<<EOT
<!DOCTYPE>
<html>
<head>
<title>$title</title>
<base href="{$_G['siteurl']}">
<meta http-equiv="Content-Type" content="text/html;charset=$charset" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<link rel="stylesheet" href="static/bootstrap/css/bootstrap.min.css" type="text/css" media="all" />
<link rel="stylesheet" href="admin/login/images/adminlogin.css" type="text/css" media="all" />
<link rel="stylesheet" href="static/css/common.css" type="text/css" media="all" />
<script type="text/javascript" src="static/js/md5.js"></script>
<script type="text/javascript" src="static/jquery/jquery.min.js?{VERHASH}"></script>
<script type="text/javascript" src="static/js/common.js?{VERHASH}"></script>
<!--[if lt IE 9]>
<script src="static/js/jquery.placeholder.js" type="text/javascript"></script>
<![endif]-->
<meta content="oaooa.com" name="Copyright" />
</head>
<body>
EOT;
if ($form) {
$loginset_img=$_G['setting']['loginset']['img']?$_G['setting']['loginset']['img']:'user/login/images/login.jpg';
$loginset_bcolor=$_G['setting']['loginset']['bcolor']?$_G['setting']['loginset']['bcolor']:'#76838f';
echo <<<EOT
<div id="wrapper_div" style="width: 100%;height:100%; position: absolute; top: 0px; left: 0px; margin: 0px; padding: 0px; overflow: hidden;z-index:0; font-size: 0px; background:$loginset_bcolor;">
<img src="$loginset_img" name="imgbg" id="imgbg" style="right: 0px; bottom: 0px; top: 0px; left: 0px; z-index:1;margin:0;padding:0;overflow:hidden; position: absolute;width:100%;height:100%" height="100%" width="100%">
</div>
<div class="mainContainer">
<table class="loginContainer" wide="100%" height="100%">
<tr><td align="center" valign="middle">
EOT;
}
}
function html_login_footer($halt = true) {
$version = CORE_VERSION;
$release = CORE_RELEASE;
echo <<<EOT
</td>
</tr>
</table>
</div>
</body>
</html>
EOT;
$halt && exit();
}
function html_login_form() {
global $_G;
$uid = getglobal('uid');
$isguest = !getglobal('uid');
$lang1 = lang();
$year=dgmdate(TIMESTAMP,'Y');
$maintitle=lang('title_admincp');
$loginuser = $isguest ? '<input class="form-control" name="admin_email" type="text" title="" onfocus="if(this.value==\'' . lang('login_email_username') . '\'){this.value=\'\'}" onblur="if(this.value==\'\'){this.value=\'' . lang('login_email_username') . '\'}" autocomplete="off" />' : '<div class="username">' . $_G['member']['username'] . '</div><div class="email">' . $_G['member']['email'] . '</div>';
$sid = getglobal('sid');
$avatarstatus=getglobal('avatarstatus','member');
if(!$uid ){
$avastar ='<img src="'.($_G['setting']['sitelogo']?\IO::getFileUri('attach::'.$_G['setting']['sitelogo']):'data/attachment/sitelogo/sitelogo.png').'" />';
}else{
$avastar = avatar_block($uid);
}
$avastar.='<div class="maintitle">'.$maintitle.'</div>';
$extra = BASESCRIPT . '?' . $_SERVER['QUERY_STRING'];
$forcesecques = '<option value="0">' . ($_G['config']['admincp']['forcesecques'] ? $lang1['forcesecques'] : $lang1['security_question_0']) . '</option>';
echo <<<EOT
<form method="post" name="login" id="loginform" action="$extra" onsubmit="pwmd5('admin_password')">
<input type="hidden" name="sid" value="$sid">
<input type="hidden" name="referer" value="$_GET[referer]">
<div class="loginformContainer">
<div class="avatarContainer">$avastar</div>
$loginuser
<div id="admin_password_Container">
<input name="admin_password" id="admin_password" type="password" class="form-control" value="" autocomplete="off" placeholder="$lang1[password]" />
</div>
<input name="submit" value="$lang1[login]" type="submit" class="btn btn-primary" />
<div class="copyright">Powered by <a href="https://www.oaooa.com/" target="_blank">oaooa</a> &copy; 2012-$year</div>
</div>
</form>
<script type="text/JavaScript">
jQuery(document).ready(function(e) {
jQuery('#loginform .form-control:first').focus();
if(jQuery('.ie8,.ie9').length){ //ie8模拟placeholder;
jQuery(':input[placeholder]').each(function(){
jQuery(this).placeholder();
});
}
});
</script>
EOT;
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -1 +1 @@
<!DOCTYPE html><html lang=zh><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=favicon.ico><title></title><link href=/admin/system/dist/css/chunk-2b4f90f7.519dec70.css rel=prefetch><link href=/admin/system/dist/css/chunk-494f643e.7502109f.css rel=prefetch><link href=/admin/system/dist/css/chunk-5ae5cc35.d763cbce.css rel=prefetch><link href=/admin/system/dist/css/chunk-5cdcd199.6f46c04d.css rel=prefetch><link href=/admin/system/dist/css/chunk-74c32c70.4b7d665e.css rel=prefetch><link href=/admin/system/dist/css/chunk-76f23146.6fc79cd8.css rel=prefetch><link href=/admin/system/dist/css/chunk-7828662a.c81657ef.css rel=prefetch><link href=/admin/system/dist/css/chunk-9f9c2568.5356ad7d.css rel=prefetch><link href=/admin/system/dist/css/chunk-af3b1b98.b822363f.css rel=prefetch><link href=/admin/system/dist/css/chunk-e730cc06.987283b7.css rel=prefetch><link href=/admin/system/dist/css/system_temp.a56510eb.css rel=prefetch><link href=/admin/system/dist/js/chunk-2b4f90f7.ec4ac270.js rel=prefetch><link href=/admin/system/dist/js/chunk-2d0a3327.ad2684c9.js rel=prefetch><link href=/admin/system/dist/js/chunk-2d0bdbc6.4ec7bc5e.js rel=prefetch><link href=/admin/system/dist/js/chunk-2d0dd46d.0816c17e.js rel=prefetch><link href=/admin/system/dist/js/chunk-2d0efd3c.44a093d1.js rel=prefetch><link href=/admin/system/dist/js/chunk-2d20fcd9.50f81306.js rel=prefetch><link href=/admin/system/dist/js/chunk-2d21ddf7.9f7b329e.js rel=prefetch><link href=/admin/system/dist/js/chunk-494f643e.77a11d42.js rel=prefetch><link href=/admin/system/dist/js/chunk-5ae5cc35.25761a21.js rel=prefetch><link href=/admin/system/dist/js/chunk-5cdcd199.070f9c94.js rel=prefetch><link href=/admin/system/dist/js/chunk-74c32c70.1f5e9382.js rel=prefetch><link href=/admin/system/dist/js/chunk-76f23146.0d2957ed.js rel=prefetch><link href=/admin/system/dist/js/chunk-7828662a.e587f025.js rel=prefetch><link href=/admin/system/dist/js/chunk-9f9c2568.538835dd.js rel=prefetch><link href=/admin/system/dist/js/chunk-af3b1b98.850ec152.js rel=prefetch><link href=/admin/system/dist/js/chunk-e730cc06.3ce9a994.js rel=prefetch><link href=/admin/system/dist/js/system_temp.c7e32270.js rel=prefetch><link href=/admin/system/dist/css/chunk-vendors.4d5d56a8.css rel=preload as=style><link href=/admin/system/dist/css/index.7d0ec6bf.css rel=preload as=style><link href=/admin/system/dist/js/chunk-vendors.3b95dfe3.js rel=preload as=script><link href=/admin/system/dist/js/index.b5ff203c.js rel=preload as=script><link href=/admin/system/dist/css/chunk-vendors.4d5d56a8.css rel=stylesheet><link href=/admin/system/dist/css/index.7d0ec6bf.css rel=stylesheet></head><body><div id=app></div><script src=/admin/system/dist/js/chunk-vendors.3b95dfe3.js></script><script src=/admin/system/dist/js/index.b5ff203c.js></script></body></html>
<!DOCTYPE html><html lang=zh><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=favicon.ico><title></title><link href=/admin/system/dist/css/chunk-2b4f90f7.519dec70.css rel=prefetch><link href=/admin/system/dist/css/chunk-494f643e.7502109f.css rel=prefetch><link href=/admin/system/dist/css/chunk-5ae5cc35.d763cbce.css rel=prefetch><link href=/admin/system/dist/css/chunk-5cdcd199.6f46c04d.css rel=prefetch><link href=/admin/system/dist/css/chunk-74c32c70.4b7d665e.css rel=prefetch><link href=/admin/system/dist/css/chunk-76f23146.6fc79cd8.css rel=prefetch><link href=/admin/system/dist/css/chunk-7828662a.c81657ef.css rel=prefetch><link href=/admin/system/dist/css/chunk-9f9c2568.5356ad7d.css rel=prefetch><link href=/admin/system/dist/css/chunk-af3b1b98.b822363f.css rel=prefetch><link href=/admin/system/dist/css/chunk-e730cc06.987283b7.css rel=prefetch><link href=/admin/system/dist/css/system_temp.a56510eb.css rel=prefetch><link href=/admin/system/dist/js/chunk-2b4f90f7.ec4ac270.js rel=prefetch><link href=/admin/system/dist/js/chunk-2d0a3327.ad2684c9.js rel=prefetch><link href=/admin/system/dist/js/chunk-2d0bdbc6.4ec7bc5e.js rel=prefetch><link href=/admin/system/dist/js/chunk-2d0dd46d.e13ddeba.js rel=prefetch><link href=/admin/system/dist/js/chunk-2d0efd3c.44a093d1.js rel=prefetch><link href=/admin/system/dist/js/chunk-2d20fcd9.50f81306.js rel=prefetch><link href=/admin/system/dist/js/chunk-2d21ddf7.9f7b329e.js rel=prefetch><link href=/admin/system/dist/js/chunk-494f643e.77a11d42.js rel=prefetch><link href=/admin/system/dist/js/chunk-5ae5cc35.25761a21.js rel=prefetch><link href=/admin/system/dist/js/chunk-5cdcd199.070f9c94.js rel=prefetch><link href=/admin/system/dist/js/chunk-74c32c70.1f5e9382.js rel=prefetch><link href=/admin/system/dist/js/chunk-76f23146.0d2957ed.js rel=prefetch><link href=/admin/system/dist/js/chunk-7828662a.e587f025.js rel=prefetch><link href=/admin/system/dist/js/chunk-9f9c2568.538835dd.js rel=prefetch><link href=/admin/system/dist/js/chunk-af3b1b98.850ec152.js rel=prefetch><link href=/admin/system/dist/js/chunk-e730cc06.3ce9a994.js rel=prefetch><link href=/admin/system/dist/js/system_temp.c7e32270.js rel=prefetch><link href=/admin/system/dist/css/chunk-vendors.4d5d56a8.css rel=preload as=style><link href=/admin/system/dist/css/index.7d0ec6bf.css rel=preload as=style><link href=/admin/system/dist/js/chunk-vendors.3b95dfe3.js rel=preload as=script><link href=/admin/system/dist/js/index.be6002c4.js rel=preload as=script><link href=/admin/system/dist/css/chunk-vendors.4d5d56a8.css rel=stylesheet><link href=/admin/system/dist/css/index.7d0ec6bf.css rel=stylesheet></head><body><div id=app></div><script src=/admin/system/dist/js/chunk-vendors.3b95dfe3.js></script><script src=/admin/system/dist/js/index.be6002c4.js></script></body></html>

View File

@@ -0,0 +1 @@
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d0dd46d"],{8164:function(e,t,s){"use strict";s.r(t);var n=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("div",{directives:[{name:"loading",rawName:"v-loading",value:e.loading,expression:"loading"}]},[s("el-card",{staticClass:"box-card",staticStyle:{background:"rgb(240, 249, 235)","text-align":"center"},attrs:{shadow:"hover"}},[s("p",{staticStyle:{"margin-bottom":"0"}},[s("el-link",{attrs:{type:"success",underline:!1}},[e._v(e._s(e.$t("upgrade_successful1")))])],1),s("p",{staticStyle:{margin:"0"}},[s("el-link",{attrs:{type:"success",underline:!1}},[e._v(e._s(e.version))])],1),s("p",{staticStyle:{"margin-bottom":"0"}},[s("el-link",{attrs:{type:"success",underline:!1}},[e._v(e._s(e.$t("upgrade_successful3",{dir:e.dir})))])],1),s("p",{staticStyle:{margin:"0"}},[s("el-link",{attrs:{type:"success",underline:!1}},[e._v(e._s(e.$t("upgrade_successful4",{backdir:e.backdir})))])],1)])],1)},a=[],r=(s("96cf"),s("1da1")),i={data:function(){return{loading:!1,version:"",dir:"",backdir:""}},created:function(){this.getData()},methods:{getData:function(){var e=this;return Object(r["a"])(regeneratorRuntime.mark((function t(){var s,n;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return e.loading=!0,t.next=3,e.axios.post("admin.php?mod=system&op=intsystemupgrade&operation=patch&step=5&version="+e.$route.params.version);case 3:s=t.sent,n=s.data,e.version=e.$t("upgrade_successful2",{msg:n.version}),e.dir=n.dir,e.backdir=n.backdir,e.loading=!1;case 9:case"end":return t.stop()}}),t)})))()}},components:{},mounted:function(){}},c=i,d=s("2877"),o=Object(d["a"])(c,n,a,!1,null,"321830d5",null);t["default"]=o.exports}}]);

File diff suppressed because one or more lines are too long

View File

@@ -1,343 +1,343 @@
<?php
/*
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
* @license https://www.oaooa.com/licenses/
*
* @link https://www.oaooa.com
* @author zyx(zyx@oaooa.com)
*/
if (!defined('IN_OAOOA') || !defined('IN_ADMIN')) {
exit('Access Denied');
}
$navtitle = lang('upgrade') . ' - ' . lang('admin_navtitle');
@set_time_limit(0);
include_once DZZ_ROOT . './core/core_version.php';
include_once libfile('function/admin');
include_once libfile('function/cache');
$dzz_upgrade = new dzz_upgrade();
$step = intval($_GET['step']);
$op = $_GET['op'];
$step = $step ? $step : 1;
$operation = $_GET['operation'] ? trim($_GET['operation']) : 'check';
$steplang = array('', lang('founder_upgrade_updatelist'), lang('founder_upgrade_download'), lang('founder_upgrade_compare'), lang('founder_upgrade_upgrading'), lang('founder_upgrade_complete'), 'dbupdate' => lang('founder_upgrade_dbupdate'));
if ($operation == 'patch' || $operation == 'cross') {
if (!$_G['setting']['bbclosed']) {
exit(json_encode(array('bbclosed'=>true)));
}
$msg = '';
$version = trim($_GET['version']);
$release = trim($_GET['release']);
$locale = trim($_GET['locale']);
$charset = trim($_GET['charset']);
$upgradeinfo = $upgrade_step = array();
// if ($_GET['ungetfrom']) {
// if (md5($_GET['ungetfrom'] . $_G['config']['security']['authkey']) == $_GET['ungetfrommd5']) {
// $dbreturnurl = $_G['siteurl'] . ADMINSCRIPT . '?mod=system#/systemupgrade/'.$version;
// $url = outputurl( $_G['siteurl'] . 'install/update.php?step=prepare&from=' . rawurlencode($dbreturnurl) . '&frommd5=' . rawurlencode(md5($dbreturnurl . $_G['config']['security']['authkey'])) );
// exit(json_encode(array('iframe'=>true,'url'=>$url)));
// dheader('Location: ' . $url);
// } else {
// exit(json_encode(array('error'=>true,'msg'=>lang('upgrade_param_error'))));
// }
// }
$upgrade_step = C::t('cache') -> fetch('upgrade_step');
$upgrade_step = dunserialize($upgrade_step['cachevalue']);
$upgrade_step['step'] = $step;
$upgrade_step['operation'] = $operation;
$upgrade_step['version'] = $version;
$upgrade_step['release'] = $release;
$upgrade_step['charset'] = $charset;
$upgrade_step['locale'] = $locale;
C::t('cache') -> insert(array('cachekey' => 'upgrade_step', 'cachevalue' => serialize($upgrade_step), 'dateline' => $_G['timestamp'], ), false, true);
$upgrade_run = C::t('cache') -> fetch('upgrade_run');
if (!$upgrade_run) {
C::t('cache') -> insert(array('cachekey' => 'upgrade_run', 'cachevalue' => serialize($_G['setting']['upgrade']), 'dateline' => $_G['timestamp'], ), false, true);
$upgrade_run = $_G['setting']['upgrade'];
} else {
$upgrade_run = dunserialize($upgrade_run['cachevalue']);
}
if ($step != 5) {
foreach ($upgrade_run as $type => $list) {
if ($type == $operation && $version == $list['latestversion']) {
$dzz_upgrade -> locale = $locale;
$dzz_upgrade -> charset = $charset;
$upgradeinfo = $list;
break;
}
}
if (!$upgradeinfo) {
upgradeinformation(-1);
exit(json_encode(array('upgradeNone'=>true)));
}
$updatefilelist = $dzz_upgrade -> fetch_updatefile_list($upgradeinfo);
$updatemd5filelist = $updatefilelist['md5'];
$updatefilelist = $updatefilelist['file'];
$theurl = $_G['siteurl'].ADMINSCRIPT . '?mod=system&op=intsystemupgrade&operation=' . $operation . '&version=' . $version . '&locale=' . $locale . '&charset=' . $charset;
if (empty($updatefilelist)) {
upgradeinformation(-2);
exit(json_encode(array('upgradeError'=>true)));
}
}
if ($step == 1) {
exit(json_encode(array('step'=>1,'data'=>$updatefilelist)));
} elseif ($step == 2) {
$fileseq = intval($_GET['fileseq']);
$fileseq = $fileseq ? $fileseq : 1;
if ($fileseq > count($updatefilelist)) {
$linkurl = $theurl . '&step=3';
upgradeinformation(0);
exit(json_encode(array('step'=>2,'downloadstatus'=>4)));
} else {
$downloadstatus = $dzz_upgrade -> download_file($upgradeinfo, $updatefilelist[$fileseq - 1], 'upload', $updatemd5filelist[$fileseq - 1]);
if ($downloadstatus == 1) {
$data = array('file' => $updatefilelist[$fileseq - 1],'fileseq'=>$fileseq,'percent' => sprintf("%2d", 100 * $fileseq / count($updatefilelist)));
upgradeinformation(1);
exit(json_encode(array('step'=>2,'data'=>$data,'downloadstatus'=>1)));
} elseif ($downloadstatus == 2) {
$data = array('file' => $updatefilelist[$fileseq - 1],'fileseq'=>($fileseq + 1),'percent' => sprintf("%2d", 100 * $fileseq / count($updatefilelist)));
upgradeinformation(1);
exit(json_encode(array('step'=>2,'data'=>$data,'downloadstatus'=>2)));
} else {
$data = array('file' => $updatefilelist[$fileseq - 1]);
upgradeinformation(-3);
exit(json_encode(array('step'=>2,'data'=>$data,'downloadstatus'=>3)));
}
}
} elseif ($step == 3) {
list($modifylist, $showlist, $ignorelist,$newlist) = $dzz_upgrade -> compare_basefile($upgradeinfo, $updatefilelist,$updatemd5filelist);
$tableData = array();
$button = '';
if (empty($modifylist) && empty($showlist) && empty($ignorelist) && empty($newlist)) {
}else{
if(empty($modifylist)){
$button = lang('founder_upgrade_regular');
}else{
$button = lang('founder_upgrade_force');
}
foreach($updatefilelist as $val){
if(isset($modifylist[$val])){
$res = array('name'=>$val,'status'=>1);
}elseif(isset($showlist[$val])){
$res = array('name'=>$val,'status'=>2);
}elseif(isset($newlist[$val])){
$res = array('name'=>$val,'status'=>3);
}else{
$res = array('name'=>$val,'status'=>1);
}
$tableData[] = $res;
}
}
upgradeinformation(-4);
exit(json_encode(array('step'=>3,'tableData'=>$tableData,'button'=>$button,'oldversion'=>CORE_VERSION)));
} elseif ($step == 4) {
$confirm = $_GET['confirm'];
if (!$confirm) {
if ($_GET['siteftpsetting']) {
$action = $theurl . '&step=4&confirm=ftp&formhash='.FORMHASH . ($_GET['startupgrade'] ? '&startupgrade=1' : '');
exit(json_encode(array('siteftpsetting'=>true,'url'=>$action)));
}
if ($upgradeinfo['isupdatedb']) {
$checkupdatefilelist = array('install/update.php', 'install/data/install.sql', 'install/data/install_data.sql');
$checkupdatefilelist = array_merge($checkupdatefilelist, $updatefilelist);
} else {
$checkupdatefilelist = $updatefilelist;
}
if ($dzz_upgrade -> check_folder_perm($checkupdatefilelist)) {
$confirm = 'file';
} else {
exit(json_encode(array('againsiteftpsetting'=>true)));
}
}
$paraftp = '';
if ($_GET['siteftp']) {
foreach ($_GET['siteftp'] as $k => $v) {
$paraftp .= '&siteftp[' . $k . ']=' . $v;
}
}
if (!$_GET['startupgrade']) {
if (!$_GET['backfile']) {
$linkurl = $theurl . '&step=4&backfile=1&confirm=' . $confirm . $paraftp;
upgradeinformation(2);
exit(json_encode(array('backfile'=>true,'url'=>$linkurl)));
}
foreach ($updatefilelist as $updatefile) {
$destfile = DZZ_ROOT . $updatefile;
$backfile = DZZ_ROOT . './data/back/pichome' . CORE_VERSION . '/' . $updatefile;
if (is_file($destfile)) {
if (!$dzz_upgrade -> copy_file($destfile, $backfile, 'file')) {
upgradeinformation(-5);
exit(json_encode(array('destfile'=>true)));
}
}
}
upgradeinformation(3);
exit(json_encode(array('complete'=>true,'url'=>$theurl.'&step=4&startupgrade=1&confirm='.$confirm.$paraftp)));
}
$linkurl = $theurl . '&step=4&startupgrade=1&confirm=' . $confirm . $paraftp;
$ftplinkurl = $theurl . '&step=4&startupgrade=1&siteftpsetting=1';
foreach ($updatefilelist as $updatefile) {
$srcfile = DZZ_ROOT . './data/update/pichome' . $version . '/' . $updatefile;
if ($confirm == 'ftp') {
$destfile = $updatefile;
} else {
$destfile = DZZ_ROOT . $updatefile;
}
if (!$dzz_upgrade -> copy_file($srcfile, $destfile, $confirm)) {
if ($confirm == 'ftp') {
upgradeinformation(-6);
exit(json_encode(array('ftpError'=>true,'file'=>$updatefile,'againUpdate'=>$linkurl,'ftpUrl'=>$ftplinkurl)));
} else {
upgradeinformation(-7);
exit(json_encode(array('copyError'=>true,'file'=>$updatefile,'againUpdate'=>$linkurl,'ftpUrl'=>$ftplinkurl)));
}
}
}
if ($upgradeinfo['isupdatedb']) {
$upgrade_step['step'] = 'dbupdate';
C::t('cache') -> insert(array('cachekey' => 'upgrade_step', 'cachevalue' => serialize($upgrade_step), 'dateline' => $_G['timestamp'], ), false, true);
// $dbreturnurl = $_G['siteurl'] . ADMINSCRIPT . '?mod=system&op=systemupgrade&operation=' . $operation . '&version=' . $version . '&step=5';
$dbreturnurl = $_G['siteurl'] . ADMINSCRIPT . '?mod=system#/systemupgrade/'.$version;
$linkurl = $_G['siteurl'] . 'install/update.php?step=prepare&from=' . rawurlencode($dbreturnurl) . '&frommd5=' . rawurlencode(md5($dbreturnurl . $_G['config']['security']['authkey']));
upgradeinformation(4);
exit(json_encode(array('updateMysql'=>true,'url'=>$linkurl)));
}
exit(json_encode(array('nextStep'=>true)));
} elseif ($step == 5) {
$file = DZZ_ROOT . './data/update/pichome' . $version . '/updatelist.tmp';
@unlink($file);
@unlink(DZZ_ROOT . './install/update.php');
C::t('cache') -> delete('upgrade_step');
C::t('cache') -> delete('upgrade_run');
C::t('setting') -> update('upgrade', '');
updatecache('setting');
$old_update_dir = './data/update/';
$new_update_dir = './data/update' . md5('update' . $_G['config']['security']['authkey']) . '/';
$old_back_dir = './data/back/';
$new_back_dir = './data/back' . md5('back' . $_G['config']['security']['authkey']) . '/';
$dzz_upgrade -> copy_dir(DZZ_ROOT . $old_update_dir, DZZ_ROOT . $new_update_dir);
$dzz_upgrade -> copy_dir(DZZ_ROOT . $old_back_dir, DZZ_ROOT . $new_back_dir);
$dzz_upgrade -> rmdirs(DZZ_ROOT . $old_update_dir);
$dzz_upgrade -> rmdirs(DZZ_ROOT . $old_back_dir);
upgradeinformation(0);
exit(json_encode(array('dir'=>$new_update_dir,'backdir'=>$new_back_dir)));
// $msg = lang('upgrade_successful', array('version' => $version, 'save_update_dir' => $new_update_dir, 'save_back_dir' => $new_back_dir, 'upgradeurl' => upgradeinformation(0)));
}
}elseif ($operation == 'check') {
$msg = '';
$upgrade_step = C::t('cache') -> fetch('upgrade_step');
if (!empty($upgrade_step['cachevalue'])) {
$upgrade_step['cachevalue'] = dunserialize($upgrade_step['cachevalue']);
if (!empty($upgrade_step['cachevalue']['step'])) {
$theurl = ADMINSCRIPT . '?mod=system&op=systemupgrade&operation=' . $upgrade_step['cachevalue']['operation'] . '&version=' . $upgrade_step['cachevalue']['version'] . '&locale=' . $upgrade_step['cachevalue']['locale'] . '&charset=' . $upgrade_step['cachevalue']['charset'];
$recheckurl = ADMINSCRIPT . '?mod=system&op=systemupgrade&operation=recheck';
if ($upgrade_step['cachevalue']['step'] == 'dbupdate') {
// $dbreturnurl = $_G['siteurl'] . $theurl . '&step=5';
$dbreturnurl = $_G['siteurl'] . ADMINSCRIPT . '?mod=system#/systemupgrade/'.$upgrade_step['cachevalue']['version'];
$stepurl = $_G['siteurl'] . 'install/update.php?step=prepare&from=' . rawurlencode($dbreturnurl) . '&frommd5=' . rawurlencode(md5($dbreturnurl . $_G['config']['security']['authkey']));
exit(json_encode(array('iframe'=>true,'steplang'=>$steplang['dbupdate'],'url'=>$stepurl)));
} else {
exit(json_encode(array('html'=>true,'steplang'=>$steplang[$upgrade_step['cachevalue']['step']],'data'=>$upgrade_step['cachevalue'])));
}
}else{
$dzz_upgrade -> check_upgrade();
exit(json_encode(array('html'=>false)));
}
}else{
$dzz_upgrade -> check_upgrade();
exit(json_encode(array('html'=>false)));
}
exit();
}elseif ($operation == 'showupgrade') {
if ($_G['setting']['upgrade']) {
C::t('cache') -> insert(array('cachekey' => 'upgrade_step', 'cachevalue' => serialize(array('curversion' => $dzz_upgrade -> versionpath())), 'dateline' => $_G['timestamp'], ), false, true);
$upgraderow = $patchrow = array();
$charset = str_replace('-', '', strtoupper($_G['config']['output']['charset']));
$dbversion = helper_dbtool::dbversion();
$locale = '';
if ($charset == 'BIG5') {
$locale = 'TC';
} elseif ($charset == 'GBK') {
$locale = 'SC';
} elseif ($charset == 'UTF8') {
if ($_G['config']['output']['language'] == 'zh-cn' || $_G['config']['output']['language'] == 'zh_cn') {
$locale = 'SC';
} elseif ($_G['config']['output']['language'] == 'zh-tw' || $_G['config']['output']['language'] == 'zh_tw') {
$locale = 'TC';
}else{
$locale = 'SC';
}
}
if (!is_array($_G['setting']['upgrade']))
$_G['setting']['upgrade'] = unserialize($_G['setting']['upgrade']);
$list = array();
foreach ($_G['setting']['upgrade'] as $type => $upgrade) {
$flist = array();
$unupgrade = 0;
if (version_compare($upgrade['phpversion'], PHP_VERSION) > 0 || version_compare($upgrade['mysqlversion'], $dbversion) > 0) {
$unupgrade = 1;
}
if ($unupgrade) {
$flist['title'] = 'oaooa PicHome ' . $upgrade['latestversion'] . '_' . $locale . '_' . $charset;
$flist['msg'] = lang('founder_upgrade_require_config') . ' php v' . PHP_VERSION . 'MYSQL v' . $dbversion;
$flist['update'] = false;
} else {
$flist['title'] = 'oaooa PicHome ' . $upgrade['latestversion'] . '_' . $locale . '_' . $charset;
$flist['update'] = true;
$flist['version'] = $upgrade['latestversion'];
$flist['locale'] = $locale;
$flist['charset'] = $charset;
}
$list[] = $flist;
}
exit(json_encode(array('content'=>true,'data'=>$list)));
} else {
exit(json_encode(array('content'=>false)));
}
}elseif ($operation == 'recheck') {
$upgrade_step = C::t('cache') -> fetch('upgrade_step');
$upgrade_step = dunserialize($upgrade_step['cachevalue']);
$file = DZZ_ROOT . './data/update/pichome' . $upgrade_step['version'] . '/updatelist.tmp';
@unlink($file);
@unlink(DZZ_ROOT . './install/update.php');
C::t('cache') -> delete('upgrade_step');
C::t('cache') -> delete('upgrade_run');
C::t('setting') -> update('upgrade', '');
updatecache('setting');
$old_update_dir = './data/update/';
$dzz_upgrade -> rmdirs(DZZ_ROOT . $old_update_dir);
$dzz_upgrade -> check_upgrade();
// $url = outputurl($_G['siteurl'].MOD_URL.'&op=systemupgrade' );
// dheader('Location: ' . $url);
}
// include template('upgrade');
<?php
/*
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
* @license https://www.oaooa.com/licenses/
*
* @link https://www.oaooa.com
* @author zyx(zyx@oaooa.com)
*/
if (!defined('IN_OAOOA') || !defined('IN_ADMIN')) {
exit('Access Denied');
}
$navtitle = lang('upgrade') . ' - ' . lang('admin_navtitle');
@set_time_limit(0);
include_once DZZ_ROOT . './core/core_version.php';
include_once libfile('function/admin');
include_once libfile('function/cache');
$dzz_upgrade = new dzz_upgrade();
$step = intval($_GET['step']);
$op = $_GET['op'];
$step = $step ? $step : 1;
$operation = $_GET['operation'] ? trim($_GET['operation']) : 'check';
$steplang = array('', lang('founder_upgrade_updatelist'), lang('founder_upgrade_download'), lang('founder_upgrade_compare'), lang('founder_upgrade_upgrading'), lang('founder_upgrade_complete'), 'dbupdate' => lang('founder_upgrade_dbupdate'));
if ($operation == 'patch' || $operation == 'cross') {
if (!$_G['setting']['bbclosed']) {
exit(json_encode(array('bbclosed'=>true)));
}
$msg = '';
$version = trim($_GET['version']);
$release = trim($_GET['release']);
$locale = trim($_GET['locale']);
$charset = trim($_GET['charset']);
$upgradeinfo = $upgrade_step = array();
// if ($_GET['ungetfrom']) {
// if (md5($_GET['ungetfrom'] . $_G['config']['security']['authkey']) == $_GET['ungetfrommd5']) {
// $dbreturnurl = $_G['siteurl'] . ADMINSCRIPT . '?mod=system#/systemupgrade/'.$version;
// $url = outputurl( $_G['siteurl'] . 'install/update.php?step=prepare&from=' . rawurlencode($dbreturnurl) . '&frommd5=' . rawurlencode(md5($dbreturnurl . $_G['config']['security']['authkey'])) );
// exit(json_encode(array('iframe'=>true,'url'=>$url)));
// dheader('Location: ' . $url);
// } else {
// exit(json_encode(array('error'=>true,'msg'=>lang('upgrade_param_error'))));
// }
// }
$upgrade_step = C::t('cache') -> fetch('upgrade_step');
$upgrade_step = dunserialize($upgrade_step['cachevalue']);
$upgrade_step['step'] = $step;
$upgrade_step['operation'] = $operation;
$upgrade_step['version'] = $version;
$upgrade_step['release'] = $release;
$upgrade_step['charset'] = $charset;
$upgrade_step['locale'] = $locale;
C::t('cache') -> insert(array('cachekey' => 'upgrade_step', 'cachevalue' => serialize($upgrade_step), 'dateline' => $_G['timestamp'], ), false, true);
$upgrade_run = C::t('cache') -> fetch('upgrade_run');
if (!$upgrade_run) {
C::t('cache') -> insert(array('cachekey' => 'upgrade_run', 'cachevalue' => serialize($_G['setting']['upgrade']), 'dateline' => $_G['timestamp'], ), false, true);
$upgrade_run = $_G['setting']['upgrade'];
} else {
$upgrade_run = dunserialize($upgrade_run['cachevalue']);
}
if ($step != 5) {
foreach ($upgrade_run as $type => $list) {
if ($type == $operation && $version == $list['latestversion']) {
$dzz_upgrade -> locale = $locale;
$dzz_upgrade -> charset = $charset;
$upgradeinfo = $list;
break;
}
}
if (!$upgradeinfo) {
upgradeinformation(-1);
exit(json_encode(array('upgradeNone'=>true)));
}
$updatefilelist = $dzz_upgrade -> fetch_updatefile_list($upgradeinfo);
$updatemd5filelist = $updatefilelist['md5'];
$updatefilelist = $updatefilelist['file'];
$theurl = $_G['siteurl'].ADMINSCRIPT . '?mod=system&op=intsystemupgrade&operation=' . $operation . '&version=' . $version . '&locale=' . $locale . '&charset=' . $charset;
if (empty($updatefilelist)) {
upgradeinformation(-2);
exit(json_encode(array('upgradeError'=>true)));
}
}
if ($step == 1) {
exit(json_encode(array('step'=>1,'data'=>$updatefilelist)));
} elseif ($step == 2) {
$fileseq = intval($_GET['fileseq']);
$fileseq = $fileseq ? $fileseq : 1;
if ($fileseq > count($updatefilelist)) {
$linkurl = $theurl . '&step=3';
upgradeinformation(0);
exit(json_encode(array('step'=>2,'downloadstatus'=>4)));
} else {
$downloadstatus = $dzz_upgrade -> download_file($upgradeinfo, $updatefilelist[$fileseq - 1], 'upload', $updatemd5filelist[$fileseq - 1]);
if ($downloadstatus == 1) {
$data = array('file' => $updatefilelist[$fileseq - 1],'fileseq'=>$fileseq,'percent' => sprintf("%2d", 100 * $fileseq / count($updatefilelist)));
upgradeinformation(1);
exit(json_encode(array('step'=>2,'data'=>$data,'downloadstatus'=>1)));
} elseif ($downloadstatus == 2) {
$data = array('file' => $updatefilelist[$fileseq - 1],'fileseq'=>($fileseq + 1),'percent' => sprintf("%2d", 100 * $fileseq / count($updatefilelist)));
upgradeinformation(1);
exit(json_encode(array('step'=>2,'data'=>$data,'downloadstatus'=>2)));
} else {
$data = array('file' => $updatefilelist[$fileseq - 1]);
upgradeinformation(-3);
exit(json_encode(array('step'=>2,'data'=>$data,'downloadstatus'=>3)));
}
}
} elseif ($step == 3) {
list($modifylist, $showlist, $ignorelist,$newlist) = $dzz_upgrade -> compare_basefile($upgradeinfo, $updatefilelist,$updatemd5filelist);
$tableData = array();
$button = '';
if (empty($modifylist) && empty($showlist) && empty($ignorelist) && empty($newlist)) {
}else{
if(empty($modifylist)){
$button = lang('founder_upgrade_regular');
}else{
$button = lang('founder_upgrade_force');
}
foreach($updatefilelist as $val){
if(isset($modifylist[$val])){
$res = array('name'=>$val,'status'=>1);
}elseif(isset($showlist[$val])){
$res = array('name'=>$val,'status'=>2);
}elseif(isset($newlist[$val])){
$res = array('name'=>$val,'status'=>3);
}else{
$res = array('name'=>$val,'status'=>1);
}
$tableData[] = $res;
}
}
upgradeinformation(-4);
exit(json_encode(array('step'=>3,'tableData'=>$tableData,'button'=>$button,'oldversion'=>CORE_VERSION)));
} elseif ($step == 4) {
$confirm = $_GET['confirm'];
if (!$confirm) {
if ($_GET['siteftpsetting']) {
$action = $theurl . '&step=4&confirm=ftp&formhash='.FORMHASH . ($_GET['startupgrade'] ? '&startupgrade=1' : '');
exit(json_encode(array('siteftpsetting'=>true,'url'=>$action)));
}
if ($upgradeinfo['isupdatedb']) {
$checkupdatefilelist = array('install/update.php', 'install/data/install.sql', 'install/data/install_data.sql');
$checkupdatefilelist = array_merge($checkupdatefilelist, $updatefilelist);
} else {
$checkupdatefilelist = $updatefilelist;
}
if ($dzz_upgrade -> check_folder_perm($checkupdatefilelist)) {
$confirm = 'file';
} else {
exit(json_encode(array('againsiteftpsetting'=>true)));
}
}
$paraftp = '';
if ($_GET['siteftp']) {
foreach ($_GET['siteftp'] as $k => $v) {
$paraftp .= '&siteftp[' . $k . ']=' . $v;
}
}
if (!$_GET['startupgrade']) {
if (!$_GET['backfile']) {
$linkurl = $theurl . '&step=4&backfile=1&confirm=' . $confirm . $paraftp;
upgradeinformation(2);
exit(json_encode(array('backfile'=>true,'url'=>$linkurl)));
}
foreach ($updatefilelist as $updatefile) {
$destfile = DZZ_ROOT . $updatefile;
$backfile = DZZ_ROOT . './data/back/pichome' . CORE_VERSION . '/' . $updatefile;
if (is_file($destfile)) {
if (!$dzz_upgrade -> copy_file($destfile, $backfile, 'file')) {
upgradeinformation(-5);
exit(json_encode(array('destfile'=>true)));
}
}
}
upgradeinformation(3);
exit(json_encode(array('complete'=>true,'url'=>$theurl.'&step=4&startupgrade=1&confirm='.$confirm.$paraftp)));
}
$linkurl = $theurl . '&step=4&startupgrade=1&confirm=' . $confirm . $paraftp;
$ftplinkurl = $theurl . '&step=4&startupgrade=1&siteftpsetting=1';
foreach ($updatefilelist as $updatefile) {
$srcfile = DZZ_ROOT . './data/update/pichome' . $version . '/' . $updatefile;
if ($confirm == 'ftp') {
$destfile = $updatefile;
} else {
$destfile = DZZ_ROOT . $updatefile;
}
if (!$dzz_upgrade -> copy_file($srcfile, $destfile, $confirm)) {
if ($confirm == 'ftp') {
upgradeinformation(-6);
exit(json_encode(array('ftpError'=>true,'file'=>$updatefile,'againUpdate'=>$linkurl,'ftpUrl'=>$ftplinkurl)));
} else {
upgradeinformation(-7);
exit(json_encode(array('copyError'=>true,'file'=>$updatefile,'againUpdate'=>$linkurl,'ftpUrl'=>$ftplinkurl)));
}
}
}
if ($upgradeinfo['isupdatedb']) {
$upgrade_step['step'] = 'dbupdate';
C::t('cache') -> insert(array('cachekey' => 'upgrade_step', 'cachevalue' => serialize($upgrade_step), 'dateline' => $_G['timestamp'], ), false, true);
// $dbreturnurl = $_G['siteurl'] . ADMINSCRIPT . '?mod=system&op=systemupgrade&operation=' . $operation . '&version=' . $version . '&step=5';
$dbreturnurl = $_G['siteurl'] . ADMINSCRIPT . '?mod=system#/systemupgrade/'.$version;
$linkurl = $_G['siteurl'] . 'install/update.php?step=prepare&from=' . rawurlencode($dbreturnurl) . '&frommd5=' . rawurlencode(md5($dbreturnurl . $_G['config']['security']['authkey']));
upgradeinformation(4);
exit(json_encode(array('updateMysql'=>true,'url'=>$linkurl)));
}
exit(json_encode(array('nextStep'=>true)));
} elseif ($step == 5) {
$file = DZZ_ROOT . './data/update/pichome' . $version . '/updatelist.tmp';
@unlink($file);
@unlink(DZZ_ROOT . './install/update.php');
C::t('cache') -> delete('upgrade_step');
C::t('cache') -> delete('upgrade_run');
C::t('setting') -> update('upgrade', '');
updatecache('setting');
$old_update_dir = './data/update/';
$new_update_dir = './data/update' . md5('update' . $_G['config']['security']['authkey']) . '/';
$old_back_dir = './data/back/';
$new_back_dir = './data/back' . md5('back' . $_G['config']['security']['authkey']) . '/';
$dzz_upgrade -> copy_dir(DZZ_ROOT . $old_update_dir, DZZ_ROOT . $new_update_dir);
$dzz_upgrade -> copy_dir(DZZ_ROOT . $old_back_dir, DZZ_ROOT . $new_back_dir);
$dzz_upgrade -> rmdirs(DZZ_ROOT . $old_update_dir);
$dzz_upgrade -> rmdirs(DZZ_ROOT . $old_back_dir);
upgradeinformation(0);
exit(json_encode(array('version' => $version,'dir'=>$new_update_dir,'backdir'=>$new_back_dir)));
// $msg = lang('upgrade_successful', array('version' => $version, 'save_update_dir' => $new_update_dir, 'save_back_dir' => $new_back_dir, 'upgradeurl' => upgradeinformation(0)));
}
}elseif ($operation == 'check') {
$msg = '';
$upgrade_step = C::t('cache') -> fetch('upgrade_step');
if (!empty($upgrade_step['cachevalue'])) {
$upgrade_step['cachevalue'] = dunserialize($upgrade_step['cachevalue']);
if (!empty($upgrade_step['cachevalue']['step'])) {
$theurl = ADMINSCRIPT . '?mod=system&op=systemupgrade&operation=' . $upgrade_step['cachevalue']['operation'] . '&version=' . $upgrade_step['cachevalue']['version'] . '&locale=' . $upgrade_step['cachevalue']['locale'] . '&charset=' . $upgrade_step['cachevalue']['charset'];
$recheckurl = ADMINSCRIPT . '?mod=system&op=systemupgrade&operation=recheck';
if ($upgrade_step['cachevalue']['step'] == 'dbupdate') {
// $dbreturnurl = $_G['siteurl'] . $theurl . '&step=5';
$dbreturnurl = $_G['siteurl'] . ADMINSCRIPT . '?mod=system#/systemupgrade/'.$upgrade_step['cachevalue']['version'];
$stepurl = $_G['siteurl'] . 'install/update.php?step=prepare&from=' . rawurlencode($dbreturnurl) . '&frommd5=' . rawurlencode(md5($dbreturnurl . $_G['config']['security']['authkey']));
exit(json_encode(array('iframe'=>true,'steplang'=>$steplang['dbupdate'],'url'=>$stepurl)));
} else {
exit(json_encode(array('html'=>true,'steplang'=>$steplang[$upgrade_step['cachevalue']['step']],'data'=>$upgrade_step['cachevalue'])));
}
}else{
$dzz_upgrade -> check_upgrade();
exit(json_encode(array('html'=>false)));
}
}else{
$dzz_upgrade -> check_upgrade();
exit(json_encode(array('html'=>false)));
}
exit();
}elseif ($operation == 'showupgrade') {
if ($_G['setting']['upgrade']) {
C::t('cache') -> insert(array('cachekey' => 'upgrade_step', 'cachevalue' => serialize(array('curversion' => $dzz_upgrade -> versionpath())), 'dateline' => $_G['timestamp'], ), false, true);
$upgraderow = $patchrow = array();
$charset = str_replace('-', '', strtoupper($_G['config']['output']['charset']));
$dbversion = helper_dbtool::dbversion();
$locale = '';
if ($charset == 'BIG5') {
$locale = 'TC';
} elseif ($charset == 'GBK') {
$locale = 'SC';
} elseif ($charset == 'UTF8') {
if ($_G['config']['output']['language'] == 'zh-cn' || $_G['config']['output']['language'] == 'zh_cn') {
$locale = 'SC';
} elseif ($_G['config']['output']['language'] == 'zh-tw' || $_G['config']['output']['language'] == 'zh_tw') {
$locale = 'TC';
}else{
$locale = 'SC';
}
}
if (!is_array($_G['setting']['upgrade']))
$_G['setting']['upgrade'] = unserialize($_G['setting']['upgrade']);
$list = array();
foreach ($_G['setting']['upgrade'] as $type => $upgrade) {
$flist = array();
$unupgrade = 0;
if (version_compare($upgrade['phpversion'], PHP_VERSION) > 0 || version_compare($upgrade['mysqlversion'], $dbversion) > 0) {
$unupgrade = 1;
}
if ($unupgrade) {
$flist['title'] = 'oaooa PicHome ' . $upgrade['latestversion'] . '_' . $locale . '_' . $charset;
$flist['msg'] = lang('founder_upgrade_require_config') . ' php v' . PHP_VERSION . 'MYSQL v' . $dbversion;
$flist['update'] = false;
} else {
$flist['title'] = 'oaooa PicHome ' . $upgrade['latestversion'] . '_' . $locale . '_' . $charset;
$flist['update'] = true;
$flist['version'] = $upgrade['latestversion'];
$flist['locale'] = $locale;
$flist['charset'] = $charset;
}
$list[] = $flist;
}
exit(json_encode(array('content'=>true,'data'=>$list)));
} else {
exit(json_encode(array('content'=>false)));
}
}elseif ($operation == 'recheck') {
$upgrade_step = C::t('cache') -> fetch('upgrade_step');
$upgrade_step = dunserialize($upgrade_step['cachevalue']);
$file = DZZ_ROOT . './data/update/pichome' . $upgrade_step['version'] . '/updatelist.tmp';
@unlink($file);
@unlink(DZZ_ROOT . './install/update.php');
C::t('cache') -> delete('upgrade_step');
C::t('cache') -> delete('upgrade_run');
C::t('setting') -> update('upgrade', '');
updatecache('setting');
$old_update_dir = './data/update/';
$dzz_upgrade -> rmdirs(DZZ_ROOT . $old_update_dir);
$dzz_upgrade -> check_upgrade();
// $url = outputurl($_G['siteurl'].MOD_URL.'&op=systemupgrade' );
// dheader('Location: ' . $url);
}
// include template('upgrade');
?>

View File

@@ -1,414 +1,416 @@
<?php
/*
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
* @license https://www.oaooa.com/licenses/
*
* @link https://www.oaooa.com
* @author zyx(zyx@oaooa.com)
*/
if (!defined('IN_OAOOA') || !defined('IN_ADMIN')) {
exit('Access Denied');
}
$navtitle = lang('upgrade') . ' - ' . lang('admin_navtitle');
@set_time_limit(0);
include_once DZZ_ROOT . './core/core_version.php';
include_once libfile('function/admin');
include_once libfile('function/cache');
$dzz_upgrade = new dzz_upgrade();
$step = intval($_GET['step']);
$op = $_GET['op'];
$step = $step ? $step : 1;
$operation = $_GET['operation'] ? trim($_GET['operation']) : 'check';
$steplang = array('', lang('founder_upgrade_updatelist'), lang('founder_upgrade_download'), lang('founder_upgrade_compare'), lang('founder_upgrade_upgrading'), lang('founder_upgrade_complete'), 'dbupdate' => lang('founder_upgrade_dbupdate'));
if ($operation == 'patch' || $operation == 'cross') {
if (!$_G['setting']['bbclosed']) {
$msg = '<p style="margin:10px 0;color:red">' . lang('upgrade_close_site') . '</p>';
$msg .= '<p style="margin:10px 0"><input type="button" class="btn btn-primary" onclick="window.location.reload();" value="' . lang('founder_upgrade_reset') . '" /></p>';
$msg .= "<p style=\"margin:10px 0\"><script type=\"text/javascript\">";
$msg .= "if(history.length > (BROWSER.ie ? 0 : 1)) document.write('<a href=\"javascript:history.go(-1);\" >" . lang('message_return') . "</a>');";
$msg .= "</script></p>";
if (!$_GET['iframe']) {
include template('upgrade');
exit();
} else {
include template('upgrade_iframe');
exit();
}
}
$msg = '';
$version = trim($_GET['version']);
//$release = trim($_GET['release']);
$locale = trim($_GET['locale']);
$charset = trim($_GET['charset']);
$upgradeinfo = $upgrade_step = array();
if ($_GET['ungetfrom']) {
if (md5($_GET['ungetfrom'] . $_G['config']['security']['authkey']) == $_GET['ungetfrommd5']) {
$dbreturnurl = $_G['siteurl'] . ADMINSCRIPT . '?mod=system&op=systemupgrade&operation=' . $operation . '&version=' . $version . '&step=5';
$url = outputurl( $_G['siteurl'] . 'install/update.php?step=prepare&from=' . rawurlencode($dbreturnurl) . '&frommd5=' . rawurlencode(md5($dbreturnurl . $_G['config']['security']['authkey'])) );
dheader('Location: ' . $url);
} else {
showmessage('upgrade_param_error');
}
}
$upgrade_step = C::t('cache') -> fetch('upgrade_step');
$upgrade_step = dunserialize($upgrade_step['cachevalue']);
$upgrade_step['step'] = $step;
$upgrade_step['operation'] = $operation;
$upgrade_step['version'] = $version;
//$upgrade_step['release'] = $release;
$upgrade_step['charset'] = $charset;
$upgrade_step['locale'] = $locale;
C::t('cache') -> insert(array('cachekey' => 'upgrade_step', 'cachevalue' => serialize($upgrade_step), 'dateline' => $_G['timestamp'], ), false, true);
$upgrade_run = C::t('cache') -> fetch('upgrade_run');
if (!$upgrade_run) {
C::t('cache') -> insert(array('cachekey' => 'upgrade_run', 'cachevalue' => serialize($_G['setting']['upgrade']), 'dateline' => $_G['timestamp'], ), false, true);
$upgrade_run = $_G['setting']['upgrade'];
} else {
$upgrade_run = dunserialize($upgrade_run['cachevalue']);
}
if ($step != 5) {
foreach ($upgrade_run as $type => $list) {
if ($type == $operation && $version == $list['latestversion']) {
$dzz_upgrade -> locale = $locale;
$dzz_upgrade -> charset = $charset;
$upgradeinfo = $list;
break;
}
}
if (!$upgradeinfo) {
$msg = '<p style="margin:10px 0;color:red">' . lang('upgrade_none', array('upgradeurl' => upgradeinformation(-1))) . '</p>';
$msg .= "<p style=\"margin:10px 0\"><script type=\"text/javascript\">";
$msg .= "if(history.length > (BROWSER.ie ? 0 : 1)) document.write('<a href=\"javascript:history.go(-1);\" >" . lang('message_return') . "</a>');";
$msg .= "</script></p>";
if (!$_GET['iframe']) {
include template('upgrade');
exit();
} else {
include template('upgrade_iframe');
exit();
}
}
$updatefilelist = $dzz_upgrade -> fetch_updatefile_list($upgradeinfo);
$updatemd5filelist = $updatefilelist['md5'];
$updatefilelist = $updatefilelist['file'];
$theurl = $_G['siteurl'].ADMINSCRIPT . '?mod=system&op=systemupgrade&operation=' . $operation . '&version=' . $version . '&locale=' . $locale . '&charset=' . $charset;
if (empty($updatefilelist)) {
$msg = '<p style="margin:10px 0;color:red">' . lang('upgrade_download_upgradelist_error', array('upgradeurl' => upgradeinformation(-2))) . '</p>';
$msg .= '<script type="text/JavaScript">setTimeout("location.href=\'' . ($thurl) . '\';", 1000);</script>';
$msg .= ' <p style="margin:10px 0"><a href="' . $thurl . '">' . lang('message_redirect') . '</p>';
if (!$_GET['iframe']) {
include template('upgrade');
exit();
} else {
include template('upgrade_iframe');
exit();
}
}
}
if ($step == 1) {
$linkurl = $theurl . '&step=2';
include template('upgrade');
exit();
} elseif ($step == 2) {
$fileseq = intval($_GET['fileseq']);
$fileseq = $fileseq ? $fileseq : 1;
if ($fileseq > count($updatefilelist)) {
$linkurl = $theurl . '&step=3';
$downloadstatus = 3;
$msg = lang('upgrade_download_complete_to_compare', array('upgradeurl' => upgradeinformation(0)));
if (!$_GET['iframe']) {
$msg .= '<script type="text/JavaScript">setTimeout("location.href=\'' . $linkurl . '\';", 1000);</script>';
$msg .= ' <p><a href="' . $linkurl . '">' . lang('message_redirect') . '</a></p>';
} else {
$msg .= '<script type="text/JavaScript">setTimeout("parent.location.href=\'' . $linkurl . '\';", 1000);</script>';
$msg .= ' <p><a href="javascript:;" onclick="parent.location.href=\'' . $linkurl . '\';return false;">' . lang('message_redirect') . '</a></p>';
include template('upgrade_iframe');
exit();
}
} else {
if (!$_GET['iframe']) {
$linkurl = $theurl . '&step=2&fileseq=' . $fileseq . '&iframe=1';
$msg = '<iframe id="downiframe" marginheight="0" marginwidth="0" allowtransparency="true" frameborder="0" src="' . $linkurl . '" style="width:100%;height:100%;"></iframe>';
} else {
$downloadstatus = $dzz_upgrade -> download_file($upgradeinfo, $updatefilelist[$fileseq - 1], 'upload', $updatemd5filelist[$fileseq - 1]);
if ($downloadstatus == 1) {
$linkurl = $theurl . '&step=2&fileseq=' . $fileseq . '&iframe=1';
$msg = lang('upgrade_downloading_file', array('file' => $updatefilelist[$fileseq - 1], 'percent' => sprintf("%2d", 100 * $fileseq / count($updatefilelist)) . '%', 'upgradeurl' => upgradeinformation(1))) . '<script type="text/JavaScript">setTimeout("location.href=\'' . $linkurl . '\';", 10);</script>';
$msg .= ' <p><a href="' . $linkurl . '">' . lang('message_redirect') . '</a></p>';
} elseif ($downloadstatus == 2) {
$linkurl = $theurl . '&step=2&fileseq=' . ($fileseq + 1) . '&iframe=1';
$msg = '<p style="margin:10px 0">' . lang('upgrade_downloading_file', array('file' => $updatefilelist[$fileseq - 1], 'percent' => sprintf("%2d", 100 * $fileseq / count($updatefilelist)) . '%', 'upgradeurl' => upgradeinformation(1))) . '<script type="text/JavaScript">setTimeout("location.href=\'' . $linkurl . '\';", 10);</script></p>';
$msg .= ' <p><a href="' . $linkurl . '">' . lang('message_redirect') . '</a></p>';
} else {
$linkurl = $theurl . '&step=2&fileseq=' . ($fileseq) . '&iframe=1';
$msg = '<p style="margin:10px 0">' . lang('upgrade_redownload', array('file' => $updatefilelist[$fileseq - 1], 'upgradeurl' => upgradeinformation(-3))) . '</p>';
$msg .= '<p style="margin:10px 0;"><input type="button" class="btn btn-success" value="'.lang('founder_upgrade_reset').'" onclick="location.href=\'' . $linkurl . '\'" />';
}
include template('upgrade_iframe');
exit();
}
}
} elseif ($step == 3) {
list($modifylist, $showlist, $ignorelist,$newlist) = $dzz_upgrade -> compare_basefile($upgradeinfo, $updatefilelist,$updatemd5filelist);
if (empty($modifylist) && empty($showlist) && empty($ignorelist) && empty($newlist)) {
$msg = lang('filecheck_nofound_md5file', array('upgradeurl' => upgradeinformation(-4)));
}
$linkurl = $theurl . '&step=4';
} elseif ($step == 4) {
$confirm = $_GET['confirm'];
if (!$confirm) {
if ($_GET['siteftpsetting']) {
$action = $theurl . '&step=4&confirm=ftp' . ($_GET['startupgrade'] ? '&startupgrade=1' : '');
include template('upgrade');
exit();
}
if ($upgradeinfo['isupdatedb']) {
$checkupdatefilelist = array('install/update.php', 'install/data/install.sql', 'install/data/install_data.sql');
$checkupdatefilelist = array_merge($checkupdatefilelist, $updatefilelist);
} else {
$checkupdatefilelist = $updatefilelist;
}
if ($dzz_upgrade -> check_folder_perm($checkupdatefilelist)) {
$confirm = 'file';
} else {
$linkurl = $theurl . '&step=4';
$ftplinkurl = $linkurl . '&siteftpsetting=1';
$msg = '<p style="margin:10px 0">' . lang('upgrade_cannot_access_file') . '</p>';
$msg .= '<p style="margin:10px 0"><input type="button" class="btn btn-primary" onclick="window.location.href=\'' . $ftplinkurl . '\'" value="' . lang('founder_upgrade_set_ftp') . '" />';
$msg .= ' &nbsp; <input type="button" class="btn btn-default" onclick="window.location.href=\'' . $linkurl . '\'" value="' . lang('founder_upgrade_reset') . '" /></p>';
$msg .= "<script type=\"text/javascript\">";
$msg .= "if(history.length > (BROWSER.ie ? 0 : 1)) document.write('<a href=\"javascript:history.go(-1);\" class=\"lightlink\">" . lang('message_return') . "</a>');";
$msg .= "</script>";
include template('upgrade');
exit();
}
}
$paraftp = '';
if ($_GET['siteftp']) {
foreach ($_GET['siteftp'] as $k => $v) {
$paraftp .= '&siteftp[' . $k . ']=' . $v;
}
}
if (!$_GET['startupgrade']) {
if (!$_GET['backfile']) {
$linkurl = $theurl . '&step=4&backfile=1&confirm=' . $confirm . $paraftp;
$msg = '<p style="margin:10px 0">' . lang('upgrade_backuping', array('upgradeurl' => upgradeinformation(2))) . '</p>';
$msg .= '<script type="text/JavaScript">setTimeout("location.href=\'' . ($linkurl) . '\';", 1000);</script>';
$msg .= ' <p style="margin:10px 0"><a href="' . $linkurl . '">' . lang('message_redirect') . '</p>';
include template('upgrade');
exit();
}
foreach ($updatefilelist as $updatefile) {
$destfile = DZZ_ROOT . $updatefile;
$backfile = DZZ_ROOT . './data/back/pichome' . CORE_VERSION . '/' . $updatefile;
if (is_file($destfile)) {
if (!$dzz_upgrade -> copy_file($destfile, $backfile, 'file')) {
$msg = '<p style="margin:10px 0">' . lang('upgrade_backup_error', array('upgradeurl' => upgradeinformation(-5))) . '</p>';
$msg .= "<p style=\"margin:10px 0\"><script type=\"text/javascript\">";
$msg .= "if(history.length > (BROWSER.ie ? 0 : 1)) document.write('<a href=\"javascript:history.go(-1);\" >" . lang('message_return') . "</a>');";
$msg .= "</script></p>";
include template('upgrade');
exit();
}
}
}
$msg = '<p style="margin:10px 0">' . lang('upgrade_backup_complete', array('upgradeurl' => upgradeinformation(3))) . '</p>';
$msg .= '<script type="text/JavaScript">setTimeout("location.href=\'' . ($theurl . '&step=4&startupgrade=1&confirm=' . $confirm . $paraftp) . '\';", 1000);</script>';
$msg .= ' <p><a href="' . ($theurl . '&step=4&startupgrade=1&confirm=' . $confirm . $paraftp) . '">' . lang('message_redirect') . '</p>';
include template('upgrade');
exit();
}
$linkurl = $theurl . '&step=4&startupgrade=1&confirm=' . $confirm . $paraftp;
$ftplinkurl = $theurl . '&step=4&startupgrade=1&siteftpsetting=1';
foreach ($updatefilelist as $updatefile) {
$srcfile = DZZ_ROOT . './data/update/pichome' . $version . '/' . $updatefile;
if ($confirm == 'ftp') {
$destfile = $updatefile;
} else {
$destfile = DZZ_ROOT . $updatefile;
}
if (!$dzz_upgrade -> copy_file($srcfile, $destfile, $confirm)) {
if ($confirm == 'ftp') {
$msg = '<p style="margin:10px 0">' . lang('upgrade_ftp_upload_error', array('file' => $updatefile, 'upgradeurl' => upgradeinformation(-6))) . '</p>';
$msg .= '<p style="margin:10px 0"><input type="button" class="btn btn-primary" onclick="window.location.href=\'' . $linkurl . '\'" value="' . lang('founder_upgrade_reupload') . '" />';
$msg .= '&nbsp;<input type="button" class="btn btn-default" onclick="window.location.href=\'' . $ftplinkurl . '\'" value="' . lang('founder_upgrade_reset_ftp') . '" /></p>';
$msg .= "<p style=\"margin:10px 0\"><script type=\"text/javascript\">";
$msg .= "if(history.length > (BROWSER.ie ? 0 : 1)) document.write('<a href=\"javascript:history.go(-1);\" class=\"lightlink\">" . lang('message_return') . "</a>');";
$msg .= "</script></p>";
include template('upgrade');
exit();
} else {
$msg = '<p style="margin:10px 0">' . lang('upgrade_copy_error', array('file' => $updatefile, 'upgradeurl' => upgradeinformation(-7))) . '</p>';
$msg .= '<p style="margin:10px 0"><input type="button" class="btn btn-primary" onclick="window.location.href=\'' . $linkurl . '\'" value="' . lang('founder_upgrade_recopy') . '" />';
$msg .= '&nbsp;<input type="button" class="btn btn-default" onclick="window.location.href=\'' . $ftplinkurl . '\'" value="' . lang('founder_upgrade_set_ftp') . '" /></p>';
$msg .= "<p style=\"margin:10px 0\"><script type=\"text/javascript\">";
$msg .= "if(history.length > (BROWSER.ie ? 0 : 1)) document.write('<a href=\"javascript:history.go(-1);\" class=\"lightlink\">" . lang('message_return') . "</a>');";
$msg .= "</script></p>";
include template('upgrade');
exit();
}
}
}
if ($upgradeinfo['isupdatedb']) {
$upgrade_step['step'] = 'dbupdate';
C::t('cache') -> insert(array('cachekey' => 'upgrade_step', 'cachevalue' => serialize($upgrade_step), 'dateline' => $_G['timestamp'], ), false, true);
$dbreturnurl = $_G['siteurl'] . ADMINSCRIPT . '?mod=system&op=systemupgrade&operation=' . $operation . '&version=' . $version . '&step=5';
$linkurl = $_G['siteurl'] . 'install/update.php?step=prepare&from=' . rawurlencode($dbreturnurl) . '&frommd5=' . rawurlencode(md5($dbreturnurl . $_G['config']['security']['authkey']));
$msg = '<p style="margin:10px 0">' . lang('upgrade_file_successful', array('upgradeurl' => upgradeinformation(4))) . '</p>';
$msg .= '<script type="text/JavaScript">setTimeout(function(){createIframe(\'' . $linkurl . '\');}, 1000);</script>';
$msg .= ' <p><a href="javascript:;" onclick="createIframe(\'' . $linkurl . '\');return false">' . lang('message_redirect') . '</p>';
include template('upgrade');
exit();
}
$url = outputurl( $_G['siteurl'].MOD_URL.'&op=systemupgrade&operation=' . $operation . '&version=' . $version . '&step=5' );
dheader('Location: ' . $url);
} elseif ($step == 5) {
$file = DZZ_ROOT . './data/update/pichome' . $version . '/updatelist.tmp';
@unlink($file);
@unlink(DZZ_ROOT . './install/update.php');
C::t('cache') -> delete('upgrade_step');
C::t('cache') -> delete('upgrade_run');
C::t('setting') -> update('upgrade', '');
updatecache('setting');
$old_update_dir = './data/update/';
$new_update_dir = './data/update' . md5('update' . $_G['config']['security']['authkey']) . '/';
$old_back_dir = './data/back/';
$new_back_dir = './data/back' . md5('back' . $_G['config']['security']['authkey']) . '/';
$dzz_upgrade -> copy_dir(DZZ_ROOT . $old_update_dir, DZZ_ROOT . $new_update_dir);
$dzz_upgrade -> copy_dir(DZZ_ROOT . $old_back_dir, DZZ_ROOT . $new_back_dir);
$dzz_upgrade -> rmdirs(DZZ_ROOT . $old_update_dir);
$dzz_upgrade -> rmdirs(DZZ_ROOT . $old_back_dir);
$msg = lang('upgrade_successful', array('version' => $version, 'save_update_dir' => $new_update_dir, 'save_back_dir' => $new_back_dir, 'upgradeurl' => upgradeinformation(0)));
}
}elseif ($operation == 'check') {
$msg = '';
if (!intval($_GET['rechecking'])) {
$upgrade_step = C::t('cache') -> fetch('upgrade_step');
if (!empty($upgrade_step['cachevalue'])) {
$upgrade_step['cachevalue'] = dunserialize($upgrade_step['cachevalue']);
if (!empty($upgrade_step['cachevalue']['step'])) {
$theurl = ADMINSCRIPT . '?mod=system&op=systemupgrade&operation=' . $upgrade_step['cachevalue']['operation'] . '&version=' . $upgrade_step['cachevalue']['version'] . '&locale=' . $upgrade_step['cachevalue']['locale'] . '&charset=' . $upgrade_step['cachevalue']['charset'];
$recheckurl = ADMINSCRIPT . '?mod=system&op=systemupgrade&operation=recheck';
if ($upgrade_step['cachevalue']['step'] == 'dbupdate') {
$dbreturnurl = $_G['siteurl'] . $theurl . '&step=5';
$stepurl = $_G['siteurl'] . 'install/update.php?step=prepare&from=' . rawurlencode($dbreturnurl) . '&frommd5=' . rawurlencode(md5($dbreturnurl . $_G['config']['security']['authkey']));
$msg = '<p style="margin:10px 0;">' . lang('upgrade_continue_db', array('steplang' => $steplang['dbupdate'], 'stepurl' => $stepurl, 'recheckurl' => $recheckurl)) . '</p>';
} else {
$stepurl = $theurl . '&step=' . $upgrade_step['cachevalue']['step'];
$msg = '<p style="margin:10px 0;">' . lang('upgrade_continue', array('steplang' => $steplang[$upgrade_step['cachevalue']['step']], 'stepurl' => $stepurl, 'recheckurl' => $recheckurl)) . '</p>';
}
}
}
} else {
C::t('cache') -> delete('upgrade_step');
}
if (!intval($_GET['checking']) || $msg) {
} else {
$dzz_upgrade -> check_upgrade();
$url = outputurl( $_G['siteurl'].MOD_URL.'&op=systemupgrade&operation=showupgrade' );
dheader('Location: ' . $url);
}
}elseif ($operation == 'showupgrade') {
if ($_G['setting']['upgrade']) {
C::t('cache') -> insert(array('cachekey' => 'upgrade_step', 'cachevalue' => serialize(array('curversion' => $dzz_upgrade -> versionpath())), 'dateline' => $_G['timestamp'], ), false, true);
$upgraderow = $patchrow = array();
$charset = str_replace('-', '', strtoupper($_G['config']['output']['charset']));
$dbversion = helper_dbtool::dbversion();
$locale = '';
if ($charset == 'BIG5') {
$locale = 'TC';
} elseif ($charset == 'GBK') {
$locale = 'SC';
} elseif ($charset == 'UTF8') {
if ($_G['config']['output']['language'] == 'zh-cn' || $_G['config']['output']['language'] == 'zh_cn') {
$locale = 'SC';
} elseif ($_G['config']['output']['language'] == 'zh-tw' || $_G['config']['output']['language'] == 'zh_tw') {
$locale = 'TC';
}else{
$locale = 'SC';
}
}
if (!is_array($_G['setting']['upgrade']))
$_G['setting']['upgrade'] = unserialize($_G['setting']['upgrade']);
$list = array();
foreach ($_G['setting']['upgrade'] as $type => $upgrade) {
$unupgrade = 0;
if (version_compare($upgrade['phpversion'], PHP_VERSION) > 0 || version_compare($upgrade['mysqlversion'], $dbversion) > 0) {
$unupgrade = 1;
}
$list[$type]['linkurl'] = $linkurl = ADMINSCRIPT . '?mod=system&op=systemupgrade&operation=' . $type . '&version=' . $upgrade['latestversion'] . '&locale=' . $locale . '&charset=' . $charset;
if ($unupgrade) {
$list[$type]['title'] = 'oaooa PicHome ' . $upgrade['latestversion'] . '_' . $locale . '_' . $charset;
$list[$type]['btn1'] = lang('founder_upgrade_require_config') . ' php v' . PHP_VERSION . 'MYSQL v' . $dbversion;
} else {
$list[$type]['title'] = 'oaooa PicHome ' . $upgrade['latestversion'] . '_' . $locale . '_' . $charset;
$list[$type]['btn1'] = '<input type="button" class="btn btn-success" onclick="confirm(\'' . lang('founder_upgrade_backup_remind') . '\') ? window.location.href=\'' . $linkurl . '\' : \'\';" value="' . lang('founder_upgrade_automatically') . '">';
$list[$type]['official'] = '<a class="btn btn-link" href="' . $upgrade['official'] . '" target="_blank">' . lang('founder_upgrade_manually') . '</a>';
}
}
} else {
$msg = lang('upgrade_latest_version');
}
}elseif ($operation == 'recheck') {
$upgrade_step = C::t('cache') -> fetch('upgrade_step');
$upgrade_step = dunserialize($upgrade_step['cachevalue']);
$file = DZZ_ROOT . './data/update/pichome' . $upgrade_step['version'] . '/updatelist.tmp';
@unlink($file);
@unlink(DZZ_ROOT . './install/update.php');
C::t('cache') -> delete('upgrade_step');
C::t('cache') -> delete('upgrade_run');
C::t('setting') -> update('upgrade', '');
updatecache('setting');
$old_update_dir = './data/update/';
$dzz_upgrade -> rmdirs(DZZ_ROOT . $old_update_dir);
$url = outputurl($_G['siteurl'].MOD_URL.'&op=systemupgrade' );
dheader('Location: ' . $url);
}
include template('upgrade');
<?php
/*
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
* @license https://www.oaooa.com/licenses/
*
* @link https://www.oaooa.com
* @author zyx(zyx@oaooa.com)
*/
if (!defined('IN_OAOOA') || !defined('IN_ADMIN')) {
exit('Access Denied');
}
$navtitle = lang('upgrade') . ' - ' . lang('admin_navtitle');
@set_time_limit(0);
include_once DZZ_ROOT . './core/core_version.php';
include_once libfile('function/admin');
include_once libfile('function/cache');
$dzz_upgrade = new dzz_upgrade();
$step = intval($_GET['step']);
$op = $_GET['op'];
$step = $step ? $step : 1;
$operation = $_GET['operation'] ? trim($_GET['operation']) : 'check';
$steplang = array('', lang('founder_upgrade_updatelist'), lang('founder_upgrade_download'), lang('founder_upgrade_compare'), lang('founder_upgrade_upgrading'), lang('founder_upgrade_complete'), 'dbupdate' => lang('founder_upgrade_dbupdate'));
if ($operation == 'patch' || $operation == 'cross') {
if (!$_G['setting']['bbclosed']) {
$msg = '<p style="margin:10px 0;color:red">' . lang('upgrade_close_site') . '</p>';
$msg .= '<p style="margin:10px 0"><input type="button" class="btn btn-primary" onclick="window.location.reload();" value="' . lang('founder_upgrade_reset') . '" /></p>';
$msg .= "<p style=\"margin:10px 0\"><script type=\"text/javascript\">";
$msg .= "if(history.length > (BROWSER.ie ? 0 : 1)) document.write('<a href=\"javascript:history.go(-1);\" >" . lang('message_return') . "</a>');";
$msg .= "</script></p>";
if (!$_GET['iframe']) {
include template('upgrade');
exit();
} else {
include template('upgrade_iframe');
exit();
}
}
$msg = '';
$version = trim($_GET['version']);
//$release = trim($_GET['release']);
$locale = trim($_GET['locale']);
$charset = trim($_GET['charset']);
$upgradeinfo = $upgrade_step = array();
if ($_GET['ungetfrom']) {
if (md5($_GET['ungetfrom'] . $_G['config']['security']['authkey']) == $_GET['ungetfrommd5']) {
$dbreturnurl = $_G['siteurl'] . ADMINSCRIPT . '?mod=system&op=systemupgrade&operation=' . $operation . '&version=' . $version . '&step=5';
$url = outputurl( $_G['siteurl'] . 'install/update.php?step=prepare&from=' . rawurlencode($dbreturnurl) . '&frommd5=' . rawurlencode(md5($dbreturnurl . $_G['config']['security']['authkey'])) );
dheader('Location: ' . $url);
} else {
showmessage('upgrade_param_error');
}
}
$upgrade_step = C::t('cache') -> fetch('upgrade_step');
$upgrade_step = dunserialize($upgrade_step['cachevalue']);
$upgrade_step['step'] = $step;
$upgrade_step['operation'] = $operation;
$upgrade_step['version'] = $version;
//$upgrade_step['release'] = $release;
$upgrade_step['charset'] = $charset;
$upgrade_step['locale'] = $locale;
C::t('cache') -> insert(array('cachekey' => 'upgrade_step', 'cachevalue' => serialize($upgrade_step), 'dateline' => $_G['timestamp'], ), false, true);
$upgrade_run = C::t('cache') -> fetch('upgrade_run');
if (!$upgrade_run) {
C::t('cache') -> insert(array('cachekey' => 'upgrade_run', 'cachevalue' => serialize($_G['setting']['upgrade']), 'dateline' => $_G['timestamp'], ), false, true);
$upgrade_run = $_G['setting']['upgrade'];
} else {
$upgrade_run = dunserialize($upgrade_run['cachevalue']);
}
if ($step != 5) {
foreach ($upgrade_run as $type => $list) {
if ($type == $operation && $version == $list['latestversion']) {
$dzz_upgrade -> locale = $locale;
$dzz_upgrade -> charset = $charset;
$upgradeinfo = $list;
break;
}
}
if (!$upgradeinfo) {
$msg = '<p style="margin:10px 0;color:red">' . lang('upgrade_none', array('upgradeurl' => upgradeinformation(-1))) . '</p>';
$msg .= "<p style=\"margin:10px 0\"><script type=\"text/javascript\">";
$msg .= "if(history.length > (BROWSER.ie ? 0 : 1)) document.write('<a href=\"javascript:history.go(-1);\" >" . lang('message_return') . "</a>');";
$msg .= "</script></p>";
if (!$_GET['iframe']) {
include template('upgrade');
exit();
} else {
include template('upgrade_iframe');
exit();
}
}
$updatefilelist = $dzz_upgrade -> fetch_updatefile_list($upgradeinfo);
$updatemd5filelist = $updatefilelist['md5'];
$updatefilelist = $updatefilelist['file'];
$theurl = $_G['siteurl'].ADMINSCRIPT . '?mod=system&op=systemupgrade&operation=' . $operation . '&version=' . $version . '&locale=' . $locale . '&charset=' . $charset;
if (empty($updatefilelist)) {
$msg = '<p style="margin:10px 0;color:red">' . lang('upgrade_download_upgradelist_error', array('upgradeurl' => upgradeinformation(-2))) . '</p>';
$msg .= '<script type="text/JavaScript">setTimeout("location.href=\'' . ($thurl) . '\';", 1000);</script>';
$msg .= ' <p style="margin:10px 0"><a href="' . $thurl . '">' . lang('message_redirect') . '</p>';
if (!$_GET['iframe']) {
include template('upgrade');
exit();
} else {
include template('upgrade_iframe');
exit();
}
}
}
if ($step == 1) {
$linkurl = $theurl . '&step=2';
include template('upgrade');
exit();
} elseif ($step == 2) {
$fileseq = intval($_GET['fileseq']);
$fileseq = $fileseq ? $fileseq : 1;
if ($fileseq > count($updatefilelist)) {
$linkurl = $theurl . '&step=3';
$downloadstatus = 3;
$msg = lang('upgrade_download_complete_to_compare', array('upgradeurl' => upgradeinformation(0)));
if (!$_GET['iframe']) {
$msg .= '<script type="text/JavaScript">setTimeout("location.href=\'' . $linkurl . '\';", 1000);</script>';
$msg .= ' <p><a href="' . $linkurl . '">' . lang('message_redirect') . '</a></p>';
} else {
$msg .= '<script type="text/JavaScript">setTimeout("parent.location.href=\'' . $linkurl . '\';", 1000);</script>';
$msg .= ' <p><a href="javascript:;" onclick="parent.location.href=\'' . $linkurl . '\';return false;">' . lang('message_redirect') . '</a></p>';
include template('upgrade_iframe');
exit();
}
} else {
if (!$_GET['iframe']) {
$linkurl = $theurl . '&step=2&fileseq=' . $fileseq . '&iframe=1';
$msg = '<iframe id="downiframe" marginheight="0" marginwidth="0" allowtransparency="true" frameborder="0" src="' . $linkurl . '" style="width:100%;height:100%;"></iframe>';
} else {
$downloadstatus = $dzz_upgrade -> download_file($upgradeinfo, $updatefilelist[$fileseq - 1], 'upload', $updatemd5filelist[$fileseq - 1]);
if ($downloadstatus == 1) {
$linkurl = $theurl . '&step=2&fileseq=' . $fileseq . '&iframe=1';
$msg = lang('upgrade_downloading_file', array('file' => $updatefilelist[$fileseq - 1], 'percent' => sprintf("%2d", 100 * $fileseq / count($updatefilelist)) . '%', 'upgradeurl' => upgradeinformation(1))) . '<script type="text/JavaScript">setTimeout("location.href=\'' . $linkurl . '\';", 10);</script>';
$msg .= ' <p><a href="' . $linkurl . '">' . lang('message_redirect') . '</a></p>';
} elseif ($downloadstatus == 2) {
$linkurl = $theurl . '&step=2&fileseq=' . ($fileseq + 1) . '&iframe=1';
$msg = '<p style="margin:10px 0">' . lang('upgrade_downloading_file', array('file' => $updatefilelist[$fileseq - 1], 'percent' => sprintf("%2d", 100 * $fileseq / count($updatefilelist)) . '%', 'upgradeurl' => upgradeinformation(1))) . '<script type="text/JavaScript">setTimeout("location.href=\'' . $linkurl . '\';", 10);</script></p>';
$msg .= ' <p><a href="' . $linkurl . '">' . lang('message_redirect') . '</a></p>';
} else {
$linkurl = $theurl . '&step=2&fileseq=' . ($fileseq) . '&iframe=1';
$msg = '<p style="margin:10px 0">' . lang('upgrade_redownload', array('file' => $updatefilelist[$fileseq - 1], 'upgradeurl' => upgradeinformation(-3))) . '</p>';
$msg .= '<p style="margin:10px 0;"><input type="button" class="btn btn-success" value="'.lang('founder_upgrade_reset').'" onclick="location.href=\'' . $linkurl . '\'" />';
}
include template('upgrade_iframe');
exit();
}
}
} elseif ($step == 3) {
list($modifylist, $showlist, $ignorelist,$newlist) = $dzz_upgrade -> compare_basefile($upgradeinfo, $updatefilelist,$updatemd5filelist);
if (empty($modifylist) && empty($showlist) && empty($ignorelist) && empty($newlist)) {
$msg = lang('filecheck_nofound_md5file', array('upgradeurl' => upgradeinformation(-4)));
}
$linkurl = $theurl . '&step=4';
} elseif ($step == 4) {
$confirm = $_GET['confirm'];
if (!$confirm) {
if ($_GET['siteftpsetting']) {
$action = $theurl . '&step=4&confirm=ftp' . ($_GET['startupgrade'] ? '&startupgrade=1' : '');
include template('upgrade');
exit();
}
if ($upgradeinfo['isupdatedb']) {
$checkupdatefilelist = array('install/update.php', 'install/data/install.sql', 'install/data/install_data.sql');
$checkupdatefilelist = array_merge($checkupdatefilelist, $updatefilelist);
} else {
$checkupdatefilelist = $updatefilelist;
}
if ($dzz_upgrade -> check_folder_perm($checkupdatefilelist)) {
$confirm = 'file';
} else {
$linkurl = $theurl . '&step=4';
$ftplinkurl = $linkurl . '&siteftpsetting=1';
$msg = '<p style="margin:10px 0">' . lang('upgrade_cannot_access_file') . '</p>';
$msg .= '<p style="margin:10px 0"><input type="button" class="btn btn-primary" onclick="window.location.href=\'' . $ftplinkurl . '\'" value="' . lang('founder_upgrade_set_ftp') . '" />';
$msg .= ' &nbsp; <input type="button" class="btn btn-default" onclick="window.location.href=\'' . $linkurl . '\'" value="' . lang('founder_upgrade_reset') . '" /></p>';
$msg .= "<script type=\"text/javascript\">";
$msg .= "if(history.length > (BROWSER.ie ? 0 : 1)) document.write('<a href=\"javascript:history.go(-1);\" class=\"lightlink\">" . lang('message_return') . "</a>');";
$msg .= "</script>";
include template('upgrade');
exit();
}
}
$paraftp = '';
if ($_GET['siteftp']) {
foreach ($_GET['siteftp'] as $k => $v) {
$paraftp .= '&siteftp[' . $k . ']=' . $v;
}
}
if (!$_GET['startupgrade']) {
if (!$_GET['backfile']) {
$linkurl = $theurl . '&step=4&backfile=1&confirm=' . $confirm . $paraftp;
$msg = '<p style="margin:10px 0">' . lang('upgrade_backuping', array('upgradeurl' => upgradeinformation(2))) . '</p>';
$msg .= '<script type="text/JavaScript">setTimeout("location.href=\'' . ($linkurl) . '\';", 1000);</script>';
$msg .= ' <p style="margin:10px 0"><a href="' . $linkurl . '">' . lang('message_redirect') . '</p>';
include template('upgrade');
exit();
}
foreach ($updatefilelist as $updatefile) {
$destfile = DZZ_ROOT . $updatefile;
$backfile = DZZ_ROOT . './data/back/pichome' . CORE_VERSION . '/' . $updatefile;
if (is_file($destfile)) {
if (!$dzz_upgrade -> copy_file($destfile, $backfile, 'file')) {
$msg = '<p style="margin:10px 0">' . lang('upgrade_backup_error', array('upgradeurl' => upgradeinformation(-5))) . '</p>';
$msg .= "<p style=\"margin:10px 0\"><script type=\"text/javascript\">";
$msg .= "if(history.length > (BROWSER.ie ? 0 : 1)) document.write('<a href=\"javascript:history.go(-1);\" >" . lang('message_return') . "</a>');";
$msg .= "</script></p>";
include template('upgrade');
exit();
}
}
}
$msg = '<p style="margin:10px 0">' . lang('upgrade_backup_complete', array('upgradeurl' => upgradeinformation(3))) . '</p>';
$msg .= '<script type="text/JavaScript">setTimeout("location.href=\'' . ($theurl . '&step=4&startupgrade=1&confirm=' . $confirm . $paraftp) . '\';", 1000);</script>';
$msg .= ' <p><a href="' . ($theurl . '&step=4&startupgrade=1&confirm=' . $confirm . $paraftp) . '">' . lang('message_redirect') . '</p>';
include template('upgrade');
exit();
}
$linkurl = $theurl . '&step=4&startupgrade=1&confirm=' . $confirm . $paraftp;
$ftplinkurl = $theurl . '&step=4&startupgrade=1&siteftpsetting=1';
foreach ($updatefilelist as $updatefile) {
$srcfile = DZZ_ROOT . './data/update/pichome' . $version . '/' . $updatefile;
if ($confirm == 'ftp') {
$destfile = $updatefile;
} else {
$destfile = DZZ_ROOT . $updatefile;
}
if (!$dzz_upgrade -> copy_file($srcfile, $destfile, $confirm)) {
if ($confirm == 'ftp') {
$msg = '<p style="margin:10px 0">' . lang('upgrade_ftp_upload_error', array('file' => $updatefile, 'upgradeurl' => upgradeinformation(-6))) . '</p>';
$msg .= '<p style="margin:10px 0"><input type="button" class="btn btn-primary" onclick="window.location.href=\'' . $linkurl . '\'" value="' . lang('founder_upgrade_reupload') . '" />';
$msg .= '&nbsp;<input type="button" class="btn btn-default" onclick="window.location.href=\'' . $ftplinkurl . '\'" value="' . lang('founder_upgrade_reset_ftp') . '" /></p>';
$msg .= "<p style=\"margin:10px 0\"><script type=\"text/javascript\">";
$msg .= "if(history.length > (BROWSER.ie ? 0 : 1)) document.write('<a href=\"javascript:history.go(-1);\" class=\"lightlink\">" . lang('message_return') . "</a>');";
$msg .= "</script></p>";
include template('upgrade');
exit();
} else {
$msg = '<p style="margin:10px 0">' . lang('upgrade_copy_error', array('file' => $updatefile, 'upgradeurl' => upgradeinformation(-7))) . '</p>';
$msg .= '<p style="margin:10px 0"><input type="button" class="btn btn-primary" onclick="window.location.href=\'' . $linkurl . '\'" value="' . lang('founder_upgrade_recopy') . '" />';
$msg .= '&nbsp;<input type="button" class="btn btn-default" onclick="window.location.href=\'' . $ftplinkurl . '\'" value="' . lang('founder_upgrade_set_ftp') . '" /></p>';
$msg .= "<p style=\"margin:10px 0\"><script type=\"text/javascript\">";
$msg .= "if(history.length > (BROWSER.ie ? 0 : 1)) document.write('<a href=\"javascript:history.go(-1);\" class=\"lightlink\">" . lang('message_return') . "</a>');";
$msg .= "</script></p>";
include template('upgrade');
exit();
}
}
}
if ($upgradeinfo['isupdatedb']) {
$upgrade_step['step'] = 'dbupdate';
C::t('cache') -> insert(array('cachekey' => 'upgrade_step', 'cachevalue' => serialize($upgrade_step), 'dateline' => $_G['timestamp'], ), false, true);
$dbreturnurl = $_G['siteurl'] . ADMINSCRIPT . '?mod=system&op=systemupgrade&operation=' . $operation . '&version=' . $version . '&step=5';
$linkurl = $_G['siteurl'] . 'install/update.php?step=prepare&from=' . rawurlencode($dbreturnurl) . '&frommd5=' . rawurlencode(md5($dbreturnurl . $_G['config']['security']['authkey']));
$msg = '<p style="margin:10px 0">' . lang('upgrade_file_successful', array('upgradeurl' => upgradeinformation(4))) . '</p>';
$msg .= '<script type="text/JavaScript">setTimeout(function(){createIframe(\'' . $linkurl . '\');}, 1000);</script>';
$msg .= ' <p><a href="javascript:;" onclick="createIframe(\'' . $linkurl . '\');return false">' . lang('message_redirect') . '</p>';
include template('upgrade');
exit();
}
$url = outputurl( $_G['siteurl'].MOD_URL.'&op=systemupgrade&operation=' . $operation . '&version=' . $version . '&step=5' );
dheader('Location: ' . $url);
} elseif ($step == 5) {
print_r(1111);
die;
$file = DZZ_ROOT . './data/update/pichome' . $version . '/updatelist.tmp';
@unlink($file);
@unlink(DZZ_ROOT . './install/update.php');
C::t('cache') -> delete('upgrade_step');
C::t('cache') -> delete('upgrade_run');
C::t('setting') -> update('upgrade', '');
updatecache('setting');
$old_update_dir = './data/update/';
$new_update_dir = './data/update' . md5('update' . $_G['config']['security']['authkey']) . '/';
$old_back_dir = './data/back/';
$new_back_dir = './data/back' . md5('back' . $_G['config']['security']['authkey']) . '/';
$dzz_upgrade -> copy_dir(DZZ_ROOT . $old_update_dir, DZZ_ROOT . $new_update_dir);
$dzz_upgrade -> copy_dir(DZZ_ROOT . $old_back_dir, DZZ_ROOT . $new_back_dir);
$dzz_upgrade -> rmdirs(DZZ_ROOT . $old_update_dir);
$dzz_upgrade -> rmdirs(DZZ_ROOT . $old_back_dir);
$msg = lang('upgrade_successful', array('version' => $version, 'save_update_dir' => $new_update_dir, 'save_back_dir' => $new_back_dir, 'upgradeurl' => upgradeinformation(0)));
}
}elseif ($operation == 'check') {
$msg = '';
if (!intval($_GET['rechecking'])) {
$upgrade_step = C::t('cache') -> fetch('upgrade_step');
if (!empty($upgrade_step['cachevalue'])) {
$upgrade_step['cachevalue'] = dunserialize($upgrade_step['cachevalue']);
if (!empty($upgrade_step['cachevalue']['step'])) {
$theurl = ADMINSCRIPT . '?mod=system&op=systemupgrade&operation=' . $upgrade_step['cachevalue']['operation'] . '&version=' . $upgrade_step['cachevalue']['version'] . '&locale=' . $upgrade_step['cachevalue']['locale'] . '&charset=' . $upgrade_step['cachevalue']['charset'];
$recheckurl = ADMINSCRIPT . '?mod=system&op=systemupgrade&operation=recheck';
if ($upgrade_step['cachevalue']['step'] == 'dbupdate') {
$dbreturnurl = $_G['siteurl'] . $theurl . '&step=5';
$stepurl = $_G['siteurl'] . 'install/update.php?step=prepare&from=' . rawurlencode($dbreturnurl) . '&frommd5=' . rawurlencode(md5($dbreturnurl . $_G['config']['security']['authkey']));
$msg = '<p style="margin:10px 0;">' . lang('upgrade_continue_db', array('steplang' => $steplang['dbupdate'], 'stepurl' => $stepurl, 'recheckurl' => $recheckurl)) . '</p>';
} else {
$stepurl = $theurl . '&step=' . $upgrade_step['cachevalue']['step'];
$msg = '<p style="margin:10px 0;">' . lang('upgrade_continue', array('steplang' => $steplang[$upgrade_step['cachevalue']['step']], 'stepurl' => $stepurl, 'recheckurl' => $recheckurl)) . '</p>';
}
}
}
} else {
C::t('cache') -> delete('upgrade_step');
}
if (!intval($_GET['checking']) || $msg) {
} else {
$dzz_upgrade -> check_upgrade();
$url = outputurl( $_G['siteurl'].MOD_URL.'&op=systemupgrade&operation=showupgrade' );
dheader('Location: ' . $url);
}
}elseif ($operation == 'showupgrade') {
if ($_G['setting']['upgrade']) {
C::t('cache') -> insert(array('cachekey' => 'upgrade_step', 'cachevalue' => serialize(array('curversion' => $dzz_upgrade -> versionpath())), 'dateline' => $_G['timestamp'], ), false, true);
$upgraderow = $patchrow = array();
$charset = str_replace('-', '', strtoupper($_G['config']['output']['charset']));
$dbversion = helper_dbtool::dbversion();
$locale = '';
if ($charset == 'BIG5') {
$locale = 'TC';
} elseif ($charset == 'GBK') {
$locale = 'SC';
} elseif ($charset == 'UTF8') {
if ($_G['config']['output']['language'] == 'zh-cn' || $_G['config']['output']['language'] == 'zh_cn') {
$locale = 'SC';
} elseif ($_G['config']['output']['language'] == 'zh-tw' || $_G['config']['output']['language'] == 'zh_tw') {
$locale = 'TC';
}else{
$locale = 'SC';
}
}
if (!is_array($_G['setting']['upgrade']))
$_G['setting']['upgrade'] = unserialize($_G['setting']['upgrade']);
$list = array();
foreach ($_G['setting']['upgrade'] as $type => $upgrade) {
$unupgrade = 0;
if (version_compare($upgrade['phpversion'], PHP_VERSION) > 0 || version_compare($upgrade['mysqlversion'], $dbversion) > 0) {
$unupgrade = 1;
}
$list[$type]['linkurl'] = $linkurl = ADMINSCRIPT . '?mod=system&op=systemupgrade&operation=' . $type . '&version=' . $upgrade['latestversion'] . '&locale=' . $locale . '&charset=' . $charset;
if ($unupgrade) {
$list[$type]['title'] = 'oaooa PicHome ' . $upgrade['latestversion'] . '_' . $locale . '_' . $charset;
$list[$type]['btn1'] = lang('founder_upgrade_require_config') . ' php v' . PHP_VERSION . 'MYSQL v' . $dbversion;
} else {
$list[$type]['title'] = 'oaooa PicHome ' . $upgrade['latestversion'] . '_' . $locale . '_' . $charset;
$list[$type]['btn1'] = '<input type="button" class="btn btn-success" onclick="confirm(\'' . lang('founder_upgrade_backup_remind') . '\') ? window.location.href=\'' . $linkurl . '\' : \'\';" value="' . lang('founder_upgrade_automatically') . '">';
$list[$type]['official'] = '<a class="btn btn-link" href="' . $upgrade['official'] . '" target="_blank">' . lang('founder_upgrade_manually') . '</a>';
}
}
} else {
$msg = lang('upgrade_latest_version');
}
}elseif ($operation == 'recheck') {
$upgrade_step = C::t('cache') -> fetch('upgrade_step');
$upgrade_step = dunserialize($upgrade_step['cachevalue']);
$file = DZZ_ROOT . './data/update/pichome' . $upgrade_step['version'] . '/updatelist.tmp';
@unlink($file);
@unlink(DZZ_ROOT . './install/update.php');
C::t('cache') -> delete('upgrade_step');
C::t('cache') -> delete('upgrade_run');
C::t('setting') -> update('upgrade', '');
updatecache('setting');
$old_update_dir = './data/update/';
$dzz_upgrade -> rmdirs(DZZ_ROOT . $old_update_dir);
$url = outputurl($_G['siteurl'].MOD_URL.'&op=systemupgrade' );
dheader('Location: ' . $url);
}
include template('upgrade');
?>

View File

@@ -1,169 +1,186 @@
<?php
$_config = array();
// ---------------------------- CONFIG DB ----------------------------- //
// ---------------------------- 数据库相关设置---------------------------- //
/**
* 数据库主服务器设置, 支持多组服务器设置, 当设置多组服务器时, 则会根据分布式策略使用某个服务器
* @example
* $_config['db']['1']['dbhost'] = 'localhost'; // 服务器地址
* $_config['db']['1']['dbuser'] = 'root'; // 用户
* $_config['db']['1']['dbpw'] = '';// 密码
* $_config['db']['1']['dbcharset'] = 'gbk';// 字符集
* $_config['db']['1']['pconnect'] = '0';// 是否持续连接
* $_config['db']['1']['dbname'] = 'x1';// 数据库
* $_config['db']['1']['tablepre'] = 'pre_';// 表名前缀
*
* $_config['db']['2']['dbhost'] = 'localhost';
* ...
*/
$_config['db'][1]['dbhost'] = 'localhost';//支持三种直接加端口如127.0.0.1:3306或使用UNix socket 如:/tmp/mysql.sock
$_config['db'][1]['dbuser'] = 'root';
$_config['db'][1]['dbpw'] = 'root';
$_config['db'][1]['dbcharset'] = 'utf8';
$_config['db'][1]['pconnect'] = 0;
$_config['db'][1]['dbname'] = 'pichome';
$_config['db'][1]['tablepre'] = 'pichome_';
$_config['db'][1]['port'] = '3306';//mysql端口
$_config['db'][1]['unix_socket'] = '';//使用此方式连接时 dbhost设置为localhost
/**
* 数据库从服务器设置( slave, 只读 ), 支持多组服务器设置, 当设置多组服务器时, 系统根据每次随机使用
* @example
* $_config['db']['1']['slave']['1']['dbhost'] = 'localhost';
* $_config['db']['1']['slave']['1']['dbuser'] = 'root';
* $_config['db']['1']['slave']['1']['dbpw'] = 'root';
* $_config['db']['1']['slave']['1']['dbcharset'] = 'gbk';
* $_config['db']['1']['slave']['1']['pconnect'] = '0';
* $_config['db']['1']['slave']['1']['dbname'] = 'x1';
* $_config['db']['1']['slave']['1']['tablepre'] = 'pre_';
* $_config['db']['1']['slave']['1']['weight'] = '0'; //权重:数据越大权重越高
*
* $_config['db']['1']['slave']['2']['dbhost'] = 'localhost';
* ...
*
*/
$_config['db']['1']['slave'] = array();
//启用从服务器的开关
$_config['db']['slave'] = false;
/**
* 数据库 分布部署策略设置
*
* @example 将 user 部署到第二服务器, session 部署在第三服务器, 则设置为
* $_config['db']['map']['user'] = 2;
* $_config['db']['map']['session'] = 3;
*
* 对于没有明确声明服务器的表, 则一律默认部署在第一服务器上
*
*/
$_config['db']['map'] = array();
/**
* 数据库 公共设置, 此类设置通常对针对每个部署的服务器
*/
$_config['db']['common'] = array();
/**
* 禁用从数据库的数据表, 表名字之间使用逗号分割
*
* @example session, user 这两个表仅从主服务器读写, 不使用从服务器
* $_config['db']['common']['slave_except_table'] = 'session, user';
*
*/
$_config['db']['common']['slave_except_table'] = '';
/**
* 内存服务器优化设置
* 以下设置需要PHP扩展组件支持其中 memcache 优先于其他设置,
* 当 memcache 无法启用时,会自动开启另外的两种优化模式
*/
//内存变量前缀, 可更改,避免同服务器中的程序引用错乱
$_config['memory']['prefix'] = 'oaooa_';
/* reids设置, 需要PHP扩展组件支持, timeout参数的作用没有查证 */
$_config['memory']['redis']['server'] = '';
$_config['memory']['redis']['port'] = 6379;
$_config['memory']['redis']['pconnect'] = 1;
$_config['memory']['redis']['timeout'] = 0;
$_config['memory']['redis']['requirepass'] = '';//如果redis需要密码请填写redis密码
/**
* 是否使用 Redis::SERIALIZER_IGBINARY选项,需要igbinary支持,windows下测试时请关闭否则会出>现错误Reading from client: Connection reset by peer
* 支持以下选项默认使用PHP的serializer
* Redis::SERIALIZER_IGBINARY =2
* Redis::SERIALIZER_PHP =1
* Redis::SERIALIZER_NONE =0 //则不使用serialize,即无法保存array
*/
$_config['memory']['redis']['serializer'] = 1;
$_config['memory']['memcache']['server'] = ''; // memcache 服务器地址
$_config['memory']['memcache']['port'] = 11211; // memcache 服务器端口
$_config['memory']['memcache']['pconnect'] = 1; // memcache 是否长久连接
$_config['memory']['memcache']['timeout'] = 1; // memcache 服务器连接超时
$_config['memory']['memcached']['server'] = '127.0.0.1'; // memcached 服务器地址
$_config['memory']['memcached']['port'] = 11211; // memcached 服务器端口
$_config['memory']['memcached']['pconnect'] = 1; // memcached 是否长久连接
$_config['memory']['memcached']['timeout'] = 1; // memcached 服务器连接超时
$_config['memory']['apc'] = 1; // 启动对 apc 的支持
$_config['memory']['xcache'] = 1; // 启动对 xcache 的支持
$_config['memory']['eaccelerator'] = 0; // 启动对 eaccelerator 的支持
$_config['memory']['wincache'] = 1; // 启动对 wincache 的支持
// 服务器相关设置
$_config['server']['id'] = 1; // 服务器编号多webserver的时候用于标识当前服务器的ID
//计划任务设置
$_config['remote']['on']=0; //1设定计划任务由外部触发0通过用户访问触发
$_config['remote']['cron']=0; //1设定计划任务由外部触发0通过用户访问触发
// CONFIG CACHE
$_config['cache']['type'] = 'sql'; // 缓存类型 file=文件缓存, sql=数据库缓存
// 页面输出设置
$_config['output']['charset'] = 'utf-8'; // 页面字符集
$_config['output']['forceheader'] = 1; // 强制输出页面字符集,用于避免某些环境乱码
$_config['output']['gzip'] = 0; // 是否采用 Gzip 压缩输出
$_config['output']['tplrefresh'] = 1; // 模板自动刷新开关 0=关闭, 1=打开
$_config['output']['language'] = 'zh-CN'; // 页面语言 zh-cn/zh-tw
$_config['output']['language_list']['zh-CN']='简体中文'; // 页面语言 zh-CN/en-US
$_config['output']['language_list']['en-US']='English'; // 页面语言 zh-CN/en-US
$_config['output']['staticurl'] = 'static/'; // 站点静态文件路径,“/”结尾
$_config['output']['ajaxvalidate'] = 0; // 是否严格验证 Ajax 页面的真实性 0=关闭1=打开
$_config['output']['iecompatible'] = 0; // 页面 IE 兼容模式
// COOKIE 设置
$_config['cookie']['cookiepre'] = 'oaooa_'; // COOKIE前缀
$_config['cookie']['cookiedomain'] = ''; // COOKIE作用域
$_config['cookie']['cookiepath'] = '/'; // COOKIE作用路径
// 站点安全设置
$_config['security']['authkey'] = 'oaooa'; // 站点加密密钥
$_config['security']['urlxssdefend'] = true; // 自身 URL XSS 防御
$_config['security']['attackevasive'] = 0; // CC 攻击防御 1|2|4|8
$_config['security']['querysafe']['status'] = 1; // 是否开启SQL安全检测可自动预防SQL注入攻击
$_config['security']['querysafe']['dfunction'] = array('load_file','hex','substring','if','ord','char');
$_config['security']['querysafe']['daction'] = array('@','intooutfile','intodumpfile','unionselect','(select', 'unionall', 'uniondistinct');
$_config['security']['querysafe']['dnote'] = array('/*','*/','#','--','"');
$_config['security']['querysafe']['dlikehex'] = 1;
$_config['security']['querysafe']['afullnote'] = 0;
$_config['admincp']['founder'] = '1'; // 站点创始人:拥有站点管理后台的最高权限,每个站点可以设置 1名或多名创始人
// 可以使用uid也可以使用用户名多个创始人之间请使用逗号“,”分开;
$_config['admincp']['checkip'] = 1; // 后台管理操作是否验证管理员的 IP, 1=是[安全], 0=否。仅在管理员无法登录后台时设置 0。
$_config['admincp']['runquery'] = 0; // 是否允许后台运行 SQL 语句 1=是 0=否[安全]
$_config['admincp']['dbimport'] = 0; // 是否允许后台恢复网站数据 1=是 0=否[安全]
$_config['userlogin']['checkip'] = 1; //用户登录错误验证ip对于同一ip同时使用时建议设置为0,否则当有一位用户登录错误次数超过5次该ip被锁定15分钟导致其他的同IP用户无法登录;
//$_config['system_os'] = 'linux'; //windows,linux,mac,系统会自动判断
//$_config['system_charset']='utf-8'; //操作系统编码不设置系统将根据操作系统类型来判断linux:utf-8;windows:gbk;
return $_config;
<?php
$_config = array();
// ---------------------------- CONFIG DB ----------------------------- //
// ---------------------------- 数据库相关设置---------------------------- //
/**
* 数据库主服务器设置, 支持多组服务器设置, 当设置多组服务器时, 则会根据分布式策略使用某个服务器
* @example
* $_config['db']['1']['dbhost'] = 'localhost'; // 服务器地址
* $_config['db']['1']['dbuser'] = 'root'; // 用户
* $_config['db']['1']['dbpw'] = '';// 密码
* $_config['db']['1']['dbcharset'] = 'gbk';// 字符集
* $_config['db']['1']['pconnect'] = '0';// 是否持续连接
* $_config['db']['1']['dbname'] = 'x1';// 数据库
* $_config['db']['1']['tablepre'] = 'pre_';// 表名前缀
*
* $_config['db']['2']['dbhost'] = 'localhost';
* ...
*/
$_config['db'][1]['dbhost'] = 'localhost';//支持三种直接加端口如127.0.0.1:3306或使用UNix socket 如:/tmp/mysql.sock
$_config['db'][1]['dbuser'] = 'root';
$_config['db'][1]['dbpw'] = 'root';
$_config['db'][1]['dbcharset'] = 'utf8';
$_config['db'][1]['pconnect'] = 0;
$_config['db'][1]['dbname'] = 'pichome';
$_config['db'][1]['tablepre'] = 'pichome_';
$_config['db'][1]['port'] = '3306';//mysql端口
$_config['db'][1]['unix_socket'] = '';//使用此方式连接时 dbhost设置为localhost
/**
* 数据库从服务器设置( slave, 只读 ), 支持多组服务器设置, 当设置多组服务器时, 系统根据每次随机使用
* @example
* $_config['db']['1']['slave']['1']['dbhost'] = 'localhost';
* $_config['db']['1']['slave']['1']['dbuser'] = 'root';
* $_config['db']['1']['slave']['1']['dbpw'] = 'root';
* $_config['db']['1']['slave']['1']['dbcharset'] = 'gbk';
* $_config['db']['1']['slave']['1']['pconnect'] = '0';
* $_config['db']['1']['slave']['1']['dbname'] = 'x1';
* $_config['db']['1']['slave']['1']['tablepre'] = 'pre_';
* $_config['db']['1']['slave']['1']['weight'] = '0'; //权重:数据越大权重越高
*
* $_config['db']['1']['slave']['2']['dbhost'] = 'localhost';
* ...
*
*/
$_config['db']['1']['slave'] = array();
//启用从服务器的开关
$_config['db']['slave'] = false;
/**
* 数据库 分布部署策略设置
*
* @example 将 user 部署到第二服务器, session 部署在第三服务器, 则设置为
* $_config['db']['map']['user'] = 2;
* $_config['db']['map']['session'] = 3;
*
* 对于没有明确声明服务器的表, 则一律默认部署在第一服务器上
*
*/
$_config['db']['map'] = array();
/**
* 数据库 公共设置, 此类设置通常对针对每个部署的服务器
*/
$_config['db']['common'] = array();
/**
* 禁用从数据库的数据表, 表名字之间使用逗号分割
*
* @example session, user 这两个表仅从主服务器读写, 不使用从服务器
* $_config['db']['common']['slave_except_table'] = 'session, user';
*
*/
$_config['db']['common']['slave_except_table'] = '';
/**
* 内存服务器优化设置
* 以下设置需要PHP扩展组件支持其中 memcache 优先于其他设置,
* 当 memcache 无法启用时,会自动开启另外的两种优化模式
*/
//内存变量前缀, 可更改,避免同服务器中的程序引用错乱
$_config['memory']['prefix'] = 'oaooa_';
/* reids设置, 需要PHP扩展组件支持, timeout参数的作用没有查证 */
$_config['memory']['redis']['server'] = '';
$_config['memory']['redis']['port'] = 6379;
$_config['memory']['redis']['pconnect'] = 1;
$_config['memory']['redis']['timeout'] = 0;
$_config['memory']['redis']['requirepass'] = '';//如果redis需要密码请填写redis密码
/**
* 是否使用 Redis::SERIALIZER_IGBINARY选项,需要igbinary支持,windows下测试时请关闭否则会出>现错误Reading from client: Connection reset by peer
* 支持以下选项默认使用PHP的serializer
* Redis::SERIALIZER_IGBINARY =2
* Redis::SERIALIZER_PHP =1
* Redis::SERIALIZER_NONE =0 //则不使用serialize,即无法保存array
*/
$_config['memory']['redis']['serializer'] = 1;
$_config['memory']['memcache']['server'] = ''; // memcache 服务器地址
$_config['memory']['memcache']['port'] = 11211; // memcache 服务器端口
$_config['memory']['memcache']['pconnect'] = 1; // memcache 是否长久连接
$_config['memory']['memcache']['timeout'] = 1; // memcache 服务器连接超时
$_config['memory']['memcached']['server'] = '127.0.0.1'; // memcached 服务器地址
$_config['memory']['memcached']['port'] = 11211; // memcached 服务器端口
$_config['memory']['memcached']['pconnect'] = 1; // memcached 是否长久连接
$_config['memory']['memcached']['timeout'] = 1; // memcached 服务器连接超时
$_config['memory']['apc'] = 1; // 启动对 apc 的支持
$_config['memory']['xcache'] = 1; // 启动对 xcache 的支持
$_config['memory']['eaccelerator'] = 0; // 启动对 eaccelerator 的支持
$_config['memory']['wincache'] = 1; // 启动对 wincache 的支持
// 服务器相关设置
$_config['server']['id'] = 1; // 服务器编号多webserver的时候用于标识当前服务器的ID
//计划任务设置
$_config['remote']['on']=0; //1设定计划任务由外部触发0通过用户访问触发
$_config['remote']['cron']=0; //1设定计划任务由外部触发0通过用户访问触发
// CONFIG CACHE
$_config['cache']['type'] = 'sql'; // 缓存类型 file=文件缓存, sql=数据库缓存
// 页面输出设置
$_config['output']['charset'] = 'utf-8'; // 页面字符集
$_config['output']['forceheader'] = 1; // 强制输出页面字符集,用于避免某些环境乱码
$_config['output']['gzip'] = 0; // 是否采用 Gzip 压缩输出
$_config['output']['tplrefresh'] = 1; // 模板自动刷新开关 0=关闭, 1=打开
$_config['output']['language'] = 'zh-CN'; // 页面语言 zh-cn/zh-tw
$_config['output']['language_list']['zh-CN']='简体中文'; // 页面语言 zh-CN/en-US
$_config['output']['language_list']['en-US']='English'; // 页面语言 zh-CN/en-US
$_config['output']['staticurl'] = 'static/'; // 站点静态文件路径,“/”结尾
$_config['output']['ajaxvalidate'] = 0; // 是否严格验证 Ajax 页面的真实性 0=关闭1=打开
$_config['output']['iecompatible'] = 0; // 页面 IE 兼容模式
// COOKIE 设置
$_config['cookie']['cookiepre'] = 'oaooa_'; // COOKIE前缀
$_config['cookie']['cookiedomain'] = ''; // COOKIE作用域
$_config['cookie']['cookiepath'] = '/'; // COOKIE作用路径
// 站点安全设置
$_config['security']['authkey'] = 'oaooa'; // 站点加密密钥
$_config['security']['urlxssdefend'] = true; // 自身 URL XSS 防御
$_config['security']['attackevasive'] = 0; // CC 攻击防御 1|2|4|8
$_config['security']['querysafe']['status'] = 1; // 是否开启SQL安全检测可自动预防SQL注入攻击
$_config['security']['querysafe']['dfunction'] = array('load_file','hex','substring','if','ord','char');
$_config['security']['querysafe']['daction'] = array('@','intooutfile','intodumpfile','unionselect','(select', 'unionall', 'uniondistinct');
$_config['security']['querysafe']['dnote'] = array('/*','*/','#','--','"');
$_config['security']['querysafe']['dlikehex'] = 1;
$_config['security']['querysafe']['afullnote'] = 0;
$_config['admincp']['founder'] = '1'; // 站点创始人:拥有站点管理后台的最高权限,每个站点可以设置 1名或多名创始人
// 可以使用uid也可以使用用户名多个创始人之间请使用逗号“,”分开;
$_config['admincp']['checkip'] = 1; // 后台管理操作是否验证管理员的 IP, 1=是[安全], 0=否。仅在管理员无法登录后台时设置 0。
$_config['admincp']['runquery'] = 0; // 是否允许后台运行 SQL 语句 1=是 0=否[安全]
$_config['admincp']['dbimport'] = 0; // 是否允许后台恢复网站数据 1=是 0=否[安全]
$_config['userlogin']['checkip'] = 1; //用户登录错误验证ip对于同一ip同时使用时建议设置为0,否则当有一位用户登录错误次数超过5次该ip被锁定15分钟导致其他的同IP用户无法登录;
//$_config['system_os'] = 'linux'; //windows,linux,mac,系统会自动判断
//$_config['system_charset']='utf-8'; //操作系统编码不设置系统将根据操作系统类型来判断linux:utf-8;windows:gbk;
//pichome宽高
$_config['pichomethumbwidth']= 900;
$_config['pichomethumbheight']= 900;
//pichome缩略图颜色允许后缀
$_config['getcolorextlimit'] = ['jpg','png','jpeg','gif','webp','pdf'];
//ffmpeg位置
$_config['pichomeffmpegposition'] = '';
$_config['pichomeffprobposition'] = '';
//支持获取音视频信息的后缀
$_config['pichomeffmpeggetvieoinoext']= [ 'avi', 'rm', 'rmvb', 'mkv', 'mov', 'wmv', 'asf', 'mpg', 'mpe', 'mpeg', 'mp4', 'm4v', 'mpeg', 'f4v', 'vob', 'ogv', 'mts', 'm2ts',
'3gp', 'webm', 'flv', 'wav', 'mp3', 'ogg', 'midi', 'wma', 'vqf', 'ra', 'aac', 'flac', 'ape', 'amr', 'aiff', 'au', 'm4a'];
//支持获取音视频缩略图后缀
$_config['pichomeffmpeggetthumbext']= [ 'avi', 'rm', 'rmvb', 'mkv', 'mov', 'wmv', 'asf', 'mpg', 'mpe', 'mpeg', 'mp4', 'm4v', 'mpeg', 'f4v', 'vob', 'ogv', 'mts', 'm2ts',
'3gp', 'webm', 'flv', 'wav', 'mp3', 'ogg', 'midi', 'wma', 'vqf', 'ra', 'aac', 'flac', 'ape', 'amr', 'aiff', 'au', 'm4a'];
return $_config;

View File

@@ -1,471 +1,472 @@
<?php
/**
* This file is part of the ImagePalette package.
*
* (c) Brian McDonald <brian@brianmcdonald.io>
* (c) gandalfx - https://github.com/gandalfx
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Class ImagePalette
*
* Gets the prominent colors in a given image. To get common color matching, all pixels are matched
* against a white-listed color palette.
*
* @package BrianMcdo\ImagePalette
*/
class ImagePalette implements IteratorAggregate
{
/**
* File or Url
* @var string
*/
protected $file;
/**
* Loaded Image
* @var object
*/
protected $loadedImage;
/**
* Process every Nth pixel
* @var int
*/
protected $precision;
/**
* Width of image
* @var integer
*/
protected $width;
/**
* Height of image
* @var integer
*/
protected $height;
/**
* Number of colors to return
* @var integer
*/
protected $paletteLength;
/**
* Colors Whitelist
* @var array
*/
/* protected $whiteList = array(
0x660000, 0x990000, 0xcc0000, 0xcc3333, 0xea4c88, 0x993399,
0x663399, 0x333399, 0x0066cc, 0x0099cc, 0x66cccc, 0x77cc33,
0x669900, 0x336600, 0x666600, 0x999900, 0xcccc33, 0xffff00,
0xffcc33, 0xff9900, 0xff6600, 0xcc6633, 0x996633, 0x663300,
0x000000, 0x999999, 0xcccccc, 0xffffff, 0xE7D8B1, 0xFDADC7,
0x424153, 0xABBCDA, 0xF5DD01
);*/
protected $whiteList = array(
0x111111,0xFFFFFF,0x9E9E9E,0xA48057,0xFC85B3,0xFF2727,0xFFA34B,0xFFD534,0x47C595,0x51C4C4,0x2B76E7,0x6D50ED
);
protected $whiteList1 = array();
/**
* Colors that were found to be prominent
* Array of Color objects
*
* @var array
*/
protected $palette;
protected $colorNumber;
/**
* Library used
* Supported are GD and Imagick
* @var string
*/
protected $lib;
/**
* Constructor
* @param string $file
* @param int $precision
* @param int $paletteLength
* @param string $library
*/
public function __construct($file, $precision = 10, $paletteLength = 5, $library = 'gd',$whiteList=array())
{
$this->file = $file;
$this->precision = $precision;
$this->paletteLength = $paletteLength;
// use provided libname or auto-detect
$this->lib = $this->graphicsLibrary($library);
// create an array with color ints as keys
$this->whiteList = array_fill_keys($whiteList?$whiteList:$this->whiteList, 0);
$this->whiteList1 = array_fill_keys($whiteList?$whiteList:$this->whiteList, array());
$this->process($this->lib);
}
/**
* Select graphics library to use for processing
*
* @param string $lib
* @return mixed
* @throws \Exception
*/
protected function graphicsLibrary($lib = 'gd')
{
$libraries = [
'gd' => 'GD',
'imagick' => 'Imagick',
//'gmagick' => [false, 'Gmagick']
];
if( ! array_key_exists($lib, $libraries))
{
throw new Exception('This extension specified is not supported.');
}
if( ! extension_loaded($lib))
{
throw new Exception('This extension is not installed');
}
return $libraries[$lib];
}
/**
* Select a graphical library and start generating the Image Palette
* @param string $lib
* @throws \Exception
*/
protected function process($lib)
{
if(!$this->{'setWorkingImage' . $lib} ()) return false;
$this->{'setImagesize' . $lib} ();
$this->readPixels();
$ps=array_keys($this->whiteList);
// sort whiteList
arsort($this->whiteList1);
$total=0;
foreach($this->whiteList as $key => $v){
$total+=intval($v);
}
//print_r($this->whiteList);exit('ddd');
$arr=array();
$arr1=array();
foreach($this->whiteList1 as $key =>$val){
if(!($this->whiteList[$key])) continue;
arsort($val);
$v=array_keys($val);
$arr[$v[0]]=round(($this->whiteList[$key]/$total)*100,2);
$arr1[$v[0]]=array_search($key,$ps);
}
$arr=array_slice($arr,0,$this->paletteLength,true);
$arr1=array_slice($arr1,0,$this->paletteLength,true);
$this->palette=$arr;
$this->colorNumber=$arr1;
// sort whiteList accordingly
// $this->filter($arr);
/*array_map(
function($color) {
return new Color($color);
},
array_keys($arr)
);*/
}
public function getPalette(){
return $this->palette;
}
public function getColorNumber(){
return $this->colorNumber;
}
public function getWhiteList1(){
return $this->whiteList1;
}
public function getWidth(){
return $this->width;
}
public function getHeight(){
return $this->height;
}
/**
* Load and set the working image.
*/
protected function setWorkingImageGD()
{
//$extension = 'jpg';//pathinfo($this->file, PATHINFO_EXTENSION);
$info=@getimagesize($this->file);
switch ($info['mime'])
{
case 'image/png':
$this->loadedImage = imagecreatefrompng($this->file);
break;
case 'image/jpeg':
$this->loadedImage = imagecreatefromjpeg($this->file);
break;
case 'image/gif':
$this->loadedImage = imagecreatefromgif($this->file);
break;
default:
throw new Exception("The file type .$extension is not supported.");
}
return ture;
}
/**
* Load and set working image
*
* @todo needs work
* @return mixed
*/
protected function setWorkingImageImagick()
{
$file = file_get_contents($this->file);
$temp = tempnam("/tmp", uniqid("ImagePalette_", true));
if(!file_put_contents($temp, $file)) return false;
$this->loadedImage = new Imagick($temp);
$this->loadedImage ->thumbnailImage(64,64,true);
return true;
}
/**
* Load and set working image
*
* @todo needs work
* @throws \Exception
* @return mixed
*/
protected function setWorkingImageGmagick()
{
throw new Exception("Gmagick not supported");
}
/**
* Get and set size of the image using GD.
*/
protected function setImageSizeGD()
{
list($this->width, $this->height) = getimagesize($this->file);
}
/**
* Get and set size of image using ImageMagick.
*/
protected function setImageSizeImagick()
{
$d = $this->loadedImage->getImageGeometry();
$this->width = $d['width'];
$this->height = $d['height'];
}
/**
* For each interesting pixel, add its closest color to the loaded colors array
*
* @return mixed
*/
protected function readPixels()
{
// Row
for ($x = 0; $x < $this->width; $x += $this->precision)
{
// Column
for ($y = 0; $y < $this->height; $y += $this->precision)
{
$color = $this->getPixelColor($x, $y);
// transparent pixels don't really have a color
if ($color->isTransparent())
continue 1;
// increment closes whiteList color (key)
$this->whiteList[ $this->getClosestColor($color) ]++;
//$this->whiteList1[$color->toInt()]++;
}
}
}
/**
* Get closest matching color
*
* @param Color $color
* @return int
*/
protected function getClosestColor(Color $color)
{
$cint=$color->toInt();
$bestDiff = PHP_INT_MAX;
// default to black so hhvm won't cry
$bestColor = 0x000000;
$rgbarr=array();
foreach ($this->whiteList as $wlColor => $hits)
{
// calculate difference (don't sqrt)
$diff = $color->getDiff($wlColor);
// see if we got a new best
if ($diff < $bestDiff)
{
$bestDiff = $diff;
$bestColor = $wlColor;
}
}
if(!isset( $this->whiteList1[$bestColor][$cint])) $this->whiteList1[$bestColor][$cint]=1;
else {
$this->whiteList1[$bestColor][$cint]++;
}
return $bestColor;
}
/**
* Returns an array describing the color at x,y
* At index 0 is the color as a whole int (may include alpha)
* At index 1 is the color's red value
* At index 2 is the color's green value
* At index 3 is the color's blue value
*
* @param int $x
* @param int $y
* @return Color
*/
protected function getPixelColor($x, $y)
{
return $this->{'getPixelColor' . $this->lib} ($x, $y);
}
/**
* Using to retrieve color information about a specified pixel
*
* @see getPixelColor()
* @param int $x
* @param int $y
* @return Color
*/
protected function getPixelColorGD($x, $y)
{
$color = imagecolorat($this->loadedImage, $x, $y);
return new Color (
$color
// $rgb['red'],
// $rgb['green'],
// $rgb['blue']
);
}
/**
* Using to retrieve color information about a specified pixel
*
* @see getPixelColor()
* @param int $x
* @param int $y
* @return Color
*/
protected function getPixelColorImagick($x, $y)
{
$rgb = $this->loadedImage->getImagePixelColor($x, $y)->getColor();
foreach($rgb as $k => $v){
if($v<0) $v=0;
$rgb[$k]=$v;
}
return new Color([
$rgb['r'],
$rgb['g'],
$rgb['b'],
]);
}
protected function getPixelColorGmagick($x, $y)
{
throw new Exception("Gmagick not supported: ($x, $y)");
}
/**
* Returns an array of Color objects
*
* @param int $paletteLength
* @return array
*/
public function getColors($paletteLength = null)
{
// allow custom length calls
if ( ! is_numeric($paletteLength))
{
$paletteLength = $this->paletteLength;
}
// take the best hits
return array_slice($this->palette, 0, $paletteLength, true);
}
/**
* Returns a json encoded version of the palette
*
* @return string
*/
public function __toString()
{
// Color PHP 5.3 compatible -> not JsonSerializable :(
return json_encode(array_map(
function($color) {
return (string) $color;
},
$this->getColors()
));
}
/**
* Convenient getter access as properties
*
* @param $name
* @throws \Exception
* @return mixed
*/
public function __get($name)
{
$method = 'get' . ucfirst($name);
if (method_exists($this, $method))
{
return $this->$method();
}
throw new Exception("Method $method does not exist");
}
/**
* Returns the palette for implementation of the IteratorAggregate interface
* Used in foreach loops
*
* @see getColors()
* @return \ArrayIterator
*/
public function getIterator()
{
return new ArrayIterator($this->getColors());
}
}
<?php
/**
* This file is part of the ImagePalette package.
*
* (c) Brian McDonald <brian@brianmcdonald.io>
* (c) gandalfx - https://github.com/gandalfx
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Class ImagePalette
*
* Gets the prominent colors in a given image. To get common color matching, all pixels are matched
* against a white-listed color palette.
*
* @package BrianMcdo\ImagePalette
*/
class ImagePalette implements IteratorAggregate
{
/**
* File or Url
* @var string
*/
protected $file;
/**
* Loaded Image
* @var object
*/
protected $loadedImage;
/**
* Process every Nth pixel
* @var int
*/
protected $precision;
/**
* Width of image
* @var integer
*/
protected $width;
/**
* Height of image
* @var integer
*/
protected $height;
/**
* Number of colors to return
* @var integer
*/
protected $paletteLength;
/**
* Colors Whitelist
* @var array
*/
/* protected $whiteList = array(
0x660000, 0x990000, 0xcc0000, 0xcc3333, 0xea4c88, 0x993399,
0x663399, 0x333399, 0x0066cc, 0x0099cc, 0x66cccc, 0x77cc33,
0x669900, 0x336600, 0x666600, 0x999900, 0xcccc33, 0xffff00,
0xffcc33, 0xff9900, 0xff6600, 0xcc6633, 0x996633, 0x663300,
0x000000, 0x999999, 0xcccccc, 0xffffff, 0xE7D8B1, 0xFDADC7,
0x424153, 0xABBCDA, 0xF5DD01
);*/
protected $whiteList = array(
0x111111,0xFFFFFF,0x9E9E9E,0xA48057,0xFC85B3,0xFF2727,0xFFA34B,0xFFD534,0x47C595,0x51C4C4,0x2B76E7,0x6D50ED
);
protected $whiteList1 = array();
/**
* Colors that were found to be prominent
* Array of Color objects
*
* @var array
*/
protected $palette;
protected $colorNumber;
/**
* Library used
* Supported are GD and Imagick
* @var string
*/
protected $lib;
/**
* Constructor
* @param string $file
* @param int $precision
* @param int $paletteLength
* @param string $library
*/
public function __construct($file, $precision = 10, $paletteLength = 5, $library = 'gd',$whiteList=array())
{
$this->file = $file;
$this->precision = $precision;
$this->paletteLength = $paletteLength;
// use provided libname or auto-detect
$this->lib = $this->graphicsLibrary($library);
// create an array with color ints as keys
$this->whiteList = array_fill_keys($whiteList?$whiteList:$this->whiteList, 0);
$this->whiteList1 = array_fill_keys($whiteList?$whiteList:$this->whiteList, array());
$this->process($this->lib);
}
/**
* Select graphics library to use for processing
*
* @param string $lib
* @return mixed
* @throws \Exception
*/
protected function graphicsLibrary($lib = 'gd')
{
$libraries = [
'gd' => 'GD',
'imagick' => 'Imagick',
//'gmagick' => [false, 'Gmagick']
];
if( ! array_key_exists($lib, $libraries))
{
throw new Exception('This extension specified is not supported.');
}
if( ! extension_loaded($lib))
{
throw new Exception('This extension is not installed');
}
return $libraries[$lib];
}
/**
* Select a graphical library and start generating the Image Palette
* @param string $lib
* @throws \Exception
*/
protected function process($lib)
{
if(!$this->{'setWorkingImage' . $lib} ()) return false;
$this->{'setImagesize' . $lib} ();
$this->readPixels();
$ps=array_keys($this->whiteList);
// sort whiteList
arsort($this->whiteList1);
$total=0;
foreach($this->whiteList as $key => $v){
$total+=intval($v);
}
//print_r($this->whiteList);exit('ddd');
$arr=array();
$arr1=array();
foreach($this->whiteList1 as $key =>$val){
if(!($this->whiteList[$key])) continue;
arsort($val);
$v=array_keys($val);
$arr[$v[0]]=round(($this->whiteList[$key]/$total)*100,2);
$arr1[$v[0]]=array_search($key,$ps);
}
$arr=array_slice($arr,0,$this->paletteLength,true);
$arr1=array_slice($arr1,0,$this->paletteLength,true);
$this->palette=$arr;
$this->colorNumber=$arr1;
// sort whiteList accordingly
// $this->filter($arr);
/*array_map(
function($color) {
return new Color($color);
},
array_keys($arr)
);*/
}
public function getPalette(){
return $this->palette;
}
public function getColorNumber(){
return $this->colorNumber;
}
public function getWhiteList1(){
return $this->whiteList1;
}
public function getWidth(){
return $this->width;
}
public function getHeight(){
return $this->height;
}
/**
* Load and set the working image.
*/
protected function setWorkingImageGD()
{
//$extension = 'jpg';//pathinfo($this->file, PATHINFO_EXTENSION);
$info=@getimagesize($this->file);
switch ($info['mime'])
{
case 'image/png':
$this->loadedImage = imagecreatefrompng($this->file);
break;
case 'image/jpeg':
$this->loadedImage = imagecreatefromjpeg($this->file);
break;
case 'image/gif':
$this->loadedImage = imagecreatefromgif($this->file);
break;
default:
throw new Exception("The file type .$extension is not supported.");
}
return ture;
}
/**
* Load and set working image
*
* @todo needs work
* @return mixed
*/
protected function setWorkingImageImagick()
{
$file = file_get_contents($this->file);
$temp = tempnam(DZZ_ROOT.'./data/attachment/cache', uniqid("ImagePalette_", true));
if(!file_put_contents($temp, $file)) return false;
$this->loadedImage = new Imagick($temp);
$this->loadedImage ->thumbnailImage(64,64,true);
@unlink($temp);
return true;
}
/**
* Load and set working image
*
* @todo needs work
* @throws \Exception
* @return mixed
*/
protected function setWorkingImageGmagick()
{
throw new Exception("Gmagick not supported");
}
/**
* Get and set size of the image using GD.
*/
protected function setImageSizeGD()
{
list($this->width, $this->height) = getimagesize($this->file);
}
/**
* Get and set size of image using ImageMagick.
*/
protected function setImageSizeImagick()
{
$d = $this->loadedImage->getImageGeometry();
$this->width = $d['width'];
$this->height = $d['height'];
}
/**
* For each interesting pixel, add its closest color to the loaded colors array
*
* @return mixed
*/
protected function readPixels()
{
// Row
for ($x = 0; $x < $this->width; $x += $this->precision)
{
// Column
for ($y = 0; $y < $this->height; $y += $this->precision)
{
$color = $this->getPixelColor($x, $y);
// transparent pixels don't really have a color
if ($color->isTransparent())
continue 1;
// increment closes whiteList color (key)
$this->whiteList[ $this->getClosestColor($color) ]++;
//$this->whiteList1[$color->toInt()]++;
}
}
}
/**
* Get closest matching color
*
* @param Color $color
* @return int
*/
protected function getClosestColor(Color $color)
{
$cint=$color->toInt();
$bestDiff = PHP_INT_MAX;
// default to black so hhvm won't cry
$bestColor = 0x000000;
$rgbarr=array();
foreach ($this->whiteList as $wlColor => $hits)
{
// calculate difference (don't sqrt)
$diff = $color->getDiff($wlColor);
// see if we got a new best
if ($diff < $bestDiff)
{
$bestDiff = $diff;
$bestColor = $wlColor;
}
}
if(!isset( $this->whiteList1[$bestColor][$cint])) $this->whiteList1[$bestColor][$cint]=1;
else {
$this->whiteList1[$bestColor][$cint]++;
}
return $bestColor;
}
/**
* Returns an array describing the color at x,y
* At index 0 is the color as a whole int (may include alpha)
* At index 1 is the color's red value
* At index 2 is the color's green value
* At index 3 is the color's blue value
*
* @param int $x
* @param int $y
* @return Color
*/
protected function getPixelColor($x, $y)
{
return $this->{'getPixelColor' . $this->lib} ($x, $y);
}
/**
* Using to retrieve color information about a specified pixel
*
* @see getPixelColor()
* @param int $x
* @param int $y
* @return Color
*/
protected function getPixelColorGD($x, $y)
{
$color = imagecolorat($this->loadedImage, $x, $y);
return new Color (
$color
// $rgb['red'],
// $rgb['green'],
// $rgb['blue']
);
}
/**
* Using to retrieve color information about a specified pixel
*
* @see getPixelColor()
* @param int $x
* @param int $y
* @return Color
*/
protected function getPixelColorImagick($x, $y)
{
$rgb = $this->loadedImage->getImagePixelColor($x, $y)->getColor();
foreach($rgb as $k => $v){
if($v<0) $v=0;
$rgb[$k]=$v;
}
return new Color([
$rgb['r'],
$rgb['g'],
$rgb['b'],
]);
}
protected function getPixelColorGmagick($x, $y)
{
throw new Exception("Gmagick not supported: ($x, $y)");
}
/**
* Returns an array of Color objects
*
* @param int $paletteLength
* @return array
*/
public function getColors($paletteLength = null)
{
// allow custom length calls
if ( ! is_numeric($paletteLength))
{
$paletteLength = $this->paletteLength;
}
// take the best hits
return array_slice($this->palette, 0, $paletteLength, true);
}
/**
* Returns a json encoded version of the palette
*
* @return string
*/
public function __toString()
{
// Color PHP 5.3 compatible -> not JsonSerializable :(
return json_encode(array_map(
function($color) {
return (string) $color;
},
$this->getColors()
));
}
/**
* Convenient getter access as properties
*
* @param $name
* @throws \Exception
* @return mixed
*/
public function __get($name)
{
$method = 'get' . ucfirst($name);
if (method_exists($this, $method))
{
return $this->$method();
}
throw new Exception("Method $method does not exist");
}
/**
* Returns the palette for implementation of the IteratorAggregate interface
* Used in foreach loops
*
* @see getColors()
* @return \ArrayIterator
*/
public function getIterator()
{
return new ArrayIterator($this->getColors());
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,168 +1,182 @@
<?php
/*
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
* @license https://www.oaooa.com/licenses/
*
* @link https://www.oaooa.com
* @author zyx(zyx@oaooa.com)
*/
if (!defined('IN_OAOOA')) {
exit('Access Denied');
}
class dzz_io
{
protected function initIO($path)
{
$path = self::clean($path);
$bzarr = explode(':', $path);
$allowbz = C::t('connect')->fetch_all_bz();//array('baiduPCS','ALIOSS','dzz','JSS','disk');
if (strpos($path, 'dzz::') !== false) {
$classname = 'io_dzz';
} elseif (strpos($path, 'attach::') !== false) {
$classname = 'io_dzz';
} elseif (strpos($path, 'TMP::') !== false) {
$classname = 'io_dzz';
} elseif (is_numeric($bzarr[0])) {
$classname = 'io_dzz';
} elseif (in_array($bzarr[0], $allowbz)) {
$classname = 'io_' . $bzarr[0];
} elseif (preg_match('/^\w{32}$/i', $path)) {
$classname = 'io_dzz';
} else {
return false;
}
return new $classname($path);
}
function MoveToSpace($path, $attach, $ondup = 'overwrite')
{
$path = self::clean($path);
if ($io = self::initIO($path)) {
return $io->MoveToSpace($path, $attach, $ondup);
} else {
return false;
}
}
function authorize($bz, $refer = '')
{
if ($io = self::initIO($bz)) {
$io->authorize($refer);
}
}
function getQuota($bz)
{
if ($io = self::initIO($bz)) {
return $io->getQuota($bz);
} else {
return false;
}
}
function chmod($path, $chmod, $son = 0)
{
if ($io = self::initIO($path)) {
return $io->chmod($path, $chmod, $son);
} else {
return false;
}
}
function parsePath($path)
{
$path = self::clean($path);
if ($io = self::initIO($path)) {
return $io->parsePath($path);
} else {
return false;
}
}
function output_thumb($file, $mine = 'image/JPEG')
{//根据文件地址,输出图像流
global $_G;
$last_modified_time = filemtime($file);
if ($last_modified_time) {
$etag = md5_file($file);
header("Last-Modified: " . gmdate("D, d M Y H:i:s", $last_modified_time) . " GMT");
header("Etag: $etag");
if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $last_modified_time ||
trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag
) {
header("HTTP/1.1 304 Not Modified");
exit;
}
}
/*if(!$last_modified_time) $last_modified_time = TIMESTAMP;*/
@header('cache-control:public');
header('Content-Type: ' . $mine);
@ob_end_clean();
if (getglobal('gzipcompress')) @ob_start('ob_gzhandler');
@readfile($file);
@flush();
@ob_flush();
exit();
}
/*将文件缓存到本地,并且返回本地的访问地址*/
function cacheFile($data)
{
global $_G;
$subdir = $subdir1 = $subdir2 = '';
$subdir1 = date('Ym');
$subdir2 = date('d');
$subdir = $subdir1 . '/' . $subdir2 . '/';
$target1 = 'dzzcache/' . $subdir . 'index.html';
$target = 'dzzcache/' . $subdir . random(10);
$target_attach = $_G['setting']['attachdir'] . $target1;
$targetpath = dirname($target_attach);
dmkdir($targetpath);
if (file_put_contents($target, $data)) {
return $target;
} else {
return false;
}
}
public function clean($str) {//清除路径
if(is_array($str)){
foreach($str as $key=> $value){
$str[$key]=self::clean_path(str_replace(array( "\n", "\r", '../'), '', $value));
}
}else{
$str= self::clean_path(str_replace(array( "\n", "\r", '../'), '', $str));
}
return $str;
}
private function clean_path($str){
if(preg_match("/\.\.\//",$str)){
$str=str_replace('../','',$str);
return self::clean_path($str);
}else{
return $str;
}
}
public function getApps($path){
$path = self::clean($path);
if ($io = self::initIO($path)) {
$return = $io->getApps($path);
return $return;
} else return false;
}
public function getAllFiles($path,$fid){
$path = self::clean($path);
if ($io = self::initIO($path)) {
$return = $io->getAllFiles($path,$fid);
return $return;
} else return false;
}
}
<?php
/*
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
* @license https://www.oaooa.com/licenses/
*
* @link https://www.oaooa.com
* @author zyx(zyx@oaooa.com)
*/
if (!defined('IN_OAOOA')) {
exit('Access Denied');
}
class dzz_io
{
protected function initIO($path)
{
$path = self::clean($path);
$bzarr = explode(':', $path);
$allowbz = C::t('connect')->fetch_all_bz();//array('baiduPCS','ALIOSS','dzz','JSS','disk');
if (strpos($path, 'dzz::') !== false) {
$classname = 'io_dzz';
} elseif (strpos($path, 'attach::') !== false) {
$classname = 'io_dzz';
} elseif (strpos($path, 'TMP::') !== false) {
$classname = 'io_dzz';
} elseif (is_numeric($bzarr[0])) {
$classname = 'io_dzz';
} elseif (in_array($bzarr[0], $allowbz)) {
$classname = 'io_' . $bzarr[0];
} elseif (preg_match('/^\w{32}$/i', $path)) {
$classname = 'io_dzz';
} else {
return false;
}
return new $classname($path);
}
function MoveToSpace($path, $attach, $ondup = 'overwrite')
{
$path = self::clean($path);
if ($io = self::initIO($path)) {
return $io->MoveToSpace($path, $attach, $ondup);
} else {
return false;
}
}
function authorize($bz, $refer = '')
{
if ($io = self::initIO($bz)) {
$io->authorize($refer);
}
}
function getQuota($bz)
{
if ($io = self::initIO($bz)) {
return $io->getQuota($bz);
} else {
return false;
}
}
function chmod($path, $chmod, $son = 0)
{
if ($io = self::initIO($path)) {
return $io->chmod($path, $chmod, $son);
} else {
return false;
}
}
function parsePath($path)
{
$path = self::clean($path);
if ($io = self::initIO($path)) {
return $io->parsePath($path);
} else {
return false;
}
}
function output_thumb($file, $mine = 'image/JPEG')
{//根据文件地址,输出图像流
global $_G;
$last_modified_time = filemtime($file);
if ($last_modified_time) {
$etag = md5_file($file);
header("Last-Modified: " . gmdate("D, d M Y H:i:s", $last_modified_time) . " GMT");
header("Etag: $etag");
if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $last_modified_time ||
trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag
) {
header("HTTP/1.1 304 Not Modified");
exit;
}
}
/*if(!$last_modified_time) $last_modified_time = TIMESTAMP;*/
@header('cache-control:public');
header('Content-Type: ' . $mine);
@ob_end_clean();
if (getglobal('gzipcompress')) @ob_start('ob_gzhandler');
@readfile($file);
@flush();
@ob_flush();
exit();
}
/*将文件缓存到本地,并且返回本地的访问地址*/
function cacheFile($data)
{
global $_G;
$subdir = $subdir1 = $subdir2 = '';
$subdir1 = date('Ym');
$subdir2 = date('d');
$subdir = $subdir1 . '/' . $subdir2 . '/';
$target1 = 'dzzcache/' . $subdir . 'index.html';
$target = 'dzzcache/' . $subdir . random(10);
$target_attach = $_G['setting']['attachdir'] . $target1;
$targetpath = dirname($target_attach);
dmkdir($targetpath);
if (file_put_contents($target, $data)) {
return $target;
} else {
return false;
}
}
public function clean($str) {//清除路径
if(is_array($str)){
foreach($str as $key=> $value){
$str[$key]=self::clean_path(str_replace(array( "\n", "\r", '../'), '', $value));
}
}else{
$str= self::clean_path(str_replace(array( "\n", "\r", '../'), '', $str));
}
return $str;
}
private function clean_path($str){
if(preg_match("/\.\.\//",$str)){
$str=str_replace('../','',$str);
return self::clean_path($str);
}else{
return $str;
}
}
public function getApps($path){
$path = self::clean($path);
if ($io = self::initIO($path)) {
$return = $io->getApps($path);
return $return;
} else return false;
}
public function getAllFiles($path,$fid,$page=1,$limit=100){
$path = self::clean($path);
if ($io = self::initIO($path)) {
$return = $io->getAllFiles($path,$fid,$page,$limit);
return $return;
} else return false;
}
public function getAlltag($path){
$path = self::clean($path);
if ($io = self::initIO($path)) {
$return = $io->getAlltag($path);
return $return;
} else return false;
}
public function getAlltaggroup($path){
$path = self::clean($path);
if ($io = self::initIO($path)) {
$return = $io->getAlltaggroup($path);
return $return;
} else return false;
}
}

View File

@@ -0,0 +1,77 @@
<?php
/*
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
* @license https://www.oaooa.com/licenses/
*
* @link https://www.oaooa.com
* @author zyx(zyx@oaooa.com)
*/
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
//所有用户应用
//uid=0 的表示为默认应用
class table_connect extends dzz_table
{
public function __construct() {
$this->_table = 'connect';
$this->_pk = 'bz';
$this->_pre_cache_key = 'connect_';
$this->_cache_ttl = 60*60;
parent::__construct();
}
public function fetch_all_by_available($onlyuser=false){
$data=array();
if($onlyuser) $available=1;
else $available=0;
$query=DB::query("SELECT * FROM ".DB::table($this->_table)." WHERE available > '{$available}' and type!='local' ORDER BY disp");
while($value=DB::fetch($query)){
//检测可用性
if($value['type']=='pan' && (empty($value['key']) || empty($value['secret']))){
$value['available']=0;
$value['warning']=lang('please_open_after_setting');
continue;
}
if(!is_file(DZZ_ROOT.'./core/class/io/io_'.($value['bz']).'.php')){
$value['available']=0;
$value['warning']='api'.lang('typename_attach').'io_'.($value['bz']).'.php'.lang('inexistence').'';
continue;
}
$data[$value['bz']]=$value;
}
return $data;
}
public function fetch_all_folderdata($uid){
$data=self::fetch_all_by_available();
$folderdata=array();
foreach($data as $value){
foreach(DB::fetch_all("select id from ".DB::table($value['dname'])." where uid>0 && uid='{$uid}'") as $value1){
$arr=C::t($value['dname'])->fetch_by_id($value1['id']);
$folderdata[$arr['fid']]=$arr;
}
}
return $folderdata;
}
public function fetch_all_bz(){
$data=array();
foreach(DB::fetch_all("select bz from %t where 1",array($this->_table)) as $value){
$data[]=$value['bz'];
}
return $data;
}
public function delete_by_bz($bz){
if($bz=='dzz') return false; //dzz是内置不能删除
$data=self::fetch($bz);
if(is_file(DZZ_ROOT.'./core/class/table/table_'.$data['dname'].'.php')){
C::t($data['dname'])->delete_by_bz($bz);
}
return self::delete($bz);
}
}
?>

View File

@@ -0,0 +1,82 @@
<?php
/*
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
* @license https://www.oaooa.com/licenses/
*
* @link https://www.oaooa.com
* @author zyx(zyx@oaooa.com)
*/
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
//所有用户应用
//uid=0 的表示为默认应用
class table_connect_disk extends dzz_table
{
public function __construct() {
$this->_table = 'connect_disk';
$this->_pk = 'id';
$this->_pre_cache_key = 'connect_disk_';
$this->_cache_ttl = 300;
parent::__construct();
}
public function fetch_by_id($id){
$value=parent::fetch($id);
$cloud=DB::fetch_first("select * from ".DB::table('connect')." where bz='{$value['bz']}'");
$data=array(
'id'=>$value['id'],
'fid'=>md5($cloud['bz'].':'.$value['id'].':'.$cloud['root']),
'pfid'=>0,
'fname'=>$value['cloudname'],
'ficon'=>'dzz/images/default/system/'.$cloud['bz'].'.png',
'bz'=>$cloud['bz'].':'.$value['id'].':',
'path'=>$cloud['bz'].':'.$value['id'].':'.$cloud['root'],
'type'=>'disk',
'fsperm'=>perm_FolderSPerm::flagPower($cloud['bz']),
'perm'=>perm_binPerm::getGroupPower('all'),
'flag'=>$cloud['bz'],
'iconview'=>1,
'disp'=>'0',
);
return $data;
}
public function fetch_all_by_id($ids){
$data=array();
foreach($ids as $id){
$value=self::fetch_by_id($id);
$data[$value['fid']]=$value;
}
return $data;
}
public function delete_by_id($id){
$return=array();
$data=parent::fetch($id);
if(parent::delete($id)){
$return['msg']='success';
//C::t('source_shortcut')->delete_by_bz($data['bz'].':'.$id.':',true);//删除快捷方式;
//删除图片缓存文件
$imgcache=getglobal('setting/attachdir').'./imgcache/'.$data['bz'].'/'.$id.'/';
removedirectory($imgcache);
}
return $return;
}
public function delete_by_uid($uid){
if(!$uid) return 0;
foreach(DB::fetch_all("select id from %t where uid=%d",array($this->_table,$uid)) as $value){
self::delete_by_id($value['id']);
}
return true;
}
public function delete_by_bz($bz){
foreach(DB::fetch_all("select id from %t where bz=%s",array($this->_table,$bz)) as $value){
self::delete_by_id($value['id']);
}
}
}
?>

View File

@@ -0,0 +1,82 @@
<?php
/*
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
* @license https://www.oaooa.com/licenses/
*
* @link https://www.oaooa.com
* @author zyx(zyx@oaooa.com)
*/
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
//所有用户应用
//uid=0 的表示为默认应用
class table_connect_ftp extends dzz_table
{
public function __construct() {
$this->_table = 'connect_ftp';
$this->_pk = 'id';
$this->_pre_cache_key = 'connect_ftp_';
$this->_cache_ttl = 300;
parent::__construct();
}
public function fetch_by_id($id){
$value=self::fetch($id);
$cloud=DB::fetch_first("select * from ".DB::table('connect')." where bz='{$value['bz']}'");
$data=array(
'id'=>$value['id'],
'fid'=>md5($cloud['bz'].':'.$value['id'].':'.$cloud['root']),
'pfid'=>0,
'fname'=>$value['cloudname'],
'ficon'=>'dzz/images/default/system/'.$cloud['bz'].'.png',
'bz'=>$cloud['bz'].':'.$value['id'].':',
'path'=>$cloud['bz'].':'.$value['id'].':'.$cloud['root'],
'type'=>'ftp',
'fsperm'=>perm_FolderSPerm::flagPower($cloud['bz']),
'perm'=>perm_binPerm::getGroupPower('all'),
'flag'=>$cloud['bz'],
'iconview'=>1,
'disp'=>'0',
);
return $data;
}
public function fetch_all_by_id($ids){
$data=array();
foreach($ids as $id){
$value=self::fetch_by_id($id);
$data[$value['fid']]=$value;
}
return $data;
}
public function delete_by_id($id){
$return=array();
$data=parent::fetch($id);
if(parent::delete($id)){
$return['msg']='success';
//C::t('source_shortcut')->delete_by_bz($data['bz'].':'.$id.':',true);//删除快捷方式;
//删除图片缓存文件
$imgcache=getglobal('setting/attachdir').'./imgcache/'.$data['bz'].'/'.$id.'/';
removedirectory($imgcache);
}
return $return;
}
public function delete_by_uid($uid){
if(!$uid) return 0;
foreach(DB::fetch_all("select id from %t where uid=%d",array($this->_table,$uid)) as $value){
self::delete_by_id($value['id']);
}
return true;
}
public function delete_by_bz($bz){
foreach(DB::fetch_all("select id from %t where bz=%s",array($this->_table,$bz)) as $value){
self::delete_by_id($value['id']);
}
}
}
?>

View File

@@ -0,0 +1,83 @@
<?php
/*
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
* @license https://www.oaooa.com/licenses/
*
* @link https://www.oaooa.com
* @author zyx(zyx@oaooa.com)
*/
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
//所有用户应用
//uid=0 的表示为默认应用
class table_connect_onedrive extends dzz_table
{
public function __construct() {
$this->_table = 'connect_onedrive';
$this->_pk = 'id';
$this->_pre_cache_key = 'connect_onedrive_';
$this->_cache_ttl = 300;
parent::__construct();
}
public function fetch_by_id($id){
$value=self::fetch($id);
$cloud=DB::fetch_first("select * from ".DB::table('connect')." where bz='{$value['bz']}'");
if(!$value['cloudname']) $value['cloudname']=$cloud['name'].':'.($value['cusername']?$value['cusername']:$cloud['cuid']);
$data=array(
'id'=>$value['id'],
'fid'=>md5($cloud['bz'].':'.$value['id'].':'.$cloud['root']),
'pfid'=>0,
'fname'=>$value['cloudname'],
'ficon'=>'dzz/images/default/system/'.$cloud['bz'].'.png',
'bz'=>$cloud['bz'].':'.$value['id'].':',
'path'=>$cloud['bz'].':'.$value['id'].':'.$cloud['root'],
'type'=>'pan',
'fsperm'=>perm_FolderSPerm::flagPower($cloud['bz']),
'perm'=>perm_binPerm::getGroupPower('all'),
'flag'=>$cloud['bz'],
'iconview'=>1,
'disp'=>'0',
);
return $data;
}
public function fetch_all_by_id($ids){
$data=array();
foreach($ids as $id){
$value=self::fetch_by_id($id);
$data[$value['fid']]=$value;
}
return $data;
}
public function delete_by_id($id){
$return=array();
$data=parent::fetch($id);
if(parent::delete($id)){
$return['msg']='success';
//C::t('source_shortcut')->delete_by_bz($data['bz'].':'.$id.':',true);//删除快捷方式;
//删除图片缓存文件
$imgcache=getglobal('setting/attachdir').'./imgcache/'.$data['bz'].'/'.$id.'/';
removedirectory($imgcache);
}
return $return;
}
public function delete_by_uid($uid){
if(!$uid) return 0;
foreach(DB::fetch_all("select id from %t where uid=%d",array($this->_table,$uid)) as $value){
self::delete_by_id($value['id']);
}
return true;
}
public function delete_by_bz($bz){
foreach(DB::fetch_all("select id from %t where bz=%s",array($this->_table,$bz)) as $value){
self::delete_by_id($value['id']);
}
}
}
?>

View File

@@ -0,0 +1,83 @@
<?php
/*
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
* @license https://www.oaooa.com/licenses/
*
* @link https://www.oaooa.com
* @author zyx(zyx@oaooa.com)
*/
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
//所有用户应用
//uid=0 的表示为默认应用
class table_connect_pan extends dzz_table
{
public function __construct() {
$this->_table = 'connect_pan';
$this->_pk = 'id';
$this->_pre_cache_key = 'connect_pan_';
$this->_cache_ttl = 300;
parent::__construct();
}
public function fetch_by_id($id){
$value=self::fetch($id);
$cloud=DB::fetch_first("select * from ".DB::table('connect')." where bz='{$value['bz']}'");
if(!$value['cloudname']) $value['cloudname']=$cloud['name'].':'.($value['cusername']?$value['cusername']:$cloud['cuid']);
$data=array(
'id'=>$value['id'],
'fid'=>md5($cloud['bz'].':'.$value['id'].':'.$cloud['root']),
'pfid'=>0,
'fname'=>$value['cloudname'],
'ficon'=>'dzz/images/default/system/'.$cloud['bz'].'.png',
'bz'=>$cloud['bz'].':'.$value['id'].':',
'path'=>$cloud['bz'].':'.$value['id'].':'.$cloud['root'],
'type'=>'pan',
'fsperm'=>perm_FolderSPerm::flagPower($cloud['bz']),
'perm'=>perm_binPerm::getGroupPower('all'),
'flag'=>$cloud['bz'],
'iconview'=>1,
'disp'=>'0',
);
return $data;
}
public function fetch_all_by_id($ids){
$data=array();
foreach($ids as $id){
$value=self::fetch_by_id($id);
$data[$value['fid']]=$value;
}
return $data;
}
public function delete_by_id($id){
$return=array();
$data=parent::fetch($id);
if(parent::delete($id)){
$return['msg']='success';
//C::t('source_shortcut')->delete_by_bz($data['bz'].':'.$id.':',true);//删除快捷方式;
//删除图片缓存文件
$imgcache=getglobal('setting/attachdir').'./imgcache/'.$data['bz'].'/'.$id.'/';
removedirectory($imgcache);
}
return $return;
}
public function delete_by_uid($uid){
if(!$uid) return 0;
foreach(DB::fetch_all("select id from %t where uid=%d",array($this->_table,$uid)) as $value){
self::delete_by_id($value['id']);
}
return true;
}
public function delete_by_bz($bz){
foreach(DB::fetch_all("select id from %t where bz=%s",array($this->_table,$bz)) as $value){
self::delete_by_id($value['id']);
}
}
}
?>

View File

@@ -0,0 +1,84 @@
<?php
/*
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
* @license https://www.oaooa.com/licenses/
*
* @link https://www.oaooa.com
* @author zyx(zyx@oaooa.com)
*/
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
//所有用户应用
//uid=0 的表示为默认应用
class table_connect_storage extends dzz_table
{
public function __construct() {
$this->_table = 'connect_storage';
$this->_pk = 'id';
/*$this->_pre_cache_key = 'connect_storage_';
$this->_cache_ttl = 0;*/
parent::__construct();
}
public function fetch_by_id($id){
$value=self::fetch($id);
$cloud=DB::fetch_first("select * from ".DB::table('connect')." where bz='{$value['bz']}'");
$value['access_id']=authcode($value['access_id'],'DECODE',$value['bz'])?authcode($value['access_id'],'DECODE',$value['bz']):$value['access_id'];
if(!$value['cloudname']) $value['cloudname']=$cloud['name'].':'.($value['bucket']?$value['bucket']:cutstr($value['access_id'], 4, ''));
if($value['bucket']) $value['bucket'].='/';
$data=array(
'id'=>$value['id'],
'fid'=>md5($cloud['bz'].':'.$value['id'].':'.$value['bucket']),
'pfid'=>0,
'fname'=>$value['cloudname'],
'ficon'=>'dzz/images/default/system/'.$cloud['bz'].'.png',
'bz'=>$cloud['bz'].':'.$value['id'].':',
'path'=>$cloud['bz'].':'.$value['id'].':'.$value['bucket'],
'type'=>'storage',
'fsperm'=>$value['bucket']?'0':perm_FolderSPerm::flagPower($cloud['bz'].'_root'),
'perm'=>perm_binPerm::getGroupPower('all'),
'flag'=>$cloud['bz'],
'iconview'=>1,
'disp'=>'0',
);
return $data;
}
public function fetch_all_by_id($ids){
$data=array();
foreach($ids as $id){
if($value=self::fetch_by_id($id)) $data[$value['fid']]=$value;
}
return $data;
}
public function delete_by_id($id){
//删除此应用的快捷方式
$return=array();
$data=parent::fetch($id);
if(parent::delete($id)){
$return['msg']='success';
//C::t('source_shortcut')->delete_by_bz($data['bz'].':'.$id.':',true);//删除快捷方式;
//删除图片缓存文件
$imgcache=getglobal('setting/attachdir').'./imgcache/'.$data['bz'].'/'.$id.'/';
removedirectory($imgcache);
}
return $return;
}
public function delete_by_uid($uid){
if(!$uid) return 0;
foreach(DB::fetch_all("select id from %t where uid=%d",array($this->_table,$uid)) as $value){
self::delete_by_id($value['id']);
}
return true;
}
public function delete_by_bz($bz){
foreach(DB::fetch_all("select id from %t where bz=%s",array($this->_table,$bz)) as $value){
self::delete_by_id($value['id']);
}
}
}
?>

View File

@@ -0,0 +1,102 @@
<?php
/*
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
* @license https://www.oaooa.com/licenses/
*
* @link https://www.oaooa.com
* @author zyx(zyx@oaooa.com)
*/
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
//所有用户应用
//uid=0 的表示为默认应用
class table_local_router extends dzz_table
{
public function __construct() {
$this->_table = 'local_router';
$this->_pk = 'routerid';
//$this->_pre_cache_key = 'local_router_';
//$this->_cache_ttl = 0;
parent::__construct();
}
public function fetch_by_routerid($routerid){
$data=self::fetch($routerid);
$data['router']=unserialize($data['router']);
$data['drouter']=self::getRouterDetail($data['router']);
return $data;
}
public function fetch_all_orderby_priority($available=false){
$data=array();
$where='1';
if($available){
$where.=' and `available`>0';
}
foreach(DB::fetch_all("SELECT * FROM %t WHERE $where ORDER BY priority DESC ",array($this->_table)) as $value){
$value['router']=unserialize($value['router']);
$value['drouter']=self::getRouterDetail($value['router']);
$data[$value['routerid']]=$value;
}
return $data;
}
public function getRouterDetail($router){
$html='';
foreach($router as $type =>$value){
switch($type){
case 'exts':
if($value) $html.="文件后缀:".implode(',',$value);
else $html.="文件后缀:不限制";
break;
case 'size':
$sizearr=array();
if(is_numeric($value['lt'])) $sizearr[]="大于".formatsize($value['lt']*1024*1024);
if(is_numeric($value['gt'])) $sizearr[]="小于".formatsize($value['gt']*1024*1024);
if($sizearr) $html.='<br>文件大小:'.implode(' and ',$sizearr);
else $html.='<br>文件大小:不限制';
break;
}
}
return $html;
}
public function insert($setarr){
$setarr['router']=serialize($setarr['router']);
return parent::insert($setarr,1);
}
public function update($routerid,$setarr){
if($setarr['router']) $setarr['router']=serialize($setarr['router']);
return parent::update($routerid,$setarr);
}
public function delete_by_remoteid($remoteid){
return DB::delete($this->_table,"remoteid='{$remoteid}'");
}
//根据路由规则筛选出存储位置
public function getRemoteId($data){
$remoteid=0;
$guize=self::fetch_all_orderby_priority(true);
foreach($guize as $value){
//没有此存储位置
if(!$ldata = C::t('local_storage')->fetch($value['remoteid'])){
continue;
}else{
$available = DB::result_first("select available from %t where bz = %s", array('connect',$ldata['bz']));
if($available <1) continue;
}
//云停用跳转
if($available<1) continue;
if($value['router']['exts']){
if(!in_array(strtolower($data['filetype']),$value['router']['exts'])) continue;
}
if(is_numeric($value['router']['size']['lt']) && $data['filesize']<$value['router']['size']['lt']*1024*1024) continue;
if(is_numeric($value['router']['size']['gt']) && $data['filesize']>$value['router']['size']['gt']*1024*1024) continue;
return $value['remoteid'];
}
return $remoteid;
}
}
?>

View File

@@ -0,0 +1,119 @@
<?php
/*
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
* @license https://www.oaooa.com/licenses/
*
* @link https://www.oaooa.com
* @author zyx(zyx@oaooa.com)
*/
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
class table_local_storage extends dzz_table
{
public function __construct() {
$this->_table = 'local_storage';
$this->_pk = 'remoteid';
/*$this->_pre_cache_key = 'local_storage_';
$this->_cache_ttl = 300;*/
parent::__construct();
}
public function fetch_by_remoteid($remoteid){
$remoteid=intval($remoteid);
if(!$data=self::fetch($remoteid)){
return array();
}
if($connect=C::t('connect')->fetch($data['bz'])){
$data=array_merge($connect,$data);
}
if($data['dname'] && $data['did']){
if($pan=C::t($data['dname'])->fetch($data['did'])) $data=array_merge($pan,$data);
}
return $data;
}
public function getBzByRemoteid($remoteid){ //通过remoteid获取bz,默认返回dzz
if(!($data=self::fetch_by_remoteid($remoteid))){
return 'dzz';
}
if($data['type']=='pan') $bz=$data['bz'].':'.$data['id'].':'.$data['root'];
elseif($data['type']=='storage') $bz=$data['bz'].':'.$data['id'].':'.$data['bucket'];
elseif($data['type']=='ftp') $bz=$data['bz'].':'.$data['id'].':'.$data['root'];
elseif($data['type']=='disk') $bz=$data['bz'].':'.$data['id'].':'.$data['root'];
else $bz='dzz';
return $bz;
}
public function fetch_all_orderby_disp(){
$data=array();
foreach(DB::fetch_all("SELECT s.*,c.available FROM %t s LEFT JOIN %t c ON c.bz=s.bz WHERE 1 ORDER BY s.disp ",array($this->_table,'connect')) as $value){
$data[$value['remoteid']]=$value;
}
return $data;
}
public function update_usesize_by_remoteid($remoteid,$ceof){
if(!$remoteid) $remoteid=DB::result_first("select remoteid from %t where bz='dzz' limit 1",array($this->_table));
$ceof=intval($ceof);
try{
if($ceof>0){
DB::query("update %t set usesize=usesize+%d where remoteid=%d",array($this->_table,$ceof,$remoteid));
}else{
DB::query("update %t set usesize=usesize-%d where remoteid=%d",array($this->_table,abs($ceof),$remoteid));
}
$this->clear_cache($remoteid);
}catch(Exception $e){}
return true;
}
public function update_sizecount_by_remoteid($remoteid){
if($arr=self::getQuota($remoteid)){
self::update($remoteid,$arr);
return $arr;
}
return false;
}
public function getQuota($remoteid){
global $_G;
$data=self::fetch_by_remoteid($remoteid);
$return=array();
if($data['type']=='local'){
$return['usesize']=C::t('attachment')->getSizeByRemote($remoteid);
$return['totalsize']=disk_free_space($_G['setting']['attachdir']);
}elseif($data['type']=='pan'){
$bz=$data['bz'].':'.$data['id'].':';
$arr=IO::getQuota($bz);
$return['usesize']=C::t('attachment')->getSizeByRemote($remoteid);
if(is_numeric($arr['quota']) && is_numeric($arr['used'])) $return['totalsize']=($arr['quota'])-($arr['used']);
}elseif($data['type']=='storage'){
$return['usesize']=C::t('attachment')->getSizeByRemote($remoteid);
$return['totalsize']=0;
}elseif($data['type']=='ftp'){
$bz=$data['bz'].':'.$data['id'].':';
$return['usesize']=C::t('attachment')->getSizeByRemote($remoteid);
$return['totalsize']=0;
}elseif($data['type']=='disk'){
$bz=$data['bz'].':'.$data['id'].':';
$return['usesize']=C::t('attachment')->getSizeByRemote($remoteid);
$return['totalsize']=disk_free_space($data['attachdir']);
}else{
$return['usesize']=C::t('attachment')->getSizeByRemote($remoteid);
$return['totalsize']=0;
}
return $return;
}
public function delete_by_remoteid($remoteid){
$data=self::fetch($remoteid);
if($data['bz']=='dzz') return array('error'=>'内置,不能删除');
if(C::t('attachment')->getSizeByRemote($remoteid)>0) return array('error'=>'有文件未迁移,不能删除');
C::t('local_router')->delete_by_remoteid($remoteid);
if($data['dname'] && $data['did']) C::t($data['dname'])->delete_by_id($data['did']);//删除链接
return self::delete($remoteid);
}
public function getRemoteId(){
return DB::result_first("select s.remoteid from ".DB::table('local_storage')." s LEFT JOIN ".DB::table('connect')." c ON s.bz=c.bz where c.available>0 order by s.isdefault DESC, s.disp ASC");
}
}
?>

View File

@@ -0,0 +1,30 @@
<?php
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
class table_pichome_ffmpeg_record extends dzz_table
{
public function __construct()
{
$this->_table = 'pichome_ffmpeg_record';
$this->_pk = 'rid';
$this->_pre_cache_key = 'pichome_ffmpeg_record';
$this->_cache_ttl = 3600;
parent::__construct();
}
public function insert($setarr,$isforce = 0){
$rid = $setarr['rid'];
if(DB::result_first("select rid from %t where rid = %s",array($this->_table,$rid))){
if(!$isforce) return $rid;
else {
parent::delete($rid);
return parent::insert($setarr);
}
}else{
return parent::insert($setarr);
}
}
}

View File

@@ -1,107 +1,153 @@
<?php
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
class table_pichome_folder extends dzz_table
{
public function __construct()
{
$this->_table = 'pichome_folder';
$this->_pk = 'fid';
$this->_pre_cache_key = 'pichome_folder';
$this->_cache_ttl = 3600;
parent::__construct();
}
//根据appid删除目录
public function delete_by_appid($appid){
$fids = [];
foreach(DB::fetch_all("select fid from %t where appid = %s",array($this->_table,$appid)) as $v){
$fids[] = $v['fid'];
}
return parent::delete($fids);
}
//插入和更新目录数据
public function insert_folderdata_by_appid($appid,$folderdata,$folderarr = array(),$pfid='',$pathkey=''){
foreach ($folderdata as $v) {
$fid = $v['id'].$appid;
$setarr=['fname'=>$v['name'],'dateline'=>TIMESTAMP,'pfid'=>$pfid,'appid'=>$appid,'pathkey'=>$pathkey.$fid];
if($v['coverId']) $setarr['cover'] = $v['coverId'].$appid;
if($v['password']) $setarr['password'] = $v['password'];
if($v['passwordTips']) $setarr['passwordtips'] = trim($v['passwordTips']);
//如果已经有该id时更新
if($fname = DB::result_first("select fname from %t where fid = %s",array($this->_table,$fid))){
parent::update($fid,$setarr);
$setarr['fid'] = $fid;
}else{
//如果插入数据失败跳过当前层级目录
$setarr['fid'] = $fid;
if(!parent::insert($setarr))continue;
}
$folderarr[] = $setarr;
if ($v['children']) {
$tmpchild = $v['children'];
foreach($tmpchild as $child){
$cfid = $child['id'].$appid;
$setarr=['fname'=>$child['name'],'dateline'=>TIMESTAMP,'pfid'=>$fid,'appid'=>$appid,'pathkey'=>$pathkey.$fid.$cfid];
if($child['coverId']) $setarr['cover'] = $child['coverId'].$appid;
if($child['password']) $setarr['password'] = $child['password'];
if($v['passwordTips']) $setarr['passwordtips'] = trim($child['passwordTips']);
}
$folderarr = $this->insert_folderdata_by_appid($appid,$tmpchild,$folderarr,$fid,$pathkey.$fid.$cfid);
}
}
return $folderarr;
}
//检查目录是否包含密码,多个目录时,只有都包含密码才视为包含密码
public function check_haspasswrod($folderids,$appid){
$haspassword = 0;
//组合目录id
$fids = [];
foreach($folderids as $v){
$fids[] = $v.$appid;
}
$haspasswordfids = [];
foreach($fids as $val){
//查找当前目录及其上级中任意一层包含密码,则视为该目录包含密码
if(DB::result_first("select fid from %t where pathkey regexp %s and password != '' ",array($this->_table,'.*'.$val.'$'))){
$haspasswordfids[$val] = 1;
}else{
$haspasswordfids[$val] = 0;
}
}
foreach($haspasswordfids as $v){
if(!$v) {
$haspassword = 0;
break;
}else{
$haspassword = 1;
}
}
return $haspassword;
}
//根据fid判断当前目录及其上机是否有密码如果当前目录不存在则返回2存在密码返回1
public function check_password_byfid($fid){
if($data = parent::fetch($fid)){
return DB::result_first("select fid from %t where pathkey regexp %s and password != '' ",array($this->_table,'.*'.$fid.'$')) ? 1:0;
}else{
return 2;
}
}
//转义查询语句当中的path
public function path_transferred_meaning($path){
return str_replace(array('\'','(',')','+','^','$','{','}','[',']','#'),array("\'",'\(','\)','\+','\^','\$','\{','\}','\[','\]','\#'),$path);
}
public function fetch_all_folder_by_appid($appid,$pfid=''){
foreach(DB::fetch_all("select fid,fname from %t where appid = %s and password = '' and pfid = %s",array($this->_table,$appid,$pfid)) as $v){
$v['num'] = C::t('pichome_folderresources')->get_sum_by_fid($v['fid']);
$v['children'] = $this->fetch_all_folder_by_appid($appid,$v['fid']);
$returndata[] = $v;
}
return $returndata;
}
}
<?php
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
class table_pichome_folder extends dzz_table
{
public function __construct()
{
$this->_table = 'pichome_folder';
$this->_pk = 'fid';
$this->_pre_cache_key = 'pichome_folder';
$this->_cache_ttl = 3600;
parent::__construct();
}
//根据appid删除目录
public function delete_by_appid($appid){
$fids = [];
foreach(DB::fetch_all("select fid from %t where appid = %s",array($this->_table,$appid)) as $v){
$fids[] = $v['fid'];
}
return parent::delete($fids);
}
//插入和更新目录数据
public function insert_folderdata_by_appid($appid,$folderdata,$folderarr = array(),$pfid='',$pathkey=''){
foreach ($folderdata as $v) {
$fid = $v['id'].$appid;
$setarr=['fname'=>$v['name'],'dateline'=>TIMESTAMP,'pfid'=>$pfid,'appid'=>$appid,'pathkey'=>($pathkey)?$pathkey:$fid];
if($v['coverId']) $setarr['cover'] = $v['coverId'].$appid;
if($v['password']) $setarr['password'] = $v['password'];
if($v['passwordTips']) $setarr['passwordtips'] = trim($v['passwordTips']);
//如果已经有该id时更新
if($fname = DB::result_first("select fname from %t where fid = %s",array($this->_table,$fid))){
parent::update($fid,$setarr);
$setarr['fid'] = $fid;
}else{
//如果插入数据失败跳过当前层级目录
$setarr['fid'] = $fid;
if(!$setarr['fname']) continue;
if(!parent::insert($setarr))continue;
}
$folderarr[] = $setarr;
if ($v['children']) {
$tmpchild = $v['children'];
foreach($tmpchild as $child){
$cfid = $child['id'].$appid;
$folderarr = $this->insert_folderdata_by_appid($appid,[$child],$folderarr,$fid,($pathkey) ? $pathkey.$cfid:$fid.$cfid);
}
}
}
return $folderarr;
}
//检查目录是否包含密码,多个目录时,只有都包含密码才视为包含密码
public function check_haspasswrod($folderids,$appid){
$haspassword = 0;
//组合目录id
$fids = [];
foreach($folderids as $v){
$fids[] = $v.$appid;
}
$haspasswordfids = [];
foreach($fids as $val){
//查找当前目录及其上级中任意一层包含密码,则视为该目录包含密码
if(DB::result_first("select fid from %t where pathkey regexp %s and password != '' ",array($this->_table,'.*'.$val.'$'))){
$haspasswordfids[$val] = 1;
}else{
$haspasswordfids[$val] = 0;
}
}
foreach($haspasswordfids as $v){
if(!$v) {
$haspassword = 0;
break;
}else{
$haspassword = 1;
}
}
unset($haspasswordfids);
unset($folderids);
return $haspassword;
}
//根据fid判断当前目录及其上机是否有密码如果当前目录不存在则返回2存在密码返回1
public function check_password_byfid($fid){
if($data = parent::fetch($fid)){
return DB::result_first("select fid from %t where pathkey regexp %s and password != '' ",array($this->_table,'.*'.$fid.'$')) ? 1:0;
}else{
return 2;
}
}
//转义查询语句当中的path
public function path_transferred_meaning($path){
return str_replace(array('\'','(',')','+','^','$','{','}','[',']','#'),array("\'",'\(','\)','\+','\^','\$','\{','\}','\[','\]','\#'),$path);
}
public function fetch_all_folder_by_appid($appid,$pfid=''){
foreach(DB::fetch_all("select fid,fname from %t where appid = %s and password = '' and pfid = %s",array($this->_table,$appid,$pfid)) as $v){
$v['num'] = C::t('pichome_folderresources')->get_sum_by_fid($v['fid']);
$v['children'] = $this->fetch_all_folder_by_appid($appid,$v['fid']);
$returndata[] = $v;
}
return $returndata;
}
public function fetch_folder_by_appid_pfid($appid,$pfid=[]){
$folderdata = [];
if(!empty($pfid)){
foreach(DB::fetch_all("select fid,fname,pathkey,appid,pfid,filenum as nosubfilenum from %t where appid = %s and pfid in(%n)",array($this->_table,$appid,$pfid)) as $v){
$v['filenum'] = DB::result_first("SELECT count(DISTINCT fr.rid) FROM %t fr
left join %t f on fr.fid = f.fid
where fr.appid = %s and f.pathkey like %s",array('pichome_folderresources','pichome_folder',$appid,$v['pathkey'].'%'));
$v['leaf'] = DB::result_first("select count(*) from %t where pfid = %s",array($this->_table,$v['fid'])) ? false:true;
$folderdata[] = $v;
}
}else{
foreach(DB::fetch_all("select fid,fname,pathkey,appid,pfid,filenum as nosubfilenum from %t where appid = %s and pfid = ''",array($this->_table,$appid)) as $v){
$v['filenum'] = DB::result_first("SELECT count(DISTINCT fr.rid) FROM %t fr
left join %t f on fr.fid = f.fid
where fr.appid = %s and f.pathkey like %s",array('pichome_folderresources','pichome_folder',$appid,$v['pathkey'].'%'));
$v['leaf'] = DB::result_first("select count(*) from %t where pfid = %s",array($this->_table,$v['fid'])) ? false:true;
$folderdata[] = $v;
}
}
return $folderdata;
}
public function search_by_fname($keyword,$appid=''){
$folderdata = [];
$wheresql = ' fname like %s ';
$params = array($this->_table,'%'.$keyword.'%');
if($appid){
$wheresql .= ' and appid = %s ';
$params[] = $appid;
}
foreach(DB::fetch_all("select fname,fid,pathkey,appid,pfid from %t where $wheresql",$params)as $v ){
$folderdata[$v['fid']] = $v;
}
foreach ($folderdata as $k=>$v){
$len=strlen($folderdata[$k]['pathkey']);
$folderdata[$k]['len']=$len;
}
$cloumarr = array_column($folderdata,'len');
array_multisort($cloumarr,SORT_ASC,$folderdata);
return $folderdata;
}
}

View File

@@ -0,0 +1,24 @@
<?php
if (!defined('IN_OAOOA')) {
exit('Access Denied');
}
class table_pichome_folder_relation extends dzz_table
{
public function __construct()
{
$this->_table = 'pichome_folder_relation';
$this->_pk = 'id';
$this->_pre_cache_key = 'pichome_folder_relation';
$this->_cache_ttl = 3600;
parent::__construct();
}
public function fetch_by_ofid_appid($ofid,$appid){
return DB::fetch_first("select * from %t where nfid = %d and appid = %s",array($this->_table,$ofid,$appid));
}
}

View File

@@ -1,72 +1,77 @@
<?php
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
class table_pichome_folderresources extends dzz_table
{
public function __construct()
{
$this->_table = 'pichome_folderresources';
$this->_pk = 'id';
$this->_pre_cache_key = 'pichome_folderresources';
$this->_cache_ttl = 3600;
parent::__construct();
}
public function insert($setarr){
if($id = DB::result_first("select id from %t where rid = %s and fid =%s",array($this->_table,$setarr['rid'],$setarr['fid']))){
return $id;
}else{
return parent::insert($setarr);
}
}
public function delete_by_appid($appid){
$rids=[];
foreach(DB::fetch_all("select rid from %t where appid = %s",array($this->_table,$appid)) as $v){
$rids[] = $v['rid'];
}
return parent::delete($rids);
}
public function delete_by_rid($rid){
if(!is_array($rid)) $rid = (array) $rid;
$dids = [];
foreach(DB::fetch_all("select id from %t where rid in(%n)",array($this->_table,$rid)) as $v){
$dids[] = $v['id'];
}
return parent::delete($dids);
}
public function fetch_id_by_rid($rid){
$ids = [];
foreach(DB::fetch_all("select id from %t where rid = %s",array($this->_table,$rid)) as $v){
$ids[] = $v['id'];
}
return $ids;
}
public function get_sum_by_fid($fid){
return DB::result_first("select count(rid) from %t where fid=%s",array($this->_table,$fid));
}
public function get_sum_by_fids($fids){
if(!is_array($fids)) $fids = (array) $fids;
$datas = [];
foreach(DB::fetch_all("select fid,count(rid) as num from %t where fid in(%n) group by fid",array($this->_table,$fids)) as $val){
$datas[$val['fid']]= $val['num'];
}
return $datas;
}
public function get_foldername_by_rid($rid){
$foldernames = [];
foreach(DB::fetch_all("select f.fid,f.fname from %t fr left join %t f on f.fid=fr.fid where rid = %s",array($this->_table,'pichome_folder',$rid)) as $v){
$foldernames[$v['fid']] = $v['fname'];
}
return $foldernames;
}
public function fetch_rid_by_fids($fids,$limit = 6,$rid=''){
if(!is_array($fids)) $fids = (array) $fids;
$rids = [];
foreach(DB::fetch_all("select distinct rid from %t where fid in(%n) and rid != %s limit 0,$limit",array($this->_table,$fids,$rid)) as $v){
$rids[] = $v['rid'];
}
return $rids;
}
<?php
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
class table_pichome_folderresources extends dzz_table
{
public function __construct()
{
$this->_table = 'pichome_folderresources';
$this->_pk = 'id';
$this->_pre_cache_key = 'pichome_folderresources';
$this->_cache_ttl = 3600;
parent::__construct();
}
public function insert($setarr){
if($id = DB::result_first("select id from %t where rid = %s and fid =%s and appid = %s",array($this->_table,$setarr['rid'],$setarr['fid'],$setarr['appid']))){
return $id;
}else{
if($id = DB::result_first("select id from %t where rid = %s and fid = %s and appid = %s",array($this->_table,$setarr['rid'],$setarr['fid'],$setarr['appid']))){
$rid = $setarr['rid'];
unset($setarr['rid']);
return parent::update($rid,$setarr);
}
return parent::insert($setarr);
}
}
public function delete_by_appid($appid){
$rids=[];
foreach(DB::fetch_all("select rid from %t where appid = %s",array($this->_table,$appid)) as $v){
$rids[] = $v['rid'];
}
return parent::delete($rids);
}
public function delete_by_rid($rid){
if(!is_array($rid)) $rid = (array) $rid;
$dids = [];
foreach(DB::fetch_all("select id from %t where rid in(%n)",array($this->_table,$rid)) as $v){
$dids[] = $v['id'];
}
return parent::delete($dids);
}
public function fetch_id_by_rid($rid){
$ids = [];
foreach(DB::fetch_all("select id from %t where rid = %s",array($this->_table,$rid)) as $v){
$ids[] = $v['id'];
}
return $ids;
}
public function get_sum_by_fid($fid){
return DB::result_first("select count(rid) from %t where fid=%s",array($this->_table,$fid));
}
public function get_sum_by_fids($fids){
if(!is_array($fids)) $fids = (array) $fids;
$datas = [];
foreach(DB::fetch_all("select fid,count(rid) as num from %t where fid in(%n) group by fid",array($this->_table,$fids)) as $val){
$datas[$val['fid']]= $val['num'];
}
return $datas;
}
public function get_foldername_by_rid($rid){
$foldernames = [];
foreach(DB::fetch_all("select f.fid,f.fname from %t fr left join %t f on f.fid=fr.fid where rid = %s",array($this->_table,'pichome_folder',$rid)) as $v){
$foldernames[$v['fid']] = $v['fname'];
}
return $foldernames;
}
public function fetch_rid_by_fids($fids,$limit = 6,$rid=''){
if(!is_array($fids)) $fids = (array) $fids;
$rids = [];
foreach(DB::fetch_all("select distinct rid from %t where fid in(%n) and rid != %s limit 0,$limit",array($this->_table,$fids,$rid)) as $v){
$rids[] = $v['rid'];
}
return $rids;
}
}

View File

@@ -0,0 +1,30 @@
<?php
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
class table_pichome_imagickrecord extends dzz_table
{
public function __construct()
{
$this->_table = 'pichome_imagickrecord';
$this->_pk = 'rid';
$this->_pre_cache_key = 'pichome_imagickrecord';
$this->_cache_ttl = 3600;
parent::__construct();
}
public function insert($setarr,$isforce = 0){
$rid = $setarr['rid'];
if(DB::result_first("select rid from %t where rid = %s",array($this->_table,$rid))){
if(!$isforce) return $rid;
else {
parent::delete($rid);
return parent::insert($setarr);
}
}else{
return parent::insert($setarr);
}
}
}

View File

@@ -1,235 +1,361 @@
<?php
if (!defined('IN_OAOOA')) {
exit('Access Denied');
}
class table_pichome_resources extends dzz_table
{
public function __construct()
{
$this->_table = 'pichome_resources';
$this->_pk = 'rid';
$this->_pre_cache_key = 'pichome_resources';
$this->_cache_ttl = 3600;
parent::__construct();
}
public function insert($setarr)
{
if (DB::result_first("select count(*) from %t where rid = %s", array($this->_table, $setarr['rid']))) {
$rid = $setarr['rid'];
unset($setarr['rid']);
return parent::update($rid, $setarr);
} else {
return parent::insert($setarr);
}
}
public function delete_by_appid($appid)
{
$rids = [];
foreach (DB::fetch_all("select rid from %t where appid = %s", array($this->_table, $appid)) as $v) {
$rids[] = $v['rid'];
}
return $this->delete_by_rid($rids);
}
public function fetch_by_path($path)
{
$path = trim($path);
return DB::result_first("select * from %t where path = %s", array($this->_table, $path));
}
public function delete_by_rid($rids)
{
if (!is_array($rids)) $rids = (array)$rids;
C::t('pichome_resources_attr')->delete_by_rid($rids);
C::t('pichome_folderresources')->delete_by_rid($rids);
C::t('pichome_palette')->delete_by_rid($rids);
C::t('pichome_comments')->delete_by_rid($rids);
C::t('pichome_resourcestag')->delete_by_rid($rids);
C::t('pichome_share')->delete_by_rid($rids);
return parent::delete($rids);
}
//以rid获取文件缩略图
public function get_icon_by_rids($rids)
{
if (!is_array($rids)) $rids = (array)$rids;
$icondatas = [];
foreach (DB::fetch_all("select r.rid,r.type,r.hasthumb,ra.path from %t r left join %t ra on r.rid=ra.rid where rid in(%n) ", array($this->_table, $rids)) as $v) {
if ($v['hasthumb']) {
$filename = str_replace(strrchr($v['name'], "."), "", $v['name']);
$filepath = dirname($v['path']);
$thumbpath = $filepath . $filename . '_thumb.png';
// if (!file_exists($thumbpath)) $thumbpath = iconv('UTF-8', 'GB2312', $thumbpath);
$icondatas[$v['rid']] = $thumbpath;
} else {
if ($v['type'] == 'commonimage') {
$v['icondata'] = $v['path'];
} else {
$v['icondata'] = geticonfromext($v['ext'], $v['type']);
}
}
}
return $icondatas;
}
public function fetch_by_rids($rids)
{
global $Opentype;
if (!is_array($rids)) $rids = (array)$rids;
$datas = $tmpdatas = [];
foreach (parent::fetch_all($rids) as $v) {
$v['fsize'] = formatsize($v['size']);
$v['mtime'] = dgmdate(round($v['mtime'] / 1000), 'Y/m/d H:i');
$v['dateline'] = dgmdate(round($v['dateline'] / 1000), 'Y/m/d H:i');
$v['name'] = str_replace(strrchr($v['name'], "."), "", $v['name']);
$v['btime'] = dgmdate(round($v['btime'] / 1000), 'Y/m/d H:i');
$v['dpath'] = dzzencode($v['rid'], '', 0);
if (in_array($v['ext'], $Opentype['video'])) {
$v['opentype'] = 'video';
} elseif (in_array($v['ext'], $Opentype['text'])) {
$v['opentype'] = 'text';
} elseif (in_array($v['ext'], $Opentype['pdf'])) {
$v['opentype'] = 'pdf';
} elseif (in_array($v['ext'], $Opentype['image'])) {
$v['opentype'] = 'image';
} else {
$v['opentype'] = 'other';
}
$tmpdatas[$v['rid']] = $v;
}
foreach($rids as $rid){
$datas[$rid] = $tmpdatas[$rid];
}
foreach (C::t('pichome_resources_attr')->fetch_all($rids) as $v) {
if ($datas[$v['rid']]['hasthumb']) {
$filepath = dirname($v['path']);
$filename = substr($v['path'],strrpos($v['path'],'/')+1);
$filename = str_replace(strrchr($filename, "."),"",$filename);
$thumbpath = 'library/' . $filepath . '/' . $filename . '_thumbnail.png';
$datas[$v['rid']]['icondata'] = str_replace('+',' ',urlencode($thumbpath));
}
else {
if ($datas[$v['rid']]['type'] == 'commonimage') {
$datas[$v['rid']]['icondata'] = str_replace('+',' ',urlencode('library/' . $v['path']));
} else {
$datas[$v['rid']]['icondata'] = geticonfromext($datas[$v['rid']]['ext'], $datas[$v['rid']]['type']);
}
}
$datas[$v['rid']]['realpath'] = str_replace('+',' ',urlencode('library/' . $v['path']));
$colorsarr = [];
//获取颜色数据
$colordata = C::t('pichome_palette')->fetch_colordata_by_rid($v['rid']);
foreach ($colordata as $cv) {
$colorsarr[] = $cv;
}
$datas[$v['rid']]['color'] = $colorsarr[0];
$datas[$v['rid']]['link'] = $v['link'];
}
//array_multisort($datas, 'rid', SORT_ASC, $rids);
foreach (C::t('pichome_resourcestag')->fetch_all_tag_by_rids($rids) as $k => $v) {
$datas[$k]['tags'] = $v;
// $datas[$k]['tags'] = '•'.implode('•',$v);
}
return $datas;
}
public function fetch_by_rid($rid)
{
global $Opentype;
if (!$resourcesdata = parent::fetch($rid)) return array();
if ($resourcesdata['isdelete'] > 0) return array();
$attrdata = C::t('pichome_resources_attr')->fetch($rid);
$resourcesdata = array_merge($resourcesdata, $attrdata);
$resourcesdata['colors'] = C::t('pichome_palette')->fetch_colordata_by_rid($rid);
if (in_array($resourcesdata['ext'], $Opentype['video'])) {
$resourcesdata['opentype'] = 'video';
} elseif (in_array($resourcesdata['ext'], $Opentype['text'])) {
$resourcesdata['opentype'] = 'text';
} elseif (in_array($resourcesdata['ext'], $Opentype['pdf'])) {
$resourcesdata['opentype'] = 'pdf';
} elseif (in_array($resourcesdata['ext'], $Opentype['image'])) {
$resourcesdata['opentype'] = 'image';
} else {
$resourcesdata['opentype'] = 'other';
}
if ($resourcesdata['hasthumb']) {
$filepath = dirname($resourcesdata['path']);
$filename = substr($resourcesdata['path'],strrpos($resourcesdata['path'],'/')+1);
$filename = str_replace(strrchr($filename, "."),"",$filename);
$thumbpath = 'library/' . $filepath . '/' . $filename . '_thumbnail.png';
$resourcesdata['icondata'] = $thumbpath;
//}
} else {
if ($resourcesdata['type'] == 'commonimage') {
$resourcesdata['icondata'] = 'library/' . $resourcesdata['path'];
} else {
$resourcesdata['icondata'] = geticonfromext($resourcesdata['ext'], $resourcesdata['type']);
}
}
$imginfo = @getimagesize($resourcesdata['icondata']);
$resourcesdata['iconwidth'] = $imginfo[0];
$resourcesdata['iconheight'] = $imginfo[1];
$resourcesdata['icondata'] = str_replace('+',' ',urlencode($resourcesdata['icondata']));
//获取所有库分享和下载权限
$downshare = C::t('pichome_vapp')->fetch_all_sharedownlod();
$resourcesdata['share'] = $downshare[$resourcesdata['appid']]['share'];
$resourcesdata['download'] = $downshare[$resourcesdata['appid']]['download'];
$resourcesdata['originalimg'] = str_replace('+',' ',urlencode('library/' . $resourcesdata['path']));
$resourcesdata['realpath'] = str_replace('+',' ',urlencode('library/' . $resourcesdata['path']));
$resourcesdata['name'] = str_replace(strrchr($resourcesdata['name'], "."), "", $resourcesdata['name']);
$resourcesdata['fsize'] = formatsize($resourcesdata['size']);
$resourcesdata['mtime'] = dgmdate(round($resourcesdata['mtime'] / 1000), 'Y/m/d H:i');
$resourcesdata['dateline'] = dgmdate(round($resourcesdata['dateline'] / 1000), 'Y/m/d H:i');
$resourcesdata['btime'] = dgmdate(round($resourcesdata['btime'] / 1000), 'Y/m/d H:i');
unset($resourcesdata['path']);
$resourcesdata['foldernames'] = C::t('pichome_folderresources')->get_foldername_by_rid($rid);
$resourcesdata['tag'] = C::t('pichome_resourcestag')->fetch_tag_by_rid($rid);
$resourcesdata['dpath'] = dzzencode($rid, '', 0);
return $resourcesdata;
}
public function getdatasbyrids($rids)
{
$returndata = [];
//文件数据
$resourcesdata = $this->fetch_by_rids($rids);
//获取所有库分享和下载权限
$downshare = C::t('pichome_vapp')->fetch_all_sharedownlod();
//文件附属表数据
// $attrdata = C::t('pichome_resources_attr')->fetch_by_rids($rids);
//文件标注数
$annonationnumdata = C::t('pichome_comments')->fetch_annonationnum_by_rids($rids);
foreach ($resourcesdata as $v) {
$v['annonationnum'] = $annonationnumdata[$v['rid']]['num'];
$v['share'] = $downshare[$v['appid']]['share'];
$v['download'] = $downshare[$v['appid']]['download'];
$returndata[] = $v;
}
return $returndata;
}
public function fetch_like_words($keyword, $limit = 10)
{
$likewords = [];
$presql = " case when name like %s then 3 when name like %s then 2 when name like %s then 1 end as rn";
$wheresql = " name like %s";
$params = [$keyword . '%', '%' . $keyword, '%' . $keyword . '%', $this->_table, '%' . $keyword . '%'];
foreach (DB::fetch_all("select name,$presql from %t where $wheresql order by rn desc limit 0,$limit", $params) as $v) {
$likewords[] = $v['name'];
}
return $likewords;
}
}
<?php
if (!defined('IN_OAOOA')) {
exit('Access Denied');
}
class table_pichome_resources extends dzz_table
{
public function __construct()
{
$this->_table = 'pichome_resources';
$this->_pk = 'rid';
$this->_pre_cache_key = 'pichome_resources';
$this->_cache_ttl = 3600;
parent::__construct();
}
public function insert($setarr)
{
if (DB::result_first("select count(*) from %t where rid = %s", array($this->_table, $setarr['rid']))) {
$rid = $setarr['rid'];
unset($setarr['rid']);
parent::update($rid, $setarr);
} else {
parent::insert($setarr);
}
return true;
}
public function delete_by_appid($appid)
{
//$i = 0;
$rids = [];
foreach (DB::fetch_all("select rid from %t where appid = %s limit 0,1000", array($this->_table, $appid)) as $v) {
$rids[] = $v['rid'];
}
if ($rids) $this->delete_by_rid($rids);
//return $i;
}
public function fetch_by_path($path)
{
$path = trim($path);
return DB::result_first("select * from %t where path = %s", array($this->_table, $path));
}
public function delete_by_rid($rids)
{
if (!is_array($rids)) $rids = (array)$rids;
C::t('pichome_resources_attr')->delete_by_rid($rids);
C::t('pichome_folderresources')->delete_by_rid($rids);
C::t('pichome_palette')->delete_by_rid($rids);
C::t('pichome_comments')->delete_by_rid($rids);
C::t('pichome_resourcestag')->delete_by_rid($rids);
C::t('pichome_share')->delete_by_rid($rids);
C::t('pichome_ffmpeg_record')->delete($rids);
C::t('pichome_imagickrecord')->delete($rids);
return $this->delete($rids);
}
public function fetch_by_rids($rids)
{
global $Opentype;
if (!is_array($rids)) $rids = (array)$rids;
$datas = $tmpdatas = [];
foreach (parent::fetch_all($rids) as $v) {
$v['fsize'] = formatsize($v['size']);
$v['mtime'] = dgmdate(round($v['mtime'] / 1000), 'Y/m/d H:i');
$v['dateline'] = dgmdate(round($v['dateline'] / 1000), 'Y/m/d H:i');
$v['name'] = str_replace(strrchr($v['name'], "."), "", $v['name']);
$v['btime'] = dgmdate(round($v['btime'] / 1000), 'Y/m/d H:i');
$v['dpath'] = dzzencode($v['rid'], '', 0,0);
if (in_array($v['ext'], $Opentype['video'])) {
$v['opentype'] = 'video';
} elseif (in_array($v['ext'], $Opentype['text'])) {
$v['opentype'] = 'text';
} elseif (in_array($v['ext'], $Opentype['pdf'])) {
$v['opentype'] = 'pdf';
} elseif (in_array($v['ext'], $Opentype['image'])) {
$v['opentype'] = 'image';
} else {
$v['opentype'] = 'other';
}
$tmpdatas[$v['rid']] = $v;
}
foreach ($rids as $rid) {
$datas[$rid] = $tmpdatas[$rid];
}
foreach (C::t('pichome_resources_attr')->fetch_all($rids) as $v) {
$datas[$v['rid']]['path'] = $v['path'];
//$datas[$v['rid']]['hasthumb'] = $v['hasthumb'];
$colorsarr = [];
//获取颜色数据
$colordata = C::t('pichome_palette')->fetch_colordata_by_rid($v['rid']);
foreach ($colordata as $cv) {
$colorsarr[] = $cv;
}
$datas[$v['rid']]['color'] = $colorsarr[0];
$datas[$v['rid']]['link'] = $v['link'];
}
//array_multisort($datas, 'rid', SORT_ASC, $rids);
foreach (C::t('pichome_resourcestag')->fetch_all_tag_by_rids($rids) as $k => $v) {
$datas[$k]['tags'] = $v;
// $datas[$k]['tags'] = '•'.implode('•',$v);
}
return $datas;
}
//获取数据后端使用
public function fetch_data_by_rid($rid){
if (!$resourcesdata = parent::fetch($rid)) return array();
if ($resourcesdata['isdelete'] > 0) return array();
$downshare = C::t('pichome_vapp')->fetch_all_sharedownlod();
if($downshare[$resourcesdata['appid']]['isdelete']) return array();
$attrdata = C::t('pichome_resources_attr')->fetch($rid);
$resourcesdata = array_merge($resourcesdata, $attrdata);
$resourcesdata['realpath'] =$downshare[$resourcesdata['appid']]['path'] . BS . $resourcesdata['path'];
return $resourcesdata;
}
public function fetch_by_rid($rid)
{
global $Opentype;
if (!$resourcesdata = parent::fetch($rid)) return array();
if ($resourcesdata['isdelete'] > 0) return array();
//获取所有库分享和下载权限
$downshare = C::t('pichome_vapp')->fetch_all_sharedownlod();
$attrdata = C::t('pichome_resources_attr')->fetch($rid);
$resourcesdata = array_merge($resourcesdata, $attrdata);
$resourcesdata['colors'] = C::t('pichome_palette')->fetch_colordata_by_rid($rid);
$resourcesdata['ext'] = strtolower($resourcesdata['ext']);
if (in_array($resourcesdata['ext'], $Opentype['video'])) {
$resourcesdata['opentype'] = 'video';
} elseif (in_array($resourcesdata['ext'], $Opentype['text'])) {
$resourcesdata['opentype'] = 'text';
} elseif (in_array($resourcesdata['ext'], $Opentype['pdf'])) {
$resourcesdata['opentype'] = 'pdf';
} elseif (in_array($resourcesdata['ext'], $Opentype['image'])) {
$resourcesdata['opentype'] = 'image';
} else {
$resourcesdata['opentype'] = 'other';
}
if ($resourcesdata['hasthumb']) {
//如果是本地文件
if ($resourcesdata['apptype'] == 1) {
$filename = 'pichomethumb'.BS . $resourcesdata['appid'] . BS . md5($resourcesdata['path']) . '.jpg';
$thumbpath = getglobal('setting/attachurl') . $filename;
//echo $thumbpath;die;
$resourcesdata['icondata'] = str_replace('+', '%20', urlencode($thumbpath));
}
else {
$resourcesdata['path'] = str_replace('\\','/',$resourcesdata['path']);
$filepath = dirname($resourcesdata['path']);
$filename = substr($resourcesdata['path'], strrpos($resourcesdata['path'], '/') + 1);
$filename = str_replace(strrchr($filename, "."), "", $filename);
$filepath = str_replace('/',BS,$filepath);
if ($downshare[$resourcesdata['appid']]['iswebsitefile']) {
$tmppath = str_replace(DZZ_ROOT, '', $downshare[$resourcesdata['appid']]['path']);
$thumbpath = $tmppath . BS . $filepath . BS . $filename . '_thumbnail.png';
$resourcesdata['icondata'] = str_replace('+', '%20', urlencode($thumbpath));
} else {
$tmppath = $downshare[$resourcesdata['appid']]['path'];
$thumbpath = $tmppath . BS . $filepath . BS . $filename . '_thumbnail.png';
$resourcesdata['icondata'] = getglobal('siteurl') . 'index.php?mod=io&op=getImg&path=' . dzzencode($thumbpath,'',0,0);
}
//$thumbpath = 'library/' . $filepath . '/' . $filename . '_thumbnail.png';
//$resourcesdata['icondata'] = $thumbpath;
}
//}
} else {
if ($resourcesdata['type'] == 'commonimage') {
if ($downshare[$resourcesdata['appid']]['iswebsitefile']) {
$tmppath = str_replace(DZZ_ROOT, '', $downshare[$resourcesdata['appid']]['path']);
$thumbpath = $tmppath . BS . $resourcesdata['path'];
$thumbpath = str_replace(BS,'/',$thumbpath);
$resourcesdata['icondata'] = str_replace('+', '%20', urlencode($thumbpath));
} else {
$tmppath = $downshare[$resourcesdata['appid']]['path'];
$resourcesdata['icondata'] = getglobal('siteurl') . 'index.php?mod=io&op=getImg&path=' . dzzencode($tmppath,'',0,0);
}
} else {
$resourcesdata['icondata'] = geticonfromext($resourcesdata['ext'], $resourcesdata['type']);
}
}
//echo $resourcesdata['icondata'];die;
$imginfo = @getimagesize($resourcesdata['icondata']);
$resourcesdata['iconwidth'] = $imginfo[0] ? $imginfo[0]:0;
$resourcesdata['iconheight'] = $imginfo[1] ? $imginfo[1]:0;
$resourcesdata['icondata'] = str_replace('+', '%20', $resourcesdata['icondata']);
$resourcesdata['share'] = $downshare[$resourcesdata['appid']]['share'];
$resourcesdata['download'] = $downshare[$resourcesdata['appid']]['download'];
if ($downshare[$resourcesdata['appid']]['iswebsitefile']){
$originalimg= str_replace(DZZ_ROOT,'',$downshare[$resourcesdata['appid']]['path'] . BS . $resourcesdata['path']);
$originalimg = str_replace(BS,'/',$originalimg);
$resourcesdata['originalimg'] = str_replace('+', '%20', urlencode($originalimg));
$resourcesdata['realpath'] =str_replace('+', '%20', urlencode($originalimg));
}else{
$originalimg = $downshare[$resourcesdata['appid']]['path'] . BS . $resourcesdata['path'];
$resourcesdata['originalimg'] = getglobal('siteurl') . 'index.php?mod=io&op=getImg&path=' . dzzencode($originalimg,'',0,0);
if(in_array($resourcesdata['opentype'],array('text','video','pdf'))){
$resourcesdata['realpath'] = str_replace('+','',urlencode(getglobal('siteurl') . 'index.php?mod=io&op=getImg&path=' . dzzencode($originalimg,'',0,0)));
}else{
$resourcesdata['realpath'] = getglobal('siteurl') . 'index.php?mod=io&op=getImg&path=' . dzzencode($originalimg,'',0,0);
}
}
$resourcesdata['name'] = str_replace(strrchr($resourcesdata['name'], "."), "", $resourcesdata['name']);
$resourcesdata['fsize'] = formatsize($resourcesdata['size']);
$resourcesdata['mtime'] = dgmdate(round($resourcesdata['mtime'] / 1000), 'Y/m/d H:i');
$resourcesdata['dateline'] = dgmdate(round($resourcesdata['dateline'] / 1000), 'Y/m/d H:i');
$resourcesdata['btime'] = dgmdate(round($resourcesdata['btime'] / 1000), 'Y/m/d H:i');
unset($resourcesdata['path']);
$resourcesdata['foldernames'] = C::t('pichome_folderresources')->get_foldername_by_rid($rid);
$resourcesdata['tag'] = C::t('pichome_resourcestag')->fetch_tag_by_rid($rid);
$resourcesdata['dpath'] = dzzencode($rid, '', 0,0);
//print_r($resourcesdata);die;
return $resourcesdata;
}
public function getdatasbyrids($rids)
{
$returndata = [];
//文件数据
$resourcesdata = $this->fetch_by_rids($rids);
//获取所有库分享和下载权限,以及编码数据
$downshare = C::t('pichome_vapp')->fetch_all_sharedownlod();
//文件附属表数据
// $attrdata = C::t('pichome_resources_attr')->fetch_by_rids($rids);
//文件标注数
$annonationnumdata = C::t('pichome_comments')->fetch_annonationnum_by_rids($rids);
foreach ($resourcesdata as $v) {
//echo $v['hasthumb'];die;
$v['annonationnum'] = $annonationnumdata[$v['rid']]['num'];
$v['share'] = $downshare[$v['appid']]['share'];
$v['download'] = $downshare[$v['appid']]['download'];
if ($v['hasthumb']) {
//如果是本地文件
if ($v['apptype'] == 1) {
$filename = 'pichomethumb'.BS . $v['appid'] . BS . md5($v['path']) . '.jpg';
$thumbpath = getglobal('setting/attachurl') . $filename;
$v['icondata'] = str_replace('+', '%20', urlencode($thumbpath));
} else {
$v['path'] = str_replace('\\','/',$v['path']);
$filepath = dirname($v['path']);
$filename = substr($v['path'], strrpos($v['path'], '/') + 1);
$filepath = str_replace('/',BS,$filepath);
$filename = str_replace(strrchr($filename, "."), "", $filename);
$filepath = str_replace('/',BS,$filepath);
if ($downshare[$v['appid']]['iswebsitefile']) {
$tmppath = str_replace(DZZ_ROOT, '', $downshare[$v['appid']]['path']);
$thumbpath = $tmppath . BS . $filepath . BS . $filename . '_thumbnail.png';
$v['icondata'] = str_replace('+', '%20', urlencode($thumbpath));
} else {
$tmppath = $downshare[$v['appid']]['path'];
$thumbpath = $tmppath . BS . $filepath .BS . $filename . '_thumbnail.png';
$v['icondata'] = getglobal('siteurl') . 'index.php?mod=io&op=getImg&path=' . dzzencode($thumbpath);
}
}
} else {
if ($v['type'] == 'commonimage') {
if ($downshare[$v['appid']]['iswebsitefile']) {
$tmppath = str_replace(DZZ_ROOT, '', $downshare[$v['appid']]['path']);
$v['icondata'] = str_replace('+', '%20', urlencode($tmppath . '/' . $v['path']));
} else {
$tmppath = $downshare[$v['appid']]['path'] . BS . $v['path'];
$v['icondata'] = getglobal('siteurl') . 'index.php?mod=io&op=getImg&path=' . dzzencode($tmppath,'',0,0);
}
} else {
$v['icondata'] = geticonfromext($v['ext'], $v['type']);
$v['width'] = 128;
$v['height'] = 128;
}
}
//文件真实地址
if ($downshare[$v['appid']]['iswebsitefile']){
$originalimg= str_replace(DZZ_ROOT,'',$downshare[$v['appid']]['path'] . BS . $v['path']);
$originalimg = str_replace(BS,'/',$originalimg);
$v['realpath'] =str_replace('+', '%20', urlencode($originalimg));
}else{
$originalimg = $downshare[$v['appid']]['path'] . BS . $v['path'];
$v['realpath'] = getglobal('siteurl') . 'index.php?mod=io&op=getImg&path=' . dzzencode($originalimg,'',0,0);
}
unset($v['path']);
$returndata[] = $v;
}
return $returndata;
}
public function geticondata_by_rid($rid){
$resourcesdata = DB::fetch_first("select r.rid,r.appid,r.hasthumb,r.ext,r.type,ra.path as fpath,
v.path,r.apptype,v.iswebsitefile from %t r
left join %t ra on r.rid=ra.rid left join %t v on r.appid = v.appid where r.rid = %s and r.isdelete = 0",
array($this->_table,'pichome_resources_attr','pichome_vapp',$rid));
if ($resourcesdata['hasthumb']) {
//如果是本地文件
if ($resourcesdata['apptype'] == 1) {
$filename = 'pichomethumb'.BS . $resourcesdata['appid'] . BS. md5($resourcesdata['fpath']) . '.jpg';
$thumbpath = getglobal('setting/attachurl') . $filename;
$resourcesdata['icondata'] = str_replace('+', '%20', urlencode($thumbpath));
}
else {
$resourcesdata['fpath'] = str_replace('\\','/',$resourcesdata['fpath']);
$filepath = dirname($resourcesdata['fpath']);
$filename = substr($resourcesdata['fpath'], strrpos($resourcesdata['fpath'], '/') + 1);
$filename = str_replace(strrchr($filename, "."), "", $filename);
$filepath = str_replace('/',BS,$filepath);
if ($resourcesdata['iswebsitefile']) {
$tmppath = str_replace(DZZ_ROOT, '', $resourcesdata['path']);
$thumbpath = $tmppath . BS . $filepath . BS. $filename . '_thumbnail.png';
$resourcesdata['icondata'] = str_replace('+', '%20', urlencode($thumbpath));
} else {
$tmppath = $resourcesdata['path'];
$thumbpath = $tmppath . BS . $filepath . BS . $filename . '_thumbnail.png';
$resourcesdata['icondata'] = getglobal('siteurl') . 'index.php?mod=io&op=getImg&path=' . dzzencode($thumbpath,'',0,0);
}
}
} else {
if ($resourcesdata['type'] == 'commonimage') {
if ($resourcesdata['iswebsitefile']) {
$tmppath = str_replace(DZZ_ROOT, '', $resourcesdata['path']);
$thumbpath = $tmppath . BS . $resourcesdata['fpath'];
$thumbpath = str_replace(BS,'/',$thumbpath);
$resourcesdata['icondata'] = str_replace('+', '%20', urlencode($thumbpath));
} else {
$tmppath = $resourcesdata['path'];
$resourcesdata['icondata'] = getglobal('siteurl') . 'index.php?mod=io&op=getImg&path=' . dzzencode($tmppath,'',0,0);
}
} else {
$resourcesdata['icondata'] = geticonfromext($resourcesdata['ext'], $resourcesdata['type']);
}
}
return $resourcesdata;
}
public function fetch_like_words($keyword, $limit = 10)
{
$likewords = [];
$presql = " case when name like %s then 3 when name like %s then 2 when name like %s then 1 end as rn";
$wheresql = " name like %s";
$params = [$keyword . '%', '%' . $keyword, '%' . $keyword . '%', $this->_table, '%' . $keyword . '%'];
foreach (DB::fetch_all("select name,$presql from %t where $wheresql order by rn desc limit 0,$limit", $params) as $v) {
$likewords[] = $v['name'];
}
return $likewords;
}
}

View File

@@ -1,81 +1,66 @@
<?php
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
class table_pichome_resources_attr extends dzz_table
{
public function __construct()
{
$this->_table = 'pichome_resources_attr';
$this->_pk = 'rid';
$this->_pre_cache_key = 'pichome_resourcesattr';
$this->_cache_ttl = 3600;
parent::__construct();
}
public function insert($setarr){
$rid = trim($setarr['rid']);
if($attrdata = parent::fetch($rid)){
unset($setarr['rid']);
if($setarr['tag']){
$tagarr = explode(',',$setarr['tag']);
$otagarr = explode(',',$attrdata['tag']);
$delrtids = [];
foreach(DB::fetch_all("select id,tid from %t where rid = %s and tid not in(%n)",array('pichome_resourcestag',$rid,$tagarr)) as $v){
$delrtids[] = $v['id'];
C::t('pichome_tag')->delete_by_tid($v['tid']);
}
if(!empty($delrtids)) C::t('pichome_resourcestag')->delete($delrtids);
$addrtids = array_diff($tagarr,$otagarr);
foreach ($addrtids as $tid){
$rtag = ['appid' => $attrdata['appid'], 'rid' => $rid, 'tid' => $tid];
C::t('pichome_resourcestag')->insert($rtag);
}
}
return parent::update($rid,$setarr);
}else{
return parent::insert($setarr,1);
}
}
//删除文件属性数据
public function delete_by_rid($rids){
if(!is_array($rids)) $rids = (array)$rids;
$aids = [];
$tids = [];
foreach(DB::fetch_all("select * from %t where rid in(%n) ",array($this->_table,$rids)) as $v){
$tids= array_merge($tids,explode(',',$v['tags']));
}
$tids = array_unique($tids);
foreach ($tids as $tid){
C::t('pichome_tag')->delete_by_tid($tid);
}
return parent::delete($rids);
}
public function fetch_by_rids($rids){
if(!is_array($rids)) $rids = (array)$rids;
$data = [];
foreach(parent::fetch_all($rids) as $v){
$data[$v['rid']] = $v;
}
return $v;
}
public function fetch_rids_by_link($link,$appid,$limit=6,$rid=''){
$rids = [];
foreach(DB::fetch_all("select distinct rid from %t where link =%s and rid !=%s and appid = %s limit 0,$limit",array($this->_table,$link,$rid,$appid)) as $v){
$rids[] = $v['rid'];
}
return $rids;
}
public function fetch_like_words($keyword,$limit=10){
$likewords = [];
$presql = " case when 'desc' like %s then 3 when 'desc' like %s then 2 when 'desc' like %s then 1 end as rn";
$wheresql = " 'desc' like %s";
$params = [$keyword . '%', '%' . $keyword,'%'.$keyword.'%',$this->_table,'%'.$keyword.'%'];
foreach(DB::fetch_all("select 'desc',$presql from %t where $wheresql order by rn desc limit 0,$limit",$params) as $v){
$likewords[] = $v['desc'];
}
return $likewords;
}
<?php
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
class table_pichome_resources_attr extends dzz_table
{
public function __construct()
{
$this->_table = 'pichome_resources_attr';
$this->_pk = 'rid';
$this->_pre_cache_key = 'pichome_resourcesattr';
$this->_cache_ttl = 3600;
parent::__construct();
}
public function insert($setarr){
$rid = trim($setarr['rid']);
if($attrdata = parent::fetch($rid)){
unset($setarr['rid']);
return parent::update($rid,$setarr);
}else{
return parent::insert($setarr);
}
}
//删除文件属性数据
public function delete_by_rid($rids){
if(!is_array($rids)) $rids = (array)$rids;
$aids = [];
$tids = [];
foreach(DB::fetch_all("select * from %t where rid in(%n) ",array($this->_table,$rids)) as $v){
$tids= array_merge($tids,explode(',',$v['tags']));
}
$tids = array_unique($tids);
foreach ($tids as $tid){
C::t('pichome_tag')->delete_by_tid($tid);
}
return parent::delete($rids);
}
public function fetch_by_rids($rids){
if(!is_array($rids)) $rids = (array)$rids;
$data = [];
foreach(parent::fetch_all($rids) as $v){
$data[$v['rid']] = $v;
}
return $v;
}
public function fetch_rids_by_link($link,$appid,$limit=6,$rid=''){
$rids = [];
foreach(DB::fetch_all("select distinct rid from %t where link =%s and rid !=%s and appid = %s limit 0,$limit",array($this->_table,$link,$rid,$appid)) as $v){
$rids[] = $v['rid'];
}
return $rids;
}
public function fetch_like_words($keyword,$limit=10){
$likewords = [];
$presql = " case when 'desc' like %s then 3 when 'desc' like %s then 2 when 'desc' like %s then 1 end as rn";
$wheresql = " 'desc' like %s";
$params = [$keyword . '%', '%' . $keyword,'%'.$keyword.'%',$this->_table,'%'.$keyword.'%'];
foreach(DB::fetch_all("select 'desc',$presql from %t where $wheresql order by rn desc limit 0,$limit",$params) as $v){
$likewords[] = $v['desc'];
}
return $likewords;
}
}

View File

@@ -0,0 +1,34 @@
<?php
if (!defined('IN_OAOOA')) {
exit('Access Denied');
}
class table_pichome_resources_relation extends dzz_table
{
public function __construct()
{
$this->_table = 'pichome_resources_relation';
$this->_pk = 'id';
$this->_pre_cache_key = 'pichome_resources_relation';
$this->_cache_ttl = 3600;
parent::__construct();
}
public function insert($setarr)
{
if (DB::result_first("select count(*) from %t where rid = %s", array($this->_table, $setarr['rid']))) {
$rid = $setarr['rid'];
unset($setarr['rid']);
return parent::update($rid, $setarr);
} else {
return parent::insert($setarr);
}
}
public function fetch_by_orid_appid($orid,$appid){
return DB::fetch_first("select * from %t where orid = %s and appid = %s",$this->_table,$orid,$appid);
}
}

View File

@@ -1,89 +1,90 @@
<?php
if (!defined('IN_OAOOA')) {
exit('Access Denied');
}
class table_pichome_resourcestag extends dzz_table
{
public function __construct()
{
$this->_table = 'pichome_resourcestag';
$this->_pk = 'id';
$this->_pre_cache_key = 'pichome_resourcestag';
$this->_cache_ttl = 3600;
parent::__construct();
}
public function insert($setarr)
{
if ($id = DB::result_first("select id from %t where tid = %d and rid = %s", array($this->_table, $setarr['tid'],$setarr['rid']))) {
parent::update($id, $setarr);
} else {
$id=parent::insert($setarr);
C::t('pichome_tag')->add_hots_by_tid($setarr['tid']);
}
return $id;
}
public function fetch_tag_by_rid($rid){
$tagdata = [];
foreach(DB::fetch_all("select t.tid,t.tagname from %t rt left join %t t on rt.tid = t.tid where rt.rid = %s",array($this->_table,'pichome_tag',$rid)) as $v){
$tagdata[$v['tid']] = $v['tagname'];
}
return $tagdata;
}
public function fetch_id_by_rid($rid)
{
$ids = [];
foreach(DB::fetch_all("select id from %t where rid = %s",array($this->_table,$rid)) as $v){
$ids[] = $v['id'];
}
return $ids;
}
//根据appid删除数据
public function delete_by_appid($appid)
{
$dids = [];
foreach (DB::fetch_all("select id from %t where appid = %s", array($this->_table, $appid)) as $v) {
$dids[] = $v['id'];
}
return parent::delete($dids);
}
public function delete_by_rid($rid)
{
$delids = [];
foreach (DB::fetch_all("select id from %t where rid = %s", array($this->_table, $rid)) as $v) {
$delids[] = $v['id'];
}
return parent::delete($delids);
}
public function fetch_rids_by_tids($tids,$appid,$limit=6,$rid=''){
if(!is_array($tids)) $tids = (array) $tids;
$rids = [];
foreach(DB::fetch_all("select distinct rid from %t where tid in(%n) and rid != %s and appid = %s limit 0,$limit",array($this->_table,$tids,$rid,$appid)) as $v){
$rids[] = $v['rid'];
}
return $rids;
}
public function fetch_all_tag_by_rids($rids){
$data = [];
foreach(DB::fetch_all("select rt.rid,rt.tid,t.tagname from %t rt
left join %t t on rt.tid = t.tid where rt.rid in(%n)",array($this->_table,'pichome_tag',$rids)) as $v){
$data[$v['rid']][]= $v['tagname'];
}
return $data;
}
public function delete_by_ridtid($rid,$tids){
if(!is_array($tids)) $tids = (array) $tids;
$ids = [];
foreach(DB::fetch_all("select id,tid from %t where rid = %s and tid in(%n)",array($this->_table,$rid,$tids)) as $v){
$ids[] = $v['id'];
C::t('pichome_tag')->delete_by_tid($v['tid']);
}
return parent::delete($ids);
}
}
<?php
if (!defined('IN_OAOOA')) {
exit('Access Denied');
}
class table_pichome_resourcestag extends dzz_table
{
public function __construct()
{
$this->_table = 'pichome_resourcestag';
$this->_pk = 'id';
$this->_pre_cache_key = 'pichome_resourcestag';
$this->_cache_ttl = 3600;
parent::__construct();
}
public function insert($setarr)
{
if ($id = DB::result_first("select id from %t where tid = %d and rid = %s", array($this->_table, $setarr['tid'],$setarr['rid']))) {
parent::update($id, $setarr);
} else {
$id=parent::insert($setarr);
C::t('pichome_tag')->add_hots_by_tid($setarr['tid']);
}
return $id;
}
public function fetch_tag_by_rid($rid){
$tagdata = [];
foreach(DB::fetch_all("select t.tid,t.tagname from %t rt left join %t t on rt.tid = t.tid where rt.rid = %s",array($this->_table,'pichome_tag',$rid)) as $v){
$tagdata[$v['tid']] = $v['tagname'];
}
return $tagdata;
}
public function fetch_id_by_rid($rid)
{
$ids = [];
foreach(DB::fetch_all("select id from %t where rid = %s",array($this->_table,$rid)) as $v){
$ids[] = $v['id'];
}
return $ids;
}
//根据appid删除数据
public function delete_by_appid($appid)
{
$dids = [];
foreach (DB::fetch_all("select id from %t where appid = %s", array($this->_table, $appid)) as $v) {
$dids[] = $v['id'];
}
return parent::delete($dids);
}
public function delete_by_rid($rid)
{
if(!is_array($rid)) $rid = (array)$rid;
$delids = [];
foreach (DB::fetch_all("select id from %t where rid in(%n)", array($this->_table, $rid)) as $v) {
$delids[] = $v['id'];
}
return parent::delete($delids);
}
public function fetch_rids_by_tids($tids,$appid,$limit=6,$rid=''){
if(!is_array($tids)) $tids = (array) $tids;
$rids = [];
foreach(DB::fetch_all("select distinct rid from %t where tid in(%n) and rid != %s and appid = %s limit 0,$limit",array($this->_table,$tids,$rid,$appid)) as $v){
$rids[] = $v['rid'];
}
return $rids;
}
public function fetch_all_tag_by_rids($rids){
$data = [];
foreach(DB::fetch_all("select rt.rid,rt.tid,t.tagname from %t rt
left join %t t on rt.tid = t.tid where rt.rid in(%n)",array($this->_table,'pichome_tag',$rids)) as $v){
$data[$v['rid']][]= $v['tagname'];
}
return $data;
}
public function delete_by_ridtid($rid,$tids){
if(!is_array($tids)) $tids = (array) $tids;
$ids = [];
foreach(DB::fetch_all("select id,tid from %t where rid = %s and tid in(%n)",array($this->_table,$rid,$tids)) as $v){
$ids[] = $v['id'];
C::t('pichome_tag')->delete_by_tid($v['tid']);
}
return parent::delete($ids);
}
}

View File

@@ -1,178 +1,162 @@
<?php
if (!defined('IN_OAOOA')) {
exit('Access Denied');
}
class table_pichome_searchrecent extends dzz_table
{
public function __construct()
{
$this->_table = 'pichome_searchrecent';
$this->_pk = 'id';
$this->_pre_cache_key = 'pichome_searchrecent';
$this->_cache_ttl = 3600;
parent::__construct();
}
public function add_search($keyword, $appid = '', $ktype = 0)
{
global $_G;
$wheresql = ' keywords = %s and ktype=%d ';
$params = array($this->_table, $keyword, $ktype);
if ($_G['uid']) {
$wheresql .= ' and uid = %d ';
$params[] = $_G['uid'];
}
if ($appid) {
$wheresql .= ' and appid = %s ';
$params[] = $appid;
}
if ($data = DB::fetch_first("select id,hots from %t where$wheresql", $params)) {
$hots = $data['hots'] + 1;
return parent::update($data['id'], array('hots' => $hots, 'dateline' => TIMESTAMP));
} else {
$setarr = [
'keywords' => $keyword,
'ktype' => $ktype,
'dateline' => TIMESTAMP,
'uid' => isset($_G['uid']) ? $_G['uid'] : 0,
'hots' => 1,
'appid' => $appid
];
return parent::insert($setarr);
}
}
//查询最近搜索标签
public function fetch_renctent_search_tag($appid = '', $limit = 8)
{
global $_G;
$wheresql = ' s.ktype = 1 ';
$params = array($this->_table, 'pichome_tag');
if ($appid) {
$wheresql .= ' and s.appid = %s ';
$params[] = $appid;
}
if ($_G['uid']) {
$wheresql .= ' and s.uid = %d';
$params[] = $_G['uid'];
}
$datas = [];
foreach (DB::fetch_all("select s.keywords,t.tid from %t s left join %t t on s.keywords = t.tagname where
$wheresql and t.tid > 0 order by s.hots desc,s.dateline desc limit 0,$limit", $params) as $v) {
$datas[$v['tid']] = $v['keywords'];
}
return $datas;
}
public function fetch_hotkeyword_by_appid($appid = '', $limit = 16,$noids=array(),$datas=array())
{
$start = strtotime(date("Y-m-d", strtotime("-7 day")));
$end = strtotime(dgmdate(time(), 'Y-m-d')) + 86400;
$params = array($this->_table/*, $start, $end*/);
/* //$wheresql = " dateline <= %d and dateline > %d";
if ($appid) {
$wheresql .= ' and appid =%s ';
$params[] = $appid;
}
if($noids){
$wheresql .= ' and id not in(%n) ';
$params[] = $noids;
}*/
$count = DB::result_first("select count(id) from %t where 1 order by hots desc limit 0,$limit", $params);
foreach (DB::fetch_all("select keywords,id from %t where 1 order by hots desc limit 0,$limit", $params) as $v) {
$data = $this->get_data_by_keyword($v['keywords'],$v['id']);
if(!$data){
parent::delete($v['id']);
}else{
$datas[$v['id']] = $data;
}
}
$resultcount = count($datas);
//如果有关键词没有结果,并且结果数量大于查询出来的数量
if($resultcount < $limit && $count > $limit){
$ids = array_keys($datas);
$limit = $limit - $resultcount;
$datas = $this->fetch_hotkeyword_by_appid($appid,$limit,$ids,$datas);
}
return $datas;
}
public function get_data_by_keyword($keyword){
$tmpdata = DB::fetch_first("select r.rid,r.name,ra.path,r.hasthumb,r.ext,r.type from %t r
left join %t ra on ra.rid=r.rid LEFT JOIN %t c on c.rid = r.rid
left join %t rt on r.rid = rt.rid left join %t t on rt.tid= t.tid where r.name like%s or ra.link like %s or ra.desc LIKE %s or c.annotation LIKE %s or t.tagname LIKE %s
order by rand() limit 1 ",
array('pichome_resources', 'pichome_resources_attr', 'pichome_comments', 'pichome_resourcestag', 'pichome_tag', '%' . $keyword . '%',
'%' . $keyword . '%', '%' . $keyword . '%', '%' . $keyword . '%', '%' . $keyword . '%'));
if (!$tmpdata) {
return false;
} else {
if ($tmpdata['hasthumb']) {
$filename = str_replace(strrchr($tmpdata['name'], "."), "", $tmpdata['name']);
$filepath = dirname($tmpdata['path']);
$thumbpath = DZZ_ROOT . 'library/' . $filepath . '/' . $filename . '_thumbnail.png';
$thumbpath = str_replace(DZZ_ROOT, '', $thumbpath);
$tmpdata['icondata'] = $thumbpath;
} else {
if ($tmpdata['type'] == 'commonimage') {
$tmpdata['icondata'] = 'library/' . $tmpdata['path'];
} else {
$tmpdata['icondata'] = geticonfromext($tmpdata['ext'], $tmpdata['type']);
}
}
$tmpdata['keyword'] = $keyword;
}
return $tmpdata;
}
//查询最近搜索分类
public function fetch_renctent_search_foldername($appid, $limit = 10)
{
global $_G;
$wheresql = ' s.ktype = 2 and s.appid = %s';
$params = array($this->_table, 'pichome_folder', $appid);
if ($_G['uid']) {
$wheresql .= ' and s.uid = %d';
$params[] = $_G['uid'];
}
$datas = [];
foreach (DB::fetch_all("select s.keywords,f.fid from %t s left join %t f on f.fname = s.keywords and f.appid = s.appid
where $wheresql and f.fid !='' and s.hots > 0 order by s.hots desc,s.dateline desc limit 0,$limit", $params) as $v) {
$datas[$v['fid']]['name'] = $v['keywords'];
$datas[$v['fid']]['fid'] = $v['fid'];
}
$fids = array_keys($datas);
if (!empty($fids)) {
foreach (DB::fetch_all("select f.fname,f.fid,count(fr.rid) as num from %t fr
left join %t f on f.fid=fr.fid where fr.fid in(%n) group by fr.fid", array('pichome_folderresources', 'pichome_folder', $fids)) as $val) {
$datas[$val['fid']]['sum'] = $val['num'];
$datas[$val['fid']]['fname'] = $val['fname'];
}
}
return $datas;
}
public function fetch_like_words($keyword, $limit = 10)
{
$likewords = [];
$presql = " case when keywords like %s then 3 when keywords like %s then 2 when keywords like %s then 1 end as rn";
$wheresql = " keywords like %s";
$params = [$keyword . '%', '%' . $keyword, '%' . $keyword . '%', $this->_table, '%' . $keyword . '%'];
foreach (DB::fetch_all("select keywords,$presql from %t where $wheresql order by rn desc limit 0,$limit", $params) as $v) {
$likewords[] = $v['keywords'];
}
return $likewords;
}
public function delete_by_appid($appid)
{
$delid = [];
foreach (DB::fetch_all("select id from %t where appid = %s", array($this->_table, $appid)) as $v) {
$delid[] = $v['id'];
}
return parent::delete($delid);
}
}
<?php
if (!defined('IN_OAOOA')) {
exit('Access Denied');
}
class table_pichome_searchrecent extends dzz_table
{
public function __construct()
{
$this->_table = 'pichome_searchrecent';
$this->_pk = 'id';
$this->_pre_cache_key = 'pichome_searchrecent';
$this->_cache_ttl = 3600;
parent::__construct();
}
public function add_search($keyword, $appid = '', $ktype = 0)
{
global $_G;
$wheresql = ' keywords = %s and ktype=%d ';
$params = array($this->_table, $keyword, $ktype);
if ($_G['uid']) {
$wheresql .= ' and uid = %d ';
$params[] = $_G['uid'];
}
if ($appid) {
$wheresql .= ' and appid = %s ';
$params[] = $appid;
}
if ($data = DB::fetch_first("select id,hots from %t where$wheresql", $params)) {
$hots = $data['hots'] + 1;
return parent::update($data['id'], array('hots' => $hots, 'dateline' => TIMESTAMP));
} else {
$setarr = [
'keywords' => $keyword,
'ktype' => $ktype,
'dateline' => TIMESTAMP,
'uid' => isset($_G['uid']) ? $_G['uid'] : 0,
'hots' => 1,
'appid' => $appid
];
return parent::insert($setarr);
}
}
//查询最近搜索标签
public function fetch_renctent_search_tag($appid = '', $limit = 8)
{
global $_G;
$wheresql = ' s.ktype = 1 ';
$params = array($this->_table, 'pichome_tag');
if ($appid) {
$wheresql .= ' and s.appid = %s ';
$params[] = $appid;
}
if ($_G['uid']) {
$wheresql .= ' and s.uid = %d';
$params[] = $_G['uid'];
}
$datas = [];
foreach (DB::fetch_all("select s.keywords,t.tid from %t s left join %t t on s.keywords = t.tagname where
$wheresql and t.tid > 0 order by s.hots desc,s.dateline desc limit 0,$limit", $params) as $v) {
$datas[$v['tid']] = $v['keywords'];
}
return $datas;
}
public function fetch_hotkeyword_by_appid($appid = '', $limit = 16, $noids = array(), $datas = array())
{
/* $start = strtotime(date("Y-m-d", strtotime("-7 day")));
$end = strtotime(dgmdate(time(), 'Y-m-d')) + 86400;*/
$params = array($this->_table/*, $start, $end*/);
$count = DB::result_first("select count(id) from %t where 1 order by hots desc limit 0,$limit", $params);
//print_r(DB::fetch_all("select keywords,id from %t where 1 order by hots desc limit 0,$limit", $params));die;
foreach (DB::fetch_all("select keywords,id from %t where 1 order by hots desc limit 0,$limit", $params) as $v) {
$data = $this->get_data_by_keyword($v['keywords']);
if (!$data) {
parent::delete($v['id']);
} else {
$datas[$v['id']] = $data;
}
}
// print_r($datas);die;
$resultcount = count($datas);
//如果有关键词没有结果,并且结果数量大于查询出来的数量
if ($resultcount < $limit && $count > $limit) {
$ids = array_keys($datas);
$limit = $limit - $resultcount;
$datas = $this->fetch_hotkeyword_by_appid($appid, $limit, $ids, $datas);
}
return $datas;
}
public function get_data_by_keyword($keyword)
{
$rid = DB::result_first("select r.rid from %t r left join %t ra on ra.rid=r.rid
where ra.searchval LIKE %s order by rand() limit 0,1 ",
array('pichome_resources', 'pichome_resources_attr', '%' . $keyword . '%'));
$tmpdata = C::t('pichome_resources')->geticondata_by_rid($rid);
if (!$tmpdata) {
return false;
} else {
$tmpdata['keyword'] = $keyword;
}
return $tmpdata;
}
//查询最近搜索分类
public function fetch_renctent_search_foldername($appid, $limit = 10)
{
global $_G;
$wheresql = ' s.ktype = 2 and s.appid = %s';
$params = array($this->_table, 'pichome_folder', $appid);
if ($_G['uid']) {
$wheresql .= ' and s.uid = %d';
$params[] = $_G['uid'];
}
$datas = [];
foreach (DB::fetch_all("select s.keywords,f.fid from %t s left join %t f on f.fname = s.keywords and f.appid = s.appid
where $wheresql and f.fid !='' and s.hots > 0 order by s.hots desc,s.dateline desc limit 0,$limit", $params) as $v) {
$datas[$v['fid']]['name'] = $v['keywords'];
$datas[$v['fid']]['fid'] = $v['fid'];
}
$fids = array_keys($datas);
if (!empty($fids)) {
foreach (DB::fetch_all("select f.fname,f.fid,count(fr.rid) as num from %t fr
left join %t f on f.fid=fr.fid where fr.fid in(%n) group by fr.fid", array('pichome_folderresources', 'pichome_folder', $fids)) as $val) {
$datas[$val['fid']]['sum'] = $val['num'];
$datas[$val['fid']]['fname'] = $val['fname'];
}
}
return $datas;
}
public function fetch_like_words($keyword, $limit = 10)
{
$likewords = [];
$presql = " case when keywords like %s then 3 when keywords like %s then 2 when keywords like %s then 1 end as rn";
$wheresql = " keywords like %s";
$params = [$keyword . '%', '%' . $keyword, '%' . $keyword . '%', $this->_table, '%' . $keyword . '%'];
foreach (DB::fetch_all("select keywords,$presql from %t where $wheresql order by rn desc limit 0,$limit", $params) as $v) {
$likewords[] = $v['keywords'];
}
return $likewords;
}
public function delete_by_appid($appid)
{
$delid = [];
foreach (DB::fetch_all("select id from %t where appid = %s", array($this->_table, $appid)) as $v) {
$delid[] = $v['id'];
}
return parent::delete($delid);
}
}

View File

@@ -1,66 +1,66 @@
<?php
if (!defined('IN_OAOOA')) {
exit('Access Denied');
}
class table_pichome_taggroup extends dzz_table
{
public function __construct()
{
$this->_table = 'pichome_taggroup';
$this->_pk = 'cid';
$this->_pre_cache_key = 'pichome_taggroup';
$this->_cache_ttl = 3600;
parent::__construct();
}
public function insert($setarr)
{
$cid = $setarr['cid'];
if ($taggroup = DB::fetch_first("select * from %t where cid = %s", array($this->_table, $cid))) {
unset($setarr['cid']);
if ($taggroup['catname'] != $setarr['catname']) parent::update($cid, $setarr);
return $cid;
} else {
if (parent::insert($setarr)) return $cid;
}
}
public function fetch_cid_by_appid($appid)
{
$cids = [];
foreach (DB::fetch_all("select cid from %t where appid = %s", array($this->_table, $appid)) as $v) {
$cids[] = $v['cid'];
}
return $cids;
}
public function delete_by_cids($cids)
{
if (!is_array($cids)) $cids = (array)$cids;
if (!empty($cids)) {
C::t('pichome_tagrelation')->delete_by_cids($cids);
parent::delete($cids);
}
}
public function delete_by_appid($appid)
{
$delid = [];
foreach (DB::fetch_all("select cid from %t where appid = %s", array($this->_table, $appid)) as $v) {
$delid[] = $v['cid'];
}
return parent::delete($delid);
}
public function fetch_by_appid($appid)
{
$data = [];
return DB::fetch_all("select * from %t where appid = %s", array($this->_table, $appid));
}
<?php
if (!defined('IN_OAOOA')) {
exit('Access Denied');
}
class table_pichome_taggroup extends dzz_table
{
public function __construct()
{
$this->_table = 'pichome_taggroup';
$this->_pk = 'cid';
$this->_pre_cache_key = 'pichome_taggroup';
$this->_cache_ttl = 3600;
parent::__construct();
}
public function insert($setarr)
{
$cid = $setarr['cid'];
if ($taggroup = DB::fetch_first("select * from %t where cid = %s and appid = %s", array($this->_table, $cid,$setarr['appid']))) {
unset($setarr['cid']);
if ($taggroup['catname'] != $setarr['catname']) parent::update($cid, $setarr);
return $cid;
} else {
if (parent::insert($setarr)) return $cid;
}
}
public function fetch_cid_by_appid($appid)
{
$cids = [];
foreach (DB::fetch_all("select cid from %t where appid = %s", array($this->_table, $appid)) as $v) {
$cids[] = $v['cid'];
}
return $cids;
}
public function delete_by_cids($cids)
{
if (!is_array($cids)) $cids = (array)$cids;
if (!empty($cids)) {
C::t('pichome_tagrelation')->delete_by_cids($cids);
parent::delete($cids);
}
}
public function delete_by_appid($appid)
{
$delid = [];
foreach (DB::fetch_all("select cid from %t where appid = %s", array($this->_table, $appid)) as $v) {
$delid[] = $v['cid'];
}
return parent::delete($delid);
}
public function fetch_by_appid($appid)
{
$data = [];
return DB::fetch_all("select * from %t where appid = %s", array($this->_table, $appid));
}
}

View File

@@ -0,0 +1,29 @@
<?php
if (!defined('IN_OAOOA')) {
exit('Access Denied');
}
class table_pichome_taggroup_relation extends dzz_table
{
public function __construct()
{
$this->_table = 'pichome_taggroup_relation';
$this->_pk = 'id';
$this->_pre_cache_key = 'pichome_taggroup_relation';
$this->_cache_ttl = 3600;
parent::__construct();
}
//获取库下所有标签分类对应数据
public function fetch_by_appid($appid){
$data = [];
foreach(DB::fetch_all("select * from %t where appid = %s",array($this->_table,$appid)) as $v){
$data[$v['gid']] = $v;
}
return $data;
}
public function fetch_cid_by_gid($gid,$appid){
return DB::result_first("select cid from %t where gid = %d and appid = %s",array($this->_table,$gid,$appid));
}
}

View File

@@ -1,51 +1,51 @@
<?php
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
class table_pichome_tagrelation extends dzz_table
{
public function __construct()
{
$this->_table = 'pichome_tagrelation';
$this->_pk = 'id';
$this->_pre_cache_key = 'pichome_tagrelation';
$this->_cache_ttl = 3600;
parent::__construct();
}
public function insert($setarr){
if($id = DB::fetch_first("select id from %t where cid = %s and tid = %d",array($this->_table,$setarr['cid'],$setarr['tid']))){
return $id;
}else{
//同一库下一个标签只能归属于一个分类
$this->delete_by_tpid($setarr['tid'],$setarr['appid']);
return parent::insert($setarr,1);
}
}
public function delete_by_tpid($tid,$appid){
//兼容以修复已经出现错误的数据
$ids = [];
foreach(DB::fetch_all("select id from %t where tid = %d and appid =%s",array($this->_table,$tid,$appid)) as $v){
$ids[] = $v['id'];
}
//$id = DB::result_first("select id from %t where tid = %d and appid =%s",array($this->_table,$tid,$appid));
if(!empty($ids))return parent::delete($ids);
return true;
}
public function delete_by_cids($cids){
if(!is_array($cids)) $cids = (array)$cids;
$ids = [];
foreach(DB::fetch_all("select id from %t where cid in(%n)",array($this->_table,$cids)) as $v){
$ids[] = $v['id'];
}
parent::delete($ids);
}
public function delete_by_appid($appid)
{
$delid =[];
foreach (DB::fetch_all("select id from %t where appid = %s",array($this->_table,$appid)) as $v){
$delid[] = $v['id'];
}
return parent::delete($delid);
}
<?php
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
class table_pichome_tagrelation extends dzz_table
{
public function __construct()
{
$this->_table = 'pichome_tagrelation';
$this->_pk = 'id';
$this->_pre_cache_key = 'pichome_tagrelation';
$this->_cache_ttl = 3600;
parent::__construct();
}
public function insert($setarr){
if($id = DB::fetch_first("select id from %t where cid = %s and tid = %d",array($this->_table,$setarr['cid'],$setarr['tid']))){
return $id;
}else{
//同一库下一个标签只能归属于一个分类
$this->delete_by_tpid($setarr['tid'],$setarr['appid']);
return parent::insert($setarr);
}
}
public function delete_by_tpid($tid,$appid){
//兼容以修复已经出现错误的数据
$ids = [];
foreach(DB::fetch_all("select id from %t where tid = %d and appid =%s",array($this->_table,$tid,$appid)) as $v){
$ids[] = $v['id'];
}
//$id = DB::result_first("select id from %t where tid = %d and appid =%s",array($this->_table,$tid,$appid));
if(!empty($ids))return parent::delete($ids);
return true;
}
public function delete_by_cids($cids){
if(!is_array($cids)) $cids = (array)$cids;
$ids = [];
foreach(DB::fetch_all("select id from %t where cid in(%n)",array($this->_table,$cids)) as $v){
$ids[] = $v['id'];
}
parent::delete($ids);
}
public function delete_by_appid($appid)
{
$delid =[];
foreach (DB::fetch_all("select id from %t where appid = %s",array($this->_table,$appid)) as $v){
$delid[] = $v['id'];
}
return parent::delete($delid);
}
}

View File

@@ -1,87 +1,118 @@
<?php
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
class table_pichome_vapp extends dzz_table
{
public function __construct()
{
$this->_table = 'pichome_vapp';
$this->_pk = 'appid';
$this->_pre_cache_key = 'pichome_vapp';
$this->_cache_ttl = 3600;
parent::__construct();
}
private function code62($x) {
$show = '';
while($x > 0) {
$s = $x % 62;
if ($s > 35) {
$s = chr($s+61);
} elseif ($s > 9 && $s <=35) {
$s = chr($s + 55);
}
$show .= $s;
$x = floor($x/62);
}
return $show;
}
public function getSid($url) {
$url = crc32($url);
$result = sprintf("%u", $url);
return self::code62($result);
}
public function insert($setarr){
$path = $setarr['path'];
if($appid = DB::result_first("select appid from %t where path = %s",array($this->_table,$path))){
return $appid;
}else{
$setarr['appid'] = $this->getSid($setarr['path']);
if(parent::insert($setarr)){
return $setarr['appid'];
}
}
}
public function fetch_by_path($path){
return DB::fetch_first("select * from %t where path = %s",array($this->_table,$path));
}
//获取不重复的应用名称
public function getNoRepeatName($name)
{
static $i = 0;
if (DB::result_first("select COUNT(*) from %t where appname=%s ", array($this->_table, $name))) {
$name = preg_replace("/\(\d+\)/i", '', $name) . '(' . ($i + 1) . ')';
$i += 1;
return $this->getNoRepeatName($name);
} else {
return $name;
}
}
//删除虚拟应用
public function delete_vapp_by_appid($appid){
//删除文件表数据
C::t('pichome_resources')->delete_by_appid($appid);
//删除目录表数据
C::t('pichome_folder')->delete_by_appid($appid);
//删除目录文件关系表数据
C::t('pichome_folderresources')->delete_by_appid($appid);
//删除标签分类表数据
C::t('pichome_taggroup')->delete_by_appid($appid);
//删除标签关系表数据
C::t('pichome_tagrelation')->delete_by_appid($appid);
//删除最近搜索表数据
C::t('pichome_searchrecent')->delete_by_appid($appid);
return parent::delete($appid);
}
public function fetch_all_sharedownlod(){
$downshare = array();
foreach(DB::fetch_all("select appid,download,share from %t where 1",array($this->_table)) as $v){
$downshare[$v['appid']]=['share'=>$v['share'],'download'=>$v['download']];
}
return $downshare;
}
<?php
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
class table_pichome_vapp extends dzz_table
{
public function __construct()
{
$this->_table = 'pichome_vapp';
$this->_pk = 'appid';
$this->_pre_cache_key = 'pichome_vapp';
$this->_cache_ttl = 3600;
parent::__construct();
}
private function code62($x) {
$show = '';
while($x > 0) {
$s = $x % 62;
if ($s > 35) {
$s = chr($s+61);
} elseif ($s > 9 && $s <=35) {
$s = chr($s + 55);
}
$show .= $s;
$x = floor($x/62);
}
return $show;
}
public function getSid($url) {
$microtime = microtime();
list($msec, $sec) = explode(' ', $microtime);
$msec = $msec * 1000000;
$url = crc32($url.$sec.random(6).$msec);
$result = sprintf("%u", $url);
$sid = self::code62($result);
$len = strlen($sid);
if($len < 6){
$sid .= random(1);
}
if(strlen($sid) > 6){
$sid = substr($sid,0,6);
}
if(DB::result_first("select appid from %t where appid = %s",array($this->_table,$sid))){
$sid = $this->getSid($url);
}
return $sid;
}
public function insert($setarr){
//如果为oaooa库时
if($setarr['type'] == 2){
$setarr['path'] =$setarr['did'].'_'.$setarr['kuid'].'_'.$setarr['fid'];
$path = md5($setarr['path']);
}else{
$path = $setarr['path'];
}
if($appid = DB::result_first("select appid from %t where path = %s and isdelete = 0",array($this->_table,$setarr['path']))){
parent::update($appid,$setarr);
return $appid;
}
//生成appid
$setarr['appid'] = $this->getSid($path);
if(parent::insert($setarr)){
return $setarr['appid'];
}
}
public function fetch_by_path($path){
return DB::fetch_first("select * from %t where path = %s",array($this->_table,$path));
}
//获取不重复的应用名称
public function getNoRepeatName($name)
{
static $i = 0;
if (DB::result_first("select COUNT(*) from %t where appname=%s ", array($this->_table, $name))) {
$name = preg_replace("/\(\d+\)/i", '', $name) . '(' . ($i + 1) . ')';
$i += 1;
return $this->getNoRepeatName($name);
} else {
return $name;
}
}
//删除虚拟应用
public function delete_vapp_by_appid($appid){
//删除文件表数据
C::t('pichome_resources')->delete_by_appid($appid);
//删除目录表数据
C::t('pichome_folder')->delete_by_appid($appid);
//删除目录文件关系表数据
C::t('pichome_folderresources')->delete_by_appid($appid);
//删除标签分类表数据
C::t('pichome_taggroup')->delete_by_appid($appid);
//删除标签关系表数据
C::t('pichome_tagrelation')->delete_by_appid($appid);
//删除最近搜索表数据
C::t('pichome_searchrecent')->delete_by_appid($appid);
//resources表数据未完成删除前不允许删除vapp表
if(DB::result_first("select count(rid) from %t where appid = %s",array('pichome_resources',$appid))){
return ;
}else{
if(is_dir(getglobal('setting/attachdir').'pichomethumb/'.$appid)){
removedirectory(getglobal('setting/attachdir').'pichomethumb/'.$appid);
}
return parent::delete($appid);
}
}
public function fetch_all_sharedownlod(){
$downshare = array();
foreach(DB::fetch_all("select * from %t where 1",array($this->_table)) as $v){
$downshare[$v['appid']]=$v;
}
return $downshare;
}
}

View File

@@ -1,18 +1,18 @@
<?php
/*
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
* @license https://www.oaooa.com/licenses/
*
* @link https://www.oaooa.com
* @author zyx(zyx@oaooa.com)
*/
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
if(!defined('CORE_VERSION')) {
define('CORE_VERSION', 'beta2.0');
define('CORE_VERSION_LEVEL', 'Pichome');
define('CORE_RELEASE', '20211110');
define('CORE_FIXBUG' , '20000000');
<?php
/*
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
* @license https://www.oaooa.com/licenses/
*
* @link https://www.oaooa.com
* @author zyx(zyx@oaooa.com)
*/
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
if(!defined('CORE_VERSION')) {
define('CORE_VERSION', 'beta3.0');
define('CORE_VERSION_LEVEL', 'Pichome');
define('CORE_RELEASE', '20211208');
define('CORE_FIXBUG' , '03000000');
}

View File

@@ -0,0 +1,8 @@
<?php
if (!defined('IN_OAOOA')) {
exit('Access Denied');
}
ignore_user_abort(true);
@set_time_limit(0);
dfsockopen(getglobal('localurl') . 'index.php?mod=pichome&op=delete', 0, '', '', false, '', 1);

View File

@@ -0,0 +1,7 @@
<?php
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
ignore_user_abort(true);
@set_time_limit(0);
dfsockopen(getglobal('localurl'). 'index.php?mod=imageColor&op=index',0, '', '', false, '', 1);

View File

@@ -0,0 +1,8 @@
<?php
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
ignore_user_abort(true);
@set_time_limit(0);
dfsockopen(getglobal('localurl'). 'index.php?mod=ffmpeg&op=getinfo',0, '', '', false, '', 1);

View File

@@ -0,0 +1,7 @@
<?php
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
ignore_user_abort(true);
@set_time_limit(0);
dfsockopen(getglobal('localurl'). 'index.php?mod=ffmpeg&op=thumb',0, '', '', false, '', 1);

View File

@@ -1,22 +1,15 @@
<?php
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
//ignore_user_abort(true);
@set_time_limit(0);
$appdata = DB::fetch_all("select * from %t where 1 ",array('pichome_vapp'));
foreach($appdata as $v){
$jsonfile = DZZ_ROOT.'library/' . $v['path'] . '/mtime.json';
if (!file_exists($jsonfile)) {
//删除库
C::t('#pichome#pichome_vapp')->delete_vapp_by_appid($v['appid']);
}else{
if($v['state'] == 1){
dfsockopen(getglobal('localurl'). 'index.php?mod=pichome&op=exportfile&appid='.$v['appid'],0, '', '', false, '', 1);
}elseif($v['state'] == 2){
dfsockopen(getglobal('localurl'). 'index.php?mod=pichome&op=exportfilecheck&appid='.$v['appid'],0, '', '', false, '', 1);
}
}
<?php
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
ignore_user_abort(true);
@set_time_limit(0);
$appdata = DB::fetch_all("select * from %t where isdelete = 0 ",array('pichome_vapp'));
foreach($appdata as $v){
if($v['state'] == 1){
dfsockopen(getglobal('localurl'). 'index.php?mod=pichome&op=exportfile&appid='.$v['appid'],0, '', '', false, '', 1);
}elseif($v['state'] == 2){
dfsockopen(getglobal('localurl'). 'index.php?mod=pichome&op=exportfilecheck&appid='.$v['appid'],0, '', '', false, '', 1);
}
}

View File

@@ -0,0 +1,96 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>{lang about}</title>
<link rel="stylesheet" href="static/jquery_weui/css/weui.min.css">
<link rel="stylesheet" href="static/jquery_weui/css/jquery-weui.min.css">
<link rel="stylesheet" href="static/dzzicon/icon.css">
<script type="text/javascript" src="static/jquery/jquery.min.js"></script>
<style>
html, body {
height: 100%;
}
.about-container {
width: 100%;
height: 100%;
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center;
-webkit-align-content: center;
align-content: center;
-webkit-justify-content: center;
justify-content: center;
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
}
.wrapper {
text-align: center;
}
.about-body p {
margin-bottom: 10px;
}
a {
cursor: pointer;
color: #3779ff;
}
.about-body .logo {
padding: 10px;
margin-bottom: 0;
}
.about-body .name {
font-size: 28px;
margin-bottom: 20px;
}
.about-body .name>span {
padding: 0 2px;
}
.about-body p .guide {
color: #999;
}
.about-copyright {
color: #999;
font-size: 12px;
text-align: center;
padding: 10px;
}
.about-copyright>a {
color: #999;
}
.about-copyright>a:hover {
color: #999;
text-decoration: underline
}
</style>
</head>
<body>
<div class="about-container">
<div class="wrapper">
<div class="modal-body about-body">
<p class="logo"> <img src="$about[logo]" /> </p>
<p class="name">
<!--{if $about['name_zh']}-->
<span class="name-zh">$about[name_zh]</span>
<!--{/if}-->
<!--{if $about['name_en']}-->
<span class="name-en"><b>Dzz</b>$about[name_en]</span>
<!--{/if}-->
</p>
<div class="detail">
<!--{if $about['version']}-->
<p class="version"> <span class="guide">{lang about_current_version}:</span> <span class="text">{eval echo lang('V_'.$license['license_version'])} $about[version]</span> </p>
<!--{/if}-->
<p class="license"> <span class="guide">{lang license_user_sum}:</span> <span class="text">{$ucount} / {eval echo $license[license_limit]?$license[license_limit]:lang('unlimited')}</span> </p>
<p class="license"> <span class="guide">{lang license_to}:</span> <span class="text">{$license[license_company]}</a></span> </p>
<p class="support"> <span class="guide">{lang service_and_support}:</span> <span class="text"> <a href="http://help.oaooa.com" target="_blank">www.oaooa.com</a></span> </p>
</div>
</div>
<div class="about-copyright">Copyright ©2012-{eval echo dgmdate(TIMESTAMP,'Y');} <a href="https://www.oaooa.com" target="_blank" >oaooa.com</a>&nbsp; All Rights Reserved</div>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,5 @@
<script type="text/javascript">var DZZSCRIPT='{DZZSCRIPT}',LANG='{$_G[language]}', STATICURL = 'static/', IMGDIR = '{$_G[setting][imgdir]}', VERHASH = '{VERHASH}', charset = '{CHARSET}', dzz_uid = '$_G[uid]', cookiepre = '{$_G[config][cookie][cookiepre]}', cookiedomain = '{$_G[config][cookie][cookiedomain]}', cookiepath = '{$_G[config][cookie][cookiepath]}',attackevasive = '{$_G[config][security][attackevasive]}', disallowfloat = '{$_G[setting][disallowfloat]}', REPORTURL = '$_G[currenturl_encode]', SITEURL = '$_G[siteurl]', JSPATH = '$_G[setting][jspath]',MOD_PATH='{MOD_PATH}',APP_URL='{MOD_URL}',MOD_URL='{MOD_URL}';VAPP_URL='{VAPP_URL}';</script>
</head>
<body id="nv_{$_G[basescript]}" class="$bodyClass" >
<div id="append_parent" style="z-index:99999;"></div>
<div id="ajaxwaitid" style="z-index:99999;"></div>

View File

@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset={CHARSET}" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title><!--{if !empty($navtitle)}-->$navtitle - <!--{/if}-->$_G[setting][sitename] </title>
<meta name="keywords" content="{if !empty($_G[setting][metakeywords])}{echo htmlspecialchars($_G[setting][metakeywords])}{/if}" />
<meta name="description" content="{if !empty($_G[setting][metadescription])}{echo htmlspecialchars($_G[setting][metadescription])} {/if}" />
<meta name="generator" content="oaooa" />
<meta name="author" content="oaooa" />
<meta name="copyright" content="2012-{eval echo dgmdate(TIMESTAMP,'Y-m-d');} www.oaooa.com" />
<meta name="MSSmartTagsPreventParsing" content="True" />
<meta http-equiv="MSThemeCompatible" content="Yes" />
<meta name="renderer" content="webkit">
<base href="{$_G['siteurl']}" />
<link rel="stylesheet" type="text/css" href="static/jquery_weui/css/weui.min.css?{VERHASH}">
<link rel="stylesheet" type="text/css" href="static/jquery_weui/css/jquery-weui.min.css?{VERHASH}" >
<link rel="stylesheet" type="text/css" href="static/dzzicon/icon.css?{VERHASH}"/>
<script type="text/javascript" src="static/jquery/jquery.min.js?{VERHASH}"></script>
<script type="text/javascript" src="static/jquery/jquery.json-2.4.min.js?{VERHASH}"></script>
<script src="static/jquery_weui/js/jquery-weui.min.js?{VERHASH}" type="text/javascript" charset="utf-8"></script>
<script src="static/jquery_weui/js/swiper.min.js?{VERHASH}" type="text/javascript" charset="utf-8"></script>
<script src="static/jquery_weui/js/appevent.js?{VERHASH}" type="text/javascript" charset="utf-8"></script>

View File

@@ -0,0 +1,139 @@
<!--{template common/header_ajax}-->
<!--{if $_GET['action']=='setEventkey'}-->
<style>
#fwin_setEvent .modal-dialog{max-width:450px;}
</style>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title">$typetitle[$type]</h4>
</div>
<div class="modal-body" style="padding:30px;">
<form class="form-horizontal">
<input type="hidden" id="eventkey" />
<!--{if $type=='click'}-->
<div class="form-group">
<!--{if $menu_select[click]}-->
<select class="form-control" id="js_select_click" onchange="eventkey_select_change(this)">
<option value="" data-url="" >{lang please_choose}</option>
<!--{loop $menu_select[click] $key $value}-->
<option value="$key" >$value</option>
<!--{/loop}-->
<option value="keys" >{lang custom}KEY</option>
</select>
<!--{else}-->
<input type="hidden" id="js_select_click" value="keys" />
<input type="text" class="form-control js_input_limit" data-limit="64" id="js_select_click_input" value="" >
<p class="help-inline">{lang menu_information_not_more_than_64_words}</p>
<p class="help-inline">{lang set_value_interface_function_effect}</p>
<!--{/if}-->
</div>
<div class="form-group hidden">
<input type="text" class="form-control js_input_limit" data-limit="64" id="js_select_click_input" value="" >
<p class="help-inline">{lang menu_information_not_more_than_64_words}</p>
<p class="help-inline">{lang set_value_interface_function_effect}</p>
</div>
<!--{else}-->
<div class="form-group">
<!--{if $menu_select[link]}-->
<select class="form-control" id="js_select_link" onchange="eventkey_select_change(this)">
<option value="" data-url="" >{lang please_choose}</option>
<!--{loop $menu_select[link] $key $value}-->
<option value="$key" >$value</option>
<!--{/loop}-->
<option value="links">{lang custom_link}</option>
</select>
<!--{else}-->
<input type="hidden" id="js_select_link" value="links" />
<input type="text" class="form-control" id="js_select_link_input" value="" >
<span class="help-inline">{lang member_click_skip_link}</span>
<!--{/if}-->
</div>
<div class="form-group hidden">
<input type="text" class="form-control" id="js_select_link_input" value="">
<span class="help-inline">{lang member_click_skip_link}</span>
</div>
<!--{/if}-->
</form>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary btn-width" data-dismiss="modal" onclick="setEventkeyComplete()"><strong>{lang confirms}</strong></button>&nbsp;&nbsp; <button type="button" data-dismiss="modal" class="btn btn-default"><strong>{lang cancel}</strong></button>
</div>
<script type="text/javascript" reload="1">
jQuery('.fwinmask .focus').select();
var dataid='$_GET[dataid]';
var menuarr=$json_menu_select;
var type='$type';
if(dataid!=''){
var li=jQuery('.js_li[data-id='+dataid+']');
if(type=='click'){
var val=li.attr('data-key');
if(!val ||(val && !menuarr['click'][val])){
val='keys';
}
jQuery('#js_select_click').val(val);
jQuery('#eventkey').val(val);
jQuery('#js_select_click_input').val(val);
if(val=='keys'){
jQuery('#js_select_click_input').parent().removeClass('hidden').end().val(li.attr('data-key')).focus();
}
}else{
var val=li.attr('data-url');
if(!val ||(val && !menuarr['link'][val])){
val='links';
}
//jQuery('#js_link_select').val(val);
jQuery('#js_select_link').val(val);
jQuery('#eventkey').val(val);
jQuery('#js_select_link_input').val(val);
if(val=='links'){
jQuery('#js_select_link_input').parent().removeClass('hidden').end().val(li.attr('data-url')).focus();
}
}
}
function eventkey_select_change(obj){
var el=jQuery(obj);
if(el.val()=='keys'){
jQuery('#js_select_click_input').parent().removeClass('hidden').end().focus();
}else{
jQuery('#js_select_click_input').parent().addClass('hidden');
}
if(el.val()=='links'){
jQuery('#js_select_link_input').parent().removeClass('hidden').end().focus();
}else{
jQuery('#js_select_link_input').parent().addClass('hidden');
}
jQuery('#eventkey').val(el.val());
}
function setEventkeyComplete(){
var li=jQuery('.js_li[data-id='+dataid+']');
var val=jQuery('#eventkey').val();
if(val=='') return;
if(type=='click'){
if(val=='keys'){
val=jQuery('#js_select_click_input').val();
}
li.attr('data-type','click');
li.attr('data-key',val);
li.find('.btn-group').replaceWith('<a class=" pull-right js_click " href="javascript:;" title="{lang menu}KEY" onclick="setEventkey(this,\'click\');return false"><span class="icon icon_click_gray"></span></a>');
}else{
if(val=='links'){
val=jQuery('#js_select_link_input').val();
}
li.attr('data-type','view');
li.attr('data-url',val);
li.find('.btn-group').replaceWith('<a class=" pull-right js_link" href="javascript:;" title="{lang skip_links}" onclick="setEventkey(this,\'link\');return false"><span class="icon icon_link_gray"></span></a>');
}
}
</script>
<!--{/if}-->
<!--{template common/footer_ajax}-->

View File

@@ -0,0 +1,232 @@
<style>
.group-tabul{
margin-left: 0px;
padding-left: 0px;
float: left;
}
.line {
height: 2px;
margin: 10px 0;
font-size: 0;
overflow: hidden;
background-color: transparent;
border-width: 0;
border-top: 1px solid #e7e7e7;
border-bottom: 1px solid #FFF;
}
/*.pull-in {*/
/*margin-left: -15px;*/
/*margin-right: -15px;*/
/*}*/
/*.line-dashed {
border-style: dashed;
background: transparent;
}*/
.form-horizontal .form-group {
margin-right: 0;
margin-left: 0;
}
.line-lg {
margin-top: 15px;
margin-bottom: 15px;
}
.relative {
position: relative;
}
.form-group {
margin-bottom: 0;
}
.copy-success {
position: absolute;
left: -210px;
top: -15px;
padding: 8px;
}
.absoluter {
position: absolute;
right: 0;
top: 0;
padding: 5px;
}
.panel-body {
padding: 15px 0;
}
.ul_hide{
display: block;
}
.form-group .input-black .input-animate {
background-image: -webkit-gradient(linear, left top, left bottom, from(#4c89fb), to(#4c89fb)), -webkit-gradient(linear, left top, left bottom, from(#e6e8eb), to(#e6e8eb));
background-image: -webkit-linear-gradient(#4c89fb, #4c89fb), -webkit-linear-gradient(#e6e8eb, #e6e8eb);
background-image: -o-linear-gradient(#4c89fb, #4c89fb), -o-linear-gradient(#e6e8eb, #e6e8eb);
background-image: linear-gradient(#4c89fb, #4c89fb), linear-gradient(#e6e8eb, #e6e8eb);
}
.form-group .input-black .input-animate.animate {
background-image: -webkit-gradient(linear, left top, left bottom, from(#4c89fb), to(#4c89fb)), -webkit-gradient(linear, left top, left bottom, from(#e6e8eb), to(#e6e8eb));
background-image: -webkit-linear-gradient(#4c89fb, #4c89fb), -webkit-linear-gradient(#e6e8eb, #e6e8eb);
background-image: -o-linear-gradient(#4c89fb, #4c89fb), -o-linear-gradient(#e6e8eb, #e6e8eb);
background-image: linear-gradient(#4c89fb, #4c89fb), linear-gradient(#e6e8eb, #e6e8eb);
}
</style>
<div class="main-header clearfix">
<ul class="group-tabul" style="margin-bottom:0px">
<li class="active"><a href="{$baseurl_info}">{eval echo $base_info_title?$base_info_title:'{lang application_message}';}</a></li>
<li><a href="{$baseurl_menu}">{eval echo $base_menu_title?$base_menu_title:'{lang application_menu}';}</a></li>
</ul>
</div>
<div class="main-content" style="border-top:1px solid #FFF">
<div class="panel-body" >
<div class="entity-panel-body form-horizontal">
<div class="form-group clearfix relative"> <img src="$wxapp[icon]" style="width:80px;position:absolute;left:20px;top:0px">
<div class=" ml20" style="padding-left:100px;">
<h4 class="relative"><strong>$wxapp[name]</strong></h4>
<p class="relative" style="padding-top:5px">$wxapp[desc]</p>
</div>
</div>
<div class="line line-dashed line-lg pull-in"></div>
<div class="form-group clearfix relative">
<form name="settingform" class="form-horizontal form-horizontal-left" action="$baseurl_info" method="post" style="margin:0">
<input type="hidden" name="settingsubmit" value="true" />
<input type="hidden" name="formhash" value="{FORMHASH}" />
<div class="form-group">
<div class="input-black input-static input-form">
<label class="control-label wxlabel">AgendID</label><br>
<div class="input-animate" style="width: 200px;display: inline-block;margin-top: 15px;">
<input type="text" id="agentid" class="form-control" name="agentid" value="$wxapp[agentid]" placeholder="AgendID">
</div>
<span class="help-inline help-info">{lang access_method_login_application}</span>
</div>
<!--<label class="control-label" for="agentid">AgendID</label>-->
<!--<input id="agentid" type="text" class="form-control" style="width:80px;" name="agentid" value="$wxapp[agentid]" />-->
<!--<span class="help-inline">{lang access_method_login_application}</span>-->
</div>
<div class="form-group">
<div class="input-black input-static input-form">
<label class="control-label wxlabel">Secret</label><br>
<div class="input-animate" style="width: 200px;display: inline-block;margin-top: 15px;">
<input type="text" id="agentid" class="form-control" name="secret" value="$wxapp[secret]" placeholder="Secret">
</div>
<span class="help-inline help-info">{lang access_method_login_application_secret}</span>
</div>
<!--<label class="control-label" for="agentid">Secret</label> -->
<!--<input id="agentid" type="text" class="form-control" style="width:80px;" name="secret" value="$wxapp[secret]" />-->
<!--<span class="help-inline">{lang access_method_login_application_secret}</span>-->
</div>
<div class="form-group">
<div class="input-black input-static input-form">
<label class="control-label wxlabel">{lang application_state}</label><br>
<!--<label class="radio-inline"><input type="radio" name="appstatus" value="0" &lt;!&ndash;{if !$wxapp[status]}&ndash;&gt;checked="checked"&lt;!&ndash;{/if}&ndash;&gt; >{lang open_start}</label>-->
<!--<label class="radio-inline"><input type="radio" name="appstatus" value="1" &lt;!&ndash;{if $wxapp[status]>0}&ndash;&gt;checked="checked"&lt;!&ndash;{/if}&ndash;&gt; >{lang close}</label>-->
<span class="help-inline help-info" style="padding-bottom:0;vertical-align: 0;margin-top: 2px;display: inline-block;padding-left: 0;">{lang application_state_message}</span>
<div style="display:inline-block;margin-bottom: 10px;margin-left: 30px;">
<span class="switch-info">{lang open_start}</span>
<input type="checkbox" class="js-switch-primary" checked="" data-switchery="true">
<script type="text/javascript">
var elem = document.querySelector('.js-switch-primary');
Switchery(elem, {
color: '#62a8ea'
});
</script>
</div>
</div>
<div class="form-group" >
<button type="submit" id="ueditorform_btn" class="btn btn-primary" style="padding:6px 25px;" data-loading-text="{lang In_the_save}" >{lang save}</button>
</div>
</form>
</div>
<div class="line line-dashed line-lg pull-in"></div>
<div class="form-group clearfix padding-left">
<div class="col-sm-12" style="padding: 0">
<p class="form-control-static danger relative"><strong style="font-size: 1em;color: rgba(51, 51, 51, 1);">*{lang need_weixin_enterprises_set}</strong> <a href="http://qy.weixin.qq.com/" target="_blank" class="pull-right btn btn-primary-outline">{lang weixin_enterprises_edit}</a> </p>
</div>
</div>
<!--<div class="line line-dashed line-lg pull-in"></div>-->
<div class="form-group clearfix padding-left margin-10">
<label class="wxlabel-item">
<h5><strong>{lang scope_application_visible}:</strong></h5>
</label>
<div class="wxlabel-info">
<p class="form-control-static relative">{lang top_institutions}<span class="gray">{lang weixin_enterprises_address_book_}</span> </p>
</div>
</div>
<!--<div class="line line-dashed line-lg pull-in"></div>-->
<div class="form-group clearfix padding-left margin-10">
<label class="wxlabel-item">
<h5><strong>{lang trusted_domain_name}:</strong></h5>
</label>
<div class="wxlabel-info">
<p class="">$wxapp[host]<span class="copyBtn-wrap">
<span class="copy-btn js_copy" style="border: none;" data-clipboard-text="$wxapp[host]" title="{lang copy}">{lang copy}</span>
<span class="alert copy-success alert-success hide ">{lang copy_success_paste_need_place}</span> </span> </p>
</div>
</div>
<!--<div class="line line-dashed line-lg pull-in"></div>-->
<div class="form-group clearfix padding-left margin-10">
<label class="col-sm-12" style="padding: 0;color: rgba(104, 120, 146, 1);">
<h5><strong>{lang syntony_URL_configuration_information}:</strong></h5>
</label>
</div>
<div class="form-group clearfix padding-left margin-10">
<label class="wxlabel-item">URL</label>
<div class="wxlabel-info">
<p class="form-control-static relative" style="padding-left:0;">$wxapp[callback] <span class="copyBtn-wrap">
<span class="copy-btn js_copy" data-clipboard-text="$wxapp[callback]" title="{lang copy}">{lang copy}</span>
<span class="alert copy-success alert-success hide ">{lang copy_success_paste_need_place}</span> </span> </p>
</div>
</div>
<div class="form-group clearfix padding-left margin-10">
<label class="wxlabel-item">Token</label>
<div class="wxlabel-info">
<p class="form-control-static relative">$wxapp['token'] <span class="copyBtn-wrap">
<span class="copy-btn js_copy" data-clipboard-text="$wxapp[token]" title="{lang copy}">{lang copy}</span>
<span class="alert copy-success alert-success hide ">{lang copy_success_paste_need_place}</span> </span> </p>
</div>
</div>
<div class="form-group clearfix padding-left margin-10">
<label class="wxlabel-item">AESKey</label>
<div class="wxlabel-info">
<p class="form-control-static relative">$wxapp[encodingaeskey] <span class="copyBtn-wrap">
<span class="copy-btn js_copy" data-clipboard-text="$wxapp[encodingaeskey]" title="{lang copy}">{lang copy}</span>
<span class="alert copy-success alert-success hide ">{lang copy_success_paste_need_place}</span> </span> </p>
</div>
</div>
<div class="line line-dashed line-lg pull-in"></div>
<label class="col-sm-12" style="padding: 0">
<h5><strong>{lang other_configuration_information}</strong></h5>
</label>
<div class="col-sm-12" style="margin-bottom:20px;padding: 0;">
<p class="form-control-static relative">
<img src="$wxapp[otherpic]" style="max-width:100%">
</p>
</div>
</div>
</div>
<script type="text/javascript">
jQuery(document).ready(function(e) {
jQuery('.input-black').each(function() {
InputAnimate.init(jQuery(this));
})
var client = new ZeroClipboard(jQuery('.js_copy'));
client.on( "load", function( client ) {
// alert( "ZeroClipboard SWF is ready!" );
client.on( "complete", function( client,args ) {
var self=this;
jQuery(this).parent().find('.copy-success').removeClass('hide');
window.setTimeout(function(){
jQuery(self).parent().find('.copy-success').addClass('hide');
},1000);
});
});
});
</script>
<script src="static/js/ZeroClipboard/ZeroClipboard.min.js?{VERHASH}"></script>
<script src="static/js/input_field.js"></script>
<!--{template common/footer_simple}-->

View File

@@ -0,0 +1,503 @@
<style>
.group-tabul{
margin-left: 0px;
padding-left: 0px;
float: left;
}
.custom_menu_list {
padding: 2px 15px;
border-top: 1px solid #FFF;
border-bottom: 1px solid #e5e5e5;
height: 38px;
overflow:visible;
}
.custom_menu_list:hover{
background:#F7F7F7;
}
.custom_menu_addName, .custom_menu_name, .custom_menu_subName {
height: 34px;
line-height: 32px;
display: inline-block;
vertical-align: middle;
cursor: pointer;
}
.js_add_second{
padding-left:42px;
}
.custom_menu_list.cm_subname {
padding-left: 42px;
}
.custom_menu_title_text {
padding: 12px 15px 12px 35px;
border-bottom: 1px solid #e5e5e5;
margin:0;
}
.hover_visible{
opacity:0;
_filter: Alpha(opacity=0);
}
.custom_menu_list:hover .hover_visible{
opacity:1;
_filter: Alpha(opacity=100);
}
.custom_menu_list.editing:hover .hover_visible,.custom_menu_list.editing .hover_visible{
display:none;
}
.custom_menu_input{
height: 26px;
border: 1px solid #ddd;
outline: 0;
width: 250px;
padding:0 5px;
display: none;
margin: 2px 0;
}
.custom_menu_notice {
margin-left: 20px;
display: none;
color: #da4a38;
}
.error .custom_menu_input{
border-color:#da4a38;
}
.error .js_input_limit{
border-color:#da4a38;
}
.error .custom_menu_notice{
display:inline-block;
}
.custom_menu_list.editing .custom_menu_subName,.custom_menu_list.editing .custom_menu_name,.custom_menu_list.editing .custom_menu_addName,.custom_menu_list.editing .icon{
display:none;
}
.custom_menu_list.editing .custom_menu_input{
display:inline-block;
}
.icon {
display: inline-block;
width: 24px;
height: 24px;
background-image: url(static/image/common/icon_main.png)!important;
background-repeat: no-repeat!important;
}
.icon_click_gray {
width: 28px;
height: 16px;
background-position: -224px -126px;
}
.icon_link_gray {
width: 20px;
height: 20px;
background-position: -190px -158px;
}
.custom_menu_list .icon_link_gray {
margin: 8px 0 0;
}
.custom_menu_list .icon_click_gray {
margin: 8px -4px 0 0;
}
.custom_menu_list .icon_arrow_down, .custom_menu_list .icon_arrow_right {
margin-right: 8px;
}
.icon_arrow_down {
width: 8px;
height: 8px;
background-position: -64px -96px;
}
.custom_menu_list .icon_add_small {
vertical-align: -3px;
margin-right: 5px;
}
.icon_add_small {
width: 14px;
height: 14px;
background-position: -32px -160px;
}
.icon_edit_gray {
height: 16px;
width: 16px;
background-position: -192px -33px;
}
.custom_menu_list .icon_edit_gray {
vertical-align: middle;
margin-left: 8px;
}
.custom_menu_list .icon_remove {
margin: 8px 0 0 10px;
}
.icon_remove, .icon_remove_gray {
width: 16px;
height: 17px;
background-position: -160px -32px;
}
</style>
<div class="main-header clearfix">
<ul class="group-tabul" style="margin-bottom:0px">
<li><a href="{$baseurl_info}">{eval echo $base_info_title?$base_info_title:'{lang application_message}';}</a></li>
<li class="active"><a href="{$baseurl_menu}">{eval echo $base_menu_title?$base_menu_title:'{lang application_menu}';}</a></li>
</ul>
</div>
<div class="main-content" style="border-top:1px solid #FFF;">
<ul class="help-block text_center custom_menu_title_text ">
<li>{lang creat_three_level_menu}</li>
<li>{lang edit_menu_in_the_user_can_not_see}</li>
<li>{lang menu_release_24_hours_to_update}</li>
<li>{lang drag_can_be_sorted}</li>
</ul>
<div class="custom_menu_mainList_wrap">
<!--{loop $menu[button] $key $value}-->
<div class="custom_cmname_list_wrap">
<div class="custom_menu_list cm_name js_li clearfix" data-id="$key" data-name="$value[name]" data-type="$value[type]" <!--{if $value[type]=='click'}--> data-key="$value[key]"<!--{elseif $value[type]=='view'}-->data-url="$value[url]"<!--{/if}-->>
<a class="icon icon_remove pull-right js_menu_remove hover_visible" href="javascript:;"></a>
<span class="icon icon_arrow_down"></span><span class="custom_menu_name">$value[name]</span>
<!--{if $value[type] && $value[type]=='view'}-->
<a class=" pull-right js_link" href="javascript:;" title="{lang skip_links}" onclick="setEventkey(this,'link');return false"><span class="icon icon_link_gray"></span></a>
<!--{elseif $value[type]}-->
<a class=" pull-right js_click " href="javascript:;" title="{lang menu}KEY" onclick="setEventkey(this,'click');return false"><span class="icon icon_click_gray"></span></a>
<!--{/if}-->
<a class="js_change_name ml10 hover_visible icon icon_edit_gray" href="javascript:;" title="{lang modification}"></a>
<input type="text" class="custom_menu_input js_add_2_menu js_input_limit " value="$value[name]" autofocus data-limit="8">
<span class="custom_menu_notice ">{lang level_1_menu_name_limit_beyond_truncation}</span>
</div>
<div class="custom_menu_list_wrap" data-id="$key">
<!--{loop $value[sub_button] $key1 $value1}-->
<div class="custom_menu_list cm_subname js_li clearfix" data-id="{$key}_{$key1}" data-name="$value1[name]" data-type="$value1[type]" <!--{if $value1[type]=='click'}--> data-key="$value1[key]"<!--{elseif $value1[type]=='view'}-->data-url="$value1[url]"<!--{/if}-->>
<a class="icon icon_remove pull-right js_menu_remove hover_visible" href="javascript:;"></a>
<span class="custom_menu_subName">$value1[name]</span>
<!--{if $value1[type]=='view'}-->
<a class=" pull-right js_link" href="javascript:;" title="{lang skip_links}" onclick="setEventkey(this,'link');return false"><span class="icon icon_link_gray"></span></a>
<!--{elseif $value1[type]=='click'}-->
<a class=" pull-right js_click " href="javascript:;" title="{lang menu}KEY" onclick="setEventkey(this,'click');return false"><span class="icon icon_click_gray"></span></a>
<!--{/if}-->
<a class="js_change_name ml10 hover_visible icon icon_edit_gray" href="javascript:;" title="{lang modification}"></a>
<input type="text" class="custom_menu_input js_add_2_menu js_input_limit" value="$value1[name]" autofocus data-limit="16" >
<span class="custom_menu_notice ">{lang level_2_menu_name_limit_beyond_truncation}</span>
</div>
<!--{/loop}-->
</div>
<div class="custom_menu_list js_add_second" data-id="$key">
<span class="icon icon_add_small"></span>
<span class="custom_menu_addName gray">{lang add_second_level_of_menus}</span>
<input type="text" class="custom_menu_input js_add_2_menu js_input_limit" data-limit="16" autofocus placeholder="{lang level_2_menu_name_limit}">
<span class="custom_menu_notice ">{lang level_2_menu_name_limit_beyond_truncation}</span>
</div>
</div>
<!--{/loop}-->
</div>
<div class="custom_menu_list js_add">
<span class="icon icon_add_small"></span>
<span class="custom_menu_addName gray">{lang add_themselves_menu}</span>
<input type="text" class="custom_menu_input js_add_menu js_input_limit " data-limit="8" autofocus placeholder="{lang level_2_menu_name_limit}">
<span class="custom_menu_notice ">{lang level_1_menu_name_limit_beyond_truncation}</span>
</div>
<div style="padding:10px;">
<button class="btn btn-primary" onclick="menu_save(this)" data-loading-text="{lang In_the_save}" style="width:80px;">{lang save}</button>
&nbsp;&nbsp;<button class="btn btn-success" onclick="menu_publish(this)" data-loading-text="{lang release}" style="width:120px;" <!--{if !$setting['agentid']}-->disabled="disabled"<!--{/if}-->>{lang published_weixin}</button>
&nbsp;&nbsp;<button class="btn btn-danger" onclick="menu_default(this)" data-loading-text="{lang in_recovery}">{lang restore_defaults}</button>
<small class="pull-right gray mt10">{lang release_24_hours_to_update}</small>
</div>
</div>
<script type="text/javascript">
jQuery(document).ready(function(e) {
check_add_second();
jQuery(document).on('click','.js_change_name',function(){
jQuery(this).parent().addClass('editing');
jQuery(this).parent().find('.custom_menu_input').focus();
});
jQuery(document).on('click','.js_add_second',function(){
if(!jQuery('.custom_menu_list_wrap[data-id='+jQuery(this).attr('data-id')+'] .cm_subname').length){//如果一级目录有事件,弹窗提示;
var self=this;
showDialog('{lang use_the_secondary_menu}', 'confirm', '{lang secondary_menu_confirm}', function(){
jQuery(self).addClass('editing').find('.custom_menu_input').focus();
});
}else{
jQuery(this).addClass('editing');
jQuery(this).find('.custom_menu_input').focus();
}
});
jQuery(document).on('click','.js_add',function(){
jQuery(this).addClass('editing');
jQuery(this).find('.custom_menu_input').focus();
});
jQuery(document).on('click','.js_menu_remove',function(){
var li=jQuery(this).parent();
if(li.hasClass('cm_name')){//是主菜单时,删除所有子菜单
jQuery('.custom_menu_list[data-id='+li.attr('data-id')+']').remove();
jQuery('.custom_menu_list_wrap[data-id='+li.attr('data-id')+']').remove();
}
li.remove();
check_add_second();
});
jQuery(document).on('keyup','.js_input_limit',function(e){
var val=jQuery(this).val();
if(mb_strlen(val)>jQuery(this).attr('data-limit')){
jQuery(this).parent().addClass('error');
}else{
jQuery(this).parent().removeClass('error');
}
if(e.keyCode=='13'){
jQuery(this).trigger('blur');
}
});
jQuery(document).on('blur','.custom_menu_input',function(){
var li=jQuery(this).parent();
var cut_val=mb_cutstr(this.value,jQuery(this).attr('data-limit'));
if(this.value){
if(li.hasClass('js_add_second')){
var pid=li.attr('data-id');
if(jQuery('.custom_menu_list_wrap[data-id='+pid+'] .cm_subname').length<5){//判定是否已经有5个二级菜单了
var html='<div class="custom_menu_list cm_subname js_li clearfix" data-name="'+cut_val+'">'
+' <a class="icon icon_remove pull-right js_menu_remove hover_visible" href="javascript:;"></a>'
+' <span class="custom_menu_subName">'+cut_val+'</span>'
+' <div class="btn-group pull-right eventkey">'
+' <button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">'
+' {lang add_the_event_type} <span class="caret"></span>'
+' </button>'
+' <ul class="dropdown-menu" role="menu">'
+' <li><a href="javascript:;" onclick="setEventkey(this,\'click\');return false">{lang menu}key</a></li>'
+' <li><a href="javascript:;" onclick="setEventkey(this,\'link\');return false">{lang jump_page}</a></li>'
+' </ul>'
+' </div>'
+' <a class="js_change_name ml10 hover_visible icon icon_edit_gray" href="javascript:;" title="{lang modification}"></a>'
+' <input type="text" class="custom_menu_input js_add_2_menu js_input_limit " value="'+cut_val+'" autofocus="true" data-limit="16" >'
+' <span class="custom_menu_notice ">{lang level_2_menu_name_limit_beyond_truncation}</span>'
+' </div>';
jQuery('.custom_menu_list_wrap[data-id='+pid+']').append(html);
jQuery('.js_li[data-id='+pid+']').attr('data-type','').find('.js_click,.js_link,.btn-group').remove();
check_add_second();
init_dragsort(2);
}
this.value='';
}else if(li.hasClass('js_add')){
if(jQuery('.cm_name').length<3){
var html='<div class="custom_menu_list cm_name js_li clearfix" data-name="'+cut_val+'" data-type="">'
+' <a class="icon icon_remove pull-right js_menu_remove hover_visible" href="javascript:;"></a>'
+' <span class="icon icon_arrow_down"></span><span class="custom_menu_name">'+cut_val+'</span>'
+' <a class="js_change_name ml10 hover_visible icon icon_edit_gray" href="javascript:;" title="{lang modification}"></a>'
+' <input type="text" class="custom_menu_input js_add_2_menu js_input_limit " value="'+cut_val+'" autofocus="true" data-limit="8">'
+' <span class="custom_menu_notice ">{lang level_1_menu_name_limit_beyond_truncation}</span>'
+'</div>'
+'<div class="custom_menu_list_wrap"></div>'
+'<div class="custom_menu_list js_add_second">'
+' <span class="icon icon_add_small"></span>'
+' <span class="custom_menu_addName gray">{lang add_second_level_of_menus}</span>'
+' <input type="text" class="custom_menu_input js_add_2_menu js_input_limit" data-limit="16" autofocus="true" placeholder="{lang level_2_menu_name_limit}">'
+' <span class="custom_menu_notice ">{lang level_2_menu_name_limit_beyond_truncation}</span>'
+'</div>';
jQuery(html).appendTo('.custom_menu_mainList_wrap');
check_add_second();
init_dragsort(1);
}
}else{
li.find('.custom_menu_subName,.custom_menu_name').html(cut_val);
li.attr('data-name',cut_val);
this.value=cut_val;
}
}
li.removeClass('editing');
});
init_dragsort();
});
var ajaxurl='$baseurl_ajax';
function init_dragsort(flag){
if(flag==1) jQuery('.custom_menu_mainList_wrap').dragsort(null,function(){check_add_second();});
else if(flag==2) jQuery('.custom_menu_list_wrap').dragsort(null,function(){check_add_second();});
else{
jQuery('.custom_menu_list_wrap').dragsort(null,function(){check_add_second();});
jQuery('.custom_menu_mainList_wrap').dragsort(null,function(){check_add_second();});
}
}
function menu_save(obj){
var button=jQuery(obj);
button.button('loading');
var menu=[];
jQuery('.custom_menu_mainList_wrap .js_li').each(function(){
var li=jQuery(this);
if(li.hasClass('cm_name')){
var dataid=li.attr('data-id');
var type=li.attr('data-type');
var arr={}
arr['name']=li.attr('data-name');
if(type){
arr['type']=li.attr('data-type');
if(type=='click'){
arr['key']=li.attr('data-key');
}else{
arr['url']=li.attr('data-url');
}
}else{
arr['sub_button']=[];
}
menu.push(arr);
}else if(li.hasClass('cm_subname')){
var id0=li.parent().attr('data-id');
var type=li.attr('data-type');
var arr={};
arr['name']=li.attr('data-name');
if(type){
arr['type']=li.attr('data-type');
if(type=='click'){
arr['key']=li.attr('data-key');
}else{
arr['url']=li.attr('data-url');
}
}
menu[id0]['sub_button'].push(arr);
}
});
jQuery.post(ajaxurl+'&action=menu_save',{menu:menu},function(json){
if(json.msg=='success'){
showmessage('{lang save_success}!','success',1000,1);
}else{
showmessage('{lang save_unsuccess}!','danger',3000,1);
}
button.button('reset');
},'json');
}
function menu_default(obj){
if(confirm('{lang restore_the_default_menu}')){
var button=jQuery(obj);
button.button('loading');
jQuery.post(ajaxurl+'&action=menu_default',function(json){
window.location.reload();
});
}
}
function menu_publish(obj){
var button=jQuery(obj);
button.button('loading');
var menu=[];
if(jQuery('.custom_menu_mainList_wrap .js_li .btn-group').length){
showmessage('{lang none_response_event_please_check}','danger',5000,1);
button.button('reset');
return;
}
jQuery('.custom_menu_mainList_wrap .js_li').each(function(){
var li=jQuery(this);
if(li.hasClass('cm_name')){
var dataid=li.attr('data-id');
var type=li.attr('data-type');
var arr={}
arr['name']=li.attr('data-name');
if(type){
arr['type']=li.attr('data-type');
if(type=='click'){
arr['key']=li.attr('data-key');
}else{
arr['url']=li.attr('data-url');
}
}else{
arr['sub_button']=[];
}
menu.push(arr);
}else if(li.hasClass('cm_subname')){
var id0=li.parent().attr('data-id');
var type=li.attr('data-type');
var arr={};
if(type){
arr['name']=li.attr('data-name');
arr['type']=li.attr('data-type');
if(type=='click'){
marr['key']=li.attr('data-key');
}else{
arr['url']=li.attr('data-url');
}
menu[id0]['sub_button'].push(arr);
}
}
});
jQuery.post(ajaxurl+'&action=menu_publish',{menu:menu},function(json){
if(json.msg=='success'){
showmessage('{lang release_success}!','success',1000,1);
}else{
showmessage(json.error,'danger',3000,1);
}
button.button('reset');
},'json');
}
function setEventkey(obj,type){
var el=jQuery(obj);
var dataid=el.closest('.js_li').attr('data-id');
showWindow('setEvent',ajaxurl+'&action=setEventkey&type='+type+'&dataid='+dataid+'&t='+new Date().getTime());
}
function check_add_second(){
var i=0;
jQuery('.custom_menu_mainList_wrap .custom_menu_list,.custom_menu_mainList_wrap .custom_menu_list_wrap').each(function(){
var me=jQuery(this);
if(me.hasClass('cm_name')){
me.attr('data-id',i);
i++;
}else if(me.hasClass('custom_menu_list_wrap')){
me.attr('data-id',(i-1));
var li=jQuery('.cm_name[data-id='+(i-1)+']');
if(jQuery('.custom_menu_list_wrap[data-id='+(i-1)+'] .cm_subname').length){//有子菜单主菜单去除evnent
jQuery('.custom_menu_list_wrap[data-id='+(i-1)+'] .cm_subname').each(function(index){
var el=jQuery(this);
el.attr('data-id',(i-1)+'_'+index);
if(el.attr('data-type')==''){
jQuery('<div class="btn-group pull-right eventkey"><button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">{lang add_the_event_type}<span class="caret"></span></button><ul class="dropdown-menu" role="menu"> <li><a href="javascript:;" onclick="setEventkey(this,\'click\');return false">{lang menu}key</a></li><li><a href="javascript:;" onclick="setEventkey(this,\'link\');return false">{lang jump_page}</a></li></ul> </div>').appendTo(this);
}
});
li.attr('data-type','').find('.js_click,.js_link,.btn-group').remove();
}else{
if(li.attr('data-type')==''){
li.find('.js_click,.js_link,.btn-group').remove();
jQuery('<div class="btn-group pull-right eventkey"><button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">{lang add_the_event_type}<span class="caret"></span></button><ul class="dropdown-menu" role="menu"> <li><a href="javascript:;" onclick="setEventkey(this,\'click\');return false">{lang menu}key</a></li><li><a href="javascript:;" onclick="setEventkey(this,\'link\');return false">{lang jump_page}</a></li></ul> </div>').appendTo(li);
}
}
}else if(me.hasClass('js_add_second')){
me.attr('data-id',i-1);
if(jQuery('.custom_menu_list_wrap[data-id='+(i-1)+'] .cm_subname').length>4) me.addClass('hidden');
else me.removeClass('hidden');
}
});
if(i>2){
jQuery('.js_add').addClass('hidden');
}else{
jQuery('.js_add').removeClass('hidden');
}
}
function mb_strlen(str) {
var len = 0;
for(var i = 0; i < str.length; i++) {
len += str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255 ? 2 : 1;
}
return len;
}
function mb_cutstr(str, maxlen) {
var len = 0;
var ret = '';
var dot = '';
maxlen = maxlen - dot.length;
for(var i = 0; i < str.length; i++) {
len += str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255 ? 2 : 1;
if(len > maxlen) {
ret += dot;
break;
}
ret += str.substr(i, 1);
}
return ret;
}
</script>
<script type="text/javascript" src="static/js/jquery.dragsort.js?{VERHASH}"></script>

View File

@@ -0,0 +1,147 @@
<style>
.line {
height: 2px;
margin: 10px 0;
font-size: 0;
overflow: hidden;
background-color: transparent;
border-width: 0;
border-top: 1px solid #e7e7e7;
border-bottom: 1px solid #FFF;
}
.pull-in {
margin-left: -15px;
margin-right: -15px;
}
/*.line-dashed {
border-style: dashed;
background: transparent;
}*/
.line-lg {
margin-top: 15px;
margin-bottom: 15px;
}
.padding-left .col-sm-12 {
padding-left: 40px;
}
.relative {
position: relative;
}
.copy-success {
position: absolute;
left: -210px;
top: -15px;
padding: 8px;
}
.absoluter {
position: absolute;
right: 0;
top: 0;
padding: 5px;
}
</style>
<div class="main-header">
<ul class="nav nav-pills nav-pills-bottomguide">
<li class="active"><a href="{$baseurl_info}">{eval echo $base_info_title?$base_info_title:'{lang application_message}';}</a></li>
<li><a href="{$baseurl_menu}">{eval echo $base_menu_title?$base_menu_title:'{lang application_menu}';}</a></li>
</ul>
</div>
<div class="main-content" style="border-top:1px solid #FFF">
<div class="panel-body" >
<div class="entity-panel-body form-horizontal">
<form id="settingform" name="settingform" class="form-horizontal form-horizontal-left" action="$baseurl_info" method="post" style="margin:0">
<input type="hidden" name="settingsubmit" value="true" />
<input type="hidden" name="formhash" value="{FORMHASH}" />
<dl>
<dt>AppID:</dt>
<dd class="clearfix">
<input type="text" id="AppID" class="form-control" name="AppID" value="$setting[AppID]" required="true" />
<span class="help-block">{lang developer_credentials_login_commonality_terrace}</span>
</dd>
</dl>
<dl>
<dt>AppSecret:</dt>
<dd class="clearfix">
<input type="text" id="AppSecret" class="form-control" name="AppSecret" value="$setting[AppSecret]" required="true" />
<span class="help-block">{lang developer_credentials_login_commonality_terrace}</span>
</dd>
</dl>
<dl>
<dd>
<input type="hidden" id="fbind" name="fbind" value="bind" />
<button class="btn btn-success btn-width" onclick="document.getElementById('settingform').onsubmit();" >{lang bundle}</button>
&nbsp;&nbsp;<button class="btn btn-danger btn-width" onclick="document.getElementById('fbind').value='unbind';document.getElementById('settingform').onsubmit();">{lang unbundle}</button>
</dd>
</dl>
</form>
<div class="line line-dashed line-lg pull-in"></div>
<div class="form-group clearfix padding-left">
<div class="col-sm-12">
<p class="form-control-static danger relative"><i class="glyphicon glyphicon-hand-down"></i> <strong style="font-size:1.5em">{lang need_developer_center_settings}</strong> <a href="https://mp.weixin.qq.com/advanced/advanced?action=dev" target="_blank" class="pull-right btn btn-default">{lang weixin_public_number}</a> </p>
</div>
</div>
<div class="line line-dashed line-lg pull-in"></div>
<div class="form-group clearfix padding-left">
<label class="col-sm-12">
<h5><strong>{lang server_configuration_information}</strong></h5>
</label>
</div>
<div class="form-group clearfix padding-left">
<label class="col-xs-2 control-label">URL({lang server_address})</label>
<div class="col-xs-10">
<p class="form-control-static relative" style="padding-left:0;">$wxmp[callback] <span class="absoluter">
<button class="btn btn-default js_copy" data-clipboard-text="$wxmp[callback]" title="{lang copy}">{lang copy}</button>
<span class="alert copy-success alert-success hide ">{lang copy_success_paste_need_place}</span> </span> </p>
</div>
</div>
<div class="form-group clearfix padding-left">
<label class="col-xs-2 control-label">Token({lang token})</label>
<div class="col-xs-10">
<p class="form-control-static relative">$wxmp['token'] <span class="absoluter">
<button class="btn btn-default js_copy" data-clipboard-text="$wxmp[token]" title="{lang copy_success_paste_need_place}">{lang copy_success_paste_need_place}</button>
<span class="alert copy-success alert-success hide ">{lang copy_success_paste_need_place}</span> </span> </p>
</div>
</div>
<div class="form-group clearfix padding-left">
<label class="col-xs-2 control-label">EncodingAESKey({lang message_encryption_key})</label>
<div class="col-xs-10">
<p class="form-control-static relative">$wxmp[encodingaeskey] <span class="absoluter">
<button class="btn btn-default js_copy" data-clipboard-text="$wxmp[encodingaeskey]" title="{lang copy}">{lang copy}</button>
<span class="alert copy-success alert-success hide ">{lang copy_success_paste_need_place}</span> </span> </p>
</div>
</div>
<div class="form-group clearfix padding-left">
<label class="col-xs-2 control-label">{lang message_encryption}</label>
<div class="col-xs-10">
<p class="form-control-static relative">{lang safe_mode}</p>
</div>
</div>
</div>
</div>
<script type="text/javascript">
jQuery(document).ready(function(e) {
var client = new ZeroClipboard(jQuery('.js_copy'));
client.on( "load", function( client ) {
// alert( "ZeroClipboard SWF is ready!" );
client.on( "complete", function( client,args ) {
var self=this;
jQuery(this).parent().find('.copy-success').removeClass('hide');
window.setTimeout(function(){
jQuery(self).parent().find('.copy-success').addClass('hide');
},1000);
});
});
});
</script>
<script src="static/js/ZeroClipboard/ZeroClipboard.min.js?{VERHASH}"></script>
<!--{template common/footer_simple}-->

View File

@@ -0,0 +1,157 @@
<?php
/*
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
* @license https://www.oaooa.com/licenses/
*
* @link https://www.oaooa.com
* @author zyx(zyx@oaooa.com)
*/
require_once DZZ_ROOT . './dzz/ffmpeg/vendor/autoload.php';
require_once(DZZ_ROOT . './dzz/class/class_encode.php');
class fmpeg
{
private $fm;
private $logger = NULL;
public function __construct($options = array())
{
$option = array(
'ffmpeg.binaries' =>(getglobal('config/pichomeffmpegposition')) ? getglobal('config/pichomeffmpegposition'):(strstr(PHP_OS, 'WIN') ? DZZ_ROOT . 'dzz\ffmpeg\ffmpeg\ffmpeg.exe' : '/usr/bin/ffmpeg'),
'ffprobe.binaries' => (getglobal('config/pichomeffprobeposition')) ? (getglobal('config/pichomeffprobeposition')):(strstr(PHP_OS, 'WIN') ? DZZ_ROOT . 'dzz\ffmpeg\ffmpeg\ffprobe.exe' : '/usr/bin/ffprobe'),
'timeout' => 3600, // The timeout for the underlying process
'ffmpeg.threads' => 1, // The number of threads that FFMpeg should use
);
$this->fm = FFMpeg\FFMpeg::create($option, $this->logger);
return $this->fm;
}
public function getInfo($data)
{
$option = array(
'ffmpeg.binaries' =>(getglobal('config/pichomeffmpegposition')) ? getglobal('config/pichomeffmpegposition'):(strstr(PHP_OS, 'WIN') ? DZZ_ROOT . 'dzz\ffmpeg\ffmpeg\ffmpeg.exe' : '/usr/bin/ffmpeg'),
'ffprobe.binaries' => (getglobal('config/pichomeffprobeposition')) ? (getglobal('config/pichomeffprobeposition')):(strstr(PHP_OS, 'WIN') ? DZZ_ROOT . 'dzz\ffmpeg\ffmpeg\ffprobe.exe' : '/usr/bin/ffprobe'),
'timeout' => 3600, // The timeout for the underlying process
'ffmpeg.threads' => 1, // The number of threads that FFMpeg should use
);
$file = $path = $data['realpath'];
if (!is_file($file)) {
$cachepath = getglobal('setting/attachdir') . 'cache/ffmpeg_cahce_' . md5($path) . '.' . $data['ext'];
if (!file_put_contents($cachepath, file_get_contents($file))) {
return false;
}
$file = $cachepath;
}
$ffprobe = FFMpeg\FFProbe::create($option, null);
if ('audio' == getTypeByExt($data['ext'])) {
$meta = $ffprobe
->streams($file) // extracts streams informations
->audios() // filters video streams
->first();
$info = array();
if ($meta) {
$info = array(
'duration' => round($meta->get('duration'), 2),
);
}
} else {
$meta = $ffprobe
->streams($file) // extracts streams informations
->videos() // filters video streams
->first();
$info = array();
if ($meta) {
$info = array(
'width' => intval($meta->get('width')),
'height' => intval($meta->get('height')),
'duration' => round($meta->get('duration'), 2),
);
}
}
if ($cachepath) @unlink($cachepath);
return $info;
}
/* 获取缩略图
$file:文件地址
$time:获取缩略图的时间点单位秒
*/
public function getThumb($data,$time = 1)
{
global $_G;
$file = $data['realpath'];
//本地路径
if (!is_file($file)) {
$cachefile = $_G['setting']['attachdir'] . './cache/' . md5($data['path']) . '.' . $data['ext'];
$handle = fopen($cachefile, 'w+');
$fp = fopen($file, 'rb');
while (!feof($fp)) {
fwrite($handle, fread($fp, 8192));
}
fclose($handle);
fclose($fp);
$file = $cachefile;
}
if ('audio' == getTypeByExt($data['ext'])) {
$target = md5($data['path']) . '.jpg';
$jpg = $_G['setting']['attachdir'] . './pichomethumb/' . $data['appid'] . '/' . $target;
$jpgpath = dirname($jpg);
dmkdir($jpgpath);
if (!in_array($data['ext'], array('mp3', 'wav'))) {
$audio = $this->fm->open($file);
$audio_format = new FFMpeg\Format\Audio\Mp3();
$tmp = $_G['setting']['attachdir'] . './cache/' . md5($file) . '.mp3';
$audio->save($audio_format, $tmp);
}
$audio = $this->fm->open($tmp ? $tmp : $file);
$waveform = $audio->waveform(720, 360, array('#888888'));
$waveform->save($jpg);
if ($tmp) @unlink($tmp);
} else {
$target = md5($data['path']) . '.jpg';
$jpg = $_G['setting']['attachdir'] . './pichomethumb/' . $data['appid'] . '/' . $target;
$jpgpath = dirname($jpg);
dmkdir($jpgpath);
try {
$video = $this->fm->open($file);
$video
->frame(FFMpeg\Coordinate\TimeCode::fromSeconds($time))
->save($jpg);
} catch (\Exception $e) {
runlog('ffmpeg', $e->getMessage() . ' File:' . $file);
}
}
if ($cachefile) @unlink($cachefile);
if (is_file($jpg)) {
return $jpg;
} else {
return false;
}
}
//兼容linux下获取文件名
public function get_basename($filename)
{
if ($filename) {
return preg_replace('/^.+[\\\\\\/]/', '', $filename);
}
return '';
}
}

View File

@@ -0,0 +1,53 @@
<?php
namespace dzz\ffmpeg\classes;
use \core as C;
use \DB as DB;
use \fmpeg as fmpeg;
class info
{
public function run(&$data)
{
$exts = (getglobal('config/pichomeffmpeggetvieoinoext')) ? getglobal('config/pichomeffmpeggetvieoinoext'):[
'avi', 'rm', 'rmvb', 'mkv', 'mov', 'wmv', 'asf', 'mpg', 'mpe', 'mpeg', 'mp4', 'm4v', 'mpeg', 'f4v', 'vob', 'ogv', 'mts', 'm2ts',
'3gp', 'webm', 'flv', 'wav', 'mp3', 'ogg', 'midi', 'wma', 'vqf', 'ra', 'aac', 'flac', 'ape', 'amr', 'aiff', 'au', 'm4a'
];
$data['ext'] = strtolower($data['ext']);
if (empty($data['ext']) || !in_array($data['ext'], $exts)) {
return true;
} else {
$ffprobeposition = getglobal('config/pichomeffprobeposition') ? getglobal('config/pichomeffprobeposition'):(strstr(PHP_OS, 'WIN')?DZZ_ROOT . 'dzz\ffmpeg\ffmpeg\ffprobe.exe':'/usr/bin/ffprobe');
if(!is_file($ffprobeposition)) return ;
$setarr = [
'rid'=>$data['rid'],
'appid'=>$data['appid'],
'ext'=>$data['ext']
];
$isforce = (isset($setarr['isforce'])) ? 1:0;
C::t('pichome_ffmpeg_record')->insert($setarr,$isforce);
}
}
public function rundata($data)
{
require_once DZZ_ROOT . './dzz/ffmpeg/class/class_fmpeg.php';
try {
if ($info = fmpeg::getInfo($data)) {
if (isset($info['duration'])) C::t('pichome_resources_attr')->update($data['rid'], array('duration' => $info['duration']));
if (isset($info['width'])) C::t('pichome_resources')->update($data['rid'], array('width' => $info['width'], 'height' => $info['height']));
C::t('pichome_ffmpeg_record')->update($data['rid'],array('infostatus'=>1));
}
} catch (\Exception $e) {
runlog('ffmpeg', $e->getMessage() . 'rid:' . $data['rid']);
}
}
}

View File

@@ -0,0 +1,64 @@
<?php
namespace dzz\ffmpeg\classes;
use \core as C;
use \DB as DB;
use \fmpeg as fmpeg;
class thumb
{
public function run(&$data)
{
$exts = (getglobal('config/pichomeffmpeggetthumbext')) ? getglobal('config/pichomeffmpeggetvieoinoext'):[
'avi', 'rm', 'rmvb', 'mkv', 'mov', 'wmv', 'asf', 'mpg', 'mpe', 'mpeg', 'mp4', 'm4v', 'mpeg', 'f4v', 'vob', 'ogv', 'mts', 'm2ts',
'3gp', 'webm', 'flv', 'wav', 'mp3', 'ogg', 'midi', 'wma', 'vqf', 'ra', 'aac', 'flac', 'ape', 'amr', 'aiff', 'au', 'm4a'
];
$data['ext'] = strtolower($data['ext']);
if (empty($data['ext']) || !in_array($data['ext'], $exts)) {
} else {
if(strstr(PHP_OS, 'WIN') && !is_file(DZZ_ROOT . 'dzz\ffmpeg\ffmpeg\ffprobe.exe')){
return ;
}elseif(!is_file('/usr/bin/ffprobe')){
return ;
}
$setarr = [
'rid'=>$data['rid'],
'appid'=>$data['appid'],
'ext'=>$data['ext']
];
$isforce = (isset($setarr['isforce'])) ? 1:0;
C::t('pichome_ffmpeg_record')->insert($setarr,$isforce);
//dfsockopen(getglobal('localurl') . 'index.php?mod=ffmpeg&op=getinfo&path=' . dzzencode($data['rid']), 0, '', '', false, '', 0.1);
}
}
public function rundata(&$data)
{
require_once DZZ_ROOT . './dzz/ffmpeg/class/class_fmpeg.php';
$fm = new fmpeg();
if ($data['Duration']) {
$start = ceil($data['duration'] / 5);
} else {
$start = 1;
}
if ($target = $fm->getThumb($data, $start)) {
if ($imginfo = getimagesize($target)) {
$resourcesarr = [
'width' => $imginfo[0] ? $imginfo[0]:0,
'height' =>$imginfo[1] ? $imginfo[1]:0
];
C::t('pichome_resources')->update($data['rid'],$resourcesarr);
C::t('pichome_resources')->update($data['rid'], array('hasthumb' => 1));
C::t('pichome_ffmpeg_record')->update($data['rid'], array('thumbstatus' => 1,'thumb'=>$target));
}
}
}
}

6
dzz/ffmpeg/composer.json Normal file
View File

@@ -0,0 +1,6 @@
{
"require": {
"php-ffmpeg/php-ffmpeg": "^0.9.3",
"php-ffmpeg/extras": "^0.3.1"
}
}

650
dzz/ffmpeg/composer.lock generated Normal file
View File

@@ -0,0 +1,650 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "79c0351ad302ceea820d708f203ad405",
"packages": [
{
"name": "alchemy/binary-driver",
"version": "1.6.0",
"source": {
"type": "git",
"url": "https://github.com/alchemy-fr/BinaryDriver.git",
"reference": "80c6633890afb71d2417ae851d0ad167d8b00b95"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/alchemy-fr/BinaryDriver/zipball/80c6633890afb71d2417ae851d0ad167d8b00b95",
"reference": "80c6633890afb71d2417ae851d0ad167d8b00b95",
"shasum": ""
},
"require": {
"evenement/evenement": "^2.0|^1.0",
"monolog/monolog": "^1.3",
"php": ">=5.5",
"psr/log": "^1.0",
"symfony/process": "^2.0|^3.0"
},
"require-dev": {
"phpunit/phpunit": "^4.0|^5.0"
},
"type": "library",
"autoload": {
"psr-0": {
"Alchemy": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Romain Neutron",
"email": "imprec@gmail.com",
"homepage": "http://www.lickmychip.com/"
},
{
"name": "Phraseanet Team",
"email": "info@alchemy.fr",
"homepage": "http://www.phraseanet.com/"
},
{
"name": "Nicolas Le Goff",
"email": "legoff.n@gmail.com"
}
],
"description": "A set of tools to build binary drivers",
"keywords": [
"binary",
"driver"
],
"time": "2016-03-02T13:49:15+00:00"
},
{
"name": "doctrine/cache",
"version": "v1.8.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/cache.git",
"reference": "d768d58baee9a4862ca783840eca1b9add7a7f57"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/cache/zipball/d768d58baee9a4862ca783840eca1b9add7a7f57",
"reference": "d768d58baee9a4862ca783840eca1b9add7a7f57",
"shasum": ""
},
"require": {
"php": "~7.1"
},
"conflict": {
"doctrine/common": ">2.2,<2.4"
},
"require-dev": {
"alcaeus/mongo-php-adapter": "^1.1",
"doctrine/coding-standard": "^4.0",
"mongodb/mongodb": "^1.1",
"phpunit/phpunit": "^7.0",
"predis/predis": "~1.0"
},
"suggest": {
"alcaeus/mongo-php-adapter": "Required to use legacy MongoDB driver"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.8.x-dev"
}
},
"autoload": {
"psr-4": {
"Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
}
],
"description": "Caching library offering an object-oriented API for many cache backends",
"homepage": "https://www.doctrine-project.org",
"keywords": [
"cache",
"caching"
],
"time": "2018-08-21T18:01:43+00:00"
},
{
"name": "evenement/evenement",
"version": "v2.1.0",
"source": {
"type": "git",
"url": "https://github.com/igorw/evenement.git",
"reference": "6ba9a777870ab49f417e703229d53931ed40fd7a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/igorw/evenement/zipball/6ba9a777870ab49f417e703229d53931ed40fd7a",
"reference": "6ba9a777870ab49f417e703229d53931ed40fd7a",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
},
"require-dev": {
"phpunit/phpunit": "^6.0||^5.7||^4.8.35"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
}
},
"autoload": {
"psr-0": {
"Evenement": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Igor Wiedler",
"email": "igor@wiedler.ch"
}
],
"description": "Événement is a very simple event dispatching library for PHP",
"keywords": [
"event-dispatcher",
"event-emitter"
],
"time": "2017-07-17T17:39:19+00:00"
},
{
"name": "monolog/monolog",
"version": "1.24.0",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
"reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266",
"reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"psr/log": "~1.0"
},
"provide": {
"psr/log-implementation": "1.0.0"
},
"require-dev": {
"aws/aws-sdk-php": "^2.4.9 || ^3.0",
"doctrine/couchdb": "~1.0@dev",
"graylog2/gelf-php": "~1.0",
"jakub-onderka/php-parallel-lint": "0.9",
"php-amqplib/php-amqplib": "~2.4",
"php-console/php-console": "^3.1.3",
"phpunit/phpunit": "~4.5",
"phpunit/phpunit-mock-objects": "2.3.0",
"ruflin/elastica": ">=0.90 <3.0",
"sentry/sentry": "^0.13",
"swiftmailer/swiftmailer": "^5.3|^6.0"
},
"suggest": {
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
"doctrine/couchdb": "Allow sending log messages to a CouchDB server",
"ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
"ext-mongo": "Allow sending log messages to a MongoDB server",
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
"mongodb/mongodb": "Allow sending log messages to a MongoDB server via PHP Driver",
"php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
"php-console/php-console": "Allow sending log messages to Google Chrome",
"rollbar/rollbar": "Allow sending log messages to Rollbar",
"ruflin/elastica": "Allow sending log messages to an Elastic Search server",
"sentry/sentry": "Allow sending log messages to a Sentry server"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Monolog\\": "src/Monolog"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
}
],
"description": "Sends your logs to files, sockets, inboxes, databases and various web services",
"homepage": "http://github.com/Seldaek/monolog",
"keywords": [
"log",
"logging",
"psr-3"
],
"time": "2018-11-05T09:00:11+00:00"
},
{
"name": "neutron/temporary-filesystem",
"version": "2.3.0",
"source": {
"type": "git",
"url": "https://github.com/romainneutron/Temporary-Filesystem.git",
"reference": "694aa3885f653dd429584e825ffbab79441d285f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/romainneutron/Temporary-Filesystem/zipball/694aa3885f653dd429584e825ffbab79441d285f",
"reference": "694aa3885f653dd429584e825ffbab79441d285f",
"shasum": ""
},
"require": {
"php": "^5.6 || ^7.0",
"symfony/filesystem": "^2.3 || ^3.0 || ^4.0"
},
"require-dev": {
"phpunit/phpunit": "^5.0"
},
"type": "library",
"autoload": {
"psr-0": {
"Neutron": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Romain Neutron",
"email": "imprec@gmail.com"
}
],
"description": "Symfony filesystem extension to handle temporary files",
"time": "2018-02-07T21:11:57+00:00"
},
{
"name": "php-ffmpeg/extras",
"version": "0.3.1",
"source": {
"type": "git",
"url": "https://github.com/alchemy-fr/PHP-FFMpeg-Extras.git",
"reference": "4b3f87467e27c828641c3361ad395492775ab98c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/alchemy-fr/PHP-FFMpeg-Extras/zipball/4b3f87467e27c828641c3361ad395492775ab98c",
"reference": "4b3f87467e27c828641c3361ad395492775ab98c",
"shasum": ""
},
"require": {
"php": ">=5.3.2",
"php-ffmpeg/php-ffmpeg": "~0.3"
},
"require-dev": {
"phpunit/phpunit": "~3.7",
"sami/sami": "~1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.3-dev"
}
},
"autoload": {
"psr-0": {
"FFMpeg": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Alchemy",
"email": "dev.team@alchemy.fr",
"homepage": "http://www.alchemy.fr/"
}
],
"description": "A set of audio/video formats compatible with PHP-FFMpeg",
"keywords": [
"codecs",
"ffmpeg"
],
"time": "2014-02-24T10:48:44+00:00"
},
{
"name": "php-ffmpeg/php-ffmpeg",
"version": "0.9.5",
"source": {
"type": "git",
"url": "https://github.com/PHP-FFMpeg/PHP-FFMpeg.git",
"reference": "96225b2dff65a4c3b0b541f2420742ffe5851127"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHP-FFMpeg/PHP-FFMpeg/zipball/96225b2dff65a4c3b0b541f2420742ffe5851127",
"reference": "96225b2dff65a4c3b0b541f2420742ffe5851127",
"shasum": ""
},
"require": {
"alchemy/binary-driver": "^1.5",
"doctrine/cache": "^1.0",
"evenement/evenement": "^2.0 || ^1.0",
"neutron/temporary-filesystem": "^2.1.1",
"php": "^5.3.9 || ^7.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8",
"sami/sami": "~1.0",
"silex/silex": "~1.0"
},
"suggest": {
"php-ffmpeg/extras": "A compilation of common audio & video drivers for PHP-FFMpeg"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.7-dev"
}
},
"autoload": {
"psr-0": {
"FFMpeg": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Romain Neutron",
"email": "imprec@gmail.com",
"homepage": "http://www.lickmychip.com/"
},
{
"name": "Phraseanet Team",
"email": "info@alchemy.fr",
"homepage": "http://www.phraseanet.com/"
},
{
"name": "Patrik Karisch",
"email": "patrik@karisch.guru",
"homepage": "http://www.karisch.guru"
},
{
"name": "Romain Biard",
"email": "romain.biard@gmail.com",
"homepage": "https://www.strime.io/"
}
],
"description": "FFMpeg PHP, an Object Oriented library to communicate with AVconv / ffmpeg",
"keywords": [
"audio",
"audio processing",
"avconv",
"avprobe",
"ffmpeg",
"ffprobe",
"video",
"video processing"
],
"time": "2017-06-30T19:27:10+00:00"
},
{
"name": "psr/log",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd",
"reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Log\\": "Psr/Log/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for logging libraries",
"homepage": "https://github.com/php-fig/log",
"keywords": [
"log",
"psr",
"psr-3"
],
"time": "2018-11-20T15:27:04+00:00"
},
{
"name": "symfony/filesystem",
"version": "v4.2.8",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
"reference": "e16b9e471703b2c60b95f14d31c1239f68f11601"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/e16b9e471703b2c60b95f14d31c1239f68f11601",
"reference": "e16b9e471703b2c60b95f14d31c1239f68f11601",
"shasum": ""
},
"require": {
"php": "^7.1.3",
"symfony/polyfill-ctype": "~1.8"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Filesystem\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Filesystem Component",
"homepage": "https://symfony.com",
"time": "2019-02-07T11:40:08+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.11.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "82ebae02209c21113908c229e9883c419720738a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a",
"reference": "82ebae02209c21113908c229e9883c419720738a",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"suggest": {
"ext-ctype": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.11-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
},
{
"name": "Gert de Pagter",
"email": "BackEndTea@gmail.com"
}
],
"description": "Symfony polyfill for ctype functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"ctype",
"polyfill",
"portable"
],
"time": "2019-02-06T07:57:58+00:00"
},
{
"name": "symfony/process",
"version": "v3.4.27",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "a9c4dfbf653023b668c282e4e02609d131f4057a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/a9c4dfbf653023b668c282e4e02609d131f4057a",
"reference": "a9c4dfbf653023b668c282e4e02609d131f4057a",
"shasum": ""
},
"require": {
"php": "^5.5.9|>=7.0.8"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.4-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Process\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
"time": "2019-04-08T16:15:54+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": []
}

40
dzz/ffmpeg/convert.php Normal file
View File

@@ -0,0 +1,40 @@
<?php
/*
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
* @license https://www.oaooa.com/licenses/
*
* @link https://www.oaooa.com
* @author zyx(zyx@oaooa.com)
*/
ignore_user_abort(true);
@set_time_limit(0);
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
$setting = C::t('setting')->fetch('ffmpeg_setting',true);
if($setting['upload_convert_immediately']>1){
exit('admin set not convert!');
}
include_once dzz_libfile('ffmpeg');
$max=10;
$time=TIMESTAMP-60*60*5;
if($max<=DB::result_first("select COUNT(*) from %t where percent>0 and percent<100 and dateline>%d",array('video_record',$time))){
exit('Over the maximum load, please wait a moment.');
}
$id=intval($_GET['id']);
if(!$ff=C::t('video_record')->fetch($id)){
exit('convert error');
}
if(dzz_process::islocked('ffmpeg_convert_'.$id,60*60)){
exit('converting!');
}
if($ff['status']==2){
dzz_process::unlock('ffmpeg_convert_'.$id);
exit('convert completed');
}
$fm=new fmpeg($setting);
$ret=$fm->convert($ff['aid'],$ff['format']);
dzz_process::unlock('ffmpeg_convert_'.$id);
exit('success');

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

71
dzz/ffmpeg/getinfo.php Normal file
View File

@@ -0,0 +1,71 @@
<?php
ignore_user_abort(true);
if (!defined('IN_OAOOA')) {
exit('Access Denied');
}
@set_time_limit(0);
ini_set('memory_limit', -1);
@ini_set('max_execution_time', 0);
$appids = [];
foreach(DB::fetch_all("select appid from %t where `type` = %d and getinfo = %d",array('pichome_vapp',1,1)) as $v){
$appids[] = $v['appid'];
}
if(empty($appids)){
exit('success');
}
$locked = true;
for($i=0;$i<1;$i++){
$processname = 'DZZ_LOCK_PICHOMEGETINFO'.$i;
if (!dzz_process::islocked($processname, 60*60)) {
$locked=false;
break;
}
}
$processname = 'DZZ_LOCK_PICHOMEGETINFO'.$i;
$limit = 10;
$start=$i*$limit;
if (!dzz_process::islocked($processname, 60*60)) {
$locked=false;
}
if ($locked) {
exit(json_encode( array('error'=>'进程已被锁定请稍后再试')));
}
use dzz\ffmpeg\classes\info as info;
$info =new info;
foreach(DB::fetch_all("select * from %t where infostatus = 0 and appid in(%n)
order by infodonum asc limit $start,$limit",array('pichome_ffmpeg_record',$appids)) as $v){
$processname1 = 'PICHOMEGETINFO_'.$v['rid'];
if (dzz_process::islocked($processname1, 60*5)) {
continue;
}
$data = C::t('pichome_resources')->fetch_data_by_rid($v['rid']);
if(empty($data)){
C::t('pichome_ffmpeg_record')->delete($v['rid']);
dzz_process::unlock($processname1);
continue;
}else{
//如果信息执行次数大于三次直接赋值为1不再尝试获取
if($v['infodonum'] > 3 && $v['infostatus'] == 0){
$v['infostatus'] = 1;
C::t('pichome_ffmpeg_record')->update($v['rid'],array('infostatus'=>1));
dzz_process::unlock($processname1);
continue;
}
//如果信息和缩略图标记为已生成,标记该文件信息状态为已获取
if($v['thumbstatus'] == 1 && $v['infostatus'] == 1){
C::t('pichome_resources_attr')->update($v['rid'],array('isget'=>1));
dzz_process::unlock($processname1);
continue;
}
DB::query("update %t set infodonum=infodonum+%d where rid = %s ", array('pichome_ffmpeg_record', 1, $data['rid']));
$info->rundata($data);
dzz_process::unlock($processname1);
}
}
dzz_process::unlock($processname);
if(DB::result_first("select * from %t where infostatus = 0 ",array('pichome_ffmpeg_record'))){
dfsockopen(getglobal('localurl') . 'index.php?mod=ffmpeg&op=getinfo', 0, '', '', false, '', 0.1);
}
exit('success');

77
dzz/ffmpeg/thumb.php Normal file
View File

@@ -0,0 +1,77 @@
<?php
/**
* Created by PhpStorm.
* User: 86187
* Date: 2020/3/7
* Time: 15:53
*/
ignore_user_abort(true);
if (!defined('IN_OAOOA')) {
exit('Access Denied');
}
@set_time_limit(0);
ini_set('memory_limit', -1);
@ini_set('max_execution_time', 0);
$appids = [];
foreach(DB::fetch_all("select appid from %t where `type` = %d and getinfo = %d",array('pichome_vapp',1,1)) as $v){
$appids[] = $v['appid'];
}
if(empty($appids)){
exit('success');
}
$locked = true;
for($i=0;$i<1;$i++){
$processname = 'DZZ_LOCK_PICHOMEGETVIDOTHUMB'.$i;
if (!dzz_process::islocked($processname, 60*60)) {
$locked=false;
break;
}
}
$processname = 'DZZ_LOCK_PICHOMEGETVIDOTHUMB'.$i;
$limit = 10;
$start=$i*$limit;
if (!dzz_process::islocked($processname, 60*60)) {
$locked=false;
}
if ($locked) {
exit(json_encode( array('error'=>'进程已被锁定请稍后再试')));
}
use dzz\ffmpeg\classes\thumb as thumb;
$thumb =new thumb;
foreach(DB::fetch_all("select * from %t where thumbstatus = 0 and appid in(%n)
order by thumbdonum asc limit $start,$limit",array('pichome_ffmpeg_record',$appids)) as $v){
$processname1 = 'PICHOMEGETVIDOTHUMB_'.$v['rid'];
if (dzz_process::islocked($processname1, 60*5)) {
continue;
}
$data = C::t('pichome_resources')->fetch_data_by_rid($v['rid']);
if(empty($data)){
C::t('pichome_ffmpeg_record')->delete($v['rid']);
dzz_process::unlock($processname1);
continue;
}else{
//如果缩略图获取次数大于三次直接赋值为1不再尝试获取
if($v['thumbdonum'] > 3 && $v['thumbstatus'] == 0){
$v['infostatus'] = 1;
C::t('pichome_ffmpeg_record')->update($v['rid'],array('infostatus'=>1));
dzz_process::unlock($processname1);
continue;
}
//如果信息和缩略图标记为已生成,标记该文件信息状态为已获取
if($v['thumbstatus'] == 1 && $v['infostatus'] == 1){
C::t('pichome_resources_attr')->update($v['rid'],array('isget'=>1));
dzz_process::unlock($processname1);
continue;
}
DB::query("update %t set thumbdonum=thumbdonum+%d where rid = %s ", array('pichome_ffmpeg_record', 1, $data['rid']));
$thumb->rundata($data);
dzz_process::unlock($processname1);
}
}
dzz_process::unlock($processname);
if(DB::result_first("select * from %t where thumbstatus = 0 ",array('pichome_ffmpeg_record'))){
dfsockopen(getglobal('localurl') . 'index.php?mod=ffmpeg&op=thumb', 0, '', '', false, '', 0.1);
}
exit('success');

View File

@@ -0,0 +1,21 @@
BinaryDriver is released with MIT License :
Copyright (c) 2013 Alchemy
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

@@ -0,0 +1,219 @@
<?php
/*
* This file is part of Alchemy\BinaryDriver.
*
* (c) Alchemy <info@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\BinaryDriver;
use Alchemy\BinaryDriver\Exception\ExecutableNotFoundException;
use Alchemy\BinaryDriver\Exception\ExecutionFailureException;
use Alchemy\BinaryDriver\Listeners\Listeners;
use Alchemy\BinaryDriver\Listeners\ListenerInterface;
use Evenement\EventEmitter;
use Monolog\Logger;
use Monolog\Handler\NullHandler;
use Psr\Log\LoggerInterface;
use Symfony\Component\Process\ExecutableFinder;
use Symfony\Component\Process\Process;
abstract class AbstractBinary extends EventEmitter implements BinaryInterface
{
/** @var ConfigurationInterface */
protected $configuration;
/** @var ProcessBuilderFactoryInterface */
protected $factory;
/** @var ProcessRunner */
private $processRunner;
/** @var Listeners */
private $listenersManager;
public function __construct(ProcessBuilderFactoryInterface $factory, LoggerInterface $logger, ConfigurationInterface $configuration)
{
$this->factory = $factory;
$this->configuration = $configuration;
$this->processRunner = new ProcessRunner($logger, $this->getName());
$this->listenersManager = new Listeners();
$this->applyProcessConfiguration();
}
/**
* {@inheritdoc}
*/
public function listen(ListenerInterface $listener)
{
$this->listenersManager->register($listener, $this);
return $this;
}
/**
* {@inheritdoc}
*/
public function unlisten(ListenerInterface $listener)
{
$this->listenersManager->unregister($listener, $this);
return $this;
}
/**
* {@inheritdoc}
*/
public function getConfiguration()
{
return $this->configuration;
}
/**
* {@inheritdoc}
*
* @return BinaryInterface
*/
public function setConfiguration(ConfigurationInterface $configuration)
{
$this->configuration = $configuration;
$this->applyProcessConfiguration();
return $this;
}
/**
* {@inheritdoc}
*/
public function getProcessBuilderFactory()
{
return $this->factory;
}
/**
* {@inheritdoc}
*
* @return BinaryInterface
*/
public function setProcessBuilderFactory(ProcessBuilderFactoryInterface $factory)
{
$this->factory = $factory;
$this->applyProcessConfiguration();
return $this;
}
/**
* {@inheritdoc}
*/
public function getProcessRunner()
{
return $this->processRunner;
}
/**
* {@inheritdoc}
*/
public function setProcessRunner(ProcessRunnerInterface $runner)
{
$this->processRunner = $runner;
return $this;
}
/**
* {@inheritdoc}
*/
public function command($command, $bypassErrors = false, $listeners = null)
{
if (!is_array($command)) {
$command = array($command);
}
return $this->run($this->factory->create($command), $bypassErrors, $listeners);
}
/**
* {@inheritdoc}
*/
public static function load($binaries, LoggerInterface $logger = null, $configuration = array())
{
$finder = new ExecutableFinder();
$binary = null;
$binaries = is_array($binaries) ? $binaries : array($binaries);
foreach ($binaries as $candidate) {
if (file_exists($candidate) && is_executable($candidate)) {
$binary = $candidate;
break;
}
if (null !== $binary = $finder->find($candidate)) {
break;
}
}
if (null === $binary) {
throw new ExecutableNotFoundException(sprintf(
'Executable not found, proposed : %s', implode(', ', $binaries)
));
}
if (null === $logger) {
$logger = new Logger(__NAMESPACE__ . ' logger');
$logger->pushHandler(new NullHandler());
}
$configuration = $configuration instanceof ConfigurationInterface ? $configuration : new Configuration($configuration);
return new static(new ProcessBuilderFactory($binary), $logger, $configuration);
}
/**
* Returns the name of the driver
*
* @return string
*/
abstract public function getName();
/**
* Executes a process, logs events
*
* @param Process $process
* @param Boolean $bypassErrors Set to true to disable throwing ExecutionFailureExceptions
* @param ListenerInterface|array $listeners A listener or an array of listener to register for this unique run
*
* @return string The Process output
*
* @throws ExecutionFailureException in case of process failure.
*/
protected function run(Process $process, $bypassErrors = false, $listeners = null)
{
if (null !== $listeners) {
if (!is_array($listeners)) {
$listeners = array($listeners);
}
$listenersManager = clone $this->listenersManager;
foreach ($listeners as $listener) {
$listenersManager->register($listener, $this);
}
} else {
$listenersManager = $this->listenersManager;
}
return $this->processRunner->run($process, $listenersManager->storage, $bypassErrors);
}
private function applyProcessConfiguration()
{
if ($this->configuration->has('timeout')) {
$this->factory->setTimeout($this->configuration->get('timeout'));
}
return $this;
}
}

View File

@@ -0,0 +1,76 @@
<?php
namespace Alchemy\BinaryDriver;
use Psr\Log\LoggerInterface;
use Symfony\Component\Process\Process;
/**
* Convenient PHPUnit methods for testing BinaryDriverInterface implementations.
*/
class BinaryDriverTestCase extends \PHPUnit_Framework_TestCase
{
/**
* @return ProcessBuilderFactoryInterface
*/
public function createProcessBuilderFactoryMock()
{
return $this->getMock('Alchemy\BinaryDriver\ProcessBuilderFactoryInterface');
}
/**
* @param integer $runs The number of runs expected
* @param Boolean $success True if the process expects to be successfull
* @param string $commandLine The commandline executed
* @param string $output The process output
* @param string $error The process error output
*
* @return Process
*/
public function createProcessMock($runs = 1, $success = true, $commandLine = null, $output = null, $error = null, $callback = false)
{
$process = $this->getMockBuilder('Symfony\Component\Process\Process')
->disableOriginalConstructor()
->getMock();
$builder = $process->expects($this->exactly($runs))
->method('run');
if (true === $callback) {
$builder->with($this->isInstanceOf('Closure'));
}
$process->expects($this->any())
->method('isSuccessful')
->will($this->returnValue($success));
foreach (array(
'getOutput' => $output,
'getErrorOutput' => $error,
'getCommandLine' => $commandLine,
) as $command => $value) {
$process
->expects($this->any())
->method($command)
->will($this->returnValue($value));
}
return $process;
}
/**
* @return LoggerInterface
*/
public function createLoggerMock()
{
return $this->getMock('Psr\Log\LoggerInterface');
}
/**
* @return ConfigurationInterface
*/
public function createConfigurationMock()
{
return $this->getMock('Alchemy\BinaryDriver\ConfigurationInterface');
}
}

View File

@@ -0,0 +1,67 @@
<?php
/*
* This file is part of Alchemy\BinaryDriver.
*
* (c) Alchemy <info@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\BinaryDriver;
use Alchemy\BinaryDriver\Exception\ExecutableNotFoundException;
use Alchemy\BinaryDriver\Exception\ExecutionFailureException;
use Alchemy\BinaryDriver\Listeners\ListenerInterface;
use Psr\Log\LoggerInterface;
use Evenement\EventEmitterInterface;
interface BinaryInterface extends ConfigurationAwareInterface, ProcessBuilderFactoryAwareInterface, ProcessRunnerAwareInterface, EventEmitterInterface
{
/**
* Adds a listener to the binary driver
*
* @param ListenerInterface $listener
*
* @return BinaryInterface
*/
public function listen(ListenerInterface $listener);
/**
* Removes a listener from the binary driver
*
* @param ListenerInterface $listener
*
* @return BinaryInterface
*/
public function unlisten(ListenerInterface $listener);
/**
* Runs a command against the driver.
*
* Calling this method on a `ls` driver with the command `-a` would run `ls -a`.
*
* @param array|string $command A command or an array of command
* @param Boolean $bypassErrors If set to true, an erronous process will not throw an exception
* @param ListenerInterface|array $listeners A listener or an array of listeners to register for this unique run
*
* @return string The command output
*
* @throws ExecutionFailureException in case of process failure.
*/
public function command($command, $bypassErrors = false, $listeners = null);
/**
* Loads a binary
*
* @param string|array $binaries A binary name or an array of binary names
* @param null|LoggerInterface $logger A Logger
* @param array|ConfigurationInterface $configuration The configuration
*
* @throws ExecutableNotFoundException In case none of the binaries were found
*
* @return BinaryInterface
*/
public static function load($binaries, LoggerInterface $logger = null, $configuration = array());
}

View File

@@ -0,0 +1,107 @@
<?php
/*
* This file is part of Alchemy\BinaryDriver.
*
* (c) Alchemy <info@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\BinaryDriver;
class Configuration implements ConfigurationInterface
{
private $data;
public function __construct(array $data = array())
{
$this->data = $data;
}
/**
* {@inheritdoc}
*/
public function getIterator()
{
return new \ArrayIterator($this->data);
}
/**
* {@inheritdoc}
*/
public function get($key, $default = null)
{
return isset($this->data[$key]) ? $this->data[$key] : $default;
}
/**
* {@inheritdoc}
*/
public function set($key, $value)
{
$this->data[$key] = $value;
return $this;
}
/**
* {@inheritdoc}
*/
public function has($key)
{
return array_key_exists($key, $this->data);
}
/**
* {@inheritdoc}
*/
public function remove($key)
{
$value = $this->get($key);
unset($this->data[$key]);
return $value;
}
/**
* {@inheritdoc}
*/
public function all()
{
return $this->data;
}
/**
* {@inheritdoc}
*/
public function offsetExists($offset)
{
return $this->has($offset);
}
/**
* {@inheritdoc}
*/
public function offsetGet($offset)
{
return $this->get($offset);
}
/**
* {@inheritdoc}
*/
public function offsetSet($offset, $value)
{
$this->set($offset, $value);
}
/**
* {@inheritdoc}
*/
public function offsetUnset($offset)
{
$this->remove($offset);
}
}

View File

@@ -0,0 +1,29 @@
<?php
/*
* This file is part of Alchemy\BinaryDriver.
*
* (c) Alchemy <info@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\BinaryDriver;
interface ConfigurationAwareInterface
{
/**
* Returns the configuration
*
* @return ConfigurationInterface
*/
public function getConfiguration();
/**
* Set the configuration
*
* @param ConfigurationInterface $configuration
*/
public function setConfiguration(ConfigurationInterface $configuration);
}

View File

@@ -0,0 +1,58 @@
<?php
/*
* This file is part of Alchemy\BinaryDriver.
*
* (c) Alchemy <info@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\BinaryDriver;
interface ConfigurationInterface extends \ArrayAccess, \IteratorAggregate
{
/**
* Returns the value given a key from configuration
*
* @param string $key
* @param mixed $default The default value in case the key does not exist
*
* @return mixed
*/
public function get($key, $default = null);
/**
* Set a value to configuration
*
* @param string $key The key
* @param mixed $value The value corresponding to the key
*/
public function set($key, $value);
/**
* Tells if Configuration contains `$key`
*
* @param string $key
*
* @return Boolean
*/
public function has($key);
/**
* Removes a value given a key
*
* @param string $key
*
* @return mixed The previous value
*/
public function remove($key);
/**
* Returns all values set in the configuration
*
* @return array
*/
public function all();
}

View File

@@ -0,0 +1,16 @@
<?php
/*
* This file is part of Alchemy\BinaryDriver.
*
* (c) Alchemy <info@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\BinaryDriver\Exception;
interface ExceptionInterface
{
}

View File

@@ -0,0 +1,16 @@
<?php
/*
* This file is part of Alchemy\BinaryDriver.
*
* (c) Alchemy <info@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\BinaryDriver\Exception;
class ExecutableNotFoundException extends \RuntimeException implements ExceptionInterface
{
}

View File

@@ -0,0 +1,16 @@
<?php
/*
* This file is part of Alchemy\BinaryDriver.
*
* (c) Alchemy <info@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\BinaryDriver\Exception;
class ExecutionFailureException extends \RuntimeException implements ExceptionInterface
{
}

View File

@@ -0,0 +1,16 @@
<?php
/*
* This file is part of Alchemy\BinaryDriver.
*
* (c) Alchemy <info@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\BinaryDriver\Exception;
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
{
}

View File

@@ -0,0 +1,58 @@
<?php
/*
* This file is part of Alchemy\BinaryDriver.
*
* (c) Alchemy <info@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\BinaryDriver\Listeners;
use Evenement\EventEmitter;
use Symfony\Component\Process\Process;
class DebugListener extends EventEmitter implements ListenerInterface
{
private $prefixOut;
private $prefixErr;
private $eventOut;
private $eventErr;
public function __construct($prefixOut = '[OUT] ', $prefixErr = '[ERROR] ', $eventOut = 'debug', $eventErr = 'debug')
{
$this->prefixOut = $prefixOut;
$this->prefixErr = $prefixErr;
$this->eventOut = $eventOut;
$this->eventErr = $eventErr;
}
/**
* {@inheritdoc}
*/
public function handle($type, $data)
{
if (Process::ERR === $type) {
$this->emitLines($this->eventErr, $this->prefixErr, $data);
} elseif (Process::OUT === $type) {
$this->emitLines($this->eventOut, $this->prefixOut, $data);
}
}
/**
* {@inheritdoc}
*/
public function forwardedEvents()
{
return array_unique(array($this->eventErr, $this->eventOut));
}
private function emitLines($event, $prefix, $lines)
{
foreach (explode("\n", $lines) as $line) {
$this->emit($event, array($prefix . $line));
}
}
}

View File

@@ -0,0 +1,32 @@
<?php
/*
* This file is part of Alchemy\BinaryDriver.
*
* (c) Alchemy <info@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\BinaryDriver\Listeners;
use Evenement\EventEmitterInterface;
interface ListenerInterface extends EventEmitterInterface
{
/**
* Handle the output of a ProcessRunner
*
* @param string $type The data type, one of Process::ERR, Process::OUT constants
* @param string $data The output
*/
public function handle($type, $data);
/**
* An array of events that should be forwarded to BinaryInterface
*
* @return array
*/
public function forwardedEvents();
}

View File

@@ -0,0 +1,88 @@
<?php
namespace Alchemy\BinaryDriver\Listeners;
use SplObjectStorage;
use Evenement\EventEmitter;
class Listeners extends EventEmitter
{
/** @var SplObjectStorage */
public $storage;
public function __construct()
{
$this->storage = new SplObjectStorage();
}
public function __clone()
{
$storage = $this->storage;
$this->storage = new SplObjectStorage();
$this->storage->addAll($storage);
}
/**
* Registers a listener, pass the listener events to the target.
*
* @param ListenerInterface $listener
* @param null|EventEmitter $target
*
* @return ListenersInterface
*/
public function register(ListenerInterface $listener, EventEmitter $target = null)
{
$EElisteners = array();
if (null !== $target) {
$EElisteners = $this->forwardEvents($listener, $target, $listener->forwardedEvents());
}
$this->storage->attach($listener, $EElisteners);
return $this;
}
/**
* Unregisters a listener, removes the listener events from the target.
*
* @param ListenerInterface $listener
*
* @return ListenersInterface
*
* @throws InvalidArgumentException In case the listener is not registered
*/
public function unregister(ListenerInterface $listener)
{
if (!isset($this->storage[$listener])) {
throw new InvalidArgumentException('Listener is not registered.');
}
foreach ($this->storage[$listener] as $event => $EElistener) {
$listener->removeListener($event, $EElistener);
}
$this->storage->detach($listener);
return $this;
}
private function forwardEvents($source, $target, array $events)
{
$EElisteners = array();
foreach ($events as $event) {
$listener = $this->createListener($event, $target);
$source->on($event, $EElisteners[$event] = $listener);
}
return $EElisteners;
}
private function createListener($event, $target)
{
return function () use ($event, $target) {
$target->emit($event, func_get_args());
};
}
}

View File

@@ -0,0 +1,178 @@
<?php
/*
* This file is part of Alchemy\BinaryDriver.
*
* (c) Alchemy <info@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\BinaryDriver;
use Alchemy\BinaryDriver\Exception\InvalidArgumentException;
use Symfony\Component\Process\ProcessBuilder;
class ProcessBuilderFactory implements ProcessBuilderFactoryInterface
{
/**
* The binary path
*
* @var String
*/
protected $binary;
/**
* The timeout for the generated processes
*
* @var integer|float
*/
private $timeout;
/**
* An internal ProcessBuilder.
*
* Note that this one is used only if Symfony ProcessBuilder has method
* setPrefix (2.3)
*
* @var ProcessBuilder
*/
private $builder;
/**
* Tells whether Symfony LTS ProcessBuilder should be emulated or not.
*
* This symfony version provided a brand new ::setPrefix method.
*
* @var Boolean
*/
public static $emulateSfLTS;
/**
* Constructor
*
* @param String $binary The path to the binary
*
* @throws InvalidArgumentException In case binary path is invalid
*/
public function __construct($binary)
{
$this->detectEmulation();
if (!self::$emulateSfLTS) {
$this->builder = new ProcessBuilder();
}
$this->useBinary($binary);
}
/**
* Covenient method for unit testing
*
* @return type
*/
public function getBuilder()
{
return $this->builder;
}
/**
* Covenient method for unit testing
*
* @param ProcessBuilder $builder
* @return ProcessBuilderFactory
*/
public function setBuilder(ProcessBuilder $builder)
{
$this->builder = $builder;
return $this;
}
/**
* @inheritdoc
*/
public function getBinary()
{
return $this->binary;
}
/**
* @inheritdoc
*/
public function useBinary($binary)
{
if (!is_executable($binary)) {
throw new InvalidArgumentException(sprintf('`%s` is not an executable binary', $binary));
}
$this->binary = $binary;
if (!static::$emulateSfLTS) {
$this->builder->setPrefix($binary);
}
return $this;
}
/**
* @inheritdoc
*/
public function setTimeout($timeout)
{
$this->timeout = $timeout;
if (!static::$emulateSfLTS) {
$this->builder->setTimeout($this->timeout);
}
return $this;
}
/**
* @inheritdoc
*/
public function getTimeout()
{
return $this->timeout;
}
/**
* @inheritdoc
*/
public function create($arguments = array())
{
if (null === $this->binary) {
throw new InvalidArgumentException('No binary set');
}
if (!is_array($arguments)) {
$arguments = array($arguments);
}
if (static::$emulateSfLTS) {
array_unshift($arguments, $this->binary);
return ProcessBuilder::create($arguments)
->setTimeout($this->timeout)
->getProcess();
} else {
return $this->builder
->setArguments($arguments)
->getProcess();
}
}
private function detectEmulation()
{
if (null !== static::$emulateSfLTS) {
return $this;
}
static::$emulateSfLTS = !method_exists('Symfony\Component\Process\ProcessBuilder', 'setPrefix');
return $this;
}
}

View File

@@ -0,0 +1,29 @@
<?php
/*
* This file is part of Alchemy\BinaryDriver.
*
* (c) Alchemy <info@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\BinaryDriver;
interface ProcessBuilderFactoryAwareInterface
{
/**
* Returns the current process builder factory
*
* @return ProcessBuilderFactoryInterface
*/
public function getProcessBuilderFactory();
/**
* Set a process builder factory
*
* @param ProcessBuilderFactoryInterface $factory
*/
public function setProcessBuilderFactory(ProcessBuilderFactoryInterface $factory);
}

View File

@@ -0,0 +1,65 @@
<?php
/*
* This file is part of Alchemy\BinaryDriver.
*
* (c) Alchemy <info@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\BinaryDriver;
use Alchemy\BinaryDriver\Exception\InvalidArgumentException;
use Symfony\Component\Process\Process;
interface ProcessBuilderFactoryInterface
{
/**
* Returns a new instance of Symfony Process
*
* @param string|array $arguments An argument or an array of arguments
*
* @return Process
*
* @throws InvalidArgumentException
*/
public function create($arguments = array());
/**
* Returns the path to the binary that is used
*
* @return String
*/
public function getBinary();
/**
* Sets the path to the binary
*
* @param String $binary A path to a binary
*
* @return ProcessBuilderFactoryInterface
*
* @throws InvalidArgumentException In case binary is not executable
*/
public function useBinary($binary);
/**
* Set the default timeout to apply on created processes.
*
* @param integer|float $timeout
*
* @return ProcessBuilderFactoryInterface
*
* @throws InvalidArgumentException In case the timeout is not valid
*/
public function setTimeout($timeout);
/**
* Returns the current timeout applied to the created processes.
*
* @return integer|float
*/
public function getTimeout();
}

View File

@@ -0,0 +1,104 @@
<?php
/*
* This file is part of Alchemy\BinaryDriver.
*
* (c) Alchemy <info@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\BinaryDriver;
use Alchemy\BinaryDriver\Exception\ExecutionFailureException;
use Psr\Log\LoggerInterface;
use SplObjectStorage;
use Symfony\Component\Process\Exception\RuntimeException;
use Symfony\Component\Process\Process;
class ProcessRunner implements ProcessRunnerInterface
{
/** @var LoggerInterface */
private $logger;
/** @var string */
private $name;
public function __construct(LoggerInterface $logger, $name)
{
$this->logger = $logger;
$this->name = $name;
}
/**
* {@inheritdoc}
*
* @return ProcessRunner
*/
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
return $this;
}
/**
* @return LoggerInterface
*/
public function getLogger()
{
return $this->logger;
}
/**
* {@inheritdoc}
*/
public function run(Process $process, SplObjectStorage $listeners, $bypassErrors)
{
$this->logger->info(sprintf(
'%s running command %s', $this->name, $process->getCommandLine()
));
try {
$process->run($this->buildCallback($listeners));
} catch (RuntimeException $e) {
if (!$bypassErrors) {
$this->doExecutionFailure($process->getCommandLine(), $e);
}
}
if (!$bypassErrors && !$process->isSuccessful()) {
$this->doExecutionFailure($process->getCommandLine());
} elseif (!$process->isSuccessful()) {
$this->logger->error(sprintf(
'%s failed to execute command %s', $this->name, $process->getCommandLine()
));
return;
} else {
$this->logger->info(sprintf('%s executed command successfully', $this->name));
return $process->getOutput();
}
}
private function buildCallback(SplObjectStorage $listeners)
{
return function ($type, $data) use ($listeners) {
foreach ($listeners as $listener) {
$listener->handle($type, $data);
}
};
}
private function doExecutionFailure($command, \Exception $e = null)
{
$this->logger->error(sprintf(
'%s failed to execute command %s', $this->name, $command
));
throw new ExecutionFailureException(sprintf(
'%s failed to execute command %s', $this->name, $command
), $e ? $e->getCode() : null, $e ?: null);
}
}

View File

@@ -0,0 +1,29 @@
<?php
/*
* This file is part of Alchemy\BinaryDriver.
*
* (c) Alchemy <info@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\BinaryDriver;
interface ProcessRunnerAwareInterface
{
/**
* Returns the current process runner
*
* @return ProcessRunnerInterface
*/
public function getProcessRunner();
/**
* Sets a process runner
*
* @param ProcessRunnerInterface $runner
*/
public function setProcessRunner(ProcessRunnerInterface $runner);
}

View File

@@ -0,0 +1,33 @@
<?php
/*
* This file is part of Alchemy\BinaryDriver.
*
* (c) Alchemy <info@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\BinaryDriver;
use Alchemy\BinaryDriver\Exception\ExecutionFailureException;
use Psr\Log\LoggerAwareInterface;
use SplObjectStorage;
use Symfony\Component\Process\Process;
interface ProcessRunnerInterface extends LoggerAwareInterface
{
/**
* Executes a process, logs events
*
* @param Process $process
* @param SplObjectStorage $listeners Some listeners
* @param Boolean $bypassErrors Set to true to disable throwing ExecutionFailureExceptions
*
* @return string The Process output
*
* @throws ExecutionFailureException in case of process failure.
*/
public function run(Process $process, SplObjectStorage $listeners, $bypassErrors);
}

7
dzz/ffmpeg/vendor/autoload.php vendored Normal file
View File

@@ -0,0 +1,7 @@
<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit0028b869d9f066bb1e686f4c2c87cb1a::getLoader();

View File

@@ -0,0 +1,445 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Autoload;
/**
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
*
* $loader = new \Composer\Autoload\ClassLoader();
*
* // register classes with namespaces
* $loader->add('Symfony\Component', __DIR__.'/component');
* $loader->add('Symfony', __DIR__.'/framework');
*
* // activate the autoloader
* $loader->register();
*
* // to enable searching the include path (eg. for PEAR packages)
* $loader->setUseIncludePath(true);
*
* In this example, if you try to use a class in the Symfony\Component
* namespace or one of its children (Symfony\Component\Console for instance),
* the autoloader will first look for the class under the component/
* directory, and it will then fallback to the framework/ directory if not
* found before giving up.
*
* This class is loosely based on the Symfony UniversalClassLoader.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @see http://www.php-fig.org/psr/psr-0/
* @see http://www.php-fig.org/psr/psr-4/
*/
class ClassLoader
{
// PSR-4
private $prefixLengthsPsr4 = array();
private $prefixDirsPsr4 = array();
private $fallbackDirsPsr4 = array();
// PSR-0
private $prefixesPsr0 = array();
private $fallbackDirsPsr0 = array();
private $useIncludePath = false;
private $classMap = array();
private $classMapAuthoritative = false;
private $missingClasses = array();
private $apcuPrefix;
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', $this->prefixesPsr0);
}
return array();
}
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
public function getClassMap()
{
return $this->classMap;
}
/**
* @param array $classMap Class to filename map
*/
public function addClassMap(array $classMap)
{
if ($this->classMap) {
$this->classMap = array_merge($this->classMap, $classMap);
} else {
$this->classMap = $classMap;
}
}
/**
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*/
public function add($prefix, $paths, $prepend = false)
{
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
(array) $paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
(array) $paths
);
}
return;
}
$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
(array) $paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
(array) $paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
(array) $paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
// Register directories for a new namespace.
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
(array) $paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 base directories
*/
public function set($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr0 = (array) $paths;
} else {
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
}
}
/**
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*/
public function setPsr4($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr4 = (array) $paths;
} else {
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
}
}
/**
* Turns on searching the include path for class files.
*
* @param bool $useIncludePath
*/
public function setUseIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
}
/**
* Can be used to check if the autoloader uses the include path to check
* for classes.
*
* @return bool
*/
public function getUseIncludePath()
{
return $this->useIncludePath;
}
/**
* Turns off searching the prefix and fallback directories for classes
* that have not been registered with the class map.
*
* @param bool $classMapAuthoritative
*/
public function setClassMapAuthoritative($classMapAuthoritative)
{
$this->classMapAuthoritative = $classMapAuthoritative;
}
/**
* Should class lookup fail if not found in the current class map?
*
* @return bool
*/
public function isClassMapAuthoritative()
{
return $this->classMapAuthoritative;
}
/**
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
*
* @param string|null $apcuPrefix
*/
public function setApcuPrefix($apcuPrefix)
{
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
}
/**
* The APCu prefix in use, or null if APCu caching is not enabled.
*
* @return string|null
*/
public function getApcuPrefix()
{
return $this->apcuPrefix;
}
/**
* Registers this instance as an autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
}
/**
* Unregisters this instance as an autoloader.
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
}
/**
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return bool|null True if loaded, null otherwise
*/
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
includeFile($file);
return true;
}
}
/**
* Finds the path to the file where the class is defined.
*
* @param string $class The name of the class
*
* @return string|false The path if found, false otherwise
*/
public function findFile($class)
{
// class map lookup
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
return false;
}
if (null !== $this->apcuPrefix) {
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
if ($hit) {
return $file;
}
}
$file = $this->findFileWithExtension($class, '.php');
// Search for Hack files if we are running on HHVM
if (false === $file && defined('HHVM_VERSION')) {
$file = $this->findFileWithExtension($class, '.hh');
}
if (null !== $this->apcuPrefix) {
apcu_add($this->apcuPrefix.$class, $file);
}
if (false === $file) {
// Remember that this class does not exist.
$this->missingClasses[$class] = true;
}
return $file;
}
private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
$first = $class[0];
if (isset($this->prefixLengthsPsr4[$first])) {
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath . '\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
}
}
}
}
// PSR-4 fallback dirs
foreach ($this->fallbackDirsPsr4 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
return $file;
}
}
// PSR-0 lookup
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
} else {
// PEAR-like class name
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
}
if (isset($this->prefixesPsr0[$first])) {
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
}
}
}
// PSR-0 fallback dirs
foreach ($this->fallbackDirsPsr0 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
// PSR-0 include paths.
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
return $file;
}
return false;
}
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*/
function includeFile($file)
{
include $file;
}

21
dzz/ffmpeg/vendor/composer/LICENSE vendored Normal file
View File

@@ -0,0 +1,21 @@
Copyright (c) Nils Adermann, Jordi Boggiano
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

@@ -0,0 +1,9 @@
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);

View File

@@ -0,0 +1,10 @@
<?php
// autoload_files.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
);

View File

@@ -0,0 +1,13 @@
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Neutron' => array($vendorDir . '/neutron/temporary-filesystem/src'),
'FFMpeg' => array($vendorDir . '/php-ffmpeg/extras/src', $vendorDir . '/php-ffmpeg/php-ffmpeg/src'),
'Evenement' => array($vendorDir . '/evenement/evenement/src'),
'Alchemy' => array($vendorDir . '/alchemy/binary-driver/src'),
);

View File

@@ -0,0 +1,15 @@
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
'Symfony\\Component\\Process\\' => array($vendorDir . '/symfony/process'),
'Symfony\\Component\\Filesystem\\' => array($vendorDir . '/symfony/filesystem'),
'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'),
'Doctrine\\Common\\Cache\\' => array($vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache'),
);

View File

@@ -0,0 +1,70 @@
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit0028b869d9f066bb1e686f4c2c87cb1a
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit0028b869d9f066bb1e686f4c2c87cb1a', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit0028b869d9f066bb1e686f4c2c87cb1a', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit0028b869d9f066bb1e686f4c2c87cb1a::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
}
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit0028b869d9f066bb1e686f4c2c87cb1a::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire0028b869d9f066bb1e686f4c2c87cb1a($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire0028b869d9f066bb1e686f4c2c87cb1a($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
}
}

View File

@@ -0,0 +1,102 @@
<?php
// autoload_static.php @generated by Composer
namespace Composer\Autoload;
class ComposerStaticInit0028b869d9f066bb1e686f4c2c87cb1a
{
public static $files = array (
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
);
public static $prefixLengthsPsr4 = array (
'S' =>
array (
'Symfony\\Polyfill\\Ctype\\' => 23,
'Symfony\\Component\\Process\\' => 26,
'Symfony\\Component\\Filesystem\\' => 29,
),
'P' =>
array (
'Psr\\Log\\' => 8,
),
'M' =>
array (
'Monolog\\' => 8,
),
'D' =>
array (
'Doctrine\\Common\\Cache\\' => 22,
),
);
public static $prefixDirsPsr4 = array (
'Symfony\\Polyfill\\Ctype\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/polyfill-ctype',
),
'Symfony\\Component\\Process\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/process',
),
'Symfony\\Component\\Filesystem\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/filesystem',
),
'Psr\\Log\\' =>
array (
0 => __DIR__ . '/..' . '/psr/log/Psr/Log',
),
'Monolog\\' =>
array (
0 => __DIR__ . '/..' . '/monolog/monolog/src/Monolog',
),
'Doctrine\\Common\\Cache\\' =>
array (
0 => __DIR__ . '/..' . '/doctrine/cache/lib/Doctrine/Common/Cache',
),
);
public static $prefixesPsr0 = array (
'N' =>
array (
'Neutron' =>
array (
0 => __DIR__ . '/..' . '/neutron/temporary-filesystem/src',
),
),
'F' =>
array (
'FFMpeg' =>
array (
0 => __DIR__ . '/..' . '/php-ffmpeg/extras/src',
1 => __DIR__ . '/..' . '/php-ffmpeg/php-ffmpeg/src',
),
),
'E' =>
array (
'Evenement' =>
array (
0 => __DIR__ . '/..' . '/evenement/evenement/src',
),
),
'A' =>
array (
'Alchemy' =>
array (
0 => __DIR__ . '/..' . '/alchemy/binary-driver/src',
),
),
);
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit0028b869d9f066bb1e686f4c2c87cb1a::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit0028b869d9f066bb1e686f4c2c87cb1a::$prefixDirsPsr4;
$loader->prefixesPsr0 = ComposerStaticInit0028b869d9f066bb1e686f4c2c87cb1a::$prefixesPsr0;
}, null, ClassLoader::class);
}
}

View File

@@ -0,0 +1,656 @@
[
{
"name": "alchemy/binary-driver",
"version": "1.6.0",
"version_normalized": "1.6.0.0",
"source": {
"type": "git",
"url": "https://github.com/alchemy-fr/BinaryDriver.git",
"reference": "80c6633890afb71d2417ae851d0ad167d8b00b95"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/alchemy-fr/BinaryDriver/zipball/80c6633890afb71d2417ae851d0ad167d8b00b95",
"reference": "80c6633890afb71d2417ae851d0ad167d8b00b95",
"shasum": ""
},
"require": {
"evenement/evenement": "^2.0|^1.0",
"monolog/monolog": "^1.3",
"php": ">=5.5",
"psr/log": "^1.0",
"symfony/process": "^2.0|^3.0"
},
"require-dev": {
"phpunit/phpunit": "^4.0|^5.0"
},
"time": "2016-03-02T13:49:15+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-0": {
"Alchemy": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Romain Neutron",
"email": "imprec@gmail.com",
"homepage": "http://www.lickmychip.com/"
},
{
"name": "Phraseanet Team",
"email": "info@alchemy.fr",
"homepage": "http://www.phraseanet.com/"
},
{
"name": "Nicolas Le Goff",
"email": "legoff.n@gmail.com"
}
],
"description": "A set of tools to build binary drivers",
"keywords": [
"binary",
"driver"
]
},
{
"name": "doctrine/cache",
"version": "v1.8.0",
"version_normalized": "1.8.0.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/cache.git",
"reference": "d768d58baee9a4862ca783840eca1b9add7a7f57"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/cache/zipball/d768d58baee9a4862ca783840eca1b9add7a7f57",
"reference": "d768d58baee9a4862ca783840eca1b9add7a7f57",
"shasum": ""
},
"require": {
"php": "~7.1"
},
"conflict": {
"doctrine/common": ">2.2,<2.4"
},
"require-dev": {
"alcaeus/mongo-php-adapter": "^1.1",
"doctrine/coding-standard": "^4.0",
"mongodb/mongodb": "^1.1",
"phpunit/phpunit": "^7.0",
"predis/predis": "~1.0"
},
"suggest": {
"alcaeus/mongo-php-adapter": "Required to use legacy MongoDB driver"
},
"time": "2018-08-21T18:01:43+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.8.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
}
],
"description": "Caching library offering an object-oriented API for many cache backends",
"homepage": "https://www.doctrine-project.org",
"keywords": [
"cache",
"caching"
]
},
{
"name": "evenement/evenement",
"version": "v2.1.0",
"version_normalized": "2.1.0.0",
"source": {
"type": "git",
"url": "https://github.com/igorw/evenement.git",
"reference": "6ba9a777870ab49f417e703229d53931ed40fd7a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/igorw/evenement/zipball/6ba9a777870ab49f417e703229d53931ed40fd7a",
"reference": "6ba9a777870ab49f417e703229d53931ed40fd7a",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
},
"require-dev": {
"phpunit/phpunit": "^6.0||^5.7||^4.8.35"
},
"time": "2017-07-17T17:39:19+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Evenement": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Igor Wiedler",
"email": "igor@wiedler.ch"
}
],
"description": "Événement is a very simple event dispatching library for PHP",
"keywords": [
"event-dispatcher",
"event-emitter"
]
},
{
"name": "monolog/monolog",
"version": "1.24.0",
"version_normalized": "1.24.0.0",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
"reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266",
"reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"psr/log": "~1.0"
},
"provide": {
"psr/log-implementation": "1.0.0"
},
"require-dev": {
"aws/aws-sdk-php": "^2.4.9 || ^3.0",
"doctrine/couchdb": "~1.0@dev",
"graylog2/gelf-php": "~1.0",
"jakub-onderka/php-parallel-lint": "0.9",
"php-amqplib/php-amqplib": "~2.4",
"php-console/php-console": "^3.1.3",
"phpunit/phpunit": "~4.5",
"phpunit/phpunit-mock-objects": "2.3.0",
"ruflin/elastica": ">=0.90 <3.0",
"sentry/sentry": "^0.13",
"swiftmailer/swiftmailer": "^5.3|^6.0"
},
"suggest": {
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
"doctrine/couchdb": "Allow sending log messages to a CouchDB server",
"ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
"ext-mongo": "Allow sending log messages to a MongoDB server",
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
"mongodb/mongodb": "Allow sending log messages to a MongoDB server via PHP Driver",
"php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
"php-console/php-console": "Allow sending log messages to Google Chrome",
"rollbar/rollbar": "Allow sending log messages to Rollbar",
"ruflin/elastica": "Allow sending log messages to an Elastic Search server",
"sentry/sentry": "Allow sending log messages to a Sentry server"
},
"time": "2018-11-05T09:00:11+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Monolog\\": "src/Monolog"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
}
],
"description": "Sends your logs to files, sockets, inboxes, databases and various web services",
"homepage": "http://github.com/Seldaek/monolog",
"keywords": [
"log",
"logging",
"psr-3"
]
},
{
"name": "neutron/temporary-filesystem",
"version": "2.3.0",
"version_normalized": "2.3.0.0",
"source": {
"type": "git",
"url": "https://github.com/romainneutron/Temporary-Filesystem.git",
"reference": "694aa3885f653dd429584e825ffbab79441d285f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/romainneutron/Temporary-Filesystem/zipball/694aa3885f653dd429584e825ffbab79441d285f",
"reference": "694aa3885f653dd429584e825ffbab79441d285f",
"shasum": ""
},
"require": {
"php": "^5.6 || ^7.0",
"symfony/filesystem": "^2.3 || ^3.0 || ^4.0"
},
"require-dev": {
"phpunit/phpunit": "^5.0"
},
"time": "2018-02-07T21:11:57+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-0": {
"Neutron": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Romain Neutron",
"email": "imprec@gmail.com"
}
],
"description": "Symfony filesystem extension to handle temporary files"
},
{
"name": "php-ffmpeg/extras",
"version": "0.3.1",
"version_normalized": "0.3.1.0",
"source": {
"type": "git",
"url": "https://github.com/alchemy-fr/PHP-FFMpeg-Extras.git",
"reference": "4b3f87467e27c828641c3361ad395492775ab98c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/alchemy-fr/PHP-FFMpeg-Extras/zipball/4b3f87467e27c828641c3361ad395492775ab98c",
"reference": "4b3f87467e27c828641c3361ad395492775ab98c",
"shasum": ""
},
"require": {
"php": ">=5.3.2",
"php-ffmpeg/php-ffmpeg": "~0.3"
},
"require-dev": {
"phpunit/phpunit": "~3.7",
"sami/sami": "~1.0"
},
"time": "2014-02-24T10:48:44+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.3-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"FFMpeg": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Alchemy",
"email": "dev.team@alchemy.fr",
"homepage": "http://www.alchemy.fr/"
}
],
"description": "A set of audio/video formats compatible with PHP-FFMpeg",
"keywords": [
"codecs",
"ffmpeg"
]
},
{
"name": "php-ffmpeg/php-ffmpeg",
"version": "0.9.5",
"version_normalized": "0.9.5.0",
"source": {
"type": "git",
"url": "https://github.com/PHP-FFMpeg/PHP-FFMpeg.git",
"reference": "96225b2dff65a4c3b0b541f2420742ffe5851127"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHP-FFMpeg/PHP-FFMpeg/zipball/96225b2dff65a4c3b0b541f2420742ffe5851127",
"reference": "96225b2dff65a4c3b0b541f2420742ffe5851127",
"shasum": ""
},
"require": {
"alchemy/binary-driver": "^1.5",
"doctrine/cache": "^1.0",
"evenement/evenement": "^2.0 || ^1.0",
"neutron/temporary-filesystem": "^2.1.1",
"php": "^5.3.9 || ^7.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8",
"sami/sami": "~1.0",
"silex/silex": "~1.0"
},
"suggest": {
"php-ffmpeg/extras": "A compilation of common audio & video drivers for PHP-FFMpeg"
},
"time": "2017-06-30T19:27:10+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.7-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"FFMpeg": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Romain Neutron",
"email": "imprec@gmail.com",
"homepage": "http://www.lickmychip.com/"
},
{
"name": "Phraseanet Team",
"email": "info@alchemy.fr",
"homepage": "http://www.phraseanet.com/"
},
{
"name": "Patrik Karisch",
"email": "patrik@karisch.guru",
"homepage": "http://www.karisch.guru"
},
{
"name": "Romain Biard",
"email": "romain.biard@gmail.com",
"homepage": "https://www.strime.io/"
}
],
"description": "FFMpeg PHP, an Object Oriented library to communicate with AVconv / ffmpeg",
"keywords": [
"audio",
"audio processing",
"avconv",
"avprobe",
"ffmpeg",
"ffprobe",
"video",
"video processing"
]
},
{
"name": "psr/log",
"version": "1.1.0",
"version_normalized": "1.1.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd",
"reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"time": "2018-11-20T15:27:04+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Psr\\Log\\": "Psr/Log/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for logging libraries",
"homepage": "https://github.com/php-fig/log",
"keywords": [
"log",
"psr",
"psr-3"
]
},
{
"name": "symfony/filesystem",
"version": "v4.2.8",
"version_normalized": "4.2.8.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
"reference": "e16b9e471703b2c60b95f14d31c1239f68f11601"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/e16b9e471703b2c60b95f14d31c1239f68f11601",
"reference": "e16b9e471703b2c60b95f14d31c1239f68f11601",
"shasum": ""
},
"require": {
"php": "^7.1.3",
"symfony/polyfill-ctype": "~1.8"
},
"time": "2019-02-07T11:40:08+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Symfony\\Component\\Filesystem\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Filesystem Component",
"homepage": "https://symfony.com"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.11.0",
"version_normalized": "1.11.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "82ebae02209c21113908c229e9883c419720738a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a",
"reference": "82ebae02209c21113908c229e9883c419720738a",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"suggest": {
"ext-ctype": "For best performance"
},
"time": "2019-02-06T07:57:58+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.11-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
},
{
"name": "Gert de Pagter",
"email": "BackEndTea@gmail.com"
}
],
"description": "Symfony polyfill for ctype functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"ctype",
"polyfill",
"portable"
]
},
{
"name": "symfony/process",
"version": "v3.4.27",
"version_normalized": "3.4.27.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "a9c4dfbf653023b668c282e4e02609d131f4057a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/a9c4dfbf653023b668c282e4e02609d131f4057a",
"reference": "a9c4dfbf653023b668c282e4e02609d131f4057a",
"shasum": ""
},
"require": {
"php": "^5.5.9|>=7.0.8"
},
"time": "2019-04-08T16:15:54+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.4-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Symfony\\Component\\Process\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com"
}
]

View File

@@ -0,0 +1,19 @@
Copyright (c) 2006-2015 Doctrine Project
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

@@ -0,0 +1,104 @@
<?php
namespace Doctrine\Common\Cache;
use const PHP_VERSION_ID;
use function apc_cache_info;
use function apc_clear_cache;
use function apc_delete;
use function apc_exists;
use function apc_fetch;
use function apc_sma_info;
use function apc_store;
/**
* APC cache provider.
*
* @link www.doctrine-project.org
* @deprecated since version 1.6, use ApcuCache instead
*/
class ApcCache extends CacheProvider
{
/**
* {@inheritdoc}
*/
protected function doFetch($id)
{
return apc_fetch($id);
}
/**
* {@inheritdoc}
*/
protected function doContains($id)
{
return apc_exists($id);
}
/**
* {@inheritdoc}
*/
protected function doSave($id, $data, $lifeTime = 0)
{
return apc_store($id, $data, $lifeTime);
}
/**
* {@inheritdoc}
*/
protected function doDelete($id)
{
// apc_delete returns false if the id does not exist
return apc_delete($id) || ! apc_exists($id);
}
/**
* {@inheritdoc}
*/
protected function doFlush()
{
return apc_clear_cache() && apc_clear_cache('user');
}
/**
* {@inheritdoc}
*/
protected function doFetchMultiple(array $keys)
{
return apc_fetch($keys) ?: [];
}
/**
* {@inheritdoc}
*/
protected function doSaveMultiple(array $keysAndValues, $lifetime = 0)
{
$result = apc_store($keysAndValues, null, $lifetime);
return empty($result);
}
/**
* {@inheritdoc}
*/
protected function doGetStats()
{
$info = apc_cache_info('', true);
$sma = apc_sma_info();
// @TODO - Temporary fix @see https://github.com/krakjoe/apcu/pull/42
if (PHP_VERSION_ID >= 50500) {
$info['num_hits'] = $info['num_hits'] ?? $info['nhits'];
$info['num_misses'] = $info['num_misses'] ?? $info['nmisses'];
$info['start_time'] = $info['start_time'] ?? $info['stime'];
}
return [
Cache::STATS_HITS => $info['num_hits'],
Cache::STATS_MISSES => $info['num_misses'],
Cache::STATS_UPTIME => $info['start_time'],
Cache::STATS_MEMORY_USAGE => $info['mem_size'],
Cache::STATS_MEMORY_AVAILABLE => $sma['avail_mem'],
];
}
}

View File

@@ -0,0 +1,106 @@
<?php
namespace Doctrine\Common\Cache;
use function apcu_cache_info;
use function apcu_clear_cache;
use function apcu_delete;
use function apcu_exists;
use function apcu_fetch;
use function apcu_sma_info;
use function apcu_store;
use function count;
/**
* APCu cache provider.
*
* @link www.doctrine-project.org
*/
class ApcuCache extends CacheProvider
{
/**
* {@inheritdoc}
*/
protected function doFetch($id)
{
return apcu_fetch($id);
}
/**
* {@inheritdoc}
*/
protected function doContains($id)
{
return apcu_exists($id);
}
/**
* {@inheritdoc}
*/
protected function doSave($id, $data, $lifeTime = 0)
{
return apcu_store($id, $data, $lifeTime);
}
/**
* {@inheritdoc}
*/
protected function doDelete($id)
{
// apcu_delete returns false if the id does not exist
return apcu_delete($id) || ! apcu_exists($id);
}
/**
* {@inheritdoc}
*/
protected function doDeleteMultiple(array $keys)
{
$result = apcu_delete($keys);
return $result !== false && count($result) !== count($keys);
}
/**
* {@inheritdoc}
*/
protected function doFlush()
{
return apcu_clear_cache();
}
/**
* {@inheritdoc}
*/
protected function doFetchMultiple(array $keys)
{
return apcu_fetch($keys) ?: [];
}
/**
* {@inheritdoc}
*/
protected function doSaveMultiple(array $keysAndValues, $lifetime = 0)
{
$result = apcu_store($keysAndValues, null, $lifetime);
return empty($result);
}
/**
* {@inheritdoc}
*/
protected function doGetStats()
{
$info = apcu_cache_info(true);
$sma = apcu_sma_info();
return [
Cache::STATS_HITS => $info['num_hits'],
Cache::STATS_MISSES => $info['num_misses'],
Cache::STATS_UPTIME => $info['start_time'],
Cache::STATS_MEMORY_USAGE => $info['mem_size'],
Cache::STATS_MEMORY_AVAILABLE => $sma['avail_mem'],
];
}
}

Some files were not shown because too many files have changed in this diff Show More