From d0a0d9e70b92e25ebcf9fc7851fb5b44030faa6f Mon Sep 17 00:00:00 2001 From: Jacek Kowalski <Jacek@jacekk.info> Date: Mon, 17 Sep 2012 09:43:06 +0000 Subject: [PATCH] 1. Usunięcie pliku upgrade.php i przeniesienie jego funkcjonalności do pliku BotSession. 2. Uwzględnienie w/w zmiany w plikach INSTALL, UPGRADE, .htaccess 3. Usunięcie z pliku BUILD wzmianki o katalogu ./data/kino --- /dev/null | 23 ----------------------- INSTALL | 1 - BUILD | 1 - UPGRADE | 10 ---------- class/BotSession.php | 20 ++++++++++++++++++++ .htaccess | 3 --- 6 files changed, 20 insertions(+), 38 deletions(-) diff --git a/.htaccess b/.htaccess index d9b52bb..7e6cbd9 100644 --- a/.htaccess +++ b/.htaccess @@ -31,9 +31,6 @@ <Files test.php> Allow from all </Files> -<Files upgrade.php> - Allow from all -</Files> <Files index.html> Allow from all diff --git a/BUILD b/BUILD index 4c0a5a4..0a98595 100644 --- a/BUILD +++ b/BUILD @@ -7,7 +7,6 @@ REMOVEDIR /.git REMOVE /cache/.emptydir REMOVE /data/humor/archiwum/.emptydir -REMOVE /data/kino/cache/.emptydir REMOVE /data/kurs/archiwum/.emptydir REMOVE /data/lotto/archiwum/.emptydir REMOVE /data/pogoda/.emptydir diff --git a/INSTALL b/INSTALL index 6fbd300..9529f18 100644 --- a/INSTALL +++ b/INSTALL @@ -1,5 +1,4 @@ * rozpakuj archiwum z botem do wybranego folderu -* usuń plik upgrade.php * zezwól na zapis (ustaw chmody) w folderach i ich podkatalogach: - ./cache - ./data diff --git a/UPGRADE b/UPGRADE index 3a7622d..f4306dd 100644 --- a/UPGRADE +++ b/UPGRADE @@ -6,11 +6,6 @@ * zastąp plik ./modules/70_kino/handler.php * usuń katalog ./data/kino -* zastąp plik ./.htaccess -* wgraj plik ./upgrade.php -* uruchom plik upgrade.php w przeglądarce -* usuń plik ./upgrade.php - =========================== AKTUALIZACJA Z WERSJI 2.3 =========================== @@ -24,11 +19,6 @@ * zastąp plik ./data/lotto/pobierz.php * usuń katalog ./data/kino * usuń wszystkie pliki z katalogu ./cache - -* zastąp plik ./.htaccess -* wgraj plik ./upgrade.php -* uruchom plik upgrade.php w przeglądarce -* usuń plik ./upgrade.php ====================================== AKTUALIZACJA Z WERSJI 2.2/2.1/2.0 RC diff --git a/class/BotSession.php b/class/BotSession.php index d273779..9099b8a 100644 --- a/class/BotSession.php +++ b/class/BotSession.php @@ -37,6 +37,24 @@ $this->PDO = new PDO('sqlite:'.BOT_TOPDIR.'/database/'.sha1($this->user).'.sqlite'); $this->PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->PDO->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_TO_STRING); + + $st = $this->PDO->query('SELECT value FROM data WHERE class=\'\' AND name=\'_version\''); + if($st->rowCount > 0) { + $row = $st->fetch(PDO::FETCH_ASSOC); + $version = (int)$row['value']; + } + else + { + $version = 0; + } + $st->closeCursor(); + + if($version < 1) { + $this->PDO->query('UPDATE data SET class=\'kino\' WHERE class=\'\' AND name=\'kino\''); + $this->PDO->query('INSERT OR REPLACE INTO data (class, name, value) VALUES (\'\', \'_version\', 1)'); + $version = 1; + } + return; } @@ -65,6 +83,8 @@ $this->PDO->beginTransaction(); $st = $this->PDO->prepare('INSERT OR REPLACE INTO data (class, name, value) VALUES (?, ?, ?)'); + $st->execute(array('', '_version', 1)); + foreach($files as $file) { $data = unserialize(file_get_contents($file)); foreach($data as $name => $value) { diff --git a/upgrade.php b/upgrade.php deleted file mode 100644 index 077bfac..0000000 --- a/upgrade.php +++ /dev/null @@ -1,23 +0,0 @@ -<?php -require_once('./class/std.php'); -$files = glob('database/*.sqlite'); -$count = count($files); - -header('Content-Type: text/plain'); - -foreach($files as $num => $file) { - echo 'Plik '.$num.' z '.$count.' ('.$file.')...'."\n"; - flush(); - - $PDO = new PDO('sqlite:'.BOT_TOPDIR.'/'.$file); - $PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $PDO->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_TO_STRING); - $stmt = $PDO->query('UPDATE data SET class=\'kino\' WHERE class=\'\' AND name=\'kino\''); - $stmt->closeCursor(); - echo "\t".'poprawiono '.$stmt->rowCount().' zmiennych sesyjnych'."\n"; - unset($stmt); - flush(); - - unset($PDO); -} -?> \ No newline at end of file -- Gitblit v1.9.1