@ -0,0 +1,112 @@ | |||
<?php | |||
defined('IN_MET') or exit('No permission'); | |||
load::sys_class('admin'); | |||
load::sys_func('file'); | |||
//接口初始化 | |||
class application extends admin { | |||
private $clangs = ''; //返回的文字 | |||
private $url; //返回URL | |||
private $appfile; //应用文件 | |||
public function __construct() { | |||
global $_M; | |||
parent::__construct(); | |||
} | |||
//ajaxURL | |||
private function ajaxurl() { | |||
global $_M; | |||
return $_M['url']['own_form']; | |||
} | |||
//公共查询方法 | |||
private function sqlone($tname,$where = '') { | |||
global $_M; | |||
$table = $_M['table'][$tname]; | |||
if($where){ | |||
$where = 'where '.$where; | |||
} | |||
return DB::get_one("select * from {$table} {$where}"); | |||
} | |||
//安装应用初始化 | |||
public function doindex(){ | |||
global $_M; | |||
$ajaxurl = $this->ajaxurl(); | |||
if($_M['form']['url']){ | |||
$url = ' | |||
<dl><dt>安装提示</dt><dd style="color: #23b7e5;"> | |||
'.base64_decode($_M['form']['url']).' | |||
</dd></dl>'; | |||
} | |||
$appfile = $_M['form']['appfile']; | |||
require $this->template('own/application'); | |||
} | |||
//进行执行安装 | |||
public function doaddapp(){ | |||
global $_M; | |||
$this->appfile = $_M['form']['appfile']; | |||
$where = "m_name='{$this->appfile}'"; | |||
$applist = $this->sqlone('applist',$where); | |||
if($applist){ | |||
$this->clangs = get_word($applist['appname']).' 应用已存在,请勿重复安装。'; | |||
$this->turnover(); | |||
} | |||
$file = path_relative("app/app/{$this->appfile}/admin/install.class.php"); | |||
require_once($file); | |||
if(get_parent_class('install')){ | |||
$url = $_M[url][site_admin].'index.php?lang='.$_M[langset].'&n='.$this->appfile.'&c=install&a=dosql'; | |||
$url = '<a href="'.$url.'" target="_blank">【点击URL安装新应用】'.$url.'</a>'; | |||
$this->url = urlencode(base64_encode($url)); | |||
$this->clangs = '点击URL安装新应用'; | |||
}else{ | |||
$install = new install(); | |||
$this->clangs = @$install->dosql(); | |||
if($this->clangs){ | |||
if($this->clangs == 'complete'){ | |||
$this->clangs = '安装完成'; | |||
} | |||
}else{ | |||
$this->clangs = '安装完成'; | |||
} | |||
$this->url = base64_encode($this->clangs); | |||
} | |||
$this->turnover(); | |||
} | |||
//返回方法 | |||
private function turnover() { | |||
global $_M; | |||
turnover($_M['url']['own_form'] . 'a=doindex&url='.$this->url.'&appfile='.$this->appfile, $this->clangs); | |||
} | |||
//应用安装文件名检测,查看是否存在 | |||
public function doappfile(){ | |||
global $_M; | |||
$file = '../app/app/'.$_M['form']['appfile']; | |||
if(is_dir($file)){ | |||
$file = $file.'/admin/install.class.php'; | |||
if(file_exists($file)){ | |||
$where = "m_name='{$_M['form']['appfile']}'"; | |||
$applist = $this->sqlone('applist',$where); | |||
if($applist){ | |||
echo '0|'.get_word($applist['appname']).' 应用已存在,请勿重复安装。'; | |||
}else{ | |||
echo '1|'.$_M['form']['appfile'].'可以正常安装。'; | |||
} | |||
}else{ | |||
echo '0|../app/app/'.$_M['form']['appfile'].'/ 下不存在install.class.php文件'; | |||
} | |||
}else{ | |||
echo '0|../app/app/ 下不存在文件夹 '.$_M['form']['appfile']; | |||
} | |||
} | |||
} | |||
?> |
@ -0,0 +1,70 @@ | |||
<?php | |||
defined('IN_MET') or exit ('No permission'); | |||
load::sys_class('admin'); | |||
load::sys_class('nav.class.php'); | |||
load::sys_func('file'); | |||
//需要手动安装,或者发给客户自己手动安装时请将标记① ②的注释去掉 | |||
class install extends admin //① | |||
{ | |||
private $no; //应用NO值 | |||
private $m_name = 'apptool'; //应用文件 | |||
private $ver = '1.0'; //应用文件 | |||
public function __construct() {//② | |||
global $_M; | |||
parent::__construct(); | |||
} | |||
//安装应用 | |||
public function dosql() { | |||
global $_M; | |||
$where = "m_name='{$this->m_name}'"; | |||
if($this->sqlone('applist',$where) != false){ | |||
echo '请勿重复安装'; | |||
return '请勿重复安装'; | |||
exit; | |||
} | |||
do{ | |||
$this->no = mt_rand(2001,9999); | |||
$stall = $this->sqlone('applist'); | |||
} while ($stall != false); | |||
//开始执行程序[需要的东西可以在下面执行了] | |||
$this->appsql(); | |||
echo '安装成功'; | |||
return '安装成功'; | |||
} | |||
//执行APP相关的表数据插入 | |||
private function appsql() { | |||
global $_M; | |||
//注册应用 | |||
$updatetime = time(); | |||
$field = "no='{$this->no}',ver='{$this->ver}',m_name='{$this->m_name}',m_class='application',m_action='doindex',appname='应用安装助手',info='应用开发必备工具!能够快速安装应用,不必每次都要拼写安装URL进行安装。',addtime='{$updatetime}'"; | |||
$this->addsql('applist',$field); | |||
} | |||
//公共查询方法 | |||
private function sqlone($tname,$where = '') { | |||
global $_M; | |||
$table = $_M['table'][$tname]; | |||
if(!$where){ | |||
$where = "no='{$this->no}'"; | |||
} | |||
return DB::get_one("select * from {$table} where {$where}"); | |||
} | |||
//公共写入方法 | |||
private function addsql($tname,$field) { | |||
global $_M; | |||
$table = $_M['table'][$tname]; | |||
DB::query("INSERT INTO {$table} SET {$field}"); | |||
} | |||
} | |||
?> |
@ -0,0 +1,50 @@ | |||
<!--<?php | |||
defined('IN_MET') or exit('No permission'); | |||
require $this->template('ui/head'); | |||
echo <<<EOT | |||
--> | |||
<form method="POST" class="ui-from" name="myform" action="{$_M['url']['own_form']}a=doaddapp" target="_self"> | |||
<div class="v52fmbx"> | |||
<h3 class="v52fmbx_hr">注意事项:</h3> | |||
<dl> | |||
<dd class="ftype_description"> | |||
1、应用文件需要放在网站 根目录/APP/APP下 【注意】两个APP;<BR /> | |||
2、根据应用安装文件的不同,会出现不同的安装页面,均属于正常;<BR /> | |||
3、安装执行后,若应用未安装成功,请检测安装文件是否有错误;<BR /> | |||
4、只可以安装自行开发的应用,官方应用市场下载的应用无法二次安装。 | |||
</dd> | |||
</dl> | |||
<dl> | |||
<dt>应用文件夹</dt> | |||
<dd class="ftype_input"> | |||
<div class="fbox"> | |||
<input type="text" name="appfile" value="{$appfile}" data-ajaxcheck-url="{$ajaxurl}&a=doappfile"> | |||
</div> | |||
<span class="tips">请保证应用文件位置正确,和安装文件代码无错误。</span> | |||
</dd> | |||
</dl> | |||
{$url} | |||
<dl class="noborder"> | |||
<dt> </dt> | |||
<dd> | |||
<input type="submit" name="submit" value="安装" class="submit"> | |||
</dd> | |||
</dl> | |||
<dl> | |||
<dd class="ftype_description ftype_a" style="background:none;"> | |||
<a href="http://api.metinfo.wang" target="_blank">MetTooL 功能介绍</a> | |||
<i style="font-style:normal; padding:0px 8px; color:#eee;">|</i> | |||
<a href="http://api.metinfo.wang" target="_blank">MetTooL 更新说明</a> | |||
<i style="font-style:normal; padding:0px 8px; color:#eee;">|</i> | |||
<span style="color: #aaa; font-style: italic;">反馈QQ群:1452532</span> | |||
<i style="font-style:normal; padding:0px 8px; color:#eee;">|</i> | |||
<a target="_blank" href="http://shang.qq.com/wpa/qunwpa?idkey=e6bcac0a76480ffd47e41ff0fb82473659f40bde92c8116d3b7214b5343f388c"><img border="0" src="http://pub.idqqimg.com/wpa/images/group.png" alt="Metinfo( 米拓 )应用交流" title="Metinfo( 米拓 )应用交流"></a> | |||
</dd> | |||
</dl> | |||
</div> | |||
</form> | |||
<!-- | |||
EOT; | |||
require $this->template('ui/foot'); | |||
?> |
@ -0,0 +1,5 @@ | |||
define(function (require, exports, module) { | |||
var common = require('common'); //加载公共函数文件(语言文字获取等) | |||
var langtxt = common.langtxt(); //获取语言文字 | |||
}); |
@ -0,0 +1,89 @@ | |||
<?php | |||
defined('IN_MET') or exit ('No permission'); | |||
load::sys_class('admin'); | |||
load::sys_class('nav.class.php'); | |||
load::sys_func('file'); | |||
class uninstall extends admin { | |||
private $no; //应用NO值 | |||
private $m_name; //应用文件夹 | |||
public function __construct() { | |||
global $_M; | |||
parent::__construct(); | |||
$this->no = $_M['form']['no']; | |||
} | |||
public function dodel() { | |||
global $_M; | |||
//准备一些提前删除的内容 | |||
$file = $this->sqlone('applist'); | |||
$this->m_name = $file['m_name']; | |||
//删除固定的app表 | |||
$this->appsql(); | |||
//删除应用文件 | |||
$this->delfile(); | |||
} | |||
//删除固定的app表 | |||
private function appsql() { | |||
global $_M; | |||
//删除栏目接口表 | |||
$this->delsql('ifcolumn'); | |||
//删除应用生成文件所调用事件的信息表 | |||
$this->delsql('ifcolumn_addfile'); | |||
//删除会员侧导航信息表 | |||
$this->delsql('ifmember_left'); | |||
//删除应用插件表 | |||
$this->delsql('app_plugin'); | |||
//删除网站后台栏目信息表 | |||
$where = "field='{$this->no}'"; | |||
$this->delsql('admin_column',$where); | |||
//删除网站栏目信息表 | |||
$where = "module='{$this->no}'"; | |||
$this->delsql('column',$where); | |||
//删除语言表 | |||
$where = "app='{$this->no}'"; | |||
$this->delsql('language',$where); | |||
//删除应用注册表 | |||
$this->delsql('applist'); | |||
} | |||
//删除应用文件夹 | |||
private function delfile() { | |||
if($this->m_name){ | |||
deldir('../app/app/'.$this->m_name); | |||
} | |||
} | |||
//公共查询方法 | |||
private function sqlone($tname,$where = '') { | |||
global $_M; | |||
$table = $_M['table'][$tname]; | |||
if(!$where){ | |||
$where = "no='{$this->no}'"; | |||
} | |||
return DB::get_one("select * from {$table} where {$where}"); | |||
} | |||
//公共删除数据 | |||
private function delsql($tname,$where = '') { | |||
global $_M; | |||
$table = $_M['table'][$tname]; | |||
if(!$where){ | |||
$where = "no='{$this->no}'"; | |||
} | |||
DB::query("DELETE FROM {$table} WHERE {$where}"); | |||
} | |||
} | |||
?> |