public function indexAction()
 {
     $connection = Tools::getConnection();
     $this->_prepareVersions();
     $tables = array('all' => 'All');
     $result = $connection->query("SHOW TABLES");
     $result->setFetchMode(Phalcon\DB::FETCH_NUM);
     while ($table = $result->fetchArray($result)) {
         $tables[$table[0]] = $table[0];
     }
     $this->view->setVar('tables', $tables);
 }
 public function indexAction()
 {
     $config = Tools::getConfig();
     $connection = Tools::getConnection();
     $tables = array();
     $result = $connection->query("SHOW TABLES");
     $result->setFetchMode(Phalcon\Db::FETCH_NUM);
     while ($table = $result->fetchArray($result)) {
         $tables[$table[0]] = $table[0];
     }
     $this->view->setVar('tables', $tables);
     $this->view->setVar('databaseName', $config->database->name);
 }
 public function runAction()
 {
     if ($this->request->isPost()) {
         $force = $this->request->getPost('force', 'int');
         try {
             Migrations::run(array('config' => Tools::getConfig(), 'directory' => null, 'tableName' => 'all', 'migrationsDir' => $this->migrationsDir, 'force' => $force));
             $this->flash->success('The migration was executed successfully.');
         } catch (BuilderException $e) {
             $this->flash->error($e->getMessage());
         }
     }
     $this->_prepareVersions();
 }
Exemplo n.º 4
0
 public function run($parameters)
 {
     $action = $this->getOption(array('action', 1));
     $directory = $this->getOption(array('directory'));
     if (!$directory) {
         $directory = __DIR__ . '/../../../../';
     }
     if ($action == 'enable') {
         \Phalcon\Web\Tools::install($directory);
     } else {
         if ($action == 'disable') {
             \Phalcon\Web\Tools::install($directory);
         } else {
             throw new Exception("Invalid action");
         }
     }
     //
 }
 public function saveAction()
 {
     if ($this->request->isPost()) {
         $fileName = $this->request->getPost('name', 'string');
         $fileName = str_replace('..', '', $fileName);
         $controllersDir = Tools::getConfig()->application->controllersDir;
         if (!file_exists($controllersDir . '/' . $fileName)) {
             $this->flash->error('Controller could not be found');
             return $this->dispatcher->forward(array('controller' => 'controllers', 'action' => 'list'));
         }
         if (!is_writable($controllersDir . '/' . $fileName)) {
             $this->flash->error('Controller file does not has write access');
             return $this->dispatcher->forward(array('controller' => 'controllers', 'action' => 'list'));
         }
         file_put_contents($controllersDir . '/' . $fileName, $this->request->getPost('code'));
         $this->flash->success('The controller "' . $fileName . '" was saved successfully');
     }
     return $this->dispatcher->forward(array('controller' => 'controllers', 'action' => 'list'));
 }
Exemplo n.º 6
0
 protected function _listTables($all = false)
 {
     $config = Tools::getConfig();
     $connection = Tools::getConnection();
     if ($all) {
         $tables = array('all' => 'All');
     } else {
         $tables = array();
     }
     $dbTables = $connection->listTables();
     foreach ($dbTables as $dbTable) {
         $tables[$dbTable] = $dbTable;
     }
     $this->view->tables = $tables;
     if ($config->database->adapter != 'Sqlite') {
         $this->view->databaseName = $config->database->dbname;
     } else {
         $this->view->databaseName = null;
     }
 }
Exemplo n.º 7
0
 /**
  * {@inheritdoc}
  *
  * @param array $parameters
  * @return mixed
  * @throws CommandsException
  */
 public function run(array $parameters)
 {
     $action = $this->getOption(array('action', 1));
     $directory = './';
     if ($action == 'enable') {
         if (file_exists($directory . 'public/webtools.php')) {
             throw new CommandsException('Webtools are already enabled!');
         }
         Tools::install($directory);
         echo Color::success('Webtools successfully enabled!');
     } elseif ($action == 'disable') {
         if (!file_exists($directory . 'public/webtools.php')) {
             throw new CommandsException('Webtools are already disabled!');
         }
         Tools::uninstall($directory);
         echo Color::success('Webtools successfully disabled!');
     } else {
         throw new CommandsException('Invalid action!');
     }
 }
