コード例 #1
0
ファイル: Db.php プロジェクト: vgrish/dvelum
 /**
  * Save database connection config
  */
 public function saveAction()
 {
     $name = Request::post('name', 'string', false);
     $pass = Request::post('pass', 'string', false);
     $host = Request::post('host', 'string', false);
     $user = Request::post('user', 'string', false);
     $base = Request::post('base', 'string', false);
     $id = Request::post('id', 'integer', false);
     $setpass = Request::post('setpass', 'boolean', false);
     $config = array('user' => $user, 'pass' => $pass, 'base' => $base, 'host' => $host, 'name' => $name);
     if ($id !== false && $id >= 0) {
         if (!$this->_connConfig->offsetExists($id)) {
             Response::jsonError($this->_lang->WRONG_REQUEST);
         }
         if (!$setpass) {
             $oldCfg = $this->_connConfig->get($id);
             $config['pass'] = $oldCfg['pass'];
         }
     } else {
         $id = $this->_connConfig->getCount();
         while ($this->_connConfig->offsetExists($id)) {
             $id++;
         }
     }
     $this->_connConfig->set($id, $config);
     if ($this->_connConfig->save()) {
         Response::jsonSuccess();
     } else {
         Response::jsonError($this->_lang->CANT_WRITE_FS);
     }
 }
コード例 #2
0
ファイル: Controller.php プロジェクト: vgrish/dvelum
 /**
  * Rebuild all packages
  */
 public function rebuildallAction()
 {
     $this->_checkCanEdit();
     $dest = $this->_packagesConfig->get('path');
     /*
      * Returning a reference from a function
      */
     $data =& $this->_packagesConfig->dataLink();
     if ($this->_packagesConfig->get('all_in_one')) {
         $s = '';
         foreach ($data['packages'] as $item) {
             if (!$item['active']) {
                 continue;
             }
             $s .= $this->_compilePackage($item);
         }
         Utils::exportCode($dest . $this->_packagesConfig->get('main_package') . '.php', $s);
     } else {
         foreach ($data['packages'] as $name => $item) {
             $s = $this->_compilePackage($item);
             $data['packages'][$name]['checksum'] = md5($s);
             if (Utils::exportCode($dest . $name . '.php', $s) === false) {
                 Response::jsonError($this->_lang->CANT_WRITE_FS);
             }
             $data['packages'][$name]['fchecksum'] = md5_file($dest . $name . '.php');
         }
     }
     if ($this->buildmapAction() === false) {
         Response::jsonError($this->_lang->CANT_WRITE_FS);
     }
     if (!$this->_packagesConfig->save()) {
         Response::jsonError($this->_lang->CANT_WRITE_FS);
     } else {
         Response::jsonSuccess();
     }
 }