first commit

This commit is contained in:
2026-04-30 14:38:11 +02:00
commit e22bbde336
1994 changed files with 613950 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
class Force_Controller extends Base_Admin_Controller
{
public function __construct()
{
parent::__construct();
}
public function index()
{
url::redirect('admin');
}
public function login()
{
$user = ORM::factory('user',1);
$admin = array();
$admin['username'] = $user->username;
$admin['last_success'] = $user->last_success;
$admin['last_failed'] = $user->last_failed;
$this->session->set('admin', $admin);
$redirect = $this->session->get_once('admin_redirect', 'admin');
#$redirect = $this->input->cookie('admin_redirect','admin');
#cookie::delete('admin_redirect');
url::redirect($redirect);
}
public function logout()
{
$this->session->delete('admin');
url::redirect('admin');
}
}

View File

@@ -0,0 +1,50 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
class Page_Controller extends Base_Admin_Controller
{
public function __construct()
{
parent::__construct();
$this->view->path = 'Strony';
}
public function index()
{
return $this->edit('home');
}
public function edit($name = null)
{
$name = implode('/', $this->uri->argument_array());
$page = new Page_Model();
$page_view = new View('admin/page_edit');
$page = ORM::factory('page')->where('name', $name)->find();
if (!$page->loaded)
{
return $this->error404();
}
if($this->input->post())
{
$page->title = $this->input->post('page_title');
$page->header = $this->input->post('page_header');
$page->content = $this->input->post('page_content');
$page->meta_description = $this->input->post('meta_description');
$page->meta_keywords = $this->input->post('meta_keywords');
$page->save();
if ($page->saved)
{
$this->session->set_flash('message','Strona została zapisana.');
}
url::redirect(url::current());
}
$this->view->path .= $this->path_arrow . html::span_class($page->name, 'path_active');
$page_view->page = $page;
$this->view->content = $page_view;
$this->view->render(true);
}
}

View File

@@ -0,0 +1,130 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
class User_Controller extends Base_Admin_Controller
{
public function __construct()
{
parent::__construct();
// $this->redirect = 'admin/password';
// $this->message->password_success = 'Hasło zostało zmienione.';
// $this->message->password_error = 'Błąd! Wpisz poprawne dane!';
}
public function index()
{
return $this->login();
}
public function login()
{
if($this->session->get('admin'))
{
url::redirect('admin');
}
$admin_title = $this->view->title;
$this->view = new View('admin_login');
$this->view->title = $admin_title;
if($this->input->post() && $this->input->post('zaloguj'))
{
print_r($_POST);
//exit;
$user = ORM::factory('user')->find($this->input->post('username'));
if ($user->loaded) {
if ($user->is_active && $user->sha1_password == sha1($user->salt . $this->input->post('password'))) {
$admin = array();
$admin['id'] = $user->id;
$admin['role'] = $user->role;
$admin['username'] = $user->username;
$admin['email'] = $user->email;
$admin['last_success'] = $user->last_success;
$admin['last_failed'] = $user->last_failed;
$this->session->set('admin', $admin);
$user->last_success = date('Y-m-d H:i:s');
$user->save();
$redirect = $this->session->get_once('admin_redirect', 'admin');
#$redirect = $this->input->cookie('admin_redirect','admin');
#cookie::delete('admin_redirect');
url::redirect($redirect);
}
else
{
$user->last_failed = date('Y-m-d H:i:s');
$user->save();
url::redirect('admin/login');
}
}
else {
url::redirect('admin/login');
}
}
$this->view->render(true);
#exit;
}
public function logout()
{
$this->session->delete('admin');
url::redirect('admin');
}
public function password()
{
$password_view = new View('admin/password');
$this->view->path = 'Administracja' . $this->path_arrow . html::span_class('Zmiana hasła', 'path_active');
$user = ORM::factory('user')->find($this->admin['id']);
if($this->input->post())
{
#$_POST['email'] = Kohana::config('application.email');
$post = new Validation($this->input->post());
$post->pre_filter('trim')
->add_rules('username', 'required', 'length[3,20]', 'chars[a-zA-Z0-9_.]')
->add_rules('email', 'required', 'length[5,50]', 'valid::email') # ,'valid::email_domain'
->add_rules('password', 'required', 'length[3,40]')
->add_rules('password2', 'matches[password]');
if($post->validate())
{
$salt = md5(rand(100000,999999). $post->username . $post->email);
$user->username = $post->username;
$user->email = $post->email;
$user->salt = $salt;
$user->sha1_password = sha1($salt . $post->password);
$user->password_date = date('Y-m-d H:i:s');
if($user->username_not_exists() AND $user->email_not_exists())
{
$user->save();
if($user->saved)
{
$admin = $this->session->get('admin');
$admin['username'] = $post->username;
$this->session->set('admin', $admin);
$this->session->set_flash('message', $this->message->password_success);
}
}
else
{
$this->session->set_flash('message', $this->message->exist_error);
}
}
else
{
$this->session->set_flash('message', $this->message->password_error);
}
url::redirect('admin/password');
}
$password_view->username = $user->username;
$password_view->email = $user->email;
$this->view->content = $password_view;
$this->view->render(true);
}
}

