Beispiel #1
0
 /**
  * Adds the component to the platform
  *
  * Called when this component receives an HTTP POST request to
  * /platform.
  */
 public function addPlatform($callName, $input, $params = array())
 {
     Logger::Log('starts POST AddPlatform', LogLevel::DEBUG);
     $file = dirname(__FILE__) . '/config.ini';
     $text = "[DIR]\n" . "temp = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), str_replace("\\", "/", $input->getTempDirectory())) . "\"\n" . "files = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), str_replace("\\", "/", $input->getFilesDirectory())) . "\"\n";
     if (!@file_put_contents($file, $text)) {
         Logger::Log('POST AddPlatform failed, config.ini no access', LogLevel::ERROR);
         return Model::isProblem();
     }
     $platform = new Platform();
     $platform->setStatus(201);
     return Model::isCreated($platform);
 }
Beispiel #2
0
 /**
  * Adds the component to the platform
  *
  * Called when this component receives an HTTP POST request to
  * /platform.
  */
 public function addPlatform()
 {
     Logger::Log('starts POST AddPlatform', LogLevel::DEBUG);
     // decode the received course data, as an object
     $insert = Platform::decodePlatform($this->_app->request->getBody());
     // always been an array
     $arr = true;
     if (!is_array($insert)) {
         $insert = array($insert);
         $arr = false;
     }
     // this array contains the indices of the inserted objects
     $res = array();
     foreach ($insert as $in) {
         $file = dirname(__FILE__) . '/config.ini';
         $text = "[DB]\n" . "db_path = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), $in->getDatabaseUrl()) . "\"\n" . "db_user = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), $in->getDatabaseOperatorUser()) . "\"\n" . "db_passwd = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), $in->getDatabaseOperatorPassword()) . "\"\n" . "db_name = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), $in->getDatabaseName()) . "\"\n" . "[PL]\n" . "urlExtern = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), $in->getExternalUrl()) . "\"\n" . "url = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), $in->getBaseUrl()) . "\"";
         if (!@file_put_contents($file, $text)) {
             Logger::Log('POST AddPlatform failed, config.ini no access', LogLevel::ERROR);
             $this->_app->response->setStatus(409);
             $this->_app->stop();
         }
         // starts a query
         ob_start();
         eval("?>" . file_get_contents(dirname(__FILE__) . '/Sql/AddPlatform.sql'));
         $sql = ob_get_contents();
         ob_end_clean();
         $result = DBRequest::request2($sql, false, parse_ini_file(dirname(__FILE__) . '/config.ini', TRUE));
         // checks the correctness of the query
         if (!isset($result['errno']) || !$result['errno']) {
             $platform = new Platform();
             $platform->setStatus(201);
             $res[] = $platform;
             $this->_app->response->setStatus(201);
         } else {
             Logger::Log('POST AddPlatform failed', LogLevel::ERROR);
             $this->_app->response->setStatus(409);
             $this->_app->response->setBody(Platform::encodePlatform($res));
             $this->_app->stop();
         }
     }
     if (!$arr && count($res) == 1) {
         $this->_app->response->setBody(Platform::encodePlatform($res[0]));
     } else {
         $this->_app->response->setBody(Platform::encodePlatform($res));
     }
 }
Beispiel #3
0
 /**
  * Adds the component to the platform
  *
  * Called when this component receives an HTTP POST request to
  * /platform.
  */
 public function addPlatform($callName, $input, $params = array())
 {
     Logger::Log('starts POST AddPlatform', LogLevel::DEBUG);
     //$this->loadConfig($name);
     // decode the received course data, as an object
     $insert = $input;
     $result = Model::isOK();
     // always been an array
     $arr = true;
     if (!is_array($insert)) {
         $insert = array($insert);
         $arr = false;
     }
     // this array contains the indices of the inserted objects
     $res = array();
     foreach ($insert as $in) {
         $file = dirname(__FILE__) . '/config.ini';
         $text = "[DB]\n" . "db_path = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), $in->getDatabaseUrl()) . "\"\n" . "db_user = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), $in->getDatabaseOperatorUser()) . "\"\n" . "db_passwd = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), $in->getDatabaseOperatorPassword()) . "\"\n" . "db_name = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), $in->getDatabaseName()) . "\"\n" . "[PL]\n" . "urlExtern = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), $in->getExternalUrl()) . "\"\n" . "url = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), $in->getBaseUrl()) . "\"";
         if (!@file_put_contents($file, $text)) {
             Logger::Log('POST AddPlatform failed, config.ini no access', LogLevel::ERROR);
             $result = Model::isProblem();
         }
         $platform = new Platform();
         $platform->setStatus(201);
         $res[] = $platform;
         $result = Model::isCreated();
     }
     $return['content'] = $res;
     return $return;
 }
Beispiel #4
0
 /**
  * Adds the component to the platform
  *
  * Called when this component receives an HTTP POST request to
  * /platform.
  */
 public function addPlatform()
 {
     Logger::Log('starts POST AddPlatform', LogLevel::DEBUG);
     // decode the received course data, as an object
     $insert = Platform::decodePlatform($this->app->request->getBody());
     // always been an array
     $arr = true;
     if (!is_array($insert)) {
         $insert = array($insert);
         $arr = false;
     }
     // this array contains the indices of the inserted objects
     $res = array();
     foreach ($insert as $in) {
         $file = dirname(__FILE__) . '/config.ini';
         $text = "[DIR]\n" . "temp = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), str_replace("\\", "/", $in->getTempDirectory())) . "\"\n" . "files = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), str_replace("\\", "/", $in->getFilesDirectory())) . "\"\n";
         if (!@file_put_contents($file, $text)) {
             Logger::Log('POST AddPlatform failed, config.ini no access', LogLevel::ERROR);
             $this->app->response->setStatus(409);
             $this->app->stop();
         }
         $platform = new Platform();
         $platform->setStatus(201);
         $res[] = $platform;
         $this->app->response->setStatus(201);
     }
     if (!$arr && count($res) == 1) {
         $this->app->response->setBody(Platform::encodePlatform($res[0]));
     } else {
         $this->app->response->setBody(Platform::encodePlatform($res));
     }
 }