Example #1
0
 public function out()
 {
     $id = intval($_POST['id']);
     $info = model('plugin')->info_data($id);
     if (!empty($info['file'])) {
         $data = @Plugin::run($info['file'], 'plugin_ini_data', '', true);
     }
     $data_array = array();
     if (!empty($data)) {
         //执行数据库操作
         foreach ($data as $value) {
             $data_array[] = $this->config['DB_PREFIX'] . $value;
         }
         //创建文件夹
         $dir = __ROOTDIR__ . '/plugins/' . $info['file'];
         @mkdir($dir . '/dbbak/', 0777, true);
         if (!file_exists($dir . '/dbbak/')) {
             $this->msg('文件夹创建失败,请保证本插件目录有写入权限', 0);
         }
         //导出数据库
         $db = new Dbbak($this->config['DB_HOST'], $this->config['DB_USER'], $this->config['DB_PWD'], $this->config['DB_NAME'], 'utf8', $dir . '/dbbak/');
         if (!$db->exportSql($data_array, 0, $sql)) {
             $this->msg('数据库导出失败!', 0);
         }
     }
     $old_config = model('plugin')->info($info['file']);
     //写入插件信息
     $html = '<?xml version="1.0" encoding="utf-8"?>' . PHP_EOL;
     $html .= '<config>' . PHP_EOL;
     $html .= '<name>' . $info['name'] . '</name>' . PHP_EOL;
     $html .= '<file>' . $info['file'] . '</file>' . PHP_EOL;
     $html .= '<ver>' . $info['ver'] . '</ver>' . PHP_EOL;
     $html .= '<author>' . $info['author'] . '</author>' . PHP_EOL;
     $html .= '<info>' . $old_config['info'] . '</info>' . PHP_EOL;
     $html .= '<prefix>' . $this->config['DB_PREFIX'] . '</prefix>' . PHP_EOL;
     $html .= '</config>' . PHP_EOL;
     @file_put_contents($dir . '/config.xml', $html);
     @Plugin::run($info['file'], 'out', $info);
     $this->msg('插件导出完毕,请自行到plugin目录下载插件文件', 1);
 }
Example #2
0
 public function out()
 {
     $id = intval($_POST['id']);
     $info = model('form')->info($id);
     //创建文件夹
     $dir = __ROOTDIR__ . '/data/form/' . $info['table'];
     @mkdir($dir, 0777, true);
     if (!file_exists($dir)) {
         $this->msg('文件夹创建失败,请保证"/data/form/"有写入权限', 0);
     }
     @mkdir($dir . '/dbbak/', 0777, true);
     if (!file_exists($dir . '/dbbak/')) {
         $this->msg('文件夹创建失败,请保证"/data/form/dbbak/"有写入权限', 0);
     }
     $data_array = model('form')->field_list_data($id);
     if (empty($data_array)) {
         $this->msg('无法获取多用表单字段', 0);
     }
     //导出数据库
     $db = new Dbbak($this->config['DB_HOST'], $this->config['DB_USER'], $this->config['DB_PWD'], $this->config['DB_NAME'], 'utf8', $dir . '/dbbak/');
     $sql = "INSERT INTO " . $this->config['DB_PREFIX'] . "form VALUES(null, '" . mysql_escape_string($info['name']) . "', '" . mysql_escape_string($info['table']) . "','" . mysql_escape_string($info['display']) . "','" . mysql_escape_string($info['page']) . "','" . mysql_escape_string($info['tpl']) . "','" . mysql_escape_string($info['alone_tpl']) . "','" . mysql_escape_string($info['order']) . "','" . mysql_escape_string($info['where']) . ",'" . mysql_escape_string($info['return_type']) . ",'" . mysql_escape_string($info['return_msg']) . "')\n";
     foreach ($data_array as $vo) {
         $sql .= "INSERT INTO " . $this->config['DB_PREFIX'] . "form_field VALUES(null, 101010, '" . mysql_escape_string($vo['name']) . "', '" . mysql_escape_string($vo['field']) . "', '" . mysql_escape_string($vo['type']) . "', '" . mysql_escape_string($vo['property']) . "', '" . mysql_escape_string($vo['len']) . "', '" . mysql_escape_string($vo['decimal']) . "', '" . mysql_escape_string($vo['default']) . "', '" . mysql_escape_string($vo['sequence']) . "', '" . mysql_escape_string($vo['tip']) . "', '" . mysql_escape_string($vo['config']) . "', '" . mysql_escape_string($vo['must']) . "', '" . mysql_escape_string($vo['admin_display']) . "', '" . mysql_escape_string($vo['admin_html']) . "')\n";
     }
     if (!$db->exportSql($this->config['DB_PREFIX'] . 'form_data_' . $info['table'], 0, $sql)) {
         $this->msg('数据库导出失败!', 0);
     }
     //写入表单信息
     $html = '<?xml version="1.0" encoding="utf-8"?>' . PHP_EOL;
     $html .= '<config>' . PHP_EOL;
     $html .= '<name>' . $info['name'] . '</name>' . PHP_EOL;
     $html .= '<table>' . $info['table'] . '</table>' . PHP_EOL;
     $html .= '<prefix>' . $this->config['DB_PREFIX'] . '</prefix>' . PHP_EOL;
     $html .= '</config>' . PHP_EOL;
     @file_put_contents($dir . '/form.xml', $html);
     if (!file_exists($dir . '/form.xml')) {
         $this->msg('表单信息导出失败,请检查目录权限!', 0);
     }
     $this->msg('扩展模型导出完毕,请自行到"data/form"中下载文件', 1);
 }