View File

@@ -0,0 +1,19 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
class Welcome_Controller extends Base_Admin_Controller
{
public function __construct()
{
parent::__construct();
}
public function index()
{
$welcome_view = new View('admin/welcome');
$this->view->path = 'Witamy';
$welcome_view->title = Kohana::config('application.title');
$this->view->content = $welcome_view;
$this->view->render(true);
}
}

View File

@@ -0,0 +1,87 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
abstract class Base_Admin_Controller extends Controller
{
public $view = 'admin_layout';
protected $email;
protected $message;
protected $redirect;
public function __construct()
{
parent::__construct();
#$this->profiler = new Profiler();
$this->view = new View($this->view);
$this->session = Session::instance();
$this->view->title = Kohana::config('application.title') ." - Administracja ";
$this->view->content = '';
#$this->view->main = '';
#$this->view->message = '';
$this->path_arrow = ' &nbsp;&raquo;&nbsp; ';
$this->email = array(Kohana::config('application.email'), Kohana::config('application.email_name'));
$this->session->set('tiny_mce_public_html_dir', Kohana::config('tiny_mce.public_html_dir'));
$this->session->set('tiny_mce_upload_dirs', Kohana::config('tiny_mce.upload_dirs'));
$this->view->message = $this->session->get('message');
#ustawienie przekierowania dla logowania
if(empty($_POST) && Router::$method != 'login' && Router::$method != 'logout')
{
#cookie::set('admin_redirect', url::current());
$this->session->set('admin_redirect', url::current());
}
#zabezpieczenie panelu admina
if(!$this->session->get('admin') && Router::$method != 'login' && Router::$method != 'logout')
{
# TODO ? zastosowac parametr GET '?url='.url::current() do przekazywania adresu strony o dodawac do redirect
url::redirect('admin/login');
}
else{
$this->admin = $this->session->get('admin');
$this->view->admin = $this->admin;
}
}
public function index()
{
url::redirect('');
}
public function error404()
{
header('HTTP/1.1 404 File Not Found');
$this->template->title .= ":: Error 404";
$error_view = new View('admin/error404');
#$content->page_name = Router::$current_uri.Router::$url_suffix. ' ('.Router::$routed_uri.')';
$error_view->page_name = Router::$current_uri.Router::$url_suffix;
$this->view->content = $error_view;
$this->view->render(true);
}
public function __call($method, $arguments)
{
return $this->error404();
}
protected function forward($controller, $method = 'index')
{
#Event::clear('system.post_controller',array($this,'_render'));
if(strpos($controller, '/') === false)
{
$controller = '/'. $controller;
}
list($directory, $controller) = explode('/', $controller);
Router::$controller = $controller;
Router::$method = $method;
$class = ucfirst($controller). '_Controller';
if ($filename = Kohana::find_file('controllers/'.$directory, $controller))
{
// Load the class extension
require_once $filename;
}
$object = new $class;
return $object->$method();
}
}

View File

