summaryrefslogtreecommitdiff
path: root/core/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'core/helpers')
-rw-r--r--core/helpers/MY_url.php7
-rw-r--r--core/helpers/core_installer.php28
-rw-r--r--core/helpers/log.php44
3 files changed, 69 insertions, 10 deletions
diff --git a/core/helpers/MY_url.php b/core/helpers/MY_url.php
index 1c40c2bc..12c51f8d 100644
--- a/core/helpers/MY_url.php
+++ b/core/helpers/MY_url.php
@@ -33,7 +33,10 @@ class url extends url_Core {
return url::site($path, "http");
}
- public static function abs_current() {
- return self::abs_site(url::current());
+ /**
+ * Just like url::current except that it returns an absolute URI
+ */
+ public static function abs_current($qs=false) {
+ return self::abs_site(url::current($qs));
}
}
diff --git a/core/helpers/core_installer.php b/core/helpers/core_installer.php
index 399b6bf5..53b5bfe6 100644
--- a/core/helpers/core_installer.php
+++ b/core/helpers/core_installer.php
@@ -45,13 +45,13 @@ class core_installer {
$db->query("CREATE TABLE `items` (
`created` int(9) default NULL,
- `description` char(255) default NULL,
+ `description` varchar(255) default NULL,
`height` int(9) default NULL,
`id` int(9) NOT NULL auto_increment,
`left` int(9) NOT NULL,
`level` int(9) NOT NULL,
- `mime_type` char(64) default NULL,
- `name` char(255) default NULL,
+ `mime_type` varchar(64) default NULL,
+ `name` varchar(255) default NULL,
`owner_id` int(9) default NULL,
`parent_id` int(9) NOT NULL,
`resize_height` int(9) default NULL,
@@ -59,8 +59,8 @@ class core_installer {
`right` int(9) NOT NULL,
`thumb_height` int(9) default NULL,
`thumb_width` int(9) default NULL,
- `title` char(255) default NULL,
- `type` char(32) NOT NULL,
+ `title` varchar(255) default NULL,
+ `type` varchar(32) NOT NULL,
`updated` int(9) default NULL,
`view_count` int(9) default 0,
`width` int(9) default NULL,
@@ -69,9 +69,21 @@ class core_installer {
KEY `type` (`type`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ $db->query("CREATE TABLE `logs` (
+ `id` int(9) NOT NULL auto_increment,
+ `category` varchar(64) default NULL,
+ `html` varchar(255) default NULL,
+ `message` text default NULL,
+ `referer` varchar(255) default NULL,
+ `severity` int(9) default 0,
+ `timestamp` int(9) default 0,
+ `url` varchar(255) default NULL,
+ PRIMARY KEY (`id`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+
$db->query("CREATE TABLE `modules` (
`id` int(9) NOT NULL auto_increment,
- `name` char(255) default NULL,
+ `name` varchar(255) default NULL,
`version` int(9) default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY(`name`))
@@ -79,7 +91,7 @@ class core_installer {
$db->query("CREATE TABLE `permissions` (
`id` int(9) NOT NULL auto_increment,
- `name` char(255) default NULL,
+ `name` varchar(255) default NULL,
`version` int(9) default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY(`name`))
@@ -95,7 +107,7 @@ class core_installer {
$db->query("CREATE TABLE `vars` (
`id` int(9) NOT NULL auto_increment,
`module_id` int(9),
- `name` char(255) NOT NULL,
+ `name` varchar(255) NOT NULL,
`value` text,
PRIMARY KEY (`id`),
UNIQUE KEY(`module_id`, `name`))
diff --git a/core/helpers/log.php b/core/helpers/log.php
new file mode 100644
index 00000000..fece9de3
--- /dev/null
+++ b/core/helpers/log.php
@@ -0,0 +1,44 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2008 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class log_Core {
+ const INFO = 1;
+ const WARNING = 2;
+ const ERROR = 3;
+
+ /**
+ * Add a log entry.
+ *
+ * @param string $category an arbitrary category we can use to filter log messages
+ * @param string $message a detailed log message
+ * @param integer $severity INFO, WARNING or ERROR
+ * @param string $html an html snippet presented alongside the log message to aid the admin
+ */
+ function add($category, $message, $severity=INFO, $html) {
+ $log = ORM::factory("log");
+ $log->category = $category;
+ $log->message = $message;
+ $log->severity = $severity;
+ $log->html = $html;
+ $log->url = url::abs_current(true);
+ $log->referer = request::referrer(null);
+ $log->timestamp = time();
+ $log->save();
+ }
+}