Example #3
0
 public function out()
 {
     $mid = intval($_POST['mid']);
     $info = model('model_manage')->info($mid);
     if (!empty($info['admin_category'])) {
         $data = @model($info['admin_category'])->model_ini_data();
         $file_array = @model($info['admin_category'])->model_ini_file();
     }
     if (empty($data) || empty($file_array)) {
         $this->msg('读取配置信息失败!可能该模型受保护无法导出!', 0);
     }
     $data_array = array();
     foreach ($data as $value) {
         $data_array[] = $this->config['DB_PREFIX'] . $value;
     }
     //创建文件夹
     $dir = __ROOTDIR__ . '/data/module/' . $info['model'];
     @mkdir($dir, 0777, true);
     if (!file_exists($dir)) {
         $this->msg('文件夹创建失败,请保证"/data/module/"有写入权限', 0);
     }
     @mkdir($dir . '/dbbak/', 0777, true);
     if (!file_exists($dir . '/dbbak/')) {
         $this->msg('文件夹创建失败,请保证"/data/module/dbbak/"有写入权限', 0);
     }
     //导出数据库
     $db = new Dbbak($this->config['DB_HOST'], $this->config['DB_USER'], $this->config['DB_PWD'], $this->config['DB_NAME'], 'utf8', $dir . '/dbbak/');
     $sql = "INSERT INTO " . $this->config['DB_PREFIX'] . "model VALUES(null, '" . mysql_escape_string($info['model']) . "', '" . mysql_escape_string($info['name']) . "', '" . mysql_escape_string($info['admin_category']) . "', '" . mysql_escape_string($info['admin_content']) . "', '" . mysql_escape_string($info['module_category']) . "', '" . mysql_escape_string($info['module_content']) . "', '" . mysql_escape_string($info['url_category']) . "', '" . mysql_escape_string($info['url_category_page']) . "', '" . mysql_escape_string($info['url_content']) . "', '" . mysql_escape_string($info['url_content_page']) . "', '" . mysql_escape_string($info['table']) . "', '" . mysql_escape_string($info['file']) . "', '" . mysql_escape_string($info['config']) . "', '" . mysql_escape_string($info['befrom']) . "')\n";
     if (!$db->exportSql($data_array, 0, $sql)) {
         $this->msg('数据库导出失败!', 0);
     }
     foreach ($file_array as $value) {
         $file = __ROOTDIR__ . '/' . $value;
         $copyfile = $dir . '/file/';
         if (file_exists($file)) {
             if (is_dir($file)) {
                 @mkdir($copyfile . $value, 0777, true);
                 if (!copy_dir($file, $copyfile . $value)) {
                     $this->msg('文件导出失败,可能由于导出目录没有写入权限!', 0);
                 }
             } else {
                 @mkdir(dirname($copyfile . $value), 0777, true);
                 if (!@copy($file, $copyfile . $value)) {
                     $this->msg('文件导出失败,可能由于导出目录没有写入权限!', 0);
                 }
             }
         }
     }
     //写入模型信息
     $html = '<?xml version="1.0" encoding="utf-8"?>' . PHP_EOL;
     $html .= '<config>' . PHP_EOL;
     $html .= '<name>' . $info['name'] . '</name>' . PHP_EOL;
     $html .= '<model>' . $info['model'] . '</model>' . PHP_EOL;
     $html .= '<prefix>' . $this->config['DB_PREFIX'] . '</prefix>' . PHP_EOL;
     $html .= '</config>' . PHP_EOL;
     @file_put_contents($dir . '/model.xml', $html);
     if (!file_exists($dir . '/model.xml')) {
         $this->msg('模型信息导出失败,请检查目录权限!', 0);
     }
     if (method_exists($info['model'], 'model_ini_out')) {
         model($info['model'])->model_ini_out();
     }
     $this->msg('模型导出完毕,请自行到"data/module"中下载文件', 1);
 }