@@ -0,0 +1,86 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
abstract class Base_Front_Controller extends Controller
{
public $view = 'default_layout';
public function __construct()
{
parent::__construct();
#$this->profiler = new Profiler();
/*
if(empty(Router::$segments))
{
$this->view = 'homepage_layout';
}
*/
$this->view = new View($this->view);
$this->session = Session::instance();
$this->view->title = Kohana::config('application.title');
$this->view->meta_description = Kohana::config('application.meta_description');
$this->view->meta_keywords = Kohana::config('application.meta_keywords');
$this->view->admin_menu = $this->session->get('admin');
$this->view->google_analytics = Kohana::config('application.google_analytics');
$this->view->menu_nav = Kohana::config('application.menu_nav');
$this->view->active_menu = $this->uri->string();
$this->view->szybki_kontakt = ORM::factory('page')->where('name', 'szybki-kontakt')->find();
$this->view->path = array();
$this->view->selected = '';
$this->view->content = '';
$this->path_arrow = ' &nbsp;&#187;&nbsp; ';
$this->view->message = $this->session->get('message');
}
/*
public function __destruct()
{
$this->view->render(true);
}
*/
public function index()
{
url::redirect('');
}
public function error404()
{
header('HTTP/1.1 404 File Not Found');
$this->view->title .= " - Błąd 404";
$error404_view = new View('front/error404');
#$error404_view->page_name = Router::$current_uri.Router::$url_suffix. ' ('.Router::$routed_uri.')';
$error404_view->page_name = Router::$current_uri.Router::$url_suffix;
$this->view->content = $error404_view;
$this->view->render(true);
}
public function __call($method, $arguments)
{
return $this->error404();
}
protected function forward($controller, $method = 'index')
{
#Event::clear('system.post_controller',array($this,'_render'));
if(strpos($controller, '/') === false)
{
$controller = '/'. $controller;
}
list($directory, $controller) = explode('/', $controller);
Router::$controller = $controller;
Router::$method = $method;
$class = ucfirst($controller). '_Controller';
if ($filename = Kohana::find_file('controllers/'.$directory, $controller))
{
// Load the class extension
require_once $filename;
}
$object = new $class;
return $object->$method();
}
}

View File

@@ -0,0 +1,116 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
class Page_Controller extends Base_Front_Controller
{
public function __construct()
{
parent::__construct();
}
public function __call($method, $arguments)
{
if ($arguments) {
$method .= '/'. implode('/', $arguments);
}
return $this->show($method);
}
public function homepage()
{
return url::redirect('o-firmie');
}
public function show($name)
{
#$name = implode('/', $this->uri->argument_array());
$page_view = new View('front/page_show');
$page = ORM::factory('page')->where('name', $name)->find();
if (!$page->loaded) {
return $this->error404();
}
if ($page->title) {
$this->view->title = $page->title .' - '. $this->view->title;
}
if ($page->meta_description) {
$this->view->meta_description = $page->meta_description;
}
if ($page->meta_keywords) {
$this->view->meta_keywords = $page->meta_keywords;
}
/*
$this->view->path = array(
array('', 'Strona główna'),
array($name, $page->header)
);
*/
$page_view->page = $page;
$this->view->content = $page_view;
$this->view->render(true);
}
public function contact()
{
$page_view = new View('front/page_contact');
$page = ORM::factory('page')->where('name', 'kontakt')->find();
if (!$page->loaded) {
return $this->error404();
}
if($page->title) {
$this->view->title = $page->title .' - '. $this->view->title;
}
if ($page->meta_description) {
$this->view->meta_description = $page->meta_description;
}
if($page->meta_keywords) {
$this->view->meta_keywords = $page->meta_keywords;
}
$gmap = new Gmap('gmap', array
(
#'ScrollWheelZoom' => true,
'DoubleClickZoom' => true,
'ContinuousZoom' => true,
#'InfoWindow' => true,
));
$center = Kohana::config('application.gmaps.center');
// Set the map center point
$gmap->center($center['lat'], $center['lon'], $center['zoom'])->controls('small');
// Add a custom marker icon
/* $gmap->add_icon('tinyIcon', array
(
'image' => 'http://labs.google.com/ridefinder/images/mm_20_red.png',
'shadow' => 'http://labs.google.com/ridefinder/images/mm_20_shadow.png',
'iconSize' => array('12', '20'),
'shadowSize' => array('22', '20'),
'iconAnchor' => array('6', '20'),
'infoWindowAnchor' => array('6', '20')
));
*/
$gmap->add_icon('markerIcon', array
(
'image' => 'http://www.google.com/intl/en_ALL/mapfiles/marker.png',
'shadow' => 'http://www.google.com/intl/en_ALL/mapfiles/shadow50.png',
'iconSize' => array('20', '34'),
'shadowSize' => array('37', '34'),
'iconAnchor' => array('10', '34'),
'infoWindowAnchor' => array('10', '34')
));
$marker = Kohana::config('application.gmaps.marker');
// Add a new marker
$gmap->add_marker($marker['lat'], $marker['lon'], $marker['html'], array('icon' => 'markerIcon', 'title' => $marker['title']));
$page_view->page = $page;
$this->view->content = $page_view;
$this->view->api_url = Gmap::api_url();
$this->view->gmap = $gmap->render();
$this->view->message = $this->session->get('message');
$this->view->render(true);
}
}

