示例#1
0
 public function ExtUpload()
 {
     $files = knl_lib_Registry::getFiles();
     $ext_field = $files->getFile('ext_field');
     if ($ext_field['error'] == 0) {
         //$ext_field['name'];
         //$ext_field['size'];
         //$ext_field['tmp_name'];
         $str_to_path = "";
         $zip_file = zip_open($ext_field['tmp_name']);
         while ($zip_read = zip_read($zip_file)) {
             //echo zip_entry_name($zip_read);echo "<br>";
             if (zip_entry_name($zip_read) == "config.xml") {
                 $buf = zip_entry_read($zip_read, zip_entry_filesize($zip_read));
                 $xml_cfg = new DOMDocument();
                 $xml_cfg->loadXML($buf);
                 $conf = $this->xml_read_cfg($xml_cfg);
                 $conf_full[] = $conf;
                 $str_to_path = $conf['extension'];
                 knl_dao_ext_new::getInstance()->createExtension($conf);
             }
             if (zip_entry_name($zip_read) == "config_aux.xml") {
                 $buf = zip_entry_read($zip_read, zip_entry_filesize($zip_read));
                 $xml_cfg = new DOMDocument();
                 $xml_cfg->loadXML($buf);
                 $conf = $this->xml_read_cfg($xml_cfg);
                 $conf_full[] = $conf;
                 knl_dao_ext_new::getInstance()->createExtension($conf);
             }
         }
         if (!empty($str_to_path)) {
             $zip_file = zip_open($ext_field['tmp_name']);
             $this->unzip_extension($zip_file, $str_to_path);
         }
     }
     echo "Fim da instalação<br>\n<pre>";
     print_r($conf_full);
 }