<?php

/*
  PHP version 5
  Copyright (c) 2002-2018 ECISP.CN、EarcLink.COM
  警告：这不是一个免费的软件，请在许可范围内使用，请尊重知识产权，侵权必究，举报有奖
  作者：黄祥云 E-mail:6326420@qq.com  QQ:6326420 TEL:18665655030
  ESPCMS官网介绍：http://www.ecisp.cn	企业建站：http://www.earclink.cn

 */

namespace modul_application;

class ESPCMS_InstallDB {


    public static function get_write_file() {
        $func_items[] = array('name' => './');
        $func_items[] = array('name' => './espcms_admin/');
        $func_items[] = array('name' => './espcms_datacache/');
        $func_items[] = array('name' => './espcms_includes/');
        $func_items[] = array('name' => './espcms_install/');
        $func_items[] = array('name' => './espcms_interface/');
        $func_items[] = array('name' => './espcms_public/');
        $func_items[] = array('name' => './espcms_web/');
        $func_items[] = array('name' => './html/');
        $func_items[] = array('name' => './upload/');
        $func_items[] = array('name' => './upfile/');
        return $func_items;
    }


    public static function connect_service($ac_name = array(), $post = array(), $isjson = true) {
        global $espcms_db_version;
        if (!$ac_name || !preg_match("/^[\w]+$/i", $ac_name)) {
            return false;
        }

        $post['siteurl'] = espcms_host('AP');
        $post['vol'] = $espcms_db_version;
        $send_add = espcms_decrypt(ESPCMS_QUERST_ADD_LONG, ESPCMS_ADD_ENCODE);
        $response = espcms_curl_post($send_add . $ac_name, espcms_array_to_xml($post));
        if (!$response) {
            return false;
        }
        if ($isjson) {
            $response_josn = json_decode($response, true);
            if (is_array($response_josn)) {
                return $response_josn;
            } else {
                return false;
            }
        } elseif (!$isjson && $response) {
            return $response;
        } else {
            return false;
        }
    }

}
