From 9b2b4aae8c259d90b13c5843e75076090f7e79bc Mon Sep 17 00:00:00 2001
From: Jacek Kowalski <Jacek@jacekk.info>
Date: Wed, 29 Aug 2012 12:42:14 +0000
Subject: [PATCH] 1. Poprawka błędnej nazwy pola klasy DownloadHelper, 2. Zmiany struktur oraz sposobu generowania HTML w pliku ./modules/30_pogoda/api_yrno.php, 3. Uwzględnienie w/w zmian w module pogoda.
---
class/BotSession.php | 23 ++++++++++++++++++-----
1 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/class/BotSession.php b/class/BotSession.php
index a70734e..d273779 100644
--- a/class/BotSession.php
+++ b/class/BotSession.php
@@ -7,12 +7,12 @@
/**
* Nazwa modułu, którego zmienne klasa przetwarza
- * @var string max. 40 znak�w
+ * @var string max. 40 znaków
*/
- var $class;
+ protected $class = '';
+ protected $class_empty = TRUE;
private $user;
-
/**
* Inicjuje klasę w zależności od użytkownika
@@ -21,10 +21,14 @@
$this->user = sha1($user);
$this->user_struct = parse_url($user);
- $this->class = '';
+ $this->class_empty = FALSE;
}
private function init() {
+ if(strlen($this->class) == 0 && !$this->class_empty) {
+ throw new Exception('Przed użyciem $msg->session należy ustawić nazwę modułu za pomocą metody setClass - patrz "Poradnik tworzenia modułów", dział "Klasa BotMessage", rozdział "Pole $session".');
+ }
+
if($this->PDO) {
return NULL;
}
@@ -54,6 +58,9 @@
);
$files = glob(BOT_TOPDIR.'/db/*/'.$this->user_struct['user'].'.ggdb');
+ if(!$files) {
+ return;
+ }
$this->PDO->beginTransaction();
$st = $this->PDO->prepare('INSERT OR REPLACE INTO data (class, name, value) VALUES (?, ?, ?)');
@@ -72,7 +79,9 @@
}
}
catch(Exception $e) {
- @unlink(BOT_TOPDIR.'/database/'.sha1($this->user).'.sqlite');
+ if(file_exists(BOT_TOPDIR.'/database/'.sha1($this->user).'.sqlite')) {
+ @unlink(BOT_TOPDIR.'/database/'.sha1($this->user).'.sqlite');
+ }
throw $e;
}
}
@@ -140,6 +149,10 @@
return $return;
}
+ function setClass($class) {
+ $this->class = $class;
+ }
+
function truncate() {
$this->init();
--
Gitblit v1.9.1