Example #1
0
 /**
  * Tworzy instancję Rejestru
  *
  * @param MK_Registry $registry
  *
  * @throws MK_Exception
  */
 public static function setInstance(MK_Registry $registry)
 {
     if (self::$registry !== null) {
         throw new MK_Exception('Rejestr już jest utworzony');
     }
     self::$registry = $registry;
 }
Example #2
0
File: PDO.php Project: b091/mkphp-1
 /**
  * Wstawia parametry do rejestru
  */
 public static function setRegistryParams()
 {
     $limit = MK_Validator::positiveIntegerArgument('limit', $_POST) ? (int) $_POST['limit'] : DB_DEFAULT_LIMIT;
     $start = MK_Validator::positiveIntegerArgument('start', $_POST) ? (int) $_POST['start'] : DB_DEFAULT_START;
     $sortDirection = MK_Validator::stringArgument('dir', $_POST) ? pg_escape_string($_POST['dir']) : DB_DEFAULT_SORT_DIRECTION;
     $sortColumn = MK_Validator::stringArgument('sort', $_POST) ? pg_escape_string($_POST['sort']) : DB_DEFAULT_SORT_COLUMN;
     MK_Registry::set('limit', $limit);
     MK_Registry::set('start', $start);
     MK_Registry::set('dir', $sortDirection);
     MK_Registry::set('sort', $sortColumn);
 }
Example #3
0
 /**
  * @throws Exception
  */
 private function proceed()
 {
     if (MK_Registry::get("upgradeSourceFolder")) {
         //pobranie folderów wersji
         $foldersVersion = scandir(MK_Registry::get("upgradeSourceFolder"));
         if (count($foldersVersion) < 3) {
             self::writeToLog("BRAK SQLi i PARSERÓW DO WYKONANIA");
             return;
         }
         foreach ($foldersVersion as $folderVersion) {
             if (in_array($folderVersion, $this->ignoreDir)) {
                 continue;
             }
             self::writeToLog("Bieżąca wersja: " . $folderVersion);
             // zapamiętanie która wersja jest upgradowana,
             // potrzebne to jest do backupów
             MK_Registry::set("currentVersion", str_replace("_", "", $folderVersion));
             //pobranie folderów z datami w wersji
             $foldersInVersion = scandir(MK_Registry::get("upgradeSourceFolder") . DIRECTORY_SEPARATOR . $folderVersion);
             if (empty($foldersInVersion)) {
                 continue;
             }
             foreach ($foldersInVersion as $folderDate) {
                 if (in_array($folderDate, $this->ignoreDir)) {
                     continue;
                 }
                 //pobranie plikow z folderów z datami w wersji
                 $filesInfolderDatePath = MK_Registry::get("upgradeSourceFolder") . DIRECTORY_SEPARATOR . $folderVersion . DIRECTORY_SEPARATOR . $folderDate;
                 $filesInfolderDate = scandir($filesInfolderDatePath);
                 if (empty($filesInfolderDate)) {
                     continue;
                 }
                 foreach ($filesInfolderDate as $file) {
                     $pathToFile = $filesInfolderDatePath . DIRECTORY_SEPARATOR . $file;
                     // zadanie bylo juz wykonane
                     $completedUpgradeTaks = $this->getCompletedUpgradeTaks($folderVersion, $folderDate . DIRECTORY_SEPARATOR . $file);
                     if (!empty($completedUpgradeTaks) || !is_file($pathToFile)) {
                         continue;
                     }
                     $fileName = explode(".", $file);
                     $extension = array_pop($fileName);
                     $fileName = implode(".", $fileName);
                     $setCompletedUpgradeTask = false;
                     self::writeToLog("BEGIN ({$extension}): {$pathToFile}");
                     // rozpoznawanie po typie
                     switch ($extension) {
                         default:
                         case 'sql':
                             $zawartosc = file_get_contents($pathToFile);
                             if (!empty($zawartosc)) {
                                 $affectedRows = $this->Execute($zawartosc);
                             } else {
                                 self::writeToLog("PUSTA ZAWARTOŚĆ PLIKU {$pathToFile}");
                             }
                             // oznaczenie zadania jako wykonane
                             $setCompletedUpgradeTask = true;
                             unset($zawartosc);
                             break;
                         case 'php':
                             // zapamiętanie scieżki zgrywanego pliku,
                             // aby później można było ją wykorzystać w includowanej klasie
                             MK_Registry::set("filesInfolderDatePath", $filesInfolderDatePath);
                             /** @noinspection PhpIncludeInspection */
                             include $pathToFile;
                             // oznaczenie zadania jako wykonane
                             $setCompletedUpgradeTask = true;
                             break;
                     }
                     self::writeToLog("END ({$extension}): {$pathToFile}");
                     if ($setCompletedUpgradeTask) {
                         $this->setCompletedUpgradeTask($folderVersion, $folderDate . DIRECTORY_SEPARATOR . $file);
                     }
                 }
             }
         }
     }
 }