예제 #1
0
 private function validateDBConnection()
 {
     try {
         ob_start();
         $dbName = LudoDBRegistry::get('DB_NAME');
         LudoDB::setDb("information_schema");
         LudoDB::getInstance()->connect();
         LudoDB::setDb($dbName);
         LudoDB::createDatabase($dbName);
         LudoDB::getInstance()->connect();
         ob_end_clean();
     } catch (Exception $e) {
         throw new LudoDBException("Cannot connect to database, error message: " . $e->getMessage(), 400);
     }
 }
예제 #2
0
 /**
  * Start profiling.
  * @param array $data
  * @return array
  * @throws LudoDBException
  */
 public function profile($data = array())
 {
     $inDevelop = LudoDBRegistry::get('DEVELOP_MODE');
     if (!isset($inDevelop) || !$inDevelop) {
         throw new LudoDBException("Profiling can only be executed in develop mode. Use LudoDBRegistry::set('DEVELOP_MODE', true) to activate develop mode");
     }
     $request = implode("/", $this->arguments);
     $name = preg_replace("/[^0-9a-z]/si", "", $request);
     $this->start($name);
     $handler = new LudoDBRequestHandler();
     $result = json_decode($handler->handle(array('request' => $request, 'data' => $data)), true);
     if (!$result['success']) {
         throw new LudoDBException($result['message']);
     }
     $url = $this->end();
     return array("result" => $url, "request" => $request, "data" => $data);
 }
예제 #3
0
 private function sanitize($filePath)
 {
     $extension = $this->getExtension($filePath);
     if ($extension != 'pgn') {
         return null;
     }
     if (class_exists("LudoDBRegistry")) {
         $tempPath = LudoDBRegistry::get('FILE_UPLOAD_PATH');
     } else {
         $tempPath = null;
     }
     if (isset($tempPath) && substr($filePath, 0, strlen($tempPath)) == $tempPath) {
     } else {
         if (substr($filePath, 0, 1) === "/") {
             return null;
         }
     }
     $filePath = preg_replace("/[^0-9\\.a-z_\\-\\/]/si", "", $filePath);
     if (!file_exists($filePath)) {
         return null;
     }
     return $filePath;
 }
예제 #4
0
 /**
  * Return name of database for database connection.
  * @return String
  */
 public static function getDb()
 {
     return LudoDBRegistry::get('DB_NAME');
 }
예제 #5
0
 private function getTempPath($filename)
 {
     $extension = $this->getExtension($filename);
     return LudoDBRegistry::get(self::FILE_UPLOAD_KEY) . "/uploaded" . date("YmdHis") . '-' . rand(10000, 99999) . "." . $extension;
 }
예제 #6
0
 /**
  * Return instance name for Oracle connectoin
  * @return String
  */
 public function getInstanceName()
 {
     return LudoDBRegistry::get('DB_INSTANCE');
 }