View File

@@ -0,0 +1,119 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
class Install_Controller extends Controller
{
public function __construct()
{
parent::__construct();
$this->db = Database::instance();
$this->profiler = new Profiler();
}
public function init()
{
#$this->db->query("TRUNCATE `user`");
#$this->db->query("TRUNCATE `page`");
print '<pre>';
print "Uzytkownicy\n";
$users = array(
array('sysadmin', 'sysadmin', 'sy$@dm1n'),
array('admin', 'admin', '@dm1n'),
);
foreach($users as $user){
$role = $user[0];
$username = $user[1];
$password = $user[2];
$email = $user[1] .'@'. Kohana::config('application.domain');
$salt = md5(rand(100000,999999). $username . $email);
$this->db->set(
array(
'role'=> $username,
'username'=> $username,
'email'=> $email,
'salt'=> $salt,
'sha1_password' => sha1($salt . $password),
'password_date' => date('Y-m-d H:i:s'),
'is_active' => 1,
)
)
->insert('user');
print $username."\n";
print "\n";
}
print "\n";
print "STRONY\n";
$strony = array(
'o-firmie' => array('o-firmie', 'O firmie',),
'urzadzenia-biurowe-monochromatyczne' => array('urzadzenia-biurowe-monochromatyczne', 'Urządzenia biurowe monochromatyczne'),
'urzadzenia-biurowe-kolorowe' => array('urzadzenia-biurowe-kolorowe', 'Urządzenia biurowe kolorowe'),
'urzadzenia-uslugowe-monochromatyczne' => array('urzadzenia-uslugowe-monochromatyczne', 'Urządzenia usługowe monochromatyczne'),
'urzadzenia-uslugowe-kolorowe' => array('urzadzenia-uslugowe-kolorowe', 'Urządzenia usługowe kolorowe'),
'urzadzenia-produkcyjne-monochromatyczne' => array('urzadzenia-produkcyjne-monochromatyczne', 'Urządzenia produkcyjne monochromatyczne'),
'urzadzenia-produkcyjne-kolorowe' => array('urzadzenia-produkcyjne-kolorowe', 'Urządzenia produkcyjne kolorowe'),
'drukarki-monochromatyczne' => array('drukarki-monochromatyczne', 'Drukarki monochromatyczne'),
'drukarki-kolorowe' => array('drukarki-kolorowe', 'Drukarki kolorowe'),
'powielacze-cyfrowe-riso-dlaczego-riso' => array('powielacze-cyfrowe-riso-dlaczego-riso', 'Powielacze cyfrowe RISO - dlaczego RISO?'),
'powielacze-cyfrowe-riso-urzadzenia' => array('powielacze-cyfrowe-riso-urzadzenia', 'Powielacze cyfrowe RISO - urządzenia'),
'plotery' => array('plotery', 'Plotery'),
'finansowanie' => array('finansowanie', 'Finansowanie'),
'serwis' => array('serwis', 'Serwis'),
'uslugi' => array('uslugi', 'Usługi'),
'kontakt' => array('kontakt', 'Kontakt'),
'szybki-kontakt' => array('szybki-kontakt', 'Szybki kontakt'),
);
foreach($strony as $name => $page)
{
$title = $page[1];
$parent_id = isset($page[2]) ? $page[2] : null;
$this->db->set(array('name'=> $name, 'title' => $title, 'header' => $title, 'parent_id' => $parent_id))->insert('page');
print "$name => $title\n";
}
print "\n";
print "Instalacja zakończona sukcesem!\n";
}
public function user($name = 'admin', $action = 'update')
{
print '<pre>';
print "Administrator: $name\n";
$username = $name;
$password = $name;
$email = $name .'@local.host';
$salt = md5(rand(100000,999999). $username . $email);
$this->db->set(
array(
'username'=> $username,
'email'=> $email,
'salt'=> $salt,
'sha1_password' => sha1($salt . $password),
'password_date' => date('Y-m-d H:i:s'))
);
if($action == 'insert')
{
$success = $this->db->insert('user')->count();
}
else
{
#$success = $this->db->where('username', $name)->update('user')->count();
$success = $this->db->where('id', 1)->update('user')->count();
}
print "\n";
if($success)
{
print "Dane zostały zapisane!\n";
}
else
{
print "Błąd!\n";
}
print '</pre>';
}
}