Example #1
0
 public function zfAction()
 {
     if (!extension_loaded('zip')) {
         return $this->sendError('You need to install the ZIP extension of PHP');
     }
     $console = $this->getServiceLocator()->get('console');
     $tmpDir = sys_get_temp_dir();
     $request = $this->getRequest();
     $version = $request->getParam('version');
     $path = rtrim($request->getParam('path'), '/');
     if (file_exists($path)) {
         return $this->sendError("The directory {$path} already exists. You cannot install the ZF2 library here.");
     }
     if (empty($version)) {
         $version = Zf::getLastVersion();
         if (false === $version) {
             return $this->sendError("I cannot connect to the Zend Framework website.");
         }
     } else {
         if (!Zf::checkVersion($version)) {
             return $this->sendError("The specified ZF version, {$version}, doesn't exist.");
         }
     }
     $tmpFile = ZF::getTmpFileName($tmpDir, $version);
     if (!file_exists($tmpFile)) {
         if (!Zf::downloadZip($tmpFile, $version)) {
             return $this->sendError("I cannot download the ZF2 library from github.");
         }
     }
     $zip = new \ZipArchive();
     if ($zip->open($tmpFile)) {
         $zipFolders = $zip->statIndex(0);
         $zipFolder = $tmpDir . '/' . rtrim($zipFolders['name'], "/");
         if (!$zip->extractTo($tmpDir)) {
             return $this->sendError("Error during the unzip of {$tmpFile}.");
         }
         $result = Utility::copyFiles($zipFolder, $path);
         if (file_exists($zipFolder)) {
             Utility::deleteFolder($zipFolder);
         }
         $zip->close();
         if (false === $result) {
             return $this->sendError("Error during the copy of the files in {$path}.");
         }
     }
     $console->writeLine("The ZF library {$version} has been installed in {$path}.", Color::GREEN);
 }
Example #2
0
 public function setParam($wert, $typ)
 {
     if ($this->paramAnzahlAktuell + 1 > $this->paramAnzahlGesamt) {
         die($this->_getError(2));
     }
     switch ($typ) {
         case 'str':
             $this->param[] = ZF::sqlString($wert, $this->connection);
             break;
         case 'int':
             $this->param[] = ZF::sqlInteger($wert);
             break;
         case 'double':
             $this->param[] = ZF::sqlDouble($wert);
             break;
         default:
             die($this->_getError(3));
     }
     $this->paramAnzahlAktuell++;
 }
Example #3
0
        }
        if (isset($this->_storageDirectory) && $this->_storageDirectory) {
            $configOptions['storageOptions']['directory'] = $this->_storageDirectory;
        }
        // ensure that zf.php loads the Zend_Tool_Project features
        $configOptions['classesToLoad'] = 'Zend\\Tool\\Project\\Provider\\Manifest';
        $autoloader = new Zend\Loader\StandardAutoloader();
        $autoloader->setFallbackAutoloader(true);
        $autoloader->register();
        $console = new Zend\Tool\Framework\Client\Console\Console($configOptions);
        $console->dispatch();
        return null;
    }
    /**
     * _logMessage() - Internal method used to log setup and information messages.
     *
     * @param string  $message
     * @param boolean $storeMessage
     * @return void
     */
    protected function _logMessage($message, $storeMessage = true)
    {
        if (!$storeMessage) {
            return;
        }
        $this->_messages[] = $message;
    }
}
if (!getenv('ZF_NO_MAIN')) {
    ZF::main();
}
Example #4
0
 /**
  * @return mixed
  */
 public function zfAction()
 {
     // check for help mode
     if ($this->requestOptions->getFlagHelp()) {
         return $this->zfHelp();
     }
     // output header
     $this->consoleHeader('Installing Zend Framework 2 library');
     // check for zip extension
     if (!extension_loaded('zip')) {
         return $this->sendError(array(array(Color::NORMAL => 'You need to install the ZIP extension of PHP.')));
     }
     // get needed options to shorten code
     $path = $this->requestOptions->getPath();
     $tmpDir = $this->requestOptions->getTmpDir();
     $version = $this->requestOptions->getVersion();
     // check if path provided
     if ($path == '.') {
         return $this->sendError(array(array(Color::NORMAL => 'Please provide the path to install the ZF2 library in.')));
     }
     // check if path exists
     if (file_exists($path)) {
         return $this->sendError(array(array(Color::NORMAL => 'The directory '), array(Color::RED => $path), array(Color::NORMAL => ' already exists. '), array(Color::NORMAL => 'You cannot install the ZF2 library here.')));
     }
     // check version
     if (empty($version)) {
         $version = Zf::getLastVersion();
         if (false === $version) {
             return $this->sendError(array(array(Color::NORMAL => 'I cannot connect to the Zend Framework website.')));
         }
     } else {
         if (!Zf::checkVersion($version)) {
             return $this->sendError(array(array(Color::NORMAL => 'The specified ZF version, '), array(Color::RED => $version), array(Color::NORMAL => ' does not exist.')));
         }
     }
     // get tmp file and check it
     $tmpFile = ZF::getTmpFileName($tmpDir, $version);
     if (!file_exists($tmpFile)) {
         if (!Zf::downloadZip($tmpFile, $version)) {
             return $this->sendError(array(array(Color::NORMAL => 'I cannot download the ZF2 library from GitHub.')));
         }
     }
     // unzip archive
     $zip = new \ZipArchive();
     if ($zip->open($tmpFile)) {
         $zipFolders = $zip->statIndex(0);
         $zipFolder = $tmpDir . '/' . rtrim($zipFolders['name'], "/");
         if (!$zip->extractTo($tmpDir)) {
             return $this->sendError(array(array(Color::NORMAL => 'Error during the unzip of '), array(Color::RED => $tmpFile)));
         }
         $result = Utility::copyFiles($zipFolder, $path);
         if (file_exists($zipFolder)) {
             Utility::deleteFolder($zipFolder);
         }
         $zip->close();
         if (false === $result) {
             return $this->sendError(array(array(Color::NORMAL => 'Error during the copy of the files in '), array(Color::RED => $path)));
         }
     }
     $this->console->write(' Done ', Color::NORMAL, Color::CYAN);
     $this->console->write(' ');
     $this->console->write('The ZF library ');
     $this->console->write($version, Color::GREEN);
     $this->console->write(' has been installed in ');
     $this->console->writeLine(realpath($path), Color::GREEN);
     // output footer
     $this->consoleFooter('library was successfully installed');
 }
Example #5
0
 /**
  * is there a result left in the resultset
  * @return boolean
  */
 public function nextResult()
 {
     if ($this->currentRow =& mysqli_fetch_assoc($this->currentResult)) {
         foreach ($this->currentRow as $key => $value) {
             $this->currentRow[$key] = ZF::mysqlUnescapeString($value);
         }
         return true;
     } else {
         return false;
     }
 }