diff --git a/.htaccess b/.htaccess
new file mode 100644
index 0000000..1d930b1
--- /dev/null
+++ b/.htaccess
@@ -0,0 +1,21 @@
+# Turn on URL rewriting
+RewriteEngine On
+
+# Installation directory
+RewriteBase /
+
+# Protect hidden files from being viewed
+
+ Order Deny,Allow
+ Deny From All
+
+
+# Protect application and system files from being viewed
+RewriteRule ^(?:application|modules|system)\b - [F,L]
+
+# Allow any files or directories that exist to be displayed directly
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteCond %{REQUEST_FILENAME} !-d
+
+# Rewrite all other URLs to index.php/URL
+RewriteRule .* index.php/$0 [PT]
diff --git a/application/bootstrap.php b/application/bootstrap.php
index d6081cd..cff5b3a 100644
--- a/application/bootstrap.php
+++ b/application/bootstrap.php
@@ -22,7 +22,7 @@ else
* @see http://kohanaframework.org/guide/using.configuration
* @see http://php.net/timezones
*/
-date_default_timezone_set('America/Chicago');
+date_default_timezone_set('Asia/Novosibirsk');
/**
* Set the default locale.
@@ -30,7 +30,7 @@ date_default_timezone_set('America/Chicago');
* @see http://kohanaframework.org/guide/using.configuration
* @see http://php.net/setlocale
*/
-setlocale(LC_ALL, 'en_US.utf-8');
+setlocale(LC_ALL, 'ru_RU.utf-8');
/**
* Enable the Kohana auto-loader.
@@ -53,7 +53,7 @@ ini_set('unserialize_callback_func', 'spl_autoload_call');
/**
* Set the default language
*/
-I18n::lang('en-us');
+I18n::lang('ru');
/**
* Set Kohana::$environment if a 'KOHANA_ENV' environment variable has been supplied.
@@ -80,7 +80,9 @@ if (isset($_SERVER['KOHANA_ENV']))
* - boolean caching enable or disable internal caching FALSE
*/
Kohana::init(array(
- 'base_url' => '/',
+ 'base_url' => '/',
+ 'index_file' => FALSE,
+ 'errors' => TRUE
));
/**
@@ -97,12 +99,12 @@ Kohana::$config->attach(new Config_File);
* Enable modules. Modules are referenced by a relative or absolute path.
*/
Kohana::modules(array(
- // 'auth' => MODPATH.'auth', // Basic authentication
+ 'auth' => MODPATH.'auth', // Basic authentication
// 'cache' => MODPATH.'cache', // Caching with multiple backends
// 'codebench' => MODPATH.'codebench', // Benchmarking tool
- // 'database' => MODPATH.'database', // Database access
+ 'database' => MODPATH.'database', // Database access
// 'image' => MODPATH.'image', // Image manipulation
- // 'orm' => MODPATH.'orm', // Object Relationship Mapping
+ 'orm' => MODPATH.'orm', // Object Relationship Mapping
// 'unittest' => MODPATH.'unittest', // Unit testing
// 'userguide' => MODPATH.'userguide', // User guide and API documentation
));
@@ -113,6 +115,6 @@ Kohana::modules(array(
*/
Route::set('default', '((/(/)))')
->defaults(array(
- 'controller' => 'welcome',
- 'action' => 'index',
+ 'controller' => 'login',
+ 'action' => 'view',
));
diff --git a/application/classes/controller/footer.php b/application/classes/controller/footer.php
new file mode 100644
index 0000000..531c717
--- /dev/null
+++ b/application/classes/controller/footer.php
@@ -0,0 +1,10 @@
+template->years = Kohana::config('common.this_year');
+ if (date('Y') > Kohana::config('common.this_year')) $this->template->years = Kohana::config('common.this_year') . date('-Y');
+ }
+ public function action_view(){$this->request->redirect('');}
+}
\ No newline at end of file
diff --git a/application/classes/controller/header.php b/application/classes/controller/header.php
new file mode 100644
index 0000000..cdc481f
--- /dev/null
+++ b/application/classes/controller/header.php
@@ -0,0 +1,27 @@
+template->title = $this->request->post('title');
+ $styles = $this->request->post('styles');
+ $scripts = $this->request->post('scripts');
+ $temp = "";
+ if (is_array($styles)){
+ foreach($styles as $style=>$media):
+ if ($media != 'screen' and $media != 'print'){
+ $style=$media;
+ $media="screen";
+ }
+ $temp .= ''."\n";
+ endforeach;
+ $this->template->styles = $temp;
+ }
+ else $this->template->styles = '\n";
+ if (is_array($scripts)) foreach($scripts as $script):
+ $temp .= ''."\n";
+ endforeach;
+ $this->template->scripts = $temp;
+ }
+ public function action_view(){$this->request->redirect('');}
+}
\ No newline at end of file
diff --git a/application/classes/controller/login.php b/application/classes/controller/login.php
new file mode 100644
index 0000000..6a49bce
--- /dev/null
+++ b/application/classes/controller/login.php
@@ -0,0 +1,20 @@
+logged_in()){
+ if (Auth::instance()->logged_in(array('admin')) === FALSE) return $this->request->redirect('events/view');
+ return $this->request->redirect('overview/view');
+ }
+ if ($_POST){
+ $user = ORM::factory('user');
+ $status = Auth::instance()->login($_POST['login'], $_POST['password']);
+ if ($status){
+ if (Auth::instance()->logged_in(array('admin')) === FALSE) return $this->request->redirect('events/view');
+ return $this->request->redirect('overview/view');
+ }
+ else $this->template->error = "Неверный логин или пароль.";
+ }
+ }
+}
diff --git a/application/classes/controller/logout.php b/application/classes/controller/logout.php
new file mode 100644
index 0000000..6f26669
--- /dev/null
+++ b/application/classes/controller/logout.php
@@ -0,0 +1,8 @@
+logout()) return $this->request->redirect('login');
+ else $this->template->error = "Ошибка выхода пользователя.";
+ }
+}
diff --git a/application/classes/controller/navigation.php b/application/classes/controller/navigation.php
new file mode 100644
index 0000000..ad7cb2b
--- /dev/null
+++ b/application/classes/controller/navigation.php
@@ -0,0 +1,19 @@
+template = new View('navigation/actions');
+ $this->template->login_or_logout = HTML::anchor('login', 'Вход');
+ if (Auth::instance()->logged_in()){
+ $this->template->login_or_logout = HTML::anchor('logout', 'Выход');
+ }
+ if (Auth::instance()->logged_in('admin')){
+ $this->template->admin_actions = View::factory('navigation/admin')->render();
+ }
+ if (Auth::instance()->logged_in('user') or Auth::instance()->logged_in('superuser') or Auth::instance()->logged_in('admin')){
+ $user_actions = View::factory('navigation/user')->render();
+ }
+ }
+ public function action_view(){$this->request->redirect('');}
+}
diff --git a/application/config/auth.php b/application/config/auth.php
new file mode 100644
index 0000000..0be13f5
--- /dev/null
+++ b/application/config/auth.php
@@ -0,0 +1,16 @@
+ 'ORM',
+ 'hash_method' => 'sha256',
+ 'hash_key' => "3wj88uew hello uwri88 dshnber riweuri",
+ 'lifetime' => 1209600,
+ 'session_key' => 'auth_user',
+
+ // Username/password combinations for the Auth File driver
+ 'users' => array(
+ // 'admin' => 'b3154acf3a344170077d11bdb5fff31532f679a1919e716a02',
+ ),
+
+);
diff --git a/application/config/common.php b/application/config/common.php
new file mode 100644
index 0000000..ee6f688
--- /dev/null
+++ b/application/config/common.php
@@ -0,0 +1,6 @@
+ "2011",
+ 'title' => "Конкурс быстрого программирования «Поихаил!»"
+);
\ No newline at end of file
diff --git a/application/config/database.php b/application/config/database.php
new file mode 100644
index 0000000..4882766
--- /dev/null
+++ b/application/config/database.php
@@ -0,0 +1,31 @@
+ array
+ (
+ 'type' => 'mysql',
+ 'connection' => array(
+ /**
+ * The following options are available for MySQL:
+ *
+ * string hostname server hostname, or socket
+ * string database database name
+ * string username database username
+ * string password database password
+ * boolean persistent use persistent connections?
+ *
+ * Ports and sockets may be appended to the hostname.
+ */
+ 'hostname' => 'localhost',
+ 'database' => 'nemove',
+ 'username' => 'dandelion',
+ 'password' => '',
+ 'persistent' => FALSE,
+ ),
+ 'table_prefix' => '',
+ 'charset' => 'utf8',
+ 'caching' => FALSE,
+ 'profiling' => TRUE,
+ ),
+);
diff --git a/application/views/error.php b/application/views/error.php
new file mode 100644
index 0000000..ff6d66c
--- /dev/null
+++ b/application/views/error.php
@@ -0,0 +1,4 @@
+post('title',$title)->post('styles','main.css')->execute() ?>
+
+
+ execute() ?>
diff --git a/application/views/footer.php b/application/views/footer.php
new file mode 100644
index 0000000..c2ced7d
--- /dev/null
+++ b/application/views/footer.php
@@ -0,0 +1,5 @@
+
+
+
+