Exemplo n.º 1
0
    protected function _api($u = null)
    {
        $u = null === $u ? \webdof\wURI::getInstance() : $u;
        ini_set('display_errors', 0);
        $this->login();
        /*
         * ToDo:  set output formatter (defaults to jsonp)
         */
        $this->ob_compress();
        header("Content-Type: application/x-javascript; charset=UTF-8;");
        ob_start(function ($c) {
            $r = isset($this->data['data_out']) ? $this->data['data_out'] : new \stdclass();
            $r->type = isset($r->type) ? $r->type : 'print';
            $r->out = isset($r->out) ? $r->out : $c;
            $fnregex = "/^[A-Za-z0-9\$\\.-_\\({1}\\){1}]+\$/";
            $callback = isset($_REQUEST['callback']) && preg_match($fnregex, $_REQUEST['callback']) ? strip_tags($_REQUEST['callback']) : '';
            if ($callback === '') {
                $o = json_encode($r);
            } else {
                $r->callback = $callback;
                $o = $callback . '(' . json_encode($r) . ')';
            }
            return $o;
        });
        /* BEGIN extract phar (todo build/refactor API) */
        if (isset($_GET['EXTRA_EXTRACT_PHAR'])) {
            if (file_exists($this->data['CONFIGFILE']) && $this->data['config_new']['PACKAGE'] !== $this->data['config']['PACKAGE']) {
                \webdof\wResponse::status(409);
                $str = 'Error: Invalid installer package name';
                if (true === $this->debug) {
                    trigger_error($str, E_USER_ERROR);
                }
                die($str);
            }
            if (1 !== intval($this->data['INSTALLER_PHAR_AVAILABLE']) || intval(str_replace(array('"', "'"), array('', ''), $this->data['INSTALLER'])) !== 1 || !isset($this->data['PHAR_INCLUDE']) || !class_exists('\\Extract')) {
                \webdof\wResponse::status(400);
                $str = 'Error: Not in installer context';
                if (true === $this->debug) {
                    trigger_error($str, E_USER_ERROR);
                }
                die($str);
            }
            if (true !== $this->isLoggedIn()) {
                \webdof\wResponse::status(401);
                die('Invalid credentials, try to install via <a href="{___$$URL_INSTALLER_HTMLPAGE$$___}">{___$$URL_INSTALLER_HTMLPAGE$$___}</a>!');
            }
            try {
                $userInfo = posix_getpwuid(fileowner(__FILE__));
                $this->data['config']['DIR_PACKAGE'] = $userInfo['dir'] . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR;
                chmod($this->data['config']['DIR_PACKAGE'], 0755);
                if (!is_dir($this->data['config']['DIR_PACKAGE']) || !is_writable($this->data['config']['DIR_PACKAGE'])) {
                    $this->data['config']['DIR_PACKAGE'] = $userInfo['dir'] . DIRECTORY_SEPARATOR;
                    chmod($this->data['config']['DIR_PACKAGE'], 0755);
                }
                if (!is_dir($this->data['config']['DIR_PACKAGE']) || !is_writable($this->data['config']['DIR_PACKAGE'])) {
                    $this->data['config']['DIR_PACKAGE'] = $this->data['DIR'];
                }
            } catch (\Exception $e) {
                $str = 'Warning: Cannot get home dir';
                if (true === $this->debug) {
                    trigger_error($str, E_USER_WARNING);
                }
                $this->data['config']['DIR_PACKAGE'] = $this->data['DIR'];
            }
            if (isset($_REQUEST['DIR_PACKAGE']) && is_dir($_REQUEST['DIR_PACKAGE'])) {
                chmod($_REQUEST['DIR_PACKAGE'], 0755);
                $this->data['config']['DIR_PACKAGE'] = $_REQUEST['DIR_PACKAGE'];
            }
            if (!is_dir($this->data['config']['DIR_PACKAGE']) || !is_writable($this->data['config']['DIR_PACKAGE'])) {
                $this->data['config']['DIR_PACKAGE'] = $this->data['DIR'];
            }
            if (isset($_REQUEST['DIR_WWW']) && is_dir($_REQUEST['DIR_WWW'])) {
                chmod($_REQUEST['DIR_WWW'], 0755);
                $this->data['config']['DIRS']['www'] = $_REQUEST['DIR_WWW'];
            }
            if (!is_dir($this->data['config']['DIRS']['www']) || !is_writable($this->data['config']['DIRS']['www'])) {
                $this->data['config']['DIRS']['www'] = $this->data['DIR'] . 'www' . DIRECTORY_SEPARATOR;
            }
            $this->data['CONFIGFILE'] = $this->data['config']['DIR_PACKAGE'] . 'config.frdl.php';
            if (isset($_REQUEST['test']) && 'response' === $_REQUEST['test']) {
                \webdof\wResponse::status(200);
                $this->data['data_out']->code = 200;
                $this->data['data_out']->extra = true;
                $this->data['data_out']->out = 'OK';
                $this->data['data_out']->changed = json_encode($this->data['config']) !== json_encode($this->data['config_new']);
                $this->data['data_out']->config = new \stdclass();
                $this->data['data_out']->config_new = new \stdclass();
                $this->data['data_out']->config->PACKAGE = $this->data['config']['PACKAGE'];
                $this->data['data_out']->config_new->PACKAGE = $this->data['config_new']['PACKAGE'];
                $this->data['data_out']->config->VERSION = $this->data['config']['VERSION'];
                $this->data['data_out']->config_new->VERSION = $this->data['config_new']['VERSION'];
                $this->data['data_out']->config->INSTALLED = $this->data['config']['INSTALLED'];
                $this->data['data_out']->config_new->INSTALLED = $this->data['config_new']['INSTALLED'];
                $this->data['data_out']->config->REGISTERED = $this->data['config']['REGISTERED'];
                $this->data['data_out']->config_new->REGISTERED = $this->data['config_new']['REGISTERED'];
                $this->data['data_out']->config->UNAME = $this->data['config']['UNAME'];
                $this->data['data_out']->config_new->UNAME = $this->data['config_new']['UNAME'];
                $this->data['data_out']->config->UID = $this->data['config']['UID'];
                $this->data['data_out']->config_new->UID = $this->data['config_new']['UID'];
                $this->data['data_out']->config->DIR_PACKAGE = $this->data['config']['DIR_PACKAGE'];
                $this->data['data_out']->config_new->DIR_PACKAGE = $this->data['config_new']['DIR_PACKAGE'];
                $wwwdir = is_dir($this->data['config']['DIRS']['www']) ? $this->data['config']['DIRS']['www'] : $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR;
                $this->data['data_out']->config->DIR_WWW = $wwwdir;
                $this->data['data_out']->config_new->DIR_WWW = $wwwdir;
                die('OK');
            }
            $EXTRA =& $this->data['config']['EXTRA'];
            mkdir($this->data['config']['DIR_PACKAGE'], 0755, true);
            try {
                \Extract::from($this->data['PHAR_INCLUDE'])->to($this->data['config']['DIR_PACKAGE'], function (\Entry $entry) use(&$EXTRA) {
                    if (false == strpos(basename($entry->getName()), '.') && (true == \webdof\valFormats::is(basename($entry->getName()), 'md5', true) || true == \webdof\valFormats::is(basename($entry->getName()), 'sha1', true))) {
                        return;
                    }
                    if ('config.frdl.php' == basename($entry->getName()) || 'config.php' == basename($entry->getName())) {
                        return;
                    }
                    //  if(true == $EXTRA['extra']['pragmamx']['main'] ){
                    if ('.htaccess' === basename($entry->getName())) {
                        return;
                    }
                    if ('index.php' === basename($entry->getName())) {
                        return;
                    }
                    //   }
                });
            } catch (\Exception $e) {
                //\webdof\wResponse::status(409);
                //$str = $this->data['PHAR_INCLUDE'] .' -> '.$this->data['DIR'].' ('.__LINE__.') - ' .$e->getMessage();
                //if(true === $this->debug)trigger_error($str, E_USER_ERROR);
                //die($str);
            }
            if (file_exists($this->data['config']['DIR_PACKAGE'] . 'composer.json')) {
                /*
                			 	   		 $.WebfanDesktop.Registry.Programs[\'frdl-webfan\'].config.loc.api_url="'.$this->data['config']['URL_API_ORIGINAL'].'";
                */
                $this->data['data_out']->js = trim(preg_replace("/\\s+|\n/", " ", 'try{
			 			$(\'#window_\' + \'frdl-webfan\').find(\'#wd-li-frdl-webfan-installPHAR\').find(\'u\').html(\'Update\');
			 			$.WebfanDesktop.Registry.Programs[\'frdl-webfan\'].formConfig();
			 		
			 			}catch(err){console.error(err);}			 			
			 			'));
                if ('' === $this->data['config_new']['ADMIN_PWD']) {
                    $this->data['config_new']['ADMIN_PWD'] = $this->data['config']['ADMIN_PWD'];
                }
                if ($this->data['config_new']['ADMIN_PWD'] !== $this->data['config']['ADMIN_PWD']) {
                    $this->data['data_out']->js .= ' 
					     		alert("Attention: Password has changed (' . trim($_POST['pwd'], '"\' ') . ')!");
							 ';
                }
                if ('' === $this->data['config_new']['PIN']) {
                    $this->data['config_new']['PIN'] = $this->data['config']['PIN'];
                }
                if ($this->data['config_new']['PIN'] !== $this->data['config']['PIN']) {
                    $this->data['data_out']->js .= ' 
					     		alert("Attention: PIN has changed (' . $this->aSess['PIN'] . ')!");
							 ';
                }
                $this->data['config']['VERSION'] = $this->data['config_new']['VERSION'];
                $this->data['config']['DOWNLOADUPDATETIME'] = $this->data['config_new']['DOWNLOADTIME'];
                $this->data['config']['UPDATETIME'] = time();
                $this->data['config']['ADMIN_PWD'] = $this->aSess['ADMIN_PWD'];
                $this->data['config']['PIN'] = $this->aSess['PIN'];
                if (0 === intval($this->data['config']['UID']) && 0 !== intval($this->data['config_new']['UID'])) {
                    $this->data['config']['UID'] = $this->data['config_new']['UID'];
                }
                if ('' === $this->data['config']['UNAME'] && '' !== $this->data['config_new']['UNAME']) {
                    $this->data['config']['UNAME'] = $this->data['config_new']['UNAME'];
                }
                $this->data['config']['DIRS'] = array_merge(isset($this->data['config']['DIRS']) && is_array($this->data['config']['DIRS']) ? $this->data['config']['DIRS'] : array(), array('psr-0' => null, 'psr-4' => $this->data['config']['DIR_PACKAGE'] . '.ApplicationComposer' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR, 'apps' => $this->data['config']['DIR_PACKAGE'] . '.ApplicationComposer' . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR, 'components' => $this->data['config']['DIR_PACKAGE'] . '.ApplicationComposer' . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR, 'batch' => $this->data['config']['DIR_PACKAGE'] . '.ApplicationComposer' . DIRECTORY_SEPARATOR . 'batch' . DIRECTORY_SEPARATOR, 'cache' => $this->data['config']['DIR_PACKAGE'] . '.ApplicationComposer' . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR, 'config' => $this->data['config']['DIR_PACKAGE'] . '.ApplicationComposer' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR, 'data.norm' => $this->data['config']['DIR_PACKAGE'] . '.ApplicationComposer' . DIRECTORY_SEPARATOR . 'data.norm' . DIRECTORY_SEPARATOR, 'data.storage' => $this->data['config']['DIR_PACKAGE'] . '.ApplicationComposer' . DIRECTORY_SEPARATOR . 'data.storage' . DIRECTORY_SEPARATOR, 'packages' => $this->data['config']['DIR_PACKAGE'] . '.ApplicationComposer' . DIRECTORY_SEPARATOR . 'packages' . DIRECTORY_SEPARATOR, 'repositories' => $this->data['config']['DIR_PACKAGE'] . '.ApplicationComposer' . DIRECTORY_SEPARATOR . 'repositories' . DIRECTORY_SEPARATOR, 'servers' => $this->data['config']['DIR_PACKAGE'] . '.ApplicationComposer' . DIRECTORY_SEPARATOR . 'servers' . DIRECTORY_SEPARATOR, 'share' => $this->data['config']['DIR_PACKAGE'] . '.ApplicationComposer' . DIRECTORY_SEPARATOR . 'share' . DIRECTORY_SEPARATOR, 'tmp' => $this->data['config']['DIR_PACKAGE'] . '.ApplicationComposer' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR, 'vendor' => $this->data['config']['DIR_PACKAGE'] . '.ApplicationComposer' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR, 'www' => is_dir($this->data['config']['DIRS']['www']) && is_writable($this->data['config']['DIRS']['www']) ? $this->data['config']['DIRS']['www'] : $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR, 'files' => isset($_REQUEST['EXTRA_DIR']) && is_dir($_REQUEST['EXTRA_DIR']) ? $_REQUEST['EXTRA_DIR'] : (is_dir($this->homedir() . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR) ? $this->homedir() . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR : $this->data['config']['DIR_PACKAGE'] . '.ApplicationComposer' . DIRECTORY_SEPARATOR . '.files' . DIRECTORY_SEPARATOR)));
                $files = array();
                $this->data['config']['FILES'] = array_merge(isset($this->data['config']['FILES']) && is_array($this->data['config']['FILES']) ? $this->data['config']['FILES'] : array(), array('composer' => $this->data['config']['DIR_PACKAGE'] . 'composer.json', 'config' => $this->data['CONFIGFILE'], 'database-schema' => $this->data['config']['DIRS']['config'] . 'database-schema.dat', 'boot.batch' => $this->data['config']['DIRS']['batch'] . '.boot.bat'));
                $config = $this->data['config'];
                if (true === $EXTRA['extra']['pragmamx']['main']) {
                    $config['URL'] .= 'setup.php';
                }
                if (!isset($this->data['config']['autoupdate'])) {
                    $this->data['config']['autoupdate'] = true;
                }
                $php = "<?php\n\t\t\t \t\t\t/*\n\t\t\t \t\t\t  - Do not edit this file manually! \n\t\t\t \t\t\t  Application Composer - Config\n\t\t\t \t\t\t  Download: {___\${$URL_INSTALLER_HTMLPAGE}\${$___}}\n\t\t\t \t\t\t  \n\t\t\t \t\t\t*/\n\t\t\t \t\t\t    if(isset(\$this) &&\n\t\t\t \t\t\t     (  get_class(\$this) === '\\" . get_class($this) . "' \n\t\t\t \t\t\t     || is_subclass_of(\$this, '\\frdl\\ApplicationComposer\\Command\\CMD')  \n\t\t\t \t\t\t     || get_class(\$this) === '" . get_class($this) . "' \n\t\t\t \t\t\t     || is_subclass_of(\$this, 'frdl\\ApplicationComposer\\Command\\CMD')  \n\t\t\t \t\t\t     || is_subclass_of(\$this, 'frdl\\xGlobal\fexe')  \n\t\t\t \t\t\t     )\n\t\t\t \t\t\t     ){\n\t\t\t \t\t\t     \t \$this->data['config'] = " . var_export($config, true) . ";\t\t\n\t\t\t \t\t\t     \t\n                         \t    ";
                $php .= "\n\n\n/*\n* If you have PragmaMx installed, its db-config will be used instead!\n*/\n\$pmxconfigfile=__DIR__.DIRECTORY_SEPARATOR. 'config.php';\nif(true === \$this->data['config']['EXTRA']['extra']['pragmamx']['main'] && file_exists( \$pmxconfigfile)  ){\n\ttry{\n\t  ob_start();\n\t\t@include \$pmxconfigfile;\n\t\tif(isset(\$dbtype))\$this->data['config']['db-driver']=strtolower(\$dbtype);\n\t\tif(isset(\$dbhost))\$this->data['config']['db-host']=\$dbhost;\n\t\tif(isset(\$dbuname))\$this->data['config']['db-user']=\$dbuname;\n\t\tif(isset(\$dbpass))\$this->data['config']['db-pwd']=\$dbpass;\n\t\tif(isset(\$dbname))\$this->data['config']['db-dbname']=\$dbname;\n\t\tif(isset(\$prefix))\$this->data['config']['db-pfx']=\$prefix;\n\t  ob_end_clean();\t\t\t\n\t}catch(\\Exception \$e){\n\t\t\n\t}\n\n}\n\nif(!isset(\$this->data['config']['db-driver']))\$this->data['config']['db-driver']='';\nif(!isset(\$this->data['config']['db-host']))\$this->data['config']['db-host']='';\nif(!isset(\$this->data['config']['db-user']))\$this->data['config']['db-user']='';\nif(!isset(\$this->data['config']['db-pwd']))\$this->data['config']['db-pwd']='';\nif(!isset(\$this->data['config']['db-dbname']))\$this->data['config']['db-dbname']='';\nif(!isset(\$this->data['config']['db-pfx']))\$this->data['config']['db-pfx']='';\n\n\n";
                $php .= "}";
                file_put_contents($this->data['CONFIGFILE'], $php);
                /*
                if(dirname(realpath($this->data['DIR']))!==dirname(realpath($this->data['config']['DIR_PACKAGE']))){
                	$this->copy_dir($this->data['DIR'], $this->data['config']['DIR_PACKAGE'], true);
                	rmdir($this->data['DIR'].'.ApplicationComposer'.DIRECTORY_SEPARATOR);
                	
                }
                */
                $msg = '';
                $EXTRA_DIR = '' !== $_REQUEST['DIR_WWW'] && is_dir($_REQUEST['DIR_WWW']) ? rtrim($_REQUEST['DIR_WWW'], '/ ') : $this->data['config']['DIRS']['www'];
                mkdir($EXTRA_DIR, 0755, true);
                if ('yes' === $_REQUEST['INSTALL_UPDATE_PMX']) {
                    $tok = 'http://download.pragmamx.org/pmx/';
                    if ($tok === substr($_REQUEST['INSTALL_UPDATE_PMX_URL'], 0, strlen($tok))) {
                        $zipcontents = file_get_contents($_REQUEST['INSTALL_UPDATE_PMX_URL']);
                        if (false === $zipcontents) {
                            $msg .= 'Download of PragmaMx failed!';
                        } else {
                            $zipfilename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . '~tmp.pragmamxdownload.zip';
                            file_put_contents($zipfilename, $zipcontents);
                            $Zip = new \frdl\webfan\Compress\zip\wUnzip($zipfilename, $EXTRA_DIR);
                            $r = $Zip->unzip();
                            $msg .= 'PragmaMx extracted.';
                            unlink($zipfilename);
                            $zipcontents = file_get_contents('https://github.com/frdlweb/flow4pmx/archive/master.zip');
                            if (false === $zipcontents) {
                                $msg .= 'Download of flow4pmx failed!';
                            } else {
                                $zipfilename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . '~tmp.flow4pmx.zip';
                                file_put_contents($zipfilename, $zipcontents);
                                $Zip = new \frdl\webfan\Compress\zip\wUnzip($zipfilename, $EXTRA_DIR);
                                $r = $Zip->unzip();
                                $this->copy_dir($EXTRA_DIR . 'flow4pmx-master' . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR . ltrim($EXTRA_DIR, '/ '), true);
                                rmdir($EXTRA_DIR . 'flow4pmx-master' . DIRECTORY_SEPARATOR);
                                $msg .= 'flow4pmx extracted.';
                                unlink($zipfilename);
                            }
                        }
                    }
                }
                /* eo install/update pmx */
                if ('yes' === $_REQUEST['INSTALL_UPDATE_WP']) {
                    $tok = 'https://wordpress.org/';
                    if ($tok === substr($_REQUEST['INSTALL_UPDATE_WP_URL'], 0, strlen($tok))) {
                        $zipcontents = file_get_contents($_REQUEST['INSTALL_UPDATE_WP_URL']);
                        if (false === $zipcontents) {
                            $msg .= 'Download of Wordpress failed!';
                        } else {
                            $zipfilename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . '~tmp.wordpressdownload.zip';
                            file_put_contents($zipfilename, $zipcontents);
                            $Zip = new \frdl\webfan\Compress\zip\wUnzip($zipfilename, $this->data['DIR']);
                            $r = $Zip->unzip();
                            /* rename(ltrim($this->data['DIR'], '/ ').'wordpress',trim($this->data['DIR'], '/ ')); */
                            $this->copy_dir($EXTRA_DIR . 'wordpress' . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR . ltrim($EXTRA_DIR, '/ '), true);
                            rmdir($this->data['DIR'] . 'wordpress' . DIRECTORY_SEPARATOR);
                            $msg .= 'Wordpress extracted.';
                            unlink($zipfilename);
                        }
                    }
                }
                try {
                    $flowfile = $this->data['DIR'] . 'js' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'flow.js';
                    file_put_contents($flowfile, file_get_contents('http://api.webfan.de/api-d/4/js-api/library.js?skipcache=' . mt_rand(100000, 999999999999999)));
                    chmod($flowfile, 0755);
                } catch (\Exception $e) {
                    //	\webdof\wResponse::status(409);
                    //		$str = $this->data['PHAR_INCLUDE'] .' -> '.$this->data['DIR'].' - ('.__LINE__.') ' .$e->getMessage();
                    //		if(true === $this->debug)trigger_error($str, E_USER_ERROR);
                    //	die($str);
                }
                unset($Zip, $r, $tok, $zipcontents, $zipfilename);
                $DIR_PACKAGE = rtrim(realpath($this->data['config']['DIR_PACKAGE']), '/ ') . DIRECTORY_SEPARATOR;
                $VERSION = $this->data['config']['VERSION'];
                $SERVERCODE = <<<PHP
<?php
/**
*  Generated by frdl/webfan
*  This file should NOT be edited manually!
*  
*  @role:      server
*  @app:       frdl/webfan
*  @version:   {$VERSION}
*  @project:   @root  
*  @dir:       {$DIR_PACKAGE}
*
*/
namespace frdlweb\\webfan\\server;
\$dir = '{$DIR_PACKAGE}';
chdir(\$dir);
require \$dir.'.ApplicationComposer'. DIRECTORY_SEPARATOR .  'bootstrap.php';
require \$dir.'.ApplicationComposer'. DIRECTORY_SEPARATOR .  'apps' . DIRECTORY_SEPARATOR . 'webfan.fexe.php';


PHP;
                foreach (array(DIRECTORY_SEPARATOR . ltrim($this->data['DIR'], '/ ') . '~index.php', DIRECTORY_SEPARATOR . ltrim($this->data['DIR'], '/ ') . 'api.php', DIRECTORY_SEPARATOR . ltrim($this->data['DIR'], '/ ') . 'app.php', DIRECTORY_SEPARATOR . ltrim($this->data['DIR'], '/ ') . 'setup.php') as $serverFile) {
                    file_put_contents($serverFile, $SERVERCODE);
                }
                if (!file_exists(DIRECTORY_SEPARATOR . ltrim($this->data['DIR'], '/ ') . 'index.php')) {
                    copy('~index.php', DIRECTORY_SEPARATOR . ltrim($this->data['DIR'], '/ ') . 'index.php');
                }
                if (isset($_REQUEST['u'])) {
                    unlink($this->data['PHAR_INCLUDE']);
                    $this->data['data_out']->js .= ' $.WebfanDesktop.Registry.Programs[\'frdl-webfan\'].config.EXTRA_INSTALLER = null;	';
                }
                $config['URL'] = str_replace('setup.phpsetup.php', 'setup.php', $config['URL']);
                $this->data['data_out']->js .= '
			                	$(\'#window_main_postbox-ttt-all\').wdPostbox(\'deleteMessage\', \'install-frdl-webfan-installer-' . $this->data['config_new']['VERSION'] . '\',  \'update\', false);	 	   	
					 	   	
					 	   	
					 	   	alert(\'' . $msg . '\\nPlease set up the configuration next...\');
			 		    	window.location = "' . $config['URL'] . '";
			 		    	';
                $this->writeToConfigFile();
                \webdof\wResponse::status(201);
                die('Extracted');
            } else {
                $str = 'Error extracting php archive (' . __LINE__ . ') ';
                \webdof\wResponse::status(409);
                if (true === $this->debug) {
                    trigger_error($str, E_USER_ERROR);
                }
                die($str);
            }
        } elseif (isset($_REQUEST[self::CMD])) {
            return $this->_api_request_cmd($_REQUEST[self::CMD]);
        }
        \webdof\wResponse::status(404);
        die('Unexpected end of api.request');
    }
Exemplo n.º 2
0
 protected function _extract($zipFileUrl, $toDir)
 {
     $success = false;
     $zipcontents = file_get_contents($zipFileUrl);
     if (false === $zipcontents) {
         $success = false;
         return $success;
     }
     $zipfilename = getTempFilename($zipFileUrl);
     file_put_contents($zipfilename, $zipcontents);
     if (!is_dir($toDir)) {
         mkdir($toDir, 0755, true);
     }
     if (!is_dir($toDir)) {
         $success = false;
         return $success;
     }
     try {
         $Zip = new \frdl\webfan\Compress\zip\wUnzip($zipfilename, $toDir);
         $r = $Zip->unzip();
         unlink($zipfilename);
     } catch (\Exception $e) {
         $success = false;
         return $success;
     }
     $success = 0 === count($r['errors']) ? true : false;
     return $success;
 }