Exemplo n.º 8
0
 public function run($parameters)
 {
     $action = $this->getOption(array('action', 1));
     $directory = $this->getOption(array('directory'));
     if (!$directory) {
         $directory = __DIR__ . '/../../../../';
     }
     if ($action == 'enable') {
         Tools::install($directory);
     } else {
         if ($action == 'disable') {
             Tools::install($directory);
         } else {
             throw new \Exception("Invalid action");
         }
     }
     if ($action == 'enable') {
         print Color::success('Webtools successfully enabled') . PHP_EOL;
     } else {
         if ($action == 'disable') {
             print Color::success('Webtools successfully disabled') . PHP_EOL;
         }
     }
 }
Exemplo n.º 9
0
 /**
  * Build project
  *
  * @return bool
  */
 public function build()
 {
     $this->buildDirectories()->getVariableValues()->createConfig()->createBootstrapFile()->createHtaccessFiles()->createControllerBase()->createModule()->createIndexViewFiles()->createControllerFile()->createHtrouterFile();
     $this->options->contains('enableWebTools') && Tools::install($this->options->get('projectPath'));
     return true;
 }
Exemplo n.º 10
0
<?php

/*
  +------------------------------------------------------------------------+
  | Phalcon Developer Tools                                                |
  +------------------------------------------------------------------------+
  | Copyright (c) 2011-2016 Phalcon Team (http://www.phalconphp.com)       |
  +------------------------------------------------------------------------+
  | This source file is subject to the New BSD License that is bundled     |
  | with this package in the file docs/LICENSE.txt.                        |
  |                                                                        |
  | If you did not receive a copy of the license and are unable to         |
  | obtain it through the world-wide-web, please send an email             |
  | to license@phalconphp.com so we can send you a copy immediately.       |
  +------------------------------------------------------------------------+
  | Authors: Andres Gutierrez <*****@*****.**>                      |
  |          Eduar Carvajal <*****@*****.**>                         |
  +------------------------------------------------------------------------+
*/
use Phalcon\Web\Tools;
require 'webtools.config.php';
require PTOOLSPATH . '/scripts/Phalcon/Web/Tools.php';
Tools::main(PTOOLSPATH, PTOOLS_IP);
Exemplo n.º 11
0
 /**
  * Initialize system dirs
  *
  * @return $this
  */
 protected function initDirs()
 {
     $config = Tools::getConfig()->offsetGet('application');
     $dirs = array('modelsDir', 'controllersDir', 'migrationsDir');
     $this->path->setRootPath(dirname(getcwd()));
     $projectPath = $this->path->getRootPAth();
     foreach ($dirs as $dirName) {
         if (isset($config[$dirName]) && $config[$dirName]) {
             if ($this->isAbsolutePath($config[$dirName])) {
                 $path = $config[$dirName];
             } else {
                 $path = $projectPath . $config[$dirName];
             }
             $path = rtrim($path, '\\/') . DIRECTORY_SEPARATOR;
             if (file_exists($path)) {
                 $this->{$dirName} = $path;
             }
         }
     }
     return $this;
 }
Exemplo n.º 12
0
 public function build($name, $path, $templatePath, $options)
 {
     $this->buildDirectories($this->_dirs, $path);
     if (isset($options['useConfigIni'])) {
         $useIniConfig = $options['useConfigIni'];
     } else {
         $useIniConfig = false;
     }
     if ($useIniConfig) {
         $this->createConfig($path, $templatePath, $name, 'ini');
     } else {
         $this->createConfig($path, $templatePath, $name, 'php');
     }
     $this->createBootstrapFile($name, $path, $templatePath, $useIniConfig);
     $this->createHtaccessFiles($path, $templatePath);
     $this->createControllerBase($path, $templatePath, $name);
     $this->createModule($path, $templatePath, $name);
     $this->createIndexViewFiles($path, $templatePath);
     $this->createControllerFile($path, $name);
     if ($options['enableWebTools']) {
         \Phalcon\Web\Tools::install($path);
     }
     return true;
 }
Exemplo n.º 13
0
 public function indexAction()
 {
     $this->view->setVar('posibleConfig', $this->_posibleConfig);
     $this->view->setVar('settings', Tools::getConfig());
 }
Exemplo n.º 14
0
 /**
  * Check if IP address for securing Phalcon Developers Tools area matches
  * the given
  *
  * @param  string $ip
  * @return bool
  */
 private function checkToolsIp($ip)
 {
     return strpos($ip, Tools::getToolsIp()) === 0;
 }